Skip to content

Commit

Permalink
[libc] Update macros/optimization.h build dependency for CMake and Ba…
Browse files Browse the repository at this point in the history
…zel.

Update macros/optimization.h build dependency for CMake and Bazel.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D143805
  • Loading branch information
lntue committed Feb 11, 2023
1 parent a630b8e commit 4663d78
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 29 deletions.
2 changes: 1 addition & 1 deletion libc/src/__support/CMakeLists.txt
Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions libc/src/__support/FPUtil/CMakeLists.txt
Expand Up @@ -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
Expand Down Expand Up @@ -110,6 +111,7 @@ add_header_library(
.fp_bits
.fenv_impl
libc.src.__support.CPP.optional
libc.src.__support.macros.optimization
)


Expand Down Expand Up @@ -183,6 +185,7 @@ add_header_library(
nearest_integer.h
DEPENDS
libc.src.__support.common
libc.src.__support.macros.optimization
FLAGS
ROUND_OPT
)
Expand All @@ -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)
2 changes: 2 additions & 0 deletions libc/src/__support/FPUtil/generic/CMakeLists.txt
Expand Up @@ -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
)

Expand All @@ -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
)
21 changes: 21 additions & 0 deletions libc/src/math/generic/CMakeLists.txt
Expand Up @@ -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
)
Expand All @@ -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
)
Expand All @@ -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
)
Expand All @@ -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
)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
)
Expand All @@ -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
)
Expand All @@ -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
)
Expand Down Expand Up @@ -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
)
Expand All @@ -1279,6 +1292,7 @@ add_entrypoint_object(
DEPENDS
.explogxf
libc.src.__support.FPUtil.fp_bits
libc.src.__support.macros.optimization
COMPILE_OPTIONS
-O3
)
Expand All @@ -1292,6 +1306,7 @@ add_entrypoint_object(
DEPENDS
.explogxf
libc.src.__support.FPUtil.fp_bits
libc.src.__support.macros.optimization
COMPILE_OPTIONS
-O3
)
Expand All @@ -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
)
Expand All @@ -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
)
Expand All @@ -1338,6 +1355,7 @@ add_entrypoint_object(
DEPENDS
.explogxf
libc.src.__support.FPUtil.fp_bits
libc.src.__support.macros.optimization
COMPILE_OPTIONS
-O3
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
)
Expand Down
7 changes: 4 additions & 3 deletions libc/src/math/generic/log10f.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions libc/src/math/generic/log1pf.cpp
Expand Up @@ -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.
Expand Down Expand Up @@ -104,7 +105,7 @@ LLVM_LIBC_FUNCTION(float, log1pf, (float x)) {
case 0xbf800000U: // x = -1.0
fputil::raise_except(FE_DIVBYZERO);
return static_cast<float>(fputil::FPBits<float>::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
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libc/src/math/generic/log2f.cpp
Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions libc/src/math/generic/logf.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 4663d78

Please sign in to comment.