14 #ifndef LLVM_ADT_POINTERINTPAIR_H 15 #define LLVM_ADT_POINTERINTPAIR_H 24 template <
typename T>
struct DenseMapInfo;
25 template <
typename Po
interT,
unsigned IntBits,
typename PtrTraits>
61 Value = Info::updatePointer(Value, PtrVal);
65 Value = Info::updateInt(Value, static_cast<intptr_t>(IntVal));
69 Value = Info::updatePointer(0, PtrVal);
73 Value = Info::updateInt(Info::updatePointer(0, PtrVal),
74 static_cast<intptr_t>(IntVal));
83 "Can only return the address if IntBits is cleared and " 84 "PtrTraits doesn't change the pointer");
85 return reinterpret_cast<PointerTy *
>(&Value);
91 Value =
reinterpret_cast<intptr_t>(Val);
103 (void)PtrTraits::getFromVoidPointer(V);
108 return Value == RHS.Value;
112 return Value != RHS.Value;
119 return Value <= RHS.Value;
123 return Value >= RHS.Value;
127 template <
typename Po
interT,
unsigned IntBits,
typename PtrTraits>
129 static_assert(PtrTraits::NumLowBitsAvailable <
130 std::numeric_limits<uintptr_t>::digits,
131 "cannot use a pointer type that has all bits free");
132 static_assert(IntBits <= PtrTraits::NumLowBitsAvailable,
133 "PointerIntPair with integer size too large for pointer");
137 ~(uintptr_t)(((
intptr_t)1 << PtrTraits::NumLowBitsAvailable) - 1),
141 IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable - IntBits,
144 IntMask = (uintptr_t)(((
intptr_t)1 << IntBits) - 1),
147 ShiftedIntMask = (uintptr_t)(IntMask << IntShift)
151 return PtrTraits::getFromVoidPointer(
152 reinterpret_cast<void *>(Value & PointerBitMask));
156 return (Value >> IntShift) & IntMask;
161 reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(Ptr));
162 assert((PtrWord & ~PointerBitMask) == 0 &&
163 "Pointer is not sufficiently aligned");
165 return PtrWord | (OrigValue & ~PointerBitMask);
170 assert((IntWord & ~IntMask) == 0 &&
"Integer too large for field");
173 return (OrigValue & ~ShiftedIntMask) | IntWord << IntShift;
178 template <
typename Po
interTy,
unsigned IntBits,
typename IntType>
180 static const bool value =
true;
184 template <
typename Po
interTy,
unsigned IntBits,
typename IntType>
189 uintptr_t Val =
static_cast<uintptr_t
>(-1);
190 Val <<= PointerLikeTypeTraits<Ty>::NumLowBitsAvailable;
191 return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
195 uintptr_t Val =
static_cast<uintptr_t
>(-2);
196 Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
197 return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
205 static bool isEqual(
const Ty &LHS,
const Ty &RHS) {
return LHS == RHS; }
209 template <
typename PointerTy,
unsigned IntBits,
typename IntType,
228 enum { NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits };
233 #endif // LLVM_ADT_POINTERINTPAIR_H bool operator!=(const PointerIntPair &RHS) const
void setInt(IntType IntVal)
bool operator>(const PointerIntPair &RHS) const
Compute iterated dominance frontiers using a linear time algorithm.
PointerTy getPointer() const
bool operator<=(const PointerIntPair &RHS) const
static Ty getTombstoneKey()
static PointerIntPair getFromOpaqueValue(const void *V)
static unsigned getHashValue(Ty V)
static PointerIntPair getFromOpaqueValue(void *V)
void setPointer(PointerTy PtrVal)
PointerTy * getAddrOfPointer()
static unsigned getInt(StringRef R)
Get an unsigned integer, including error checks.
PointerTy const * getAddrOfPointer() const
void * getOpaqueValue() const
static intptr_t updateInt(intptr_t OrigValue, intptr_t Int)
static PointerIntPair< PointerTy, IntBits, IntType > getFromVoidPointer(const void *P)
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
void setFromOpaqueValue(void *Val)
bool operator<(const PointerIntPair &RHS) const
static void * getAsVoidPointer(const PointerIntPair< PointerTy, IntBits, IntType > &P)
PointerIntPair - This class implements a pair of a pointer and small integer.
void initWithPointer(PointerTy PtrVal)
static PointerIntPair< PointerTy, IntBits, IntType > getFromVoidPointer(void *P)
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 ...
static intptr_t updatePointer(intptr_t OrigValue, PointerT Ptr)
void setPointerAndInt(PointerTy PtrVal, IntType IntVal)
constexpr PointerIntPair()=default
static bool isEqual(const Ty &LHS, const Ty &RHS)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator>=(const PointerIntPair &RHS) const
LLVM Value Representation.
PointerIntPair(PointerTy PtrVal)
bool operator==(const PointerIntPair &RHS) const