LLVM 20.0.0git
TpiStreamBuilder.h
Go to the documentation of this file.
1//===- TpiStreamBuilder.h - PDB Tpi Stream Creation -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_PDB_NATIVE_TPISTREAMBUILDER_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_TPISTREAMBUILDER_H
11
17#include "llvm/Support/Error.h"
18
19#include <vector>
20
21namespace llvm {
22class BinaryByteStream;
23template <typename T> struct BinaryItemTraits;
24
26 static size_t length(const codeview::CVType &Item) { return Item.length(); }
28 return Item.data();
29 }
30};
31
32namespace msf {
33class MSFBuilder;
34struct MSFLayout;
35}
36namespace pdb {
37struct TpiStreamHeader;
38
40public:
41 explicit TpiStreamBuilder(msf::MSFBuilder &Msf, uint32_t StreamIdx);
43
46
48 void addTypeRecord(ArrayRef<uint8_t> Type, std::optional<uint32_t> Hash);
50 ArrayRef<uint32_t> Hashes);
51
53
54 uint32_t getRecordCount() const { return TypeRecordCount; }
55
57
59
60private:
61 void updateTypeIndexOffsets(ArrayRef<uint16_t> Sizes);
62
63 uint32_t calculateHashBufferSize() const;
64 uint32_t calculateIndexOffsetSize() const;
65 Error finalize();
66
67 msf::MSFBuilder &Msf;
68 BumpPtrAllocator &Allocator;
69
70 uint32_t TypeRecordCount = 0;
71 size_t TypeRecordBytes = 0;
72
74 std::vector<ArrayRef<uint8_t>> TypeRecBuffers;
75 std::vector<uint32_t> TypeHashes;
76 std::vector<codeview::TypeIndexOffset> TypeIndexOffsets;
77 uint32_t HashStreamIndex = kInvalidStreamIndex;
78 std::unique_ptr<BinaryByteStream> HashValueStream;
79
80 const TpiStreamHeader *Header;
81 uint32_t Idx;
82};
83} // namespace pdb
84}
85
86#endif
This file defines the BumpPtrAllocator interface.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
ArrayRef< uint8_t > data() const
Definition: CVRecord.h:49
uint32_t length() const
Definition: CVRecord.h:40
uint32_t getRecordCount() const
TpiStreamBuilder & operator=(const TpiStreamBuilder &)=delete
void addTypeRecord(ArrayRef< uint8_t > Type, std::optional< uint32_t > Hash)
Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer)
void addTypeRecords(ArrayRef< uint8_t > Types, ArrayRef< uint16_t > Sizes, ArrayRef< uint32_t > Hashes)
TpiStreamBuilder(const TpiStreamBuilder &)=delete
void setVersionHeader(PdbRaw_TpiVer Version)
const uint16_t kInvalidStreamIndex
Definition: RawConstants.h:19
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
static ArrayRef< uint8_t > bytes(const codeview::CVType &Item)
static size_t length(const codeview::CVType &Item)