C-Breeze
C Compiler Infrastructure

[ Project home page]
Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

loopTree Class Reference

#include <loops.h>

List of all members.

Public Types

enum  EdgeKind { TreeEdge, BackEdge, ForwardEdge, CrossEdge }

Public Member Functions

 loopTree (procNode *procedure)
 Create a loop tree.

 ~loopTree ()
 Delete a loop tree.

procNodeprocedure () const
 Procedure.

loopTreeNodetopLoop () const
 Top loop object.

edge_mapbackedges ()
 Accessors.

edge_maptreeedges ()
loopTreeNodewhichLoop (basicblockNode *block)
 Which loop.

loopTreeNodeloopAncestor (loopTreeNode *loop)
 Find a loop ancestor.

EdgeKind classifyEdge (basicblockNode *source, basicblockNode *target)
 Edge classification.

void report ()
 Report.


Private Member Functions

void findLoop (basicblockNode *candidate, basicblock_set_map &generators_map)
 Decide if a block is a loop header.

void findBody (basicblockNode *head, basicblock_set &generators, loopTreeNode::LoopKind kind)
 Determine the body of a loop.

basicblockNodecommonDominator (basicblockNode *first, basicblockNode *second)
 Find a common dominator for two blocks.

void classifyEdges (basicblock_list &post_order)
 Classify edges.

void depthFirstSearch (basicblockNode *cur, basicblock_list &post_order, int &pre_order_number, int &post_order_number)
 Depth-first search.

void setDepths (loopTreeNode *cur, int depth)
 Set the depth on each loop nest.

void report (loopTreeNode *cur, int level)
 Report (tree recursion).


Private Attributes

procNode_procedure
 The procedure.

loopTreeNode_top
 The loop tree.

loop_list _loops
 A list of the loops.

blockloop_map _containedIn
 Mapping from basic blocks to loops.

edge_map _backEdges
 List of back edges.

edge_map _forwardEdges
 List of forward edges.

edge_map _treeEdges
 List of tree edges.

edge_map _crossEdges
 List of cross edges.

basicblock_int_map _preOrder
 Depth-first pre-order of the nodes.

basicblock_int_map _rpostOrder
 Depth-first reverse-post-order of the nodes.


Member Enumeration Documentation

enum loopTree::EdgeKind
 

Enumeration values:
TreeEdge 
BackEdge 
ForwardEdge 
CrossEdge 

Definition at line 148 of file loops.h.

Referenced by classifyEdge(), and depthFirstSearch().


Constructor & Destructor Documentation

loopTree::loopTree procNode   procedure
 

Create a loop tree.

This constructor is responsible for creating the loop tree. Dominators(procedure, boolean) must be run before this phase will work. Since there is no way to run this from the command line, you MUST run the dominators pass yourself.

Definition at line 106 of file loops.cc.

References basicblock_list, basicblock_list_p, basicblock_set, basicblock_set_map, classifyEdges(), procNode::entry(), procNode::exit(), findBody(), findLoop(), procedure(), setDepths(), and loopTreeNode::Top.

loopTree::~loopTree  
 

Delete a loop tree.

This destructor is reponsible for deleting all of the loop tree nodes as well.

Definition at line 157 of file loops.cc.

References _loops, and loop_list_p.


Member Function Documentation

edge_map& loopTree::backedges   [inline]
 

Accessors.

Definition at line 235 of file loops.h.

References edge_map.

loopTree::EdgeKind loopTree::classifyEdge basicblockNode   source,
basicblockNode   target
 

Edge classification.

Given a particular source and target in the control-flow graph, indicate which kind of edge it is: tree, forward, backward, or cross.

Definition at line 548 of file loops.cc.

References _backEdges, _crossEdges, _forwardEdges, BackEdge, basicblock_set, CrossEdge, edge_map_p, EdgeKind, ForwardEdge, and TreeEdge.

Referenced by procedureInfo::reverse_post_order().

void loopTree::classifyEdges basicblock_list   post_order [private]
 

Classify edges.

Perform a depth-first search of the control-flow graph, building pre-order and reverse-post-order orderings of the nodes, as well as classifying th edges. Also, return a list with the post-order traversal.

Definition at line 409 of file loops.cc.

References _backEdges, _crossEdges, _forwardEdges, _preOrder, _procedure, _rpostOrder, procNode::body(), depthFirstSearch(), procNode::entry(), stmt_list, stmt_list_p, and blockNode::stmts().

Referenced by loopTree().

basicblockNode * loopTree::commonDominator basicblockNode   first,
basicblockNode   second
[private]
 

Find a common dominator for two blocks.

Definition at line 380 of file loops.cc.

References Dominators::dominates(), and basicblockNode::parent().

Referenced by findLoop().

void loopTree::depthFirstSearch basicblockNode   cur,
basicblock_list   post_order,
int &    pre_order_number,
int &    post_order_number
[private]
 

Depth-first search.

Definition at line 443 of file loops.cc.

References _backEdges, _crossEdges, _forwardEdges, _preOrder, _rpostOrder, _treeEdges, BackEdge, basicblock_list_p, stmtNode::comment(), CrossEdge, EdgeKind, ForwardEdge, basicblockNode::succs(), and TreeEdge.

Referenced by classifyEdges().

void loopTree::findBody basicblockNode   head,
basicblock_set   generators,
loopTreeNode::LoopKind    kind
[private]
 

Determine the body of a loop.

Definition at line 243 of file loops.cc.

References _containedIn, _loops, _preOrder, _top, basicblock_list, basicblock_list_p, basicblock_set, basicblock_set_p, stmtNode::comment(), loopAncestor(), loopTreeNode::MultipleEntry, loopTreeNode::parentLoop(), basicblockNode::preds(), loopTreeNode::SingleEntry, loopTreeNode::Top, and whichLoop().

Referenced by findLoop(), and loopTree().

void loopTree::findLoop basicblockNode   candidate,
basicblock_set_map   generators_map
[private]
 

Decide if a block is a loop header.

Definition at line 176 of file loops.cc.

References _backEdges, basicblock_set, basicblock_set_p, commonDominator(), edge_map_p, and findBody().

Referenced by loopTree().

loopTreeNode * loopTree::loopAncestor loopTreeNode   loop
 

Find a loop ancestor.

Definition at line 399 of file loops.cc.

References loopTreeNode::parentLoop().

Referenced by findBody().

procNode* loopTree::procedure   const [inline]
 

Procedure.

Definition at line 223 of file loops.h.

Referenced by loopTree().

void loopTree::report loopTreeNode   cur,
int    level
[private]
 

Report (tree recursion).

Definition at line 594 of file loops.cc.

References loop_set_p, loopTreeNode::nestedLoops(), report(), and loopTreeNode::report().

void loopTree::report  
 

Report.

Definition at line 586 of file loops.cc.

Referenced by report().

void loopTree::setDepths loopTreeNode   cur,
int    depth
[private]
 

Set the depth on each loop nest.

Definition at line 534 of file loops.cc.

References loopTreeNode::depth(), loop_set_p, and loopTreeNode::nestedLoops().

Referenced by loopTree().

loopTreeNode* loopTree::topLoop   const [inline]
 

Top loop object.

Note that this is not really a loop; it's just used as the root of the tree

Definition at line 230 of file loops.h.

edge_map& loopTree::treeedges   [inline]
 

Definition at line 236 of file loops.h.

References edge_map.

loopTreeNode * loopTree::whichLoop basicblockNode   block
 

Which loop.

Determine which loop a particular basic block belongs to.

Definition at line 167 of file loops.cc.

References _containedIn, and blockloop_map_p.

Referenced by findBody().


Member Data Documentation

edge_map loopTree::_backEdges [private]
 

List of back edges.

Back edges are stored according to the *target* of the back-edge, not the source. This is because the algorithm needs to easily find all the back-edges that impinge on a candidate node.

Definition at line 174 of file loops.h.

Referenced by classifyEdge(), classifyEdges(), depthFirstSearch(), and findLoop().

blockloop_map loopTree::_containedIn [private]
 

Mapping from basic blocks to loops.

Definition at line 166 of file loops.h.

Referenced by findBody(), and whichLoop().

edge_map loopTree::_crossEdges [private]
 

List of cross edges.

Stored according to the source of the edge

Definition at line 192 of file loops.h.

Referenced by classifyEdge(), classifyEdges(), and depthFirstSearch().

edge_map loopTree::_forwardEdges [private]
 

List of forward edges.

Stored according to the source of the edge

Definition at line 180 of file loops.h.

Referenced by classifyEdge(), classifyEdges(), and depthFirstSearch().

loop_list loopTree::_loops [private]
 

A list of the loops.

Definition at line 162 of file loops.h.

Referenced by findBody(), and ~loopTree().

basicblock_int_map loopTree::_preOrder [private]
 

Depth-first pre-order of the nodes.

Definition at line 196 of file loops.h.

Referenced by classifyEdges(), depthFirstSearch(), and findBody().

procNode* loopTree::_procedure [private]
 

The procedure.

Definition at line 154 of file loops.h.

Referenced by classifyEdges().

basicblock_int_map loopTree::_rpostOrder [private]
 

Depth-first reverse-post-order of the nodes.

Definition at line 200 of file loops.h.

Referenced by classifyEdges(), and depthFirstSearch().

loopTreeNode* loopTree::_top [private]
 

The loop tree.

Definition at line 158 of file loops.h.

Referenced by findBody().

edge_map loopTree::_treeEdges [private]
 

List of tree edges.

Stored according to the source of the edge

Definition at line 186 of file loops.h.

Referenced by depthFirstSearch().


The documentation for this class was generated from the following files:

Generated on August 27, 2003
Back to the C-Breeze home page