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);
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) {
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;
214 auto EC = Extract(IterRef, ThisLen, ThisValue);
218 }
else if (ThisLen == 0) {
238 if (HadError !=
nullptr)
243 BinaryStreamRef IterRef;
248 bool HasError{
false};
249 bool *HadError{
nullptr};
252template <
typename T>
class FixedStreamArrayIterator;
271 return Stream ==
Other.Stream;
275 return !(*
this ==
Other);
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;
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
RefType drop_front(uint64_t N) const
Return a new BinaryStreamRef with the first N elements removed.
RefType slice(uint64_t Offset, uint64_t Len) const
Return a new BinaryStreamRef with the first Offset elements removed, and retaining exactly Len elemen...
uint64_t getLength() const
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Error readBytes(uint64_t Offset, uint64_t Size, ArrayRef< uint8_t > &Buffer) const
Given an Offset into this StreamRef and a Size, return a reference to a buffer owned by the stream.
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< T > 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
given an offset into the array's underlying stream, return an iterator to the record at that offset.
VarStreamArray(const Extractor &E)
Extractor & getExtractor()
BinaryStreamRef getUnderlyingStream() const
VarStreamArrayIterator< ValueType, Extractor > 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.
void consumeError(Error Err)
Consume a Error without doing anything.
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
bool isAddrAligned(Align Lhs, const void *Addr)
Checks that Addr is a multiple of the alignment.