[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
This commit is contained in:
Michael Jones 2022-08-31 11:14:27 -07:00
parent 8d95fd7e56
commit fe41529755
12 changed files with 29 additions and 31 deletions

View File

@ -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
)

View File

@ -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

View File

@ -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;

View File

@ -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 {

View File

@ -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 {

View File

@ -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"

View File

@ -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 {

View File

@ -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 {

View File

@ -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

View File

@ -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) {

View File

@ -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",

View File

@ -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(