coins.opt
クラス CommonSubexpElimHirE

java.lang.Object
  |
  +--coins.opt.CommonSubexpElim
        |
        +--coins.opt.CommonSubexpElimHir
              |
              +--coins.opt.CommonSubexpElimHirE
直系の既知のサブクラス:
PRE

public class CommonSubexpElimHirE
extends CommonSubexpElimHir

This class performs common subexpresssion elimination operations that are specific to HIR.


フィールドの概要
protected  AliasAnal fAlias
           
protected  java.util.Set fAvailableExps
          fAvailable Set of ExpId's for currently available expressions in BBlock .
protected  java.util.Set fAvailableTemps
          fAssigned: Set of available temporal variables in BBlock.
protected  boolean fBeforePRE
           
protected  int[] fExpCost
           
protected  int fIndexMax
           
protected  int fIndexMin
           
protected  java.util.Map fLatestNodeForExpId
           
protected  RecordAlias fRecordAlias
           
protected  java.util.Set fReplacedNodes
           
protected  int fThreshold
          fThreshold Replacement threshold.
 
クラス coins.opt.CommonSubexpElimHir から継承したフィールド
fGlobalExpTempMap, fGlobalTempExpMap, hir
 
クラス coins.opt.CommonSubexpElim から継承したフィールド
fDbgLevel, fFunctionsWithoutSideEffect, flowRoot, fSubpFlow, sym, symRoot
 
コンストラクタの概要
CommonSubexpElimHirE(FlowRoot pFlowRoot, int pThreshold)
           
CommonSubexpElimHirE(FlowRoot pFlowRoot, int pThreshold, boolean pBeforePRE)
          Constructor CommonSubexpElimHirE
 
メソッドの概要
protected  void adjustAvailability(HIR pExp, Stmt pStmt, BBlock pBBlock)
          adjustAvailability Add pExp and all its subexpressions to fAvailableExps.
 boolean containsCall(HIR pHir)
           
(パッケージプライベート)  void dbg(int level, java.lang.Object pObject)
           
(パッケージプライベート)  void dbg(int level, java.lang.String pHeader, java.lang.Object pObject)
           
 boolean doBBlockLocal(BBlock pBBlock)
          Performs the common subexpression elimination within the given BBlock.
 void estimateExpCost(SubpDefinition pSubpDef)
          estimateExpCost Estimate the approximate cost of subexpressions in the HIR body of pSubpDef by formula (Exp cost) = (node cost) + (cost of subexpressions) The costs of VarNode and contents node are machineParam.costOfInstruction(MachineParam.COST_INDEX_TEMP_LOAD).
protected  HIR getLatestCall(HIR pExp, BBlock pBBlock)
           
protected  HIR getLatestNodeOfExp(HIR pExp, BBlock pBBlock)
          getLatestNodeOfExp Get the latest node having maximum node index among the nodes whose node index is less than that of pExp.
protected  void insertTheStatement(Stmt pInsertionPoint, Stmt pStmtToBeInserted)
           
protected  boolean replaceAvailableExp(HIR pExp, BBlock pBBlock, Stmt pStmt)
          replaceAvailableExp Replace the computation of pExp by a temporal variable if all of its operands are in fAvailableExps.
protected  boolean replaceExp(HIR pExp, BBlock pBBlock, Stmt pStmt)
          replaceExp Replace the computation of pExp by a temporal variable.
protected  boolean replaceTheExpression(HIR pOldExp, HIR pNewExp, BBlock pBBlock)
          replaceTheExpression Replace pOldExp with pNewExp after recording all nodes of pOldExp to fReplacedNodes so that they should not be replaced in later processing.
(パッケージプライベート)  boolean toBeExcluded(HIR pHir)
          Expressions to be excluded from replacement are FunctionExp, List, comparison expression, undecay, BlockStmt, left hand side of AssignStmt, and expressions whose type is vector/struct/union/Subp.
protected  boolean tryToEliminateExp(HIR pExp, BBlock pBBlock, Stmt pStmt)
          tryToEliminateExp //##25 Try to eliminate pExp or its subexpressions if their values are already computed in pBBlock.
protected  boolean tryToEliminateSubexp(HIR pExp, BBlock pBBlock, Stmt pStmt)
          tryToEliminateSubexp //##25 Try to eliminate subexpressions of pExp if their values are already computed in pBBlock.
protected  boolean tryToReplaceSubexp(HIR pExp, BBlock pBBlock, Stmt pStmt)
          tryToReplaceSubexp Try to replace subexpressions of pExp which is to be replaced.
 
クラス coins.opt.CommonSubexpElimHir から継承したメソッド
eliminateComplex, eliminateSimple, operandSet, recordTempExpCorrespondence, registerUseSyms, reregisterSubexps
 
クラス coins.opt.CommonSubexpElim から継承したメソッド
doBBlockLocal
 
クラス java.lang.Object から継承したメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

fAlias

protected AliasAnal fAlias

fRecordAlias

protected RecordAlias fRecordAlias

fAvailableExps

protected java.util.Set fAvailableExps
fAvailable Set of ExpId's for currently available expressions in BBlock .


fAvailableTemps

protected java.util.Set fAvailableTemps
fAssigned: Set of available temporal variables in BBlock.


fReplacedNodes

protected java.util.Set fReplacedNodes

fLatestNodeForExpId

protected java.util.Map fLatestNodeForExpId

fExpCost

protected int[] fExpCost

fIndexMin

protected int fIndexMin

fIndexMax

protected int fIndexMax

fBeforePRE

protected boolean fBeforePRE

fThreshold

protected int fThreshold
fThreshold Replacement threshold. Expressions with cost less than fThreshold are not replaced by temporal but recomputed each time.

コンストラクタの詳細

CommonSubexpElimHirE

public CommonSubexpElimHirE(FlowRoot pFlowRoot,
                            int pThreshold)

CommonSubexpElimHirE

public CommonSubexpElimHirE(FlowRoot pFlowRoot,
                            int pThreshold,
                            boolean pBeforePRE)
Constructor CommonSubexpElimHirE

パラメータ:
pBeforePRE - true if invoked as the preparatory optimization for partial redundancy elimination, false otherwise.
メソッドの詳細

doBBlockLocal

public boolean doBBlockLocal(BBlock pBBlock)
Performs the common subexpression elimination within the given BBlock. If call encountered,global variable values are assumed to be not available.

オーバーライド:
クラス CommonSubexpElim 内の doBBlockLocal
戻り値:
true if the underlying IR has changed (optimized).

tryToEliminateExp

protected boolean tryToEliminateExp(HIR pExp,
                                    BBlock pBBlock,
                                    Stmt pStmt)
tryToEliminateExp //##25 Try to eliminate pExp or its subexpressions if their values are already computed in pBBlock. Adjust available expressions at exit.

パラメータ:
pExp - expression to be examined for elimination.
pBBlock - basic block containing pExp.
pStmt - statement containing pExp.
戻り値:
true if elimination is done, false if no elimination is done.

tryToEliminateSubexp

protected boolean tryToEliminateSubexp(HIR pExp,
                                       BBlock pBBlock,
                                       Stmt pStmt)
tryToEliminateSubexp //##25 Try to eliminate subexpressions of pExp if their values are already computed in pBBlock. If pExp is HirList, then try for each list element. Availability adjustment is done for each subexpression (not for pExp).

パラメータ:
pExp - expression whose subexpression are to be examined for elimination.
pBBlock - basic block containing pExp.
pStmt - statement containing pExp.
戻り値:
true if elimination is done, false if no elimination is done.

toBeExcluded

boolean toBeExcluded(HIR pHir)
Expressions to be excluded from replacement are FunctionExp, List, comparison expression, undecay, BlockStmt, left hand side of AssignStmt, and expressions whose type is vector/struct/union/Subp.

戻り値:
true if pHir should be excluded from elimination else return false.

containsCall

public boolean containsCall(HIR pHir)

adjustAvailability

protected void adjustAvailability(HIR pExp,
                                  Stmt pStmt,
                                  BBlock pBBlock)
adjustAvailability Add pExp and all its subexpressions to fAvailableExps. If pExp modifies some variable, then remove all expressions using it as a leaf operand from fAvailableExps; and remove the variable from fAvailableTemps.

パラメータ:
pExp - Expression to be adjusted.
pStmt - Statement including pExp. //##65

replaceAvailableExp

protected boolean replaceAvailableExp(HIR pExp,
                                      BBlock pBBlock,
                                      Stmt pStmt)
replaceAvailableExp Replace the computation of pExp by a temporal variable if all of its operands are in fAvailableExps.

パラメータ:
pExp - expression to be examined for replacement.
pBBlock - basic block containing pExp.
pStmt - statement containing pExp.
戻り値:
true if actually replaced, false otherwise.

replaceExp

protected boolean replaceExp(HIR pExp,
                             BBlock pBBlock,
                             Stmt pStmt)
replaceExp Replace the computation of pExp by a temporal variable. If pExp has no corresponding temporal, generate a temporal. If the corresponding temporal is already available, just replece by it. If the corresponding temporal is not available, insert the computation of the temporal in front of pStmt and replace by it. Add the temporal to the set of availabel temporals.

パラメータ:
pExp - expression to be replaced.
pBBlock - basic block containing pExp.
pStmt - statement containing pExp.
戻り値:
true if actually replaced, false otherwise.

tryToReplaceSubexp

protected boolean tryToReplaceSubexp(HIR pExp,
                                     BBlock pBBlock,
                                     Stmt pStmt)
tryToReplaceSubexp Try to replace subexpressions of pExp which is to be replaced. (By the modification for speeding up SetRefRepr computation, this method will always return without replacing subexpressions. 0601)

パラメータ:
pExp - expression whose subexpression are to be examined for relacement.
pBBlock - basic block containing pExp.
pStmt - statement containing pExp.

replaceTheExpression

protected boolean replaceTheExpression(HIR pOldExp,
                                       HIR pNewExp,
                                       BBlock pBBlock)
replaceTheExpression Replace pOldExp with pNewExp after recording all nodes of pOldExp to fReplacedNodes so that they should not be replaced in later processing.

パラメータ:
pOldExp - expression to be replaced.
pNewExp - expression to be used in replacement.
pBBlock - basic block containing pOldExp.

insertTheStatement

protected void insertTheStatement(Stmt pInsertionPoint,
                                  Stmt pStmtToBeInserted)

getLatestNodeOfExp

protected HIR getLatestNodeOfExp(HIR pExp,
                                 BBlock pBBlock)
getLatestNodeOfExp Get the latest node having maximum node index among the nodes whose node index is less than that of pExp. It is assumed that the node index shows the order of execution within a basic block.

パラメータ:
pExp - expression to be replaced.
pBBlock - basic block containing pExp.
戻り値:
the latest node if found, null if not found.

getLatestCall

protected HIR getLatestCall(HIR pExp,
                            BBlock pBBlock)

estimateExpCost

public void estimateExpCost(SubpDefinition pSubpDef)
estimateExpCost Estimate the approximate cost of subexpressions in the HIR body of pSubpDef by formula (Exp cost) = (node cost) + (cost of subexpressions) The costs of VarNode and contents node are machineParam.costOfInstruction(MachineParam.COST_INDEX_TEMP_LOAD). The cost of nodes producing no instructions (DECAY, UNDECAY, EXP_STMT, SEQ, etc.) is 0 (child cost only). The costs of other executable nodes are 1. The node costs are recorded in fExpCost array.

パラメータ:
pSubpDef - Subprogram definition.

dbg

void dbg(int level,
         java.lang.Object pObject)

dbg

void dbg(int level,
         java.lang.String pHeader,
         java.lang.Object pObject)