|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.compilers.opt.util.SpaceEffGraph org.jikesrvm.compilers.opt.controlflow.LSTGraph
public class LSTGraph
Identify natural loops and builds the LST (Loop Structure Tree)
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
Field Summary | |
---|---|
private static boolean |
DEBUG
|
private HashMap<BasicBlock,LSTNode> |
loopMap
Map of bb to LSTNode of innermost loop containing bb |
protected LSTNode |
rootNode
|
Fields inherited from class org.jikesrvm.compilers.opt.util.SpaceEffGraph |
---|
_firstNode, _lastNode, backwardTopSorted, forwardTopSorted, numberOfNodes |
Constructor Summary | |
---|---|
private |
LSTGraph(IR ir)
Constructor, it creates the LST graph |
protected |
LSTGraph(LSTGraph graph)
Copying constructor |
Method Summary | |
---|---|
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)
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)
Is the edge from source to target an exit from the loop containing source? |
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. |
Methods inherited from class org.jikesrvm.compilers.opt.util.SpaceEffGraph |
---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final boolean DEBUG
protected LSTNode rootNode
private final HashMap<BasicBlock,LSTNode> loopMap
Constructor Detail |
---|
protected LSTGraph(LSTGraph graph)
graph
- to copyprivate LSTGraph(IR ir)
ir
- the IRMethod Detail |
---|
public static void perform(IR ir)
ir
- the IR to processpublic int getLoopNestDepth(BasicBlock bb)
bb
- the basic block
public boolean inInnermostLoop(BasicBlock bb)
bb
- the basic block
public boolean isLoopExit(BasicBlock source, BasicBlock target)
source
- the basic block that is the source of the edgetarget
- the basic block that is the target of the edgepublic LSTNode getLoop(BasicBlock b)
public LSTNode getRoot()
public String toString()
SpaceEffGraph
toString
in class SpaceEffGraph
private String dumpIt(LSTNode n)
private void setDepth(IR ir, LSTNode node, int depth)
private void findBackEdges(BasicBlock bb, int numBlocks)
bb
- The basic block to processnumBlocks
- The number of basic blocksprivate 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
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |