coins.ir.hir
クラス SimplifyHir

java.lang.Object
  |
  +--coins.ir.hir.SimplifyHir

public class SimplifyHir
extends java.lang.Object

SimplifyHir:

 This class simplifies HIR by deleting labeled statements with
 null statement body if the label is not explicitly refered,
 in order to suppress the generation of useless basic blocks
 in converting HIR to LIR. If HIR is changed by this class,
 finishHir() is called in this class so that HIR may keep
 consistency.
 This is invoked just before HIR-to-LIR conversion by the
 compiler driver. This does nothing if the compiler option
   -coins:hirOpt=noSimplify
 is specified and pForceSimplify is false.
 It is not recommended to invoke this before HIR transformations
 such as optimization and parallelization because the simplified
 HIR may be unsuitablbe for such HIR transformations.

 Description of simplifications

 If-statement:

  (if (condition)
   (labeledStmt (thenLabel) thenPartStatement)
   (labeledStmt (elseLabel) )
   (labeledStmt (endLabel) ))
  -->
  (if (condition)
   (labeledStmt (thenLabel) thenPartStatement)
   
   (labeledStmt (endLabel) ))

  (if (condition)
   (labeledStmt (thenLabel) )
   (labeledStmt (elseLabel) elsePartStatement)
   (labeledStmt (endLabel) ))
  -->
  (if (condition)
   
   (labeledStmt (elseLabel) elsePartStatement)
   (labeledStmt (endLabel) ))

 Loop-statement:
  The general form of a loop statement is
   (loop
    LoopInitPart
    ConditionalInitPart -- usually null
    (labeledStmt (loopBackLabel)
     (expStmt ... )) -- loop-start conditionPart
    (labeledStmt (loopBodyLabel)
     (block
       ... -- loop body part
      (labeledStmt (loopStepLabel) ))
    (expStmt ... ) -- loop-end condition
    (labeledStmt (loopEndLabel) ))
  If loop-start condition is null, remove loopBodylabel
   by changing (labeledStmt (loopBodyLabel) (block ...))
            to (block ... ).
  If loopStepLabel is not explicitly refered (that is,
  the loop does not contain continue-statement), then
  (labeledStmt (loopStepLabel) ) is deleted.

 Switch-statement:
  The simplification of switch-statement is covered
  by the simplification of labeled statement.

 Labeled-satement:

  Simplify LabeledStmt having LabeledStmt as its body:

  (labelDef (lab1) (labelDef (lab2) stmtBody))
  -->
  (labelDef (lab1 lab2) stmtBody)

  (labelDef (lab1)
   (block
    (labelDef (lab2) stmtBody)
         .... ))
  -->
  (labelDef (lab1 lab2)
   (block
    stmtBody
     .... ))

 After above simplifications, change statements with multiple
 labels to statements with single label and rewrite HIR nodes
 refering erazed labels to the remaining label, that is,
  (labelDef (lab1 lab2 ... labn) stmtBody)
  -->
   (labelDef (lab1) stmtBody)
    and change references to lab2, ..., labn to lab1.


フィールドの概要
(パッケージプライベート)  boolean fChanged
           
(パッケージプライベート)  int fDbgLevel
           
(パッケージプライベート)  java.util.ArrayList fLabelDefToBeDeleted
           
(パッケージプライベート)  java.util.ArrayList fLabeledStmt
           
(パッケージプライベート)  java.util.ArrayList fLabelRef
           
(パッケージプライベート)  java.util.HashMap fReplaceLabel
           
(パッケージプライベート)  boolean fSomeSubpChanged
           
(パッケージプライベート)  java.util.ArrayList fStmtToBeDeleted
           
(パッケージプライベート)  java.util.ArrayList fStmtWithMultipleLabels
           
(パッケージプライベート)  Subp fSubp
           
(パッケージプライベート)  HirRoot hirRoot
           
(パッケージプライベート)  IoRoot ioRoot
           
 
コンストラクタの概要
SimplifyHir(HirRoot pHirRoot, boolean pForceSimplify)
           
 
メソッドの概要
(パッケージプライベート)  void deleteIfNull(LabeledStmt pStmt)
           
 void deleteUnusedLabelsOfIfStmt(IfStmt pIfStmt)
           
 void deleteUnusedLabelsOfLoopStmt(LoopStmt pLoopStmt)
           
 void recordLabelRefOfSwitchStmt(SwitchStmt pSwitchStmt)
           
(パッケージプライベート)  boolean shouldHaveLabel(LabeledStmt pStmt)
           
 void simplifyHir(Subp pSubp)
           
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

hirRoot

HirRoot hirRoot

ioRoot

IoRoot ioRoot

fSubp

Subp fSubp

fLabelDefToBeDeleted

java.util.ArrayList fLabelDefToBeDeleted

fStmtToBeDeleted

java.util.ArrayList fStmtToBeDeleted

fLabeledStmt

java.util.ArrayList fLabeledStmt

fStmtWithMultipleLabels

java.util.ArrayList fStmtWithMultipleLabels

fLabelRef

java.util.ArrayList fLabelRef

fReplaceLabel

java.util.HashMap fReplaceLabel

fChanged

boolean fChanged

fSomeSubpChanged

boolean fSomeSubpChanged

fDbgLevel

int fDbgLevel
コンストラクタの詳細

SimplifyHir

public SimplifyHir(HirRoot pHirRoot,
                   boolean pForceSimplify)
メソッドの詳細

simplifyHir

public void simplifyHir(Subp pSubp)

deleteUnusedLabelsOfIfStmt

public void deleteUnusedLabelsOfIfStmt(IfStmt pIfStmt)

deleteUnusedLabelsOfLoopStmt

public void deleteUnusedLabelsOfLoopStmt(LoopStmt pLoopStmt)

recordLabelRefOfSwitchStmt

public void recordLabelRefOfSwitchStmt(SwitchStmt pSwitchStmt)

shouldHaveLabel

boolean shouldHaveLabel(LabeledStmt pStmt)

deleteIfNull

void deleteIfNull(LabeledStmt pStmt)