Go to the documentation of this file.
22 #ifndef LLVM_SUPPORT_BINARYSTREAMARRAY_H
23 #define LLVM_SUPPORT_BINARYSTREAMARRAY_H
47 template <
typename T>
struct VarStreamArrayExtractor {
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};
155 template <
typename ValueType,
typename Extractor>
156 class VarStreamArrayIterator
157 :
public iterator_facade_base<VarStreamArrayIterator<ValueType, Extractor>,
158 std::forward_iterator_tag, const ValueType> {
159 typedef VarStreamArrayIterator<ValueType, Extractor> IterType;
160 typedef VarStreamArray<ValueType, Extractor>
ArrayType;
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};
267 assert(Stream.getLength() %
sizeof(
T) == 0);
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());
319 template <
typename T>
320 class FixedStreamArrayIterator
321 :
public iterator_facade_base<FixedStreamArrayIterator<T>,
322 std::random_access_iterator_tag, const T> {
342 return (
Index == R.Index) && (Array == R.Array);
359 return Index - R.Index;
374 #endif // LLVM_SUPPORT_BINARYSTREAMARRAY_H
This is an optimization pass for GlobalISel generic memory operations.
VarStreamArray(BinaryStreamRef Stream, uint32_t Skew=0)
VarStreamArray< ValueType, Extractor > substream(uint32_t Begin, uint32_t End) const
const ValueType & operator*() const
bool operator==(const IterType &R) const
FixedStreamArrayIterator(const FixedStreamArrayIterator< T > &Other)
bool operator!=(const FixedStreamArray< T > &Other) const
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
void consumeError(Error Err)
Consume a Error without doing anything.
Extractor & getExtractor()
VarStreamArrayIterator(const Extractor &E)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
uint64_t getLength() const
VarStreamArrayIterator< ValueType, Extractor > Iterator
FixedStreamArrayIterator< T > begin() const
bool operator==(const FixedStreamArrayIterator< T > &R) const
FixedStreamArray()=default
FixedStreamArray(BinaryStreamRef Stream)
VarStreamArrayIterator(const ArrayType &Array, const Extractor &E, uint32_t Offset, bool *HadError)
FixedStreamArrayIterator< T > & operator-=(std::ptrdiff_t N)
friend class FixedStreamArrayIterator< T >
FixedStreamArrayIterator< T > & operator=(const FixedStreamArrayIterator< T > &Other)
FixedStreamArrayIterator(const FixedStreamArray< T > &Array, uint32_t Index)
VarStreamArrayIterator()=default
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
BinaryStreamRef getUnderlyingStream() const
IterType & operator+=(unsigned N)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
VarStreamArray represents an array of variable length records backed by a stream.
FixedStreamArrayIterator< T > end() const
FixedStreamArray & operator=(const FixedStreamArray &)=default
~VarStreamArrayIterator()=default
const T & operator[](uint32_t Index) const
const T & operator*() const
bool operator==(const FixedStreamArray< T > &Other) const
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
FixedStreamArrayIterator< T > & operator+=(std::ptrdiff_t N)
Iterator begin(bool *HadError=nullptr) const
VarStreamArray(const Extractor &E)
bool isOffsetValid(uint32_t Offset) const
RefType slice(uint64_t Offset, uint64_t Len) const
Return a new BinaryStreamRef with the first Offset elements removed, and retaining exactly Len elemen...
bool isAddrAligned(Align Lhs, const void *Addr)
Checks that Addr is a multiple of the alignment.
void setUnderlyingStream(BinaryStreamRef NewStream, uint32_t NewSkew=0)
VarStreamArray(BinaryStreamRef Stream, const Extractor &E, uint32_t Skew=0)
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.
BinaryStreamRef getUnderlyingStream() const
bool operator<(const FixedStreamArrayIterator< T > &RHS) const
uint32_t getRecordLength() const
const Extractor & getExtractor() 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.
FixedStreamArrayIterator< T > Iterator
RefType drop_front(uint64_t N) const
Return a new BinaryStreamRef with the first N elements removed.
std::ptrdiff_t operator-(const FixedStreamArrayIterator< T > &R) const
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Optional< std::vector< StOtherPiece > > Other