|
|||||||||
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.SubscriptExpr
public class SubscriptExpr
This class represents a subscript operation which computes an address of an array element (at a high-level).
$Id: SubscriptExpr.java,v 1.140 2007-10-17 13:40:01 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Regardless of whether the source language uses row major or column major array ordering, the subscripts represented by this expression are always in row major (C style) ordering.
Field Summary |
---|
Fields inherited from class scale.score.expr.Expr |
---|
fpReorder, SE_DOMAIN, SE_NONE, SE_OVERFLOW, SE_STATE |
Constructor Summary | |
---|---|
SubscriptExpr(Type type,
Expr array,
Expr[] subscripts,
Expr[] mins,
Expr[] sizes)
|
Method Summary | |
---|---|
boolean |
addUse(Table<Declaration,SubscriptExpr> arraySubscripts)
Add this SubscriptExpr to the table if it has a
valid array reference. |
void |
addUses(java.util.AbstractCollection<Note> uses)
Add all the uses of the address, specified by this SubscriptExpr instance, to the Vector . |
void |
addUses(java.util.AbstractCollection<Note> uses,
Vector<Chord> dominated)
Add all the uses of the address, specified by this SubscriptExpr instance, to the Vector . |
Vector<LoopHeaderChord> |
allRelatedLoops()
Return loops whose indexes this subscript expression is using. |
boolean |
allSubscriptsOptimizationCandidates()
Return true if all the subscripts of the subscript expression are optimization candidates. |
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. |
boolean |
equivalentImp(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. |
Vector<Expr> |
getArguments()
Return a new vector with copies of the expression arguments. |
Expr |
getArray()
Return the expression specifying the array. |
void |
getDeclList(java.util.AbstractCollection<Declaration> varList)
Add all declarations referenced in this expression to the Vector. |
Expr |
getDimension(int i)
Return the expression representing the dimension of the i-th subscript. |
java.lang.String |
getDisplayLabel()
Return a String suitable for labeling this node in a graphical display. |
void |
getExprList(Vector<Expr> expList)
Add all Expr instances in this expression to the Vector. |
Expr |
getIndexOrigin(int i)
Return the expression representing the index origin of the i-th subscript. |
void |
getLoadExprList(Vector<LoadExpr> expList)
Add all LoadExpr instances in this expression to the Vector. |
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. |
Expr |
getSubscript(int i)
Return the expression representing the i-th subscript. |
Expr[] |
getSubscripts()
Return an enumeration of the subscripts of a subscript operator. |
boolean |
isDefined(Expr lv)
The given expression is defined if the SubscriptExpr expression is defined and the given expression is the array. |
boolean |
isUse(Note arg)
Return true if the argument is a use of the SubscriptExpr instance address. |
void |
loopClean()
Clean up any loop related information. |
Expr |
lower()
Lower the SubscriptExpr to an ArrayIndexExpr or AdditionExpr instance. |
Expr |
lowerIndex()
Lower the SubscriptExpr to just the index calculation. |
int |
numOperands()
Return the number of operands to this expression. |
int |
numSubscripts()
Return the number of subscripts to the array. |
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 references. |
protected void |
removeOperand(int i)
Allow some expressions such as VectorExpr to remove an operand. |
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. |
void |
setArray(Expr array)
Set the array expression to this expression. |
void |
setDimension(Expr size,
int i)
Set the size of the specified dimension. |
protected void |
setOperand(Expr operand)
|
Expr |
setOperand(Expr operand,
int position)
Set the nth operand of an expression. |
void |
setSubscripts(Expr index,
int i)
Set the index into the specified dimension. |
int |
sideEffects()
Return an indication of the side effects execution of this expression may cause. |
java.lang.String |
toStringSpecial()
Return any special information of a node that is not a child or annotation. |
void |
unlinkExpression()
If the node is no longer needed, sever its use-def link, etc. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
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 SubscriptExpr(Type type, Expr array, Expr[] subscripts, Expr[] mins, Expr[] sizes)
type
- must be a PointerTypearray
- is the expression node holding address of array
being subscriptedsubscripts
- is the vector of expressions representing array
subscriptsmins
- is the vector of expressions represnting the index
origin for each dimensionsizes
- is the vector of expressions representing the size
for each dimensionMethod Detail |
---|
public Expr copy()
Expr
copy
in class Expr
public Expr getArray()
public int numSubscripts()
public Expr getSubscript(int i)
public Expr getIndexOrigin(int i)
public Expr getDimension(int i)
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 java.lang.String getDisplayLabel()
Expr
getDisplayLabel
in interface DisplayNode
getDisplayLabel
in class Expr
public boolean isDefined(Expr lv)
isDefined
in class Expr
lv
- the expression reprsenting the array name
public Expr getReference()
getReference
in class Expr
public final Expr[] getOperandArray()
getOperandArray
in class Expr
public void setArray(Expr array)
public void setDimension(Expr size, int i)
size
- is the new dimension sizei
- specifies the dimensionpublic void setSubscripts(Expr index, int i)
index
- is the new dimension indexi
- specifies the dimensionprotected void setOperand(Expr operand)
public Expr setOperand(Expr operand, int position)
Expr
operand
must not be
null
.
setOperand
in class Expr
operand
- - the new operandposition
- - indicates which operand
public int numOperands()
numOperands
in class Expr
public final Expr getOperand(int position)
getOperand
in class Expr
position
- the index of the operandprotected void removeOperand(int i)
public Vector<Expr> getArguments()
public boolean equivalentImp(Expr exp)
public boolean equivalent(Expr exp)
equivalent
in class Expr
public Expr[] getSubscripts()
public boolean addUse(Table<Declaration,SubscriptExpr> arraySubscripts)
SubscriptExpr
to the table if it has a
valid array reference. A valid subscript expression is one that
dependence testing can utilize. Examples of invalid subscript
expressions include
(func(a,b))[i] strct.arr[i]
public void addUses(java.util.AbstractCollection<Note> uses)
SubscriptExpr
instance, to the Vector
.
The uses are obtained by following the use-def links.
isUse(scale.score.Note)
public void addUses(java.util.AbstractCollection<Note> uses, Vector<Chord> dominated)
SubscriptExpr
instance, to the Vector
.
The CFG nodes of uses must be in the dominated list.
The uses are obtained by following the use-def links.
isUse(scale.score.Note)
public boolean isUse(Note arg)
SubscriptExpr
instance address.
addUses(java.util.AbstractCollection)
public java.lang.String toStringSpecial()
Root
toStringSpecial
in class Expr
public Vector<LoopHeaderChord> allRelatedLoops()
public Expr lower()
ArrayIndexExpr
or AdditionExpr
instance.
Lowering may result in a sequence of CFG nodes as well as the
lowered expression. These nodes are appended to the supplied
vector in the order in which they should be in the CFG. Also,
some temporary variables may be created to hold intermediate
results. These new variable declarations are added to the
supplied vector.
public Expr lowerIndex()
public void loopClean()
loopClean
in class Expr
public void unlinkExpression()
unlinkExpression
in class Expr
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 allSubscriptsOptimizationCandidates()
public boolean optimizationCandidate()
optimizationCandidate
in class Expr
ScalarReplacement
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 recordRefs(Chord stmt, References refs)
recordRefs
in class Expr
public void removeRefs(Chord stmt, References refs)
removeRefs
in class Expr
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 |