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>
96 static const int Num = 0;
99 static const int Num = 1;
101 template <
typename T>
struct UNION_DOESNT_CONTAIN_TYPE {};
107 : Val(const_cast<void *>(
123 template <
typename T>
int is()
const {
124 typedef typename ::llvm::PointerUnionTypeSelector<
126 PT2,
T, IsPT2, 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");
157 assert(is<PT1>() &&
"Val is not the first pointer");
160 "Can't get the address because PointerLikeTypeTraits changes the ptr");
192 template <
typename PT1,
typename PT2>
197 template <
typename PT1,
typename PT2>
202 template <
typename PT1,
typename PT2>
209 template <
typename PT1,
typename PT2>
237 struct IsInnerUnion {
239 IsInnerUnion(
ValTy val) : Val(val) {}
240 template <
typename T>
int is()
const {
241 return Val.template is<InnerUnion>() &&
242 Val.template get<InnerUnion>().template is<T>();
244 template <
typename T>
T get()
const {
245 return Val.template get<InnerUnion>().
template get<T>();
251 IsPT3(
ValTy val) : Val(val) {}
252 template <
typename T>
int is()
const {
return Val.template is<T>(); }
253 template <
typename T>
T get()
const {
return Val.template get<T>(); }
269 template <
typename T>
int is()
const {
271 typedef typename ::llvm::PointerUnionTypeSelector<
272 PT1,
T, IsInnerUnion,
275 return Ty(Val).template is<T>();
281 template <
typename T>
T get()
const {
282 assert(is<T>() &&
"Invalid accessor called");
284 typedef typename ::llvm::PointerUnionTypeSelector<
285 PT1,
T, IsInnerUnion,
288 return Ty(Val).template get<T>();
330 template <
typename PT1,
typename PT2,
typename PT3>
350 template <
typename PT1,
typename PT2,
typename PT3,
typename PT4>
374 template <
typename T>
int is()
const {
376 typedef typename ::llvm::PointerUnionTypeSelector<
379 return Val.template is<Ty>() && Val.template get<Ty>().template is<T>();
385 template <
typename T>
T get()
const {
386 assert(is<T>() &&
"Invalid accessor called");
388 typedef typename ::llvm::PointerUnionTypeSelector<
391 return Val.template get<Ty>().
template get<T>();
437 template <
typename PT1,
typename PT2,
typename PT3,
typename PT4>
464 return Pair(FirstInfo::getTombstoneKey());
471 return LHS.template is<T>() == RHS.template is<T>() &&
473 RHS.template get<T>())
475 RHS.template get<U>()));
481 #endif // LLVM_ADT_POINTERUNION_H
const PointerUnion4 & operator=(const PT3 &RHS)
void * getOpaqueValue() const
PointerUnionTypeSelectorReturn< RET_NE >::Return Return
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...
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.
PointerUnion< T, U > Pair
static PointerUnion4 getFromOpaqueValue(void *VP)
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwises returns null...
const PointerUnion & operator=(const PT2 &RHS)
PointerUnion< InnerUnion, PT3 > ValTy
int is() const
Test if the Union currently holds the type matching T.
static unsigned getHashValue(const Pair &PairVal)
PointerUnion< InnerUnion1, InnerUnion2 > ValTy
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
static PointerUnion< PT1, PT2 > getFromVoidPointer(void *P)
static PointerUnion getFromOpaqueValue(void *VP)
PointerTy const * getAddrOfPointer() const
static PointerIntPair getFromOpaqueValue(void *V)
void * getOpaqueValue() const
PointerUnionTypeSelector< T1, T2, RET_EQ, RET_NE >::Return Return
static void * getAsVoidPointer(void *P)
static Pair getEmptyKey()
static void * getAsVoidPointer(const PointerUnion3< PT1, PT2, PT3 > &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.
static PointerUnion4< PT1, PT2, PT3, PT4 > getFromVoidPointer(void *P)
PointerTy getPointer() const
static bool isEqual(const Function &Caller, const Function &Callee)
const PointerUnion3 & operator=(const PT3 &RHS)
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwises returns null...
static void * getAsVoidPointer(const PointerUnion< PT1, PT2 > &P)
const PointerUnion4 & operator=(const PT2 &RHS)
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
const PointerUnion & operator=(std::nullptr_t)
Assignment from nullptr which just clears the union.
PointerIntPair - This class implements a pair of a pointer and small integer.
void initWithPointer(PointerTy PtrVal)
const PointerUnion3 & operator=(const PT1 &RHS)
Assignment operators - Allow assigning into this union from either pointer type, setting the discrimi...
PT1 const * getAddrOfPtr1() const
If the union is set to the first pointer type get an address pointing to it.
const PointerUnion4 & operator=(const PT4 &RHS)
int is() const
Test if the Union currently holds the type matching T.
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
static PointerUnion3< PT1, PT2, PT3 > getFromVoidPointer(void *P)
PointerUnionTypeSelectorReturn< RET_EQ >::Return Return
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
static PointerUnion3 getFromOpaqueValue(void *VP)
static void * getAsVoidPointer(const PointerUnion4< PT1, PT2, PT3, PT4 > &P)
const PointerUnion4 & operator=(std::nullptr_t)
Assignment from nullptr which just clears the union.
void * getOpaqueValue() const
PointerUnion< PT1, PT2 > InnerUnion
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwises returns null...
DenseMapInfo< T > FirstInfo
DenseMapInfo< U > SecondInfo
void setPointerAndInt(PointerTy PtrVal, IntType IntVal)
bool operator!=(uint64_t V1, const APInt &V2)
void * getOpaqueValue() const
A pointer union of three pointer types.
const PointerUnion3 & operator=(const PT2 &RHS)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isEqual(const Pair &LHS, const Pair &RHS)
PointerUnion< PT1, PT2 > InnerUnion1
bool operator==(uint64_t V1, const APInt &V2)
int is() const
Test if the Union currently holds the type matching T.
PointerIntPair< void *, 1, bool, PointerUnionUIntTraits< PT1, PT2 > > ValTy
static void * getFromVoidPointer(void *P)
PointerUnion< PT3, PT4 > InnerUnion2
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()