|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Root scale.score.Domination
public class Domination
This class computes the dominators and post dominators of nodes in a graph.
$Id: Domination.java,v 1.76 2007-10-04 19:58:18 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
As described in A Fast Algorithm for Finding Dominators in a Flowgraph by Lengauer and Tarjan, ACM. Tran. on Prog. Lang and System, July 1979.
Constructor Summary | |
---|---|
Domination(boolean post,
Chord start)
|
Method Summary | |
---|---|
void |
addDominatee(Chord d,
Chord me)
Specify that node d dominates node me . |
static int |
computed()
Return the number of times the dominance frontier was computed. |
static int |
created()
Return the number of instances of this class that were created. |
static int |
deadCFGNodes()
Return the number of dead nodes removed. |
void |
displayDominance(java.io.PrintStream s,
Chord n)
Print out the dominance relations for node n . |
Chord[] |
getDominatees(Chord dominator)
Return the set of CFG nodes that dominator
strictly dominates. |
Chord |
getDominatorOf(Chord v)
Return the dominator of v. |
Vector<Chord> |
getIterativeDomination(Chord n)
Return the set of all nodes strictly dominated by node n and all nodes dominated by nodes dominated by
n , and so on. |
void |
getIterativeDomination(Chord n,
Vector<Chord> v)
Return the set of all nodes strictly dominated by node n and all nodes dominated by nodes dominated by
n , and so on. |
boolean |
getIterativeDominationLH(LoopPreHeaderChord lph,
Vector<Chord> idom,
boolean calls,
HashSet<Chord> stops)
Return true if the entire loop is dominated by the loop pre-header without interference from calls, etc. |
void |
getIterativeDominationNF(Chord dominator,
Vector<Chord> idom)
Return the set of all nodes dominated by node n and
all nodes dominated by nodes dominated by n , and so
on. |
void |
getIterativeDominationNF(Chord dominator,
Vector<Chord> idom,
boolean calls,
HashSet<Chord> stops)
Return the set of all nodes dominated by node c and
all nodes dominated by nodes dominated by c , and so
on. |
void |
getIterativeDominationNF(Chord dominator,
Vector<Chord> idom,
HashSet<Chord> stops)
Return the set of all nodes dominated by node c and
all nodes dominated by nodes dominated by c , and so
on. |
boolean |
inDominatees(Chord n,
Chord d)
Return true if CFG node n strictly dominates node
d . |
boolean |
inIterativeDominatees(Chord n,
Chord d)
Return true if CFG node n dominates node
d . |
boolean |
isPostDomination()
Return true if this domination is a post domination. |
int |
numDominatees(Chord dominator)
Return the number of the nodes that dominator strictly
dominates. |
void |
pushDominatees(Chord dominator,
Stack<Chord> wl)
Push onto the stack all of the nodes that dominator
strictly dominates. |
void |
removeDeadCode()
Removes all nodes that do not have a dominator. |
void |
removeDominatee(Chord d,
Chord me)
Specify that node d no longer dominates node
me . |
java.lang.String |
toStringSpecial()
Return any special information of a node that is not a child or annotation. |
Methods inherited from class scale.common.Root |
---|
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayColorHint, getDisplayLabel, getDisplayName, getDisplayShapeHint, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toString, toStringAnnotations, toStringClass, trace, trace, trace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Domination(boolean post, Chord start)
post
- false for dominators, true for post dominators to be
determinedstart
- the starting node in the graph (or end if post
dominators)Method Detail |
---|
public static int created()
public static int computed()
public static int deadCFGNodes()
public final Chord getDominatorOf(Chord v)
public final void addDominatee(Chord d, Chord me)
d
dominates node me
.
This method should only be used to update the domination
information after the dominators have been computed.
public final void removeDominatee(Chord d, Chord me)
d
no longer dominates node
me
. This method should only be used to update the
domination information after the dominators have been computed.
public final Chord[] getDominatees(Chord dominator)
dominator
strictly dominates.
public final void pushDominatees(Chord dominator, Stack<Chord> wl)
dominator
strictly dominates. The nodes are placed on the stack in
ascending order by the node's label.
Scribble.labelCFG()
public final int numDominatees(Chord dominator)
dominator
strictly
dominates.
public void getIterativeDominationNF(Chord dominator, Vector<Chord> idom)
n
and
all nodes dominated by nodes dominated by n
, and so
on. However, don't go past a non-pure subroutine call.
Consider the case where a subroutine call exists inside of a loop
dominated by c
. In this case, all of the nodes in
the loop must be eliminated from the set returned.
We can go to the ends of the CFG as long as there is no join. For example, in
(1) x = g + 3; (2) if (exp) (3) y = abc(); (4) y = g + 4even though line (1) dominates line (4), the call to abc on line (3) prevents the nodes of line (4) from being included in the same set. However, in
(1) x = g + 3; (2) if (exp) (3) return x; (4) y = g + 4line (4) can be included because line (3) is an "end". Note - In this case:
(1) x = g + 3; (2) if (exp) (3) z = 123; (4) y = g + 4line (4) is still not included because there is a join to line (4) and our logic is not powerful enough to know that line(3) is not a problem.
Note - this method uses nextVisit()
.
dominator
- is the dominator nodeidom
- is the vector to which the dominated nodes are addedpublic void getIterativeDominationNF(Chord dominator, Vector<Chord> idom, HashSet<Chord> stops)
c
and
all nodes dominated by nodes dominated by c
, and so
on. However, don't go past a non-pure subroutine call or one of
the nodes specified by the stops
.
Consider the case where a subroutine call exists inside of a loop
dominated by c
. In this case, all of the nodes in
the loop must be eliminated from the set returned.
We can go to the ends of the CFG as long as there is no join. For example, in
(1) x = g + 3; (2) if (exp) (3) y = abc(); (4) y = g + 4even though line (1) dominates line (4), the call to abc on line (3) prevents the nodes of line (4) from being included in the same set. However, in
(1) x = g + 3; (2) if (exp) (3) return x; (4) y = g + 4line (4) can be included because line (3) is an "end". Note - In this case:
(1) x = g + 3; (2) if (exp) (3) z = 123; (4) y = g + 4line (4) is still not included because there is a join to line (4) and our logic is not powerful enough to know that line(3) is not a problem.
Note - this method uses nextVisit()
.
dominator
- is the dominator nodeidom
- is the vector to which the dominated nodes are addedstops
- is the list of nodes that should terminate the collectionpublic void getIterativeDominationNF(Chord dominator, Vector<Chord> idom, boolean calls, HashSet<Chord> stops)
c
and
all nodes dominated by nodes dominated by c
, and so
on. If specified, do not go past a non-pure subroutine call. Do
not go past one of the nodes specified by the stops
.
Consider the case where a subroutine call exists inside of a loop
dominated by c
. In this case, all of the nodes in
the loop must be eliminated from the set returned.
We can go to the ends of the CFG as long as there is no join. For example, in
(1) x = g + 3; (2) if (exp) (3) y = abc(); (4) y = g + 4even though line (1) dominates line (4), the call to abc on line (3) prevents the nodes of line (4) from being included in the same set. However, in
(1) x = g + 3; (2) if (exp) (3) return x; (4) y = g + 4line (4) can be included because line (3) is an "end". Note - In this case:
(1) x = g + 3; (2) if (exp) (3) z = 123; (4) y = g + 4line (4) is still not included because there is a join to line (4) and our logic is not powerful enough to know that line(3) is not a problem.
Note - this method uses nextVisit()
.
dominator
- is the dominator nodeidom
- is the vector to which the dominated nodes are addedcalls
- is true if a call to a non-pure function should terminatestops
- is the list of nodes that should terminate the collectionpublic boolean getIterativeDominationLH(LoopPreHeaderChord lph, Vector<Chord> idom, boolean calls, HashSet<Chord> stops)
Chord.nextVisit();before calling this method.
lph
- is the dominator nodeidom
- is the vector to which the dominated nodes are addedcalls
- is true if non-pure calls should be checkedstops
- is the list of nodes that should terminate the
collectionpublic final Vector<Chord> getIterativeDomination(Chord n)
n
and all nodes dominated by nodes dominated by
n
, and so on.
n
- is the dominator nodepublic void getIterativeDomination(Chord n, Vector<Chord> v)
n
and all nodes dominated by nodes dominated by
n
, and so on.
n
- is the dominator nodev
- is the vector to which the dominated nodes are addedpublic final boolean inDominatees(Chord n, Chord d)
n
strictly dominates node
d
.
n
- the node to testd
- the node to testpublic final boolean inIterativeDominatees(Chord n, Chord d)
n
dominates node
d
.
n
- the node to testd
- the node to testpublic final void displayDominance(java.io.PrintStream s, Chord n)
n
.
s
- the stream to write topublic final boolean isPostDomination()
public final void removeDeadCode()
public java.lang.String toStringSpecial()
Root
toStringSpecial
in class Root
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |