scale.score.expr
Class LoadExpr

java.lang.Object
  extended by scale.common.Root
      extended by scale.score.Note
          extended by scale.score.expr.Expr
              extended by scale.score.expr.LoadExpr
All Implemented Interfaces:
AnnotationInterface, DisplayNode
Direct Known Subclasses:
LoadDeclAddressExpr, LoadDeclValueExpr

public abstract class LoadExpr
extends Expr

This class is the base class for expressions that represent references to memory.

$Id: LoadExpr.java,v 1.90 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 class represents use-def chains.


Field Summary
 
Fields inherited from class scale.score.expr.Expr
fpReorder, SE_DOMAIN, SE_NONE, SE_OVERFLOW, SE_STATE
 
Constructor Summary
protected LoadExpr()
           
  LoadExpr(Type t, Declaration decl)
           
 
Method Summary
 void addMayUse(MayUse mayUse)
          Add may use information to the load expression.
 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.
abstract  Expr copyNoUD()
          Make a copy of this load expression without the use - def information.
 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.
 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.
 Declaration getDecl()
          Return the Clef declaration of the variable being loaded.
 void getDeclList(java.util.AbstractCollection<Declaration> varList)
          Add all declarations referenced in this expression to the Vector.
 void getExprList(Vector<Expr> expList)
          Add all Expr instances in this expression to the Vector.
 void getLoadExprList(Vector<LoadExpr> expList)
          Add all LoadExpr instances in this expression to the Vector.
 MayUse getMayUse()
          Return the may use information assocaited with the load.
 java.lang.String getName()
          Return the name of the declaration being loaded.
 Expr getObject()
          Given a load expression, return the object expression for the load.
 Expr[] getOperandArray()
          Return an array of the operands to the expression.
 Expr getReference()
          Return the value associated with the load expression.
 int getReuseLevel()
           
 Declaration getSubsetDecl()
          Return the original declaration of the value loaded.
 ExprChord getUseDef()
          Return the ExprChord that defines the value load by this load expression.
 boolean isMemoryDef()
          Return true if the node reference is a definition.
 boolean isMemRefExpr()
          Return true if the expression loads a value from memory.
 void loopClean()
          Clean up any loop related information.
 int numOperands()
          Return the number of operands to this expression.
 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.
 boolean referencesVariableInCommon()
          Return true if the variable referenced is in Fortran COMMON.
 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 setCrossloopReuse(int level)
           
 void setDecl(Declaration decl)
          Change the declaration associated with the load operation.
 void setSpatialReuse(int level)
           
 void setStep(int step)
           
 void setTemporalReuse(int level)
           
 void setUseDef(ExprChord expr)
          Define a link from this load of a value to the scale.score.chords.ExprChord that defines the value.
static boolean setUseMayUse(boolean flg)
          Specify whether the equivalent() method should use the may-use information.
static boolean setUseOriginal(boolean flg)
          Specify whether the equivalent() method should use the non-SSA original VariableDecl.
 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.
 boolean validLValue()
          Return true if this expression is valid on the left side of an assignment.
 
Methods inherited from class scale.score.expr.Expr
addCast, addCast, changeInDataEdge, conditionalCopy, conditionalUnlinkExpression, copy, deleteOutDataEdge, executionOrder, executionOrdinal, findCriticalChord, findLinearCoefficient, getAffineExpr, getAffineRepresentation, getCall, getConstantValue, getConstantValue, getCoreType, getCriticalChord, getDefExpr, getDisplayColorHint, getDisplayLabel, getDisplayShapeHint, getDualExpr, getInDataEdge, getInDataEdgeArray, getLoopHeader, getLow, getLValue, getOperand, getOutDataEdge, getPointedToCore, getRValue, getType, hasTrueFalseResult, isCast, isDefined, isDefined, isLiteralExpr, isLoopInvariant, isMatchExpr, isScalar, isSimpleExpr, mayGenerateCall, numInDataEdges, optimizationCandidate, reduce, removeDualExprs, setOperand, setOutDataEdge, setType, toStringSpecial
 
Methods inherited from class scale.score.Note
executionCostEstimate, getChord, getEssentialUse, setAnnotationLevel, setReportLevel, toString, visit
 
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

LoadExpr

public LoadExpr(Type t,
                Declaration decl)

LoadExpr

protected LoadExpr()
Method Detail

getSubsetDecl

public Declaration getSubsetDecl()
Return the original declaration of the value loaded. This is the variable before SSA renumbering is used to determine whether two virtual vars are in the same subset or if one is a superset. Hence the name.


equivalent

public boolean equivalent(Expr exp)
Return true if the expressions are equivalent. This method should be called by the equivalent() method of the derived classes.

Overrides:
equivalent in class Expr
Returns:
true if the expressions are equivalent
See Also:
setUseOriginal(boolean)

setUseOriginal

public static boolean setUseOriginal(boolean flg)
Specify whether the equivalent() method should use the non-SSA original VariableDecl.

Returns:
the previous setting
See Also:
equivalent(scale.score.expr.Expr), PRE

setUseMayUse

public static boolean setUseMayUse(boolean flg)
Specify whether the equivalent() method should use the may-use information.

Returns:
the previous setting
See Also:
equivalent(scale.score.expr.Expr), ValNum

copyNoUD

public abstract Expr copyNoUD()
Make a copy of this load expression without the use - def information.


setUseDef

public final void setUseDef(ExprChord expr)
Define a link from this load of a value to the scale.score.chords.ExprChord that defines the value.

Overrides:
setUseDef in class Expr
Parameters:
expr - the new use-def link

getUseDef

public final ExprChord getUseDef()
Return the ExprChord that defines the value load by this load expression.

Overrides:
getUseDef in class Expr

addMayUse

public void addMayUse(MayUse mayUse)
Add may use information to the load expression.

Parameters:
mayUse - the expresion representing the may use

getMayUse

public final MayUse getMayUse()
Return the may use information assocaited with the load.


removeUseDef

public void removeUseDef()
Remove any use - def links, may - use links, etc.

Specified by:
removeUseDef in class Expr

getDecl

public final Declaration getDecl()
Return the Clef declaration of the variable being loaded.


setDecl

public final void setDecl(Declaration decl)
Change the declaration associated with the load operation.

Parameters:
decl - is the new declataion

getName

public java.lang.String getName()
Return the name of the declaration being loaded.


getOperandArray

public final Expr[] getOperandArray()
Return an array of the operands to the expression.

Specified by:
getOperandArray in class Expr

numOperands

public final int numOperands()
Return the number of operands to this expression.

Specified by:
numOperands in class Expr

getReference

public Expr getReference()
Return the value associated with the load expression. The value is the load itself.

Overrides:
getReference in class Expr
Returns:
the load expression.

getObject

public Expr getObject()
Given a load expression, return the object expression for the load. This is the converse of getReference. If the expression is the structure or array name which is part of a field reference or array subscript then return the expression representing the field or the subscript. For a scalar load, the method returns the load.

Returns:
the object representing the load.

canonical

public long canonical()
Return a unique value representing this particular expression.

Overrides:
canonical in class Expr

loopClean

public void loopClean()
Clean up any loop related information.

Overrides:
loopClean in class Expr

unlinkExpression

public void unlinkExpression()
If the node is no longer needed, sever its use-def link, etc.

Overrides:
unlinkExpression in class Expr

isMemoryDef

public boolean isMemoryDef()
Return true if the node reference is a definition. That is, does this node represents a write to a memory location.

Overrides:
isMemoryDef in class Expr

findSubscriptExpr

public SubscriptExpr findSubscriptExpr()
Return the SubscriptExpr that this load uses or null if none is found. This method uses the use-def link to find an existing SubscriptExpr
Overrides:
findSubscriptExpr in class Expr

setTemporalReuse

public void setTemporalReuse(int level)
Overrides:
setTemporalReuse in class Expr

setCrossloopReuse

public void setCrossloopReuse(int level)
Overrides:
setCrossloopReuse in class Expr

setSpatialReuse

public void setSpatialReuse(int level)
Overrides:
setSpatialReuse in class Expr

setStep

public void setStep(int step)
Overrides:
setStep in class Expr

getReuseLevel

public int getReuseLevel()
Overrides:
getReuseLevel in class Expr

isMemRefExpr

public boolean isMemRefExpr()
Return true if the expression loads a value from memory.

Overrides:
isMemRefExpr in class Expr

referencesVariableInCommon

public final boolean referencesVariableInCommon()
Return true if the variable referenced is in Fortran COMMON.


validLValue

public boolean validLValue()
Return true if this expression is valid on the left side of an assignment.

Overrides:
validLValue in class Expr

containsDeclaration

public final boolean containsDeclaration(Declaration decl)
Return true if this expression contains a reference to the variable.

Overrides:
containsDeclaration in class Expr
See Also:
setUseOriginal(boolean)

dependsOnDeclaration

public final boolean dependsOnDeclaration(Declaration decl)
Return true if this expression's value depends on the variable. The use-def links are followed.

Overrides:
dependsOnDeclaration in class Expr
See Also:
setUseOriginal(boolean)

getAliasAnnote

public AliasAnnote getAliasAnnote()
Get the alias annotation associated with a Scribble operator. Most Scribble operators do not have alias variables so this routine may return null. Typically, the alias variable information is attached to the declaration node associated with the load operations. However, we sometimes need to create alias variables to hold alias information that is not directly assigned to a user variable (e.g., **x).

Overrides:
getAliasAnnote in class Expr
Returns:
the alias annotation associated with the expression

getDeclList

public void getDeclList(java.util.AbstractCollection<Declaration> varList)
Add all declarations referenced in this expression to the Vector.

Specified by:
getDeclList in class Expr

getLoadExprList

public void getLoadExprList(Vector<LoadExpr> expList)
Add all LoadExpr instances in this expression to the Vector.

Specified by:
getLoadExprList in class Expr

getExprList

public void getExprList(Vector<Expr> expList)
Add all Expr instances in this expression to the Vector.

Specified by:
getExprList in class Expr

pushOperands

public void pushOperands(Stack<Expr> wl)
Push all of the operands of this expression on the Stack.

Specified by:
pushOperands in class Expr

replaceDecl

public boolean replaceDecl(Declaration oldDecl,
                           Declaration newDecl)
Replace all occurrances of a Declaration with another Declaration. Return true if a replace occurred.

Specified by:
replaceDecl in class Expr
Returns:
true if a replace occurred.

validate

public void validate()
Check this node for validity. This method throws an exception if the node is not linked properly.

Overrides:
validate in class Expr

recordRefs

public void recordRefs(Chord stmt,
                       References refs)
Record any variable references in this expression in the table of references.

Specified by:
recordRefs in class Expr

removeRefs

public void removeRefs(Chord stmt,
                       References refs)
Remove any variable references in this expression from the table of references.

Specified by:
removeRefs in class Expr

sideEffects

public int sideEffects()
Return an indication of the side effects execution of this expression may cause.

Specified by:
sideEffects in class Expr
See Also:
Expr.SE_NONE