/// <summary> /// Initializes a new instance of the <see cref="BaseMethodCompiler" /> class. /// </summary> /// <param name="compiler">The assembly compiler.</param> /// <param name="method">The method to compile by this instance.</param> /// <param name="basicBlocks">The basic blocks.</param> /// <param name="threadID">The thread identifier.</param> protected BaseMethodCompiler(BaseCompiler compiler, MosaMethod method, BasicBlocks basicBlocks, int threadID) { Compiler = compiler; Method = method; Type = method.DeclaringType; Scheduler = compiler.CompilationScheduler; Architecture = compiler.Architecture; TypeSystem = compiler.TypeSystem; TypeLayout = compiler.TypeLayout; Trace = compiler.CompilerTrace; Linker = compiler.Linker; BasicBlocks = basicBlocks ?? new BasicBlocks(); Pipeline = new CompilerPipeline(); StackLayout = new StackLayout(Architecture, method.Signature.Parameters.Count + (method.HasThis || method.HasExplicitThis ? 1 : 0)); VirtualRegisters = new VirtualRegisters(Architecture); LocalVariables = emptyOperandList; ThreadID = threadID; DominanceAnalysis = new Dominance(Compiler.CompilerOptions.DominanceAnalysisFactory, BasicBlocks); PluggedMethod = compiler.PlugSystem.GetPlugMethod(Method); stop = false; MethodData = compiler.CompilerData.GetCompilerMethodData(Method); MethodData.Counters.Clear(); EvaluateParameterOperands(); }
/// <summary> /// Initializes a new compiler instance. /// </summary> /// <param name="architecture">The compiler target architecture.</param> /// <param name="assembly">The assembly of this compiler.</param> /// <exception cref="System.ArgumentNullException">Either <paramref name="architecture"/> or <paramref name="assembly"/> is null.</exception> protected AssemblyCompiler(IArchitecture architecture, IMetadataModule assembly) { if (architecture == null) throw new ArgumentNullException(@"architecture"); _architecture = architecture; _assembly = assembly; _pipeline = new CompilerPipeline(); }
/// <summary> /// Initializes a new compiler instance. /// </summary> /// <param name="architecture">The compiler target architecture.</param> /// <param name="typeSystem">The type system.</param> protected AssemblyCompiler(IArchitecture architecture, ITypeSystem typeSystem) { if (architecture == null) throw new ArgumentNullException(@"architecture"); this.architecture = architecture; this.pipeline = new CompilerPipeline(); this.typeSystem = typeSystem; }
/// <summary> /// Initializes a new compiler instance. /// </summary> /// <param name="architecture">The compiler target architecture.</param> /// <param name="typeSystem">The type system.</param> protected AssemblyCompiler(IArchitecture architecture, ITypeSystem typeSystem, ITypeLayout typeLayout, IInternalTrace internalTrace, CompilerOptions compilerOptions) { if (architecture == null) throw new ArgumentNullException(@"architecture"); this.pipeline = new CompilerPipeline(); this.architecture = architecture; this.typeSystem = typeSystem; this.typeLayout = typeLayout; this.internalTrace = internalTrace; this.compilerOptions = compilerOptions; this.genericTypePatcher = new GenericTypePatcher(typeSystem); }
/// <summary> /// Initializes a new compiler instance. /// </summary> /// <param name="architecture">The compiler target architecture.</param> /// <param name="typeSystem">The type system.</param> /// <param name="typeLayout">The type layout.</param> /// <param name="compilationScheduler">The compilation scheduler.</param> /// <param name="compilerTrace">The compiler trace.</param> /// <param name="linker">The linker.</param> /// <param name="compilerOptions">The compiler options.</param> /// <exception cref="System.ArgumentNullException">@Architecture</exception> protected BaseCompiler(BaseArchitecture architecture, TypeSystem typeSystem, MosaTypeLayout typeLayout, ICompilationScheduler compilationScheduler, CompilerTrace compilerTrace, BaseLinker linker, CompilerOptions compilerOptions) { if (architecture == null) throw new ArgumentNullException(@"Architecture"); Pipeline = new CompilerPipeline(); Architecture = architecture; TypeSystem = typeSystem; TypeLayout = typeLayout; CompilerTrace = compilerTrace; CompilerOptions = compilerOptions; Counters = new Counters(); CompilationScheduler = compilationScheduler; PlugSystem = new PlugSystem(); Linker = linker; if (Linker == null) { Linker = compilerOptions.LinkerFactory(); Linker.Initialize(compilerOptions.BaseAddress, architecture.Endianness, architecture.ElfMachineType); } // Create new dictionary IntrinsicTypes = new Dictionary<string, Type>(); // Get all the classes that implement the IIntrinsicInternalMethod interface IEnumerable<Type> types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => typeof(IIntrinsicInternalMethod).IsAssignableFrom(p) && p.IsClass); // Iterate through all the found types foreach (var t in types) { // Now get all the ReplacementTarget attributes var attributes = (ReplacementTargetAttribute[])t.GetCustomAttributes(typeof(ReplacementTargetAttribute), true); for (int i = 0; i < attributes.Length; i++) { // Finally add the dictionary entry mapping the target string and the type IntrinsicTypes.Add(attributes[i].Target, t); } } PlatformInternalRuntimeType = GetPlatformInternalRuntimeType(); }
/// <summary> /// Initializes a new compiler instance. /// </summary> /// <param name="architecture">The compiler target architecture.</param> /// <param name="typeSystem">The type system.</param> /// <param name="typeLayout">The type layout.</param> /// <param name="compilationScheduler">The compilation scheduler.</param> /// <param name="internalTrace">The internal trace.</param> /// <param name="compilerOptions">The compiler options.</param> protected BaseCompiler(BaseArchitecture architecture, TypeSystem typeSystem, MosaTypeLayout typeLayout, ICompilationScheduler compilationScheduler, IInternalTrace internalTrace, ILinker linker, CompilerOptions compilerOptions) { if (architecture == null) throw new ArgumentNullException(@"Architecture"); Pipeline = new CompilerPipeline(); Architecture = architecture; TypeSystem = typeSystem; TypeLayout = typeLayout; InternalTrace = internalTrace; CompilerOptions = compilerOptions; Counters = new Counters(); CompilationScheduler = compilationScheduler; PlugSystem = new PlugSystem(); Linker = linker; if (Linker == null) { Linker = compilerOptions.LinkerFactory(); Linker.Initialize(compilerOptions.OutputFile, architecture.Endianness, architecture.ElfMachineType); } }
public CompileUnit SetUpTypeInferenceSource() { CompilerPipeline compilerPipeline = UnityScriptCompiler.Pipelines.AdjustBooPipeline(new ResolveExpressions()); compilerPipeline.RemoveAt(compilerPipeline.Find(typeof(ApplySemantics))); compilerPipeline.BreakOnErrors = false; var unityScriptCompiler = new UnityScriptCompiler(); CopyUnityScriptCompilerParametersTo(unityScriptCompiler); unityScriptCompiler.Parameters.Pipeline = compilerPipeline; unityScriptCompiler.Parameters.AddToEnvironment( typeof(TypeInferenceRuleProvider), GetCustomTypeInferenceRuleProvider); var compilerContext = unityScriptCompiler.Run(CompileUnit.CloneNode()); if (((ICollection)compilerContext.Errors).Count != 0) { throw new CompilationErrorsException(compilerContext.Errors); } return(compilerContext.CompileUnit); }
/// <summary> /// Extends the method compiler pipeline with x86 specific stages. /// </summary> /// <param name="methodCompilerPipeline">The method compiler pipeline to extend.</param> public override void ExtendMethodCompilerPipeline(CompilerPipeline methodCompilerPipeline) { methodCompilerPipeline.InsertAfterLast <PlatformStubStage>( new IMethodCompilerStage[] { //new CheckOperandCountStage(), new PlatformIntrinsicStage(), new LongOperandTransformationStage(), new IRTransformationStage(), //new StopStage(), new TweakTransformationStage(), new FixedRegisterAssignmentStage(), new SimpleDeadCodeRemovalStage(), new AddressModeConversionStage(), new FloatingPointStage(), }); methodCompilerPipeline.InsertAfterLast <StackLayoutStage>( new BuildStackStage() ); methodCompilerPipeline.InsertBefore <CodeGenerationStage>( new FinalTweakTransformationStage() ); methodCompilerPipeline.InsertBefore <CodeGenerationStage>( new JumpOptimizationStage() ); methodCompilerPipeline.InsertBefore <CodeGenerationStage>( new ConversionPhaseStage() ); }
/// <summary> /// Extends the post compiler pipeline with ARMv6 specific stages. /// </summary> /// <param name="compilerPipeline">The pipeline to extend.</param> public override void ExtendPostCompilerPipeline(CompilerPipeline compilerPipeline) { }
/// <summary> /// Extends the post-compiler pipeline with x86 compiler stages. /// </summary> /// <param name="compilerPipeline">The pipeline to extend.</param> public override void ExtendPostCompilerPipeline(CompilerPipeline compilerPipeline) { }
/// <summary> /// Extends the method compiler pipeline with x86 specific stages. /// </summary> /// <param name="methodCompilerPipeline">The method compiler pipeline to extend.</param> public override void ExtendMethodCompilerPipeline(CompilerPipeline methodCompilerPipeline) { // FIXME: Create a specific code generator instance using requested feature flags. // FIXME: Add some more optimization passes, which take advantage of advanced x86 instructions // and packed operations available with SSE extensions methodCompilerPipeline.InsertAfterLast<PlatformStubStage>( new IMethodCompilerStage[] { //new CheckOperandCountStage(), new PlatformIntrinsicTransformationStage(), new LongOperandTransformationStage(), //new StopStage(), new IRTransformationStage(), new TweakTransformationStage(), new FixedRegisterAssignmentStage(), new SimpleDeadCodeRemovalStage(), new AddressModeConversionStage(), new FloatingPointStage(), }); methodCompilerPipeline.InsertAfterLast<StackLayoutStage>( new BuildStackStage() ); methodCompilerPipeline.InsertBefore<CodeGenerationStage>( new FinalTweakTransformationStage() ); methodCompilerPipeline.InsertBefore<CodeGenerationStage>( new JumpPeepholeOptimizationStage() ); }
/// <summary> /// Extends the method compiler pipeline with x86 specific stages. /// </summary> /// <param name="methodCompilerPipeline">The method compiler pipeline to extend.</param> public override void ExtendMethodCompilerPipeline(CompilerPipeline methodCompilerPipeline) { // FIXME: Create a specific code generator instance using requested feature flags. // FIXME: Add some more optimization passes, which take advantage of advanced x86 instructions // and packed operations available with MMX/SSE extensions methodCompilerPipeline.InsertAfter<PlatformStubStage>( new IMethodCompilerStage[] { //InstructionLogger.Instance, new LongOperandTransformationStage(), //InstructionLogger.Instance, new AddressModeConversionStage(), //InstructionLogger.Instance, new IRTransformationStage(), //InstructionLogger.Instance, new TweakTransformationStage(), //InstructionLogger.Instance, new MemToMemConversionStage(), //InstructionLogger.Instance, new ExceptionHeaderPreprocessingStage(), }); methodCompilerPipeline.InsertAfter<IBlockOrderStage>( new IMethodCompilerStage[] { new SimplePeepholeOptimizationStage(), //InstructionLogger.Instance, }); //FlowGraphVisualizationStage.Instance, }
/// <summary> /// Extends the assembly compiler pipeline with x86 specific stages. /// </summary> /// <param name="assemblyCompilerPipeline">The assembly compiler pipeline to extend.</param> public override void ExtendAssemblyCompilerPipeline(CompilerPipeline assemblyCompilerPipeline) { }
public void Initialize(MosaCompiler compiler) { if (compiler == null) throw new ArgumentNullException(@"compiler"); Compiler = compiler; Architecture = Compiler.CompilerOptions.Architecture; TypeSystem = Compiler.TypeSystem; TypeLayout = Compiler.TypeLayout; CompilerTrace = Compiler.CompilerTrace; CompilerOptions = Compiler.CompilerOptions; CompilationScheduler = Compiler.CompilationScheduler; Linker = compiler.Linker; PreCompilePipeline = new CompilerPipeline(); PostCompilePipeline = new CompilerPipeline(); Counters = new Counters(); PlugSystem = new PlugSystem(); CompilerData = new CompilerData(this); // Create new dictionary IntrinsicTypes = new Dictionary<string, Type>(); // Get all the classes that implement the IIntrinsicInternalMethod interface IEnumerable<Type> types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => typeof(IIntrinsicInternalMethod).IsAssignableFrom(p) && p.IsClass); // Iterate through all the found types foreach (var t in types) { // Now get all the ReplacementTarget attributes var attributes = (ReplacementTargetAttribute[])t.GetCustomAttributes(typeof(ReplacementTargetAttribute), true); for (int i = 0; i < attributes.Length; i++) { // Finally add the dictionary entry mapping the target string and the type IntrinsicTypes.Add(attributes[i].Target, t); } } PlatformInternalRuntimeType = GetPlatformInternalRuntimeType(); // Extended Setup ExtendCompilerSetup(); // Build the default pre-compiler pipeline Architecture.ExtendPreCompilerPipeline(this.PreCompilePipeline); // Build the default post-compiler pipeline Architecture.ExtendPostCompilerPipeline(this.PostCompilePipeline); }
/// <summary> /// Initializes a new instance of the <see cref="BaseMethodCompiler"/> class. /// </summary> /// <param name="linker">The _linker.</param> /// <param name="architecture">The target compilation Architecture.</param> /// <param name="type">The type, which owns the method to compile.</param> /// <param name="method">The method to compile by this instance.</param> protected BaseMethodCompiler( IAssemblyLinker linker, IArchitecture architecture, ICompilationSchedulerStage compilationScheduler, RuntimeType type, RuntimeMethod method, ITypeSystem typeSystem, ITypeLayout typeLayout) { if (architecture == null) throw new ArgumentNullException(@"architecture"); if (linker == null) throw new ArgumentNullException(@"linker"); if (compilationScheduler == null) throw new ArgumentNullException(@"compilationScheduler"); this.linker = linker; this.architecture = architecture; this.method = method; this.type = type; parameters = new List<Operand>(new Operand[method.Parameters.Count]); nextStackSlot = 0; basicBlocks = new List<BasicBlock>(); instructionSet = null; // this will be set later pipeline = new CompilerPipeline(); this.compilationScheduler = compilationScheduler; this.moduleTypeSystem = method.Module; this.typeSystem = typeSystem; this.typeLayout = typeLayout; }
protected abstract void SetUpCompilerPipeline(CompilerPipeline pipeline);
void ParseOptions(string[] args, CompilerParameters _options) { bool debugSteps = false; ArrayList arglist = new ArrayList(args); ExpandResponseFiles(ref arglist); AddDefaultResponseFile(ref arglist); foreach (string arg in arglist) { if ("-" == arg) { _options.Input.Add(new StringInput("<stdin>", Consume(Console.In))); } else { if (IsFlag(arg)) { if ("-utf8" == arg) { continue; } switch (arg[1]) { case 'v': { _options.TraceSwitch.Level = TraceLevel.Warning; Trace.Listeners.Add(new TextWriterTraceListener(Console.Error)); if (arg.Length > 2) { switch (arg.Substring(1)) { case "vv": { _options.TraceSwitch.Level = TraceLevel.Info; break; } case "vvv": { _options.TraceSwitch.Level = TraceLevel.Verbose; break; } } } else { _options.TraceSwitch.Level = TraceLevel.Warning; } break; } case 'r': { if (arg.IndexOf(":") > 2) { switch (arg.Substring(1, 8)) { case "resource": { string resourceFile; int start = arg.IndexOf(":") + 1; int comma = arg.LastIndexOf(','); if (comma >= 0) { resourceFile = arg.Substring(start, comma - start); string resourceName = arg.Substring(comma + 1); _options.Resources.Add(new NamedFileResource(resourceFile, resourceName)); } else { resourceFile = arg.Substring(start); _options.Resources.Add(new FileResource(resourceFile)); } break; } default: { InvalidOption(arg); break; } } } else { string assemblyName = arg.Substring(3); _options.References.Add(LoadAssembly(assemblyName)); } break; } case 'o': { _options.OutputAssembly = arg.Substring(arg.IndexOf(":") + 1); break; } case 't': { string targetType = arg.Substring(arg.IndexOf(":") + 1); switch (targetType) { case "library": { _options.OutputType = CompilerOutputType.Library; break; } case "exe": { _options.OutputType = CompilerOutputType.ConsoleApplication; break; } case "winexe": { _options.OutputType = CompilerOutputType.WindowsApplication; break; } default: { InvalidOption(arg); break; } } break; } case 'p': { string pipelineName = arg.Substring(3); _options.Pipeline = CompilerPipeline.GetPipeline(pipelineName); break; } case 'c': { string culture = arg.Substring(3); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(culture); break; } case 's': { switch (arg.Substring(1, 6)) { case "srcdir": { string path = arg.Substring(8); AddFilesForPath(path, _options); break; } default: { InvalidOption(arg); break; } } break; } case 'd': { switch (arg.Substring(1)) { case "debug": case "debug+": { _options.Debug = true; break; } case "debug-": { _options.Debug = false; break; } case "ducky": { _options.Ducky = true; break; } case "debug-steps": { debugSteps = true; break; } default: { InvalidOption(arg); break; } } break; } case 'e': { switch (arg.Substring(1, 8)) { case "embedres": { // TODO: Add check for runtime support for "mono resources" string resourceFile; int start = arg.IndexOf(":") + 1; int comma = arg.LastIndexOf(','); if (comma >= 0) { resourceFile = arg.Substring(start, comma - start); string resourceName = arg.Substring(comma + 1); _options.Resources.Add(new NamedEmbeddedFileResource(resourceFile, resourceName)); } else { resourceFile = arg.Substring(start); _options.Resources.Add(new EmbeddedFileResource(resourceFile)); } break; } default: { InvalidOption(arg); break; } } break; } default: { InvalidOption(arg); break; } } } else { _options.Input.Add(new FileInput(arg)); } } } if (null == _options.Pipeline) { _options.Pipeline = new CompileToFile(); } if (debugSteps) { _options.Pipeline.AfterStep += new CompilerStepEventHandler(DebugModuleAfterStep); } }
protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls) { pipeline.Insert(1, new ImplicitBaseClassCompilerStep(typeof(DemoDslBase), "Execute")); }
/// <summary> /// Extends the method compiler pipeline with x86 specific stages. /// </summary> /// <param name="methodCompilerPipeline">The method compiler pipeline to extend.</param> public override void ExtendMethodCompilerPipeline(CompilerPipeline methodCompilerPipeline) { // FIXME: Create a specific code generator instance using requested feature flags. // FIXME: Add some more optimization passes, which take advantage of advanced x86 instructions // and packed operations available with MMX/SSE extensions methodCompilerPipeline.AddRange (new IMethodCompilerStage[] { new LongOperandTransformationStage (), new InstructionLogger (typeof(LongOperandTransformationStage)), new AddressModeConversionStage (), new InstructionLogger (typeof(AddressModeConversionStage)), new CILTransformationStage (), new InstructionLogger (typeof(CILTransformationStage)), new IRTransformationStage (), new InstructionLogger (typeof(IRTransformationStage)), new TweakTransformationStage (), new InstructionLogger (typeof(TweakTransformationStage)), new MemToMemConversionStage (), new InstructionLogger (typeof(MemToMemConversionStage)), new SimplePeepholeOptimizationStage (), new InstructionLogger (typeof(SimplePeepholeOptimizationStage)) //FlowGraphVisualizationStage.Instance, }); }
/// <summary> /// Extends the method compiler pipeline with x64 specific stages. /// </summary> /// <param name="methodCompilerPipeline">The method compiler pipeline to extend.</param> public override void ExtendMethodCompilerPipeline(CompilerPipeline methodCompilerPipeline) { // TODO }
/// <summary> /// Extends the pre-compiler pipeline with x86 compiler stages. /// </summary> /// <param name="compilerPipeline">The pipeline to extend.</param> public override void ExtendCompilerPipeline(CompilerPipeline compilerPipeline) { compilerPipeline.Add( new StartUpStage() ); compilerPipeline.Add( new InterruptVectorStage() ); compilerPipeline.Add( new SSEInitStage() ); }
/// <summary> /// Extends the pre-compiler pipeline with architecture specific compiler stages. /// </summary> /// <param name="compilerPipeline">The pipeline to extend.</param> public abstract void ExtendCompilerPipeline(CompilerPipeline compilerPipeline);
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (pipeline == null) throw new ObjectDisposedException(@"MethodCompilerBase"); foreach (IMethodCompilerStage mcs in pipeline) { IDisposable d = mcs as IDisposable; if (null != d) d.Dispose(); } pipeline.Clear(); pipeline = null; architecture = null; linker = null; method = null; type = null; instructionSet = null; basicBlocks = null; }
/// <summary> /// Initializes a new instance of. /// </summary> protected CompilerBase() { _pipeline = new CompilerPipeline(); }
/// <summary> /// Extends the assembly compiler pipeline with ARMv6 specific stages. /// </summary> /// <param name="compilerPipeline">The pipeline to extend.</param> public override void ExtendCompilerPipeline(CompilerPipeline compilerPipeline) { // TODO }
/// <summary> /// Extends the compiler pipeline with x86 specific stages. /// </summary> /// <param name="compilerPipeline">The pipeline to extend.</param> public override void ExtendCompilerPipeline(CompilerPipeline compilerPipeline) { compilerPipeline.InsertAfterFirst<ICompilerStage>( new InterruptVectorStage() ); compilerPipeline.InsertAfterFirst<InterruptVectorStage>( new ExceptionVectorStage() ); compilerPipeline.InsertAfterLast<TypeLayoutStage>( new MethodTableBuilderStage() ); }
/// <summary> /// Initializes a new compiler instance. /// </summary> /// <param name="architecture">The compiler target architecture.</param> /// <param name="typeSystem">The type system.</param> /// <param name="typeLayout">The type layout.</param> /// <param name="compilationScheduler">The compilation scheduler.</param> /// <param name="internalTrace">The internal trace.</param> /// <param name="compilerOptions">The compiler options.</param> protected BaseCompiler(IArchitecture architecture, ITypeSystem typeSystem, ITypeLayout typeLayout, ICompilationScheduler compilationScheduler, IInternalTrace internalTrace, CompilerOptions compilerOptions) { if (architecture == null) throw new ArgumentNullException(@"architecture"); this.pipeline = new CompilerPipeline(); this.architecture = architecture; this.typeSystem = typeSystem; this.typeLayout = typeLayout; this.internalTrace = internalTrace; this.compilerOptions = compilerOptions; this.genericTypePatcher = new GenericTypePatcher(typeSystem); this.counters = new Counters(); this.compilationScheduler = compilationScheduler; this.linker = compilerOptions.Linker; this.plugSystem = new PlugSystem(); }
/// <summary> /// Extends the method compiler pipeline with ARMv6 specific stages. /// </summary> /// <param name="methodCompilerPipeline">The method compiler pipeline to extend.</param> public override void ExtendMethodCompilerPipeline(CompilerPipeline methodCompilerPipeline) { methodCompilerPipeline.InsertAfterLast<PlatformStubStage>( new IMethodCompilerStage[] { //new LongOperandTransformationStage(), new IRTransformationStage(), }); //methodCompilerPipeline.InsertAfterLast<CodeGenerationStage>( // new ExceptionLayoutStage() //); methodCompilerPipeline.InsertBefore<GreedyRegisterAllocatorStage>( new StopStage() ); }
protected override void AddCompilerSteps(BooCompiler compiler, string filename, CompilerPipeline pipeline) { compiler.Parameters.AddAssembly(typeof(Boo.Lang.Compiler.Ast.DepthFirstTransformer).Assembly); compiler.Parameters.Pipeline.Insert(1, new MethodSubstitutionBaseClassCompilerStep(typeof(MyMethodSubstitutionBaseClass), "System", "Boo.Lang.Compiler.Ast.DepthFirstTransformer")); }
protected override void AddCompilerSteps(BooCompiler compiler, string filename, CompilerPipeline pipeline) { compiler.Parameters.Pipeline.Insert(1, new ImplicitBaseClassCompilerStep(typeof(MyAnonymousBaseClass), "Run")); }
/// <summary> /// Extends the assembly compiler pipeline with architecture specific assembly compiler stages. /// </summary> /// <param name="assemblyPipeline">The pipeline to extend.</param> public abstract void ExtendAssemblyCompilerPipeline(CompilerPipeline assemblyPipeline);
/// <summary> /// Extends the method compiler pipeline with ARM specific stages. /// </summary> /// <param name="methodCompilerPipeline">The method compiler pipeline to extend.</param> public override void ExtendMethodCompilerPipeline(CompilerPipeline methodCompilerPipeline) { }
protected override void AddCompilerSteps(BooCompiler compiler, string filename, CompilerPipeline pipeline) { pipeline.Insert(1, new AutoReferenceFilesCompilerStep(Path.GetDirectoryName(filename))); }
/// <summary> /// Extends the method compiler pipeline with x86 specific stages. /// </summary> /// <param name="methodCompilerPipeline">The method compiler pipeline to extend.</param> public override void ExtendMethodCompilerPipeline(CompilerPipeline methodCompilerPipeline) { methodCompilerPipeline.InsertAfterLast<PlatformStubStage>( new IMethodCompilerStage[] { //new CheckOperandCountStage(), new PlatformIntrinsicStage(), new LongOperandTransformationStage(), //new StopStage(), new IRTransformationStage(), new TweakTransformationStage(), new FixedRegisterAssignmentStage(), new SimpleDeadCodeRemovalStage(), new AddressModeConversionStage(), new FloatingPointStage(), }); methodCompilerPipeline.InsertAfterLast<StackLayoutStage>( new BuildStackStage() ); methodCompilerPipeline.InsertBefore<CodeGenerationStage>( new FinalTweakTransformationStage() ); methodCompilerPipeline.InsertBefore<CodeGenerationStage>( new JumpOptimizationStage() ); }
protected virtual void AddCompilerSteps(BooCompiler compiler, string filename, CompilerPipeline pipeline) { }
/// <summary> /// Extends the pre-compiler pipeline with x86 compiler stages. /// </summary> /// <param name="compilerPipeline">The pipeline to extend.</param> public override void ExtendPreCompilerPipeline(CompilerPipeline compilerPipeline) { compilerPipeline.InsertAfterFirst<ICompilerStage>( new InterruptVectorStage() ); compilerPipeline.InsertAfterLast<ICompilerStage>( new SSESetupStage() ); }
protected override void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls) { pipeline.Insert(1, new ImplicitBaseClassCompilerStep(typeof(BaseScheduler), "Prepare", "Rhino.DSL.Tests.SchedulingDSL")); }
/// <summary> /// Extends the assembly compiler pipeline with ARM specific stages. /// </summary> /// <param name="assemblyCompilerPipeline">The assembly compiler pipeline to extend.</param> public override void ExtendAssemblyCompilerPipeline(CompilerPipeline assemblyCompilerPipeline) { //assemblyCompilerPipeline.InsertAfterFirst<IAssemblyCompilerStage>( // new InterruptVectorStage() //); //assemblyCompilerPipeline.InsertAfterFirst<InterruptVectorStage>( // new ExceptionVectorStage() //); //assemblyCompilerPipeline.InsertAfterLast<TypeLayoutStage>( // new MethodTableBuilderStage() //); }
/// <summary> /// Customise the compiler to fit this DSL engine. /// This is the most commonly overriden method. /// </summary> protected virtual void CustomizeCompiler(BooCompiler compiler, CompilerPipeline pipeline, string[] urls) { }
public void Initialize(MosaCompiler compiler) { if (compiler == null) throw new ArgumentNullException(@"compiler"); Compiler = compiler; Architecture = Compiler.CompilerOptions.Architecture; TypeSystem = Compiler.TypeSystem; TypeLayout = Compiler.TypeLayout; CompilerTrace = Compiler.CompilerTrace; CompilerOptions = Compiler.CompilerOptions; CompilationScheduler = Compiler.CompilationScheduler; Linker = compiler.Linker; PreCompilePipeline = new CompilerPipeline(); PostCompilePipeline = new CompilerPipeline(); GlobalCounters = new Counters(); PlugSystem = new PlugSystem(); CompilerData = new CompilerData(); // Create new dictionary IntrinsicTypes = new Dictionary<string, Type>(); foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) { if (type.IsClass && typeof(IIntrinsicInternalMethod).IsAssignableFrom(type)) { // Now get all the ReplacementTarget attributes var attributes = (ReplacementTargetAttribute[])type.GetCustomAttributes(typeof(ReplacementTargetAttribute), true); for (int i = 0; i < attributes.Length; i++) { // Finally add the dictionary entry mapping the target string and the type IntrinsicTypes.Add(attributes[i].Target, type); } } } PlatformInternalRuntimeType = GetPlatformInternalRuntimeType(); InternalRuntimeType = GeInternalRuntimeType(); // Extended Setup ExtendCompilerSetup(); // Build the default pre-compiler pipeline Architecture.ExtendPreCompilerPipeline(PreCompilePipeline); // Build the default post-compiler pipeline Architecture.ExtendPostCompilerPipeline(PostCompilePipeline); }
/// <summary> /// Initializes a new instance of the <see cref="BaseMethodCompiler"/> class. /// </summary> /// <param name="compiler">The assembly compiler.</param> /// <param name="method">The method to compile by this instance.</param> /// <param name="instructionSet">The instruction set.</param> protected BaseMethodCompiler(BaseCompiler compiler, RuntimeMethod method, InstructionSet instructionSet) { this.compiler = compiler; this.method = method; this.type = method.DeclaringType; this.compilationScheduler = compiler.Scheduler; this.moduleTypeSystem = method.Module; this.architecture = compiler.Architecture; this.typeSystem = compiler.TypeSystem; this.typeLayout = Compiler.TypeLayout; this.internalTrace = Compiler.InternalTrace; this.linker = compiler.Linker; this.basicBlocks = new BasicBlocks(); this.instructionSet = instructionSet ?? new InstructionSet(256); this.pipeline = new CompilerPipeline(); this.stackLayout = new StackLayout(architecture, method.Parameters.Count + (method.Signature.HasThis || method.Signature.HasExplicitThis ? 1 : 0)); this.virtualRegisterLayout = new VirtualRegisterLayout(architecture, stackLayout); EvaluateParameterOperands(); this.stopMethodCompiler = false; }
/// <summary> /// Requests the architecture to add architecture specific compilation stages to the pipeline. These /// may depend upon the current state of the pipeline. /// </summary> /// <param name="methodPipeline">The pipeline of the method compiler to add architecture specific compilation stages to.</param> public abstract void ExtendMethodCompilerPipeline(CompilerPipeline methodPipeline);
public void SetUp() { _pipeline = new CompilerPipeline(); }
/// <summary> /// Extends the method compiler pipeline with ARM specific stages. /// </summary> /// <param name="methodCompilerPipeline">The method compiler pipeline to extend.</param> public override void ExtendMethodCompilerPipeline(CompilerPipeline methodCompilerPipeline) { //methodCompilerPipeline.InsertAfterLast<PlatformStubStage>( // new IMethodCompilerStage[] // { // new LongOperandTransformationStage(), // new AddressModeConversionStage(), // new IRTransformationStage(), // new TweakTransformationStage(), // new MemToMemConversionStage(), // }); //methodCompilerPipeline.InsertAfterLast<IBlockOrderStage>( // new SimplePeepholeOptimizationStage() //); //methodCompilerPipeline.InsertAfterLast<CodeGenerationStage>( // new ExceptionLayoutStage() //); }
protected override void AddCompilerSteps(BooCompiler compiler, string filename, CompilerPipeline pipeline) { compiler.Parameters.References.Add(typeof(XmlDocument).Assembly); pipeline.Insert(1, new AutoImportCompilerStep("System.Xml")); }