16#ifndef LLVM_ADT_BITSET_H
17#define LLVM_ADT_BITSET_H
29template <
unsigned NumBits>
31 using BitWord = uintptr_t;
33 static constexpr unsigned BitwordBits =
sizeof(BitWord) * CHAR_BIT;
35 static_assert(BitwordBits == 64 || BitwordBits == 32,
36 "Unsupported word size");
38 static constexpr unsigned NumWords =
39 (NumBits + BitwordBits - 1) / BitwordBits;
41 using StorageType = std::array<BitWord, NumWords>;
46 if constexpr (
sizeof(BitWord) ==
sizeof(
uint64_t)) {
47 for (
size_t I = 0;
I !=
B.size(); ++
I)
50 unsigned BitsToAssign = NumBits;
51 for (
size_t I = 0;
I !=
B.size() && BitsToAssign; ++
I) {
55 for (
size_t offset = 0; offset != 2 && BitsToAssign; ++offset) {
56 Bits[2 *
I + offset] =
static_cast<uint32_t>(Elt >> (32 * offset));
57 BitsToAssign = BitsToAssign >= 32 ? BitsToAssign - 32 : 0;
76 Bits[
I / BitwordBits] |= BitWord(1) << (
I % BitwordBits);
81 Bits[
I / BitwordBits] &= ~(BitWord(1) << (
I % BitwordBits));
86 Bits[
I / BitwordBits] ^= BitWord(1) << (
I % BitwordBits);
91 BitWord Mask = BitWord(1) << (
I % BitwordBits);
92 return (Bits[
I / BitwordBits] & Mask) != 0;
95 constexpr bool test(
unsigned I)
const {
return (*
this)[
I]; }
97 constexpr size_t size()
const {
return NumBits; }
111 for (
unsigned I = 0,
E = Bits.size();
I !=
E; ++
I) {
112 Bits[
I] ^=
RHS.Bits[
I];
123 for (
unsigned I = 0,
E = Bits.size();
I !=
E; ++
I)
124 Bits[
I] &=
RHS.Bits[
I];
134 for (
unsigned I = 0,
E = Bits.size();
I !=
E; ++
I) {
135 Bits[
I] |=
RHS.Bits[
I];
147 for (
auto &
B : Result.Bits)
153 return std::equal(std::begin(Bits), std::end(Bits), std::begin(
RHS.Bits));
159 for (
unsigned I = 0,
E =
size();
I !=
E; ++
I) {
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
constexpr Bitset operator^(const Bitset &RHS) const
constexpr Bitset & set(unsigned I)
constexpr Bitset & flip(unsigned I)
bool operator<(const Bitset &Other) const
bool operator!=(const Bitset &RHS) const
constexpr Bitset(const std::array< uint64_t,(NumBits+63)/64 > &B)
constexpr Bitset()=default
constexpr Bitset & operator^=(const Bitset &RHS)
constexpr Bitset operator&(const Bitset &RHS) const
constexpr bool operator[](unsigned I) const
constexpr size_t size() const
constexpr Bitset & operator|=(const Bitset &RHS)
bool operator==(const Bitset &RHS) const
constexpr Bitset(std::initializer_list< unsigned > Init)
constexpr Bitset & operator&=(const Bitset &RHS)
constexpr bool test(unsigned I) const
constexpr Bitset operator|(const Bitset &RHS) const
constexpr Bitset & reset(unsigned I)
constexpr Bitset operator~() const
This is an optimization pass for GlobalISel generic memory operations.
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
FunctionAddr VTableAddr Count
int popcount(T Value) noexcept
Count the number of set bits in a value.