use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class SaveCalleeSaveRegisters method restoreAtExit.
private static void restoreAtExit(LIR lir, LIRGeneratorTool.MoveFactory moveFactory, LIRGenerationResult lirGenRes, RegisterMap<Variable> calleeSaveRegisters, AbstractBlockBase<?> block) {
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(block);
int insertionIndex = instructions.size() - 1;
LIRInsertionBuffer buffer = new LIRInsertionBuffer();
buffer.init(instructions);
assert instructions.get(insertionIndex) instanceof StandardOp.BlockEndOp;
calleeSaveRegisters.forEach((Register register, Variable saved) -> {
LIRInstruction restore = moveFactory.createMove(register.asValue(saved.getValueKind()), saved);
buffer.append(insertionIndex, restore);
restore.setComment(lirGenRes, "SaveCalleeSavedRegisters: restoreAtExit");
});
buffer.finish();
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class SaveCalleeSaveRegisters method saveAtEntry.
private static RegisterMap<Variable> saveAtEntry(LIR lir, LIRGeneratorTool lirGen, LIRGenerationResult lirGenRes, RegisterArray calleeSaveRegisters, Architecture arch) {
AbstractBlockBase<?> startBlock = lir.getControlFlowGraph().getStartBlock();
ArrayList<LIRInstruction> instructions = lir.getLIRforBlock(startBlock);
int insertionIndex = 1;
LIRInsertionBuffer buffer = new LIRInsertionBuffer();
buffer.init(instructions);
StandardOp.LabelOp entry = (StandardOp.LabelOp) instructions.get(insertionIndex - 1);
RegisterValue[] savedRegisterValues = new RegisterValue[calleeSaveRegisters.size()];
int savedRegisterValueIndex = 0;
RegisterMap<Variable> saveMap = new RegisterMap<>(arch);
for (Register register : calleeSaveRegisters) {
PlatformKind registerPlatformKind = arch.getLargestStorableKind(register.getRegisterCategory());
LIRKind lirKind = LIRKind.value(registerPlatformKind);
RegisterValue registerValue = register.asValue(lirKind);
Variable saveVariable = lirGen.newVariable(lirKind);
LIRInstruction save = lirGen.getSpillMoveFactory().createMove(saveVariable, registerValue);
buffer.append(insertionIndex, save);
save.setComment(lirGenRes, "SaveCalleeSavedRegisters: saveAtEntry");
saveMap.put(register, saveVariable);
savedRegisterValues[savedRegisterValueIndex++] = registerValue;
}
entry.addIncomingValues(savedRegisterValues);
buffer.finish();
return saveMap;
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class NodeLIRBuilder method createPhiOut.
private Value[] createPhiOut(AbstractMergeNode merge, AbstractEndNode pred) {
List<Value> values = new ArrayList<>();
for (PhiNode phi : merge.valuePhis()) {
ValueNode node = phi.valueAt(pred);
Value value = operand(node);
assert value != null;
if (isRegister(value)) {
/*
* Fixed register intervals are not allowed at block boundaries so we introduce a
* new Variable.
*/
value = gen.emitMove(value);
} else if (!allowObjectConstantToStackMove() && node instanceof ConstantNode && !LIRKind.isValue(value)) {
/*
* Some constants are not allowed as inputs for PHIs in certain backends. Explicitly
* create a copy of this value to force it into a register. The new variable is only
* used in the PHI.
*/
Variable result = gen.newVariable(value.getValueKind());
gen.emitMove(result, value);
value = result;
}
values.add(value);
}
return values.toArray(new Value[values.size()]);
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class LIRGenerator method emitLoadConstant.
@Override
public AllocatableValue emitLoadConstant(ValueKind<?> kind, Constant constant) {
Variable result = newVariable(kind);
emitMoveConstant(result, constant);
return result;
}
use of org.graalvm.compiler.lir.Variable in project graal by oracle.
the class JVMCIInfopointErrorTest method testInvalidShortDerivedOop.
@Test(expected = Error.class)
public void testInvalidShortDerivedOop() {
test((tool, state, safepoint) -> {
Variable baseOop = tool.newVariable(LIRKind.fromJavaKind(tool.target().arch, JavaKind.Object));
tool.append(new ValueDef(baseOop));
PlatformKind kind = tool.target().arch.getPlatformKind(JavaKind.Short);
LIRKind lirKind = LIRKind.derivedReference(kind, baseOop, false);
Variable var = tool.newVariable(lirKind);
tool.append(new ValueDef(var));
safepoint.accept(state);
tool.append(new ValueUse(var));
});
}
Aggregations