9#ifndef LLVM_ADT_POINTERSUMTYPE_H
10#define LLVM_ADT_POINTERSUMTYPE_H
26template <uintptr_t
N,
typename PointerArgT,
36template <
typename TagT,
typename... MemberTs>
struct PointerSumTypeHelper;
87 StorageT() :
Value(0) {}
104 "Pointer is insufficiently aligned to store the discriminant!");
105 Storage.Value =
reinterpret_cast<uintptr_t
>(V) |
N;
113 Result.set<
N>(Pointer);
124 template <TagT N>
bool is()
const {
return N ==
getTag(); }
133 assert(
is<N>() &&
"This instance has a different active member.");
158 Storage.MinTagPointer = InitialPtr;
162 "Switching to typed storage changed the pointer returned!");
164 return &Storage.MinTagPointer;
167 explicit operator bool()
const {
206template <
typename TagT,
typename... MemberTs>
213 template <TagT N,
typename Po
interT,
typename TraitsT>
232 std::min({MemberTs::TraitsT::NumLowBitsAvailable...});
236 static_cast<TagT
>(std::min({
static_cast<TagT
>(MemberTs::Tag)...}));
244 template <
typename MemberT,
typename... InnerMemberTs>
246 static_assert(MemberT::Tag < (1 <<
NumTagBits),
247 "This discriminant value requires too many bits!");
249 template <
typename MemberT>
struct Checker<MemberT> : std::true_type {
250 static_assert(MemberT::Tag < (1 <<
NumTagBits),
251 "This discriminant value requires too many bits!");
254 "Each member must pass the checker.");
260template <
typename TagT,
typename... MemberTs>
270 return SumType::template create<SomeTag>(SomePointerInfo::getEmptyKey());
274 return SumType::template create<SomeTag>(
275 SomePointerInfo::getTombstoneKey());
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines DenseMapInfo traits for DenseMap.
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
This file implements the C++20 <bit> header.
A sum type over pointer-like types.
bool operator<=(const PointerSumType &R) const
HelperT::template Lookup< N >::PointerT cast() const
bool operator==(const PointerSumType &R) const
bool operator>=(const PointerSumType &R) const
static PointerSumType create(typename HelperT::template Lookup< N >::PointerT Pointer)
A typed constructor for a specific tagged member of the sum type.
bool operator!=(const PointerSumType &R) const
HelperT::template Lookup< HelperT::MinTag >::PointerT * getAddrOfZeroTagPointer()
If the tag is zero and the pointer's value isn't changed when being stored, get the address of the st...
void clear()
Clear the value to null with the min tag type.
HelperT::template Lookup< HelperT::MinTag >::PointerT const * getAddrOfZeroTagPointer() const
If the tag is zero and the pointer's value isn't changed when being stored, get the address of the st...
uintptr_t getOpaqueValue() const
HelperT::template Lookup< N >::PointerT get() const
bool operator>(const PointerSumType &R) const
bool operator<(const PointerSumType &R) const
constexpr PointerSumType()=default
void * getVoidPtr() const
void set(typename HelperT::template Lookup< N >::PointerT Pointer)
A typed setter to a given tagged member of the sum type.
LLVM Value Representation.
const char unit< Period >::value[]
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
To bit_cast(const From &from) noexcept
DenseMapInfo< SomePointerT > SomePointerInfo
detail::PointerSumTypeHelper< TagT, MemberTs... > HelperT
typename HelperT::template Lookup< HelperT::MinTag >::PointerT SomePointerT
PointerSumType< TagT, MemberTs... > SumType
static bool isEqual(const SumType &LHS, const SumType &RHS)
static unsigned getHashValue(const SumType &Arg)
static SumType getTombstoneKey()
static SumType getEmptyKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
A compile time pair of an integer tag and the pointer-like type which it indexes within a sum type.
typename MemberT::PointerT PointerT
The Nth member's pointer type.
decltype( LookupOverload< N >(static_cast< PointerSumTypeHelper * >(nullptr))) MemberT
typename MemberT::TraitsT TraitsT
The Nth member's traits type.
A helper template for implementing PointerSumType.
static void LookupOverload(...)
static constexpr TagT MinTag
static constexpr int NumTagBits
static PointerSumTypeMember< N, PointerT, TraitsT > LookupOverload(PointerSumTypeMember< N, PointerT, TraitsT > *)