Go to the documentation of this file.
42 : NameStorage(
Allocator), Types(Types), PartialOffsets(PartialOffsets) {
43 Records.resize(RecordCountHint);
70 Records.resize(RecordCountHint);
75 reset(Reader, RecordCountHint);
81 reset(Reader, RecordCountHint);
88 return Records[
Index.toArrayIndex()].Offset;
94 auto EC = ensureTypeExists(
Index);
98 return Records[
Index.toArrayIndex()].Type;
102 if (
Index.isSimple())
105 if (
auto EC = ensureTypeExists(
Index)) {
111 return Records[
Index.toArrayIndex()].Type;
122 if (
auto EC = ensureTypeExists(
Index)) {
124 return "<unknown UDT>";
128 ensureCapacityFor(
Index);
129 if (Records[
I].
Name.data() ==
nullptr) {
131 Records[
I].Name = Result;
133 return Records[
I].Name;
140 if (Records.size() <=
Index.toArrayIndex())
142 if (!Records[
Index.toArrayIndex()].Type.valid())
155 return visitRangeForType(TI);
158 void LazyRandomTypeCollection::ensureCapacityFor(
TypeIndex Index) {
165 uint32_t NewCapacity = MinSize * 3 / 2;
168 Records.resize(NewCapacity);
173 if (PartialOffsets.
empty())
174 return fullScanForType(TI);
182 auto Prev = std::prev(Next);
191 return make_error<CodeViewError>(
"Invalid type index");
195 if (Next == PartialOffsets.
end()) {
201 visitRange(TIB, Prev->Offset, TIE);
207 if (
auto EC = ensureTypeExists(TI)) {
218 if (
auto EC = ensureTypeExists(Prev + 1)) {
231 auto Begin = Types.
begin();
243 CurrentTI = LargestTypeIndex + 1;
244 Begin = Types.
at(Offset);
248 auto End = Types.
end();
249 while (Begin != End) {
250 ensureCapacityFor(CurrentTI);
251 LargestTypeIndex =
std::max(LargestTypeIndex, CurrentTI);
253 Records[Idx].Type = *Begin;
254 Records[Idx].Offset = Begin.offset();
259 if (CurrentTI <= TI) {
260 return make_error<CodeViewError>(
"Type Index does not exist!");
267 auto RI = Types.
at(BeginOffset);
270 ensureCapacityFor(End);
271 while (Begin != End) {
272 LargestTypeIndex =
std::max(LargestTypeIndex, Begin);
274 Records[Idx].Type = *RI;
275 Records[Idx].Offset = RI.offset();
This is an optimization pass for GlobalISel generic memory operations.
auto upper_bound(R &&Range, T &&Value)
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
std::string computeTypeName(TypeCollection &Types, TypeIndex Index)
static TypeIndex fromArrayIndex(uint32_t Index)
bool contains(TypeIndex Index) override
static ErrorSuccess success()
Create a success value.
uint64_t bytesRemaining() const
static void error(Error &&EC)
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
uint32_t capacity() override
void consumeError(Error Err)
Consume a Error without doing anything.
StringRef getTypeName(TypeIndex Index) override
uint32_t getOffsetOfType(TypeIndex Index)
Provides amortized O(1) random access to a CodeView type stream.
FixedStreamArrayIterator< T > begin() const
Provides read only access to a subclass of BinaryStream.
bool replaceType(TypeIndex &Index, CVType Data, bool Stabilize) override
LazyRandomTypeCollection(uint32_t RecordCountHint)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
FixedStreamArrayIterator< T > end() const
void reset(ArrayRef< uint8_t > Data, uint32_t RecordCountHint)
static StringRef simpleTypeName(TypeIndex TI)
StringRef - Represent a constant reference to a string, i.e.
uint32_t toArrayIndex() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Iterator begin(bool *HadError=nullptr) const
Optional< TypeIndex > getNext(TypeIndex Prev) override
Lightweight error class with error context and mandatory checking.
Optional< CVType > tryGetType(TypeIndex Index)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
StringRef save(const char *S)
Iterator at(uint32_t Offset) const
given an offset into the array's underlying stream, return an iterator to the record at that offset.
Optional< TypeIndex > getFirst() override
CVType getType(TypeIndex Index) override
LLVM Value Representation.
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 ...