scale.score.chords
Class LeaveChord

java.lang.Object
  extended by scale.common.Root
      extended by scale.score.Note
          extended by scale.score.chords.Chord
              extended by scale.score.chords.SequentialChord
                  extended by scale.score.chords.EndChord
                      extended by scale.score.chords.LeaveChord
All Implemented Interfaces:
AnnotationInterface, DisplayNode
Direct Known Subclasses:
ReturnChord

public abstract class LeaveChord
extends EndChord

This class is a parent class for routine terminating statements.

$Id: LeaveChord.java,v 1.43 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.

Though not an inherent property of routine terminating statements, the ones that exist (return and exit) potentially carry a single data value.


Field Summary
 
Fields inherited from class scale.score.chords.Chord
lineNumber
 
Constructor Summary
LeaveChord()
           
LeaveChord(Expr resultValue)
           
 
Method Summary
 void changeInDataEdge(Expr oldExpr, Expr newExpr)
          This method changes an incoming data edge to point to a new expression.
 void deleteInDataEdges()
          Remove all the in-coming adat edges.
 int executionCostEstimate()
          Return a relative cost estimate for executing the expression.
 Vector<Declaration> getDeclList()
          Return a vector of all declarations referenced in this CFG node or null.
 Vector<Expr> getExprList()
          Return a vector of all LoadExpr instances in this CFG node or null.
 Expr getInDataEdge(int i)
          Return the specified in-coming data edge.
 Expr[] getInDataEdgeArray()
          Use this method when you may be modifying an in-coming data edge to this expression while iterating over the in-coming edges.
 Vector<LoadExpr> getLoadExprList()
          Return a vector of all LoadExpr instances in this CFG node or null.
 Expr getResultValue()
          Return the expression that defines the result of the routine.
 int numInDataEdges()
          Return the number of in-coming data edges.
 void pushInDataEdges(Stack<Expr> wl)
          Push all incoming data edges on the stack.
 void recordRefs(References refs)
          Record any variable references in this CFG node in the table of references.
 boolean removeDualExprs()
          Remove all DualExpr instances from the CFG.
 void removeRefs(References refs)
          Remove any variable references in this CFG node 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 setResultValue(Expr resultValue)
          Set the expression that defines the result of the routine.
 java.lang.String toStringSpecial()
          Return a string containing additional information about this Chord.
 void validate()
          Check this node for validity.
 
Methods inherited from class scale.score.chords.EndChord
copy, linkTo, setTarget, visit
 
Methods inherited from class scale.score.chords.SequentialChord
changeOutCfgEdge, clearEdge, clearEdgeMarkers, deleteOutCfgEdges, edgeMarked, getNextChord, getOutCfgEdge, getOutCfgEdgeArray, getTarget, indexOfOutCfgEdge, isLastInBasicBlock, isSequential, linkSubgraph, markEdge, numOutCfgEdges, pushAllOutCfgEdges, pushOutCfgEdges, pushOutCfgEdges, pushSortedOutCfgEdges, pushSortedOutCfgEdges, replaceOutCfgEdge, setTargetUnsafe
 
Methods inherited from class scale.score.chords.Chord
addInCfgEdge, changeParentOutCfgEdge, copySourceLine, deadCFGNodes, deletedCFGNodes, deleteInCfgEdge, executionOrder, expungeFromCfg, extractFromCfg, findLoopExit, findPhiChords, firstInBasicBlock, getCall, getDefExpr, getDisplayColorHint, getDisplayLabel, getDisplayShapeHint, getFirstInCfgEdge, getInCfgEdge, getInCfgEdge, getInCfgEdgeArray, getLabel, getLoopHeader, getLoopHeader, getLoopNumber, getSourceLineNumber, gotoCFGNodes, inBasicBlock, indexOfInCfgEdge, insertAfterOutCfg, insertBeforeInCfg, isAssignChord, isBranch, isExprChord, isFirstInBasicBlock, isLoopExit, isLoopHeader, isLoopPreHeader, isLoopTail, isMarker, isPhiExpr, isSpecial, lastInBasicBlock, loopClean, nextVisit, nthIndexOfInCfgEdge, nullCFGNodes, numInCfgEdges, numOfInCfgEdge, parentsFinished, parentsVisited, pushAllInCfgEdges, pushChordWhenReady, pushChordWhenReady, pushInCfgEdges, pushInCfgEdges, removeDeadCode, removeFromCfg, reorderInCfgEdgesOfCopy, replaceInCfgEdge, setLabel, setSourceLineNumber, setVisited, unlinkChord, visited
 
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

LeaveChord

public LeaveChord(Expr resultValue)
Parameters:
resultValue - is the expression that defines the result of the routine or null

LeaveChord

public LeaveChord()
Method Detail

getInDataEdgeArray

public final Expr[] getInDataEdgeArray()
Use this method when you may be modifying an in-coming data edge to this expression while iterating over the in-coming edges.

Overrides:
getInDataEdgeArray in class Chord
Returns:
an array of in-coming data edges.

getInDataEdge

public final Expr getInDataEdge(int i)
Return the specified in-coming data edge.

Overrides:
getInDataEdge in class Chord

numInDataEdges

public final int numInDataEdges()
Return the number of in-coming data edges.

Overrides:
numInDataEdges in class Chord

pushInDataEdges

public void pushInDataEdges(Stack<Expr> wl)
Push all incoming data edges on the stack.

Overrides:
pushInDataEdges in class Chord

getResultValue

public Expr getResultValue()
Return the expression that defines the result of the routine.


setResultValue

public void setResultValue(Expr resultValue)
Set the expression that defines the result of the routine.


changeInDataEdge

public void changeInDataEdge(Expr oldExpr,
                             Expr newExpr)
This method changes an incoming data edge to point to a new expression.

This method ensures that the node previously pointing to this one is updated properly, as well as, the node which will now point to this node.

Expr and Chord nodes have a fixed number of incoming edges with specific meaning applied to each. Hence, the edge being replaced is indicated by position.

Overrides:
changeInDataEdge in class Chord
Parameters:
oldExpr - is the expression to be replaced
newExpr - is the new expression

deleteInDataEdges

public void deleteInDataEdges()
Remove all the in-coming adat edges.

Overrides:
deleteInDataEdges in class SequentialChord

toStringSpecial

public java.lang.String toStringSpecial()
Return a string containing additional information about this Chord.

Overrides:
toStringSpecial in class Chord

getDeclList

public Vector<Declaration> getDeclList()
Return a vector of all declarations referenced in this CFG node or null.

Overrides:
getDeclList in class SequentialChord

getLoadExprList

public Vector<LoadExpr> getLoadExprList()
Return a vector of all LoadExpr instances in this CFG node or null.

Overrides:
getLoadExprList in class SequentialChord

getExprList

public Vector<Expr> getExprList()
Return a vector of all LoadExpr instances in this CFG node or null.

Overrides:
getExprList in class SequentialChord

replaceDecl

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

Overrides:
replaceDecl in class SequentialChord

removeUseDef

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

Overrides:
removeUseDef in class SequentialChord

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 Note

recordRefs

public void recordRefs(References refs)
Record any variable references in this CFG node in the table of references.

Overrides:
recordRefs in class Chord

removeRefs

public void removeRefs(References refs)
Remove any variable references in this CFG node from the table of references.

Overrides:
removeRefs in class Chord

executionCostEstimate

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

Overrides:
executionCostEstimate in class SequentialChord

removeDualExprs

public boolean removeDualExprs()
Remove all DualExpr instances from the CFG. Use the lower form. This eliminates references to variables that may no longer be needed.

Overrides:
removeDualExprs in class Chord