use of org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand in project JikesRVM by JikesRVM.
the class NormalizeConstants method asRegInt.
static Operand asRegInt(Operand addr, Instruction s, IR ir) {
if (addr instanceof IntConstantOperand) {
RegisterOperand rop = ir.regpool.makeTempInt();
s.insertBefore(Move.create(REF_MOVE, rop, addr));
return rop.copyD2U();
} else if (addr instanceof ConstantOperand) {
// must not happen
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
}
// Operand was OK as is.
return addr;
}
use of org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand in project JikesRVM by JikesRVM.
the class NormalizeConstants method asRegPolymorphic.
static Operand asRegPolymorphic(Operand addr, Instruction s, IR ir) {
if (addr instanceof IntConstantOperand) {
RegisterOperand rop = ir.regpool.makeTempInt();
s.insertBefore(Move.create(REF_MOVE, rop, addr));
return rop.copyD2U();
} else if (addr instanceof AddressConstantOperand) {
RegisterOperand rop = ir.regpool.makeTempAddress();
s.insertBefore(Move.create(REF_MOVE, rop, addr));
return rop.copyD2U();
} else if ((VM.BuildFor64Addr) && (addr instanceof LongConstantOperand)) {
RegisterOperand rop = ir.regpool.makeTempLong();
s.insertBefore(Move.create(REF_MOVE, rop, addr));
return rop.copyD2U();
}
// Operand was OK as is.
return addr;
}
use of org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand in project JikesRVM by JikesRVM.
the class NormalizeConstants method asImmediateOrRegLong.
static Operand asImmediateOrRegLong(Operand addr, Instruction s, IR ir, boolean signed) {
if (VM.BuildFor64Addr && (addr instanceof LongConstantOperand)) {
if (!canBeImmediate(((LongConstantOperand) addr).value, signed)) {
RegisterOperand rop = ir.regpool.makeTempLong();
s.insertBefore(Move.create(REF_MOVE, rop, addr));
return rop.copyD2U();
} else {
// can be immediate --> convert to int
return new IntConstantOperand((int) ((LongConstantOperand) addr).value);
}
} else if (addr instanceof ConstantOperand) {
// must not happen
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
}
// Operand was OK as is.
return addr;
}
use of org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand in project JikesRVM by JikesRVM.
the class NormalizeConstants method asImmediateOrRegPolymorphic.
static Operand asImmediateOrRegPolymorphic(Operand addr, Instruction s, IR ir, boolean signed) {
if (addr instanceof IntConstantOperand) {
if (!canBeImmediate(((IntConstantOperand) addr).value, signed)) {
RegisterOperand rop = ir.regpool.makeTempInt();
s.insertBefore(Move.create(REF_MOVE, rop, addr));
return rop.copyD2U();
}
} else if (addr instanceof AddressConstantOperand) {
if (!canBeImmediate(((AddressConstantOperand) addr).value, signed)) {
RegisterOperand rop = ir.regpool.makeTempAddress();
s.insertBefore(Move.create(REF_MOVE, rop, addr));
return rop.copyD2U();
} else {
// can be immediate --> convert to int
return new IntConstantOperand(((AddressConstantOperand) addr).value.toInt());
}
} else if (VM.BuildFor64Addr && (addr instanceof LongConstantOperand)) {
if (!canBeImmediate(((LongConstantOperand) addr).value, signed)) {
RegisterOperand rop = ir.regpool.makeTempLong();
s.insertBefore(Move.create(REF_MOVE, rop, addr));
return rop.copyD2U();
} else {
// can be immediate --> convert to int
return new IntConstantOperand((int) ((LongConstantOperand) addr).value);
}
}
// Operand was OK as is.
return addr;
}
use of org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand in project JikesRVM by JikesRVM.
the class BURS_Helpers method OSR.
/**
* special case handling OSR instructions expand long type variables to two
* integers
* @param burs the burs instance
* @param s an OSRPoint instruction
*/
protected void OSR(BURS burs, Instruction s) {
if (VM.VerifyAssertions) {
opt_assert(OsrPoint.conforms(s));
}
// Check type info first because this needs to be done
// for both 32-bit and 64-bit cases.
InlinedOsrTypeInfoOperand typeInfo;
if (VM.BuildFor32Addr) {
// Clearing type info is ok, because instruction will be mutated and the
// info will be reinserted
typeInfo = OsrPoint.getClearInlinedTypeInfo(s);
} else {
// Instruction won't be changed so info needs to be left in
typeInfo = OsrPoint.getInlinedTypeInfo(s);
}
if (VM.VerifyAssertions) {
if (typeInfo == null) {
VM.sysWriteln("OsrPoint " + s + " has a <null> type info:");
VM.sysWriteln(" position :" + s.getBytecodeIndex() + "@" + s.position().method);
}
opt_assert(typeInfo != null);
}
int numparam = OsrPoint.getNumberOfElements(s);
if (VM.BuildFor32Addr) {
// 1. how many params
int numlong = 0;
for (int i = 0; i < numparam; i++) {
Operand param = OsrPoint.getElement(s, i);
if (param.getType().isLongType()) {
numlong++;
}
}
// 2. collect params
Operand[] params = new Operand[numparam];
for (int i = 0; i < numparam; i++) {
params[i] = OsrPoint.getClearElement(s, i);
}
// set the number of valid params in osr type info, used
// in LinearScan
typeInfo.validOps = numparam;
// 3: only makes second half register of long being used
// creates room for long types.
burs.append(OsrPoint.mutate(s, s.operator(), typeInfo, numparam + numlong));
int pidx = numparam;
for (int i = 0; i < numparam; i++) {
Operand param = params[i];
OsrPoint.setElement(s, i, param);
if (param instanceof RegisterOperand) {
RegisterOperand rparam = (RegisterOperand) param;
// LinearScan will update the map.
if (rparam.getType().isLongType()) {
OsrPoint.setElement(s, pidx++, L(burs.ir.regpool.getSecondReg(rparam.getRegister())));
}
} else if (param instanceof LongConstantOperand) {
LongConstantOperand val = (LongConstantOperand) param;
if (VM.TraceOnStackReplacement) {
VM.sysWriteln("caught a long const " + val);
}
OsrPoint.setElement(s, i, IC(val.upper32()));
OsrPoint.setElement(s, pidx++, IC(val.lower32()));
} else if (param instanceof IntConstantOperand) {
} else {
throw new OptimizingCompilerException("BURS_Helpers", "unexpected parameter type" + param);
}
}
if (pidx != (numparam + numlong)) {
VM.sysWriteln("pidx = " + pidx);
VM.sysWriteln("numparam = " + numparam);
VM.sysWriteln("numlong = " + numlong);
}
if (VM.VerifyAssertions) {
opt_assert(pidx == (numparam + numlong));
}
} else {
// set the number of valid params in osr type info, used
// in LinearScan
typeInfo.validOps = numparam;
burs.append(s);
}
}
Aggregations