public class DominatorTree extends Tree
TODO: we do not support IRs with exception handlers.
Modifier and Type | Field and Description |
---|---|
private DominatorTreeNode[] |
dominatorInfoMap
A structure used to quickly index into the DominatorVertex tree
|
private boolean |
forward
true if we are computing regular dominators, false for post-dominators |
private IR |
ir
The governing IR
|
Constructor and Description |
---|
DominatorTree(IR ir,
boolean forward)
Build a dominator tree from an IR.
|
Modifier and Type | Method and Description |
---|---|
private void |
addNode(BasicBlock b)
Creates dominator tree nodes for the passed block and adds them to the
map.
|
BasicBlock |
deepestCommonAncestor(BasicBlock a,
BasicBlock b)
Return the deepest common dominance ancestor of blocks
a and b |
int |
depth(BasicBlock b)
Return the distance from the root of the dominator tree to a given
basic block
|
boolean |
dominates(BasicBlock master,
BasicBlock slave)
Does basic block number "master" dominate basic block number "slave"?
|
boolean |
dominates(int b,
BitVector bits)
Does basic block number b dominate all basic blocks in a set?
|
boolean |
dominates(int master,
int slave)
Does basic block number "master" dominate basic block number "slave"?
|
Enumeration<TreeNode> |
getChildren(BasicBlock bb)
Enumerate the children of the vertex corresponding to a basic
block
|
BitVector |
getDominanceFrontier(BasicBlock bb)
Return the (already calculated) dominance frontier for
a basic block
|
BitVector |
getDominanceFrontier(int number)
Return the (already calculated) dominance frontier for
a basic block
|
private BasicBlock |
getFirstNode()
Get the first node, either entry or exit
depending on which way we are viewing the graph
|
BasicBlock |
getParent(BasicBlock bb)
Return the parent of the vertex corresponding to a basic
block
|
static void |
perform(IR ir,
boolean forward)
Build a dominator tree from an IR.
|
elements, getBottomUpEnumerator, getRoot, getTopDownEnumerator, isEmpty, numberOfNodes, setRoot, toString
private final boolean forward
true
if we are computing regular dominators, false
for post-dominatorsprivate final DominatorTreeNode[] dominatorInfoMap
public DominatorTree(IR ir, boolean forward)
ir
- the governing IRforward
- are we building regular dominators or post-dominators?public static void perform(IR ir, boolean forward)
ir
- the governing IRforward
- are we building regular dominators or post-dominators?private BasicBlock getFirstNode()
public Enumeration<TreeNode> getChildren(BasicBlock bb)
bb
- the basic blockpublic BasicBlock getParent(BasicBlock bb)
bb
- the basic blockpublic BitVector getDominanceFrontier(BasicBlock bb)
bb
- the basic blockpublic BitVector getDominanceFrontier(int number)
number
- the number of the basic blockpublic boolean dominates(int b, BitVector bits)
b
- the number of the basic block to testbits
- BitVector representation of the set of basic blocks to testpublic boolean dominates(int master, int slave)
master
- the number of the proposed "master" basic blockslave
- the number of the proposed "slave blockpublic boolean dominates(BasicBlock master, BasicBlock slave)
master
- the number of the proposed "master" basic blockslave
- the number of the proposed "slave blockprivate void addNode(BasicBlock b)
b
- the basic blockpublic int depth(BasicBlock b)
b
- the basic block in questionb
's depthpublic BasicBlock deepestCommonAncestor(BasicBlock a, BasicBlock b)
a
and b
a
- The first basic blockb
- The second basic blocka
and b