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

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 09:09:15 PDT 2025


Author: Matt Arsenault
Date: 2025-08-05T01:09:12+09:00
New Revision: b738f630f73975bc591a82fdcb4858ae5da67477

URL: https://github.com/llvm/llvm-project/commit/b738f630f73975bc591a82fdcb4858ae5da67477
DIFF: https://github.com/llvm/llvm-project/commit/b738f630f73975bc591a82fdcb4858ae5da67477.diff

LOG: ADT: Expose typedef for Bitset's storage type (#151986)

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

Added: 
    

Modified: 
    llvm/include/llvm/ADT/Bitset.h

Removed: 
    


################################################################################
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;


        


More information about the llvm-commits mailing list