[libc-commits] [libc] [libc][math][c23] Add {nextafter, nexttoward, nextup, nextdown}f16 C23 math functions (PR #94535)
via libc-commits
libc-commits at lists.llvm.org
Wed Jun 5 13:44:34 PDT 2024
https://github.com/overmighty created https://github.com/llvm/llvm-project/pull/94535
#93566
>From 24f61cf478d6603e1e4526c65c32e59def97d0e7 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Wed, 5 Jun 2024 22:16:54 +0200
Subject: [PATCH 1/4] [libc][math][c23] Add nextafterf16 C23 math function
---
libc/config/linux/aarch64/entrypoints.txt | 1 +
libc/config/linux/x86_64/entrypoints.txt | 1 +
libc/docs/math/index.rst | 2 +-
libc/spec/stdc.td | 1 +
libc/src/math/CMakeLists.txt | 1 +
libc/src/math/generic/CMakeLists.txt | 13 ++++++++
libc/src/math/generic/nextafterf16.cpp | 19 +++++++++++
libc/src/math/nextafterf16.h | 20 ++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 32 ++++++++++++++++---
libc/test/src/math/smoke/NextAfterTest.h | 10 +++---
.../test/src/math/smoke/nextafterf16_test.cpp | 13 ++++++++
11 files changed, 103 insertions(+), 10 deletions(-)
create mode 100644 libc/src/math/generic/nextafterf16.cpp
create mode 100644 libc/src/math/nextafterf16.h
create mode 100644 libc/test/src/math/smoke/nextafterf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index c990a5ba9e669..82c5190de20de 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -512,6 +512,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.lrintf16
libc.src.math.lroundf16
libc.src.math.nearbyintf16
+ libc.src.math.nextafterf16
libc.src.math.rintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 780ffb6d972cd..be57f4f0b994a 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -545,6 +545,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.lrintf16
libc.src.math.lroundf16
libc.src.math.nearbyintf16
+ libc.src.math.nextafterf16
libc.src.math.rintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index fd753742b522d..d7d80f4d322b0 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -190,7 +190,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| nearbyint | |check| | |check| | |check| | |check| | |check| | 7.12.9.3 | F.10.6.3 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| nextafter | |check| | |check| | |check| | | |check| | 7.12.11.3 | F.10.8.3 |
+| nextafter | |check| | |check| | |check| | |check| | |check| | 7.12.11.3 | F.10.8.3 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| nextdown | |check| | |check| | |check| | | |check| | 7.12.11.6 | F.10.8.6 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 0aadeb1a43a00..4ee0535391aba 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -632,6 +632,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"nextafterf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
FunctionSpec<"nextafter", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
FunctionSpec<"nextafterl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"nextafterf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"nextafterf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"nexttowardf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<LongDoubleType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 5ae03b1f46c32..98aac12477591 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -270,6 +270,7 @@ add_math_entrypoint_object(nearbyintf128)
add_math_entrypoint_object(nextafter)
add_math_entrypoint_object(nextafterf)
add_math_entrypoint_object(nextafterl)
+add_math_entrypoint_object(nextafterf16)
add_math_entrypoint_object(nextafterf128)
add_math_entrypoint_object(nexttoward)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 95904bef93d24..deafba461604a 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2523,6 +2523,19 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ nextafterf16
+ SRCS
+ nextafterf16.cpp
+ HDRS
+ ../nextafterf16.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.manipulation_functions
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
nextafterf128
SRCS
diff --git a/libc/src/math/generic/nextafterf16.cpp b/libc/src/math/generic/nextafterf16.cpp
new file mode 100644
index 0000000000000..144b3fc614614
--- /dev/null
+++ b/libc/src/math/generic/nextafterf16.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of nextafterf16 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/nextafterf16.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float16, nextafterf16, (float16 x, float16 y)) {
+ return fputil::nextafter(x, y);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/nextafterf16.h b/libc/src/math/nextafterf16.h
new file mode 100644
index 0000000000000..293569ef40c53
--- /dev/null
+++ b/libc/src/math/nextafterf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for nextafterf16 ------------------*- 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_NEXTAFTERF16_H
+#define LLVM_LIBC_SRC_MATH_NEXTAFTERF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float16 nextafterf16(float16 x, float16 y);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_NEXTAFTERF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 09e54349501ca..075ab2eb319d1 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2515,8 +2515,10 @@ add_fp_unittest(
HDRS
NextAfterTest.h
DEPENDS
+ libc.hdr.fenv_macros
libc.src.math.nextafter
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.bit
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -2529,8 +2531,10 @@ add_fp_unittest(
HDRS
NextAfterTest.h
DEPENDS
+ libc.hdr.fenv_macros
libc.src.math.nextafterf
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.bit
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -2543,8 +2547,26 @@ add_fp_unittest(
HDRS
NextAfterTest.h
DEPENDS
+ libc.hdr.fenv_macros
libc.src.math.nextafterl
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.bit
+ libc.src.__support.FPUtil.fenv_impl
+ libc.src.__support.FPUtil.fp_bits
+)
+
+add_fp_unittest(
+ nextafterf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ nextafterf16_test.cpp
+ HDRS
+ NextAfterTest.h
+ DEPENDS
+ libc.hdr.fenv_macros
+ libc.src.math.nextafterf16
+ libc.src.__support.CPP.bit
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -2557,8 +2579,10 @@ add_fp_unittest(
HDRS
NextAfterTest.h
DEPENDS
+ libc.hdr.fenv_macros
libc.src.math.nextafterf128
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.bit
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
diff --git a/libc/test/src/math/smoke/NextAfterTest.h b/libc/test/src/math/smoke/NextAfterTest.h
index d65ccdf8e70c3..6278f899d8a8b 100644
--- a/libc/test/src/math/smoke/NextAfterTest.h
+++ b/libc/test/src/math/smoke/NextAfterTest.h
@@ -9,15 +9,15 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTAFTERTEST_H
-#include "hdr/math_macros.h"
#include "src/__support/CPP/bit.h"
-#include "src/__support/CPP/type_traits.h"
-#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
+#include "hdr/fenv_macros.h"
+
// TODO: Strengthen errno,exception checks and remove these assert macros
// after new matchers/test fixtures are added
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \
@@ -181,7 +181,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
result_bits = FPBits(result);
ASSERT_EQ(result_bits.get_biased_exponent(), x_bits.get_biased_exponent());
ASSERT_EQ(result_bits.get_mantissa(),
- x_bits.get_mantissa() + StorageType(1));
+ static_cast<StorageType>(x_bits.get_mantissa() + StorageType(1)));
x = -x;
@@ -195,7 +195,7 @@ class NextAfterTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
result_bits = FPBits(result);
ASSERT_EQ(result_bits.get_biased_exponent(), x_bits.get_biased_exponent());
ASSERT_EQ(result_bits.get_mantissa(),
- x_bits.get_mantissa() + StorageType(1));
+ static_cast<StorageType>(x_bits.get_mantissa() + StorageType(1)));
}
};
diff --git a/libc/test/src/math/smoke/nextafterf16_test.cpp b/libc/test/src/math/smoke/nextafterf16_test.cpp
new file mode 100644
index 0000000000000..860a0c74acbca
--- /dev/null
+++ b/libc/test/src/math/smoke/nextafterf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for nextafterf16 ----------------------------------------===//
+//
+// 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 "NextAfterTest.h"
+
+#include "src/math/nextafterf16.h"
+
+LIST_NEXTAFTER_TESTS(float16, LIBC_NAMESPACE::nextafterf16)
>From f5206227211cbb69a9826926dc3b142a8d2ef72e Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Wed, 5 Jun 2024 22:28:34 +0200
Subject: [PATCH 2/4] [libc][math][c23] Add nexttowardf16 C23 math function
---
libc/config/linux/aarch64/entrypoints.txt | 1 +
libc/config/linux/x86_64/entrypoints.txt | 1 +
libc/docs/math/index.rst | 2 +-
libc/spec/stdc.td | 1 +
libc/src/math/CMakeLists.txt | 1 +
libc/src/math/generic/CMakeLists.txt | 13 +++++++++
libc/src/math/generic/nexttowardf16.cpp | 21 ++++++++++++++
libc/src/math/nexttowardf16.h | 20 +++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 28 +++++++++++++++++--
libc/test/src/math/smoke/NextTowardTest.h | 11 ++++----
.../src/math/smoke/nexttowardf16_test.cpp | 13 +++++++++
11 files changed, 102 insertions(+), 10 deletions(-)
create mode 100644 libc/src/math/generic/nexttowardf16.cpp
create mode 100644 libc/src/math/nexttowardf16.h
create mode 100644 libc/test/src/math/smoke/nexttowardf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 82c5190de20de..532bdc4f59abf 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -513,6 +513,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.lroundf16
libc.src.math.nearbyintf16
libc.src.math.nextafterf16
+ libc.src.math.nexttowardf16
libc.src.math.rintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index be57f4f0b994a..c8a69ea95c460 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -546,6 +546,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.lroundf16
libc.src.math.nearbyintf16
libc.src.math.nextafterf16
+ libc.src.math.nexttowardf16
libc.src.math.rintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index d7d80f4d322b0..8c4c16a2b9bef 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -194,7 +194,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| nextdown | |check| | |check| | |check| | | |check| | 7.12.11.6 | F.10.8.6 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| nexttoward | |check| | |check| | |check| | | N/A | 7.12.11.4 | F.10.8.4 |
+| nexttoward | |check| | |check| | |check| | |check| | N/A | 7.12.11.4 | F.10.8.4 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| nextup | |check| | |check| | |check| | | |check| | 7.12.11.5 | F.10.8.5 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 4ee0535391aba..859534b39168e 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -638,6 +638,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"nexttowardf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<LongDoubleType>]>,
FunctionSpec<"nexttoward", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<LongDoubleType>]>,
FunctionSpec<"nexttowardl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"nexttowardf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
FunctionSpec<"nextdown", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"nextdownf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 98aac12477591..45639530afb21 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -276,6 +276,7 @@ add_math_entrypoint_object(nextafterf128)
add_math_entrypoint_object(nexttoward)
add_math_entrypoint_object(nexttowardf)
add_math_entrypoint_object(nexttowardl)
+add_math_entrypoint_object(nexttowardf16)
add_math_entrypoint_object(nextdown)
add_math_entrypoint_object(nextdownf)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index deafba461604a..81de74a4aeb92 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2585,6 +2585,19 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ nexttowardf16
+ SRCS
+ nexttowardf16.cpp
+ HDRS
+ ../nexttowardf16.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.manipulation_functions
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
nextdown
SRCS
diff --git a/libc/src/math/generic/nexttowardf16.cpp b/libc/src/math/generic/nexttowardf16.cpp
new file mode 100644
index 0000000000000..d1d78e8f22d3e
--- /dev/null
+++ b/libc/src/math/generic/nexttowardf16.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of nexttowardf16 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/nexttowardf16.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float16, nexttowardf16, (float16 x, long double y)) {
+ // We can reuse the nextafter implementation because the internal nextafter is
+ // templated on the types of the arguments.
+ return fputil::nextafter(x, y);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/nexttowardf16.h b/libc/src/math/nexttowardf16.h
new file mode 100644
index 0000000000000..604eb32c25778
--- /dev/null
+++ b/libc/src/math/nexttowardf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for nexttowardf16 -----------------*- 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_NEXTTOWARDF16_H
+#define LLVM_LIBC_SRC_MATH_NEXTTOWARDF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float16 nexttowardf16(float16 x, long double y);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_NEXTTOWARDF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 075ab2eb319d1..61618af2772cb 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2597,8 +2597,10 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
HDRS
NextTowardTest.h
DEPENDS
+ libc.hdr.fenv_macros
libc.src.math.nexttoward
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.bit
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -2611,8 +2613,10 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
HDRS
NextTowardTest.h
DEPENDS
+ libc.hdr.fenv_macros
libc.src.math.nexttowardf
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.bit
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
endif()
@@ -2626,8 +2630,26 @@ add_fp_unittest(
HDRS
NextTowardTest.h
DEPENDS
+ libc.hdr.fenv_macros
libc.src.math.nexttowardl
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.CPP.bit
+ libc.src.__support.FPUtil.fenv_impl
+ libc.src.__support.FPUtil.fp_bits
+)
+
+add_fp_unittest(
+ nexttowardf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ nexttowardf16_test.cpp
+ HDRS
+ NextTowardTest.h
+ DEPENDS
+ libc.hdr.fenv_macros
+ libc.src.math.nexttowardf16
+ libc.src.__support.CPP.bit
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
diff --git a/libc/test/src/math/smoke/NextTowardTest.h b/libc/test/src/math/smoke/NextTowardTest.h
index a24ec9ff6bd81..5992273d91901 100644
--- a/libc/test/src/math/smoke/NextTowardTest.h
+++ b/libc/test/src/math/smoke/NextTowardTest.h
@@ -9,16 +9,15 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_NEXTTOWARDTEST_H
-#include "hdr/fenv_macros.h"
-#include "hdr/math_macros.h"
#include "src/__support/CPP/bit.h"
-#include "src/__support/CPP/type_traits.h"
-#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
+#include "hdr/fenv_macros.h"
+
// TODO: Strengthen errno,exception checks and remove these assert macros
// after new matchers/test fixtures are added
#define ASSERT_FP_EQ_WITH_EXCEPTION(result, expected, expected_exception) \
@@ -194,7 +193,7 @@ class NextTowardTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
result_bits = FPBits(result);
ASSERT_EQ(result_bits.get_biased_exponent(), x_bits.get_biased_exponent());
ASSERT_EQ(result_bits.get_mantissa(),
- x_bits.get_mantissa() + StorageType(1));
+ static_cast<StorageType>(x_bits.get_mantissa() + StorageType(1)));
x = -x;
@@ -208,7 +207,7 @@ class NextTowardTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest {
result_bits = FPBits(result);
ASSERT_EQ(result_bits.get_biased_exponent(), x_bits.get_biased_exponent());
ASSERT_EQ(result_bits.get_mantissa(),
- x_bits.get_mantissa() + StorageType(1));
+ static_cast<StorageType>(x_bits.get_mantissa() + StorageType(1)));
}
};
diff --git a/libc/test/src/math/smoke/nexttowardf16_test.cpp b/libc/test/src/math/smoke/nexttowardf16_test.cpp
new file mode 100644
index 0000000000000..8490e8de94cee
--- /dev/null
+++ b/libc/test/src/math/smoke/nexttowardf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for nexttowardf16 ---------------------------------------===//
+//
+// 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 "NextTowardTest.h"
+
+#include "src/math/nexttowardf16.h"
+
+LIST_NEXTTOWARD_TESTS(float16, LIBC_NAMESPACE::nexttowardf16)
>From 3fae04ed280b868c70b555189a3cfb245031975f Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Wed, 5 Jun 2024 22:35:03 +0200
Subject: [PATCH 3/4] [libc][math][c23] Add nextupf16 C23 math function
---
libc/config/linux/aarch64/entrypoints.txt | 1 +
libc/config/linux/x86_64/entrypoints.txt | 1 +
libc/docs/c23.rst | 2 +-
libc/docs/math/index.rst | 2 +-
libc/spec/stdc.td | 1 +
libc/src/math/CMakeLists.txt | 1 +
libc/src/math/generic/CMakeLists.txt | 13 +++++++++++++
libc/src/math/generic/nextupf16.cpp | 19 +++++++++++++++++++
libc/src/math/nextupf16.h | 20 ++++++++++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 16 ++++++++++++----
libc/test/src/math/smoke/nextupf16_test.cpp | 13 +++++++++++++
11 files changed, 83 insertions(+), 6 deletions(-)
create mode 100644 libc/src/math/generic/nextupf16.cpp
create mode 100644 libc/src/math/nextupf16.h
create mode 100644 libc/test/src/math/smoke/nextupf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 532bdc4f59abf..3d5ca833c6b78 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -514,6 +514,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.nearbyintf16
libc.src.math.nextafterf16
libc.src.math.nexttowardf16
+ libc.src.math.nextupf16
libc.src.math.rintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index c8a69ea95c460..b28e0fae3e6d8 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -547,6 +547,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.nearbyintf16
libc.src.math.nextafterf16
libc.src.math.nexttowardf16
+ libc.src.math.nextupf16
libc.src.math.rintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
diff --git a/libc/docs/c23.rst b/libc/docs/c23.rst
index 5bbb056ec5c75..b09907004dc9a 100644
--- a/libc/docs/c23.rst
+++ b/libc/docs/c23.rst
@@ -59,7 +59,7 @@ Additions:
* ufromfp* |check|
* fromfpx* |check|
* ufromfpx* |check|
- * nextup*
+ * nextup* |check|
* nextdown*
* canonicalize* |check|
* fmaximum*
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 8c4c16a2b9bef..4149ebf8dffc6 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -196,7 +196,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| nexttoward | |check| | |check| | |check| | |check| | N/A | 7.12.11.4 | F.10.8.4 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| nextup | |check| | |check| | |check| | | |check| | 7.12.11.5 | F.10.8.5 |
+| nextup | |check| | |check| | |check| | |check| | |check| | 7.12.11.5 | F.10.8.5 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| remainder | |check| | |check| | |check| | | | 7.12.10.2 | F.10.7.2 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 859534b39168e..f1ac1ec8779f9 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -648,6 +648,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"nextup", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"nextupf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
FunctionSpec<"nextupl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"nextupf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"nextupf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"powf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 45639530afb21..e50a834ce24ce 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -286,6 +286,7 @@ add_math_entrypoint_object(nextdownf128)
add_math_entrypoint_object(nextup)
add_math_entrypoint_object(nextupf)
add_math_entrypoint_object(nextupl)
+add_math_entrypoint_object(nextupf16)
add_math_entrypoint_object(nextupf128)
add_math_entrypoint_object(pow)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 81de74a4aeb92..7d88e231fb5e3 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2683,6 +2683,19 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ nextupf16
+ SRCS
+ nextupf16.cpp
+ HDRS
+ ../nextupf16.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.manipulation_functions
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
nextupf128
SRCS
diff --git a/libc/src/math/generic/nextupf16.cpp b/libc/src/math/generic/nextupf16.cpp
new file mode 100644
index 0000000000000..5d3d52c94068f
--- /dev/null
+++ b/libc/src/math/generic/nextupf16.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of nextupf16 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/nextupf16.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float16, nextupf16, (float16 x)) {
+ return fputil::nextupdown</*IsDown=*/false>(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/nextupf16.h b/libc/src/math/nextupf16.h
new file mode 100644
index 0000000000000..b2973e4afc256
--- /dev/null
+++ b/libc/src/math/nextupf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for nextupf16 ---------------------*- 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_NEXTUPF16_H
+#define LLVM_LIBC_SRC_MATH_NEXTUPF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float16 nextupf16(float16 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_NEXTUPF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 61618af2772cb..10e47f9edb6f8 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2715,7 +2715,6 @@ add_fp_unittest(
NextUpTest.h
DEPENDS
libc.src.math.nextup
- libc.src.__support.FPUtil.manipulation_functions
)
add_fp_unittest(
@@ -2728,7 +2727,6 @@ add_fp_unittest(
NextUpTest.h
DEPENDS
libc.src.math.nextupf
- libc.src.__support.FPUtil.manipulation_functions
)
add_fp_unittest(
@@ -2741,7 +2739,18 @@ add_fp_unittest(
NextUpTest.h
DEPENDS
libc.src.math.nextupl
- libc.src.__support.FPUtil.manipulation_functions
+)
+
+add_fp_unittest(
+ nextupf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ nextupf16_test.cpp
+ HDRS
+ NextUpTest.h
+ DEPENDS
+ libc.src.math.nextupf16
)
add_fp_unittest(
@@ -2754,7 +2763,6 @@ add_fp_unittest(
NextUpTest.h
DEPENDS
libc.src.math.nextupf128
- libc.src.__support.FPUtil.manipulation_functions
)
# TODO(lntue): The current implementation of fputil::general::fma<float> is only
diff --git a/libc/test/src/math/smoke/nextupf16_test.cpp b/libc/test/src/math/smoke/nextupf16_test.cpp
new file mode 100644
index 0000000000000..a146d279f3a71
--- /dev/null
+++ b/libc/test/src/math/smoke/nextupf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for nextupf16 -------------------------------------------===//
+//
+// 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 "NextUpTest.h"
+
+#include "src/math/nextupf16.h"
+
+LIST_NEXTUP_TESTS(float16, LIBC_NAMESPACE::nextupf16)
>From 67357b53283c30b74f8ea81c60c77b1687420e53 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Wed, 5 Jun 2024 22:39:21 +0200
Subject: [PATCH 4/4] [libc][math][c23] Add nextdownf16 C23 math function
---
libc/config/linux/aarch64/entrypoints.txt | 1 +
libc/config/linux/x86_64/entrypoints.txt | 1 +
libc/docs/c23.rst | 2 +-
libc/docs/math/index.rst | 2 +-
libc/spec/stdc.td | 1 +
libc/src/math/CMakeLists.txt | 1 +
libc/src/math/generic/CMakeLists.txt | 13 ++++++++++++
libc/src/math/generic/nextdownf16.cpp | 19 ++++++++++++++++++
libc/src/math/nextdownf16.h | 20 +++++++++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 16 +++++++++++----
libc/test/src/math/smoke/nextdownf16_test.cpp | 13 ++++++++++++
11 files changed, 83 insertions(+), 6 deletions(-)
create mode 100644 libc/src/math/generic/nextdownf16.cpp
create mode 100644 libc/src/math/nextdownf16.h
create mode 100644 libc/test/src/math/smoke/nextdownf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 3d5ca833c6b78..2b812566a8a92 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -513,6 +513,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.lroundf16
libc.src.math.nearbyintf16
libc.src.math.nextafterf16
+ libc.src.math.nextdownf16
libc.src.math.nexttowardf16
libc.src.math.nextupf16
libc.src.math.rintf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index b28e0fae3e6d8..f70039fb40d76 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -546,6 +546,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.lroundf16
libc.src.math.nearbyintf16
libc.src.math.nextafterf16
+ libc.src.math.nextdownf16
libc.src.math.nexttowardf16
libc.src.math.nextupf16
libc.src.math.rintf16
diff --git a/libc/docs/c23.rst b/libc/docs/c23.rst
index b09907004dc9a..fa7a59893f89c 100644
--- a/libc/docs/c23.rst
+++ b/libc/docs/c23.rst
@@ -60,7 +60,7 @@ Additions:
* fromfpx* |check|
* ufromfpx* |check|
* nextup* |check|
- * nextdown*
+ * nextdown* |check|
* canonicalize* |check|
* fmaximum*
* fminimum*
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 4149ebf8dffc6..3d74e2f023bf7 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -192,7 +192,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| nextafter | |check| | |check| | |check| | |check| | |check| | 7.12.11.3 | F.10.8.3 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| nextdown | |check| | |check| | |check| | | |check| | 7.12.11.6 | F.10.8.6 |
+| nextdown | |check| | |check| | |check| | |check| | |check| | 7.12.11.6 | F.10.8.6 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| nexttoward | |check| | |check| | |check| | |check| | N/A | 7.12.11.4 | F.10.8.4 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index f1ac1ec8779f9..a864995fba8ec 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -643,6 +643,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"nextdown", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"nextdownf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
FunctionSpec<"nextdownl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"nextdownf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"nextdownf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"nextup", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index e50a834ce24ce..d32ea09e2b424 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -281,6 +281,7 @@ add_math_entrypoint_object(nexttowardf16)
add_math_entrypoint_object(nextdown)
add_math_entrypoint_object(nextdownf)
add_math_entrypoint_object(nextdownl)
+add_math_entrypoint_object(nextdownf16)
add_math_entrypoint_object(nextdownf128)
add_math_entrypoint_object(nextup)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 7d88e231fb5e3..7b73f32048f93 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2634,6 +2634,19 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ nextdownf16
+ SRCS
+ nextdownf16.cpp
+ HDRS
+ ../nextdownf16.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.manipulation_functions
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
nextdownf128
SRCS
diff --git a/libc/src/math/generic/nextdownf16.cpp b/libc/src/math/generic/nextdownf16.cpp
new file mode 100644
index 0000000000000..9fdaa9dafdd8b
--- /dev/null
+++ b/libc/src/math/generic/nextdownf16.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of nextdownf16 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/nextdownf16.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float16, nextdownf16, (float16 x)) {
+ return fputil::nextupdown</*IsDown=*/true>(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/nextdownf16.h b/libc/src/math/nextdownf16.h
new file mode 100644
index 0000000000000..19137574ac92f
--- /dev/null
+++ b/libc/src/math/nextdownf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for nextdownf16 -------------------*- 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_NEXTDOWNF16_H
+#define LLVM_LIBC_SRC_MATH_NEXTDOWNF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float16 nextdownf16(float16 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_NEXTDOWNF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 10e47f9edb6f8..93cc4fd472602 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2663,7 +2663,6 @@ add_fp_unittest(
NextDownTest.h
DEPENDS
libc.src.math.nextdown
- libc.src.__support.FPUtil.manipulation_functions
)
add_fp_unittest(
@@ -2676,7 +2675,6 @@ add_fp_unittest(
NextDownTest.h
DEPENDS
libc.src.math.nextdownf
- libc.src.__support.FPUtil.manipulation_functions
)
add_fp_unittest(
@@ -2689,7 +2687,18 @@ add_fp_unittest(
NextDownTest.h
DEPENDS
libc.src.math.nextdownl
- libc.src.__support.FPUtil.manipulation_functions
+)
+
+add_fp_unittest(
+ nextdownf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ nextdownf16_test.cpp
+ HDRS
+ NextDownTest.h
+ DEPENDS
+ libc.src.math.nextdownf16
)
add_fp_unittest(
@@ -2702,7 +2711,6 @@ add_fp_unittest(
NextDownTest.h
DEPENDS
libc.src.math.nextdownf128
- libc.src.__support.FPUtil.manipulation_functions
)
add_fp_unittest(
diff --git a/libc/test/src/math/smoke/nextdownf16_test.cpp b/libc/test/src/math/smoke/nextdownf16_test.cpp
new file mode 100644
index 0000000000000..353f085861778
--- /dev/null
+++ b/libc/test/src/math/smoke/nextdownf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for nextdownf16 -----------------------------------------===//
+//
+// 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 "NextDownTest.h"
+
+#include "src/math/nextdownf16.h"
+
+LIST_NEXTDOWN_TESTS(float16, LIBC_NAMESPACE::nextdownf16)
More information about the libc-commits
mailing list