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


C# Context.InsertBefore方法代码示例

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


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

示例1: Cmp

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Cmp"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void Cmp(Context context)
        {
            Operand left = context.Operand1;
            Operand right = context.Operand2;

            if (left.IsConstant)
            {
                Operand ecx = AllocateVirtualRegister(left.Type);
                Context before = context.InsertBefore();

                before.AppendInstruction(X86.Mov, ecx, left);
                context.Operand1 = ecx;
            }

            if (right.IsConstant && (left.IsChar || left.IsShort || left.IsByte))
            {
                Operand edx = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
                Context before = context.InsertBefore();

                if (left.IsSigned)
                {
                    before.AppendInstruction(X86.Movsx, edx, left);
                }
                else
                {
                    before.AppendInstruction(X86.Movzx, edx, left);
                }
                context.Operand1 = edx;
            }
        }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:34,代码来源:TweakTransformationStage.cs

示例2: Cmp

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Cmp"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Cmp(Context context)
        {
            Operand left = context.Operand1;
            Operand right = context.Operand2;

            if (left.IsConstant)
            {
                Operand v1 = AllocateVirtualRegister(left.Type);
                Context before = context.InsertBefore();

                before.AppendInstruction(X86.Mov, v1, left);
                context.Operand1 = v1;
            }

            if (right.IsConstant && (left.IsChar || left.IsShort || left.IsByte))
            {
                Operand v2 = AllocateVirtualRegister(TypeSystem.BuiltIn.I4);
                InstructionSize size = left.IsByte ? InstructionSize.Size8 : InstructionSize.Size16;

                if (left.IsSigned)
                {
                    context.InsertBefore().AppendInstruction(X86.Movsx, size, v2, left);
                }
                else
                {
                    context.InsertBefore().AppendInstruction(X86.Movzx, size, v2, left);
                }

                context.Operand1 = v2;
            }
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:35,代码来源:TweakTransformationStage.cs

示例3: ThreeTwoAddressConversion

        /// <summary>
        /// Converts the given instruction from three address format to a two address format.
        /// </summary>
        /// <param name="ctx">The conversion context.</param>
        private static void ThreeTwoAddressConversion(Context ctx)
        {
            if (!(ctx.Instruction is BaseIRInstruction))
                return;

            if (ctx.Instruction is IntegerCompare
                || ctx.Instruction is FloatCompare
                || ctx.Instruction is Load
                || ctx.Instruction is Store
                || ctx.Instruction is Call
                || ctx.Instruction is ZeroExtendedMove
                || ctx.Instruction is SignExtendedMove)
                return;

            Operand result = ctx.Result;
            Operand op1 = ctx.Operand1;
            Operand op2 = ctx.Operand2;

            // Create registers for different data types
            RegisterOperand eax = new RegisterOperand(op1.Type, op1.StackType == StackTypeCode.F ? (Register)SSE2Register.XMM0 : GeneralPurposeRegister.EAX);
            RegisterOperand storeOperand = new RegisterOperand(result.Type, result.StackType == StackTypeCode.F ? (Register)SSE2Register.XMM0 : GeneralPurposeRegister.EAX);

            ctx.Result = storeOperand;
            ctx.Operand1 = op2;
            ctx.Operand2 = null;
            ctx.OperandCount = 1;

            if (op1.StackType != StackTypeCode.F)
            {
                if (IsSigned(op1) && !(op1 is ConstantOperand))
                    ctx.InsertBefore().SetInstruction(IRInstruction.SignExtendedMove, eax, op1);
                else if (IsUnsigned(op1) && !(op1 is ConstantOperand))
                    ctx.InsertBefore().SetInstruction(IRInstruction.ZeroExtendedMove, eax, op1);
                else
                    ctx.InsertBefore().SetInstruction(X86.Mov, eax, op1);
            }
            else
            {
                if (op1.Type.Type == CilElementType.R4)
                {
                    if (op1 is ConstantOperand)
                    {
                        Context before = ctx.InsertBefore();
                        before.SetInstruction(X86.Mov, eax, op1);
                        before.AppendInstruction(X86.Cvtss2sd, eax, eax);
                    }
                    else
                    {
                        ctx.InsertBefore().SetInstruction(X86.Cvtss2sd, eax, op1);
                    }
                }
                else
                {
                    ctx.InsertBefore().SetInstruction(X86.Mov, eax, op1);
                }
            }

            ctx.AppendInstruction(X86.Mov, result, eax);
        }
开发者ID:grover,项目名称:MOSA-Project,代码行数:63,代码来源:AddressModeConversionStage.cs

示例4: InsertLoadBeforeInstruction

        private Operand InsertLoadBeforeInstruction(Context context, string symbolName, SigType type)
        {
            Context before = context.InsertBefore();
            Operand result = this.methodCompiler.CreateTemporary(type);
            Operand op = new SymbolOperand(type, symbolName);

            before.SetInstruction(Instruction.Get(OpCode.Ldc_i4), result, op);

            return result;
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:10,代码来源:StaticAllocationResolutionStage.cs

示例5: LoadFirstOperandIntoRegister

        private void LoadFirstOperandIntoRegister(Context context)
        {
            // load into a register
            Operand operand = context.Operand1;

            Operand register = AllocateVirtualRegister(operand.Type);
            context.Operand1 = register;

            context.InsertBefore().SetInstruction(GetMove(register, operand), register, operand);
        }
开发者ID:Boddlnagg,项目名称:MOSA-Project,代码行数:10,代码来源:FloatingPointStage.cs

示例6: In

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.In"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public void In(Context context)
        {
            var size = context.Size;

            if (size == InstructionSize.Size32)
                return;

            Debug.Assert(context.Result.Register == GeneralPurposeRegister.EAX);

            // NOTE: Other option is to use Movzx after IN instruction
            context.InsertBefore().SetInstruction(X86.Mov, context.Result, ConstantZero);
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:16,代码来源:FinalTweakTransformationStage.cs

示例7: Cmp

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Cmp"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Cmp(Context context)
        {
            Operand left = context.Operand1;

            if (left.IsConstant)
            {
                Operand v1 = AllocateVirtualRegister(left.Type);

                context.InsertBefore().AppendInstruction(X86.Mov, v1, left);
                context.Operand1 = v1;
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:16,代码来源:TweakTransformationStage.cs

示例8: In

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.In"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void In(Context context)
        {
            var size = context.Size;

            if (size == InstructionSize.Size32)
                return;

            Debug.Assert(context.Result.Register == GeneralPurposeRegister.EAX);

            // NOTE: Other option is to use Movzx after IN instruction
            context.InsertBefore().SetInstruction(X86.Mov, context.Result, Operand.CreateConstant(TypeSystem, 0));
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:16,代码来源:FinalTweakTransformationStage.cs

示例9: In

        public void In(Context context)
        {
            var size = context.Size;

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

            Debug.Assert(context.Result.Register == GeneralPurposeRegister.EAX);

            // NOTE: Other option is to use Movzx after IN instruction
            context.InsertBefore().SetInstruction(X86.Mov, context.Result, ConstantZero);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:13,代码来源:FinalTweakTransformationStage.cs

示例10: InsertCopyStatement

        /// <summary>
        /// Inserts the copy statement.
        /// </summary>
        /// <param name="predecessor">The predecessor.</param>
        /// <param name="result">The result.</param>
        /// <param name="operand">The operand.</param>
        private void InsertCopyStatement(BasicBlock predecessor, Operand result, Operand operand)
        {
            var context = new Context(this.instructionSet, predecessor);
            while (!context.EndOfInstruction && IsBranchInstruction(context))
                context.GotoNext();

            if (context.Index != -1)
                context = context.InsertBefore();

            var source = operand is SsaOperand ? (operand as SsaOperand).Operand : operand;
            var destination = result is SsaOperand ? (result as SsaOperand).Operand : result;

            Debug.Assert(!(source is SsaOperand));
            Debug.Assert(!(destination is SsaOperand));

            context.SetInstruction(IR.Instruction.MoveInstruction, destination, source);
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:23,代码来源:LeaveSSA.cs

示例11: ThreeTwoAddressConversion

        /// <summary>
        /// Converts the given instruction from three address format to a two address format.
        /// </summary>
        /// <param name="context">The conversion context.</param>
        private void ThreeTwoAddressConversion(Context context)
        {
            if (!(context.Instruction is X86Instruction))
                return;

            if (!(context.OperandCount >= 1 && context.ResultCount >= 1 && context.Result != context.Operand1))
                return;

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

            context.Operand1 = result;

            context.InsertBefore().SetInstruction(GetMove(result, operand1), result, operand1);

            return;
        }
开发者ID:tea,项目名称:MOSA-Project,代码行数:21,代码来源:AddressModeConversionStage.cs

示例12: Call

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Call"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public void Call(Context context)
        {
            // FIXME: Result operand should be used instead of Operand1 for the result
            // FIXME: Move to FixedRegisterAssignmentStage
            Operand destinationOperand = context.Operand1;

            if (destinationOperand == null || destinationOperand.IsSymbol)
                return;

            if (!destinationOperand.IsRegister)
            {
                Context before = context.InsertBefore();
                Operand eax = AllocateVirtualRegister(destinationOperand.Type);

                before.SetInstruction(X86.Mov, eax, destinationOperand);
                context.Operand1 = eax;
            }
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:22,代码来源:TweakTransformationStage.cs

示例13: ExpandSub

 /// <summary>
 /// Visitation function for SubSInstruction.
 /// </summary>
 /// <param name="context">The context.</param>
 void IR.IIRVisitor.SubSInstruction(Context context)
 {
     if (IsInt64(context.Operand1))
     {
         ExpandSub(context);
     }
     else
     {
         if (context.Operand2 is ConstantOperand && context.Operand1.Type.Type == CilElementType.Char)
         {
             RegisterOperand r10 = new RegisterOperand(context.Operand1.Type, GeneralPurposeRegister.R10);
             context.InsertBefore().SetInstruction(Instruction.MovInstruction, r10, context.Operand2);
             context.Operand2 = r10;
         }
     }
 }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:20,代码来源:LongOperandTransformationStage.cs

示例14: HandleMemoryToMemoryOperation

        private void HandleMemoryToMemoryOperation(Context ctx)
        {
            Operand destination = ctx.Result;
            Operand source = ctx.Operand1;

            Debug.Assert(destination is MemoryOperand && source is MemoryOperand);

            SigType destinationSigType = destination.Type;

            if (this.RequiresSseOperation(destinationSigType))
            {
                IInstruction moveInstruction = this.GetMoveInstruction(destinationSigType);
                RegisterOperand destinationRegister = this.AllocateRegister(destinationSigType);

                ctx.Result = destinationRegister;
                ctx.AppendInstruction(moveInstruction, destination, destinationRegister);
            }
            else
            {
                SigType sourceSigType = ctx.Operand1.Type;
                IInstruction moveInstruction = this.GetMoveInstruction(sourceSigType);
                RegisterOperand sourceRegister = this.AllocateRegister(sourceSigType);

                ctx.Operand1 = sourceRegister;

                ctx.InsertBefore().SetInstruction(moveInstruction, sourceRegister, source);
            }
        }
开发者ID:GeroL,项目名称:MOSA-Project,代码行数:28,代码来源:MemToMemConversionStage.cs

示例15: HandleMemoryToMemoryOperation2

        private void HandleMemoryToMemoryOperation2(Context ctx)
        {
            Operand destination = ctx.Operand1;
            Operand source = ctx.Operand2;

            Debug.Assert(destination.IsMemoryAddress && source.IsMemoryAddress);

            SigType destinationSigType = destination.Type;

            if (RequiresSseOperation(destinationSigType))
            {
                BaseInstruction moveInstruction = GetMoveInstruction(destinationSigType);
                Operand destinationRegister = AllocateRegister(destinationSigType);

                ctx.Operand1 = destinationRegister;
                ctx.AppendInstruction(moveInstruction, destination, destinationRegister);
            }
            else
            {
                SigType sourceSigType = source.Type;
                BaseInstruction moveInstruction = GetMoveInstruction(sourceSigType);
                Operand sourceRegister = AllocateRegister(sourceSigType);

                ctx.Operand2 = sourceRegister;
                ctx.InsertBefore().SetInstruction(moveInstruction, sourceRegister, source);
            }
        }
开发者ID:pdelprat,项目名称:MOSA-Project,代码行数:27,代码来源:MemToMemConversionStage.cs


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