9#ifndef LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H
31template <
typename ValueT>
class HashTable;
33template <
typename ValueT>
36 std::forward_iterator_tag,
37 const std::pair<uint32_t, ValueT>> {
38 using BaseT =
typename HashTableIterator::iterator_facade_base;
43 : Map(&Map), Index(Index), IsEnd(IsEnd) {}
47 int I = Map.Present.find_first();
68 return (Map == R.Map) && (Index == R.Index);
70 const std::pair<uint32_t, ValueT> &
operator*()
const {
71 assert(Map->Present.test(Index));
72 return Map->Buckets[Index];
77 using BaseT::operator++;
79 while (Index < Map->Buckets.size()) {
81 if (Map->Present.test(Index))
90 bool isEnd()
const {
return IsEnd; }
91 uint32_t index()
const {
return Index; }
93 const HashTable<ValueT> *Map;
98template <
typename ValueT>
105 using BucketList = std::vector<std::pair<uint32_t, ValueT>>;
120 if (
H->Capacity == 0)
122 "Invalid Hash Table Capacity");
123 if (
H->Size > maxLoad(
H->Capacity))
125 "Invalid Hash Table Size");
133 "Present bit vector does not match size!");
139 "Present bit vector intersects deleted!");
156 constexpr int BitsPerWord = 8 *
sizeof(
uint32_t);
193 for (
const auto &Entry : *
this) {
217 template <
typename Key,
typename TraitsT>
221 std::optional<uint32_t> FirstUnused;
224 if (Traits.storageKeyToLookupKey(
Buckets[
I].first) == K)
249 template <
typename Key,
typename TraitsT>
251 return set_as_internal(K, std::move(V), Traits, std::nullopt);
254 template <
typename Key,
typename TraitsT>
256 auto Iter =
find_as(K, Traits);
258 return (*Iter).second;
272 template <
typename Key,
typename TraitsT>
273 bool set_as_internal(
const Key &K,
ValueT V,
TraitsT &Traits,
274 std::optional<uint32_t> InternalKey) {
275 auto Entry =
find_as(K, Traits);
276 if (Entry !=
end()) {
278 assert(Traits.storageKeyToLookupKey(
Buckets[Entry.index()].first) == K);
280 Buckets[Entry.index()].second = V;
287 B.first = InternalKey ? *InternalKey : Traits.lookupKeyToStorageKey(K);
300 template <
typename TraitsT>
308 uint32_t NewCapacity = (
capacity() <= INT32_MAX) ? MaxLoad * 2 : UINT32_MAX;
315 auto LookupKey = Traits.storageKeyToLookupKey(
Buckets[
I].first);
316 NewMap.set_as_internal(LookupKey,
Buckets[
I].second, Traits,
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SparseBitVector class.
Provides read only access to a subclass of BinaryStream.
Error readObject(const T *&Dest)
Get a pointer to an object of type T from the underlying stream, as if by memcpy, and store the resul...
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
Provides write only access to a subclass of WritableBinaryStream.
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
bool test(unsigned Idx) const
bool intersects(const SparseBitVector< ElementSize > *RHS) const
LLVM Value Representation.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
HashTableIterator & operator++()
bool operator==(const HashTableIterator &R) const
HashTableIterator(const HashTable< ValueT > &Map)
const std::pair< uint32_t, ValueT > & operator*() const
HashTableIterator & operator=(const HashTableIterator &R)
HashTableIterator(const HashTableIterator &R)=default
Error load(BinaryStreamReader &Stream)
bool isDeleted(uint32_t K) const
bool set_as(const Key &K, ValueT V, TraitsT &Traits)
Set the entry using a key type that the specified Traits can convert from a real key to an internal k...
Error commit(BinaryStreamWriter &Writer) const
HashTableIterator< ValueT > const_iterator
const_iterator begin() const
ValueT get(const Key &K, TraitsT &Traits) const
uint32_t capacity() const
bool isPresent(uint32_t K) const
const_iterator find_as(const Key &K, TraitsT &Traits) const
Find the entry whose key has the specified hash value, using the specified traits defining hash funct...
const_iterator end() const
uint32_t calculateSerializedLength() const
HashTable(uint32_t Capacity)
Error readSparseBitVector(BinaryStreamReader &Stream, SparseBitVector<> &V)
Error writeSparseBitVector(BinaryStreamWriter &Writer, SparseBitVector<> &Vec)
This is an optimization pass for GlobalISel generic memory operations.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.