From eb3e0d5908969b79a99ef3d1c69cac2b8219045d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 9 Mar 2019 17:31:17 -0500 Subject: [PATCH] common/fp/op/FPRecipExponent: Add half-precision floating point specialization --- src/common/fp/op/FPRecipExponent.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/common/fp/op/FPRecipExponent.cpp b/src/common/fp/op/FPRecipExponent.cpp index eaa7addb..4e0224e7 100644 --- a/src/common/fp/op/FPRecipExponent.cpp +++ b/src/common/fp/op/FPRecipExponent.cpp @@ -17,28 +17,16 @@ namespace Dynarmic::FP { namespace { -// We don't care about unreachable code warnings here -// TODO: Remove this warning disabling of warnings when -// half-float support is added. -#ifdef _MSC_VER -#pragma warning(disable:4702) -#endif template FPT DetermineExponentValue(size_t value) { if constexpr (sizeof(FPT) == sizeof(u32)) { return static_cast(Common::Bits<23, 30>(value)); - } - - if constexpr (sizeof(FPT) == sizeof(u64)) { + } else if constexpr (sizeof(FPT) == sizeof(u64)) { return static_cast(Common::Bits<52, 62>(value)); + } else { + return static_cast(Common::Bits<10, 14>(value)); } - - // Half-float - return static_cast(Common::Bits<10, 14>(value)); } -#ifdef _MSC_VER -#pragma warning(default:4702) -#endif } // Anonymous namespace template @@ -50,7 +38,7 @@ FPT FPRecipExponent(FPT op, FPCR fpcr, FPSR& fpsr) { return FPProcessNaN(type, op, fpcr, fpsr); } - const FPT sign_bits = FPInfo::Zero(sign); + const FPT sign_bits = FPT(FPInfo::Zero(sign)); const FPT exponent = DetermineExponentValue(op); // Zero and denormals @@ -64,6 +52,7 @@ FPT FPRecipExponent(FPT op, FPCR fpcr, FPSR& fpsr) { return FPT(sign_bits | negated_exponent); } +template u16 FPRecipExponent(u16 op, FPCR fpcr, FPSR& fpsr); template u32 FPRecipExponent(u32 op, FPCR fpcr, FPSR& fpsr); template u64 FPRecipExponent(u64 op, FPCR fpcr, FPSR& fpsr);