MLIR: mlir::DialectBytecodeWriter Class Reference (original) (raw)
This class defines a virtual interface for writing to a bytecode stream, providing hooks into the bytecode writer. More...
#include "[mlir/Bytecode/BytecodeImplementation.h](BytecodeImplementation%5F8h%5Fsource.html)"
Public Member Functions | |
---|---|
virtual | ~DialectBytecodeWriter ()=default |
template<typename RangeT , typename CallbackFn > | |
void | writeList (RangeT &&range, CallbackFn &&callback) |
Write out a list of elements, invoking the provided callback for each element. More... | |
virtual void | writeAttribute (Attribute attr)=0 |
Write a reference to the given attribute. More... | |
virtual void | writeOptionalAttribute (Attribute attr)=0 |
template | |
void | writeAttributes (ArrayRef< T > attrs) |
virtual void | writeType (Type type)=0 |
Write a reference to the given type. More... | |
template | |
void | writeTypes (ArrayRef< T > types) |
virtual void | writeResourceHandle (const AsmDialectResourceHandle &resource)=0 |
Write the given handle to a dialect resource. More... | |
virtual void | writeVarInt (uint64_t value)=0 |
Write a variable width integer to the output stream. More... | |
virtual void | writeSignedVarInt (int64_t value)=0 |
Write a signed variable width integer to the output stream. More... | |
void | writeSignedVarInts (ArrayRef< int64_t > value) |
void | writeVarIntWithFlag (uint64_t value, bool flag) |
Write a VarInt and a flag packed together. More... | |
template | |
void | writeSparseArray (ArrayRef< T > array) |
Write out a "small" sparse array of integer <= 32 bits elements, where index/value pairs can be compressed when the array is small. More... | |
virtual void | writeAPIntWithKnownWidth (const APInt &value)=0 |
Write an APInt to the bytecode stream whose bitwidth will be known externally at read time. More... | |
virtual void | writeAPFloatWithKnownSemantics (const APFloat &value)=0 |
Write an APFloat to the bytecode stream whose semantics will be known externally at read time. More... | |
virtual void | writeOwnedString (StringRef str)=0 |
Write a string to the bytecode, which is owned by the caller and is guaranteed to not die before the end of the bytecode process. More... | |
virtual void | writeOwnedBlob (ArrayRef< char > blob)=0 |
Write a blob to the bytecode, which is owned by the caller and is guaranteed to not die before the end of the bytecode process. More... | |
virtual void | writeOwnedBool (bool value)=0 |
Write a bool to the output stream. More... | |
virtual int64_t | getBytecodeVersion () const =0 |
Return the bytecode version being emitted for. More... | |
virtual FailureOr< const DialectVersion * > | getDialectVersion (StringRef dialectName) const =0 |
Retrieve the dialect version by name if available. More... | |
template | |
FailureOr< const DialectVersion * > | getDialectVersion () const |
This class defines a virtual interface for writing to a bytecode stream, providing hooks into the bytecode writer.
As such, this class should only be derived and defined by the main bytecode writer, users (i.e. dialects) should generally only interact with this class via the BytecodeDialectInterface below.
Definition at line 277 of file BytecodeImplementation.h.
virtual mlir::DialectBytecodeWriter::~DialectBytecodeWriter ( ) | virtualdefault |
---|
◆ getBytecodeVersion()
virtual int64_t mlir::DialectBytecodeWriter::getBytecodeVersion ( ) const | pure virtual |
---|
◆ getDialectVersion() [1/2]
template
FailureOr<const DialectVersion *> mlir::DialectBytecodeWriter::getDialectVersion ( ) const | inline |
---|
◆ getDialectVersion() [2/2]
virtual FailureOr<const DialectVersion *> mlir::DialectBytecodeWriter::getDialectVersion ( StringRef dialectName) const | pure virtual |
---|
◆ writeAPFloatWithKnownSemantics()
virtual void mlir::DialectBytecodeWriter::writeAPFloatWithKnownSemantics ( const APFloat & value) | pure virtual |
---|
◆ writeAPIntWithKnownWidth()
virtual void mlir::DialectBytecodeWriter::writeAPIntWithKnownWidth ( const APInt & value) | pure virtual |
---|
Write an APInt to the bytecode stream whose bitwidth will be known externally at read time.
This method is useful for encoding APInt values when the width is known via external means, such as via a type. This method should generally only be invoked if you need an APInt, otherwise use the varint methods above. APInt values are generally encoded using zigzag encoding, to enable more efficient encodings for negative values.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
◆ writeAttribute()
virtual void mlir::DialectBytecodeWriter::writeAttribute ( Attribute attr) | pure virtual |
---|
◆ writeAttributes()
template
void mlir::DialectBytecodeWriter::writeAttributes ( ArrayRef< T > attrs) | inline |
---|
◆ writeList()
template<typename RangeT , typename CallbackFn >
void mlir::DialectBytecodeWriter::writeList ( RangeT && range, CallbackFn && callback ) | inline |
---|
◆ writeOptionalAttribute()
virtual void mlir::DialectBytecodeWriter::writeOptionalAttribute ( Attribute attr) | pure virtual |
---|
◆ writeOwnedBlob()
virtual void mlir::DialectBytecodeWriter::writeOwnedBlob ( ArrayRef< char > blob) | pure virtual |
---|
◆ writeOwnedBool()
virtual void mlir::DialectBytecodeWriter::writeOwnedBool ( bool value) | pure virtual |
---|
◆ writeOwnedString()
virtual void mlir::DialectBytecodeWriter::writeOwnedString ( StringRef str) | pure virtual |
---|
Write a string to the bytecode, which is owned by the caller and is guaranteed to not die before the end of the bytecode process.
This should only be called if such a guarantee can be made, such as when the string is owned by an attribute or type.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
◆ writeResourceHandle()
◆ writeSignedVarInt()
virtual void mlir::DialectBytecodeWriter::writeSignedVarInt ( int64_t value) | pure virtual |
---|
◆ writeSignedVarInts()
void mlir::DialectBytecodeWriter::writeSignedVarInts ( ArrayRef< int64_t > value) | inline |
---|
◆ writeSparseArray()
template
void mlir::DialectBytecodeWriter::writeSparseArray ( ArrayRef< T > array) | inline |
---|
Write out a "small" sparse array of integer <= 32 bits elements, where index/value pairs can be compressed when the array is small.
This method will scan the array multiple times and should not be used for large arrays. The optional provided "zero" can be used to adjust for the expected repeated value. We assume here that the array size fits in a 32 bits integer.
Definition at line 340 of file BytecodeImplementation.h.
References writeVarInt(), and writeVarIntWithFlag().
◆ writeType()
virtual void mlir::DialectBytecodeWriter::writeType ( Type type) | pure virtual |
---|
◆ writeTypes()
template
void mlir::DialectBytecodeWriter::writeTypes ( ArrayRef< T > types) | inline |
---|
◆ writeVarInt()
virtual void mlir::DialectBytecodeWriter::writeVarInt ( uint64_t value) | pure virtual |
---|
◆ writeVarIntWithFlag()
void mlir::DialectBytecodeWriter::writeVarIntWithFlag ( uint64_t value, bool flag ) | inline |
---|
The documentation for this class was generated from the following file:
- include/mlir/Bytecode/BytecodeImplementation.h