[libc-commits] [libc] 826d636 - [libc] Make canonicalizef128, modff128 and remquof128 use the emulated float128 type (#223769)
via libc-commits
libc-commits at lists.llvm.org
Mon Nov 9 00:18:19 PST 2026
Author: Aditya Goyal
Date: 2026-11-09T13:48:09+05:30
New Revision: 826d63662a3b3b65e323ae4099c2c27bc62ef3ca
URL: https://github.com/llvm/llvm-project/commit/826d63662a3b3b65e323ae4099c2c27bc62ef3ca
DIFF: https://github.com/llvm/llvm-project/commit/826d63662a3b3b65e323ae4099c2c27bc62ef3ca.diff
LOG: [libc] Make canonicalizef128, modff128 and remquof128 use the emulated float128 type (#223769)
This PR makes canonicalizef128, modff128 and remquof128 use the emulated Float128 type.
Closes: #221569
Added:
libc/test/src/math/modff128_test.cpp
libc/test/src/math/remquof128_test.cpp
Modified:
libc/config/baremetal/aarch64/entrypoints.txt
libc/config/baremetal/arm/entrypoints.txt
libc/config/baremetal/riscv/entrypoints.txt
libc/config/darwin/aarch64/entrypoints.txt
libc/config/darwin/x86_64/entrypoints.txt
libc/config/freebsd/x86_64/entrypoints.txt
libc/config/gpu/amdgpu/entrypoints.txt
libc/config/gpu/nvptx/entrypoints.txt
libc/config/linux/aarch64/entrypoints.txt
libc/config/linux/arm/entrypoints.txt
libc/config/linux/riscv/entrypoints.txt
libc/config/linux/x86_64/entrypoints.txt
libc/config/windows/entrypoints.txt
libc/shared/math/canonicalizef128.h
libc/shared/math/modff128.h
libc/shared/math/remquof128.h
libc/src/__support/math/CMakeLists.txt
libc/src/__support/math/canonicalizef128.h
libc/src/__support/math/modff128.h
libc/src/__support/math/remquof128.h
libc/src/math/canonicalizef128.h
libc/src/math/generic/CMakeLists.txt
libc/src/math/generic/canonicalizef128.cpp
libc/src/math/generic/modff128.cpp
libc/src/math/generic/remquof128.cpp
libc/src/math/modff128.h
libc/src/math/remquof128.h
libc/test/shared/shared_math_constexpr_test.cpp
libc/test/shared/shared_math_test.cpp
libc/test/src/math/CMakeLists.txt
libc/test/src/math/ModfTest.h
libc/test/src/math/smoke/CMakeLists.txt
libc/test/src/math/smoke/canonicalizef128_test.cpp
libc/test/src/math/smoke/modff128_test.cpp
libc/test/src/math/smoke/remquof128_test.cpp
libc/utils/MPFRWrapper/MPFRUtils.cpp
utils/bazel/llvm-project-overlay/libc/BUILD.bazel
utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
Removed:
################################################################################
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 8bb90fcc20ea13..5cec9bf6308c52 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -371,6 +371,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -563,6 +564,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -591,6 +593,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -799,7 +802,6 @@ endif()
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
@@ -816,12 +818,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
- libc.src.math.modff128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
- libc.src.math.remquof128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index a1c1606fb75406..8e9d282af024fd 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -383,6 +383,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -575,6 +576,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -603,6 +605,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -810,7 +813,6 @@ endif()
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
@@ -827,12 +829,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
- libc.src.math.modff128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
- libc.src.math.remquof128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index f6ecc79ccd5275..591ccdc0046126 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -374,6 +374,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -566,6 +567,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -594,6 +596,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -802,7 +805,6 @@ endif()
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
@@ -819,12 +821,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
- libc.src.math.modff128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
- libc.src.math.remquof128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index d5dacf834d6d3e..795e3a1d35b0a5 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -192,6 +192,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -384,6 +385,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -412,6 +414,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -621,7 +624,6 @@ endif()
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
@@ -638,12 +640,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
- libc.src.math.modff128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
- libc.src.math.remquof128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index fb7bba25bf7a77..a8d9027f0646d1 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -119,6 +119,7 @@ set(TARGET_LIBM_ENTRYPOINTS
## Currently disabled for failing tests.
# math.h entrypoints
#libc.src.math.atan2f128
+ #libc.src.math.canonicalizef128
#libc.src.math.copysign
#libc.src.math.copysignf
#libc.src.math.copysignf128
@@ -236,6 +237,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.logbl
#libc.src.math.modf
#libc.src.math.modff
+ #libc.src.math.modff128
#libc.src.math.modfl
#libc.src.math.nan
#libc.src.math.nanf
@@ -254,6 +256,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.remainder
#libc.src.math.remainderl
#libc.src.math.remquof
+ #libc.src.math.remquof128
#libc.src.math.remquo
#libc.src.math.remquol
#libc.src.math.rint
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 28c3ca6411f7f6..fc253220765666 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -128,6 +128,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atan2f128
libc.src.math.atanf
libc.src.math.atanhf
+ libc.src.math.canonicalizef128
libc.src.math.cbrt
libc.src.math.cbrtf
libc.src.math.copysign
@@ -285,6 +286,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -306,6 +308,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainder
libc.src.math.remainderl
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquo
libc.src.math.remquol
libc.src.math.rint
@@ -554,7 +557,6 @@ endif()
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
@@ -571,12 +573,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
- libc.src.math.modff128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
- libc.src.math.remquof128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index b28c80501c9ec4..925a8edcfd7a43 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -317,6 +317,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.canonicalizef80
libc.src.math.cbrt
@@ -502,6 +503,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -530,6 +532,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 2e9b333d58d60c..be18714d41913f 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -313,6 +313,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.canonicalizef80
libc.src.math.cbrt
@@ -499,6 +500,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -527,6 +529,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 8ba560989af6af..032c5f89456618 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -627,6 +627,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -815,6 +816,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -843,6 +845,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -1045,7 +1048,6 @@ endif()
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
@@ -1062,12 +1064,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
- libc.src.math.modff128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
- libc.src.math.remquof128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 5e04635e298e77..b99d52c87d5518 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -416,6 +416,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atan
libc.src.math.atanf
libc.src.math.atanhf
+ libc.src.math.canonicalizef128
libc.src.math.cbrt
libc.src.math.cbrtf
libc.src.math.cbrtbf16
@@ -587,6 +588,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -615,6 +617,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 56813aaf66a91f..71eceb3345624d 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -686,6 +686,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -878,6 +879,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -906,6 +908,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -1125,7 +1128,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# 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
@@ -1142,12 +1144,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
- libc.src.math.modff128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
- libc.src.math.remquof128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 25b24740400b97..c5ccda8c404583 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -708,6 +708,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atanhf
libc.src.math.canonicalize
libc.src.math.canonicalizef
+ libc.src.math.canonicalizef128
libc.src.math.canonicalizel
libc.src.math.cbrt
libc.src.math.cbrtf
@@ -900,6 +901,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -928,6 +930,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainderl
libc.src.math.remquo
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquol
libc.src.math.rint
libc.src.math.rintf
@@ -1147,7 +1150,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# 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
@@ -1164,12 +1166,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
- libc.src.math.modff128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.remainderf128
- libc.src.math.remquof128
libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index c0c46291515b81..8e5e6b748b3ef7 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -159,6 +159,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.atan
libc.src.math.atanf
libc.src.math.atanhf
+ libc.src.math.canonicalizef128
libc.src.math.cbrt
libc.src.math.cbrtf
libc.src.math.cbrtbf16
@@ -319,6 +320,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.lroundl
libc.src.math.modf
libc.src.math.modff
+ libc.src.math.modff128
libc.src.math.modfl
libc.src.math.nan
libc.src.math.nanf
@@ -340,6 +342,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.remainder
libc.src.math.remainderl
libc.src.math.remquof
+ libc.src.math.remquof128
libc.src.math.remquo
libc.src.math.remquol
libc.src.math.rint
diff --git a/libc/shared/math/canonicalizef128.h b/libc/shared/math/canonicalizef128.h
index 3e58766807f07b..f9813e0a1a66bf 100644
--- a/libc/shared/math/canonicalizef128.h
+++ b/libc/shared/math/canonicalizef128.h
@@ -1,18 +1,19 @@
-//===-- Shared canonicalizef128 function ------------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Shared declaration of the float128 canonicalize function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
#define LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/canonicalizef128.h"
@@ -24,6 +25,4 @@ using math::canonicalizef128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
diff --git a/libc/shared/math/modff128.h b/libc/shared/math/modff128.h
index 480dc16d4fe3cd..98b4643e99ba5c 100644
--- a/libc/shared/math/modff128.h
+++ b/libc/shared/math/modff128.h
@@ -1,18 +1,19 @@
-//===-- Shared modff128 function --------------------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Shared declaration of the float128 modf function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SHARED_MATH_MODFF128_H
#define LLVM_LIBC_SHARED_MATH_MODFF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/modff128.h"
@@ -24,6 +25,4 @@ using math::modff128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_MODFF128_H
diff --git a/libc/shared/math/remquof128.h b/libc/shared/math/remquof128.h
index 4331c02bb99793..a3bbbfdc9c2bc5 100644
--- a/libc/shared/math/remquof128.h
+++ b/libc/shared/math/remquof128.h
@@ -1,18 +1,19 @@
-//===-- Shared remquof128 function ------------------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Shared declaration of the float128 remquo function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SHARED_MATH_REMQUOF128_H
#define LLVM_LIBC_SHARED_MATH_REMQUOF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/remquof128.h"
@@ -24,6 +25,4 @@ using math::remquof128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_REMQUOF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index eb039efc77f544..6f29a3bc0f94bb 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -715,8 +715,8 @@ add_header_library(
HDRS
canonicalizef128.h
DEPENDS
- libc.include.llvm-libc-types.float128
libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.float128
libc.src.__support.macros.config
)
@@ -2275,7 +2275,7 @@ add_header_library(
HDRS
modff128.h
DEPENDS
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.macros.config
)
@@ -2510,8 +2510,8 @@ add_header_library(
HDRS
remquof128.h
DEPENDS
- libc.include.llvm-libc-types.float128
libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.FPUtil.float128
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/canonicalizef128.h b/libc/src/__support/math/canonicalizef128.h
index 77ce2058bc8595..98f44806a4647a 100644
--- a/libc/src/__support/math/canonicalizef128.h
+++ b/libc/src/__support/math/canonicalizef128.h
@@ -1,32 +1,34 @@
-//===-- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 canonicalize function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr int canonicalizef128(float128 *cx, const float128 *x) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr int canonicalizef128(Float128 *cx, const Float128 *x) {
return fputil::canonicalize(*cx, *x);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
diff --git a/libc/src/__support/math/modff128.h b/libc/src/__support/math/modff128.h
index b519298a50ae19..59e8c6484df9c2 100644
--- a/libc/src/__support/math/modff128.h
+++ b/libc/src/__support/math/modff128.h
@@ -1,31 +1,33 @@
-//===-- Implementation header for modff128 ----------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 modf function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_MODFF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_MODFF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 modff128(float128 x, float128 *iptr) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 modff128(Float128 x, Float128 *iptr) {
return fputil::modf(x, *iptr);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_MODFF128_H
diff --git a/libc/src/__support/math/remquof128.h b/libc/src/__support/math/remquof128.h
index d22b3359d43c8f..648793752d5178 100644
--- a/libc/src/__support/math/remquof128.h
+++ b/libc/src/__support/math/remquof128.h
@@ -1,31 +1,33 @@
-//===-- Implementation header for remquof128 --------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 remquo function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 remquof128(float128 x, float128 y, int *exp) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 remquof128(Float128 x, Float128 y, int *exp) {
return fputil::remquo(x, y, *exp);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
diff --git a/libc/src/math/canonicalizef128.h b/libc/src/math/canonicalizef128.h
index eeeb7e3fb4526c..79bf59d0c8a83c 100644
--- a/libc/src/math/canonicalizef128.h
+++ b/libc/src/math/canonicalizef128.h
@@ -1,19 +1,29 @@
-//===-- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Declaration of the float128 canonicalize function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_CANONICALIZEF128_H
#define LLVM_LIBC_SRC_MATH_CANONICALIZEF128_H
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
int canonicalizef128(float128 *cx, const float128 *x);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index ac2da02e814acd..5cd1b2b139aa19 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -37,6 +37,7 @@ add_entrypoint_object(
HDRS
../canonicalizef128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.canonicalizef128
)
@@ -2045,6 +2046,7 @@ add_entrypoint_object(
HDRS
../modff128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.modff128
)
@@ -2916,6 +2918,7 @@ add_entrypoint_object(
HDRS
../remquof128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.remquof128
)
diff --git a/libc/src/math/generic/canonicalizef128.cpp b/libc/src/math/generic/canonicalizef128.cpp
index 48bce08a555cf0..2013e30c75ee52 100644
--- a/libc/src/math/generic/canonicalizef128.cpp
+++ b/libc/src/math/generic/canonicalizef128.cpp
@@ -1,18 +1,30 @@
-//===-- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the canonicalizef128 function.
+///
+//===----------------------------------------------------------------------===//
#include "src/math/canonicalizef128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/canonicalizef128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(int, canonicalizef128, (float128 * cx, const float128 *x)) {
- return math::canonicalizef128(cx, x);
+ Float128 cx_val{};
+ const Float128 x_val = cpp::bit_cast<Float128>(*x);
+ int result = math::canonicalizef128(&cx_val, &x_val);
+ *cx = cpp::bit_cast<float128>(cx_val);
+ return result;
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/modff128.cpp b/libc/src/math/generic/modff128.cpp
index 099bb2e907fb8d..8769d36e56cabd 100644
--- a/libc/src/math/generic/modff128.cpp
+++ b/libc/src/math/generic/modff128.cpp
@@ -1,18 +1,30 @@
-//===-- Implementation of modff128 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the modff128 function.
+///
+//===----------------------------------------------------------------------===//
#include "src/math/modff128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/modff128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, modff128, (float128 x, float128 *iptr)) {
- return math::modff128(x, iptr);
+ Float128 iptr_val{};
+ float128 result = cpp::bit_cast<float128>(
+ math::modff128(cpp::bit_cast<Float128>(x), &iptr_val));
+ *iptr = cpp::bit_cast<float128>(iptr_val);
+ return result;
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remquof128.cpp b/libc/src/math/generic/remquof128.cpp
index 779597d00eac07..0e3a825dd45a23 100644
--- a/libc/src/math/generic/remquof128.cpp
+++ b/libc/src/math/generic/remquof128.cpp
@@ -1,18 +1,27 @@
-//===-- Implementation of remquof128 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the remquof128 function.
+///
+//===----------------------------------------------------------------------===//
#include "src/math/remquof128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/remquof128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, remquof128, (float128 x, float128 y, int *exp)) {
- return math::remquof128(x, y, exp);
+ return cpp::bit_cast<float128>(math::remquof128(
+ cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y), exp));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/modff128.h b/libc/src/math/modff128.h
index 32c98423a050cf..cfb25ca360a3cf 100644
--- a/libc/src/math/modff128.h
+++ b/libc/src/math/modff128.h
@@ -1,19 +1,29 @@
-//===-- Implementation header for modff128 -----------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Declaration of the float128 modf function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_MODFF128_H
#define LLVM_LIBC_SRC_MATH_MODFF128_H
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
float128 modff128(float128 x, float128 *iptr);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/remquof128.h b/libc/src/math/remquof128.h
index 49e99a9a8bb2ce..f9b74dd3442dc2 100644
--- a/libc/src/math/remquof128.h
+++ b/libc/src/math/remquof128.h
@@ -1,19 +1,29 @@
-//===-- Implementation header for remquof128 --------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Declaration of the float128 remquo function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_REMQUOF128_H
#define LLVM_LIBC_SRC_MATH_REMQUOF128_H
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
float128 remquof128(float128 x, float128 y, int *exp);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index ca506c2d1f75cd..3b162ca663e7d4 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -407,6 +407,11 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
// Emulated Float128 Tests
//===----------------------------------------------------------------------===//
+static_assert(0 == [] {
+ Float128 cx = Float128(0.0);
+ Float128 x = Float128(0.0);
+ return LIBC_NAMESPACE::shared::canonicalizef128(&cx, &x);
+}());
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::copysignf128(Float128(0.0),
@@ -510,8 +515,16 @@ static_assert(0LL == LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::logbf128(Float128(1.0)));
static_assert(0L == LIBC_NAMESPACE::shared::lrintf128(Float128(0.0)));
static_assert(0L == LIBC_NAMESPACE::shared::lroundf128(Float128(0.0)));
+static_assert(Float128(0.0) == [] {
+ Float128 iptr{};
+ return LIBC_NAMESPACE::shared::modff128(Float128(0.0), &iptr);
+}());
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::nearbyintf128(Float128(0.0)));
+static_assert(Float128(0.0) == [] {
+ int exp{};
+ return LIBC_NAMESPACE::shared::remquof128(Float128(1.0), Float128(1.0), &exp);
+}());
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::rintf128(Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::roundevenf128(Float128(0.0)));
@@ -558,11 +571,6 @@ static_assert(1 == [] {
#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-static_assert(0 == [] {
- float128 cx = float128(0.0);
- float128 x = float128(0.0);
- return LIBC_NAMESPACE::shared::canonicalizef128(&cx, &x);
-}());
static_assert(0.0 ==
LIBC_NAMESPACE::shared::ddivf128(float128(0.0), float128(1.0)));
static_assert(0.0 ==
@@ -589,17 +597,9 @@ static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::ufromfpxf128(float128(0.0), 0, 32));
static_assert(0 ==
LIBC_NAMESPACE::shared::fmodf128(float128(4.0), float128(2.0)));
-static_assert(float128(0.0) == [] {
- float128 iptr{};
- return LIBC_NAMESPACE::shared::modff128(float128(0.0), &iptr);
-}());
static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::remainderf128(float128(1.0),
float128(1.0)));
-static_assert(float128(0.0) == [] {
- int exp{};
- return LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0), &exp);
-}());
static_assert(0.0f ==
LIBC_NAMESPACE::shared::fmulf128(float128(0.0), float128(0.0)));
static_assert(0.0f ==
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 53cf9a94c39b29..27d4a3b5fd36a1 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -598,6 +598,11 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::atan2f128(Float128(0.0), Float128(0.0)));
+ Float128 canonicalizef128_cx = Float128(0.0);
+ Float128 canonicalizef128_x = Float128(0.0);
+ EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef128(&canonicalizef128_cx,
+ &canonicalizef128_x));
+ EXPECT_FP_EQ(Float128(0.0), canonicalizef128_cx);
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::copysignf128(
Float128(0.0), Float128(0.0)));
@@ -645,11 +650,20 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::logbf128(Float128(1.0)));
EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintf128(Float128(0.0)));
EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf128(Float128(0.0)));
+ Float128 modff128_iptr = Float128(0.0);
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::modff128(Float128(0.0), &modff128_iptr));
+ EXPECT_FP_EQ(Float128(0.0), modff128_iptr);
EXPECT_TRUE(FPBits(LIBC_NAMESPACE::shared::nanf128("")).is_nan());
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::nearbyintf128(Float128(0.0)));
+ int remquof128_exp = 0;
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::remquof128(Float128(1.0), Float128(1.0),
+ &remquof128_exp));
+ EXPECT_EQ(1, remquof128_exp);
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::rintf128(Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::roundevenf128(Float128(0.0)));
@@ -738,12 +752,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16addf128(
float128(2.0), float128(3.0)));
- float128 canonicalizef128_cx = float128(0.0);
- float128 canonicalizef128_x = float128(0.0);
- EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef128(&canonicalizef128_cx,
- &canonicalizef128_x));
- EXPECT_FP_EQ(float128(0.0), canonicalizef128_cx);
-
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::bf16subf128(
float128(0.0), float128(0.0)));
EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::bf16fmaf128(
@@ -796,17 +804,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_FP_EQ(float128(0.0),
LIBC_NAMESPACE::shared::ufromfpxf128(float128(0.0), 0, 32));
LIBC_NAMESPACE::shared::fmodf128(float128(1.0), float128(1.0));
- float128 modff128_iptr = float128(0.0);
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::modff128(float128(0.0), &modff128_iptr));
- EXPECT_FP_EQ(float128(0.0), modff128_iptr);
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::remainderf128(
float128(1.0), float128(1.0)));
- int remquof128_exp = 0;
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0),
- &remquof128_exp));
- EXPECT_EQ(1, remquof128_exp);
EXPECT_FP_EQ(0x0p+0f,
LIBC_NAMESPACE::shared::fsubf128(float128(0.0), float128(0.0)));
EXPECT_FP_EQ(0x0p+0f,
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 7be0f192e5062c..c7b18dd4f14ef1 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -1866,6 +1866,21 @@ add_fp_unittest(
libc.src.__support.FPUtil.nearest_integer_operations
)
+add_fp_unittest(
+ modff128_test
+ SUITE
+ libc-math-tests
+ SRCS
+ modff128_test.cpp
+ HDRS
+ ModfTest.h
+ DEPENDS
+ libc.src.math.modff128
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.float128
+ libc.src.__support.FPUtil.nearest_integer_operations
+)
+
add_fp_unittest(
fdimf_test
SUITE
@@ -2208,6 +2223,23 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
+add_fp_unittest(
+ remquof128_test
+ NEED_MPFR_F128
+ SUITE
+ libc-math-tests
+ SRCS
+ remquof128_test.cpp
+ HDRS
+ RemQuoTest.h
+ DEPENDS
+ libc.src.math.remquof128
+ libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.float128
+ libc.src.__support.FPUtil.fp_bits
+)
+
add_fp_unittest(
hypotf_test
NEED_MPFR
diff --git a/libc/test/src/math/ModfTest.h b/libc/test/src/math/ModfTest.h
index 00e665bac5f1bd..c87ec7fd0e99d6 100644
--- a/libc/test/src/math/ModfTest.h
+++ b/libc/test/src/math/ModfTest.h
@@ -95,7 +95,7 @@ class ModfTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
T integral;
T frac = func(x, &integral);
- ASSERT_TRUE(LIBC_NAMESPACE::fputil::abs(frac) < 1.0l);
+ ASSERT_TRUE(LIBC_NAMESPACE::fputil::abs(frac) < T(1.0));
ASSERT_TRUE(LIBC_NAMESPACE::fputil::trunc(x) == integral);
ASSERT_TRUE(integral + frac == x);
}
diff --git a/libc/test/src/math/modff128_test.cpp b/libc/test/src/math/modff128_test.cpp
new file mode 100644
index 00000000000000..d9abddc5c75cf7
--- /dev/null
+++ b/libc/test/src/math/modff128_test.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Exhaustive tests for the modff128 function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "ModfTest.h"
+
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/modff128.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+LIST_MODF_TESTS(Modff128, float128, LIBC_NAMESPACE::modff128)
diff --git a/libc/test/src/math/remquof128_test.cpp b/libc/test/src/math/remquof128_test.cpp
new file mode 100644
index 00000000000000..6ac441f96c34ae
--- /dev/null
+++ b/libc/test/src/math/remquof128_test.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Exhaustive tests for the remquof128 function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "RemQuoTest.h"
+
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/remquof128.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+LIST_REMQUO_TESTS(Remquof128, float128, LIBC_NAMESPACE::remquof128)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 436e864342beef..c72a2e50e9deaf 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -473,6 +473,7 @@ add_fp_unittest(
HDRS
CanonicalizeTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.canonicalizef128
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.fenv_impl
@@ -2670,6 +2671,7 @@ add_fp_unittest(
HDRS
ModfTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.modff128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.basic_operations
@@ -4011,6 +4013,7 @@ add_fp_unittest(
HDRS
RemQuoTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.remquof128
libc.src.__support.FPUtil.basic_operations
libc.src.__support.FPUtil.fp_bits
diff --git a/libc/test/src/math/smoke/canonicalizef128_test.cpp b/libc/test/src/math/smoke/canonicalizef128_test.cpp
index f9f3c3dda8fcbd..fa460b154ee93b 100644
--- a/libc/test/src/math/smoke/canonicalizef128_test.cpp
+++ b/libc/test/src/math/smoke/canonicalizef128_test.cpp
@@ -1,14 +1,24 @@
-//===-- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Smoke tests for the canonicalizef128 function.
+///
+//===----------------------------------------------------------------------===//
#include "CanonicalizeTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/canonicalizef128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_CANONICALIZE_TESTS(Canonicalizef128, float128,
LIBC_NAMESPACE::canonicalizef128)
diff --git a/libc/test/src/math/smoke/modff128_test.cpp b/libc/test/src/math/smoke/modff128_test.cpp
index de096a351afc96..cdcb769ec9a8f3 100644
--- a/libc/test/src/math/smoke/modff128_test.cpp
+++ b/libc/test/src/math/smoke/modff128_test.cpp
@@ -1,13 +1,23 @@
-//===-- Unittests for modff128 --------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// 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 the modff128 function.
+///
+//===----------------------------------------------------------------------===//
#include "ModfTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/modff128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_MODF_TESTS(Modff128, float128, LIBC_NAMESPACE::modff128)
diff --git a/libc/test/src/math/smoke/remquof128_test.cpp b/libc/test/src/math/smoke/remquof128_test.cpp
index 1beded84679d72..fef73bc2034a5a 100644
--- a/libc/test/src/math/smoke/remquof128_test.cpp
+++ b/libc/test/src/math/smoke/remquof128_test.cpp
@@ -1,13 +1,23 @@
-//===-- Unittests for remquof128 ------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// 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 the remquof128 function.
+///
+//===----------------------------------------------------------------------===//
#include "RemQuoTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/remquof128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_REMQUO_TESTS(Remquof128, float128, LIBC_NAMESPACE::remquof128)
diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp
index 41db72c53da6bb..fea8c5512977dc 100644
--- a/libc/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp
@@ -386,6 +386,11 @@ template void explain_binary_operation_two_outputs_error<float16>(
template void explain_binary_operation_two_outputs_error<bfloat16>(
Operation, const BinaryInput<bfloat16> &, const BinaryOutput<bfloat16> &,
double, RoundingMode);
+#ifdef LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
+template void explain_binary_operation_two_outputs_error<float128>(
+ Operation, const BinaryInput<float128> &, const BinaryOutput<float128> &,
+ double, RoundingMode);
+#endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
template <typename InputType, typename OutputType>
void explain_binary_operation_one_output_error(
@@ -675,6 +680,11 @@ template bool compare_binary_operation_two_outputs<float16>(
template bool compare_binary_operation_two_outputs<bfloat16>(
Operation, const BinaryInput<bfloat16> &, const BinaryOutput<bfloat16> &,
double, RoundingMode);
+#ifdef LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
+template bool compare_binary_operation_two_outputs<float128>(
+ Operation, const BinaryInput<float128> &, const BinaryOutput<float128> &,
+ double, RoundingMode);
+#endif // LIBC_TYPES_FLOAT128_IS_NOT_LONG_DOUBLE
template <typename InputType, typename OutputType>
bool compare_binary_operation_one_output(Operation op,
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index bdae359342bb71..8a5abe7d94e258 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -7188,8 +7188,8 @@ libc_support_library(
hdrs = ["src/__support/math/canonicalizef128.h"],
deps = [
":__support_fputil_basic_operations",
+ ":__support_fputil_float128",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -8749,9 +8749,9 @@ libc_support_library(
name = "__support_math_modff128",
hdrs = ["src/__support/math/modff128.h"],
deps = [
+ ":__support_fputil_float128",
":__support_fputil_manipulation_functions",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -8984,8 +8984,8 @@ libc_support_library(
hdrs = ["src/__support/math/remquof128.h"],
deps = [
":__support_fputil_division_and_remainder_operations",
+ ":__support_fputil_float128",
":__support_macros_config",
- ":llvm_libc_types_float128",
],
)
@@ -13636,6 +13636,8 @@ libc_math_function(
libc_math_function(
name = "canonicalizef128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_canonicalizef128",
],
)
@@ -15881,6 +15883,8 @@ libc_math_function(
libc_math_function(
name = "modff128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_modff128",
],
)
@@ -16228,6 +16232,8 @@ libc_math_function(
libc_math_function(
name = "remquof128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_remquof128",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
index 0f5e3a7043b9d0..631a979891a182 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
@@ -878,6 +878,12 @@ math_mpfr_test(
hdrs = ["ModfTest.h"],
)
+math_mpfr_test(
+ name = "modff128",
+ hdrs = ["ModfTest.h"],
+ deps = ["//libc:__support_fputil_float128"],
+)
+
math_mpfr_test(
name = "nearbyint",
hdrs = ["NearbyIntTest.h"],
@@ -949,6 +955,12 @@ math_mpfr_test(
hdrs = ["RemQuoTest.h"],
)
+math_mpfr_test(
+ name = "remquof128",
+ hdrs = ["RemQuoTest.h"],
+ deps = ["//libc:__support_fputil_float128"],
+)
+
math_mpfr_test(
name = "remquof16",
hdrs = ["RemQuoTest.h"],
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 b9941945f70242..a0e51425a7f9a3 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
@@ -171,6 +171,7 @@ math_test(
name = "canonicalizef128",
hdrs = ["CanonicalizeTest.h"],
deps = [
+ "//libc:__support_fputil_float128",
"//libc:__support_integer_literals",
],
)
@@ -1882,6 +1883,9 @@ math_test(
math_test(
name = "modff128",
hdrs = ["ModfTest.h"],
+ deps = [
+ "//libc:__support_fputil_float128",
+ ],
)
math_test(
@@ -2102,6 +2106,9 @@ math_test(
math_test(
name = "remquof128",
hdrs = ["RemQuoTest.h"],
+ deps = [
+ "//libc:__support_fputil_float128",
+ ],
)
math_test(
More information about the libc-commits
mailing list