LLVM  14.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"
11 #include "llvm/ADT/DenseSet.h"
12 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/Support/Allocator.h"
20 #include "llvm/Support/Endian.h"
21 #include "llvm/Support/Error.h"
22 #include <algorithm>
23 #include <cassert>
24 #include <cstdint>
25 #include <cstring>
26 
27 using namespace llvm;
28 using namespace llvm::codeview;
29 
31  return TypeIndex::fromArrayIndex(SeenRecords.size());
32 }
33 
35  : RecordStorage(Storage) {}
36 
38 
40  if (empty())
41  return None;
42 
44 }
45 
47  if (++Prev == nextTypeIndex())
48  return None;
49  return Prev;
50 }
51 
53  return CVType(SeenRecords[Index.toArrayIndex()]);
54 }
55 
57  llvm_unreachable("Method not implemented");
58 }
59 
61  if (Index.isSimple() || Index.isNoneType())
62  return false;
63 
64  return Index.toArrayIndex() < SeenRecords.size();
65 }
66 
67 uint32_t AppendingTypeTableBuilder::size() { return SeenRecords.size(); }
68 
69 uint32_t AppendingTypeTableBuilder::capacity() { return SeenRecords.size(); }
70 
72  return SeenRecords;
73 }
74 
75 void AppendingTypeTableBuilder::reset() { SeenRecords.clear(); }
76 
79  uint8_t *Stable = RecordStorage.Allocate<uint8_t>(Record.size());
80  memcpy(Stable, Record.data(), Record.size());
81  return ArrayRef<uint8_t>(Stable, Record.size());
82 }
83 
86  TypeIndex NewTI = nextTypeIndex();
87  Record = stabilize(RecordStorage, Record);
88  SeenRecords.push_back(Record);
89  return NewTI;
90 }
91 
94  TypeIndex TI;
95  auto Fragments = Builder.end(nextTypeIndex());
96  assert(!Fragments.empty());
97  for (auto C : Fragments)
98  TI = insertRecordBytes(C.RecordData);
99  return TI;
100 }
101 
103  bool Stabilize) {
104  assert(Index.toArrayIndex() < SeenRecords.size() &&
105  "This function cannot be used to insert records!");
106 
107  ArrayRef<uint8_t> Record = Data.data();
108  if (Stabilize)
109  Record = stabilize(RecordStorage, Record);
110  SeenRecords[Index.toArrayIndex()] = Record;
111  return true;
112 }
llvm::codeview::AppendingTypeTableBuilder::~AppendingTypeTableBuilder
~AppendingTypeTableBuilder()
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
RecordSerialization.h
llvm::codeview::TypeIndex::FirstNonSimpleIndex
static const uint32_t FirstNonSimpleIndex
Definition: TypeIndex.h:97
BinaryByteStream.h
llvm::codeview::TypeIndex::fromArrayIndex
static TypeIndex fromArrayIndex(uint32_t Index)
Definition: TypeIndex.h:122
llvm::codeview::AppendingTypeTableBuilder::getFirst
Optional< TypeIndex > getFirst() override
Definition: AppendingTypeTableBuilder.cpp:39
Allocator.h
Error.h
llvm::codeview::AppendingTypeTableBuilder::replaceType
bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override
Definition: AppendingTypeTableBuilder.cpp:102
llvm::Optional
Definition: APInt.h:33
llvm::codeview::AppendingTypeTableBuilder::records
ArrayRef< ArrayRef< uint8_t > > records() const
Definition: AppendingTypeTableBuilder.cpp:71
llvm::codeview::AppendingTypeTableBuilder::nextTypeIndex
TypeIndex nextTypeIndex() const
Definition: AppendingTypeTableBuilder.cpp:30
STLExtras.h
llvm::codeview::AppendingTypeTableBuilder::contains
bool contains(TypeIndex Index) override
Definition: AppendingTypeTableBuilder.cpp:60
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::BumpPtrAllocatorImpl::Allocate
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:145
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::codeview::AppendingTypeTableBuilder::getTypeName
StringRef getTypeName(TypeIndex Index) override
Definition: AppendingTypeTableBuilder.cpp:56
DenseSet.h
CodeView.h
llvm::None
const NoneType None
Definition: None.h:23
llvm::codeview::ContinuationRecordBuilder
Definition: ContinuationRecordBuilder.h:33
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
AppendingTypeTableBuilder.h
ArrayRef.h
llvm::codeview::AppendingTypeTableBuilder::reset
void reset()
Definition: AppendingTypeTableBuilder.cpp:75
llvm::codeview::AppendingTypeTableBuilder::size
uint32_t size() override
Definition: AppendingTypeTableBuilder.cpp:67
llvm::codeview::TypeCollection::empty
bool empty()
Definition: TypeCollection.h:22
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::codeview::AppendingTypeTableBuilder::getType
CVType getType(TypeIndex Index) override
Definition: AppendingTypeTableBuilder.cpp:52
llvm::Record
Definition: Record.h:1472
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:650
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::codeview::CVRecord< TypeLeafKind >
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
uint32_t
stabilize
static ArrayRef< uint8_t > stabilize(BumpPtrAllocator &RecordStorage, ArrayRef< uint8_t > Record)
Definition: AppendingTypeTableBuilder.cpp:77
llvm::codeview::AppendingTypeTableBuilder::capacity
uint32_t capacity() override
Definition: AppendingTypeTableBuilder.cpp:69
TypeIndex.h
ContinuationRecordBuilder.h
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
llvm::codeview::AppendingTypeTableBuilder::insertRecordBytes
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)
Definition: AppendingTypeTableBuilder.cpp:85
llvm::codeview::TypeIndex
A 32-bit type reference.
Definition: TypeIndex.h:95
llvm::codeview::AppendingTypeTableBuilder::insertRecord
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
Definition: AppendingTypeTableBuilder.cpp:93
BinaryStreamWriter.h
llvm::codeview::AppendingTypeTableBuilder::AppendingTypeTableBuilder
AppendingTypeTableBuilder(BumpPtrAllocator &Storage)
Definition: AppendingTypeTableBuilder.cpp:34
llvm::codeview::AppendingTypeTableBuilder::getNext
Optional< TypeIndex > getNext(TypeIndex Prev) override
Definition: AppendingTypeTableBuilder.cpp:46
llvm::codeview::CVType
CVRecord< TypeLeafKind > CVType
Definition: CVRecord.h:65
Endian.h