[libc-commits] [libc] [libc][math][c23] Add entrypoints and tests for setpayloadsig{, f, f128} (PR #102413)
via libc-commits
libc-commits at lists.llvm.org
Wed Aug 7 19:10:41 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Job Henandez Lara (Jobhdez)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/102413.diff
19 Files Affected:
- (modified) libc/config/linux/aarch64/entrypoints.txt (+3)
- (modified) libc/config/linux/arm/entrypoints.txt (+2)
- (modified) libc/config/linux/riscv/entrypoints.txt (+3)
- (modified) libc/config/linux/x86_64/entrypoints.txt (+3)
- (modified) libc/docs/math/index.rst (+1-1)
- (modified) libc/newhdrgen/yaml/math.yaml (+22)
- (modified) libc/spec/stdc.td (+3)
- (modified) libc/src/math/CMakeLists.txt (+3)
- (modified) libc/src/math/generic/CMakeLists.txt (+37)
- (added) libc/src/math/generic/setpayloadsig.cpp (+20)
- (added) libc/src/math/generic/setpayloadsigf.cpp (+20)
- (added) libc/src/math/generic/setpayloadsigf128.cpp (+20)
- (added) libc/src/math/setpayloadsig.h (+20)
- (added) libc/src/math/setpayloadsigf.h (+20)
- (added) libc/src/math/setpayloadsigf128.h (+21)
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+37)
- (added) libc/test/src/math/smoke/setpayloadsig_test.cpp (+13)
- (added) libc/test/src/math/smoke/setpayloadsigf128_test.cpp (+13)
- (added) libc/test/src/math/smoke/setpayloadsigf_test.cpp (+13)
``````````diff
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index cdc93f437bf5fa..fcf2dd766bd2d5 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -546,6 +546,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
+ libc.src.math.setpayloadsig
+ libc.src.math.setpayloadsigf
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
@@ -726,6 +728,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.roundf128
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
+ libc.src.math.setpayloadsigf128
libc.src.math.sqrtf128
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 5d33faad0cb0bb..9d648b754579e9 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -376,6 +376,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
+ libc.src.math.setpayloadsig
+ libc.src.math.setpayloadsigf
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 66dd6e261f3d63..d98a7b43ec0ff9 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -549,6 +549,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
+ libc.src.math.setpayloadsig
+ libc.src.math.setpayloadsigf
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
@@ -633,6 +635,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.roundf128
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
+ libc.src.math.setpayloadsigf128
libc.src.math.sqrtf128
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index ace1b1b08eb12b..24ffb52ee00d70 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -549,6 +549,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
+ libc.src.math.setpayloadsig
+ libc.src.math.setpayloadsigf
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
@@ -722,6 +724,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.roundf128
libc.src.math.scalbnf128
libc.src.math.setpayloadf128
+ libc.src.math.setpayloadsigf128
libc.src.math.sqrtf128
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
diff --git a/libc/docs/math/index.rst b/libc/docs/math/index.rst
index c665ce397f9b7d..0df1d5ec4b5fea 100644
--- a/libc/docs/math/index.rst
+++ b/libc/docs/math/index.rst
@@ -226,7 +226,7 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| setpayload | |check| | |check| | | |check| | |check| | F.10.13.2 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| setpayloadsig | | | | |check| | | F.10.13.3 | N/A |
+| setpayloadsig | |check| | |check| | | |check| | |check| | F.10.13.3 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| totalorder | |check| | |check| | | |check| | |check| | F.10.12.1 | N/A |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/newhdrgen/yaml/math.yaml b/libc/newhdrgen/yaml/math.yaml
index 12410c1d41e8cf..ae19811a6a0d36 100644
--- a/libc/newhdrgen/yaml/math.yaml
+++ b/libc/newhdrgen/yaml/math.yaml
@@ -1773,6 +1773,20 @@ functions:
- type: _Float16 *
- type: _Float16
guard: LIBC_TYPES_HAS_FLOAT16
+ - name: setpayloadsig
+ standards:
+ - stdc
+ return_type: double
+ arguments:
+ - type: double *
+ - type: double
+ - name: setpayloadsigf
+ standards:
+ - stdc
+ return_type: int
+ arguments:
+ - type: float *
+ - type: float
- name: setpayloadsigf16
standards:
- stdc
@@ -1781,6 +1795,14 @@ functions:
- type: _Float16 *
- type: _Float16
guard: LIBC_TYPES_HAS_FLOAT16
+ - name: setpayloadsigf128
+ standards:
+ - stdc
+ return_type: int
+ arguments:
+ - type: float128 *
+ - type: float128
+ guard: LIBC_TYPES_HAS_FLOAT128
- name: totalorderf16
standards:
- stdc
diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 6f974e4384a535..4d586de02e130a 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -761,7 +761,10 @@ def StdC : StandardSpec<"stdc"> {
GuardedFunctionSpec<"setpayloadf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"setpayloadf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
+ FunctionSpec<"setpayloadsig", RetValSpec<IntType>, [ArgSpec<DoublePtr>, ArgSpec<DoubleType>]>,
+ FunctionSpec<"setpayloadsigf", RetValSpec<IntType>, [ArgSpec<FloatPtr>, ArgSpec<FloatType>]>,
GuardedFunctionSpec<"setpayloadsigf16", RetValSpec<IntType>, [ArgSpec<Float16Ptr>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
+ GuardedFunctionSpec<"setpayloadsigf128", RetValSpec<IntType>, [ArgSpec<Float128Ptr>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
GuardedFunctionSpec<"f16addf128", RetValSpec<Float16Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">,
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index a0bd5269169fa3..fb36c49216ba81 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -439,7 +439,10 @@ add_math_entrypoint_object(setpayloadf)
add_math_entrypoint_object(setpayloadf16)
add_math_entrypoint_object(setpayloadf128)
+add_math_entrypoint_object(setpayloadsig)
+add_math_entrypoint_object(setpayloadsigf)
add_math_entrypoint_object(setpayloadsigf16)
+add_math_entrypoint_object(setpayloadsigf128)
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 be5cc2e02635af..602417386667f1 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4499,6 +4499,30 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ setpayloadsig
+ SRCS
+ setpayloadsig.cpp
+ HDRS
+ ../setpayloadsig.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
+add_entrypoint_object(
+ setpayloadsigf
+ SRCS
+ setpayloadsigf.cpp
+ HDRS
+ ../setpayloadsigf.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
setpayloadsigf16
SRCS
@@ -4512,6 +4536,19 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ setpayloadsigf128
+ SRCS
+ setpayloadsigf128.cpp
+ HDRS
+ ../setpayloadsigf128.h
+ DEPENDS
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.basic_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
f16add
SRCS
diff --git a/libc/src/math/generic/setpayloadsig.cpp b/libc/src/math/generic/setpayloadsig.cpp
new file mode 100644
index 00000000000000..fa8b165ca12777
--- /dev/null
+++ b/libc/src/math/generic/setpayloadsig.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of setpayloadsig 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/setpayloadsig.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, setpayloadsig, (double *res, double pl)) {
+ return static_cast<int>(fputil::setpayload</*IsSignaling=*/true>(*res, pl));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/setpayloadsigf.cpp b/libc/src/math/generic/setpayloadsigf.cpp
new file mode 100644
index 00000000000000..ec9d98f2123a86
--- /dev/null
+++ b/libc/src/math/generic/setpayloadsigf.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of setpayloadsigf 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/setpayloadsigf.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, setpayloadsigf, (float *res, float pl)) {
+ return static_cast<int>(fputil::setpayload</*IsSignaling=*/true>(*res, pl));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/setpayloadsigf128.cpp b/libc/src/math/generic/setpayloadsigf128.cpp
new file mode 100644
index 00000000000000..d98e4d1fc8b1cf
--- /dev/null
+++ b/libc/src/math/generic/setpayloadsigf128.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of setpayloadsigf128 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/setpayloadsigf128.h"
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, setpayloadsigf128, (float128 *res, float128 pl)) {
+ return static_cast<int>(fputil::setpayload</*IsSignaling=*/true>(*res, pl));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/setpayloadsig.h b/libc/src/math/setpayloadsig.h
new file mode 100644
index 00000000000000..8059e6f018210c
--- /dev/null
+++ b/libc/src/math/setpayloadsig.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for setpayloadsig -----------------*- 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_SETPAYLOADSIG_H
+#define LLVM_LIBC_SRC_MATH_SETPAYLOADSIG_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int setpayloadsig(double *res, double pl);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_SETPAYLOADSIG_H
diff --git a/libc/src/math/setpayloadsigf.h b/libc/src/math/setpayloadsigf.h
new file mode 100644
index 00000000000000..e7a0175682ea7c
--- /dev/null
+++ b/libc/src/math/setpayloadsigf.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for setpayloadsigf ----------------*- 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_SETPAYLOADSIGF_H
+#define LLVM_LIBC_SRC_MATH_SETPAYLOADSIGF_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int setpayloadsigf(float *res, float pl);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_SETPAYLOADSIGF_H
diff --git a/libc/src/math/setpayloadsigf128.h b/libc/src/math/setpayloadsigf128.h
new file mode 100644
index 00000000000000..4e036b9c8ba007
--- /dev/null
+++ b/libc/src/math/setpayloadsigf128.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for setpayloadsigf128 -------------*- 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_SETPAYLOADSIGF128_H
+#define LLVM_LIBC_SRC_MATH_SETPAYLOADSIGF128_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int setpayloadsigf128(float128 *res, float128 pl);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_SETPAYLOADSIGF128_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 6becaa569e62af..272295d3841a5a 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3957,6 +3957,30 @@ add_fp_unittest(
libc.src.math.setpayloadf128
)
+add_fp_unittest(
+ setpayloadsig_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ setpayloadsig_test.cpp
+ HDRS
+ SetPayloadSigTest.h
+ DEPENDS
+ libc.src.math.setpayloadsig
+)
+
+add_fp_unittest(
+ setpayloadsigf_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ setpayloadsigf_test.cpp
+ HDRS
+ SetPayloadSigTest.h
+ DEPENDS
+ libc.src.math.setpayloadsigf
+)
+
add_fp_unittest(
setpayloadsigf16_test
SUITE
@@ -3969,6 +3993,19 @@ add_fp_unittest(
libc.src.math.setpayloadsigf16
)
+add_fp_unittest(
+ setpayloadsigf128_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ setpayloadsigf128_test.cpp
+ HDRS
+ SetPayloadSigTest.h
+ DEPENDS
+ libc.src.math.setpayloadsigf128
+)
+
+
add_fp_unittest(
f16add_test
SUITE
diff --git a/libc/test/src/math/smoke/setpayloadsig_test.cpp b/libc/test/src/math/smoke/setpayloadsig_test.cpp
new file mode 100644
index 00000000000000..4a7dea73bbc8f6
--- /dev/null
+++ b/libc/test/src/math/smoke/setpayloadsig_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for setpayloadsig ---------------------------------------===//
+//
+// 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 "SetPayloadSigTest.h"
+
+#include "src/math/setpayloadsig.h"
+
+LIST_SETPAYLOADSIG_TESTS(double, LIBC_NAMESPACE::setpayloadsig)
diff --git a/libc/test/src/math/smoke/setpayloadsigf128_test.cpp b/libc/test/src/math/smoke/setpayloadsigf128_test.cpp
new file mode 100644
index 00000000000000..ea7d0268b3a29e
--- /dev/null
+++ b/libc/test/src/math/smoke/setpayloadsigf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for setpayloadsigf128 -----------------------------------===//
+//
+// 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 "SetPayloadSigTest.h"
+
+#include "src/math/setpayloadsigf128.h"
+
+LIST_SETPAYLOADSIG_TESTS(float128, LIBC_NAMESPACE::setpayloadsigf128)
diff --git a/libc/test/src/math/smoke/setpayloadsigf_test.cpp b/libc/test/src/math/smoke/setpayloadsigf_test.cpp
new file mode 100644
index 00000000000000..dd8ca2fe86ece0
--- /dev/null
+++ b/libc/test/src/math/smoke/setpayloadsigf_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for setpayloadsigf --------------------------------------===//
+//
+// 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 "SetPayloadSigTest.h"
+
+#include "src/math/setpayloadsigf.h"
+
+LIST_SETPAYLOADSIG_TESTS(float, LIBC_NAMESPACE::setpayloadsigf)
``````````
</details>
https://github.com/llvm/llvm-project/pull/102413
More information about the libc-commits
mailing list