예제 #1
0
 /**
  * Build BURS trees for dependence graph <code>bb</code>, label the trees, and then generate MIR
  * instructions based on the labeling.
  *
  * @param bb The dependence graph. XXX Is this correct?
  */
 public void invoke(OPT_BasicBlock bb) {
   OPT_BURS_STATE burs = new OPT_BURS_STATE(this);
   for (OPT_InstructionEnumeration e = bb.forwardRealInstrEnumerator(); e.hasMoreElements(); ) {
     OPT_Instruction s = e.next();
     OPT_BURS_TreeNode tn = buildTree(s);
     burs.label(tn);
     burs.mark(tn, /* goalnt */ (byte) 1);
     generateTree(tn, burs);
   }
 }
예제 #2
0
  // Generate code for a single tree root.
  private void generateTree(OPT_BURS_TreeNode k, OPT_BURS_STATE burs) {
    OPT_BURS_TreeNode child1 = k.child1;
    OPT_BURS_TreeNode child2 = k.child2;
    if (child1 != null) {
      if (child2 != null) {
        // k has two children; use register labeling to
        // determine order that minimizes register pressure
        if (k.isSuperNodeRoot()) {
          byte act = burs.action[k.rule(k.getNonTerminal())];
          if ((act & burs.RIGHT_CHILD_FIRST) != 0) {
            // rule selected forces order of evaluation
            generateTree(child2, burs);
            generateTree(child1, burs);
          } else {
            generateTree(child1, burs);
            generateTree(child2, burs);
          }
        } else {
          generateTree(child1, burs);
          generateTree(child2, burs);
        }
      } else {
        generateTree(child1, burs);
      }
    } else if (child2 != null) {
      generateTree(child2, burs);
    }

    if (k.isSuperNodeRoot()) {
      int nonterminal = k.getNonTerminal();
      int rule = k.rule(nonterminal);
      burs.code(k, nonterminal, rule);
      if (DEBUG) VM.sysWrite(k + " " + OPT_BURS_Debug.string[rule] + "\n");
    }
  }