use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.
the class Simplifier method intShl.
private static DefUseEffect intShl(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_INTEGER_OPS) {
Operand op2 = Binary.getVal2(s);
Operand op1 = Binary.getVal1(s);
if (op2.isIntConstant()) {
int val2 = op2.asIntConstant().value;
if (op1.isIntConstant()) {
// BOTH CONSTANTS: FOLD
int val1 = op1.asIntConstant().value;
Move.mutate(s, INT_MOVE, Binary.getClearResult(s), IC(val1 << val2));
return DefUseEffect.MOVE_FOLDED;
} else {
// ONLY OP2 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if (val2 == 0) {
// x << 0 == x
Move.mutate(s, INT_MOVE, Binary.getClearResult(s), Binary.getClearVal1(s));
return DefUseEffect.MOVE_REDUCED;
}
if ((val2 >= BITS_IN_INT) || (val2 < 0)) {
// x << 32 == 0
Move.mutate(s, INT_MOVE, Binary.getClearResult(s), IC(0));
return DefUseEffect.MOVE_FOLDED;
}
}
} else if (op1.isIntConstant()) {
int val1 = op1.asIntConstant().value;
// ONLY OP1 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if (val1 == 0) {
// 0 << x == 0
Move.mutate(s, INT_MOVE, Binary.getClearResult(s), IC(0));
return DefUseEffect.MOVE_FOLDED;
}
}
}
return DefUseEffect.UNCHANGED;
}
use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.
the class Simplifier method refNot.
private static DefUseEffect refNot(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_REF_OPS) {
Operand op = Unary.getVal(s);
if (op.isConstant() && !op.isMovableObjectConstant()) {
// CONSTANT: FOLD
Word val = getAddressValue(op).toWord();
Move.mutate(s, REF_MOVE, Unary.getClearResult(s), AC(val.not().toAddress()));
return DefUseEffect.MOVE_FOLDED;
}
}
return DefUseEffect.UNCHANGED;
}
use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.
the class Simplifier method intShr.
private static DefUseEffect intShr(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_INTEGER_OPS) {
Operand op1 = Binary.getVal1(s);
Operand op2 = Binary.getVal2(s);
if (op2.isIntConstant()) {
int val2 = op2.asIntConstant().value;
if (op1.isIntConstant()) {
// BOTH CONSTANTS: FOLD
int val1 = op1.asIntConstant().value;
Move.mutate(s, INT_MOVE, Binary.getClearResult(s), IC(val1 >> val2));
return DefUseEffect.MOVE_FOLDED;
} else {
// ONLY OP2 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if (val2 == 0) {
// x >> 0 == x
Move.mutate(s, INT_MOVE, Binary.getClearResult(s), Binary.getClearVal1(s));
return DefUseEffect.MOVE_REDUCED;
}
if ((val2 >= BITS_IN_INT) || (val2 < 0)) {
// x >> 32 == x >> 31
Binary.setVal2(s, IC(31));
return DefUseEffect.UNCHANGED;
}
}
} else if (op1.isIntConstant()) {
int val1 = op1.asIntConstant().value;
// ONLY OP1 IS CONSTANT: ATTEMPT TO APPLY AXIOMS
if ((val1 == -1) || (val1 == 0)) {
// -1 >> x == -1,0 >> x == 0
Move.mutate(s, INT_MOVE, Binary.getClearResult(s), op1);
return DefUseEffect.MOVE_FOLDED;
}
}
}
return DefUseEffect.UNCHANGED;
}
use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.
the class Simplifier method int2Float.
private static DefUseEffect int2Float(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_FLOAT_OPS) {
Operand op = Unary.getVal(s);
if (op.isIntConstant()) {
// CONSTANT: FOLD
int val = op.asIntConstant().value;
Move.mutate(s, FLOAT_MOVE, Unary.getClearResult(s), FC(val));
return DefUseEffect.MOVE_FOLDED;
}
}
return DefUseEffect.UNCHANGED;
}
use of org.jikesrvm.compilers.opt.ir.operand.Operand in project JikesRVM by JikesRVM.
the class Simplifier method int2AddrSigExt.
private static DefUseEffect int2AddrSigExt(Instruction s, OptOptions opts) {
if (opts.SIMPLIFY_REF_OPS) {
Operand op = Unary.getVal(s);
if (op.isIntConstant()) {
// CONSTANT: FOLD
int val = op.asIntConstant().value;
Move.mutate(s, REF_MOVE, Unary.getClearResult(s), AC(Address.fromIntSignExtend(val)));
return DefUseEffect.MOVE_FOLDED;
}
}
return DefUseEffect.UNCHANGED;
}
Aggregations