14 #ifndef LLVM_ADT_POINTERINTPAIR_H
15 #define LLVM_ADT_POINTERINTPAIR_H
24 template <
typename T>
struct DenseMapInfo;
26 template <
typename Po
interT,
unsigned IntBits,
typename PtrTraits>
67 Value = Info::updateInt(
Value, static_cast<intptr_t>(IntVal));
71 Value = Info::updatePointer(0, PtrVal);
75 Value = Info::updateInt(Info::updatePointer(0, PtrVal),
76 static_cast<intptr_t>(IntVal));
85 "Can only return the address if IntBits is cleared and "
86 "PtrTraits doesn't change the pointer");
104 (void)PtrTraits::getFromVoidPointer(V);
109 return Value == RHS.Value;
112 return Value != RHS.Value;
117 return Value <= RHS.Value;
120 return Value >= RHS.Value;
124 template <
typename Po
interT,
unsigned IntBits,
typename PtrTraits>
125 struct PointerIntPairInfo {
126 static_assert(PtrTraits::NumLowBitsAvailable <
127 std::numeric_limits<uintptr_t>::digits,
128 "cannot use a pointer type that has all bits free");
129 static_assert(IntBits <= PtrTraits::NumLowBitsAvailable,
130 "PointerIntPair with integer size too large for pointer");
134 ~(uintptr_t)(((
intptr_t)1 << PtrTraits::NumLowBitsAvailable) - 1),
138 IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable - IntBits,
148 return PtrTraits::getFromVoidPointer(
158 reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(Ptr));
160 "Pointer is not sufficiently aligned");
167 assert((IntWord & ~
IntMask) == 0 &&
"Integer too large for field");
174 template <
typename T>
struct isPodLike;
175 template <
typename Po
interTy,
unsigned IntBits,
typename IntType>
181 template <
typename Po
interTy,
unsigned IntBits,
typename IntType>
185 uintptr_t Val =
static_cast<uintptr_t
>(-1);
186 Val <<= PointerLikeTypeTraits<Ty>::NumLowBitsAvailable;
187 return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
190 uintptr_t Val =
static_cast<uintptr_t
>(-2);
191 Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
192 return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
198 static bool isEqual(
const Ty &LHS,
const Ty &RHS) {
return LHS == RHS; }
202 template <
typename PointerTy,
unsigned IntBits,
typename IntType,
219 enum { NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits };
void setInt(IntType IntVal)
bool operator==(const PointerIntPair &RHS) const
static Ty getTombstoneKey()
static PointerIntPair getFromOpaqueValue(const void *V)
PointerBitMask - The bits that come from the pointer.
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
static unsigned getHashValue(Ty V)
PointerTy const * getAddrOfPointer() const
static PointerIntPair getFromOpaqueValue(void *V)
bool operator<(const PointerIntPair &RHS) const
void setPointer(PointerTy PtrVal)
PointerTy * getAddrOfPointer()
static unsigned getInt(StringRef R)
Get an unsigned integer, including error checks.
static intptr_t updateInt(intptr_t OrigValue, intptr_t Int)
IntShift - The number of low bits that we reserve for other uses, and keep zero.
void setFromOpaqueValue(void *Val)
PointerTy getPointer() const
bool operator!=(const PointerIntPair &RHS) const
PointerIntPair - This class implements a pair of a pointer and small integer.
void initWithPointer(PointerTy PtrVal)
IntMask - This is the unshifted mask for valid bits of the int type.
bool operator<=(const PointerIntPair &RHS) const
bool operator>(const PointerIntPair &RHS) const
PointerIntPair(PointerTy PtrVal, IntType IntVal)
static PointerT getPointer(intptr_t Value)
static intptr_t getInt(intptr_t Value)
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
void * getOpaqueValue() const
static intptr_t updatePointer(intptr_t OrigValue, PointerT Ptr)
void setPointerAndInt(PointerTy PtrVal, IntType IntVal)
static PointerIntPair< PointerTy, IntBits, IntType > getFromVoidPointer(void *P)
static bool isEqual(const Ty &LHS, const Ty &RHS)
PointerIntPair< PointerTy, IntBits, IntType > Ty
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
static void * getAsVoidPointer(const PointerIntPair< PointerTy, IntBits, IntType > &P)
PointerIntPair(PointerTy PtrVal)
bool operator>=(const PointerIntPair &RHS) const
static PointerIntPair< PointerTy, IntBits, IntType > getFromVoidPointer(const void *P)