================ @@ -535,92 +472,178 @@ struct FPRep<FPType::X86_Binary80> : public FPRepBase<FPType::X86_Binary80> { // - Quiet Not a Number // - Unnormal // This can be reduced to the following logic: - if (exp_bits() == encode(BiasedExponent::BITS_ALL_ONES())) + if (exp_bits() == encode(BiasedExp::BITS_ALL_ONES())) return !is_inf(); - if (exp_bits() != encode(BiasedExponent::BITS_ALL_ZEROES())) - return (sig_bits() & encode(Significand::MSB())) == 0; + if (exp_bits() != encode(BiasedExp::BITS_ALL_ZEROES())) + return (sig_bits() & encode(Sig::MSB())) == 0; return false; } LIBC_INLINE constexpr bool is_quiet_nan() const { return exp_sig_bits() >= - encode(BiasedExponent::BITS_ALL_ONES(), - Significand::MSB() | (Significand::MSB() >> 1)); + encode(BiasedExp::BITS_ALL_ONES(), Sig::MSB() | (Sig::MSB() >> 1)); } LIBC_INLINE constexpr bool is_signaling_nan() const { return is_nan() && !is_quiet_nan(); } LIBC_INLINE constexpr bool is_inf() const { - return exp_sig_bits() == - encode(BiasedExponent::BITS_ALL_ONES(), Significand::MSB()); - } - LIBC_INLINE constexpr bool is_zero() const { - return exp_sig_bits() == - encode(BiasedExponent::BITS_ALL_ZEROES(), Significand::ZERO()); + return exp_sig_bits() == encode(BiasedExp::BITS_ALL_ONES(), Sig::MSB()); } LIBC_INLINE constexpr bool is_finite() const { return !is_inf() && !is_nan(); } LIBC_INLINE constexpr bool is_subnormal() const { - return exp_sig_bits() > - encode(BiasedExponent::BITS_ALL_ZEROES(), Significand::ZERO()); + return exp_bits() == encode(BiasedExp::BITS_ALL_ZEROES()); } LIBC_INLINE constexpr bool is_normal() const { const auto exp = exp_bits(); - if (exp == encode(BiasedExponent::BITS_ALL_ZEROES()) || - exp == encode(BiasedExponent::BITS_ALL_ONES())) + if (exp == encode(BiasedExp::BITS_ALL_ZEROES()) || + exp == encode(BiasedExp::BITS_ALL_ONES())) return false; return get_implicit_bit(); } + LIBC_INLINE constexpr StorageType get_explicit_mantissa() const { + return sig_bits(); + } - LIBC_INLINE static constexpr FPRep zero(Sign sign = Sign::POS) { - return encode(sign, BiasedExponent::BITS_ALL_ZEROES(), Significand::ZERO()); + // This functions is specific to FPRepSem<FPType::X86_Binary80>. + // TODO: Remove if possible. + LIBC_INLINE constexpr bool get_implicit_bit() const { + return static_cast<bool>(bits & EXPLICIT_BIT_MASK); } - LIBC_INLINE static constexpr FPRep one(Sign sign = Sign::POS) { - return encode(sign, Exponent::ZERO(), Significand::MSB()); + + // This functions is specific to FPRepSem<FPType::X86_Binary80>. + // TODO: Remove if possible. + LIBC_INLINE constexpr void set_implicit_bit(bool implicitVal) { + if (get_implicit_bit() != implicitVal) + bits ^= EXPLICIT_BIT_MASK; } - LIBC_INLINE static constexpr FPRep min_subnormal(Sign sign = Sign::POS) { - return encode(sign, BiasedExponent::BITS_ALL_ZEROES(), Significand::LSB()); +}; + +// 'FPRep' is the bottom of the class hierarchy that only deals with 'FPType'. +// The operations dealing with specific float semantics are implemented by +// 'FPRepSem' above and specialized when needed. +// +// 'RetT' is the return type used by the builders. If not specified it defaults +// to the 'StorageType' but 'FPBits' class below defaults it to itself so ---------------- legrosbuffle wrote:
Yes, much clearer. https://github.com/llvm/llvm-project/pull/78588 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits