Exemple #1
0
  /**
   * Add an existing equation to the system
   *
   * @param eq the equation
   */
  void addEquation(DF_Equation eq) {
    equations.addGraphNode(eq);
    newEquations.add(eq);

    DF_LatticeCell lhs = eq.getLHS();
    if (!(lhs.getDefs().hasNext() || lhs.getUses().hasNext())) {
      lhs.addDef(eq);
      equations.addGraphNode(lhs);
    } else {
      lhs.addDef(eq);
    }

    DF_LatticeCell[] operands = eq.getOperands();
    for (int i = 1; i < operands.length; i++) {
      DF_LatticeCell op = operands[i];
      if (!(op.getDefs().hasNext() || op.getUses().hasNext())) {
        op.addUse(eq);
        equations.addGraphNode(op);
      } else {
        op.addUse(eq);
      }
    }

    if (EAGER && eq.evaluate()) changedCell(lhs);
  }
Exemple #2
0
 /**
  * Add an equation with three operands on the right-hand side.
  *
  * @param lhs the lattice cell set by this equation
  * @param operator the equation operator
  * @param op1 first operand on the rhs
  * @param op2 second operand on the rhs
  * @param op3 third operand on the rhs
  */
 void newEquation(
     DF_LatticeCell lhs,
     DF_Operator operator,
     DF_LatticeCell op1,
     DF_LatticeCell op2,
     DF_LatticeCell op3) {
   // add to the list of equations
   DF_Equation eq = new DF_Equation(lhs, operator, op1, op2, op3);
   equations.addGraphNode(eq);
   equations.addGraphNode(lhs);
   equations.addGraphNode(op1);
   equations.addGraphNode(op2);
   equations.addGraphNode(op3);
   newEquations.add(eq);
   // add lattice cells for the operands to the working solution
   //       cells.put(lhs.getKey(),lhs);
   //       cells.put(op1.getKey(),op1);
   op1.addUse(eq);
   //       cells.put(op2.getKey(),op2);
   op2.addUse(eq);
   //       cells.put(op3.getKey(),op3);
   op3.addUse(eq);
   lhs.addDef(eq);
   if (EAGER && eq.evaluate()) changedCell(lhs);
 }
Exemple #3
0
 /**
  * Add an equation to the system with an arbitrary number of operands on the right-hand side.
  *
  * @param lhs lattice cell set by this equation
  * @param operator the equation operator
  * @param rhs the operands on the rhs
  */
 protected void newEquation(DF_LatticeCell lhs, DF_Operator operator, DF_LatticeCell[] rhs) {
   // add to the list of equations
   DF_Equation eq = new DF_Equation(lhs, operator, rhs);
   equations.addGraphNode(eq);
   equations.addGraphNode(lhs);
   newEquations.add(eq);
   // add the operands to the working solution
   //       cells.put(lhs.getKey(),lhs);
   for (DF_LatticeCell rh : rhs) {
     //        cells.put(rhs[i].getKey(),rhs[i]);
     rh.addUse(eq);
     equations.addGraphNode(rh);
   }
   lhs.addDef(eq);
   if (EAGER && eq.evaluate()) changedCell(lhs);
 }
Exemple #4
0
 /**
  * Solve the set of dataflow equations.
  *
  * <p>PRECONDITION: equations are set up
  */
 public void solve() {
   // addGraphEdges();
   numberEquationsTopological();
   initializeLatticeCells();
   initializeWorkList();
   while (!workList.isEmpty()) {
     DF_Equation eq = workList.first();
     workList.remove(eq);
     boolean change = eq.evaluate();
     if (DEBUG) {
       System.out.println("After evaluation " + eq);
     }
     if (change) {
       updateWorkList(eq);
     }
   }
 }