use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class ComplexLIR2MIRExpansion method get_time_base.
private static void get_time_base(Instruction s, IR ir) {
if (VM.BuildFor32Addr) {
BasicBlock BB1 = s.getBasicBlock();
BB1 = BB1.segregateInstruction(s, ir);
Register defHigh = Nullary.getResult(s).getRegister();
Register defLow = ir.regpool.getSecondReg(defHigh);
Register t0 = ir.regpool.getInteger();
Register cr = ir.regpool.getCondition();
defLow.setSpansBasicBlock();
defHigh.setSpansBasicBlock();
// Try to get the base
Register TU = ir.regpool.getPhysicalRegisterSet().asPPC().getTU();
Register TL = ir.regpool.getPhysicalRegisterSet().asPPC().getTL();
s.insertBefore(MIR_Move.create(PPC_MFTBU, I(defHigh), I(TU)));
s.insertBefore(MIR_Move.create(PPC_MFTB, I(defLow), I(TL)));
// Try again to see if it changed
s.insertBefore(MIR_Move.create(PPC_MFTBU, I(t0), I(TU)));
s.insertBefore(MIR_Binary.create(PPC_CMP, I(cr), I(t0), I(defHigh)));
MIR_CondBranch.mutate(s, PPC_BCOND, I(cr), PowerPCConditionOperand.NOT_EQUAL(), BB1.makeJumpTarget(), new BranchProfileOperand());
// fix up CFG
BB1.insertOut(BB1);
} else {
// We read the 64-bit time base register atomically
Register def = Nullary.getResult(s).getRegister();
// See PowerPC Architecture, Book II, pp.352-353
Register TL = ir.regpool.getPhysicalRegisterSet().asPPC().getTL();
MIR_Move.mutate(s, PPC_MFTB, L(def), L(TL));
}
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class LiveAnalysis method getLiveRegistersOnEntry.
/**
* @param bb the basic block we're interested in
* @return the set of registers that are live across a basic block, and who
* are live before the basic block entry.
*/
HashSet<Register> getLiveRegistersOnEntry(BasicBlock bb) {
HashSet<Register> result = new HashSet<Register>(10);
for (Enumeration<LiveIntervalElement> e = liveIntervals.enumerateLiveIntervals(bb); e.hasMoreElements(); ) {
LiveIntervalElement lie = e.nextElement();
Instruction begin = lie.getBegin();
if (begin == null)
result.add(lie.getRegister());
}
return result;
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class LiveAnalysis method getLiveRegistersOnExit.
/**
* @param bb the basic block we're interested in
* @return the set of registers that are live across a basic block, and who
* are live after the basic block exit.
*/
HashSet<Register> getLiveRegistersOnExit(BasicBlock bb) {
HashSet<Register> result = new HashSet<Register>(10);
for (Enumeration<LiveIntervalElement> e = liveIntervals.enumerateLiveIntervals(bb); e.hasMoreElements(); ) {
LiveIntervalElement lie = e.nextElement();
Instruction end = lie.getEnd();
if (end == null)
result.add(lie.getRegister());
}
return result;
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class LoadElimination method findOrCreateRegister.
/**
* Given a value number, return the temporary register allocated
* for that value number. Create one if necessary.
*
* @param heapType a TypeReference or RVMField identifying the array SSA
* heap type
* @param valueNumber the value number
* @param registers a mapping from value number to temporary register
* @param pool register pool to allocate new temporaries from
* @param type the type to store in the new register
*
* @return the temporary register allocated for the value number
*/
static Register findOrCreateRegister(Object heapType, int valueNumber, HashMap<UseRecord, Register> registers, GenericRegisterPool pool, TypeReference type) {
UseRecord key = new UseRecord(heapType, valueNumber);
Register result = registers.get(key);
if (result == null) {
// create a new temp and insert it in the mapping
result = pool.makeTemp(type).getRegister();
registers.put(key, result);
}
return result;
}
use of org.jikesrvm.compilers.opt.ir.Register in project JikesRVM by JikesRVM.
the class LoopVersioning method perform.
/**
* @param _ir the IR to process
*/
@Override
public void perform(IR _ir) {
ir = _ir;
// Create SSA
ir.desiredSSAOptions = desiredSSAOptions;
if (!inSSAphase) {
enterSSA.perform(ir);
}
if (DEBUG) {
SSA.printInstructions(ir);
}
// Perform loop annotation
if (!ir.hasReachableExceptionHandlers()) {
// Build LST tree and dominator info
domPhase.perform(ir);
DefUse.computeDU(ir);
// Build annotated version
ir.HIRInfo.loopStructureTree = new AnnotatedLSTGraph(ir, ir.HIRInfo.loopStructureTree);
}
if (VERIFY) {
ir.verify(getName(), true);
}
// Check loop annotation has been performed
if (!(ir.HIRInfo.loopStructureTree instanceof AnnotatedLSTGraph)) {
report("Optimisation of " + ir.getMethod() + " failed as LST wasn't annotated\n");
} else {
loopRegisterSet = new HashSet<Register>();
if (DEBUG) {
VM.sysWriteln(ir.getMethod().toString());
VM.sysWriteln(ir.HIRInfo.loopStructureTree.toString());
SSA.printInstructions(ir);
}
while (findLoopToOptimise((AnnotatedLSTNode) ir.HIRInfo.loopStructureTree.getRoot())) {
if (DEBUG) {
VM.sysWriteln("Successful optimisation of " + ir.getMethod());
SSA.printInstructions(ir);
VM.sysWriteln(ir.cfg.toString());
}
// Get IR into shape for next pass
DefUse.computeDU(ir);
LTDominators.perform(ir, true, true);
ir.HIRInfo.dominatorTree = new DominatorTree(ir, true);
LSTGraph.perform(ir);
AnnotatedLSTGraph.perform(ir);
if (VERIFY) {
ir.verify(getName(), true);
}
if (DEBUG) {
VM.sysWriteln("after an optimization pass");
VM.sysWriteln(ir.HIRInfo.loopStructureTree.toString());
SSA.printInstructions(ir);
VM.sysWriteln("Finish optimize: " + ir.getMethod().toString());
}
}
// No longer in use
loopRegisterSet = null;
}
if (!inSSAphase) {
// Leave SSA
leaveSSA.perform(ir);
}
if (VERIFY) {
ir.verify(getName(), true);
}
}
Aggregations