14#ifndef LLVM_ADT_DENSEMAP_H
15#define LLVM_ADT_DENSEMAP_H
32#include <initializer_list>
44template <
typename KeyT,
typename ValueT>
49 const KeyT &
getFirst()
const {
return std::pair<KeyT, ValueT>::first; }
57 typename KeyInfoT = DenseMapInfo<KeyT>,
60class DenseMapIterator;
62template <
typename DerivedT,
typename KeyT,
typename ValueT,
typename KeyInfoT,
91 return map_range(*
this, [](
const BucketT &
P) {
return P.getFirst(); });
96 return map_range(*
this, [](
const BucketT &
P) {
return P.getSecond(); });
100 return map_range(*
this, [](
const BucketT &
P) {
return P.getFirst(); });
104 return map_range(*
this, [](
const BucketT &
P) {
return P.getSecond(); });
107 [[nodiscard]]
bool empty()
const {
return getNumEntries() == 0; }
108 unsigned size()
const {
return getNumEntries(); }
115 if (NumBuckets > getNumBuckets())
121 if (getNumEntries() == 0 && getNumTombstones() == 0)
126 if (getNumEntries() * 4 < getNumBuckets() && getNumBuckets() > 64) {
132 if constexpr (std::is_trivially_destructible_v<ValueT>) {
134 for (BucketT &
B : buckets())
135 B.getFirst() = EmptyKey;
138 unsigned NumEntries = getNumEntries();
139 for (BucketT &
B : buckets()) {
140 if (!KeyInfoT::isEqual(
B.getFirst(), EmptyKey)) {
141 if (!KeyInfoT::isEqual(
B.getFirst(), TombstoneKey)) {
142 B.getSecond().~ValueT();
145 B.getFirst() = EmptyKey;
148 assert(NumEntries == 0 &&
"Node count imbalance!");
157 return doFind(Val) !=
nullptr;
174 if (BucketT *Bucket = doFind(Val))
175 return makeIterator(Bucket);
178 template <
class LookupKeyT>
180 if (
const BucketT *Bucket = doFind(Val))
181 return makeConstIterator(Bucket);
188 if (
const BucketT *Bucket = doFind(Val))
189 return Bucket->getSecond();
196 template <
typename U = std::remove_cv_t<ValueT>>
198 if (
const BucketT *Bucket = doFind(Val))
199 return Bucket->getSecond();
205 const ValueT &
at(const_arg_type_t<KeyT> Val)
const {
206 auto Iter = this->
find(std::move(Val));
207 assert(Iter != this->
end() &&
"DenseMap::at failed due to a missing key");
214 std::pair<iterator, bool>
insert(
const std::pair<KeyT, ValueT> &KV) {
215 return try_emplace_impl(KV.first, KV.second);
221 std::pair<iterator, bool>
insert(std::pair<KeyT, ValueT> &&KV) {
222 return try_emplace_impl(std::move(KV.first), std::move(KV.second));
228 template <
typename... Ts>
230 return try_emplace_impl(std::move(Key), std::forward<Ts>(Args)...);
236 template <
typename... Ts>
238 return try_emplace_impl(Key, std::forward<Ts>(Args)...);
246 template <
typename LookupKeyT>
247 std::pair<iterator, bool>
insert_as(std::pair<KeyT, ValueT> &&KV,
248 const LookupKeyT &Val) {
250 if (LookupBucketFor(Val, TheBucket))
251 return {makeIterator(TheBucket),
false};
254 TheBucket = findBucketForInsertion(Val, TheBucket);
255 TheBucket->getFirst() = std::move(KV.first);
256 ::new (&TheBucket->getSecond())
ValueT(std::move(KV.second));
257 return {makeIterator(TheBucket),
true};
261 template <
typename InputIt>
void insert(InputIt
I, InputIt
E) {
271 template <
typename V>
275 Ret.first->second = std::forward<V>(Val);
279 template <
typename V>
281 auto Ret =
try_emplace(std::move(Key), std::forward<V>(Val));
283 Ret.first->second = std::forward<V>(Val);
287 template <
typename... Ts>
289 auto Ret =
try_emplace(Key, std::forward<Ts>(Args)...);
291 Ret.first->second =
ValueT(std::forward<Ts>(Args)...);
295 template <
typename... Ts>
297 auto Ret =
try_emplace(std::move(Key), std::forward<Ts>(Args)...);
299 Ret.first->second =
ValueT(std::forward<Ts>(Args)...);
304 BucketT *TheBucket = doFind(Val);
308 TheBucket->getSecond().~ValueT();
310 decrementNumEntries();
311 incrementNumTombstones();
315 BucketT *TheBucket = &*
I;
316 TheBucket->getSecond().~ValueT();
318 decrementNumEntries();
319 incrementNumTombstones();
323 return lookupOrInsertIntoBucket(Key).first->second;
327 return lookupOrInsertIntoBucket(std::move(Key)).first->second;
334 return Ptr >= getBuckets() &&
Ptr < getBucketsEnd();
346 if (getNumBuckets() == 0)
350 for (BucketT &
B : buckets()) {
351 if (!KeyInfoT::isEqual(
B.getFirst(), EmptyKey) &&
352 !KeyInfoT::isEqual(
B.getFirst(), TombstoneKey))
353 B.getSecond().~ValueT();
354 B.getFirst().~KeyT();
362 assert((getNumBuckets() & (getNumBuckets() - 1)) == 0 &&
363 "# initial buckets must be a power of two!");
365 for (BucketT &
B : buckets())
366 ::new (&
B.getFirst())
KeyT(EmptyKey);
386 for (BucketT &
B : OldBuckets) {
387 if (!KeyInfoT::isEqual(
B.getFirst(), EmptyKey) &&
388 !KeyInfoT::isEqual(
B.getFirst(), TombstoneKey)) {
391 bool FoundVal = LookupBucketFor(
B.getFirst(), DestBucket);
393 assert(!FoundVal &&
"Key already in new map?");
394 DestBucket->getFirst() = std::move(
B.getFirst());
395 ::new (&DestBucket->getSecond())
ValueT(std::move(
B.getSecond()));
396 incrementNumEntries();
399 B.getSecond().~ValueT();
401 B.getFirst().~KeyT();
405 template <
typename OtherBaseT>
409 assert(getNumBuckets() == other.getNumBuckets());
411 setNumEntries(other.getNumEntries());
412 setNumTombstones(other.getNumTombstones());
414 BucketT *Buckets = getBuckets();
415 const BucketT *OtherBuckets = other.getBuckets();
416 const size_t NumBuckets = getNumBuckets();
417 if constexpr (std::is_trivially_copyable_v<KeyT> &&
418 std::is_trivially_copyable_v<ValueT>) {
419 memcpy(
reinterpret_cast<void *
>(Buckets), OtherBuckets,
420 NumBuckets *
sizeof(BucketT));
424 for (
size_t I = 0;
I < NumBuckets; ++
I) {
425 ::new (&Buckets[
I].getFirst())
KeyT(OtherBuckets[
I].getFirst());
426 if (!KeyInfoT::isEqual(Buckets[
I].getFirst(), EmptyKey) &&
427 !KeyInfoT::isEqual(Buckets[
I].getFirst(), TombstoneKey))
428 ::new (&Buckets[
I].getSecond())
ValueT(OtherBuckets[
I].getSecond());
434 return KeyInfoT::getHashValue(Val);
437 template <
typename LookupKeyT>
439 return KeyInfoT::getHashValue(Val);
443 static_assert(std::is_base_of_v<DenseMapBase, DerivedT>,
444 "Must pass the derived type to this template!");
445 return KeyInfoT::getEmptyKey();
451 template <
typename KeyArgT,
typename... Ts>
452 std::pair<BucketT *, bool> lookupOrInsertIntoBucket(KeyArgT &&Key,
454 BucketT *TheBucket =
nullptr;
455 if (LookupBucketFor(Key, TheBucket))
456 return {TheBucket,
false};
459 TheBucket = findBucketForInsertion(Key, TheBucket);
460 TheBucket->getFirst() = std::forward<KeyArgT>(Key);
461 ::new (&TheBucket->getSecond())
ValueT(
std::forward<Ts>(Args)...);
462 return {TheBucket,
true};
465 template <
typename KeyArgT,
typename... Ts>
466 std::pair<iterator, bool> try_emplace_impl(KeyArgT &&Key, Ts &&...Args) {
467 auto [Bucket,
Inserted] = lookupOrInsertIntoBucket(
468 std::forward<KeyArgT>(Key), std::forward<Ts>(Args)...);
469 return {makeIterator(Bucket),
Inserted};
472 iterator makeIterator(BucketT *TheBucket) {
476 const_iterator makeConstIterator(
const BucketT *TheBucket)
const {
480 unsigned getNumEntries()
const {
481 return static_cast<const DerivedT *
>(
this)->getNumEntries();
484 void setNumEntries(
unsigned Num) {
485 static_cast<DerivedT *
>(
this)->setNumEntries(Num);
488 void incrementNumEntries() { setNumEntries(getNumEntries() + 1); }
490 void decrementNumEntries() { setNumEntries(getNumEntries() - 1); }
492 unsigned getNumTombstones()
const {
493 return static_cast<const DerivedT *
>(
this)->getNumTombstones();
496 void setNumTombstones(
unsigned Num) {
497 static_cast<DerivedT *
>(
this)->setNumTombstones(Num);
500 void incrementNumTombstones() { setNumTombstones(getNumTombstones() + 1); }
502 void decrementNumTombstones() { setNumTombstones(getNumTombstones() - 1); }
504 const BucketT *getBuckets()
const {
505 return static_cast<const DerivedT *
>(
this)->getBuckets();
508 BucketT *getBuckets() {
return static_cast<DerivedT *
>(
this)->getBuckets(); }
510 unsigned getNumBuckets()
const {
511 return static_cast<const DerivedT *
>(
this)->getNumBuckets();
514 BucketT *getBucketsEnd() {
return getBuckets() + getNumBuckets(); }
516 const BucketT *getBucketsEnd()
const {
517 return getBuckets() + getNumBuckets();
520 iterator_range<BucketT *> buckets() {
524 iterator_range<const BucketT *> buckets()
const {
528 void grow(
unsigned AtLeast) {
static_cast<DerivedT *
>(
this)->grow(AtLeast); }
530 void shrink_and_clear() {
static_cast<DerivedT *
>(
this)->shrink_and_clear(); }
532 template <
typename LookupKeyT>
533 BucketT *findBucketForInsertion(
const LookupKeyT &
Lookup,
534 BucketT *TheBucket) {
546 unsigned NewNumEntries = getNumEntries() + 1;
547 unsigned NumBuckets = getNumBuckets();
549 this->grow(NumBuckets * 2);
550 LookupBucketFor(
Lookup, TheBucket);
552 (NewNumEntries + getNumTombstones()) <=
554 this->grow(NumBuckets);
555 LookupBucketFor(
Lookup, TheBucket);
561 incrementNumEntries();
565 if (!KeyInfoT::isEqual(TheBucket->getFirst(), EmptyKey))
566 decrementNumTombstones();
571 template <
typename LookupKeyT>
572 const BucketT *doFind(
const LookupKeyT &Val)
const {
573 const BucketT *BucketsPtr = getBuckets();
574 const unsigned NumBuckets = getNumBuckets();
579 unsigned BucketNo =
getHashValue(Val) & (NumBuckets - 1);
580 unsigned ProbeAmt = 1;
582 const BucketT *Bucket = BucketsPtr + BucketNo;
583 if (
LLVM_LIKELY(KeyInfoT::isEqual(Val, Bucket->getFirst())))
585 if (
LLVM_LIKELY(KeyInfoT::isEqual(Bucket->getFirst(), EmptyKey)))
590 BucketNo += ProbeAmt++;
591 BucketNo &= NumBuckets - 1;
595 template <
typename LookupKeyT> BucketT *doFind(
const LookupKeyT &Val) {
596 return const_cast<BucketT *
>(
604 template <
typename LookupKeyT>
605 bool LookupBucketFor(
const LookupKeyT &Val, BucketT *&FoundBucket) {
606 BucketT *BucketsPtr = getBuckets();
607 const unsigned NumBuckets = getNumBuckets();
609 if (NumBuckets == 0) {
610 FoundBucket =
nullptr;
615 BucketT *FoundTombstone =
nullptr;
618 assert(!KeyInfoT::isEqual(Val, EmptyKey) &&
619 !KeyInfoT::isEqual(Val, TombstoneKey) &&
620 "Empty/Tombstone value shouldn't be inserted into map!");
622 unsigned BucketNo =
getHashValue(Val) & (NumBuckets - 1);
623 unsigned ProbeAmt = 1;
625 BucketT *ThisBucket = BucketsPtr + BucketNo;
627 if (
LLVM_LIKELY(KeyInfoT::isEqual(Val, ThisBucket->getFirst()))) {
628 FoundBucket = ThisBucket;
634 if (
LLVM_LIKELY(KeyInfoT::isEqual(ThisBucket->getFirst(), EmptyKey))) {
637 FoundBucket = FoundTombstone ? FoundTombstone : ThisBucket;
643 if (KeyInfoT::isEqual(ThisBucket->getFirst(), TombstoneKey) &&
645 FoundTombstone = ThisBucket;
649 BucketNo += ProbeAmt++;
650 BucketNo &= (NumBuckets - 1);
668template <
typename DerivedT,
typename KeyT,
typename ValueT,
typename KeyInfoT,
673 if (
LHS.size() !=
RHS.size())
676 for (
auto &KV :
LHS) {
677 auto I =
RHS.find(KV.first);
678 if (
I ==
RHS.end() ||
I->second != KV.second)
688template <
typename DerivedT,
typename KeyT,
typename ValueT,
typename KeyInfoT,
697 typename KeyInfoT = DenseMapInfo<KeyT>,
700 KeyT, ValueT, KeyInfoT, BucketT> {
709 unsigned NumTombstones;
715 explicit DenseMap(
unsigned InitialReserve = 0) { init(InitialReserve); }
727 template <
typename InputIt>
DenseMap(
const InputIt &
I,
const InputIt &
E) {
728 init(std::distance(
I,
E));
732 template <
typename RangeT>
736 DenseMap(std::initializer_list<typename BaseT::value_type> Vals)
770 if (allocateBuckets(other.NumBuckets)) {
779 unsigned OldNumBuckets = NumBuckets;
780 BucketT *OldBuckets = Buckets;
782 allocateBuckets(std::max<unsigned>(
799 unsigned OldNumBuckets = NumBuckets;
800 unsigned OldNumEntries = NumEntries;
804 unsigned NewNumBuckets = 0;
806 NewNumBuckets = std::max(64, 1 << (
Log2_32_Ceil(OldNumEntries) + 1));
807 if (NewNumBuckets == NumBuckets) {
818 unsigned getNumEntries()
const {
return NumEntries; }
820 void setNumEntries(
unsigned Num) { NumEntries = Num; }
822 unsigned getNumTombstones()
const {
return NumTombstones; }
824 void setNumTombstones(
unsigned Num) { NumTombstones = Num; }
826 BucketT *getBuckets()
const {
return Buckets; }
828 unsigned getNumBuckets()
const {
return NumBuckets; }
830 bool allocateBuckets(
unsigned Num) {
832 if (NumBuckets == 0) {
837 Buckets =
static_cast<BucketT *
>(
842 void init(
unsigned InitNumEntries) {
844 if (allocateBuckets(InitBuckets)) {
853template <
typename KeyT,
typename ValueT,
unsigned InlineBuckets = 4,
854 typename KeyInfoT = DenseMapInfo<KeyT>,
858 SmallDenseMap<KeyT, ValueT, InlineBuckets, KeyInfoT, BucketT>, KeyT,
859 ValueT, KeyInfoT, BucketT> {
867 "InlineBuckets must be a power of 2.");
870 unsigned NumEntries : 31;
871 unsigned NumTombstones;
883 AlignedCharArrayUnion<BucketT[InlineBuckets], LargeRep> storage;
887 if (NumInitBuckets > InlineBuckets)
889 init(NumInitBuckets);
902 template <
typename InputIt>
908 template <
typename RangeT>
921 unsigned TmpNumEntries =
RHS.NumEntries;
922 RHS.NumEntries = NumEntries;
923 NumEntries = TmpNumEntries;
928 if (Small &&
RHS.Small) {
933 for (
unsigned i = 0, e = InlineBuckets; i != e; ++i) {
934 BucketT *LHSB = &getInlineBuckets()[i],
935 *RHSB = &
RHS.getInlineBuckets()[i];
936 bool hasLHSValue = (!KeyInfoT::isEqual(LHSB->getFirst(), EmptyKey) &&
937 !KeyInfoT::isEqual(LHSB->getFirst(), TombstoneKey));
938 bool hasRHSValue = (!KeyInfoT::isEqual(RHSB->getFirst(), EmptyKey) &&
939 !KeyInfoT::isEqual(RHSB->getFirst(), TombstoneKey));
940 if (hasLHSValue && hasRHSValue) {
946 std::swap(LHSB->getFirst(), RHSB->getFirst());
948 ::new (&RHSB->getSecond())
ValueT(std::move(LHSB->getSecond()));
949 LHSB->getSecond().~ValueT();
950 }
else if (hasRHSValue) {
951 ::new (&LHSB->getSecond())
ValueT(std::move(RHSB->getSecond()));
952 RHSB->getSecond().~ValueT();
957 if (!Small && !
RHS.Small) {
966 LargeRep TmpRep = std::move(*LargeSide.getLargeRep());
967 LargeSide.getLargeRep()->~LargeRep();
968 LargeSide.Small =
true;
973 for (
unsigned i = 0, e = InlineBuckets; i != e; ++i) {
974 BucketT *NewB = &LargeSide.getInlineBuckets()[i],
975 *OldB = &SmallSide.getInlineBuckets()[i];
976 ::new (&NewB->getFirst())
KeyT(std::move(OldB->getFirst()));
977 OldB->getFirst().~KeyT();
978 if (!KeyInfoT::isEqual(NewB->getFirst(), EmptyKey) &&
979 !KeyInfoT::isEqual(NewB->getFirst(), TombstoneKey)) {
980 ::new (&NewB->getSecond())
ValueT(std::move(OldB->getSecond()));
981 OldB->getSecond().~ValueT();
987 SmallSide.Small =
false;
988 new (SmallSide.getLargeRep()) LargeRep(std::move(TmpRep));
1007 deallocateBuckets();
1009 if (other.getNumBuckets() > InlineBuckets) {
1011 new (getLargeRep()) LargeRep(allocateBuckets(other.getNumBuckets()));
1018 if (InitBuckets > InlineBuckets) {
1020 new (getLargeRep()) LargeRep(allocateBuckets(InitBuckets));
1026 if (AtLeast > InlineBuckets)
1027 AtLeast = std::max<unsigned>(64,
NextPowerOf2(AtLeast - 1));
1032 BucketT *TmpBegin =
reinterpret_cast<BucketT *
>(&TmpStorage);
1033 BucketT *TmpEnd = TmpBegin;
1039 for (BucketT &
B : inlineBuckets()) {
1040 if (!KeyInfoT::isEqual(
B.getFirst(), EmptyKey) &&
1041 !KeyInfoT::isEqual(
B.getFirst(), TombstoneKey)) {
1042 assert(
size_t(TmpEnd - TmpBegin) < InlineBuckets &&
1043 "Too many inline buckets!");
1044 ::new (&TmpEnd->getFirst())
KeyT(std::move(
B.getFirst()));
1045 ::new (&TmpEnd->getSecond())
ValueT(std::move(
B.getSecond()));
1047 B.getSecond().~ValueT();
1049 B.getFirst().~KeyT();
1055 if (AtLeast > InlineBuckets) {
1057 new (getLargeRep()) LargeRep(allocateBuckets(AtLeast));
1063 LargeRep OldRep = std::move(*getLargeRep());
1064 getLargeRep()->~LargeRep();
1065 if (AtLeast <= InlineBuckets) {
1068 new (getLargeRep()) LargeRep(allocateBuckets(AtLeast));
1079 unsigned OldSize = this->
size();
1083 unsigned NewNumBuckets = 0;
1086 if (NewNumBuckets > InlineBuckets && NewNumBuckets < 64u)
1089 if ((Small && NewNumBuckets <= InlineBuckets) ||
1090 (!Small && NewNumBuckets == getLargeRep()->NumBuckets)) {
1095 deallocateBuckets();
1096 init(NewNumBuckets);
1100 unsigned getNumEntries()
const {
return NumEntries; }
1102 void setNumEntries(
unsigned Num) {
1104 assert(Num < (1U << 31) &&
"Cannot support more than 1<<31 entries");
1108 unsigned getNumTombstones()
const {
return NumTombstones; }
1110 void setNumTombstones(
unsigned Num) { NumTombstones = Num; }
1112 const BucketT *getInlineBuckets()
const {
1117 return reinterpret_cast<const BucketT *
>(&storage);
1120 BucketT *getInlineBuckets() {
1121 return const_cast<BucketT *
>(
1122 const_cast<const SmallDenseMap *
>(
this)->getInlineBuckets());
1125 const LargeRep *getLargeRep()
const {
1128 return reinterpret_cast<const LargeRep *
>(&storage);
1131 LargeRep *getLargeRep() {
1132 return const_cast<LargeRep *
>(
1133 const_cast<const SmallDenseMap *
>(
this)->getLargeRep());
1136 const BucketT *getBuckets()
const {
1137 return Small ? getInlineBuckets() : getLargeRep()->Buckets;
1140 BucketT *getBuckets() {
1141 return const_cast<BucketT *
>(
1142 const_cast<const SmallDenseMap *
>(
this)->getBuckets());
1145 unsigned getNumBuckets()
const {
1146 return Small ? InlineBuckets : getLargeRep()->NumBuckets;
1149 iterator_range<BucketT *> inlineBuckets() {
1150 BucketT *Begin = getInlineBuckets();
1154 void deallocateBuckets() {
1159 sizeof(BucketT) * getLargeRep()->NumBuckets,
1161 getLargeRep()->~LargeRep();
1164 LargeRep allocateBuckets(
unsigned Num) {
1165 assert(Num > InlineBuckets &&
"Must allocate more buckets than are inline");
1167 sizeof(BucketT) * Num,
alignof(BucketT))),
1173template <
typename KeyT,
typename ValueT,
typename KeyInfoT,
typename Bucket,
1181 using value_type = std::conditional_t<IsConst, const Bucket, Bucket>;
1203 return makeEnd(Buckets, Epoch);
1204 if (shouldReverseIterate<KeyT>()) {
1206 Iter.RetreatPastEmptyBuckets();
1210 Iter.AdvancePastEmptyBuckets();
1216 if (shouldReverseIterate<KeyT>())
1224 if (shouldReverseIterate<KeyT>())
1232 template <
bool IsConstSrc,
1233 typename = std::enable_if_t<!IsConstSrc && IsConst>>
1241 if (shouldReverseIterate<KeyT>())
1248 if (shouldReverseIterate<KeyT>())
1255 assert((!
LHS.Ptr ||
LHS.isHandleInSync()) &&
"handle not in sync!");
1256 assert((!
RHS.Ptr ||
RHS.isHandleInSync()) &&
"handle not in sync!");
1257 assert(
LHS.getEpochAddress() ==
RHS.getEpochAddress() &&
1258 "comparing incomparable iterators!");
1259 return LHS.Ptr ==
RHS.Ptr;
1270 if (shouldReverseIterate<KeyT>()) {
1272 RetreatPastEmptyBuckets();
1276 AdvancePastEmptyBuckets();
1287 void AdvancePastEmptyBuckets() {
1289 const KeyT Empty = KeyInfoT::getEmptyKey();
1290 const KeyT Tombstone = KeyInfoT::getTombstoneKey();
1292 while (
Ptr !=
End && (KeyInfoT::isEqual(
Ptr->getFirst(), Empty) ||
1293 KeyInfoT::isEqual(
Ptr->getFirst(), Tombstone)))
1297 void RetreatPastEmptyBuckets() {
1299 const KeyT Empty = KeyInfoT::getEmptyKey();
1300 const KeyT Tombstone = KeyInfoT::getTombstoneKey();
1302 while (
Ptr !=
End && (KeyInfoT::isEqual(
Ptr[-1].getFirst(), Empty) ||
1303 KeyInfoT::isEqual(
Ptr[-1].getFirst(), Tombstone)))
1308template <
typename KeyT,
typename ValueT,
typename KeyInfoT>
1310 return X.getMemorySize();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
This file defines DenseMapInfo traits for DenseMap.
This file defines the DebugEpochBase and DebugEpochBase::HandleBase classes.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file defines counterparts of C library allocation functions defined in the namespace 'std'.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file contains library features backported from future STL versions.
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
bool isHandleInSync() 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(const_arg_type_t< KeyT > Val)
static unsigned getHashValue(const KeyT &Val)
static const KeyT getEmptyKey()
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
std::pair< iterator, bool > insert(std::pair< KeyT, ValueT > &&KV)
bool erase(const KeyT &Val)
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
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,...
const_iterator find_as(const LookupKeyT &Val) const
const_iterator end() const
void moveFromOldBuckets(iterator_range< BucketT * > OldBuckets)
iterator find_as(const LookupKeyT &Val)
Alternate version of find() which allows a different, and possibly less expensive,...
const_iterator find(const_arg_type_t< KeyT > Val) const
std::pair< iterator, bool > emplace_or_assign(const KeyT &Key, Ts &&...Args)
void insert(InputIt I, InputIt E)
insert - Range insertion of pairs.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
static const KeyT getTombstoneKey()
const ValueT & at(const_arg_type_t< KeyT > Val) const
at - Return the entry for the specified key, or abort if no such entry exists.
bool isPointerIntoBucketsArray(const void *Ptr) const
isPointerIntoBucketsArray - Return true if the specified pointer points somewhere into the DenseMap's...
void copyFrom(const DenseMapBase< OtherBaseT, KeyT, ValueT, KeyInfoT, BucketT > &other)
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
std::pair< iterator, bool > try_emplace(const KeyT &Key, Ts &&...Args)
const_iterator begin() const
std::pair< iterator, bool > emplace_or_assign(KeyT &&Key, Ts &&...Args)
void insert_range(Range &&R)
Inserts range of 'std::pair<KeyT, ValueT>' values into the map.
const void * getPointerIntoBucketsArray() const
getPointerIntoBucketsArray() - Return an opaque pointer into the buckets array.
std::pair< iterator, bool > insert_or_assign(KeyT &&Key, V &&Val)
ValueT lookup_or(const_arg_type_t< KeyT > Val, U &&Default) const
unsigned getMinBucketToReserveForEntries(unsigned NumEntries)
Returns the number of buckets to allocate to ensure that the DenseMap can accommodate NumEntries with...
static unsigned getHashValue(const LookupKeyT &Val)
ValueT & operator[](const KeyT &Key)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
std::pair< iterator, bool > insert_or_assign(const KeyT &Key, V &&Val)
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again.
ValueT & operator[](KeyT &&Key)
size_t getMemorySize() const
Return the approximate size (in bytes) of the actual map.
std::conditional_t< IsConst, const Bucket, Bucket > value_type
static DenseMapIterator makeIterator(pointer P, iterator_range< pointer > Buckets, const DebugEpochBase &Epoch)
friend bool operator!=(const DenseMapIterator &LHS, const DenseMapIterator &RHS)
DenseMapIterator & operator++()
pointer operator->() const
reference operator*() const
DenseMapIterator()=default
static DenseMapIterator makeBegin(iterator_range< pointer > Buckets, bool IsEmpty, const DebugEpochBase &Epoch)
DenseMapIterator operator++(int)
DenseMapIterator(const DenseMapIterator< KeyT, ValueT, KeyInfoT, Bucket, IsConstSrc > &I)
friend bool operator==(const DenseMapIterator &LHS, const DenseMapIterator &RHS)
static DenseMapIterator makeEnd(iterator_range< pointer > Buckets, const DebugEpochBase &Epoch)
std::forward_iterator_tag iterator_category
DenseMap(std::initializer_list< typename BaseT::value_type > Vals)
void copyFrom(const DenseMap &other)
DenseMap & operator=(DenseMap &&other)
DenseMap(unsigned InitialReserve=0)
Create a DenseMap with an optional InitialReserve that guarantee that this number of elements can be ...
void grow(unsigned AtLeast)
DenseMap(llvm::from_range_t, const RangeT &Range)
DenseMap(const DenseMap &other)
DenseMap(const InputIt &I, const InputIt &E)
DenseMap(DenseMap &&other)
DenseMap & operator=(const DenseMap &other)
void grow(unsigned AtLeast)
SmallDenseMap(const InputIt &I, const InputIt &E)
void swap(SmallDenseMap &RHS)
void init(unsigned InitBuckets)
SmallDenseMap & operator=(SmallDenseMap &&other)
SmallDenseMap & operator=(const SmallDenseMap &other)
SmallDenseMap(unsigned NumInitBuckets=0)
SmallDenseMap(std::initializer_list< typename BaseT::value_type > Vals)
SmallDenseMap(SmallDenseMap &&other)
SmallDenseMap(const SmallDenseMap &other)
void copyFrom(const SmallDenseMap &other)
SmallDenseMap(llvm::from_range_t, const RangeT &Range)
A range adaptor for a pair of iterators.
constexpr char IsConst[]
Key for Kernel::Arg::Metadata::mIsConst.
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.
constexpr auto adl_begin(RangeT &&range) -> decltype(adl_detail::begin_impl(std::forward< RangeT >(range)))
Returns the begin iterator to range using std::begin and function found through Argument-Dependent Lo...
BitVector::size_type capacity_in_bytes(const BitVector &X)
bool operator!=(uint64_t V1, const APInt &V2)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
constexpr auto adl_end(RangeT &&range) -> decltype(adl_detail::end_impl(std::forward< RangeT >(range)))
Returns the end iterator to range using std::end and functions found through Argument-Dependent Looku...
T bit_ceil(T Value)
Returns the smallest integral power of two no smaller than Value if Value is nonzero.
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
auto map_range(ContainerTy &&C, FuncTy F)
LLVM_ABI LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * allocate_buffer(size_t Size, size_t Alignment)
Allocate a buffer of memory with the given size and alignment.
LLVM_ABI void deallocate_buffer(void *Ptr, size_t Size, size_t Alignment)
Deallocate a buffer of memory with the given size and alignment.
@ Default
The result values are uniform if and only if all operands are uniform.
constexpr uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A suitably aligned and sized character array member which can hold elements of any type.
const ValueT & getSecond() const
const KeyT & getFirst() const