Skip to content
Permalink
Browse files
Merge pull request #6774 from lioncash/enum
Interpreter_FPUtils: Make FPCC enum an enum class
  • Loading branch information
degasus committed May 7, 2018
2 parents 6ec1e74 + d5de49f commit b007210
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
@@ -17,7 +17,7 @@
constexpr double PPC_NAN = std::numeric_limits<double>::quiet_NaN();

// the 4 less-significand bits in FPSCR[FPRF]
enum FPCC
enum class FPCC
{
FL = 8, // <
FG = 4, // >
@@ -20,11 +20,11 @@ void Interpreter::Helper_UpdateCR1()

void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction inst, double fa, double fb)
{
int compareResult;
FPCC compare_result;

if (std::isnan(fa) || std::isnan(fb))
{
compareResult = FPCC::FU;
compare_result = FPCC::FU;
if (MathUtil::IsSNAN(fa) || MathUtil::IsSNAN(fb))
{
SetFPException(FPSCR_VXSNAN);
@@ -40,30 +40,32 @@ void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction inst, double fa,
}
else if (fa < fb)
{
compareResult = FPCC::FL;
compare_result = FPCC::FL;
}
else if (fa > fb)
{
compareResult = FPCC::FG;
compare_result = FPCC::FG;
}
else // Equals
{
compareResult = FPCC::FE;
compare_result = FPCC::FE;
}

const u32 compare_value = static_cast<u32>(compare_result);

// Clear and set the FPCC bits accordingly.
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compareResult;
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compare_value;

PowerPC::SetCRField(inst.CRFD, compareResult);
PowerPC::SetCRField(inst.CRFD, compare_value);
}

void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction inst, double fa, double fb)
{
int compareResult;
FPCC compare_result;

if (std::isnan(fa) || std::isnan(fb))
{
compareResult = FPCC::FU;
compare_result = FPCC::FU;

if (MathUtil::IsSNAN(fa) || MathUtil::IsSNAN(fb))
{
@@ -72,21 +74,23 @@ void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction inst, double fa
}
else if (fa < fb)
{
compareResult = FPCC::FL;
compare_result = FPCC::FL;
}
else if (fa > fb)
{
compareResult = FPCC::FG;
compare_result = FPCC::FG;
}
else // Equals
{
compareResult = FPCC::FE;
compare_result = FPCC::FE;
}

const u32 compare_value = static_cast<u32>(compare_result);

// Clear and set the FPCC bits accordingly.
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compareResult;
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compare_value;

PowerPC::SetCRField(inst.CRFD, compareResult);
PowerPC::SetCRField(inst.CRFD, compare_value);
}

void Interpreter::fcmpo(UGeckoInstruction inst)

0 comments on commit b007210

Please sign in to comment.