30 #ifndef LLVM_ADT_SCOPEDHASHTABLE_H 31 #define LLVM_ADT_SCOPEDHASHTABLE_H 41 template <
typename K,
typename V,
typename KInfo = DenseMapInfo<K>,
42 typename AllocatorTy = MallocAllocator>
45 template <
typename K,
typename V>
55 const K &
getKey()
const {
return Key; }
63 template <
typename AllocatorTy>
66 const K &key,
const V &val,
71 New->NextInScope = nextInScope;
72 New->NextForKey = nextForKey;
79 Allocator.Deallocate(
this);
83 template <
typename K,
typename V,
typename KInfo = DenseMapInfo<K>,
84 typename AllocatorTy = MallocAllocator>
109 return LastValInScope;
113 LastValInScope = Val;
117 template <
typename K,
typename V,
typename KInfo = DenseMapInfo<K>>
125 assert(Node &&
"Dereference end()");
133 return Node == RHS.Node;
136 return Node != RHS.Node;
140 assert(Node &&
"incrementing past end()");
149 template <
typename K,
typename V,
typename KInfo,
typename AllocatorTy>
174 assert(!CurScope && TopLevelMap.
empty() &&
"Scope imbalance!");
183 return TopLevelMap.
count(Key);
187 auto I = TopLevelMap.
find(Key);
188 if (
I != TopLevelMap.
end())
189 return I->second->getValue();
195 insertIntoScope(CurScope, Key, Val);
204 TopLevelMap.
find(Key);
205 if (I == TopLevelMap.
end())
return end();
217 assert(S &&
"No scope active!");
219 KeyEntry = ValTy::Create(S->getLastValInScope(), KeyEntry,
Key, Val,
221 S->setLastValInScope(KeyEntry);
227 template <
typename K,
typename V,
typename KInfo,
typename Allocator>
230 PrevScope = HT.CurScope;
232 LastValInScope =
nullptr;
235 template <
typename K,
typename V,
typename KInfo,
typename Allocator>
237 assert(HT.CurScope ==
this &&
"Scope imbalance!");
238 HT.CurScope = PrevScope;
243 if (!ThisEntry->getNextForKey()) {
244 assert(HT.TopLevelMap[ThisEntry->getKey()] == ThisEntry &&
246 HT.TopLevelMap.erase(ThisEntry->getKey());
249 assert(KeyEntry == ThisEntry &&
"Scope imbalance!");
254 LastValInScope = ThisEntry->getNextInScope();
257 ThisEntry->Destroy(HT.getAllocator());
263 #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)