public final class AnnotatedLSTNode extends LSTNode
predecessor: initialLoopIterator = ...; header: phiLoopIterator = phi (initialLoopIterator, carriedLoopIterator) ...body1... carriedLoopIterator = phiLoopIterator iteratorInstr.opcode stride; ...body2... exit: if carriedLoopIterator condition terminalIteratorValue goto header successor:While loops (and implicitly for loops) aren't handled as they can be transformed to this form by
CFGTransformations
.
TODO:
LSTNode
Modifier and Type | Class and Description |
---|---|
(package private) static class |
AnnotatedLSTNode.BBEnum
This class implements an enumeration of
BasicBlock s. |
private static class |
AnnotatedLSTNode.NonRegularLoopException
Exception thrown when a non-regular loop is encountered
|
LSTNode.Edge
SpaceEffGraphNode.GraphEdgeEnumeration<T extends GraphEdge>, SpaceEffGraphNode.OutEdgeEnumeration
Modifier and Type | Field and Description |
---|---|
private Operand |
carriedLoopIterator
The iterator that is used to loop within the exit block
|
ConditionOperand |
condition
The condition that is used to check for the end of loop
|
private static boolean |
DEBUG
Flag to optionally print verbose debugging messages
|
BasicBlock |
exit
The in loop block that either loops or leaves the loop
|
private Instruction |
ifCmpInstr
The if instruction within the exit block
|
Operand |
initialIteratorValue
The the initial iterator that comes into the phi node in the header
|
private IR |
ir
A pointer to the governing IR
|
private Instruction |
iteratorInstr
The instruction that modifies the iterator
|
private Operand |
phiLoopIterator
The the phi iterator that gets modified by the stride to produce the carried iterator
|
BasicBlock |
predecessor
The out of loop block before the header
|
Operand |
strideValue
The stride operand to the iterator instruction
|
BasicBlock |
successor
The out of loop block following the exit block
|
Operand |
terminalIteratorValue
The value that ends the loop
|
depth, header, loop, loopExits, loopMultiplier
_inEdgeEnd, _inEdgeStart, _outEdgeEnd, _outEdgeStart, info, next, nextSorted, prev
Constructor and Description |
---|
AnnotatedLSTNode(IR ir,
LSTNode node)
Constructor
|
Modifier and Type | Method and Description |
---|---|
private void |
checkInEdgesAreInLoop(BasicBlock block)
Check the edges into a block are from within the loop
|
private void |
checkOutEdgesAreInLoop(BasicBlock block)
Check the edges out of a block are within the loop
|
boolean |
contains(BasicBlock block) |
static Instruction |
definingInstruction(Operand op)
Find the instruction that defines an operand.
|
void |
dump()
Dumps a human readable description of the loop.
|
(package private) void |
dumpBlock(BasicBlock block)
Dump a human readable description of a basic block within the loop
|
(package private) static void |
dumpInstruction(IR ir,
Instruction instr)
Dump a human readable description of an instruction within a
basic block within the loop
|
static Operand |
follow(Operand use)
Follow the operand's definition filtering out moves
This code is taken and modified from an old
LoopUnrolling |
Operand |
generateLoopInvariantOperand(BasicBlock block,
Operand op)
Loop invariants may not be accessible before a loop, so generate
the instructions so they are
|
Enumeration<BasicBlock> |
getBasicBlocks()
Return an enumeration of basic blocks corresponding to a depth
first traversal of the blocks in the loops graphs
|
private AnnotatedLSTNode.BBEnum |
getBasicBlocks(BasicBlock block,
AnnotatedLSTNode.BBEnum bbs,
BitVector blocksLeftToVisit)
Return an enumeration of basic blocks corresponding to a depth
first traversal of the blocks in the loops graphs
|
Operand |
getCarriedLoopIterator()
Get the carried loop iterator
|
int |
getFixedDistanceFromPhiIterator(Operand op)
Get fixed distance from the phi iterator
|
int |
getMonotonicStrideValue()
Return the stride value for monotonic loops
|
(package private) static String |
instructionToString(IR ir,
Instruction instr)
Converts instruction to String in of AnnotatedLSTNode format.
|
boolean |
isAffineLoop()
Is this an affine loop of the form:
predecessor:
initialLoopIterator = ...;
header:
phiLoopIterator = phi (initialLoopIterator, carriedLoopIterator)
...body1...
|
boolean |
isCarriedLoopIterator(Operand op)
Is this operand related to the carried iterator of this loop?
|
(package private) static boolean |
isConstant(Operand op)
Test whether the operand is constant
|
boolean |
isCountableLoop()
Is this a countable loop of the form:
predecessor:
initialLoopIterator = ConstantInitialValue;
header:
phiLoopIterator = phi (initialLoopIterator, carriedLoopIterator)
...body1...
|
(package private) boolean |
isFixedDistanceFromPhiIterator(Operand op)
Is this operand a fixed distance from the phi iterator?
|
boolean |
isInLoop(BasicBlock block)
Is the a particular block in this loop?
|
boolean |
isInvariant(Operand op)
Is this value modified by the loop?
|
private static boolean |
isLoopInvariant(Operand op,
BitVector loop,
BasicBlock header)
Test whether operand value will be invariant in a loop by tracing
back earlier definitions.
|
boolean |
isMonotonic() |
boolean |
isMonotonicDecreasing() |
boolean |
isMonotonicIncreasing() |
boolean |
isNonRegularLoop()
Is this loop a non-regular loop?
|
boolean |
isPhiLoopIterator(Operand op)
Is this operand related to the phi iterator of this loop?
|
boolean |
isRelatedToIterator(Operand op)
Is this operand related to the iterator of this loop?
|
private void |
perform()
Convert node into annotated format
|
private void |
processExit()
Process the loop exit basic block.
|
private void |
processHeader()
Process the loop header basic block.
|
private void |
processLoopBlock(BasicBlock block)
Process a regular block within the loop
|
String |
toString()
Converts the annotated loop to a concise string
|
addLoopExit, getChildren, getHeader, getLoop, getParent, initializeLoopExits
_sortDFS, _sortRevTop, _sortTop, append, appendInEdge, appendOutEdge, clearDfsVisited, clearFlags, clearInFlags, clearLoopHeader, clearOnStack, clearOutFlags, clearTopVisited, deleteIn, deleteOut, deleteOut, deleteOut, dfsVisited, findOutEdgeTo, firstInEdge, firstInNode, firstOutEdge, firstOutNode, flagsOn, getIndex, getNext, getNumber, getNumberOfIn, getNumberOfOut, getPrev, hasIn, hasOneIn, hasOneIn, hasOneOut, hasOneOut, hasOut, hasZeroIn, hasZeroOut, inEdges, inNodes, insertOut, insertOut, isLoopHeader, onStack, outEdges, outNodes, pointsIn, pointsOut, printExtended, printInEdges, printInNodes, printOutEdges, printOutNodes, remove, removeIn, removeIn, removeOut, removeOut, replaceInEdge, replaceOut, setDfsVisited, setDfsVisitedOnStack, setIndex, setLoopHeader, setNumber, setOnStack, setTopVisited, sortDFS, sortRevTop, sortTop, topVisited
private static final boolean DEBUG
public BasicBlock predecessor
public BasicBlock exit
public BasicBlock successor
private Instruction ifCmpInstr
private Instruction iteratorInstr
public Operand initialIteratorValue
private Operand carriedLoopIterator
private Operand phiLoopIterator
public Operand terminalIteratorValue
public ConditionOperand condition
public Operand strideValue
public AnnotatedLSTNode(IR ir, LSTNode node)
ir
- The containing IRnode
- The node that's being annotatedpublic boolean isCountableLoop()
predecessor: initialLoopIterator = ConstantInitialValue; header: phiLoopIterator = phi (initialLoopIterator, carriedLoopIterator) ...body1... carriedLoopIterator = phiLoopIterator (+|-) ConstantStride; ...body2... exit: if carriedLoopIterator condition ConstantTerminalIteratorValue goto header successor:ie. lots of constant fields so we can calculate the number of loop iterations (handy for pre-scheduling).
public boolean isAffineLoop()
predecessor: initialLoopIterator = ...; header: phiLoopIterator = phi (initialLoopIterator, carriedLoopIterator) ...body1... carriedLoopIterator = phiLoopIterator (+|-) invariantStride; ...body2... exit: if carriedLoopIterator condition invariantTerminalIteratorValue goto header successor:ie. lots of constant fields so we can calculate the number of loop iterations (handy for pre-scheduling).
public boolean isNonRegularLoop()
public boolean isInvariant(Operand op)
op
- an operandpublic boolean isRelatedToIterator(Operand op)
op
- Operand to testpublic boolean isPhiLoopIterator(Operand op)
op
- Operand to testpublic boolean isCarriedLoopIterator(Operand op)
op
- Operand to testpublic boolean isMonotonic()
public int getMonotonicStrideValue()
public boolean isMonotonicIncreasing()
public boolean isMonotonicDecreasing()
public boolean contains(BasicBlock block)
block
- the block to chck fortrue
if the basic block appears in the looppublic void dump()
void dumpBlock(BasicBlock block)
block
- The basic block to dumpstatic void dumpInstruction(IR ir, Instruction instr)
ir
- Containing IRinstr
- The instruction to dumpstatic String instructionToString(IR ir, Instruction instr)
ir
- Containing IRinstr
- The instruction to dumpstatic boolean isConstant(Operand op)
op
- Operand to determine whether it's constantboolean isFixedDistanceFromPhiIterator(Operand op)
op
- the operand to testpublic int getFixedDistanceFromPhiIterator(Operand op)
op
- the operand to testprivate static boolean isLoopInvariant(Operand op, BitVector loop, BasicBlock header)
LoopUnrolling
.op
- Operand to determine whether it's invariantloop
- Loop in which we wish to know the invariance of the operandheader
- The loop header for determining if PEIs are invariantpublic Operand generateLoopInvariantOperand(BasicBlock block, Operand op)
block
- to generate instructions intoop
- the operand we hope to use before the looppublic static Operand follow(Operand use)
LoopUnrolling
use
- Operand to followpublic static Instruction definingInstruction(Operand op)
op
- The operand we're searching for the definition ofpublic boolean isInLoop(BasicBlock block)
block
- the block to check fortrue
iff block is in the loopprivate AnnotatedLSTNode.BBEnum getBasicBlocks(BasicBlock block, AnnotatedLSTNode.BBEnum bbs, BitVector blocksLeftToVisit)
block
- block to visitbbs
- enumeration so farblocksLeftToVisit
- blocks left to visitpublic Enumeration<BasicBlock> getBasicBlocks()
private void checkOutEdgesAreInLoop(BasicBlock block) throws AnnotatedLSTNode.NonRegularLoopException
block
- to checkAnnotatedLSTNode.NonRegularLoopException
- if the loop was not regularprivate void checkInEdgesAreInLoop(BasicBlock block) throws AnnotatedLSTNode.NonRegularLoopException
block
- to checkAnnotatedLSTNode.NonRegularLoopException
- if the loop was not regularprivate void perform() throws OptimizingCompilerException
OptimizingCompilerException
private void processHeader() throws AnnotatedLSTNode.NonRegularLoopException
AnnotatedLSTNode.NonRegularLoopException
- if the loop was not regularprivate void processExit() throws AnnotatedLSTNode.NonRegularLoopException
AnnotatedLSTNode.NonRegularLoopException
- if the loop was not regularprivate void processLoopBlock(BasicBlock block) throws AnnotatedLSTNode.NonRegularLoopException
block
- The basic block to processAnnotatedLSTNode.NonRegularLoopException
- if the loop was not regularpublic Operand getCarriedLoopIterator()