/** * 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; }