23 using namespace llvm::pdb;
35 "Invalid Hash Table Capacity");
36 if (H->Size > maxLoad(H->Capacity))
37 return make_error<RawError>(raw_error_code::corrupt_file,
38 "Invalid Hash Table Size");
42 if (
auto EC = readSparseBitVector(Stream,
Present))
45 return make_error<RawError>(raw_error_code::corrupt_file,
46 "Present bit vector does not match size!");
48 if (
auto EC = readSparseBitVector(Stream,
Deleted))
51 return make_error<RawError>(raw_error_code::corrupt_file,
52 "Present bit vector interesects deleted!");
91 if (
auto EC = writeSparseBitVector(Writer,
Present))
94 if (
auto EC = writeSparseBitVector(Writer,
Deleted))
97 for (
const auto &Entry : *
this) {
152 auto Entry =
find(K);
153 if (Entry !=
end()) {
157 Buckets[Entry.index()].second = V;
192 uint32_t HashTable::maxLoad(
uint32_t capacity) {
return capacity * 2 / 3 + 1; }
194 void HashTable::grow() {
225 "Expected hash table number of words"));
232 "Expected hash table word"));
233 for (
unsigned Idx = 0; Idx < 32; ++Idx)
234 if (Word & (1U << Idx))
235 V.
set((
I * 32) + Idx);
248 "Could not write linear map number of words"));
253 for (
uint32_t WordIdx = 0; WordIdx < 32; ++WordIdx, ++Idx) {
255 Word |= (1 << WordIdx);
258 return joinErrors(std::move(EC), make_error<RawError>(
260 "Could not write linear map word"));
267 : Map(&Map), Index(Index), IsEnd(IsEnd) {}
269 HashTableIterator::HashTableIterator(
const HashTable &Map) : Map(&Map) {
286 if (IsEnd && R.IsEnd)
288 if (IsEnd != R.IsEnd)
291 return (Map == R.Map) && (Index == R.Index);
300 while (Index < Map->Buckets.size()) {
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
uint32_t calculateSerializedLength() const
HashTableIterator end() const
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
HashTableIterator & operator++()
bool isPresent(uint32_t K) const
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...
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
const std::pair< uint32_t, uint32_t > & operator*() const
Error commit(BinaryStreamWriter &Writer) const
support::ulittle32_t Word
friend class HashTableIterator
void set(uint32_t K, uint32_t V)
HashTableIterator begin() const
bool isDeleted(uint32_t K) const
HashTableIterator find(uint32_t K)
bool operator==(const HashTableIterator &R) const
Provides write only access to a subclass of WritableBinaryStream.
Error writeInteger(T Value)
Write the the integer Value to the underlying stream in the specified endianness. ...
uint32_t capacity() const
HashTableIterator & operator=(const HashTableIterator &R)
Error load(BinaryStreamReader &Stream)
static ErrorSuccess success()
Create a success value.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
bool intersects(const SparseBitVector< ElementSize > *RHS) const
Error joinErrors(Error E1, Error E2)
Concatenate errors.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Provides read only access to a subclass of BinaryStream.