Search in sources :

Example 1 with NodeLIRBuilderTool

use of org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool 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 NodeLIRBuilderTool

use of org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool in project graal by oracle.

the class LIRGenerationPhase method run.

@Override
protected final void run(TargetDescription target, LIRGenerationResult lirGenRes, LIRGenerationPhase.LIRGenerationContext context) {
    NodeLIRBuilderTool nodeLirBuilder = context.nodeLirBuilder;
    StructuredGraph graph = context.graph;
    ScheduleResult schedule = context.schedule;
    for (AbstractBlockBase<?> b : lirGenRes.getLIR().getControlFlowGraph().getBlocks()) {
        emitBlock(nodeLirBuilder, lirGenRes, (Block) b, graph, schedule.getBlockToNodesMap());
    }
    context.lirGen.beforeRegisterAllocation();
    assert SSAUtil.verifySSAForm(lirGenRes.getLIR());
    nodeCount.add(graph.getDebug(), graph.getNodeCount());
}
Also used : ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) NodeLIRBuilderTool(org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool)

Aggregations

ScheduleResult (org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult)2 NodeLIRBuilderTool (org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool)2 LIRGenerationContext (org.graalvm.compiler.core.LIRGenerationPhase.LIRGenerationContext)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 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 Block (org.graalvm.compiler.nodes.cfg.Block)1