[libc-commits] [libc] [libc][math][c23] Add {nearbyint, rint, lrint, llrint, lround, llround}f16 C23 math functions (PR #94218)
via libc-commits
libc-commits at lists.llvm.org
Tue Jun 4 04:49:38 PDT 2024
- Previous message: [libc-commits] [libc] [libc][math][c23] Add {nearbyint, rint, lrint, llrint, lround, llround}f16 C23 math functions (PR #94218)
- Next message: [libc-commits] [libc] [libc][math][c23] Add {nearbyint, rint, lrint, llrint, lround, llround}f16 C23 math functions (PR #94218)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
https://github.com/overmighty updated https://github.com/llvm/llvm-project/pull/94218
>From 8e8b95eb4d5675a7fbaba51ec36be4274272b277 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Sun, 2 Jun 2024 20:02:09 +0200
Subject: [PATCH 1/7] [libc][math][c23] Add nearbyintf16 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/nearbyintf16.cpp | 19 ++++++++++++++++++
libc/src/math/nearbyintf16.h | 20 +++++++++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 13 ++++++++++++
.../test/src/math/smoke/nearbyintf16_test.cpp | 13 ++++++++++++
10 files changed, 83 insertions(+), 1 deletion(-)
create mode 100644 libc/src/math/generic/nearbyintf16.cpp
create mode 100644 libc/src/math/nearbyintf16.h
create mode 100644 libc/test/src/math/smoke/nearbyintf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 3bbd1629e3d8d..e0e35e517da4b 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -502,6 +502,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.ceilf16
libc.src.math.fabsf16
libc.src.math.floorf16
+ libc.src.math.nearbyintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
libc.src.math.truncf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 62434298890f0..e265542c8d974 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -535,6 +535,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.ceilf16
libc.src.math.fabsf16
libc.src.math.floorf16
+ libc.src.math.nearbyintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
libc.src.math.truncf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 9df7dcfc256db..0e1b1978a450d 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| | | |check| | 7.12.9.3 | F.10.6.3 |
+| 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 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index cacc91ce8789a..ac6895710d2ac 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -615,6 +615,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"nearbyint", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"nearbyintf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
FunctionSpec<"nearbyintl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"nearbyintf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"nearbyintf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"nextafterf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 3b07b0b8679c4..ba802073c5316 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -255,6 +255,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(nearbyintf16)
add_math_entrypoint_object(nearbyintf128)
add_math_entrypoint_object(nextafter)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 369616caa2565..a93b41185e64f 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -809,6 +809,19 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ nearbyintf16
+ SRCS
+ nearbyintf16.cpp
+ HDRS
+ ../nearbyintf16.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
nearbyintf128
SRCS
diff --git a/libc/src/math/generic/nearbyintf16.cpp b/libc/src/math/generic/nearbyintf16.cpp
new file mode 100644
index 0000000000000..efd31e9143f57
--- /dev/null
+++ b/libc/src/math/generic/nearbyintf16.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of nearbyintf16 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/nearbyintf16.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float16, nearbyintf16, (float16 x)) {
+ return fputil::round_using_current_rounding_mode(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/nearbyintf16.h b/libc/src/math/nearbyintf16.h
new file mode 100644
index 0000000000000..3e6f3fb3d493c
--- /dev/null
+++ b/libc/src/math/nearbyintf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for nearbyintf16 ------------------*- 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_NEARBYINTF16_H
+#define LLVM_LIBC_SRC_MATH_NEARBYINTF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float16 nearbyintf16(float16 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_NEARBYINTF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 685a53d8e7c6a..1e3ca3b6da3eb 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2299,6 +2299,19 @@ add_fp_unittest(
libc.src.math.nearbyintl
)
+add_fp_unittest(
+ nearbyintf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ nearbyintf16_test.cpp
+ HDRS
+ NearbyIntTest.h
+ DEPENDS
+ libc.hdr.fenv_macros
+ libc.src.math.nearbyintf16
+)
+
add_fp_unittest(
nearbyintf128_test
SUITE
diff --git a/libc/test/src/math/smoke/nearbyintf16_test.cpp b/libc/test/src/math/smoke/nearbyintf16_test.cpp
new file mode 100644
index 0000000000000..e6ec250cec91f
--- /dev/null
+++ b/libc/test/src/math/smoke/nearbyintf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for nearbyintf16 ----------------------------------------===//
+//
+// 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/nearbyintf16.h"
+
+LIST_NEARBYINT_TESTS(float16, LIBC_NAMESPACE::nearbyintf16)
>From 3599323e0c1f644ae49db6cabdf1059ac9033b20 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Mon, 3 Jun 2024 14:27:57 +0200
Subject: [PATCH 2/7] [libc][math][c23] Add rintf16 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/rintf16.cpp | 19 +++++++++++++++++++
libc/src/math/rintf16.h | 20 ++++++++++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 14 ++++++++++++++
libc/test/src/math/smoke/rintf16_test.cpp | 13 +++++++++++++
10 files changed, 84 insertions(+), 1 deletion(-)
create mode 100644 libc/src/math/generic/rintf16.cpp
create mode 100644 libc/src/math/rintf16.h
create mode 100644 libc/test/src/math/smoke/rintf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index e0e35e517da4b..51593764f8313 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -503,6 +503,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.fabsf16
libc.src.math.floorf16
libc.src.math.nearbyintf16
+ libc.src.math.rintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
libc.src.math.truncf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index e265542c8d974..80778a42b840a 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -536,6 +536,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.fabsf16
libc.src.math.floorf16
libc.src.math.nearbyintf16
+ libc.src.math.rintf16
libc.src.math.roundf16
libc.src.math.roundevenf16
libc.src.math.truncf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 0e1b1978a450d..ec405506b1525 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -202,7 +202,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| remquo | |check| | |check| | |check| | | | 7.12.10.3 | F.10.7.3 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| rint | |check| | |check| | |check| | | |check| | 7.12.9.4 | F.10.6.4 |
+| rint | |check| | |check| | |check| | |check| | |check| | 7.12.9.4 | F.10.6.4 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| round | |check| | |check| | |check| | |check| | |check| | 7.12.9.6 | F.10.6.6 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index ac6895710d2ac..d3b6313696a23 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -589,6 +589,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"rint", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"rintf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
FunctionSpec<"rintl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"rintf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"rintf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"lrint", RetValSpec<LongType>, [ArgSpec<DoubleType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index ba802073c5316..fa7f67c7c069b 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -291,6 +291,7 @@ add_math_entrypoint_object(remquol)
add_math_entrypoint_object(rint)
add_math_entrypoint_object(rintf)
add_math_entrypoint_object(rintl)
+add_math_entrypoint_object(rintf16)
add_math_entrypoint_object(rintf128)
add_math_entrypoint_object(round)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index a93b41185e64f..c38080204594f 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -662,6 +662,19 @@ add_entrypoint_object(
libc.src.__support.FPUtil.nearest_integer_operations
)
+add_entrypoint_object(
+ rintf16
+ SRCS
+ rintf16.cpp
+ HDRS
+ ../rintf16.h
+ COMPILE_OPTIONS
+ -O3
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
+)
+
add_entrypoint_object(
rintf128
SRCS
diff --git a/libc/src/math/generic/rintf16.cpp b/libc/src/math/generic/rintf16.cpp
new file mode 100644
index 0000000000000..e0caa7ad2550e
--- /dev/null
+++ b/libc/src/math/generic/rintf16.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of rintf16 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/rintf16.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(float16, rintf16, (float16 x)) {
+ return fputil::round_using_current_rounding_mode(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/rintf16.h b/libc/src/math/rintf16.h
new file mode 100644
index 0000000000000..5ea9587ef3cf6
--- /dev/null
+++ b/libc/src/math/rintf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for rintf16 -----------------------*- 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_RINTF16_H
+#define LLVM_LIBC_SRC_MATH_RINTF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+float16 rintf16(float16 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_RINTF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 1e3ca3b6da3eb..5ad3c17a406b7 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -675,6 +675,20 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
+add_fp_unittest(
+ rintf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ rintf16_test.cpp
+ HDRS
+ RIntTest.h
+ DEPENDS
+ libc.src.math.rintf16
+ libc.src.__support.FPUtil.fenv_impl
+ libc.src.__support.FPUtil.fp_bits
+)
+
add_fp_unittest(
rintf128_test
SUITE
diff --git a/libc/test/src/math/smoke/rintf16_test.cpp b/libc/test/src/math/smoke/rintf16_test.cpp
new file mode 100644
index 0000000000000..2adf2560bae1f
--- /dev/null
+++ b/libc/test/src/math/smoke/rintf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for rintf16 ---------------------------------------------===//
+//
+// 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 "RIntTest.h"
+
+#include "src/math/rintf16.h"
+
+LIST_RINT_TESTS(float16, LIBC_NAMESPACE::rintf16)
>From a886cb81b8712ca4a60aa5a601291d232ba88f58 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Mon, 3 Jun 2024 15:01:46 +0200
Subject: [PATCH 3/7] [libc][math][c23] Add lrintf16 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/lrintf16.cpp | 20 ++++++++++++
libc/src/math/lrintf16.h | 20 ++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 31 +++++++++++++++++++
libc/test/src/math/smoke/RoundToIntegerTest.h | 7 +++--
libc/test/src/math/smoke/lrintf16_test.cpp | 13 ++++++++
11 files changed, 107 insertions(+), 3 deletions(-)
create mode 100644 libc/src/math/generic/lrintf16.cpp
create mode 100644 libc/src/math/lrintf16.h
create mode 100644 libc/test/src/math/smoke/lrintf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 51593764f8313..52afd3c0a5a3f 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -502,6 +502,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.ceilf16
libc.src.math.fabsf16
libc.src.math.floorf16
+ libc.src.math.lrintf16
libc.src.math.nearbyintf16
libc.src.math.rintf16
libc.src.math.roundf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 80778a42b840a..878fb3a02b67d 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -535,6 +535,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.ceilf16
libc.src.math.fabsf16
libc.src.math.floorf16
+ libc.src.math.lrintf16
libc.src.math.nearbyintf16
libc.src.math.rintf16
libc.src.math.roundf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index ec405506b1525..9e446ee9f326d 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -180,7 +180,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| logb | |check| | |check| | |check| | | |check| | 7.12.6.17 | F.10.3.17 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| lrint | |check| | |check| | |check| | | |check| | 7.12.9.5 | F.10.6.5 |
+| lrint | |check| | |check| | |check| | |check| | |check| | 7.12.9.5 | F.10.6.5 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| lround | |check| | |check| | |check| | | |check| | 7.12.9.7 | F.10.6.7 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index d3b6313696a23..9f540e05ddffe 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -595,6 +595,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"lrint", RetValSpec<LongType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"lrintf", RetValSpec<LongType>, [ArgSpec<FloatType>]>,
FunctionSpec<"lrintl", RetValSpec<LongType>, [ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"lrintf16", RetValSpec<LongType>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"lrintf128", RetValSpec<LongType>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"llrint", RetValSpec<LongLongType>, [ArgSpec<DoubleType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index fa7f67c7c069b..173b2779f9c9b 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -235,6 +235,7 @@ add_math_entrypoint_object(llroundf128)
add_math_entrypoint_object(lrint)
add_math_entrypoint_object(lrintf)
add_math_entrypoint_object(lrintl)
+add_math_entrypoint_object(lrintf16)
add_math_entrypoint_object(lrintf128)
add_math_entrypoint_object(lround)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index c38080204594f..f26a1a2016849 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -724,6 +724,19 @@ add_entrypoint_object(
libc.src.__support.FPUtil.nearest_integer_operations
)
+add_entrypoint_object(
+ lrintf16
+ SRCS
+ lrintf16.cpp
+ HDRS
+ ../lrintf16.h
+ COMPILE_OPTIONS
+ -O3
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
+)
+
add_entrypoint_object(
lrintf128
SRCS
diff --git a/libc/src/math/generic/lrintf16.cpp b/libc/src/math/generic/lrintf16.cpp
new file mode 100644
index 0000000000000..d49be281a686b
--- /dev/null
+++ b/libc/src/math/generic/lrintf16.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of lrintf16 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/lrintf16.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(long, lrintf16, (float16 x)) {
+ return fputil::round_to_signed_integer_using_current_rounding_mode<float16,
+ long>(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/lrintf16.h b/libc/src/math/lrintf16.h
new file mode 100644
index 0000000000000..f31fba4cc6a46
--- /dev/null
+++ b/libc/src/math/lrintf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for lrintf16 ----------------------*- 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_LRINTF16_H
+#define LLVM_LIBC_SRC_MATH_LRINTF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+long lrintf16(float16 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_LRINTF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 5ad3c17a406b7..3704560517ac3 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -511,6 +511,7 @@ add_fp_unittest(
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.lround
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -528,6 +529,7 @@ add_fp_unittest(
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.lroundf
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -545,6 +547,7 @@ add_fp_unittest(
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.lroundl
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -562,6 +565,7 @@ add_fp_unittest(
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.lroundf128
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -579,6 +583,7 @@ add_fp_unittest(
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.llround
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -596,6 +601,7 @@ add_fp_unittest(
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.llroundf
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -613,6 +619,7 @@ add_fp_unittest(
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.llroundl
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -630,6 +637,7 @@ add_fp_unittest(
libc.src.fenv.feraiseexcept
libc.src.fenv.fetestexcept
libc.src.math.llroundf128
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)
@@ -713,6 +721,7 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.math.lrint
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -727,6 +736,7 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.math.lrintf
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -741,6 +751,22 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.math.lrintl
+ libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
+ libc.src.__support.FPUtil.fp_bits
+)
+
+add_fp_unittest(
+ lrintf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ lrintf16_test.cpp
+ HDRS
+ RoundToIntegerTest.h
+ DEPENDS
+ libc.src.math.lrintf16
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -755,6 +781,7 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.math.lrintf128
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -769,6 +796,7 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.math.llrint
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -783,6 +811,7 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.math.llrintf
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -797,6 +826,7 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.math.llrintl
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -811,6 +841,7 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.math.llrintf128
+ libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
diff --git a/libc/test/src/math/smoke/RoundToIntegerTest.h b/libc/test/src/math/smoke/RoundToIntegerTest.h
index 3ff311f46b056..02ae601716afc 100644
--- a/libc/test/src/math/smoke/RoundToIntegerTest.h
+++ b/libc/test/src/math/smoke/RoundToIntegerTest.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_SMOKE_ROUNDTOINTEGERTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_SMOKE_ROUNDTOINTEGERTEST_H
+#include "src/__support/CPP/algorithm.h"
#include "src/__support/FPUtil/FEnvImpl.h"
#include "src/__support/FPUtil/FPBits.h"
#include "test/UnitTest/FEnvSafeTest.h"
@@ -113,8 +114,10 @@ class RoundToIntegerTestTemplate
}
void testSubnormalRange(RoundToIntegerFunc func) {
- constexpr StorageType COUNT = 1'000'001;
- constexpr StorageType STEP = (MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT;
+ constexpr int COUNT = 1'000'001;
+ constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
+ static_cast<StorageType>((MAX_SUBNORMAL - MIN_SUBNORMAL) / COUNT),
+ StorageType(1));
for (StorageType i = MIN_SUBNORMAL; i <= MAX_SUBNORMAL; i += STEP) {
F x = FPBits(i).get_val();
if (x == F(0.0))
diff --git a/libc/test/src/math/smoke/lrintf16_test.cpp b/libc/test/src/math/smoke/lrintf16_test.cpp
new file mode 100644
index 0000000000000..28b1a1cb888d7
--- /dev/null
+++ b/libc/test/src/math/smoke/lrintf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for lrintf16 --------------------------------------------===//
+//
+// 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 "RoundToIntegerTest.h"
+
+#include "src/math/lrintf16.h"
+
+LIST_ROUND_TO_INTEGER_TESTS_WITH_MODES(float16, long, LIBC_NAMESPACE::lrintf16)
>From f4a9850649608a3b65d9b418d18c0ac5131615df Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Mon, 3 Jun 2024 15:05:51 +0200
Subject: [PATCH 4/7] [libc][math][c23] Add llrintf16 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/llrintf16.cpp | 21 +++++++++++++++++++++
libc/src/math/llrintf16.h | 20 ++++++++++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 15 +++++++++++++++
libc/test/src/math/smoke/llrintf16_test.cpp | 14 ++++++++++++++
10 files changed, 88 insertions(+), 1 deletion(-)
create mode 100644 libc/src/math/generic/llrintf16.cpp
create mode 100644 libc/src/math/llrintf16.h
create mode 100644 libc/test/src/math/smoke/llrintf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 52afd3c0a5a3f..c1207babfe06a 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -502,6 +502,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.ceilf16
libc.src.math.fabsf16
libc.src.math.floorf16
+ libc.src.math.llrintf16
libc.src.math.lrintf16
libc.src.math.nearbyintf16
libc.src.math.rintf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 878fb3a02b67d..9871d7b00ca1b 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -535,6 +535,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.ceilf16
libc.src.math.fabsf16
libc.src.math.floorf16
+ libc.src.math.llrintf16
libc.src.math.lrintf16
libc.src.math.nearbyintf16
libc.src.math.rintf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index 9e446ee9f326d..ffbfec8c40039 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -174,7 +174,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| llogb | |check| | |check| | |check| | | |check| | 7.12.6.10 | F.10.3.10 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| llrint | |check| | |check| | |check| | | |check| | 7.12.9.5 | F.10.6.5 |
+| llrint | |check| | |check| | |check| | |check| | |check| | 7.12.9.5 | F.10.6.5 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| llround | |check| | |check| | |check| | | |check| | 7.12.9.7 | F.10.6.7 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 9f540e05ddffe..75fc9b83c1ba5 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -601,6 +601,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"llrint", RetValSpec<LongLongType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"llrintf", RetValSpec<LongLongType>, [ArgSpec<FloatType>]>,
FunctionSpec<"llrintl", RetValSpec<LongLongType>, [ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"llrintf16", RetValSpec<LongLongType>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"llrintf128", RetValSpec<LongLongType>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"sqrt", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 173b2779f9c9b..09c6b6bbd9c46 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -225,6 +225,7 @@ add_math_entrypoint_object(logbf128)
add_math_entrypoint_object(llrint)
add_math_entrypoint_object(llrintf)
add_math_entrypoint_object(llrintl)
+add_math_entrypoint_object(llrintf16)
add_math_entrypoint_object(llrintf128)
add_math_entrypoint_object(llround)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index f26a1a2016849..978899a213452 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -786,6 +786,19 @@ add_entrypoint_object(
libc.src.__support.FPUtil.nearest_integer_operations
)
+add_entrypoint_object(
+ llrintf16
+ SRCS
+ llrintf16.cpp
+ HDRS
+ ../llrintf16.h
+ COMPILE_OPTIONS
+ -O3
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
+)
+
add_entrypoint_object(
llrintf128
SRCS
diff --git a/libc/src/math/generic/llrintf16.cpp b/libc/src/math/generic/llrintf16.cpp
new file mode 100644
index 0000000000000..ccde2db1cbf8f
--- /dev/null
+++ b/libc/src/math/generic/llrintf16.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of llrintf16 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/llrintf16.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(long long, llrintf16, (float16 x)) {
+ return fputil::round_to_signed_integer_using_current_rounding_mode<float128,
+ long long>(
+ x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/llrintf16.h b/libc/src/math/llrintf16.h
new file mode 100644
index 0000000000000..90ad0e9e2ea2a
--- /dev/null
+++ b/libc/src/math/llrintf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for llrintf16 ---------------------*- 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_LLRINTF16_H
+#define LLVM_LIBC_SRC_MATH_LLRINTF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+long long llrintf16(float16 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_LLRINTF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 3704560517ac3..b281a3ffdce51 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -831,6 +831,21 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
+add_fp_unittest(
+ llrintf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ llrintf16_test.cpp
+ HDRS
+ RoundToIntegerTest.h
+ DEPENDS
+ libc.src.math.llrintf16
+ libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
+ libc.src.__support.FPUtil.fp_bits
+)
+
add_fp_unittest(
llrintf128_test
SUITE
diff --git a/libc/test/src/math/smoke/llrintf16_test.cpp b/libc/test/src/math/smoke/llrintf16_test.cpp
new file mode 100644
index 0000000000000..d16bd8f38b052
--- /dev/null
+++ b/libc/test/src/math/smoke/llrintf16_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for llrintf16 -------------------------------------------===//
+//
+// 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 "RoundToIntegerTest.h"
+
+#include "src/math/llrintf16.h"
+
+LIST_ROUND_TO_INTEGER_TESTS_WITH_MODES(float16, long long,
+ LIBC_NAMESPACE::llrintf16)
>From 30cd5374be45c49fc146666ea882113737128ecb Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Mon, 3 Jun 2024 15:22:42 +0200
Subject: [PATCH 5/7] [libc][math][c23] Add lroundf16 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/lroundf16.cpp | 19 +++++++
libc/src/math/lroundf16.h | 20 +++++++
libc/test/src/math/smoke/CMakeLists.txt | 58 ++++++++++++---------
libc/test/src/math/smoke/lroundf16_test.cpp | 13 +++++
10 files changed, 104 insertions(+), 25 deletions(-)
create mode 100644 libc/src/math/generic/lroundf16.cpp
create mode 100644 libc/src/math/lroundf16.h
create mode 100644 libc/test/src/math/smoke/lroundf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index c1207babfe06a..dfdebf7c277be 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -504,6 +504,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.floorf16
libc.src.math.llrintf16
libc.src.math.lrintf16
+ libc.src.math.lroundf16
libc.src.math.nearbyintf16
libc.src.math.rintf16
libc.src.math.roundf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 9871d7b00ca1b..8558fd847ab7b 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -537,6 +537,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.floorf16
libc.src.math.llrintf16
libc.src.math.lrintf16
+ libc.src.math.lroundf16
libc.src.math.nearbyintf16
libc.src.math.rintf16
libc.src.math.roundf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index ffbfec8c40039..abd96dc124d54 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -182,7 +182,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| lrint | |check| | |check| | |check| | |check| | |check| | 7.12.9.5 | F.10.6.5 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| lround | |check| | |check| | |check| | | |check| | 7.12.9.7 | F.10.6.7 |
+| lround | |check| | |check| | |check| | |check| | |check| | 7.12.9.7 | F.10.6.7 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| modf | |check| | |check| | |check| | | |check| | 7.12.6.18 | F.10.3.18 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 75fc9b83c1ba5..8e0a4b2154078 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -579,6 +579,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"lround", RetValSpec<LongType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"lroundf", RetValSpec<LongType>, [ArgSpec<FloatType>]>,
FunctionSpec<"lroundl", RetValSpec<LongType>, [ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"lroundf16", RetValSpec<LongType>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"lroundf128", RetValSpec<LongType>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"llround", RetValSpec<LongLongType>, [ArgSpec<DoubleType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 09c6b6bbd9c46..99cb3982b58c4 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -242,6 +242,7 @@ add_math_entrypoint_object(lrintf128)
add_math_entrypoint_object(lround)
add_math_entrypoint_object(lroundf)
add_math_entrypoint_object(lroundl)
+add_math_entrypoint_object(lroundf16)
add_math_entrypoint_object(lroundf128)
add_math_entrypoint_object(modf)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 978899a213452..ddbf594144c2d 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -564,6 +564,19 @@ add_entrypoint_object(
libc.src.__support.FPUtil.nearest_integer_operations
)
+add_entrypoint_object(
+ lroundf16
+ SRCS
+ lroundf16.cpp
+ HDRS
+ ../lroundf16.h
+ COMPILE_OPTIONS
+ -O3
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
+)
+
add_entrypoint_object(
lroundf128
SRCS
diff --git a/libc/src/math/generic/lroundf16.cpp b/libc/src/math/generic/lroundf16.cpp
new file mode 100644
index 0000000000000..c854168d80786
--- /dev/null
+++ b/libc/src/math/generic/lroundf16.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of lroundf16 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/lroundf16.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(long, lroundf16, (float16 x)) {
+ return fputil::round_to_signed_integer<float128, long>(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/lroundf16.h b/libc/src/math/lroundf16.h
new file mode 100644
index 0000000000000..57201e7063a9e
--- /dev/null
+++ b/libc/src/math/lroundf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for lroundf16 ---------------------*- 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_LROUNDF16_H
+#define LLVM_LIBC_SRC_MATH_LROUNDF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+long lroundf16(float16 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_LROUNDF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index b281a3ffdce51..48bc2e545a4c3 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -507,11 +507,9 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.errno.errno
- libc.src.fenv.feclearexcept
- libc.src.fenv.feraiseexcept
- libc.src.fenv.fetestexcept
libc.src.math.lround
libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -525,11 +523,9 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.errno.errno
- libc.src.fenv.feclearexcept
- libc.src.fenv.feraiseexcept
- libc.src.fenv.fetestexcept
libc.src.math.lroundf
libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -543,11 +539,25 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.errno.errno
- libc.src.fenv.feclearexcept
- libc.src.fenv.feraiseexcept
- libc.src.fenv.fetestexcept
libc.src.math.lroundl
libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
+ libc.src.__support.FPUtil.fp_bits
+)
+
+add_fp_unittest(
+ lroundf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ lroundf16_test.cpp
+ HDRS
+ RoundToIntegerTest.h
+ DEPENDS
+ libc.src.errno.errno
+ libc.src.math.lroundf16
+ libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -561,11 +571,9 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.errno.errno
- libc.src.fenv.feclearexcept
- libc.src.fenv.feraiseexcept
- libc.src.fenv.fetestexcept
libc.src.math.lroundf128
libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -579,11 +587,9 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.errno.errno
- libc.src.fenv.feclearexcept
- libc.src.fenv.feraiseexcept
- libc.src.fenv.fetestexcept
libc.src.math.llround
libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -597,11 +603,9 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.errno.errno
- libc.src.fenv.feclearexcept
- libc.src.fenv.feraiseexcept
- libc.src.fenv.fetestexcept
libc.src.math.llroundf
libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -615,11 +619,9 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.errno.errno
- libc.src.fenv.feclearexcept
- libc.src.fenv.feraiseexcept
- libc.src.fenv.fetestexcept
libc.src.math.llroundl
libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -633,11 +635,9 @@ add_fp_unittest(
RoundToIntegerTest.h
DEPENDS
libc.src.errno.errno
- libc.src.fenv.feclearexcept
- libc.src.fenv.feraiseexcept
- libc.src.fenv.fetestexcept
libc.src.math.llroundf128
libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
)
@@ -720,6 +720,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.lrint
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
@@ -735,6 +736,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.lrintf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
@@ -750,6 +752,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.lrintl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
@@ -765,6 +768,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.lrintf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
@@ -780,6 +784,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.lrintf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
@@ -795,6 +800,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.llrint
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
@@ -810,6 +816,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.llrintf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
@@ -825,6 +832,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.llrintl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
@@ -840,6 +848,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.llrintf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
@@ -855,6 +864,7 @@ add_fp_unittest(
HDRS
RoundToIntegerTest.h
DEPENDS
+ libc.src.errno.errno
libc.src.math.llrintf128
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fenv_impl
diff --git a/libc/test/src/math/smoke/lroundf16_test.cpp b/libc/test/src/math/smoke/lroundf16_test.cpp
new file mode 100644
index 0000000000000..3077134d58f91
--- /dev/null
+++ b/libc/test/src/math/smoke/lroundf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for lroundf16 -------------------------------------------===//
+//
+// 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 "RoundToIntegerTest.h"
+
+#include "src/math/lroundf16.h"
+
+LIST_ROUND_TO_INTEGER_TESTS(float16, long, LIBC_NAMESPACE::lroundf16)
>From c9c1068124effd99ec744c09acba1fba24280f41 Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Mon, 3 Jun 2024 15:26:52 +0200
Subject: [PATCH 6/7] [libc][math][c23] Add llroundf16 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/llroundf16.cpp | 19 +++++++++++++++++++
libc/src/math/llroundf16.h | 20 ++++++++++++++++++++
libc/test/src/math/smoke/CMakeLists.txt | 16 ++++++++++++++++
libc/test/src/math/smoke/llroundf16_test.cpp | 13 +++++++++++++
10 files changed, 86 insertions(+), 1 deletion(-)
create mode 100644 libc/src/math/generic/llroundf16.cpp
create mode 100644 libc/src/math/llroundf16.h
create mode 100644 libc/test/src/math/smoke/llroundf16_test.cpp
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index dfdebf7c277be..23842c951c8cc 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -503,6 +503,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.fabsf16
libc.src.math.floorf16
libc.src.math.llrintf16
+ libc.src.math.llroundf16
libc.src.math.lrintf16
libc.src.math.lroundf16
libc.src.math.nearbyintf16
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 8558fd847ab7b..6506ea3108169 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -536,6 +536,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.fabsf16
libc.src.math.floorf16
libc.src.math.llrintf16
+ libc.src.math.llroundf16
libc.src.math.lrintf16
libc.src.math.lroundf16
libc.src.math.nearbyintf16
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index abd96dc124d54..b1a8aa2dd9470 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -176,7 +176,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| llrint | |check| | |check| | |check| | |check| | |check| | 7.12.9.5 | F.10.6.5 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| llround | |check| | |check| | |check| | | |check| | 7.12.9.7 | F.10.6.7 |
+| llround | |check| | |check| | |check| | |check| | |check| | 7.12.9.7 | F.10.6.7 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| logb | |check| | |check| | |check| | | |check| | 7.12.6.17 | F.10.3.17 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 8e0a4b2154078..2e64336ed4835 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -585,6 +585,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"llround", RetValSpec<LongLongType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"llroundf", RetValSpec<LongLongType>, [ArgSpec<FloatType>]>,
FunctionSpec<"llroundl", RetValSpec<LongLongType>, [ArgSpec<LongDoubleType>]>,
+ GuardedFunctionSpec<"llroundf16", RetValSpec<LongLongType>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"llroundf128", RetValSpec<LongLongType>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
FunctionSpec<"rint", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index 99cb3982b58c4..84c9beebfbea2 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -231,6 +231,7 @@ add_math_entrypoint_object(llrintf128)
add_math_entrypoint_object(llround)
add_math_entrypoint_object(llroundf)
add_math_entrypoint_object(llroundl)
+add_math_entrypoint_object(llroundf16)
add_math_entrypoint_object(llroundf128)
add_math_entrypoint_object(lrint)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index ddbf594144c2d..4fb744254cfdc 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -626,6 +626,19 @@ add_entrypoint_object(
libc.src.__support.FPUtil.nearest_integer_operations
)
+add_entrypoint_object(
+ llroundf16
+ SRCS
+ llroundf16.cpp
+ HDRS
+ ../llroundf16.h
+ COMPILE_OPTIONS
+ -O3
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.nearest_integer_operations
+)
+
add_entrypoint_object(
llroundf128
SRCS
diff --git a/libc/src/math/generic/llroundf16.cpp b/libc/src/math/generic/llroundf16.cpp
new file mode 100644
index 0000000000000..e12421aa1f6fa
--- /dev/null
+++ b/libc/src/math/generic/llroundf16.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of llroundf16 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/llroundf16.h"
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(long long, llroundf16, (float16 x)) {
+ return fputil::round_to_signed_integer<float128, long long>(x);
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/llroundf16.h b/libc/src/math/llroundf16.h
new file mode 100644
index 0000000000000..379c45446ab27
--- /dev/null
+++ b/libc/src/math/llroundf16.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for llroundf16 --------------------*- 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_LLROUNDF16_H
+#define LLVM_LIBC_SRC_MATH_LLROUNDF16_H
+
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE {
+
+long long llroundf16(float16 x);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_MATH_LLROUNDF16_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 48bc2e545a4c3..8f4eb37e665cb 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -625,6 +625,22 @@ add_fp_unittest(
libc.src.__support.FPUtil.fp_bits
)
+add_fp_unittest(
+ llroundf16_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ llroundf16_test.cpp
+ HDRS
+ RoundToIntegerTest.h
+ DEPENDS
+ libc.src.errno.errno
+ libc.src.math.llroundf16
+ libc.src.__support.CPP.algorithm
+ libc.src.__support.FPUtil.fenv_impl
+ libc.src.__support.FPUtil.fp_bits
+)
+
add_fp_unittest(
llroundf128_test
SUITE
diff --git a/libc/test/src/math/smoke/llroundf16_test.cpp b/libc/test/src/math/smoke/llroundf16_test.cpp
new file mode 100644
index 0000000000000..9342b24fd5d04
--- /dev/null
+++ b/libc/test/src/math/smoke/llroundf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for llroundf16 ------------------------------------------===//
+//
+// 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 "RoundToIntegerTest.h"
+
+#include "src/math/llroundf16.h"
+
+LIST_ROUND_TO_INTEGER_TESTS(float16, long long, LIBC_NAMESPACE::llroundf16)
>From e448177ab4cb062d6bb4a6218718ab287d45669a Mon Sep 17 00:00:00 2001
From: OverMighty <its.overmighty at gmail.com>
Date: Tue, 4 Jun 2024 13:48:43 +0200
Subject: [PATCH 7/7] [libc][math][c23] Fix usage of float128 instead of
float16
---
libc/src/math/generic/llrintf16.cpp | 2 +-
libc/src/math/generic/llroundf16.cpp | 2 +-
libc/src/math/generic/lroundf16.cpp | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libc/src/math/generic/llrintf16.cpp b/libc/src/math/generic/llrintf16.cpp
index ccde2db1cbf8f..0bed21ad17bb8 100644
--- a/libc/src/math/generic/llrintf16.cpp
+++ b/libc/src/math/generic/llrintf16.cpp
@@ -13,7 +13,7 @@
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long long, llrintf16, (float16 x)) {
- return fputil::round_to_signed_integer_using_current_rounding_mode<float128,
+ return fputil::round_to_signed_integer_using_current_rounding_mode<float16,
long long>(
x);
}
diff --git a/libc/src/math/generic/llroundf16.cpp b/libc/src/math/generic/llroundf16.cpp
index e12421aa1f6fa..9485674d54bcb 100644
--- a/libc/src/math/generic/llroundf16.cpp
+++ b/libc/src/math/generic/llroundf16.cpp
@@ -13,7 +13,7 @@
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long long, llroundf16, (float16 x)) {
- return fputil::round_to_signed_integer<float128, long long>(x);
+ return fputil::round_to_signed_integer<float16, long long>(x);
}
} // namespace LIBC_NAMESPACE
diff --git a/libc/src/math/generic/lroundf16.cpp b/libc/src/math/generic/lroundf16.cpp
index c854168d80786..db8113d7bfb5e 100644
--- a/libc/src/math/generic/lroundf16.cpp
+++ b/libc/src/math/generic/lroundf16.cpp
@@ -13,7 +13,7 @@
namespace LIBC_NAMESPACE {
LLVM_LIBC_FUNCTION(long, lroundf16, (float16 x)) {
- return fputil::round_to_signed_integer<float128, long>(x);
+ return fputil::round_to_signed_integer<float16, long>(x);
}
} // namespace LIBC_NAMESPACE
- Previous message: [libc-commits] [libc] [libc][math][c23] Add {nearbyint, rint, lrint, llrint, lround, llround}f16 C23 math functions (PR #94218)
- Next message: [libc-commits] [libc] [libc][math][c23] Add {nearbyint, rint, lrint, llrint, lround, llround}f16 C23 math functions (PR #94218)
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the libc-commits
mailing list