From 14f55d74760057c5ba08e11b838df02d63504e9c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 9 Mar 2019 01:23:27 -0500 Subject: [PATCH] common/fp/unpacked: Add half-precision instantiation of FPRoundBase --- src/common/fp/unpacked.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/common/fp/unpacked.cpp b/src/common/fp/unpacked.cpp index 9afe4b1b..ad6374a1 100644 --- a/src/common/fp/unpacked.cpp +++ b/src/common/fp/unpacked.cpp @@ -88,7 +88,7 @@ FPT FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) { if (((!isFP16 && fpcr.FZ()) || (isFP16 && fpcr.FZ16())) && exponent < minimum_exp) { fpsr.UFC(true); - return FPInfo::Zero(sign); + return FPT(FPInfo::Zero(sign)); } int biased_exp = std::max(exponent - minimum_exp + 1, 0); @@ -151,13 +151,13 @@ FPT FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) { #endif constexpr int max_biased_exp = (1 << E) - 1; if (biased_exp >= max_biased_exp) { - result = overflow_to_inf ? FPInfo::Infinity(sign) : FPInfo::MaxNormal(sign); + result = overflow_to_inf ? FPT(FPInfo::Infinity(sign)) : FPT(FPInfo::MaxNormal(sign)); FPProcessException(FPExc::Overflow, fpcr, fpsr); FPProcessException(FPExc::Inexact, fpcr, fpsr); } else { result = sign ? 1 : 0; result <<= E; - result += biased_exp; + result += FPT(biased_exp); result <<= F; result |= static_cast(mantissa) & FPInfo::mantissa_mask; if (error != ResidualError::Zero) { @@ -172,7 +172,7 @@ FPT FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) { } else { result = sign ? 1 : 0; result <<= E; - result += biased_exp; + result += FPT(biased_exp); result <<= F; result |= static_cast(mantissa) & FPInfo::mantissa_mask; if (error != ResidualError::Zero) { @@ -183,6 +183,7 @@ FPT FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) { return result; } +template u16 FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr); template u32 FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr); template u64 FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr);