9#ifndef LLVM_ADT_BITMASKENUM_H
10#define LLVM_ADT_BITMASKENUM_H
43#define LLVM_MARK_AS_BITMASK_ENUM(LargestValue) \
44 LLVM_BITMASK_LARGEST_ENUMERATOR = LargestValue
67#define LLVM_DECLARE_ENUM_AS_BITMASK(Enum, LargestValue) \
68 template <> struct is_bitmask_enum<Enum> : std::true_type {}; \
69 template <> struct largest_bitmask_enum_bit<Enum> { \
70 static constexpr std::underlying_type_t<Enum> value = LargestValue; \
84#define LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE() \
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>>=; \
96 using ::llvm::BitmaskEnumDetail::operator!; \
98 using ::llvm::BitmaskEnumDetail::any
104template <
typename E,
typename Enable =
void>
109 E,
std::enable_if_t<sizeof(E::LLVM_BITMASK_LARGEST_ENUMERATOR) >= 0>>
117 E,
std::enable_if_t<sizeof(E::LLVM_BITMASK_LARGEST_ENUMERATOR) >= 0>> {
120 static_cast<UnderlyingTy>(E::LLVM_BITMASK_LARGEST_ENUMERATOR);
127template <
typename E>
constexpr std::underlying_type_t<E>
Mask() {
135template <
typename E>
constexpr std::underlying_type_t<E>
Underlying(
E Val) {
137 assert(U >= 0 &&
"Negative enum values are not allowed.");
138 assert(U <=
Mask<E>() &&
"Enum value too large (or largest val too small?)");
142template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
144 return Val ==
static_cast<E>(0);
147template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
149 return Val !=
static_cast<E>(0);
152template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
157template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
162template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
167template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
172template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
177template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
185template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
191template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
197template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
203template <typename e, typename = std::enable_if_t<is_bitmask_enum<e>::value>>
209template <typename e, typename = std::enable_if_t<is_bitmask_enum<e>::value>>
219template <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.