9#ifndef LLVM_ADT_BITMASKENUM_H
10#define LLVM_ADT_BITMASKENUM_H
42#define LLVM_MARK_AS_BITMASK_ENUM(LargestValue) \
43 LLVM_BITMASK_LARGEST_ENUMERATOR = LargestValue
66#define LLVM_DECLARE_ENUM_AS_BITMASK(Enum, LargestValue) \
67 template <> struct is_bitmask_enum<Enum> : std::true_type {}; \
68 template <> struct largest_bitmask_enum_bit<Enum> { \
69 static constexpr std::underlying_type_t<Enum> value = LargestValue; \
83#define LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE() \
84 using ::llvm::BitmaskEnumDetail::operator~; \
85 using ::llvm::BitmaskEnumDetail::operator|; \
86 using ::llvm::BitmaskEnumDetail::operator&; \
87 using ::llvm::BitmaskEnumDetail::operator^; \
88 using ::llvm::BitmaskEnumDetail::operator<<; \
89 using ::llvm::BitmaskEnumDetail::operator>>; \
90 using ::llvm::BitmaskEnumDetail::operator|=; \
91 using ::llvm::BitmaskEnumDetail::operator&=; \
92 using ::llvm::BitmaskEnumDetail::operator^=; \
93 using ::llvm::BitmaskEnumDetail::operator<<=; \
94 using ::llvm::BitmaskEnumDetail::operator>>=; \
95 using ::llvm::BitmaskEnumDetail::operator!; \
97 using ::llvm::BitmaskEnumDetail::any
103template <
typename E,
typename Enable =
void>
108 E,
std::void_t<decltype(E::LLVM_BITMASK_LARGEST_ENUMERATOR)>>
116 E,
std::void_t<decltype(E::LLVM_BITMASK_LARGEST_ENUMERATOR)>> {
119 static_cast<UnderlyingTy>(E::LLVM_BITMASK_LARGEST_ENUMERATOR);
126template <
typename E>
constexpr std::underlying_type_t<E>
Mask() {
134template <
typename E>
constexpr std::underlying_type_t<E>
Underlying(
E Val) {
136 assert(U >= 0 &&
"Negative enum values are not allowed.");
137 assert(U <=
Mask<E>() &&
"Enum value too large (or largest val too small?)");
141template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
143 return Val ==
static_cast<E>(0);
146template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
148 return Val !=
static_cast<E>(0);
151template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
156template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
161template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
166template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
171template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
176template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
184template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
190template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
196template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
202template <typename e, typename = std::enable_if_t<is_bitmask_enum<e>::value>>
208template <typename e, typename = std::enable_if_t<is_bitmask_enum<e>::value>>
218template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains library features backported from future STL versions.
This file implements the C++20 <bit> header.
e & operator>>=(e &lhs, e rhs)
constexpr E operator>>(E LHS, E RHS)
constexpr E operator^(E LHS, E RHS)
constexpr bool any(E Val)
constexpr E operator~(E Val)
constexpr std::underlying_type_t< E > Underlying(E Val)
Check that Val is in range for E, and return Val cast to E's underlying type.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
constexpr bool operator!(E Val)
E & operator^=(E &LHS, E RHS)
E & operator&=(E &LHS, E RHS)
constexpr E operator&(E LHS, E RHS)
e & operator<<=(e &lhs, e rhs)
constexpr E operator<<(E LHS, E RHS)
E & operator|=(E &LHS, E RHS)
constexpr E operator|(E LHS, E RHS)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE()
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
constexpr unsigned BitWidth
constexpr int bit_width_constexpr(T Value)
Returns the number of bits needed to represent Value if Value is nonzero.
constexpr uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
Implement std::hash so that hash_code can be used in STL containers.
Traits class to determine whether an enum has a LLVM_BITMASK_LARGEST_ENUMERATOR enumerator.
static constexpr UnderlyingTy value
std::underlying_type_t< E > UnderlyingTy
Trait class to determine bitmask enumeration largest bit.