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


C# Context.ReplaceInstructionOnly方法代码示例

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


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

示例1:

 /// <summary>
 /// Visitation function for AddFloat.
 /// </summary>
 /// <param name="context">The context.</param>
 void IIRVisitor.AddFloat(Context context)
 {
     if (context.Result.IsR4)
     {
         context.ReplaceInstructionOnly(X86.Addss);
         context.Size = InstructionSize.Size32;
     }
     else
     {
         context.ReplaceInstructionOnly(X86.Addsd);
         context.Size = InstructionSize.Size64;
     }
 }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:17,代码来源:IRTransformationStage.cs

示例2: AllocateVirtualRegister

        /// <summary>
        /// Addresses the of instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void IIRVisitor.AddressOf(Context context)
        {
            Operand result = context.Result;
            Operand register = AllocateVirtualRegister(result.Type);

            context.Result = register;
            context.ReplaceInstructionOnly(X86.Lea);

            context.AppendInstruction(X86.Mov, result, register);
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:14,代码来源:IRTransformationStage.cs

示例3: RegisterOperand

        /// <summary>
        /// Addresses the of instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void IR.IIRVisitor.AddressOfInstruction(Context context)
        {
            var opRes = context.Result;

            RegisterOperand register = new RegisterOperand(opRes.Type, GeneralPurposeRegister.EAX);
            context.Result = register;
            context.ReplaceInstructionOnly(Instruction.LeaInstruction);
            //context.Ignore = true;
            context.AppendInstruction(Instruction.MovInstruction, opRes, register);
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:14,代码来源:IRTransformationStage.cs

示例4:

        /// <summary>
        /// Addresses the of instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void IIRVisitor.AddressOf(Context context)
        {
            var opRes = context.Result;

            Operand register = Operand.CreateCPURegister(opRes.Type, GeneralPurposeRegister.EAX);
            //VirtualRegisterOperand register = AllocateVirtualRegister(opRes.Type);

            context.Result = register;
            context.ReplaceInstructionOnly(X86.Lea);
            context.AppendInstruction(X86.Mov, opRes, register);
        }
开发者ID:Expro,项目名称:MOSA-Project,代码行数:15,代码来源:IRTransformationStage.cs

示例5: RegisterOperand

        /// <summary>
        /// Addresses the of instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void IIRVisitor.AddressOf(Context context)
        {
            var opRes = context.Result;

            RegisterOperand register = new RegisterOperand(opRes.Type, GeneralPurposeRegister.EAX);
            //VirtualRegisterOperand register = methodCompiler.VirtualRegisterLayout.AllocateVirtualRegister(opRes.Type);

            context.Result = register;
            context.ReplaceInstructionOnly(X86.Lea);
            context.AppendInstruction(X86.Mov, opRes, register);
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:15,代码来源:IRTransformationStage.cs

示例6: PerformStaticAllocationOf

        private void PerformStaticAllocationOf(Context allocation, Context assignment)
        {
            RuntimeType allocatedType = allocation.InvokeTarget.DeclaringType;

            // Allocate a linker symbol to refer to for this allocation. Use the destination field name as the linker symbol name.
            string symbolName = assignment.RuntimeField.ToString() + @"<<$cctor";
            using (var stream = methodCompiler.Linker.Allocate(symbolName, SectionKind.BSS, typeLayout.GetTypeSize(allocatedType), 4))
            {
                // FIXME: Do we have to initialize this?
                string methodTableSymbol = GetMethodTableForType(allocatedType);

                if (methodTableSymbol != null)
                    methodCompiler.Linker.Link(LinkType.AbsoluteAddress | LinkType.NativeI4, symbolName, 0, 0, methodTableSymbol, IntPtr.Zero);
            }

            // Issue a load request before the newobj and before the assignment.
            Operand symbol1 = this.InsertLoadBeforeInstruction(allocation, symbolName, assignment.RuntimeField.SignatureType);
            allocation.Operand1 = symbol1;

            Operand symbol2 = this.InsertLoadBeforeInstruction(assignment, symbolName, assignment.RuntimeField.SignatureType);
            assignment.Operand1 = symbol2;

            // Change the newobj to a call and increase the operand count to include the this ptr.
            allocation.OperandCount++;
            allocation.ResultCount = 0;
            allocation.ReplaceInstructionOnly(Instruction.Get(OpCode.Call));
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:27,代码来源:StaticAllocationResolutionStage.cs

示例7: if

        /// <summary>
        /// Visitation function for MoveInstruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void IIRVisitor.Move(Context context)
        {
            Operand result = context.Result;
            Operand operand = context.Operand1;
            //context.Operand1 = EmitConstant(context.Operand1);

            if (context.Result.StackType == StackTypeCode.F)
            {
                // TODO:
            }
            else if (context.Result.IsMemoryAddress && context.Operand1.IsMemoryAddress)
            {
                Operand load = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.R9);

                context.SetInstruction(AVR32.Ld, load, operand);
                context.AppendInstruction(AVR32.St, result, load);

                //if (!Is32Bit(operand) && IsSigned(operand))
                //    context.SetInstruction(Instruction.Movsx, load, operand);
                //else if (!Is32Bit(operand) && IsUnsigned(operand))
                //    context.SetInstruction(Instruction.Movzx, load, operand);
                //else
                //    context.SetInstruction(Instruction.Mov, load, operand);

                //context.AppendInstruction(Instruction.Mov, result, store);
            }
            else if (context.Result.IsRegister && context.Operand1.IsMemoryAddress)
            {
                context.ReplaceInstructionOnly(AVR32.Ld);
            }
            else if (context.Result.IsMemoryAddress && context.Operand1.IsRegister)
            {
                context.SetInstruction(AVR32.St, result, operand);
            }
            else if (context.Result.IsRegister && context.Operand1.IsRegister)
            {
                context.ReplaceInstructionOnly(AVR32.Mov);
            }
            else if (context.Result.IsMemoryAddress && context.Operand1.IsConstant)
            {
                Operand load = Operand.CreateCPURegister(BuiltInSigType.IntPtr, GeneralPurposeRegister.R9);

                context.SetInstruction(AVR32.Mov, load, operand);
                context.AppendInstruction(AVR32.St, result, load);
            }
            else if (context.Result.IsMemoryAddress && context.Operand1.IsSymbol)
            {
                //context.SetInstruction(Instruction.St, result, operand);
            }
        }
开发者ID:Expro,项目名称:MOSA-Project,代码行数:54,代码来源:IRTransformationStage.cs

示例8: RegisterOperand

 /// <summary>
 /// Visitation function for <see cref="IX86Visitor.Movsx"/> instructions.
 /// </summary>
 /// <param name="context">The context.</param>
 void IX86Visitor.Movsx(Context context)
 {
     if (Is32Bit(context.Operand1))
     {
         context.ReplaceInstructionOnly(X86.Mov);
     }
     else
     {
         Operand result = context.Result;
         if (!(result is RegisterOperand))
         {
             RegisterOperand ecx = new RegisterOperand(context.Result.Type, GeneralPurposeRegister.ECX);
             context.Result = ecx;
             context.AppendInstruction(X86.Mov, result, ecx);
         }
     }
 }
开发者ID:grover,项目名称:MOSA-Project,代码行数:21,代码来源:TweakTransformationStage.cs

示例9:

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

示例10: Movzx

 /// <summary>
 /// Visitation function for <see cref="IX86Visitor.Movzx"/> instructions.
 /// </summary>
 /// <param name="context">The context.</param>
 public void Movzx(Context context)
 {
     if (context.Operand1.IsInt || context.Operand1.IsPointer || !context.Operand1.IsValueType)
     {
         context.ReplaceInstructionOnly(X86.Mov);
     }
 }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:11,代码来源:TweakTransformationStage.cs

示例11: RegisterOperand

        /// <summary>
        /// Visitation function for MoveInstruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void IR.IIRVisitor.Move(Context context)
        {
            Operand result = context.Result;
            Operand operand = context.Operand1;
            //context.Operand1 = EmitConstant(context.Operand1);

            if (context.Result.StackType == StackTypeCode.F)
            {
                // TODO:
            }
            else
            {
                if (context.Result is MemoryOperand && context.Operand1 is MemoryOperand)
                {
                    RegisterOperand load = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.R9);

                    context.SetInstruction(AVR32.Ld, load, operand);
                    context.AppendInstruction(AVR32.St, result, load);

                    //if (!Is32Bit(operand) && IsSigned(operand))
                    //    context.SetInstruction(Instruction.Movsx, load, operand);
                    //else if (!Is32Bit(operand) && IsUnsigned(operand))
                    //    context.SetInstruction(Instruction.Movzx, load, operand);
                    //else
                    //    context.SetInstruction(Instruction.Mov, load, operand);

                    //context.AppendInstruction(Instruction.Mov, result, store);
                }
                else
                    if (context.Result is RegisterOperand && context.Operand1 is MemoryOperand)
                    {
                        context.ReplaceInstructionOnly(AVR32.Ld);
                    }
                    else
                        if (context.Result is MemoryOperand && context.Operand1 is RegisterOperand)
                        {
                            context.SetInstruction(AVR32.St, result, operand);
                        }
                        else
                            if (context.Result is RegisterOperand && context.Operand1 is RegisterOperand)
                            {
                                context.ReplaceInstructionOnly(AVR32.Mov);
                            }
                            else
                                if (context.Result is MemoryOperand && context.Operand1 is ConstantOperand)
                                {
                                    RegisterOperand load = new RegisterOperand(BuiltInSigType.IntPtr, GeneralPurposeRegister.R9);

                                    context.SetInstruction(AVR32.Mov, load, operand);
                                    context.AppendInstruction(AVR32.St, result, load);
                                }
                                else
                                    if (context.Result is MemoryOperand && context.Operand1 is SymbolOperand)
                                    {
                                        //context.SetInstruction(Instruction.St, result, operand);
                                    }
                                    else
                                        if (context.Result is MemoryOperand && context.Operand1 is LabelOperand)
                                        {
                                            //context.SetInstruction(Instruction.St, result, operand);
                                        }

            }
        }
开发者ID:toddhainsworth,项目名称:MOSA-Project,代码行数:68,代码来源:IRTransformationStage.cs

示例12: if

 /// <summary>
 /// Visitation function for IntegerToFloatingPointConversion.
 /// </summary>
 /// <param name="context">The context.</param>
 void IIRVisitor.IntegerToFloatConversion(Context context)
 {
     if (context.Result.Type.Type == CilElementType.R4)
         context.ReplaceInstructionOnly(X86.Cvtsi2ss);
     else if (context.Result.Type.Type == CilElementType.R8)
         context.ReplaceInstructionOnly(X86.Cvtsi2sd);
     else
         throw new NotSupportedException();
 }
开发者ID:Expro,项目名称:MOSA-Project,代码行数:13,代码来源:IRTransformationStage.cs

示例13: switch

 /// <summary>
 /// Visitation function for FloatingPointToIntegerConversionInstruction.
 /// </summary>
 /// <param name="context">The context.</param>
 void IIRVisitor.FloatToIntegerConversion(Context context)
 {
     Operand source = context.Operand1;
     Operand destination = context.Result;
     switch (destination.Type.Type)
     {
         case CilElementType.I1: goto case CilElementType.I4;
         case CilElementType.I2: goto case CilElementType.I4;
         case CilElementType.I4:
             if (source.Type.Type == CilElementType.R8)
                 context.ReplaceInstructionOnly(X86.Cvttsd2si);
             else
                 context.ReplaceInstructionOnly(X86.Cvttss2si);
             break;
         case CilElementType.I8: return; // FIXME: throw new NotSupportedException();
         case CilElementType.U1: goto case CilElementType.U4;
         case CilElementType.U2: goto case CilElementType.U4;
         case CilElementType.U4: return; // FIXME: throw new NotSupportedException();
         case CilElementType.U8: return; // FIXME: throw new NotSupportedException();
         case CilElementType.I: goto case CilElementType.I4;
         case CilElementType.U: goto case CilElementType.U4;
     }
 }
开发者ID:Expro,项目名称:MOSA-Project,代码行数:27,代码来源:IRTransformationStage.cs

示例14: HandleShiftOperation

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

示例15: HandleNonCommutativeOperation

 /// <summary>
 /// Handles the non commutative operation.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="instruction">The instruction.</param>
 private void HandleNonCommutativeOperation(Context context, BaseInstruction instruction)
 {
     EmitResultConstants(context);
     EmitOperandConstants(context);
     context.ReplaceInstructionOnly(instruction);
 }
开发者ID:Expro,项目名称:MOSA-Project,代码行数:11,代码来源:IRTransformationStage.cs


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