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


C# BasicBlocks.AddHeadBlock方法代码示例

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


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

示例1: 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

示例2: CreateBasicBlockInstructionSet

        private static BasicBlocks CreateBasicBlockInstructionSet()
        {
            var basicBlocks = new BasicBlocks();

            var block = basicBlocks.CreateBlock();
            basicBlocks.AddHeadBlock(block);

            var context = new Context(block);

            context.AppendInstruction(IRInstruction.Nop);
            context.AppendInstruction(IRInstruction.Nop);
            context.AppendInstruction(IRInstruction.Nop);
            context.AppendInstruction(IRInstruction.Nop);
            context.AppendInstruction(IRInstruction.Nop);
            context.AppendInstruction(IRInstruction.Nop);

            return basicBlocks;
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:18,代码来源:LiveRangeTests.cs

示例3: Run

        protected override void Run()
        {
            var typeInitializer = Compiler.PostCompilePipeline.FindFirst<TypeInitializerSchedulerStage>().TypeInitializerMethod;

            var basicBlocks = new BasicBlocks();
            var block = basicBlocks.CreateBlock();
            basicBlocks.AddHeadBlock(block);
            var context = new Context(block);

            var entryPoint = Operand.CreateSymbolFromMethod(TypeSystem, typeInitializer);

            context.AppendInstruction(IRInstruction.Call, null, entryPoint);
            context.InvokeMethod = typeInitializer;

            var method = Compiler.CreateLinkerMethod(StartUpName);
            Compiler.CompileMethod(method, basicBlocks, 0);

            Linker.EntryPoint = Linker.GetSymbol(method.FullName, SectionKind.Text);
        }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:19,代码来源:SimPowerUpStage.cs

示例4: Run

        protected override void Run()
        {
            Debug.Assert(setupMethod == null, "SSE setup method already generated!");

            setupMethod = Compiler.CreateLinkerMethod("SSEInit");

            var eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.U4, GeneralPurposeRegister.EAX);
            var cr0 = Operand.CreateCPURegister(TypeSystem.BuiltIn.U4, ControlRegister.CR0);
            var cr4 = Operand.CreateCPURegister(TypeSystem.BuiltIn.U4, ControlRegister.CR4);

            var basicBlocks = new BasicBlocks();
            var block = basicBlocks.CreateBlock();
            basicBlocks.AddHeadBlock(block);
            var ctx = new Context(block);

            /*
               ;enable SSE and the like
                mov eax, cr0
                and ax, 0xFFFB		;clear coprocessor emulation CR0.EM
                or ax, 0x2			;set coprocessor monitoring  CR0.MP
                mov cr0, eax
                mov eax, cr4
                or ax, 3 << 9		;set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time
                mov cr4, eax
                ret
            */

            ctx.AppendInstruction(X86.MovCR, eax, cr0);
            ctx.AppendInstruction(X86.And, eax, eax, Operand.CreateConstant(TypeSystem.BuiltIn.U4, 0xFFFB));
            ctx.AppendInstruction(X86.Or, eax, eax, Operand.CreateConstant(TypeSystem.BuiltIn.U4, 0x2));
            ctx.AppendInstruction(X86.MovCR, cr0, eax);

            ctx.AppendInstruction(X86.MovCR, eax, cr4);
            ctx.AppendInstruction(X86.Or, eax, eax, Operand.CreateConstant(TypeSystem.BuiltIn.U4, 0x600));
            ctx.AppendInstruction(X86.MovCR, cr4, eax);

            ctx.AppendInstruction(X86.Ret);

            Compiler.CompileMethod(setupMethod, basicBlocks, 0);

            var typeInitializerSchedulerStage = Compiler.PostCompilePipeline.FindFirst<TypeInitializerSchedulerStage>();
            typeInitializerSchedulerStage.Schedule(setupMethod);
        }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:43,代码来源:SSESetupStage.cs

示例5: RunPreCompile

        protected override void RunPreCompile()
        {
            var sseInitMethod = Compiler.CreateLinkerMethod("SSEInit");

            var eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.U4, GeneralPurposeRegister.EAX);
            var cr0 = Operand.CreateCPURegister(TypeSystem.BuiltIn.U4, ControlRegister.CR0);
            var cr4 = Operand.CreateCPURegister(TypeSystem.BuiltIn.U4, ControlRegister.CR4);

            var basicBlocks = new BasicBlocks();
            var block = basicBlocks.CreateBlock();
            basicBlocks.AddHeadBlock(block);
            var ctx = new Context(block);

            /*
               ;enable SSE and the like
                mov eax, cr0
                and ax, 0xFFFB		;clear coprocessor emulation CR0.EM
                or ax, 0x2			;set coprocessor monitoring  CR0.MP
                mov cr0, eax
                mov eax, cr4
                or ax, 3 << 9		;set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time
                mov cr4, eax
                ret
            */

            ctx.AppendInstruction(X86.MovCR, eax, cr0);
            ctx.AppendInstruction(X86.And, eax, eax, Operand.CreateConstant(TypeSystem.BuiltIn.U4, 0xFFFB));
            ctx.AppendInstruction(X86.Or, eax, eax, Operand.CreateConstant(TypeSystem.BuiltIn.U4, 0x2));
            ctx.AppendInstruction(X86.MovCR, cr0, eax);

            ctx.AppendInstruction(X86.MovCR, eax, cr4);
            ctx.AppendInstruction(X86.Or, eax, eax, Operand.CreateConstant(TypeSystem.BuiltIn.U4, 0x600));
            ctx.AppendInstruction(X86.MovCR, cr4, eax);

            ctx.AppendInstruction(X86.Ret);

            Compiler.CompileMethod(sseInitMethod, basicBlocks);

            var startUpType = TypeSystem.GetTypeByName("Mosa.Runtime", "StartUp");
            var startUpMethod = startUpType.FindMethodByName("Stage2");

            Compiler.PlugSystem.CreatePlug(sseInitMethod, startUpMethod);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:43,代码来源:SSEInitStage.cs

示例6: CreateInterruptVectors

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

            if (type == null)
                return;

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

            if (method == null)
                return;

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

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

            for (int i = 0; i <= 255; i++)
            {
                var basicBlocks = new BasicBlocks();
                var block = basicBlocks.CreateBlock();
                basicBlocks.AddHeadBlock(block);
                var ctx = new Context(block);

                ctx.AppendInstruction(X86.Cli);
                if (i <= 7 || i >= 16 | i == 9) // For IRQ 8, 10, 11, 12, 13, 14 the cpu will automatically pushed the error code
                    ctx.AppendInstruction(X86.Push, null, Operand.CreateConstant(TypeSystem, 0));
                ctx.AppendInstruction(X86.Push, null, Operand.CreateConstant(TypeSystem, i));
                ctx.AppendInstruction(X86.Pushad);
                ctx.AppendInstruction(X86.Push, null, esp);
                ctx.AppendInstruction(X86.Call, null, interrupt);
                ctx.AppendInstruction(X86.Pop, esp);
                ctx.AppendInstruction(X86.Popad);
                ctx.AppendInstruction(X86.Add, esp, esp, Operand.CreateConstant(TypeSystem, 8));
                ctx.AppendInstruction(X86.Sti);
                ctx.AppendInstruction(X86.IRetd);

                var interruptMethod = Compiler.CreateLinkerMethod("InterruptISR" + i.ToString());
                Compiler.CompileMethod(interruptMethod, basicBlocks);
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:43,代码来源:InterruptVectorStage.cs

示例7: Run

        protected override void Run()
        {
            if (multibootMethod == null)
            {
                multibootHeader = Linker.CreateSymbol(MultibootHeaderSymbolName, SectionKind.Text, 1, 0x30);

                multibootMethod = Compiler.CreateLinkerMethod("MultibootInit");

                Linker.EntryPoint = Linker.GetSymbol(multibootMethod.FullName, SectionKind.Text);

                WriteMultibootHeader();

                Linker.CreateSymbol(Multiboot0695Stage.MultibootEAX, SectionKind.BSS, Architecture.NativeAlignment, Architecture.NativePointerSize);
                Linker.CreateSymbol(MultibootEBX, SectionKind.BSS, Architecture.NativeAlignment, Architecture.NativePointerSize);

                return;
            }

            var typeInitializerSchedulerStage = Compiler.PostCompilePipeline.FindFirst<TypeInitializerSchedulerStage>();

            var eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);
            var ebx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBX);
            var ebp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBP);
            var esp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ESP);

            var MultibootEAX = Operand.CreateUnmanagedSymbolPointer(TypeSystem, Multiboot0695Stage.MultibootEAX);
            var multibootEBX = Operand.CreateUnmanagedSymbolPointer(TypeSystem, Multiboot0695Stage.MultibootEBX);

            var zero = Operand.CreateConstant(TypeSystem.BuiltIn.I4, 0);
            var stackTop = Operand.CreateConstant(TypeSystem.BuiltIn.I4, STACK_ADDRESS);

            var basicBlocks = new BasicBlocks();
            var block = basicBlocks.CreateBlock();
            basicBlocks.AddHeadBlock(block);
            var ctx = new Context(block);

            // Setup the stack and place the sentinel on the stack to indicate the start of the stack
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, esp, zero, stackTop);
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, ebp, zero, zero);

            // Place the multiboot address into a static field
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, MultibootEAX, zero, eax);
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, multibootEBX, zero, ebx);

            // call type initializer
            var entryPoint = Operand.CreateSymbolFromMethod(TypeSystem, typeInitializerSchedulerStage.TypeInitializerMethod);
            ctx.AppendInstruction(X86.Call, null, entryPoint);

            // should never get here
            ctx.AppendInstruction(X86.Ret);

            Compiler.CompileMethod(multibootMethod, basicBlocks, 0);
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:53,代码来源:Multiboot0695Stage.cs

示例8: RunPostCompile

        protected override void RunPostCompile()
        {
            var eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);
            var ebx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBX);
            var ebp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBP);
            var esp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ESP);

            var multibootEAX = Operand.CreateUnmanagedSymbolPointer(TypeSystem, Multiboot0695Stage.MultibootEAX);
            var multibootEBX = Operand.CreateUnmanagedSymbolPointer(TypeSystem, Multiboot0695Stage.MultibootEBX);

            var stackTop = Operand.CreateConstant(TypeSystem.BuiltIn.I4, STACK_ADDRESS);
            var zero = Operand.CreateConstant(TypeSystem.BuiltIn.I4, 0);
            var four = Operand.CreateConstant(TypeSystem.BuiltIn.I4, 4);

            var basicBlocks = new BasicBlocks();
            var block = basicBlocks.CreateBlock();
            basicBlocks.AddHeadBlock(block);
            var ctx = new Context(block);

            // Setup the stack and place the sentinel on the stack to indicate the start of the stack
            ctx.AppendInstruction(X86.Mov, InstructionSize.Size32, esp, stackTop);
            ctx.AppendInstruction(X86.Mov, InstructionSize.Size32, ebp, stackTop);
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, esp, zero, zero);
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, esp, four, zero);

            // Place the multiboot address into a static field
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, multibootEAX, zero, eax);
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, multibootEBX, zero, ebx);

            var startUpType = TypeSystem.GetTypeByName("Mosa.Runtime", "StartUp");
            var startUpMethod = startUpType.FindMethodByName("Initialize");

            var entryPoint = Operand.CreateSymbolFromMethod(TypeSystem, startUpMethod);
            ctx.AppendInstruction(X86.Call, null, entryPoint);

            ctx.AppendInstruction(X86.Ret);

            Compiler.CompileMethod(multibootMethod, basicBlocks);

            WriteMultibootHeader();
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:41,代码来源:Multiboot0695Stage.cs

示例9: RunPostCompile

        protected override void RunPostCompile()
        {
            WriteMultibootHeader();

            var typeInitializerSchedulerStage = Compiler.CompilePipeline.FindFirst<TypeInitializerSchedulerStage>();

            var eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);
            var ebx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBX);
            var ebp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBP);
            var esp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ESP);

            var multibootEAX = Operand.CreateUnmanagedSymbolPointer(TypeSystem, Multiboot0695Stage.MultibootEAX);
            var multibootEBX = Operand.CreateUnmanagedSymbolPointer(TypeSystem, Multiboot0695Stage.MultibootEBX);

            var zero = Operand.CreateConstant(TypeSystem.BuiltIn.I4, 0);
            var stackTop = Operand.CreateConstant(TypeSystem.BuiltIn.I4, STACK_ADDRESS);

            var basicBlocks = new BasicBlocks();
            var block = basicBlocks.CreateBlock();
            basicBlocks.AddHeadBlock(block);
            var ctx = new Context(block);

            // Setup the stack and place the sentinel on the stack to indicate the start of the stack
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, esp, zero, stackTop);
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, ebp, zero, zero);

            // Place the multiboot address into a static field
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, multibootEAX, zero, eax);
            ctx.AppendInstruction(X86.MovStore, InstructionSize.Size32, null, multibootEBX, zero, ebx);

            // should never get here
            ctx.AppendInstruction(X86.Ret);

            Compiler.CompileMethod(multibootMethod, basicBlocks);

            Linker.SetFirst(multibootHeader);
        }
开发者ID:charsleysa,项目名称:MOSA-Project,代码行数:37,代码来源:Multiboot0695Stage.cs


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