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>
63 Value = Info::updatePointer(Value, PtrVal);
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");
87 return reinterpret_cast<PointerTy *
>(&Value);
93 Value =
reinterpret_cast<intptr_t>(Val);
105 (void)PtrTraits::getFromVoidPointer(V);
110 return Value == RHS.Value;
114 return Value != RHS.Value;
121 return Value <= RHS.Value;
125 return Value >= RHS.Value;
129 template <
typename Po
interT,
unsigned IntBits,
typename PtrTraits>
131 static_assert(PtrTraits::NumLowBitsAvailable <
132 std::numeric_limits<uintptr_t>::digits,
133 "cannot use a pointer type that has all bits free");
134 static_assert(IntBits <= PtrTraits::NumLowBitsAvailable,
135 "PointerIntPair with integer size too large for pointer");
139 ~(uintptr_t)(((
intptr_t)1 << PtrTraits::NumLowBitsAvailable) - 1),
143 IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable - IntBits,
146 IntMask = (uintptr_t)(((
intptr_t)1 << IntBits) - 1),
149 ShiftedIntMask = (uintptr_t)(IntMask << IntShift)
153 return PtrTraits::getFromVoidPointer(
154 reinterpret_cast<void *>(Value & PointerBitMask));
158 return (Value >> IntShift) & IntMask;
163 reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(Ptr));
164 assert((PtrWord & ~PointerBitMask) == 0 &&
165 "Pointer is not sufficiently aligned");
167 return PtrWord | (OrigValue & ~PointerBitMask);
172 assert((IntWord & ~IntMask) == 0 &&
"Integer too large for field");
175 return (OrigValue & ~ShiftedIntMask) | IntWord << IntShift;
180 template <
typename Po
interTy,
unsigned IntBits,
typename IntType>
182 static const bool value =
true;
186 template <
typename Po
interTy,
unsigned IntBits,
typename IntType>
191 uintptr_t Val =
static_cast<uintptr_t
>(-1);
192 Val <<= PointerLikeTypeTraits<Ty>::NumLowBitsAvailable;
193 return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
197 uintptr_t Val =
static_cast<uintptr_t
>(-2);
198 Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
199 return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
207 static bool isEqual(
const Ty &LHS,
const Ty &RHS) {
return LHS == RHS; }
211 template <
typename PointerTy,
unsigned IntBits,
typename IntType,
230 enum { NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits };
235 #endif // LLVM_ADT_POINTERINTPAIR_H bool operator!=(const PointerIntPair &RHS) const
void setInt(IntType IntVal)
bool operator>(const PointerIntPair &RHS) const
This class represents lattice values for constants.
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
Analysis containing CSE Info
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