[llvm] [libc] [libc][NFC] Integrate `FloatProperties` into `FPBits` (PR #76506)
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 28 06:31:33 PST 2023
https://github.com/gchatelet created https://github.com/llvm/llvm-project/pull/76506
`FloatProperties` is always included when `FPBits` is. This will help further refactoring.
>From 1b0eb15033d46ac7f9b26ba7a97eb4d3a7f956df Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Thu, 28 Dec 2023 14:31:10 +0000
Subject: [PATCH] [libc][NFC] Integrate `FloatProperties` into `FPBits`
`FloatProperties` is always included when `FPBits` is. This will help further refactoring.
---
libc/fuzzing/stdlib/CMakeLists.txt | 2 +-
libc/fuzzing/stdlib/strtofloat_fuzz.cpp | 2 +-
libc/src/__support/FPUtil/CMakeLists.txt | 17 +-
libc/src/__support/FPUtil/FPBits.h | 189 +++++++++++++++-
libc/src/__support/FPUtil/FloatProperties.h | 211 ------------------
.../__support/FPUtil/ManipulationFunctions.h | 1 -
libc/src/__support/FPUtil/dyadic_float.h | 1 -
libc/src/__support/FPUtil/fpbits_str.h | 1 -
.../__support/FPUtil/generic/CMakeLists.txt | 2 -
libc/src/__support/FPUtil/generic/FMA.h | 1 -
.../stdio/printf_core/float_dec_converter.h | 1 -
libc/test/src/__support/str_to_fp_test.h | 2 +-
libc/utils/MPFRWrapper/CMakeLists.txt | 1 -
libc/utils/MPFRWrapper/MPFRUtils.cpp | 1 -
.../llvm-project-overlay/libc/BUILD.bazel | 18 +-
.../libc/libc_build_rules.bzl | 1 -
.../libc/test/src/__support/BUILD.bazel | 2 +-
.../test/src/math/libc_math_test_rules.bzl | 1 -
.../libc/utils/MPFRWrapper/BUILD.bazel | 1 -
19 files changed, 197 insertions(+), 258 deletions(-)
delete mode 100644 libc/src/__support/FPUtil/FloatProperties.h
diff --git a/libc/fuzzing/stdlib/CMakeLists.txt b/libc/fuzzing/stdlib/CMakeLists.txt
index 09ac985623cad8..711b0fd9820f93 100644
--- a/libc/fuzzing/stdlib/CMakeLists.txt
+++ b/libc/fuzzing/stdlib/CMakeLists.txt
@@ -26,7 +26,7 @@ add_libc_fuzzer(
libc.src.stdlib.strtof
libc.src.stdlib.strtod
libc.src.stdlib.strtold
- libc.src.__support.FPUtil.float_properties
+ libc.src.__support.FPUtil.fp_bits
)
add_libc_fuzzer(
diff --git a/libc/fuzzing/stdlib/strtofloat_fuzz.cpp b/libc/fuzzing/stdlib/strtofloat_fuzz.cpp
index ea2f492f57ae76..0e0d82fd3e8af9 100644
--- a/libc/fuzzing/stdlib/strtofloat_fuzz.cpp
+++ b/libc/fuzzing/stdlib/strtofloat_fuzz.cpp
@@ -14,7 +14,7 @@
#include "src/stdlib/strtof.h"
#include "src/stdlib/strtold.h"
-#include "src/__support/FPUtil/FloatProperties.h"
+#include "src/__support/FPUtil/FPBits.h"
#include <math.h>
#include <stddef.h>
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index 1cb22536a1cf6e..ad2c4ad27bced3 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -23,25 +23,18 @@ add_header_library(
libc.src.errno.errno
)
-add_header_library(
- float_properties
- HDRS
- FloatProperties.h
- DEPENDS
- libc.src.__support.macros.properties.float
- libc.src.__support.uint128
- libc.src.__support.math_extras
-)
-
add_header_library(
fp_bits
HDRS
FPBits.h
DEPENDS
- .float_properties
libc.src.__support.common
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
+ libc.src.__support.macros.attributes
+ libc.src.__support.macros.properties.float
+ libc.src.__support.math_extras
+ libc.src.__support.uint128
)
add_header_library(
@@ -49,7 +42,6 @@ add_header_library(
HDRS
fpbits_str.h
DEPENDS
- .float_properties
.fp_bits
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
@@ -230,7 +222,6 @@ add_header_library(
HDRS
dyadic_float.h
DEPENDS
- .float_properties
.fp_bits
.multiply_add
libc.src.__support.common
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index 790449cc0080c8..d06625ed13852d 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -13,14 +13,199 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/UInt128.h"
#include "src/__support/common.h"
-#include "src/__support/macros/attributes.h" // LIBC_INLINE
+#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR
+#include "src/__support/macros/properties/float.h" // LIBC_COMPILER_HAS_FLOAT128
+#include "src/__support/math_extras.h" // mask_trailing_ones
-#include "FloatProperties.h"
#include <stdint.h>
namespace LIBC_NAMESPACE {
namespace fputil {
+// The supported floating point types.
+enum class FPType {
+ IEEE754_Binary16,
+ IEEE754_Binary32,
+ IEEE754_Binary64,
+ IEEE754_Binary128,
+ X86_Binary80,
+};
+
+namespace internal {
+
+// The type of encoding for supported floating point types.
+enum class FPEncoding {
+ IEEE754,
+ X86_ExtendedPrecision,
+};
+
+template <FPType> struct FPBaseProperties {};
+
+template <> struct FPBaseProperties<FPType::IEEE754_Binary16> {
+ using StorageType = uint16_t;
+ LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 16;
+ LIBC_INLINE_VAR static constexpr int SIG_LEN = 10;
+ LIBC_INLINE_VAR static constexpr int EXP_LEN = 5;
+ LIBC_INLINE_VAR static constexpr auto ENCODING = FPEncoding::IEEE754;
+};
+
+template <> struct FPBaseProperties<FPType::IEEE754_Binary32> {
+ using StorageType = uint32_t;
+ LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 32;
+ LIBC_INLINE_VAR static constexpr int SIG_LEN = 23;
+ LIBC_INLINE_VAR static constexpr int EXP_LEN = 8;
+ LIBC_INLINE_VAR static constexpr auto ENCODING = FPEncoding::IEEE754;
+};
+
+template <> struct FPBaseProperties<FPType::IEEE754_Binary64> {
+ using StorageType = uint64_t;
+ LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 64;
+ LIBC_INLINE_VAR static constexpr int SIG_LEN = 52;
+ LIBC_INLINE_VAR static constexpr int EXP_LEN = 11;
+ LIBC_INLINE_VAR static constexpr auto ENCODING = FPEncoding::IEEE754;
+};
+
+template <> struct FPBaseProperties<FPType::IEEE754_Binary128> {
+ using StorageType = UInt128;
+ LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 128;
+ LIBC_INLINE_VAR static constexpr int SIG_LEN = 112;
+ LIBC_INLINE_VAR static constexpr int EXP_LEN = 15;
+ LIBC_INLINE_VAR static constexpr auto ENCODING = FPEncoding::IEEE754;
+};
+
+template <> struct FPBaseProperties<FPType::X86_Binary80> {
+ using StorageType = UInt128;
+ LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 80;
+ LIBC_INLINE_VAR static constexpr int SIG_LEN = 64;
+ LIBC_INLINE_VAR static constexpr int EXP_LEN = 15;
+ LIBC_INLINE_VAR static constexpr auto ENCODING =
+ FPEncoding::X86_ExtendedPrecision;
+};
+
+} // namespace internal
+
+template <FPType fp_type>
+struct FPProperties : public internal::FPBaseProperties<fp_type> {
+private:
+ using UP = internal::FPBaseProperties<fp_type>;
+
+public:
+ // The number of bits to represent sign. For documentation purpose, always 1.
+ LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1;
+ using UP::EXP_LEN; // The number of bits for the *exponent* part
+ using UP::SIG_LEN; // The number of bits for the *significand* part
+ using UP::TOTAL_LEN; // For convenience, the sum of `SIG_LEN`, `EXP_LEN`,
+ // and `SIGN_LEN`.
+ static_assert(SIGN_LEN + EXP_LEN + SIG_LEN == TOTAL_LEN);
+
+ // An unsigned integer that is wide enough to contain all of the floating
+ // point bits.
+ using StorageType = typename UP::StorageType;
+
+ // The number of bits in StorageType.
+ LIBC_INLINE_VAR static constexpr int STORAGE_LEN =
+ sizeof(StorageType) * CHAR_BIT;
+ static_assert(STORAGE_LEN >= TOTAL_LEN);
+
+ // The exponent bias. Always positive.
+ LIBC_INLINE_VAR static constexpr int32_t EXP_BIAS =
+ (1U << (EXP_LEN - 1U)) - 1U;
+ static_assert(EXP_BIAS > 0);
+
+protected:
+ // The shift amount to get the *significand* part to the least significant
+ // bit. Always `0` but kept for consistency.
+ LIBC_INLINE_VAR static constexpr int SIG_MASK_SHIFT = 0;
+ // The shift amount to get the *exponent* part to the least significant bit.
+ LIBC_INLINE_VAR static constexpr int EXP_MASK_SHIFT = SIG_LEN;
+ // The shift amount to get the *sign* part to the least significant bit.
+ LIBC_INLINE_VAR static constexpr int SIGN_MASK_SHIFT = SIG_LEN + EXP_LEN;
+
+ // The bit pattern that keeps only the *significand* part.
+ LIBC_INLINE_VAR static constexpr StorageType SIG_MASK =
+ mask_trailing_ones<StorageType, SIG_LEN>() << SIG_MASK_SHIFT;
+
+public:
+ // The bit pattern that keeps only the *exponent* part.
+ LIBC_INLINE_VAR static constexpr StorageType EXP_MASK =
+ mask_trailing_ones<StorageType, EXP_LEN>() << EXP_MASK_SHIFT;
+ // The bit pattern that keeps only the *sign* part.
+ LIBC_INLINE_VAR static constexpr StorageType SIGN_MASK =
+ mask_trailing_ones<StorageType, SIGN_LEN>() << SIGN_MASK_SHIFT;
+ // The bit pattern that keeps only the *exponent + significand* part.
+ LIBC_INLINE_VAR static constexpr StorageType EXP_SIG_MASK =
+ mask_trailing_ones<StorageType, EXP_LEN + SIG_LEN>();
+ // The bit pattern that keeps only the *sign + exponent + significand* part.
+ LIBC_INLINE_VAR static constexpr StorageType FP_MASK =
+ mask_trailing_ones<StorageType, TOTAL_LEN>();
+
+ static_assert((SIG_MASK & EXP_MASK & SIGN_MASK) == 0, "masks disjoint");
+ static_assert((SIG_MASK | EXP_MASK | SIGN_MASK) == FP_MASK, "masks cover");
+
+private:
+ LIBC_INLINE static constexpr StorageType bit_at(int position) {
+ return StorageType(1) << position;
+ }
+
+public:
+ // The number of bits after the decimal dot when the number is in normal form.
+ LIBC_INLINE_VAR static constexpr int FRACTION_LEN =
+ UP::ENCODING == internal::FPEncoding::X86_ExtendedPrecision ? SIG_LEN - 1
+ : SIG_LEN;
+ LIBC_INLINE_VAR static constexpr uint32_t MANTISSA_PRECISION =
+ FRACTION_LEN + 1;
+ LIBC_INLINE_VAR static constexpr StorageType FRACTION_MASK =
+ mask_trailing_ones<StorageType, FRACTION_LEN>();
+
+protected:
+ // If a number x is a NAN, then it is a quiet NAN if:
+ // QUIET_NAN_MASK & bits(x) != 0
+ LIBC_INLINE_VAR static constexpr StorageType QUIET_NAN_MASK =
+ UP::ENCODING == internal::FPEncoding::X86_ExtendedPrecision
+ ? bit_at(SIG_LEN - 1) | bit_at(SIG_LEN - 2) // 0b1100...
+ : bit_at(SIG_LEN - 1); // 0b1000...
+
+ // If a number x is a NAN, then it is a signalling NAN if:
+ // SIGNALING_NAN_MASK & bits(x) != 0
+ LIBC_INLINE_VAR static constexpr StorageType SIGNALING_NAN_MASK =
+ UP::ENCODING == internal::FPEncoding::X86_ExtendedPrecision
+ ? bit_at(SIG_LEN - 1) | bit_at(SIG_LEN - 3) // 0b1010...
+ : bit_at(SIG_LEN - 2); // 0b0100...
+};
+
+//-----------------------------------------------------------------------------
+template <typename FP> LIBC_INLINE static constexpr FPType get_fp_type() {
+ if constexpr (cpp::is_same_v<FP, float> && __FLT_MANT_DIG__ == 24)
+ return FPType::IEEE754_Binary32;
+ else if constexpr (cpp::is_same_v<FP, double> && __DBL_MANT_DIG__ == 53)
+ return FPType::IEEE754_Binary64;
+ else if constexpr (cpp::is_same_v<FP, long double>) {
+ if constexpr (__LDBL_MANT_DIG__ == 53)
+ return FPType::IEEE754_Binary64;
+ else if constexpr (__LDBL_MANT_DIG__ == 64)
+ return FPType::X86_Binary80;
+ else if constexpr (__LDBL_MANT_DIG__ == 113)
+ return FPType::IEEE754_Binary128;
+ }
+#if defined(LIBC_COMPILER_HAS_C23_FLOAT16)
+ else if constexpr (cpp::is_same_v<FP, _Float16>)
+ return FPType::IEEE754_Binary16;
+#endif
+#if defined(LIBC_COMPILER_HAS_C23_FLOAT128)
+ else if constexpr (cpp::is_same_v<FP, _Float128>)
+ return FPType::IEEE754_Binary128;
+#endif
+#if defined(LIBC_COMPILER_HAS_FLOAT128_EXTENSION)
+ else if constexpr (cpp::is_same_v<FP, __float128>)
+ return FPType::IEEE754_Binary128;
+#endif
+ else
+ static_assert(cpp::always_false<FP>, "Unsupported type");
+}
+
+template <typename FP>
+struct FloatProperties : public FPProperties<get_fp_type<FP>()> {};
+
namespace internal {
// This is a temporary class to unify common methods and properties between
diff --git a/libc/src/__support/FPUtil/FloatProperties.h b/libc/src/__support/FPUtil/FloatProperties.h
deleted file mode 100644
index 6bf75b7167d32d..00000000000000
--- a/libc/src/__support/FPUtil/FloatProperties.h
+++ /dev/null
@@ -1,211 +0,0 @@
-//===-- Properties of floating point numbers --------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FLOATPROPERTIES_H
-#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FLOATPROPERTIES_H
-
-#include "src/__support/UInt128.h"
-#include "src/__support/macros/attributes.h" // LIBC_INLINE, LIBC_INLINE_VAR
-#include "src/__support/macros/properties/float.h" // LIBC_COMPILER_HAS_FLOAT128
-#include "src/__support/math_extras.h" // mask_trailing_ones
-
-#include <stdint.h>
-
-namespace LIBC_NAMESPACE {
-namespace fputil {
-
-// The supported floating point types.
-enum class FPType {
- IEEE754_Binary16,
- IEEE754_Binary32,
- IEEE754_Binary64,
- IEEE754_Binary128,
- X86_Binary80,
-};
-
-// For now 'FPEncoding', 'FPBaseProperties' and 'FPCommonProperties' are
-// implementation details.
-namespace internal {
-
-// The type of encoding for supported floating point types.
-enum class FPEncoding {
- IEEE754,
- X86_ExtendedPrecision,
-};
-
-template <FPType> struct FPBaseProperties {};
-
-template <> struct FPBaseProperties<FPType::IEEE754_Binary16> {
- using StorageType = uint16_t;
- LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 16;
- LIBC_INLINE_VAR static constexpr int SIG_LEN = 10;
- LIBC_INLINE_VAR static constexpr int EXP_LEN = 5;
- LIBC_INLINE_VAR static constexpr auto ENCODING = FPEncoding::IEEE754;
-};
-
-template <> struct FPBaseProperties<FPType::IEEE754_Binary32> {
- using StorageType = uint32_t;
- LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 32;
- LIBC_INLINE_VAR static constexpr int SIG_LEN = 23;
- LIBC_INLINE_VAR static constexpr int EXP_LEN = 8;
- LIBC_INLINE_VAR static constexpr auto ENCODING = FPEncoding::IEEE754;
-};
-
-template <> struct FPBaseProperties<FPType::IEEE754_Binary64> {
- using StorageType = uint64_t;
- LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 64;
- LIBC_INLINE_VAR static constexpr int SIG_LEN = 52;
- LIBC_INLINE_VAR static constexpr int EXP_LEN = 11;
- LIBC_INLINE_VAR static constexpr auto ENCODING = FPEncoding::IEEE754;
-};
-
-template <> struct FPBaseProperties<FPType::IEEE754_Binary128> {
- using StorageType = UInt128;
- LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 128;
- LIBC_INLINE_VAR static constexpr int SIG_LEN = 112;
- LIBC_INLINE_VAR static constexpr int EXP_LEN = 15;
- LIBC_INLINE_VAR static constexpr auto ENCODING = FPEncoding::IEEE754;
-};
-
-template <> struct FPBaseProperties<FPType::X86_Binary80> {
- using StorageType = UInt128;
- LIBC_INLINE_VAR static constexpr int TOTAL_LEN = 80;
- LIBC_INLINE_VAR static constexpr int SIG_LEN = 64;
- LIBC_INLINE_VAR static constexpr int EXP_LEN = 15;
- LIBC_INLINE_VAR static constexpr auto ENCODING =
- FPEncoding::X86_ExtendedPrecision;
-};
-
-} // namespace internal
-
-template <FPType fp_type>
-struct FPProperties : public internal::FPBaseProperties<fp_type> {
-private:
- using UP = internal::FPBaseProperties<fp_type>;
-
-public:
- // The number of bits to represent sign. For documentation purpose, always 1.
- LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1;
- using UP::EXP_LEN; // The number of bits for the *exponent* part
- using UP::SIG_LEN; // The number of bits for the *significand* part
- using UP::TOTAL_LEN; // For convenience, the sum of `SIG_LEN`, `EXP_LEN`,
- // and `SIGN_LEN`.
- static_assert(SIGN_LEN + EXP_LEN + SIG_LEN == TOTAL_LEN);
-
- // An unsigned integer that is wide enough to contain all of the floating
- // point bits.
- using StorageType = typename UP::StorageType;
-
- // The number of bits in StorageType.
- LIBC_INLINE_VAR static constexpr int STORAGE_LEN =
- sizeof(StorageType) * CHAR_BIT;
- static_assert(STORAGE_LEN >= TOTAL_LEN);
-
- // The exponent bias. Always positive.
- LIBC_INLINE_VAR static constexpr int32_t EXP_BIAS =
- (1U << (EXP_LEN - 1U)) - 1U;
- static_assert(EXP_BIAS > 0);
-
-protected:
- // The shift amount to get the *significand* part to the least significant
- // bit. Always `0` but kept for consistency.
- LIBC_INLINE_VAR static constexpr int SIG_MASK_SHIFT = 0;
- // The shift amount to get the *exponent* part to the least significant bit.
- LIBC_INLINE_VAR static constexpr int EXP_MASK_SHIFT = SIG_LEN;
- // The shift amount to get the *sign* part to the least significant bit.
- LIBC_INLINE_VAR static constexpr int SIGN_MASK_SHIFT = SIG_LEN + EXP_LEN;
-
- // The bit pattern that keeps only the *significand* part.
- LIBC_INLINE_VAR static constexpr StorageType SIG_MASK =
- mask_trailing_ones<StorageType, SIG_LEN>() << SIG_MASK_SHIFT;
-
-public:
- // The bit pattern that keeps only the *exponent* part.
- LIBC_INLINE_VAR static constexpr StorageType EXP_MASK =
- mask_trailing_ones<StorageType, EXP_LEN>() << EXP_MASK_SHIFT;
- // The bit pattern that keeps only the *sign* part.
- LIBC_INLINE_VAR static constexpr StorageType SIGN_MASK =
- mask_trailing_ones<StorageType, SIGN_LEN>() << SIGN_MASK_SHIFT;
- // The bit pattern that keeps only the *exponent + significand* part.
- LIBC_INLINE_VAR static constexpr StorageType EXP_SIG_MASK =
- mask_trailing_ones<StorageType, EXP_LEN + SIG_LEN>();
- // The bit pattern that keeps only the *sign + exponent + significand* part.
- LIBC_INLINE_VAR static constexpr StorageType FP_MASK =
- mask_trailing_ones<StorageType, TOTAL_LEN>();
-
- static_assert((SIG_MASK & EXP_MASK & SIGN_MASK) == 0, "masks disjoint");
- static_assert((SIG_MASK | EXP_MASK | SIGN_MASK) == FP_MASK, "masks cover");
-
-private:
- LIBC_INLINE static constexpr StorageType bit_at(int position) {
- return StorageType(1) << position;
- }
-
-public:
- // The number of bits after the decimal dot when the number is in normal form.
- LIBC_INLINE_VAR static constexpr int FRACTION_LEN =
- UP::ENCODING == internal::FPEncoding::X86_ExtendedPrecision ? SIG_LEN - 1
- : SIG_LEN;
- LIBC_INLINE_VAR static constexpr uint32_t MANTISSA_PRECISION =
- FRACTION_LEN + 1;
- LIBC_INLINE_VAR static constexpr StorageType FRACTION_MASK =
- mask_trailing_ones<StorageType, FRACTION_LEN>();
-
-protected:
- // If a number x is a NAN, then it is a quiet NAN if:
- // QUIET_NAN_MASK & bits(x) != 0
- LIBC_INLINE_VAR static constexpr StorageType QUIET_NAN_MASK =
- UP::ENCODING == internal::FPEncoding::X86_ExtendedPrecision
- ? bit_at(SIG_LEN - 1) | bit_at(SIG_LEN - 2) // 0b1100...
- : bit_at(SIG_LEN - 1); // 0b1000...
-
- // If a number x is a NAN, then it is a signalling NAN if:
- // SIGNALING_NAN_MASK & bits(x) != 0
- LIBC_INLINE_VAR static constexpr StorageType SIGNALING_NAN_MASK =
- UP::ENCODING == internal::FPEncoding::X86_ExtendedPrecision
- ? bit_at(SIG_LEN - 1) | bit_at(SIG_LEN - 3) // 0b1010...
- : bit_at(SIG_LEN - 2); // 0b0100...
-};
-
-//-----------------------------------------------------------------------------
-template <typename FP> LIBC_INLINE static constexpr FPType get_fp_type() {
- if constexpr (cpp::is_same_v<FP, float> && __FLT_MANT_DIG__ == 24)
- return FPType::IEEE754_Binary32;
- else if constexpr (cpp::is_same_v<FP, double> && __DBL_MANT_DIG__ == 53)
- return FPType::IEEE754_Binary64;
- else if constexpr (cpp::is_same_v<FP, long double>) {
- if constexpr (__LDBL_MANT_DIG__ == 53)
- return FPType::IEEE754_Binary64;
- else if constexpr (__LDBL_MANT_DIG__ == 64)
- return FPType::X86_Binary80;
- else if constexpr (__LDBL_MANT_DIG__ == 113)
- return FPType::IEEE754_Binary128;
- }
-#if defined(LIBC_COMPILER_HAS_C23_FLOAT16)
- else if constexpr (cpp::is_same_v<FP, _Float16>)
- return FPType::IEEE754_Binary16;
-#endif
-#if defined(LIBC_COMPILER_HAS_C23_FLOAT128)
- else if constexpr (cpp::is_same_v<FP, _Float128>)
- return FPType::IEEE754_Binary128;
-#endif
-#if defined(LIBC_COMPILER_HAS_FLOAT128_EXTENSION)
- else if constexpr (cpp::is_same_v<FP, __float128>)
- return FPType::IEEE754_Binary128;
-#endif
- else
- static_assert(cpp::always_false<FP>, "Unsupported type");
-}
-
-template <typename FP>
-struct FloatProperties : public FPProperties<get_fp_type<FP>()> {};
-
-} // namespace fputil
-} // namespace LIBC_NAMESPACE
-
-#endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_FLOATPROPERTIES_H
diff --git a/libc/src/__support/FPUtil/ManipulationFunctions.h b/libc/src/__support/FPUtil/ManipulationFunctions.h
index 8ea753564ed227..a2064594e63a5c 100644
--- a/libc/src/__support/FPUtil/ManipulationFunctions.h
+++ b/libc/src/__support/FPUtil/ManipulationFunctions.h
@@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_MANIPULATIONFUNCTIONS_H
#include "FPBits.h"
-#include "FloatProperties.h"
#include "NearestIntegerOperations.h"
#include "NormalFloat.h"
diff --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h
index f8056fecb8ecc1..561345fd87cfd7 100644
--- a/libc/src/__support/FPUtil/dyadic_float.h
+++ b/libc/src/__support/FPUtil/dyadic_float.h
@@ -10,7 +10,6 @@
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_DYADIC_FLOAT_H
#include "FPBits.h"
-#include "FloatProperties.h"
#include "multiply_add.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/UInt.h"
diff --git a/libc/src/__support/FPUtil/fpbits_str.h b/libc/src/__support/FPUtil/fpbits_str.h
index bab3d5f97a6b35..ce368c89f95ef7 100644
--- a/libc/src/__support/FPUtil/fpbits_str.h
+++ b/libc/src/__support/FPUtil/fpbits_str.h
@@ -12,7 +12,6 @@
#include "src/__support/CPP/string.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/FloatProperties.h"
#include "src/__support/integer_to_string.h"
#include "src/__support/macros/attributes.h"
diff --git a/libc/src/__support/FPUtil/generic/CMakeLists.txt b/libc/src/__support/FPUtil/generic/CMakeLists.txt
index b17f3252104733..0ae62f40dc6163 100644
--- a/libc/src/__support/FPUtil/generic/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/generic/CMakeLists.txt
@@ -23,7 +23,6 @@ add_header_library(
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
libc.src.__support.FPUtil.fenv_impl
- libc.src.__support.FPUtil.float_properties
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.rounding_mode
libc.src.__support.macros.optimization
@@ -39,7 +38,6 @@ add_header_library(
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
libc.src.__support.FPUtil.fenv_impl
- libc.src.__support.FPUtil.float_properties
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.rounding_mode
libc.src.__support.macros.optimization
diff --git a/libc/src/__support/FPUtil/generic/FMA.h b/libc/src/__support/FPUtil/generic/FMA.h
index c70069487d99aa..4ba9e1d2be39e0 100644
--- a/libc/src/__support/FPUtil/generic/FMA.h
+++ b/libc/src/__support/FPUtil/generic/FMA.h
@@ -13,7 +13,6 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/FloatProperties.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/UInt128.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
diff --git a/libc/src/stdio/printf_core/float_dec_converter.h b/libc/src/stdio/printf_core/float_dec_converter.h
index 798bb955cca145..78ce7af3a060ae 100644
--- a/libc/src/stdio/printf_core/float_dec_converter.h
+++ b/libc/src/stdio/printf_core/float_dec_converter.h
@@ -11,7 +11,6 @@
#include "src/__support/CPP/string_view.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/FloatProperties.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/float_to_string.h"
#include "src/__support/integer_to_string.h"
diff --git a/libc/test/src/__support/str_to_fp_test.h b/libc/test/src/__support/str_to_fp_test.h
index 1e7343f865b7d7..ba6d46293cd003 100644
--- a/libc/test/src/__support/str_to_fp_test.h
+++ b/libc/test/src/__support/str_to_fp_test.h
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "src/__support/FPUtil/FloatProperties.h"
+#include "src/__support/FPUtil/FPBits.h"
#include "src/__support/UInt128.h"
#include "src/__support/str_to_float.h"
#include "src/errno/libc_errno.h"
diff --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt
index 416307a20d7d18..d9fa0e31df0e50 100644
--- a/libc/utils/MPFRWrapper/CMakeLists.txt
+++ b/libc/utils/MPFRWrapper/CMakeLists.txt
@@ -12,7 +12,6 @@ if(LIBC_TESTS_CAN_USE_MPFR)
libc.src.__support.CPP.string_view
libc.src.__support.CPP.type_traits
libc.src.__support.FPUtil.fp_bits
- libc.src.__support.FPUtil.float_properties
libc.src.__support.FPUtil.fpbits_str
LibcTest.unit
)
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 6b9400ea453ffd..2a079eeb3a995f 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -11,7 +11,6 @@
#include "src/__support/CPP/string.h"
#include "src/__support/CPP/string_view.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/FloatProperties.h"
#include "src/__support/FPUtil/fpbits_str.h"
#include "test/UnitTest/FPMatcher.h"
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index d4f2c078db79d9..b5238f7686e5f4 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -658,17 +658,6 @@ libc_support_library(
],
)
-libc_support_library(
- name = "__support_fputil_float_properties",
- hdrs = ["src/__support/FPUtil/FloatProperties.h"],
- deps = [
- ":__support_macros_attributes",
- ":__support_macros_properties_float",
- ":__support_math_extras",
- ":__support_uint128",
- ],
-)
-
libc_support_library(
name = "__support_fputil_fp_bits",
hdrs = ["src/__support/FPUtil/FPBits.h"],
@@ -677,8 +666,9 @@ libc_support_library(
":__support_common",
":__support_cpp_bit",
":__support_cpp_type_traits",
- ":__support_fputil_float_properties",
":__support_macros_attributes",
+ ":__support_macros_properties_float",
+ ":__support_math_extras",
":__support_uint128",
],
)
@@ -690,7 +680,6 @@ libc_support_library(
":__support_common",
":__support_cpp_string",
":__support_cpp_type_traits",
- ":__support_fputil_float_properties",
":__support_fputil_fp_bits",
":__support_integer_to_string",
":__support_uint128",
@@ -801,7 +790,6 @@ libc_support_library(
":__support_cpp_bit",
":__support_cpp_type_traits",
":__support_fputil_fenv_impl",
- ":__support_fputil_float_properties",
":__support_fputil_fp_bits",
":__support_fputil_rounding_mode",
":__support_macros_attributes",
@@ -880,7 +868,6 @@ libc_support_library(
hdrs = ["src/__support/FPUtil/dyadic_float.h"],
deps = [
":__support_common",
- ":__support_fputil_float_properties",
":__support_fputil_fp_bits",
":__support_fputil_multiply_add",
":__support_macros_optimization",
@@ -2782,7 +2769,6 @@ libc_support_library(
":__support_cpp_string_view",
":__support_float_to_string",
":__support_fputil_fenv_impl",
- ":__support_fputil_float_properties",
":__support_fputil_fp_bits",
":__support_fputil_rounding_mode",
":__support_integer_to_string",
diff --git a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
index 0c63bdb9633372..cf27001be9dfed 100644
--- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
@@ -139,7 +139,6 @@ def libc_math_function(
":__support_fputil_division_and_remainder_operations",
":__support_fputil_fenv_impl",
":__support_fputil_fp_bits",
- ":__support_fputil_float_properties",
":__support_fputil_hypot",
":__support_fputil_manipulation_functions",
":__support_fputil_nearest_integer_operations",
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
index 11a7b3b7404ff7..22f4d03ee900b6 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/__support/BUILD.bazel
@@ -49,7 +49,7 @@ libc_test(
"str_to_long_double_test.cpp",
],
deps = [
- "//libc:__support_fputil_float_properties",
+ "//libc:__support_fputil_fp_bits",
"//libc:__support_str_to_float",
"//libc:__support_uint128",
],
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl b/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl
index 1dffafdd539495..aba259ba6401a5 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/libc_math_test_rules.bzl
@@ -27,7 +27,6 @@ def math_test(name, hdrs = [], deps = [], **kwargs):
deps = [
"//libc:__support_fputil_basic_operations",
"//libc:__support_fputil_fenv_impl",
- "//libc:__support_fputil_float_properties",
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_manipulation_functions",
"//libc:__support_fputil_nearest_integer_operations",
diff --git a/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel
index 6c8c20e3b9e877..564af38c20e0c6 100644
--- a/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/utils/MPFRWrapper/BUILD.bazel
@@ -44,7 +44,6 @@ libc_support_library(
"//libc:__support_cpp_string",
"//libc:__support_cpp_string_view",
"//libc:__support_cpp_type_traits",
- "//libc:__support_fputil_float_properties",
"//libc:__support_fputil_fp_bits",
"//libc:__support_fputil_fpbits_str",
"//libc/test/UnitTest:fp_test_helpers",
More information about the llvm-commits
mailing list