35 : Msf(Msf),
Allocator(Msf.getAllocator()), Header(nullptr), Idx(StreamIdx) {
47 size_t NewSize = TypeRecordBytes + Record.
size();
48 constexpr
size_t EightKB = 8 * 1024;
49 if (NewSize / EightKB > TypeRecordBytes / EightKB || TypeRecords.empty()) {
50 TypeIndexOffsets.push_back(
55 TypeRecordBytes = NewSize;
57 TypeRecords.push_back(Record);
59 TypeHashes.push_back(*Hash);
62 Error TpiStreamBuilder::finalize() {
103 uint32_t TpiStreamBuilder::calculateHashBufferSize()
const {
104 assert((TypeRecords.size() == TypeHashes.size() || TypeHashes.empty()) &&
105 "either all or no type records should have hashes");
109 uint32_t TpiStreamBuilder::calculateIndexOffsetSize()
const {
119 calculateHashBufferSize() + calculateIndexOffsetSize();
121 if (HashStreamSize == 0)
124 auto ExpectedIndex = Msf.
addStream(HashStreamSize);
126 return ExpectedIndex.takeError();
127 HashStreamIndex = *ExpectedIndex;
128 if (!TypeHashes.empty()) {
135 reinterpret_cast<const uint8_t *>(HashBuffer.data()),
136 calculateHashBufferSize());
145 if (
auto EC = finalize())
148 auto InfoS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer,
155 for (
auto Rec : TypeRecords) {
163 auto HVS = WritableMappedBlockStream::createIndexedStream(
164 Layout, Buffer, HashStreamIndex, Allocator);
166 if (HashValueStream) {
171 for (
auto &IndexOffset : TypeIndexOffsets) {
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
This class represents lattice values for constants.
Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
static const uint32_t FirstNonSimpleIndex
const uint16_t kInvalidStreamIndex
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
detail::packed_endian_specific_integral< uint32_t, little, unaligned > ulittle32_t
size_t size() const
size - Get the array size.
Error writeStreamRef(BinaryStreamRef Ref)
Efficiently reads all data from Ref, and writes it to this stream.
Provides write only access to a subclass of WritableBinaryStream.
Error setStreamSize(uint32_t Idx, uint32_t Size)
Update the size of an existing stream.
static ErrorSuccess success()
Create a success value.
Expected< uint32_t > addStream(uint32_t Size, ArrayRef< uint32_t > Blocks)
Add a stream to the MSF file with the given size, occupying the given list of blocks.
void setVersionHeader(PdbRaw_TpiVer Version)
uint32_t calculateSerializedLength()
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Error finalizeMsfLayout()
void addTypeRecord(ArrayRef< uint8_t > Type, Optional< uint32_t > Hash)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
const uint32_t MaxTpiHashBuckets