LLVM  6.0.0svn
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 
17 
18 using namespace llvm;
19 using namespace llvm::codeview;
20 
22  : NameStorage(Allocator), Records(Records) {
23  Names.resize(Records.size());
24 }
25 
27  if (empty())
28  return None;
29  return TypeIndex::fromArrayIndex(0);
30 }
31 
33  assert(contains(Prev));
34  ++Prev;
35  if (Prev.toArrayIndex() == size())
36  return None;
37  return Prev;
38 }
39 
41  assert(Index.toArrayIndex() < Records.size());
42  ArrayRef<uint8_t> Bytes = Records[Index.toArrayIndex()];
43  const RecordPrefix *Prefix =
44  reinterpret_cast<const RecordPrefix *>(Bytes.data());
45  TypeLeafKind Kind = static_cast<TypeLeafKind>(uint16_t(Prefix->RecordKind));
46  return CVType(Kind, Bytes);
47 }
48 
50  if (Index.isNoneType() || Index.isSimple())
51  return TypeIndex::simpleTypeName(Index);
52 
53  uint32_t I = Index.toArrayIndex();
54  if (Names[I].data() == nullptr) {
55  StringRef Result = NameStorage.save(computeTypeName(*this, Index));
56  Names[I] = Result;
57  }
58  return Names[I];
59 }
60 
62  return Index.toArrayIndex() <= size();
63 }
64 
65 uint32_t TypeTableCollection::size() { return Records.size(); }
66 
67 uint32_t TypeTableCollection::capacity() { return Records.size(); }
Compute iterated dominance frontiers using a linear time algorithm.
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:236
CVRecord< TypeLeafKind > CVType
Definition: TypeRecord.h:36
bool isNoneType() const
Definition: TypeIndex.h:114
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:116
static TypeIndex fromArrayIndex(uint32_t Index)
Definition: TypeIndex.h:121
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:26
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