coins.opt
Class LoopUnrolling

java.lang.Object
  extended bycoins.opt.LoopExpansion
      extended bycoins.opt.LoopUnrolling

public class LoopUnrolling
extends LoopExpansion

title: LoopUnrolling class. description: Expand LoopStmt.


Field Summary
protected  int fExpRate
          Optimize option: Rate of loop unrolling; expand count of loop body.
protected  int fNodeCountMultipliedByExpFactor
           
protected  int fUpperLimitOfExpansionFactor
           
 
Fields inherited from class coins.opt.LoopExpansion
fDbgLevel, flowRoot, fMaxAllowableNodesInLoopBody, fNumberOfGeneralRegisters, fOptionMap, fOptions, hirRoot, ioRoot, symRoot
 
Constructor Summary
LoopUnrolling(HirRoot phirRoot)
          Construct this object.
LoopUnrolling(HirRoot pHirRoot, int pExpansionFactor, int pMaxAllowableNodesInLoopBody, int pNodeCountMultipliedByExpFactor)
          Constructor specifying loop unrolling parameters.
 
Method Summary
protected  int computeExpansionFactor(LoopStmt pLoopStmt)
           
 boolean doSubprogram(SubpDefinition pSubpDef)
          Do Loop Expansion optimization in subprogram.
protected  void expandLoop(ForStmt pForStmt)
           
 int getExpRate()
          Get the rate of loop unrolling; expand count of loop body.
protected  Exp getStepExp(Stmt pStmt)
          Generate Exp of step in pBlock it is called to get Exp which represents amount of increase of Loop-control-variable in Loop-step-part.
protected  Exp integralPromotion(int pOperator, Exp pOperand1)
           
protected  Exp integralPromotion(int pOperator, Exp pOperand1, Exp pOperand2)
           
protected  boolean isBadElement(HIR hirElement)
          Check whether hir element is bad for loop expansion, is follows CallStmt volatiled sym and JumpStmt at loop expand optimization.
protected  boolean isExpansible(ForStmt pForStmt)
          Check whether loop-unrolling optimization can be applied to pForStmt The Loop-control-variable is set to fLoopVar.
 boolean isSIMD()
          Get Optimize option considering SIMD environment.
protected  AssignStmt makeAssignStmt(Var pVariable, Exp pExp)
           
protected  Stmt mergeAssignStmt(Stmt pStmt, Const pStepConst)
          Applies merge-assingment optimization to pStepConst.
protected  void pickUpVariables(ForStmt pForStmt)
          Analyze variables contained in ForStmt to get information to doing Loop expansion optimization.
protected  HIR replaceExpAdjustingType(Exp lOld, Exp lNew)
          Replace expression lOld by lNew adjusting type to that of lOld.
 void setExpRate(int pRate)
          Set the rate of loop unrolling; expand count of loop body.
 void setSIMD_Environment(boolean isSIMD)
          Set Optimize option by Considering SIMD environment.
protected  Type typeForArithmeticExp(Type pType)
           
 
Methods inherited from class coins.opt.LoopExpansion
calcStatementCount, getArrayVar, getDebug, getMaxAllowableStmtsInLoopBody, getSimpleExp, getSubscriptVar, hasBadElement, setMaxAllowableStmtsInLoopBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fExpRate

protected int fExpRate
Optimize option: Rate of loop unrolling; expand count of loop body.


fUpperLimitOfExpansionFactor

protected int fUpperLimitOfExpansionFactor

fNodeCountMultipliedByExpFactor

protected int fNodeCountMultipliedByExpFactor
Constructor Detail

LoopUnrolling

public LoopUnrolling(HirRoot phirRoot)
Construct this object.

Parameters:
phirRoot - HirRoot object.

LoopUnrolling

public LoopUnrolling(HirRoot pHirRoot,
                     int pExpansionFactor,
                     int pMaxAllowableNodesInLoopBody,
                     int pNodeCountMultipliedByExpFactor)
Constructor specifying loop unrolling parameters.

Parameters:
pHirRoot - HirRoot instance.
pExpansionFactor - upper limit of loop expansion factor.
pMaxAllowableNodesInLoopBody - maximum number of allowable nodes in loop body.
pNodeCountMultipliedByExpFactor - upper limit of the number of nodes in loop body after loop expansion.
Method Detail

isSIMD

public boolean isSIMD()
Get Optimize option considering SIMD environment.

Returns:
true if Optimize is to be considered SIMD environment, false if else.

setSIMD_Environment

public void setSIMD_Environment(boolean isSIMD)
Set Optimize option by Considering SIMD environment.

Parameters:
isSIMD - Optimize by considering SIMD environment.

getExpRate

public int getExpRate()
Get the rate of loop unrolling; expand count of loop body.

Returns:
Rate of loop unrolling; expand count of loop body.

setExpRate

public void setExpRate(int pRate)
Set the rate of loop unrolling; expand count of loop body.

Parameters:
pRate - Rate of loop unrolling; expand count of loop body. it is allowed more than 2.

doSubprogram

public boolean doSubprogram(SubpDefinition pSubpDef)
Do Loop Expansion optimization in subprogram.

Specified by:
doSubprogram in class LoopExpansion
Parameters:
pSubpDef - SubpDefinition to do optimization.
Returns:
true if optimized, false if else.

pickUpVariables

protected void pickUpVariables(ForStmt pForStmt)
Analyze variables contained in ForStmt to get information to doing Loop expansion optimization.

Parameters:
pForStmt - ForStmt to be analyzed.

isExpansible

protected boolean isExpansible(ForStmt pForStmt)
Check whether loop-unrolling optimization can be applied to pForStmt The Loop-control-variable is set to fLoopVar. if Loop-control-variable is not found, it is set to null.

Parameters:
pForStmt - ForStmt object.
Returns:
true pForStmt may be optimized by Loop-if expansion. false pForStmt is not optimized by Loop-if expansion.

expandLoop

protected void expandLoop(ForStmt pForStmt)

getStepExp

protected Exp getStepExp(Stmt pStmt)
Generate Exp of step in pBlock it is called to get Exp which represents amount of increase of Loop-control-variable in Loop-step-part.

Returns:
Exp which represents amount of increase of Loop-control-variable in Loop-step-part.

mergeAssignStmt

protected Stmt mergeAssignStmt(Stmt pStmt,
                               Const pStepConst)
Applies merge-assingment optimization to pStepConst. 'a + i' to 'a + i + ( i + step ) + ( i + step*2 ) + ...'

Parameters:
pStmt - Stmt object
pStepConst - Const object which represents increase in loop step
Returns:
Stmt which is marged assginments.

isBadElement

protected boolean isBadElement(HIR hirElement)
Check whether hir element is bad for loop expansion, is follows CallStmt volatiled sym and JumpStmt at loop expand optimization.

Overrides:
isBadElement in class LoopExpansion
Returns:
true if Stmt contains CallStmt, false if else.

computeExpansionFactor

protected int computeExpansionFactor(LoopStmt pLoopStmt)

integralPromotion

protected Exp integralPromotion(int pOperator,
                                Exp pOperand1,
                                Exp pOperand2)

integralPromotion

protected Exp integralPromotion(int pOperator,
                                Exp pOperand1)

makeAssignStmt

protected AssignStmt makeAssignStmt(Var pVariable,
                                    Exp pExp)

typeForArithmeticExp

protected Type typeForArithmeticExp(Type pType)

replaceExpAdjustingType

protected HIR replaceExpAdjustingType(Exp lOld,
                                      Exp lNew)
Replace expression lOld by lNew adjusting type to that of lOld.

Parameters:
lOld - old expression to be replaced.
lNew - new expression for replacement.
Returns:
replaced expression.