scale.score.expr
Class LoadValueIndirectExpr

java.lang.Object
  extended by scale.common.Root
      extended by scale.score.Note
          extended by scale.score.expr.Expr
              extended by scale.score.expr.UnaryExpr
                  extended by scale.score.expr.LoadValueIndirectExpr
All Implemented Interfaces:
AnnotationInterface, DisplayNode

public class LoadValueIndirectExpr
extends UnaryExpr

This class represents the indirect load operator.

$Id: LoadValueIndirectExpr.java,v 1.91 2007-10-04 19:58:31 burrill Exp $

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

Other loads are handled by other nodes. Load immediate is handled by LiteralExpr, load address is handled by LoadDeclAddressExpr, load of a value is handled by LoadDeclValueExpr, and load value from address is handled by LoadValueIndirectExpr.

See Also:
LoadDeclAddressExpr, LoadDeclValueExpr, LoadValueIndirectExpr, LiteralExpr

Field Summary
 
Fields inherited from class scale.score.expr.Expr
fpReorder, SE_DOMAIN, SE_NONE, SE_OVERFLOW, SE_STATE
 
Constructor Summary
LoadValueIndirectExpr(Expr addr)
          This method builds a load indirect operation.
 
Method Summary
 void addMayUse(MayUse mayUse)
          Add may use information to the load expression.
 Expr copy()
          Make a copy of this load expression.
 Expr copyNoUD()
          Make a copy of this load expression without the use - def information.
static Expr create(Expr addr)
          Create an expression representing the load from the specified address.
 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.
 SubscriptExpr findSubscriptExpr()
          Return the SubscriptExpr that this load uses or null if none is found.
 Expr getAddr()
          Return the Expr representing the address loaded by this expression.
 Literal getConstantValue()
          Return the constant value of the expression.
 Literal getConstantValue(HashMap<Expr,Literal> cvMap)
          Return the constant value of the expression.
 java.lang.String getDisplayLabel()
          Return a String suitable for labeling this node in a graphical display.
 MayUse getMayUse()
          Return the may use information assocaited with the load.
 Expr getObject()
          Given a load expression, return the object expression for the load.
 Expr getReference()
          Return the variable reference for the expression.
 int getReuseLevel()
           
 boolean isLoopInvariant(LoopHeaderChord loop)
          Return true if this expression is loop invariant.
 boolean isMemRefExpr()
          Return true if the expression loads a value from memory.
 void loopClean()
          Clean up any loop related information.
 boolean optimizationCandidate()
          Return true if the expression can be moved without problems.
 void removeUseDef()
          Remove any inormation such as use - def links, may use links, etc.
 void setCrossloopReuse(int level)
           
 void setSpatialReuse(int level)
           
 void setStep(int step)
           
 void setTemporalReuse(int level)
           
 int sideEffects()
          Return an indication of the side effects execution of this expression may cause.
 void visit(Predicate p)
          Process a node by calling its associated routine.
 
Methods inherited from class scale.score.expr.UnaryExpr
containsDeclaration, dependsOnDeclaration, equivalent, getAliasAnnote, getArg, getDeclList, getExprList, getLoadExprList, getOperand, getOperandArray, numOperands, pushOperands, recordRefs, removeRefs, replaceDecl, setArg, setOperand, unlinkExpression, validate
 
Methods inherited from class scale.score.expr.Expr
addCast, addCast, canonical, changeInDataEdge, conditionalCopy, conditionalUnlinkExpression, deleteOutDataEdge, executionOrder, executionOrdinal, findLinearCoefficient, getAffineExpr, getAffineRepresentation, getCall, getCoreType, getCriticalChord, getDefExpr, getDisplayColorHint, getDisplayShapeHint, getDualExpr, getInDataEdge, getInDataEdgeArray, getLoopHeader, getLow, getLValue, getOutDataEdge, getPointedToCore, getRValue, getType, getUseDef, hasTrueFalseResult, isCast, isDefined, isDefined, isLiteralExpr, isMatchExpr, isMemoryDef, isScalar, isSimpleExpr, mayGenerateCall, numInDataEdges, reduce, removeDualExprs, setOutDataEdge, setType, setUseDef, toStringSpecial, validLValue
 
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

LoadValueIndirectExpr

public LoadValueIndirectExpr(Expr addr)
This method builds a load indirect operation. The type is determined from the argument.

Parameters:
addr - address of value to be loaded
Method Detail

create

public static Expr create(Expr addr)
Create an expression representing the load from the specified address. Use this method when the argument class is not known.


getAddr

public final Expr getAddr()
Return the Expr representing the address loaded by this expression.


copy

public Expr copy()
Make a copy of this load expression. The use - def information is copied too.

Specified by:
copy in class Expr
Returns:
a copy of this expression

copyNoUD

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


visit

public void visit(Predicate p)
Description copied from class: Note
Process a node by calling its associated routine. See the "visitor" design pattern in Design Patterns: Elements of Reusable Object-Oriented Software by E. Gamma, et al, Addison Wesley, ISBN 0-201-63361-2.

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.

Specified by:
visit in class Note
See Also:
Predicate

getDisplayLabel

public java.lang.String getDisplayLabel()
Description copied from class: Expr
Return a String suitable for labeling this node in a graphical display. This method should be over-ridden as it simplay returns the class name.

Specified by:
getDisplayLabel in interface DisplayNode
Overrides:
getDisplayLabel in class Expr

getReference

public Expr getReference()
Return the variable reference for the expression. We use this to get the variable reference for operations such as array subscript and structure operations.

Overrides:
getReference in class Expr
Returns:
null since a general expression doesn't have a variable

addMayUse

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

Parameters:
mayUse - the expresion representing the may use

getMayUse

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


removeUseDef

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

Overrides:
removeUseDef in class UnaryExpr

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.

isMemRefExpr

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

Overrides:
isMemRefExpr in class Expr

findCriticalChord

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.

Overrides:
findCriticalChord in class Expr
Parameters:
lMap - is used to memoize the expression to critical Chord information
independent - is returned if the expression is not dependent on anything

isLoopInvariant

public boolean isLoopInvariant(LoopHeaderChord loop)
Return true if this expression is loop invariant.

Overrides:
isLoopInvariant in class Expr
Parameters:
loop - is the loop

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

loopClean

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

Overrides:
loopClean in class UnaryExpr

optimizationCandidate

public boolean optimizationCandidate()
Return true if the expression can be moved without problems. Expressions that reference global variables, non-atomic variables, etc are not optimization candidates.

For a load indirect (e.g., *ptr), we can treat it as optimizatible if the restrict attribute is set as in

   int * restrict ptr;
 
This allows global value numbering to change (*ptr + *ptr) to (x = *ptr, (x + x)).

Overrides:
optimizationCandidate in class UnaryExpr

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

executionCostEstimate

public int executionCostEstimate()
Return a relative cost estimate for executing the expression.

Overrides:
executionCostEstimate in class UnaryExpr

sideEffects

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

Overrides:
sideEffects in class UnaryExpr
See Also:
Expr.SE_NONE

getConstantValue

public Literal getConstantValue(HashMap<Expr,Literal> cvMap)
Return the constant value of the expression. Follow use-def links.

Overrides:
getConstantValue in class Expr
See Also:
Lattice, ValueDecl

getConstantValue

public Literal getConstantValue()
Return the constant value of the expression. Do not follow use-def links.

Overrides:
getConstantValue in class Expr
See Also:
Lattice, ValueDecl