36 : Msf(Msf),
Allocator(Msf.getAllocator()), Header(nullptr), Idx(StreamIdx) {
48 size_t NewSize = TypeRecordBytes + Record.
size();
49 constexpr
size_t EightKB = 8 * 1024;
50 if (NewSize / EightKB > TypeRecordBytes / EightKB || TypeRecords.empty()) {
51 TypeIndexOffsets.push_back(
56 TypeRecordBytes = NewSize;
58 TypeRecords.push_back(Record);
60 TypeHashes.push_back(*Hash);
63 Error TpiStreamBuilder::finalize() {
104 uint32_t TpiStreamBuilder::calculateHashBufferSize()
const {
105 assert((TypeRecords.size() == TypeHashes.size() || TypeHashes.empty()) &&
106 "either all or no type records should have hashes");
110 uint32_t TpiStreamBuilder::calculateIndexOffsetSize()
const {
120 calculateHashBufferSize() + calculateIndexOffsetSize();
122 if (HashStreamSize == 0)
125 auto ExpectedIndex = Msf.
addStream(HashStreamSize);
127 return ExpectedIndex.takeError();
128 HashStreamIndex = *ExpectedIndex;
129 if (!TypeHashes.empty()) {
136 reinterpret_cast<const uint8_t *>(HashBuffer.data()),
137 calculateHashBufferSize());
146 if (
auto EC = finalize())
149 auto InfoS = WritableMappedBlockStream::createIndexedStream(Layout, Buffer,
156 for (
auto Rec : TypeRecords)
161 auto HVS = WritableMappedBlockStream::createIndexedStream(
162 Layout, Buffer, HashStreamIndex, Allocator);
164 if (HashValueStream) {
169 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.
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
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.
const uint32_t MinTpiHashBuckets
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()
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.