scale.score.chords
Class LoopHeaderChord

java.lang.Object
  extended by scale.common.Root
      extended by scale.score.Note
          extended by scale.score.chords.Chord
              extended by scale.score.chords.SequentialChord
                  extended by scale.score.chords.LoopHeaderChord
All Implemented Interfaces:
AnnotationInterface, DisplayNode
Direct Known Subclasses:
BeginChord

public class LoopHeaderChord
extends SequentialChord

This class is used to mark the start of a loop.

$Id: LoopHeaderChord.java,v 1.136 2007-10-29 13:39:26 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

An instance of this class always has two and only two in-coming CFG edges. One is from a LoopPreHeaderChord and the other is from a LoopTailChord. No code is generated for a LoopHeaderChord instance.

Don't assume that a LoopHeaderChord instance will always start a basic block. For example, a "do { } while (false);" will not have a LoopTailChord after SCC.

There may be one, none, or several LoopExitChord instances associated with a loop.

Below are two images of the loop structure used by Scale. They show the CFG before going into SSA mode. Both were generated from:

 int sumfor(int n)
 {
   int sum, i;
   sum = 0;
   for (i = 0; i < n; i++)
     sum += i;
   return sum;
 }
 
Regular LoopLoop Test at End
Regular Loop Loop Test at End

See Also:
LoopPreHeaderChord, LoopTailChord, LoopExitChord, LoopInitChord

Field Summary
static boolean classTrace
          True if traces are to be performed.
 
Fields inherited from class scale.score.chords.Chord
lineNumber
 
Constructor Summary
LoopHeaderChord(Scribble scribble, LoopHeaderChord parent)
           
LoopHeaderChord(Scribble scribble, LoopHeaderChord parent, Chord next)
           
 
Method Summary
 void addChildLoop(LoopHeaderChord child)
          Specify that child is a loop contained in this loop.
 void addLoopExit(LoopExitChord loopExit)
          Specify a LoopExitChord instance associated with this loop.
 LoopHeaderChord commonAncestor(LoopHeaderChord l2)
          Return the common ancestor of this loop and the specified loop.
 Chord copy()
          Make a copy of this loop header sans any data dependence information.
 int countNodesInLoop()
          Return the number of nodes in the loop, not including the loop header or the LoopExitChord nodes.
 void defPrimaryInductionVariable(InductionVar var)
          Define the primary induction variable for this loop.
 DDGraph getDDGraph(boolean createSpatialDependencies)
          Return the data dependency graph for this CFG.
 DColor getDisplayColorHint()
          Return a String specifying the color to use for coloring this node in a graphical display.
 LoopHeaderChord getFirstChild()
          Return the first child loop.
 LoopExitChord getFirstExit()
          Return the first loop exit.
 InductionVar getInductionVar(Expr exp)
          Return the InductionVar instance referenced by this LoadExpr expression or null.
 InductionVar getInductionVar(int index)
          Return the indicated induction variable.
 InductionVar getInductionVar(VariableDecl vd)
          Return the InductionVar instance associated with this variable or null.
 Expr getInductionVarInitExpr()
          Return the expression that initializes the primary induction variable or null if it is not known.
 Vector<InductionVar> getInductionVars()
          Return a vector of this loop's induction variables.
 LoopHeaderChord getInnerLoop(int i)
          Return the specified inner loop.
 Vector<LoopHeaderChord> getInnerLoops()
          Return a Vector of all of the loops (LoopHeaderChord instances) contained in this loop.
 void getInnermostLoops(Vector<LoopHeaderChord> loops)
          Add all innermost loops in this loop tree to the vector.
 void getLoopChordsRecursive(HashSet<Chord> chords)
          Return all the CFG nodes in this loop and all of its inner loops.
 LoopExitChord getLoopExit(int i)
          Return the specified loop exit.
 LoopHeaderChord getLoopHeader()
          Return the LoopHeaderChord instance associated with this loop exit.
 InductionVar getLoopIndex(LoadExpr le)
          Return the InductionVar instance associated with this LoadExpr or null.
 VariableDecl getLoopIndexVar()
          Return the primary loop index variable or null if none known.
 LoopInitChord getLoopInit()
          Return the LoopInitChord instance for this loop.
 int getLoopNumber()
          Return the integer value associated with a loop.
 LoopTailChord getLoopTail()
          Return the LoopTailChord instance for this loop if known.
 IfThenElseChord getLoopTest()
          Return the loop test Chord for this loop or null if not known.
 Expr getLowerBound()
          Return the node representing the loop's lower bound.
 int getNestedLevel()
          Return the nest level for a loop.
 LoopHeaderChord getParent()
          Return the parent loop of this loop.
 LoopPreHeaderChord getPreHeader()
          Return the LoopPreHeaderChord instance for this loop.
 InductionVar getPrimaryInductionVar()
          Return the best primary induction variable.
 InductionVar getPrimaryInductionVar(int index)
          Return the indicated primary induction variable.
 int getProfEntryCnt()
          Return the number of times the loop was entered during execution.
 int getProfIterationCnt()
          Return the number of times the loop was iterated during execution as determined by profiling.
 Scribble getScribble()
          Return the Scribble instance for this loop header.
 long getStepValue()
          Return the step value of the primary induction variable or 0 if it is not known.
 boolean getSubscripts(Table<Declaration,SubscriptExpr> subs)
          Create the mapping from the array names to the SubscriptExpr instances in this loop.
 boolean getSubscriptsRecursive(Table<Declaration,SubscriptExpr> subs)
          Create a Table mapping from array name to SubscriptExpr instances in this loop nest.
 Vector<LoopHeaderChord> getTightlyNestedLoops()
          Return a vector of the tightly nested loops or null.
 LoopHeaderChord getTopLoop()
          Returns the top most "real" loop containing this loop.
 Cost getTripCount()
           
 int getUnrollFactor()
          Return the requested unroll factor.
 Expr getUpperBound()
          Return the node representing the loop's upper bound.
 boolean hasInnerLoop(LoopHeaderChord child)
          Return true if the specified loop is a child of this loop.
 java.lang.String inductionVarName()
          Return the name of the primary induction variable.
 boolean inhibitLoopPermute()
           
 AffineExpr isAffine(Expr n)
          Return the affine expression defined by the specified expression or null if the expression is not affine.
 boolean isDDComplete()
          Return true if the data dependence information for this loop nest is complete.
 boolean isInnerMostLoop()
          Return true if this loop is an inner-most loop.
 boolean isInvariant(Expr exp)
          Return true if the expression is invariant in the loop.
 boolean isLoopExit(LoopExitChord le)
          Return true if the specified loop exit is for this loop.
 boolean isLoopHeader()
          Return true if this chord is a LoopHeaderChord.
 boolean isLoopIndex(Expr exp)
          Return true if the specified expression is a LoadExpr instance that references a loop induction variable.
 boolean isLoopIndex(VariableDecl vd)
          Return true if the specified variable is a loop induction variable.
 boolean isLoopInfoComplete()
          Return true if the loop information for this loop is complete.
 boolean isPerfectlyNested()
          Return true if this is a perfectly nested loop.
 boolean isPrimaryLoopIndex(Expr exp)
          Return true if the specified LoadExpr instance references the primary loop induction variable.
 boolean isPrimaryLoopIndex(VariableDecl vd)
          Return true if the specified variable is the primary loop induction variable.
 boolean isSpecial()
          Return true if this is CFG node was added for the convenience of the compiler and does not correspond to actual source code in the user program.
 boolean isSubloop(LoopHeaderChord loop)
          Return true if this loop is a subloop of loop or if this == loop.
 boolean isTightlyNested()
          Return true if this loop is tightly nested.
 boolean isTrueLoop()
          Return true if this loop is an actual loop in the program.
 void labelCFGLoopOrder()
          Give unique labels to all CFG nodes.
 void linkSubgraph(HashMap<Chord,Chord> nm)
          Link a new CFG node that contains old links.
 void loopClean()
          Eliminate associated loop information.
 boolean loopContainsCall()
          Return true if an expression in the loop may result in a call to a subroutine.
 int nestedLevel()
          Return the nesting depth of the inner-most loop relative to this loop.
 void newSSAForm()
          Remove the induction variable information from this loop and all child loops.
 int numChordsInLoop()
          Return the number of nodes in this loop including its subloops.
 int numInDataEdges()
          Return the number of in-coming data edges.
 int numInductionVars()
          Return the number of induction variables found for the loop.
 int numInnerLoops()
          Return the number of the loops contained in this loop (i.e., the number of immediate sub-loops).
 int numLoopExits()
          Return the number of loop exits.
 int numPrimaryInductionVars()
          Return the number of induction variables with termination tests.
 boolean parentsFinished(HashSet<Chord> finished)
          Always return true, since we ignore the back edge when performing a topological sort.
 boolean parentsVisited()
          Always return true, since we ignore the back edge when performing a topological sort.
 boolean print(int indent)
          Print a display of the information about the loop.
 void printSubscripts(Table<Declaration,SubscriptExpr> arraySubscripts)
          Print the (sometimes very large) list of subscript expressions in this loop.
 void recomputeLoop()
          Specify that the loop information is no longer valid.
 void recomputeLoops()
          Specify that the loop information is no longer valid for this loop and all its sub-loops.
 void removeChildLoop(LoopHeaderChord child)
          Specify that child is no longer a loop contained in this loop.
 void removeLoopExit(LoopExitChord loopExit)
          Specify that LoopExitChord instance is no longer a loop exit for this loop.
 void setDDComplete()
          Specify that the data dependence information for this loop is complete to initialize for data dependence testing.
 void setDDIncomplete()
          Specify that the data dependence information for this loop is not complete because data dependence testing failed.
 void setLoopInit(LoopInitChord loopInit)
          Specify the LoopInitChord instance associated with this loop.
 void setLoopTail(LoopTailChord loopTail)
          Specify the LoopTailChord instance associated with this loop.
 void setLoopTest(IfThenElseChord loopTest)
          Specify the loop exit test associated with this loop.
 void setParent(LoopHeaderChord parent)
          Specify the enclosing loop of this loop.
 void setProfEntryCnt(int count)
          Specify the number of times the loop was entered during execution.
 void setProfIterationCnt(int count)
          Specify the number of times the loop was iterated during execution.
 void setScribble(Scribble scribble)
          Specify the Scribble instance for this loop header.
 void setUnrollFactor(int unrollFactor)
          Set the requested unroll factor.
 java.lang.String toStringSpecial()
          Construct a String that contains the loop header chord of this loop.
 void unlinkChord()
          Break any un-needed links from this LoopHeaderChord instance that has been deleted.
 void usePragma(PragmaStk.Pragma pragma)
           
 void validate()
          Check this node for validity.
 void visit(Predicate p)
          Process a node by calling its associated routine.
 
Methods inherited from class scale.score.chords.SequentialChord
changeOutCfgEdge, clearEdge, clearEdgeMarkers, deleteInDataEdges, deleteOutCfgEdges, edgeMarked, executionCostEstimate, getDeclList, getExprList, getLoadExprList, getNextChord, getOutCfgEdge, getOutCfgEdgeArray, getTarget, indexOfOutCfgEdge, isLastInBasicBlock, isSequential, linkTo, markEdge, numOutCfgEdges, pushAllOutCfgEdges, pushOutCfgEdges, pushOutCfgEdges, pushSortedOutCfgEdges, pushSortedOutCfgEdges, removeUseDef, replaceDecl, replaceOutCfgEdge, setTarget, setTargetUnsafe
 
Methods inherited from class scale.score.chords.Chord
addInCfgEdge, changeInDataEdge, changeParentOutCfgEdge, copySourceLine, deadCFGNodes, deletedCFGNodes, deleteInCfgEdge, executionOrder, expungeFromCfg, extractFromCfg, findLoopExit, findPhiChords, firstInBasicBlock, getCall, getDefExpr, getDisplayLabel, getDisplayShapeHint, getFirstInCfgEdge, getInCfgEdge, getInCfgEdge, getInCfgEdgeArray, getInDataEdge, getInDataEdgeArray, getLabel, getLoopHeader, getSourceLineNumber, gotoCFGNodes, inBasicBlock, indexOfInCfgEdge, insertAfterOutCfg, insertBeforeInCfg, isAssignChord, isBranch, isExprChord, isFirstInBasicBlock, isLoopExit, isLoopPreHeader, isLoopTail, isMarker, isPhiExpr, lastInBasicBlock, nextVisit, nthIndexOfInCfgEdge, nullCFGNodes, numInCfgEdges, numOfInCfgEdge, pushAllInCfgEdges, pushChordWhenReady, pushChordWhenReady, pushInCfgEdges, pushInCfgEdges, pushInDataEdges, recordRefs, removeDeadCode, removeDualExprs, removeFromCfg, removeRefs, reorderInCfgEdgesOfCopy, replaceInCfgEdge, setLabel, setSourceLineNumber, setVisited, visited
 
Methods inherited from class scale.score.Note
getChord, getEssentialUse, setAnnotationLevel, setReportLevel, toString
 
Methods inherited from class scale.common.Root
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayName, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, trace, trace, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

classTrace

public static boolean classTrace
True if traces are to be performed.

Constructor Detail

LoopHeaderChord

public LoopHeaderChord(Scribble scribble,
                       LoopHeaderChord parent,
                       Chord next)
Parameters:
parent - the parent loop of this loop or null
next - is the successor CFG node

LoopHeaderChord

public LoopHeaderChord(Scribble scribble,
                       LoopHeaderChord parent)
Parameters:
parent - the parent loop of this loop or null
Method Detail

copy

public Chord copy()
Make a copy of this loop header sans any data dependence information.

Specified by:
copy in class Chord
Returns:
a copy of this node

loopClean

public void loopClean()
Eliminate associated loop information. All of the removed information is generated.

Overrides:
loopClean in class Chord

getParent

public final LoopHeaderChord getParent()
Return the parent loop of this loop.


addChildLoop

public final void addChildLoop(LoopHeaderChord child)
Specify that child is a loop contained in this loop.


removeChildLoop

public final void removeChildLoop(LoopHeaderChord child)
Specify that child is no longer a loop contained in this loop.


hasInnerLoop

public boolean hasInnerLoop(LoopHeaderChord child)
Return true if the specified loop is a child of this loop.


isInnerMostLoop

public final boolean isInnerMostLoop()
Return true if this loop is an inner-most loop. It is an inner-most loop if it has no children loops.


getFirstChild

public final LoopHeaderChord getFirstChild()
Return the first child loop.


getInnerLoops

public Vector<LoopHeaderChord> getInnerLoops()
Return a Vector of all of the loops (LoopHeaderChord instances) contained in this loop.


getInnerLoop

public LoopHeaderChord getInnerLoop(int i)
Return the specified inner loop.


getInnermostLoops

public final void getInnermostLoops(Vector<LoopHeaderChord> loops)
Add all innermost loops in this loop tree to the vector. The BeginChord instance is never added.


numInnerLoops

public final int numInnerLoops()
Return the number of the loops contained in this loop (i.e., the number of immediate sub-loops).


unlinkChord

public void unlinkChord()
Break any un-needed links from this LoopHeaderChord instance that has been deleted.

Overrides:
unlinkChord in class Chord

parentsVisited

public final boolean parentsVisited()
Always return true, since we ignore the back edge when performing a topological sort.

Overrides:
parentsVisited in class Chord

parentsFinished

public final boolean parentsFinished(HashSet<Chord> finished)
Always return true, since we ignore the back edge when performing a topological sort.

Overrides:
parentsFinished in class Chord
Parameters:
finished - is the set to test.

setParent

public final void setParent(LoopHeaderChord parent)
Specify the enclosing loop of this loop.

Parameters:
parent - new parent loop of this loop

addLoopExit

public void addLoopExit(LoopExitChord loopExit)
Specify a LoopExitChord instance associated with this loop.

Parameters:
loopExit - is the LoopExitChord instance

removeLoopExit

public final void removeLoopExit(LoopExitChord loopExit)
Specify that LoopExitChord instance is no longer a loop exit for this loop.


getFirstExit

public final LoopExitChord getFirstExit()
Return the first loop exit.


getLoopExit

public final LoopExitChord getLoopExit(int i)
Return the specified loop exit.


numLoopExits

public final int numLoopExits()
Return the number of loop exits.


isLoopExit

public boolean isLoopExit(LoopExitChord le)
Return true if the specified loop exit is for this loop.


getPreHeader

public LoopPreHeaderChord getPreHeader()
Return the LoopPreHeaderChord instance for this loop.


usePragma

public final void usePragma(PragmaStk.Pragma pragma)

getUnrollFactor

public final int getUnrollFactor()
Return the requested unroll factor. This value may be set via a pragma or via profiling.


setUnrollFactor

public final void setUnrollFactor(int unrollFactor)
Set the requested unroll factor. This value may be set via a pragma or via profiling.


inhibitLoopPermute

public final boolean inhibitLoopPermute()

setLoopTail

public void setLoopTail(LoopTailChord loopTail)
Specify the LoopTailChord instance associated with this loop.

Parameters:
loopTail - the LoopTailChord

getLoopTail

public LoopTailChord getLoopTail()
Return the LoopTailChord instance for this loop if known.


setLoopInit

public void setLoopInit(LoopInitChord loopInit)
Specify the LoopInitChord instance associated with this loop.

Parameters:
loopInit - the LoopInitChord

getLoopInit

public LoopInitChord getLoopInit()
Return the LoopInitChord instance for this loop.


setLoopTest

public void setLoopTest(IfThenElseChord loopTest)
Specify the loop exit test associated with this loop.

Parameters:
loopTest - the loop test Chord

getLoopTest

public IfThenElseChord getLoopTest()
Return the loop test Chord for this loop or null if not known. There may be multiple loop exit tests. At most one of these tests will be known.


getLoopHeader

public LoopHeaderChord getLoopHeader()
Return the LoopHeaderChord instance associated with this loop exit.

Overrides:
getLoopHeader in class Chord

isSpecial

public boolean isSpecial()
Return true if this is CFG node was added for the convenience of the compiler and does not correspond to actual source code in the user program.

Overrides:
isSpecial in class Chord

numInDataEdges

public int numInDataEdges()
Return the number of in-coming data edges.

Overrides:
numInDataEdges in class Chord

visit

public void visit(Predicate p)
Description copied from class: Note
Process a node by calling its associated routine. See the "visitor" design pattern in Design Patterns: Elements of Reusable Object-Oriented Software by E. Gamma, et al, Addison Wesley, ISBN 0-201-63361-2.

Each class has a visit(Predicate p) method. For example, in class ABC:

   public void visit(Predicate p)
   {
     p.visitABC(this);
   }
 
and the class that implements Predicate has a method
   public void visitABC(Note n)
   {
     ABC a = (ABC) n;
     ...
   }
 
Thus, the class that implements Predicate can call
   n.visit(this);
 
where n is a Note sub-class without determining which specific sub-class n is. The visit pattern basically avoids implementing a large switch statement or defining different methods in each class for some purpose.

Specified by:
visit in class Note
See Also:
Predicate

getNestedLevel

public final int getNestedLevel()
Return the nest level for a loop. A value of 0 indicates an entry node. A value of 1 means the outermost loop. The nest level increases for inner loops.


isPerfectlyNested

public boolean isPerfectlyNested()
Return true if this is a perfectly nested loop. Assuming the loop exit test is at the beginning of the loop, a perfectly nested loop is a tightly nested loop that has no nodes, other than Phi functions, between the LoopHeaderChord & the loop exit test, between the loop exit test and the inner loop, and between the inner loop exit and the loop tail. This method is correct for loops where the loop exit test is at the end of the loop.

See Also:
isTightlyNested()

isTightlyNested

public final boolean isTightlyNested()
Return true if this loop is tightly nested. A tighly nested loop has only one inner loop and that inner loop is a tightly nested loop.


getTightlyNestedLoops

public final Vector<LoopHeaderChord> getTightlyNestedLoops()
Return a vector of the tightly nested loops or null. A tighly nested loop has only one inner loop and that inner loop is a tightly nested loop.


nestedLevel

public final int nestedLevel()
Return the nesting depth of the inner-most loop relative to this loop. This method is only valid for tightly nested looops.


defPrimaryInductionVariable

public void defPrimaryInductionVariable(InductionVar var)
Define the primary induction variable for this loop. This method is used when we know syntactically what the induction variable is.


getPrimaryInductionVar

public InductionVar getPrimaryInductionVar()
Return the best primary induction variable.


inductionVarName

public java.lang.String inductionVarName()
Return the name of the primary induction variable.


getLoopIndexVar

public VariableDecl getLoopIndexVar()
Return the primary loop index variable or null if none known.


getPrimaryInductionVar

public InductionVar getPrimaryInductionVar(int index)
Return the indicated primary induction variable.


numPrimaryInductionVars

public int numPrimaryInductionVars()
Return the number of induction variables with termination tests.


getInductionVarInitExpr

public Expr getInductionVarInitExpr()
Return the expression that initializes the primary induction variable or null if it is not known.


getStepValue

public long getStepValue()
Return the step value of the primary induction variable or 0 if it is not known.


getLowerBound

public Expr getLowerBound()
Return the node representing the loop's lower bound.


getUpperBound

public Expr getUpperBound()
Return the node representing the loop's upper bound.


isInvariant

public boolean isInvariant(Expr exp)
Return true if the expression is invariant in the loop. The expression must be connected to the CFG.


isPrimaryLoopIndex

public boolean isPrimaryLoopIndex(VariableDecl vd)
Return true if the specified variable is the primary loop induction variable.


loopContainsCall

public boolean loopContainsCall()
Return true if an expression in the loop may result in a call to a subroutine.


numInductionVars

public int numInductionVars()
Return the number of induction variables found for the loop.


getInductionVar

public InductionVar getInductionVar(int index)
Return the indicated induction variable.


getInductionVars

public Vector<InductionVar> getInductionVars()
Return a vector of this loop's induction variables.


getTopLoop

public final LoopHeaderChord getTopLoop()
Returns the top most "real" loop containing this loop. The result may be this if this is the top loop or this is the BeginChord.


getScribble

public final Scribble getScribble()
Return the Scribble instance for this loop header.


setScribble

public final void setScribble(Scribble scribble)
Specify the Scribble instance for this loop header.


getDDGraph

public DDGraph getDDGraph(boolean createSpatialDependencies)
Return the data dependency graph for this CFG. It's value will be null if there are no array references in loops.

Parameters:
createSpatialDependencies - is true if spatial edges should be created

labelCFGLoopOrder

public void labelCFGLoopOrder()
Give unique labels to all CFG nodes. For any given node n1, node n1's label is greater than the labels of all its immediate predecessors. In addition, for any LoopExitChord, its label is greater than the label of any other node in the loop. Note - if node n2's label is greater than node n1's label, this does not necessarily mean that n2 is always executed after n1; they could be in parallel branches of the CFG. So, one can not compare the labels of two nodes and declare that one is executed before or after the other. But, the label values do provide a useful partial ordering.

For a complete ordering of a CFG do

    scribble.getLoopTree().labelCFGLoopOrder();
 

Note - other algorithms may use the label field and destroy this value. An example is the computation of dominators.

Note - this method uses nextVisit().

See Also:
AASR, Scribble.linearize(scale.common.Vector), Chord.pushChordWhenReady(Stack, int)

getSubscripts

public boolean getSubscripts(Table<Declaration,SubscriptExpr> subs)
Create the mapping from the array names to the SubscriptExpr instances in this loop. Only "valid" subscript expressions are added. A valid subscript expression is one that dependence testing can utilize. Examples of invalid subscript expressions include
   (func(a,b))[i]
   strct.arr[i]
 

Returns:
true if all subscripts are valid

getSubscriptsRecursive

public boolean getSubscriptsRecursive(Table<Declaration,SubscriptExpr> subs)
Create a Table mapping from array name to SubscriptExpr instances in this loop nest. Only "valid" subscript expressions are added. A valid subscript expression is one that dependence testing can utilize. Examples of invalid subscript expressions include
   (func(a,b))[i]
   strct.arr[i]
 

Returns:
true if all subscripts are valid

isAffine

public AffineExpr isAffine(Expr n)
Return the affine expression defined by the specified expression or null if the expression is not affine.

Parameters:
n - is the expression.

recomputeLoops

public void recomputeLoops()
Specify that the loop information is no longer valid for this loop and all its sub-loops.


recomputeLoop

public void recomputeLoop()
Specify that the loop information is no longer valid.


newSSAForm

public void newSSAForm()
Remove the induction variable information from this loop and all child loops.


setProfEntryCnt

public final void setProfEntryCnt(int count)
Specify the number of times the loop was entered during execution.


getProfEntryCnt

public final int getProfEntryCnt()
Return the number of times the loop was entered during execution.


setProfIterationCnt

public final void setProfIterationCnt(int count)
Specify the number of times the loop was iterated during execution.


getProfIterationCnt

public final int getProfIterationCnt()
Return the number of times the loop was iterated during execution as determined by profiling.


isLoopHeader

public final boolean isLoopHeader()
Return true if this chord is a LoopHeaderChord.

Overrides:
isLoopHeader in class Chord

isDDComplete

public boolean isDDComplete()
Return true if the data dependence information for this loop nest is complete.


isLoopInfoComplete

public boolean isLoopInfoComplete()
Return true if the loop information for this loop is complete.


setDDIncomplete

public void setDDIncomplete()
Specify that the data dependence information for this loop is not complete because data dependence testing failed.


setDDComplete

public void setDDComplete()
Specify that the data dependence information for this loop is complete to initialize for data dependence testing.


printSubscripts

public void printSubscripts(Table<Declaration,SubscriptExpr> arraySubscripts)
Print the (sometimes very large) list of subscript expressions in this loop.


isSubloop

public boolean isSubloop(LoopHeaderChord loop)
Return true if this loop is a subloop of loop or if this == loop.


getTripCount

public Cost getTripCount()

toStringSpecial

public java.lang.String toStringSpecial()
Construct a String that contains the loop header chord of this loop.

Overrides:
toStringSpecial in class Chord
Returns:
String object that contains a printable description of the loop header chord of this loop.

isTrueLoop

public boolean isTrueLoop()
Return true if this loop is an actual loop in the program.


getLoopChordsRecursive

public void getLoopChordsRecursive(HashSet<Chord> chords)
Return all the CFG nodes in this loop and all of its inner loops.


numChordsInLoop

public int numChordsInLoop()
Return the number of nodes in this loop including its subloops. The CFG is not necessarily spanned to calculate the value.


countNodesInLoop

public int countNodesInLoop()
Return the number of nodes in the loop, not including the loop header or the LoopExitChord nodes. The CFG is spanned to calculate the value.

See Also:
Chord.nextVisit(), numChordsInLoop

commonAncestor

public LoopHeaderChord commonAncestor(LoopHeaderChord l2)
Return the common ancestor of this loop and the specified loop. The common ancestor is the deepest loop that contains both loops. The result may be this loop, the specified loop or some other loop. Note that the BeginChord node is a loop header.


print

public boolean print(int indent)
Print a display of the information about the loop.


getDisplayColorHint

public DColor getDisplayColorHint()
Return a String specifying the color to use for coloring this node in a graphical display.

Specified by:
getDisplayColorHint in interface DisplayNode
Overrides:
getDisplayColorHint in class Chord
See Also:
DColor

getLoopIndex

public InductionVar getLoopIndex(LoadExpr le)
Return the InductionVar instance associated with this LoadExpr or null.


isLoopIndex

public boolean isLoopIndex(Expr exp)
Return true if the specified expression is a LoadExpr instance that references a loop induction variable.


isLoopIndex

public boolean isLoopIndex(VariableDecl vd)
Return true if the specified variable is a loop induction variable.


getInductionVar

public InductionVar getInductionVar(Expr exp)
Return the InductionVar instance referenced by this LoadExpr expression or null.


getInductionVar

public InductionVar getInductionVar(VariableDecl vd)
Return the InductionVar instance associated with this variable or null.


isPrimaryLoopIndex

public boolean isPrimaryLoopIndex(Expr exp)
Return true if the specified LoadExpr instance references the primary loop induction variable.


linkSubgraph

public void linkSubgraph(HashMap<Chord,Chord> nm)
Link a new CFG node that contains old links. When a LoopHeaderChord is copied, the copy has the same links as the original loop header. This method updates those links.

Overrides:
linkSubgraph in class SequentialChord
Parameters:
nm - is a map from the old nodes to the new nodes.
See Also:
Scribble.linkSubgraph(scale.common.Vector, scale.common.HashMap, scale.common.Vector)

validate

public void validate()
Check this node for validity. This method throws an exception if the node is not linked properly.

Overrides:
validate in class Note

getLoopNumber

public final int getLoopNumber()
Return the integer value associated with a loop. The value 0 indicates no loop.

Overrides:
getLoopNumber in class Chord
See Also:
URJ