From 0e62dac4bbd5fe935fc7b4f31e184c0081cf0cbd Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 30 Jul 2021 10:17:35 +0200 Subject: [PATCH] JitArm64: Implement mtfsfix Part 5 of 6 of implementing the FPSCR system register instructions. --- Source/Core/Core/PowerPC/JitArm64/Jit.h | 1 + .../JitArm64/JitArm64_SystemRegisters.cpp | 36 +++++++++++++++++++ .../Core/PowerPC/JitArm64/JitArm64_Tables.cpp | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.h b/Source/Core/Core/PowerPC/JitArm64/Jit.h index aead64de77..46d1f24521 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.h +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.h @@ -121,6 +121,7 @@ public: void mffsx(UGeckoInstruction inst); void mtfsb0x(UGeckoInstruction inst); void mtfsb1x(UGeckoInstruction inst); + void mtfsfix(UGeckoInstruction inst); // LoadStore void lXX(UGeckoInstruction inst); diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp index 4a40ee7450..e0cd9d36a9 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_SystemRegisters.cpp @@ -816,3 +816,39 @@ void JitArm64::mtfsb1x(UGeckoInstruction inst) if (inst.CRBD >= 29) UpdateRoundingMode(); } + +void JitArm64::mtfsfix(UGeckoInstruction inst) +{ + INSTRUCTION_START + JITDISABLE(bJITSystemRegistersOff); + FALLBACK_IF(inst.Rc); + + u8 imm = (inst.hex >> (31 - 19)) & 0xF; + u8 shift = 28 - 4 * inst.CRFD; + + ARM64Reg WA = gpr.GetReg(); + LDR(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(fpscr)); + + if (imm == 0xF) + { + ORR(WA, WA, LogicalImm(0xF << shift, 32)); + } + else if (imm == 0x0) + { + BFI(WA, ARM64Reg::WZR, shift, 4); + } + else + { + ARM64Reg WB = gpr.GetReg(); + MOVZ(WB, imm); + BFI(WA, WB, shift, 4); + gpr.Unlock(WB); + } + + STR(IndexType::Unsigned, WA, PPC_REG, PPCSTATE_OFF(fpscr)); + gpr.Unlock(WA); + + // Field 7 contains NI and RN. + if (inst.CRFD == 7) + UpdateRoundingMode(); +} diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp index 4d44cce2dc..aa6255c0ff 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Tables.cpp @@ -318,7 +318,7 @@ constexpr std::array table63{{ {583, &JitArm64::mffsx}, // mffsx {70, &JitArm64::mtfsb0x}, // mtfsb0x {38, &JitArm64::mtfsb1x}, // mtfsb1x - {134, &JitArm64::FallBackToInterpreter}, // mtfsfix + {134, &JitArm64::mtfsfix}, // mtfsfix {711, &JitArm64::FallBackToInterpreter}, // mtfsfx }};