public class LSTGraph extends SpaceEffGraph
Note: throws an exception if an irreducible loop is found (which I believe could only happen in Java from modified bytecode, because Java source code is structured enough to prevent irreducible loops.)
DominatorsPhase
Modifier and Type | Field and Description |
---|---|
private static boolean |
DEBUG |
private IR |
ir |
private HashMap<BasicBlock,LSTNode> |
loopMap
Map of bb to LSTNode of innermost loop containing bb
|
protected LSTNode |
rootNode |
_firstNode, _lastNode, backwardTopSorted, forwardTopSorted, numberOfNodes
Modifier | Constructor and Description |
---|---|
private |
LSTGraph(IR ir)
Constructor, it creates the LST graph
|
protected |
LSTGraph(LSTGraph graph)
Copying constructor
|
Modifier and Type | Method and Description |
---|---|
private void |
clearBackEdges(SpaceEffGraphNode bb)
Clears the back edges for the basic block passed
|
private String |
dumpIt(LSTNode n) |
private void |
findBackEdges(BasicBlock bb,
int numBlocks,
Map<SpaceEffGraphNode,Integer> dfnMap)
This routine performs a non-recursive depth-first search starting at
the block passed looking for back edges.
|
private void |
findNaturalLoop(SpaceEffGraphEdge edge,
BitVector loop)
This routine implements part of the algorithm to compute natural loops
as defined in Muchnick p 192.
|
LSTNode |
getLoop(BasicBlock b) |
int |
getLoopNestDepth(BasicBlock bb) |
LSTNode |
getRoot()
Return the root node of the tree
|
boolean |
inInnermostLoop(BasicBlock bb)
Is a given basic block in an innermost loop?
|
boolean |
isLoopExit(BasicBlock source,
BasicBlock target) |
static void |
perform(IR ir)
The main entry point
|
private void |
setDepth(IR ir,
LSTNode node,
int depth) |
String |
toString()
Return a string representation of this graph.
|
addGraphEdge, addGraphEdge, addGraphNode, addRootNode, addTopSortNode, allocateNodeNumber, buildRevTopSort, buildTopSort, clearDFS, compactNodeNumbering, enumerateNodes, firstNode, initTopSort, isTopSorted, lastNode, numberOfNodes, printDepthFirst, removeGraphNode, resetTopSorted, rootNodes, setFirstNode, setLastNode, setNumberOfNodes, setTopSorted, startNode, topSort, topSortOrder
private static final boolean DEBUG
private final HashMap<BasicBlock,LSTNode> loopMap
public int getLoopNestDepth(BasicBlock bb)
bb
- the basic blockpublic boolean inInnermostLoop(BasicBlock bb)
bb
- the basic blockpublic boolean isLoopExit(BasicBlock source, BasicBlock target)
public LSTNode getLoop(BasicBlock b)
public LSTNode getRoot()
public String toString()
SpaceEffGraph
toString
in class SpaceEffGraph
private void findBackEdges(BasicBlock bb, int numBlocks, Map<SpaceEffGraphNode,Integer> dfnMap)
bb
- The basic block to processnumBlocks
- The number of basic blocksdfnMap
- numbering from the depth first traversalprivate void clearBackEdges(SpaceEffGraphNode bb)
bb
- the basic blockprivate void findNaturalLoop(SpaceEffGraphEdge edge, BitVector loop)
edge
- the edge to processloop
- bit vector to hold the results of the algorithm