LLVM 22.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"
21#include <cstdint>
22
23namespace llvm {
24namespace codeview {
25struct LocallyHashedType;
26
27class ContinuationRecordBuilder;
28
30 /// Storage for records. These need to outlive the TypeTableBuilder.
31 BumpPtrAllocator &RecordStorage;
32
33 /// A serializer that can write non-continuation leaf types. Only used as
34 /// a convenience function so that we can provide an interface method to
35 /// write an unserialized record.
36 SimpleTypeSerializer SimpleSerializer;
37
38 /// Hash table.
40
41 /// Contains a list of all records indexed by TypeIndex.toArrayIndex().
42 SmallVector<ArrayRef<uint8_t>, 2> SeenRecords;
43
44public:
47
48 // TypeCollection overrides
49 std::optional<TypeIndex> getFirst() override;
50 std::optional<TypeIndex> getNext(TypeIndex Prev) override;
51 CVType getType(TypeIndex Index) override;
53 bool contains(TypeIndex Index) override;
54 uint32_t size() override;
55 uint32_t capacity() override;
56 bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override;
57
58 // public interface
59 void reset();
60 TypeIndex nextTypeIndex() const;
61
62 BumpPtrAllocator &getAllocator() { return RecordStorage; }
63
64 ArrayRef<ArrayRef<uint8_t>> records() const;
65
66 TypeIndex insertRecordAs(hash_code Hash, ArrayRef<uint8_t> &Record);
67 TypeIndex insertRecordBytes(ArrayRef<uint8_t> &Record);
68 TypeIndex insertRecord(ContinuationRecordBuilder &Builder);
69
70 template <typename T> TypeIndex writeLeafType(T &Record) {
71 ArrayRef<uint8_t> Data = SimpleSerializer.serialize(Record);
72 return insertRecordBytes(Data);
73 }
74};
75
76} // end namespace codeview
77} // end namespace llvm
78
79#endif // LLVM_DEBUGINFO_CODEVIEW_MERGINGTYPETABLEBUILDER_H
This file defines the BumpPtrAllocator interface.
#define LLVM_ABI
Definition: Compiler.h:213
static std::string getTypeName(OverloadKind Kind, Type *Ty)
This file defines the DenseMap class.
uint32_t Index
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition: Value.cpp:480
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
Definition: TapiFile.cpp:39
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
ArrayRef< uint8_t > serialize(T &Record)
A 32-bit type reference.
Definition: TypeIndex.h:97
An opaque object representing a hash code.
Definition: Hashing.h:76
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1702