[libc-commits] [libc] [libc][math] exapnd macro definition for iscanonical variants (PR #110865)

via libc-commits libc-commits at lists.llvm.org
Wed Oct 2 08:18:02 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Shourya Goel (Sh0g0-1758)

<details>
<summary>Changes</summary>

It appears that #<!-- -->110565 fails because the macro LLVM_LIBC_FUNCTION is not being recognized or expanded properly. This PR expands the macro and also removes the static_assert since conversion from bool to int is well defined in C/C++. 

---
Full diff: https://github.com/llvm/llvm-project/pull/110865.diff


5 Files Affected:

- (modified) libc/src/math/generic/iscanonical.cpp (+2-2) 
- (modified) libc/src/math/generic/iscanonicalf.cpp (+2-2) 
- (modified) libc/src/math/generic/iscanonicalf128.cpp (+2-2) 
- (modified) libc/src/math/generic/iscanonicalf16.cpp (+2-2) 
- (modified) libc/src/math/generic/iscanonicall.cpp (+2-2) 


``````````diff
diff --git a/libc/src/math/generic/iscanonical.cpp b/libc/src/math/generic/iscanonical.cpp
index d67a6b87b3e506..69a95c719a85c9 100644
--- a/libc/src/math/generic/iscanonical.cpp
+++ b/libc/src/math/generic/iscanonical.cpp
@@ -13,9 +13,9 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, iscanonical, (double x)) {
+int iscanonical(double x) {
   double temp;
-  return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+  return fputil::canonicalize(temp, x) == 0;
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/iscanonicalf.cpp b/libc/src/math/generic/iscanonicalf.cpp
index daa0708794d2f4..b27c0fd1fabf44 100644
--- a/libc/src/math/generic/iscanonicalf.cpp
+++ b/libc/src/math/generic/iscanonicalf.cpp
@@ -13,9 +13,9 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, iscanonicalf, (float x)) {
+int iscanonicalf(float x) {
   float temp;
-  return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+  return fputil::canonicalize(temp, x) == 0;
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/iscanonicalf128.cpp b/libc/src/math/generic/iscanonicalf128.cpp
index 9be50050f8234c..ccd9b34411b2c4 100644
--- a/libc/src/math/generic/iscanonicalf128.cpp
+++ b/libc/src/math/generic/iscanonicalf128.cpp
@@ -13,9 +13,9 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, iscanonicalf128, (float128 x)) {
+int iscanonicalf128(float128 x) {
   float128 temp;
-  return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+  return fputil::canonicalize(temp, x) == 0;
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/iscanonicalf16.cpp b/libc/src/math/generic/iscanonicalf16.cpp
index 4f7bb1a0050f51..236b6276295137 100644
--- a/libc/src/math/generic/iscanonicalf16.cpp
+++ b/libc/src/math/generic/iscanonicalf16.cpp
@@ -13,9 +13,9 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, iscanonicalf16, (float16 x)) {
+int iscanonicalf16(float16 x) {
   float16 temp;
-  return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+  return fputil::canonicalize(temp, x) == 0;
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/iscanonicall.cpp b/libc/src/math/generic/iscanonicall.cpp
index 756c1f8fb4abfa..9aa28ecccf6a86 100644
--- a/libc/src/math/generic/iscanonicall.cpp
+++ b/libc/src/math/generic/iscanonicall.cpp
@@ -13,9 +13,9 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, iscanonicall, (long double x)) {
+int iscanonicall(long double x) {
   long double temp;
-  return static_cast<int>(fputil::canonicalize(temp, x) == 0);
+  return fputil::canonicalize(temp, x) == 0;
 }
 
 } // namespace LIBC_NAMESPACE_DECL

``````````

</details>


https://github.com/llvm/llvm-project/pull/110865


More information about the libc-commits mailing list