31 #ifndef LLVM_ADT_SCOPEDHASHTABLE_H 32 #define LLVM_ADT_SCOPEDHASHTABLE_H 42 template <
typename K,
typename V,
typename KInfo = DenseMapInfo<K>,
43 typename AllocatorTy = MallocAllocator>
46 template <
typename K,
typename V>
56 const K &
getKey()
const {
return Key; }
64 template <
typename AllocatorTy>
67 const K &key,
const V &val,
72 New->NextInScope = nextInScope;
73 New->NextForKey = nextForKey;
80 Allocator.Deallocate(
this);
84 template <
typename K,
typename V,
typename KInfo = DenseMapInfo<K>,
85 typename AllocatorTy = MallocAllocator>
110 return LastValInScope;
114 LastValInScope = Val;
118 template <
typename K,
typename V,
typename KInfo = DenseMapInfo<K>>
126 assert(Node &&
"Dereference end()");
134 return Node == RHS.Node;
137 return Node != RHS.Node;
141 assert(Node &&
"incrementing past end()");
150 template <
typename K,
typename V,
typename KInfo,
typename AllocatorTy>
175 assert(!CurScope && TopLevelMap.
empty() &&
"Scope imbalance!");
184 return TopLevelMap.
count(Key);
188 auto I = TopLevelMap.
find(Key);
189 if (
I != TopLevelMap.
end())
190 return I->second->getValue();
196 insertIntoScope(CurScope, Key, Val);
205 TopLevelMap.
find(Key);
206 if (I == TopLevelMap.
end())
return end();
218 assert(S &&
"No scope active!");
220 KeyEntry = ValTy::Create(S->getLastValInScope(), KeyEntry,
Key, Val,
222 S->setLastValInScope(KeyEntry);
228 template <
typename K,
typename V,
typename KInfo,
typename Allocator>
231 PrevScope = HT.CurScope;
233 LastValInScope =
nullptr;
236 template <
typename K,
typename V,
typename KInfo,
typename Allocator>
238 assert(HT.CurScope ==
this &&
"Scope imbalance!");
239 HT.CurScope = PrevScope;
244 if (!ThisEntry->getNextForKey()) {
245 assert(HT.TopLevelMap[ThisEntry->getKey()] == ThisEntry &&
247 HT.TopLevelMap.erase(ThisEntry->getKey());
250 assert(KeyEntry == ThisEntry &&
"Scope imbalance!");
255 LastValInScope = ThisEntry->getNextInScope();
258 ThisEntry->Destroy(HT.getAllocator());
264 #endif // LLVM_ADT_SCOPEDHASHTABLE_H
ScopedHashTableVal * getNextInScope()
const_iterator end(StringRef path)
Get end iterator over path.
ScopedHashTableIterator operator++(int)
This class represents lattice values for constants.
void insertIntoScope(ScopeTy *S, const K &Key, const V &Val)
insertIntoScope - This inserts the specified key/value at the specified (possibly not the current) sc...
bool operator==(const ScopedHashTableIterator &RHS) const
size_type count(const K &Key) const
Return 1 if the specified key is in the table, 0 otherwise.
const ScopedHashTableScope * getParentScope() const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
static ScopedHashTableVal * Create(ScopedHashTableVal *nextInScope, ScopedHashTableVal *nextForKey, const K &key, const V &val, AllocatorTy &Allocator)
bool operator!=(const ScopedHashTableIterator &RHS) const
iterator find(const_arg_type_t< KeyT > Val)
ScopedHashTableScope * getParentScope()
const AllocatorTy & getAllocator() const
const ScopedHashTableVal * getNextForKey() const
AllocatorTy & getAllocator()
Access to the allocator.
V lookup(const K &Key) const
ScopedHashTableVal * getNextForKey()
const V & getValue() const
ScopedHashTable(AllocatorTy A)
void insert(const K &Key, const V &Val)
iterator begin(const K &Key)
ScopedHashTableIterator & operator++()
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
ScopedHashTableScope(ScopedHashTable< K, V, KInfo, AllocatorTy > &HT)
ScopedHashTableIterator(ScopedHashTableVal< K, V > *node)
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
const ScopeTy * getCurScope() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void Destroy(AllocatorTy &Allocator)