Search in sources :

Example 1 with LIRGenerationContext

use of org.graalvm.compiler.core.LIRGenerationPhase.LIRGenerationContext 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();
    }
}
Also used : ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) FrameMapBuilder(org.graalvm.compiler.lir.framemap.FrameMapBuilder) DebugContext(org.graalvm.compiler.debug.DebugContext) AbstractBlockBase(org.graalvm.compiler.core.common.cfg.AbstractBlockBase) NodeLIRBuilderTool(org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool) LIRGenerationResult(org.graalvm.compiler.lir.gen.LIRGenerationResult) LIRGenerationContext(org.graalvm.compiler.core.LIRGenerationPhase.LIRGenerationContext) LIR(org.graalvm.compiler.lir.LIR) Block(org.graalvm.compiler.nodes.cfg.Block) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) LIRGeneratorTool(org.graalvm.compiler.lir.gen.LIRGeneratorTool)

Example 2 with LIRGenerationContext

use of org.graalvm.compiler.core.LIRGenerationPhase.LIRGenerationContext in project graal by oracle.

the class GraalCompilerState method lirGeneration.

/**
 * Executes the {@link LIRGenerationPhase}.
 */
protected final void lirGeneration() {
    LIRGenerationContext context = new LIRGenerationContext(lirGenTool, nodeLirGen, request.graph, schedule);
    new LIRGenerationPhase().apply(request.backend.getTarget(), lirGenRes, context);
}
Also used : LIRGenerationContext(org.graalvm.compiler.core.LIRGenerationPhase.LIRGenerationContext) LIRGenerationPhase(org.graalvm.compiler.core.LIRGenerationPhase)

Aggregations

LIRGenerationContext (org.graalvm.compiler.core.LIRGenerationPhase.LIRGenerationContext)2 LIRGenerationPhase (org.graalvm.compiler.core.LIRGenerationPhase)1 AbstractBlockBase (org.graalvm.compiler.core.common.cfg.AbstractBlockBase)1 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 LIR (org.graalvm.compiler.lir.LIR)1 FrameMapBuilder (org.graalvm.compiler.lir.framemap.FrameMapBuilder)1 LIRGenerationResult (org.graalvm.compiler.lir.gen.LIRGenerationResult)1 LIRGeneratorTool (org.graalvm.compiler.lir.gen.LIRGeneratorTool)1 ScheduleResult (org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult)1 Block (org.graalvm.compiler.nodes.cfg.Block)1 NodeLIRBuilderTool (org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool)1