/// <summary>
        /// Initializes a new instance of the <see cref="ExplorerMethodCompiler"/> class.
        /// </summary>
        /// <param name="compiler">The compiler.</param>
        /// <param name="method">The method.</param>
        public ExplorerMethodCompiler(ExplorerCompiler compiler, RuntimeMethod method)
            : base(compiler, method, null)
        {
            var compilerOptions = Compiler.CompilerOptions;

            // Populate the pipeline
            Pipeline.AddRange(new IMethodCompilerStage[] {
                new CILDecodingStage(),
                new BasicBlockBuilderStage(),
                new ExceptionPrologueStage(),
                new OperandAssignmentStage(),

                //new SingleUseMarkerStage(),
                //new OperandUsageAnalyzerStage(),
                new StaticAllocationResolutionStage(),
                new CILTransformationStage(),

                (compilerOptions.EnableSSA && compilerOptions.EnableSSAOptimizations) ? new LocalVariablePromotionStage() : null,
                (compilerOptions.EnableSSA) ? new EdgeSplitStage() : null,
                (compilerOptions.EnableSSA) ? new DominanceCalculationStage() : null,
                (compilerOptions.EnableSSA) ? new PhiPlacementStage() : null,
                (compilerOptions.EnableSSA) ? new EnterSSAStage() : null,
                (compilerOptions.EnableSSA && compilerOptions.EnableSSAOptimizations) ? new SSAOptimizations() : null,
                (compilerOptions.EnableSSA) ? new LeaveSSA() : null,

                new StackLayoutStage(),
                new PlatformIntrinsicTransformationStage(),
                new PlatformStubStage(),
                new LoopAwareBlockOrderStage(),

                //new SimpleTraceBlockOrderStage(),
                //new SimpleRegisterAllocatorStage(),
                new CodeGenerationStage(),
            });
        }
Esempio n. 2
0
        public static void Compile(ITypeSystem typeSystem, ITypeLayout typeLayout, IInternalTrace internalTrace, string platform, bool enabledSSA)
        {
            IArchitecture architecture;

            switch (platform.ToLower())
            {
                case "x86": architecture = Mosa.Platform.x86.Architecture.CreateArchitecture(Mosa.Platform.x86.ArchitectureFeatureFlags.AutoDetect); break;
                case "avr32": architecture = Mosa.Platform.AVR32.Architecture.CreateArchitecture(Mosa.Platform.AVR32.ArchitectureFeatureFlags.AutoDetect); break;
                default:
                    architecture = Mosa.Platform.x86.Architecture.CreateArchitecture(Mosa.Platform.x86.ArchitectureFeatureFlags.AutoDetect); break;
            }

            CompilerOptions compilerOptions = new CompilerOptions();
            compilerOptions.EnableSSA = enabledSSA;
            compilerOptions.EnableSSAOptimizations = enabledSSA && enabledSSA;
            compilerOptions.Linker = new ExplorerLinker();

            ExplorerCompiler compiler = new ExplorerCompiler(architecture, typeSystem, typeLayout, internalTrace, compilerOptions);

            compiler.Compile();
        }