-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc] Make str_to_float independent of fenv #102369
[libc] Make str_to_float independent of fenv #102369
Conversation
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.
@llvm/pr-subscribers-libc Author: Michael Jones (michaelrj-google) ChangesThe str_to_float conversion code doesn't need the features provided by Full diff: https://github.com/llvm/llvm-project/pull/102369.diff 3 Files Affected:
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",
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with 1 nit.
@michaelrj-google this PR broke rv32 compilation: https://lab.llvm.org/staging/#/builders/196/builds/471/steps/8/logs/stdio |
I'm looking into the rv32 issue |
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.
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.
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.