https://github.com/Sukumarsawant updated https://github.com/llvm/llvm-project/pull/238686
>From 3365c377e9c383eca615b4e520a0bfd00c754a48 Mon Sep 17 00:00:00 2001 From: Sukumarsawant <[email protected]> Date: Wed, 4 Nov 2026 10:41:07 +0530 Subject: [PATCH 1/2] adds iscanonicalf80, isnanf80, issignalingf80, canonicalizef80 --- libc/config/baremetal/aarch64/entrypoints.txt | 4 + libc/config/baremetal/arm/entrypoints.txt | 4 + libc/config/baremetal/hexagon/entrypoints.txt | 4 + libc/config/baremetal/riscv/entrypoints.txt | 4 + libc/config/darwin/aarch64/entrypoints.txt | 4 + libc/config/darwin/x86_64/entrypoints.txt | 4 + libc/config/freebsd/x86_64/entrypoints.txt | 4 + libc/config/gpu/amdgpu/entrypoints.txt | 4 + libc/config/gpu/nvptx/entrypoints.txt | 4 + libc/config/linux/aarch64/entrypoints.txt | 4 + libc/config/linux/arm/entrypoints.txt | 4 + libc/config/linux/riscv/entrypoints.txt | 4 + libc/config/linux/x86_64/entrypoints.txt | 4 + libc/config/windows/entrypoints.txt | 4 + libc/docs/headers/math/index.md | 6 +- libc/shared/math.h | 4 + libc/shared/math/canonicalizef80.h | 28 +++++++ libc/shared/math/iscanonicalf80.h | 28 +++++++ libc/shared/math/isnanf80.h | 28 +++++++ libc/shared/math/issignalingf80.h | 28 +++++++ libc/src/__support/math/CMakeLists.txt | 40 ++++++++++ libc/src/__support/math/canonicalizef80.h | 33 ++++++++ libc/src/__support/math/iscanonicalf80.h | 34 +++++++++ libc/src/__support/math/isnanf80.h | 33 ++++++++ libc/src/__support/math/issignalingf80.h | 33 ++++++++ libc/src/math/CMakeLists.txt | 4 + libc/src/math/canonicalizef80.h | 27 +++++++ libc/src/math/generic/CMakeLists.txt | 44 +++++++++++ libc/src/math/generic/canonicalizef80.cpp | 30 ++++++++ libc/src/math/generic/iscanonicalf80.cpp | 26 +++++++ libc/src/math/generic/isnanf80.cpp | 26 +++++++ libc/src/math/generic/issignalingf80.cpp | 26 +++++++ libc/src/math/iscanonicalf80.h | 27 +++++++ libc/src/math/isnanf80.h | 27 +++++++ libc/src/math/issignalingf80.h | 27 +++++++ libc/test/shared/CMakeLists.txt | 8 ++ .../shared/shared_math_constexpr_test.cpp | 8 ++ libc/test/shared/shared_math_test.cpp | 7 ++ libc/test/src/math/smoke/CMakeLists.txt | 55 ++++++++++++++ .../src/math/smoke/canonicalizef80_test.cpp | 22 ++++++ .../src/math/smoke/iscanonicalf80_test.cpp | 21 +++++ libc/test/src/math/smoke/isnanf80_test.cpp | 21 +++++ .../src/math/smoke/issignalingf80_test.cpp | 21 +++++ .../llvm-project-overlay/libc/BUILD.bazel | 76 +++++++++++++++++++ .../libc/test/src/math/smoke/BUILD.bazel | 33 ++++++++ 45 files changed, 884 insertions(+), 3 deletions(-) create mode 100644 libc/shared/math/canonicalizef80.h create mode 100644 libc/shared/math/iscanonicalf80.h create mode 100644 libc/shared/math/isnanf80.h create mode 100644 libc/shared/math/issignalingf80.h create mode 100644 libc/src/__support/math/canonicalizef80.h create mode 100644 libc/src/__support/math/iscanonicalf80.h create mode 100644 libc/src/__support/math/isnanf80.h create mode 100644 libc/src/__support/math/issignalingf80.h create mode 100644 libc/src/math/canonicalizef80.h create mode 100644 libc/src/math/generic/canonicalizef80.cpp create mode 100644 libc/src/math/generic/iscanonicalf80.cpp create mode 100644 libc/src/math/generic/isnanf80.cpp create mode 100644 libc/src/math/generic/issignalingf80.cpp create mode 100644 libc/src/math/iscanonicalf80.h create mode 100644 libc/src/math/isnanf80.h create mode 100644 libc/src/math/issignalingf80.h create mode 100644 libc/test/src/math/smoke/canonicalizef80_test.cpp create mode 100644 libc/test/src/math/smoke/iscanonicalf80_test.cpp create mode 100644 libc/test/src/math/smoke/isnanf80_test.cpp create mode 100644 libc/test/src/math/smoke/issignalingf80_test.cpp diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt index 11ad7feaaabc8..51a7e841be644 100644 --- a/libc/config/baremetal/aarch64/entrypoints.txt +++ b/libc/config/baremetal/aarch64/entrypoints.txt @@ -512,14 +512,17 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.iscanonical libc.src.math.iscanonicalf libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.iscanonicall libc.src.math.isnan libc.src.math.isnanf libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.isnanl libc.src.math.issignaling libc.src.math.issignalingf libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.issignalingl libc.src.math.ldexp libc.src.math.ldexpf @@ -797,6 +800,7 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 _Float128 entrypoints libc.src.math.canonicalizef128 + libc.src.math.canonicalizef80 libc.src.math.daddf128 libc.src.math.ddivf128 libc.src.math.dfmaf128 diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt index b083112410fe6..9dbf5b174f485 100644 --- a/libc/config/baremetal/arm/entrypoints.txt +++ b/libc/config/baremetal/arm/entrypoints.txt @@ -524,14 +524,17 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.iscanonical libc.src.math.iscanonicalf libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.iscanonicall libc.src.math.isnan libc.src.math.isnanf libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.isnanl libc.src.math.issignaling libc.src.math.issignalingf libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.issignalingl libc.src.math.ldexp libc.src.math.ldexpf @@ -808,6 +811,7 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 _Float128 entrypoints libc.src.math.canonicalizef128 + libc.src.math.canonicalizef80 libc.src.math.daddf128 libc.src.math.ddivf128 libc.src.math.dfmaf128 diff --git a/libc/config/baremetal/hexagon/entrypoints.txt b/libc/config/baremetal/hexagon/entrypoints.txt index c4876402a580a..70770f335cea2 100644 --- a/libc/config/baremetal/hexagon/entrypoints.txt +++ b/libc/config/baremetal/hexagon/entrypoints.txt @@ -755,6 +755,7 @@ if(LIBC_TYPES_HAS_FLOAT128) # math.h C23 _Float128 entrypoints libc.src.math.atan2f128 libc.src.math.canonicalizef128 + libc.src.math.canonicalizef80 libc.src.math.ceilf128 libc.src.math.copysignf128 libc.src.math.daddf128 @@ -789,8 +790,11 @@ if(LIBC_TYPES_HAS_FLOAT128) libc.src.math.getpayloadf128 libc.src.math.ilogbf128 libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.ldexpf128 libc.src.math.llogbf128 libc.src.math.llrintf128 diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt index 150b878f27430..50860421640ab 100644 --- a/libc/config/baremetal/riscv/entrypoints.txt +++ b/libc/config/baremetal/riscv/entrypoints.txt @@ -515,14 +515,17 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.iscanonical libc.src.math.iscanonicalf libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.iscanonicall libc.src.math.isnan libc.src.math.isnanf libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.isnanl libc.src.math.issignaling libc.src.math.issignalingf libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.issignalingl libc.src.math.ldexp libc.src.math.ldexpf @@ -800,6 +803,7 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 _Float128 entrypoints libc.src.math.canonicalizef128 + libc.src.math.canonicalizef80 libc.src.math.daddf128 libc.src.math.ddivf128 libc.src.math.dfmaf128 diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt index 791aa7a19c386..d8f87db7b1dfd 100644 --- a/libc/config/darwin/aarch64/entrypoints.txt +++ b/libc/config/darwin/aarch64/entrypoints.txt @@ -333,14 +333,17 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.iscanonical libc.src.math.iscanonicalf libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.iscanonicall libc.src.math.isnan libc.src.math.isnanf libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.isnanl libc.src.math.issignaling libc.src.math.issignalingf libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.issignalingl libc.src.math.ldexp libc.src.math.ldexpf @@ -619,6 +622,7 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 _Float128 entrypoints libc.src.math.canonicalizef128 + libc.src.math.canonicalizef80 libc.src.math.daddf128 libc.src.math.ddivf128 libc.src.math.dfmaf128 diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt index 62479a8693e54..2ed69d3132f66 100644 --- a/libc/config/darwin/x86_64/entrypoints.txt +++ b/libc/config/darwin/x86_64/entrypoints.txt @@ -200,8 +200,11 @@ set(TARGET_LIBM_ENTRYPOINTS #libc.src.math.ilogbf128 #libc.src.math.ilogbl #libc.src.math.iscanonicalf128 + #libc.src.math.iscanonicalf80 #libc.src.math.isnanf128 + #libc.src.math.isnanf80 #libc.src.math.issignalingf128 + #libc.src.math.issignalingf80 #libc.src.math.llogbf128 #libc.src.math.llrint #libc.src.math.llrintf @@ -303,6 +306,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS libc.src.math.bf16subf libc.src.math.bf16subl libc.src.math.canonicalizebf16 + libc.src.math.canonicalizef80 libc.src.math.ceilbf16 libc.src.math.copysignbf16 libc.src.math.exp2bf16 diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt index a01c3bd6b9135..58e01f56eb2e6 100644 --- a/libc/config/freebsd/x86_64/entrypoints.txt +++ b/libc/config/freebsd/x86_64/entrypoints.txt @@ -245,8 +245,11 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.ilogbf128 libc.src.math.ilogbl libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.ldexp libc.src.math.ldexpf libc.src.math.ldexpf128 @@ -552,6 +555,7 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS libc.src.math.atan2l libc.src.math.canonicalizef128 + libc.src.math.canonicalizef80 libc.src.math.daddf128 libc.src.math.ddivf128 libc.src.math.dfmaf128 diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt index 026436dfab966..89f406302063f 100644 --- a/libc/config/gpu/amdgpu/entrypoints.txt +++ b/libc/config/gpu/amdgpu/entrypoints.txt @@ -318,6 +318,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.canonicalize libc.src.math.canonicalizef libc.src.math.canonicalizel + libc.src.math.canonicalizef80 libc.src.math.cbrt libc.src.math.cbrtf libc.src.math.cbrtbf16 @@ -452,11 +453,14 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.ilogbf128 libc.src.math.ilogbl libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.isnan libc.src.math.isnanf libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.isnanl libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.ldexp libc.src.math.ldexpf libc.src.math.ldexpf128 diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt index b98fb8a7e902f..d4711b17cdc86 100644 --- a/libc/config/gpu/nvptx/entrypoints.txt +++ b/libc/config/gpu/nvptx/entrypoints.txt @@ -314,6 +314,7 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.canonicalize libc.src.math.canonicalizef libc.src.math.canonicalizel + libc.src.math.canonicalizef80 libc.src.math.cbrt libc.src.math.cbrtf libc.src.math.cbrtbf16 @@ -449,11 +450,14 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.ilogbf128 libc.src.math.ilogbl libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.isnan libc.src.math.isnanf libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.isnanl libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.ldexp libc.src.math.ldexpf libc.src.math.ldexpf128 diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index f504f087515d4..f8ec339978c09 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -755,14 +755,17 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.iscanonical libc.src.math.iscanonicalf libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.iscanonicall libc.src.math.isnan libc.src.math.isnanf libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.isnanl libc.src.math.issignaling libc.src.math.issignalingf libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.issignalingl libc.src.math.ldexp libc.src.math.ldexpf @@ -1034,6 +1037,7 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) list(APPEND TARGET_LIBM_ENTRYPOINTS # math.h C23 _Float128 entrypoints libc.src.math.canonicalizef128 + libc.src.math.canonicalizef80 libc.src.math.daddf128 libc.src.math.ddivf128 libc.src.math.dfmaf128 diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt index 1581714356562..4ecc4fb107c43 100644 --- a/libc/config/linux/arm/entrypoints.txt +++ b/libc/config/linux/arm/entrypoints.txt @@ -542,8 +542,11 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.ilogbf128 libc.src.math.ilogbl libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.ldexp libc.src.math.ldexpf libc.src.math.ldexpf128 @@ -695,6 +698,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS libc.src.math.bf16subf libc.src.math.bf16subl libc.src.math.canonicalizebf16 + libc.src.math.canonicalizef80 libc.src.math.ceilbf16 libc.src.math.copysignbf16 libc.src.math.exp2bf16 diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt index 9d354ab9a0ff1..3282e0963429a 100644 --- a/libc/config/linux/riscv/entrypoints.txt +++ b/libc/config/linux/riscv/entrypoints.txt @@ -818,14 +818,17 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.iscanonical libc.src.math.iscanonicalf libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.iscanonicall libc.src.math.isnan libc.src.math.isnanf libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.isnanl libc.src.math.issignaling libc.src.math.issignalingf libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.issignalingl libc.src.math.ldexp libc.src.math.ldexpf @@ -1114,6 +1117,7 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) # math.h C23 _Float128 entrypoints libc.src.math.atan2l libc.src.math.canonicalizef128 + libc.src.math.canonicalizef80 libc.src.math.daddf128 libc.src.math.ddivf128 libc.src.math.dfmaf128 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index 091580ee6ff9f..f98111980f480 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -840,14 +840,17 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.iscanonical libc.src.math.iscanonicalf libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.iscanonicall libc.src.math.isnan libc.src.math.isnanf libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.isnanl libc.src.math.issignaling libc.src.math.issignalingf libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.issignalingl libc.src.math.ldexp libc.src.math.ldexpf @@ -1136,6 +1139,7 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128) # math.h C23 _Float128 entrypoints libc.src.math.atan2l libc.src.math.canonicalizef128 + libc.src.math.canonicalizef80 libc.src.math.daddf128 libc.src.math.ddivf128 libc.src.math.dfmaf128 diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt index 2805795f0b85f..11c9a454e69a1 100644 --- a/libc/config/windows/entrypoints.txt +++ b/libc/config/windows/entrypoints.txt @@ -278,8 +278,11 @@ set(TARGET_LIBM_ENTRYPOINTS libc.src.math.ilogbf128 libc.src.math.ilogbl libc.src.math.iscanonicalf128 + libc.src.math.iscanonicalf80 libc.src.math.isnanf128 + libc.src.math.isnanf80 libc.src.math.issignalingf128 + libc.src.math.issignalingf80 libc.src.math.ldexp libc.src.math.ldexpf libc.src.math.ldexpf128 @@ -402,6 +405,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS libc.src.math.bf16subf libc.src.math.bf16subl libc.src.math.canonicalizebf16 + libc.src.math.canonicalizef80 libc.src.math.ceilbf16 libc.src.math.copysignbf16 libc.src.math.exp2bf16 diff --git a/libc/docs/headers/math/index.md b/libc/docs/headers/math/index.md index 8df3cd80e3499..897e6d3186949 100644 --- a/libc/docs/headers/math/index.md +++ b/libc/docs/headers/math/index.md @@ -90,7 +90,7 @@ log | \<Func> | \<Func_f> (float) | \<Func> (double) | \<Func_f80> (f80) | \<Func> (double-double) | \<Func_f16> (float16) | \<Func_f128> (float128) | \<Func_bf16> (bfloat16) | C23 Definition Section | C23 Error Handling Section | | ---------------- | ----------------- | ---------------- | ----------------- | ----------------------- | --------------------- | ----------------------- | ----------------------- | ---------------------- | -------------------------- | | ceil | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.9.1 | F.10.6.1 | -| canonicalize | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.11.7 | F.10.8.7 | +| canonicalize | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.11.7 | F.10.8.7 | | copysign | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.11.1 | F.10.8.1 | | dadd | N/A | N/A | | | N/A | {{ check }}\* | N/A | 7.12.14.1 | F.10.11 | | ddiv | N/A | N/A | | | N/A | {{ check }}\* | N/A | 7.12.14.4 | F.10.11 | @@ -131,8 +131,8 @@ log | fsub | N/A | {{ check }} | | | N/A | {{ check }}\* | N/A | 7.12.14.2 | F.10.11 | | getpayload | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | F.10.13.1 | N/A | | ilogb | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.8 | F.10.3.8 | -| iscanonical | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.3.2 | N/A | -| issignaling | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.3.8 | N/A | +| iscanonical | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.3.2 | N/A | +| issignaling | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.3.8 | N/A | | ldexp | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.9 | F.10.3.9 | | llogb | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.10 | F.10.3.10 | | llrint | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.9.5 | F.10.6.5 | diff --git a/libc/shared/math.h b/libc/shared/math.h index 5c9dffcb513c2..5a058776ed631 100644 --- a/libc/shared/math.h +++ b/libc/shared/math.h @@ -63,6 +63,7 @@ #include "math/canonicalizebf16.h" #include "math/canonicalizef.h" #include "math/canonicalizef128.h" +#include "math/canonicalizef80.h" #include "math/canonicalizef16.h" #include "math/canonicalizel.h" #include "math/cbrt.h" @@ -304,12 +305,14 @@ #include "math/iscanonicalbf16.h" #include "math/iscanonicalf.h" #include "math/iscanonicalf128.h" +#include "math/iscanonicalf80.h" #include "math/iscanonicalf16.h" #include "math/iscanonicall.h" // TODO: isnan is a macro in <math.h> // #include "math/isnan.h" #include "math/isnanf.h" #include "math/isnanf128.h" +#include "math/isnanf80.h" #include "math/isnanf16.h" #include "math/isnanl.h" // TODO: issignaling is a macro in <math.h> @@ -317,6 +320,7 @@ #include "math/issignalingbf16.h" #include "math/issignalingf.h" #include "math/issignalingf128.h" +#include "math/issignalingf80.h" #include "math/issignalingf16.h" #include "math/issignalingl.h" #include "math/ldexp.h" diff --git a/libc/shared/math/canonicalizef80.h b/libc/shared/math/canonicalizef80.h new file mode 100644 index 0000000000000..1a771dc2bc2fc --- /dev/null +++ b/libc/shared/math/canonicalizef80.h @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Shared canonicalizef80 function. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SHARED_MATH_CANONICALIZEF80_H +#define LLVM_LIBC_SHARED_MATH_CANONICALIZEF80_H + +#include "shared/libc_common.h" +#include "src/__support/math/canonicalizef80.h" + +namespace LIBC_NAMESPACE_DECL { +namespace shared { + +using math::canonicalizef80; + +} // namespace shared +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SHARED_MATH_CANONICALIZEF80_H diff --git a/libc/shared/math/iscanonicalf80.h b/libc/shared/math/iscanonicalf80.h new file mode 100644 index 0000000000000..27b8a1116a390 --- /dev/null +++ b/libc/shared/math/iscanonicalf80.h @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Shared iscanonicalf80 function. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SHARED_MATH_ISCANONICALF80_H +#define LLVM_LIBC_SHARED_MATH_ISCANONICALF80_H + +#include "shared/libc_common.h" +#include "src/__support/math/iscanonicalf80.h" + +namespace LIBC_NAMESPACE_DECL { +namespace shared { + +using math::iscanonicalf80; + +} // namespace shared +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SHARED_MATH_ISCANONICALF80_H diff --git a/libc/shared/math/isnanf80.h b/libc/shared/math/isnanf80.h new file mode 100644 index 0000000000000..9f7011509432e --- /dev/null +++ b/libc/shared/math/isnanf80.h @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Shared isnanf80 function. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SHARED_MATH_ISNANF80_H +#define LLVM_LIBC_SHARED_MATH_ISNANF80_H + +#include "shared/libc_common.h" +#include "src/__support/math/isnanf80.h" + +namespace LIBC_NAMESPACE_DECL { +namespace shared { + +using math::isnanf80; + +} // namespace shared +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SHARED_MATH_ISNANF80_H diff --git a/libc/shared/math/issignalingf80.h b/libc/shared/math/issignalingf80.h new file mode 100644 index 0000000000000..7594c2d4b9ebf --- /dev/null +++ b/libc/shared/math/issignalingf80.h @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Shared issignalingf80 function. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SHARED_MATH_ISSIGNALINGF80_H +#define LLVM_LIBC_SHARED_MATH_ISSIGNALINGF80_H + +#include "shared/libc_common.h" +#include "src/__support/math/issignalingf80.h" + +namespace LIBC_NAMESPACE_DECL { +namespace shared { + +using math::issignalingf80; + +} // namespace shared +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SHARED_MATH_ISSIGNALINGF80_H diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt index d14a52716643a..e96433f83d153 100644 --- a/libc/src/__support/math/CMakeLists.txt +++ b/libc/src/__support/math/CMakeLists.txt @@ -697,6 +697,16 @@ add_header_library( libc.src.__support.macros.config ) +add_header_library( + canonicalizef80 + HDRS + canonicalizef80.h + DEPENDS + libc.src.__support.FPUtil.basic_operations + libc.src.__support.FPUtil.float80 + libc.src.__support.macros.config +) + add_header_library( canonicalizef16 HDRS @@ -1780,6 +1790,16 @@ add_header_library( libc.src.__support.macros.config ) +add_header_library( + iscanonicalf80 + HDRS + iscanonicalf80.h + DEPENDS + libc.src.__support.FPUtil.float80 + libc.src.__support.FPUtil.basic_operations + libc.src.__support.macros.config +) + add_header_library( iscanonicalf16 HDRS @@ -1827,6 +1847,16 @@ add_header_library( libc.src.__support.macros.config ) +add_header_library( + isnanf80 + HDRS + isnanf80.h + DEPENDS + libc.src.__support.FPUtil.float80 + libc.src.__support.FPUtil.fp_bits + libc.src.__support.macros.config +) + add_header_library( isnanl HDRS @@ -1884,6 +1914,16 @@ add_header_library( libc.src.__support.macros.config ) +add_header_library( + issignalingf80 + HDRS + issignalingf80.h + DEPENDS + libc.src.__support.FPUtil.float80 + libc.src.__support.FPUtil.basic_operations + libc.src.__support.macros.config +) + add_header_library( issignalingf16 HDRS diff --git a/libc/src/__support/math/canonicalizef80.h b/libc/src/__support/math/canonicalizef80.h new file mode 100644 index 0000000000000..7435070985cc4 --- /dev/null +++ b/libc/src/__support/math/canonicalizef80.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Implementation of the canonicalizef80 function. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF80_H +#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF80_H + +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/FPUtil/float80.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { +namespace math { + +using LIBC_NAMESPACE::fputil::Float80; + +LIBC_INLINE constexpr int canonicalizef80(Float80 *cx, const Float80 *x) { + return fputil::canonicalize(*cx, *x); +} + +} // namespace math +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF80_H diff --git a/libc/src/__support/math/iscanonicalf80.h b/libc/src/__support/math/iscanonicalf80.h new file mode 100644 index 0000000000000..b2b8b51ccf401 --- /dev/null +++ b/libc/src/__support/math/iscanonicalf80.h @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Implementation of the iscanonicalf80 function. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ISCANONICALF80_H +#define LLVM_LIBC_SRC___SUPPORT_MATH_ISCANONICALF80_H + +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/FPUtil/float80.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { +namespace math { + +using LIBC_NAMESPACE::fputil::Float80; + +LIBC_INLINE constexpr int iscanonicalf80(Float80 x) { + Float80 temp{}; + return fputil::canonicalize(temp, x) == 0; +} + +} // namespace math +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC___SUPPORT_MATH_ISCANONICALF80_H diff --git a/libc/src/__support/math/isnanf80.h b/libc/src/__support/math/isnanf80.h new file mode 100644 index 0000000000000..00f434c4599ce --- /dev/null +++ b/libc/src/__support/math/isnanf80.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Implementation of the isnanf80 function. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ISNANF80_H +#define LLVM_LIBC_SRC___SUPPORT_MATH_ISNANF80_H + +#include "src/__support/FPUtil/FPBits.h" +#include "src/__support/FPUtil/float80.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { +namespace math { + +using LIBC_NAMESPACE::fputil::Float80; + +LIBC_INLINE LIBC_CONSTEXPR int isnanf80(Float80 x) { + return fputil::FPBits<Float80>(x).is_nan(); +} + +} // namespace math +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC___SUPPORT_MATH_ISNANF80_H diff --git a/libc/src/__support/math/issignalingf80.h b/libc/src/__support/math/issignalingf80.h new file mode 100644 index 0000000000000..9602d8723b040 --- /dev/null +++ b/libc/src/__support/math/issignalingf80.h @@ -0,0 +1,33 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Implementation of the issignalingf80 function. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ISSIGNALINGF80_H +#define LLVM_LIBC_SRC___SUPPORT_MATH_ISSIGNALINGF80_H + +#include "src/__support/FPUtil/BasicOperations.h" +#include "src/__support/FPUtil/float80.h" +#include "src/__support/macros/config.h" + +namespace LIBC_NAMESPACE_DECL { +namespace math { + +using LIBC_NAMESPACE::fputil::Float80; + +LIBC_INLINE constexpr int issignalingf80(Float80 x) { + return fputil::issignaling_impl(x); +} + +} // namespace math +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC___SUPPORT_MATH_ISSIGNALINGF80_H diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index b5aa8dc5f8d14..d642038357981 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -87,6 +87,7 @@ add_math_entrypoint_object(canonicalizef) add_math_entrypoint_object(canonicalizel) add_math_entrypoint_object(canonicalizef16) add_math_entrypoint_object(canonicalizef128) +add_math_entrypoint_object(canonicalizef80) add_math_entrypoint_object(canonicalizebf16) add_math_entrypoint_object(iscanonical) @@ -94,6 +95,7 @@ add_math_entrypoint_object(iscanonicalf) add_math_entrypoint_object(iscanonicall) add_math_entrypoint_object(iscanonicalf16) add_math_entrypoint_object(iscanonicalf128) +add_math_entrypoint_object(iscanonicalf80) add_math_entrypoint_object(iscanonicalbf16) add_math_entrypoint_object(cbrt) @@ -386,6 +388,7 @@ add_math_entrypoint_object(isnan) add_math_entrypoint_object(isnanf) add_math_entrypoint_object(isnanf16) add_math_entrypoint_object(isnanf128) +add_math_entrypoint_object(isnanf80) add_math_entrypoint_object(isnanl) add_math_entrypoint_object(issignaling) @@ -393,6 +396,7 @@ add_math_entrypoint_object(issignalingf) add_math_entrypoint_object(issignalingl) add_math_entrypoint_object(issignalingf16) add_math_entrypoint_object(issignalingf128) +add_math_entrypoint_object(issignalingf80) add_math_entrypoint_object(issignalingbf16) add_math_entrypoint_object(lgammaf) diff --git a/libc/src/math/canonicalizef80.h b/libc/src/math/canonicalizef80.h new file mode 100644 index 0000000000000..9b2183b6c0dba --- /dev/null +++ b/libc/src/math/canonicalizef80.h @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Public declaration of the canonicalizef80 entrypoint. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_MATH_CANONICALIZEF80_H +#define LLVM_LIBC_SRC_MATH_CANONICALIZEF80_H + +#include "src/__support/FPUtil/float80.h" +#include "src/__support/macros/config.h" +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE_DECL { + +int canonicalizef80(float80 *cx, const float80 *x); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_CANONICALIZEF80_H diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index e7511ba7fbe82..72e6967363566 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -40,6 +40,17 @@ add_entrypoint_object( libc.src.__support.math.canonicalizef128 ) +add_entrypoint_object( + canonicalizef80 + SRCS + canonicalizef80.cpp + HDRS + ../canonicalizef80.h + DEPENDS + libc.src.__support.CPP.bit + libc.src.__support.math.canonicalizef80 +) + add_entrypoint_object( canonicalizel SRCS @@ -105,6 +116,17 @@ add_entrypoint_object( libc.src.__support.math.iscanonicalf128 ) +add_entrypoint_object( + iscanonicalf80 + SRCS + iscanonicalf80.cpp + HDRS + ../iscanonicalf80.h + DEPENDS + libc.src.__support.CPP.bit + libc.src.__support.math.iscanonicalf80 +) + add_entrypoint_object( iscanonicalbf16 SRCS @@ -3202,6 +3224,17 @@ add_entrypoint_object( libc.src.__support.math.issignalingf128 ) +add_entrypoint_object( + issignalingf80 + SRCS + issignalingf80.cpp + HDRS + ../issignalingf80.h + DEPENDS + libc.src.__support.CPP.bit + libc.src.__support.math.issignalingf80 +) + add_entrypoint_object( issignalingbf16 SRCS @@ -3243,6 +3276,17 @@ add_entrypoint_object( libc.src.__support.math.isnanf128 ) +add_entrypoint_object( + isnanf80 + SRCS + isnanf80.cpp + HDRS + ../isnanf80.h + DEPENDS + libc.src.__support.CPP.bit + libc.src.__support.math.isnanf80 +) + add_entrypoint_object( isnanl SRCS diff --git a/libc/src/math/generic/canonicalizef80.cpp b/libc/src/math/generic/canonicalizef80.cpp new file mode 100644 index 0000000000000..f6ae1c73ce521 --- /dev/null +++ b/libc/src/math/generic/canonicalizef80.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Implementation of the canonicalizef80 function. +/// +//===----------------------------------------------------------------------===// + +#include "src/math/canonicalizef80.h" +#include "src/__support/CPP/bit.h" +#include "src/__support/math/canonicalizef80.h" + +namespace LIBC_NAMESPACE_DECL { + +using LIBC_NAMESPACE::fputil::Float80; + +LLVM_LIBC_FUNCTION(int, canonicalizef80, (float80 *cx, const float80 *x)) { + Float80 cx_f80 = cpp::bit_cast<Float80>(*cx); + Float80 x_f80 = cpp::bit_cast<Float80>(*x); + int res = math::canonicalizef80(&cx_f80, &x_f80); + *cx = cpp::bit_cast<float80>(cx_f80); + return res; +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/iscanonicalf80.cpp b/libc/src/math/generic/iscanonicalf80.cpp new file mode 100644 index 0000000000000..970ffdec62fea --- /dev/null +++ b/libc/src/math/generic/iscanonicalf80.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Implementation of the iscanonicalf80 function. +/// +//===----------------------------------------------------------------------===// + +#include "src/math/iscanonicalf80.h" +#include "src/__support/CPP/bit.h" +#include "src/__support/math/iscanonicalf80.h" + +namespace LIBC_NAMESPACE_DECL { + +using LIBC_NAMESPACE::fputil::Float80; + +LLVM_LIBC_FUNCTION(int, iscanonicalf80, (float80 x)) { + return math::iscanonicalf80(cpp::bit_cast<Float80>(x)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/isnanf80.cpp b/libc/src/math/generic/isnanf80.cpp new file mode 100644 index 0000000000000..93d11b7987d29 --- /dev/null +++ b/libc/src/math/generic/isnanf80.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Implementation of the isnanf80 function. +/// +//===----------------------------------------------------------------------===// + +#include "src/math/isnanf80.h" +#include "src/__support/CPP/bit.h" +#include "src/__support/math/isnanf80.h" + +namespace LIBC_NAMESPACE_DECL { + +using LIBC_NAMESPACE::fputil::Float80; + +LLVM_LIBC_FUNCTION(int, isnanf80, (float80 x)) { + return math::isnanf80(cpp::bit_cast<Float80>(x)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/generic/issignalingf80.cpp b/libc/src/math/generic/issignalingf80.cpp new file mode 100644 index 0000000000000..384bf7f9931d0 --- /dev/null +++ b/libc/src/math/generic/issignalingf80.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Implementation of the issignalingf80 function. +/// +//===----------------------------------------------------------------------===// + +#include "src/math/issignalingf80.h" +#include "src/__support/CPP/bit.h" +#include "src/__support/math/issignalingf80.h" + +namespace LIBC_NAMESPACE_DECL { + +using LIBC_NAMESPACE::fputil::Float80; + +LLVM_LIBC_FUNCTION(int, issignalingf80, (float80 x)) { + return math::issignalingf80(cpp::bit_cast<Float80>(x)); +} + +} // namespace LIBC_NAMESPACE_DECL diff --git a/libc/src/math/iscanonicalf80.h b/libc/src/math/iscanonicalf80.h new file mode 100644 index 0000000000000..304d2b96e1203 --- /dev/null +++ b/libc/src/math/iscanonicalf80.h @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Public declaration of the iscanonicalf80 entrypoint. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_MATH_ISCANONICALF80_H +#define LLVM_LIBC_SRC_MATH_ISCANONICALF80_H + +#include "src/__support/FPUtil/float80.h" +#include "src/__support/macros/config.h" +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE_DECL { + +int iscanonicalf80(float80 x); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_ISCANONICALF80_H diff --git a/libc/src/math/isnanf80.h b/libc/src/math/isnanf80.h new file mode 100644 index 0000000000000..f208e90027800 --- /dev/null +++ b/libc/src/math/isnanf80.h @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Public declaration of the isnanf80 entrypoint. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_MATH_ISNANF80_H +#define LLVM_LIBC_SRC_MATH_ISNANF80_H + +#include "src/__support/FPUtil/float80.h" +#include "src/__support/macros/config.h" +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE_DECL { + +int isnanf80(float80 x); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_ISNANF80_H diff --git a/libc/src/math/issignalingf80.h b/libc/src/math/issignalingf80.h new file mode 100644 index 0000000000000..c59582e893d0b --- /dev/null +++ b/libc/src/math/issignalingf80.h @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Public declaration of the issignalingf80 entrypoint. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_MATH_ISSIGNALINGF80_H +#define LLVM_LIBC_SRC_MATH_ISSIGNALINGF80_H + +#include "src/__support/FPUtil/float80.h" +#include "src/__support/macros/config.h" +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE_DECL { + +int issignalingf80(float80 x); + +} // namespace LIBC_NAMESPACE_DECL + +#endif // LLVM_LIBC_SRC_MATH_ISSIGNALINGF80_H diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt index 8a0e371efa7b8..88e3d044dc554 100644 --- a/libc/test/shared/CMakeLists.txt +++ b/libc/test/shared/CMakeLists.txt @@ -79,6 +79,7 @@ else() libc.src.__support.math.canonicalizebf16 libc.src.__support.math.canonicalizef libc.src.__support.math.canonicalizef128 + libc.src.__support.math.canonicalizef80 libc.src.__support.math.canonicalizef16 libc.src.__support.math.canonicalizel libc.src.__support.math.cbrt @@ -318,17 +319,20 @@ else() libc.src.__support.math.iscanonicalbf16 libc.src.__support.math.iscanonicalf libc.src.__support.math.iscanonicalf128 + libc.src.__support.math.iscanonicalf80 libc.src.__support.math.iscanonicalf16 libc.src.__support.math.iscanonicall libc.src.__support.math.isnan libc.src.__support.math.isnanf libc.src.__support.math.isnanf128 + libc.src.__support.math.isnanf80 libc.src.__support.math.isnanf16 libc.src.__support.math.isnanl libc.src.__support.math.issignaling libc.src.__support.math.issignalingbf16 libc.src.__support.math.issignalingf libc.src.__support.math.issignalingf128 + libc.src.__support.math.issignalingf80 libc.src.__support.math.issignalingf16 libc.src.__support.math.issignalingl libc.src.__support.math.ldexp @@ -562,6 +566,7 @@ else() libc.src.__support.math.canonicalizebf16 libc.src.__support.math.canonicalizef libc.src.__support.math.canonicalizef128 + libc.src.__support.math.canonicalizef80 libc.src.__support.math.canonicalizef16 libc.src.__support.math.canonicalizel libc.src.__support.math.ceil @@ -715,17 +720,20 @@ else() libc.src.__support.math.iscanonicalbf16 libc.src.__support.math.iscanonicalf libc.src.__support.math.iscanonicalf128 + libc.src.__support.math.iscanonicalf80 libc.src.__support.math.iscanonicalf16 libc.src.__support.math.iscanonicall libc.src.__support.math.isnan libc.src.__support.math.isnanf libc.src.__support.math.isnanf128 + libc.src.__support.math.isnanf80 libc.src.__support.math.isnanf16 libc.src.__support.math.isnanl libc.src.__support.math.issignaling libc.src.__support.math.issignalingbf16 libc.src.__support.math.issignalingf libc.src.__support.math.issignalingf128 + libc.src.__support.math.issignalingf80 libc.src.__support.math.issignalingf16 libc.src.__support.math.issignalingl libc.src.__support.math.ldexp diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp index 6d5f06531d156..4543e4e5f785f 100644 --- a/libc/test/shared/shared_math_constexpr_test.cpp +++ b/libc/test/shared/shared_math_constexpr_test.cpp @@ -453,6 +453,14 @@ constexpr Float80 TOTALORDERMAGF80_Y = Float80(0.0); static_assert(1 == LIBC_NAMESPACE::shared::totalordermagf80(&TOTALORDERMAGF80_X, &TOTALORDERMAGF80_Y)); +static_assert(1 == LIBC_NAMESPACE::shared::iscanonicalf80(Float80(0.0))); +static_assert(0 == LIBC_NAMESPACE::shared::isnanf80(Float80(0.0))); +static_assert(0 == LIBC_NAMESPACE::shared::issignalingf80(Float80(0.0))); +static_assert(0 == [] { + Float80 cx(0.0); + Float80 x(0.0); + return LIBC_NAMESPACE::shared::canonicalizef80(&cx, &x); +}()); static_assert(Float128(1.0) == LIBC_NAMESPACE::shared::fdimf128(Float128(1.0), Float128(0.0))); static_assert(Float128(0.0) == diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp index 524513f66eb06..8e1d98ee2a008 100644 --- a/libc/test/shared/shared_math_test.cpp +++ b/libc/test/shared/shared_math_test.cpp @@ -714,6 +714,13 @@ TEST(LlvmLibcSharedMathTest, AllFloat80) { Float80 totalordermagf80_y = Float80(0.0); EXPECT_EQ(1, LIBC_NAMESPACE::shared::totalordermagf80(&totalordermagf80_x, &totalordermagf80_y)); + EXPECT_EQ(1, LIBC_NAMESPACE::shared::iscanonicalf80(Float80(0.0))); + EXPECT_EQ(0, LIBC_NAMESPACE::shared::isnanf80(Float80(0.0))); + EXPECT_EQ(0, LIBC_NAMESPACE::shared::issignalingf80(Float80(0.0))); + Float80 canonicalizef80_cx = Float80(0.0); + Float80 canonicalizef80_x = Float80(0.0); + EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef80(&canonicalizef80_cx, + &canonicalizef80_x)); } #ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128 diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index b1cebbf92b7ca..a206d328ceb35 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -465,6 +465,22 @@ add_fp_unittest( libc.src.__support.integer_literals ) +add_fp_unittest( + canonicalizef80_test + SUITE + libc-math-smoke-tests + SRCS + canonicalizef80_test.cpp + HDRS + CanonicalizeTest.h + DEPENDS + libc.src.math.canonicalizef80 + libc.src.__support.FPUtil.float80 + libc.src.__support.FPUtil.fp_bits + libc.src.__support.FPUtil.fenv_impl + libc.src.__support.integer_literals +) + add_fp_unittest( canonicalizel_test SUITE @@ -557,6 +573,19 @@ add_fp_unittest( libc.src.math.iscanonicalf128 ) +add_fp_unittest( + iscanonicalf80_test + SUITE + libc-math-smoke-tests + SRCS + iscanonicalf80_test.cpp + HDRS + IsCanonicalTest.h + DEPENDS + libc.src.__support.FPUtil.float80 + libc.src.math.iscanonicalf80 +) + add_fp_unittest( iscanonicalbf16_test SUITE @@ -583,6 +612,19 @@ add_fp_unittest( libc.src.math.isnanf128 ) +add_fp_unittest( + isnanf80_test + SUITE + libc-math-smoke-tests + SRCS + isnanf80_test.cpp + HDRS + IsNanTest.h + DEPENDS + libc.src.__support.FPUtil.float80 + libc.src.math.isnanf80 +) + add_fp_unittest( ceil_test SUITE @@ -2229,6 +2271,19 @@ add_fp_unittest( libc.src.math.issignalingf128 ) +add_fp_unittest( + issignalingf80_test + SUITE + libc-math-smoke-tests + SRCS + issignalingf80_test.cpp + HDRS + IsSignalingTest.h + DEPENDS + libc.src.__support.FPUtil.float80 + libc.src.math.issignalingf80 +) + add_fp_unittest( issignalingbf16_test SUITE diff --git a/libc/test/src/math/smoke/canonicalizef80_test.cpp b/libc/test/src/math/smoke/canonicalizef80_test.cpp new file mode 100644 index 0000000000000..b7a3764582396 --- /dev/null +++ b/libc/test/src/math/smoke/canonicalizef80_test.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Smoke tests for canonicalizef80. +/// +//===----------------------------------------------------------------------===// + +#include "CanonicalizeTest.h" + +#include "src/__support/FPUtil/float80.h" +#include "src/math/canonicalizef80.h" + +using LIBC_NAMESPACE::fputil::Float80; + +LIST_CANONICALIZE_TESTS(Canonicalizef80, Float80, + LIBC_NAMESPACE::canonicalizef80) diff --git a/libc/test/src/math/smoke/iscanonicalf80_test.cpp b/libc/test/src/math/smoke/iscanonicalf80_test.cpp new file mode 100644 index 0000000000000..6a295d6c695b2 --- /dev/null +++ b/libc/test/src/math/smoke/iscanonicalf80_test.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Smoke tests for iscanonicalf80. +/// +//===----------------------------------------------------------------------===// + +#include "IsCanonicalTest.h" + +#include "src/__support/FPUtil/float80.h" +#include "src/math/iscanonicalf80.h" + +using LIBC_NAMESPACE::fputil::Float80; + +LIST_ISCANONICAL_TESTS(Iscanonicalf80, Float80, LIBC_NAMESPACE::iscanonicalf80) diff --git a/libc/test/src/math/smoke/isnanf80_test.cpp b/libc/test/src/math/smoke/isnanf80_test.cpp new file mode 100644 index 0000000000000..20daacd990ac5 --- /dev/null +++ b/libc/test/src/math/smoke/isnanf80_test.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Smoke tests for isnanf80. +/// +//===----------------------------------------------------------------------===// + +#include "IsNanTest.h" + +#include "src/__support/FPUtil/float80.h" +#include "src/math/isnanf80.h" + +using LIBC_NAMESPACE::fputil::Float80; + +LIST_ISNAN_TESTS(Isnanf80, Float80, LIBC_NAMESPACE::isnanf80) diff --git a/libc/test/src/math/smoke/issignalingf80_test.cpp b/libc/test/src/math/smoke/issignalingf80_test.cpp new file mode 100644 index 0000000000000..34b25d4d6b619 --- /dev/null +++ b/libc/test/src/math/smoke/issignalingf80_test.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Smoke tests for issignalingf80. +/// +//===----------------------------------------------------------------------===// + +#include "IsSignalingTest.h" + +#include "src/__support/FPUtil/float80.h" +#include "src/math/issignalingf80.h" + +using LIBC_NAMESPACE::fputil::Float80; + +LIST_ISSIGNALING_TESTS(Issignalingf80, Float80, LIBC_NAMESPACE::issignalingf80) diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel index 473f6ca5ee966..a3111da849026 100644 --- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel @@ -7031,6 +7031,16 @@ libc_support_library( ], ) +libc_support_library( + name = "__support_math_canonicalizef80", + hdrs = ["src/__support/math/canonicalizef80.h"], + deps = [ + ":__support_fputil_basic_operations", + ":__support_fputil_float80", + ":__support_macros_config", + ], +) + libc_support_library( name = "__support_math_canonicalizef16", hdrs = ["src/__support/math/canonicalizef16.h"], @@ -8126,6 +8136,16 @@ libc_support_library( ], ) +libc_support_library( + name = "__support_math_iscanonicalf80", + hdrs = ["src/__support/math/iscanonicalf80.h"], + deps = [ + ":__support_fputil_basic_operations", + ":__support_fputil_float80", + ":__support_macros_config", + ], +) + libc_support_library( name = "__support_math_iscanonicalf16", hdrs = ["src/__support/math/iscanonicalf16.h"], @@ -8173,6 +8193,16 @@ libc_support_library( ], ) +libc_support_library( + name = "__support_math_isnanf80", + hdrs = ["src/__support/math/isnanf80.h"], + deps = [ + ":__support_fputil_float80", + ":__support_fputil_fp_bits", + ":__support_macros_config", + ], +) + libc_support_library( name = "__support_math_isnanl", hdrs = ["src/__support/math/isnanl.h"], @@ -8230,6 +8260,16 @@ libc_support_library( ], ) +libc_support_library( + name = "__support_math_issignalingf80", + hdrs = ["src/__support/math/issignalingf80.h"], + deps = [ + ":__support_fputil_basic_operations", + ":__support_fputil_float80", + ":__support_macros_config", + ], +) + libc_support_library( name = "__support_math_issignalingf16", hdrs = ["src/__support/math/issignalingf16.h"], @@ -13362,6 +13402,15 @@ libc_math_function( ], ) +libc_math_function( + name = "canonicalizef80", + additional_deps = [ + ":__support_cpp_bit", + ":__support_fputil_float80", + ":__support_math_canonicalizef80", + ], +) + libc_math_function( name = "canonicalizef16", additional_deps = [ @@ -13490,6 +13539,15 @@ libc_math_function( ], ) +libc_math_function( + name = "iscanonicalf80", + additional_deps = [ + ":__support_cpp_bit", + ":__support_fputil_float80", + ":__support_math_iscanonicalf80", + ], +) + libc_math_function( name = "iscanonicalf16", additional_deps = [ @@ -13520,6 +13578,15 @@ libc_math_function( ], ) +libc_math_function( + name = "isnanf80", + additional_deps = [ + ":__support_cpp_bit", + ":__support_fputil_float80", + ":__support_math_isnanf80", + ], +) + libc_math_function( name = "isnanl", additional_deps = [ @@ -13571,6 +13638,15 @@ libc_math_function( ], ) +libc_math_function( + name = "issignalingf80", + additional_deps = [ + ":__support_cpp_bit", + ":__support_fputil_float80", + ":__support_math_issignalingf80", + ], +) + libc_math_function( name = "issignalingf16", additional_deps = [ diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel index c9bb3bf8f9a42..56f48fd31598d 100644 --- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel @@ -168,6 +168,15 @@ math_test( ], ) +math_test( + name = "canonicalizef80", + hdrs = ["CanonicalizeTest.h"], + deps = [ + "//libc:__support_fputil_float80", + "//libc:__support_integer_literals", + ], +) + math_test( name = "canonicalizef16", hdrs = ["CanonicalizeTest.h"], @@ -207,6 +216,14 @@ math_test( ], ) +math_test( + name = "iscanonicalf80", + hdrs = ["IsCanonicalTest.h"], + deps = [ + "//libc:__support_fputil_float80", + ], +) + math_test(name = "cbrt") math_test( @@ -1585,6 +1602,14 @@ math_test( ], ) +math_test( + name = "isnanf80", + hdrs = ["IsNanTest.h"], + deps = [ + "//libc:__support_fputil_float80", + ], +) + math_test( name = "isnanf16", hdrs = ["IsNanTest.h"], @@ -2628,6 +2653,14 @@ math_test( ], ) +math_test( + name = "issignalingf80", + hdrs = ["IsSignalingTest.h"], + deps = [ + "//libc:__support_fputil_float80", + ], +) + math_test(name = "log10f16") math_test(name = "log2f16") >From 2c1aaeb1fe0caf25bec114734175d77569fca063 Mon Sep 17 00:00:00 2001 From: Sukumarsawant <[email protected]> Date: Wed, 4 Nov 2026 12:03:09 +0530 Subject: [PATCH 2/2] clang-format --- libc/shared/math.h | 8 ++++---- libc/src/math/generic/canonicalizef80.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libc/shared/math.h b/libc/shared/math.h index 5a058776ed631..1bf0723ff44d1 100644 --- a/libc/shared/math.h +++ b/libc/shared/math.h @@ -63,8 +63,8 @@ #include "math/canonicalizebf16.h" #include "math/canonicalizef.h" #include "math/canonicalizef128.h" -#include "math/canonicalizef80.h" #include "math/canonicalizef16.h" +#include "math/canonicalizef80.h" #include "math/canonicalizel.h" #include "math/cbrt.h" #include "math/cbrtbf16.h" @@ -305,23 +305,23 @@ #include "math/iscanonicalbf16.h" #include "math/iscanonicalf.h" #include "math/iscanonicalf128.h" -#include "math/iscanonicalf80.h" #include "math/iscanonicalf16.h" +#include "math/iscanonicalf80.h" #include "math/iscanonicall.h" // TODO: isnan is a macro in <math.h> // #include "math/isnan.h" #include "math/isnanf.h" #include "math/isnanf128.h" -#include "math/isnanf80.h" #include "math/isnanf16.h" +#include "math/isnanf80.h" #include "math/isnanl.h" // TODO: issignaling is a macro in <math.h> // #include "math/issignaling.h" #include "math/issignalingbf16.h" #include "math/issignalingf.h" #include "math/issignalingf128.h" -#include "math/issignalingf80.h" #include "math/issignalingf16.h" +#include "math/issignalingf80.h" #include "math/issignalingl.h" #include "math/ldexp.h" #include "math/ldexpbf16.h" diff --git a/libc/src/math/generic/canonicalizef80.cpp b/libc/src/math/generic/canonicalizef80.cpp index f6ae1c73ce521..6e3ea47082ee1 100644 --- a/libc/src/math/generic/canonicalizef80.cpp +++ b/libc/src/math/generic/canonicalizef80.cpp @@ -19,7 +19,7 @@ namespace LIBC_NAMESPACE_DECL { using LIBC_NAMESPACE::fputil::Float80; -LLVM_LIBC_FUNCTION(int, canonicalizef80, (float80 *cx, const float80 *x)) { +LLVM_LIBC_FUNCTION(int, canonicalizef80, (float80 * cx, const float80 *x)) { Float80 cx_f80 = cpp::bit_cast<Float80>(*cx); Float80 x_f80 = cpp::bit_cast<Float80>(*x); int res = math::canonicalizef80(&cx_f80, &x_f80); _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
