24void SmallPtrSetImplBase::shrink_and_clear() {
39std::pair<const void *const *, bool>
40SmallPtrSetImplBase::insert_imp_big(
const void *
Ptr) {
51 const void **Bucket =
const_cast<const void**
>(FindBucketFor(
Ptr));
53 return std::make_pair(Bucket,
false);
62 return std::make_pair(Bucket,
true);
65const void *
const *SmallPtrSetImplBase::doFind(
const void *
Ptr)
const {
68 unsigned ProbeAmt = 1;
70 const void *
const *Bucket =
CurArray + BucketNo;
78 BucketNo += ProbeAmt++;
83const void *
const *SmallPtrSetImplBase::FindBucketFor(
const void *
Ptr)
const {
86 unsigned ProbeAmt = 1;
88 const void *
const *Tombstone =
nullptr;
94 return Tombstone ? Tombstone : Array+Bucket;
103 Tombstone = Array+Bucket;
106 Bucket = (Bucket + ProbeAmt++) & (ArraySize-1);
112void SmallPtrSetImplBase::Grow(
unsigned NewSize) {
118 const void **NewBuckets = (
const void**)
safe_malloc(
sizeof(
void*) * NewSize);
123 memset(
CurArray, -1, NewSize*
sizeof(
void*));
126 for (
const void **BucketPtr = OldBuckets; BucketPtr != OldEnd; ++BucketPtr) {
128 const void *Elt = *BucketPtr;
130 *
const_cast<void**
>(FindBucketFor(Elt)) =
const_cast<void*
>(Elt);
159 MoveHelper(SmallSize, std::move(that));
163 assert(&
RHS !=
this &&
"Self-copy should be handled by the caller.");
167 "Cannot assign sets with different small sizes");
180 sizeof(
void*) *
RHS.CurArraySize);
203 MoveHelper(SmallSize, std::move(
RHS));
206void SmallPtrSetImplBase::MoveHelper(
unsigned SmallSize,
208 assert(&RHS !=
this &&
"Self-move should be handled by the caller.");
216 RHS.CurArray =
RHS.SmallArray;
225 RHS.CurArraySize = SmallSize;
228 RHS.NumTombstones = 0;
232 if (
this == &
RHS)
return;
249 std::copy(
RHS.CurArray,
RHS.CurArray +
RHS.NumNonEmpty, this->SmallArray);
268 RHS.CurArray =
RHS.SmallArray;
274 unsigned MinNonEmpty = std::min(this->NumNonEmpty,
RHS.NumNonEmpty);
277 if (this->NumNonEmpty > MinNonEmpty) {
280 RHS.SmallArray + MinNonEmpty);
282 std::copy(
RHS.SmallArray + MinNonEmpty,
RHS.SmallArray +
RHS.NumNonEmpty,
283 this->SmallArray + MinNonEmpty);
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
This file defines DenseMapInfo traits for DenseMap.
This file defines counterparts of C library allocation functions defined in the namespace 'std'.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallPtrSet class.
SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s,...
unsigned NumTombstones
Number of tombstones in CurArray.
void MoveFrom(unsigned SmallSize, SmallPtrSetImplBase &&RHS)
SmallPtrSetImplBase(const void **SmallStorage, const SmallPtrSetImplBase &that)
const void ** CurArray
CurArray - This is the current set of buckets.
unsigned NumNonEmpty
Number of elements in CurArray that contain a value or are a tombstone.
const void ** SmallArray
SmallArray - Points to a fixed size set of buckets, used in 'small mode'.
void CopyFrom(const SmallPtrSetImplBase &RHS)
unsigned CurArraySize
CurArraySize - The allocated size of CurArray, always a power of two.
const void ** EndPointer() const
static void * getEmptyMarker()
static void * getTombstoneMarker()
void swap(SmallPtrSetImplBase &RHS)
swap - Swaps the elements of two sets.
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_malloc(size_t Sz)
LLVM_ATTRIBUTE_RETURNS_NONNULL void * safe_realloc(void *Ptr, size_t Sz)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
An information struct used to provide DenseMap with the various necessary components for a given valu...