15#ifndef LLVM_ADT_POINTERUNION_H
16#define LLVM_ADT_POINTERUNION_H
55 template <
typename Derived,
typename ValTy,
int I,
typename ...Types>
58 template <
typename Derived,
typename ValTy,
int I>
68 template <
typename Derived,
typename ValTy,
int I,
typename Type,
77 : Base(ValTy(const_cast<void *>(
81 using Base::operator=;
86 return static_cast<Derived &
>(*this);
108template <
typename... PTs>
111 PointerUnion<PTs...>,
113 void *, pointer_union_detail::bitsRequired(sizeof...(PTs)), int,
114 pointer_union_detail::PointerUnionUIntTraits<PTs...>>,
117 "PointerUnion alternative types cannot be repeated");
124 using Base =
typename PointerUnion::PointerUnionMembers;
131 template <
typename To,
typename From,
typename Enable>
friend struct CastInfo;
141 bool isNull()
const {
return !this->Val.getPointer(); }
149 template <
typename T>
150 [[deprecated(
"Use isa instead")]]
151 inline bool is()
const {
158 template <
typename T>
159 [[deprecated(
"Use cast instead")]]
183 this->Val.getPointer() &&
184 "Can't get the address because PointerLikeTypeTraits changes the ptr");
185 return const_cast<First *
>(
186 reinterpret_cast<const First *
>(this->Val.getAddrOfPointer()));
191 this->Val.initWithPointer(
nullptr);
196 using Base::operator=;
206template <
typename ...PTs>
211template <
typename ...PTs>
216template <
typename ...PTs>
222template <
typename To,
typename... PTs>
225 CastInfo<To, PointerUnion<PTs...>>> {
240template <
typename To,
typename... PTs>
243 CastInfo<To, PointerUnion<PTs...>>> {
248template <
typename ...PTs>
251 return P.getOpaqueValue();
273 return Union(FirstInfo::getTombstoneKey());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines DenseMapInfo traits for DenseMap.
This file defines the PointerIntPair class.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
bool isNull() const
Test if the pointer held in the union is null, regardless of which type it is.
T get() const
Returns the value of the specified pointer type.
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwise returns null.
First const * getAddrOfPtr1() const
If the union is set to the first pointer type get an address pointing to it.
bool is() const
Test if the Union currently holds the type matching T.
void * getOpaqueValue() const
PointerUnion(std::nullptr_t)
const PointerUnion & operator=(std::nullptr_t)
Assignment from nullptr which just clears the union.
First * getAddrOfPtr1()
If the union is set to the first pointer type get an address pointing to it.
static PointerUnion getFromOpaqueValue(void *VP)
The instances of the Type class are immutable: once they are created, they are never changed.
PointerUnionMembers()=default
PointerUnionMembers(Type V)
Derived & operator=(Type V)
PointerUnionMembers()=default
Provide PointerLikeTypeTraits for void* that is used by PointerUnion for the template arguments.
static void * getFromVoidPointer(void *P)
static constexpr int NumLowBitsAvailable
static void * getAsVoidPointer(void *P)
constexpr int bitsRequired(unsigned n)
Determine the number of bits required to store integers with values < n.
constexpr int lowBitsAvailable()
This is an optimization pass for GlobalISel generic memory operations.
bool operator<(int64_t V1, const APSInt &V2)
bool operator!=(uint64_t V1, const APInt &V2)
auto dyn_cast_if_present(const Y &Val)
dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case ...
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
std::tuple_element_t< I, std::tuple< Ts... > > TypeAtIndex
Find the type at a given index in a list of types.
static bool isPossible(From &f)
PointerUnion< PTs... > From
static To doCast(From &f)
This struct provides a method for customizing the way a cast is performed.
static bool isPossible(const From &f)
Provides a cast trait that strips const from types to make it easier to implement a const-version of ...
This cast trait just provides the default implementation of doCastIfPossible to make CastInfo special...
PointerUnion< PTs... > Union
static Union getEmptyKey()
static unsigned getHashValue(const Union &UnionVal)
static Union getTombstoneKey()
static bool isEqual(const Union &LHS, const Union &RHS)
DenseMapInfo< typename pointer_union_detail::GetFirstType< PTs... >::type > FirstInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Find the first index where a type appears in a list of types.
static PointerUnion< PTs... > getFromVoidPointer(void *P)
static constexpr int NumLowBitsAvailable
static void * getAsVoidPointer(const PointerUnion< PTs... > &P)
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
Determine if all types in Ts are distinct.
Find the first type in a list of types.