ROSE
0.9.6a
|
#include <DominatorTree.h>
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) | |
ControlFlowGraph * | getCFG () |
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... | |
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.
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.
DominatorTreesAndDominanceFrontiers::DominatorTree::DominatorTree | ( | SgNode * | head, |
Direction | d = PRE |
||
) |
|
inline |
get the CFG the dominator tree is built from
Definition at line 59 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.
References _cfg.
|
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.
|
inline |
returns the corresponding direction for the numbering of the CFG.
Definition at line 63 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.
References _iddir.
|
inline |
returns the number of nodes in the tree
Definition at line 65 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.
References _size.
|
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().
|
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 | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
performs the next iteration of finding i-dom for a given node, returns whether the i-dom changed from the previous iteration.
|
private |
The control flow graph the dominator tree is built from.
Definition at line 88 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.
Referenced by getCFG().
|
private |
Indicates construction of a dominator or post-dominator tree.
Definition at line 91 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.
Referenced by getDirection().
|
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().
|
private |
Definition at line 100 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.
Referenced by getSize().
|
private |
Holds the immediate dominator for each ControlNode (indexed using CFG indices)
Definition at line 103 of file dominatorTreesAndDominanceFrontiers/DominatorTree.h.
Referenced by getDom().