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^=; \
92 using ::llvm::BitmaskEnumDetail::any
98template <
typename E,
typename Enable =
void>
103 E,
std::enable_if_t<sizeof(E::LLVM_BITMASK_LARGEST_ENUMERATOR) >= 0>>
111 E,
std::enable_if_t<sizeof(E::LLVM_BITMASK_LARGEST_ENUMERATOR) >= 0>> {
114 static_cast<UnderlyingTy>(E::LLVM_BITMASK_LARGEST_ENUMERATOR);
117namespace BitmaskEnumDetail {
121template <
typename E>
constexpr std::underlying_type_t<E>
Mask() {
129template <
typename E>
constexpr std::underlying_type_t<E>
Underlying(
E Val) {
131 assert(U >= 0 &&
"Negative enum values are not allowed.");
132 assert(U <= Mask<E>() &&
"Enum value too large (or largest val too small?)");
140template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
142 return Val !=
static_cast<E>(0);
145template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
147 return static_cast<E>(~Underlying(Val) & Mask<E>());
150template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
155template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
160template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
168template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
174template <typename E, typename = std::enable_if_t<is_bitmask_enum<E>::value>>
180template <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>>
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Given that RA is a live value
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains library features backported from future STL versions.
LLVM Value Representation.
constexpr E operator^(E LHS, E RHS)
constexpr bool any(E Val)
constexpr E operator~(E Val)
constexpr unsigned bitWidth(uint64_t Value)
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.
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 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.
std::underlying_type_t< E > UnderlyingTy
Trait class to determine bitmask enumeration largest bit.