1 //===- TypeStreamMerger.h ---------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H
10 #define LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
15 #include "llvm/Support/Error.h"
21 struct GloballyHashedType
;
22 class GlobalTypeTableBuilder
;
23 class MergingTypeTableBuilder
;
25 /// Merge one set of type records into another. This method assumes
26 /// that all records are type records, and there are no Id records present.
28 /// \param Dest The table to store the re-written type records into.
30 /// \param SourceToDest A vector, indexed by the TypeIndex in the source
31 /// type stream, that contains the index of the corresponding type record
32 /// in the destination stream.
34 /// \param Types The collection of types to merge in.
36 /// \returns Error::success() if the operation succeeded, otherwise an
37 /// appropriate error code.
38 Error
mergeTypeRecords(MergingTypeTableBuilder
&Dest
,
39 SmallVectorImpl
<TypeIndex
> &SourceToDest
,
40 const CVTypeArray
&Types
);
42 /// Merge one set of id records into another. This method assumes
43 /// that all records are id records, and there are no Type records present.
44 /// However, since Id records can refer back to Type records, this method
45 /// assumes that the referenced type records have also been merged into
46 /// another type stream (for example using the above method), and accepts
47 /// the mapping from source to dest for that stream so that it can re-write
48 /// the type record mappings accordingly.
50 /// \param Dest The table to store the re-written id records into.
52 /// \param Types The mapping to use for the type records that these id
55 /// \param SourceToDest A vector, indexed by the TypeIndex in the source
56 /// id stream, that contains the index of the corresponding id record
57 /// in the destination stream.
59 /// \param Ids The collection of id records to merge in.
61 /// \returns Error::success() if the operation succeeded, otherwise an
62 /// appropriate error code.
63 Error
mergeIdRecords(MergingTypeTableBuilder
&Dest
, ArrayRef
<TypeIndex
> Types
,
64 SmallVectorImpl
<TypeIndex
> &SourceToDest
,
65 const CVTypeArray
&Ids
);
67 /// Merge a unified set of type and id records, splitting them into
68 /// separate output streams.
70 /// \param DestIds The table to store the re-written id records into.
72 /// \param DestTypes the table to store the re-written type records into.
74 /// \param SourceToDest A vector, indexed by the TypeIndex in the source
75 /// id stream, that contains the index of the corresponding id record
76 /// in the destination stream.
78 /// \param IdsAndTypes The collection of id records to merge in.
80 /// \returns Error::success() if the operation succeeded, otherwise an
81 /// appropriate error code.
82 Error
mergeTypeAndIdRecords(MergingTypeTableBuilder
&DestIds
,
83 MergingTypeTableBuilder
&DestTypes
,
84 SmallVectorImpl
<TypeIndex
> &SourceToDest
,
85 const CVTypeArray
&IdsAndTypes
,
86 Optional
<uint32_t> &PCHSignature
);
88 Error
mergeTypeAndIdRecords(GlobalTypeTableBuilder
&DestIds
,
89 GlobalTypeTableBuilder
&DestTypes
,
90 SmallVectorImpl
<TypeIndex
> &SourceToDest
,
91 const CVTypeArray
&IdsAndTypes
,
92 ArrayRef
<GloballyHashedType
> Hashes
,
93 Optional
<uint32_t> &PCHSignature
);
95 Error
mergeTypeRecords(GlobalTypeTableBuilder
&Dest
,
96 SmallVectorImpl
<TypeIndex
> &SourceToDest
,
97 const CVTypeArray
&Types
,
98 ArrayRef
<GloballyHashedType
> Hashes
,
99 Optional
<uint32_t> &PCHSignature
);
101 Error
mergeIdRecords(GlobalTypeTableBuilder
&Dest
, ArrayRef
<TypeIndex
> Types
,
102 SmallVectorImpl
<TypeIndex
> &SourceToDest
,
103 const CVTypeArray
&Ids
,
104 ArrayRef
<GloballyHashedType
> Hashes
);
106 } // end namespace codeview
107 } // end namespace llvm
109 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H