14 #ifndef LLVM_ADT_POINTERINTPAIR_H
15 #define LLVM_ADT_POINTERINTPAIR_H
41 typename PtrTraits = PointerLikeTypeTraits<PointerTy> >
44 enum LLVM_ENUM_INT_TYPE(uintptr_t) {
47 ~(uintptr_t)(((
intptr_t)1 << PtrTraits::NumLowBitsAvailable)-1),
51 IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable-IntBits,
54 IntMask = (uintptr_t)(((
intptr_t)1 << IntBits)-1),
57 ShiftedIntMask = (uintptr_t)(IntMask << IntShift)
62 assert(IntBits <= PtrTraits::NumLowBitsAvailable &&
63 "PointerIntPair formed with integer size too large for pointer");
71 return PtrTraits::getFromVoidPointer(
72 reinterpret_cast<void*>(
Value & PointerBitMask));
76 return (IntType)((
Value >> IntShift) & IntMask);
81 =
reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(PtrVal));
82 assert((PtrWord & ((1 << PtrTraits::NumLowBitsAvailable)-1)) == 0 &&
83 "Pointer is not sufficiently aligned");
90 assert(IntWord < (1 << IntBits) &&
"Integer too large for field");
93 Value &= ~ShiftedIntMask;
94 Value |= IntWord << IntShift;
99 =
reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(PtrVal));
100 assert((PtrWord & ((1 << PtrTraits::NumLowBitsAvailable)-1)) == 0 &&
101 "Pointer is not sufficiently aligned");
107 =
reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(PtrVal));
108 assert((PtrWord & ((1 << PtrTraits::NumLowBitsAvailable)-1)) == 0 &&
109 "Pointer is not sufficiently aligned");
111 assert(IntWord < (1 << IntBits) &&
"Integer too large for field");
113 Value = PtrWord | (IntWord << IntShift);
122 "Can only return the address if IntBits is cleared and "
123 "PtrTraits doesn't change the pointer");
137 (void)PtrTraits::getFromVoidPointer(V);
149 template <
typename T>
struct isPodLike;
150 template<
typename Po
interTy,
unsigned IntBits,
typename IntType>
156 template<
typename Po
interTy,
unsigned IntBits,
typename IntType>
160 uintptr_t Val =
static_cast<uintptr_t
>(-1);
161 Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
162 return Ty(reinterpret_cast<PointerTy>(Val), IntType((1 << IntBits)-1));
165 uintptr_t Val =
static_cast<uintptr_t
>(-2);
166 Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
167 return Ty(reinterpret_cast<PointerTy>(Val), IntType(0));
173 static bool isEqual(
const Ty &LHS,
const Ty &RHS) {
return LHS == RHS; }
177 template<
typename PointerTy,
unsigned IntBits,
typename IntType,
195 NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits
bool operator<=(const PointerIntPair &RHS) const
PointerIntPair(PointerTy PtrVal, IntType IntVal)
void setFromOpaqueValue(void *Val)
static Ty getTombstoneKey()
bool operator==(const PointerIntPair &RHS) const
static unsigned getHashValue(Ty V)
void setPointer(PointerTy PtrVal)
void setPointerAndInt(PointerTy PtrVal, IntType IntVal)
PointerTy * getAddrOfPointer()
void initWithPointer(PointerTy PtrVal)
void setInt(IntType IntVal)
bool operator>(const PointerIntPair &RHS) const
bool operator>=(const PointerIntPair &RHS) const
bool operator!=(const PointerIntPair &RHS) const
static PointerIntPair getFromOpaqueValue(void *V)
PointerTy getPointer() const
void * getOpaqueValue() const
bool operator<(const PointerIntPair &RHS) const
PointerIntPair(PointerTy PtrVal)
static PointerIntPair< PointerTy, IntBits, IntType > getFromVoidPointer(void *P)
static PointerIntPair getFromOpaqueValue(const void *V)
static bool isEqual(const Ty &LHS, const Ty &RHS)
PointerIntPair< PointerTy, IntBits, IntType > Ty
LLVM Value Representation.
static void * getAsVoidPointer(const PointerIntPair< PointerTy, IntBits, IntType > &P)
PointerTy const * getAddrOfPointer() const
static PointerIntPair< PointerTy, IntBits, IntType > getFromVoidPointer(const void *P)