|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectscale.common.Root
scale.score.Note
scale.score.expr.Expr
scale.score.expr.ValueExpr
scale.score.expr.LiteralExpr
public class LiteralExpr
This class represents the instantiation of a literal in Scribble.
$Id: LiteralExpr.java,v 1.97 2007-10-17 13:40:00 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
This literal can be an aggregation of scalar values, a string, or a scalar value. The literal's actual value is stored in a seperate object.
Literal| Field Summary |
|---|
| Fields inherited from class scale.score.expr.Expr |
|---|
fpReorder, SE_DOMAIN, SE_NONE, SE_OVERFLOW, SE_STATE |
| Constructor Summary | |
|---|---|
LiteralExpr(Literal literal)
This method builds an expression node with this operation as the operator. |
|
| Method Summary | |
|---|---|
Expr |
add(Type type,
Expr arg)
Return an expression that represents the addition of this expression to the argument expression. |
long |
canonical()
Return a unique value representing this particular expression. |
Expr |
copy()
Perform a deep copy of the expression tree. |
Expr |
divide(Type type,
Expr arg)
Return an expression that represents the division of this expression by the argument expression. |
boolean |
equivalent(Expr exp)
Return true if the expressions are equivalent. |
int |
executionCostEstimate()
Return a relative cost estimate for executing the expression. |
protected Chord |
findCriticalChord(HashMap<Expr,Chord> lMap,
Chord independent)
Return the Chord with the
highest label value from the set of Chords that must be executed before
this expression. |
int |
findLinearCoefficient(VariableDecl indexVar,
LoopHeaderChord thisLoop)
Determine the coefficent of a linear expression. |
protected AffineExpr |
getAffineRepresentation(HashMap<Expr,AffineExpr> affines,
LoopHeaderChord thisLoop)
Return the affine
representation for this expression. |
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. |
java.lang.String |
getDisplayLabel()
Return a String suitable for labeling this node in a graphical display. |
Literal |
getLiteral()
Return the literal associated
with this expression. |
boolean |
hasTrueFalseResult()
Return true if the result of the expression is either true (1) or false (0). |
boolean |
isLiteralExpr()
Return true if this is a literal expression. |
boolean |
isLoopInvariant(LoopHeaderChord loop)
Return true if this expression is loop invariant. |
boolean |
isOne()
Return true if the value of this literal is known to be one. |
boolean |
isSimpleExpr()
Return true if this is a simple expression. |
boolean |
isZero()
Return true if the value of this literal is known to be zero. |
Expr |
multiply(Type type,
Expr arg)
Return an expression that represents the multiplication of this expression to the argument expression. |
boolean |
optimizationCandidate()
Return true if the literal value is an atomic type. |
void |
recordRefs(Chord stmt,
References refs)
Record any variable references in this expression in the table of references. |
void |
removeRefs(Chord stmt,
References refs)
Remove any variable references in this expression from the table of references. |
boolean |
replaceDecl(Declaration oldDecl,
Declaration newDecl)
Replace all occurrances of a declaration with another declaration. |
void |
setLiteral(Literal literal)
Set the literal associated with
this expression. |
Expr |
subtract(Type type,
Expr arg)
Return an expression that represents the subtraction of the argument expression from expression. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
| Methods inherited from class scale.score.expr.ValueExpr |
|---|
getExprList, getLoadExprList, getOperandArray, numOperands, pushOperands, removeUseDef, sideEffects |
| Methods inherited from class scale.score.Note |
|---|
getChord, getEssentialUse, 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 LiteralExpr(Literal literal)
| Method Detail |
|---|
public boolean equivalent(Expr exp)
equivalent() method
of the derived classes.
equivalent in class Exprpublic Literal getLiteral()
literal associated
with this expression.
public void setLiteral(Literal literal)
literal associated with
this expression.
public Expr copy()
Expr
copy in class Exprpublic 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 NotePredicatepublic java.lang.String getDisplayLabel()
Expr
getDisplayLabel in interface DisplayNodegetDisplayLabel in class Exprpublic Literal getConstantValue(HashMap<Expr,Literal> cvMap)
getConstantValue in class ExprLatticepublic Literal getConstantValue()
getConstantValue in class ExprLattice
protected Chord findCriticalChord(HashMap<Expr,Chord> lMap,
Chord independent)
Chord with the
highest label value from the set of Chords that must be executed before
this expression.
findCriticalChord in class ExprlMap - is used to memoize the expression to critical Chord informationindependent - is returned if the expression is not dependent
on anythingpublic long canonical()
canonical in class Exprpublic boolean isLoopInvariant(LoopHeaderChord loop)
isLoopInvariant in class ValueExprloop - is the loop
public int findLinearCoefficient(VariableDecl indexVar,
LoopHeaderChord thisLoop)
findLinearCoefficient in class Expr
protected AffineExpr getAffineRepresentation(HashMap<Expr,AffineExpr> affines,
LoopHeaderChord thisLoop)
Expraffine
representation for this expression. This method should be
called only from the getAffineExpr()
method. This method never returns null.
getAffineRepresentation in class Expraffines - is a mapping from an expression to its representation
and is used to avoid combinatorial explosion through use-def
linksthisLoop - the loop for which this expression may be affineAffineExpr,
AffineExpr.notAffinepublic boolean optimizationCandidate()
optimizationCandidate in class Exprpublic int executionCostEstimate()
executionCostEstimate in class Notepublic void getDeclList(java.util.AbstractCollection<Declaration> varList)
getDeclList in class ValueExpr
public boolean replaceDecl(Declaration oldDecl,
Declaration newDecl)
declaration with another declaration. Return true if a replace
occurred.
replaceDecl in class ValueExpr
public void recordRefs(Chord stmt,
References refs)
references.
recordRefs in class ValueExpr
public void removeRefs(Chord stmt,
References refs)
references.
removeRefs in class ValueExpr
public Expr add(Type type,
Expr arg)
SubscriptExpr.lower()
public Expr subtract(Type type,
Expr arg)
SubscriptExpr.lower()
public Expr multiply(Type type,
Expr arg)
SubscriptExpr.lower()
public Expr divide(Type type,
Expr arg)
SubscriptExpr.lower()public boolean isZero()
public boolean isOne()
public boolean isSimpleExpr()
isSimpleExpr in class Exprpublic boolean isLiteralExpr()
isLiteralExpr in class Exprpublic boolean hasTrueFalseResult()
hasTrueFalseResult in class Expr
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||