|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.compilers.opt.ssa.GlobalValueNumberState
public final class GlobalValueNumberState
This class holds the results of global value numbering. ala Alpern, Wegman and Zadeck, PoPL 88. See Muchnick p.348 for a discussion (which is quite buggy, should have stuck to the dragon book, which gives a high-level description of the correct algorithm on page 143).
Field Summary | |
---|---|
private ArrayList<GVCongruenceClass> |
B
ArrayList of GVCongruenceClass, indexed by value number. |
private static boolean |
DEBUG
Print verbose debugging output? |
private static boolean |
NO_PARAM_ALIAS
Assume parameters are not aliased? |
static int |
UNKNOWN
Constant used to flag "unknown" value numbers |
(package private) ValueGraph |
valueGraph
The value graph. |
private Stack<GVCongruenceClass> |
workList
Stack used for a work list. |
Constructor Summary | |
---|---|
GlobalValueNumberState(IR ir)
Construct a structure to hold global value number results for an IR. |
Method Summary | |
---|---|
private void |
addDependentClassesToWorklist(GVCongruenceClass c)
Assuming congruence class c has changed: find all other classes that might be affected, and add them to the worklist |
private boolean |
checkCongruence(ValueGraphVertex v,
GVCongruenceClass c)
Does the current state of the algorithm optimistically assume that a vertex v is congruent to the vertices in a congruence class? |
private boolean |
checkCongruence(ValueGraphVertex v1,
ValueGraphVertex v2)
Does the current state of the algorithm optimistically assume that two nodes are congruent? |
(package private) GVCongruenceClass |
congruenceClass(Object name)
|
private GVCongruenceClass |
createCongruenceClass(Object label)
Given a label, return a new congruence class for that label. |
(package private) boolean |
DD(int v1,
int v2)
Definitely-different relation for two value numbers. |
(package private) boolean |
DD(Object name1,
Object name2)
Definitely-different relation. |
(package private) boolean |
DS(Object name1,
Object name2)
Definitely-same relation. |
private int |
findCongruenceMatch(ArrayList<GVCongruenceClass> vector,
ValueGraphVertex v)
Does vertex v belong to any congruence class in a vector? |
private GVCongruenceClass |
findOrCreateCongruenceClass(Object label,
HashMap<Object,GVCongruenceClass> labelMap)
Given a label, return the congruence class for that label. |
(package private) int |
getValueNumber(Object name)
Return the (integer) value number for a given variable |
private void |
globalValueNumber()
Compute node congruence over the value number graph. |
private void |
initialize()
Initialize the congruence classes, assuming that all nodes with the same label are congruent. |
private void |
initializeWorkList()
Initialize the work list. |
private static boolean |
isBornAtAllocation(Object label)
Does a given label indicate that the object is created at an allocation site? |
private static boolean |
isConstant(Object label)
Does a given label indicate that the object has a constant value? |
(package private) void |
mergeClasses(ValueGraphVertex v1,
ValueGraphVertex v2)
Merge the congruence classes containing vertices v1 and v2 |
private void |
partitionClass(GVCongruenceClass partition)
Partition a congruence class. |
(package private) void |
printValueNumbers()
Print the value numbers for each node in the value graph. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int UNKNOWN
private static final boolean DEBUG
private static final boolean NO_PARAM_ALIAS
private final ArrayList<GVCongruenceClass> B
final ValueGraph valueGraph
private final Stack<GVCongruenceClass> workList
Constructor Detail |
---|
GlobalValueNumberState(IR ir)
ir
- governing IRMethod Detail |
---|
private void globalValueNumber()
Algorithm: Muchnick pp. 348-355
Note: the Muchnick algorithm is buggy. In particular, it does not put all needed congruence classes on the worklist.
Two nodes in the value graph are congruent if one of the following holds:
Optimistic algorithm:
The following method breaks Muchnick's algorithm, which will assign m and n the same value number. Muchnick's problem is that it does not put the congruence class for 'int_mul' back on the worklist when we discover, for example, that i is not congruent to k
public int foo(int a, int b, int c, int d, int e, int f, int g, int h) { int i = a+b; int j = c+d; int k = e+f; int l = g+h; int m = i * j; int n = k * l; int o = m/n; return o; }
void mergeClasses(ValueGraphVertex v1, ValueGraphVertex v2)
boolean DS(Object name1, Object name2)
name1
- first variablename2
- second variable
boolean DD(int v1, int v2)
TODO: add more smarts
v1
- first value numberv2
- second value number
boolean DD(Object name1, Object name2)
TODO: add more smarts
name1
- name of first object to comparename2
- name of second object to compare
GVCongruenceClass congruenceClass(Object name)
int getValueNumber(Object name)
name
- name of the variable to look up
void printValueNumbers()
private void initialize()
private GVCongruenceClass findOrCreateCongruenceClass(Object label, HashMap<Object,GVCongruenceClass> labelMap)
label
- the label of a congruence classlabelMap
- a mapping from labels to congruence class
private GVCongruenceClass createCongruenceClass(Object label)
label
- the label of a congruence class
private void initializeWorkList()
private void partitionClass(GVCongruenceClass partition)
partition
- the class to partitionprivate void addDependentClassesToWorklist(GVCongruenceClass c)
c
- the congruence class that has changedprivate int findCongruenceMatch(ArrayList<GVCongruenceClass> vector, ValueGraphVertex v)
vector
- a vector of congruence classesv
- the vertex to search for
private boolean checkCongruence(ValueGraphVertex v, GVCongruenceClass c)
v
- the vertex in questionc
- the congurence class to check
private boolean checkCongruence(ValueGraphVertex v1, ValueGraphVertex v2)
v1
- first vertexv2
- second vertexprivate static boolean isConstant(Object label)
private static boolean isBornAtAllocation(Object label)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |