コード例 #1
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var target = context.BranchTargets[0];

            context.SetNop();

            TransformContext.RemoveBlockFromPHIInstructions(context.Block, target);
        }
コード例 #2
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var target = context.BranchTargets[0];
            var block  = context.Block;

            context.SetInstruction(IRInstruction.Nop);

            TransformContext.RemoveBlockFromPHIInstructions(block, target);
        }
コード例 #3
0
ファイル: Branch32.cs プロジェクト: uxmal/MOSA-Project
        public override void Transform(Context context, TransformContext transformContext)
        {
            var target = context.BranchTargets[0];
            var block  = context.Block;

            bool compare = true;

            switch (context.ConditionCode)
            {
            case ConditionCode.Equal: compare = context.Operand1.ConstantUnsigned32 == context.Operand2.ConstantUnsigned32; break;

            case ConditionCode.NotEqual: compare = context.Operand1.ConstantUnsigned32 != context.Operand2.ConstantUnsigned32; break;

            case ConditionCode.GreaterOrEqual: compare = context.Operand1.ConstantUnsigned32 >= context.Operand2.ConstantUnsigned32; break;

            case ConditionCode.Greater: compare = context.Operand1.ConstantUnsigned32 > context.Operand2.ConstantUnsigned32; break;

            case ConditionCode.LessOrEqual: compare = context.Operand1.ConstantUnsigned32 <= context.Operand2.ConstantUnsigned32; break;

            case ConditionCode.Less: compare = context.Operand1.ConstantUnsigned32 < context.Operand2.ConstantUnsigned32; break;

            case ConditionCode.UnsignedGreater: compare = context.Operand1.ConstantUnsigned32 > context.Operand2.ConstantUnsigned32; break;

            case ConditionCode.UnsignedGreaterOrEqual: compare = context.Operand1.ConstantUnsigned32 >= context.Operand2.ConstantUnsigned32; break;

            case ConditionCode.UnsignedLess: compare = context.Operand1.ConstantUnsigned32 < context.Operand2.ConstantUnsigned32; break;

            case ConditionCode.UnsignedLessOrEqual: compare = context.Operand1.ConstantUnsigned32 <= context.Operand2.ConstantUnsigned32; break;
            }

            if (!compare)
            {
                context.SetInstruction(IRInstruction.Nop);
            }
            else
            {
                context.SetInstruction(IRInstruction.Jmp, target);

                // rest of instructions in block are never used
                context.GotoNext();
                while (!context.IsBlockEndInstruction)
                {
                    if (!context.IsEmptyOrNop)
                    {
                        context.SetInstruction(IRInstruction.Nop);
                    }
                    context.GotoNext();
                }
            }

            TransformContext.RemoveBlockFromPHIInstructions(block, target);
        }
コード例 #4
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var target = context.BranchTargets[0];
            var block  = context.Block;

            var phiBlock = GetOtherBranchTarget(block, target);

            context.SetInstruction(IRInstruction.Jmp, target);

            RemoveRestOfInstructions(context);

            TransformContext.RemoveBlockFromPHIInstructions(block, phiBlock);
        }