|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.score.Note scale.score.expr.Expr scale.score.expr.DualExpr
public class DualExpr
A dual expression is used when there is both a "high-level" and a "low-level" representation of an expression.
$Id: DualExpr.java,v 1.67 2007-10-17 13:39:59 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Both the high-level and the low-level expressions are in-coming data edges. For example, for the subscript operation A[i], the DualExpr expression would have a SubscriptExpr in-coming data edge representing A[I]. It would also have a LoadDeclValueExpr in-coming data edge representing the load of the address of the temporary in which the address A+I*sizeof(A[i]) was placed by the low-level expression.
Field Summary |
---|
Fields inherited from class scale.score.expr.Expr |
---|
fpReorder, SE_DOMAIN, SE_NONE, SE_OVERFLOW, SE_STATE |
Constructor Summary | |
---|---|
DualExpr(Expr high,
Expr low)
Create a dual expression that has both a high- and low-level representation. |
Method Summary | |
---|---|
long |
canonical()
Return a unique value representing this particular expression. |
boolean |
containsDeclaration(Declaration decl)
Return true if this expression contains a reference to the variable. |
Expr |
copy()
Perform a deep copy of the expression tree. |
boolean |
dependsOnDeclaration(Declaration decl)
Return true if this expression's value depends on the variable. |
boolean |
equivalent(Expr exp)
Return true if the expressions are equivalent. |
int |
executionCostEstimate()
Return a relative cost estimate for executing the expression. |
SubscriptExpr |
findSubscriptExpr()
Return the SubscriptExpr that this load
uses or null if none is found. |
AliasAnnote |
getAliasAnnote()
Get the alias annotation associated with a Scribble operator. |
Literal |
getConstantValue()
Return the constant value of the expression. |
Literal |
getConstantValue(HashMap<Expr,Literal> cvMap)
Return the constant value of the expression. |
void |
getDeclList(java.util.AbstractCollection<Declaration> varList)
Add all declarations referenced in this expression to the Vector. |
DColor |
getDisplayColorHint()
Return an integer specifying the color to use for coloring this node in a graphical display. |
java.lang.String |
getDisplayLabel()
Return a String suitable for labeling this node in a graphical display. |
DShape |
getDisplayShapeHint()
Return a integer specifying a shape to use when drawing this node in a graphical display. |
Note |
getEssentialUse()
Return this Note unless it is a non-essential expression. |
void |
getExprList(Vector<Expr> expList)
Add all Expr instances in this expression to the Vector. |
Expr |
getHigh()
Return the high-level representation. |
void |
getLoadExprList(Vector<LoadExpr> expList)
Add all LoadExpr instances in this expression to the Vector. |
Expr |
getLow()
Return the low-level representation. |
Expr |
getOperand(int position)
Return the nth operand. |
Expr[] |
getOperandArray()
Return an array of the operands to the expression. |
Expr |
getReference()
Return the array associated with the subscript expression. |
boolean |
isDefined(Expr lv)
The given expression is defined if the dual expression is defined and the given expression is either the low or high level expression. |
void |
loopClean()
Clean up any loop related information. |
void |
lowerPermanently()
Replace this DualExpr with its lowered form. |
int |
numOperands()
Return the number of operands to this expression. |
boolean |
optimizationCandidate()
Return true if the expression can be moved without problems. |
void |
pushOperands(Stack<Expr> wl)
Push all of the operands of this expression on the Stack. |
void |
recordRefs(Chord stmt,
References refs)
Record any variable references in this expression in the table of reference. |
void |
removeRefs(Chord stmt,
References refs)
Remove any variable references in this expression from the table of references. |
void |
removeUseDef()
Remove any use - def links, may - use links, etc. |
boolean |
replaceDecl(Declaration oldDecl,
Declaration newDecl)
Replace all occurrances of a Declaration with another Declaration. |
protected Expr |
setOperand(Expr operand,
int position)
Set the nth operand of an expression. |
int |
sideEffects()
Return an indication of the side effects execution of this expression may cause. |
void |
unlinkExpression()
If the node is no longer needed, sever its use-def link, etc. |
void |
validate()
Check this node for validity. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
Methods inherited from class scale.score.Note |
---|
getChord, setAnnotationLevel, setReportLevel, toString |
Methods inherited from class scale.common.Root |
---|
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayName, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toStringAnnotations, toStringClass, trace, trace, trace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public DualExpr(Expr high, Expr low)
high
- the high-level representationlow
- the low-level representationMethod Detail |
---|
public boolean equivalent(Expr exp)
equivalent
in class Expr
protected Expr setOperand(Expr operand, int position)
Expr
operand
must not be
null
.
setOperand
in class Expr
operand
- - the new operandposition
- - indicates which operand
public final Expr getOperand(int position)
getOperand
in class Expr
position
- the index of the operandpublic final Expr[] getOperandArray()
getOperandArray
in class Expr
public int numOperands()
numOperands
in class Expr
public Expr copy()
Expr
copy
in class Expr
public final Expr getHigh()
public final Expr getLow()
getLow
in class Expr
public Expr getReference()
getReference
in class Expr
public java.lang.String getDisplayLabel()
Expr
getDisplayLabel
in interface DisplayNode
getDisplayLabel
in class Expr
public DColor getDisplayColorHint()
getDisplayColorHint
in interface DisplayNode
getDisplayColorHint
in class Expr
DColor
public DShape getDisplayShapeHint()
getDisplayShapeHint
in interface DisplayNode
getDisplayShapeHint
in class Expr
DShape
public boolean isDefined(Expr lv)
isDefined
in class Expr
lv
- the low or high level expression
public void visit(Predicate p)
Note
Each class has a visit(Predicate p)
method. For
example, in class ABC
:
public void visit(Predicate p) { p.visitABC(this); }and the class that implements
Predicate
has a method
public void visitABC(Note n) { ABC a = (ABC) n; ... }Thus, the class that implements
Predicate
can call
n.visit(this);where
n
is a Note
sub-class without
determining which specific sub-class n
is.
The visit pattern basically avoids implementing a large
switch
statement or defining different methods
in each class for some purpose.
visit
in class Note
Predicate
public Literal getConstantValue(HashMap<Expr,Literal> cvMap)
getConstantValue
in class Expr
Lattice
public Literal getConstantValue()
getConstantValue
in class Expr
Lattice
public long canonical()
canonical
in class Expr
public void loopClean()
loopClean
in class Expr
public void unlinkExpression()
unlinkExpression
in class Expr
public void lowerPermanently()
public boolean containsDeclaration(Declaration decl)
containsDeclaration
in class Expr
LoadExpr.setUseOriginal(boolean)
public boolean dependsOnDeclaration(Declaration decl)
dependsOnDeclaration
in class Expr
LoadExpr.setUseOriginal(boolean)
public boolean optimizationCandidate()
optimizationCandidate
in class Expr
public SubscriptExpr findSubscriptExpr()
SubscriptExpr
that this load
uses or null
if none is found. This method uses the
use-def link to find an existing SubscriptExpr
findSubscriptExpr
in class Expr
public AliasAnnote getAliasAnnote()
getAliasAnnote
in class Expr
public void getDeclList(java.util.AbstractCollection<Declaration> varList)
getDeclList
in class Expr
public void getLoadExprList(Vector<LoadExpr> expList)
getLoadExprList
in class Expr
public void getExprList(Vector<Expr> expList)
getExprList
in class Expr
public void pushOperands(Stack<Expr> wl)
pushOperands
in class Expr
public boolean replaceDecl(Declaration oldDecl, Declaration newDecl)
replaceDecl
in class Expr
public void removeUseDef()
removeUseDef
in class Expr
public void validate()
validate
in class Expr
public void recordRefs(Chord stmt, References refs)
recordRefs
in class Expr
public void removeRefs(Chord stmt, References refs)
removeRefs
in class Expr
public Note getEssentialUse()
Chord
this method returns
this
. For a DualExpr
or an address cast (e.g., ConversionExpr
) this method
returns the out data edge.
getEssentialUse
in class Note
public int executionCostEstimate()
executionCostEstimate
in class Note
public int sideEffects()
sideEffects
in class Expr
Expr.SE_NONE
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |