LLVM  8.0.1
AppendingTypeTableBuilder.cpp
Go to the documentation of this file.
1 //===- AppendingTypeTableBuilder.cpp --------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 #include "llvm/ADT/ArrayRef.h"
12 #include "llvm/ADT/DenseSet.h"
13 #include "llvm/ADT/STLExtras.h"
18 #include "llvm/Support/Allocator.h"
21 #include "llvm/Support/Endian.h"
22 #include "llvm/Support/Error.h"
23 #include <algorithm>
24 #include <cassert>
25 #include <cstdint>
26 #include <cstring>
27 
28 using namespace llvm;
29 using namespace llvm::codeview;
30 
32  return TypeIndex::fromArrayIndex(SeenRecords.size());
33 }
34 
36  : RecordStorage(Storage) {}
37 
39 
41  if (empty())
42  return None;
43 
45 }
46 
48  if (++Prev == nextTypeIndex())
49  return None;
50  return Prev;
51 }
52 
54  CVType Type;
55  Type.RecordData = SeenRecords[Index.toArrayIndex()];
56  const RecordPrefix *P =
57  reinterpret_cast<const RecordPrefix *>(Type.RecordData.data());
58  Type.Type = static_cast<TypeLeafKind>(uint16_t(P->RecordKind));
59  return Type;
60 }
61 
63  llvm_unreachable("Method not implemented");
64 }
65 
67  if (Index.isSimple() || Index.isNoneType())
68  return false;
69 
70  return Index.toArrayIndex() < SeenRecords.size();
71 }
72 
73 uint32_t AppendingTypeTableBuilder::size() { return SeenRecords.size(); }
74 
75 uint32_t AppendingTypeTableBuilder::capacity() { return SeenRecords.size(); }
76 
78  return SeenRecords;
79 }
80 
81 void AppendingTypeTableBuilder::reset() { SeenRecords.clear(); }
82 
85  TypeIndex NewTI = nextTypeIndex();
86  uint8_t *Stable = RecordStorage.Allocate<uint8_t>(Record.size());
87  memcpy(Stable, Record.data(), Record.size());
88  Record = ArrayRef<uint8_t>(Stable, Record.size());
89  SeenRecords.push_back(Record);
90  return NewTI;
91 }
92 
95  TypeIndex TI;
96  auto Fragments = Builder.end(nextTypeIndex());
97  assert(!Fragments.empty());
98  for (auto C : Fragments)
99  TI = insertRecordBytes(C.RecordData);
100  return TI;
101 }
Optional< TypeIndex > getNext(TypeIndex Prev) override
This class represents lattice values for constants.
Definition: AllocatorList.h:24
ArrayRef< ArrayRef< uint8_t > > records() const
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:34
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
bool isNoneType() const
Definition: TypeIndex.h:116
static const uint32_t FirstNonSimpleIndex
Definition: TypeIndex.h:98
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
A 32-bit type reference.
Definition: TypeIndex.h:96
uint32_t toArrayIndex() const
Definition: TypeIndex.h:118
static TypeIndex fromArrayIndex(uint32_t Index)
Definition: TypeIndex.h:123
#define P(N)
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
StringRef getTypeName(TypeIndex Index) override
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:141
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:215
TypeIndex insertRecordBytes(ArrayRef< uint8_t > &Record)
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const T * data() const
Definition: ArrayRef.h:146
std::vector< CVType > end(TypeIndex Index)
ArrayRef< uint8_t > RecordData
Definition: CVRecord.h:49
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49