[libc-commits] [libc] [llvm] [libc] Make str_to_float independent of fenv (PR #102369)
via libc-commits
libc-commits at lists.llvm.org
Wed Aug 7 14:20:20 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Michael Jones (michaelrj-google)
<details>
<summary>Changes</summary>
The str_to_float conversion code doesn't need the features provided by
fenv and the dependency is creating a blocker for hand-in-hand. This
patch uses a workaround to remove this dependency.
---
Full diff: https://github.com/llvm/llvm-project/pull/102369.diff
3 Files Affected:
- (modified) libc/src/__support/CMakeLists.txt (-2)
- (modified) libc/src/__support/str_to_float.h (+9-6)
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (-2)
``````````diff
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index d8a192f1ffa570..9bd1e29081a801 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -190,8 +190,6 @@ add_header_library(
libc.src.__support.CPP.bit
libc.src.__support.CPP.limits
libc.src.__support.CPP.optional
- libc.src.__support.FPUtil.dyadic_float
- libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.rounding_mode
libc.src.errno.errno
diff --git a/libc/src/__support/str_to_float.h b/libc/src/__support/str_to_float.h
index c72bc1f957dc37..ade08f78a11dcc 100644
--- a/libc/src/__support/str_to_float.h
+++ b/libc/src/__support/str_to_float.h
@@ -13,9 +13,7 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/string_view.h"
-#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/dyadic_float.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/common.h"
#include "src/__support/ctype_utils.h"
@@ -27,6 +25,8 @@
#include "src/__support/uint128.h"
#include "src/errno/libc_errno.h" // For ERANGE
+#include <stdint.h>
+
namespace LIBC_NAMESPACE_DECL {
namespace internal {
@@ -525,10 +525,13 @@ clinger_fast_path(ExpandedFloat<T> init_num,
FPBits result;
T float_mantissa;
if constexpr (cpp::is_same_v<StorageType, UInt<128>>) {
- float_mantissa = static_cast<T>(fputil::DyadicFloat<128>(
- Sign::POS, 0,
- fputil::DyadicFloat<128>::MantissaType(
- {uint64_t(mantissa), uint64_t(mantissa >> 64)})));
+ // float_mantissa = static_cast<T>(fputil::DyadicFloat<128>(
+ // Sign::POS, 0,
+ // fputil::DyadicFloat<128>::MantissaType(
+ // {uint64_t(mantissa), uint64_t(mantissa >> 64)})));
+ float_mantissa = (static_cast<T>(uint64_t(mantissa)) *
+ static_cast<T>(1ull << 32) * static_cast<T>(1ull << 32)) +
+ static_cast<T>(uint64_t(mantissa >> 64));
} else {
float_mantissa = static_cast<T>(mantissa);
}
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 253b89216a88fa..0eac44d72cfece 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -658,8 +658,6 @@ libc_support_library(
":__support_cpp_optional",
":__support_cpp_string_view",
":__support_ctype_utils",
- ":__support_fputil_dyadic_float",
- ":__support_fputil_fenv_impl",
":__support_fputil_fp_bits",
":__support_fputil_rounding_mode",
":__support_str_to_integer",
``````````
</details>
https://github.com/llvm/llvm-project/pull/102369
More information about the libc-commits
mailing list