Search in sources :

Example 1 with LowTierContext

use of org.graalvm.compiler.phases.tiers.LowTierContext in project graal by oracle.

the class AArch64HotSpotSuitesProvider method createSuites.

@Override
public Suites createSuites(OptionValues options) {
    Suites suites = super.createSuites(options);
    ListIterator<BasePhase<? super LowTierContext>> findPhase = suites.getLowTier().findPhase(FixReadsPhase.class);
    if (findPhase == null) {
        findPhase = suites.getLowTier().findPhase(ExpandLogicPhase.class);
    }
    findPhase.add(new AddressLoweringByUsePhase(addressLoweringByUse));
    // Put AArch64ReadReplacementPhase right before the SchedulePhase
    findPhase = suites.getLowTier().findPhase(SchedulePhase.class);
    while (PhaseSuite.findNextPhase(findPhase, SchedulePhase.class)) {
    // Search for last occurrence of SchedulePhase
    }
    findPhase.previous();
    findPhase.add(new AArch64ReadReplacementPhase());
    return suites;
}
Also used : LowTierContext(org.graalvm.compiler.phases.tiers.LowTierContext) SchedulePhase(org.graalvm.compiler.phases.schedule.SchedulePhase) AArch64ReadReplacementPhase(org.graalvm.compiler.replacements.aarch64.AArch64ReadReplacementPhase) ExpandLogicPhase(org.graalvm.compiler.phases.common.ExpandLogicPhase) AddressLoweringByUsePhase(org.graalvm.compiler.phases.common.AddressLoweringByUsePhase) BasePhase(org.graalvm.compiler.phases.BasePhase) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 2 with LowTierContext

use of org.graalvm.compiler.phases.tiers.LowTierContext in project graal by oracle.

the class NativeImageGenerator method createSuites.

public static Suites createSuites(FeatureHandler featureHandler, RuntimeConfiguration runtimeConfig, SnippetReflectionProvider snippetReflection, boolean hosted) {
    Providers runtimeCallProviders = runtimeConfig.getBackendForNormalMethod().getProviders();
    OptionValues options = hosted ? HostedOptionValues.singleton() : RuntimeOptionValues.singleton();
    Suites suites = GraalConfiguration.instance().createSuites(options, hosted);
    PhaseSuite<HighTierContext> highTier = suites.getHighTier();
    PhaseSuite<MidTierContext> midTier = suites.getMidTier();
    PhaseSuite<LowTierContext> lowTier = suites.getLowTier();
    ListIterator<BasePhase<? super HighTierContext>> position;
    if (hosted) {
        position = GraalConfiguration.instance().createHostedInliners(highTier);
    } else {
        /* Find the runtime inliner. */
        position = highTier.findPhase(InliningPhase.class);
    }
    if (position != null) {
        /* These two phases must be after all method inlining. */
        position.add(new DeadStoreRemovalPhase());
        position.add(new RemoveUnwindPhase());
    } else {
        /* There is no inlining, so prepend them in reverse order. */
        highTier.prependPhase(new RemoveUnwindPhase());
        highTier.prependPhase(new DeadStoreRemovalPhase());
    }
    highTier.appendPhase(new StackValuePhase());
    lowTier.addBeforeLast(new OptimizeExceptionCallsPhase());
    CompressEncoding compressEncoding = ImageSingletons.lookup(CompressEncoding.class);
    SubstrateAMD64RegisterConfig registerConfig = (SubstrateAMD64RegisterConfig) runtimeCallProviders.getCodeCache().getRegisterConfig();
    SubstrateAMD64AddressLowering addressLowering = new SubstrateAMD64AddressLowering(compressEncoding, registerConfig);
    lowTier.findPhase(FixReadsPhase.class).add(new AddressLoweringPhase(addressLowering));
    if (SubstrateOptions.MultiThreaded.getValue()) {
        /*
             * Graal inserts only loop safepoints. We want a SafepointNode also before every return.
             */
        midTier.findPhase(LoopSafepointInsertionPhase.class).add(new MethodSafepointInsertionPhase());
    } else {
        /* No need for safepoints when we have only one thread. */
        VMError.guarantee(midTier.removePhase(LoopSafepointInsertionPhase.class));
    }
    if (hosted) {
        lowTier.appendPhase(new VerifyNoGuardsPhase());
        /* Disable the Graal method inlining, since we have our own inlining system. */
        highTier.removePhase(InliningPhase.class);
        /* Remove phases that are not suitable for AOT compilation. */
        highTier.findPhase(ConvertDeoptimizeToGuardPhase.class, true).remove();
        midTier.findPhase(DeoptimizationGroupingPhase.class).remove();
    } else {
        ListIterator<BasePhase<? super MidTierContext>> it = midTier.findPhase(DeoptimizationGroupingPhase.class);
        it.previous();
        it.add(new CollectDeoptimizationSourcePositionsPhase());
    }
    featureHandler.forEachGraalFeature(feature -> feature.registerGraalPhases(runtimeCallProviders, snippetReflection, suites, hosted));
    return suites;
}
Also used : LowTierContext(org.graalvm.compiler.phases.tiers.LowTierContext) HostedOptionValues(com.oracle.svm.core.option.HostedOptionValues) RuntimeOptionValues(com.oracle.svm.core.option.RuntimeOptionValues) OptionValues(org.graalvm.compiler.options.OptionValues) StackValuePhase(com.oracle.svm.core.graal.stackvalue.StackValuePhase) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) SubstrateAMD64RegisterConfig(com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig) DeadStoreRemovalPhase(com.oracle.svm.core.graal.phases.DeadStoreRemovalPhase) Providers(org.graalvm.compiler.phases.util.Providers) HostedProviders(com.oracle.graal.pointsto.meta.HostedProviders) RemoveUnwindPhase(com.oracle.svm.core.graal.phases.RemoveUnwindPhase) SubstrateAMD64AddressLowering(com.oracle.svm.core.graal.code.amd64.SubstrateAMD64AddressLowering) MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) OptimizeExceptionCallsPhase(com.oracle.svm.core.graal.phases.OptimizeExceptionCallsPhase) BasePhase(org.graalvm.compiler.phases.BasePhase) AddressLoweringPhase(org.graalvm.compiler.phases.common.AddressLoweringPhase) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites) LoopSafepointInsertionPhase(org.graalvm.compiler.phases.common.LoopSafepointInsertionPhase) ConvertDeoptimizeToGuardPhase(org.graalvm.compiler.phases.common.ConvertDeoptimizeToGuardPhase) FixReadsPhase(org.graalvm.compiler.phases.common.FixReadsPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) MethodSafepointInsertionPhase(com.oracle.svm.core.graal.phases.MethodSafepointInsertionPhase) DeoptimizationGroupingPhase(org.graalvm.compiler.phases.common.DeoptimizationGroupingPhase) CollectDeoptimizationSourcePositionsPhase(com.oracle.svm.core.graal.phases.CollectDeoptimizationSourcePositionsPhase) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) VerifyNoGuardsPhase(com.oracle.svm.hosted.phases.VerifyNoGuardsPhase)

Example 3 with LowTierContext

use of org.graalvm.compiler.phases.tiers.LowTierContext in project graal by oracle.

the class SPARCSuitesCreator method createSuites.

@Override
public Suites createSuites(OptionValues options) {
    Suites s = super.createSuites(options);
    ListIterator<BasePhase<? super LowTierContext>> l = s.getLowTier().findPhase(ExpandLogicPhase.class);
    while (PhaseSuite.findNextPhase(l, ExpandLogicPhase.class)) {
    // Search for last occurrence of ExpandLogicPhase
    }
    l.previous();
    l.add(new SPARCIntegerCompareCanonicalizationPhase());
    return s;
}
Also used : LowTierContext(org.graalvm.compiler.phases.tiers.LowTierContext) BasePhase(org.graalvm.compiler.phases.BasePhase) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 4 with LowTierContext

use of org.graalvm.compiler.phases.tiers.LowTierContext in project graal by oracle.

the class AddressLoweringHotSpotSuitesProvider method createSuites.

@Override
public Suites createSuites(OptionValues options) {
    Suites suites = super.createSuites(options);
    ListIterator<BasePhase<? super LowTierContext>> findPhase = suites.getLowTier().findPhase(FixReadsPhase.class);
    if (findPhase == null) {
        findPhase = suites.getLowTier().findPhase(ExpandLogicPhase.class);
    }
    findPhase.add(new AddressLoweringPhase(addressLowering));
    return suites;
}
Also used : LowTierContext(org.graalvm.compiler.phases.tiers.LowTierContext) ExpandLogicPhase(org.graalvm.compiler.phases.common.ExpandLogicPhase) BasePhase(org.graalvm.compiler.phases.BasePhase) AddressLoweringPhase(org.graalvm.compiler.phases.common.AddressLoweringPhase) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 5 with LowTierContext

use of org.graalvm.compiler.phases.tiers.LowTierContext in project graal by oracle.

the class GraalCompiler method emitFrontEnd.

/**
 * Builds the graph, optimizes it.
 */
@SuppressWarnings("try")
public static void emitFrontEnd(Providers providers, TargetProvider target, StructuredGraph graph, PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, Suites suites) {
    DebugContext debug = graph.getDebug();
    try (DebugContext.Scope s = debug.scope("FrontEnd");
        DebugCloseable a = FrontEnd.start(debug)) {
        HighTierContext highTierContext = new HighTierContext(providers, graphBuilderSuite, optimisticOpts);
        if (graph.start().next() == null) {
            graphBuilderSuite.apply(graph, highTierContext);
            new DeadCodeEliminationPhase(DeadCodeEliminationPhase.Optionality.Optional).apply(graph);
            debug.dump(DebugContext.BASIC_LEVEL, graph, "After parsing");
        } else {
            debug.dump(DebugContext.INFO_LEVEL, graph, "initial state");
        }
        suites.getHighTier().apply(graph, highTierContext);
        graph.maybeCompress();
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After high tier");
        MidTierContext midTierContext = new MidTierContext(providers, target, optimisticOpts, profilingInfo);
        suites.getMidTier().apply(graph, midTierContext);
        graph.maybeCompress();
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After mid tier");
        LowTierContext lowTierContext = new LowTierContext(providers, target);
        suites.getLowTier().apply(graph, lowTierContext);
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After low tier");
        debug.dump(DebugContext.BASIC_LEVEL, graph.getLastSchedule(), "Final HIR schedule");
        graph.logInliningTree();
    } catch (Throwable e) {
        throw debug.handle(e);
    } finally {
        graph.checkCancellation();
    }
}
Also used : MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) LowTierContext(org.graalvm.compiler.phases.tiers.LowTierContext) DebugContext(org.graalvm.compiler.debug.DebugContext) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)

Aggregations

LowTierContext (org.graalvm.compiler.phases.tiers.LowTierContext)5 BasePhase (org.graalvm.compiler.phases.BasePhase)4 Suites (org.graalvm.compiler.phases.tiers.Suites)4 AddressLoweringPhase (org.graalvm.compiler.phases.common.AddressLoweringPhase)2 ExpandLogicPhase (org.graalvm.compiler.phases.common.ExpandLogicPhase)2 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)2 MidTierContext (org.graalvm.compiler.phases.tiers.MidTierContext)2 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)1 SubstrateAMD64AddressLowering (com.oracle.svm.core.graal.code.amd64.SubstrateAMD64AddressLowering)1 SubstrateAMD64RegisterConfig (com.oracle.svm.core.graal.code.amd64.SubstrateAMD64RegisterConfig)1 CollectDeoptimizationSourcePositionsPhase (com.oracle.svm.core.graal.phases.CollectDeoptimizationSourcePositionsPhase)1 DeadStoreRemovalPhase (com.oracle.svm.core.graal.phases.DeadStoreRemovalPhase)1 MethodSafepointInsertionPhase (com.oracle.svm.core.graal.phases.MethodSafepointInsertionPhase)1 OptimizeExceptionCallsPhase (com.oracle.svm.core.graal.phases.OptimizeExceptionCallsPhase)1 RemoveUnwindPhase (com.oracle.svm.core.graal.phases.RemoveUnwindPhase)1 StackValuePhase (com.oracle.svm.core.graal.stackvalue.StackValuePhase)1 HostedOptionValues (com.oracle.svm.core.option.HostedOptionValues)1 RuntimeOptionValues (com.oracle.svm.core.option.RuntimeOptionValues)1 VerifyNoGuardsPhase (com.oracle.svm.hosted.phases.VerifyNoGuardsPhase)1 CompressEncoding (org.graalvm.compiler.core.common.CompressEncoding)1