9 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H 10 #define LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H 26 class BinaryStreamReader;
27 class BinaryStreamWriter;
36 template <
typename ValueT>
39 std::forward_iterator_tag,
40 const std::pair<uint32_t, ValueT>> {
45 : Map(&Map), Index(Index), IsEnd(IsEnd) {}
49 int I = Map.Present.find_first();
54 Index = static_cast<uint32_t>(
I);
70 return (Map == R.Map) && (Index == R.Index);
72 const std::pair<uint32_t, ValueT> &
operator*()
const {
73 assert(Map->Present.test(Index));
74 return Map->Buckets[Index];
80 std::forward_iterator_tag,
81 const std::pair<uint32_t, ValueT>>::operator++;
83 while (Index < Map->Buckets.size()) {
85 if (Map->Present.test(Index))
94 bool isEnd()
const {
return IsEnd; }
95 uint32_t index()
const {
return Index; }
97 const HashTable<ValueT> *Map;
102 template <
typename ValueT>
109 using BucketList = std::vector<std::pair<uint32_t, ValueT>>;
124 if (
H->Capacity == 0)
126 "Invalid Hash Table Capacity");
127 if (
H->Size > maxLoad(
H->Capacity))
129 "Invalid Hash Table Size");
137 "Present bit vector does not match size!");
143 "Present bit vector intersects deleted!");
160 constexpr
int BitsPerWord = 8 *
sizeof(
uint32_t);
197 for (
const auto &Entry : *
this) {
221 template <
typename Key,
typename TraitsT>
228 if (Traits.storageKeyToLookupKey(
Buckets[
I].first) == K)
253 template <
typename Key,
typename TraitsT>
258 template <
typename Key,
typename TraitsT>
260 auto Iter =
find_as(K, Traits);
262 return (*Iter).second;
276 template <
typename Key,
typename TraitsT>
279 auto Entry =
find_as(K, Traits);
280 if (Entry !=
end()) {
282 assert(Traits.storageKeyToLookupKey(
Buckets[Entry.index()].first) == K);
284 Buckets[Entry.index()].second = V;
291 B.first = InternalKey ? *InternalKey : Traits.lookupKeyToStorageKey(K);
304 template <
typename TraitsT>
312 uint32_t NewCapacity = (
capacity() <= INT32_MAX) ? MaxLoad * 2 : UINT32_MAX;
319 auto LookupKey = Traits.storageKeyToLookupKey(
Buckets[
I].first);
320 NewMap.set_as_internal(LookupKey,
Buckets[
I].second, Traits,
336 #endif // LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
HashTableIterator & operator++()
This class represents lattice values for constants.
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 writeSparseBitVector(BinaryStreamWriter &Writer, SparseBitVector<> &Vec)
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
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...
HashTableIterator & operator=(const HashTableIterator &R)
bool test(unsigned Idx) const
const std::pair< uint32_t, ValueT > & operator *() const
uint32_t calculateSerializedLength() const
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
HashTableIterator< ValueT > const_iterator
Error readSparseBitVector(BinaryStreamReader &Stream, SparseBitVector<> &V)
const_iterator begin() const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
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...
Provides write only access to a subclass of WritableBinaryStream.
Error commit(BinaryStreamWriter &Writer) const
HashTableIterator(const HashTable< ValueT > &Map)
ValueT get(const Key &K, TraitsT &Traits) const
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
bool operator==(const HashTableIterator &R) const
static ErrorSuccess success()
Create a success value.
bool isDeleted(uint32_t K) const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Error load(BinaryStreamReader &Stream)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
const_iterator end() const
bool isPresent(uint32_t K) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint32_t capacity() const
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Provides read only access to a subclass of BinaryStream.
HashTable(uint32_t Capacity)
bool intersects(const SparseBitVector< ElementSize > *RHS) const