LLVM  16.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"
14 #include "llvm/Support/Allocator.h"
16 #include <cassert>
17 #include <cstdint>
18 #include <cstring>
19 
20 using namespace llvm;
21 using namespace llvm::codeview;
22 
24  return TypeIndex::fromArrayIndex(SeenRecords.size());
25 }
26 
28  : RecordStorage(Storage) {}
29 
31 
33  if (empty())
34  return None;
35 
37 }
38 
40  if (++Prev == nextTypeIndex())
41  return None;
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 
60 uint32_t AppendingTypeTableBuilder::size() { return SeenRecords.size(); }
61 
62 uint32_t AppendingTypeTableBuilder::capacity() { return SeenRecords.size(); }
63 
65  return SeenRecords;
66 }
67 
68 void 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 
100  ArrayRef<uint8_t> Record = Data.data();
101  if (Stabilize)
102  Record = stabilize(RecordStorage, Record);
103  SeenRecords[Index.toArrayIndex()] = Record;
104  return true;
105 }
llvm::codeview::AppendingTypeTableBuilder::~AppendingTypeTableBuilder
~AppendingTypeTableBuilder()
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::codeview::TypeIndex::FirstNonSimpleIndex
static const uint32_t FirstNonSimpleIndex
Definition: TypeIndex.h:98
llvm::codeview::TypeIndex::fromArrayIndex
static TypeIndex fromArrayIndex(uint32_t Index)
Definition: TypeIndex.h:123
ErrorHandling.h
llvm::codeview::AppendingTypeTableBuilder::getFirst
Optional< TypeIndex > getFirst() override
Definition: AppendingTypeTableBuilder.cpp:32
Allocator.h
llvm::codeview::AppendingTypeTableBuilder::replaceType
bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override
Definition: AppendingTypeTableBuilder.cpp:95
llvm::Optional
Definition: APInt.h:33
llvm::codeview::AppendingTypeTableBuilder::records
ArrayRef< ArrayRef< uint8_t > > records() const
Definition: AppendingTypeTableBuilder.cpp:64
llvm::codeview::AppendingTypeTableBuilder::nextTypeIndex
TypeIndex nextTypeIndex() const
Definition: AppendingTypeTableBuilder.cpp:23
llvm::codeview::AppendingTypeTableBuilder::contains
bool contains(TypeIndex Index) override
Definition: AppendingTypeTableBuilder.cpp:53
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
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:49
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
CodeView.h
llvm::codeview::ContinuationRecordBuilder
Definition: ContinuationRecordBuilder.h:27
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:63
AppendingTypeTableBuilder.h
ArrayRef.h
llvm::codeview::AppendingTypeTableBuilder::reset
void reset()
Definition: AppendingTypeTableBuilder.cpp:68
llvm::codeview::AppendingTypeTableBuilder::size
uint32_t size() override
Definition: AppendingTypeTableBuilder.cpp:60
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:45
llvm::Record
Definition: Record.h:1573
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:651
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:50
llvm::codeview::CVRecord< TypeLeafKind >
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
uint32_t
stabilize
static ArrayRef< uint8_t > stabilize(BumpPtrAllocator &RecordStorage, ArrayRef< uint8_t > Record)
Definition: AppendingTypeTableBuilder.cpp:70
llvm::codeview::AppendingTypeTableBuilder::capacity
uint32_t capacity() override
Definition: AppendingTypeTableBuilder.cpp:62
llvm::None
constexpr std::nullopt_t None
Definition: None.h:27
llvm::BumpPtrAllocatorImpl::Allocate
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:148
TypeIndex.h
ContinuationRecordBuilder.h
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
llvm::codeview::AppendingTypeTableBuilder::insertRecordBytes
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)
Definition: AppendingTypeTableBuilder.cpp:78
llvm::codeview::TypeIndex
A 32-bit type reference.
Definition: TypeIndex.h:96
llvm::codeview::AppendingTypeTableBuilder::insertRecord
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
Definition: AppendingTypeTableBuilder.cpp:86
llvm::codeview::AppendingTypeTableBuilder::AppendingTypeTableBuilder
AppendingTypeTableBuilder(BumpPtrAllocator &Storage)
Definition: AppendingTypeTableBuilder.cpp:27
llvm::codeview::AppendingTypeTableBuilder::getNext
Optional< TypeIndex > getNext(TypeIndex Prev) override
Definition: AppendingTypeTableBuilder.cpp:39
llvm::codeview::CVType
CVRecord< TypeLeafKind > CVType
Definition: CVRecord.h:64