[libc] [llvm] [libc] Fix forward missing `BigInt` specialization of `mask_leading_ones` / `mask_trailing_ones` (PR #84325)

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 08:31:22 PST 2024


================
@@ -1056,4 +1056,59 @@ rotr(T value, int rotate) {
 
 } // namespace LIBC_NAMESPACE::cpp
 
+namespace LIBC_NAMESPACE {
+
+// Specialization of mask_trailing_ones ('math_extras.h') for BigInt.
+template <typename T, size_t count>
+LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_big_int_v<T>, T>
+mask_trailing_ones() {
+  static_assert(!T::SIGNED);
+  if (count == 0)
+    return T();
+  constexpr unsigned T_BITS = CHAR_BIT * sizeof(T);
+  static_assert(count <= T_BITS && "Invalid bit index");
+  using word_type = typename T::word_type;
+  T out;
+  const int chunk_index_containing_bit = static_cast<int>(count / T::WORD_SIZE);
----------------
nickdesaulniers wrote:

If so, don't forget to capitalize the identifiers so that this doesn't regress the readability lint.

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


More information about the llvm-commits mailing list