[libc-commits] [libc] [llvm] [NFC] rename builtin_wrapper into math_extras (PR #72998)
Guillaume Chatelet via libc-commits
libc-commits at lists.llvm.org
Tue Nov 21 06:42:52 PST 2023
https://github.com/gchatelet created https://github.com/llvm/llvm-project/pull/72998
`builtin_wrapper.h` contains mostly math related things and is not really about
builtins anymore. Renaming it to `math_extras.h` to mimic what is done in LLVM.
`math_extras.h` will receive all small functions related to math and bit manip.
>From d95fb62af71ee2232c3019577822aee6c5a695a4 Mon Sep 17 00:00:00 2001
From: Guillaume Chatelet <gchatelet at google.com>
Date: Tue, 21 Nov 2023 14:38:32 +0000
Subject: [PATCH] [libc][NFC] Rename builtin_wrappers.h into math_extras.h to
mimic llvm.
---
libc/src/__support/CMakeLists.txt | 20 +++++++++----------
libc/src/__support/FPUtil/CMakeLists.txt | 10 +++++-----
libc/src/__support/FPUtil/FPBits.h | 2 +-
libc/src/__support/FPUtil/Hypot.h | 2 +-
.../__support/FPUtil/generic/CMakeLists.txt | 10 +++++-----
libc/src/__support/FPUtil/generic/FMA.h | 2 +-
libc/src/__support/FPUtil/generic/FMod.h | 2 +-
libc/src/__support/FPUtil/generic/sqrt.h | 2 +-
.../FPUtil/generic/sqrt_80_bit_long_double.h | 2 +-
libc/src/__support/UInt.h | 2 +-
libc/src/__support/integer_utils.h | 2 +-
.../{builtin_wrappers.h => math_extras.h} | 10 +++++-----
libc/src/__support/str_to_float.h | 2 +-
libc/src/math/generic/CMakeLists.txt | 10 +++++-----
libc/src/math/generic/powf.cpp | 2 +-
.../llvm-project-overlay/libc/BUILD.bazel | 20 +++++++++----------
.../libc/libc_build_rules.bzl | 2 +-
.../test/src/math/libc_math_test_rules.bzl | 2 +-
18 files changed, 52 insertions(+), 52 deletions(-)
rename libc/src/__support/{builtin_wrappers.h => math_extras.h} (96%)
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index 35b724b3e3df9a4..fa9c7d5dd9a9aa3 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -27,9 +27,9 @@ add_header_library(
)
add_header_library(
- builtin_wrappers
+ math_extras
HDRS
- builtin_wrappers.h
+ math_extras.h
DEPENDS
.named_pair
libc.src.__support.CPP.type_traits
@@ -131,14 +131,14 @@ add_header_library(
.str_to_integer
.str_to_num_result
.uint128
- libc.src.__support.CPP.optional
+ libc.src.__support.common
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.__support.FPUtil.dyadic_float
- libc.src.__support.builtin_wrappers
- libc.src.__support.common
+ libc.src.__support.math_extras
libc.src.errno.errno
)
@@ -187,10 +187,10 @@ add_header_library(
HDRS
integer_utils.h
DEPENDS
- .builtin_wrappers
+ .math_extras
.number_pair
- libc.src.__support.CPP.type_traits
libc.src.__support.common
+ libc.src.__support.CPP.type_traits
)
add_header_library(
@@ -198,9 +198,9 @@ add_header_library(
HDRS
UInt.h
DEPENDS
- .builtin_wrappers
- .number_pair
.integer_utils
+ .math_extras
+ .number_pair
libc.src.__support.CPP.array
libc.src.__support.CPP.type_traits
libc.src.__support.macros.optimization
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index 4025c2a5d19a53f..2ea0e6936325a4b 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -45,12 +45,12 @@ add_header_library(
HDRS
FPBits.h
DEPENDS
- .platform_defs
.float_properties
- libc.src.__support.builtin_wrappers
+ .platform_defs
+ libc.src.__support.common
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
- libc.src.__support.common
+ libc.src.__support.math_extras
)
add_header_library(
@@ -153,10 +153,10 @@ add_header_library(
.fenv_impl
.fp_bits
.rounding_mode
- libc.src.__support.builtin_wrappers
+ libc.src.__support.common
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
- libc.src.__support.common
+ libc.src.__support.math_extras
libc.src.__support.uint128
)
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index 37e9bc9cfc84c3a..9f1d31aac4ea81e 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -13,8 +13,8 @@
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/builtin_wrappers.h"
#include "src/__support/common.h"
+#include "src/__support/math_extras.h"
#include "FloatProperties.h"
#include <stdint.h>
diff --git a/libc/src/__support/FPUtil/Hypot.h b/libc/src/__support/FPUtil/Hypot.h
index 357d9a6e99c7457..f30753ae9d1716d 100644
--- a/libc/src/__support/FPUtil/Hypot.h
+++ b/libc/src/__support/FPUtil/Hypot.h
@@ -16,8 +16,8 @@
#include "src/__support/CPP/bit.h"
#include "src/__support/CPP/type_traits.h"
#include "src/__support/UInt128.h"
-#include "src/__support/builtin_wrappers.h"
#include "src/__support/common.h"
+#include "src/__support/math_extras.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/libc/src/__support/FPUtil/generic/CMakeLists.txt b/libc/src/__support/FPUtil/generic/CMakeLists.txt
index 7f986d05adedf92..07b42ecdff46cdd 100644
--- a/libc/src/__support/FPUtil/generic/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/generic/CMakeLists.txt
@@ -4,16 +4,16 @@ add_header_library(
sqrt.h
sqrt_80_bit_long_double.h
DEPENDS
+ libc.include.fenv
+ libc.src.__support.common
libc.src.__support.CPP.bit
libc.src.__support.CPP.type_traits
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.platform_defs
libc.src.__support.FPUtil.rounding_mode
- libc.src.__support.builtin_wrappers
- libc.src.__support.common
+ libc.src.__support.math_extras
libc.src.__support.uint128
- libc.include.fenv
)
add_header_library(
@@ -27,8 +27,8 @@ add_header_library(
libc.src.__support.FPUtil.float_properties
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.rounding_mode
- libc.src.__support.builtin_wrappers
libc.src.__support.macros.optimization
+ libc.src.__support.math_extras
libc.src.__support.uint128
)
@@ -43,7 +43,7 @@ add_header_library(
libc.src.__support.FPUtil.float_properties
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.rounding_mode
- libc.src.__support.builtin_wrappers
libc.src.__support.macros.optimization
+ libc.src.__support.math_extras
libc.src.math.generic.math_utils
)
diff --git a/libc/src/__support/FPUtil/generic/FMA.h b/libc/src/__support/FPUtil/generic/FMA.h
index b90b134926bb649..e60bb783798541a 100644
--- a/libc/src/__support/FPUtil/generic/FMA.h
+++ b/libc/src/__support/FPUtil/generic/FMA.h
@@ -15,9 +15,9 @@
#include "src/__support/FPUtil/FloatProperties.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/UInt128.h"
-#include "src/__support/builtin_wrappers.h"
#include "src/__support/macros/attributes.h" // LIBC_INLINE
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/math_extras.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/libc/src/__support/FPUtil/generic/FMod.h b/libc/src/__support/FPUtil/generic/FMod.h
index ff320f36ee2277b..f5e022e4a826af4 100644
--- a/libc/src/__support/FPUtil/generic/FMod.h
+++ b/libc/src/__support/FPUtil/generic/FMod.h
@@ -13,8 +13,8 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/builtin_wrappers.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/math_extras.h"
#include "src/math/generic/math_utils.h"
namespace LIBC_NAMESPACE {
diff --git a/libc/src/__support/FPUtil/generic/sqrt.h b/libc/src/__support/FPUtil/generic/sqrt.h
index 7d446d3a5ffb135..1d33f927ebb671b 100644
--- a/libc/src/__support/FPUtil/generic/sqrt.h
+++ b/libc/src/__support/FPUtil/generic/sqrt.h
@@ -17,8 +17,8 @@
#include "src/__support/FPUtil/PlatformDefs.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/UInt128.h"
-#include "src/__support/builtin_wrappers.h"
#include "src/__support/common.h"
+#include "src/__support/math_extras.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
index 685a90dba7c704b..811a6b522318650 100644
--- a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
+++ b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
@@ -14,8 +14,8 @@
#include "src/__support/FPUtil/PlatformDefs.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/UInt128.h"
-#include "src/__support/builtin_wrappers.h"
#include "src/__support/common.h"
+#include "src/__support/math_extras.h"
namespace LIBC_NAMESPACE {
namespace fputil {
diff --git a/libc/src/__support/UInt.h b/libc/src/__support/UInt.h
index 9aeb239b8328bea..b41b839332d2d92 100644
--- a/libc/src/__support/UInt.h
+++ b/libc/src/__support/UInt.h
@@ -13,9 +13,9 @@
#include "src/__support/CPP/limits.h"
#include "src/__support/CPP/optional.h"
#include "src/__support/CPP/type_traits.h"
-#include "src/__support/builtin_wrappers.h"
#include "src/__support/integer_utils.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/math_extras.h"
#include "src/__support/number_pair.h"
#include <stddef.h> // For size_t
diff --git a/libc/src/__support/integer_utils.h b/libc/src/__support/integer_utils.h
index 7b62cb0d9f50593..1d9a134934cc556 100644
--- a/libc/src/__support/integer_utils.h
+++ b/libc/src/__support/integer_utils.h
@@ -12,7 +12,7 @@
#include "src/__support/CPP/type_traits.h"
#include "src/__support/common.h"
-#include "builtin_wrappers.h"
+#include "math_extras.h"
#include "number_pair.h"
#include <stdint.h>
diff --git a/libc/src/__support/builtin_wrappers.h b/libc/src/__support/math_extras.h
similarity index 96%
rename from libc/src/__support/builtin_wrappers.h
rename to libc/src/__support/math_extras.h
index bd307a3544cd930..751f166a4f4e7d0 100644
--- a/libc/src/__support/builtin_wrappers.h
+++ b/libc/src/__support/math_extras.h
@@ -1,5 +1,5 @@
-//===--Convenient template for builtins -------------------------*- C++ -*-===//
-// (Count Lead Zeroes) and (Count Trailing Zeros)
+//===-- Mimics llvm/Support/MathExtras.h ------------------------*- C++ -*-===//
+// Provides useful math and bit functions.
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBC_SRC___SUPPORT_BUILTIN_WRAPPERS_H
-#define LLVM_LIBC_SRC___SUPPORT_BUILTIN_WRAPPERS_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H
#include "named_pair.h"
#include "src/__support/CPP/type_traits.h"
@@ -223,4 +223,4 @@ sub_with_borrow<unsigned long long>(unsigned long long a, unsigned long long b,
} // namespace LIBC_NAMESPACE
-#endif // LLVM_LIBC_SRC___SUPPORT_BUILTIN_WRAPPERS_H
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H
diff --git a/libc/src/__support/str_to_float.h b/libc/src/__support/str_to_float.h
index e827e3322fac11f..d96204f373fbb6f 100644
--- a/libc/src/__support/str_to_float.h
+++ b/libc/src/__support/str_to_float.h
@@ -16,11 +16,11 @@
#include "src/__support/FPUtil/dyadic_float.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/UInt128.h"
-#include "src/__support/builtin_wrappers.h"
#include "src/__support/common.h"
#include "src/__support/ctype_utils.h"
#include "src/__support/detailed_powers_of_ten.h"
#include "src/__support/high_precision_decimal.h"
+#include "src/__support/math_extras.h"
#include "src/__support/str_to_integer.h"
#include "src/__support/str_to_num_result.h"
#include "src/errno/libc_errno.h" // For ERANGE
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 413ac049a22b840..ac39ad383c6b695 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -775,10 +775,11 @@ add_entrypoint_object(
../powf.h
DEPENDS
.common_constants
- .explogxf
- .exp2f_impl
.exp10f_impl
- libc.src.__support.builtin_wrappers
+ .exp2f_impl
+ .explogxf
+ libc.include.errno
+ libc.include.math
libc.src.__support.CPP.bit
libc.src.__support.CPP.optional
libc.src.__support.FPUtil.fenv_impl
@@ -790,9 +791,8 @@ add_entrypoint_object(
libc.src.__support.FPUtil.sqrt
libc.src.__support.FPUtil.triple_double
libc.src.__support.macros.optimization
- libc.include.errno
+ libc.src.__support.math_extras
libc.src.errno.errno
- libc.include.math
COMPILE_OPTIONS
-O3
)
diff --git a/libc/src/math/generic/powf.cpp b/libc/src/math/generic/powf.cpp
index 891b09c69baed6d..b56022f61c5566b 100644
--- a/libc/src/math/generic/powf.cpp
+++ b/libc/src/math/generic/powf.cpp
@@ -18,9 +18,9 @@
#include "src/__support/FPUtil/nearest_integer.h"
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/FPUtil/sqrt.h" // Speedup for powf(x, 1/2) = sqrtf(x)
-#include "src/__support/builtin_wrappers.h"
#include "src/__support/common.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/math_extras.h"
#include "exp10f_impl.h" // Speedup for powf(10, y) = exp10f(y)
#include "exp2f_impl.h" // Speedup for powf(2, y) = exp2f(y)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index c89c1f7950b974e..cfc00e0ef64eab2 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -394,7 +394,7 @@ libc_support_library(
name = "__support_integer_utils",
hdrs = ["src/__support/integer_utils.h"],
deps = [
- ":__support_builtin_wrappers",
+ ":__support_math_extras",
":__support_common",
":__support_cpp_type_traits",
":__support_number_pair",
@@ -405,7 +405,7 @@ libc_support_library(
name = "__support_uint",
hdrs = ["src/__support/UInt.h"],
deps = [
- ":__support_builtin_wrappers",
+ ":__support_math_extras",
":__support_cpp_array",
":__support_cpp_limits",
":__support_cpp_optional",
@@ -491,7 +491,7 @@ libc_support_library(
"src/__support/str_to_float.h",
],
deps = [
- ":__support_builtin_wrappers",
+ ":__support_math_extras",
":__support_common",
":__support_cpp_limits",
":__support_cpp_optional",
@@ -547,8 +547,8 @@ libc_support_library(
)
libc_support_library(
- name = "__support_builtin_wrappers",
- hdrs = ["src/__support/builtin_wrappers.h"],
+ name = "__support_math_extras",
+ hdrs = ["src/__support/math_extras.h"],
deps = [
":__support_cpp_type_traits",
":__support_macros_attributes",
@@ -561,7 +561,7 @@ libc_support_library(
name = "__support_fputil_generic_fmod",
hdrs = ["src/__support/FPUtil/generic/FMod.h"],
deps = [
- ":__support_builtin_wrappers",
+ ":__support_math_extras",
":__support_common",
":__support_cpp_limits",
":__support_cpp_type_traits",
@@ -633,7 +633,7 @@ libc_support_library(
hdrs = ["src/__support/FPUtil/FPBits.h"],
textual_hdrs = ["src/__support/FPUtil/x86_64/LongDoubleBits.h"],
deps = [
- ":__support_builtin_wrappers",
+ ":__support_math_extras",
":__support_common",
":__support_cpp_bit",
":__support_cpp_type_traits",
@@ -662,7 +662,7 @@ libc_support_library(
name = "__support_fputil_hypot",
hdrs = ["src/__support/FPUtil/Hypot.h"],
deps = [
- ":__support_builtin_wrappers",
+ ":__support_math_extras",
":__support_common",
":__support_cpp_bit",
":__support_cpp_type_traits",
@@ -741,7 +741,7 @@ libc_support_library(
name = "__support_fputil_sqrt",
hdrs = sqrt_hdrs,
deps = [
- ":__support_builtin_wrappers",
+ ":__support_math_extras",
":__support_common",
":__support_cpp_bit",
":__support_cpp_type_traits",
@@ -770,7 +770,7 @@ libc_support_library(
# doesn't support FMA, so they can't be compiled on their own.
textual_hdrs = fma_platform_hdrs,
deps = [
- ":__support_builtin_wrappers",
+ ":__support_math_extras",
":__support_cpp_bit",
":__support_cpp_type_traits",
":__support_fputil_fenv_impl",
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 1abda0deb7d6461..d93f089ac9ed357 100644
--- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
@@ -145,7 +145,7 @@ def libc_math_function(
":__support_fputil_nearest_integer_operations",
":__support_fputil_normal_float",
":__support_fputil_platform_defs",
- ":__support_builtin_wrappers",
+ ":__support_math_extras",
":__support_fputil_except_value_utils",
]
libc_function(
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 2d759b5ec0f7c59..2a756788feb07bd 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
@@ -25,7 +25,7 @@ def math_test(name, hdrs = [], deps = [], **kwargs):
srcs = [test_name + ".cpp"] + hdrs,
libc_function_deps = ["//libc:func_name".replace("func_name", name)],
deps = [
- "//libc:__support_builtin_wrappers",
+ "//libc:__support_math_extras",
"//libc:__support_fputil_basic_operations",
"//libc:__support_fputil_fenv_impl",
"//libc:__support_fputil_float_properties",
More information about the libc-commits
mailing list