|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||
java.lang.Object
|
+--coins.ir.hir.HIR_Impl
|
+--coins.ir.hir.StmtImpl
|
+--coins.ir.hir.LoopStmtImpl
Loop-statement class. // Components (children) of loop statement // child1: LoopInitPart. (Stmt) // This may be null. // getLoopInitPart returns this statement. // child2: ConditionalInitPart (This has been deleted. Give null.) // This is executed only once if loop condition is satisfied. // (At present, this is implemented by if-stmt attached to // LoopInitPart so that hir2lir has no need of // special treatment.) // child3: StartConditionPart with loopBackLabel. (LabeledStmt) // This should be given but its LabeledStmt may be null. // getLoopBackPoint() returns this LabeledStmt. // child4: LoopBody that is a LabeledStmt with loopBodyLabel. // StmtBody part of the LabeledStmt is BlockStmt // having LabeledStmt with loopStepLabel (LabeledStmt) // as the last statement of the loop-body BlockStmt. // An implementation of the LoopBody is // (labeledStmt // (list) // (block // sequence of statements given as pLoopBody parameter // of setChildrenOfLoop // (labeledStmt // (list ) // null))) // LoopBody should be given but its BlockStmt may have // no executable statements. // getLoopBodyPart() returns this LabeledStmt. // child5: EndCondition. (ExpStmt) // This may be null. // getLoopEndCondition() returns the expression of the ExpStmt. // child6: LoopStepPart jumping to loopBackLabel. (Stmt) // This may be null. // getLoopStepPart() returns this statement. // child7: LoopEndpart with loopEndLabel. (LabeledStmt) // This should be given but its LabeledStmt may be null. // getLoopEndPart() returns this LabeledStmt.
| フィールドの概要 | |
Label |
fLoopBackLabel
|
Label |
fLoopEndLabel
|
(パッケージプライベート) LoopInf |
fLoopInf
|
Label |
fLoopStepLabel
|
| クラス coins.ir.hir.StmtImpl から継承したフィールド |
fMultiBlock, fNextStmt, fPrevStmt |
| クラス coins.ir.hir.HIR_Impl から継承したフィールド |
fAdditionalChild, fChildCount, fChildNode1, fChildNode2, fDbgLevel, fHirAnnex, fOperator, fParentNode, fType, hirRoot, inversionTable, machineParam, sourceLanguage |
| インタフェース coins.ir.hir.HIR から継承したフィールド |
OP_CODE_NAME, OP_CODE_NAME_DENSE |
| インタフェース coins.ir.IR から継承したフィールド |
OP_INF, OP_LIST, OP_PROG, OP_SUBP_DEF |
| コンストラクタの概要 | |
LoopStmtImpl()
|
|
LoopStmtImpl(HirRoot pHirRoot)
|
|
| メソッドの概要 | |
void |
accept(HirVisitor pVisitor)
accept Acceptor used in HIR visitor. |
void |
addToConditionalInitPart(Stmt pStmt)
addToConditionalInitPart ConditionalInitPart is executed once if the LoopStartCondition is satisfied. |
void |
addToLoopBodyPart(Stmt pStmt)
Add the statement pStmt before the step-labeled statement (as the last statement except the null statement with the loop-step label). |
void |
addToLoopEndPart(Stmt pStmt)
Add pStmt as the statement next to the existing loop-end statement. |
void |
addToLoopInitPart(Stmt pStmt)
Add pStmt as the last statement of loop-init-part. |
void |
addToLoopStepPart(Stmt pStmt)
Add the statement pStmt to the loop-step part (add as the statement next to the existing statement of the loop-step part). |
java.lang.Object |
clone()
clone Override Object.clone in HIR. |
void |
combineWithConditionalExp(Stmt pStmt,
HIR pCond)
Combine pStmt with conditional expression part pCond of control statement so that pStmt should be executed before pCond. |
BlockStmt |
getConditionalInitPart()
getConditionalInitPart Get the BlockStmt containing the statements added by addToConditionalInitPart. |
Stmt |
getConditionalInitPart2()
|
Label |
getLoopBackLabel()
|
LabeledStmt |
getLoopBackPoint()
getLoopBackPoint Get the statement with loopBackLabel. |
Label |
getLoopBodyLabel()
|
Stmt |
getLoopBodyPart()
getLoopBodyPart Get the loop body that is repetitively executed. |
Exp |
getLoopEndCondition()
getLoopEndCondition Get the loop end conditional expression. |
Label |
getLoopEndLabel()
|
LabeledStmt |
getLoopEndPart()
getLoopEndPart Get the loop end part having the loopEndLabel. |
LoopInf |
getLoopInf()
This method is not used anymore. |
Stmt |
getLoopInitPart()
Get the loop initiation part that is executed before repetition. |
Exp |
getLoopStartCondition()
getLoopStartCondition Get the loop start conditional expression that has the loopBackLabel. |
Label |
getLoopStepLabel()
|
Stmt |
getLoopStepPart()
getLoopStepPart Get the loop step part that is executed before jumping to loopBackLabel. |
boolean |
isLoopStmt()
|
boolean |
isSimpleForLoop()
isSimpleForLoop Check if this is a simple for loop, that is, an instance of ForStmt and conditional init part is null and loop end condition is null. |
boolean |
isSimpleIndexedLoop()
isSimpleIndexedLoop Check if this is a simple indexed loop, that is, an instance of IndexedLoopStmt and conditional init part is null and loop end condition is null. |
boolean |
isSimpleRepeatLoop()
isSimpleRepeatLoop Check if this is a simple repeat-while-true loop, that is, an instance of RepeatStmt and conditional init part is null and loop start condition is null and loop step part is null. |
boolean |
isSimpleUntilLoop()
|
boolean |
isSimpleWhileLoop()
isSimpleWhileLoop Check if this is a simple while loop, that is, an instance of WhileStmt and conditional init part is null and loop step part is null and loop end condition is null. |
protected Stmt |
makeConditionalInitPart(Exp pStartCondition,
Stmt pConditionalInitPart)
|
void |
replaceBodyPart(LabeledStmt pNewStmt)
Replace the loop body with pNewStmt. |
void |
replaceConditionalInitPart(LabeledStmt pNewStmt)
|
void |
setChildrenOfLoop(Stmt pInitPart,
Label pLoopBackLabel,
Stmt pConditionalInitPart,
Exp pStartCondition,
Stmt pLoopBody,
Label pLoopStepLabel,
Exp pEndCondition,
Stmt pLoopStepPart,
Label pLoopEndLabel,
Stmt pLoopEndPart)
|
void |
setLoopEndCondition(Exp pCondition)
Set the expression pCondition as the loop-end condition expression. |
void |
setLoopInf(LoopInf pLoopInf)
This method is not used anymore. |
void |
setLoopStartCondition(Exp pCondition)
Set the expression pCondition as the loop-start condition expression. |
| クラス java.lang.Object から継承したメソッド |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| インタフェース coins.ir.IR から継承したメソッド |
addInf, getChild1, getChild2, getInf, getInfList, getParent, getSym, print, print, removeInf |
| インタフェース coins.ir.IR0 から継承したメソッド |
getChild, getChildCount, getIndex, getOperator, setChild |
| インタフェース coins.ir.hir.HIR0 から継承したメソッド |
assignStmt, blockStmt, callStmt, constNode, contentsExp, convExp, copyWithOperands, copyWithOperandsChangingLabels, decayExp, elemNode, exp, exp, expStmt, falseNode, finishHir, forStmt, functionExp, getChildNumber, getFlag, getFlagBox, getNextStmt, getStmtContainingThisNode, getType, hirClone, hirIterator, hirList, hirSeq, ifStmt, intConstNode, irList, isSameAs, jumpStmt, labelDef, labeledStmt, labelNode, pointedExp, print, program, qualifiedExp, repeatStmt, replaceThisNode, returnStmt, setFlag, setIndexNumberToAllNodes, sizeofExp, sizeofExp, subpDefinition, subpNode, subscriptedExp, switchStmt, symNode, trueNode, undecayExp, varNode, whileStmt |
| フィールドの詳細 |
public Label fLoopBackLabel
public Label fLoopStepLabel
public Label fLoopEndLabel
LoopInf fLoopInf
| コンストラクタの詳細 |
public LoopStmtImpl()
public LoopStmtImpl(HirRoot pHirRoot)
| メソッドの詳細 |
public void setChildrenOfLoop(Stmt pInitPart,
Label pLoopBackLabel,
Stmt pConditionalInitPart,
Exp pStartCondition,
Stmt pLoopBody,
Label pLoopStepLabel,
Exp pEndCondition,
Stmt pLoopStepPart,
Label pLoopEndLabel,
Stmt pLoopEndPart)
public Stmt getLoopInitPart()
LoopStmt の記述: Get the loop initiation part that is executed before repetition. Ex. For a loop statement for (i=0; i
- 定義:
- インタフェース
LoopStmt内のgetLoopInitPart
- 戻り値:
- the loop initiation part;
public BlockStmt getConditionalInitPart()
LoopStmt の記述:
LoopStmt 内の getConditionalInitPartpublic Stmt getConditionalInitPart2()
public Exp getLoopStartCondition()
LoopStmt の記述: Get the loop start conditional expression that has the loopBackLabel. For a loop statement for (i=0; i
- 定義:
- インタフェース
LoopStmt内のgetLoopStartCondition
- 戻り値:
- the loop start condition expression.
public LabeledStmt getLoopBackPoint()
LoopStmt の記述:
LoopStmt 内の getLoopBackPointpublic Stmt getLoopBodyPart()
LoopStmt の記述:
Get the loop body that is repetitively executed.
It is a block statement (BlockStmt)
with loop start label and the blcok
statement contains a labeled statement.
with loopStepLabel as its last statement.
For a statement
for (i = 0; i < 10; i++)
a[i] = 0;
a labeled statement
_lab6: { a[i] = 0; }
will be returned where _lab6 is a loop start label
generated by the compiler.
For a statement
while (i < 10) {
a = a + b;
if (a >= 10) {
i = i + 1;
continue;
}
i = i + 1;
}
a labeled statement
_lab10: {
a = a + b;
if (a >= 10) {
i = i + 1;
goto _lab3;
}
i = i + 1;
_lab4:
}
will be returned where _lab10 is the loop start label
and _lab4 is the loop step label generated by the compiler.
LoopStmt 内の getLoopBodyPartpublic Exp getLoopEndCondition()
LoopStmt の記述:
Get the loop end conditional expression.
For a loop statement
do { ... }
while (i>0);
the expression i>0 is returned.
For a loop statement
for (i=0; i
- 定義:
- インタフェース
LoopStmt 内の getLoopEndCondition
- 戻り値:
- the loop end condition expression.
public Stmt getLoopStepPart()
LoopStmt の記述: Get the loop step part that is executed before jumping to loopBackLabel. For a loop statement for (i=0; i
- 定義:
- インタフェース
LoopStmt内のgetLoopStepPart
- 戻り値:
- the loop step part.
public LabeledStmt getLoopEndPart()
LoopStmt の記述: Get the loop end part having the loopEndLabel. For a loop statement for (i=0; i
- 定義:
- インタフェース
LoopStmt内のgetLoopEndPart
- 戻り値:
- the loop end part having the loopEndLabel.
public Label getLoopBackLabel()
LoopStmt 内の getLoopBackLabelpublic Label getLoopBodyLabel()
LoopStmt 内の getLoopBodyLabelpublic Label getLoopStepLabel()
LoopStmt 内の getLoopStepLabelpublic Label getLoopEndLabel()
LoopStmt 内の getLoopEndLabelpublic LoopInf getLoopInf()
LoopStmt の記述:
LoopStmt 内の getLoopInfpublic void setLoopInf(LoopInf pLoopInf)
LoopStmt の記述:
LoopStmt 内の setLoopInfpublic void addToLoopInitPart(Stmt pStmt)
LoopStmt の記述:
LoopStmt 内の addToLoopInitPartpStmt - statement to be added to loop-init-part.public void addToConditionalInitPart(Stmt pStmt)
LoopStmt の記述:
ConditionalInitPart is executed once if the LoopStartCondition
is satisfied. It is a block to where loop invariant expressions
are to be moved so that they are executed only once. The
ConditionalInitPart is created by addToConditionalInitPart(pStmt)
as a block containing ConditionalInitBlock in the LoopInitPart
in the following way:
Case 1: LoopStartCondition is null:
LoopInitPart_ is changed as follows:
{
oroginal LoopInitPart_;
{ // ConditionalInitBlock.
// getConditionalInitPart() returns this else-block.
Sequence of statements added by addToConditionalInitPart;
}
}
The transformation procedure is:
If ConditionalInitBlock is not yet created,
create it as a BlockStmt and add it as the last statement
of LoopInitBlock
pStmt is added as the last statement of ConditionalInitBlock.
case 2: LoopStartCondition is not null and ConditionalInitPart
is not yet created:
LoopInitPart_ is changed as follows:
{
oroginal LoopInitPart_;
if (loopStartConditionExpression == false) {
jump to loopEndLabel;
}else { // ConditionalInitBlock.
// getConditionalInitPart() returns this else-block.
Sequence of statements added by addToConditionalInitPart;
jump to loopBodyLabel;
}
}
The else-part of above if-statement is called as
ConditionalInitBlock.
case 3: ConditionalInitBlock is already created:
pStmt is inserted before "goto loopBodyLabel" of ConditionalInitBlock.
Expressions to be executed only once for this loop
may be added to ConditionalInitBlock by calling
addToConditionalInitPart successively.
When ConditionalInitBlock with "jump to loopBodyLabel" is created,
setFlag(HIR.FLAG_LOOP_WITH_CONDITIONAL_INIT, true)
is executed to show that the loop became irreducible but
it is a tame loop that can be treated in many optimization/
parallelization procedures.
No special treatment is required for ConditionalInitPart in
HIR-to-LIR conversion, HIR-to-C conversion, HIR flow analysis,
etc. because it takes a form of normal HIR expression.
LoopStmt 内の addToConditionalInitPart
protected Stmt makeConditionalInitPart(Exp pStartCondition,
Stmt pConditionalInitPart)
public void addToLoopBodyPart(Stmt pStmt)
LoopStmt の記述:
LoopStmt 内の addToLoopBodyPartpStmt - statement to be added to the boop body.public void addToLoopStepPart(Stmt pStmt)
LoopStmt の記述:
LoopStmt 内の addToLoopStepPartpStmt - statement to be added to the loop-step part.public void addToLoopEndPart(Stmt pStmt)
LoopStmt の記述:
LoopStmt 内の addToLoopEndPartpStmt - statement to be added to the loop-end part.public void setLoopStartCondition(Exp pCondition)
LoopStmt の記述:
LoopStmt 内の setLoopStartConditionpCondition - expression to be set.public void setLoopEndCondition(Exp pCondition)
LoopStmt の記述:
LoopStmt 内の setLoopEndConditionpCondition - expression to be set.
public void replaceConditionalInitPart(LabeledStmt pNewStmt)
throws CompileError
CompileErrorpublic void replaceBodyPart(LabeledStmt pNewStmt)
LoopStmt の記述:
LoopStmt 内の replaceBodyPartpNewStmt - statement to be set as the new
loop body statement.public boolean isSimpleForLoop()
LoopStmt の記述:
Check if this is a simple for loop, that is,
an instance of ForStmt and
conditional init part is null and
loop end condition is null.
LoopStmt 内の isSimpleForLooppublic boolean isSimpleWhileLoop()
LoopStmt の記述:
Check if this is a simple while loop, that is,
an instance of WhileStmt and
conditional init part is null and
loop step part is null and
loop end condition is null.
LoopStmt 内の isSimpleWhileLooppublic boolean isSimpleRepeatLoop()
LoopStmt の記述:
Check if this is a simple repeat-while-true loop, that is,
an instance of RepeatStmt and
conditional init part is null and
loop start condition is null and
loop step part is null.
LoopStmt 内の isSimpleRepeatLooppublic boolean isSimpleUntilLoop()
public boolean isSimpleIndexedLoop()
LoopStmt の記述:
Check if this is a simple indexed loop, that is,
an instance of IndexedLoopStmt and
conditional init part is null and
loop end condition is null.
LoopStmt 内の isSimpleIndexedLooppublic boolean isLoopStmt()
StmtImpl 内の isLoopStmt
public void combineWithConditionalExp(Stmt pStmt,
HIR pCond)
Stmt 内の combineWithConditionalExpStmtImpl 内の combineWithConditionalExppStmt - statement to be executed before pCond.pCond - conditional expression to be combined with pStmt.
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
HIR_Impl の記述:
StmtImpl 内の clonejava.lang.CloneNotSupportedExceptionpublic void accept(HirVisitor pVisitor)
HIR0 の記述:
HIR0 内の acceptHIR_Impl 内の acceptpVisitor - HirVisitor
|
||||||||||
| 前のクラス 次のクラス | フレームあり フレームなし | |||||||||
| 概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド | |||||||||