15 #ifndef LLVM_ADT_POINTERUNION_H 16 #define LLVM_ADT_POINTERUNION_H 40 template <
typename T1,
typename T2,
typename RET_EQ,
typename RET_NE>
45 template <
typename T,
typename RET_EQ,
typename RET_NE>
50 template <
typename T1,
typename T2,
typename RET_EQ,
typename RET_NE>
67 NumLowBitsAvailable = PT1BitsAv < PT2BitsAv ? PT1BitsAv : PT2BitsAv
96 static const int Num = 0;
99 static const int Num = 1;
101 template <
typename T>
struct UNION_DOESNT_CONTAIN_TYPE {};
106 : Val(const_cast<void *>(
120 explicit operator bool()
const {
return !isNull(); }
123 template <
typename T>
int is()
const {
124 using Ty = typename ::llvm::PointerUnionTypeSelector<
127 UNION_DOESNT_CONTAIN_TYPE<T>>>
::Return;
129 return static_cast<int>(Val.
getInt()) == TyNo;
135 template <
typename T>
T get()
const {
136 assert(is<T>() &&
"Invalid accessor called");
151 return const_cast<PointerUnion *
>(
this)->getAddrOfPtr1();
157 assert(is<PT1>() &&
"Val is not the first pointer");
160 "Can't get the address because PointerLikeTypeTraits changes the ptr");
161 return const_cast<PT1 *
>(
188 V.Val = ValTy::getFromOpaqueValue(VP);
193 template <
typename PT1,
typename PT2>
198 template <
typename PT1,
typename PT2>
203 template <
typename PT1,
typename PT2>
210 template <
typename PT1,
typename PT2>
237 struct IsInnerUnion {
240 IsInnerUnion(
ValTy val) : Val(val) {}
242 template <
typename T>
int is()
const {
243 return Val.template is<InnerUnion>() &&
244 Val.template get<InnerUnion>().template is<T>();
247 template <
typename T>
T get()
const {
248 return Val.template get<InnerUnion>().
template get<T>();
255 IsPT3(
ValTy val) : Val(val) {}
257 template <
typename T>
int is()
const {
return Val.template is<T>(); }
258 template <
typename T>
T get()
const {
return Val.template get<T>(); }
270 explicit operator bool()
const {
return !isNull(); }
273 template <
typename T>
int is()
const {
275 using Ty = typename ::llvm::PointerUnionTypeSelector<
276 PT1,
T, IsInnerUnion,
278 return Ty(Val).template is<T>();
284 template <
typename T>
T get()
const {
285 assert(is<T>() &&
"Invalid accessor called");
287 using Ty = typename ::llvm::PointerUnionTypeSelector<
288 PT1,
T, IsInnerUnion,
290 return Ty(Val).template get<T>();
325 V.Val = ValTy::getFromOpaqueValue(VP);
332 template <
typename PT1,
typename PT2,
typename PT3>
349 template <
typename PT1,
typename PT2,
typename PT3>
350 bool operator<(PointerUnion3<PT1, PT2, PT3> lhs,
357 template <
typename PT1,
typename PT2,
typename PT3,
typename PT4>
377 explicit operator bool()
const {
return !isNull(); }
380 template <
typename T>
int is()
const {
382 using Ty = typename ::llvm::PointerUnionTypeSelector<
386 return Val.template is<Ty>() && Val.template get<Ty>().template is<T>();
392 template <
typename T>
T get()
const {
393 assert(is<T>() &&
"Invalid accessor called");
395 using Ty = typename ::llvm::PointerUnionTypeSelector<
399 return Val.template get<Ty>().
template get<T>();
438 V.Val = ValTy::getFromOpaqueValue(VP);
445 template <
typename PT1,
typename PT2,
typename PT3,
typename PT4>
472 return Pair(FirstInfo::getTombstoneKey());
481 return LHS.template is<T>() == RHS.template is<T>() &&
483 RHS.template get<T>())
485 RHS.template get<U>()));
491 #endif // LLVM_ADT_POINTERUNION_H static void * getAsVoidPointer(const PointerUnion3< PT1, PT2, PT3 > &P)
const PointerUnion4 & operator=(const PT3 &RHS)
Provide PointerLikeTypeTraits for void* that is used by PointerUnion for the two template arguments...
const PointerUnion4 & operator=(const PT1 &RHS)
Assignment operators - Allow assigning into this union from either pointer type, setting the discrimi...
This class represents lattice values for constants.
PointerTy getPointer() const
int is() const
Test if the Union currently holds the type matching T.
const PointerUnion & operator=(const PT1 &RHS)
Assignment operators - Allow assigning into this union from either pointer type, setting the discrimi...
PT1 * getAddrOfPtr1()
If the union is set to the first pointer type get an address pointing to it.
static PointerUnion4 getFromOpaqueValue(void *VP)
static void * getAsVoidPointer(const PointerUnion< PT1, PT2 > &P)
const PointerUnion & operator=(const PT2 &RHS)
static unsigned getHashValue(const Pair &PairVal)
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwises returns null...
static PointerUnion getFromOpaqueValue(void *VP)
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
static void * getAsVoidPointer(void *P)
static Pair getEmptyKey()
typename PointerUnionTypeSelectorReturn< RET_EQ >::Return Return
PointerTy const * getAddrOfPointer() const
void * getOpaqueValue() const
void * getOpaqueValue() const
PT1 const * getAddrOfPtr1() const
If the union is set to the first pointer type get an address pointing to it.
static void * getAsVoidPointer(const PointerUnion4< PT1, PT2, PT3, PT4 > &P)
Get a type based on whether two types are the same or not.
const PointerUnion3 & operator=(std::nullptr_t)
Assignment from nullptr which just clears the union.
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
void * getOpaqueValue() const
static bool isEqual(const Function &Caller, const Function &Callee)
const PointerUnion3 & operator=(const PT3 &RHS)
typename PointerUnionTypeSelector< T1, T2, RET_EQ, RET_NE >::Return Return
const PointerUnion4 & operator=(const PT2 &RHS)
const PointerUnion & operator=(std::nullptr_t)
Assignment from nullptr which just clears the union.
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
void initWithPointer(PointerTy PtrVal)
void * getOpaqueValue() const
typename PointerUnionTypeSelectorReturn< RET_NE >::Return Return
const PointerUnion3 & operator=(const PT1 &RHS)
Assignment operators - Allow assigning into this union from either pointer type, setting the discrimi...
const PointerUnion4 & operator=(const PT4 &RHS)
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwises returns null...
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
static PointerUnion3 getFromOpaqueValue(void *VP)
const PointerUnion4 & operator=(std::nullptr_t)
Assignment from nullptr which just clears the union.
int is() const
Test if the Union currently holds the type matching T.
static PointerUnion< PT1, PT2 > getFromVoidPointer(void *P)
void setPointerAndInt(PointerTy PtrVal, IntType IntVal)
bool operator!=(uint64_t V1, const APInt &V2)
A pointer union of three pointer types.
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwises returns null...
static PointerUnion3< PT1, PT2, PT3 > getFromVoidPointer(void *P)
const PointerUnion3 & operator=(const PT2 &RHS)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isEqual(const Pair &LHS, const Pair &RHS)
int is() const
Test if the Union currently holds the type matching T.
bool operator==(uint64_t V1, const APInt &V2)
static void * getFromVoidPointer(void *P)
static PointerUnion4< PT1, PT2, PT3, PT4 > getFromVoidPointer(void *P)
A pointer union of four pointer types.
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
static Pair getTombstoneKey()