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.
This commit is contained in:
Lioncash 2019-03-08 06:20:50 -05:00 committed by MerryMage
parent bbd5330ad2
commit 490bebbd9a
2 changed files with 7 additions and 1 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) {

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);