From 8b21a65ed483b6cb37d838db662acdddb6e8d921 Mon Sep 17 00:00:00 2001 From: SimoneN64 Date: Fri, 19 Jan 2024 01:06:21 +0100 Subject: [PATCH] Revert "FGR improvements" This reverts commit c4f021cb9d940386c8dd182fa8095bbeee82ecfa. --- src/backend/core/registers/Cop1.hpp | 5 +- .../core/registers/cop/cop1instructions.cpp | 276 ++++++++---------- src/common.hpp | 6 +- 3 files changed, 119 insertions(+), 168 deletions(-) diff --git a/src/backend/core/registers/Cop1.hpp b/src/backend/core/registers/Cop1.hpp index a42bb4c7..053b17da 100644 --- a/src/backend/core/registers/Cop1.hpp +++ b/src/backend/core/registers/Cop1.hpp @@ -108,9 +108,8 @@ struct Cop1 { void SetCauseOverflow(); void SetCauseInvalid(); private: - template auto FGR_T(Cop0Status&, u32) -> T&; - template auto FGR_S(Cop0Status&, u32) -> T&; - template auto FGR_D(Cop0Status&, u32) -> T&; + template + auto FGR(Cop0Status&, u32) -> T&; void decodeInterp(Interpreter&, u32); void decodeJIT(JIT&, u32); void absd(Registers&, u32 instr); diff --git a/src/backend/core/registers/cop/cop1instructions.cpp b/src/backend/core/registers/cop/cop1instructions.cpp index ea719dd9..3f8a2e29 100644 --- a/src/backend/core/registers/cop/cop1instructions.cpp +++ b/src/backend/core/registers/cop/cop1instructions.cpp @@ -6,7 +6,7 @@ #include namespace n64 { -template<> auto Cop1::FGR_T(Cop0Status& status, u32 index) -> s32& { +template<> auto Cop1::FGR(Cop0Status& status, u32 index) -> s32& { if (status.fr) { return fgr[index].int32; } else { @@ -18,86 +18,38 @@ template<> auto Cop1::FGR_T(Cop0Status& status, u32 index) -> s32& { } } -template<> auto Cop1::FGR_T(Cop0Status& status, u32 index) -> u32& { - return (u32&)FGR_T(status, index); +template<> auto Cop1::FGR(Cop0Status& status, u32 index) -> u32& { + return (u32&)FGR(status, index); } -template<> auto Cop1::FGR_S(Cop0Status& status, u32 index) -> s32& { - if (status.fr) { - return fgr[index].int32; - } else { - return fgr[index & ~1].int32; - } -} - -template<> auto Cop1::FGR_S(Cop0Status& status, u32 index) -> u32& { - return (u32&)FGR_S(status, index); -} - -template<> auto Cop1::FGR_D(Cop0Status& status, u32 index) -> s32& { - fgr[index].int32h = 0; - return fgr[index].int32; -} - -template<> auto Cop1::FGR_T(Cop0Status& status, u32 index) -> float& { - return fgr[index].float32; -} - -template<> auto Cop1::FGR_D(Cop0Status& status, u32 index) -> float& { - fgr[index].float32h = 0; - return fgr[index].float32; -} - -template<> auto Cop1::FGR_S(Cop0Status& status, u32 index) -> float& { +template<> auto Cop1::FGR(Cop0Status& status, u32 index) -> float& { if (status.fr) { return fgr[index].float32; } else { - return fgr[index & ~1].float32; + if (index & 1) { + return fgr[index & ~1].float32h; + } else { + return fgr[index].float32; + } } } -template<> auto Cop1::FGR_T(Cop0Status& status, u32 index) -> s64& { +template<> auto Cop1::FGR(Cop0Status& status, u32 index) -> s64& { if (status.fr) { return fgr[index].int64; - } - else { + } else { return fgr[index & ~1].int64; } } -template<> auto Cop1::FGR_D(Cop0Status&, u32 index) -> s64& { - return fgr[index].int64; +template<> auto Cop1::FGR(Cop0Status& status, u32 index) -> u64& { + return (u64&)FGR(status, index); } -template<> auto Cop1::FGR_S(Cop0Status& status, u32 index) -> s64& { - return FGR_T(status, index); -} - -template<> auto Cop1::FGR_T(Cop0Status& status, u32 index) -> u64& { - return (u64&)FGR_T(status, index); -} - -template<> auto Cop1::FGR_D(Cop0Status& status, u32 index) -> u64& { - return (u64&)FGR_D(status, index); -} - -template<> auto Cop1::FGR_S(Cop0Status& status, u32 index) -> u64& { - return FGR_T(status, index); -} - -template<> auto Cop1::FGR_T(Cop0Status&, u32 index) -> double& { - return fgr[index].float64; -} - -template<> auto Cop1::FGR_D(Cop0Status& status, u32 index) -> double& { - return FGR_T(status, index); -} - -template<> auto Cop1::FGR_S(Cop0Status& status, u32 index) -> double& { +template<> auto Cop1::FGR(Cop0Status& status, u32 index) -> double& { if (status.fr) { return fgr[index].float64; - } - else { + } else { return fgr[index & ~1].float64; } } @@ -173,14 +125,14 @@ void Cop1::SetCauseInvalid() { #define OP(T, op) do { \ CheckFPUUsable(); \ - auto fs = FS(T, instr); \ - auto ft = FT(T, instr); \ + auto fs = FGR(regs.cop0.status, FS(instr)); \ + auto ft = FGR(regs.cop0.status, FT(instr)); \ CheckArg(fs); \ CheckArg(ft); \ T result; \ OP_CheckExcept({result = (op);}); \ CheckResult(result); \ - FD(T, instr) = result; \ + FGR(regs.cop0.status, FD(instr)) = result; \ } while(0) template @@ -425,42 +377,42 @@ void Cop1::addd(Registers& regs, u32 instr) { void Cop1::ceills(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; CVT_OP_CheckExcept({ result = std::ceil(fs); }); CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::ceilws(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; CVT_OP_CheckExcept({ result = std::ceil(fs); }); CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::ceilld(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; CVT_OP_CheckExcept({ result = std::ceil(fs); }); CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::ceilwd(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; CVT_OP_CheckExcept({ result = std::ceil(fs); }); CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cfc1(Registers& regs, u32 instr) const { @@ -502,36 +454,36 @@ void Cop1::ctc1(Registers& regs, u32 instr) { void Cop1::cvtds(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckArg(fs); double result; OP_CheckExcept({ result = double(fs); }); CheckResult(result); - FD(double, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cvtsd(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckArg(fs); float result; OP_CheckExcept({ result = float(fs); }); CheckResult(result); - FD(float, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cvtsw(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(s32, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); float result; OP_CheckExcept({ result = float(fs); }); CheckResult(result); - FD(float, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cvtsl(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(s64, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); if (fs >= s64(0x0080000000000000) || fs < s64(0xff80000000000000)) { SetCauseUnimplemented(); CheckFPUException(); @@ -539,57 +491,57 @@ void Cop1::cvtsl(Registers& regs, u32 instr) { float result; OP_CheckExcept({ result = float(fs); }); CheckResult(result); - FD(float, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cvtwd(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; PUSHROUNDING; CVT_OP_CheckExcept({ result = std::rint(fs); }); POPROUNDING; CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cvtws(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; PUSHROUNDING; CVT_OP_CheckExcept({ result = std::rint(fs); }); POPROUNDING; CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cvtls(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; PUSHROUNDING; CVT_OP_CheckExcept({ result = std::rint(fs); }); POPROUNDING; CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cvtdw(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(s32, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); double result; OP_CheckExcept({ result = double(fs); }); CheckResult(result); - FD(double, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cvtdl(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(s64, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); if (fs >= s64(0x0080000000000000) || fs < s64(0xff80000000000000)) { SetCauseUnimplemented(); @@ -598,26 +550,26 @@ void Cop1::cvtdl(Registers& regs, u32 instr) { double result; OP_CheckExcept({ result = double(fs); }); CheckResult(result); - FD(double, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::cvtld(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; PUSHROUNDING; CVT_OP_CheckExcept({ result = std::rint(fs); }); POPROUNDING; CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } template void Cop1::cf(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checkqnanregs(fs, ft); fcr31.compare = false; } @@ -625,8 +577,8 @@ void Cop1::cf(Registers& regs, u32 instr) { template void Cop1::cun(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checkqnanregs(fs, ft); fcr31.compare = any_unordered(fs, ft); } @@ -634,8 +586,8 @@ void Cop1::cun(Registers& regs, u32 instr) { template void Cop1::ceq(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checkqnanregs(fs, ft); fcr31.compare = fs == ft; } @@ -643,8 +595,8 @@ void Cop1::ceq(Registers& regs, u32 instr) { template void Cop1::cueq(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checkqnanregs(fs, ft); fcr31.compare = fs == ft || any_unordered(fs, ft); } @@ -652,8 +604,8 @@ void Cop1::cueq(Registers& regs, u32 instr) { template void Cop1::colt(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checkqnanregs(fs, ft); fcr31.compare = fs < ft; } @@ -661,8 +613,8 @@ void Cop1::colt(Registers& regs, u32 instr) { template void Cop1::cult(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checkqnanregs(fs, ft); fcr31.compare = fs < ft || any_unordered(fs, ft); } @@ -670,8 +622,8 @@ void Cop1::cult(Registers& regs, u32 instr) { template void Cop1::cole(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checkqnanregs(fs, ft); fcr31.compare = fs <= ft; } @@ -679,8 +631,8 @@ void Cop1::cole(Registers& regs, u32 instr) { template void Cop1::cule(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checkqnanregs(fs, ft); fcr31.compare = fs <= ft || any_unordered(fs, ft); } @@ -688,8 +640,8 @@ void Cop1::cule(Registers& regs, u32 instr) { template void Cop1::csf(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checknanregs(fs, ft); fcr31.compare = false; } @@ -697,8 +649,8 @@ void Cop1::csf(Registers& regs, u32 instr) { template void Cop1::cngle(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checknanregs(fs, ft); fcr31.compare = any_unordered(fs, ft); } @@ -706,8 +658,8 @@ void Cop1::cngle(Registers& regs, u32 instr) { template void Cop1::cseq(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checknanregs(fs, ft); fcr31.compare = fs == ft; } @@ -715,8 +667,8 @@ void Cop1::cseq(Registers& regs, u32 instr) { template void Cop1::cngl(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checknanregs(fs, ft); fcr31.compare = fs == ft || any_unordered(fs, ft); } @@ -724,8 +676,8 @@ void Cop1::cngl(Registers& regs, u32 instr) { template void Cop1::clt(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checknanregs(fs, ft); fcr31.compare = fs < ft; } @@ -733,8 +685,8 @@ void Cop1::clt(Registers& regs, u32 instr) { template void Cop1::cnge(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checknanregs(fs, ft); fcr31.compare = fs < ft || any_unordered(fs, ft); } @@ -742,8 +694,8 @@ void Cop1::cnge(Registers& regs, u32 instr) { template void Cop1::cle(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checknanregs(fs, ft); fcr31.compare = fs <= ft; } @@ -751,8 +703,8 @@ void Cop1::cle(Registers& regs, u32 instr) { template void Cop1::cngt(Registers& regs, u32 instr) { CheckFPUUsable(); - T fs = FS(T, instr); - T ft = FT(T, instr); + T fs = FGR(regs.cop0.status, FS(instr)); + T ft = FGR(regs.cop0.status, FT(instr)); checknanregs(fs, ft); fcr31.compare = fs <= ft || any_unordered(fs, ft); } @@ -816,14 +768,14 @@ void Cop1::subd(Registers ®s, u32 instr) { void Cop1::movs(Registers& regs, u32 instr) { CheckFPUUsable_PreserveCause(); - auto val = FS(u64, instr); - FD(u64, instr) = val; + auto val = FGR(regs.cop0.status, FS(instr)); + FGR(regs.cop0.status, FD(instr)) = val; } void Cop1::movd(Registers& regs, u32 instr) { CheckFPUUsable_PreserveCause(); - auto val = FS(double, instr); - FD(double, instr) = val; + auto val = FGR(regs.cop0.status, FS(instr)); + FGR(regs.cop0.status, FD(instr)) = val; } void Cop1::negs(Registers ®s, u32 instr) { @@ -844,122 +796,122 @@ void Cop1::sqrtd(Registers ®s, u32 instr) { void Cop1::roundls(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; CVT_OP_CheckExcept({ result = std::nearbyint(fs); }); CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::roundld(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; CVT_OP_CheckExcept({ result = std::nearbyint(fs); }); CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::roundws(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; CVT_OP_CheckExcept({ result = std::nearbyint(fs); }); CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::roundwd(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; CVT_OP_CheckExcept({ result = std::nearbyint(fs); }); CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::floorls(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; CVT_OP_CheckExcept({ result = std::floor(fs); }); CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::floorld(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; CVT_OP_CheckExcept({ result = std::floor(fs); }); CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::floorws(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; CVT_OP_CheckExcept({ result = std::floor(fs); }); CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::floorwd(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; CVT_OP_CheckExcept({ result = std::floor(fs); }); CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::truncws(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; CVT_OP_CheckExcept({ result = std::trunc(fs); }); CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::truncwd(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckWCVTArg(fs); s32 result; CVT_OP_CheckExcept({ result = std::trunc(fs); }); CheckRound(fs, result); - FD(s32, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::truncls(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(float, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; CVT_OP_CheckExcept({ result = std::trunc(fs); }); CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } void Cop1::truncld(Registers& regs, u32 instr) { CheckFPUUsable(); - auto fs = FS(double, instr); + auto fs = FGR(regs.cop0.status, FS(instr)); CheckLCVTArg(fs); s64 result; CVT_OP_CheckExcept({ result = std::trunc(fs); }); CheckRound(fs, result); - FD(s64, instr) = result; + FGR(regs.cop0.status, FD(instr)) = result; } template @@ -1035,7 +987,7 @@ void Cop1::lwc1Interp(Registers& regs, Mem& mem, u32 instr) { FireException(regs, GetTLBExceptionCode(regs.cop0.tlbError, LOAD), 0, regs.oldPC); } else { u32 data = mem.Read(regs, physical); - FT(u32, instr) = data; + FGR(regs.cop0.status, FT(instr)) = data; } } @@ -1047,7 +999,7 @@ void Cop1::swc1Interp(Registers& regs, Mem& mem, u32 instr) { HandleTLBException(regs, addr); FireException(regs, GetTLBExceptionCode(regs.cop0.tlbError, STORE), 0, regs.oldPC); } else { - mem.Write(regs, physical, FT(u32, instr)); + mem.Write(regs, physical, FGR(regs.cop0.status, FT(instr))); } } @@ -1066,7 +1018,7 @@ void Cop1::ldc1Interp(Registers& regs, Mem& mem, u32 instr) { FireException(regs, GetTLBExceptionCode(regs.cop0.tlbError, LOAD), 0, regs.oldPC); } else { u64 data = mem.Read(regs, physical); - FT(u64, instr) = data; + FGR(regs.cop0.status, FT(instr)) = data; } } @@ -1078,28 +1030,28 @@ void Cop1::sdc1Interp(Registers& regs, Mem& mem, u32 instr) { HandleTLBException(regs, addr); FireException(regs, GetTLBExceptionCode(regs.cop0.tlbError, STORE), 0, regs.oldPC); } else { - mem.Write(regs, physical, FT(u64, instr)); + mem.Write(regs, physical, FGR(regs.cop0.status, FT(instr))); } } void Cop1::mfc1(Registers& regs, u32 instr) { CheckFPUUsable_PreserveCause(); - regs.gpr[RT(instr)] = (u64)FS(s32, instr); + regs.gpr[RT(instr)] = FGR(regs.cop0.status, FS(instr)); } void Cop1::dmfc1(Registers& regs, u32 instr) { CheckFPUUsable_PreserveCause(); - regs.gpr[RT(instr)] = (u64)FS(s64, instr); + regs.gpr[RT(instr)] = FGR(regs.cop0.status, FS(instr)); } void Cop1::mtc1(Registers& regs, u32 instr) { CheckFPUUsable_PreserveCause(); - FS(u32, instr) = (u64)regs.gpr[RT(instr)]; + FGR(regs.cop0.status, FS(instr)) = regs.gpr[RT(instr)]; } void Cop1::dmtc1(Registers& regs, u32 instr) { CheckFPUUsable_PreserveCause(); - FS(u64, instr) = (u64)regs.gpr[RT(instr)]; + FGR(regs.cop0.status, FS(instr)) = regs.gpr[RT(instr)]; } } diff --git a/src/common.hpp b/src/common.hpp index e90e8239..989ae9d9 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -42,9 +42,9 @@ static FORCE_INLINE constexpr u32 GetVideoFrequency(bool pal) { #define RD(x) (((x) >> 11) & 0x1F) #define RT(x) (((x) >> 16) & 0x1F) #define RS(x) (((x) >> 21) & 0x1F) -#define FD(type, x) FGR_D(regs.cop0.status, (((x) >> 6) & 0x1F)) -#define FT(type, x) FGR_T(regs.cop0.status, RT((x))) -#define FS(type, x) FGR_S(regs.cop0.status, RD((x))) +#define FD(x) (((x) >> 6) & 0x1F) +#define FT(x) RT(x) +#define FS(x) RD(x) #define BASE(x) RS(x) #define VT(x) (((x) >> 16) & 0x1F) #define VS(x) (((x) >> 11) & 0x1F)