当前位置: 首页>>代码示例>>C#>>正文


C# BasicBlocks类代码示例

本文整理汇总了C#中BasicBlocks的典型用法代码示例。如果您正苦于以下问题:C# BasicBlocks类的具体用法?C# BasicBlocks怎么用?C# BasicBlocks使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BasicBlocks类属于命名空间,在下文中一共展示了BasicBlocks类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SparseConditionalConstantPropagation

        public SparseConditionalConstantPropagation(BasicBlocks basicBlocks, ITraceFactory traceFactory)
        {
            this.TraceFactory = traceFactory;
            this.BasicBlocks = basicBlocks;

            MainTrace = CreateTrace("SparseConditionalConstantPropagation");

            // Method is empty - must be a plugged method
            if (BasicBlocks.HeadBlocks.Count == 0)
                return;

            blockStates = new bool[BasicBlocks.Count];

            for (int i = 0; i < BasicBlocks.Count; i++)
            {
                blockStates[i] = false;
            }

            // Initialize
            foreach (var block in BasicBlocks.HeadBlocks)
            {
                AddExecutionBlock(block);
            }

            while (blockWorklist.Count > 0 || instructionWorkList.Count > 0)
            {
                ProcessBlocks();
                ProcessInstructions();
            }

            DumpTrace();

            // Release
            phiStatements = null;
        }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:35,代码来源:SparseConditionalConstantPropagation.cs

示例2: BaseMethodCompiler

        /// <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();
        }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:33,代码来源:BaseMethodCompiler.cs

示例3: FinalizeAll

 public static void FinalizeAll(BasicBlocks basicBlocks, IList<ProtectedRegion> protectedRegions)
 {
     foreach (var region in protectedRegions)
     {
         region.Finalize(basicBlocks);
     }
 }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:7,代码来源:ProtectedRegion.cs

示例4: PerformAnalysis

        public void PerformAnalysis(BasicBlocks basicBlocks)
        {
            // Create dictionary of referenced blocks
            var referenced = new Dictionary<BasicBlock, int>(basicBlocks.Count);

            // Allocate list of ordered Blocks
            blockOrder = new BasicBlock[basicBlocks.Count];
            int orderBlockCnt = 0;

            // Create sorted worklist
            var workList = new Stack<BasicBlock>();

            foreach (var head in basicBlocks.HeadBlocks)
            {
                workList.Push(head);

                while (workList.Count != 0)
                {
                    var block = workList.Pop();

                    if (!referenced.ContainsKey(block))
                    {
                        referenced.Add(block, 0);
                        blockOrder[orderBlockCnt++] = block;

                        foreach (var successor in block.NextBlocks)
                            if (!referenced.ContainsKey(successor))
                                workList.Push(successor);
                    }
                }
            }
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:32,代码来源:SimpleTraceBlockOrder.cs

示例5: SimMethodCompiler

        /// <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),
            });
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:43,代码来源:SimMethodCompiler.cs

示例6: AotMethodCompiler

        /// <summary>
        /// Initializes a new instance of the <see cref="AotMethodCompiler" /> class.
        /// </summary>
        /// <param name="compiler">The compiler.</param>
        /// <param name="method">The method.</param>
        /// <param name="basicBlocks">The basic blocks.</param>
        /// <param name="instructionSet">The instruction set.</param>
        public AotMethodCompiler(BaseCompiler compiler, MosaMethod method, BasicBlocks basicBlocks, InstructionSet instructionSet)
            : base(compiler, method, basicBlocks, instructionSet)
        {
            var compilerOptions = compiler.CompilerOptions;

            Pipeline.Add(new IMethodCompilerStage[] {
                new CILDecodingStage(),
                new BasicBlockBuilderStage(),
                new StackSetupStage(),
                new ExceptionPrologueStage(),
                new OperandAssignmentStage(),
                new StaticAllocationResolutionStage(),
                new CILTransformationStage(),
                new ConvertCompoundMoveStage(),
                (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	PlatformEdgeSplitStage(),
                new GreedyRegisterAllocatorStage(),
                new StackLayoutStage(),
                new EmptyBlockRemovalStage(),
                new BlockOrderingStage(),
                new CodeGenerationStage(),
            });
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:37,代码来源:AotMethodCompiler.cs

示例7: CreateExceptionVector

        /// <summary>
        /// Creates the ISR methods.
        /// </summary>
        private void CreateExceptionVector()
        {
            var type = TypeSystem.GetTypeByName("Mosa.Kernel.x86", "IDT");

            if (type == null)
                return;

            var method = type.FindMethodByName("ExceptionHandlerType");

            if (method == null)
                return;

            Operand exceptionMethod = Operand.CreateSymbolFromMethod(TypeSystem, method);

            Operand esp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ESP);

            BasicBlocks basicBlocks = new BasicBlocks();
            InstructionSet instructionSet = new InstructionSet(25);
            Context ctx = instructionSet.CreateNewBlock(basicBlocks);
            basicBlocks.AddHeaderBlock(ctx.BasicBlock);

            // TODO - setup stack for call to the managed exception handler

            //1.
            //2.

            //3. Call the managed exception handler
            ctx.AppendInstruction(X86.Call, null, exceptionMethod);

            var vectorMethod = Compiler.CreateLinkerMethod("ExceptionVector");

            Compiler.CompileMethod(vectorMethod, basicBlocks, instructionSet);
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:36,代码来源:ExceptionVectorStage.cs

示例8: BaseMethodCompiler

        /// <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="instructionSet">The instruction set.</param>
        protected BaseMethodCompiler(BaseCompiler compiler, MosaMethod method, BasicBlocks basicBlocks, InstructionSet instructionSet)
        {
            this.Compiler = compiler;
            this.Method = method;
            this.Type = method.DeclaringType;
            this.Scheduler = compiler.CompilationScheduler;
            this.Architecture = compiler.Architecture;
            this.TypeSystem = compiler.TypeSystem;
            this.TypeLayout = Compiler.TypeLayout;
            this.InternalTrace = Compiler.InternalTrace;
            this.Linker = compiler.Linker;
            this.BasicBlocks = basicBlocks ?? new BasicBlocks();
            this.InstructionSet = instructionSet ?? new InstructionSet(256);
            this.Pipeline = new CompilerPipeline();
            this.StackLayout = new StackLayout(Architecture, method.Signature.Parameters.Count + (method.HasThis || method.HasExplicitThis ? 1 : 0));
            this.VirtualRegisters = new VirtualRegisters(Architecture);
            this.LocalVariables = emptyOperandList;
            this.DominanceAnalysis = new DominanceAnalysis(Compiler.CompilerOptions.DominanceAnalysisFactory, this.BasicBlocks);

            EvaluateParameterOperands();

            this.stop = false;

            Debug.Assert(this.Linker != null);
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:32,代码来源:BaseMethodCompiler.cs

示例9: TypeInitializerSchedulerStage

 /// <summary>
 /// Initializes a new instance of the <see cref="TypeInitializerSchedulerStage"/> class.
 /// </summary>
 public TypeInitializerSchedulerStage()
 {
     basicBlocks = new BasicBlocks();
     var block = basicBlocks.CreateBlock(BasicBlock.PrologueLabel);
     basicBlocks.AddHeaderBlock(block);
     context = new Context(block);
 }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:10,代码来源:TypeInitializerSchedulerStage.cs

示例10: TypeInitializerSchedulerStage

        /// <summary>
        /// Initializes a new instance of the <see cref="TypeInitializerSchedulerStage"/> class.
        /// </summary>
        public TypeInitializerSchedulerStage()
        {
            basicBlocks = new BasicBlocks();

            // Create the blocks
            var prologueBlock = basicBlocks.CreateBlock(BasicBlock.PrologueLabel);
            var startBlock = basicBlocks.CreateBlock(BasicBlock.StartLabel);
            var epilogueBlock = basicBlocks.CreateBlock(BasicBlock.EpilogueLabel);

            // Create the prologue instructions
            basicBlocks.AddHeadBlock(prologueBlock);
            var prologue = new Context(prologueBlock);
            prologue.AppendInstruction(IRInstruction.Prologue);
            prologue.Label = -1;
            prologue.AppendInstruction(IRInstruction.Jmp, startBlock);

            // Create the epilogue instruction
            var epilogue = new Context(epilogueBlock);
            epilogue.AppendInstruction(IRInstruction.Epilogue);

            // create start instructions
            start = new Context(startBlock);
            start.AppendInstruction(IRInstruction.Jmp, epilogueBlock);
            start.GotoPrevious();
        }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:28,代码来源:TypeInitializerSchedulerStage.cs

示例11: SimpleFastDominance

        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        public SimpleFastDominance(BasicBlocks basicBlocks, BasicBlock entryBlock)
        {
            // Blocks in reverse post order topology
            List<BasicBlock> blocks = BasicBlocks.ReversePostorder(entryBlock); //basicBlocks.GetConnectedBlocksStartingAtHead(entryBlock);

            CalculateDominance(blocks);
            CalculateChildren(blocks);
            CalculateDominanceFrontier(blocks);
        }
开发者ID:jeffreye,项目名称:MOSA-Project,代码行数:12,代码来源:SimpleFastDominance.cs

示例12: TypeInitializerSchedulerStage

        /// <summary>
        /// Initializes a new instance of the <see cref="TypeInitializerSchedulerStage"/> class.
        /// </summary>
        public TypeInitializerSchedulerStage()
        {
            basicBlocks = new BasicBlocks();
            instructionSet = new InstructionSet(25);
            context = instructionSet.CreateNewBlock(basicBlocks);
            basicBlocks.AddHeaderBlock(context.BasicBlock);

            context.AppendInstruction(IRInstruction.Prologue);
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:12,代码来源:TypeInitializerSchedulerStage.cs

示例13: Finalize

        public void Finalize(BasicBlocks basicBlocks)
        {
            foreach (var block in included)
            {
                if (!basicBlocks.Contains(block))
                    continue;

                Trace(block);
            }
        }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:10,代码来源:ProtectedRegion.cs

示例14: ProtectedRegion

        public ProtectedRegion(BasicBlocks basicBlocks, MosaExceptionHandler exceptionHandler)
        {
            this.Handler = exceptionHandler;

            foreach (var block in basicBlocks)
            {
                if (block.Label >= exceptionHandler.TryStart && block.Label < exceptionHandler.TryEnd)
                    included.Add(block);
                else
                    excluded.Add(block);
            }
        }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:12,代码来源:ProtectedRegion.cs

示例15: CreateProtectedRegions

        public static IList<ProtectedRegion> CreateProtectedRegions(BasicBlocks basicBlocks, IList<MosaExceptionHandler> exceptionHandlers)
        {
            var protectedRegions = new List<ProtectedRegion>(exceptionHandlers.Count);

            foreach (var handler in exceptionHandlers)
            {
                var protectedRegion = new ProtectedRegion(basicBlocks, handler);
                protectedRegions.Add(protectedRegion);
            }

            return protectedRegions;
        }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:12,代码来源:ProtectedRegion.cs


注:本文中的BasicBlocks类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。