scale.score
Class InductionVar

java.lang.Object
  extended by scale.score.InductionVar

public final class InductionVar
extends java.lang.Object

Record information about a loop induction variable.

$Id: InductionVar.java,v 1.42 2007-10-04 19:58:18 burrill Exp $

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

The loop induction variable is the variable that is modified on each iteration of the loop and controls whether the loop terminates. For example, in

    for (i = init; i < n; i += step) { }
 
The variable i is the induction variable. The expression init is the initialization expression, i < n is the termination expression, and i + step is the induction expression.


Constructor Summary
InductionVar(LoopHeaderChord loop, VariableDecl var)
           
 
Method Summary
 void clean()
          Unlink any expression referenced by theis induction variable instance.
 Expr getEndExpr()
          Return the end value of the induction variable or null if it is not known.
 AffineExpr getForwardExpr()
          Return the induction variable's forward affine expression.
 Expr getInitExpr()
          Return the expression that specifies the initial value of the induction variable.
 long getIterationCount()
          Return the number of times the induction variable will be iterated or -1 if not known.
 LoopHeaderChord getLoopHeader()
          Return the loop associ8ated with this induction variable.
 java.lang.String getName()
          Return the name of the induction variable.
 Expr getStepExpr()
          Return the step expression for the induction variable.
 long getStepValue()
          Return the induction step value or zero if it is not known or not a constant value.
 Expr getTermExpr()
          Return the expression that terminates the loop.
 VariableDecl getVar()
          Return a reference to the induction variable.
 boolean hasForward()
          Return true if this induction variable has a forward affine expression.
 boolean isPrimary()
          Return true if this is the primary induction variable for the loop.
 void markForward()
          Specify that this induction variable has a forward affine expression.
 void markPrimary()
          Specify that this induction variable is the primary induction variable for the loop.
 boolean moreCompleteThan(InductionVar ivar)
          Return true if this induction variable is better than the specified induction variable.
 void setForwardExpr(AffineExpr ae)
          Specify the induction variable's forward affine expression.
 void setInitExpr(Expr init)
          Set the expression that specifies the initial value of the induction variable.
 void setStepExpr(Expr step)
          Set the induction step value or zero if it is not known.
 void setTermExpr(MatchExpr term, boolean reverse)
          Set the expression that terminates the loop.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InductionVar

public InductionVar(LoopHeaderChord loop,
                    VariableDecl var)
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getLoopHeader

public LoopHeaderChord getLoopHeader()
Return the loop associ8ated with this induction variable.


getVar

public VariableDecl getVar()
Return a reference to the induction variable.


getTermExpr

public Expr getTermExpr()
Return the expression that terminates the loop.


setTermExpr

public void setTermExpr(MatchExpr term,
                        boolean reverse)
Set the expression that terminates the loop.

Parameters:
term - is the test expression
reverse - is true if the test is reversed for the exit from the loop

getInitExpr

public Expr getInitExpr()
Return the expression that specifies the initial value of the induction variable.


setInitExpr

public void setInitExpr(Expr init)
Set the expression that specifies the initial value of the induction variable.


getEndExpr

public Expr getEndExpr()
Return the end value of the induction variable or null if it is not known. Note: this is not necessarily the value the induction variable will have after the loop terminates. Rather, it is the last value the induction variable will have inside the loop.


getIterationCount

public long getIterationCount()
Return the number of times the induction variable will be iterated or -1 if not known.


getStepValue

public long getStepValue()
Return the induction step value or zero if it is not known or not a constant value.


setStepExpr

public void setStepExpr(Expr step)
Set the induction step value or zero if it is not known. The step expression must be loop invariant.


getStepExpr

public Expr getStepExpr()
Return the step expression for the induction variable. Note, the value returned may be null. It is guaranteed to be loop invariant. Note - the epression returned does not have any use-def links.


isPrimary

public boolean isPrimary()
Return true if this is the primary induction variable for the loop.


markPrimary

public void markPrimary()
Specify that this induction variable is the primary induction variable for the loop.


hasForward

public boolean hasForward()
Return true if this induction variable has a forward affine expression.


markForward

public void markForward()
Specify that this induction variable has a forward affine expression.


getForwardExpr

public AffineExpr getForwardExpr()
Return the induction variable's forward affine expression.


setForwardExpr

public void setForwardExpr(AffineExpr ae)
Specify the induction variable's forward affine expression.


getName

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


moreCompleteThan

public boolean moreCompleteThan(InductionVar ivar)
Return true if this induction variable is better than the specified induction variable. Better means more useful for standard loop transformations.


clean

public void clean()
Unlink any expression referenced by theis induction variable instance.