Ejemplo n.º 1
0
 /** Print the value numbers for each node in the value graph. */
 public void printValueNumbers() {
   for (Enumeration e = valueGraph.enumerateVertices(); e.hasMoreElements(); ) {
     OPT_ValueGraphVertex v = (OPT_ValueGraphVertex) e.nextElement();
     int valueNumber = v.getValueNumber();
     OPT_GVCongruenceClass c = (OPT_GVCongruenceClass) B.get(valueNumber);
     System.out.println(v.name + " " + valueNumber + " " + c.getLabel());
   }
 }
Ejemplo n.º 2
0
 /**
  * Assuming congruence class c has changed: find all other classes that might be affected, and add
  * them to the worklist
  *
  * @param c the congruence class that has changed
  */
 private void addDependentClassesToWorklist(OPT_GVCongruenceClass c) {
   // for each element of this congruence class:
   for (Iterator elements = c.iterator(); elements.hasNext(); ) {
     OPT_ValueGraphVertex v = (OPT_ValueGraphVertex) elements.next();
     // for each vertex which points to v in the value graph
     for (Enumeration e = v.inNodes(); e.hasMoreElements(); ) {
       OPT_ValueGraphVertex in = (OPT_ValueGraphVertex) e.nextElement();
       int vn = in.getValueNumber();
       OPT_GVCongruenceClass x = (OPT_GVCongruenceClass) B.get(vn);
       workList.push(x);
     }
   }
 }
Ejemplo n.º 3
0
 /**
  * Initialize the congruence classes, assuming that all nodes with the same label are congruent.
  */
 private void initialize() {
   // store a map from label -> congruenceClass
   HashMap labelMap = new HashMap(10);
   for (Enumeration e = valueGraph.enumerateVertices(); e.hasMoreElements(); ) {
     OPT_ValueGraphVertex v = (OPT_ValueGraphVertex) e.nextElement();
     Object label = v.getLabel();
     OPT_GVCongruenceClass c = findOrCreateCongruenceClass(label, labelMap);
     // add this node to the congruence class
     c.addVertex(v);
     // set the value number for the node
     v.setValueNumber(c.getValueNumber());
   }
 }