scale.score.chords
Class DecisionChord

java.lang.Object
  extended by scale.common.Root
      extended by scale.score.Note
          extended by scale.score.chords.Chord
              extended by scale.score.chords.DecisionChord
All Implemented Interfaces:
AnnotationInterface, DisplayNode
Direct Known Subclasses:
IfThenElseChord, SwitchChord

public abstract class DecisionChord
extends Chord

This class represents a CFG node that has multiple out-going CFG edges.

$Id: DecisionChord.java,v 1.62 2007-10-17 13:44:05 burrill Exp $

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

This is the base class for all classes that have more than one out-going CFG edge.


Field Summary
 
Fields inherited from class scale.score.chords.Chord
lineNumber
 
Constructor Summary
DecisionChord(Expr predicate)
          Create a Chord that has more than one out-going CFG edge where the edge is selected by some computation.
 
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 data edges.
abstract  int getBranchEdgeIndex(java.lang.Object key)
          Return the index of the selected out-going CFG edge.
abstract  double getBranchProbability(Chord edge)
          Return the probability that the specified edge will be executed next.
 Vector<Declaration> getDeclList()
          Return a vector of all declarations referenced in this CFG node or null.
 DColor getDisplayColorHint()
          Return a string specifying the color to use for coloring this node in a graphical display.
 DShape getDisplayShapeHint()
          Return a string specifying a shape to use when drawing this node in a graphical display.
 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.
 Chord getNextChord()
          Return null because there is no ONE next Chord in the CFG.
 Expr getPredicateExpr()
          Return the expression used to select an out-going CFG edge.
 boolean isBranch()
          Return true if this chord may have multiple out-going CFG edges.
 boolean isLastInBasicBlock()
          Return true if this is the last Chord in this Basic Block.
 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)
          Record 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.
abstract  void specifyBranchProbability(Chord edge, double probability)
          Specify the probability that the specified edge will be executed next.
 java.lang.String toStringSpecial()
          Return a String containing additional information about this CFG node..
 void validate()
          Check this node for validity.
 
Methods inherited from class scale.score.chords.Chord
addInCfgEdge, changeOutCfgEdge, changeParentOutCfgEdge, clearEdge, clearEdgeMarkers, copy, copySourceLine, deadCFGNodes, deletedCFGNodes, deleteInCfgEdge, deleteOutCfgEdges, edgeMarked, executionOrder, expungeFromCfg, extractFromCfg, findLoopExit, findPhiChords, firstInBasicBlock, getCall, getDefExpr, getDisplayLabel, getFirstInCfgEdge, getInCfgEdge, getInCfgEdge, getInCfgEdgeArray, getLabel, getLoopHeader, getLoopHeader, getLoopNumber, getOutCfgEdge, getOutCfgEdgeArray, getSourceLineNumber, gotoCFGNodes, inBasicBlock, indexOfInCfgEdge, indexOfOutCfgEdge, insertAfterOutCfg, insertBeforeInCfg, isAssignChord, isExprChord, isFirstInBasicBlock, isLoopExit, isLoopHeader, isLoopPreHeader, isLoopTail, isMarker, isPhiExpr, isSequential, isSpecial, lastInBasicBlock, linkSubgraph, linkTo, loopClean, markEdge, nextVisit, nthIndexOfInCfgEdge, nullCFGNodes, numInCfgEdges, numOfInCfgEdge, numOutCfgEdges, parentsFinished, parentsVisited, pushAllInCfgEdges, pushAllOutCfgEdges, pushChordWhenReady, pushChordWhenReady, pushInCfgEdges, pushInCfgEdges, pushOutCfgEdges, pushOutCfgEdges, pushSortedOutCfgEdges, pushSortedOutCfgEdges, removeDeadCode, removeFromCfg, reorderInCfgEdgesOfCopy, replaceInCfgEdge, replaceOutCfgEdge, setLabel, setSourceLineNumber, setVisited, unlinkChord, visited
 
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

DecisionChord

public DecisionChord(Expr predicate)
Create a Chord that has more than one out-going CFG edge where the edge is selected by some computation.

Parameters:
predicate - the expression which is evaluated to select the out-going edge
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 Expr getInDataEdge(int i)
Return the specified in-coming data edge.

Overrides:
getInDataEdge in class Chord

numInDataEdges

public 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

toStringSpecial

public java.lang.String toStringSpecial()
Return a String containing additional information about this CFG node..

Overrides:
toStringSpecial in class Chord

getPredicateExpr

public final Expr getPredicateExpr()
Return the expression used to select an out-going CFG edge.


specifyBranchProbability

public abstract void specifyBranchProbability(Chord edge,
                                              double probability)
Specify the probability that the specified edge will be executed next. The stored value for the probability is quantized for reasons of space utilization. The probability of both edges is set. The sum of the probabilities of both edges is always (approximately) 1.0.


getBranchProbability

public abstract double getBranchProbability(Chord edge)
Return the probability that the specified edge will be executed next. The stored value for the probability is quantized for reasons of space utilization. The sum of the probabilities of both edges is always (approximately) 1.0.


getNextChord

public final Chord getNextChord()
Return null because there is no ONE next Chord in the CFG.

Specified by:
getNextChord in class Chord

isLastInBasicBlock

public final boolean isLastInBasicBlock()
Return true if this is the last Chord in this Basic Block.

Specified by:
isLastInBasicBlock in class Chord
See Also:
Chord.lastInBasicBlock(), Chord.isFirstInBasicBlock(), Chord.firstInBasicBlock()

isBranch

public final boolean isBranch()
Return true if this chord may have multiple out-going CFG edges.

Overrides:
isBranch in class Chord

getBranchEdgeIndex

public abstract int getBranchEdgeIndex(java.lang.Object key)
Return the index of the selected out-going CFG edge.

Parameters:
key - specifies the out-going CFG edge

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.

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 data edges.

Specified by:
deleteInDataEdges in class Chord

getDisplayColorHint

public DColor getDisplayColorHint()
Return a string specifying the color to use for coloring this node in a graphical display. This method should be over-ridden as it simplay returns the color red.

Specified by:
getDisplayColorHint in interface DisplayNode
Overrides:
getDisplayColorHint in class Chord
See Also:
DColor

getDisplayShapeHint

public DShape getDisplayShapeHint()
Return a string specifying a shape to use when drawing this node in a graphical display. This method should be over-ridden as it simplay returns the shape "box".

Specified by:
getDisplayShapeHint in interface DisplayNode
Overrides:
getDisplayShapeHint in class Chord
See Also:
DShape

getDeclList

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

Specified by:
getDeclList in class Chord

getLoadExprList

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

Specified by:
getLoadExprList in class Chord

getExprList

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

Specified by:
getExprList in class Chord

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 Chord

removeUseDef

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

Specified by:
removeUseDef in class Chord

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)
Record any variable references in this CFG node from the table of references.

Overrides:
removeRefs in class Chord

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