[libc-commits] [libc] 19ca79e - [libc][math][c23] Implement canonicalize functions (#85940)
via libc-commits
libc-commits at lists.llvm.org
Tue Mar 26 05:28:26 PDT 2024
Author: Shourya Goel
Date: 2024-03-26T08:28:22-04:00
New Revision: 19ca79e8671439338b429982c457304c70eca701
URL: https://github.com/llvm/llvm-project/commit/19ca79e8671439338b429982c457304c70eca701
DIFF: https://github.com/llvm/llvm-project/commit/19ca79e8671439338b429982c457304c70eca701.diff
LOG: [libc][math][c23] Implement canonicalize functions (#85940)
Fixes: #85286
Added:
libc/src/math/canonicalize.h
libc/src/math/canonicalizef.h
libc/src/math/canonicalizef128.h
libc/src/math/canonicalizel.h
libc/src/math/generic/canonicalize.cpp
libc/src/math/generic/canonicalizef.cpp
libc/src/math/generic/canonicalizef128.cpp
libc/src/math/generic/canonicalizel.cpp
libc/test/src/math/smoke/CanonicalizeTest.h
libc/test/src/math/smoke/canonicalize_test.cpp
libc/test/src/math/smoke/canonicalizef128_test.cpp
libc/test/src/math/smoke/canonicalizef_test.cpp
libc/test/src/math/smoke/canonicalizel_test.cpp
Modified:
libc/config/linux/x86_64/entrypoints.txt
libc/docs/math/index.rst
libc/spec/stdc.td
libc/src/__support/FPUtil/BasicOperations.h
libc/src/__support/FPUtil/CMakeLists.txt
libc/src/math/CMakeLists.txt
libc/src/math/generic/CMakeLists.txt
libc/test/src/math/smoke/CMakeLists.txt
utils/bazel/llvm-project-overlay/libc/BUILD.bazel
Removed:
################################################################################
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 29080df5492274..5b428e51aee620 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -350,6 +350,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.asinhf
libc.src.math.atanf
libc.src.math.atanhf
+ libc.src.math.canonicalize
+ libc.src.math.canonicalizef
+ libc.src.math.canonicalizel
libc.src.math.copysign
libc.src.math.copysignf
libc.src.math.copysignl
@@ -516,6 +519,7 @@ set(TARGET_LIBM_ENTRYPOINTS
if(LIBC_TYPES_HAS_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
+ libc.src.math.canonicalizef128
libc.src.math.ceilf128
libc.src.math.copysignf128
libc.src.math.fabsf128
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index fa604faaec2ff0..080b6a4427f511 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -104,273 +104,282 @@ Implementation Status
Basic Operations
----------------
-+--------------+---------------------------------------+-------------------+-------------------+-------------------+-------------------+
-| <Func> | Linux | Windows | MacOS | Embedded | GPU |
-| +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| | x86_64 | aarch64 | aarch32 | riscv64 | x86_64 | aarch64 | x86_64 | aarch64 | aarch32 | riscv32 | AMD | nVidia |
-+==============+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+
-| ceil | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ceilf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ceill | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ceilf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| copysign | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| copysignf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| copysignl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| copysignf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fabs | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fabsf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fabsl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fabsf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fdim | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fdimf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fdiml | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fdimf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| floor | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| floorf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| floorl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| floorf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fmax | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fmaxf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fmaxf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fmaxl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fmin | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fminf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fminf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fminl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fmod | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fmodf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fmodl | |check| | |check| | | |check| | |check| | | | |check| | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fmodf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| frexp | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| frexpf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| frexpl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| frexpf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfp | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpf | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpl | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpf128 | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpx | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpxf | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpxl | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| fromfpxf128 | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ilogb | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ilogbf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ilogbl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ilogf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ldexp | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ldexpf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ldexpl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ldexpf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llogb | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llogbf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llogbl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llogf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llrint | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llrintf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llrintl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llrintf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llround | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llroundf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llroundl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| llroundf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| logb | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| logbf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| logbl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| logf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| lrint | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| lrintf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| lrintl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| lrintf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| lround | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| lroundf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| lroundl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| lroundf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| modf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| modff | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| modfl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| modff128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nan | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nanf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nanl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nanf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nearbyint | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nearbyintf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nearbyintl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextafter | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextafterf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextafterl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextafterf128| |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextdown | |check| | |check| | |check| | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextdownf | |check| | |check| | |check| | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextdownl | |check| | |check| | |check| | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextdownf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nexttoward | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nexttowardf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nexttowardl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextup | |check| | |check| | |check| | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextupf | |check| | |check| | |check| | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextupl | |check| | |check| | |check| | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| nextupf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| remainder | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| remainderf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| remainderl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| remquo | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| remquof | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| remquol | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| rint | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| rintf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| rintl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| rintf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| round | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| roundf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| roundl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| roundf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| scalbn | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| scalbnf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| scalbnl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| trunc | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| truncf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| truncl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| truncf128 | |check| | |check| | | |check| | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfp | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpf | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpl | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpf128 | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpx | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpxf | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpxl | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
-| ufromfpxf128 | |check| | | | | | | | | | | | |
-+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+
++------------------+---------------------------------------+-------------------+-------------------+-------------------+-------------------+
+| <Func> | Linux | Windows | MacOS | Embedded | GPU |
+| +---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| | x86_64 | aarch64 | aarch32 | riscv64 | x86_64 | aarch64 | x86_64 | aarch64 | aarch32 | riscv32 | AMD | nVidia |
++==================+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+
+| ceil | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ceilf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ceill | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ceilf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| canoninicalize | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| canoninicalizef | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| canoninicalizel | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+|canoninicalizef128| |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| copysign | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| copysignf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| copysignl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| copysignf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fabs | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fabsf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fabsl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fabsf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fdim | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fdimf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fdiml | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fdimf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| floor | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| floorf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| floorl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| floorf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fmax | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fmaxf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fmaxf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fmaxl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fmin | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fminf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fminf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fminl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fmod | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fmodf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fmodl | |check| | |check| | | |check| | |check| | | | |check| | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fmodf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| frexp | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| frexpf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| frexpl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| frexpf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fromfp | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fromfpf | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fromfpl | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fromfpf128 | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fromfpx | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fromfpxf | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fromfpxl | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| fromfpxf128 | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ilogb | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ilogbf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ilogbl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ilogf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ldexp | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ldexpf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ldexpl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ldexpf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llogb | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llogbf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llogbl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llogf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llrint | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llrintf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llrintl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llrintf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llround | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llroundf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llroundl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| llroundf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| logb | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| logbf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| logbl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| logf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| lrint | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| lrintf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| lrintl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| lrintf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| lround | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| lroundf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| lroundl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| lroundf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| modf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| modff | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| modfl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| modff128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nan | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nanf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nanl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nanf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nearbyint | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nearbyintf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nearbyintl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextafter | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextafterf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextafterl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextafterf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextdown | |check| | |check| | |check| | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextdownf | |check| | |check| | |check| | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextdownl | |check| | |check| | |check| | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextdownf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nexttoward | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nexttowardf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nexttowardl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextup | |check| | |check| | |check| | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextupf | |check| | |check| | |check| | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextupl | |check| | |check| | |check| | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| nextupf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| remainder | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| remainderf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| remainderl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| remquo | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| remquof | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| remquol | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| rint | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| rintf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| rintl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| rintf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| round | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| roundf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| roundl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| roundf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| scalbn | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| scalbnf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| scalbnl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| trunc | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| truncf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| truncl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| truncf128 | |check| | |check| | | |check| | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ufromfp | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ufromfpf | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ufromfpl | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ufromfpf128 | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ufromfpx | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ufromfpxf | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ufromfpxl | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
+| ufromfpxf128 | |check| | | | | | | | | | | | |
++------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
Higher Math Functions
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 89b43f06778d95..ac6e1d1801ba55 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -636,6 +636,11 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"nan", RetValSpec<DoubleType>, [ArgSpec<ConstCharPtr>]>,
FunctionSpec<"nanl", RetValSpec<LongDoubleType>, [ArgSpec<ConstCharPtr>]>,
GuardedFunctionSpec<"nanf128", RetValSpec<Float128Type>, [ArgSpec<ConstCharPtr>], "LIBC_TYPES_HAS_FLOAT128">,
+
+ FunctionSpec<"canonicalize", RetValSpec<IntType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
+ FunctionSpec<"canonicalizef", RetValSpec<IntType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
+ FunctionSpec<"canonicalizel", RetValSpec<IntType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"canonicalizef128", RetValSpec<IntType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
]
>;
diff --git a/libc/src/__support/FPUtil/BasicOperations.h b/libc/src/__support/FPUtil/BasicOperations.h
index b8cff982d3a6ea..405755f8b57d9b 100644
--- a/libc/src/__support/FPUtil/BasicOperations.h
+++ b/libc/src/__support/FPUtil/BasicOperations.h
@@ -9,11 +9,14 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_BASICOPERATIONS_H
#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_BASICOPERATIONS_H
+#include "FEnvImpl.h"
#include "FPBits.h"
#include "FEnvImpl.h"
#include "src/__support/CPP/type_traits.h"
+#include "src/__support/UInt128.h"
#include "src/__support/common.h"
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
namespace LIBC_NAMESPACE {
namespace fputil {
@@ -178,6 +181,66 @@ LIBC_INLINE T fdim(T x, T y) {
return (x > y ? x - y : 0);
}
+template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
+LIBC_INLINE int canonicalize(T &cx, const T &x) {
+ FPBits<T> sx(x);
+ if constexpr (get_fp_type<T>() == FPType::X86_Binary80) {
+ // All the pseudo and unnormal numbers are not canonical.
+ // More precisely :
+ // Exponent | Significand | Meaning
+ // | Bits 63-62 | Bits 61-0 |
+ // All Ones | 00 | Zero | Pseudo Infinity, Value = Infinty
+ // All Ones | 00 | Non-Zero | Pseudo NaN, Value = SNaN
+ // All Ones | 01 | Anything | Pseudo NaN, Value = SNaN
+ // | Bit 63 | Bits 62-0 |
+ // All zeroes | One | Anything | Pseudo Denormal, Value =
+ // | | | (−1)**s × m × 2**−16382
+ // All Other | Zero | Anything | Unnormal, Value =
+ // Values | | | (−1)**s × m × 2**−16382
+ bool bit63 = sx.get_implicit_bit();
+ UInt128 mantissa = sx.get_explicit_mantissa();
+ bool bit62 = ((mantissa & (1ULL << 62)) >> 62);
+ int exponent = sx.get_biased_exponent();
+ if (exponent == 0x7FFF) {
+ if (!bit63 && !bit62) {
+ if (mantissa == 0)
+ cx = FPBits<T>::inf(sx.sign()).get_val();
+ else {
+ cx = FPBits<T>::quiet_nan(sx.sign(), mantissa).get_val();
+ raise_except_if_required(FE_INVALID);
+ return 1;
+ }
+ } else if (!bit63 && bit62) {
+ cx = FPBits<T>::quiet_nan(sx.sign(), mantissa).get_val();
+ raise_except_if_required(FE_INVALID);
+ return 1;
+ } else if (LIBC_UNLIKELY(sx.is_signaling_nan())) {
+ cx = FPBits<T>::quiet_nan(sx.sign(), sx.get_explicit_mantissa())
+ .get_val();
+ raise_except_if_required(FE_INVALID);
+ return 1;
+ } else
+ cx = x;
+ } else if (exponent == 0 && bit63)
+ cx = FPBits<T>::make_value(mantissa, 0).get_val();
+ else if (exponent != 0 && !bit63)
+ cx = FPBits<T>::make_value(mantissa, 0).get_val();
+ else if (LIBC_UNLIKELY(sx.is_signaling_nan())) {
+ cx =
+ FPBits<T>::quiet_nan(sx.sign(), sx.get_explicit_mantissa()).get_val();
+ raise_except_if_required(FE_INVALID);
+ return 1;
+ } else
+ cx = x;
+ } else if (LIBC_UNLIKELY(sx.is_signaling_nan())) {
+ cx = FPBits<T>::quiet_nan(sx.sign(), sx.get_explicit_mantissa()).get_val();
+ raise_except_if_required(FE_INVALID);
+ return 1;
+ } else
+ cx = x;
+ return 0;
+}
+
} // namespace fputil
} // namespace LIBC_NAMESPACE
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index 4ded70a675ea88..0f435023419757 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -82,8 +82,11 @@ add_header_library(
BasicOperations.h
DEPENDS
.fp_bits
+ .fenv_impl
libc.src.__support.CPP.type_traits
+ libc.src.__support.uint128
libc.src.__support.common
+ libc.src.__support.macros.optimization
)
add_header_library(
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 61baa498321cb1..b67ee3a8e0dfbd 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -59,6 +59,11 @@ add_math_entrypoint_object(atan2f)
add_math_entrypoint_object(atanh)
add_math_entrypoint_object(atanhf)
+add_math_entrypoint_object(canonicalize)
+add_math_entrypoint_object(canonicalizef)
+add_math_entrypoint_object(canonicalizef128)
+add_math_entrypoint_object(canonicalizel)
+
add_math_entrypoint_object(ceil)
add_math_entrypoint_object(ceilf)
add_math_entrypoint_object(ceill)
diff --git a/libc/src/math/canonicalize.h b/libc/src/math/canonicalize.h
new file mode 100644
index 00000000000000..b7b5959fb667cf
--- /dev/null
+++ b/libc/src/math/canonicalize.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for canonicalize -------------------*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_CANONICALIZE_H
+#define LLVM_LIBC_SRC_MATH_CANONICALIZE_H
+
+namespace LIBC_NAMESPACE {
+
+int canonicalize(double *cx, const double *x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_CANONICALIZE_H
diff --git a/libc/src/math/canonicalizef.h b/libc/src/math/canonicalizef.h
new file mode 100644
index 00000000000000..556607f1334967
--- /dev/null
+++ b/libc/src/math/canonicalizef.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for canonicalizef ------------------*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_CANONICALIZEF_H
+#define LLVM_LIBC_SRC_MATH_CANONICALIZEF_H
+
+namespace LIBC_NAMESPACE {
+
+int canonicalizef(float *cx, const float *x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_CANONICALIZEF_H
diff --git a/libc/src/math/canonicalizef128.h b/libc/src/math/canonicalizef128.h
new file mode 100644
index 00000000000000..6db80094753767
--- /dev/null
+++ b/libc/src/math/canonicalizef128.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for canonicalizef128 ---------------*-C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_CANONICALIZEF128_H
+#define LLVM_LIBC_SRC_MATH_CANONICALIZEF128_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+int canonicalizef128(float128 *cx, const float128 *x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_CANONICALIZEF128_H
diff --git a/libc/src/math/canonicalizel.h b/libc/src/math/canonicalizel.h
new file mode 100644
index 00000000000000..1cab29e8e8b1c9
--- /dev/null
+++ b/libc/src/math/canonicalizel.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for canonicalizel ------------------*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_CANONICALIZEL_H
+#define LLVM_LIBC_SRC_MATH_CANONICALIZEL_H
+
+namespace LIBC_NAMESPACE {
+
+int canonicalizel(long double *cx, const long double *x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_CANONICALIZEL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 60d329f9adc6e3..4d9b91150d0200 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1,3 +1,51 @@
+add_entrypoint_object(
+ canonicalize
+ SRCS
+ canonicalize.cpp
+ HDRS
+ ../canonicalize.h
+ COMPILE_OPTIONS
+ -O3
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+)
+
+add_entrypoint_object(
+ canonicalizef
+ SRCS
+ canonicalizef.cpp
+ HDRS
+ ../canonicalizef.h
+ COMPILE_OPTIONS
+ -O3
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+)
+
+add_entrypoint_object(
+ canonicalizef128
+ SRCS
+ canonicalizef128.cpp
+ HDRS
+ ../canonicalizef128.h
+ COMPILE_OPTIONS
+ -O3
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+)
+
+add_entrypoint_object(
+ canonicalizel
+ SRCS
+ canonicalizel.cpp
+ HDRS
+ ../canonicalizel.h
+ COMPILE_OPTIONS
+ -O3
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+)
+
add_entrypoint_object(
ceil
SRCS
diff --git a/libc/src/math/generic/canonicalize.cpp b/libc/src/math/generic/canonicalize.cpp
new file mode 100644
index 00000000000000..f38ca01e157f88
--- /dev/null
+++ b/libc/src/math/generic/canonicalize.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of canonicalize function----------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/canonicalize.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, canonicalize, (double *cx, const double *x)) {
+ return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/generic/canonicalizef.cpp b/libc/src/math/generic/canonicalizef.cpp
new file mode 100644
index 00000000000000..dce601de149140
--- /dev/null
+++ b/libc/src/math/generic/canonicalizef.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of canonicalizef function---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/canonicalizef.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, canonicalizef, (float *cx, const float *x)) {
+ return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/generic/canonicalizef128.cpp b/libc/src/math/generic/canonicalizef128.cpp
new file mode 100644
index 00000000000000..0078b478238cb7
--- /dev/null
+++ b/libc/src/math/generic/canonicalizef128.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of canonicalizef128 function------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/canonicalizef128.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, canonicalizef128, (float128 * cx, const float128 *x)) {
+ return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/generic/canonicalizel.cpp b/libc/src/math/generic/canonicalizel.cpp
new file mode 100644
index 00000000000000..5310a316acdd3f
--- /dev/null
+++ b/libc/src/math/generic/canonicalizel.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of canonicalizel function---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/canonicalizel.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, canonicalizel,
+ (long double *cx, const long double *x)) {
+ return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 1345dca08a6a95..3b756127fe21ea 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -165,6 +165,66 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
+add_fp_unittest(
+ canonicalize_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ canonicalize_test.cpp
+ HDRS
+ CanonicalizeTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.canonicalize
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.fenv_impl
+)
+
+add_fp_unittest(
+ canonicalizef_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ canonicalizef_test.cpp
+ HDRS
+ CanonicalizeTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.canonicalizef
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.fenv_impl
+)
+
+add_fp_unittest(
+ canonicalizef128_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ canonicalizef128_test.cpp
+ HDRS
+ CanonicalizeTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.canonicalizef128
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.fenv_impl
+)
+
+add_fp_unittest(
+ canonicalizel_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ canonicalizel_test.cpp
+ HDRS
+ CanonicalizeTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.canonicalizel
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.fenv_impl
+)
+
add_fp_unittest(
ceil_test
SUITE
diff --git a/libc/test/src/math/smoke/CanonicalizeTest.h b/libc/test/src/math/smoke/CanonicalizeTest.h
new file mode 100644
index 00000000000000..ce855d5168565e
--- /dev/null
+++ b/libc/test/src/math/smoke/CanonicalizeTest.h
@@ -0,0 +1,219 @@
+//===-- Utility class to test canonicalize[f|l] -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_CANONICALIZETEST_H
+#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_CANONICALIZETEST_H
+
+#include "src/__support/FPUtil/FPBits.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+#include "include/llvm-libc-macros/math-macros.h"
+
+#define TEST_SPECIAL(x, y, expected, expected_exception) \
+ EXPECT_EQ(expected, f(&x, &y)); \
+ EXPECT_FP_EXCEPTION(expected_exception); \
+ LIBC_NAMESPACE::fputil::clear_except(FE_ALL_EXCEPT)
+
+#define TEST_REGULAR(x, y, expected) TEST_SPECIAL(x, y, expected, 0)
+
+#define LIBC_NAMESPACE __llvm_libc_19_0_0_git
+
+template <typename T>
+class CanonicalizeTest : public LIBC_NAMESPACE::testing::Test {
+
+ DECLARE_SPECIAL_CONSTANTS(T)
+
+public:
+ typedef int (*CanonicalizeFunc)(T *, const T *);
+
+ void testSpecialNumbers(CanonicalizeFunc f) {
+ T cx;
+
+ TEST_SPECIAL(cx, zero, 0, 0);
+ EXPECT_FP_EQ(cx, zero);
+
+ TEST_SPECIAL(cx, neg_zero, 0, 0);
+ EXPECT_FP_EQ(cx, neg_zero);
+
+ TEST_SPECIAL(cx, inf, 0, 0);
+ EXPECT_FP_EQ(cx, inf);
+
+ TEST_SPECIAL(cx, neg_inf, 0, 0);
+ EXPECT_FP_EQ(cx, neg_inf);
+
+ TEST_SPECIAL(cx, sNaN, 1, FE_INVALID);
+ EXPECT_FP_EQ(cx, aNaN);
+ }
+
+ void testX64_80SpecialNumbers(CanonicalizeFunc f) {
+ if constexpr (LIBC_NAMESPACE::fputil::get_fp_type<T>() ==
+ LIBC_NAMESPACE::fputil::FPType::X86_Binary80) {
+ T cx;
+ // Exponent | Significand | Meaning
+ // | Bits 63-62 | Bits 61-0 |
+ // All Ones | 00 | Zero | Pseudo Infinity, Value = Infinty
+
+ FPBits test1((UInt128(0x7FFF) << 64) + UInt128(0x0000000000000000));
+ const T test1_val = test1.get_val();
+ TEST_SPECIAL(cx, test1_val, 0, 0);
+ EXPECT_FP_EQ(cx, inf);
+
+ // Exponent | Significand | Meaning
+ // | Bits 63-62 | Bits 61-0 |
+ // All Ones | 00 | Non-Zero | Pseudo NaN, Value = SNaN
+
+ FPBits test2_1((UInt128(0x7FFF) << 64) + UInt128(0x0000000000000001));
+ const T test2_1_val = test2_1.get_val();
+ TEST_SPECIAL(cx, test2_1_val, 1, FE_INVALID);
+ EXPECT_FP_EQ(cx, aNaN);
+
+ FPBits test2_2((UInt128(0x7FFF) << 64) + UInt128(0x0000004270000001));
+ const T test2_2_val = test2_2.get_val();
+ TEST_SPECIAL(cx, test2_2_val, 1, FE_INVALID);
+ EXPECT_FP_EQ(cx, aNaN);
+
+ FPBits test2_3((UInt128(0x7FFF) << 64) + UInt128(0x0000000008261001));
+ const T test2_3_val = test2_3.get_val();
+ TEST_SPECIAL(cx, test2_3_val, 1, FE_INVALID);
+ EXPECT_FP_EQ(cx, aNaN);
+
+ FPBits test2_4((UInt128(0x7FFF) << 64) + UInt128(0x0000780008261001));
+ const T test2_4_val = test2_4.get_val();
+ TEST_SPECIAL(cx, test2_4_val, 1, FE_INVALID);
+ EXPECT_FP_EQ(cx, aNaN);
+
+ // Exponent | Significand | Meaning
+ // | Bits 63-62 | Bits 61-0 |
+ // All Ones | 01 | Anything | Pseudo NaN, Value = SNaN
+
+ FPBits test3_1((UInt128(0x7FFF) << 64) + UInt128(0x4000000000000000));
+ const T test3_1_val = test3_1.get_val();
+ TEST_SPECIAL(cx, test3_1_val, 1, FE_INVALID);
+ EXPECT_FP_EQ(cx, aNaN);
+
+ FPBits test3_2((UInt128(0x7FFF) << 64) + UInt128(0x4000004270000001));
+ const T test3_2_val = test3_2.get_val();
+ TEST_SPECIAL(cx, test3_2_val, 1, FE_INVALID);
+ EXPECT_FP_EQ(cx, aNaN);
+
+ FPBits test3_3((UInt128(0x7FFF) << 64) + UInt128(0x4000000008261001));
+ const T test3_3_val = test3_3.get_val();
+ TEST_SPECIAL(cx, test3_3_val, 1, FE_INVALID);
+ EXPECT_FP_EQ(cx, aNaN);
+
+ FPBits test3_4((UInt128(0x7FFF) << 64) + UInt128(0x4007800008261001));
+ const T test3_4_val = test3_4.get_val();
+ TEST_SPECIAL(cx, test3_4_val, 1, FE_INVALID);
+ EXPECT_FP_EQ(cx, aNaN);
+
+ // Exponent | Significand | Meaning
+ // | Bit 63 | Bits 62-0 |
+ // All zeroes | One | Anything | Pseudo Denormal, Value =
+ // | | | (−1)**s × m × 2**−16382
+
+ FPBits test4_1((UInt128(0x0000) << 64) + UInt128(0x8000000000000000));
+ const T test4_1_val = test4_1.get_val();
+ TEST_SPECIAL(cx, test4_1_val, 0, 0);
+ EXPECT_FP_EQ(
+ cx, FPBits::make_value(test4_1.get_explicit_mantissa(), 0).get_val());
+
+ FPBits test4_2((UInt128(0x0000) << 64) + UInt128(0x8000004270000001));
+ const T test4_2_val = test4_2.get_val();
+ TEST_SPECIAL(cx, test4_2_val, 0, 0);
+ EXPECT_FP_EQ(
+ cx, FPBits::make_value(test4_2.get_explicit_mantissa(), 0).get_val());
+
+ FPBits test4_3((UInt128(0x0000) << 64) + UInt128(0x8000000008261001));
+ const T test4_3_val = test4_3.get_val();
+ TEST_SPECIAL(cx, test4_3_val, 0, 0);
+ EXPECT_FP_EQ(
+ cx, FPBits::make_value(test4_3.get_explicit_mantissa(), 0).get_val());
+
+ // Exponent | Significand | Meaning
+ // | Bit 63 | Bits 62-0 |
+ // All Other | Zero | Anything | Unnormal, Value =
+ // Values | | | (−1)**s × m × 2**−16382
+
+ FPBits test5_1(UInt128(0x0000000000000001));
+ const T test5_1_val = test5_1.get_val();
+ TEST_SPECIAL(cx, test5_1_val, 0, 0);
+ EXPECT_FP_EQ(
+ cx, FPBits::make_value(test5_1.get_explicit_mantissa(), 0).get_val());
+
+ FPBits test5_2(UInt128(0x0000004270000001));
+ const T test5_2_val = test5_2.get_val();
+ TEST_SPECIAL(cx, test5_2_val, 0, 0);
+ EXPECT_FP_EQ(
+ cx, FPBits::make_value(test5_2.get_explicit_mantissa(), 0).get_val());
+
+ FPBits test5_3(UInt128(0x0000000008261001));
+ const T test5_3_val = test5_3.get_val();
+ TEST_SPECIAL(cx, test5_3_val, 0, 0);
+ EXPECT_FP_EQ(
+ cx, FPBits::make_value(test5_3.get_explicit_mantissa(), 0).get_val());
+
+ FPBits test5_4(UInt128(0x0000002816000000));
+ const T test5_4_val = test5_4.get_val();
+ TEST_SPECIAL(cx, test5_4_val, 0, 0);
+ EXPECT_FP_EQ(
+ cx, FPBits::make_value(test5_4.get_explicit_mantissa(), 0).get_val());
+
+ FPBits test5_5(UInt128(0x0000004270000001));
+ const T test5_5_val = test5_5.get_val();
+ TEST_SPECIAL(cx, test5_5_val, 0, 0);
+ EXPECT_FP_EQ(
+ cx, FPBits::make_value(test5_5.get_explicit_mantissa(), 0).get_val());
+
+ FPBits test5_6(UInt128(0x0000000008261001));
+ const T test5_6_val = test5_6.get_val();
+ TEST_SPECIAL(cx, test5_6_val, 0, 0);
+ EXPECT_FP_EQ(
+ cx, FPBits::make_value(test5_6.get_explicit_mantissa(), 0).get_val());
+ }
+ }
+
+ void testRegularNumbers(CanonicalizeFunc f) {
+ T cx;
+ const T test_var_1 = T(1.0);
+ TEST_REGULAR(cx, test_var_1, 0);
+ EXPECT_FP_EQ(cx, test_var_1);
+ const T test_var_2 = T(-1.0);
+ TEST_REGULAR(cx, test_var_2, 0);
+ EXPECT_FP_EQ(cx, test_var_2);
+ const T test_var_3 = T(10.0);
+ TEST_REGULAR(cx, test_var_3, 0);
+ EXPECT_FP_EQ(cx, test_var_3);
+ const T test_var_4 = T(-10.0);
+ TEST_REGULAR(cx, test_var_4, 0);
+ EXPECT_FP_EQ(cx, test_var_4);
+ const T test_var_5 = T(1234.0);
+ TEST_REGULAR(cx, test_var_5, 0);
+ EXPECT_FP_EQ(cx, test_var_5);
+ const T test_var_6 = T(-1234.0);
+ TEST_REGULAR(cx, test_var_6, 0);
+ EXPECT_FP_EQ(cx, test_var_6);
+ }
+};
+
+#define LIST_CANONICALIZE_TESTS(T, func) \
+ using LlvmLibcCanonicalizeTest = CanonicalizeTest<T>; \
+ TEST_F(LlvmLibcCanonicalizeTest, SpecialNumbers) { \
+ testSpecialNumbers(&func); \
+ } \
+ TEST_F(LlvmLibcCanonicalizeTest, RegularNubmers) { \
+ testRegularNumbers(&func); \
+ }
+
+#define X86_80_SPECIAL_CANONICALIZE_TEST(T, func) \
+ using LlvmLibcCanonicalizeTest = CanonicalizeTest<T>; \
+ TEST_F(LlvmLibcCanonicalizeTest, X64_80SpecialNumbers) { \
+ testX64_80SpecialNumbers(&func); \
+ }
+
+#endif // LLVM_LIBC_TEST_SRC_MATH_SMOKE_CANONICALIZETEST_H
diff --git a/libc/test/src/math/smoke/canonicalize_test.cpp b/libc/test/src/math/smoke/canonicalize_test.cpp
new file mode 100644
index 00000000000000..54a1ddd49ca4ba
--- /dev/null
+++ b/libc/test/src/math/smoke/canonicalize_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for canonicalize ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "CanonicalizeTest.h"
+
+#include "src/math/canonicalize.h"
+
+LIST_CANONICALIZE_TESTS(double, LIBC_NAMESPACE::canonicalize)
diff --git a/libc/test/src/math/smoke/canonicalizef128_test.cpp b/libc/test/src/math/smoke/canonicalizef128_test.cpp
new file mode 100644
index 00000000000000..242e2331a29eac
--- /dev/null
+++ b/libc/test/src/math/smoke/canonicalizef128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for canonicalizef128 ------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "CanonicalizeTest.h"
+
+#include "src/math/canonicalizef128.h"
+
+LIST_CANONICALIZE_TESTS(float128, LIBC_NAMESPACE::canonicalizef128)
diff --git a/libc/test/src/math/smoke/canonicalizef_test.cpp b/libc/test/src/math/smoke/canonicalizef_test.cpp
new file mode 100644
index 00000000000000..17cf3c3639a4aa
--- /dev/null
+++ b/libc/test/src/math/smoke/canonicalizef_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for canonicalizef ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "CanonicalizeTest.h"
+
+#include "src/math/canonicalizef.h"
+
+LIST_CANONICALIZE_TESTS(float, LIBC_NAMESPACE::canonicalizef)
diff --git a/libc/test/src/math/smoke/canonicalizel_test.cpp b/libc/test/src/math/smoke/canonicalizel_test.cpp
new file mode 100644
index 00000000000000..23cb21dce84ea7
--- /dev/null
+++ b/libc/test/src/math/smoke/canonicalizel_test.cpp
@@ -0,0 +1,19 @@
+//===-- Unittests for canonicalizel ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "CanonicalizeTest.h"
+
+#include "src/math/canonicalizel.h"
+
+LIST_CANONICALIZE_TESTS(long double, LIBC_NAMESPACE::canonicalizel)
+
+#ifdef LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
+
+X86_80_SPECIAL_CANONICALIZE_TEST(long double, LIBC_NAMESPACE::canonicalizel)
+
+#endif // LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 0d531a3dc12a7c..0557c3aec0d84e 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -622,6 +622,9 @@ libc_support_library(
name = "__support_fputil_basic_operations",
hdrs = ["src/__support/FPUtil/BasicOperations.h"],
deps = [
+ ":__support_fputil_fenv_impl",
+ ":__support_macros_optimization",
+ ":__support_uint128",
":__support_common",
":__support_cpp_type_traits",
":__support_fputil_fp_bits",
More information about the libc-commits
mailing list