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


C# Context.ReplaceInstructionOnly方法代码示例

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


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

示例1: RegisterOperand

 /// <summary>
 /// Visitation function for <see cref="IR.IIRVisitor.AddressOfInstruction"/> instruction.
 /// </summary>
 /// <param name="ctx">The context.</param>
 void IR.IIRVisitor.AddressOfInstruction(Context ctx)
 {
     Operand opRes = ctx.Result;
     RegisterOperand eax = new RegisterOperand (opRes.Type, GeneralPurposeRegister.EAX);
     ctx.Result = eax;
     ctx.ReplaceInstructionOnly (CPUx86.Instruction.LeaInstruction);
     //            ctx.Ignore = true;
     ctx.AppendInstruction (CPUx86.Instruction.MovInstruction, opRes, eax);
 }
开发者ID:hj1980,项目名称:Mosa,代码行数:13,代码来源:IRTransformationStage.cs

示例2: Switch

 /// <summary>
 /// Visitation function for <see cref="ICILVisitor.Switch"/>.
 /// </summary>
 /// <param name="ctx">The context.</param>
 public void Switch(Context ctx)
 {
     ctx.ReplaceInstructionOnly(Instruction.SwitchInstruction);
 }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:8,代码来源:CILTransformationStage.cs

示例3:

 /// <summary>
 /// Visitation function for <see cref="ICILVisitor.Ret"/>.
 /// </summary>
 /// <param name="ctx">The context.</param>
 void ICILVisitor.Ret(Context ctx)
 {
     ctx.ReplaceInstructionOnly (IR.Instruction.ReturnInstruction);
 }
开发者ID:54616E6E6572,项目名称:Mosa,代码行数:8,代码来源:CILTransformationStage.cs

示例4: MakeCall

        /// <summary>
        /// Expands the given invoke instruction to perform the method call.
        /// </summary>
        /// <param name="ctx">The context.</param>
        /// <returns>
        /// A single instruction or an array of instructions, which appropriately represent the method call.
        /// </returns>
        public void MakeCall(Context ctx, ISignatureContext context, IMetadataProvider metadata)
        {
            /*
             * Calling convention is right-to-left, pushed on the stack. Return value in EAX for integral
             * types 4 bytes or less, XMM0 for floating point and EAX:EDX for 64-bit. If this is a method
             * of a type, the this argument is moved to ECX right before the call.
             *
             */

            Operand invokeTarget = ctx.Operand1;
            Operand result = ctx.Result;
            Stack<Operand> operands = this.BuildOperandStack(ctx);

            ctx.ReplaceInstructionOnly(CPUx86.Instruction.NopInstruction);
            ctx.OperandCount = 0;
            ctx.Result = null;

            int stackSize = this.ReserveStackSizeForCall(ctx, metadata, context, operands);
            if (stackSize != 0)
            {
                this.PushOperands(context, ctx, operands, stackSize, metadata);
            }

            ctx.AppendInstruction(CPUx86.Instruction.CallInstruction, null, invokeTarget);

            if (stackSize != 0)
            {
                this.FreeStackAfterCall(ctx, stackSize);
            }

            this.CleanupReturnValue(ctx, result);
        }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:39,代码来源:DefaultCallingConvention.cs

示例5:

 /// <summary>
 /// Visitation function for <see cref="CIL.ICILVisitor.Branch"/>.
 /// </summary>
 /// <param name="ctx">The context.</param>
 void CIL.ICILVisitor.Branch(Context ctx)
 {
     ctx.ReplaceInstructionOnly(CPUx86.Instruction.JmpInstruction);
 }
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:8,代码来源:CILTransformationStage.cs

示例6:

 /// <summary>
 /// Visitation function for <see cref="IR.IIRVisitor.BranchInstruction"/> instructions.
 /// </summary>
 /// <param name="context">The context.</param>
 void IR.IIRVisitor.BranchInstruction(Context context)
 {
     context.ReplaceInstructionOnly (CPUx86.Instruction.BranchInstruction);
 }
开发者ID:hj1980,项目名称:Mosa,代码行数:8,代码来源:IRTransformationStage.cs

示例7: HandleShiftOperation

 /// <summary>
 /// Special handling for shift operations, which require the shift amount in the ECX or as a constant register.
 /// </summary>
 /// <param name="ctx">The transformation context.</param>
 /// <param name="instruction">The instruction to transform.</param>
 private void HandleShiftOperation(Context ctx, IInstruction instruction)
 {
     EmitOperandConstants (ctx);
     ctx.ReplaceInstructionOnly (instruction);
 }
开发者ID:hj1980,项目名称:Mosa,代码行数:10,代码来源:IRTransformationStage.cs

示例8:

 /// <summary>
 /// Visitation function for DivUInstruction.
 /// </summary>
 /// <param name="context">The context.</param>
 void IR.IIRVisitor.DivUInstruction(Context context)
 {
     context.ReplaceInstructionOnly(CPUx86.Instruction.UDivInstruction);
 }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:8,代码来源:IRTransformationStage.cs

示例9: HandleCommutativeOperation

 /// <summary>
 /// Special handling for commutative operations.
 /// </summary>
 /// <param name="context">The transformation context.</param>
 /// <param name="instruction">The instruction.</param>
 /// <remarks>
 /// Commutative operations are reordered by moving the constant to the second operand,
 /// which allows the instruction selection in the code generator to use a instruction
 /// format with an immediate operand.
 /// </remarks>
 private void HandleCommutativeOperation(Context context, IInstruction instruction)
 {
     EmitOperandConstants(context);
     context.ReplaceInstructionOnly(instruction);
 }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:15,代码来源:IRTransformationStage.cs

示例10: Ldloca

 /// <summary>
 /// Visitation function for <see cref="ICILVisitor.Ldloca"/>.
 /// </summary>
 /// <param name="ctx">The context.</param>
 public void Ldloca(Context ctx)
 {
     ctx.ReplaceInstructionOnly(Instruction.AddressOfInstruction);
 }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:8,代码来源:CILTransformationStage.cs

示例11: Branch

 /// <summary>
 /// Visitation function for <see cref="ICILVisitor.Branch"/>.
 /// </summary>
 /// <param name="ctx">The context.</param>
 public void Branch(Context ctx)
 {
     ctx.ReplaceInstructionOnly(Instruction.JmpInstruction);
 }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:8,代码来源:CILTransformationStage.cs

示例12: ReplaceWithInternalCall

        /// <summary>
        /// Replaces the instruction with an internal call.
        /// </summary>
        /// <param name="ctx">The transformation context.</param>
        /// <param name="internalCallTarget">The internal call target.</param>
        private void ReplaceWithInternalCall(Context ctx, VmCall internalCallTarget)
        {
            RuntimeType rt = RuntimeBase.Instance.TypeLoader.GetType(@"Mosa.Runtime.RuntimeBase");
            RuntimeMethod callTarget = FindMethod(rt, internalCallTarget.ToString());

            ctx.ReplaceInstructionOnly(IR.Instruction.CallInstruction);
            ctx.SetOperand(0, SymbolOperand.FromMethod(callTarget));
        }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:13,代码来源:CILTransformationStage.cs

示例13: ProcessLoadInstruction

        /// <summary>
        /// Replaces the IL load instruction by an appropriate IR move instruction or removes it entirely, if
        /// it is a native size.
        /// </summary>
        /// <param name="context">Provides the transformation context.</param>
        private void ProcessLoadInstruction(Context context)
        {
            IInstruction extension = null;
            SigType extendedType = null;
            Operand source = context.Operand1;
            Operand destination = context.Result;

            // Is this a sign or zero-extending move?
            if (source != null)
            {
                if (IsSignExtending(source))
                {
                    extension = Instruction.SignExtendedMoveInstruction;
                    extendedType = BuiltInSigType.Int32;
                }
                else if (IsZeroExtending(source))
                {
                    extension = Instruction.ZeroExtendedMoveInstruction;
                    extendedType = BuiltInSigType.UInt32;
                }
            }

            if (extension != null)
            {
                Operand temp = this.MethodCompiler.CreateTemporary(extendedType);
                destination.Replace(temp, context.InstructionSet);
                context.SetInstruction(extension, temp, source);
            }
            else
            {
                context.ReplaceInstructionOnly(Instruction.MoveInstruction);
            }
        }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:38,代码来源:CILTransformationStage.cs

示例14: Replace

 private static void Replace(Context context, IIRInstruction floatingPointInstruction, IIRInstruction signedInstruction, IIRInstruction unsignedInstruction)
 {
     if (IsFloatingPoint(context))
     {
         context.ReplaceInstructionOnly(floatingPointInstruction);
     }
     else if (IsUnsigned(context))
     {
         context.ReplaceInstructionOnly(unsignedInstruction);
     }
     else
     {
         context.ReplaceInstructionOnly(signedInstruction);
     }
 }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:15,代码来源:CILTransformationStage.cs

示例15: switch

        /// <summary>
        /// Visitation function for <see cref="IR.IIRVisitor.ZeroExtendedMoveInstruction"/> instructions.
        /// </summary>
        /// <param name="ctx">The context.</param>
        void IR.IIRVisitor.ZeroExtendedMoveInstruction(Context ctx)
        {
            switch (ctx.Operand1.Type.Type) {
                case CilElementType.I1:
                    ctx.ReplaceInstructionOnly (CPUx86.Instruction.MovzxInstruction);
                    break;
                case CilElementType.I2:
                    goto case CilElementType.I1;
                case CilElementType.I4:
                    goto case CilElementType.I1;
                case CilElementType.I8:
                    throw new NotSupportedException ();
                case CilElementType.U1:
                    goto case CilElementType.I1;
                case CilElementType.U2:
                    goto case CilElementType.I1;
                case CilElementType.U4:
                    goto case CilElementType.I1;
                case CilElementType.U8:
                    goto case CilElementType.I8;
                case CilElementType.Char:
                    goto case CilElementType.I2;
                default:
                    throw new NotSupportedException ();
            }

            if ((ctx.Result is RegisterOperand))
                return;

            Operand result = ctx.Result;
            Operand source = ctx.Operand1;
            RegisterOperand ebx = new RegisterOperand (result.Type, GeneralPurposeRegister.EBX);
            ctx.Result = ebx;

            ctx.AppendInstruction (CPUx86.Instruction.MovInstruction, result, ebx);
        }
开发者ID:hj1980,项目名称:Mosa,代码行数:40,代码来源:IRTransformationStage.cs


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