public void Setup(AssemblyCompiler compiler) { this.compiler = compiler; architecture = compiler.Architecture; typeSystem = compiler.TypeSystem; typeLayout = compiler.TypeLayout; }
/// <summary> /// Initializes a new instance of the <see cref="DefaultCallingConvention"/>. /// </summary> /// <param name="architecture">The architecture of the calling convention.</param> /// <param name="typeLayout">The type layout.</param> public DefaultCallingConvention(IArchitecture architecture, ITypeLayout typeLayout) { if (architecture == null) throw new ArgumentNullException(@"architecture"); this.architecture = architecture; this.typeLayout = typeLayout; }
/// <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) { if (architecture == null) throw new ArgumentNullException(@"architecture"); this.architecture = architecture; this.pipeline = new CompilerPipeline(); this.typeSystem = typeSystem; this.typeLayout = typeLayout; }
/// <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) { if (architecture == null) { throw new ArgumentNullException(@"architecture"); } this.architecture = architecture; this.pipeline = new CompilerPipeline(); this.typeSystem = typeSystem; this.typeLayout = typeLayout; }
public AotAssemblyCompiler(IArchitecture architecture, ITypeInitializerSchedulerStage typeInitializerSchedulerStage, IAssemblyLinker linker, ITypeSystem typeSystem, ITypeLayout typeLayout) : base(architecture, typeSystem, typeLayout) { this.Pipeline.AddRange( new IAssemblyCompilerStage[] { new AssemblyMemberCompilationSchedulerStage(), new MethodCompilerSchedulerStage(), new TypeInitializerSchedulerStageProxy(typeInitializerSchedulerStage), new TypeLayoutStage(), new LinkerProxy(linker) }); }
/// <summary> /// Prevents a default instance of the <see cref="ExplorerCompiler"/> class from being created. /// </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="internalTrace">The internal trace.</param> /// <param name="compilerOptions">The compiler options.</param> public ExplorerCompiler(IArchitecture architecture, ITypeSystem typeSystem, ITypeLayout typeLayout, IInternalTrace internalTrace, CompilerOptions compilerOptions) : base(architecture, typeSystem, typeLayout, new CompilationScheduler(typeSystem, true), internalTrace, compilerOptions) { // Build the assembly compiler pipeline Pipeline.AddRange(new ICompilerStage[] { new PlugStage(), new MethodCompilerSchedulerStage(), new TypeLayoutStage(), (ExplorerLinker)Linker }); architecture.ExtendCompilerPipeline(Pipeline); }
/// <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); }
//private readonly Queue<CCtor> cctorQueue = new Queue<CCtor>(); //private readonly TestAssemblyLinker linker; private CompilerHelper(IArchitecture architecture, ITypeSystem typeSystem, ITypeLayout typeLayout) : base(architecture, typeSystem, typeLayout) { var linker = new LinkerStub(); // Build the assembly compiler pipeline Pipeline.AddRange(new IAssemblyCompilerStage[] { new AssemblyMemberCompilationSchedulerStage(), new MethodCompilerSchedulerStage(), new TypeLayoutStage(), linker }); architecture.ExtendAssemblyCompilerPipeline(Pipeline); }
protected void LoadAssembly(string filename) { IAssemblyLoader assemblyLoader = new AssemblyLoader(); assemblyLoader.AddPrivatePath(System.IO.Path.GetDirectoryName(filename)); assemblyLoader.LoadModule(filename); typeSystem = new TypeSystem(); typeSystem.LoadModules(assemblyLoader.Modules); typeLayout = new TypeLayout(typeSystem, 4, 4); UpdateTree(); }
private ExplorerAssemblyCompiler(IArchitecture architecture, ITypeSystem typeSystem, ITypeLayout typeLayout, IInternalTrace internalTrace, CompilerOptions compilerOptions) : base(architecture, typeSystem, typeLayout, internalTrace, compilerOptions) { var linker = new ExplorerLinker(); // Build the assembly compiler pipeline Pipeline.AddRange(new IAssemblyCompilerStage[] { new AssemblyMemberCompilationSchedulerStage(), new MethodCompilerSchedulerStage(), new TypeLayoutStage(), linker }); architecture.ExtendAssemblyCompilerPipeline(Pipeline); }
private TestCaseAssemblyCompiler(IArchitecture architecture, ITypeSystem typeSystem, ITypeLayout typeLayout, IInternalTrace internalTrace, CompilerOptions compilerOptions) : base(architecture, typeSystem, typeLayout, internalTrace, compilerOptions) { linker = new TestAssemblyLinker(); // Build the assembly compiler pipeline Pipeline.AddRange(new IAssemblyCompilerStage[] { new DelegateTypePatchStage(), new PlugStage(), new AssemblyMemberCompilationSchedulerStage(), new MethodCompilerSchedulerStage(), new TypeLayoutStage(), new MetadataStage(), linker }); architecture.ExtendAssemblyCompilerPipeline(Pipeline); }
/// <summary> /// Setups the specified compiler. /// </summary> /// <param name="compiler">The compiler.</param> public void Setup(IMethodCompiler compiler) { if (compiler == null) { throw new ArgumentNullException(@"compiler"); } methodCompiler = compiler; InstructionSet = compiler.InstructionSet; basicBlocks = compiler.BasicBlocks; architecture = compiler.Architecture; typeModule = compiler.Method.Module; typeSystem = compiler.TypeSystem; typeLayout = compiler.TypeLayout; callingConvention = architecture.GetCallingConvention(); architecture.GetTypeRequirements(BuiltInSigType.IntPtr, out nativePointerSize, out nativePointerAlignment); }
public static void Compile(ITypeSystem typeSystem, ITypeLayout typeLayout, IInternalTrace internalTrace, string platform, bool enabledSSA) { IArchitecture architecture; switch (platform.ToLower()) { case "x86": architecture = x86.Architecture.CreateArchitecture(x86.ArchitectureFeatureFlags.AutoDetect); break; case "avr32": architecture = AVR32.Architecture.CreateArchitecture(AVR32.ArchitectureFeatureFlags.AutoDetect); break; default: architecture = x86.Architecture.CreateArchitecture(x86.ArchitectureFeatureFlags.AutoDetect); break; } CompilerOptions compilerOptions = new CompilerOptions(); compilerOptions.EnableSSA = enabledSSA; ExplorerAssemblyCompiler compiler = new ExplorerAssemblyCompiler(architecture, typeSystem, typeLayout, internalTrace, compilerOptions); compiler.Compile(); }
/// <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; }
public AotAssemblyCompiler(IArchitecture architecture, IAssemblyLinker linker, ITypeSystem typeSystem, ITypeLayout typeLayout, IInternalTrace internalTrace, CompilerOptions compilerOptions) : base(architecture, typeSystem, typeLayout, internalTrace, compilerOptions) { }
/// <summary> /// Initializes a new instance of the <see cref="BaseMethodCompiler"/> class. /// </summary> /// <param name="assemblyCompiler">The assembly compiler.</param> /// <param name="type">The type, which owns the method to compile.</param> /// <param name="method">The method to compile by this instance.</param> /// <param name="instructionSet">The instruction set.</param> /// <param name="compilationScheduler">The compilation scheduler.</param> protected BaseMethodCompiler(AssemblyCompiler assemblyCompiler, RuntimeType type, RuntimeMethod method, InstructionSet instructionSet, ICompilationSchedulerStage compilationScheduler) { if (compilationScheduler == null) throw new ArgumentNullException(@"compilationScheduler"); this.assemblyCompiler = assemblyCompiler; this.method = method; this.type = type; this.compilationScheduler = compilationScheduler; this.moduleTypeSystem = method.Module; this.architecture = assemblyCompiler.Architecture; this.typeSystem = assemblyCompiler.TypeSystem; this.typeLayout = AssemblyCompiler.TypeLayout; this.internalTrace = AssemblyCompiler.InternalTrace; this.linker = assemblyCompiler.Pipeline.FindFirst<IAssemblyLinker>(); this.plugSystem = assemblyCompiler.Pipeline.FindFirst<IPlugSystem>(); this.parameters = new List<Operand>(new Operand[method.Parameters.Count]); this.nextStackSlot = 0; this.basicBlocks = new List<BasicBlock>(); this.instructionSet = instructionSet ?? new InstructionSet(256); this.pipeline = new CompilerPipeline(); }
/// <summary> /// Initializes a new instance of the <see cref="AotCompiler"/> class. /// </summary> /// <param name="architecture">The architecture.</param> /// <param name="linker">The linker.</param> /// <param name="typeSystem">The type system.</param> /// <param name="typeLayout">The type layout.</param> /// <param name="internalTrace">The internal trace.</param> /// <param name="compilerOptions">The compiler options.</param> public AotCompiler(IArchitecture architecture, ILinker linker, ITypeSystem typeSystem, ITypeLayout typeLayout, IInternalTrace internalTrace, CompilerOptions compilerOptions) : base(architecture, typeSystem, typeLayout, new CompilationScheduler(typeSystem, true), internalTrace, compilerOptions) { }
/// <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> /// 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> /// Initializes a new instance of the <see cref="AotCompiler"/> class. /// </summary> /// <param name="architecture">The target compilation architecture.</param> /// <param name="typeSystem">The type system.</param> public AotCompiler(IArchitecture architecture, ITypeSystem typeSystem, ITypeLayout typeLayout) : base(architecture, typeSystem, typeLayout) { }
/// <summary> /// Initializes a new instance of the <see cref="BaseMethodCompiler"/> class. /// </summary> /// <param name="assemblyCompiler">The assembly compiler.</param> /// <param name="type">The type, which owns the method to compile.</param> /// <param name="method">The method to compile by this instance.</param> /// <param name="instructionSet">The instruction set.</param> /// <param name="compilationScheduler">The compilation scheduler.</param> protected BaseMethodCompiler(AssemblyCompiler assemblyCompiler, RuntimeType type, RuntimeMethod method, InstructionSet instructionSet, ICompilationSchedulerStage compilationScheduler) { if (compilationScheduler == null) throw new ArgumentNullException(@"compilationScheduler"); this.assemblyCompiler = assemblyCompiler; this.method = method; this.type = type; this.compilationScheduler = compilationScheduler; this.moduleTypeSystem = method.Module; this.architecture = assemblyCompiler.Architecture; this.typeSystem = assemblyCompiler.TypeSystem; this.typeLayout = AssemblyCompiler.TypeLayout; this.internalTrace = AssemblyCompiler.InternalTrace; this.linker = assemblyCompiler.Pipeline.FindFirst<IAssemblyLinker>(); this.plugSystem = assemblyCompiler.Pipeline.FindFirst<IPlugSystem>(); this.parameters = new List<Operand>(new Operand[method.Parameters.Count]); 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(); }
/// <summary> /// Setups the specified compiler. /// </summary> /// <param name="compiler">The compiler.</param> public void Setup(IMethodCompiler compiler) { if (compiler == null) throw new ArgumentNullException(@"compiler"); methodCompiler = compiler; instructionSet = compiler.InstructionSet; basicBlocks = compiler.BasicBlocks; architecture = compiler.Architecture; typeModule = compiler.Method.Module; typeSystem = compiler.TypeSystem; typeLayout = compiler.TypeLayout; callingConvention = architecture.GetCallingConvention(); architecture.GetTypeRequirements(BuiltInSigType.IntPtr, out nativePointerSize, out nativePointerAlignment); }
/// <summary> /// Retrieves a calling convention object for the requested calling convention. /// </summary> /// <param name="typeLayout">The type layout.</param> /// <returns> /// An instance of <see cref="ICallingConvention"/>. /// </returns> public override ICallingConvention GetCallingConvention(ITypeLayout typeLayout) { if (callingConvention == null) callingConvention = new DefaultCallingConvention(this, typeLayout); return callingConvention; }
/// <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; }