From 4663d784ddee07a379be50c550927c6386a5add1 Mon Sep 17 00:00:00 2001 From: Tue Ly Date: Sat, 11 Feb 2023 00:46:42 -0500 Subject: [PATCH] [libc] Update macros/optimization.h build dependency for CMake and Bazel. Update macros/optimization.h build dependency for CMake and Bazel. Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D143805 --- libc/src/__support/CMakeLists.txt | 2 +- libc/src/__support/FPUtil/CMakeLists.txt | 4 +++ libc/src/__support/FPUtil/generic/CMakeLists.txt | 2 ++ libc/src/math/generic/CMakeLists.txt | 21 +++++++++++ libc/src/math/generic/log10f.cpp | 7 ++-- libc/src/math/generic/log1pf.cpp | 7 ++-- libc/src/math/generic/log2f.cpp | 2 +- libc/src/math/generic/logf.cpp | 7 ++-- utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 44 +++++++++++++---------- 9 files changed, 67 insertions(+), 29 deletions(-) diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt index 3ff22bb..554c6d6 100644 --- a/libc/src/__support/CMakeLists.txt +++ b/libc/src/__support/CMakeLists.txt @@ -179,7 +179,7 @@ add_header_library( .integer_utils libc.src.__support.CPP.array libc.src.__support.CPP.type_traits - libc.src.__support.macros.attributes + libc.src.__support.macros.optimization ) add_header_library( diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt index bd9faa7..c635276 100644 --- a/libc/src/__support/FPUtil/CMakeLists.txt +++ b/libc/src/__support/FPUtil/CMakeLists.txt @@ -75,6 +75,7 @@ add_header_library( libc.src.__support.CPP.bit libc.src.__support.CPP.type_traits libc.src.__support.common + libc.src.__support.macros.optimization libc.include.math libc.include.errno libc.src.errno.errno @@ -110,6 +111,7 @@ add_header_library( .fp_bits .fenv_impl libc.src.__support.CPP.optional + libc.src.__support.macros.optimization ) @@ -183,6 +185,7 @@ add_header_library( nearest_integer.h DEPENDS libc.src.__support.common + libc.src.__support.macros.optimization FLAGS ROUND_OPT ) @@ -207,6 +210,7 @@ add_header_library( .multiply_add libc.src.__support.common libc.src.__support.uint + libc.src.__support.macros.optimization ) add_subdirectory(generic) diff --git a/libc/src/__support/FPUtil/generic/CMakeLists.txt b/libc/src/__support/FPUtil/generic/CMakeLists.txt index ff0a135..5b02883 100644 --- a/libc/src/__support/FPUtil/generic/CMakeLists.txt +++ b/libc/src/__support/FPUtil/generic/CMakeLists.txt @@ -26,6 +26,7 @@ add_header_library( libc.src.__support.FPUtil.float_properties libc.src.__support.FPUtil.fp_bits libc.src.__support.builtin_wrappers + libc.src.__support.macros.optimization libc.src.__support.uint128 ) @@ -40,5 +41,6 @@ add_header_library( libc.src.__support.FPUtil.float_properties libc.src.__support.FPUtil.fp_bits libc.src.__support.builtin_wrappers + libc.src.__support.macros.optimization libc.src.math.generic.math_utils ) diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 27e8335..922e16f 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -87,6 +87,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -108,6 +109,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -128,6 +130,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -150,6 +153,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -538,6 +542,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.nearest_integer libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization libc.include.errno libc.src.errno.errno libc.include.math @@ -558,6 +563,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.nearest_integer libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization libc.include.errno libc.src.errno.errno libc.include.math @@ -578,6 +584,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.nearest_integer libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization libc.include.errno libc.src.errno.errno libc.include.math @@ -599,6 +606,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.nearest_integer libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization libc.include.errno libc.src.errno.errno libc.include.math @@ -770,6 +778,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.double_double libc.src.__support.FPUtil.dyadic_float + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -804,6 +813,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -821,6 +831,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.fma libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -838,6 +849,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -1266,6 +1278,7 @@ add_entrypoint_object( .explogxf libc.src.__support.FPUtil.fp_bits libc.src.__support.FPUtil.multiply_add + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -1279,6 +1292,7 @@ add_entrypoint_object( DEPENDS .explogxf libc.src.__support.FPUtil.fp_bits + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -1292,6 +1306,7 @@ add_entrypoint_object( DEPENDS .explogxf libc.src.__support.FPUtil.fp_bits + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -1309,6 +1324,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.sqrt + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -1325,6 +1341,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.sqrt + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -1338,6 +1355,7 @@ add_entrypoint_object( DEPENDS .explogxf libc.src.__support.FPUtil.fp_bits + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) @@ -1373,6 +1391,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.sqrt + libc.src.__support.macros.optimization .inv_trigf_utils COMPILE_OPTIONS -O3 @@ -1402,6 +1421,7 @@ add_entrypoint_object( libc.src.__support.FPUtil.multiply_add libc.src.__support.FPUtil.polyeval libc.src.__support.FPUtil.sqrt + libc.src.__support.macros.optimization .inv_trigf_utils COMPILE_OPTIONS -O3 @@ -1417,6 +1437,7 @@ add_entrypoint_object( .inv_trigf_utils .math_utils libc.src.__support.FPUtil.fp_bits + libc.src.__support.macros.optimization COMPILE_OPTIONS -O3 ) diff --git a/libc/src/math/generic/log10f.cpp b/libc/src/math/generic/log10f.cpp index 57c1078..ba2f016 100644 --- a/libc/src/math/generic/log10f.cpp +++ b/libc/src/math/generic/log10f.cpp @@ -15,7 +15,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/attributes.h" // LIBC_UNLIKELY +#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY +#include "src/__support/macros/properties/cpu_features.h" // This is an algorithm for log10(x) in single precision which is // correctly rounded for all rounding modes, based on the implementation of @@ -136,14 +137,14 @@ LLVM_LIBC_FUNCTION(float, log10f, (float x)) { return fputil::round_result_slightly_down(0x1.2c9314p+3f); case 0x7956'ba5eU: // x = 69683218960000541503257137270226944.0 return fputil::round_result_slightly_up(0x1.16bebap+5f); -#ifndef LIBC_TARGET_HAS_FMA +#ifndef LIBC_TARGET_CPU_HAS_FMA case 0x08ae'a356U: // x = 0x1.5d46acp-110f return fputil::round_result_slightly_up(-0x1.07d3b4p+5f); case 0x1c7d'a337U: // x = 0x1.fb466ep-71f return fputil::round_result_slightly_up(-0x1.5137dp+4f); case 0x69c8'c583U: // x = 0x1.918b06p+84f return fputil::round_result_slightly_down(0x1.97b652p+4f); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA } int m = -FPBits::EXPONENT_BIAS; diff --git a/libc/src/math/generic/log1pf.cpp b/libc/src/math/generic/log1pf.cpp index f5ede17..1a18e0c 100644 --- a/libc/src/math/generic/log1pf.cpp +++ b/libc/src/math/generic/log1pf.cpp @@ -15,7 +15,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/attributes.h" // LIBC_UNLIKELY +#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY +#include "src/__support/macros/properties/cpu_features.h" // This is an algorithm for log10(x) in single precision which is // correctly rounded for all rounding modes. @@ -104,7 +105,7 @@ LLVM_LIBC_FUNCTION(float, log1pf, (float x)) { case 0xbf800000U: // x = -1.0 fputil::raise_except(FE_DIVBYZERO); return static_cast(fputil::FPBits::neg_inf()); -#ifndef LIBC_TARGET_HAS_FMA +#ifndef LIBC_TARGET_CPU_HAS_FMA case 0x4cc1c80bU: // x = 0x1.839016p+26f return fputil::round_result_slightly_down(0x1.26fc04p+4f); case 0x5ee8984eU: // x = 0x1.d1309cp+62f @@ -113,7 +114,7 @@ LLVM_LIBC_FUNCTION(float, log1pf, (float x)) { return fputil::round_result_slightly_up(0x1.af66cp+5f); case 0x79e7ec37U: // x = 0x1.cfd86ep+116f return fputil::round_result_slightly_up(0x1.43ff6ep+6); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA } return internal::log(xd + 1.0); diff --git a/libc/src/math/generic/log2f.cpp b/libc/src/math/generic/log2f.cpp index 62e41d8..47abcf8d 100644 --- a/libc/src/math/generic/log2f.cpp +++ b/libc/src/math/generic/log2f.cpp @@ -14,7 +14,7 @@ #include "src/__support/FPUtil/except_value_utils.h" #include "src/__support/FPUtil/multiply_add.h" #include "src/__support/common.h" -#include "src/__support/macros/attributes.h" // LIBC_UNLIKELY +#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY // This is a correctly-rounded algorithm for log2(x) in single precision with // round-to-nearest, tie-to-even mode from the RLIBM project at: diff --git a/libc/src/math/generic/logf.cpp b/libc/src/math/generic/logf.cpp index 1a73f8c..b579b5b 100644 --- a/libc/src/math/generic/logf.cpp +++ b/libc/src/math/generic/logf.cpp @@ -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/attributes.h" // LIBC_UNLIKELY +#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY +#include "src/__support/macros/properties/cpu_features.h" // This is an algorithm for log(x) in single precision which is correctly // rounded for all rounding modes, based on the implementation of log(x) from @@ -76,7 +77,7 @@ LLVM_LIBC_FUNCTION(float, logf, (float x)) { return round_result_slightly_down(0x1.08b512p+6f); case 0x7a17f30aU: // x = 0x1.2fe614p+117f return round_result_slightly_up(0x1.451436p+6f); -#ifndef LIBC_TARGET_HAS_FMA +#ifndef LIBC_TARGET_CPU_HAS_FMA case 0x1b7679ffU: // x = 0x1.ecf3fep-73f return round_result_slightly_up(-0x1.8f8e5ap+5f); case 0x1e88452dU: // x = 0x1.108a5ap-66f @@ -87,7 +88,7 @@ LLVM_LIBC_FUNCTION(float, logf, (float x)) { return round_result_slightly_up(0x1.af66cp+5f); case 0x79e7ec37U: // x = 0x1.cfd86ep+116f return round_result_slightly_up(0x1.43ff6ep+6f); -#endif // LIBC_TARGET_HAS_FMA +#endif // LIBC_TARGET_CPU_HAS_FMA } int m = -FPBits::EXPONENT_BIAS; diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel index e3102b9..1ed2cee 100644 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -143,7 +143,7 @@ libc_support_library( name = "__support_cpp_cstddef", hdrs = ["src/__support/CPP/cstddef.h"], deps = [ - "__support_cpp_type_traits", + ":__support_cpp_type_traits", ":libc_root", ], ) @@ -170,8 +170,8 @@ libc_support_library( name = "__support_cpp_span", hdrs = ["src/__support/CPP/span.h"], deps = [ - "__support_cpp_array", - "__support_cpp_type_traits", + ":__support_cpp_array", + ":__support_cpp_type_traits", ":libc_root", ], ) @@ -213,8 +213,8 @@ libc_support_library( name = "__support_number_pair", hdrs = ["src/__support/number_pair.h"], deps = [ - "__support_cpp_type_traits", - "__support_named_pair", + ":__support_cpp_type_traits", + ":__support_named_pair", ":libc_root", ], ) @@ -223,10 +223,10 @@ libc_support_library( name = "__support_integer_utils", hdrs = ["src/__support/integer_utils.h"], deps = [ - "__support_builtin_wrappers", - "__support_common", - "__support_cpp_type_traits", - "__support_number_pair", + ":__support_builtin_wrappers", + ":__support_common", + ":__support_cpp_type_traits", + ":__support_number_pair", ":libc_root", ], ) @@ -235,15 +235,15 @@ libc_support_library( name = "__support_uint", hdrs = ["src/__support/UInt.h"], deps = [ - "__support_builtin_wrappers", - "__support_cpp_array", - "__support_cpp_limits", - "__support_cpp_optional", - "__support_cpp_type_traits", - "__support_integer_utils", - "__support_macros_attributes", - "__support_macros_optimization", - "__support_number_pair", + ":__support_builtin_wrappers", + ":__support_cpp_array", + ":__support_cpp_limits", + ":__support_cpp_optional", + ":__support_cpp_type_traits", + ":__support_integer_utils", + ":__support_macros_attributes", + ":__support_macros_optimization", + ":__support_number_pair", ":libc_root", ], ) @@ -551,6 +551,7 @@ libc_support_library( textual_hdrs = nearest_integer_platform_hdrs, deps = [ ":libc_root", + ":__support_macros_optimization", ], ) @@ -851,6 +852,8 @@ libc_math_function( ":__support_fputil_fma", ":__support_fputil_multiply_add", ":__support_fputil_polyeval", + ":__support_macros_optimization", + ":__support_macros_properties_cpu_features", ":common_constants", ], ) @@ -861,6 +864,7 @@ libc_math_function( ":__support_fputil_fma", ":__support_fputil_multiply_add", ":__support_fputil_polyeval", + ":__support_macros_optimization", ":common_constants", ], ) @@ -871,6 +875,8 @@ libc_math_function( ":__support_fputil_fma", ":__support_fputil_multiply_add", ":__support_fputil_polyeval", + ":__support_macros_optimization", + ":__support_macros_properties_cpu_features", ":common_constants", ], ) @@ -881,6 +887,8 @@ libc_math_function( ":__support_fputil_fma", ":__support_fputil_multiply_add", ":__support_fputil_polyeval", + ":__support_macros_optimization", + ":__support_macros_properties_cpu_features", ":common_constants", ], ) -- 2.7.4