[libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356)

via libc-commits libc-commits at lists.llvm.org
Sun Feb 2 11:45:45 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff c1163b843b63f775817b84f124cdcf33f25c28f6 519ae5df684c9f850688048aa80abfaccc1ddaac --extensions cpp,h -- libc/cmake/modules/compiler_features/check_padding_on_unsigned_fixed_point.cpp libc/src/stdfix/countlshk.cpp libc/src/stdfix/countlshk.h libc/src/stdfix/countlshr.cpp libc/src/stdfix/countlshr.h libc/src/stdfix/countlsk.cpp libc/src/stdfix/countlsk.h libc/src/stdfix/countlslk.cpp libc/src/stdfix/countlslk.h libc/src/stdfix/countlslr.cpp libc/src/stdfix/countlslr.h libc/src/stdfix/countlsr.cpp libc/src/stdfix/countlsr.h libc/src/stdfix/countlsuhk.cpp libc/src/stdfix/countlsuhk.h libc/src/stdfix/countlsuhr.cpp libc/src/stdfix/countlsuhr.h libc/src/stdfix/countlsuk.cpp libc/src/stdfix/countlsuk.h libc/src/stdfix/countlsulk.cpp libc/src/stdfix/countlsulk.h libc/src/stdfix/countlsulr.cpp libc/src/stdfix/countlsulr.h libc/src/stdfix/countlsur.cpp libc/src/stdfix/countlsur.h libc/test/src/stdfix/CountlsTest.h libc/test/src/stdfix/countlshk_test.cpp libc/test/src/stdfix/countlshr_test.cpp libc/test/src/stdfix/countlsk_test.cpp libc/test/src/stdfix/countlslk_test.cpp libc/test/src/stdfix/countlslr_test.cpp libc/test/src/stdfix/countlsr_test.cpp libc/test/src/stdfix/countlsuhk_test.cpp libc/test/src/stdfix/countlsuhr_test.cpp libc/test/src/stdfix/countlsuk_test.cpp libc/test/src/stdfix/countlsulk_test.cpp libc/test/src/stdfix/countlsulr_test.cpp libc/test/src/stdfix/countlsur_test.cpp libc/src/__support/fixed_point/fx_bits.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/src/__support/fixed_point/fx_bits.h b/libc/src/__support/fixed_point/fx_bits.h
index a955ee6774..59e9610216 100644
--- a/libc/src/__support/fixed_point/fx_bits.h
+++ b/libc/src/__support/fixed_point/fx_bits.h
@@ -11,10 +11,10 @@
 
 #include "include/llvm-libc-macros/stdfix-macros.h"
 #include "src/__support/CPP/bit.h"
-#include "src/__support/CPP/type_traits.h"
 #include "src/__support/CPP/limits.h" // numeric_limits
-#include "src/__support/macros/attributes.h" // LIBC_INLINE
-#include "src/__support/macros/config.h" // LIBC_NAMESPACE_DECL
+#include "src/__support/CPP/type_traits.h"
+#include "src/__support/macros/attributes.h"   // LIBC_INLINE
+#include "src/__support/macros/config.h"       // LIBC_NAMESPACE_DECL
 #include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
 #include "src/__support/math_extras.h"
 
@@ -185,7 +185,8 @@ countls(T f) {
   using FXBits = FXBits<T>;
 
   constexpr int CONTAIN_LEN = cpp::numeric_limits<BitType>::digits;
-  constexpr int PADDING_LEN = CONTAIN_LEN - (FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN);
+  constexpr int PADDING_LEN =
+      CONTAIN_LEN - (FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN);
 
   if constexpr (FXRep::SIGN_LEN != 0) {
     if (x < 0)
diff --git a/libc/src/stdfix/countlshk.cpp b/libc/src/stdfix/countlshk.cpp
index 65230dd688..065b5a44ea 100644
--- a/libc/src/stdfix/countlshk.cpp
+++ b/libc/src/stdfix/countlshk.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlshk function  --------------------------------===//
+//===-- Implementation for countlshk function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/stdfix/countlshr.cpp b/libc/src/stdfix/countlshr.cpp
index d07bab8c4a..86c9f9ad00 100644
--- a/libc/src/stdfix/countlshr.cpp
+++ b/libc/src/stdfix/countlshr.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlshr function  --------------------------------===//
+//===-- Implementation for countlshr function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/stdfix/countlsk.cpp b/libc/src/stdfix/countlsk.cpp
index 87c009aba0..6512730559 100644
--- a/libc/src/stdfix/countlsk.cpp
+++ b/libc/src/stdfix/countlsk.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlsk function  --------------------------------===//
+//===-- Implementation for countlsk function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,8 +14,6 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, countlsk, (accum f)) {
-  return fixed_point::countls(f);
-}
+LLVM_LIBC_FUNCTION(int, countlsk, (accum f)) { return fixed_point::countls(f); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdfix/countlslk.cpp b/libc/src/stdfix/countlslk.cpp
index 16120b2f55..771c3ba344 100644
--- a/libc/src/stdfix/countlslk.cpp
+++ b/libc/src/stdfix/countlslk.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlslk function  --------------------------------===//
+//===-- Implementation for countlslk function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/stdfix/countlslr.cpp b/libc/src/stdfix/countlslr.cpp
index 9e0369db3b..00634c90de 100644
--- a/libc/src/stdfix/countlslr.cpp
+++ b/libc/src/stdfix/countlslr.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlslr function  --------------------------------===//
+//===-- Implementation for countlslr function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/stdfix/countlsr.cpp b/libc/src/stdfix/countlsr.cpp
index d18e673a30..ec5d7e832a 100644
--- a/libc/src/stdfix/countlsr.cpp
+++ b/libc/src/stdfix/countlsr.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlsr function  --------------------------------===//
+//===-- Implementation for countlsr function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,8 +14,6 @@
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, countlsr, (fract f)) {
-  return fixed_point::countls(f);
-}
+LLVM_LIBC_FUNCTION(int, countlsr, (fract f)) { return fixed_point::countls(f); }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdfix/countlsuhk.cpp b/libc/src/stdfix/countlsuhk.cpp
index 8a24508b83..56764aa911 100644
--- a/libc/src/stdfix/countlsuhk.cpp
+++ b/libc/src/stdfix/countlsuhk.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlsuhk function  --------------------------------===//
+//===-- Implementation for countlsuhk function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/stdfix/countlsuhr.cpp b/libc/src/stdfix/countlsuhr.cpp
index 6dec26c788..8ddb14a6aa 100644
--- a/libc/src/stdfix/countlsuhr.cpp
+++ b/libc/src/stdfix/countlsuhr.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlsuhr function  --------------------------------===//
+//===-- Implementation for countlsuhr function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/stdfix/countlsuk.cpp b/libc/src/stdfix/countlsuk.cpp
index 98ebf09694..6ae93f0dad 100644
--- a/libc/src/stdfix/countlsuk.cpp
+++ b/libc/src/stdfix/countlsuk.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlsuhk function  --------------------------------===//
+//===-- Implementation for countlsuhk function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/stdfix/countlsulk.cpp b/libc/src/stdfix/countlsulk.cpp
index 043c919a65..075d485238 100644
--- a/libc/src/stdfix/countlsulk.cpp
+++ b/libc/src/stdfix/countlsulk.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlsulk function  --------------------------------===//
+//===-- Implementation for countlsulk function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/stdfix/countlsulr.cpp b/libc/src/stdfix/countlsulr.cpp
index a77eaeabce..a1efb67673 100644
--- a/libc/src/stdfix/countlsulr.cpp
+++ b/libc/src/stdfix/countlsulr.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlsulr function  --------------------------------===//
+//===-- Implementation for countlsulr function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/stdfix/countlsur.cpp b/libc/src/stdfix/countlsur.cpp
index 6dcb54bdca..aedd545b26 100644
--- a/libc/src/stdfix/countlsur.cpp
+++ b/libc/src/stdfix/countlsur.cpp
@@ -1,4 +1,5 @@
-//===-- Implementation for countlsur function  --------------------------------===//
+//===-- Implementation for countlsur function
+//--------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/CountlsTest.h b/libc/test/src/stdfix/CountlsTest.h
index d4a4083591..a216b5f5c4 100644
--- a/libc/test/src/stdfix/CountlsTest.h
+++ b/libc/test/src/stdfix/CountlsTest.h
@@ -20,8 +20,7 @@ template <typename T> class CountlsTest : public LIBC_NAMESPACE::testing::Test {
   static constexpr T one_fourth = FXRep::ONE_FOURTH();
   static constexpr T eps = FXRep::EPS();
 
-  static constexpr auto value_len =
-      FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN;
+  static constexpr auto value_len = FXRep::INTEGRAL_LEN + FXRep::FRACTION_LEN;
 
 public:
   typedef int (*CountlsFunc)(T);
diff --git a/libc/test/src/stdfix/countlshk_test.cpp b/libc/test/src/stdfix/countlshk_test.cpp
index d5654981f9..f46316d42b 100644
--- a/libc/test/src/stdfix/countlshk_test.cpp
+++ b/libc/test/src/stdfix/countlshk_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlshk ----------------------------------------------===//
+//===-- Unittests for countlshk
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlshr_test.cpp b/libc/test/src/stdfix/countlshr_test.cpp
index 2021553be7..038e116824 100644
--- a/libc/test/src/stdfix/countlshr_test.cpp
+++ b/libc/test/src/stdfix/countlshr_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlshr ----------------------------------------------===//
+//===-- Unittests for countlshr
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlsk_test.cpp b/libc/test/src/stdfix/countlsk_test.cpp
index e7c71add68..691d6e3c39 100644
--- a/libc/test/src/stdfix/countlsk_test.cpp
+++ b/libc/test/src/stdfix/countlsk_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlsk ----------------------------------------------===//
+//===-- Unittests for countlsk
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlslk_test.cpp b/libc/test/src/stdfix/countlslk_test.cpp
index 4c7f297073..af3d8b4b5c 100644
--- a/libc/test/src/stdfix/countlslk_test.cpp
+++ b/libc/test/src/stdfix/countlslk_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlslk ----------------------------------------------===//
+//===-- Unittests for countlslk
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlslr_test.cpp b/libc/test/src/stdfix/countlslr_test.cpp
index 93b33597b9..cabb63eddc 100644
--- a/libc/test/src/stdfix/countlslr_test.cpp
+++ b/libc/test/src/stdfix/countlslr_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlslr ----------------------------------------------===//
+//===-- Unittests for countlslr
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlsr_test.cpp b/libc/test/src/stdfix/countlsr_test.cpp
index d465c2e1ea..bad60a6e33 100644
--- a/libc/test/src/stdfix/countlsr_test.cpp
+++ b/libc/test/src/stdfix/countlsr_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlsr ----------------------------------------------===//
+//===-- Unittests for countlsr
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlsuhk_test.cpp b/libc/test/src/stdfix/countlsuhk_test.cpp
index b72328b5b1..354359d914 100644
--- a/libc/test/src/stdfix/countlsuhk_test.cpp
+++ b/libc/test/src/stdfix/countlsuhk_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlsuhk ----------------------------------------------===//
+//===-- Unittests for countlsuhk
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlsuhr_test.cpp b/libc/test/src/stdfix/countlsuhr_test.cpp
index b82e105017..523323c156 100644
--- a/libc/test/src/stdfix/countlsuhr_test.cpp
+++ b/libc/test/src/stdfix/countlsuhr_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlsuhr ----------------------------------------------===//
+//===-- Unittests for countlsuhr
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlsuk_test.cpp b/libc/test/src/stdfix/countlsuk_test.cpp
index 5ca66822fe..129437a3a9 100644
--- a/libc/test/src/stdfix/countlsuk_test.cpp
+++ b/libc/test/src/stdfix/countlsuk_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlsuk ----------------------------------------------===//
+//===-- Unittests for countlsuk
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlsulk_test.cpp b/libc/test/src/stdfix/countlsulk_test.cpp
index 762d4924ba..73c8916c66 100644
--- a/libc/test/src/stdfix/countlsulk_test.cpp
+++ b/libc/test/src/stdfix/countlsulk_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlsulk ----------------------------------------------===//
+//===-- Unittests for countlsulk
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlsulr_test.cpp b/libc/test/src/stdfix/countlsulr_test.cpp
index 62c06b233e..65b5fff4f6 100644
--- a/libc/test/src/stdfix/countlsulr_test.cpp
+++ b/libc/test/src/stdfix/countlsulr_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlsulr ----------------------------------------------===//
+//===-- Unittests for countlsulr
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/test/src/stdfix/countlsur_test.cpp b/libc/test/src/stdfix/countlsur_test.cpp
index 49236db25d..694476a1bb 100644
--- a/libc/test/src/stdfix/countlsur_test.cpp
+++ b/libc/test/src/stdfix/countlsur_test.cpp
@@ -1,4 +1,5 @@
-//===-- Unittests for countlsur ----------------------------------------------===//
+//===-- Unittests for countlsur
+//----------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

``````````

</details>


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


More information about the libc-commits mailing list