[libc][NFC] Remove FloatProperties (#76508)

Access is now done through `FPBits` exclusively.
This patch also renames a few internal structs and uses `T` instead of
`FP` as a template parameter.
This commit is contained in:
Guillaume Chatelet
2024-01-03 09:51:58 +01:00
committed by GitHub
parent b7d5b0d0ee
commit c09e690556
26 changed files with 180 additions and 209 deletions

View File

@@ -22,18 +22,17 @@
#include "utils/MPFRWrapper/mpfr_inc.h"
using LIBC_NAMESPACE::fputil::FloatProperties;
using LIBC_NAMESPACE::fputil::FPBits;
// This function calculates the effective precision for a given float type and
// exponent. Subnormals have a lower effective precision since they don't
// necessarily use all of the bits of the mantissa.
template <typename F> inline constexpr int effective_precision(int exponent) {
const int full_precision = FloatProperties<F>::MANTISSA_PRECISION;
const int full_precision = FPBits<F>::MANTISSA_PRECISION;
// This is intended to be 0 when the exponent is the lowest normal and
// increase as the exponent's magnitude increases.
const int bits_below_normal =
(-exponent) - (FloatProperties<F>::EXP_BIAS - 1);
const int bits_below_normal = (-exponent) - (FPBits<F>::EXP_BIAS - 1);
// The precision should be the normal, full precision, minus the bits lost
// by this being a subnormal, minus one for the implicit leading one.