10 #ifndef LLVM_ADT_POINTEREMBEDDEDINT_H
11 #define LLVM_ADT_POINTEREMBEDDEDINT_H
19 #include <type_traits>
33 template <
typename IntT,
int Bits = sizeof(IntT) * CHAR_BIT>
39 static_assert(
Bits <
sizeof(uintptr_t) * CHAR_BIT,
40 "Cannot embed more bits than we have in a pointer!");
45 Shift =
sizeof(uintptr_t) * CHAR_BIT -
Bits,
48 Mask = static_cast<uintptr_t>(-1) <<
Bits
52 explicit RawValueTag() =
default;
65 assert((std::is_signed<IntT>::value ? isInt<Bits>(I) : isUInt<Bits>(I)) &&
66 "Integer has bits outside those preserved!");
67 Value =
static_cast<uintptr_t
>(
I) << Shift;
73 operator IntT()
const {
74 if (std::is_signed<IntT>::value)
75 return static_cast<IntT
>(
static_cast<intptr_t>(
Value) >> Shift);
76 return static_cast<IntT
>(
Value >> Shift);
82 template <
typename IntT,
int Bits>
88 return reinterpret_cast<void *
>(P.Value);
92 return T(reinterpret_cast<uintptr_t>(P),
typename T::RawValueTag());
96 return T(reinterpret_cast<uintptr_t>(P),
typename T::RawValueTag());
99 enum { NumLowBitsAvailable = T::Shift };
104 template <
typename IntT,
int Bits>
113 return IntInfo::getHashValue(Arg);
116 static bool isEqual(
const T &LHS,
const T &RHS) {
return LHS == RHS; }
121 #endif // LLVM_ADT_POINTEREMBEDDEDINT_H
static unsigned getHashValue(const T &Arg)
static T getFromVoidPointer(void *P)
static T getTombstoneKey()
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
Utility to embed an integer into a pointer-like type.
PointerEmbeddedInt(IntT I)
PointerEmbeddedInt & operator=(IntT I)
static bool isEqual(const T &LHS, const T &RHS)
PointerEmbeddedInt()=default
static T getFromVoidPointer(const void *P)
static void * getAsVoidPointer(const T &P)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.