[libc-commits] [libc] fe41529 - [libc] move builtin_wrappers out of fputil

Michael Jones via libc-commits libc-commits at lists.llvm.org
Thu Sep 1 11:17:10 PDT 2022


Author: Michael Jones
Date: 2022-09-01T11:17:00-07:00
New Revision: fe41529755df946521df64ca9932b58c8eecb52b

URL: https://github.com/llvm/llvm-project/commit/fe41529755df946521df64ca9932b58c8eecb52b
DIFF: https://github.com/llvm/llvm-project/commit/fe41529755df946521df64ca9932b58c8eecb52b.diff

LOG: [libc] move builtin_wrappers out of fputil

builtin_wrappers contains the wrappers for the clz builtins, which do
not depend on anything in fputil. This patch moves the file out of
FPUtil. The location is updated as appropriate.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D133035

Added: 
    libc/src/__support/builtin_wrappers.h

Modified: 
    libc/src/__support/CMakeLists.txt
    libc/src/__support/FPUtil/CMakeLists.txt
    libc/src/__support/FPUtil/FPBits.h
    libc/src/__support/FPUtil/Hypot.h
    libc/src/__support/FPUtil/generic/FMA.h
    libc/src/__support/FPUtil/generic/FMod.h
    libc/src/__support/FPUtil/generic/sqrt.h
    libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
    libc/src/__support/str_to_float.h
    utils/bazel/llvm-project-overlay/libc/BUILD.bazel
    utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl

Removed: 
    libc/src/__support/FPUtil/builtin_wrappers.h


################################################################################
diff  --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index 9f2f1f4a76269..b92872da94922 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -6,6 +6,12 @@ add_header_library(
     blockstore.h
 )
 
+add_header_library(
+  builtin_wrappers
+  HDRS
+    builtin_wrappers.h
+)
+
 add_header_library(
   common
   HDRS
@@ -62,7 +68,7 @@ add_header_library(
     libc.include.errno
     libc.src.__support.CPP.limits
     libc.src.__support.FPUtil.fp_bits
-    libc.src.__support.FPUtil.builtin_wrappers
+    libc.src.__support.builtin_wrappers
     libc.src.errno.errno
 )
 

diff  --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index 9a725f6021ac1..5a66139524a88 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -1,9 +1,3 @@
-add_header_library(
-  builtin_wrappers
-  HDRS
-    builtin_wrappers.h
-)
-
 add_header_library(
   fenv_impl
   HDRS
@@ -37,7 +31,7 @@ add_header_library(
   DEPENDS
     .platform_defs
     .float_properties
-    .builtin_wrappers
+    libc.src.__support.builtin_wrappers
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.type_traits
     libc.src.__support.common
@@ -119,7 +113,7 @@ add_header_library(
     .basic_operations
     .fenv_impl
     .fp_bits
-    .builtin_wrappers
+    libc.src.__support.builtin_wrappers
     libc.src.__support.CPP.bit
     libc.src.__support.CPP.type_traits
     libc.src.__support.uint128

diff  --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index 4833bdb750134..af6891decfb82 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -13,7 +13,7 @@
 
 #include "src/__support/CPP/bit.h"
 #include "src/__support/CPP/type_traits.h"
-#include "src/__support/FPUtil/builtin_wrappers.h"
+#include "src/__support/builtin_wrappers.h"
 #include "src/__support/common.h"
 
 #include "FloatProperties.h"
@@ -183,7 +183,7 @@ template <typename T> struct FPBits {
   inline static constexpr FPBits<T> make_value(UIntType number, int ep) {
     FPBits<T> result;
     // offset: +1 for sign, but -1 for implicit first bit
-    int lz = fputil::unsafe_clz(number) - FloatProp::EXPONENT_WIDTH;
+    int lz = unsafe_clz(number) - FloatProp::EXPONENT_WIDTH;
     number <<= lz;
     ep -= lz;
 

diff  --git a/libc/src/__support/FPUtil/Hypot.h b/libc/src/__support/FPUtil/Hypot.h
index d09f69881796e..077e8db20b03c 100644
--- a/libc/src/__support/FPUtil/Hypot.h
+++ b/libc/src/__support/FPUtil/Hypot.h
@@ -12,10 +12,10 @@
 #include "BasicOperations.h"
 #include "FEnvImpl.h"
 #include "FPBits.h"
-#include "builtin_wrappers.h"
 #include "src/__support/CPP/bit.h"
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/UInt128.h"
+#include "src/__support/builtin_wrappers.h"
 
 namespace __llvm_libc {
 namespace fputil {

diff  --git a/libc/src/__support/FPUtil/generic/FMA.h b/libc/src/__support/FPUtil/generic/FMA.h
index 2ceb4231b77e2..da730992fce8f 100644
--- a/libc/src/__support/FPUtil/generic/FMA.h
+++ b/libc/src/__support/FPUtil/generic/FMA.h
@@ -13,8 +13,8 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/FloatProperties.h"
-#include "src/__support/FPUtil/builtin_wrappers.h"
 #include "src/__support/UInt128.h"
+#include "src/__support/builtin_wrappers.h"
 #include "src/__support/common.h"
 
 namespace __llvm_libc {

diff  --git a/libc/src/__support/FPUtil/generic/FMod.h b/libc/src/__support/FPUtil/generic/FMod.h
index a922253e46b04..836238210e6bf 100644
--- a/libc/src/__support/FPUtil/generic/FMod.h
+++ b/libc/src/__support/FPUtil/generic/FMod.h
@@ -13,7 +13,7 @@
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/builtin_wrappers.h"
+#include "src/__support/builtin_wrappers.h"
 #include "src/__support/common.h"
 #include "src/math/generic/math_utils.h"
 

diff  --git a/libc/src/__support/FPUtil/generic/sqrt.h b/libc/src/__support/FPUtil/generic/sqrt.h
index f4c81f0a97394..a6c1e649672f0 100644
--- a/libc/src/__support/FPUtil/generic/sqrt.h
+++ b/libc/src/__support/FPUtil/generic/sqrt.h
@@ -15,8 +15,8 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/PlatformDefs.h"
-#include "src/__support/FPUtil/builtin_wrappers.h"
 #include "src/__support/UInt128.h"
+#include "src/__support/builtin_wrappers.h"
 
 namespace __llvm_libc {
 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 0835b08682906..2943c7d54a138 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
@@ -12,8 +12,8 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/PlatformDefs.h"
-#include "src/__support/FPUtil/builtin_wrappers.h"
 #include "src/__support/UInt128.h"
+#include "src/__support/builtin_wrappers.h"
 
 namespace __llvm_libc {
 namespace fputil {

diff  --git a/libc/src/__support/FPUtil/builtin_wrappers.h b/libc/src/__support/builtin_wrappers.h
similarity index 90%
rename from libc/src/__support/FPUtil/builtin_wrappers.h
rename to libc/src/__support/builtin_wrappers.h
index fc524d24d6238..d30feb92f97b9 100644
--- a/libc/src/__support/FPUtil/builtin_wrappers.h
+++ b/libc/src/__support/builtin_wrappers.h
@@ -7,11 +7,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_BUILTIN_WRAPPERS_H
-#define LLVM_LIBC_SRC_SUPPORT_FPUTIL_BUILTIN_WRAPPERS_H
+#ifndef LLVM_LIBC_SRC_SUPPORT_BUILTIN_WRAPPERS_H
+#define LLVM_LIBC_SRC_SUPPORT_BUILTIN_WRAPPERS_H
 
 namespace __llvm_libc {
-namespace fputil {
 
 // The following overloads are matched based on what is accepted by
 // __builtin_clz/ctz* rather than using the exactly-sized aliases from stdint.h.
@@ -65,7 +64,6 @@ template <typename T> static inline int unsafe_clz(T val) {
   return __internal::clz(val);
 }
 
-} // namespace fputil
 } // namespace __llvm_libc
 
-#endif // LLVM_LIBC_SRC_SUPPORT_FPUTIL_BUILTIN_WRAPPERS_H
+#endif // LLVM_LIBC_SRC_SUPPORT_BUILTIN_WRAPPERS_H

diff  --git a/libc/src/__support/str_to_float.h b/libc/src/__support/str_to_float.h
index 87262dabb309d..4f952bcb54e1e 100644
--- a/libc/src/__support/str_to_float.h
+++ b/libc/src/__support/str_to_float.h
@@ -11,8 +11,8 @@
 
 #include "src/__support/CPP/limits.h"
 #include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/builtin_wrappers.h"
 #include "src/__support/UInt128.h"
+#include "src/__support/builtin_wrappers.h"
 #include "src/__support/ctype_utils.h"
 #include "src/__support/detailed_powers_of_ten.h"
 #include "src/__support/high_precision_decimal.h"
@@ -52,11 +52,11 @@ template <class T> uint32_t inline leading_zeroes(T inputNumber) {
 }
 
 template <> uint32_t inline leading_zeroes<uint32_t>(uint32_t inputNumber) {
-  return fputil::safe_clz(inputNumber);
+  return safe_clz(inputNumber);
 }
 
 template <> uint32_t inline leading_zeroes<uint64_t>(uint64_t inputNumber) {
-  return fputil::safe_clz(inputNumber);
+  return safe_clz(inputNumber);
 }
 
 static inline uint64_t low64(const UInt128 &num) {

diff  --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 1f383c917ce88..0791a67230e63 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -168,8 +168,8 @@ cc_library(
 )
 
 cc_library(
-    name = "__support_fputil_builtin_wrappers",
-    hdrs = ["src/__support/FPUtil/builtin_wrappers.h"],
+    name = "__support_builtin_wrappers",
+    hdrs = ["src/__support/builtin_wrappers.h"],
     deps = [
         ":libc_root",
     ],
@@ -224,10 +224,10 @@ cc_library(
     hdrs = ["src/__support/FPUtil/FPBits.h"],
     textual_hdrs = ["src/__support/FPUtil/x86_64/LongDoubleBits.h"],
     deps = [
+        ":__support_builtin_wrappers",
         ":__support_common",
         ":__support_cpp_bit",
         ":__support_cpp_type_traits",
-        ":__support_fputil_builtin_wrappers",
         ":__support_fputil_float_properties",
         ":__support_fputil_platform_defs",
         ":libc_root",
@@ -238,10 +238,10 @@ cc_library(
     name = "__support_fputil_hypot",
     hdrs = ["src/__support/FPUtil/Hypot.h"],
     deps = [
+        ":__support_builtin_wrappers",
         ":__support_cpp_bit",
         ":__support_cpp_type_traits",
         ":__support_fputil_basic_operations",
-        ":__support_fputil_builtin_wrappers",
         ":__support_fputil_fenv_impl",
         ":__support_fputil_fp_bits",
         ":__support_uint128",
@@ -314,10 +314,10 @@ cc_library(
     name = "__support_fputil_sqrt",
     hdrs = sqrt_hdrs,
     deps = [
+        ":__support_builtin_wrappers",
         ":__support_common",
         ":__support_cpp_bit",
         ":__support_cpp_type_traits",
-        ":__support_fputil_builtin_wrappers",
         ":__support_fputil_fenv_impl",
         ":__support_fputil_fp_bits",
         ":__support_fputil_platform_defs",
@@ -343,10 +343,10 @@ cc_library(
     # doesn't support FMA, so they can't be compiled on their own.
     textual_hdrs = fma_platform_hdrs,
     deps = [
+        ":__support_builtin_wrappers",
         ":__support_common",
         ":__support_cpp_bit",
         ":__support_cpp_type_traits",
-        ":__support_fputil_builtin_wrappers",
         ":__support_fputil_fenv_impl",
         ":__support_fputil_float_properties",
         ":__support_fputil_fp_bits",

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 6943b83fa9432..4f09aaf644ab9 100644
--- a/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
+++ b/utils/bazel/llvm-project-overlay/libc/libc_build_rules.bzl
@@ -92,7 +92,7 @@ def libc_math_function(
         ":__support_fputil_nearest_integer_operations",
         ":__support_fputil_normal_float",
         ":__support_fputil_platform_defs",
-        ":__support_fputil_builtin_wrappers",
+        ":__support_builtin_wrappers",
         ":__support_fputil_except_value_utils",
     ]
     libc_function(


        


More information about the libc-commits mailing list