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


C# Context.AppendInstruction2方法代码示例

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


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

示例1: Div

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Div"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Div(Context context)
        {
            if (context.Result.IsCPURegister && context.Result2.IsCPURegister && context.Operand1.IsCPURegister)
                if (context.Result.Register == GeneralPurposeRegister.EDX &&
                    context.Result2.Register == GeneralPurposeRegister.EAX &&
                    context.Operand1.Register == GeneralPurposeRegister.EDX &&
                    context.Operand2.Register == GeneralPurposeRegister.EAX)
                    return;

            Operand operand1 = context.Operand1;
            Operand operand2 = context.Operand2;
            Operand operand3 = context.Operand3;
            Operand result = context.Result;
            Operand result2 = context.Result2;

            Operand EAX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);
            Operand EDX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDX);

            context.SetInstruction(X86.Mov, EDX, operand1);
            context.AppendInstruction(X86.Mov, EAX, operand2);

            if (operand3.IsCPURegister)
            {
                context.AppendInstruction2(X86.Div, EDX, EAX, EDX, EAX, operand3);
            }
            else
            {
                Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
                context.AppendInstruction(X86.Mov, v3, operand3);
                context.AppendInstruction2(X86.Div, EDX, EAX, EDX, EAX, v3);
            }

            context.AppendInstruction(X86.Mov, result2, EAX);
            context.AppendInstruction(X86.Mov, result, EDX);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:39,代码来源:FixedRegisterAssignmentStage.cs

示例2: Cdq

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Cdq"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Cdq(Context context)
        {
            if (context.Result.IsCPURegister && context.Result2.IsCPURegister && context.Operand1.IsCPURegister)
                return;

            Operand operand1 = context.Operand1;
            Operand result = context.Result;
            Operand result2 = context.Result2;

            Operand EAX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);
            Operand EDX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDX);

            context.SetInstruction(X86.Mov, EAX, operand1);
            context.AppendInstruction2(X86.Cdq, EDX, EAX, EAX);
            context.AppendInstruction(X86.Mov, result, EDX);
            context.AppendInstruction(X86.Mov, result2, EAX);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:21,代码来源:FixedRegisterAssignmentStage.cs

示例3: Mul

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Mul"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Mul(Context context)
        {
            if (context.Result.IsCPURegister && context.Result2.IsCPURegister && context.Operand1.IsCPURegister && !context.Operand2.IsConstant &&
                context.Result.Register == GeneralPurposeRegister.EDX && context.Result2.Register == GeneralPurposeRegister.EAX && context.Operand1.Register == GeneralPurposeRegister.EAX)
                return;

            Operand operand1 = context.Operand1;
            Operand operand2 = context.Operand2;
            Operand result = context.Result;
            Operand result2 = context.Result2;

            Operand EAX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);
            Operand EDX = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDX);

            context.SetInstruction(X86.Mov, EAX, operand1);

            if (operand2.IsConstant)
            {
                Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
                context.AppendInstruction(X86.Mov, v3, operand2);
                operand2 = v3;
            }

            Debug.Assert(operand2.IsCPURegister || operand2.IsVirtualRegister);

            context.AppendInstruction2(X86.Mul, EDX, EAX, EAX, operand2);
            context.AppendInstruction(X86.Mov, result, EDX);
            context.AppendInstruction(X86.Mov, result2, EAX);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:33,代码来源:FixedRegisterAssignmentStage.cs

示例4: AllocateVirtualRegister

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Mul"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        void IX86Visitor.Mul(Context context)
        {
            if (context.Result.IsCPURegister && context.Result2.IsCPURegister && context.Operand1.IsCPURegister && context.Operand2.IsRegister)
                if (context.Result.Register == GeneralPurposeRegister.EDX &&
                    context.Result2.Register == GeneralPurposeRegister.EAX &&
                    context.Operand1.Register == GeneralPurposeRegister.EAX)
                    return;

            Operand operand1 = context.Operand1;
            Operand operand2 = context.Operand2;
            Operand result = context.Result;
            Operand result2 = context.Result2;

            Operand eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);
            Operand edx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDX);

            context.SetInstruction(X86.Mov, eax, operand1);

            if (operand2.IsRegister)
            {
                context.AppendInstruction2(X86.Mul, edx, eax, eax, operand2);
            }
            else
            {
                Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
                context.AppendInstruction(X86.Mov, v3, operand2);
                context.AppendInstruction2(X86.Mul, edx, eax, eax, v3);
            }

            context.AppendInstruction(X86.Mov, result, edx);
            context.AppendInstruction(X86.Mov, result2, eax);
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:36,代码来源:FixedRegisterAssignmentStage.cs

示例5:

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Setcc"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        void IX86Visitor.Setcc(Context context)
        {
            Debug.Assert(context.Result.IsCPURegister);

            // SETcc can not use ESI or EDI registers
            if (context.Result.IsCPURegister && (context.Result.Register == GeneralPurposeRegister.ESI || context.Result.Register == GeneralPurposeRegister.EDI))
            {
                Operand result = context.Result;
                var condition = context.ConditionCode;

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

                context.SetInstruction2(X86.Xchg, EAX, result, result, EAX);
                context.AppendInstruction(X86.Setcc, condition, EAX);
                context.AppendInstruction2(X86.Xchg, result, EAX, EAX, result);
            }
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:21,代码来源:FinalTweakTransformationStage.cs

示例6: EmitFloatingPointConstants

        /// <summary>
        /// Visitation function for RemUnsigned.
        /// </summary>
        /// <param name="context">The context.</param>
        void IIRVisitor.RemUnsigned(Context context)
        {
            EmitFloatingPointConstants(context);

            Operand result = context.Result;
            Operand operand1 = context.Operand1;
            Operand operand2 = context.Operand2;

            Operand v1 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);
            Operand v2 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);

            context.SetInstruction(X86.Mov, v1, Operand.CreateConstantUnsignedInt(TypeSystem, (uint)0x0));
            context.AppendInstruction2(X86.Div, v1, v2, v1, operand1, operand2);
            context.AppendInstruction(X86.Mov, result, v2);
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:19,代码来源:IRTransformationStage.cs

示例7: Setcc

        public void Setcc(Context context)
        {
            Debug.Assert(context.Result.IsCPURegister);

            Operand result = context.Result;

            Debug.Assert(result.IsCPURegister);

            // SETcc can not use with ESI or EDI registers
            if (result.Register == GeneralPurposeRegister.ESI || result.Register == GeneralPurposeRegister.EDI)
            {
                var condition = context.ConditionCode;

                Operand eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);

                context.SetInstruction2(X86.Xchg, eax, result, result, eax);
                context.AppendInstruction(X86.Setcc, condition, eax);
                context.AppendInstruction2(X86.Xchg, result, eax, eax, result);
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:20,代码来源:FinalTweakTransformationStage.cs

示例8: InsertExchangeInstruction

 /// <summary>
 /// Creates the swap.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="destination">The destination.</param>
 /// <param name="source">The source.</param>
 public override void InsertExchangeInstruction(Context context, Operand destination, Operand source)
 {
     if (source.IsR4)
     {
         // TODO
         throw new CompilerException("R4 not implemented in InsertExchangeInstruction method");
     }
     else if (source.IsR8)
     {
         // TODO
         throw new CompilerException("R8 not implemented in InsertExchangeInstruction method");
     }
     else
     {
         context.AppendInstruction2(X86.Xchg, destination, source, source, destination);
     }
 }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:23,代码来源:Architecture.cs

示例9: AllocateVirtualRegister

        /// <summary>
        /// Visitation function for DivSigned.
        /// </summary>
        /// <param name="context">The context.</param>
        void IIRVisitor.DivSigned(Context context)
        {
            Operand operand1 = context.Operand1;
            Operand operand2 = context.Operand2;
            Operand result = context.Result;

            Operand v1 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
            Operand v2 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);
            Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);

            context.SetInstruction2(X86.Cdq, v1, v2, operand1);
            context.AppendInstruction2(X86.IDiv, v3, result, v1, v2, operand2);
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:17,代码来源:IRTransformationStage.cs

示例10: Mov

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Mov"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Mov(Context context)
        {
            if (context.Result.IsCPURegister && context.Operand1.IsCPURegister && context.Result.Register == context.Operand1.Register)
            {
                context.Empty();
                return;
            }

            // Mov can not use ESI or EDI registers with 8 or 16 bit memory or register
            if (context.Operand1.IsCPURegister && (context.Result.IsMemoryAddress || context.Result.IsCPURegister)
                && (context.Result.IsByte || context.Result.IsShort || context.Result.IsChar || context.Result.IsBoolean)
                && (context.Operand1.Register == GeneralPurposeRegister.ESI || context.Operand1.Register == GeneralPurposeRegister.EDI))
            {
                Operand source = context.Operand1;
                Operand dest = context.Result;

                var replace = (dest.IsMemoryAddress && dest.EffectiveOffsetBase == GeneralPurposeRegister.EAX)
                        ? GeneralPurposeRegister.EBX : GeneralPurposeRegister.EAX;

                Operand reg = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, replace);

                context.SetInstruction2(X86.Xchg, reg, source, source, reg);
                context.AppendInstruction(X86.Mov, dest, reg);
                context.AppendInstruction2(X86.Xchg, source, reg, reg, source);
            }
        }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:30,代码来源:FinalTweakTransformationStage.cs

示例11: ExpandSignedMove

        /// <summary>
        /// Expands the signed move instruction for 64-bits.
        /// </summary>
        /// <param name="context">The context.</param>
        private void ExpandSignedMove(Context context)
        {
            Operand op0 = context.Result;
            Operand op1 = context.Operand1;
            Debug.Assert(op0 != null, @"I8 not in a memory operand!");

            Operand op0L, op0H;
            SplitLongOperand(op0, out op0L, out op0H);

            if (op1.IsBoolean)
            {
                context.SetInstruction(X86.Movzx, InstructionSize.Size8, op0L, op1);
                context.AppendInstruction(X86.Mov, op0H, ConstantZero);
            }
            else if (op1.IsI1 || op1.IsI2)
            {
                Operand v1 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
                Operand v2 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);
                Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);

                InstructionSize size = op1.IsI1 ? InstructionSize.Size8 : InstructionSize.Size16;

                context.SetInstruction(X86.Movsx, size, v1, op1);
                context.AppendInstruction2(X86.Cdq, v3, v2, v1);
                context.AppendInstruction(X86.Mov, op0L, v2);
                context.AppendInstruction(X86.Mov, op0H, v3);
            }
            else if (op1.IsI4 || op1.IsU4 || op1.IsPointer || op1.IsI || op1.IsU)
            {
                Operand v1 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
                Operand v2 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);
                Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);

                context.SetInstruction(X86.Mov, v1, op1);
                context.AppendInstruction2(X86.Cdq, v3, v2, v1);
                context.AppendInstruction(X86.Mov, op0L, v2);
                context.AppendInstruction(X86.Mov, op0H, v3);
            }
            else if (op1.IsI8)
            {
                context.SetInstruction(X86.Mov, op0, op1);
            }
            else if (op1.IsU1 || op1.IsU2)
            {
                Operand v1 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);
                Operand v2 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);
                Operand v3 = AllocateVirtualRegister(TypeSystem.BuiltIn.U4);

                InstructionSize size = op1.IsI1 ? InstructionSize.Size8 : InstructionSize.Size16;

                context.SetInstruction(X86.Movzx, size, v1, op1);
                context.AppendInstruction2(X86.Cdq, v3, v2, v1);
                context.AppendInstruction(X86.Mov, op0L, v2);
                context.AppendInstruction(X86.Mov, op0H, ConstantZero);
            }
            else
            {
                throw new InvalidCompilerException();
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:64,代码来源:LongOperandTransformationStage.cs

示例12: ExpandMul

        /// <summary>
        /// Expands the mul instruction for 64-bit operands.
        /// </summary>
        /// <param name="context">The context.</param>
        private void ExpandMul(Context context)
        {
            Operand op0H, op1H, op2H, op0L, op1L, op2L;
            SplitLongOperand(context.Result, out op0L, out op0H);
            SplitLongOperand(context.Operand1, out op1L, out op1H);
            SplitLongOperand(context.Operand2, out op2L, out op2H);

            Operand eax = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
            Operand edx = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
            Operand ebx = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);

            Operand v20 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
            Operand v12 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);

            // unoptimized
            context.SetInstruction(X86.Mov, eax, op2L);
            context.AppendInstruction(X86.Mov, v20, eax);
            context.AppendInstruction(X86.Mov, eax, v20);
            context.AppendInstruction2(X86.Mul, edx, eax, eax, op1L);
            context.AppendInstruction(X86.Mov, op0L, eax);

            if (!op0H.IsConstantZero)
            {
                context.AppendInstruction(X86.Mov, v12, edx);
                context.AppendInstruction(X86.Mov, eax, op1L);
                context.AppendInstruction(X86.Mov, ebx, eax);
                context.AppendInstruction(X86.IMul, ebx, ebx, op2H);
                context.AppendInstruction(X86.Mov, eax, v12);
                context.AppendInstruction(X86.Add, eax, eax, ebx);
                context.AppendInstruction(X86.Mov, ebx, op2L);
                context.AppendInstruction(X86.IMul, ebx, ebx, op1H);
                context.AppendInstruction(X86.Add, eax, eax, ebx);
                context.AppendInstruction(X86.Mov, v12, eax);
                context.AppendInstruction(X86.Mov, op0H, v12);
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:40,代码来源:LongOperandTransformationStage.cs

示例13: ExpandMul

        /// <summary>
        /// Expands the mul instruction for 64-bit operands.
        /// </summary>
        /// <param name="context">The context.</param>
        private void ExpandMul(Context context)
        {
            Operand op0 = context.Result;
            Operand op1 = context.Operand1;
            Operand op2 = context.Operand2;

            Operand op0H, op1H, op2H, op0L, op1L, op2L;
            SplitLongOperand(context.Result, out op0L, out op0H);
            SplitLongOperand(context.Operand1, out op1L, out op1H);
            SplitLongOperand(context.Operand2, out op2L, out op2H);

            //Operand eax = AllocateVirtualRegister(typeSystem.BuiltIn.I4);
            //Operand edx = AllocateVirtualRegister(typeSystem.BuiltIn.I4);
            //Operand ebx = AllocateVirtualRegister(typeSystem.BuiltIn.I4);
            Operand eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);
            Operand edx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EDX);
            Operand ebx = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBX);

            Operand v16 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
            Operand v20 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
            Operand v12 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);

            // unoptimized
            context.SetInstruction(X86.Mov, eax, op2L);
            context.AppendInstruction(X86.Mov, v20, eax);
            context.AppendInstruction(X86.Mov, eax, v20);
            context.AppendInstruction2(X86.Mul, edx, eax, eax, op1L);
            context.AppendInstruction(X86.Mov, v16, eax);
            context.AppendInstruction(X86.Mov, v12, edx);
            context.AppendInstruction(X86.Mov, eax, op1L);
            context.AppendInstruction(X86.Mov, ebx, eax);
            context.AppendInstruction(X86.IMul, ebx, ebx, op2H);
            context.AppendInstruction(X86.Mov, eax, v12);
            context.AppendInstruction(X86.Add, eax, eax, ebx);
            context.AppendInstruction(X86.Mov, ebx, op2L);
            context.AppendInstruction(X86.IMul, ebx, ebx, op1H);
            context.AppendInstruction(X86.Add, eax, eax, ebx);
            context.AppendInstruction(X86.Mov, v12, eax);
            context.AppendInstruction(X86.Mov, op0L, v16);
            context.AppendInstruction(X86.Mov, op0H, v12);
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:45,代码来源:LongOperandTransformationStage.cs

示例14: Mov

        public void Mov(Context context)
        {
            Operand source = context.Operand1;
            Operand result = context.Result;

            Debug.Assert(result.IsCPURegister);

            if (source.IsCPURegister && result.Register == source.Register)
            {
                context.Empty();
                return;
            }

            var size = context.Size;

            // Mov can not use ESI or EDI registers for 8/16bit values
            if (!(size == InstructionSize.Size16 || size == InstructionSize.Size8))
                return;

            if (source.IsCPURegister && (source.Register == GeneralPurposeRegister.ESI || source.Register == GeneralPurposeRegister.EDI))
            {
                Operand eax = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EAX);

                context.SetInstruction2(X86.Xchg, eax, source, source, eax);
                context.AppendInstruction(X86.Mov, result, eax);
                context.AppendInstruction2(X86.Xchg, source, eax, eax, source);
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:28,代码来源:FinalTweakTransformationStage.cs

示例15: InsertExchangeInstruction

 /// <summary>
 /// Creates the swap.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="destination">The destination.</param>
 /// <param name="source">The source.</param>
 public override void InsertExchangeInstruction(Context context, Operand destination, Operand source)
 {
     if (source.IsR4)
     {
         // TODO
     }
     else if (source.IsR8)
     {
         // TODO
     }
     else
     {
         context.AppendInstruction2(X86.Xchg, destination, source, source, destination);
     }
 }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:21,代码来源:Architecture.cs


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