14 #ifndef LLVM_ADT_DENSEMAP_H 15 #define LLVM_ADT_DENSEMAP_H 30 #include <type_traits> 39 template <
typename KeyT,
typename ValueT>
54 template <
typename DerivedT,
typename KeyT,
typename ValueT,
typename KeyInfoT,
75 if (shouldReverseIterate<KeyT>())
76 return makeIterator(getBucketsEnd() - 1, getBuckets(), *
this);
77 return makeIterator(getBuckets(), getBucketsEnd(), *
this);
80 return makeIterator(getBucketsEnd(), getBucketsEnd(), *
this,
true);
85 if (shouldReverseIterate<KeyT>())
86 return makeConstIterator(getBucketsEnd() - 1, getBuckets(), *
this);
87 return makeConstIterator(getBuckets(), getBucketsEnd(), *
this);
90 return makeConstIterator(getBucketsEnd(), getBucketsEnd(), *
this,
true);
94 return getNumEntries() == 0;
96 unsigned size()
const {
return getNumEntries(); }
103 if (NumBuckets > getNumBuckets())
109 if (getNumEntries() == 0 && getNumTombstones() == 0)
return;
113 if (getNumEntries() * 4 < getNumBuckets() && getNumBuckets() > 64) {
118 const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
121 for (BucketT *
P = getBuckets(), *
E = getBucketsEnd();
P !=
E; ++
P)
122 P->getFirst() = EmptyKey;
124 unsigned NumEntries = getNumEntries();
125 for (BucketT *
P = getBuckets(), *
E = getBucketsEnd();
P !=
E; ++
P) {
128 P->getSecond().~ValueT();
131 P->getFirst() = EmptyKey;
134 assert(NumEntries == 0 &&
"Node count imbalance!");
142 const BucketT *TheBucket;
143 return LookupBucketFor(Val, TheBucket) ? 1 : 0;
148 if (LookupBucketFor(Val, TheBucket))
149 return makeIterator(TheBucket, getBucketsEnd(), *
this,
true);
153 const BucketT *TheBucket;
154 if (LookupBucketFor(Val, TheBucket))
155 return makeConstIterator(TheBucket, getBucketsEnd(), *
this,
true);
164 template<
class LookupKeyT>
167 if (LookupBucketFor(Val, TheBucket))
168 return makeIterator(TheBucket, getBucketsEnd(), *
this,
true);
171 template<
class LookupKeyT>
173 const BucketT *TheBucket;
174 if (LookupBucketFor(Val, TheBucket))
175 return makeConstIterator(TheBucket, getBucketsEnd(), *
this,
true);
181 ValueT
lookup(const_arg_type_t<KeyT> Val)
const {
182 const BucketT *TheBucket;
183 if (LookupBucketFor(Val, TheBucket))
184 return TheBucket->getSecond();
191 std::pair<iterator, bool>
insert(
const std::pair<KeyT, ValueT> &KV) {
192 return try_emplace(KV.first, KV.second);
198 std::pair<iterator, bool>
insert(std::pair<KeyT, ValueT> &&KV) {
199 return try_emplace(std::move(KV.first), std::move(KV.second));
205 template <
typename... Ts>
208 if (LookupBucketFor(
Key, TheBucket))
209 return std::make_pair(
210 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
215 InsertIntoBucket(TheBucket, std::move(
Key), std::forward<Ts>(
Args)...);
216 return std::make_pair(
217 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
224 template <
typename... Ts>
227 if (LookupBucketFor(Key, TheBucket))
228 return std::make_pair(
229 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
233 TheBucket = InsertIntoBucket(TheBucket, Key, std::forward<Ts>(
Args)...);
234 return std::make_pair(
235 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
244 template <
typename LookupKeyT>
245 std::pair<iterator, bool>
insert_as(std::pair<KeyT, ValueT> &&KV,
246 const LookupKeyT &Val) {
248 if (LookupBucketFor(Val, TheBucket))
249 return std::make_pair(
250 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
254 TheBucket = InsertIntoBucketWithLookup(TheBucket, std::move(KV.first),
255 std::move(KV.second), Val);
256 return std::make_pair(
257 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
262 template<
typename InputIt>
270 if (!LookupBucketFor(Val, TheBucket))
273 TheBucket->getSecond().~ValueT();
274 TheBucket->getFirst() = getTombstoneKey();
275 decrementNumEntries();
276 incrementNumTombstones();
280 BucketT *TheBucket = &*
I;
281 TheBucket->getSecond().~ValueT();
282 TheBucket->getFirst() = getTombstoneKey();
283 decrementNumEntries();
284 incrementNumTombstones();
289 if (LookupBucketFor(Key, TheBucket))
292 return *InsertIntoBucket(TheBucket, Key);
296 return FindAndConstruct(Key).second;
301 if (LookupBucketFor(
Key, TheBucket))
304 return *InsertIntoBucket(TheBucket, std::move(
Key));
308 return FindAndConstruct(std::move(
Key)).second;
315 return Ptr >= getBuckets() && Ptr < getBucketsEnd();
327 if (getNumBuckets() == 0)
330 const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
331 for (BucketT *
P = getBuckets(), *
E = getBucketsEnd();
P !=
E; ++
P) {
334 P->getSecond().~ValueT();
335 P->getFirst().~KeyT();
343 assert((getNumBuckets() & (getNumBuckets()-1)) == 0 &&
344 "# initial buckets must be a power of two!");
345 const KeyT EmptyKey = getEmptyKey();
346 for (BucketT *
B = getBuckets(), *
E = getBucketsEnd();
B !=
E; ++
B)
347 ::
new (&
B->getFirst()) KeyT(EmptyKey);
365 const KeyT EmptyKey = getEmptyKey();
366 const KeyT TombstoneKey = getTombstoneKey();
367 for (BucketT *
B = OldBucketsBegin, *
E = OldBucketsEnd;
B !=
E; ++
B) {
372 bool FoundVal = LookupBucketFor(
B->getFirst(), DestBucket);
374 assert(!FoundVal &&
"Key already in new map?");
375 DestBucket->getFirst() = std::move(
B->getFirst());
376 ::new (&DestBucket->getSecond()) ValueT(std::move(
B->getSecond()));
377 incrementNumEntries();
380 B->getSecond().~ValueT();
382 B->getFirst().~KeyT();
386 template <
typename OtherBaseT>
390 assert(getNumBuckets() == other.getNumBuckets());
392 setNumEntries(other.getNumEntries());
393 setNumTombstones(other.getNumTombstones());
396 memcpy(getBuckets(), other.getBuckets(),
397 getNumBuckets() *
sizeof(BucketT));
399 for (
size_t i = 0; i < getNumBuckets(); ++i) {
401 KeyT(other.getBuckets()[i].getFirst());
404 ::
new (&getBuckets()[i].getSecond())
405 ValueT(other.getBuckets()[i].getSecond());
410 return KeyInfoT::getHashValue(Val);
413 template<
typename LookupKeyT>
415 return KeyInfoT::getHashValue(Val);
419 static_assert(std::is_base_of<DenseMapBase, DerivedT>::value,
420 "Must pass the derived type to this template!");
421 return KeyInfoT::getEmptyKey();
425 return KeyInfoT::getTombstoneKey();
431 bool NoAdvance=
false) {
432 if (shouldReverseIterate<KeyT>()) {
433 BucketT *
B = P == getBucketsEnd() ? getBuckets() : P + 1;
434 return iterator(B, E, Epoch, NoAdvance);
436 return iterator(P, E, Epoch, NoAdvance);
439 const_iterator makeConstIterator(
const BucketT *P,
const BucketT *E,
441 const bool NoAdvance=
false)
const {
442 if (shouldReverseIterate<KeyT>()) {
443 const BucketT *
B = P == getBucketsEnd() ? getBuckets() : P + 1;
449 unsigned getNumEntries()
const {
450 return static_cast<const DerivedT *
>(
this)->getNumEntries();
453 void setNumEntries(
unsigned Num) {
454 static_cast<DerivedT *
>(
this)->setNumEntries(Num);
457 void incrementNumEntries() {
458 setNumEntries(getNumEntries() + 1);
461 void decrementNumEntries() {
462 setNumEntries(getNumEntries() - 1);
465 unsigned getNumTombstones()
const {
466 return static_cast<const DerivedT *
>(
this)->getNumTombstones();
469 void setNumTombstones(
unsigned Num) {
470 static_cast<DerivedT *
>(
this)->setNumTombstones(Num);
473 void incrementNumTombstones() {
474 setNumTombstones(getNumTombstones() + 1);
477 void decrementNumTombstones() {
478 setNumTombstones(getNumTombstones() - 1);
481 const BucketT *getBuckets()
const {
482 return static_cast<const DerivedT *
>(
this)->getBuckets();
485 BucketT *getBuckets() {
486 return static_cast<DerivedT *
>(
this)->getBuckets();
489 unsigned getNumBuckets()
const {
490 return static_cast<const DerivedT *
>(
this)->getNumBuckets();
493 BucketT *getBucketsEnd() {
494 return getBuckets() + getNumBuckets();
497 const BucketT *getBucketsEnd()
const {
498 return getBuckets() + getNumBuckets();
501 void grow(
unsigned AtLeast) {
502 static_cast<DerivedT *
>(
this)->grow(AtLeast);
505 void shrink_and_clear() {
506 static_cast<DerivedT *
>(
this)->shrink_and_clear();
509 template <
typename KeyArg,
typename... ValueArgs>
510 BucketT *InsertIntoBucket(BucketT *TheBucket, KeyArg &&
Key,
511 ValueArgs &&... Values) {
512 TheBucket = InsertIntoBucketImpl(
Key,
Key, TheBucket);
514 TheBucket->getFirst() = std::forward<KeyArg>(
Key);
515 ::new (&TheBucket->getSecond()) ValueT(std::forward<ValueArgs>(Values)...);
519 template <
typename LookupKeyT>
520 BucketT *InsertIntoBucketWithLookup(BucketT *TheBucket, KeyT &&
Key,
522 TheBucket = InsertIntoBucketImpl(
Key, Lookup, TheBucket);
524 TheBucket->getFirst() = std::move(
Key);
525 ::new (&TheBucket->getSecond()) ValueT(std::move(
Value));
529 template <
typename LookupKeyT>
530 BucketT *InsertIntoBucketImpl(
const KeyT &
Key,
const LookupKeyT &Lookup,
531 BucketT *TheBucket) {
543 unsigned NewNumEntries = getNumEntries() + 1;
544 unsigned NumBuckets = getNumBuckets();
546 this->grow(NumBuckets * 2);
547 LookupBucketFor(Lookup, TheBucket);
548 NumBuckets = getNumBuckets();
549 }
else if (
LLVM_UNLIKELY(NumBuckets-(NewNumEntries+getNumTombstones()) <=
551 this->grow(NumBuckets);
552 LookupBucketFor(Lookup, TheBucket);
558 incrementNumEntries();
561 const KeyT EmptyKey = getEmptyKey();
563 decrementNumTombstones();
572 template<
typename LookupKeyT>
573 bool LookupBucketFor(
const LookupKeyT &Val,
574 const BucketT *&FoundBucket)
const {
575 const BucketT *BucketsPtr = getBuckets();
576 const unsigned NumBuckets = getNumBuckets();
578 if (NumBuckets == 0) {
579 FoundBucket =
nullptr;
584 const BucketT *FoundTombstone =
nullptr;
585 const KeyT EmptyKey = getEmptyKey();
586 const KeyT TombstoneKey = getTombstoneKey();
589 "Empty/Tombstone value shouldn't be inserted into map!");
591 unsigned BucketNo = getHashValue(Val) & (NumBuckets-1);
592 unsigned ProbeAmt = 1;
594 const BucketT *ThisBucket = BucketsPtr + BucketNo;
597 FoundBucket = ThisBucket;
606 FoundBucket = FoundTombstone ? FoundTombstone : ThisBucket;
614 FoundTombstone = ThisBucket;
618 BucketNo += ProbeAmt++;
619 BucketNo &= (NumBuckets-1);
623 template <
typename LookupKeyT>
624 bool LookupBucketFor(
const LookupKeyT &Val, BucketT *&FoundBucket) {
625 const BucketT *ConstFoundBucket;
627 ->LookupBucketFor(Val, ConstFoundBucket);
628 FoundBucket =
const_cast<BucketT *
>(ConstFoundBucket);
638 return getNumBuckets() *
sizeof(BucketT);
642 template <
typename KeyT,
typename ValueT,
646 KeyT, ValueT, KeyInfoT, BucketT> {
655 unsigned NumTombstones;
661 explicit DenseMap(
unsigned InitialReserve = 0) {
init(InitialReserve); }
673 template<
typename InputIt>
675 init(std::distance(I, E));
681 operator delete(Buckets);
685 this->incrementEpoch();
689 std::swap(NumTombstones, RHS.NumTombstones);
701 operator delete(Buckets);
709 operator delete(Buckets);
710 if (allocateBuckets(other.NumBuckets)) {
711 this->BaseT::copyFrom(other);
718 void init(
unsigned InitNumEntries) {
720 if (allocateBuckets(InitBuckets)) {
721 this->BaseT::initEmpty();
729 unsigned OldNumBuckets = NumBuckets;
730 BucketT *OldBuckets = Buckets;
732 allocateBuckets(std::max<unsigned>(64, static_cast<unsigned>(
NextPowerOf2(AtLeast-1))));
735 this->BaseT::initEmpty();
739 this->moveFromOldBuckets(OldBuckets, OldBuckets+OldNumBuckets);
742 operator delete(OldBuckets);
746 unsigned OldNumEntries = NumEntries;
750 unsigned NewNumBuckets = 0;
753 if (NewNumBuckets == NumBuckets) {
754 this->BaseT::initEmpty();
758 operator delete(Buckets);
763 unsigned getNumEntries()
const {
767 void setNumEntries(
unsigned Num) {
771 unsigned getNumTombstones()
const {
772 return NumTombstones;
775 void setNumTombstones(
unsigned Num) {
779 BucketT *getBuckets()
const {
783 unsigned getNumBuckets()
const {
787 bool allocateBuckets(
unsigned Num) {
789 if (NumBuckets == 0) {
794 Buckets =
static_cast<BucketT*
>(
operator new(
sizeof(BucketT) * NumBuckets));
799 template <
typename KeyT,
typename ValueT,
unsigned InlineBuckets = 4,
804 SmallDenseMap<KeyT, ValueT, InlineBuckets, KeyInfoT, BucketT>, KeyT,
805 ValueT, KeyInfoT, BucketT> {
813 "InlineBuckets must be a power of 2.");
816 unsigned NumEntries : 31;
817 unsigned NumTombstones;
830 init(NumInitBuckets);
843 template<
typename InputIt>
855 unsigned TmpNumEntries = RHS.NumEntries;
856 RHS.NumEntries = NumEntries;
857 NumEntries = TmpNumEntries;
858 std::swap(NumTombstones, RHS.NumTombstones);
860 const KeyT EmptyKey = this->getEmptyKey();
861 const KeyT TombstoneKey = this->getTombstoneKey();
862 if (
Small && RHS.Small) {
867 for (
unsigned i = 0, e = InlineBuckets; i != e; ++i) {
868 BucketT *LHSB = &getInlineBuckets()[i],
869 *RHSB = &RHS.getInlineBuckets()[i];
874 if (hasLHSValue && hasRHSValue) {
880 std::swap(LHSB->getFirst(), RHSB->getFirst());
882 ::new (&RHSB->getSecond()) ValueT(std::move(LHSB->getSecond()));
883 LHSB->getSecond().~ValueT();
884 }
else if (hasRHSValue) {
885 ::new (&LHSB->getSecond()) ValueT(std::move(RHSB->getSecond()));
886 RHSB->getSecond().~ValueT();
891 if (!
Small && !RHS.Small) {
892 std::swap(getLargeRep()->Buckets, RHS.getLargeRep()->Buckets);
893 std::swap(getLargeRep()->NumBuckets, RHS.getLargeRep()->NumBuckets);
901 LargeRep TmpRep = std::move(*LargeSide.getLargeRep());
902 LargeSide.getLargeRep()->~LargeRep();
903 LargeSide.Small =
true;
908 for (
unsigned i = 0, e = InlineBuckets; i != e; ++i) {
909 BucketT *NewB = &LargeSide.getInlineBuckets()[i],
910 *OldB = &SmallSide.getInlineBuckets()[i];
911 ::new (&NewB->getFirst()) KeyT(std::move(OldB->getFirst()));
912 OldB->getFirst().~KeyT();
915 ::new (&NewB->getSecond()) ValueT(std::move(OldB->getSecond()));
916 OldB->getSecond().~ValueT();
922 SmallSide.Small =
false;
923 new (SmallSide.getLargeRep()) LargeRep(std::move(TmpRep));
944 if (other.getNumBuckets() > InlineBuckets) {
946 new (getLargeRep()) LargeRep(allocateBuckets(other.getNumBuckets()));
948 this->BaseT::copyFrom(other);
951 void init(
unsigned InitBuckets) {
953 if (InitBuckets > InlineBuckets) {
955 new (getLargeRep()) LargeRep(allocateBuckets(InitBuckets));
957 this->BaseT::initEmpty();
961 if (AtLeast >= InlineBuckets)
962 AtLeast = std::max<unsigned>(64,
NextPowerOf2(AtLeast-1));
965 if (AtLeast < InlineBuckets)
970 BucketT *TmpBegin =
reinterpret_cast<BucketT *
>(TmpStorage.
buffer);
971 BucketT *TmpEnd = TmpBegin;
975 const KeyT EmptyKey = this->getEmptyKey();
976 const KeyT TombstoneKey = this->getTombstoneKey();
977 for (BucketT *
P = getBuckets(), *
E =
P + InlineBuckets;
P !=
E; ++
P) {
980 assert(
size_t(TmpEnd - TmpBegin) < InlineBuckets &&
981 "Too many inline buckets!");
982 ::new (&TmpEnd->getFirst()) KeyT(std::move(
P->getFirst()));
983 ::new (&TmpEnd->getSecond()) ValueT(std::move(
P->getSecond()));
985 P->getSecond().~ValueT();
987 P->getFirst().~KeyT();
993 new (getLargeRep()) LargeRep(allocateBuckets(AtLeast));
994 this->moveFromOldBuckets(TmpBegin, TmpEnd);
998 LargeRep OldRep = std::move(*getLargeRep());
999 getLargeRep()->~LargeRep();
1000 if (AtLeast <= InlineBuckets) {
1003 new (getLargeRep()) LargeRep(allocateBuckets(AtLeast));
1006 this->moveFromOldBuckets(OldRep.Buckets, OldRep.Buckets+OldRep.NumBuckets);
1009 operator delete(OldRep.Buckets);
1013 unsigned OldSize = this->
size();
1017 unsigned NewNumBuckets = 0;
1020 if (NewNumBuckets > InlineBuckets && NewNumBuckets < 64u)
1023 if ((
Small && NewNumBuckets <= InlineBuckets) ||
1024 (!
Small && NewNumBuckets == getLargeRep()->NumBuckets)) {
1025 this->BaseT::initEmpty();
1029 deallocateBuckets();
1030 init(NewNumBuckets);
1034 unsigned getNumEntries()
const {
1038 void setNumEntries(
unsigned Num) {
1040 assert(Num < (1U << 31) &&
"Cannot support more than 1<<31 entries");
1044 unsigned getNumTombstones()
const {
1045 return NumTombstones;
1048 void setNumTombstones(
unsigned Num) {
1049 NumTombstones = Num;
1052 const BucketT *getInlineBuckets()
const {
1057 return reinterpret_cast<const BucketT *
>(storage.
buffer);
1060 BucketT *getInlineBuckets() {
1061 return const_cast<BucketT *
>(
1062 const_cast<const SmallDenseMap *
>(
this)->getInlineBuckets());
1065 const LargeRep *getLargeRep()
const {
1068 return reinterpret_cast<const LargeRep *
>(storage.
buffer);
1071 LargeRep *getLargeRep() {
1072 return const_cast<LargeRep *
>(
1076 const BucketT *getBuckets()
const {
1077 return Small ? getInlineBuckets() : getLargeRep()->Buckets;
1080 BucketT *getBuckets() {
1081 return const_cast<BucketT *
>(
1085 unsigned getNumBuckets()
const {
1086 return Small ? InlineBuckets : getLargeRep()->NumBuckets;
1089 void deallocateBuckets() {
1093 operator delete(getLargeRep()->Buckets);
1094 getLargeRep()->~LargeRep();
1097 LargeRep allocateBuckets(
unsigned Num) {
1098 assert(Num > InlineBuckets &&
"Must allocate more buckets than are inline");
1100 static_cast<BucketT*
>(
operator new(
sizeof(BucketT) * Num)), Num
1106 template <
typename KeyT,
typename ValueT,
typename KeyInfoT,
typename Bucket,
1117 typename std::conditional<IsConst, const Bucket, Bucket>::type;
1130 bool NoAdvance =
false)
1132 assert(isHandleInSync() &&
"invalid construction!");
1134 if (NoAdvance)
return;
1135 if (shouldReverseIterate<KeyT>()) {
1136 RetreatPastEmptyBuckets();
1139 AdvancePastEmptyBuckets();
1145 template <
bool IsConstSrc,
1146 typename =
typename std::enable_if<!IsConstSrc && IsConst>::type>
1152 assert(isHandleInSync() &&
"invalid iterator access!");
1153 if (shouldReverseIterate<KeyT>())
1158 assert(isHandleInSync() &&
"invalid iterator access!");
1159 if (shouldReverseIterate<KeyT>())
1165 assert((!Ptr || isHandleInSync()) &&
"handle not in sync!");
1168 "comparing incomparable iterators!");
1169 return Ptr == RHS.Ptr;
1172 assert((!Ptr || isHandleInSync()) &&
"handle not in sync!");
1175 "comparing incomparable iterators!");
1176 return Ptr != RHS.Ptr;
1180 assert(isHandleInSync() &&
"invalid iterator access!");
1181 if (shouldReverseIterate<KeyT>()) {
1183 RetreatPastEmptyBuckets();
1187 AdvancePastEmptyBuckets();
1191 assert(isHandleInSync() &&
"invalid iterator access!");
1196 void AdvancePastEmptyBuckets() {
1198 const KeyT
Empty = KeyInfoT::getEmptyKey();
1199 const KeyT Tombstone = KeyInfoT::getTombstoneKey();
1206 void RetreatPastEmptyBuckets() {
1208 const KeyT
Empty = KeyInfoT::getEmptyKey();
1209 const KeyT Tombstone = KeyInfoT::getTombstoneKey();
1217 template <
typename KeyT,
typename ValueT,
typename KeyInfoT>
1224 #endif // LLVM_ADT_DENSEMAP_H
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
const_iterator end(StringRef path)
Get end iterator over path.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
ValueT & operator[](const KeyT &Key)
void copyFrom(const DenseMap &other)
void moveFromOldBuckets(BucketT *OldBucketsBegin, BucketT *OldBucketsEnd)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
const KeyT & getFirst() const
Compute iterated dominance frontiers using a linear time algorithm.
void init(unsigned InitNumEntries)
typename std::conditional< IsConst, const Bucket, Bucket >::type value_type
void init(unsigned InitBuckets)
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
static const KeyT getTombstoneKey()
const void * getPointerIntoBucketsArray() const
getPointerIntoBucketsArray() - Return an opaque pointer into the buckets array.
block Block Frequency true
const_iterator end() const
DenseMap(unsigned InitialReserve=0)
Create a DenseMap wth an optional InitialReserve that guarantee that this number of elements can be i...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
reference operator*() const
A base class for data structure classes wishing to make iterators ("handles") pointing into themselve...
size_t capacity_in_bytes(const BitVector &X)
static unsigned getMinBucketToReserveForEntries(unsigned NumEntries)
Returns the number of buckets to allocate to ensure that the DenseMap can accommodate NumEntries with...
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
void incrementEpoch()
Calling incrementEpoch invalidates all handles pointing into the calling instance.
SmallDenseMap(SmallDenseMap &&other)
A base class for iterator classes ("handles") that wish to poll for iterator invalidating modificatio...
static bool isEqual(const Function &Caller, const Function &Callee)
unsigned getMinBucketToReserveForEntries(unsigned NumEntries)
Returns the number of buckets to allocate to ensure that the DenseMap can accommodate NumEntries with...
static const KeyT getEmptyKey()
void copyFrom(const DenseMapBase< OtherBaseT, KeyT, ValueT, KeyInfoT, BucketT > &other)
std::pair< iterator, bool > try_emplace(const KeyT &Key, Ts &&... Args)
SmallDenseMap(unsigned NumInitBuckets=0)
void grow(unsigned AtLeast)
value_type & FindAndConstruct(const KeyT &Key)
iterator find(const_arg_type_t< KeyT > Val)
std::forward_iterator_tag iterator_category
initializer< Ty > init(const Ty &Val)
bool erase(const KeyT &Val)
const ValueT & getSecond() const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
DenseMap(DenseMap &&other)
SmallDenseMap(const SmallDenseMap &other)
static unsigned getHashValue(const LookupKeyT &Val)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void grow(unsigned AtLeast)
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
const void * getEpochAddress() const
Returns a pointer to the epoch word stored in the data structure this handle points into...
DenseMap(const DenseMap &other)
const_iterator begin() const
#define LLVM_LIKELY(EXPR)
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again...
#define LLVM_UNLIKELY(EXPR)
llvm::AlignedCharArray< alignof(llvm::detail::AlignerImpl< T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >), sizeof(::llvm::detail::SizerImpl< T1, T2, T3, T4, T5, T6, T7, T8, T9, T10 >)>::buffer char buffer[Size]
uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
void insert(InputIt I, InputIt E)
insert - Range insertion of pairs.
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&... Args)
SmallDenseMap & operator=(const SmallDenseMap &other)
bool operator==(const ConstIterator &RHS) const
size_t getMemorySize() const
Return the approximate size (in bytes) of the actual map.
isPodLike - This is a type trait that is used to determine whether a given type can be copied around ...
DenseMapIterator operator++(int)
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
void swap(SmallDenseMap &RHS)
DenseMap & operator=(const DenseMap &other)
bool isPointerIntoBucketsArray(const void *Ptr) const
isPointerIntoBucketsArray - Return true if the specified pointer points somewhere into the DenseMap's...
const_iterator find(const_arg_type_t< KeyT > Val) const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
SmallDenseMap & operator=(SmallDenseMap &&other)
void copyFrom(const SmallDenseMap &other)
DenseMapIterator & operator++()
ValueT & operator[](KeyT &&Key)
bool isHandleInSync() const
Returns true if the DebugEpochBase this Handle is linked to has not called incrementEpoch on itself s...
bool operator!=(const ConstIterator &RHS) const
constexpr char IsConst[]
Key for Kernel::Arg::Metadata::mIsConst.
std::pair< iterator, bool > insert(std::pair< KeyT, ValueT > &&KV)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
LLVM_NODISCARD bool empty() const
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
iterator find_as(const LookupKeyT &Val)
Alternate version of find() which allows a different, and possibly less expensive, key type.
value_type & FindAndConstruct(KeyT &&Key)
SmallDenseMap(const InputIt &I, const InputIt &E)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
DenseMap(const InputIt &I, const InputIt &E)
LLVM Value Representation.
DenseMapIterator(const DenseMapIterator< KeyT, ValueT, KeyInfoT, Bucket, IsConstSrc > &I)
DenseMap & operator=(DenseMap &&other)
pointer operator->() const
DenseMapIterator(pointer Pos, pointer E, const DebugEpochBase &Epoch, bool NoAdvance=false)
std::pair< iterator, bool > insert_as(std::pair< KeyT, ValueT > &&KV, const LookupKeyT &Val)
Alternate version of insert() which allows a different, and possibly less expensive, key type.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
static unsigned getHashValue(const KeyT &Val)
const_iterator find_as(const LookupKeyT &Val) const