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


C# Context.Remove方法代码示例

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


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

示例1: Run

        /// <summary>
        /// Performs stage specific processing on the compiler context.
        /// </summary>
        public void Run()
        {
            bool remove = false;

            foreach (BasicBlock block in BasicBlocks) {
                for (Context ctx = new Context(InstructionSet, block); !ctx.EndOfInstruction; ctx.GotoNext()) {
                    if (ctx.Instruction is IR.MoveInstruction || ctx.Instruction is CIL.StlocInstruction) {
                        if (ctx.Operand1 is ConstantOperand) {
                            // HACK: We can't track a constant through a register, so we keep those moves
                            if (ctx.Result is StackOperand) {
                                Debug.Assert(ctx.Result.Definitions.Count == 1, @"Operand defined multiple times. Instruction stream not in SSA form!");
                                ctx.Result.Replace(ctx.Operand1, InstructionSet);
                                remove = true;
                            }
                        }
                    }
                    else if (ctx.Instruction is IR.PhiInstruction) {
                        IR.PhiInstruction phi = (IR.PhiInstruction)ctx.Instruction;
                        ConstantOperand co = ctx.Operand2 as ConstantOperand;
                        List<BasicBlock> blocks = ctx.Other as List<BasicBlock>;	// FIXME PG / ctx has moved
                        if (co != null && blocks.Count == 1) {
                            // We can remove the phi, as it is only defined once
                            // HACK: We can't track a constant through a register, so we keep those moves
                            if (!ctx.Result.IsRegister) {
                                Debug.Assert(ctx.Result.Definitions.Count == 1, @"Operand defined multiple times. Instruction stream not in SSA form!");
                                ctx.Result.Replace(co, InstructionSet);
                                remove = true;
                            }
                        }
                    }

                    // Shall we remove this instruction?
                    if (remove) {
                        ctx.Remove();
                        remove = false;
                    }

                }
            }
        }
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:43,代码来源:ConstantPropagationStage.cs

示例2: ReplaceIntrinsicCall

 /// <summary>
 /// Replaces the instrinsic call site
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="typeSystem">The type system.</param>
 public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
 {
     // TODO
     context.Remove();
 }
开发者ID:illuminus86,项目名称:MOSA-Project,代码行数:10,代码来源:SpinUnlock.cs

示例3:

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

示例4: 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="ctx">Provides the transformation context.</param>
 private void ProcessLoadInstruction(Context ctx)
 {
     // We don't need to rewire the source/destination yet, its already there. :(
     //Remove(ctx);
     ctx.Remove ();
 }
开发者ID:54616E6E6572,项目名称:Mosa,代码行数:11,代码来源:CILTransformationStage.cs

示例5: ConstantOperand

        /// <summary>
        /// Visitation function for <see cref="CIL.ICILVisitor.Switch"/>.
        /// </summary>
        /// <param name="ctx">The context.</param>
        void CIL.ICILVisitor.Switch(Context ctx)
        {
            IBranch branch = ctx.Branch;
            Operand operand = ctx.Operand1;

            ctx.Remove();

            for (int i = 0; i < branch.Targets.Length - 1; ++i) {
                ctx.AppendInstruction(CPUx86.Instruction.CmpInstruction, operand, new ConstantOperand(new SigType(CilElementType.I), i));
                ctx.AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.Equal);
                ctx.SetBranch(branch.Targets[i]);
            }
        }
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:17,代码来源:CILTransformationStage.cs

示例6: 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="ctx">Provides the transformation context.</param>
        private void ProcessLoadInstruction(Context ctx)
        {
            // We don't need to rewire the source/destination yet, its already there. :(
            //Remove(ctx);
            ctx.Remove();

            /* FIXME: This is only valid with reg alloc!
            Type type = null;

            load = load as LoadInstruction;

            // Is this a sign or zero-extending move?
            if (IsSignExtending(load.Source))
            {
                type = typeof(IR.SignExtendedMoveInstruction);
            }
            else if (IsZeroExtending(load.Source))
            {
                type = typeof(IR.ZeroExtendedMoveInstruction);
            }

            // Do we have a move replacement?
            if (null == type)
            {
                // No, we can safely drop the load instruction and can rewire the operands.
                /*if (1 == load.Destination.Definitions.Count && 1 == load.Destination.Uses.Count)
                {
                    load.Destination.Replace(load.Source);
                    Remove(ctx);
                }
                return;
            }
            else
            {
                Replace(ctx, Architecture.CreateInstruction(type, load.Destination, load.Source));
            }*/
        }
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:42,代码来源:CILTransformationStage.cs

示例7:

        /// <summary>
        /// Visitation function for <see cref="ICILVisitor.Call"/>.
        /// </summary>
        /// <param name="ctx">The context.</param>
        void ICILVisitor.Call(Context ctx)
        {
            if (this.CanSkipDueToRecursiveSystemObjectCtorCall(ctx) == true)
            {
                ctx.Remove();
                return;
            }

            if (this.ProcessIntrinsicCall(ctx) == false)
            {
                // Create a symbol operand for the invocation target
                RuntimeMethod invokeTarget = ctx.InvokeTarget;
                SymbolOperand symbolOperand = SymbolOperand.FromMethod(invokeTarget);

                this.ProcessInvokeInstruction(ctx, symbolOperand, ctx.Result, new List<Operand>(ctx.Operands));
            }
        }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:21,代码来源:CILTransformationStage.cs

示例8: Ldloc

 /// <summary>
 /// Visitation function for <see cref="ICILVisitor.Ldloc"/>.
 /// </summary>
 /// <param name="ctx">The context.</param>
 public void Ldloc(Context ctx)
 {
     if (ctx.Ignore == true)
     {
         ctx.Remove();
     }
     else
     {
         this.ProcessLoadInstruction(ctx);
     }
 }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:15,代码来源:CILTransformationStage.cs

示例9: ReplaceIntrinsicCall

 /// <summary>
 /// Replaces the instrinsic call site
 /// </summary>
 /// <param name="context">The context.</param>
 public void ReplaceIntrinsicCall(Context context)
 {
     //			context.SetInstruction(IR.Instruction.JmpInstruction, );
     context.Remove();
 }
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:9,代码来源:JumpProcessInterrupt.cs

示例10: Ldloc

 /// <summary>
 /// Visitation function for Ldloc instruction.
 /// </summary>
 /// <param name="context">The context.</param>
 public void Ldloc(Context context)
 {
     if (context.Ignore)
     {
         context.Remove();
     }
     else
     {
         this.ProcessLoadInstruction(context);
     }
 }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:15,代码来源:CILTransformationStage.cs

示例11:

 /// <summary>
 /// Visitation function for Pop instruction.
 /// </summary>
 /// <param name="context">The context.</param>
 void CIL.ICILVisitor.Pop(Context context)
 {
     context.Remove();
 }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:8,代码来源:CILTransformationStage.cs

示例12: ProcessInvokeInstruction

        /// <summary>
        /// Visitation function for Call instruction.
        /// </summary>
        /// <param name="context">The context.</param>
        void CIL.ICILVisitor.Call(Context context)
        {
            if (this.CanSkipDueToRecursiveSystemObjectCtorCall(context))
            {
                context.Remove();
                return;
            }

            //if (ProcessVmCall(context))
            //    return;

            if (ProcessExternalCall(context))
                return;

            // Create a symbol operand for the invocation target
            RuntimeMethod invokeTarget = context.InvokeTarget;
            SymbolOperand symbolOperand = SymbolOperand.FromMethod(invokeTarget);

            ProcessInvokeInstruction(context, symbolOperand, context.Result, new List<Operand>(context.Operands));
        }
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:24,代码来源:CILTransformationStage.cs

示例13: SwitchInstruction

        public void SwitchInstruction(Context context)
        {
            IBranch branch = context.Branch;
            Operand operand = context.Operand1;

            context.Remove();

            for (int i = 0; i < branch.Targets.Length - 1; ++i)
            {
                context.AppendInstruction(CPUx86.Instruction.CmpInstruction, operand, new ConstantOperand(new SigType(CilElementType.I), i));
                context.AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.Equal);
                context.SetBranch(branch.Targets[i]);
            }
        }
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:14,代码来源:IRTransformationStage.cs


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