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


C# Context.Empty方法代码示例

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


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

示例1: 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

示例2: Call

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Call"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void Call(Context context)
        {
            if (context.Operand1 == null)
                return;

            if (!context.Operand1.IsCPURegister)
                return;

            var before = context.Previous;

            while (before.IsEmpty && !before.IsBlockStartInstruction)
            {
                before = before.Previous;
            }

            if (before == null || before.IsBlockStartInstruction)
                return;

            if (!before.Result.IsCPURegister)
                return;

            if (context.Operand1.Register != before.Result.Register)
                return;

            before.SetInstruction(X86.Call, null, before.Operand1);
            context.Empty();
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:31,代码来源:FinalTweakTransformationStage.cs

示例3: 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

示例4: AddEpilogueInstructions

        /// <summary>
        /// Adds the epilogue instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        private void AddEpilogueInstructions(Context context)
        {
            Operand ebp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.EBP);
            Operand esp = Operand.CreateCPURegister(TypeSystem.BuiltIn.I4, GeneralPurposeRegister.ESP);

            context.Empty();

            if (MethodCompiler.StackSize != 0)
            {
                context.AppendInstruction(X86.Add, esp, esp, Operand.CreateConstant(TypeSystem, -MethodCompiler.StackSize));
            }

            context.AppendInstruction(X86.Pop, ebp);
            context.AppendInstruction(X86.Ret);
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:19,代码来源:BuildStackStage.cs

示例5: Mov

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Mov"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public override 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;

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

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

示例6: Nop

 /// <summary>
 /// Visitation function for <see cref="IX86Visitor.Nop"/> instructions.
 /// </summary>
 /// <param name="context">The context.</param>
 public override void Nop(Context context)
 {
     context.Empty();
 }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:8,代码来源:FinalTweakTransformationStage.cs

示例7: Movzx

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Movzx"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void Movzx(Context context)
        {
            // Movsx can not use ESI or EDI registers
            if (context.Operand1.IsCPURegister && (context.Operand1.Register == GeneralPurposeRegister.ESI || context.Operand1.Register == GeneralPurposeRegister.EDI))
            {
                Debug.Assert(context.Result.IsCPURegister);

                Operand dest = context.Result;
                Operand source = context.Operand1;

                if (source.Register != dest.Register)
                {
                    context.SetInstruction(X86.Mov, dest, source);
                }
                else
                {
                    context.Empty();
                }

                if (dest.IsShort || dest.IsChar)
                {
                    context.AppendInstruction(X86.And, dest, dest, Operand.CreateConstant(TypeSystem, 0xffff));
                }
                else if (dest.IsByte || dest.IsBoolean)
                {
                    context.AppendInstruction(X86.And, dest, dest, Operand.CreateConstant(TypeSystem, 0xff));
                }
            }
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:33,代码来源:FinalTweakTransformationStage.cs

示例8: Movsx

        /// <summary>
        /// Visitation function for <see cref="IX86Visitor.Movsx"/> instructions.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void Movsx(Context context)
        {
            // Movsx can not use ESI or EDI registers
            if (context.Operand1.IsCPURegister && (context.Operand1.Register == GeneralPurposeRegister.ESI || context.Operand1.Register == GeneralPurposeRegister.EDI))
            {
                Operand dest = context.Result;
                Operand source = context.Operand1;

                if (source.Register != dest.Register)
                {
                    context.SetInstruction(X86.Mov, dest, source);
                }
                else
                {
                    context.Empty();
                }

                if (source.IsShort || source.IsChar)
                {
                    context.AppendInstruction(X86.And, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x0000ffff));
                    context.AppendInstruction(X86.Xor, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x00010000));
                    context.AppendInstruction(X86.Sub, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x00010000));
                }
                else if (source.IsByte || source.IsBoolean)
                {
                    context.AppendInstruction(X86.And, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x000000ff));
                    context.AppendInstruction(X86.Xor, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x00000100));
                    context.AppendInstruction(X86.Sub, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x00000100));
                }
            }
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:35,代码来源:FinalTweakTransformationStage.cs

示例9: Movss

 /// <summary>
 /// Movsses instruction
 /// </summary>
 /// <param name="context">The context.</param>
 public override void Movss(Context context)
 {
     if (context.Result.IsCPURegister && context.Operand1.IsCPURegister && context.Result.Register == context.Operand1.Register)
     {
         context.Empty();
         return;
     }
 }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:12,代码来源:FinalTweakTransformationStage.cs

示例10:

        /// <summary>
        /// Visitation function for Return.
        /// </summary>
        /// <param name="context">The context.</param>
        void IIRVisitor.Return(Context context)
        {
            //Debug.Assert(context.BranchTargets != null);

            if (context.Operand1 != null)
            {
                var returnOperand = context.Operand1;

                context.Empty();

                CallingConvention.SetReturnValue(MethodCompiler, TypeLayout, context, returnOperand);

                context.AppendInstruction(X86.Jmp, BasicBlocks.EpilogueBlock);
            }
            else
            {
                context.SetInstruction(X86.Jmp, BasicBlocks.EpilogueBlock);
            }
        }
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:23,代码来源:IRTransformationStage.cs

示例11: Nop

 /// <summary>
 /// Visitation function for <see cref="IX86Visitor.Nop"/> instructions.
 /// </summary>
 /// <param name="context">The context.</param>
 public void Nop(Context context)
 {
     context.Empty();
 }
开发者ID:Profi-Concept,项目名称:MOSA-Project,代码行数:8,代码来源:FinalTweakTransformationStage.cs

示例12: Movzx

        public void Movzx(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;

            Operand result = context.Result;

            Debug.Assert(result.IsCPURegister);

            if (result.Register == GeneralPurposeRegister.ESI || result.Register == GeneralPurposeRegister.EDI)
            {
                Debug.Assert(context.Result.IsCPURegister);

                Operand source = context.Operand1;

                if (source.Register != result.Register)
                {
                    context.SetInstruction(X86.Mov, result, source);
                }
                else
                {
                    context.Empty();
                }

                if (size == InstructionSize.Size16)
                {
                    context.AppendInstruction(X86.And, result, result, Operand.CreateConstant(TypeSystem, 0xffff));
                }
                else if (size == InstructionSize.Size8)
                {
                    context.AppendInstruction(X86.And, result, result, Operand.CreateConstant(TypeSystem, 0xff));
                }
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:37,代码来源:FinalTweakTransformationStage.cs

示例13: Movsx

        public void Movsx(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;

            Operand result = context.Operand1;

            Debug.Assert(result.IsCPURegister);

            if (result.Register == GeneralPurposeRegister.ESI || result.Register == GeneralPurposeRegister.EDI)
            {
                Operand dest = context.Result;

                if (result.Register != dest.Register)
                {
                    context.SetInstruction(X86.Mov, dest, result);
                }
                else
                {
                    context.Empty();
                }

                if (size == InstructionSize.Size16)
                {
                    context.AppendInstruction(X86.And, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x0000ffff));
                    context.AppendInstruction(X86.Xor, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x00010000));
                    context.AppendInstruction(X86.Sub, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x00010000));
                }
                else if (size == InstructionSize.Size8)
                {
                    context.AppendInstruction(X86.And, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x000000ff));
                    context.AppendInstruction(X86.Xor, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x00000100));
                    context.AppendInstruction(X86.Sub, dest, dest, Operand.CreateConstant(MethodCompiler.TypeSystem, 0x00000100));
                }
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:39,代码来源:FinalTweakTransformationStage.cs

示例14: Movss

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

            if (context.Result.Register == context.Operand1.Register)
            {
                context.Empty();
                return;
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:11,代码来源:FinalTweakTransformationStage.cs


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