1 //===- TypeStreamMerger.h ---------------------------------------*- 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_CODEVIEW_TYPESTREAMMERGER_H 10 #define LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H 11 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" 16 17 namespace llvm { 18 namespace codeview { 19 20 class TypeIndex; 21 struct GloballyHashedType; 22 class GlobalTypeTableBuilder; 23 class MergingTypeTableBuilder; 24 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. 27 /// 28 /// \param Dest The table to store the re-written type records into. 29 /// 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. 33 /// 34 /// \param Types The collection of types to merge in. 35 /// 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); 41 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. 49 /// 50 /// \param Dest The table to store the re-written id records into. 51 /// 52 /// \param Types The mapping to use for the type records that these id 53 /// records refer to. 54 /// 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. 58 /// 59 /// \param Ids The collection of id records to merge in. 60 /// 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); 66 67 /// Merge a unified set of type and id records, splitting them into 68 /// separate output streams. 69 /// 70 /// \param DestIds The table to store the re-written id records into. 71 /// 72 /// \param DestTypes the table to store the re-written type records into. 73 /// 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. 77 /// 78 /// \param IdsAndTypes The collection of id records to merge in. 79 /// 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); 87 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); 94 95 Error mergeTypeRecords(GlobalTypeTableBuilder &Dest, 96 SmallVectorImpl<TypeIndex> &SourceToDest, 97 const CVTypeArray &Types, 98 ArrayRef<GloballyHashedType> Hashes, 99 Optional<uint32_t> &PCHSignature); 100 101 Error mergeIdRecords(GlobalTypeTableBuilder &Dest, ArrayRef<TypeIndex> Types, 102 SmallVectorImpl<TypeIndex> &SourceToDest, 103 const CVTypeArray &Ids, 104 ArrayRef<GloballyHashedType> Hashes); 105 106 } // end namespace codeview 107 } // end namespace llvm 108 109 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPESTREAMMERGER_H 110