use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class EnterSSA method computeNonLocals.
/**
* Pass through the IR and calculate which registers are not
* local to a basic block. Store the result in the <code> nonLocalRegisters
* </code> field.
*/
@SuppressWarnings("unused")
private void computeNonLocals() {
nonLocalRegisters = new HashSet<Register>(20);
Enumeration<BasicBlock> blocks = ir.getBasicBlocks();
while (blocks.hasMoreElements()) {
HashSet<Register> killed = new HashSet<Register>(5);
BasicBlock block = blocks.nextElement();
Enumeration<Instruction> instrs = block.forwardRealInstrEnumerator();
while (instrs.hasMoreElements()) {
Instruction instr = instrs.nextElement();
Enumeration<Operand> uses = instr.getUses();
while (uses.hasMoreElements()) {
Operand op = uses.nextElement();
if (op instanceof RegisterOperand) {
if (!killed.contains(op.asRegister().getRegister())) {
nonLocalRegisters.add(op.asRegister().getRegister());
}
}
}
Enumeration<Operand> defs = instr.getDefs();
while (defs.hasMoreElements()) {
Operand op = defs.nextElement();
if (op instanceof RegisterOperand) {
killed.add(op.asRegister().getRegister());
}
}
}
}
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class ValueGraph method processPi.
/**
* Update the value graph to account for a given PI instruction.
*
* <p><b>PRECONDITION:</b> <code> s.operator == PI </code>
*
* @param s the instruction in question
*/
private void processPi(Instruction s) {
Register result = GuardedUnary.getResult(s).getRegister();
ValueGraphVertex v = findOrCreateVertex(result);
Operand val = GuardedUnary.getVal(s);
// bypass Move instructions that define the right-hand side
val = bypassMoves(val);
v.copyVertex(findOrCreateVertex(val));
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class ValueGraph method bypassMoves.
/**
* Bypass MOVE instructions that def an operand: return the first def
* in the chain that is not the result of a MOVE instruction.
* <p>
* Note: treat PI instructions like MOVES
*
* @param op the RegisterOperand
* @return the first def in the chain that is not the result of
* move if it can be found, the original operand otherwise
*/
private Operand bypassMoves(Operand op) {
if (!op.isRegister())
return op;
Register r = op.asRegister().getRegister();
Instruction def = r.getFirstDef();
if (def == null) {
return op;
}
if (r.isPhysical()) {
return op;
}
if (Move.conforms(def)) {
// infinite mutual recursion.
return op;
} else if (def.operator() == PI) {
return bypassMoves(GuardedUnary.getVal(def));
} else {
return op;
}
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class ValueGraph method processPrologue.
/**
* Update the value graph to account for an IR_PROLOGUE instruction
*
* <p><b>PRECONDITION:</b> <code> Prologue.conforms(s); </code>
*
* @param s the instruction in question
*/
private void processPrologue(Instruction s) {
int numArgs = 0;
for (Enumeration<Operand> e = s.getDefs(); e.hasMoreElements(); numArgs++) {
Register formal = ((RegisterOperand) e.nextElement()).getRegister();
ValueGraphVertex v = findOrCreateVertex(formal);
v.setLabel(new ValueGraphParamLabel(numArgs), 0);
}
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class LeaveSSA method unSSAGuardsFinalize.
/**
* Rename registers and delete Phis.
*
* @param ir the governing IR, currently in SSA form
*/
private void unSSAGuardsFinalize(IR ir) {
DefUse.computeDU(ir);
for (Register r = ir.regpool.getFirstSymbolicRegister(); r != null; r = r.getNext()) {
if (!r.isValidation())
continue;
Register nreg = guardFind(r);
Enumeration<RegisterOperand> uses = DefUse.uses(r);
while (uses.hasMoreElements()) {
RegisterOperand use = uses.nextElement();
use.setRegister(nreg);
}
Enumeration<RegisterOperand> defs = DefUse.defs(r);
while (defs.hasMoreElements()) {
RegisterOperand def = defs.nextElement();
def.setRegister(nreg);
}
}
Instruction inst = guardPhis;
while (inst != null) {
inst.remove();
inst = inst2guardPhi.get(inst);
}
}
Aggregations