15 #ifndef LLVM_ADT_POINTERUNION_H
16 #define LLVM_ADT_POINTERUNION_H
34 template <
typename T1,
typename T2,
typename RET_EQ,
typename RET_NE>
39 template <
typename T,
typename RET_EQ,
typename RET_NE>
44 template <
typename T1,
typename T2,
typename RET_EQ,
typename RET_NE>
53 template <
typename PT1,
typename PT2>
80 template <
typename PT1,
typename PT2>
89 static const int Num = 0;
92 static const int Num = 1;
95 struct UNION_DOESNT_CONTAIN_TYPE { };
120 ::llvm::PointerUnionTypeSelector<PT1,
T, IsPT1,
122 UNION_DOESNT_CONTAIN_TYPE<T> > >
::Return Ty;
124 return static_cast<int>(Val.
getInt()) == TyNo;
131 assert(is<T>() &&
"Invalid accessor called");
139 if (is<T>())
return get<T>();
152 assert(is<PT1>() &&
"Val is not the first pointer");
154 "Can't get the address because PointerLikeTypeTraits changes the ptr");
186 template<
typename PT1,
typename PT2>
192 template<
typename PT1,
typename PT2>
198 template<
typename PT1,
typename PT2>
199 static bool operator<(PointerUnion<PT1, PT2> lhs,
206 template<
typename PT1,
typename PT2>
220 NumLowBitsAvailable =
222 ::NumLowBitsAvailable
229 template <
typename PT1,
typename PT2,
typename PT3>
237 struct IsInnerUnion {
239 IsInnerUnion(
ValTy val) : Val(val) { }
242 return Val.template is<InnerUnion>() &&
243 Val.template get<InnerUnion>().template is<T>();
247 return Val.template get<InnerUnion>().
template get<T>();
253 IsPT3(
ValTy val) : Val(val) { }
256 return Val.template is<T>();
260 return Val.template get<T>();
287 ::llvm::PointerUnionTypeSelector<PT1,
T, IsInnerUnion,
290 return Ty(Val).template is<T>();
297 assert(is<T>() &&
"Invalid accessor called");
300 ::llvm::PointerUnionTypeSelector<PT1,
T, IsInnerUnion,
303 return Ty(Val).template get<T>();
310 if (is<T>())
return get<T>();
345 template<
typename PT1,
typename PT2,
typename PT3>
359 NumLowBitsAvailable =
361 ::NumLowBitsAvailable
367 template <
typename PT1,
typename PT2,
typename PT3,
typename PT4>
404 return Val.template is<Ty>() &&
405 Val.template get<Ty>().template is<T>();
412 assert(is<T>() &&
"Invalid accessor called");
418 return Val.template get<Ty>().
template get<T>();
425 if (is<T>())
return get<T>();
464 template<
typename PT1,
typename PT2,
typename PT3,
typename PT4>
478 NumLowBitsAvailable =
480 ::NumLowBitsAvailable
485 template<
typename T,
typename U>
492 return Pair(FirstInfo::getEmptyKey());
495 return Pair(FirstInfo::getTombstoneKey());
502 return LHS.template is<T>() == RHS.template is<T>() &&
503 (LHS.template is<T>() ?
504 FirstInfo::isEqual(LHS.template get<T>(),
505 RHS.template get<T>()) :
506 SecondInfo::isEqual(LHS.template get<U>(),
507 RHS.template get<U>()));
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
dyn_cast<T>() - If the current value is of the specified pointer type, return it, otherwise return nu...
const PointerUnion & operator=(const PT2 &RHS)
PointerUnion< InnerUnion, PT3 > ValTy
int is() const
is<T>() return true if the Union currently holds the type matching T.
static unsigned getHashValue(const Pair &PairVal)
PointerUnion< InnerUnion1, InnerUnion2 > ValTy
PointerLikeTypeTraits - This is a traits object that is used to handle pointer types and things that ...
static PointerUnion< PT1, PT2 > getFromVoidPointer(void *P)
static PointerUnion getFromOpaqueValue(void *VP)
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)
void setPointerAndInt(PointerTy PtrVal, IntType IntVal)
void initWithPointer(PointerTy PtrVal)
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)
const PointerUnion3 & operator=(const PT3 &RHS)
T dyn_cast() const
dyn_cast<T>() - If the current value is of the specified pointer type, return it, otherwise return nu...
static void * getAsVoidPointer(const PointerUnion< PT1, PT2 > &P)
const PointerUnion4 & operator=(const PT2 &RHS)
bool isNull() const
isNull - Return true 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.
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
is<T>() return true if the Union currently holds the type matching T.
bool isNull() const
isNull - Return true 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
isNull - Return true if the pointer held in the union is null, regardless of which type it is...
static PointerIntPair getFromOpaqueValue(void *V)
static PointerUnion3 getFromOpaqueValue(void *VP)
static void * getAsVoidPointer(const PointerUnion4< PT1, PT2, PT3, PT4 > &P)
PointerIntPair< void *, 1, bool, PointerUnionUIntTraits< PT1, PT2 > > ValTy
PointerTy getPointer() const
const PointerUnion4 & operator=(std::nullptr_t)
Assignment from nullptr which just clears the union.
PointerUnion< PT1, PT2 > InnerUnion
void * getOpaqueValue() const
T dyn_cast() const
dyn_cast<T>() - If the current value is of the specified pointer type, return it, otherwise return nu...
DenseMapInfo< T > FirstInfo
DenseMapInfo< U > SecondInfo
bool operator!=(uint64_t V1, const APInt &V2)
void * getOpaqueValue() const
PointerUnion3 - This is a pointer union of three pointer types.
const PointerUnion3 & operator=(const PT2 &RHS)
static bool isEqual(const Pair &LHS, const Pair &RHS)
PointerUnion< PT1, PT2 > InnerUnion1
bool operator==(uint64_t V1, const APInt &V2)
int is() const
is<T>() return true if the Union currently holds the type matching T.
static void * getFromVoidPointer(void *P)
PointerUnion< PT3, PT4 > InnerUnion2
PointerTy const * getAddrOfPointer() const
PointerUnion4 - This is a pointer union of four pointer types.
PointerUnion - This implements a discriminated union of two pointer types, and keeps the discriminato...
static Pair getTombstoneKey()