LLVM  10.0.0svn
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  TypeIndex NewTI = nextTypeIndex();
80  uint8_t *Stable = RecordStorage.Allocate<uint8_t>(Record.size());
81  memcpy(Stable, Record.data(), Record.size());
82  Record = ArrayRef<uint8_t>(Stable, Record.size());
83  SeenRecords.push_back(Record);
84  return NewTI;
85 }
86 
89  TypeIndex TI;
90  auto Fragments = Builder.end(nextTypeIndex());
91  assert(!Fragments.empty());
92  for (auto C : Fragments)
93  TI = insertRecordBytes(C.RecordData);
94  return TI;
95 }
Optional< TypeIndex > getNext(TypeIndex Prev) override
This class represents lattice values for constants.
Definition: AllocatorList.h:23
ArrayRef< ArrayRef< uint8_t > > records() const
CVRecord< TypeLeafKind > CVType
Definition: TypeRecord.h:35
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
bool isNoneType() const
Definition: TypeIndex.h:115
static const uint32_t FirstNonSimpleIndex
Definition: TypeIndex.h:97
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
A 32-bit type reference.
Definition: TypeIndex.h:95
uint32_t toArrayIndex() const
Definition: TypeIndex.h:117
static TypeIndex fromArrayIndex(uint32_t Index)
Definition: TypeIndex.h:122
StringRef getTypeName(TypeIndex Index) override
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:140
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:148
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:214
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:145
std::vector< CVType > end(TypeIndex Index)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48