ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DominatorTreesAndDominanceFrontiers::DominatorTree Class Reference

#include <DominatorTree.h>

Collaboration diagram for DominatorTreesAndDominanceFrontiers::DominatorTree:

Public Types

enum  Direction {
  PRE,
  POST
}
 This enum holds values for determining whether the Tree is a dominator or post-dominator. More...
 

Public Member Functions

 DominatorTree (SgNode *head, Direction d=PRE)
 
ControlFlowGraphgetCFG ()
 get the CFG the dominator tree is built from More...
 
Direction getDirection ()
 returns whether this is a dominator tree (PRE) or a post-dominator tree (POST) More...
 
ControlFlowGraph::ID_dir getCFGDirection ()
 returns the corresponding direction for the numbering of the CFG. More...
 
int getSize ()
 returns the number of nodes in the tree More...
 
int getDom (ControlNode *node)
 for a given node, return the id of its immediate dominator More...
 
int getDom (int id)
 for a given node id, return the id of its immediate dominator More...
 
void printCFG ()
 
void printDominators ()
 

Private Member Functions

void _buildCFG (SgNode *head)
 
void _setupStructures ()
 
void _findDominators ()
 
int _intersect (int f1, int f2)
 
bool _processNode (int i)
 performs the next iteration of finding i-dom for a given node, returns whether the i-dom changed from the previous iteration. More...
 

Private Attributes

ControlFlowGraph_cfg
 The control flow graph the dominator tree is built from. More...
 
Direction _dir
 Indicates construction of a dominator or post-dominator tree. More...
 
ControlFlowGraph::ID_dir _iddir
 
int _size
 
int * doms
 Holds the immediate dominator for each ControlNode (indexed using CFG indices) More...
 

Detailed Description

This class constructs either a dominator or a post-dominator tree for a given function.

First, let us define "Dominance." A node X in a CFG dominates node Y if all paths into Y must first pass through X. (Similarly, a node X post-dominates node Y if all paths out of Y must pass through X)

To understand a dominator tree, first the concept of immediate dominance must be understood: For a given node Y in a CFG, its "Immediate Dominator" X is the nearest node which dominates Y. (For example, within straight-line code, the Immediate Dominator of any statement is the statement immediately preceding; in an if-statement, the immediate dominator of the first statement in the true-body is the conditional). The dominator tree is thus a graph where the successors for a given node X are all the nodes for which X is the immediate dominator.

A post-dominator tree is similar except calculated using post-dominators (hence, an immediate post-dominator for node X is the first statement Y that must be executed after X).

Definition at line 45 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

Member Enumeration Documentation

enum DominatorTreesAndDominanceFrontiers::DominatorTree::Direction

This enum holds values for determining whether the Tree is a dominator or post-dominator.

Enumerator
PRE 

This indicates that we are building a dominator tree

POST 

This indicates that we are building a post-dominator tree

Definition at line 50 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

Constructor & Destructor Documentation

DominatorTreesAndDominanceFrontiers::DominatorTree::DominatorTree ( SgNode head,
Direction  d = PRE 
)

Member Function Documentation

ControlFlowGraph* DominatorTreesAndDominanceFrontiers::DominatorTree::getCFG ( )
inline

get the CFG the dominator tree is built from

Definition at line 59 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

References _cfg.

Direction DominatorTreesAndDominanceFrontiers::DominatorTree::getDirection ( )
inline

returns whether this is a dominator tree (PRE) or a post-dominator tree (POST)

Definition at line 61 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

References _dir.

ControlFlowGraph::ID_dir DominatorTreesAndDominanceFrontiers::DominatorTree::getCFGDirection ( )
inline

returns the corresponding direction for the numbering of the CFG.

Definition at line 63 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

References _iddir.

int DominatorTreesAndDominanceFrontiers::DominatorTree::getSize ( )
inline

returns the number of nodes in the tree

Definition at line 65 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

References _size.

int DominatorTreesAndDominanceFrontiers::DominatorTree::getDom ( ControlNode node)
inline

for a given node, return the id of its immediate dominator

Definition at line 68 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

References _iddir, doms, and DominatorTreesAndDominanceFrontiers::ControlNode::getID().

int DominatorTreesAndDominanceFrontiers::DominatorTree::getDom ( int  id)
inline

for a given node id, return the id of its immediate dominator

Definition at line 70 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

References doms.

void DominatorTreesAndDominanceFrontiers::DominatorTree::printCFG ( )
void DominatorTreesAndDominanceFrontiers::DominatorTree::printDominators ( )
void DominatorTreesAndDominanceFrontiers::DominatorTree::_buildCFG ( SgNode head)
private
void DominatorTreesAndDominanceFrontiers::DominatorTree::_setupStructures ( )
private
void DominatorTreesAndDominanceFrontiers::DominatorTree::_findDominators ( )
private
int DominatorTreesAndDominanceFrontiers::DominatorTree::_intersect ( int  f1,
int  f2 
)
private
bool DominatorTreesAndDominanceFrontiers::DominatorTree::_processNode ( int  i)
private

performs the next iteration of finding i-dom for a given node, returns whether the i-dom changed from the previous iteration.

Member Data Documentation

ControlFlowGraph* DominatorTreesAndDominanceFrontiers::DominatorTree::_cfg
private

The control flow graph the dominator tree is built from.

Definition at line 88 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

Referenced by getCFG().

Direction DominatorTreesAndDominanceFrontiers::DominatorTree::_dir
private

Indicates construction of a dominator or post-dominator tree.

Definition at line 91 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

Referenced by getDirection().

ControlFlowGraph::ID_dir DominatorTreesAndDominanceFrontiers::DominatorTree::_iddir
private

Correlates with _dir, tells us whether the CFG is numbered forward (i.e. from the entry of the CFG, following forward edges), or backward (i.e. from the exit of the CFG, following backward edges).

Definition at line 98 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

Referenced by getCFGDirection(), and getDom().

int DominatorTreesAndDominanceFrontiers::DominatorTree::_size
private

Definition at line 100 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

Referenced by getSize().

int* DominatorTreesAndDominanceFrontiers::DominatorTree::doms
private

Holds the immediate dominator for each ControlNode (indexed using CFG indices)

Definition at line 103 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.

Referenced by getDom().


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