-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[libc][math] Add setpayloadl function. #102408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libc Author: Job Henandez Lara (Jobhdez) ChangesHey so far in this pr I have only added the entrypoints to make Full diff: https://github.com/llvm/llvm-project/pull/102408.diff 10 Files Affected:
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)
|
You can test this locally with the following command:git-clang-format --diff 04e7eaf91f3e9b6830feb2e08bb5b0ddb14c3174 02ea6c143b2d1f055edc0e7c9e2b6e589fa7754c --extensions h,cpp -- libc/src/math/generic/setpayloadl.cpp libc/src/math/setpayloadl.h libc/test/src/math/smoke/setpayloadl_test.cpp View the diff from clang-format here.diff --git a/libc/src/math/generic/setpayloadl.cpp b/libc/src/math/generic/setpayloadl.cpp
index fd06338047..486f3f9272 100644
--- a/libc/src/math/generic/setpayloadl.cpp
+++ b/libc/src/math/generic/setpayloadl.cpp
@@ -13,7 +13,7 @@
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(int, setpayloadl, (long double *res, long double pl)) {
+LLVM_LIBC_FUNCTION(int, setpayloadl, (long double *res, long double pl)) {
return static_cast<int>(fputil::setpayload</*IsSignaling=*/false>(*res, pl));
}
|
This pull request was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey so far in this pr I have only added the entrypoints to make
setpayloadl
run. will debug shortly. thanks.