use of org.jikesrvm.compilers.opt.ir.Operator in project JikesRVM by JikesRVM.
the class ComplexLIR2MIRExpansion method boolean_cmp.
private static void boolean_cmp(Instruction s, IR ir, boolean cmp32Bit) {
// undo the optimization because it cannot efficiently be generated
Register res = BooleanCmp.getClearResult(s).getRegister();
RegisterOperand one = (RegisterOperand) BooleanCmp.getClearVal1(s);
Operand two = BooleanCmp.getClearVal2(s);
ConditionOperand cond = BooleanCmp.getClearCond(s);
res.setSpansBasicBlock();
BasicBlock BB1 = s.getBasicBlock();
BasicBlock BB4 = BB1.splitNodeAt(s, ir);
s = s.remove();
BasicBlock BB2 = BB1.createSubBlock(0, ir);
BasicBlock BB3 = BB1.createSubBlock(0, ir);
RegisterOperand t = ir.regpool.makeTempInt();
t.getRegister().setCondition();
Operator op;
if (VM.BuildFor64Addr && !cmp32Bit) {
if (two instanceof IntConstantOperand) {
op = cond.isUNSIGNED() ? PPC64_CMPLI : PPC64_CMPI;
} else {
op = cond.isUNSIGNED() ? PPC64_CMPL : PPC64_CMP;
}
} else if (two instanceof IntConstantOperand) {
op = cond.isUNSIGNED() ? PPC_CMPLI : PPC_CMPI;
} else {
op = cond.isUNSIGNED() ? PPC_CMPL : PPC_CMP;
}
BB1.appendInstruction(MIR_Binary.create(op, t, one, two));
BB1.appendInstruction(MIR_CondBranch.create(PPC_BCOND, t.copyD2U(), PowerPCConditionOperand.get(cond), BB3.makeJumpTarget(), new BranchProfileOperand()));
BB2.appendInstruction(MIR_Unary.create(PPC_LDI, I(res), IC(0)));
BB2.appendInstruction(MIR_Branch.create(PPC_B, BB4.makeJumpTarget()));
BB3.appendInstruction(MIR_Unary.create(PPC_LDI, I(res), IC(1)));
// fix CFG
BB1.insertOut(BB2);
BB1.insertOut(BB3);
BB2.insertOut(BB4);
BB3.insertOut(BB4);
ir.cfg.linkInCodeOrder(BB1, BB2);
ir.cfg.linkInCodeOrder(BB2, BB3);
ir.cfg.linkInCodeOrder(BB3, BB4);
}
use of org.jikesrvm.compilers.opt.ir.Operator in project JikesRVM by JikesRVM.
the class PiNodes method cleanUp.
/**
* Change all PI nodes to INT_MOVE instructions
* <p> Side effect: invalidates SSA state
*
* @param ir the governing IR
*/
static void cleanUp(IR ir) {
for (Enumeration<Instruction> e = ir.forwardInstrEnumerator(); e.hasMoreElements(); ) {
Instruction s = e.nextElement();
if (s.operator() == PI) {
RegisterOperand result = GuardedUnary.getResult(s);
Operator mv = IRTools.getMoveOp(result.getType());
Operand val = GuardedUnary.getVal(s);
Move.mutate(s, mv, result, val);
}
}
// invalidate SSA state
ir.actualSSAOptions = null;
}
use of org.jikesrvm.compilers.opt.ir.Operator in project JikesRVM by JikesRVM.
the class StackManager method insertSpillBefore.
@Override
public void insertSpillBefore(Instruction s, Register r, Register type, int location) {
Operator move = getMoveOperator(type);
byte size = getSizeOfType(type);
RegisterOperand rOp;
if (type.isFloat()) {
rOp = F(r);
} else if (type.isDouble()) {
rOp = D(r);
} else {
if (VM.BuildFor64Addr && type.isInteger()) {
rOp = new RegisterOperand(r, TypeReference.Int);
} else {
rOp = new RegisterOperand(r, PRIMITIVE_TYPE_FOR_WORD);
}
}
StackLocationOperand spillLoc = new StackLocationOperand(true, -location, size);
Instruction spillOp = MIR_Move.create(move, spillLoc, rOp);
if (VERBOSE_DEBUG) {
System.out.println("INSERT_SPILL_BEFORE: " + "Inserting " + spillOp + " before " + s);
}
s.insertBefore(spillOp);
}
use of org.jikesrvm.compilers.opt.ir.Operator in project JikesRVM by JikesRVM.
the class BURS_Helpers method CMP.
/**
* emit basic code to handle an INT_IFCMP when no folding
* of the compare into some other computation is possible.
*/
protected final void CMP(Instruction s, RegisterOperand val1, Operand val2, ConditionOperand cond, boolean immediate) {
RegisterOperand cr = regpool.makeTempCondition();
Operator op;
if (immediate) {
op = cond.isUNSIGNED() ? PPC_CMPLI : PPC_CMPI;
} else {
op = cond.isUNSIGNED() ? PPC_CMPL : PPC_CMP;
}
EMIT(MIR_Binary.create(op, cr, val1, val2));
EMIT(MIR_CondBranch.mutate(s, PPC_BCOND, cr.copyD2U(), new PowerPCConditionOperand(cond), IfCmp.getTarget(s), IfCmp.getBranchProfile(s)));
}
use of org.jikesrvm.compilers.opt.ir.Operator in project JikesRVM by JikesRVM.
the class Simple method typePropagation.
/**
* Perform flow-insensitive type propagation using register list
* information. Note: register list MUST be initialized BEFORE
* calling this routine.
*
* <p> Kept separate from copyPropagation loop to enable clients
* more flexibility.
*
* @param ir the IR in question
*/
static void typePropagation(IR ir) {
// Use register list to enumerate register objects (FAST)
Register elemNext;
for (Register reg = ir.regpool.getFirstSymbolicRegister(); reg != null; reg = elemNext) {
elemNext = reg.getNext();
// Type propagation not possible if reg has no uses
if (reg.useList == null) {
continue;
}
// Type propagation not possible if reg has no defs
if (reg.defList == null) {
continue;
}
// Do not attempt type propagation if reg has multiple defs
if (!reg.isSSA()) {
continue;
}
// Now reg has exactly one definition
RegisterOperand lhs = reg.defList;
Instruction instr = lhs.instruction;
Operator op = instr.operator();
// Type propagation not possible if lhs is not in a move instr
if (!op.isMove()) {
continue;
}
Operand rhsOp = Move.getVal(instr);
// Do not attempt type propagation if RHS is not a register
if (!(rhsOp instanceof RegisterOperand)) {
continue;
}
RegisterOperand rhs = (RegisterOperand) rhsOp;
// Propagate the type in the def
lhs.copyTypeFrom(rhs);
// Now propagate lhs into all uses; substitute rhs.type for lhs.type
for (RegisterOperand use = reg.useList; use != null; use = use.getNext()) {
// because use.type has more detailed information
if (ClassLoaderProxy.includesType(rhs.getType(), use.getType()) == YES) {
continue;
}
// don't undo the effects!
if (rhs.getType().isPrimitiveType() && !use.getType().isPrimitiveType()) {
continue;
}
use.copyTypeFrom(rhs);
}
}
}
Aggregations