LLVM  8.0.1
TypeTableCollection.cpp
Go to the documentation of this file.
1 //===- TypeTableCollection.cpp -------------------------------- *- C++ --*-===//
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 
15 
16 using namespace llvm;
17 using namespace llvm::codeview;
18 
20  : NameStorage(Allocator), Records(Records) {
21  Names.resize(Records.size());
22 }
23 
25  if (empty())
26  return None;
27  return TypeIndex::fromArrayIndex(0);
28 }
29 
31  assert(contains(Prev));
32  ++Prev;
33  if (Prev.toArrayIndex() == size())
34  return None;
35  return Prev;
36 }
37 
39  assert(Index.toArrayIndex() < Records.size());
40  ArrayRef<uint8_t> Bytes = Records[Index.toArrayIndex()];
41  const RecordPrefix *Prefix =
42  reinterpret_cast<const RecordPrefix *>(Bytes.data());
43  TypeLeafKind Kind = static_cast<TypeLeafKind>(uint16_t(Prefix->RecordKind));
44  return CVType(Kind, Bytes);
45 }
46 
48  if (Index.isNoneType() || Index.isSimple())
49  return TypeIndex::simpleTypeName(Index);
50 
51  uint32_t I = Index.toArrayIndex();
52  if (Names[I].data() == nullptr) {
53  StringRef Result = NameStorage.save(computeTypeName(*this, Index));
54  Names[I] = Result;
55  }
56  return Names[I];
57 }
58 
60  return Index.toArrayIndex() <= size();
61 }
62 
63 uint32_t TypeTableCollection::size() { return Records.size(); }
64 
65 uint32_t TypeTableCollection::capacity() { return Records.size(); }
This class represents lattice values for constants.
Definition: AllocatorList.h:24
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
Definition: CodeView.h:34
std::string computeTypeName(TypeCollection &Types, TypeIndex Index)
Definition: RecordName.cpp:249
CVRecord< TypeLeafKind > CVType
Definition: TypeRecord.h:36
bool isNoneType() const
Definition: TypeIndex.h:116
A 32-bit type reference.
Definition: TypeIndex.h:96
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
uint32_t toArrayIndex() const
Definition: TypeIndex.h:118
static TypeIndex fromArrayIndex(uint32_t Index)
Definition: TypeIndex.h:123
bool contains(TypeIndex Index) override
TypeTableCollection(ArrayRef< ArrayRef< uint8_t >> Records)
static StringRef simpleTypeName(TypeIndex TI)
Definition: TypeIndex.cpp:71
Optional< TypeIndex > getFirst() override
StringRef getTypeName(TypeIndex Index) override
Basic Register Allocator
StringRef save(const char *S)
Definition: StringSaver.h:29
Optional< TypeIndex > getNext(TypeIndex Prev) override
CVType getType(TypeIndex Index) override
#define I(x, y, z)
Definition: MD5.cpp:58
const unsigned Kind
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49