[libc] Add platform independent floating point rounding mode checks.
commita98243129530c852cbd42bffafc74ab635934d8a
authorTue Ly <lntue@google.com>
Tue, 6 Jun 2023 15:50:26 +0000 (6 11:50 -0400)
committerTue Ly <lntue@google.com>
Mon, 12 Jun 2023 13:36:41 +0000 (12 09:36 -0400)
tree1ffbfcc04f7addce908bdd20746182b0a302362b
parent282324aa4a6c29d5ce31c66f8def15d9bd8e84e4
[libc] Add platform independent floating point rounding mode checks.

Many math functions need to check for floating point rounding modes to
return correct values.  Currently most of them use the internal implementation
of `fegetround`, which is platform-dependent and blocking math functions to be
enabled on platforms with unimplemented `fegetround`.  In this change, we add
platform independent rounding mode checks and switching math functions to use
them instead. https://github.com/llvm/llvm-project/issues/63016

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D152280
28 files changed:
libc/src/__support/CMakeLists.txt
libc/src/__support/FPUtil/CMakeLists.txt
libc/src/__support/FPUtil/Hypot.h
libc/src/__support/FPUtil/NearestIntegerOperations.h
libc/src/__support/FPUtil/except_value_utils.h
libc/src/__support/FPUtil/generic/CMakeLists.txt
libc/src/__support/FPUtil/generic/FMA.h
libc/src/__support/FPUtil/generic/sqrt.h
libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
libc/src/__support/FPUtil/rounding_mode.h [new file with mode: 0644]
libc/src/__support/str_to_float.h
libc/src/math/generic/CMakeLists.txt
libc/src/math/generic/atanf.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/sincosf.cpp
libc/src/math/generic/sinf.cpp
libc/src/math/generic/sinhf.cpp
libc/src/math/generic/tanhf.cpp
libc/src/stdio/printf_core/CMakeLists.txt
libc/src/stdio/printf_core/float_dec_converter.h
libc/src/stdio/printf_core/float_hex_converter.h
libc/test/src/__support/FPUtil/CMakeLists.txt
libc/test/src/__support/FPUtil/rounding_mode_test.cpp [new file with mode: 0644]
utils/bazel/llvm-project-overlay/libc/BUILD.bazel