LLVM 19.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"
20#include <cstdint>
21
22namespace llvm {
23namespace codeview {
24struct LocallyHashedType;
25
26class 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
43public:
46
47 // TypeCollection overrides
48 std::optional<TypeIndex> getFirst() override;
49 std::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();
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
This file defines the BumpPtrAllocator interface.
This file defines the DenseMap class.
This file defines the SmallVector class.
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:66
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
CVType getType(TypeIndex Index) override
ArrayRef< ArrayRef< uint8_t > > records() const
std::optional< TypeIndex > getFirst() override
std::optional< TypeIndex > getNext(TypeIndex Prev) override
TypeIndex insertRecordAs(hash_code Hash, ArrayRef< uint8_t > &Record)
bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)
ArrayRef< uint8_t > serialize(T &Record)
A 32-bit type reference.
Definition: TypeIndex.h:96
An opaque object representing a hash code.
Definition: Hashing.h:74
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.
Definition: TypeName.h:27