Skip to content

Commit d851b5c

Browse files
[libc] Make str_to_float independent of fenv (#102369)
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.
1 parent d0fe470 commit d851b5c

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

libc/src/__support/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ add_header_library(
190190
libc.src.__support.CPP.bit
191191
libc.src.__support.CPP.limits
192192
libc.src.__support.CPP.optional
193-
libc.src.__support.FPUtil.dyadic_float
194-
libc.src.__support.FPUtil.fenv_impl
195193
libc.src.__support.FPUtil.fp_bits
196194
libc.src.__support.FPUtil.rounding_mode
197195
libc.src.errno.errno

libc/src/__support/str_to_float.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
#include "src/__support/CPP/limits.h"
1414
#include "src/__support/CPP/optional.h"
1515
#include "src/__support/CPP/string_view.h"
16-
#include "src/__support/FPUtil/FEnvImpl.h"
1716
#include "src/__support/FPUtil/FPBits.h"
18-
#include "src/__support/FPUtil/dyadic_float.h"
1917
#include "src/__support/FPUtil/rounding_mode.h"
2018
#include "src/__support/common.h"
2119
#include "src/__support/ctype_utils.h"
@@ -27,6 +25,8 @@
2725
#include "src/__support/uint128.h"
2826
#include "src/errno/libc_errno.h" // For ERANGE
2927

28+
#include <stdint.h>
29+
3030
namespace LIBC_NAMESPACE_DECL {
3131
namespace internal {
3232

@@ -525,10 +525,9 @@ clinger_fast_path(ExpandedFloat<T> init_num,
525525
FPBits result;
526526
T float_mantissa;
527527
if constexpr (cpp::is_same_v<StorageType, UInt<128>>) {
528-
float_mantissa = static_cast<T>(fputil::DyadicFloat<128>(
529-
Sign::POS, 0,
530-
fputil::DyadicFloat<128>::MantissaType(
531-
{uint64_t(mantissa), uint64_t(mantissa >> 64)})));
528+
float_mantissa =
529+
(static_cast<T>(uint64_t(mantissa)) * static_cast<T>(0x1.0p64)) +
530+
static_cast<T>(uint64_t(mantissa >> 64));
532531
} else {
533532
float_mantissa = static_cast<T>(mantissa);
534533
}

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,6 @@ libc_support_library(
664664
":__support_cpp_optional",
665665
":__support_cpp_string_view",
666666
":__support_ctype_utils",
667-
":__support_fputil_dyadic_float",
668-
":__support_fputil_fenv_impl",
669667
":__support_fputil_fp_bits",
670668
":__support_fputil_rounding_mode",
671669
":__support_str_to_integer",

0 commit comments

Comments
 (0)