use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class TraceLocalMoveResolver method insertMove.
private void insertMove(Constant fromOpr, TraceInterval toInterval) {
assert insertIdx != -1 : "must setup insert position first";
AllocatableValue toOpr = allocator.getOperand(toInterval);
LIRInstruction move = getAllocator().getSpillMoveFactory().createLoad(toOpr, fromOpr);
insertionBuffer.append(insertIdx, move);
if (debug.isLogEnabled()) {
debug.log("insert move from value %s to %s at %d", fromOpr, toInterval, insertIdx);
}
}
use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class RegisterVerifier method processOperations.
void processOperations(AbstractBlockBase<?> block, final TraceInterval[] inputState) {
ArrayList<LIRInstruction> ops = allocator.getLIR().getLIRforBlock(block);
DebugContext debug = allocator.getDebug();
InstructionValueConsumer useConsumer = new InstructionValueConsumer() {
@Override
public void visitValue(LIRInstruction op, Value operand, OperandMode mode, EnumSet<OperandFlag> flags) {
// we skip spill moves inserted by the spill position optimization
if (isVariableOrRegister(operand) && allocator.isProcessed(operand) && op.id() != TraceLinearScanPhase.DOMINATOR_SPILL_MOVE_ID) {
TraceInterval interval = intervalAt(asVariable(operand));
if (op.id() != -1) {
interval = interval.getSplitChildAtOpId(op.id(), mode);
}
assert checkState(block, op, inputState, allocator.getOperand(interval), interval.location(), interval.splitParent());
}
}
};
InstructionValueConsumer defConsumer = (op, operand, mode, flags) -> {
if (isVariableOrRegister(operand) && allocator.isProcessed(operand)) {
TraceInterval interval = intervalAt(asVariable(operand));
if (op.id() != -1) {
interval = interval.getSplitChildAtOpId(op.id(), mode);
}
statePut(debug, inputState, interval.location(), interval.splitParent());
}
};
// visit all instructions of the block
for (int i = 0; i < ops.size(); i++) {
final LIRInstruction op = ops.get(i);
if (debug.isLogEnabled()) {
debug.log("%s", op.toStringWithIdPrefix());
}
// check if input operands are correct
op.visitEachInput(useConsumer);
// invalidate all caller save registers at calls
if (op.destroysCallerSavedRegisters()) {
for (Register r : allocator.getRegisterAllocationConfig().getRegisterConfig().getCallerSaveRegisters()) {
statePut(debug, inputState, r.asValue(), null);
}
}
op.visitEachAlive(useConsumer);
// set temp operands (some operations use temp operands also as output operands, so
// can't set them null)
op.visitEachTemp(defConsumer);
// set output operands
op.visitEachOutput(defConsumer);
}
}
use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class PhiResolver method create.
public static PhiResolver create(LIRGeneratorTool gen) {
AbstractBlockBase<?> block = gen.getCurrentBlock();
assert block != null;
ArrayList<LIRInstruction> instructions = gen.getResult().getLIR().getLIRforBlock(block);
return new PhiResolver(gen, new LIRInsertionBuffer(), instructions, instructions.size());
}
use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class FrameMapBuilderImpl method verifyStackSlotAllocation.
private static void verifyStackSlotAllocation(LIRGenerationResult res) {
LIR lir = res.getLIR();
InstructionValueConsumer verifySlots = (LIRInstruction op, Value value, OperandMode mode, EnumSet<OperandFlag> flags) -> {
assert !isVirtualStackSlot(value) : String.format("Instruction %s contains a virtual stack slot %s", op, value);
};
for (AbstractBlockBase<?> block : lir.getControlFlowGraph().getBlocks()) {
lir.getLIRforBlock(block).forEach(op -> {
op.visitEachInput(verifySlots);
op.visitEachAlive(verifySlots);
op.visitEachState(verifySlots);
op.visitEachTemp(verifySlots);
op.visitEachOutput(verifySlots);
});
}
}
use of org.graalvm.compiler.lir.LIRInstruction in project graal by oracle.
the class SSAVerifier method verifyBlock.
private boolean verifyBlock(AbstractBlockBase<?> block) {
currentBlock = block;
assert !visited.get(block.getId()) : "Block already visited: " + block;
visited.set(block.getId());
for (LIRInstruction op : lir.getLIRforBlock(block)) {
op.visitEachAlive(this::useConsumer);
op.visitEachState(this::useConsumer);
op.visitEachInput(this::useConsumer);
op.visitEachTemp(this::defConsumer);
op.visitEachOutput(this::defConsumer);
}
currentBlock = null;
return true;
}
Aggregations