[llvm] ADT: Expose typedef for Bitset's storage type (PR #151986)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 08:23:32 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

Allows subclasses to directly initialize the underlying storage.
This will enable tablegen to emit a smaller initializer list to
initialize constant bitsets. For runtime libcalls we need to
initialize many hundreds of bits in many different sets so this
shrinks the generated output to a more manageable size.

Extracted from #<!-- -->151948

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


1 Files Affected:

- (modified) llvm/include/llvm/ADT/Bitset.h (+9-4) 


``````````diff
diff --git a/llvm/include/llvm/ADT/Bitset.h b/llvm/include/llvm/ADT/Bitset.h
index 55b96e47f2ed6..ecb6b149f0494 100644
--- a/llvm/include/llvm/ADT/Bitset.h
+++ b/llvm/include/llvm/ADT/Bitset.h
@@ -35,12 +35,17 @@ class Bitset {
   static_assert(BITWORD_SIZE == 64 || BITWORD_SIZE == 32,
                 "Unsupported word size");
 
-  static constexpr unsigned NumWords = (NumBits + BITWORD_SIZE-1) / BITWORD_SIZE;
-  std::array<BitWord, NumWords> Bits{};
+  static constexpr unsigned NumWords =
+      (NumBits + BITWORD_SIZE - 1) / BITWORD_SIZE;
 
 protected:
-  constexpr Bitset(const std::array<BitWord, NumWords> &B)
-      : Bits{B} {}
+  using StorageType = std::array<BitWord, NumWords>;
+
+private:
+  StorageType Bits{};
+
+protected:
+  constexpr Bitset(const StorageType &B) : Bits{B} {}
 
 public:
   constexpr Bitset() = default;

``````````

</details>


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


More information about the llvm-commits mailing list