Skip to content

Commit b738f63

Browse files
authored
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
1 parent 0ee1811 commit b738f63

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/include/llvm/ADT/Bitset.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,17 @@ class Bitset {
3535
static_assert(BITWORD_SIZE == 64 || BITWORD_SIZE == 32,
3636
"Unsupported word size");
3737

38-
static constexpr unsigned NumWords = (NumBits + BITWORD_SIZE-1) / BITWORD_SIZE;
39-
std::array<BitWord, NumWords> Bits{};
38+
static constexpr unsigned NumWords =
39+
(NumBits + BITWORD_SIZE - 1) / BITWORD_SIZE;
4040

4141
protected:
42-
constexpr Bitset(const std::array<BitWord, NumWords> &B)
43-
: Bits{B} {}
42+
using StorageType = std::array<BitWord, NumWords>;
43+
44+
private:
45+
StorageType Bits{};
46+
47+
protected:
48+
constexpr Bitset(const StorageType &B) : Bits{B} {}
4449

4550
public:
4651
constexpr Bitset() = default;

0 commit comments

Comments
 (0)