9#ifndef LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_HASHTABLE_H
30 SparseBitVector<> &V);
32 SparseBitVector<> &Vec);
34template <
typename ValueT>
class HashTable;
36template <
typename ValueT>
37class HashTableIterator
39 std::forward_iterator_tag,
40 const std::pair<uint32_t, ValueT>> {
41 using BaseT =
typename HashTableIterator::iterator_facade_base;
46 : Map(&Map), Index(Index), IsEnd(IsEnd) {}
50 int I = Map.Present.find_first();
61 HashTableIterator &
operator=(
const HashTableIterator &R) {
71 return (Map == R.Map) && (Index == R.Index);
73 const std::pair<uint32_t, ValueT> &
operator*()
const {
74 assert(Map->Present.test(Index));
75 return Map->Buckets[Index];
80 using BaseT::operator++;
82 while (Index < Map->Buckets.size()) {
84 if (Map->Present.test(Index))
93 bool isEnd()
const {
return IsEnd; }
94 uint32_t index()
const {
return Index; }
96 const HashTable<ValueT> *Map;
101template <
typename ValueT>
108 using BucketList = std::vector<std::pair<uint32_t, ValueT>>;
123 if (
H->Capacity == 0)
125 "Invalid Hash Table Capacity");
126 if (
H->Size > maxLoad(
H->Capacity))
128 "Invalid Hash Table Size");
136 "Present bit vector does not match size!");
142 "Present bit vector intersects deleted!");
159 constexpr int BitsPerWord = 8 *
sizeof(
uint32_t);
161 int NumBitsP =
Present.find_last() + 1;
162 int NumBitsD =
Deleted.find_last() + 1;
196 for (
const auto &Entry : *
this) {
220 template <
typename Key,
typename TraitsT>
224 std::optional<uint32_t> FirstUnused;
227 if (Traits.storageKeyToLookupKey(
Buckets[
I].first) == K)
252 template <
typename Key,
typename TraitsT>
254 return set_as_internal(K, std::move(V), Traits, std::nullopt);
257 template <
typename Key,
typename TraitsT>
259 auto Iter =
find_as(K, Traits);
261 return (*Iter).second;
275 template <
typename Key,
typename TraitsT>
276 bool set_as_internal(
const Key &K, ValueT V,
TraitsT &Traits,
277 std::optional<uint32_t> InternalKey) {
278 auto Entry =
find_as(K, Traits);
279 if (Entry !=
end()) {
281 assert(Traits.storageKeyToLookupKey(
Buckets[Entry.index()].first) == K);
283 Buckets[Entry.index()].second = V;
290 B.first = InternalKey ? *InternalKey : Traits.lookupKeyToStorageKey(K);
303 template <
typename TraitsT>
311 uint32_t NewCapacity = (
capacity() <= INT32_MAX) ? MaxLoad * 2 : UINT32_MAX;
318 auto LookupKey = Traits.storageKeyToLookupKey(
Buckets[
I].first);
319 NewMap.set_as_internal(LookupKey,
Buckets[
I].second, Traits,
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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.
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)
LLVM_ABI Error readSparseBitVector(BinaryStreamReader &Stream, SparseBitVector<> &V)
LLVM_ABI Error writeSparseBitVector(BinaryStreamWriter &Writer, SparseBitVector<> &Vec)
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
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.