|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.dms.kjc.sir.lowering.LoopIterInfo
public class LoopIterInfo
Information about loops with fixed number of iterations.
This class was originally part of Unroller but is now used by other classes. It deals with loops that are run for a fixed number of iterations.
For our purposes, so far, we identifu a loop with a fixed number of iterations
by looking for a for
loop where a local variable is initialized to a constant,
that same local variable is added to / subtracted from / multiplied by / divided by a constant,
and the termination condition is given by comparison to a constant.
Ths code in this class does not check whether the induction variable is modified in the loop body. That check is left for the user to perform.
Field Summary |
---|
Fields inherited from interface at.dms.kjc.Constants |
---|
CMP_VERSION, JAV_CLASS, JAV_CLONE, JAV_CLONEABLE, JAV_CONSTRUCTOR, JAV_ERROR, JAV_EXCEPTION, JAV_INIT, JAV_LENGTH, JAV_NAME_SEPARATOR, JAV_OBJECT, JAV_OUTER_THIS, JAV_RUNTIME, JAV_RUNTIME_EXCEPTION, JAV_STATIC_INIT, JAV_STRING, JAV_STRINGBUFFER, JAV_THIS, JAV_THROWABLE, OPE_BAND, OPE_BNOT, OPE_BOR, OPE_BSR, OPE_BXOR, OPE_EQ, OPE_GE, OPE_GT, OPE_LE, OPE_LNOT, OPE_LT, OPE_MINUS, OPE_NE, OPE_PERCENT, OPE_PLUS, OPE_POSTDEC, OPE_POSTINC, OPE_PREDEC, OPE_PREINC, OPE_SIMPLE, OPE_SL, OPE_SLASH, OPE_SR, OPE_STAR, TID_ARRAY, TID_BIT, TID_BOOLEAN, TID_BYTE, TID_CHAR, TID_CLASS, TID_DOUBLE, TID_FLOAT, TID_INT, TID_LONG, TID_SHORT, TID_VECTOR, TID_VOID, VECTOR_EMPTY |
Method Summary | |
---|---|
int |
getFinalVal()
The one past final value of the induction variable that would cause looping. |
int |
getIncrVal()
The increment. |
int |
getInitVal()
The initial value of the induction variable. |
boolean |
getIsDeclaredInInit()
Whether the induction variable is declared in the initialization statement |
static LoopIterInfo |
getLoopInfo(JStatement init,
JExpression cond,
JStatement incr,
JStatement body,
Map<JLocalVariable,JExpression> values,
Map<JLocalVariable,JLiteral> constants)
Get unroll info for this loop. |
static int |
getNumIterations(LoopIterInfo info)
Returns how many times a for loop with unroll info info will
execute. |
int |
getOper()
The operation that is being used to change the induction variable. |
JLocalVariable |
getVar()
The induction variable in the loop. |
static int |
incrementCounter(int counter,
LoopIterInfo info)
Given the UnrollInfo info and that counter was the old
value of the count, returns the new value of the count for one loop iteration. |
static boolean |
inRange(int counter,
LoopIterInfo info)
Determines if integer value counter is within the loop bounds
given by info . |
static JStatement |
makeIncrAssignment(LoopIterInfo info,
int num)
Return an assignment statement (ExpressionStatement(AssignmentExpression)) to increment (+,-,*,/) the induction variable by num . |
static JExpression |
makeIncreased(LoopIterInfo info,
int num)
Return a JExpression that corresponds performing the loop increment operation num times on the loop induction variable. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public JLocalVariable getVar()
public int getInitVal()
public int getFinalVal()
public int getOper()
public int getIncrVal()
public boolean getIsDeclaredInInit()
public static boolean inRange(int counter, LoopIterInfo info)
counter
is within the loop bounds
given by info
.
counter
- info
-
public static int incrementCounter(int counter, LoopIterInfo info)
info
and that counter
was the old
value of the count, returns the new value of the count for one loop iteration.
Does not check whether new value is in bounds.
counter
- info
-
public static JStatement makeIncrAssignment(LoopIterInfo info, int num)
num
.
info
- num
-
public static JExpression makeIncreased(LoopIterInfo info, int num)
num
times on the loop induction variable.
For some reason the caller had to deal with the stride.
Used in unrolling loops.
info
- the LoopIterInfonum
-
public static LoopIterInfo getLoopInfo(JStatement init, JExpression cond, JStatement incr, JStatement body, Map<JLocalVariable,JExpression> values, Map<JLocalVariable,JLiteral> constants)
Right now, we check that:
We do not check that the induction variable is unmodified in the loop.
This will return null
if the loop can not be unrolled.
init
- the initialization statement of the for
loopcond
- the termination condition expressionincr
- the statement updating the induction variable of the loop.body
- the loop body (not currently used)values
- can specify the initial value of the induction variable
if it is not set up in the init statement (but setting up
in the init statement will override)constants
- can specify the initial value of the induction variable
if the init statement assigns to a variable but that variable
is not the induction variable (ask Jasper I don't know --- AD)
public static int getNumIterations(LoopIterInfo info)
info
will
execute.
Returns -1 if the input is null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |