scale.backend
Class ICEstimator

java.lang.Object
  extended by scale.backend.ICEstimator
All Implemented Interfaces:
Predicate
Direct Known Subclasses:
TripsLoopICEstimator

public class ICEstimator
extends java.lang.Object
implements Predicate

This class is the base class for code size estimators.

$Id: ICEstimator.java,v 1.19 2007-03-21 13:31:45 burrill Exp $

Copyright 2007 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.

This class is intended to be used as the base class for the estimator for any architecture that requires instruction count estimates prior to code generation. This class provides a rough estimate only.

The estimator works by visiting every in-coming data edge of a specified node. It does not follow CFG edges. To obtain the cost of a CFG node, call the estimate() method with the node as the argument. The estimate() method can also be applied to an expression. In this case, the estimate for the specified expression sub-tree will be computed.

NOTE - to facilitate obtaining the estimate for a CFG or a sub-graph of a CFG, the resetEstimate() method is provided. The estimate returned by any method is always the sum of the individual estimates between calls to reset().


Field Summary
protected  int estimate
          The current estimate.
protected  Machine machine
          Machine specific information.
 
Constructor Summary
ICEstimator(Machine machine)
          This class is used to convert the Scribble CFG to machine instructions.
 
Method Summary
 int estimate(Note n)
          Compute an estimate and return the current estimate.
 int getEstimate()
          Return the current estimate.
 int getEstimateAndReset()
          Return the estimate and reset it to zero.
 Machine getMachine()
          Return the machine definition in use.
 void resetEstimate()
          Set the estimate to zero.
 void setEstimate(int estimate)
          Set the estimate.
 void visitAbsoluteValueExpr(AbsoluteValueExpr e)
           
 void visitAdditionExpr(AdditionExpr e)
           
 void visitAllocateExpr(AllocateExpr e)
           
 void visitAndExpr(AndExpr e)
           
 void visitArrayIndexExpr(ArrayIndexExpr e)
           
 void visitBeginChord(BeginChord c)
           
 void visitBinaryExpr(BinaryExpr e)
           
 void visitBitAndExpr(BitAndExpr e)
           
 void visitBitComplementExpr(BitComplementExpr e)
           
 void visitBitOrExpr(BitOrExpr e)
           
 void visitBitShiftExpr(BitShiftExpr e)
           
 void visitBitXorExpr(BitXorExpr e)
           
 void visitBranchChord(BranchChord c)
           
 void visitCallExpr(CallExpr e)
           
 void visitCallFunctionExpr(CallFunctionExpr e)
           
 void visitCallMethodExpr(CallMethodExpr e)
           
 void visitChord(Chord c)
           
 void visitCompareExpr(CompareExpr e)
           
 void visitComplexValueExpr(ComplexValueExpr e)
           
 void visitConditionalExpr(ConditionalExpr e)
           
 void visitConversionExpr(ConversionExpr e)
           
 void visitDecisionChord(DecisionChord c)
           
 void visitDivisionExpr(DivisionExpr e)
           
 void visitDualExpr(DualExpr e)
           
 void visitEndChord(EndChord c)
           
 void visitEqualityExpr(EqualityExpr e)
           
 void visitExitChord(ExitChord c)
           
 void visitExponentiationExpr(ExponentiationExpr e)
           
 void visitExpr(Expr e)
           
 void visitExprChord(ExprChord c)
           
 void visitExprPhiExpr(ExprPhiExpr e)
           
 void visitGotoChord(GotoChord c)
           
 void visitGreaterEqualExpr(GreaterEqualExpr e)
           
 void visitGreaterExpr(GreaterExpr e)
           
 void visitIfThenElseChord(IfThenElseChord c)
           
 void visitLeaveChord(LeaveChord c)
           
 void visitLessEqualExpr(LessEqualExpr e)
           
 void visitLessExpr(LessExpr e)
           
 void visitLiteralExpr(LiteralExpr e)
           
 void visitLoadDeclAddressExpr(LoadDeclAddressExpr e)
           
 void visitLoadDeclValueExpr(LoadDeclValueExpr e)
           
 void visitLoadExpr(LoadExpr e)
           
 void visitLoadFieldAddressExpr(LoadFieldAddressExpr e)
           
 void visitLoadFieldValueExpr(LoadFieldValueExpr e)
           
 void visitLoadValueIndirectExpr(LoadValueIndirectExpr e)
           
 void visitLoopExitChord(LoopExitChord c)
           
 void visitLoopHeaderChord(LoopHeaderChord c)
           
 void visitLoopInitChord(LoopInitChord c)
           
 void visitLoopPreHeaderChord(LoopPreHeaderChord c)
           
 void visitLoopTailChord(LoopTailChord c)
           
 void visitMarkerChord(MarkerChord c)
           
 void visitMaxExpr(MaxExpr e)
           
 void visitMinExpr(MinExpr e)
           
 void visitMultiplicationExpr(MultiplicationExpr e)
           
 void visitNaryExpr(NaryExpr e)
           
 void visitNegativeExpr(NegativeExpr e)
           
 void visitNilExpr(NilExpr e)
           
 void visitNote(Note n)
           
 void visitNotEqualExpr(NotEqualExpr e)
           
 void visitNotExpr(NotExpr e)
           
 void visitNullChord(NullChord c)
           
 void visitOrExpr(OrExpr e)
           
 void visitPhiExpr(PhiExpr e)
           
 void visitPhiExprChord(PhiExprChord c)
           
 void visitRemainderExpr(RemainderExpr e)
           
 void visitReturnChord(ReturnChord c)
           
 void visitSequentialChord(SequentialChord c)
           
 void visitSubscriptExpr(SubscriptExpr e)
           
 void visitSubtractionExpr(SubtractionExpr e)
           
 void visitSwitchChord(SwitchChord c)
           
 void visitTernaryExpr(TernaryExpr e)
           
 void visitTranscendental2Expr(Transcendental2Expr e)
           
 void visitTranscendentalExpr(TranscendentalExpr e)
           
 void visitUnaryExpr(UnaryExpr e)
           
 void visitVaArgExpr(VaArgExpr e)
           
 void visitVaEndExpr(VaEndExpr e)
           
 void visitValueExpr(ValueExpr e)
           
 void visitVarArgExpr(VarArgExpr e)
           
 void visitVaStartExpr(VaStartExpr e)
           
 void visitVectorExpr(VectorExpr e)
           
protected  void whatIsThis(Note n)
          Generate an error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

machine

protected Machine machine
Machine specific information.


estimate

protected int estimate
The current estimate.

Constructor Detail

ICEstimator

public ICEstimator(Machine machine)
This class is used to convert the Scribble CFG to machine instructions.

Parameters:
machine - specifies the target architecture
Method Detail

estimate

public int estimate(Note n)
Compute an estimate and return the current estimate.

See Also:
resetEstimate()

getMachine

public final Machine getMachine()
Return the machine definition in use.


getEstimate

public final int getEstimate()
Return the current estimate.


getEstimateAndReset

public final int getEstimateAndReset()
Return the estimate and reset it to zero.


setEstimate

public final void setEstimate(int estimate)
Set the estimate.


resetEstimate

public final void resetEstimate()
Set the estimate to zero.


whatIsThis

protected void whatIsThis(Note n)
Generate an error.


visitLoadDeclAddressExpr

public void visitLoadDeclAddressExpr(LoadDeclAddressExpr e)
Specified by:
visitLoadDeclAddressExpr in interface Predicate

visitLoadValueIndirectExpr

public void visitLoadValueIndirectExpr(LoadValueIndirectExpr e)
Specified by:
visitLoadValueIndirectExpr in interface Predicate

visitLoadDeclValueExpr

public void visitLoadDeclValueExpr(LoadDeclValueExpr e)
Specified by:
visitLoadDeclValueExpr in interface Predicate

visitLoadFieldAddressExpr

public void visitLoadFieldAddressExpr(LoadFieldAddressExpr e)
Specified by:
visitLoadFieldAddressExpr in interface Predicate

visitLoadFieldValueExpr

public void visitLoadFieldValueExpr(LoadFieldValueExpr e)
Specified by:
visitLoadFieldValueExpr in interface Predicate

visitArrayIndexExpr

public void visitArrayIndexExpr(ArrayIndexExpr e)
Specified by:
visitArrayIndexExpr in interface Predicate

visitBeginChord

public void visitBeginChord(BeginChord c)
Specified by:
visitBeginChord in interface Predicate

visitEndChord

public void visitEndChord(EndChord c)
Specified by:
visitEndChord in interface Predicate

visitExitChord

public void visitExitChord(ExitChord c)
Specified by:
visitExitChord in interface Predicate

visitReturnChord

public void visitReturnChord(ReturnChord c)
Specified by:
visitReturnChord in interface Predicate

visitSwitchChord

public void visitSwitchChord(SwitchChord c)
Specified by:
visitSwitchChord in interface Predicate

visitExprChord

public void visitExprChord(ExprChord c)
Specified by:
visitExprChord in interface Predicate

visitIfThenElseChord

public void visitIfThenElseChord(IfThenElseChord c)
Specified by:
visitIfThenElseChord in interface Predicate

visitAbsoluteValueExpr

public void visitAbsoluteValueExpr(AbsoluteValueExpr e)
Specified by:
visitAbsoluteValueExpr in interface Predicate

visitAdditionExpr

public void visitAdditionExpr(AdditionExpr e)
Specified by:
visitAdditionExpr in interface Predicate

visitAndExpr

public void visitAndExpr(AndExpr e)
Specified by:
visitAndExpr in interface Predicate

visitBitAndExpr

public void visitBitAndExpr(BitAndExpr e)
Specified by:
visitBitAndExpr in interface Predicate

visitBitComplementExpr

public void visitBitComplementExpr(BitComplementExpr e)
Specified by:
visitBitComplementExpr in interface Predicate

visitBitOrExpr

public void visitBitOrExpr(BitOrExpr e)
Specified by:
visitBitOrExpr in interface Predicate

visitBitXorExpr

public void visitBitXorExpr(BitXorExpr e)
Specified by:
visitBitXorExpr in interface Predicate

visitOrExpr

public void visitOrExpr(OrExpr e)
Specified by:
visitOrExpr in interface Predicate

visitCompareExpr

public void visitCompareExpr(CompareExpr e)
Specified by:
visitCompareExpr in interface Predicate

visitDivisionExpr

public void visitDivisionExpr(DivisionExpr e)
Specified by:
visitDivisionExpr in interface Predicate

visitMultiplicationExpr

public void visitMultiplicationExpr(MultiplicationExpr e)
Specified by:
visitMultiplicationExpr in interface Predicate

visitRemainderExpr

public void visitRemainderExpr(RemainderExpr e)
Specified by:
visitRemainderExpr in interface Predicate

visitNegativeExpr

public void visitNegativeExpr(NegativeExpr e)
Specified by:
visitNegativeExpr in interface Predicate

visitNotExpr

public void visitNotExpr(NotExpr e)
Specified by:
visitNotExpr in interface Predicate

visitExponentiationExpr

public void visitExponentiationExpr(ExponentiationExpr e)
Specified by:
visitExponentiationExpr in interface Predicate

visitTranscendentalExpr

public void visitTranscendentalExpr(TranscendentalExpr e)
Specified by:
visitTranscendentalExpr in interface Predicate

visitTranscendental2Expr

public void visitTranscendental2Expr(Transcendental2Expr e)
Specified by:
visitTranscendental2Expr in interface Predicate

visitSubtractionExpr

public void visitSubtractionExpr(SubtractionExpr e)
Specified by:
visitSubtractionExpr in interface Predicate

visitBitShiftExpr

public void visitBitShiftExpr(BitShiftExpr e)
Specified by:
visitBitShiftExpr in interface Predicate

visitCallMethodExpr

public void visitCallMethodExpr(CallMethodExpr e)
Specified by:
visitCallMethodExpr in interface Predicate

visitCallFunctionExpr

public void visitCallFunctionExpr(CallFunctionExpr e)
Specified by:
visitCallFunctionExpr in interface Predicate

visitComplexValueExpr

public void visitComplexValueExpr(ComplexValueExpr e)
Specified by:
visitComplexValueExpr in interface Predicate

visitConversionExpr

public void visitConversionExpr(ConversionExpr e)
Specified by:
visitConversionExpr in interface Predicate

visitDualExpr

public void visitDualExpr(DualExpr e)
Specified by:
visitDualExpr in interface Predicate

visitEqualityExpr

public void visitEqualityExpr(EqualityExpr e)
Specified by:
visitEqualityExpr in interface Predicate

visitGreaterEqualExpr

public void visitGreaterEqualExpr(GreaterEqualExpr e)
Specified by:
visitGreaterEqualExpr in interface Predicate

visitGreaterExpr

public void visitGreaterExpr(GreaterExpr e)
Specified by:
visitGreaterExpr in interface Predicate

visitLessEqualExpr

public void visitLessEqualExpr(LessEqualExpr e)
Specified by:
visitLessEqualExpr in interface Predicate

visitLessExpr

public void visitLessExpr(LessExpr e)
Specified by:
visitLessExpr in interface Predicate

visitNotEqualExpr

public void visitNotEqualExpr(NotEqualExpr e)
Specified by:
visitNotEqualExpr in interface Predicate

visitLeaveChord

public void visitLeaveChord(LeaveChord c)

visitLiteralExpr

public void visitLiteralExpr(LiteralExpr e)
Specified by:
visitLiteralExpr in interface Predicate

visitNilExpr

public void visitNilExpr(NilExpr e)
Specified by:
visitNilExpr in interface Predicate

visitVaStartExpr

public void visitVaStartExpr(VaStartExpr e)
Specified by:
visitVaStartExpr in interface Predicate

visitVaArgExpr

public void visitVaArgExpr(VaArgExpr e)
Specified by:
visitVaArgExpr in interface Predicate

visitAllocateExpr

public void visitAllocateExpr(AllocateExpr e)
Specified by:
visitAllocateExpr in interface Predicate

visitBinaryExpr

public void visitBinaryExpr(BinaryExpr e)

visitBranchChord

public void visitBranchChord(BranchChord c)

visitCallExpr

public void visitCallExpr(CallExpr e)

visitChord

public void visitChord(Chord c)

visitDecisionChord

public void visitDecisionChord(DecisionChord c)

visitExpr

public void visitExpr(Expr e)

visitExprPhiExpr

public void visitExprPhiExpr(ExprPhiExpr e)
Specified by:
visitExprPhiExpr in interface Predicate

visitLoadExpr

public void visitLoadExpr(LoadExpr e)

visitMaxExpr

public void visitMaxExpr(MaxExpr e)
Specified by:
visitMaxExpr in interface Predicate

visitMinExpr

public void visitMinExpr(MinExpr e)
Specified by:
visitMinExpr in interface Predicate

visitNaryExpr

public void visitNaryExpr(NaryExpr e)

visitNote

public void visitNote(Note n)

visitMarkerChord

public void visitMarkerChord(MarkerChord c)
Specified by:
visitMarkerChord in interface Predicate

visitGotoChord

public void visitGotoChord(GotoChord c)
Specified by:
visitGotoChord in interface Predicate

visitLoopExitChord

public void visitLoopExitChord(LoopExitChord c)
Specified by:
visitLoopExitChord in interface Predicate

visitLoopHeaderChord

public void visitLoopHeaderChord(LoopHeaderChord c)
Specified by:
visitLoopHeaderChord in interface Predicate

visitLoopPreHeaderChord

public void visitLoopPreHeaderChord(LoopPreHeaderChord c)
Specified by:
visitLoopPreHeaderChord in interface Predicate

visitLoopTailChord

public void visitLoopTailChord(LoopTailChord c)
Specified by:
visitLoopTailChord in interface Predicate

visitLoopInitChord

public void visitLoopInitChord(LoopInitChord c)
Specified by:
visitLoopInitChord in interface Predicate

visitNullChord

public void visitNullChord(NullChord c)
Specified by:
visitNullChord in interface Predicate

visitPhiExpr

public void visitPhiExpr(PhiExpr e)
Specified by:
visitPhiExpr in interface Predicate

visitPhiExprChord

public void visitPhiExprChord(PhiExprChord c)
Specified by:
visitPhiExprChord in interface Predicate

visitSequentialChord

public void visitSequentialChord(SequentialChord c)

visitSubscriptExpr

public void visitSubscriptExpr(SubscriptExpr e)
Specified by:
visitSubscriptExpr in interface Predicate

visitTernaryExpr

public void visitTernaryExpr(TernaryExpr e)

visitUnaryExpr

public void visitUnaryExpr(UnaryExpr e)

visitValueExpr

public void visitValueExpr(ValueExpr e)

visitVarArgExpr

public void visitVarArgExpr(VarArgExpr e)

visitVaEndExpr

public void visitVaEndExpr(VaEndExpr e)
Specified by:
visitVaEndExpr in interface Predicate

visitVectorExpr

public void visitVectorExpr(VectorExpr e)
Specified by:
visitVectorExpr in interface Predicate

visitConditionalExpr

public void visitConditionalExpr(ConditionalExpr e)
Specified by:
visitConditionalExpr in interface Predicate