From 490bebbd9a48345abf8d157acb378d07811be654 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 8 Mar 2019 06:20:50 -0500 Subject: [PATCH 1/2] common/fp/unpacked: Add FPUnpackCV Adds a template function that performs the same behavior as in the ARM pseudocode, and utilizes it in FPConvert, which will be necessary for half-float support. --- src/common/fp/op/FPConvert.cpp | 2 +- src/common/fp/unpacked.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/fp/op/FPConvert.cpp b/src/common/fp/op/FPConvert.cpp index 559d0242..49524906 100644 --- a/src/common/fp/op/FPConvert.cpp +++ b/src/common/fp/op/FPConvert.cpp @@ -59,7 +59,7 @@ FPT_TO FPConvertNaN(FPT_FROM op) { template FPT_TO FPConvert(FPT_FROM op, FPCR fpcr, RoundingMode rounding_mode, FPSR& fpsr) { - const auto [type, sign, value] = FPUnpack(op, fpcr, fpsr); + const auto [type, sign, value] = FPUnpackCV(op, fpcr, fpsr); const bool is_althp = Common::BitSize() == 16 && fpcr.AHP(); if (type == FPType::SNaN || type == FPType::QNaN) { diff --git a/src/common/fp/unpacked.h b/src/common/fp/unpacked.h index 132fedd0..943ee461 100644 --- a/src/common/fp/unpacked.h +++ b/src/common/fp/unpacked.h @@ -54,6 +54,12 @@ constexpr FPUnpacked ToNormalized(bool sign, int exponent, u64 value) { template std::tuple FPUnpack(FPT op, FPCR fpcr, FPSR& fpsr); +template +std::tuple FPUnpackCV(FPT op, FPCR fpcr, FPSR& fpsr) { + fpcr.FZ16(false); + return FPUnpack(op, fpcr, fpsr); +} + template FPT FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr); From 99c494bae943aaa41c65d00fdf8edbf498159575 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 8 Mar 2019 06:24:03 -0500 Subject: [PATCH 2/2] common/fp/unpacked: Add FPRoundCV Corresponds to the equivalent pseudocode within the ARMv8 reference manual. This will be necessary for supporting half-precision floating-point. This also makes use of it within FPConvert --- src/common/fp/op/FPConvert.cpp | 2 +- src/common/fp/unpacked.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/fp/op/FPConvert.cpp b/src/common/fp/op/FPConvert.cpp index 49524906..87f965a7 100644 --- a/src/common/fp/op/FPConvert.cpp +++ b/src/common/fp/op/FPConvert.cpp @@ -93,7 +93,7 @@ FPT_TO FPConvert(FPT_FROM op, FPCR fpcr, RoundingMode rounding_mode, FPSR& fpsr) return FPInfo::Zero(sign); } - return FPRoundBase(value, fpcr, rounding_mode, fpsr); + return FPRoundCV(value, fpcr, rounding_mode, fpsr); } template u64 FPConvert(u32 op, FPCR fpcr, RoundingMode rounding_mode, FPSR& fpsr); diff --git a/src/common/fp/unpacked.h b/src/common/fp/unpacked.h index 943ee461..ae206c19 100644 --- a/src/common/fp/unpacked.h +++ b/src/common/fp/unpacked.h @@ -69,6 +69,12 @@ FPT FPRound(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) { return FPRoundBase(op, fpcr, rounding, fpsr); } +template +FPT FPRoundCV(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) { + fpcr.FZ16(false); + return FPRoundBase(op, fpcr, rounding, fpsr); +} + template FPT FPRound(FPUnpacked op, FPCR fpcr, FPSR& fpsr) { return FPRound(op, fpcr, fpcr.RMode(), fpsr);