[libc-commits] [libc] [libc][math] Adds entrypoint and tests for nearbyintf128, scalbnf128 (PR #88443)
Michael Flanders via libc-commits
libc-commits at lists.llvm.org
Thu Apr 11 14:36:45 PDT 2024
https://github.com/Flandini created https://github.com/llvm/llvm-project/pull/88443
Closes #84689.
Adding @lntue for review.
I was curious about the implementation of `round_using_current_rounding_mode` used for the `nearbyint` functions. It has one of the rounding modes as unreachable ([here](https://github.com/llvm/llvm-project/blob/main/libc/src/__support/FPUtil/NearestIntegerOperations.h#L243)), and I was wondering if this was okay for the `nearbyint` functions.
>From 4edc439f287648af221adef0778a9fe6f71c3952 Mon Sep 17 00:00:00 2001
From: Michael Flanders <mkf727 at cs.washington.edu>
Date: Wed, 10 Apr 2024 22:46:51 +0000
Subject: [PATCH] Adds entrypoint and tests for nearbyintf128,scalbnf128
---
libc/config/linux/aarch64/entrypoints.txt | 2 +
libc/config/linux/riscv/entrypoints.txt | 2 +
libc/config/linux/x86_64/entrypoints.txt | 2 +
libc/docs/math/index.rst | 4 +-
libc/spec/stdc.td | 2 +
libc/src/math/CMakeLists.txt | 2 +
libc/src/math/generic/CMakeLists.txt | 31 +++++-
libc/src/math/generic/nearbyintf128.cpp | 19 ++++
libc/src/math/generic/scalbnf128.cpp | 25 +++++
libc/src/math/nearbyintf128.h | 20 ++++
libc/src/math/scalbnf128.h | 20 ++++
libc/test/src/math/CMakeLists.txt | 67 ++++++++++++
libc/test/src/math/NearbyIntTest.h | 107 +++++++++++++++++++
libc/test/src/math/nearbyint_test.cpp | 13 +++
libc/test/src/math/nearbyintf128_test.cpp | 13 +++
libc/test/src/math/nearbyintf_test.cpp | 13 +++
libc/test/src/math/nearbyintl_test.cpp | 13 +++
libc/test/src/math/scalbnf128_test.cpp | 13 +++
libc/test/src/math/smoke/CMakeLists.txt | 14 +++
libc/test/src/math/smoke/scalbnf128_test.cpp | 13 +++
20 files changed, 390 insertions(+), 5 deletions(-)
create mode 100644 libc/src/math/generic/nearbyintf128.cpp
create mode 100644 libc/src/math/generic/scalbnf128.cpp
create mode 100644 libc/src/math/nearbyintf128.h
create mode 100644 libc/src/math/scalbnf128.h
create mode 100644 libc/test/src/math/NearbyIntTest.h
create mode 100644 libc/test/src/math/nearbyint_test.cpp
create mode 100644 libc/test/src/math/nearbyintf128_test.cpp
create mode 100644 libc/test/src/math/nearbyintf_test.cpp
create mode 100644 libc/test/src/math/nearbyintl_test.cpp
create mode 100644 libc/test/src/math/scalbnf128_test.cpp
create mode 100644 libc/test/src/math/smoke/scalbnf128_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index f5f5c437685a21..0420d826ae6308 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -512,11 +512,13 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.lroundf128
libc.src.math.modff128
libc.src.math.nanf128
+ libc.src.math.nearbyintf128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.rintf128
libc.src.math.roundf128
+ libc.src.math.scalbnf128
libc.src.math.sqrtf128
libc.src.math.truncf128
)
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 71289789158f4b..59233022a0f8e0 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -520,11 +520,13 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.lroundf128
libc.src.math.modff128
libc.src.math.nanf128
+ libc.src.math.nearbyintf128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.rintf128
libc.src.math.roundf128
+ libc.src.math.scalbnf128
libc.src.math.sqrtf128
libc.src.math.truncf128
)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 6bb53cb76220fc..45413b138b22f7 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -555,12 +555,14 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.lroundf128
libc.src.math.modff128
libc.src.math.nanf128
+ libc.src.math.nearbyintf128
libc.src.math.nextafterf128
libc.src.math.nextdownf128
libc.src.math.nextupf128
libc.src.math.rintf128
libc.src.math.roundevenf128
libc.src.math.roundf128
+ libc.src.math.scalbnf128
libc.src.math.sqrtf128
libc.src.math.truncf128
libc.src.math.ufromfpf128
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 7a7b6c9c8db5de..28503e1d13ab5a 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -188,7 +188,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| nan | |check| | |check| | |check| | | |check| | 7.12.11.2 | F.10.8.2 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| nearbyint | |check| | |check| | |check| | | | 7.12.9.3 | F.10.6.3 |
+| nearbyint | |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 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
@@ -208,7 +208,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| roundeven | |check| | |check| | |check| | | |check| | 7.12.9.8 | F.10.6.8 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| scalbn | |check| | |check| | |check| | | | 7.12.6.19 | F.10.3.19 |
+| scalbn | |check| | |check| | |check| | | |check| | 7.12.6.19 | F.10.3.19 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| trunc | |check| | |check| | |check| | | |check| | 7.12.9.9 | F.10.6.9 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 63d0449867114d..2670ea53c5f18b 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -599,6 +599,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"nearbyint", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"nearbyintf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
FunctionSpec<"nearbyintl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"nearbyintf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"nextafterf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
FunctionSpec<"nextafter", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
@@ -642,6 +643,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"scalbn", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<IntType>]>,
FunctionSpec<"scalbnf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<IntType>]>,
FunctionSpec<"scalbnl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntType>]>,
+ GuardedFunctionSpec<"scalbnf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<IntType>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"nanf", RetValSpec<FloatType>, [ArgSpec<ConstCharPtr>]>,
FunctionSpec<"nan", RetValSpec<DoubleType>, [ArgSpec<ConstCharPtr>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index e8f699fabe3655..c34c58575441d3 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -252,6 +252,7 @@ add_math_entrypoint_object(nanf128)
add_math_entrypoint_object(nearbyint)
add_math_entrypoint_object(nearbyintf)
add_math_entrypoint_object(nearbyintl)
+add_math_entrypoint_object(nearbyintf128)
add_math_entrypoint_object(nextafter)
add_math_entrypoint_object(nextafterf)
@@ -301,6 +302,7 @@ add_math_entrypoint_object(roundevenf128)
add_math_entrypoint_object(scalbn)
add_math_entrypoint_object(scalbnf)
add_math_entrypoint_object(scalbnl)
+add_math_entrypoint_object(scalbnf128)
add_math_entrypoint_object(sincos)
add_math_entrypoint_object(sincosf)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 574e000b82a8fc..fbc5aa479b47b5 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -704,7 +704,7 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
- -O2
+ -O3
)
add_entrypoint_object(
@@ -716,7 +716,7 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
- -O2
+ -O3
)
add_entrypoint_object(
@@ -728,7 +728,20 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.FPUtil.nearest_integer_operations
COMPILE_OPTIONS
- -O2
+ -O3
+)
+
+add_entrypoint_object(
+ nearbyintf128
+ SRCS
+ nearbyintf128.cpp
+ HDRS
+ ../nearbyintf128.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
+ COMPILE_OPTIONS
+ -O3
)
add_object_library(
@@ -2949,6 +2962,18 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ scalbnf128
+ SRCS
+ scalbnf128.cpp
+ HDRS
+ ../scalbnf128.h
+ DEPENDS
+ libc.src.__support.FPUtil.manipulation_functions
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
fmaf
SRCS
diff --git a/libc/src/math/generic/nearbyintf128.cpp b/libc/src/math/generic/nearbyintf128.cpp
new file mode 100644
index 00000000000000..fca3587f5b58ad
--- /dev/null
+++ b/libc/src/math/generic/nearbyintf128.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of nearbyintf128 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/nearbyintf128.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float128, nearbyintf128, (float128 x)) {
+ return fputil::round_using_current_rounding_mode(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/generic/scalbnf128.cpp b/libc/src/math/generic/scalbnf128.cpp
new file mode 100644
index 00000000000000..8713973ad05442
--- /dev/null
+++ b/libc/src/math/generic/scalbnf128.cpp
@@ -0,0 +1,25 @@
+//===-- Implementation of scalbnf128 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/scalbnf128.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float128, scalbnf128, (float128 x, int n)) {
+#if !defined(__FLT_RADIX__)
+#error __FLT_RADIX__ undefined.
+#elif __FLT_RADIX__ != 2
+#error __FLT_RADIX__!=2, unimplemented.
+#else
+ return fputil::ldexp(x, n);
+#endif
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/nearbyintf128.h b/libc/src/math/nearbyintf128.h
new file mode 100644
index 00000000000000..d12754a4810092
--- /dev/null
+++ b/libc/src/math/nearbyintf128.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for nearbyintf128 -----------------*- 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_NEARBYINTF128_H
+#define LLVM_LIBC_SRC_MATH_NEARBYINTF128_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float128 nearbyintf128(float128 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_NEARBYINTF128_H
diff --git a/libc/src/math/scalbnf128.h b/libc/src/math/scalbnf128.h
new file mode 100644
index 00000000000000..bd3b560fb7cc42
--- /dev/null
+++ b/libc/src/math/scalbnf128.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for scalbnf128 --------------------*- 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_SCALBNF128_H
+#define LLVM_LIBC_SRC_MATH_SCALBNF128_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float128 scalbnf128(float128 x, int n);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_SCALBNF128_H
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 55119868bdaa19..77f8e206e010af 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -1203,6 +1203,58 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
+add_fp_unittest(
+ nearbyint_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ nearbyint_test.cpp
+ HDRS
+ NearbyIntTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.nearbyint
+)
+
+add_fp_unittest(
+ nearbyintf_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ nearbyintf_test.cpp
+ HDRS
+ NearbyIntTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.nearbyintf
+)
+
+add_fp_unittest(
+ nearbyintl_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ nearbyintl_test.cpp
+ HDRS
+ NearbyIntTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.nearbyintl
+)
+
+add_fp_unittest(
+ nearbyintf128_test
+ SUITE
+ libc-math-unittests
+ SRCS
+ nearbyintf128_test.cpp
+ HDRS
+ NearbyIntTest.h
+ DEPENDS
+ libc.include.math
+ libc.src.math.nearbyintf128
+)
+
add_fp_unittest(
nextafter_test
SUITE
@@ -1650,6 +1702,21 @@ add_fp_unittest(
libc.src.__support.FPUtil.normal_float
)
+add_fp_unittest(
+ scalbnf128_test
+ NEED_MPFR
+ SUITE
+ libc-math-unittests
+ SRCS
+ scalbnf128_test.cpp
+ HDRS
+ ScalbnTest.h
+ DEPENDS
+ libc.src.math.scalbnf128
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.normal_float
+)
+
add_fp_unittest(
erff_test
NEED_MPFR
diff --git a/libc/test/src/math/NearbyIntTest.h b/libc/test/src/math/NearbyIntTest.h
new file mode 100644
index 00000000000000..497d8d8dd430b3
--- /dev/null
+++ b/libc/test/src/math/NearbyIntTest.h
@@ -0,0 +1,107 @@
+//===-- Utility class to test different flavors of nearbyint ----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_TEST_SRC_MATH_NEARBYINTTEST_H
+#define LLVM_LIBC_TEST_SRC_MATH_NEARBYINTTEST_H
+
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+#include <fenv.h>
+
+static constexpr int ROUNDING_MODES[4] = {FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO,
+ FE_TONEAREST};
+
+template <typename T>
+class NearbyIntTestTemplate : public LIBC_NAMESPACE::testing::Test {
+
+ DECLARE_SPECIAL_CONSTANTS(T)
+
+public:
+ typedef T (*NearbyIntFunc)(T);
+
+ void testNaN(NearbyIntFunc func) {
+ ASSERT_FP_EQ(func(aNaN), aNaN);
+ }
+
+ void testInfinities(NearbyIntFunc func) {
+ ASSERT_FP_EQ(func(inf), inf);
+ ASSERT_FP_EQ(func(neg_inf), neg_inf);
+ }
+
+ void testZeroes(NearbyIntFunc func) {
+ ASSERT_FP_EQ(func(zero), zero);
+ ASSERT_FP_EQ(func(neg_zero), neg_zero);
+ }
+
+ void testIntegers(NearbyIntFunc func) {
+ for (int mode : ROUNDING_MODES) {
+ LIBC_NAMESPACE::fputil::set_round(mode);
+
+ ASSERT_FP_EQ(func(T(1.0)), T(1.0));
+ ASSERT_FP_EQ(func(T(-1.0)), T(-1.0));
+
+ ASSERT_FP_EQ(func(T(1234.0)), T(1234.0));
+ ASSERT_FP_EQ(func(T(-1234.0)), T(-1234.0));
+
+ ASSERT_FP_EQ(func(T(10.0)), T(10.0));
+ ASSERT_FP_EQ(func(T(-10.0)), T(-10.0));
+
+ FPBits ints_start(T(0));
+ ints_start.set_biased_exponent(FPBits::SIG_LEN + FPBits::EXP_BIAS);
+ T expected = ints_start.get_val();
+ ASSERT_FP_EQ(func(expected), expected);
+ }
+ }
+
+ void testSubnormalToNearest(NearbyIntFunc func) {
+ ASSERT_FP_EQ(func(min_denormal), zero);
+ ASSERT_FP_EQ(func(-min_denormal), neg_zero);
+ }
+
+ void testSubnormalToZero(NearbyIntFunc func) {
+ LIBC_NAMESPACE::fputil::set_round(FE_TOWARDZERO);
+ ASSERT_FP_EQ(func(min_denormal), zero);
+ ASSERT_FP_EQ(func(-min_denormal), neg_zero);
+ }
+
+ void testSubnormalToPosInf(NearbyIntFunc func) {
+ LIBC_NAMESPACE::fputil::set_round(FE_UPWARD);
+ ASSERT_FP_EQ(func(min_denormal), FPBits::one().get_val());
+ ASSERT_FP_EQ(func(-min_denormal), neg_zero);
+ }
+
+ void testSubnormalToNegInf(NearbyIntFunc func) {
+ LIBC_NAMESPACE::fputil::set_round(FE_DOWNWARD);
+ FPBits negative_one = FPBits::one(Sign::NEG);
+ ASSERT_FP_EQ(func(min_denormal), zero);
+ ASSERT_FP_EQ(func(-min_denormal), negative_one.get_val());
+ }
+};
+
+#define LIST_NEARBYINT_TESTS(T, func) \
+ using LlvmLibcNearbyIntTest = NearbyIntTestTemplate<T>; \
+ TEST_F(LlvmLibcNearbyIntTest, TestNaN) { testNaN(&func); } \
+ TEST_F(LlvmLibcNearbyIntTest, TestInfinities) { testInfinities(&func); } \
+ TEST_F(LlvmLibcNearbyIntTest, TestZeroes) { testZeroes(&func); } \
+ TEST_F(LlvmLibcNearbyIntTest, TestIntegers) { testIntegers(&func); } \
+ TEST_F(LlvmLibcNearbyIntTest, TestSubnormalToNearest) { \
+ testSubnormalToNearest(&func); \
+ } \
+ TEST_F(LlvmLibcNearbyIntTest, TestSubnormalToZero) { \
+ testSubnormalToZero(&func); \
+ } \
+ TEST_F(LlvmLibcNearbyIntTest, TestSubnormalToPosInf) { \
+ testSubnormalToPosInf(&func); \
+ } \
+ TEST_F(LlvmLibcNearbyIntTest, TestSubnormalToNegInf) { \
+ testSubnormalToNegInf(&func); \
+ }
+
+#endif // LLVM_LIBC_TEST_SRC_MATH_NEARBYINTTEST_H
diff --git a/libc/test/src/math/nearbyint_test.cpp b/libc/test/src/math/nearbyint_test.cpp
new file mode 100644
index 00000000000000..11a5c3372e73ea
--- /dev/null
+++ b/libc/test/src/math/nearbyint_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for nearbyint -------------------------------------------===//
+//
+// 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 "NearbyIntTest.h"
+
+#include "src/math/nearbyint.h"
+
+LIST_NEARBYINT_TESTS(double, LIBC_NAMESPACE::nearbyint)
diff --git a/libc/test/src/math/nearbyintf128_test.cpp b/libc/test/src/math/nearbyintf128_test.cpp
new file mode 100644
index 00000000000000..74c29652e9cd5e
--- /dev/null
+++ b/libc/test/src/math/nearbyintf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for nearbyintf128 ---------------------------------------===//
+//
+// 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 "NearbyIntTest.h"
+
+#include "src/math/nearbyintf128.h"
+
+LIST_NEARBYINT_TESTS(float128, LIBC_NAMESPACE::nearbyintf128)
\ No newline at end of file
diff --git a/libc/test/src/math/nearbyintf_test.cpp b/libc/test/src/math/nearbyintf_test.cpp
new file mode 100644
index 00000000000000..fd26153cfffb94
--- /dev/null
+++ b/libc/test/src/math/nearbyintf_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for nearbyintf ------------------------------------------===//
+//
+// 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 "NearbyIntTest.h"
+
+#include "src/math/nearbyintf.h"
+
+LIST_NEARBYINT_TESTS(float, LIBC_NAMESPACE::nearbyintf)
diff --git a/libc/test/src/math/nearbyintl_test.cpp b/libc/test/src/math/nearbyintl_test.cpp
new file mode 100644
index 00000000000000..a6d81a1439e17c
--- /dev/null
+++ b/libc/test/src/math/nearbyintl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for nearbyintl ------------------------------------------===//
+//
+// 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 "NearbyIntTest.h"
+
+#include "src/math/nearbyintl.h"
+
+LIST_NEARBYINT_TESTS(long double, LIBC_NAMESPACE::nearbyintl)
diff --git a/libc/test/src/math/scalbnf128_test.cpp b/libc/test/src/math/scalbnf128_test.cpp
new file mode 100644
index 00000000000000..dc259de211489e
--- /dev/null
+++ b/libc/test/src/math/scalbnf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for scalbnf128 ------------------------------------------===//
+//
+// 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 "ScalbnTest.h"
+
+#include "src/math/scalbnf128.h"
+
+LIST_SCALBN_TESTS(float128, LIBC_NAMESPACE::scalbnf128)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 22c59c97f6c7fd..33bcdb4c903b49 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2770,6 +2770,20 @@ add_fp_unittest(
libc.src.__support.FPUtil.normal_float
)
+add_fp_unittest(
+ scalbnf128_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ scalbnf128_test.cpp
+ HDRS
+ ScalbnTest.h
+ DEPENDS
+ libc.src.math.scalbnf128
+ libc.src.__support.FPUtil.fp_bits
+ libc.src.__support.FPUtil.normal_float
+)
+
add_fp_unittest(
erff_test
SUITE
diff --git a/libc/test/src/math/smoke/scalbnf128_test.cpp b/libc/test/src/math/smoke/scalbnf128_test.cpp
new file mode 100644
index 00000000000000..dc259de211489e
--- /dev/null
+++ b/libc/test/src/math/smoke/scalbnf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for scalbnf128 ------------------------------------------===//
+//
+// 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 "ScalbnTest.h"
+
+#include "src/math/scalbnf128.h"
+
+LIST_SCALBN_TESTS(float128, LIBC_NAMESPACE::scalbnf128)
More information about the libc-commits
mailing list