[libc-commits] [libc] [libc][math] Add setpayloadl function. (PR #102408)
via libc-commits
libc-commits at lists.llvm.org
Wed Aug 7 18:13:46 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Job Henandez Lara (Jobhdez)
<details>
<summary>Changes</summary>
Hey so far in this pr I have only added the entrypoints to make `setpayloadl` run. will debug shortly. thanks.
---
Full diff: https://github.com/llvm/llvm-project/pull/102408.diff
10 Files Affected:
- (modified) libc/config/linux/aarch64/entrypoints.txt (+1)
- (modified) libc/config/linux/arm/entrypoints.txt (+1)
- (modified) libc/config/linux/riscv/entrypoints.txt (+1)
- (modified) libc/config/linux/x86_64/entrypoints.txt (+1)
- (modified) libc/src/math/CMakeLists.txt (+1)
- (modified) libc/src/math/generic/CMakeLists.txt (+12)
- (added) libc/src/math/generic/setpayloadl.cpp (+20)
- (added) libc/src/math/setpayloadl.h (+20)
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+12)
- (added) libc/test/src/math/smoke/setpayloadl_test.cpp (+13)
``````````diff
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index b705b82c70f399..83d3d924522f81 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -544,6 +544,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
+ libc.src.math.setpayloadl
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 36e940af4fb6ba..fe1afa1fd89080 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -374,6 +374,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
+ libc.src.math.setpayloadl
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 f117c5fc608fae..69aa36afcb00fc 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -547,6 +547,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
+ libc.src.math.setpayloadl
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 39d90bf06a0cf4..c7c0d1745194ef 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -547,6 +547,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
+ libc.src.math.setpayloadl
libc.src.math.sin
libc.src.math.sincos
libc.src.math.sincosf
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index a3c9b5473c290e..ac19431eb8f0a8 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -431,6 +431,7 @@ add_math_entrypoint_object(scalbnf128)
add_math_entrypoint_object(setpayload)
add_math_entrypoint_object(setpayloadf)
+add_math_entrypoint_object(setpayloadl)
add_math_entrypoint_object(setpayloadf16)
add_math_entrypoint_object(setpayloadf128)
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 77f7f4fef007b9..773a62558f2331 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4423,6 +4423,18 @@ add_entrypoint_object(
-O3
)
+add_entrypoint_object(
+ setpayloadl
+ SRCS
+ setpayloadl.cpp
+ HDRS
+ ../setpayloadl.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ COMPILE_OPTIONS
+ -O3
+)
+
add_entrypoint_object(
setpayloadf16
SRCS
diff --git a/libc/src/math/generic/setpayloadl.cpp b/libc/src/math/generic/setpayloadl.cpp
new file mode 100644
index 00000000000000..fd0633804783a7
--- /dev/null
+++ b/libc/src/math/generic/setpayloadl.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of setpayloadl 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/setpayloadl.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, setpayloadl, (long double *res, long double pl)) {
+ return static_cast<int>(fputil::setpayload</*IsSignaling=*/false>(*res, pl));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/setpayloadl.h b/libc/src/math/setpayloadl.h
new file mode 100644
index 00000000000000..f0df62f8f22f5a
--- /dev/null
+++ b/libc/src/math/setpayloadl.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for setpayloadl -------------------*- 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_SETPAYLOADL_H
+#define LLVM_LIBC_SRC_MATH_SETPAYLOADL_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int setpayloadl(long double *res, long double pl);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_SETPAYLOADL_H
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 9aa5399aae9d38..23967a47f6702c 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3933,6 +3933,18 @@ add_fp_unittest(
libc.src.math.setpayloadf
)
+add_fp_unittest(
+ setpayloadl_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ setpayloadl_test.cpp
+ HDRS
+ SetPayloadTest.h
+ DEPENDS
+ libc.src.math.setpayloadl
+)
+
add_fp_unittest(
setpayloadf16_test
SUITE
diff --git a/libc/test/src/math/smoke/setpayloadl_test.cpp b/libc/test/src/math/smoke/setpayloadl_test.cpp
new file mode 100644
index 00000000000000..45bc6fd2bb9fdf
--- /dev/null
+++ b/libc/test/src/math/smoke/setpayloadl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for setpayloadl -----------------------------------------===//
+//
+// 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 "SetPayloadTest.h"
+
+#include "src/math/setpayloadl.h"
+
+LIST_SETPAYLOAD_TESTS(long double, LIBC_NAMESPACE::setpayloadl)
``````````
</details>
https://github.com/llvm/llvm-project/pull/102408
More information about the libc-commits
mailing list