[libc] Move likely/unlikely to the optimization header
authorGuillaume Chatelet <gchatelet@google.com>
Fri, 10 Feb 2023 15:15:10 +0000 (15:15 +0000)
committerGuillaume Chatelet <gchatelet@google.com>
Fri, 10 Feb 2023 15:31:28 +0000 (15:31 +0000)
41 files changed:
libc/src/__support/FPUtil/FMA.h
libc/src/__support/FPUtil/ManipulationFunctions.h
libc/src/__support/FPUtil/aarch64/FMA.h
libc/src/__support/FPUtil/dyadic_float.h
libc/src/__support/FPUtil/except_value_utils.h
libc/src/__support/FPUtil/generic/FMA.h
libc/src/__support/FPUtil/generic/FMod.h
libc/src/__support/FPUtil/multiply_add.h
libc/src/__support/FPUtil/nearest_integer.h
libc/src/__support/FPUtil/x86_64/FMA.h
libc/src/__support/UInt.h
libc/src/__support/macros/attributes.h
libc/src/__support/macros/config.h
libc/src/__support/macros/optimization.h
libc/src/math/generic/acosf.cpp
libc/src/math/generic/acoshf.cpp
libc/src/math/generic/asinf.cpp
libc/src/math/generic/asinhf.cpp
libc/src/math/generic/atanf.cpp
libc/src/math/generic/atanhf.cpp
libc/src/math/generic/cosf.cpp
libc/src/math/generic/coshf.cpp
libc/src/math/generic/exp10f.cpp
libc/src/math/generic/exp2f.cpp
libc/src/math/generic/expf.cpp
libc/src/math/generic/expm1f.cpp
libc/src/math/generic/log10.cpp
libc/src/math/generic/sincosf.cpp
libc/src/math/generic/sincosf_utils.h
libc/src/math/generic/sinf.cpp
libc/src/math/generic/sinhf.cpp
libc/src/math/generic/tanf.cpp
libc/src/math/generic/tanhf.cpp
libc/src/string/memory_utils/bcmp_implementations.h
libc/src/string/memory_utils/memcmp_implementations.h
libc/src/string/memory_utils/memcpy_implementations.h
libc/src/string/memory_utils/op_generic.h
libc/src/string/string_utils.h
libc/test/src/math/exp2f_test.cpp
utils/bazel/llvm-project-overlay/libc/BUILD.bazel
utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel

index 0416dd4be64bc91218c05fd7d84a96858821247b..05df9cb52668b6245fa8b76cc9bd4a18eaaebe38 100644 (file)
@@ -9,9 +9,8 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_FMA_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_FMA_H
 
-#include "src/__support/common.h"
 #include "src/__support/macros/properties/architectures.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #if defined(LIBC_TARGET_CPU_HAS_FMA)
 
index 61909cf7e1375ff807bbaa41adc59f119405f543..27d91c433ac5b006323cbb47164155d0f874ff49 100644 (file)
@@ -16,8 +16,8 @@
 
 #include "src/__support/CPP/bit.h"
 #include "src/__support/CPP/type_traits.h"
-#include "src/__support/common.h"
 #include "src/__support/macros/attributes.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <limits.h>
 #include <math.h>
index 1ee37650d53172abf84b87da5c90af4ddc8a3022..5f80ed737ef278dfef5cab21399267531c4aba9f 100644 (file)
@@ -10,7 +10,7 @@
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_AARCH64_FMA_H
 
 #include "src/__support/macros/properties/architectures.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #if !defined(LIBC_TARGET_ARCH_IS_AARCH64)
 #error "Invalid include"
index 448fc9384149e9072e3e7a8e75fe3fa5ce03f1de..86c41df18bc6f03d7961c8553d6381f9cb457544 100644 (file)
@@ -14,6 +14,7 @@
 #include "multiply_add.h"
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/UInt.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <stddef.h>
 
index 3d681a785c0d06af395cd1bd529d33af4e51e0fb..9f9f0296c4279193e445bedeef3e3010a399f681 100644 (file)
@@ -12,6 +12,7 @@
 #include "FEnvImpl.h"
 #include "FPBits.h"
 #include "src/__support/CPP/optional.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 namespace __llvm_libc {
 
index 591d45dde05d1edc3446d603924783a208ba4378..2af91c12898720e4c3ecebb9c08b448bdbce5b52 100644 (file)
@@ -15,7 +15,8 @@
 #include "src/__support/FPUtil/FloatProperties.h"
 #include "src/__support/UInt128.h"
 #include "src/__support/builtin_wrappers.h"
-#include "src/__support/common.h"
+#include "src/__support/macros/attributes.h"   // LIBC_INLINE
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 namespace __llvm_libc {
 namespace fputil {
index 0ed85a4a92a3861fcbeba9b9e3ff10db815395da..1879c0ad2c5104dacab8e7dfd48ae596cb1e9113 100644 (file)
@@ -14,7 +14,7 @@
 #include "src/__support/FPUtil/FEnvImpl.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/builtin_wrappers.h"
-#include "src/__support/common.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/math/generic/math_utils.h"
 
 namespace __llvm_libc {
index 2aaa2c60465b5af8c97aa930144de873dd5b6e96..2829ebb6d0047f5e29582a57021f42cdc1674d09 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "src/__support/common.h"
 #include "src/__support/macros/properties/architectures.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 namespace __llvm_libc {
 namespace fputil {
index 3d42632bd7ca776fe981a0df1ad247cd541199e7..6d5b8bfbee791a1c313f67c564e87dff545f8ae4 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_NEAREST_INTEGER_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_NEAREST_INTEGER_H
 
-#include "src/__support/common.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/__support/macros/properties/architectures.h"
 #include "src/__support/macros/properties/cpu_features.h"
 
index 3eafb3dc00c6ef8683ae3d01f7df9eba41152c1c..31494bdd102e0aed68eaa28fd79c0d4a72b1d7f5 100644 (file)
@@ -9,9 +9,8 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_X86_64_FMA_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_X86_64_FMA_H
 
-#include "src/__support/common.h"
 #include "src/__support/macros/properties/architectures.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #if !defined(LIBC_TARGET_ARCH_IS_X86_64)
 #error "Invalid include"
index ee1e540801cdfdf44817e29e1fe7e5981ef27fbc..85de5b77bb22d62aa130be55faa06997972d18d9 100644 (file)
@@ -15,7 +15,7 @@
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/builtin_wrappers.h"
 #include "src/__support/integer_utils.h"
-#include "src/__support/macros/attributes.h" // LIBC_UNLIKELY
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/__support/number_pair.h"
 
 #include <stddef.h> // For size_t
index e949627b2a2884136c4246e8326ca2deff9d5b80..9a2fcd2645eaef750f3457385774c73625e9a8c7 100644 (file)
 
 #define LIBC_INLINE inline
 #define LIBC_INLINE_ASM __asm__ __volatile__
-
-// We use a template to implement likely/unlikely to make sure that we don't
-// accidentally pass an integer.
-namespace __llvm_libc::details {
-template <typename T>
-constexpr LIBC_INLINE bool expects_bool_condition(T value, T expected) {
-  return __builtin_expect(value, expected);
-}
-} // namespace __llvm_libc::details
-#define LIBC_LIKELY(x) __llvm_libc::details::expects_bool_condition(x, true)
-#define LIBC_UNLIKELY(x) __llvm_libc::details::expects_bool_condition(x, false)
-
 #define LIBC_UNUSED __attribute__((unused))
 
 #endif // LLVM_LIBC_SUPPORT_MACROS_ATTRIBUTES_H
index e39f5591c2598f25ebdc03d10cc874aba31ca5e3..3aeac327074cb5207c38238e38b0738428acf208 100644 (file)
@@ -13,6 +13,8 @@
 #ifndef LLVM_LIBC_SUPPORT_MACROS_CONFIG_H
 #define LLVM_LIBC_SUPPORT_MACROS_CONFIG_H
 
+#define LIBC_INLINE inline
+
 // LIBC_HAS_BUILTIN()
 //
 // Checks whether the compiler supports a Clang Feature Checking Macro, and if
@@ -23,7 +25,6 @@
 // Note: Use this macro to avoid an extra level of #ifdef __has_builtin check.
 // http://releases.llvm.org/3.3/tools/clang/docs/LanguageExtensions.html
 
-
 // Compiler builtin-detection.
 // clang.llvm.org/docs/LanguageExtensions.html#has-builtin
 #ifdef __has_builtin
index 2b5ee78cd7cb66c4d956d0aa7c3df7d2cc3da191..ebd11e61469b3206fcd2962fe08a644a233a6063 100644 (file)
 #ifndef LLVM_LIBC_SRC_SUPPORT_MACROS_OPTIMIZATION_H
 #define LLVM_LIBC_SRC_SUPPORT_MACROS_OPTIMIZATION_H
 
-#include "src/__support/macros/properties/compiler.h"
+#include "src/__support/macros/config.h" // LIBC_HAS_BUILTIN
+
+// We use a template to implement likely/unlikely to make sure that we don't
+// accidentally pass an integer.
+namespace __llvm_libc::details {
+template <typename T>
+constexpr LIBC_INLINE bool expects_bool_condition(T value, T expected) {
+  return __builtin_expect(value, expected);
+}
+} // namespace __llvm_libc::details
+#define LIBC_LIKELY(x) __llvm_libc::details::expects_bool_condition(x, true)
+#define LIBC_UNLIKELY(x) __llvm_libc::details::expects_bool_condition(x, false)
 
 #if defined(LIBC_COMPILER_IS_CLANG)
 #define LIBC_LOOP_NOUNROLL _Pragma("nounroll")
index a77b7dffbfcc841408650a133b38843053cb37ec..5723dc56a2603f6ed9c62620e58d2bc4d6e752f5 100644 (file)
@@ -13,6 +13,7 @@
 #include "src/__support/FPUtil/except_value_utils.h"
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <errno.h>
 
index 906a9abc930f4d3c7c8e969b575ea6b37cc36dda..12e0796c9130183bf35d14bc736b83b150262dc8 100644 (file)
@@ -12,6 +12,7 @@
 #include "src/__support/FPUtil/PolyEval.h"
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/math/generic/common_constants.h"
 #include "src/math/generic/explogxf.h"
 
index f94eac8d904b6af1b6e725e27c540ede957368d4..2bfa20842a1908398266c9195801bdf8d9d91251 100644 (file)
@@ -13,7 +13,8 @@
 #include "src/__support/FPUtil/except_value_utils.h"
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/sqrt.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #include <errno.h>
 
index 2afbd1acb9519abd3cceddb80e4e18a840887d10..7063387313ab81ff861de0713de87253347b38eb 100644 (file)
@@ -11,6 +11,7 @@
 #include "src/__support/FPUtil/PolyEval.h"
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/sqrt.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/math/generic/common_constants.h"
 #include "src/math/generic/explogxf.h"
 
index b72acea645f539b414ce94b9610d9cdcb657a239..ff5d4507afa3d8741ca1f9fc8b2a171887436c47 100644 (file)
@@ -9,6 +9,7 @@
 #include "src/math/atanf.h"
 #include "math_utils.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/math/generic/inv_trigf_utils.h"
 
 namespace __llvm_libc {
index ef64e0d20811e41c108963893d757d608f3f5f7b..0a077007de7846a3606cec1e7e8989fb83647498 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "src/math/atanhf.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/math/generic/explogxf.h"
 
 namespace __llvm_libc {
index 05f1cd2d99b19ea06ed1b48c06e430b7b9726251..b9a67861e6de3b5a83d79cf834039f739e593d70 100644 (file)
@@ -14,7 +14,8 @@
 #include "src/__support/FPUtil/except_value_utils.h"
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/common.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #include <errno.h>
 
index 463c564c9c5bf0e8174eb89c955808bf912eca69..c1387bc1f0c2ad9bef8d1777b17eb4708aaddc09 100644 (file)
@@ -9,6 +9,7 @@
 #include "src/math/coshf.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/math/generic/explogxf.h"
 
 namespace __llvm_libc {
index 73423aff22fa5851be9a7818091fc0da3ef0e36e..4059da5907546a706eff962bba4ecfbc251081ae 100644 (file)
@@ -15,6 +15,7 @@
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/common.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <errno.h>
 
index 52ae89a61022ca02b6b4126174f4ae84ad1074ef..b5d720faac3d3ec1ae450f0ee43b236eecfcf232 100644 (file)
@@ -13,6 +13,7 @@
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/common.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <errno.h>
 
index 4b5e180f6c65ccd60115082f96960c00e64bc137..a22449017bfc7efaac22316ed4aedd7416ffab25 100644 (file)
@@ -15,6 +15,7 @@
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/common.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 #include <errno.h>
 
index 0ee0721463225e985ef645427307dafbcd46f885..67bbb8ef0ae8f649c1b47315848ab2799d9c03bd 100644 (file)
@@ -16,7 +16,8 @@
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/common.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #include <errno.h>
 
index 498806467647b9bdef85ab9108a4bc62af7fdf3f..10d57a8f30861e7df8d3c81fc88cafa1d662335c 100644 (file)
@@ -12,6 +12,7 @@
 #include "src/__support/FPUtil/dyadic_float.h"
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/common.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 
 namespace __llvm_libc {
 
index ea6722927300b7fc5e6a822c8bd18b1cd024ce43..291d4628f60539afa44696074c56891c7bcbbd01 100644 (file)
@@ -12,7 +12,8 @@
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/common.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #include <errno.h>
 
index bda1117a8cfac423f3fca9b00474914cf4416b5a..f23617ebf180cff2c2bf094ce5b4939837f613ae 100644 (file)
@@ -11,8 +11,7 @@
 
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/__support/FPUtil/PolyEval.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #if defined(LIBC_TARGET_CPU_HAS_FMA)
 #include "range_reduction_fma.h"
index 488a3e419208cd95c0464419c0bc4f73dbbb9798..1cbe4f69e0a7a2a5c9c9af7dc2555b37b38e3ee3 100644 (file)
@@ -14,7 +14,8 @@
 #include "src/__support/FPUtil/PolyEval.h"
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/common.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #include <errno.h>
 
index 3a38e2bad571d1d33209c9a3b0dcba40e791e1ff..9ba5ac279c0e04dd6a8775bbc6a66146d912e049 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "src/math/sinhf.h"
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/math/generic/explogxf.h"
 
 namespace __llvm_libc {
index d2214282957ec4ea50d24b42fd2ac04542a7dfa9..0c055d22f24259fd398936b58bade05722c32d1f 100644 (file)
@@ -15,7 +15,8 @@
 #include "src/__support/FPUtil/multiply_add.h"
 #include "src/__support/FPUtil/nearest_integer.h"
 #include "src/__support/common.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 
 #include <errno.h>
 
index 87a8874771706389b3751049d4c623351e9a6a5d..e67eadf3ce4b74b7ecc0bbdfe390d0b7dbd74051 100644 (file)
@@ -8,7 +8,8 @@
 
 #include "src/math/tanhf.h"
 #include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/macros/optimization.h"            // LIBC_UNLIKELY
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 #include "src/math/generic/explogxf.h"
 
 namespace __llvm_libc {
index 8e3aa4dd497debde98b4974c696d2eaaa2c8e2fc..483d3c2f98c99d762ae83108407685f040cdd220 100644 (file)
@@ -10,7 +10,7 @@
 #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_BCMP_IMPLEMENTATIONS_H
 
 #include "src/__support/common.h"
-#include "src/__support/macros/optimization.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY LIBC_LOOP_NOUNROLL
 #include "src/__support/macros/properties/architectures.h"
 #include "src/string/memory_utils/op_aarch64.h"
 #include "src/string/memory_utils/op_builtin.h"
index 71b16537824364199c28800f10e5d61500f2dc7b..f99e2e47a830966aed1be6fd384bd680d0f83a83 100644 (file)
@@ -10,7 +10,7 @@
 #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP_IMPLEMENTATIONS_H
 
 #include "src/__support/common.h"
-#include "src/__support/macros/optimization.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY LIBC_LOOP_NOUNROLL
 #include "src/__support/macros/properties/architectures.h"
 #include "src/string/memory_utils/op_aarch64.h"
 #include "src/string/memory_utils/op_builtin.h"
index 211a6fb9c19ab503a2d0892e593e1be4fb4ea42d..c9c52527e2060960ee0523fab7d9c40977a73686 100644 (file)
@@ -10,7 +10,7 @@
 #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY_IMPLEMENTATIONS_H
 
 #include "src/__support/common.h"
-#include "src/__support/macros/optimization.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY LIBC_LOOP_NOUNROLL
 #include "src/__support/macros/properties/architectures.h"
 #include "src/string/memory_utils/op_aarch64.h"
 #include "src/string/memory_utils/op_builtin.h"
index ae514f4cffa29967d69df33ccaf347ec6f2268ce..03c6cab46e870d4a86aa88e8c56da6c7ab397339 100644 (file)
@@ -28,7 +28,6 @@
 #include "src/__support/common.h"
 #include "src/__support/endian.h"
 #include "src/__support/macros/optimization.h"
-#include "src/__support/macros/properties/compiler.h"
 #include "src/string/memory_utils/op_builtin.h"
 #include "src/string/memory_utils/utils.h"
 
index 2ae59707c983d1d674043ff978b9ff1b85ba769f..d3c637d409aac3abb75575964c778deddd07197f 100644 (file)
@@ -15,7 +15,7 @@
 #define LIBC_SRC_STRING_STRING_UTILS_H
 
 #include "src/__support/CPP/bitset.h"
-#include "src/__support/common.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/string/memory_utils/bzero_implementations.h"
 #include "src/string/memory_utils/memcpy_implementations.h"
 #include <stddef.h> // For size_t
index 87da023801bf3cc2cf4b89e2c107c85102e54830..c66a39a6b7836ae3f297623c6c5a6eaec7f9aafc 100644 (file)
@@ -7,6 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
 #include "src/math/exp2f.h"
 #include "test/UnitTest/FPMatcher.h"
 #include "test/UnitTest/Test.h"
index 3efde7f96c7b23be7fab128393cba10d54ad8c05..aff72f03fb88d86a937f092442eedfaac2138cc8 100644 (file)
@@ -94,7 +94,7 @@ libc_support_library(
     name = "__support_macros_optimization",
     hdrs = ["src/__support/macros/optimization.h"],
     deps = [
-        ":__support_macros_properties_compiler",
+        ":__support_macros_config",
         ":libc_root",
     ],
 )
@@ -242,6 +242,7 @@ libc_support_library(
         "__support_cpp_type_traits",
         "__support_integer_utils",
         "__support_macros_attributes",
+        "__support_macros_optimization",
         "__support_number_pair",
         ":libc_root",
     ],
@@ -410,6 +411,7 @@ libc_support_library(
         ":__support_fputil_nearest_integer_operations",
         ":__support_fputil_normal_float",
         ":__support_fputil_platform_defs",
+        ":__support_macros_optimization",
         ":__support_uint128",
         ":libc_root",
     ],
@@ -497,12 +499,12 @@ libc_support_library(
     textual_hdrs = fma_platform_hdrs,
     deps = [
         ":__support_builtin_wrappers",
-        ":__support_common",
         ":__support_cpp_bit",
         ":__support_cpp_type_traits",
         ":__support_fputil_fenv_impl",
         ":__support_fputil_float_properties",
         ":__support_fputil_fp_bits",
+        ":__support_macros_optimization",
         ":__support_macros_properties_cpu_features",
         ":__support_uint128",
         ":libc_root",
@@ -548,7 +550,6 @@ libc_support_library(
     # own.
     textual_hdrs = nearest_integer_platform_hdrs,
     deps = [
-        ":__support_common",
         ":libc_root",
     ],
 )
@@ -752,7 +753,6 @@ libc_support_library(
     name = "sincosf_utils",
     hdrs = ["src/math/generic/sincosf_utils.h"],
     deps = [
-        ":__support_common",
         ":__support_fputil_fp_bits",
         ":__support_fputil_polyeval",
         ":libc_root",
@@ -802,6 +802,7 @@ libc_math_function(
         ":__support_fputil_multiply_add",
         ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":__support_macros_properties_cpu_features",
         ":common_constants",
     ],
@@ -811,9 +812,10 @@ libc_math_function(
     name = "expf",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":common_constants",
     ],
 )
@@ -822,9 +824,10 @@ libc_math_function(
     name = "exp10f",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":common_constants",
         ":explogxf",
     ],
@@ -834,9 +837,10 @@ libc_math_function(
     name = "exp2f",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":explogxf",
     ],
 )
@@ -889,9 +893,10 @@ libc_math_function(
     name = "sinhf",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":common_constants",
         ":explogxf",
     ],
@@ -901,9 +906,10 @@ libc_math_function(
     name = "coshf",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":common_constants",
         ":explogxf",
     ],
@@ -916,6 +922,7 @@ libc_math_function(
         ":__support_fputil_multiply_add",
         ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":__support_macros_properties_cpu_features",
         ":common_constants",
         ":explogxf",
@@ -926,10 +933,11 @@ libc_math_function(
     name = "asinhf",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
         ":__support_fputil_sqrt",
+        ":__support_macros_optimization",
         ":common_constants",
         ":explogxf",
     ],
@@ -939,10 +947,11 @@ libc_math_function(
     name = "acoshf",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
         ":__support_fputil_sqrt",
+        ":__support_macros_optimization",
         ":common_constants",
         ":explogxf",
     ],
@@ -952,9 +961,10 @@ libc_math_function(
     name = "atanhf",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":common_constants",
         ":explogxf",
     ],
@@ -968,6 +978,7 @@ libc_math_function(
         ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
         ":__support_fputil_sqrt",
+        ":__support_macros_optimization",
         ":__support_macros_properties_cpu_features",
         ":inv_trigf_utils",
     ],
@@ -977,10 +988,11 @@ libc_math_function(
     name = "acosf",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
         ":__support_fputil_sqrt",
+        ":__support_macros_optimization",
         ":inv_trigf_utils",
     ],
 )
@@ -989,9 +1001,10 @@ libc_math_function(
     name = "atanf",
     additional_deps = [
         ":__support_fputil_fma",
-        ":__support_fputil_nearest_integer",
         ":__support_fputil_multiply_add",
+        ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":inv_trigf_utils",
         ":math_utils",
     ],
@@ -1148,6 +1161,7 @@ libc_math_function(
     additional_deps = [
         ":__support_fputil_fma",
         ":__support_fputil_multiply_add",
+        ":__support_macros_optimization",
         ":__support_macros_properties_cpu_features",
         ":sincosf_utils",
     ],
@@ -1158,6 +1172,7 @@ libc_math_function(
     additional_deps = [
         ":__support_fputil_fma",
         ":__support_fputil_multiply_add",
+        ":__support_macros_optimization",
         ":__support_macros_properties_cpu_features",
         ":sincosf_utils",
     ],
@@ -1169,6 +1184,7 @@ libc_math_function(
         ":__support_fputil_fma",
         ":__support_fputil_multiply_add",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":__support_macros_properties_cpu_features",
         ":range_reduction",
         ":sincosf_utils",
@@ -1182,6 +1198,7 @@ libc_math_function(
         ":__support_fputil_multiply_add",
         ":__support_fputil_nearest_integer",
         ":__support_fputil_polyeval",
+        ":__support_macros_optimization",
         ":__support_macros_properties_cpu_features",
         ":range_reduction",
         ":sincosf_utils",
@@ -1390,6 +1407,7 @@ libc_support_library(
         ":__support_macros_attributes",
         ":__support_macros_config",
         ":__support_macros_optimization",
+        ":__support_macros_properties_cpu_features",
         ":libc_root",
     ],
 )
@@ -1400,6 +1418,7 @@ libc_support_library(
     deps = [
         ":__support_common",
         ":__support_cpp_bitset",
+        ":__support_macros_optimization",
         ":libc_root",
         ":string_memory_utils",
     ],
index d2380885aed2e54a119775b743fc0498a420722a..e0adffb57bd62e53479e10ca07f26ed0e09bc563 100644 (file)
@@ -592,6 +592,7 @@ math_test(
 math_test(
     name = "exp2f",
     deps = [
+        "//libc:__support_macros_properties_cpu_features",
         "//libc/utils/MPFRWrapper:mpfr_wrapper",
     ],
 )