27 using namespace llvm::codeview;
42 : NameStorage(
Allocator), Types(Types), PartialOffsets(PartialOffsets) {
43 Records.resize(RecordCountHint);
54 makeArrayRef(Data.bytes_begin(), Data.bytes_end()), RecordCountHint) {
70 Records.resize(RecordCountHint);
79 error(ensureTypeExists(Index));
86 error(ensureTypeExists(Index));
100 if (
auto EC = ensureTypeExists(Index)) {
102 return "<unknown UDT>";
106 ensureCapacityFor(Index);
107 if (Records[I].
Name.data() ==
nullptr) {
109 Records[
I].Name = Result;
111 return Records[
I].Name;
130 return visitRangeForType(TI);
133 void LazyRandomTypeCollection::ensureCapacityFor(
TypeIndex Index) {
139 uint32_t NewCapacity = MinSize * 3 / 2;
142 Records.resize(NewCapacity);
146 if (PartialOffsets.
empty())
147 return fullScanForType(TI);
149 auto Next = std::upper_bound(PartialOffsets.
begin(), PartialOffsets.
end(), TI,
151 return Value < IO.Type;
155 auto Prev = std::prev(Next);
164 return make_error<CodeViewError>(
"Invalid type index");
168 if (Next == PartialOffsets.
end()) {
174 visitRange(TIB, Prev->Offset, TIE);
180 if (
auto EC = ensureTypeExists(TI)) {
191 if (
auto EC = ensureTypeExists(Prev + 1)) {
203 auto Begin = Types.
begin();
215 CurrentTI = LargestTypeIndex + 1;
216 Begin = Types.
at(Offset);
221 while (Begin !=
End) {
222 ensureCapacityFor(CurrentTI);
223 LargestTypeIndex =
std::max(LargestTypeIndex, CurrentTI);
224 auto Idx = CurrentTI.toArrayIndex();
225 Records[Idx].Type = *Begin;
226 Records[Idx].Offset = Begin.offset();
231 if (CurrentTI <= TI) {
232 return make_error<CodeViewError>(
"Type Index does not exist!");
239 auto RI = Types.
at(BeginOffset);
242 ensureCapacityFor(End);
243 while (Begin != End) {
244 LargestTypeIndex =
std::max(LargestTypeIndex, Begin);
246 Records[Idx].Type = *RI;
247 Records[Idx].Offset = RI.offset();
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
bool contains(TypeIndex Index) override
std::string computeTypeName(TypeCollection &Types, TypeIndex Index)
uint32_t getLength() const
FixedStreamArrayIterator< T > begin() const
LazyRandomTypeCollection(uint32_t RecordCountHint)
Optional< TypeIndex > getNext(TypeIndex Prev) override
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
FixedStreamArrayIterator< T > end() const
void reset(ArrayRef< uint8_t > Data, uint32_t RecordCountHint)
static void error(Error &&EC)
CVType getType(TypeIndex Index) override
static TypeIndex fromArrayIndex(uint32_t Index)
uint32_t capacity() override
static StringRef simpleTypeName(TypeIndex TI)
static const unsigned End
void consumeError(Error Err)
Consume a Error without doing anything.
StringRef getTypeName(TypeIndex Index) override
static ErrorSuccess success()
Create a success value.
StringRef save(const char *S)
uint32_t getOffsetOfType(TypeIndex Index)
static StringRef toStringRef(bool B)
Construct a string ref from a boolean.
uint32_t toArrayIndex() const
Iterator at(uint32_t Offset) const
given an offset into the array's underlying stream, return an iterator to the record at that offset...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
Iterator begin(bool *HadError=nullptr) const
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
Optional< TypeIndex > getFirst() override
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...
Provides amortized O(1) random access to a CodeView type stream.