Merge pull request #450 from lioncash/cv

common/fp/unpacked: Add FPRoundCV and FPUnpackCV
This commit is contained in:
Merry 2019-03-08 12:05:52 +00:00 committed by MerryMage
commit 4b86151a0c
2 changed files with 14 additions and 2 deletions

View file

@ -59,7 +59,7 @@ FPT_TO FPConvertNaN(FPT_FROM op) {
template <typename FPT_TO, typename FPT_FROM>
FPT_TO FPConvert(FPT_FROM op, FPCR fpcr, RoundingMode rounding_mode, FPSR& fpsr) {
const auto [type, sign, value] = FPUnpack<FPT_FROM>(op, fpcr, fpsr);
const auto [type, sign, value] = FPUnpackCV<FPT_FROM>(op, fpcr, fpsr);
const bool is_althp = Common::BitSize<FPT_TO>() == 16 && fpcr.AHP();
if (type == FPType::SNaN || type == FPType::QNaN) {
@ -93,7 +93,7 @@ FPT_TO FPConvert(FPT_FROM op, FPCR fpcr, RoundingMode rounding_mode, FPSR& fpsr)
return FPInfo<FPT_TO>::Zero(sign);
}
return FPRoundBase<FPT_TO>(value, fpcr, rounding_mode, fpsr);
return FPRoundCV<FPT_TO>(value, fpcr, rounding_mode, fpsr);
}
template u64 FPConvert<u64, u32>(u32 op, FPCR fpcr, RoundingMode rounding_mode, FPSR& fpsr);

View file

@ -54,6 +54,12 @@ constexpr FPUnpacked ToNormalized(bool sign, int exponent, u64 value) {
template<typename FPT>
std::tuple<FPType, bool, FPUnpacked> FPUnpack(FPT op, FPCR fpcr, FPSR& fpsr);
template<typename FPT>
std::tuple<FPType, bool, FPUnpacked> FPUnpackCV(FPT op, FPCR fpcr, FPSR& fpsr) {
fpcr.FZ16(false);
return FPUnpack(op, fpcr, fpsr);
}
template<typename FPT>
FPT FPRoundBase(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr);
@ -63,6 +69,12 @@ FPT FPRound(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) {
return FPRoundBase<FPT>(op, fpcr, rounding, fpsr);
}
template<typename FPT>
FPT FPRoundCV(FPUnpacked op, FPCR fpcr, RoundingMode rounding, FPSR& fpsr) {
fpcr.FZ16(false);
return FPRoundBase<FPT>(op, fpcr, rounding, fpsr);
}
template<typename FPT>
FPT FPRound(FPUnpacked op, FPCR fpcr, FPSR& fpsr) {
return FPRound<FPT>(op, fpcr, fpcr.RMode(), fpsr);