LLVM 19.0.0git
AppendingTypeTableBuilder.cpp
Go to the documentation of this file.
1//===- AppendingTypeTableBuilder.cpp --------------------------------------===//
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
10#include "llvm/ADT/ArrayRef.h"
16#include <cassert>
17#include <cstdint>
18#include <cstring>
19
20using namespace llvm;
21using namespace llvm::codeview;
22
24 return TypeIndex::fromArrayIndex(SeenRecords.size());
25}
26
28 : RecordStorage(Storage) {}
29
31
32std::optional<TypeIndex> AppendingTypeTableBuilder::getFirst() {
33 if (empty())
34 return std::nullopt;
35
37}
38
39std::optional<TypeIndex> AppendingTypeTableBuilder::getNext(TypeIndex Prev) {
40 if (++Prev == nextTypeIndex())
41 return std::nullopt;
42 return Prev;
43}
44
46 return CVType(SeenRecords[Index.toArrayIndex()]);
47}
48
50 llvm_unreachable("Method not implemented");
51}
52
54 if (Index.isSimple() || Index.isNoneType())
55 return false;
56
57 return Index.toArrayIndex() < SeenRecords.size();
58}
59
60uint32_t AppendingTypeTableBuilder::size() { return SeenRecords.size(); }
61
62uint32_t AppendingTypeTableBuilder::capacity() { return SeenRecords.size(); }
63
65 return SeenRecords;
66}
67
68void AppendingTypeTableBuilder::reset() { SeenRecords.clear(); }
69
72 uint8_t *Stable = RecordStorage.Allocate<uint8_t>(Record.size());
73 memcpy(Stable, Record.data(), Record.size());
74 return ArrayRef<uint8_t>(Stable, Record.size());
75}
76
79 TypeIndex NewTI = nextTypeIndex();
80 Record = stabilize(RecordStorage, Record);
81 SeenRecords.push_back(Record);
82 return NewTI;
83}
84
87 TypeIndex TI;
88 auto Fragments = Builder.end(nextTypeIndex());
89 assert(!Fragments.empty());
90 for (auto C : Fragments)
91 TI = insertRecordBytes(C.RecordData);
92 return TI;
93}
94
96 bool Stabilize) {
97 assert(Index.toArrayIndex() < SeenRecords.size() &&
98 "This function cannot be used to insert records!");
99
101 if (Stabilize)
102 Record = stabilize(RecordStorage, Record);
103 SeenRecords[Index.toArrayIndex()] = Record;
104 return true;
105}
This file defines the BumpPtrAllocator interface.
static ArrayRef< uint8_t > stabilize(BumpPtrAllocator &RecordStorage, ArrayRef< uint8_t > Record)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:148
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
std::optional< TypeIndex > getFirst() override
std::optional< TypeIndex > getNext(TypeIndex Prev) override
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)
bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override
StringRef getTypeName(TypeIndex Index) override
ArrayRef< ArrayRef< uint8_t > > records() const
std::vector< CVType > end(TypeIndex Index)
A 32-bit type reference.
Definition: TypeIndex.h:96
static TypeIndex fromArrayIndex(uint32_t Index)
Definition: TypeIndex.h:123
static const uint32_t FirstNonSimpleIndex
Definition: TypeIndex.h:98
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
CVRecord< TypeLeafKind > CVType
Definition: CVRecord.h:64
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18