Add carry support to MostSignificantWord

This commit is contained in:
Tillmann Karras
2016-08-06 21:03:57 +01:00
parent 01aebcb385
commit b9f4f1ed0f
4 changed files with 23 additions and 11 deletions

View File

@@ -339,9 +339,19 @@ void EmitX64::EmitLeastSignificantWord(IR::Block&, IR::Inst* inst) {
reg_alloc.RegisterAddDef(inst, inst->GetArg(0));
}
void EmitX64::EmitMostSignificantWord(IR::Block&, IR::Inst* inst) {
auto u64 = reg_alloc.UseDefRegister(inst->GetArg(0), inst, any_gpr);
code->SHR(64, R(u64), Imm8(32));
void EmitX64::EmitMostSignificantWord(IR::Block& block, IR::Inst* inst) {
auto carry_inst = FindUseWithOpcode(inst, IR::Opcode::GetCarryFromOp);
auto result = reg_alloc.UseDefRegister(inst->GetArg(0), inst, any_gpr);
code->SHR(64, R(result), Imm8(32));
if (carry_inst) {
EraseInstruction(block, carry_inst);
reg_alloc.DecrementRemainingUses(inst);
X64Reg carry = reg_alloc.DefRegister(carry_inst, any_gpr);
code->SETcc(CC_C, R(carry));
}
}
void EmitX64::EmitLeastSignificantHalf(IR::Block&, IR::Inst* inst) {