Exemplo n.º 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);
   }
 }
Exemplo n.º 2
0
  /**
   * Is register r1 live at any def of register r2?
   *
   * <p><strong>PRECONDITION </strong> def-use chains must be computed and valid.
   * <strong>PRECONDITION </strong> instructions are numbered, with numbers stored in
   * OPT_Instruction.scratch
   *
   * <p>Note: this implementation is not efficient. The liveness data structures must be re-designed
   * to support this efficiently.
   */
  private static boolean isLiveAtDef(OPT_Register r1, OPT_Register r2, OPT_LiveAnalysis live) {

    for (Iterator e = live.iterateLiveIntervals(r1); e.hasNext(); ) {
      OPT_LiveIntervalElement elem = (OPT_LiveIntervalElement) e.next();
      OPT_BasicBlock bb = elem.getBasicBlock();
      OPT_Instruction begin = (elem.getBegin() == null) ? bb.firstInstruction() : elem.getBegin();
      OPT_Instruction end = (elem.getEnd() == null) ? bb.lastInstruction() : elem.getEnd();
      int low = begin.scratch;
      int high = end.scratch;
      for (Enumeration defs = OPT_DefUse.defs(r2); defs.hasMoreElements(); ) {
        OPT_Operand def = (OPT_Operand) defs.nextElement();
        int n = def.instruction.scratch;
        if (n >= low && n < high) {
          return true;
        }
      }
    }

    // no conflict was found.
    return false;
  }