|
|||||||||
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.chords.Chord scale.score.chords.DecisionChord scale.score.chords.SwitchChord
public class SwitchChord
This class represents a Scribble CFG node that has multiple out-going CFG edges.
$Id: SwitchChord.java,v 1.39 2007-10-04 19:58:23 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. The edges are selected using a key object.
Field Summary |
---|
Fields inherited from class scale.score.chords.Chord |
---|
lineNumber |
Constructor Summary | |
---|---|
SwitchChord(Expr predicate)
Create a Chord that has more than one out-going CFG edge where the edge is selected by some computation. |
|
SwitchChord(Expr predicate,
Vector<java.lang.Object> keys,
Vector<Chord> targets)
Create a Chord that has more than one out-going CFG edge where the edge is selected by some computation. |
Method Summary | |
---|---|
void |
addBranchEdge(java.lang.Object key,
Chord target)
This method adds changes an out-going CFG edge of the branch. |
void |
changeOutCfgEdge(Chord oldEdge,
Chord newEdge)
Change the out-going CFG edge indicated by the position to the new edge. |
void |
clearEdge(int edge)
Clear the marker associated with the specified out-going CFG edge. |
void |
clearEdgeMarkers()
Clear all the markers. |
Chord |
copy()
Make a copy of this Chord with the same out-going CFG edges. |
static int |
created()
Return the number of instances of this class that were created. |
void |
deleteOutCfgEdges()
Set both out-going CFG edges to null . |
boolean |
edgeMarked(int edge)
Return the marker associated with the specified out-going CFG edge. |
int |
executionCostEstimate()
Return a relative cost estimate for executing the expression. |
int |
getBranchEdgeIndex(java.lang.Object key)
Return the index of the selected out-going CFG edge. |
long[] |
getBranchEdgeKeyArray()
Return an array of all of the keys used. |
double |
getBranchProbability(Chord edge)
Return the probability that the specified edge will be executed next. |
int |
getDefaultIndex()
Return the index of the default case or -1 if none. |
Chord |
getOutCfgEdge(int i)
Return the specified out-going CFG edge. |
Chord[] |
getOutCfgEdgeArray()
Use this method when you may be modifying an out-going CFG edge from this Chord while iterating over the out-going edges. |
int |
indexOfOutCfgEdge(Chord to,
int skip)
This routine is needed because it is possible for more than one out-going edge from a CFG node to go the the same CFG node. |
void |
linkSubgraph(HashMap<Chord,Chord> nm)
Link a new CFG node that contains old links. |
void |
markEdge(int edge)
Set the marker associated with the specified out-going CFG edge. |
int |
numOutCfgEdges()
Return the number of out-going CFG edges. |
void |
pushAllOutCfgEdges(Stack<Chord> wl)
Add the successors of this Chord to the stack. |
void |
pushOutCfgEdges(Stack<Chord> wl)
Add the successors of this Chord to the stack if they haven't been visited before. |
void |
pushOutCfgEdges(Stack<Chord> wl,
HashSet<Chord> done)
Add the successors of this Chord to the stack if they haven't been visited before. |
void |
pushSortedOutCfgEdges(Stack<Chord> wl)
Add the successors of this Chord to the stack if they haven't been visited, and all their parents have. |
void |
pushSortedOutCfgEdges(Stack<Chord> wl,
HashSet<Chord> finished)
Add the successors of this Chord to the stack if they haven't been visited, and all their parents have. |
void |
replaceOutCfgEdge(Chord oldChord,
Chord newChord)
Replace the existing out-going CFG edge with a new edge. |
void |
specifyBranchProbability(Chord edge,
double probability)
Specify the probability that the specified edge will be executed next. |
void |
visit(Predicate p)
Process a node by calling its associated routine. |
Methods inherited from class scale.score.chords.DecisionChord |
---|
changeInDataEdge, deleteInDataEdges, getDeclList, getDisplayColorHint, getDisplayShapeHint, getExprList, getInDataEdge, getInDataEdgeArray, getLoadExprList, getNextChord, getPredicateExpr, isBranch, isLastInBasicBlock, numInDataEdges, pushInDataEdges, recordRefs, removeDualExprs, removeRefs, removeUseDef, replaceDecl, toStringSpecial, validate |
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 SwitchChord(Expr predicate, Vector<java.lang.Object> keys, Vector<Chord> targets)
predicate
- the expression which is evaluated to select the
out-going edgekeys
- a vector of keys associated with the out-going edgestargets
- a vector of out-going CFG edgespublic SwitchChord(Expr predicate)
predicate
- the expression which is evaluated to select the
out-going edgeMethod Detail |
---|
public static int created()
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 void deleteOutCfgEdges()
null
.
This method does not maintain the validity of the CFG as the
nodes at the other ends of the edges are not modified.
deleteOutCfgEdges
in class Chord
public Chord copy()
copy
in class Chord
public int getBranchEdgeIndex(java.lang.Object key)
getBranchEdgeIndex
in class DecisionChord
key
- specifies the out-going CFG edgepublic void replaceOutCfgEdge(Chord oldChord, Chord newChord)
replaceOutCfgEdge
in class Chord
oldChord
- is the old edgenewChord
- is the new edgepublic final int numOutCfgEdges()
numOutCfgEdges
in class Chord
public final Chord getOutCfgEdge(int i)
getOutCfgEdge
in class Chord
public final int indexOfOutCfgEdge(Chord to, int skip)
indexOfOutCfgEdge
in class Chord
to
- is the target CFG nodeskip
- ispecifies how many occurrances of to
to
skip
public final long[] getBranchEdgeKeyArray()
public final int getDefaultIndex()
public final Chord[] getOutCfgEdgeArray()
getOutCfgEdgeArray
in class Chord
public void addBranchEdge(java.lang.Object key, Chord target)
key
- When predicate evaluates to this value, the associated
branch will be taken.target
- Target of branch associated with this key.public void changeOutCfgEdge(Chord oldEdge, Chord newEdge)
changeOutCfgEdge
in class Chord
oldEdge
- the out-going CFG edge to be changednewEdge
- the new out-going CFG edgepublic final void specifyBranchProbability(Chord edge, double probability)
specifyBranchProbability
in class DecisionChord
public final double getBranchProbability(Chord edge)
getBranchProbability
in class DecisionChord
public final void pushAllOutCfgEdges(Stack<Chord> wl)
pushAllOutCfgEdges
in class Chord
public final void pushOutCfgEdges(Stack<Chord> wl)
pushOutCfgEdges
in class Chord
Chord.nextVisit()
,
Chord.setVisited()
,
Chord.visited()
public final void pushOutCfgEdges(Stack<Chord> wl, HashSet<Chord> done)
pushOutCfgEdges
in class Chord
done
- is the set of visited CFG nodespublic void pushSortedOutCfgEdges(Stack<Chord> wl)
pushSortedOutCfgEdges
in class Chord
public void pushSortedOutCfgEdges(Stack<Chord> wl, HashSet<Chord> finished)
pushSortedOutCfgEdges
in class Chord
finished
- is the set of finished nodes.public void clearEdgeMarkers()
clearEdgeMarkers
in class Chord
public boolean edgeMarked(int edge)
edgeMarked
in class Chord
edge
- specifies the edge associated with the marker
getOutCfgEdge(int)
public void markEdge(int edge)
markEdge
in class Chord
edge
- specifies the edge associated with the markergetOutCfgEdge(int)
public void clearEdge(int edge)
clearEdge
in class Chord
edge
- specifies the edge associated with the markergetOutCfgEdge(int)
public void linkSubgraph(HashMap<Chord,Chord> nm)
linkSubgraph
in class Chord
nm
- is a map from the old nodes to the new nodes.Scribble.linkSubgraph(scale.common.Vector, scale.common.HashMap, scale.common.Vector)
public int executionCostEstimate()
executionCostEstimate
in class Note
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |