use of org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand in project JikesRVM by JikesRVM.
the class InstrumentationSamplingFramework method appendLoad.
/**
* Append a load of the global counter to the given basic block.
*
* WARNING: Tested for LIR only!
*
* @param bb The block to append the load to
* @param ir The IR
*/
private void appendLoad(BasicBlock bb, IR ir) {
if (DEBUG)
VM.sysWriteln("Adding load to " + bb);
Instruction load = null;
if (ir.options.ADAPTIVE_PROCESSOR_SPECIFIC_COUNTER) {
if (ir.isHIR()) {
VM.sysFail("Not implemented yet.");
} else {
// Phase is being used in LIR
if (VM.VerifyAssertions)
VM._assert(ir.isLIR());
// Insert the load instruction.
load = Load.create(INT_LOAD, cbsReg.copyRO(), ir.regpool.makeTROp(), IRTools.AC(AosEntrypoints.threadCBSField.getOffset()), new LocationOperand(AosEntrypoints.threadCBSField));
bb.appendInstruction(load);
}
} else {
// Use global counter
if (ir.isHIR()) {
Operand offsetOp = new AddressConstantOperand(AosEntrypoints.globalCBSField.getOffset());
load = GetStatic.create(GETSTATIC, cbsReg.copyRO(), offsetOp, new LocationOperand(AosEntrypoints.globalCBSField));
bb.appendInstruction(load);
} else {
// LIR
Instruction dummy = Load.create(INT_LOAD, null, null, null, null);
bb.appendInstruction(dummy);
load = Load.create(INT_LOAD, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
dummy.insertBefore(load);
dummy.remove();
}
}
}
use of org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand in project JikesRVM by JikesRVM.
the class InstrumentationSamplingFramework method prependCounterReset.
/**
* Prepend the code to reset the global counter to the given basic
* block.
*
* Warning: Tested in LIR only!
*
* @param bb The block to append the load to
* @param ir The IR
*/
private void prependCounterReset(BasicBlock bb, IR ir) {
Instruction load = null;
Instruction store = null;
if (ir.isHIR()) {
// Not tested
Operand offsetOp = new AddressConstantOperand(AosEntrypoints.cbsResetValueField.getOffset());
load = GetStatic.create(GETSTATIC, cbsReg.copyRO(), offsetOp, new LocationOperand(AosEntrypoints.cbsResetValueField));
store = PutStatic.create(PUTSTATIC, cbsReg.copyRO(), new AddressConstantOperand(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
bb.prependInstruction(store);
bb.prependInstruction(load);
} else {
// LIR
if (VM.VerifyAssertions)
VM._assert(ir.isLIR());
Instruction dummy = Load.create(INT_LOAD, null, null, null, null);
bb.prependInstruction(dummy);
// Load the reset value
load = Load.create(INT_LOAD, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.cbsResetValueField.getOffset()), new LocationOperand(AosEntrypoints.cbsResetValueField));
dummy.insertBefore(load);
// Store it in the counter register
if (ir.options.ADAPTIVE_PROCESSOR_SPECIFIC_COUNTER) {
store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeTROp(), IRTools.AC(AosEntrypoints.threadCBSField.getOffset()), new LocationOperand(AosEntrypoints.threadCBSField));
} else {
// Use global counter
store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
}
dummy.insertBefore(store);
dummy.remove();
}
}
use of org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand in project JikesRVM by JikesRVM.
the class InstrumentationSamplingFramework method prependStore.
/**
* Append a store of the global counter to the given basic block.
*
* WARNING: Tested in LIR only!
*
* @param bb The block to append the load to
* @param ir The IR
*/
private void prependStore(BasicBlock bb, IR ir) {
if (DEBUG)
VM.sysWriteln("Adding store to " + bb);
Instruction store = null;
if (ir.options.ADAPTIVE_PROCESSOR_SPECIFIC_COUNTER) {
store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeTROp(), IRTools.AC(AosEntrypoints.threadCBSField.getOffset()), new LocationOperand(AosEntrypoints.threadCBSField));
bb.prependInstruction(store);
} else {
if (ir.isHIR()) {
store = PutStatic.create(PUTSTATIC, cbsReg.copyRO(), new AddressConstantOperand(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
bb.prependInstruction(store);
} else {
Instruction dummy = Load.create(INT_LOAD, null, null, null, null);
bb.prependInstruction(dummy);
store = Store.create(INT_STORE, cbsReg.copyRO(), ir.regpool.makeJTOCOp(), IRTools.AC(AosEntrypoints.globalCBSField.getOffset()), new LocationOperand(AosEntrypoints.globalCBSField));
dummy.insertBefore(store);
dummy.remove();
}
}
}
use of org.jikesrvm.compilers.opt.ir.operand.AddressConstantOperand in project JikesRVM by JikesRVM.
the class NormalizeConstants method asRegOffset.
static Operand asRegOffset(Operand addr, Instruction s, IR ir) {
if (addr instanceof AddressConstantOperand) {
RegisterOperand rop = ir.regpool.makeTempOffset();
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.AddressConstantOperand in project JikesRVM by JikesRVM.
the class NormalizeConstants method asImmediateOrRegOffset.
static Operand asImmediateOrRegOffset(Operand addr, Instruction s, IR ir, boolean signed) {
if (addr instanceof AddressConstantOperand) {
if (!canBeImmediate(((AddressConstantOperand) addr).value, signed)) {
RegisterOperand rop = ir.regpool.makeTempOffset();
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 (addr instanceof ConstantOperand) {
// must not happen, because is 64-bit unsafe
if (VM.VerifyAssertions)
VM._assert(VM.NOT_REACHED);
}
// Operand was OK as is.
return addr;
}
Aggregations