From 8f9fe8690ad2d7747243b8f9cac9564582fcfe36 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 9 Mar 2019 00:08:08 -0500 Subject: [PATCH] common/fp/unpacked: Adjust FPUnpack to operate like ARM pseudocode This function is defined as always disabling the AHP bit in the fpcr before performing any operations. At the same time, rename the original FPUnpack function to FPUnpackBase to match the pseudocode in the ARM reference manual. --- src/common/fp/unpacked.cpp | 6 +++--- src/common/fp/unpacked.h | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/common/fp/unpacked.cpp b/src/common/fp/unpacked.cpp index b30f47fe..45d2b584 100644 --- a/src/common/fp/unpacked.cpp +++ b/src/common/fp/unpacked.cpp @@ -15,7 +15,7 @@ namespace Dynarmic::FP { template -std::tuple FPUnpack(FPT op, FPCR fpcr, FPSR& fpsr) { +std::tuple FPUnpackBase(FPT op, FPCR fpcr, FPSR& fpsr) { constexpr size_t sign_bit = FPInfo::exponent_width + FPInfo::explicit_mantissa_width; constexpr size_t exponent_high_bit = FPInfo::exponent_width + FPInfo::explicit_mantissa_width - 1; constexpr size_t exponent_low_bit = FPInfo::explicit_mantissa_width; @@ -52,8 +52,8 @@ std::tuple FPUnpack(FPT op, FPCR fpcr, FPSR& fpsr) { return {FPType::Nonzero, sign, {sign, exp, frac}}; } -template std::tuple FPUnpack(u32 op, FPCR fpcr, FPSR& fpsr); -template std::tuple FPUnpack(u64 op, FPCR fpcr, FPSR& fpsr); +template std::tuple FPUnpackBase(u32 op, FPCR fpcr, FPSR& fpsr); +template std::tuple FPUnpackBase(u64 op, FPCR fpcr, FPSR& fpsr); template std::tuple Normalize(FPUnpacked op, int extra_right_shift = 0) { diff --git a/src/common/fp/unpacked.h b/src/common/fp/unpacked.h index ae206c19..13e43474 100644 --- a/src/common/fp/unpacked.h +++ b/src/common/fp/unpacked.h @@ -52,7 +52,13 @@ constexpr FPUnpacked ToNormalized(bool sign, int exponent, u64 value) { } template -std::tuple FPUnpack(FPT op, FPCR fpcr, FPSR& fpsr); +std::tuple FPUnpackBase(FPT op, FPCR fpcr, FPSR& fpsr); + +template +std::tuple FPUnpack(FPT op, FPCR fpcr, FPSR& fpsr) { + fpcr.AHP(false); + return FPUnpackBase(op, fpcr, fpsr); +} template std::tuple FPUnpackCV(FPT op, FPCR fpcr, FPSR& fpsr) {