Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Aug 8, 2024

Hey so far in this pr I have only added the entrypoints to make setpayloadl run. will debug shortly. thanks.

@llvmbot llvmbot added the libc label Aug 8, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2024

@llvm/pr-subscribers-libc

Author: Job Henandez Lara (Jobhdez)

Changes

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 --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)

Copy link

github-actions bot commented Aug 8, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

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));
 }
 

@ghost ghost marked this pull request as draft August 8, 2024 02:14
@ghost ghost marked this pull request as ready for review August 8, 2024 03:06
@ghost ghost closed this Aug 8, 2024
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant