[llvm] [ADT] Refactor Bitset to Be More Constexpr-Usable and Add More Member Functions (PR #172062)
Jiachen Yuan via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 19 15:03:48 PST 2025
================
@@ -31,16 +31,24 @@ class Bitset {
using BitWord = uintptr_t;
static constexpr unsigned BitwordBits = sizeof(BitWord) * CHAR_BIT;
+ static constexpr unsigned RemainderNumBits = NumBits % BitwordBits;
+ static constexpr BitWord RemainderMask =
+ RemainderNumBits == 0 ? ~BitWord(0)
+ : ((BitWord(1) << RemainderNumBits) - 1);
static_assert(BitwordBits == 64 || BitwordBits == 32,
"Unsupported word size");
static constexpr unsigned NumWords =
(NumBits + BitwordBits - 1) / BitwordBits;
+ static constexpr unsigned getLastWordIndex() { return NumWords - 1; }
----------------
JiachenYuan wrote:
Sure! Added.
https://github.com/llvm/llvm-project/pull/172062
More information about the llvm-commits
mailing list