13 #ifndef LLVM_ADT_POINTERINTPAIR_H 14 #define LLVM_ADT_POINTERINTPAIR_H 25 template <
typename T>
struct DenseMapInfo;
26 template <
typename Po
interT,
unsigned IntBits,
typename PtrTraits>
64 Value = Info::updatePointer(Value, PtrVal);
68 Value = Info::updateInt(Value, static_cast<intptr_t>(
IntVal));
72 Value = Info::updatePointer(0, PtrVal);
76 Value = Info::updateInt(Info::updatePointer(0, PtrVal),
77 static_cast<intptr_t>(
IntVal));
86 "Can only return the address if IntBits is cleared and " 87 "PtrTraits doesn't change the pointer");
88 return reinterpret_cast<PointerTy *
>(&Value);
94 Value =
reinterpret_cast<intptr_t>(Val);
106 (void)PtrTraits::getFromVoidPointer(V);
111 return Value == RHS.Value;
115 return Value != RHS.Value;
122 return Value <= RHS.Value;
126 return Value >= RHS.Value;
132 template <
typename PointerTy,
unsigned IntBits,
typename IntType,
136 #ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE 138 "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable");
143 template <
typename Po
interT,
unsigned IntBits,
typename PtrTraits>
145 static_assert(PtrTraits::NumLowBitsAvailable <
146 std::numeric_limits<uintptr_t>::digits,
147 "cannot use a pointer type that has all bits free");
148 static_assert(IntBits <= PtrTraits::NumLowBitsAvailable,
149 "PointerIntPair with integer size too large for pointer");
153 ~(uintptr_t)(((
intptr_t)1 << PtrTraits::NumLowBitsAvailable) - 1),
157 IntShift = (uintptr_t)PtrTraits::NumLowBitsAvailable - IntBits,
160 IntMask = (uintptr_t)(((
intptr_t)1 << IntBits) - 1),
163 ShiftedIntMask = (uintptr_t)(IntMask << IntShift)
167 return PtrTraits::getFromVoidPointer(
168 reinterpret_cast<void *>(Value & PointerBitMask));
172 return (Value >> IntShift) & IntMask;
177 reinterpret_cast<intptr_t>(PtrTraits::getAsVoidPointer(Ptr));
178 assert((PtrWord & ~PointerBitMask) == 0 &&
179 "Pointer is not sufficiently aligned");
181 return PtrWord | (OrigValue & ~PointerBitMask);
186 assert((IntWord & ~IntMask) == 0 &&
"Integer too large for field");
189 return (OrigValue & ~ShiftedIntMask) | IntWord << IntShift;
194 template <
typename Po
interTy,
unsigned IntBits,
typename IntType>
199 uintptr_t Val =
static_cast<uintptr_t
>(-1);
200 Val <<= PointerLikeTypeTraits<Ty>::NumLowBitsAvailable;
201 return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
205 uintptr_t Val =
static_cast<uintptr_t
>(-2);
206 Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
207 return Ty::getFromOpaqueValue(reinterpret_cast<void *>(Val));
215 static bool isEqual(
const Ty &LHS,
const Ty &RHS) {
return LHS == RHS; }
219 template <
typename PointerTy,
unsigned IntBits,
typename IntType,
238 enum { NumLowBitsAvailable = PtrTraits::NumLowBitsAvailable - IntBits };
243 #endif // LLVM_ADT_POINTERINTPAIR_H bool operator!=(const PointerIntPair &RHS) const
void setInt(IntType IntVal) LLVM_LVALUE_FUNCTION
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)
void setPointerAndInt(PointerTy PtrVal, IntType IntVal) LLVM_LVALUE_FUNCTION
static PointerIntPair getFromOpaqueValue(void *V)
PointerTy * getAddrOfPointer()
static unsigned getInt(StringRef R)
Get an unsigned integer, including error checks.
#define LLVM_LVALUE_FUNCTION
Expands to '&' if ref-qualifiers for *this are supported.
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 ...
bool operator<(const PointerIntPair &RHS) const
Analysis containing CSE Info
void setPointer(PointerTy PtrVal) LLVM_LVALUE_FUNCTION
static void * getAsVoidPointer(const PointerIntPair< PointerTy, IntBits, IntType > &P)
PointerIntPair - This class implements a pair of a pointer and small integer.
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)
static intptr_t updatePointer(intptr_t OrigValue, PointerT Ptr)
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.
void initWithPointer(PointerTy PtrVal) LLVM_LVALUE_FUNCTION
void setFromOpaqueValue(void *Val) LLVM_LVALUE_FUNCTION
PointerIntPair(PointerTy PtrVal)
bool operator==(const PointerIntPair &RHS) const