10 #ifndef LLVM_ADT_POINTEREMBEDDEDINT_H
11 #define LLVM_ADT_POINTEREMBEDDEDINT_H
30 template <
typename IntT,
int Bits = sizeof(IntT) * CHAR_BIT>
36 static_assert(
Bits <
sizeof(uintptr_t) * CHAR_BIT,
37 "Cannot embed more bits than we have in a pointer!");
42 Shift =
sizeof(uintptr_t) * CHAR_BIT -
Bits,
45 Mask = static_cast<uintptr_t>(-1) <<
Bits
49 explicit RawValueTag() =
default;
64 assert((std::is_signed<IntT>::value ? llvm::isInt<Bits>(I)
65 : llvm::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);
91 return T(reinterpret_cast<uintptr_t>(P),
typename T::RawValueTag());
94 return T(reinterpret_cast<uintptr_t>(P),
typename T::RawValueTag());
97 enum { NumLowBitsAvailable = T::Shift };
102 template <
typename IntT,
int Bits>
111 return IntInfo::getHashValue(Arg);
113 static bool isEqual(
const T &LHS,
const T &RHS) {
return LHS == RHS; }
static unsigned getHashValue(const T &Arg)
static T getFromVoidPointer(void *P)
PointerEmbeddedInt< IntT, Bits > T
static T getTombstoneKey()
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
DenseMapInfo< IntT > IntInfo
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)
static T getFromVoidPointer(const void *P)
static void * getAsVoidPointer(const T &P)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.