Go to the documentation of this file.
9 #ifndef LLVM_SUPPORT_BINARYSTREAMWRITER_H
10 #define LLVM_SUPPORT_BINARYSTREAMWRITER_H
20 #include <type_traits>
59 static_assert(std::is_integral<T>::value,
60 "Cannot call writeInteger with non-integral value!");
61 uint8_t Buffer[
sizeof(
T)];
62 llvm::support::endian::write<T, llvm::support::unaligned>(
69 static_assert(std::is_enum<T>::value,
70 "Cannot call writeEnum with non-Enum type");
72 using U = std::underlying_type_t<T>;
73 return writeInteger<U>(
static_cast<U
>(Num));
130 static_assert(!std::is_pointer<T>::value,
131 "writeObject should not be used with pointers, to write "
132 "the pointed-to value dereference the pointer before calling "
148 if (Array.size() > UINT32_MAX /
sizeof(
T))
149 return make_error<BinaryStreamError>(
154 Array.size() *
sizeof(
T)));
161 template <
typename T,
typename U>
175 std::pair<BinaryStreamWriter, BinaryStreamWriter>
split(
uint64_t Off)
const;
190 #endif // LLVM_SUPPORT_BINARYSTREAMWRITER_H
This is an optimization pass for GlobalISel generic memory operations.
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
WritableBinaryStreamRef Stream
Error writeEnum(T Num)
Similar to writeInteger.
Error writeFixedString(StringRef Str)
Write the string Str to the underlying stream without a null terminator.
Provides write only access to a subclass of WritableBinaryStream.
static ErrorSuccess success()
Create a success value.
Error writeStreamRef(BinaryStreamRef Ref)
Efficiently reads all data from Ref, and writes it to this stream.
void setOffset(uint64_t Off)
Error writeArray(ArrayRef< T > Array)
Writes an array of objects of type T to the underlying stream, as if by using memcpy.
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
@ Ref
The access may reference the value stored in memory.
uint64_t getLength() const
This struct is a compact representation of a valid (non-zero power of two) alignment.
uint64_t bytesRemaining() const
uint64_t getOffset() const
Error writeSLEB128(int64_t Value)
Write the unsigned integer Value to the underlying stream using ULEB128 encoding.
Error writeCString(StringRef Str)
Write the string Str to the underlying stream followed by a null terminator.
Error writeArray(FixedStreamArray< T > Array)
Writes all elements from the array Array to the underlying stream.
Error writeULEB128(uint64_t Value)
Write the unsigned integer Value to the underlying stream using ULEB128 encoding.
virtual ~BinaryStreamWriter()=default
Error writeObject(const T &Obj)
Writes the object Obj to the underlying stream, as if by using memcpy.
Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
StringRef - Represent a constant reference to a string, i.e.
llvm::support::endianness getEndian() const
Error padToAlignment(uint32_t Align)
Lightweight error class with error context and mandatory checking.
BinaryStreamWriter & operator=(const BinaryStreamWriter &Other)=default
Error writeArray(VarStreamArray< T, U > Array)
Writes all data from the array Array to the underlying stream.
std::pair< BinaryStreamWriter, BinaryStreamWriter > split(uint64_t Off) const
Splits the Writer into two Writers at a given offset.
uint64_t getLength() const
BinaryStreamWriter()=default
A BinaryStream which can be read from as well as written to.
LLVM Value Representation.
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Optional< std::vector< StOtherPiece > > Other