use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class LIRGenerationPhase method emitBlock.
private static void emitBlock(NodeLIRBuilderTool nodeLirGen, LIRGenerationResult lirGenRes, Block b, StructuredGraph graph, BlockMap<List<Node>> blockMap) {
assert !isProcessed(lirGenRes, b) : "Block already processed " + b;
assert verifyPredecessors(lirGenRes, b);
nodeLirGen.doBlock(b, graph, blockMap);
LIR lir = lirGenRes.getLIR();
DebugContext debug = lir.getDebug();
instructionCounter.add(debug, lir.getLIRforBlock(b).size());
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class GraalCompiler method emitLIR0.
@SuppressWarnings("try")
private static LIRGenerationResult emitLIR0(Backend backend, StructuredGraph graph, Object stub, RegisterConfig registerConfig, LIRSuites lirSuites, String[] allocationRestrictedTo) {
DebugContext debug = graph.getDebug();
try (DebugContext.Scope ds = debug.scope("EmitLIR");
DebugCloseable a = EmitLIR.start(debug)) {
assert !graph.hasValueProxies();
ScheduleResult schedule = graph.getLastSchedule();
Block[] blocks = schedule.getCFG().getBlocks();
Block startBlock = schedule.getCFG().getStartBlock();
assert startBlock != null;
assert startBlock.getPredecessorCount() == 0;
AbstractBlockBase<?>[] codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, startBlock);
AbstractBlockBase<?>[] linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, startBlock);
LIR lir = new LIR(schedule.getCFG(), linearScanOrder, codeEmittingOrder, graph.getOptions(), graph.getDebug());
FrameMapBuilder frameMapBuilder = backend.newFrameMapBuilder(registerConfig);
LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(graph.compilationId(), lir, frameMapBuilder, graph, stub);
LIRGeneratorTool lirGen = backend.newLIRGenerator(lirGenRes);
NodeLIRBuilderTool nodeLirGen = backend.newNodeLIRBuilder(graph, lirGen);
// LIR generation
LIRGenerationContext context = new LIRGenerationContext(lirGen, nodeLirGen, graph, schedule);
new LIRGenerationPhase().apply(backend.getTarget(), lirGenRes, context);
try (DebugContext.Scope s = debug.scope("LIRStages", nodeLirGen, lirGenRes, lir)) {
// Dump LIR along with HIR (the LIR is looked up from context)
debug.dump(DebugContext.BASIC_LEVEL, graph.getLastSchedule(), "After LIR generation");
LIRGenerationResult result = emitLowLevel(backend.getTarget(), lirGenRes, lirGen, lirSuites, backend.newRegisterAllocationConfig(registerConfig, allocationRestrictedTo));
return result;
} catch (Throwable e) {
throw debug.handle(e);
}
} catch (Throwable e) {
throw debug.handle(e);
} finally {
graph.checkCancellation();
}
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class LIRGenerator method append.
@Override
public <I extends LIRInstruction> I append(I op) {
LIR lir = res.getLIR();
if (printIrWithLir) {
TTY.println(op.toStringWithIdPrefix());
TTY.println();
}
assert LIRVerifier.verify(op);
ArrayList<LIRInstruction> lirForBlock = lir.getLIRforBlock(getCurrentBlock());
op.setPosition(currentPosition);
lirForBlock.add(op);
return op;
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class SPARCHotSpotBackend method newCompilationResultBuilder.
@Override
public CompilationResultBuilder newCompilationResultBuilder(LIRGenerationResult lirGenRes, FrameMap frameMap, CompilationResult compilationResult, CompilationResultBuilderFactory factory) {
HotSpotLIRGenerationResult gen = (HotSpotLIRGenerationResult) lirGenRes;
LIR lir = gen.getLIR();
assert gen.getDeoptimizationRescueSlot() == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame";
Stub stub = gen.getStub();
Assembler masm = createAssembler(frameMap);
// On SPARC we always use stack frames.
HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null);
DataBuilder dataBuilder = new HotSpotDataBuilder(getCodeCache().getTarget());
OptionValues options = lir.getOptions();
DebugContext debug = lir.getDebug();
CompilationResultBuilder crb = factory.createBuilder(getProviders().getCodeCache(), getProviders().getForeignCalls(), frameMap, masm, dataBuilder, frameContext, options, debug, compilationResult);
crb.setTotalFrameSize(frameMap.totalFrameSize());
crb.setMaxInterpreterFrameSize(gen.getMaxInterpreterFrameSize());
StackSlot deoptimizationRescueSlot = gen.getDeoptimizationRescueSlot();
if (deoptimizationRescueSlot != null && stub == null) {
crb.compilationResult.setCustomStackAreaOffset(deoptimizationRescueSlot);
}
if (stub != null) {
// Even on sparc we need to save floating point registers
EconomicSet<Register> destroyedCallerRegisters = gatherDestroyedCallerRegisters(lir);
EconomicMap<LIRFrameState, SaveRegistersOp> calleeSaveInfo = gen.getCalleeSaveInfo();
updateStub(stub, destroyedCallerRegisters, calleeSaveInfo, frameMap);
}
assert registerSizePredictionValidator(crb, debug);
return crb;
}
use of org.graalvm.compiler.lir.LIR in project graal by oracle.
the class GraalCompilerState method preLIRGeneration.
/**
* Sets up {@link LIR} generation.
*/
protected final void preLIRGeneration() {
assert request.graph.isFrozen() : "Graph not frozen.";
Object stub = null;
schedule = request.graph.getLastSchedule();
ControlFlowGraph cfg = deepCopy(schedule.getCFG());
Block[] blocks = cfg.getBlocks();
Block startBlock = cfg.getStartBlock();
assert startBlock != null;
assert startBlock.getPredecessorCount() == 0;
codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, startBlock);
linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, startBlock);
LIR lir = new LIR(cfg, linearScanOrder, codeEmittingOrder, getGraphOptions(), getGraphDebug());
FrameMapBuilder frameMapBuilder = request.backend.newFrameMapBuilder(registerConfig);
lirGenRes = request.backend.newLIRGenerationResult(graph.compilationId(), lir, frameMapBuilder, request.graph, stub);
lirGenTool = request.backend.newLIRGenerator(lirGenRes);
nodeLirGen = request.backend.newNodeLIRBuilder(request.graph, lirGenTool);
}
Aggregations