14#ifndef LLVM_ADT_STRINGMAP_H
15#define LLVM_ADT_STRINGMAP_H
23#include <initializer_list>
49 RHS.TheTable =
nullptr;
114 Other.incrementEpoch();
125template <
typename ValueTy,
typename AllocatorTy = MallocAllocator>
177 HashTable[
I] = RHSHashTable[
I];
200 using AllocTy::getAllocator;
259 auto Iter = this->
find(Val);
260 assert(Iter != this->
end() &&
"StringMap::at failed due to a missing key");
278 template <
typename InputTy>
288 for (
const auto &KeyValue : *
this) {
289 auto FindInRHS =
RHS.find(KeyValue.getKey());
291 if (FindInRHS ==
RHS.end())
294 if constexpr (!std::is_same_v<ValueTy, EmptyStringSetTag>) {
295 if (!(KeyValue.getValue() == FindInRHS->getValue()))
304 return !(*
this ==
RHS);
329 std::pair<iterator, bool>
insert(std::pair<StringRef, ValueTy> KV) {
331 std::move(KV.second));
334 std::pair<iterator, bool>
insert(std::pair<StringRef, ValueTy> KV,
343 for (InputIt It =
First; It !=
Last; ++It)
350 void insert(std::initializer_list<std::pair<StringRef, ValueTy>>
List) {
356 template <
typename V>
360 Ret.first->second = std::forward<V>(Val);
368 template <
typename... ArgsTy>
373 template <
typename... ArgsTy>
438 bool Removed =
false;
445 auto *Entry =
static_cast<MapEntryTy *
>(Bucket);
462template <
typename ValueTy,
bool IsConst>
473 using pointer = std::conditional_t<IsConst, const value_type *, value_type *>;
475 std::conditional_t<IsConst, const value_type &, value_type &>;
483 AdvancePastEmptyBuckets();
488 template <
bool IsConstSrc,
489 typename = std::enable_if_t<!IsConstSrc && IsConst>>
505 AdvancePastEmptyBuckets();
517 assert((!
LHS.getEpochAddress() ||
LHS.isHandleInSync()) &&
518 "handle not in sync!");
519 assert((!
RHS.getEpochAddress() ||
RHS.isHandleInSync()) &&
520 "handle not in sync!");
521 return LHS.Ptr ==
RHS.Ptr;
530 void AdvancePastEmptyBuckets() {
531 while (*Ptr ==
nullptr)
536template <
typename ValueTy>
539 StringMapIterBase<ValueTy, true>,
540 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")
This file defines the DebugEpochBase and DebugEpochBase::HandleBase classes.
static constexpr Value * getValue(Ty &ValueOrUse)
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.
bool isHandleInSync() const
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)
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
LLVM_ABI void removeBucket(unsigned Bucket)
Remove the entry pointer at the given (live) bucket without destroying the entry, and close the hole ...
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
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
StringMapEntry< ValueTy > value_type
StringMapIterBase operator++(int)
reference operator*() const
StringMapIterBase(const DebugEpochBase *Epoch, StringMapEntryBase **Bucket, bool Advance=false)
std::conditional_t< IsConst, const value_type *, value_type * > pointer
friend bool operator==(const StringMapIterBase &LHS, const StringMapIterBase &RHS)
StringMapIterBase(const StringMapIterBase< ValueTy, IsConstSrc > &I)
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
bool remove_if(Predicate Pred)
Remove entries that match the given predicate.
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)
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.