15 #ifndef LLVM_ADT_POINTERUNION_H
16 #define LLVM_ADT_POINTERUNION_H
33 template <
typename T1,
typename T2,
typename RET_EQ,
typename RET_NE>
38 template <
typename T,
typename RET_EQ,
typename RET_NE>
43 template <
typename T1,
typename T2,
typename RET_EQ,
typename RET_NE>
52 template <
typename PT1,
typename PT2>
79 template <
typename PT1,
typename PT2>
88 static const int Num = 0;
91 static const int Num = 1;
94 struct UNION_DOESNT_CONTAIN_TYPE { };
119 ::llvm::PointerUnionTypeSelector<PT1,
T, IsPT1,
121 UNION_DOESNT_CONTAIN_TYPE<T> > >
::Return Ty;
123 return static_cast<int>(Val.
getInt()) == TyNo;
130 assert(is<T>() &&
"Invalid accessor called");
138 if (is<T>())
return get<T>();
151 assert(is<PT1>() &&
"Val is not the first pointer");
153 "Can't get the address because PointerLikeTypeTraits changes the ptr");
179 template<
typename PT1,
typename PT2>
185 template<
typename PT1,
typename PT2>
193 template<
typename PT1,
typename PT2>
207 NumLowBitsAvailable =
209 ::NumLowBitsAvailable
216 template <
typename PT1,
typename PT2,
typename PT3>
224 struct IsInnerUnion {
226 IsInnerUnion(
ValTy val) : Val(val) { }
229 return Val.template is<InnerUnion>() &&
230 Val.template get<InnerUnion>().template is<T>();
234 return Val.template get<InnerUnion>().
template get<T>();
240 IsPT3(
ValTy val) : Val(val) { }
243 return Val.template is<T>();
247 return Val.template get<T>();
274 ::llvm::PointerUnionTypeSelector<PT1,
T, IsInnerUnion,
277 return Ty(Val).template is<T>();
284 assert(is<T>() &&
"Invalid accessor called");
287 ::llvm::PointerUnionTypeSelector<PT1,
T, IsInnerUnion,
290 return Ty(Val).template get<T>();
297 if (is<T>())
return get<T>();
326 template<
typename PT1,
typename PT2,
typename PT3>
340 NumLowBitsAvailable =
342 ::NumLowBitsAvailable
348 template <
typename PT1,
typename PT2,
typename PT3,
typename PT4>
385 return Val.template is<Ty>() &&
386 Val.template get<Ty>().template is<T>();
393 assert(is<T>() &&
"Invalid accessor called");
399 return Val.template get<Ty>().
template get<T>();
406 if (is<T>())
return get<T>();
439 template<
typename PT1,
typename PT2,
typename PT3,
typename PT4>
453 NumLowBitsAvailable =
455 ::NumLowBitsAvailable
const PointerUnion4 & operator=(const PT3 &RHS)
void * getOpaqueValue() const
PointerUnionTypeSelectorReturn< RET_NE >::Return Return
const PointerUnion4 & operator=(const PT1 &RHS)
const PointerUnion & operator=(const PT1 &RHS)
PT1 * getAddrOfPtr1()
If the union is set to the first pointer type get an address pointing to it.
static PointerUnion4 getFromOpaqueValue(void *VP)
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.
PointerUnion< InnerUnion1, InnerUnion2 > ValTy
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 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. For:
static PointerUnion4< PT1, PT2, PT3, PT4 > getFromVoidPointer(void *P)
const PointerUnion3 & operator=(const PT3 &RHS)
static void * getAsVoidPointer(const PointerUnion< PT1, PT2 > &P)
const PointerUnion4 & operator=(const PT2 &RHS)
const PointerUnion3 & operator=(const PT1 &RHS)
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.
static PointerUnion3< PT1, PT2, PT3 > getFromVoidPointer(void *P)
PointerUnionTypeSelectorReturn< RET_EQ >::Return Return
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
PointerUnion< PT1, PT2 > InnerUnion
Instr is a return instruction.
void * getOpaqueValue() const
bool operator!=(uint64_t V1, const APInt &V2)
void * getOpaqueValue() const
#define LLVM_EXPLICIT
Expands to explicit on compilers which support explicit conversion operators. Otherwise expands to no...
const PointerUnion3 & operator=(const PT2 &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