コード例 #1
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var result    = context.Result;
            var operand1  = context.Operand1;
            var operand2  = context.Operand2;
            var condition = context.ConditionCode;

            var op0Low  = transformContext.AllocateVirtualRegister32();
            var op0High = transformContext.AllocateVirtualRegister32();
            var op1Low  = transformContext.AllocateVirtualRegister32();
            var op1High = transformContext.AllocateVirtualRegister32();

            var v1 = transformContext.AllocateVirtualRegister32();
            var v2 = transformContext.AllocateVirtualRegister32();
            var v3 = transformContext.AllocateVirtualRegister32();

            transformContext.SplitLongOperand(result, out Operand resultLow, out Operand resultHigh);

            context.SetInstruction(IRInstruction.GetLow32, op0Low, operand1);
            context.AppendInstruction(IRInstruction.GetHigh32, op0High, operand1);
            context.AppendInstruction(IRInstruction.GetLow32, op1Low, operand2);
            context.AppendInstruction(IRInstruction.GetHigh32, op1High, operand2);

            context.AppendInstruction(IRInstruction.Xor32, v1, op0Low, op1Low);
            context.AppendInstruction(IRInstruction.Xor32, v2, op0High, op1High);
            context.AppendInstruction(IRInstruction.Or32, v3, v1, v2);
            context.AppendInstruction(IRInstruction.Compare32x32, condition, resultLow, v3, transformContext.ConstantZero32);
            context.AppendInstruction(IRInstruction.Move32, condition, resultHigh, transformContext.ConstantZero64);
        }
コード例 #2
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var result   = context.Result;
            var operand1 = context.Operand1;
            var operand2 = context.Operand2;

            transformContext.SplitLongOperand(result, out Operand resultLow, out Operand resultHigh);

            var branch         = context.ConditionCode;
            var branchUnsigned = context.ConditionCode.GetUnsigned();

            var nextBlock = transformContext.Split(context);
            var newBlocks = transformContext.CreateNewBlockContexts(5, context.Label);

            TransformContext.UpdatePHIInstructionTargets(nextBlock.Block.NextBlocks, context.Block, nextBlock.Block);

            var op0Low  = transformContext.AllocateVirtualRegister32();
            var op0High = transformContext.AllocateVirtualRegister32();
            var op1Low  = transformContext.AllocateVirtualRegister32();
            var op1High = transformContext.AllocateVirtualRegister32();

            context.SetInstruction(IRInstruction.GetLow32, op0Low, operand1);
            context.AppendInstruction(IRInstruction.GetHigh32, op0High, operand1);
            context.AppendInstruction(IRInstruction.GetLow32, op1Low, operand2);
            context.AppendInstruction(IRInstruction.GetHigh32, op1High, operand2);

            // Compare high
            context.AppendInstruction(IRInstruction.Branch32, ConditionCode.Equal, null, op0High, op1High, newBlocks[1].Block);
            context.AppendInstruction(IRInstruction.Jmp, newBlocks[0].Block);

            // Branch if check already gave results
            if (branch == ConditionCode.Equal)
            {
                newBlocks[0].AppendInstruction(IRInstruction.Jmp, newBlocks[3].Block);
            }
            else
            {
                newBlocks[0].AppendInstruction(IRInstruction.Branch32, branch, null, op0High, op1High, newBlocks[2].Block);
                newBlocks[0].AppendInstruction(IRInstruction.Jmp, newBlocks[3].Block);
            }

            // Compare low
            newBlocks[1].AppendInstruction(IRInstruction.Branch32, branchUnsigned, null, op0Low, op1Low, newBlocks[2].Block);
            newBlocks[1].AppendInstruction(IRInstruction.Jmp, newBlocks[3].Block);

            // Success
            newBlocks[2].AppendInstruction(IRInstruction.Jmp, newBlocks[4].Block);

            // Failed
            newBlocks[3].AppendInstruction(IRInstruction.Jmp, newBlocks[4].Block);

            // Exit
            newBlocks[4].AppendInstruction(IRInstruction.Phi64, resultLow, transformContext.CreateConstant((uint)1), transformContext.ConstantZero64);
            newBlocks[4].PhiBlocks = new List <BasicBlock>(2)
            {
                newBlocks[2].Block, newBlocks[3].Block
            };
            newBlocks[4].AppendInstruction(IRInstruction.Jmp, nextBlock.Block);
        }
コード例 #3
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var result   = context.Result;
            var operand1 = context.Operand1;

            transformContext.SplitLongOperand(operand1, out Operand op0Low, out Operand _);

            var resultLow = transformContext.AllocateVirtualRegister32();

            context.SetInstruction(IRInstruction.LoadParamZeroExtend16x32, resultLow, op0Low);
            context.AppendInstruction(IRInstruction.To64, result, resultLow, transformContext.ConstantZero32);
        }
コード例 #4
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            Debug.Assert(context.ConditionCode != ConditionCode.Equal);

            var result   = context.Result;
            var operand1 = context.Operand1;
            var operand2 = context.Operand2;

            transformContext.SplitLongOperand(result, out Operand resultLow, out Operand resultHigh);

            var branch         = context.ConditionCode;
            var branchUnsigned = context.ConditionCode.GetUnsigned();

            var nextBlock = transformContext.Split(context);
            var newBlocks = transformContext.CreateNewBlockContexts(5, context.Label);

            TransformContext.UpdatePHIInstructionTargets(nextBlock.Block.NextBlocks, context.Block, nextBlock.Block);

            var op0Low  = transformContext.AllocateVirtualRegister32();
            var op0High = transformContext.AllocateVirtualRegister32();
            var op1Low  = transformContext.AllocateVirtualRegister32();
            var op1High = transformContext.AllocateVirtualRegister32();
            var tempLow = transformContext.AllocateVirtualRegister32();

            context.SetInstruction(IRInstruction.GetLow32, op0Low, operand1);
            context.AppendInstruction(IRInstruction.GetHigh32, op0High, operand1);
            context.AppendInstruction(IRInstruction.GetLow32, op1Low, operand2);
            context.AppendInstruction(IRInstruction.GetHigh32, op1High, operand2);

            // Compare high
            context.AppendInstruction(IRInstruction.Branch32, ConditionCode.Equal, null, op0High, op1High, newBlocks[1].Block);
            context.AppendInstruction(IRInstruction.Jmp, newBlocks[0].Block);

            newBlocks[0].AppendInstruction(IRInstruction.Branch32, branch, null, op0High, op1High, newBlocks[2].Block);
            newBlocks[0].AppendInstruction(IRInstruction.Jmp, newBlocks[3].Block);

            // Compare low
            newBlocks[1].AppendInstruction(IRInstruction.Branch32, branchUnsigned, null, op0Low, op1Low, newBlocks[2].Block);
            newBlocks[1].AppendInstruction(IRInstruction.Jmp, newBlocks[3].Block);

            // Success
            newBlocks[2].AppendInstruction(IRInstruction.Move32, tempLow, transformContext.CreateConstant((uint)1));
            newBlocks[2].AppendInstruction(IRInstruction.Jmp, newBlocks[4].Block);

            // Failed
            newBlocks[3].AppendInstruction(IRInstruction.Move32, tempLow, transformContext.ConstantZero32);
            newBlocks[3].AppendInstruction(IRInstruction.Jmp, newBlocks[4].Block);

            // Exit
            newBlocks[4].AppendInstruction(IRInstruction.Move32, resultLow, tempLow);
            newBlocks[4].AppendInstruction(IRInstruction.Move32, resultHigh, transformContext.ConstantZero32);
            newBlocks[4].AppendInstruction(IRInstruction.Jmp, nextBlock.Block);
        }
コード例 #5
0
ファイル: LoadParam64.cs プロジェクト: uxmal/MOSA-Project
        public override void Transform(Context context, TransformContext transformContext)
        {
            var result   = context.Result;
            var operand1 = context.Operand1;

            var resultLow  = transformContext.AllocateVirtualRegister32();
            var resultHigh = transformContext.AllocateVirtualRegister32();

            transformContext.SplitLongOperand(operand1, out Operand op1Low, out Operand op1High);

            context.SetInstruction(IRInstruction.LoadParam32, resultLow, op1Low);
            context.AppendInstruction(IRInstruction.LoadParam32, resultHigh, op1High);
            context.AppendInstruction(IRInstruction.To64, result, resultLow, resultHigh);
        }
コード例 #6
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var result   = context.Result;
            var operand1 = context.Operand1;

            transformContext.SplitLongOperand(operand1, out Operand op0Low, out Operand _);

            var resultLow  = transformContext.AllocateVirtualRegister32();
            var resultHigh = transformContext.AllocateVirtualRegister32();

            context.SetInstruction(IRInstruction.LoadParam32, resultLow, op0Low);
            context.AppendInstruction(IRInstruction.ArithShiftRight32, resultHigh, resultLow, transformContext.CreateConstant(31));
            context.AppendInstruction(IRInstruction.To64, result, resultLow, resultHigh);
        }
コード例 #7
0
        public override void Transform(Context context, TransformContext transformContext)
        {
            var offset = context.Operand1;
            var value  = context.Operand2;

            var valueLow  = transformContext.AllocateVirtualRegister32();
            var valueHigh = transformContext.AllocateVirtualRegister32();

            transformContext.SplitLongOperand(offset, out Operand op1Low, out Operand op1High);

            context.SetInstruction(IRInstruction.GetLow32, valueLow, value);
            context.AppendInstruction(IRInstruction.GetHigh32, valueHigh, value);

            context.AppendInstruction(IRInstruction.StoreParam32, null, op1Low, valueLow);
            context.AppendInstruction(IRInstruction.StoreParam32, null, op1High, valueHigh);
        }