public abstract class Loop<T extends AbstractBlockBase<T>> extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
Loop(Loop<T> parent,
int index,
T header) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
List<T> |
getBlocks() |
List<Loop<T>> |
getChildren() |
int |
getDepth() |
T |
getHeader() |
int |
getIndex() |
List<T> |
getLoopExits()
Returns the loop exits.
|
ArrayList<T> |
getNaturalExits()
Returns the natural exit points: these are the earliest block that are guaranteed to never
reach a back-edge.
|
Loop<T> |
getParent() |
int |
hashCode() |
boolean |
isAncestorOrSelf(Loop<?> potentialAncestor)
|
boolean |
isInverted() |
boolean |
isLoopExit(T block) |
boolean |
isNaturalExit(T block) |
abstract long |
numBackedges() |
void |
setInverted(boolean inverted) |
String |
toString() |
public abstract long numBackedges()
public int getDepth()
public int getIndex()
public T getHeader()
public boolean isInverted()
public void setInverted(boolean inverted)
public boolean isAncestorOrSelf(Loop<?> potentialAncestor)
public List<T> getLoopExits()
Loop.getNaturalExits().
LoopExitNodes are inserted in the control-flow during parsing and are natural exits: they are the earliest block at which we are guaranteed to have exited the loop. However, after some transformations of the graph, the natural exit might go up but the LoopExitNodes are not updated.
For example in:
for (int i = 0; i < N; i++) {
if (c) {
// Block 1
if (dummy) {
// ...
} else {
// ...
}
if (b) {
continue;
} else {
// Block 2
// LoopExitNode
break;
}
}
}
After parsing, the natural exits match the LoopExitNode: Block 2 is a natural exit and has a
LoopExitNode. If the b condition gets canonicalized to false, the natural
exit moves to Block 1 while the LoopExitNode remains in Block 2. In such a scenario,
getLoopExits() will contain block 2 while Loop.getNaturalExits() will contain
block 1.Loop.getNaturalExits()public boolean isLoopExit(T block)
public ArrayList<T> getNaturalExits()
Loop.getLoopExits()public boolean isNaturalExit(T block)