コード例 #1
0
 public void Setup(AssemblyCompiler compiler)
 {
     this.compiler = compiler;
     architecture  = compiler.Architecture;
     typeSystem    = compiler.TypeSystem;
     typeLayout    = compiler.TypeLayout;
 }
コード例 #2
0
 public void Setup(AssemblyCompiler compiler)
 {
     this.compiler = compiler;
     architecture = compiler.Architecture;
     typeSystem = compiler.TypeSystem;
     typeLayout = compiler.TypeLayout;
 }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
        /// <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;
        }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
 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)
             });
 }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
        //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);
        }
コード例 #10
0
ファイル: Main.cs プロジェクト: davidleon/MOSA-Project
        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();
        }
コード例 #11
0
        //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);
        }
コード例 #12
0
        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();
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        /// <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);
        }
コード例 #16
0
        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();
        }
コード例 #17
0
        /// <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;
        }
コード例 #18
0
 public AotAssemblyCompiler(IArchitecture architecture, IAssemblyLinker linker, ITypeSystem typeSystem, ITypeLayout typeLayout, IInternalTrace internalTrace, CompilerOptions compilerOptions)
     : base(architecture, typeSystem, typeLayout, internalTrace, compilerOptions)
 {
 }
コード例 #19
0
        /// <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();
        }
コード例 #20
0
ファイル: AotCompiler.cs プロジェクト: pdelprat/MOSA-Project
 /// <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)
 {
 }
コード例 #21
0
        /// <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;
        }
コード例 #22
0
ファイル: BaseCompiler.cs プロジェクト: jeffreye/MOSA-Project
        /// <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();
        }
コード例 #23
0
ファイル: AotCompiler.cs プロジェクト: davidleon/MOSA-Project
 /// <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)
 {
 }
コード例 #24
0
        /// <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();
        }
コード例 #25
0
 /// <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)
 {
 }
コード例 #26
0
 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)
     });
 }
コード例 #27
0
        /// <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);
        }
コード例 #28
0
        /// <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;
        }
コード例 #29
0
        /// <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;
        }