diff options
author | Hendrik Hübner <117831077+HendrikHuebner@users.noreply.github.com> | 2024-06-08 21:08:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-08 15:08:45 -0400 |
commit | 44aecca020317fc163fc6f253b03d07828f1d231 (patch) | |
tree | 90e88029e00482b995738eda5dd6fa374ba3da5a /libc | |
parent | 263be9fb0085001630e0431782a0ac0da7ab58ae (diff) | |
download | llvm-44aecca020317fc163fc6f253b03d07828f1d231.zip llvm-44aecca020317fc163fc6f253b03d07828f1d231.tar.gz llvm-44aecca020317fc163fc6f253b03d07828f1d231.tar.bz2 |
[libc][math][C23] Implemented remquof128 function (#94809)
Added remquof128 function. Closes #94312
Diffstat (limited to 'libc')
-rw-r--r-- | libc/config/linux/aarch64/entrypoints.txt | 1 | ||||
-rw-r--r-- | libc/config/linux/x86_64/entrypoints.txt | 1 | ||||
-rw-r--r-- | libc/docs/math/index.rst | 2 | ||||
-rw-r--r-- | libc/spec/stdc.td | 1 | ||||
-rw-r--r-- | libc/src/math/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libc/src/math/generic/CMakeLists.txt | 12 | ||||
-rw-r--r-- | libc/src/math/generic/remquof128.cpp | 19 | ||||
-rw-r--r-- | libc/src/math/remquof128.h | 20 | ||||
-rw-r--r-- | libc/test/src/math/smoke/CMakeLists.txt | 14 | ||||
-rw-r--r-- | libc/test/src/math/smoke/remquof128_test.cpp | 13 |
10 files changed, 83 insertions, 1 deletions
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 2265eb0..adfc1d2 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -575,6 +575,7 @@ if(LIBC_TYPES_HAS_FLOAT128) libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 + libc.src.math.remquof128 libc.src.math.rintf128 libc.src.math.roundf128 libc.src.math.scalbnf128 diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index a72bc98..e86274a 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -606,6 +606,7 @@ if(LIBC_TYPES_HAS_FLOAT128) libc.src.math.nextafterf128 libc.src.math.nextdownf128 libc.src.math.nextupf128 + libc.src.math.remquof128 libc.src.math.rintf128 libc.src.math.roundevenf128 libc.src.math.roundf128 diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst index 9d5edd4..ee2e764 100644 --- a/libc/docs/math/index.rst +++ b/libc/docs/math/index.rst @@ -200,7 +200,7 @@ Basic Operations +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | remainder | |check| | |check| | |check| | | | 7.12.10.2 | F.10.7.2 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ -| remquo | |check| | |check| | |check| | | | 7.12.10.3 | F.10.7.3 | +| remquo | |check| | |check| | |check| | | |check| | 7.12.10.3 | F.10.7.3 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ | rint | |check| | |check| | |check| | |check| | |check| | 7.12.9.4 | F.10.6.4 | +------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+ diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td index d629371..38521f5 100644 --- a/libc/spec/stdc.td +++ b/libc/spec/stdc.td @@ -581,6 +581,7 @@ def StdC : StandardSpec<"stdc"> { FunctionSpec<"remainderl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>, FunctionSpec<"remquof", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>, ArgSpec<IntPtr>]>, + GuardedFunctionSpec<"remquof128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<IntPtr>], "LIBC_TYPES_HAS_FLOAT128">, FunctionSpec<"remquo", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>, ArgSpec<IntPtr>]>, FunctionSpec<"remquol", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>, ArgSpec<IntPtr>]>, diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt index e48d60d..e6cb8fd 100644 --- a/libc/src/math/CMakeLists.txt +++ b/libc/src/math/CMakeLists.txt @@ -312,6 +312,7 @@ add_math_entrypoint_object(remainderl) add_math_entrypoint_object(remquo) add_math_entrypoint_object(remquof) +add_math_entrypoint_object(remquof128) add_math_entrypoint_object(remquol) add_math_entrypoint_object(rint) diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 8a916e7..9774083 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -2433,6 +2433,18 @@ add_entrypoint_object( ) add_entrypoint_object( + remquof128 + SRCS + remquof128.cpp + HDRS + ../remquof128.h + DEPENDS + libc.src.__support.FPUtil.division_and_remainder_operations + COMPILE_OPTIONS + -O3 +) + +add_entrypoint_object( remquo SRCS remquo.cpp diff --git a/libc/src/math/generic/remquof128.cpp b/libc/src/math/generic/remquof128.cpp new file mode 100644 index 0000000..e195c7b --- /dev/null +++ b/libc/src/math/generic/remquof128.cpp @@ -0,0 +1,19 @@ +//===-- 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 +// +//===----------------------------------------------------------------------===// + +#include "src/math/remquof128.h" +#include "src/__support/FPUtil/DivisionAndRemainderOperations.h" +#include "src/__support/common.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION(float128, remquof128, (float128 x, float128 y, int *exp)) { + return fputil::remquo(x, y, *exp); +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/math/remquof128.h b/libc/src/math/remquof128.h new file mode 100644 index 0000000..e9db1ef --- /dev/null +++ b/libc/src/math/remquof128.h @@ -0,0 +1,20 @@ +//===-- 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 +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_MATH_REMQUOF128_H +#define LLVM_LIBC_SRC_MATH_REMQUOF128_H + +#include "src/__support/macros/properties/types.h" + +namespace LIBC_NAMESPACE { + +float128 remquof128(float128 x, float128 y, int *exp); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_MATH_REMQUOF128_H diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index 8d5b4e6..dfda1bc 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -2528,6 +2528,20 @@ add_fp_unittest( ) add_fp_unittest( + remquof128_test + SUITE + libc-math-smoke-tests + SRCS + remquof128_test.cpp + HDRS + RemQuoTest.h + DEPENDS + libc.src.math.remquof128 + libc.src.__support.FPUtil.basic_operations + libc.src.__support.FPUtil.fp_bits +) + +add_fp_unittest( remquo_test SUITE libc-math-smoke-tests diff --git a/libc/test/src/math/smoke/remquof128_test.cpp b/libc/test/src/math/smoke/remquof128_test.cpp new file mode 100644 index 0000000..8ef6c3b --- /dev/null +++ b/libc/test/src/math/smoke/remquof128_test.cpp @@ -0,0 +1,13 @@ +//===-- 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 +// +//===----------------------------------------------------------------------===// + +#include "RemQuoTest.h" + +#include "src/math/remquof128.h" + +LIST_REMQUO_TESTS(float128, LIBC_NAMESPACE::remquof128) |