From b059384bc059fe07c4c6d9d17e7dbf43de56c35c Mon Sep 17 00:00:00 2001 From: Merry Date: Sat, 30 Jul 2022 19:12:06 +0100 Subject: [PATCH] emit_arm64_saturation: Implement SignedSaturatedSubWithFlag32 --- .../backend/arm64/emit_arm64_saturation.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/dynarmic/backend/arm64/emit_arm64_saturation.cpp b/src/dynarmic/backend/arm64/emit_arm64_saturation.cpp index 84b85e5c..db55ce8f 100644 --- a/src/dynarmic/backend/arm64/emit_arm64_saturation.cpp +++ b/src/dynarmic/backend/arm64/emit_arm64_saturation.cpp @@ -40,10 +40,22 @@ void EmitIR(oaknut::CodeGenerator& cod template<> void EmitIR(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) { - (void)code; - (void)ctx; - (void)inst; - ASSERT_FALSE("Unimplemented"); + const auto overflow_inst = inst->GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp); + ASSERT(overflow_inst); + + auto args = ctx.reg_alloc.GetArgumentInfo(inst); + auto Wresult = ctx.reg_alloc.WriteW(inst); + auto Wa = ctx.reg_alloc.ReadW(args[0]); + auto Wb = ctx.reg_alloc.ReadW(args[1]); + auto Woverflow = ctx.reg_alloc.WriteW(overflow_inst); + RegAlloc::Realize(Wresult, Wa, Wb, Woverflow); + ctx.reg_alloc.SpillFlags(); + + code.SUBS(Wresult, *Wa, Wb); + code.ASR(Wscratch0, Wresult, 31); + code.EOR(Wscratch0, Wscratch0, 0x8000'0000); + code.CSEL(Wresult, Wresult, Wscratch0, VC); + code.CSET(Woverflow, VS); } template<>