13 #ifndef LLVM_ADT_DENSEMAP_H 14 #define LLVM_ADT_DENSEMAP_H 27 #include <initializer_list> 30 #include <type_traits> 39 template <
typename KeyT,
typename ValueT>
41 using std::pair<KeyT, ValueT>::pair;
51 template <
typename KeyT,
typename ValueT,
57 template <
typename DerivedT,
typename KeyT,
typename ValueT,
typename KeyInfoT,
78 if (shouldReverseIterate<KeyT>())
79 return makeIterator(getBucketsEnd() - 1, getBuckets(), *
this);
80 return makeIterator(getBuckets(), getBucketsEnd(), *
this);
83 return makeIterator(getBucketsEnd(), getBucketsEnd(), *
this,
true);
88 if (shouldReverseIterate<KeyT>())
89 return makeConstIterator(getBucketsEnd() - 1, getBuckets(), *
this);
90 return makeConstIterator(getBuckets(), getBucketsEnd(), *
this);
93 return makeConstIterator(getBucketsEnd(), getBucketsEnd(), *
this,
true);
97 return getNumEntries() == 0;
99 unsigned size()
const {
return getNumEntries(); }
106 if (NumBuckets > getNumBuckets())
112 if (getNumEntries() == 0 && getNumTombstones() == 0)
return;
116 if (getNumEntries() * 4 < getNumBuckets() && getNumBuckets() > 64) {
121 const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
125 for (BucketT *
P = getBuckets(), *
E = getBucketsEnd();
P !=
E; ++
P)
126 P->getFirst() = EmptyKey;
128 unsigned NumEntries = getNumEntries();
129 for (BucketT *
P = getBuckets(), *
E = getBucketsEnd();
P !=
E; ++
P) {
132 P->getSecond().~ValueT();
135 P->getFirst() = EmptyKey;
138 assert(NumEntries == 0 &&
"Node count imbalance!");
146 const BucketT *TheBucket;
147 return LookupBucketFor(Val, TheBucket) ? 1 : 0;
152 if (LookupBucketFor(Val, TheBucket))
153 return makeIterator(TheBucket, getBucketsEnd(), *
this,
true);
157 const BucketT *TheBucket;
158 if (LookupBucketFor(Val, TheBucket))
159 return makeConstIterator(TheBucket, getBucketsEnd(), *
this,
true);
168 template<
class LookupKeyT>
171 if (LookupBucketFor(Val, TheBucket))
172 return makeIterator(TheBucket, getBucketsEnd(), *
this,
true);
175 template<
class LookupKeyT>
177 const BucketT *TheBucket;
178 if (LookupBucketFor(Val, TheBucket))
179 return makeConstIterator(TheBucket, getBucketsEnd(), *
this,
true);
185 ValueT
lookup(const_arg_type_t<KeyT> Val)
const {
186 const BucketT *TheBucket;
187 if (LookupBucketFor(Val, TheBucket))
188 return TheBucket->getSecond();
195 std::pair<iterator, bool>
insert(
const std::pair<KeyT, ValueT> &KV) {
196 return try_emplace(KV.first, KV.second);
202 std::pair<iterator, bool>
insert(std::pair<KeyT, ValueT> &&KV) {
203 return try_emplace(std::move(KV.first), std::move(KV.second));
209 template <
typename... Ts>
212 if (LookupBucketFor(
Key, TheBucket))
213 return std::make_pair(
214 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
219 InsertIntoBucket(TheBucket, std::move(
Key), std::forward<Ts>(
Args)...);
220 return std::make_pair(
221 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
228 template <
typename... Ts>
231 if (LookupBucketFor(Key, TheBucket))
232 return std::make_pair(
233 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
237 TheBucket = InsertIntoBucket(TheBucket, Key, std::forward<Ts>(
Args)...);
238 return std::make_pair(
239 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
248 template <
typename LookupKeyT>
249 std::pair<iterator, bool>
insert_as(std::pair<KeyT, ValueT> &&KV,
250 const LookupKeyT &Val) {
252 if (LookupBucketFor(Val, TheBucket))
253 return std::make_pair(
254 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
258 TheBucket = InsertIntoBucketWithLookup(TheBucket, std::move(KV.first),
259 std::move(KV.second), Val);
260 return std::make_pair(
261 makeIterator(TheBucket, getBucketsEnd(), *
this,
true),
266 template<
typename InputIt>
274 if (!LookupBucketFor(Val, TheBucket))
277 TheBucket->getSecond().~ValueT();
278 TheBucket->getFirst() = getTombstoneKey();
279 decrementNumEntries();
280 incrementNumTombstones();
284 BucketT *TheBucket = &*
I;
285 TheBucket->getSecond().~ValueT();
286 TheBucket->getFirst() = getTombstoneKey();
287 decrementNumEntries();
288 incrementNumTombstones();
293 if (LookupBucketFor(Key, TheBucket))
296 return *InsertIntoBucket(TheBucket, Key);
300 return FindAndConstruct(Key).second;
305 if (LookupBucketFor(
Key, TheBucket))
308 return *InsertIntoBucket(TheBucket, std::move(
Key));
312 return FindAndConstruct(std::move(
Key)).second;
319 return Ptr >= getBuckets() && Ptr < getBucketsEnd();
331 if (getNumBuckets() == 0)
334 const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
335 for (BucketT *
P = getBuckets(), *
E = getBucketsEnd();
P !=
E; ++
P) {
338 P->getSecond().~ValueT();
339 P->getFirst().~KeyT();
347 assert((getNumBuckets() & (getNumBuckets()-1)) == 0 &&
348 "# initial buckets must be a power of two!");
349 const KeyT EmptyKey = getEmptyKey();
350 for (BucketT *
B = getBuckets(), *
E = getBucketsEnd();
B !=
E; ++
B)
351 ::
new (&
B->getFirst()) KeyT(EmptyKey);
369 const KeyT EmptyKey = getEmptyKey();
370 const KeyT TombstoneKey = getTombstoneKey();
371 for (BucketT *
B = OldBucketsBegin, *
E = OldBucketsEnd;
B !=
E; ++
B) {
376 bool FoundVal = LookupBucketFor(
B->getFirst(), DestBucket);
378 assert(!FoundVal &&
"Key already in new map?");
379 DestBucket->getFirst() = std::move(
B->getFirst());
380 ::new (&DestBucket->getSecond()) ValueT(std::move(
B->getSecond()));
381 incrementNumEntries();
384 B->getSecond().~ValueT();
386 B->getFirst().~KeyT();
390 template <
typename OtherBaseT>
394 assert(getNumBuckets() == other.getNumBuckets());
396 setNumEntries(other.getNumEntries());
397 setNumTombstones(other.getNumTombstones());
401 memcpy(reinterpret_cast<void *>(getBuckets()), other.getBuckets(),
402 getNumBuckets() *
sizeof(BucketT));
404 for (
size_t i = 0; i < getNumBuckets(); ++i) {
406 KeyT(other.getBuckets()[i].getFirst());
409 ::
new (&getBuckets()[i].getSecond())
410 ValueT(other.getBuckets()[i].getSecond());
415 return KeyInfoT::getHashValue(Val);
418 template<
typename LookupKeyT>
420 return KeyInfoT::getHashValue(Val);
424 static_assert(std::is_base_of<DenseMapBase, DerivedT>::value,
425 "Must pass the derived type to this template!");
426 return KeyInfoT::getEmptyKey();
430 return KeyInfoT::getTombstoneKey();
436 bool NoAdvance=
false) {
437 if (shouldReverseIterate<KeyT>()) {
438 BucketT *
B = P == getBucketsEnd() ? getBuckets() : P + 1;
439 return iterator(B, E, Epoch, NoAdvance);
441 return iterator(P, E, Epoch, NoAdvance);
444 const_iterator makeConstIterator(
const BucketT *P,
const BucketT *E,
446 const bool NoAdvance=
false)
const {
447 if (shouldReverseIterate<KeyT>()) {
448 const BucketT *
B = P == getBucketsEnd() ? getBuckets() : P + 1;
454 unsigned getNumEntries()
const {
455 return static_cast<const DerivedT *
>(
this)->getNumEntries();
458 void setNumEntries(
unsigned Num) {
459 static_cast<DerivedT *
>(
this)->setNumEntries(Num);
462 void incrementNumEntries() {
463 setNumEntries(getNumEntries() + 1);
466 void decrementNumEntries() {
467 setNumEntries(getNumEntries() - 1);
470 unsigned getNumTombstones()
const {
471 return static_cast<const DerivedT *
>(
this)->getNumTombstones();
474 void setNumTombstones(
unsigned Num) {
475 static_cast<DerivedT *
>(
this)->setNumTombstones(Num);
478 void incrementNumTombstones() {
479 setNumTombstones(getNumTombstones() + 1);
482 void decrementNumTombstones() {
483 setNumTombstones(getNumTombstones() - 1);
486 const BucketT *getBuckets()
const {
487 return static_cast<const DerivedT *
>(
this)->getBuckets();
490 BucketT *getBuckets() {
491 return static_cast<DerivedT *
>(
this)->getBuckets();
494 unsigned getNumBuckets()
const {
495 return static_cast<const DerivedT *
>(
this)->getNumBuckets();
498 BucketT *getBucketsEnd() {
499 return getBuckets() + getNumBuckets();
502 const BucketT *getBucketsEnd()
const {
503 return getBuckets() + getNumBuckets();
506 void grow(
unsigned AtLeast) {
507 static_cast<DerivedT *
>(
this)->grow(AtLeast);
510 void shrink_and_clear() {
511 static_cast<DerivedT *
>(
this)->shrink_and_clear();
514 template <
typename KeyArg,
typename... ValueArgs>
515 BucketT *InsertIntoBucket(BucketT *TheBucket, KeyArg &&
Key,
516 ValueArgs &&... Values) {
517 TheBucket = InsertIntoBucketImpl(
Key,
Key, TheBucket);
519 TheBucket->getFirst() = std::forward<KeyArg>(
Key);
520 ::new (&TheBucket->getSecond()) ValueT(std::forward<ValueArgs>(Values)...);
524 template <
typename LookupKeyT>
525 BucketT *InsertIntoBucketWithLookup(BucketT *TheBucket, KeyT &&
Key,
527 TheBucket = InsertIntoBucketImpl(
Key, Lookup, TheBucket);
529 TheBucket->getFirst() = std::move(
Key);
530 ::new (&TheBucket->getSecond()) ValueT(std::move(
Value));
534 template <
typename LookupKeyT>
535 BucketT *InsertIntoBucketImpl(
const KeyT &
Key,
const LookupKeyT &Lookup,
536 BucketT *TheBucket) {
548 unsigned NewNumEntries = getNumEntries() + 1;
549 unsigned NumBuckets = getNumBuckets();
551 this->grow(NumBuckets * 2);
552 LookupBucketFor(Lookup, TheBucket);
553 NumBuckets = getNumBuckets();
554 }
else if (
LLVM_UNLIKELY(NumBuckets-(NewNumEntries+getNumTombstones()) <=
556 this->grow(NumBuckets);
557 LookupBucketFor(Lookup, TheBucket);
563 incrementNumEntries();
566 const KeyT EmptyKey = getEmptyKey();
568 decrementNumTombstones();
577 template<
typename LookupKeyT>
578 bool LookupBucketFor(
const LookupKeyT &Val,
579 const BucketT *&FoundBucket)
const {
580 const BucketT *BucketsPtr = getBuckets();
581 const unsigned NumBuckets = getNumBuckets();
583 if (NumBuckets == 0) {
584 FoundBucket =
nullptr;
589 const BucketT *FoundTombstone =
nullptr;
590 const KeyT EmptyKey = getEmptyKey();
591 const KeyT TombstoneKey = getTombstoneKey();
594 "Empty/Tombstone value shouldn't be inserted into map!");
596 unsigned BucketNo = getHashValue(Val) & (NumBuckets-1);
597 unsigned ProbeAmt = 1;
599 const BucketT *ThisBucket = BucketsPtr + BucketNo;
602 FoundBucket = ThisBucket;
611 FoundBucket = FoundTombstone ? FoundTombstone : ThisBucket;
619 FoundTombstone = ThisBucket;
623 BucketNo += ProbeAmt++;
624 BucketNo &= (NumBuckets-1);
628 template <
typename LookupKeyT>
629 bool LookupBucketFor(
const LookupKeyT &Val, BucketT *&FoundBucket) {
630 const BucketT *ConstFoundBucket;
632 ->LookupBucketFor(Val, ConstFoundBucket);
633 FoundBucket =
const_cast<BucketT *
>(ConstFoundBucket);
643 return getNumBuckets() *
sizeof(BucketT);
653 template <
typename DerivedT,
typename KeyT,
typename ValueT,
typename KeyInfoT,
661 for (
auto &KV : LHS) {
662 auto I = RHS.
find(KV.first);
663 if (
I == RHS.
end() ||
I->second != KV.second)
673 template <
typename DerivedT,
typename KeyT,
typename ValueT,
typename KeyInfoT,
678 return !(LHS == RHS);
681 template <
typename KeyT,
typename ValueT,
685 KeyT, ValueT, KeyInfoT, BucketT> {
694 unsigned NumTombstones;
700 explicit DenseMap(
unsigned InitialReserve = 0) {
init(InitialReserve); }
712 template<
typename InputIt>
714 init(std::distance(I, E));
718 DenseMap(std::initializer_list<typename BaseT::value_type> Vals) {
720 this->insert(Vals.begin(), Vals.end());
725 deallocate_buffer(Buckets,
sizeof(BucketT) * NumBuckets,
alignof(BucketT));
729 this->incrementEpoch();
733 std::swap(NumTombstones, RHS.NumTombstones);
745 deallocate_buffer(Buckets,
sizeof(BucketT) * NumBuckets,
alignof(BucketT));
753 deallocate_buffer(Buckets,
sizeof(BucketT) * NumBuckets,
alignof(BucketT));
754 if (allocateBuckets(other.NumBuckets)) {
755 this->BaseT::copyFrom(other);
762 void init(
unsigned InitNumEntries) {
764 if (allocateBuckets(InitBuckets)) {
765 this->BaseT::initEmpty();
773 unsigned OldNumBuckets = NumBuckets;
774 BucketT *OldBuckets = Buckets;
776 allocateBuckets(std::max<unsigned>(64, static_cast<unsigned>(
NextPowerOf2(AtLeast-1))));
779 this->BaseT::initEmpty();
783 this->moveFromOldBuckets(OldBuckets, OldBuckets+OldNumBuckets);
786 deallocate_buffer(OldBuckets,
sizeof(BucketT) * OldNumBuckets,
791 unsigned OldNumBuckets = NumBuckets;
792 unsigned OldNumEntries = NumEntries;
796 unsigned NewNumBuckets = 0;
799 if (NewNumBuckets == NumBuckets) {
800 this->BaseT::initEmpty();
804 deallocate_buffer(Buckets,
sizeof(BucketT) * OldNumBuckets,
810 unsigned getNumEntries()
const {
814 void setNumEntries(
unsigned Num) {
818 unsigned getNumTombstones()
const {
819 return NumTombstones;
822 void setNumTombstones(
unsigned Num) {
826 BucketT *getBuckets()
const {
830 unsigned getNumBuckets()
const {
834 bool allocateBuckets(
unsigned Num) {
836 if (NumBuckets == 0) {
841 Buckets =
static_cast<BucketT *
>(
842 allocate_buffer(
sizeof(BucketT) * NumBuckets,
alignof(BucketT)));
847 template <
typename KeyT,
typename ValueT,
unsigned InlineBuckets = 4,
852 SmallDenseMap<KeyT, ValueT, InlineBuckets, KeyInfoT, BucketT>, KeyT,
853 ValueT, KeyInfoT, BucketT> {
861 "InlineBuckets must be a power of 2.");
864 unsigned NumEntries : 31;
865 unsigned NumTombstones;
878 init(NumInitBuckets);
891 template<
typename InputIt>
903 unsigned TmpNumEntries = RHS.NumEntries;
904 RHS.NumEntries = NumEntries;
905 NumEntries = TmpNumEntries;
906 std::swap(NumTombstones, RHS.NumTombstones);
908 const KeyT EmptyKey = this->getEmptyKey();
909 const KeyT TombstoneKey = this->getTombstoneKey();
910 if (
Small && RHS.Small) {
915 for (
unsigned i = 0,
e = InlineBuckets; i !=
e; ++i) {
916 BucketT *LHSB = &getInlineBuckets()[i],
917 *RHSB = &RHS.getInlineBuckets()[i];
922 if (hasLHSValue && hasRHSValue) {
928 std::swap(LHSB->getFirst(), RHSB->getFirst());
930 ::new (&RHSB->getSecond()) ValueT(std::move(LHSB->getSecond()));
931 LHSB->getSecond().~ValueT();
932 }
else if (hasRHSValue) {
933 ::new (&LHSB->getSecond()) ValueT(std::move(RHSB->getSecond()));
934 RHSB->getSecond().~ValueT();
939 if (!
Small && !RHS.Small) {
940 std::swap(getLargeRep()->Buckets, RHS.getLargeRep()->Buckets);
941 std::swap(getLargeRep()->NumBuckets, RHS.getLargeRep()->NumBuckets);
949 LargeRep TmpRep = std::move(*LargeSide.getLargeRep());
950 LargeSide.getLargeRep()->~LargeRep();
951 LargeSide.Small =
true;
956 for (
unsigned i = 0,
e = InlineBuckets; i !=
e; ++i) {
957 BucketT *NewB = &LargeSide.getInlineBuckets()[i],
958 *OldB = &SmallSide.getInlineBuckets()[i];
959 ::new (&NewB->getFirst()) KeyT(std::move(OldB->getFirst()));
960 OldB->getFirst().~KeyT();
963 ::new (&NewB->getSecond()) ValueT(std::move(OldB->getSecond()));
964 OldB->getSecond().~ValueT();
970 SmallSide.Small =
false;
971 new (SmallSide.getLargeRep()) LargeRep(std::move(TmpRep));
992 if (other.getNumBuckets() > InlineBuckets) {
994 new (getLargeRep()) LargeRep(allocateBuckets(other.getNumBuckets()));
996 this->BaseT::copyFrom(other);
999 void init(
unsigned InitBuckets) {
1001 if (InitBuckets > InlineBuckets) {
1003 new (getLargeRep()) LargeRep(allocateBuckets(InitBuckets));
1005 this->BaseT::initEmpty();
1009 if (AtLeast > InlineBuckets)
1010 AtLeast = std::max<unsigned>(64,
NextPowerOf2(AtLeast-1));
1015 BucketT *TmpBegin =
reinterpret_cast<BucketT *
>(TmpStorage.
buffer);
1016 BucketT *TmpEnd = TmpBegin;
1020 const KeyT EmptyKey = this->getEmptyKey();
1021 const KeyT TombstoneKey = this->getTombstoneKey();
1022 for (BucketT *
P = getBuckets(), *
E =
P + InlineBuckets;
P !=
E; ++
P) {
1025 assert(
size_t(TmpEnd - TmpBegin) < InlineBuckets &&
1026 "Too many inline buckets!");
1027 ::new (&TmpEnd->getFirst()) KeyT(std::move(
P->getFirst()));
1028 ::new (&TmpEnd->getSecond()) ValueT(std::move(
P->getSecond()));
1030 P->getSecond().~ValueT();
1032 P->getFirst().~KeyT();
1038 if (AtLeast > InlineBuckets) {
1040 new (getLargeRep()) LargeRep(allocateBuckets(AtLeast));
1042 this->moveFromOldBuckets(TmpBegin, TmpEnd);
1046 LargeRep OldRep = std::move(*getLargeRep());
1047 getLargeRep()->~LargeRep();
1048 if (AtLeast <= InlineBuckets) {
1051 new (getLargeRep()) LargeRep(allocateBuckets(AtLeast));
1054 this->moveFromOldBuckets(OldRep.Buckets, OldRep.Buckets+OldRep.NumBuckets);
1057 deallocate_buffer(OldRep.Buckets,
sizeof(BucketT) * OldRep.NumBuckets,
1062 unsigned OldSize = this->
size();
1066 unsigned NewNumBuckets = 0;
1069 if (NewNumBuckets > InlineBuckets && NewNumBuckets < 64u)
1072 if ((
Small && NewNumBuckets <= InlineBuckets) ||
1073 (!
Small && NewNumBuckets == getLargeRep()->NumBuckets)) {
1074 this->BaseT::initEmpty();
1078 deallocateBuckets();
1079 init(NewNumBuckets);
1083 unsigned getNumEntries()
const {
1087 void setNumEntries(
unsigned Num) {
1089 assert(Num < (1U << 31) &&
"Cannot support more than 1<<31 entries");
1093 unsigned getNumTombstones()
const {
1094 return NumTombstones;
1097 void setNumTombstones(
unsigned Num) {
1098 NumTombstones = Num;
1101 const BucketT *getInlineBuckets()
const {
1106 return reinterpret_cast<const BucketT *
>(storage.
buffer);
1109 BucketT *getInlineBuckets() {
1110 return const_cast<BucketT *
>(
1111 const_cast<const SmallDenseMap *
>(
this)->getInlineBuckets());
1114 const LargeRep *getLargeRep()
const {
1117 return reinterpret_cast<const LargeRep *
>(storage.
buffer);
1120 LargeRep *getLargeRep() {
1121 return const_cast<LargeRep *
>(
1125 const BucketT *getBuckets()
const {
1126 return Small ? getInlineBuckets() : getLargeRep()->Buckets;
1129 BucketT *getBuckets() {
1130 return const_cast<BucketT *
>(
1134 unsigned getNumBuckets()
const {
1135 return Small ? InlineBuckets : getLargeRep()->NumBuckets;
1138 void deallocateBuckets() {
1142 deallocate_buffer(getLargeRep()->Buckets,
1143 sizeof(BucketT) * getLargeRep()->NumBuckets,
1145 getLargeRep()->~LargeRep();
1148 LargeRep allocateBuckets(
unsigned Num) {
1149 assert(Num > InlineBuckets &&
"Must allocate more buckets than are inline");
1150 LargeRep Rep = {
static_cast<BucketT *
>(allocate_buffer(
1151 sizeof(BucketT) * Num,
alignof(BucketT))),
1157 template <
typename KeyT,
typename ValueT,
typename KeyInfoT,
typename Bucket,
1168 typename std::conditional<IsConst, const Bucket, Bucket>::type;
1181 bool NoAdvance =
false)
1183 assert(isHandleInSync() &&
"invalid construction!");
1185 if (NoAdvance)
return;
1186 if (shouldReverseIterate<KeyT>()) {
1187 RetreatPastEmptyBuckets();
1190 AdvancePastEmptyBuckets();
1196 template <
bool IsConstSrc,
1197 typename =
typename std::enable_if<!IsConstSrc && IsConst>::type>
1203 assert(isHandleInSync() &&
"invalid iterator access!");
1204 if (shouldReverseIterate<KeyT>())
1209 assert(isHandleInSync() &&
"invalid iterator access!");
1210 if (shouldReverseIterate<KeyT>())
1216 assert((!Ptr || isHandleInSync()) &&
"handle not in sync!");
1219 "comparing incomparable iterators!");
1220 return Ptr == RHS.Ptr;
1223 assert((!Ptr || isHandleInSync()) &&
"handle not in sync!");
1226 "comparing incomparable iterators!");
1227 return Ptr != RHS.Ptr;
1231 assert(isHandleInSync() &&
"invalid iterator access!");
1232 if (shouldReverseIterate<KeyT>()) {
1234 RetreatPastEmptyBuckets();
1238 AdvancePastEmptyBuckets();
1242 assert(isHandleInSync() &&
"invalid iterator access!");
1247 void AdvancePastEmptyBuckets() {
1249 const KeyT
Empty = KeyInfoT::getEmptyKey();
1250 const KeyT Tombstone = KeyInfoT::getTombstoneKey();
1257 void RetreatPastEmptyBuckets() {
1259 const KeyT
Empty = KeyInfoT::getEmptyKey();
1260 const KeyT Tombstone = KeyInfoT::getTombstoneKey();
1268 template <
typename KeyT,
typename ValueT,
typename KeyInfoT>
1275 #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)
const KeyT & getFirst() const
This class represents lattice values for constants.
void init(unsigned InitNumEntries)
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
char buffer[sizeof(llvm::detail::SizerImpl< T, Ts... >)]
typename std::conditional< IsConst, const Bucket, Bucket >::type value_type
void init(unsigned InitBuckets)
static const KeyT getTombstoneKey()
const void * getPointerIntoBucketsArray() const
getPointerIntoBucketsArray() - Return an opaque pointer into the buckets array.
block Block Frequency true
bool operator!=(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)
Inequality comparison for DenseSet.
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)
bool operator==(const DenseSetImpl< ValueT, MapTy, ValueInfoT > &LHS, const DenseSetImpl< ValueT, MapTy, ValueInfoT > &RHS)
Equality comparison for DenseSet.
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
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again...
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)
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
bool operator==(const ConstIterator &RHS) const
size_t getMemorySize() const
Return the approximate size (in bytes) of the actual map.
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.
Align max(MaybeAlign Lhs, Align Rhs)
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...
DenseMap(std::initializer_list< typename BaseT::value_type > Vals)
This class represents an analyzed expression in the program.
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...
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
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