LLVM  10.0.0svn
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 <cassert>
22 #include <cstdint>
23 #include <memory>
24 #include <vector>
25 
26 namespace llvm {
27 namespace codeview {
28 
29 class ContinuationRecordBuilder;
30 
32  /// Storage for records. These need to outlive the TypeTableBuilder.
33  BumpPtrAllocator &RecordStorage;
34 
35  /// A serializer that can write non-continuation leaf types. Only used as
36  /// a convenience function so that we can provide an interface method to
37  /// write an unserialized record.
38  SimpleTypeSerializer SimpleSerializer;
39 
40  /// Hash table.
42 
43  /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
44  SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
45 
46 public:
47  explicit MergingTypeTableBuilder(BumpPtrAllocator &Storage);
49 
50  // TypeTableCollection overrides
51  Optional<TypeIndex> getFirst() override;
52  Optional<TypeIndex> getNext(TypeIndex Prev) override;
53  CVType getType(TypeIndex Index) override;
54  StringRef getTypeName(TypeIndex Index) override;
55  bool contains(TypeIndex Index) override;
56  uint32_t size() override;
57  uint32_t capacity() override;
58 
59  // public interface
60  void reset();
61  TypeIndex nextTypeIndex() const;
62 
63  BumpPtrAllocator &getAllocator() { return RecordStorage; }
64 
66 
70 
71  template <typename T> TypeIndex writeLeafType(T &Record) {
72  ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record);
73  return insertRecordBytes(Data);
74  }
75 };
76 
77 } // end namespace codeview
78 } // end namespace llvm
79 
80 #endif // LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Optional< TypeIndex > getNext(TypeIndex Prev) override
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
CVType getType(TypeIndex Index) override
StringRef getTypeName(TypeIndex Index) override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
A 32-bit type reference.
Definition: TypeIndex.h:95
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:140
ArrayRef< uint8_t > serialize(T &Record)
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
An opaque object representing a hash code.
Definition: Hashing.h:71
Optional< TypeIndex > getFirst() override
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)
TypeIndex insertRecordAs(hash_code Hash, ArrayRef< uint8_t > &Record)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
ArrayRef< ArrayRef< uint8_t > > records() const