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


C# Framework.BaseMethodCompiler类代码示例

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


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

示例1:

 /// <summary>
 /// Replaces the intrinsic call site
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="typeSystem">The type system.</param>
 void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
 {
     var result = context.Result;
     var address = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.I4);
     context.SetInstruction(IRInstruction.Move, address, Operand.CreateUnmanagedSymbolPointer(methodCompiler.TypeSystem, Multiboot0695Stage.MultibootEBX));
     context.AppendInstruction(IRInstruction.Move, result, Operand.CreateMemoryAddress(methodCompiler.TypeSystem.BuiltIn.I4, address, 0));
 }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:12,代码来源:GetMultibootEBX.cs

示例2: PatchConstructor

        private static void PatchConstructor(BaseMethodCompiler methodCompiler)
        {
            Operand thisOperand = methodCompiler.Parameters[0];
            Operand instanceOperand = methodCompiler.Parameters[1];
            Operand methodPointerOperand = methodCompiler.Parameters[2];

            var size = methodCompiler.Architecture.NativeInstructionSize;

            MosaField methodPointerField = GetField(methodCompiler.Method.DeclaringType, "methodPointer");
            int methodPointerOffset = methodCompiler.TypeLayout.GetFieldOffset(methodPointerField);
            Operand methodPointerOffsetOperand = Operand.CreateConstant(methodCompiler.TypeSystem, methodPointerOffset);

            MosaField instanceField = GetField(methodCompiler.Method.DeclaringType, "instance");
            int instanceOffset = methodCompiler.TypeLayout.GetFieldOffset(instanceField);
            Operand instanceOffsetOperand = Operand.CreateConstant(methodCompiler.TypeSystem, instanceOffset);

            var context = new Context(CreateMethodStructure(methodCompiler, true));

            Operand v1 = methodCompiler.CreateVirtualRegister(thisOperand.Type);
            Operand v2 = methodCompiler.CreateVirtualRegister(methodPointerOperand.Type);
            Operand v3 = methodCompiler.CreateVirtualRegister(instanceOperand.Type);

            context.AppendInstruction(IRInstruction.LoadInteger, v1, methodCompiler.StackFrame, thisOperand);
            context.AppendInstruction(IRInstruction.LoadInteger, v2, methodCompiler.StackFrame, methodPointerOperand);
            context.AppendInstruction(IRInstruction.LoadInteger, v3, methodCompiler.StackFrame, instanceOperand);

            context.AppendInstruction(IRInstruction.StoreInteger, size, null, v1, methodPointerOffsetOperand, v2);
            context.MosaType = methodPointerOperand.Type;
            context.AppendInstruction(IRInstruction.StoreInteger, size, null, v1, instanceOffsetOperand, v3);
            context.MosaType = instanceOperand.Type;
            context.AppendInstruction(IRInstruction.Return, methodCompiler.BasicBlocks.EpilogueBlock);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:32,代码来源:DelegatePatcher.cs

示例3: InvalidCompilerException

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            var operand = context.Operand1;

            if (!operand.IsConstant)
            {
                // try to find the constant - a bit of a hack
                Context ctx = new Context(operand.Definitions[0]);

                if (ctx.Instruction == IRInstruction.Move && ctx.Operand1.IsConstant)
                {
                    operand = ctx.Operand1;
                }
            }

            Debug.Assert(operand.IsConstant);

            int irq = (int)operand.ConstantSignedLongInteger;

            // Find the method
            var method = methodCompiler.TypeSystem.DefaultLinkerType.FindMethodByName("InterruptISR" + irq.ToString());

            if (method == null)
            {
                throw new InvalidCompilerException();
            }

            context.SetInstruction(IRInstruction.Move, context.Result, Operand.CreateSymbolFromMethod(methodCompiler.TypeSystem, method));
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:34,代码来源:GetIDTJumpLocation.cs

示例4:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            Debug.Assert(context.Result.IsI4 | context.Result.IsU4);
            Operand zero = Operand.CreateConstant(methodCompiler.TypeSystem, 0);

            context.SetInstruction(X86.MovzxLoad, InstructionSize.Size16, context.Result, context.Operand1, zero);
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:12,代码来源:Get16.cs

示例5:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            var result = context.Result;
            var dividend = context.Operand1;
            var divisor = context.Operand2;

            if (result.IsR8)
            {
                var xmm1 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R8);
                var xmm2 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R8);
                var xmm3 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R8);
                var size = InstructionSize.Size64;

                context.SetInstruction(X86.Divsd, size, xmm1, dividend, divisor);
                context.AppendInstruction(X86.Roundsd, size, xmm2, xmm1, Operand.CreateConstant(methodCompiler.TypeSystem.BuiltIn.U1, 0x3));
                context.AppendInstruction(X86.Mulsd, size, xmm3, divisor, xmm2);
                context.AppendInstruction(X86.Subsd, size, result, dividend, xmm3);
            }
            else
            {
                var xmm1 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R4);
                var xmm2 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R4);
                var xmm3 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.R4);
                var size = InstructionSize.Size32;

                context.SetInstruction(X86.Divss, size, xmm1, dividend, divisor);
                context.AppendInstruction(X86.Roundss, size, xmm2, xmm1, Operand.CreateConstant(methodCompiler.TypeSystem.BuiltIn.U1, 0x3));
                context.AppendInstruction(X86.Mulss, size, xmm3, divisor, xmm2);
                context.AppendInstruction(X86.Subss, size, result, dividend, xmm3);
            }
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:36,代码来源:Remainder.cs

示例6:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            Operand methodAddress = context.Operand1;
            Operand newESP = context.Operand2;

            context.SetInstruction(X86.Call, null, methodAddress);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:12,代码来源:FrameCall.cs

示例7:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            var zero = Operand.CreateConstant(methodCompiler.TypeSystem.BuiltIn.I4, 0);
            var MultibootEAX = Operand.CreateUnmanagedSymbolPointer(methodCompiler.TypeSystem, Multiboot0695Stage.MultibootEAX);

            context.SetInstruction(IRInstruction.Load2, context.Result, MultibootEAX, zero);
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:12,代码来源:GetMultibootEAX.cs

示例8:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            Operand result = context.Result;
            Operand imm = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.U4);

            context.SetInstruction(X86.MovCR, imm, Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.U4, control));
            context.AppendInstruction(X86.Mov, result, imm);
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:13,代码来源:GetControlRegisterBase.cs

示例9: PatchBeginInvoke

        private static void PatchBeginInvoke(BaseMethodCompiler methodCompiler)
        {
            var nullOperand = Operand.GetNull(methodCompiler.TypeSystem);

            var context = new Context(CreateMethodStructure(methodCompiler, true));
            context.AppendInstruction(IRInstruction.Return, null, nullOperand);
            context.AddBranchTarget(methodCompiler.BasicBlocks.EpilogueBlock);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:8,代码来源:DelegatePatcher.cs

示例10:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            Operand result = context.Result;
            Operand eax = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.U4);

            context.AppendInstruction(X86.Add, eax, eax, Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.U4, GeneralPurposeRegister.ESP));
            context.AppendInstruction(X86.Mov, eax, Operand.CreateMemoryAddress(methodCompiler.TypeSystem.BuiltIn.U4, eax, 0));
            context.AppendInstruction(X86.Mov, result, eax);
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:14,代码来源:GetEip.cs

示例11:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            // Create constant operand and pointer to variable containing the lock
            Operand const0 = Operand.CreateConstantSignedInt(methodCompiler.TypeSystem, 0x0);
            Operand locked = Operand.CreateMemoryAddress(methodCompiler.TypeSystem.BuiltIn.Pointer, context.Operand1, 0);

            // Set the variable locked to 0 signifying that the lock is free
            context.SetInstruction(X86.Mov, locked, const0);
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:14,代码来源:SpinUnlock.cs

示例12:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            Operand result = context.Result;
            Operand edx = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.Pointer);
            Operand operand = Operand.CreateMemoryAddress(context.Operand1.Type, edx, 0);

            context.SetInstruction(X86.Mov, edx, context.Operand1);
            context.AppendInstruction(X86.Mov, result, operand);
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:14,代码来源:Get.cs

示例13: Run

 public static void Run(BaseMethodCompiler methodCompiler, IPipelineStage stage)
 {
     Run(
         methodCompiler.Trace,
         methodCompiler.FormatStageName(stage),
         methodCompiler.Method,
         methodCompiler.BasicBlocks
     );
 }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:9,代码来源:InstructionLogger.cs

示例14:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="methodCompiler">The method compiler.</param>
        void IIntrinsicInternalMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            var ctor = context.Operand1;
            var thisObject = context.Operand2;
            var result = context.Result;

            context.SetInstruction(IRInstruction.Call, null, ctor, thisObject);
            context.AppendInstruction(IRInstruction.MoveInteger, result, thisObject);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:14,代码来源:CreateInstanceSimple.cs

示例15:

        /// <summary>
        /// Replaces the intrinsic call site
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="typeSystem">The type system.</param>
        void IIntrinsicPlatformMethod.ReplaceIntrinsicCall(Context context, BaseMethodCompiler methodCompiler)
        {
            Operand operand1 = context.Operand1;

            Operand v1 = methodCompiler.CreateVirtualRegister(methodCompiler.TypeSystem.BuiltIn.U4);

            context.SetInstruction(X86.Mov, v1, operand1);
            context.AppendInstruction(X86.Mov, Operand.CreateCPURegister(methodCompiler.TypeSystem.BuiltIn.U4, SegmentRegister.FS), v1);
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:14,代码来源:SetFS.cs


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