Merge pull request #6774 from lioncash/enum

Interpreter_FPUtils: Make FPCC enum an enum class
This commit is contained in:
Markus Wick 2018-05-07 08:48:22 +02:00 committed by GitHub
commit b007210761
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 17 deletions

View File

@ -17,7 +17,7 @@
constexpr double PPC_NAN = std::numeric_limits<double>::quiet_NaN(); constexpr double PPC_NAN = std::numeric_limits<double>::quiet_NaN();
// the 4 less-significand bits in FPSCR[FPRF] // the 4 less-significand bits in FPSCR[FPRF]
enum FPCC enum class FPCC
{ {
FL = 8, // < FL = 8, // <
FG = 4, // > FG = 4, // >

View File

@ -20,11 +20,11 @@ void Interpreter::Helper_UpdateCR1()
void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction inst, double fa, double fb) void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction inst, double fa, double fb)
{ {
int compareResult; FPCC compare_result;
if (std::isnan(fa) || std::isnan(fb)) if (std::isnan(fa) || std::isnan(fb))
{ {
compareResult = FPCC::FU; compare_result = FPCC::FU;
if (MathUtil::IsSNAN(fa) || MathUtil::IsSNAN(fb)) if (MathUtil::IsSNAN(fa) || MathUtil::IsSNAN(fb))
{ {
SetFPException(FPSCR_VXSNAN); SetFPException(FPSCR_VXSNAN);
@ -40,30 +40,32 @@ void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction inst, double fa,
} }
else if (fa < fb) else if (fa < fb)
{ {
compareResult = FPCC::FL; compare_result = FPCC::FL;
} }
else if (fa > fb) else if (fa > fb)
{ {
compareResult = FPCC::FG; compare_result = FPCC::FG;
} }
else // Equals else // Equals
{ {
compareResult = FPCC::FE; compare_result = FPCC::FE;
} }
// Clear and set the FPCC bits accordingly. const u32 compare_value = static_cast<u32>(compare_result);
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compareResult;
PowerPC::SetCRField(inst.CRFD, compareResult); // Clear and set the FPCC bits accordingly.
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compare_value;
PowerPC::SetCRField(inst.CRFD, compare_value);
} }
void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction inst, double fa, double fb) void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction inst, double fa, double fb)
{ {
int compareResult; FPCC compare_result;
if (std::isnan(fa) || std::isnan(fb)) if (std::isnan(fa) || std::isnan(fb))
{ {
compareResult = FPCC::FU; compare_result = FPCC::FU;
if (MathUtil::IsSNAN(fa) || MathUtil::IsSNAN(fb)) if (MathUtil::IsSNAN(fa) || MathUtil::IsSNAN(fb))
{ {
@ -72,21 +74,23 @@ void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction inst, double fa
} }
else if (fa < fb) else if (fa < fb)
{ {
compareResult = FPCC::FL; compare_result = FPCC::FL;
} }
else if (fa > fb) else if (fa > fb)
{ {
compareResult = FPCC::FG; compare_result = FPCC::FG;
} }
else // Equals else // Equals
{ {
compareResult = FPCC::FE; compare_result = FPCC::FE;
} }
// Clear and set the FPCC bits accordingly. const u32 compare_value = static_cast<u32>(compare_result);
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compareResult;
PowerPC::SetCRField(inst.CRFD, compareResult); // Clear and set the FPCC bits accordingly.
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compare_value;
PowerPC::SetCRField(inst.CRFD, compare_value);
} }
void Interpreter::fcmpo(UGeckoInstruction inst) void Interpreter::fcmpo(UGeckoInstruction inst)