LLVM  15.0.0git
MergingTypeTableBuilder.h
Go to the documentation of this file.
1 //===- MergingTypeTableBuilder.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_MERGINGTYPETABLEBUILDER_H
10 #define LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
11 
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/Support/Allocator.h"
20 #include <cstdint>
21 
22 namespace llvm {
23 namespace codeview {
24 struct LocallyHashedType;
25 
26 class ContinuationRecordBuilder;
27 
29  /// Storage for records. These need to outlive the TypeTableBuilder.
30  BumpPtrAllocator &RecordStorage;
31 
32  /// A serializer that can write non-continuation leaf types. Only used as
33  /// a convenience function so that we can provide an interface method to
34  /// write an unserialized record.
35  SimpleTypeSerializer SimpleSerializer;
36 
37  /// Hash table.
39 
40  /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
41  SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
42 
43 public:
44  explicit MergingTypeTableBuilder(BumpPtrAllocator &Storage);
46 
47  // TypeCollection overrides
48  Optional<TypeIndex> getFirst() override;
49  Optional<TypeIndex> getNext(TypeIndex Prev) override;
50  CVType getType(TypeIndex Index) override;
52  bool contains(TypeIndex Index) override;
53  uint32_t size() override;
54  uint32_t capacity() override;
55  bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override;
56 
57  // public interface
58  void reset();
59  TypeIndex nextTypeIndex() const;
60 
61  BumpPtrAllocator &getAllocator() { return RecordStorage; }
62 
64 
68 
69  template <typename T> TypeIndex writeLeafType(T &Record) {
70  ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record);
71  return insertRecordBytes(Data);
72  }
73 };
74 
75 } // end namespace codeview
76 } // end namespace llvm
77 
78 #endif // LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
llvm::codeview::MergingTypeTableBuilder::size
uint32_t size() override
Definition: MergingTypeTableBuilder.cpp:65
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::codeview::MergingTypeTableBuilder::capacity
uint32_t capacity() override
Definition: MergingTypeTableBuilder.cpp:67
llvm::codeview::MergingTypeTableBuilder
Definition: MergingTypeTableBuilder.h:28
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1185
Allocator.h
llvm::codeview::MergingTypeTableBuilder::getType
CVType getType(TypeIndex Index) override
Definition: MergingTypeTableBuilder.cpp:49
DenseMap.h
llvm::Optional
Definition: APInt.h:33
llvm::codeview::MergingTypeTableBuilder::replaceType
bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override
Definition: MergingTypeTableBuilder.cpp:122
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::codeview::MergingTypeTableBuilder::~MergingTypeTableBuilder
~MergingTypeTableBuilder()
SimpleTypeSerializer.h
llvm::codeview::MergingTypeTableBuilder::nextTypeIndex
TypeIndex nextTypeIndex() const
Definition: MergingTypeTableBuilder.cpp:25
llvm::codeview::TypeCollection
Definition: TypeCollection.h:18
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::codeview::MergingTypeTableBuilder::insertRecordBytes
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)
Definition: MergingTypeTableBuilder.cpp:108
llvm::codeview::MergingTypeTableBuilder::writeLeafType
TypeIndex writeLeafType(T &Record)
Definition: MergingTypeTableBuilder.h:69
llvm::codeview::MergingTypeTableBuilder::getNext
Optional< TypeIndex > getNext(TypeIndex Prev) override
Definition: MergingTypeTableBuilder.cpp:43
llvm::codeview::ContinuationRecordBuilder
Definition: ContinuationRecordBuilder.h:27
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:63
llvm::DenseMap
Definition: DenseMap.h:716
ArrayRef.h
llvm::Record
Definition: Record.h:1543
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::codeview::CVRecord< TypeLeafKind >
uint32_t
llvm::codeview::MergingTypeTableBuilder::contains
bool contains(TypeIndex Index) override
Definition: MergingTypeTableBuilder.cpp:58
llvm::codeview::MergingTypeTableBuilder::getTypeName
StringRef getTypeName(TypeIndex Index) override
Definition: MergingTypeTableBuilder.cpp:54
TypeCollection.h
CVRecord.h
llvm::codeview::MergingTypeTableBuilder::getAllocator
BumpPtrAllocator & getAllocator()
Definition: MergingTypeTableBuilder.h:61
TypeIndex.h
llvm::codeview::SimpleTypeSerializer::serialize
ArrayRef< uint8_t > serialize(T &Record)
Definition: SimpleTypeSerializer.cpp:36
SmallVector.h
llvm::codeview::MergingTypeTableBuilder::insertRecordAs
TypeIndex insertRecordAs(hash_code Hash, ArrayRef< uint8_t > &Record)
Definition: MergingTypeTableBuilder.cpp:85
llvm::codeview::MergingTypeTableBuilder::getFirst
Optional< TypeIndex > getFirst() override
Definition: MergingTypeTableBuilder.cpp:36
llvm::codeview::TypeIndex
A 32-bit type reference.
Definition: TypeIndex.h:96
llvm::codeview::MergingTypeTableBuilder::insertRecord
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
Definition: MergingTypeTableBuilder.cpp:113
llvm::codeview::MergingTypeTableBuilder::records
ArrayRef< ArrayRef< uint8_t > > records() const
Definition: MergingTypeTableBuilder.cpp:69
llvm::codeview::SimpleTypeSerializer
Definition: SimpleTypeSerializer.h:19
llvm::codeview::MergingTypeTableBuilder::reset
void reset()
Definition: MergingTypeTableBuilder.cpp:73
llvm::hash_code
An opaque object representing a hash code.
Definition: Hashing.h:73
llvm::codeview::MergingTypeTableBuilder::MergingTypeTableBuilder
MergingTypeTableBuilder(BumpPtrAllocator &Storage)
Definition: MergingTypeTableBuilder.cpp:29