15 #ifndef LLVM_ADT_SMALLPTRSET_H
16 #define LLVM_ADT_SMALLPTRSET_H
18 #include "llvm/Config/abi-breaking.h"
25 #include <initializer_list>
29 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
84 assert(SmallSize && (SmallSize & (SmallSize-1)) == 0 &&
85 "Initial size must be a power of two!");
106 return shrink_and_clear();
121 return reinterpret_cast<void*
>(-1);
134 const void **LastTombstone =
nullptr;
137 const void *
Value = *APtr;
139 return std::make_pair(APtr,
false);
141 LastTombstone = APtr;
145 if (LastTombstone !=
nullptr) {
146 *LastTombstone =
Ptr;
148 return std::make_pair(LastTombstone,
true);
158 return insert_imp_big(Ptr);
170 const void ** Loc =
const_cast<const void **
>(
P);
171 assert(*Loc == Ptr &&
"broken find!");
191 auto *Bucket = FindBucketFor(Ptr);
200 std::pair<const void *const *, bool> insert_imp_big(
const void *
Ptr);
202 const void *
const *FindBucketFor(
const void *
Ptr)
const;
203 void shrink_and_clear();
206 void Grow(
unsigned NewSize);
233 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
260 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
274 template<
typename PtrTy>
292 return PtrTraits::getFromVoidPointer(const_cast<void*>(*
Bucket));
296 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
321 template<
unsigned N,
bool isPowerTwo>
335 struct RoundUpToPowerOfTwo {
344 template <
typename PtrType>
369 auto p =
insert_imp(PtrTraits::getAsVoidPointer(Ptr));
376 return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
381 return find(Ptr) != endPtr() ? 1 : 0;
384 auto *
P =
find_imp(PtrTraits::getAsVoidPointer(Ptr));
388 template <
typename IterT>
394 void insert(std::initializer_list<PtrType> IL) {
395 insert(IL.begin(), IL.end());
399 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
406 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
424 template<
class PtrType,
unsigned SmallSize>
429 static_assert(SmallSize <= 32,
"SmallSize should be small");
436 const void *SmallStorage[SmallSizePowTwo];
442 :
BaseT(SmallStorage, SmallSizePowTwo, std::move(that)) {}
444 template<
typename It>
450 :
BaseT(SmallStorage, SmallSizePowTwo) {
451 this->
insert(IL.begin(), IL.end());
464 this->
MoveFrom(SmallSizePowTwo, std::move(RHS));
471 this->
insert(IL.begin(), IL.end());
486 template<
class T,
unsigned N>
493 #endif // LLVM_ADT_SMALLPTRSET_H
static void * getTombstoneMarker()
SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize, SmallPtrSetImpl &&that)
SmallPtrSet(const SmallPtrSet &that)
SmallPtrSetImpl(const void **SmallStorage, const SmallPtrSetImpl &that)
SmallPtrSetIterator< PtrType > const_iterator
std::ptrdiff_t difference_type
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
const void *const * find_imp(const void *Ptr) const
Returns the raw pointer needed to construct an iterator.
void MoveFrom(unsigned SmallSize, SmallPtrSetImplBase &&RHS)
unsigned NumNonEmpty
Number of elements in CurArray that contain a value or are a tombstone.
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
SmallPtrSetIterator & operator++()
SmallPtrSetIteratorImpl - This is the common base class shared between all instances of SmallPtrSetIt...
void swap(SmallPtrSetImplBase &RHS)
swap - Swaps the elements of two sets.
SmallPtrSet(std::initializer_list< PtrType > IL)
SmallPtrSet(SmallPtrSet &&that)
unsigned CurArraySize
CurArraySize - The allocated size of CurArray, always a power of two.
SmallPtrSetIterator(const void *const *BP, const void *const *E)
const void ** CurArray
CurArray - This is the current set of buckets.
RoundUpToPowerOfTwo - This is a helper template that rounds N up to the next power of two (which mean...
bool erase_imp(const void *Ptr)
erase_imp - If the set contains the specified pointer, remove it and return true, otherwise return fa...
bool operator!=(const SmallPtrSetIteratorImpl &RHS) const
SmallPtrSet< PtrType, SmallSize > & operator=(const SmallPtrSet< PtrType, SmallSize > &RHS)
static void * getEmptyMarker()
void AdvanceIfNotValid()
AdvanceIfNotValid - If the current bucket isn't valid, advance to a bucket that is.
Function Alias Analysis false
const void ** EndPointer() const
void CopyFrom(const SmallPtrSetImplBase &RHS)
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
void insert(IterT I, IterT E)
SmallPtrSet< PtrType, SmallSize > & operator=(SmallPtrSet< PtrType, SmallSize > &&RHS)
const PtrTy operator*() const
SmallPtrSetIterator operator++(int)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize)
static const unsigned End
const void *const * Bucket
iterator find(PtrType Ptr) const
LLVM_NODISCARD bool empty() const
bool operator==(const SmallPtrSetIteratorImpl &RHS) const
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
const void ** SmallArray
SmallArray - Points to a fixed size set of buckets, used in 'small mode'.
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize)
SmallPtrSetIterator< PtrType > iterator
SmallPtrSetImplBase(const void **SmallStorage, const SmallPtrSetImplBase &that)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
RoundUpToPowerOfTwoH - If N is not a power of two, increase it.
SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s, which is almost everything.
unsigned NumTombstones
Number of tombstones in CurArray.
SmallPtrSet< PtrType, SmallSize > & operator=(std::initializer_list< PtrType > IL)
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
SmallPtrSetIteratorImpl(const void *const *BP, const void *const *E)
SmallPtrSetImplBase & operator=(const SmallPtrSetImplBase &)=delete
void insert(std::initializer_list< PtrType > IL)
void swap(SmallPtrSet< PtrType, SmallSize > &RHS)
swap - Swaps the elements of two sets.
std::pair< const void *const *, bool > insert_imp(const void *Ptr)
insert_imp - This returns true if the pointer was new to the set, false if it was already in the set...
std::forward_iterator_tag iterator_category