LLVM  6.0.0svn
TypeTableBuilder.h
Go to the documentation of this file.
1 //===- TypeTableBuilder.h ----------------------------------------*- C++-*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
11 #define LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
12 
13 #include "llvm/ADT/ArrayRef.h"
14 #include "llvm/ADT/Optional.h"
15 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/Support/Allocator.h"
22 #include "llvm/Support/Error.h"
23 #include <cassert>
24 #include <cstdint>
25 #include <memory>
26 #include <vector>
27 
28 namespace llvm {
29 namespace codeview {
30 
31 class ContinuationRecordBuilder;
32 class TypeHasher;
33 
35 
36  BumpPtrAllocator &RecordStorage;
37  SimpleTypeSerializer SimpleSerializer;
38 
39  /// Private type record hashing implementation details are handled here.
40  std::unique_ptr<TypeHasher> Hasher;
41 
42  /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
43  SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
44 
45 public:
46  explicit TypeTableBuilder(BumpPtrAllocator &Storage, bool Hash = true);
48 
49  // TypeTableCollection overrides
50  Optional<TypeIndex> getFirst() override;
51  Optional<TypeIndex> getNext(TypeIndex Prev) override;
52  CVType getType(TypeIndex Index) override;
53  StringRef getTypeName(TypeIndex Index) override;
54  bool contains(TypeIndex Index) override;
55  uint32_t size() override;
56  uint32_t capacity() override;
57 
58  // public interface
59  void reset();
60  TypeIndex nextTypeIndex() const;
61 
62  BumpPtrAllocator &getAllocator() { return RecordStorage; }
63 
67 
68  template <typename T> TypeIndex writeLeafType(T &Record) {
69  ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record);
70  return insertRecordBytes(Data);
71  }
72 };
73 
74 } // end namespace codeview
75 } // end namespace llvm
76 
77 #endif // LLVM_DEBUGINFO_CODEVIEW_TYPETABLEBUILDER_H
TypeTableBuilder(BumpPtrAllocator &Storage, bool Hash=true)
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Optional< TypeIndex > getNext(TypeIndex Prev) override
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
Optional< TypeIndex > getFirst() override
bool contains(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:33
A 32-bit type reference.
Definition: TypeIndex.h:96
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:138
ArrayRef< uint8_t > serialize(T &Record)
ArrayRef< ArrayRef< uint8_t > > records() const
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
CVType getType(TypeIndex Index) override
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:864
BumpPtrAllocator & getAllocator()
TypeIndex writeLeafType(T &Record)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)