/// <summary> /// Initializes a new instance of the <see cref="SimMethodCompiler" /> class. /// </summary> /// <param name="compiler">The compiler.</param> /// <param name="method">The method.</param> /// <param name="simAdapter">The sim adapter.</param> /// <param name="basicBlocks">The basic blocks.</param> /// <param name="instructionSet">The instruction set.</param> public SimMethodCompiler(SimCompiler compiler, MosaMethod method, ISimAdapter simAdapter, BasicBlocks basicBlocks, InstructionSet instructionSet) : base(compiler, method, basicBlocks, instructionSet) { var compilerOptions = Compiler.CompilerOptions; // Populate the pipeline Pipeline.Add(new IMethodCompilerStage[] { new CILDecodingStage(), new BasicBlockBuilderStage(), new StackSetupStage(), new ExceptionPrologueStage(), new OperandAssignmentStage(), //new SingleUseMarkerStage(), //new OperandUsageAnalyzerStage(), new StaticAllocationResolutionStage(), new CILTransformationStage(), new ConvertCompoundMoveStage(), //new CheckIROperandCountStage(), (compilerOptions.EnableSSA) ? new PromoteLocalVariablesStage() : null, (compilerOptions.EnableSSA) ? new EdgeSplitStage() : null, (compilerOptions.EnableSSA) ? new PhiPlacementStage() : null, (compilerOptions.EnableSSA) ? new EnterSSAStage() : null, (compilerOptions.EnableSSA && compilerOptions.EnableSSAOptimizations) ? new SSAOptimizations() : null, (compilerOptions.EnableSSA) ? new LeaveSSA() : null, (compilerOptions.EnableSSA) ? new ConvertCompoundMoveStage() : null, new PlatformStubStage(), //new CheckPlatformOperandCountStage(), new PlatformEdgeSplitStage(), new GreedyRegisterAllocatorStage(), new StackLayoutStage(), new EmptyBlockRemovalStage(), new BlockOrderingStage(), new SimCodeGeneratorStage(simAdapter), }); }
/// <summary> /// Compiles the specified type system. /// </summary> /// <param name="typeSystem">The type system.</param> /// <param name="typeLayout">The type layout.</param> /// <param name="compilerTrace">The compiler trace.</param> /// <param name="compilerOptions">The compiler options.</param> /// <param name="architecture">The architecture.</param> /// <param name="simAdapter">The sim adapter.</param> /// <param name="linker">The linker.</param> /// <returns></returns> public static SimCompiler Compile(TypeSystem typeSystem, MosaTypeLayout typeLayout, CompilerTrace compilerTrace, CompilerOptions compilerOptions, BaseArchitecture architecture, ISimAdapter simAdapter, BaseLinker linker) { var compiler = new SimCompiler(architecture, typeSystem, typeLayout, linker, compilerOptions, compilerTrace, simAdapter); compiler.Compile(); return compiler; }
/// <summary> /// Compiles the specified type system. /// </summary> /// <param name="typeSystem">The type system.</param> /// <param name="typeLayout">The type layout.</param> /// <param name="internalTrace">The internal trace.</param> /// <param name="enabledSSA">if set to <c>true</c> [enabled ssa].</param> /// <param name="architecture">The architecture.</param> /// <param name="simAdapter">The sim adapter.</param> /// <param name="linker">The linker.</param> /// <returns></returns> public static SimCompiler Compile(TypeSystem typeSystem, MosaTypeLayout typeLayout, IInternalTrace internalTrace, bool enabledSSA, BaseArchitecture architecture, ISimAdapter simAdapter, ILinker linker) { CompilerOptions compilerOptions = new CompilerOptions(); compilerOptions.EnableSSA = enabledSSA; compilerOptions.EnableSSAOptimizations = enabledSSA; SimCompiler compiler = new SimCompiler(architecture, typeSystem, typeLayout, linker, compilerOptions, internalTrace, simAdapter); compiler.Compile(); return compiler; }
/// <summary> /// Initializes a new instance of the <see cref="SimMethodCompiler" /> class. /// </summary> /// <param name="compiler">The compiler.</param> /// <param name="method">The method.</param> /// <param name="simAdapter">The sim adapter.</param> /// <param name="basicBlocks">The basic blocks.</param> /// <param name="threadID">The thread identifier.</param> public SimMethodCompiler(SimCompiler compiler, MosaMethod method, ISimAdapter simAdapter, BasicBlocks basicBlocks, int threadID) : base(compiler, method, basicBlocks, threadID) { var compilerOptions = Compiler.CompilerOptions; // Populate the pipeline Pipeline.Add(new IMethodCompilerStage[] { new CILDecodingStage(), new ExceptionPrologueStage(), new OperandAssignmentStage(), new StackSetupStage(), new ProtectedRegionStage(), new StaticAllocationResolutionStage(), new CILTransformationStage(), new ConvertCompoundStage(), new UnboxValueTypeStage(), new ExceptionStage(), (compilerOptions.EnableInlinedMethods) ? new InlineStage() : null, (compilerOptions.EnableVariablePromotion) ? new PromoteTempVariablesStage() : null, (compilerOptions.EnableSSA) ? new EdgeSplitStage() : null, (compilerOptions.EnableSSA) ? new PhiPlacementStage() : null, (compilerOptions.EnableSSA) ? new EnterSSAStage() : null, (compilerOptions.EnableSparseConditionalConstantPropagation && compilerOptions.EnableSSA) ? new SparseConditionalConstantPropagationStage() : null, (compilerOptions.EnableOptimizations) ? new IROptimizationStage() : null, (compilerOptions.EnableSSA) ? new LeaveSSA() : null, new IRCleanup(), (compilerOptions.EnableInlinedMethods) ? new InlineEvaluationStage() : null, new PlatformStubStage(), new PlatformEdgeSplitStage(), new GreedyRegisterAllocatorStage(), new StackLayoutStage(), new EmptyBlockRemovalStage(), new BlockOrderingStage(), new SimCodeGeneratorStage(simAdapter), new ProtectedRegionLayoutStage(), }); }