LLVM  14.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/DenseSet.h"
14 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/Support/Allocator.h"
21 #include <cstdint>
22 
23 namespace llvm {
24 namespace codeview {
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:70
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::codeview::MergingTypeTableBuilder::capacity
uint32_t capacity() override
Definition: MergingTypeTableBuilder.cpp:72
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:1168
Allocator.h
llvm::codeview::MergingTypeTableBuilder::getType
CVType getType(TypeIndex Index) override
Definition: MergingTypeTableBuilder.cpp:54
llvm::Optional
Definition: APInt.h:33
llvm::codeview::MergingTypeTableBuilder::replaceType
bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override
Definition: MergingTypeTableBuilder.cpp:127
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::codeview::MergingTypeTableBuilder::~MergingTypeTableBuilder
~MergingTypeTableBuilder()
SimpleTypeSerializer.h
llvm::codeview::MergingTypeTableBuilder::nextTypeIndex
TypeIndex nextTypeIndex() const
Definition: MergingTypeTableBuilder.cpp:30
llvm::codeview::TypeCollection
Definition: TypeCollection.h:18
DenseSet.h
CodeView.h
llvm::codeview::MergingTypeTableBuilder::insertRecordBytes
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)
Definition: MergingTypeTableBuilder.cpp:113
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:48
llvm::codeview::ContinuationRecordBuilder
Definition: ContinuationRecordBuilder.h:33
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
llvm::DenseMap
Definition: DenseMap.h:714
ArrayRef.h
llvm::Record
Definition: Record.h:1472
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:650
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
TypeHashing.h
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:63
llvm::codeview::MergingTypeTableBuilder::getTypeName
StringRef getTypeName(TypeIndex Index) override
Definition: MergingTypeTableBuilder.cpp:59
TypeCollection.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:35
SmallVector.h
llvm::codeview::MergingTypeTableBuilder::insertRecordAs
TypeIndex insertRecordAs(hash_code Hash, ArrayRef< uint8_t > &Record)
Definition: MergingTypeTableBuilder.cpp:90
llvm::codeview::MergingTypeTableBuilder::getFirst
Optional< TypeIndex > getFirst() override
Definition: MergingTypeTableBuilder.cpp:41
llvm::codeview::TypeIndex
A 32-bit type reference.
Definition: TypeIndex.h:96
llvm::codeview::MergingTypeTableBuilder::insertRecord
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
Definition: MergingTypeTableBuilder.cpp:118
llvm::codeview::MergingTypeTableBuilder::records
ArrayRef< ArrayRef< uint8_t > > records() const
Definition: MergingTypeTableBuilder.cpp:74
llvm::codeview::SimpleTypeSerializer
Definition: SimpleTypeSerializer.h:19
llvm::codeview::MergingTypeTableBuilder::reset
void reset()
Definition: MergingTypeTableBuilder.cpp:78
llvm::hash_code
An opaque object representing a hash code.
Definition: Hashing.h:73
llvm::codeview::MergingTypeTableBuilder::MergingTypeTableBuilder
MergingTypeTableBuilder(BumpPtrAllocator &Storage)
Definition: MergingTypeTableBuilder.cpp:34