Revert "FGR improvements"

This reverts commit c4f021cb9d.
This commit is contained in:
SimoneN64
2024-01-19 01:05:05 +01:00
parent 893ceadd16
commit e669485193
3 changed files with 119 additions and 168 deletions

View File

@@ -107,9 +107,8 @@ struct Cop1 {
void SetCauseOverflow();
void SetCauseInvalid();
private:
template <typename T> auto FGR_T(Cop0Status&, u32) -> T&;
template <typename T> auto FGR_S(Cop0Status&, u32) -> T&;
template <typename T> auto FGR_D(Cop0Status&, u32) -> T&;
template <typename T>
auto FGR(Cop0Status&, u32) -> T&;
void decodeInterp(Interpreter&, u32);
void decodeJIT(JIT&, u32);
void absd(Registers&, u32 instr);

View File

@@ -7,7 +7,7 @@
#include <cfenv>
namespace n64 {
template<> auto Cop1::FGR_T<s32>(Cop0Status& status, u32 index) -> s32& {
template<> auto Cop1::FGR<s32>(Cop0Status& status, u32 index) -> s32& {
if (status.fr) {
return fgr[index].int32;
} else {
@@ -19,86 +19,38 @@ template<> auto Cop1::FGR_T<s32>(Cop0Status& status, u32 index) -> s32& {
}
}
template<> auto Cop1::FGR_T<u32>(Cop0Status& status, u32 index) -> u32& {
return (u32&)FGR_T<s32>(status, index);
template<> auto Cop1::FGR<u32>(Cop0Status& status, u32 index) -> u32& {
return (u32&)FGR<s32>(status, index);
}
template<> auto Cop1::FGR_S<s32>(Cop0Status& status, u32 index) -> s32& {
if (status.fr) {
return fgr[index].int32;
} else {
return fgr[index & ~1].int32;
}
}
template<> auto Cop1::FGR_S<u32>(Cop0Status& status, u32 index) -> u32& {
return (u32&)FGR_S<s32>(status, index);
}
template<> auto Cop1::FGR_D<s32>(Cop0Status& status, u32 index) -> s32& {
fgr[index].int32h = 0;
return fgr[index].int32;
}
template<> auto Cop1::FGR_T<float>(Cop0Status& status, u32 index) -> float& {
return fgr[index].float32;
}
template<> auto Cop1::FGR_D<float>(Cop0Status& status, u32 index) -> float& {
fgr[index].float32h = 0;
return fgr[index].float32;
}
template<> auto Cop1::FGR_S<float>(Cop0Status& status, u32 index) -> float& {
template<> auto Cop1::FGR<float>(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<s64>(Cop0Status& status, u32 index) -> s64& {
template<> auto Cop1::FGR<s64>(Cop0Status& status, u32 index) -> s64& {
if (status.fr) {
return fgr[index].int64;
}
else {
} else {
return fgr[index & ~1].int64;
}
}
template<> auto Cop1::FGR_D<s64>(Cop0Status&, u32 index) -> s64& {
return fgr[index].int64;
template<> auto Cop1::FGR<u64>(Cop0Status& status, u32 index) -> u64& {
return (u64&)FGR<s64>(status, index);
}
template<> auto Cop1::FGR_S<s64>(Cop0Status& status, u32 index) -> s64& {
return FGR_T<s64>(status, index);
}
template<> auto Cop1::FGR_T<u64>(Cop0Status& status, u32 index) -> u64& {
return (u64&)FGR_T<s64>(status, index);
}
template<> auto Cop1::FGR_D<u64>(Cop0Status& status, u32 index) -> u64& {
return (u64&)FGR_D<s64>(status, index);
}
template<> auto Cop1::FGR_S<u64>(Cop0Status& status, u32 index) -> u64& {
return FGR_T<u64>(status, index);
}
template<> auto Cop1::FGR_T<double>(Cop0Status&, u32 index) -> double& {
return fgr[index].float64;
}
template<> auto Cop1::FGR_D<double>(Cop0Status& status, u32 index) -> double& {
return FGR_T<double>(status, index);
}
template<> auto Cop1::FGR_S<double>(Cop0Status& status, u32 index) -> double& {
template<> auto Cop1::FGR<double>(Cop0Status& status, u32 index) -> double& {
if (status.fr) {
return fgr[index].float64;
}
else {
} else {
return fgr[index & ~1].float64;
}
}
@@ -174,14 +126,14 @@ void Cop1::SetCauseInvalid() {
#define OP(T, op) do { \
CheckFPUUsable(); \
auto fs = FS(T, instr); \
auto ft = FT(T, instr); \
auto fs = FGR<T>(regs.cop0.status, FS(instr)); \
auto ft = FGR<T>(regs.cop0.status, FT(instr)); \
CheckArg(fs); \
CheckArg(ft); \
T result; \
OP_CheckExcept({result = (op);}); \
CheckResult(result); \
FD(T, instr) = result; \
FGR<T>(regs.cop0.status, FD(instr)) = result; \
} while(0)
template <typename T>
@@ -426,42 +378,42 @@ void Cop1::addd(Registers& regs, u32 instr) {
void Cop1::ceills(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(regs.cop0.status, FS(instr));
CheckLCVTArg(fs);
s64 result;
CVT_OP_CheckExcept({ result = std::ceil(fs); });
CheckRound(fs, result);
FD(s64, instr) = result;
FGR<s64>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::ceilws(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(regs.cop0.status, FS(instr));
CheckWCVTArg(fs);
s32 result;
CVT_OP_CheckExcept({ result = std::ceil(fs); });
CheckRound(fs, result);
FD(s32, instr) = result;
FGR<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::ceilld(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(regs.cop0.status, FS(instr));
CheckLCVTArg(fs);
s64 result;
CVT_OP_CheckExcept({ result = std::ceil(fs); });
CheckRound(fs, result);
FD(s64, instr) = result;
FGR<s64>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::ceilwd(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(regs.cop0.status, FS(instr));
CheckWCVTArg(fs);
s32 result;
CVT_OP_CheckExcept({ result = std::ceil(fs); });
CheckRound(fs, result);
FD(s32, instr) = result;
FGR<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cfc1(Registers& regs, u32 instr) const {
@@ -503,36 +455,36 @@ void Cop1::ctc1(Registers& regs, u32 instr) {
void Cop1::cvtds(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(regs.cop0.status, FS(instr));
CheckArg(fs);
double result;
OP_CheckExcept({ result = double(fs); });
CheckResult(result);
FD(double, instr) = result;
FGR<double>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cvtsd(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(regs.cop0.status, FS(instr));
CheckArg(fs);
float result;
OP_CheckExcept({ result = float(fs); });
CheckResult(result);
FD(float, instr) = result;
FGR<float>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cvtsw(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(s32, instr);
auto fs = FGR<s32>(regs.cop0.status, FS(instr));
float result;
OP_CheckExcept({ result = float(fs); });
CheckResult(result);
FD(float, instr) = result;
FGR<float>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cvtsl(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(s64, instr);
auto fs = FGR<s64>(regs.cop0.status, FS(instr));
if (fs >= s64(0x0080000000000000) || fs < s64(0xff80000000000000)) {
SetCauseUnimplemented();
CheckFPUException();
@@ -540,57 +492,57 @@ void Cop1::cvtsl(Registers& regs, u32 instr) {
float result;
OP_CheckExcept({ result = float(fs); });
CheckResult(result);
FD(float, instr) = result;
FGR<float>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cvtwd(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(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<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cvtws(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(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<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cvtls(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(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<s64>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cvtdw(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(s32, instr);
auto fs = FGR<s32>(regs.cop0.status, FS(instr));
double result;
OP_CheckExcept({ result = double(fs); });
CheckResult(result);
FD(double, instr) = result;
FGR<double>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cvtdl(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(s64, instr);
auto fs = FGR<s64>(regs.cop0.status, FS(instr));
if (fs >= s64(0x0080000000000000) || fs < s64(0xff80000000000000)) {
SetCauseUnimplemented();
@@ -599,26 +551,26 @@ void Cop1::cvtdl(Registers& regs, u32 instr) {
double result;
OP_CheckExcept({ result = double(fs); });
CheckResult(result);
FD(double, instr) = result;
FGR<double>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::cvtld(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(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<s64>(regs.cop0.status, FD(instr)) = result;
}
template <typename T>
void Cop1::cf(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checkqnanregs(fs, ft);
fcr31.compare = false;
}
@@ -626,8 +578,8 @@ void Cop1::cf(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cun(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checkqnanregs(fs, ft);
fcr31.compare = any_unordered(fs, ft);
}
@@ -635,8 +587,8 @@ void Cop1::cun(Registers& regs, u32 instr) {
template <typename T>
void Cop1::ceq(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checkqnanregs(fs, ft);
fcr31.compare = fs == ft;
}
@@ -644,8 +596,8 @@ void Cop1::ceq(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cueq(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checkqnanregs(fs, ft);
fcr31.compare = fs == ft || any_unordered(fs, ft);
}
@@ -653,8 +605,8 @@ void Cop1::cueq(Registers& regs, u32 instr) {
template <typename T>
void Cop1::colt(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checkqnanregs(fs, ft);
fcr31.compare = fs < ft;
}
@@ -662,8 +614,8 @@ void Cop1::colt(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cult(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checkqnanregs(fs, ft);
fcr31.compare = fs < ft || any_unordered(fs, ft);
}
@@ -671,8 +623,8 @@ void Cop1::cult(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cole(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checkqnanregs(fs, ft);
fcr31.compare = fs <= ft;
}
@@ -680,8 +632,8 @@ void Cop1::cole(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cule(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checkqnanregs(fs, ft);
fcr31.compare = fs <= ft || any_unordered(fs, ft);
}
@@ -689,8 +641,8 @@ void Cop1::cule(Registers& regs, u32 instr) {
template <typename T>
void Cop1::csf(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checknanregs(fs, ft);
fcr31.compare = false;
}
@@ -698,8 +650,8 @@ void Cop1::csf(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cngle(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checknanregs(fs, ft);
fcr31.compare = any_unordered(fs, ft);
}
@@ -707,8 +659,8 @@ void Cop1::cngle(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cseq(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checknanregs(fs, ft);
fcr31.compare = fs == ft;
}
@@ -716,8 +668,8 @@ void Cop1::cseq(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cngl(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checknanregs(fs, ft);
fcr31.compare = fs == ft || any_unordered(fs, ft);
}
@@ -725,8 +677,8 @@ void Cop1::cngl(Registers& regs, u32 instr) {
template <typename T>
void Cop1::clt(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checknanregs(fs, ft);
fcr31.compare = fs < ft;
}
@@ -734,8 +686,8 @@ void Cop1::clt(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cnge(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checknanregs(fs, ft);
fcr31.compare = fs < ft || any_unordered(fs, ft);
}
@@ -743,8 +695,8 @@ void Cop1::cnge(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cle(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checknanregs(fs, ft);
fcr31.compare = fs <= ft;
}
@@ -752,8 +704,8 @@ void Cop1::cle(Registers& regs, u32 instr) {
template <typename T>
void Cop1::cngt(Registers& regs, u32 instr) {
CheckFPUUsable();
T fs = FS(T, instr);
T ft = FT(T, instr);
T fs = FGR<T>(regs.cop0.status, FS(instr));
T ft = FGR<T>(regs.cop0.status, FT(instr));
checknanregs(fs, ft);
fcr31.compare = fs <= ft || any_unordered(fs, ft);
}
@@ -817,14 +769,14 @@ void Cop1::subd(Registers &regs, u32 instr) {
void Cop1::movs(Registers& regs, u32 instr) {
CheckFPUUsable_PreserveCause();
auto val = FS(u64, instr);
FD(u64, instr) = val;
auto val = FGR<u64>(regs.cop0.status, FS(instr));
FGR<u64>(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<double>(regs.cop0.status, FS(instr));
FGR<double>(regs.cop0.status, FD(instr)) = val;
}
void Cop1::negs(Registers &regs, u32 instr) {
@@ -845,122 +797,122 @@ void Cop1::sqrtd(Registers &regs, u32 instr) {
void Cop1::roundls(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(regs.cop0.status, FS(instr));
CheckLCVTArg(fs);
s64 result;
CVT_OP_CheckExcept({ result = std::nearbyint(fs); });
CheckRound(fs, result);
FD(s64, instr) = result;
FGR<s64>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::roundld(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(regs.cop0.status, FS(instr));
CheckLCVTArg(fs);
s64 result;
CVT_OP_CheckExcept({ result = std::nearbyint(fs); });
CheckRound(fs, result);
FD(s64, instr) = result;
FGR<s64>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::roundws(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(regs.cop0.status, FS(instr));
CheckWCVTArg(fs);
s32 result;
CVT_OP_CheckExcept({ result = std::nearbyint(fs); });
CheckRound(fs, result);
FD(s32, instr) = result;
FGR<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::roundwd(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(regs.cop0.status, FS(instr));
CheckWCVTArg(fs);
s32 result;
CVT_OP_CheckExcept({ result = std::nearbyint(fs); });
CheckRound(fs, result);
FD(s32, instr) = result;
FGR<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::floorls(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(regs.cop0.status, FS(instr));
CheckLCVTArg(fs);
s64 result;
CVT_OP_CheckExcept({ result = std::floor(fs); });
CheckRound(fs, result);
FD(s64, instr) = result;
FGR<s64>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::floorld(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(regs.cop0.status, FS(instr));
CheckLCVTArg(fs);
s64 result;
CVT_OP_CheckExcept({ result = std::floor(fs); });
CheckRound(fs, result);
FD(s64, instr) = result;
FGR<s64>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::floorws(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(regs.cop0.status, FS(instr));
CheckWCVTArg(fs);
s32 result;
CVT_OP_CheckExcept({ result = std::floor(fs); });
CheckRound(fs, result);
FD(s32, instr) = result;
FGR<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::floorwd(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(regs.cop0.status, FS(instr));
CheckWCVTArg(fs);
s32 result;
CVT_OP_CheckExcept({ result = std::floor(fs); });
CheckRound(fs, result);
FD(s32, instr) = result;
FGR<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::truncws(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(regs.cop0.status, FS(instr));
CheckWCVTArg(fs);
s32 result;
CVT_OP_CheckExcept({ result = std::trunc(fs); });
CheckRound(fs, result);
FD(s32, instr) = result;
FGR<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::truncwd(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(regs.cop0.status, FS(instr));
CheckWCVTArg(fs);
s32 result;
CVT_OP_CheckExcept({ result = std::trunc(fs); });
CheckRound(fs, result);
FD(s32, instr) = result;
FGR<s32>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::truncls(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(float, instr);
auto fs = FGR<float>(regs.cop0.status, FS(instr));
CheckLCVTArg(fs);
s64 result;
CVT_OP_CheckExcept({ result = std::trunc(fs); });
CheckRound(fs, result);
FD(s64, instr) = result;
FGR<s64>(regs.cop0.status, FD(instr)) = result;
}
void Cop1::truncld(Registers& regs, u32 instr) {
CheckFPUUsable();
auto fs = FS(double, instr);
auto fs = FGR<double>(regs.cop0.status, FS(instr));
CheckLCVTArg(fs);
s64 result;
CVT_OP_CheckExcept({ result = std::trunc(fs); });
CheckRound(fs, result);
FD(s64, instr) = result;
FGR<s64>(regs.cop0.status, FD(instr)) = result;
}
template<class T>
@@ -1036,7 +988,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<u32>(regs, physical);
FT(u32, instr) = data;
FGR<u32>(regs.cop0.status, FT(instr)) = data;
}
}
@@ -1048,7 +1000,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<u32>(regs, physical, FT(u32, instr));
mem.Write<u32>(regs, physical, FGR<u32>(regs.cop0.status, FT(instr)));
}
}
@@ -1067,7 +1019,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<u64>(regs, physical);
FT(u64, instr) = data;
FGR<u64>(regs.cop0.status, FT(instr)) = data;
}
}
@@ -1079,28 +1031,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<u64>(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<s32>(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<s64>(regs.cop0.status, FS(instr));
}
void Cop1::mtc1(Registers& regs, u32 instr) {
CheckFPUUsable_PreserveCause();
FS(u32, instr) = (u64)regs.gpr[RT(instr)];
FGR<u32>(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<u64>(regs.cop0.status, FS(instr)) = regs.gpr[RT(instr)];
}
}

View File

@@ -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<type>(regs.cop0.status, (((x) >> 6) & 0x1F))
#define FT(type, x) FGR_T<type>(regs.cop0.status, RT((x)))
#define FS(type, x) FGR_S<type>(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)