15 #ifndef LLVM_ADT_SMALLPTRSET_H
16 #define LLVM_ADT_SMALLPTRSET_H
26 #include <initializer_list>
78 assert(SmallSize && (SmallSize & (SmallSize-1)) == 0 &&
79 "Initial size must be a power of two!");
100 return shrink_and_clear();
115 return reinterpret_cast<void*
>(-1);
128 const void **LastTombstone =
nullptr;
131 const void *
Value = *APtr;
133 return std::make_pair(APtr,
false);
135 LastTombstone = APtr;
139 if (LastTombstone !=
nullptr) {
140 *LastTombstone =
Ptr;
142 return std::make_pair(LastTombstone,
true);
152 return insert_imp_big(Ptr);
164 const void **Loc =
const_cast<const void **
>(
P);
165 assert(*Loc == Ptr &&
"broken find!");
185 auto *Bucket = FindBucketFor(Ptr);
194 std::pair<const void *const *, bool> insert_imp_big(
const void *
Ptr);
196 const void *
const *FindBucketFor(
const void *
Ptr)
const;
197 void shrink_and_clear();
200 void Grow(
unsigned NewSize);
227 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
254 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
255 void RetreatIfNotValid() {
267 template<
typename PtrTy>
284 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
287 return PtrTraits::getFromVoidPointer(const_cast<void *>(
Bucket[-1]));
291 return PtrTraits::getFromVoidPointer(const_cast<void*>(*
Bucket));
295 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
321 template<
unsigned N,
bool isPowerTwo>
335 struct RoundUpToPowerOfTwo {
344 template <
typename PtrType>
373 auto p =
insert_imp(PtrTraits::getAsVoidPointer(Ptr));
374 return std::make_pair(makeIterator(p.first), p.second);
380 return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
385 return makeIterator(
find_imp(ConstPtrTraits::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
409 iterator makeIterator(
const void *
const *
P)
const {
410 #if LLVM_ENABLE_ABI_BREAKING_CHECKS
422 template<
class PtrType,
unsigned SmallSize>
427 static_assert(SmallSize <= 32,
"SmallSize should be small");
434 const void *SmallStorage[SmallSizePowTwo];
440 :
BaseT(SmallStorage, SmallSizePowTwo, std::move(that)) {}
442 template<
typename It>
448 :
BaseT(SmallStorage, SmallSizePowTwo) {
449 this->
insert(IL.begin(), IL.end());
462 this->
MoveFrom(SmallSizePowTwo, std::move(RHS));
469 this->
insert(IL.begin(), IL.end());
484 template<
class T,
unsigned N>
491 #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)
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.
const BlockT * value_type
const void ** EndPointer() const
void CopyFrom(const SmallPtrSetImplBase &RHS)
Function Alias Analysis false
void insert(IterT I, IterT E)
SmallPtrSet< PtrType, SmallSize > & operator=(SmallPtrSet< PtrType, SmallSize > &&RHS)
std::ptrdiff_t difference_type
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)
const void *const * Bucket
std::forward_iterator_tag iterator_category
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'.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize)
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.
iterator find(ConstPtrType Ptr) const
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.
SmallPtrSetIterator< PtrType > iterator
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...