14#ifndef LLVM_ADT_STRINGMAP_H
15#define LLVM_ADT_STRINGMAP_H
22#include <initializer_list>
50 RHS.TheTable =
nullptr;
53 RHS.NumTombstones = 0;
98 static_cast<uintptr_t
>(-1)
130template <
typename ValueTy,
typename AllocatorTy = MallocAllocator>
182 static_cast<MapEntryTy *
>(Bucket)->getValue());
183 HashTable[
I] = RHSHashTable[
I];
213 using AllocTy::getAllocator;
265 auto Iter = this->
find(Val);
266 assert(Iter != this->
end() &&
"StringMap::at failed due to a missing key");
280 template <
typename InputTy>
290 for (
const auto &KeyValue : *
this) {
291 auto FindInRHS =
RHS.find(KeyValue.getKey());
293 if (FindInRHS ==
RHS.end())
296 if constexpr (!std::is_same_v<ValueTy, std::nullopt_t>) {
297 if (!(KeyValue.getValue() == FindInRHS->getValue()))
330 std::pair<iterator, bool>
insert(std::pair<StringRef, ValueTy> KV) {
332 std::move(KV.second));
335 std::pair<iterator, bool>
insert(std::pair<StringRef, ValueTy> KV,
344 for (InputIt It =
First; It !=
Last; ++It)
351 void insert(std::initializer_list<std::pair<StringRef, ValueTy>>
List) {
357 template <
typename V>
361 Ret.first->second = std::forward<V>(Val);
369 template <
typename... ArgsTy>
374 template <
typename... ArgsTy>
438 using pointer = std::conditional_t<IsConst, const value_type *, value_type *>;
440 std::conditional_t<IsConst, const value_type &, value_type &>;
447 AdvancePastEmptyBuckets();
455 AdvancePastEmptyBuckets();
465 template <
bool ToConst,
466 typename =
typename std::enable_if<!IsConst && ToConst>::type>
473 return LHS.Ptr ==
RHS.Ptr;
482 void AdvancePastEmptyBuckets() {
488template <
typename ValueTy>
491 StringMapIterBase<ValueTy, true>,
492 std::forward_iterator_tag, StringRef> {
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMapEntry class - it is intended to be a low dependency implementation det...
This file defines MallocAllocator.
#define LLVM_ALLOCATORHOLDER_EMPTYBASE
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static const BasicSubtargetSubTypeKV * find(StringRef S, ArrayRef< BasicSubtargetSubTypeKV > A)
Find KV in array using binary search.
StringMapEntryBase - Shared base class of StringMapEntry instances.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
static StringMapEntry * create(StringRef key, AllocatorTy &allocator, InitTy &&...initVals)
iterator_range< StringMapEntryBase ** > buckets()
void swap(StringMapImpl &Other)
static StringMapEntryBase * getTombstoneVal()
unsigned LookupBucketFor(StringRef Key)
LookupBucketFor - Look up the bucket that the specified string should end up in.
LLVM_ABI unsigned RehashTable(unsigned BucketNo=0)
RehashTable - Grow the table, redistributing values into the buckets with the appropriate mod-of-hash...
LLVM_ABI void RemoveKey(StringMapEntryBase *V)
RemoveKey - Remove the specified StringMapEntry from the table, but do not delete it.
StringMapEntryBase ** TheTable
unsigned getNumBuckets() const
StringMapImpl(unsigned itemSize)
LLVM_ABI void init(unsigned Size)
Allocate the table with the specified number of buckets and otherwise setup the map as empty.
static LLVM_ABI uint32_t hash(StringRef Key)
Returns the hash value that will be used for the given string.
unsigned getNumItems() const
static constexpr uintptr_t TombstoneIntVal
int FindKey(StringRef Key) const
FindKey - Look up the bucket that contains the specified key.
StringMapImpl(StringMapImpl &&RHS)
std::forward_iterator_tag iterator_category
StringMapIterBase & operator++()
pointer operator->() const
StringMapIterBase(StringMapEntryBase **Bucket, bool Advance=false)
StringMapEntry< ValueTy > value_type
StringMapIterBase operator++(int)
reference operator*() const
std::conditional_t< IsConst, const value_type *, value_type * > pointer
friend bool operator==(const StringMapIterBase &LHS, const StringMapIterBase &RHS)
StringMapIterBase()=default
friend bool operator!=(const StringMapIterBase &LHS, const StringMapIterBase &RHS)
std::ptrdiff_t difference_type
std::conditional_t< IsConst, const value_type &, value_type & > reference
StringRef operator*() const
StringMapKeyIterator()=default
StringMapKeyIterator(StringMapIterBase< ValueTy, true > Iter)
size_type count(const StringMapEntry< InputTy > &MapEntry) const
StringMap(StringMap &&RHS)
bool erase(StringRef Key)
StringMap(std::initializer_list< std::pair< StringRef, ValueTy > > List)
bool operator!=(const StringMap &RHS) const
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
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 find(StringRef Key)
const_iterator end() const
StringMap(const StringMap &RHS)
const ValueTy & at(StringRef Val) const
at - Return the entry for the specified key, or abort if no such entry exists.
bool contains(StringRef Key) const
contains - Return true if the element is in the map, false otherwise.
StringMapIterBase< ValueTy, false > iterator
iterator find(StringRef Key, uint32_t FullHashValue)
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.
iterator_range< StringMapKeyIterator< ValueTy > > keys() const
const_iterator find(StringRef Key) const
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
StringMap & operator=(StringMap RHS)
void insert(InputIt First, InputIt Last)
Inserts elements from range [first, last).
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
StringMapEntry< ValueTy > value_type
const_iterator find(StringRef Key, uint32_t FullHashValue) const
StringMapIterBase< ValueTy, true > const_iterator
const_iterator begin() const
std::pair< iterator, bool > try_emplace_with_hash(StringRef Key, uint32_t FullHashValue, ArgsTy &&...Args)
StringMap(unsigned InitialSize)
std::pair< iterator, bool > try_emplace(StringRef Key, ArgsTy &&...Args)
std::pair< iterator, bool > insert(std::pair< StringRef, ValueTy > KV, uint32_t FullHashValue)
StringMap(unsigned InitialSize, AllocatorTy A)
ValueTy & operator[](StringRef Key)
Lookup the ValueTy for the Key, or create a default constructed value if the key is not in the map.
AllocatorTy & getAllocator()
bool operator==(const StringMap &RHS) const
equal - check whether both of the containers are equal.
StringMapEntry< ValueTy > MapEntryTy
void insert(std::initializer_list< std::pair< StringRef, ValueTy > > List)
Inserts elements from initializer list ilist.
bool insert(MapEntryTy *KeyValue)
StringRef - Represent a constant reference to a string, i.e.
const StringMapIterBase< ValueTy, true > & wrapped() const
iterator_adaptor_base()=default
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
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 traits type that is used to handle pointer types and things that are just wrappers for pointers as ...