13 #ifndef LLVM_ADT_STRINGMAP_H 14 #define LLVM_ADT_STRINGMAP_H 19 #include <initializer_list> 47 RHS.TheTable =
nullptr;
50 RHS.NumTombstones = 0;
82 static_cast<uintptr_t>(-1)
107 template <
typename ValueTy,
typename AllocatorTy = MallocAllocator>
109 AllocatorTy Allocator;
129 for (
const auto &
P :
List) {
159 static_cast<MapEntryTy *>(Bucket)->getKey(),
Allocator,
160 static_cast<MapEntryTy *>(Bucket)->getValue());
161 HashTable[
I] = RHSHashTable[
I];
186 static_cast<MapEntryTy *>(Bucket)->Destroy(
Allocator);
248 template <
typename InputTy>
258 for (
const auto &KeyValue : *
this) {
259 auto FindInRHS = RHS.
find(KeyValue.getKey());
261 if (FindInRHS == RHS.
end())
264 if (!(KeyValue.getValue() == FindInRHS->getValue()))
296 std::pair<iterator, bool>
insert(std::pair<StringRef, ValueTy> KV) {
302 template <
typename V>
306 Ret.first->second = std::forward<V>(Val);
314 template <
typename... ArgsTy>
342 static_cast<MapEntryTy *>(Bucket)->Destroy(
Allocator);
370 template <
typename DerivedTy,
typename ValueTy>
381 bool NoAdvance =
false)
384 AdvancePastEmptyBuckets();
389 return static_cast<DerivedTy &>(*
this);
392 friend bool operator==(
const DerivedTy &LHS,
const DerivedTy &RHS) {
393 return LHS.Ptr == RHS.Ptr;
398 AdvancePastEmptyBuckets();
399 return static_cast<DerivedTy &>(*
this);
409 void AdvancePastEmptyBuckets() {
415 template <
typename ValueTy>
416 class StringMapConstIterator
417 :
public StringMapIterBase<StringMapConstIterator<ValueTy>,
418 const StringMapEntry<ValueTy>> {
419 using base = StringMapIterBase<StringMapConstIterator<ValueTy>,
420 const StringMapEntry<ValueTy>>;
425 bool NoAdvance =
false)
426 :
base(Bucket, NoAdvance) {}
433 template <
typename ValueTy>
434 class StringMapIterator :
public StringMapIterBase<StringMapIterator<ValueTy>,
435 StringMapEntry<ValueTy>> {
437 StringMapIterBase<StringMapIterator<ValueTy>, StringMapEntry<ValueTy>>;
442 bool NoAdvance =
false)
443 :
base(Bucket, NoAdvance) {}
454 template <
typename ValueTy>
455 class StringMapKeyIterator
456 :
public iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
457 StringMapConstIterator<ValueTy>,
458 std::forward_iterator_tag, StringRef> {
459 using base = iterator_adaptor_base<StringMapKeyIterator<ValueTy>,
461 std::forward_iterator_tag, StringRef>;
469 Key = this->
wrapped()->getKey();
479 #endif // LLVM_ADT_STRINGMAP_H std::pair< iterator, bool > insert_or_assign(StringRef Key, V &&Val)
Inserts an element or assigns to the current element if the key already exists.
iterator_range< StringMapKeyIterator< ValueTy > > keys() const
StringMapImpl(unsigned itemSize)
This class represents lattice values for constants.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
static StringMapEntry * Create(StringRef key, AllocatorTy &allocator, InitTy &&... initVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
This file defines MallocAllocator.
iterator find(StringRef Key)
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
const_iterator end() const
StringMapKeyIterator()=default
StringMap(const StringMap &RHS)
const_iterator find(StringRef Key) const
StringMapKeyIterator(StringMapConstIterator< ValueTy > Iter)
StringMap & operator=(StringMap RHS)
StringMapIterator(StringMapEntryBase **Bucket, bool NoAdvance=false)
StringMapImpl - This is the base class of StringMap that is shared among all of its instantiations.
const StringMapEntry< ValueTy > & operator *() const
friend bool operator==(const DerivedTy &LHS, const DerivedTy &RHS)
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
StringMapIterBase(StringMapEntryBase **Bucket, bool NoAdvance=false)
void swap(StringMapImpl &Other)
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&... Args)
Emplace a new element for the specified key into the map if the key isn't already in the map.
StringMapConstIterator()=default
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
StringMap(StringMap &&RHS)
size_type count(const StringMapEntry< InputTy > &MapEntry) const
StringMapEntryBase ** TheTable
StringMapIterator()=default
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const_iterator begin() const
static constexpr uintptr_t TombstoneIntVal
StringMap(unsigned InitialSize)
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
void init(unsigned Size)
Allocate the table with the specified number of buckets and otherwise setup the map as empty.
void Destroy(AllocatorTy &allocator)
Destroy - Destroy this StringMapEntry, releasing memory back to the specified allocator.
StringMapIterator< ValueTy > iterator
bool operator==(const StringMap &RHS) const
equal - check whether both of the containers are equal.
bool erase(StringRef Key)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
AllocatorTy & getAllocator()
void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.
std::pair< iterator, bool > insert(std::pair< StringRef, ValueTy > KV)
insert - Inserts the specified key/value pair into the map if the key isn't already in the map.
const AllocatorTy & getAllocator() const
static StringMapEntryBase * getTombstoneVal()
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A range adaptor for a pair of iterators.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringMap(unsigned InitialSize, AllocatorTy A)
unsigned getNumBuckets() const
StringMapConstIterator(StringMapEntryBase **Bucket, bool NoAdvance=false)
DerivedTy & operator=(const DerivedTy &Other)
const StringMapConstIterator< ValueTy > & wrapped() const
bool operator!=(const StringMap &RHS) const
DerivedTy operator++(int)
StringMap(std::initializer_list< std::pair< StringRef, ValueTy >> List)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringMapEntry< ValueTy > & operator *() const
StringMapImpl(StringMapImpl &&RHS)
unsigned getNumItems() const
StringMapEntryBase - Shared base class of StringMapEntry instances.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
StringRef - Represent a constant reference to a string, i.e.
ValueTy & operator[](StringRef Key)
Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map.
StringMapConstIterator< ValueTy > const_iterator
StringMapEntryBase ** Ptr
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
StringMapIterBase()=default