22#ifndef LLVM_SUPPORT_BINARYSTREAMARRAY_H
23#define LLVM_SUPPORT_BINARYSTREAMARRAY_H
51 T &Item)
const =
delete;
103 : Stream(Stream), Skew(Skew) {}
106 : Stream(Stream), E(E), Skew(Skew) {}
109 return Iterator(*
this, E, Skew,
nullptr);
112 bool valid()
const {
return Stream.valid(); }
119 bool empty()
const {
return Stream.getLength() == 0; }
127 return {NewStream, E, Begin};
155template <
typename ValueType,
typename Extractor>
158 std::forward_iterator_tag, const ValueType> {
165 : IterRef(Array.Stream.drop_front(
Offset)), Extract(
E),
166 Array(&Array), AbsOffset(
Offset), HadError(HadError) {
167 if (IterRef.getLength() == 0)
170 auto EC = Extract(IterRef, ThisLen, ThisValue);
183 if (Array && R.Array) {
186 return IterRef == R.IterRef;
190 if (!Array && !R.Array)
198 assert(Array && !HasError);
203 for (
unsigned I = 0;
I <
N; ++
I) {
206 AbsOffset += ThisLen;
207 IterRef = IterRef.drop_front(ThisLen);
208 if (IterRef.getLength() == 0) {
214 auto EC = Extract(IterRef, ThisLen, ThisValue);
218 }
else if (ThisLen == 0) {
238 if (HadError !=
nullptr)
243 BinaryStreamRef IterRef;
245 const ArrayType *Array{
nullptr};
247 uint32_t AbsOffset{0};
248 bool HasError{
false};
249 bool *HadError{
nullptr};
252template <
typename T>
class FixedStreamArrayIterator;
267 assert(Stream.getLength() %
sizeof(
T) == 0);
271 return Stream ==
Other.Stream;
275 return !(*
this ==
Other);
285 if (
auto EC = Stream.readBytes(Off,
sizeof(
T),
Data)) {
286 assert(
false &&
"Unexpected failure reading from stream");
292 return *
reinterpret_cast<const T *
>(
Data.data());
322 std::random_access_iterator_tag, const T> {
326 : Array(Array), Index(Index) {}
342 return (Index == R.Index) && (Array == R.Array);
351 assert(std::ptrdiff_t(Index) >=
N);
359 return Index - R.Index;
364 return Index <
RHS.Index;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
RefType slice(uint64_t Offset, uint64_t Len) const
Return a new BinaryStreamRef with the first Offset elements removed, and retaining exactly Len elemen...
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Lightweight error class with error context and mandatory checking.
std::ptrdiff_t operator-(const FixedStreamArrayIterator< T > &R) const
FixedStreamArrayIterator< T > & operator+=(std::ptrdiff_t N)
FixedStreamArrayIterator< T > & operator=(const FixedStreamArrayIterator< T > &Other)
bool operator<(const FixedStreamArrayIterator< T > &RHS) const
bool operator==(const FixedStreamArrayIterator< T > &R) const
FixedStreamArrayIterator< T > & operator-=(std::ptrdiff_t N)
const T & operator*() const
FixedStreamArrayIterator(const FixedStreamArray< T > &Array, uint32_t Index)
FixedStreamArrayIterator(const FixedStreamArrayIterator< T > &Other)
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
FixedStreamArrayIterator< CrossModuleExport > Iterator
BinaryStreamRef getUnderlyingStream() const
FixedStreamArrayIterator< T > begin() const
bool operator!=(const FixedStreamArray< T > &Other) const
FixedStreamArray & operator=(const FixedStreamArray &)=default
FixedStreamArrayIterator< T > end() const
bool operator==(const FixedStreamArray< T > &Other) const
friend class FixedStreamArrayIterator< T >
const T & operator[](uint32_t Index) const
FixedStreamArray(BinaryStreamRef Stream)
FixedStreamArray()=default
FixedStreamArray(const FixedStreamArray &)=default
VarStreamArray represents an array of variable length records backed by a stream.
VarStreamArrayIterator(const ArrayType &Array, const Extractor &E, uint32_t Offset, bool *HadError)
uint32_t getRecordLength() const
VarStreamArrayIterator(const Extractor &E)
~VarStreamArrayIterator()=default
VarStreamArrayIterator()=default
bool operator==(const IterType &R) const
IterType & operator+=(unsigned N)
const ValueType & operator*() const
VarStreamArray(BinaryStreamRef Stream, const Extractor &E, uint32_t Skew=0)
void setUnderlyingStream(BinaryStreamRef NewStream, uint32_t NewSkew=0)
Iterator at(uint32_t Offset) const
VarStreamArray(const Extractor &E)
Extractor & getExtractor()
BinaryStreamRef getUnderlyingStream() const
VarStreamArrayIterator< CVSymbol, VarStreamArrayExtractor< CVSymbol > > Iterator
bool isOffsetValid(uint32_t Offset) const
Iterator begin(bool *HadError=nullptr) const
const Extractor & getExtractor() const
VarStreamArray(BinaryStreamRef Stream, uint32_t Skew=0)
VarStreamArray< ValueType, Extractor > substream(uint32_t Begin, uint32_t End) const
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
void consumeError(Error Err)
Consume a Error without doing anything.
bool isAddrAligned(Align Lhs, const void *Addr)
Checks that Addr is a multiple of the alignment.
static constexpr Align Of()
Allow constructions of constexpr Align from types.