private void CompareIntBranch64(Context context) { SplitLongOperand(context.Operand1, out Operand op1L, out Operand op1H); SplitLongOperand(context.Operand2, out Operand op2L, out Operand op2H); var target = context.BranchTargets[0]; var branch = IRTransformationStage.GetBranch(context.ConditionCode); var branchUnsigned = IRTransformationStage.GetBranch(context.ConditionCode.GetUnsigned()); var nextBlock = Split(context); var newBlocks = CreateNewBlockContexts(2, context.Label); // Compare high dwords context.SetInstruction(X86.Cmp32, null, op1H, op2H); context.AppendInstruction(X86.BranchEqual, newBlocks[1].Block); context.AppendInstruction(X86.Jmp, newBlocks[0].Block); // Branch if check already gave results newBlocks[0].AppendInstruction(branch, target); newBlocks[0].AppendInstruction(X86.Jmp, nextBlock.Block); // Compare low dwords newBlocks[1].AppendInstruction(X86.Cmp32, null, op1L, op2L); newBlocks[1].AppendInstruction(branchUnsigned, target); newBlocks[1].AppendInstruction(X86.Jmp, nextBlock.Block); }
private void CompareInt64x64(Context context) { Debug.Assert(context.Operand1 != null && context.Operand2 != null); Debug.Assert(context.Result.IsVirtualRegister); SplitLongOperand(context.Operand1, out Operand op1L, out Operand op1H); SplitLongOperand(context.Operand2, out Operand op2L, out Operand op2H); var result = context.Result; var branch = IRTransformationStage.GetBranch(context.ConditionCode); var branchUnsigned = IRTransformationStage.GetBranch(context.ConditionCode.GetUnsigned()); var nextBlock = Split(context); var newBlocks = CreateNewBlockContexts(4, context.Label); // Compare high dwords context.SetInstruction(X86.Cmp32, null, op1H, op2H); context.AppendInstruction(X86.BranchEqual, newBlocks[1].Block); context.AppendInstruction(X86.Jmp, newBlocks[0].Block); // Branch if check already gave results if (branch == X86.BranchEqual) { newBlocks[0].AppendInstruction(X86.Jmp, newBlocks[3].Block); } else { // Branch if check already gave results newBlocks[0].AppendInstruction(branch, newBlocks[2].Block); newBlocks[0].AppendInstruction(X86.Jmp, newBlocks[3].Block); } // Compare low dwords newBlocks[1].AppendInstruction(X86.Cmp32, null, op1L, op2L); newBlocks[1].AppendInstruction(branchUnsigned, newBlocks[2].Block); newBlocks[1].AppendInstruction(X86.Jmp, newBlocks[3].Block); // Success newBlocks[2].AppendInstruction(X86.MovConst32, result, CreateConstant(1)); newBlocks[2].AppendInstruction(X86.Jmp, nextBlock.Block); // Failed newBlocks[3].AppendInstruction(X86.MovConst32, result, ConstantZero); newBlocks[3].AppendInstruction(X86.Jmp, nextBlock.Block); }