MLIR
20.0.0git
|
This class defines a virtual interface for writing to a bytecode stream, providing hooks into the bytecode writer. More...
#include "mlir/Bytecode/BytecodeImplementation.h"
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<typename T > | |
void | writeAttributes (ArrayRef< T > attrs) |
virtual void | writeType (Type type)=0 |
Write a reference to the given type. More... | |
template<typename T > | |
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<typename T > | |
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<class T > | |
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.
|
virtualdefault |
|
pure virtual |
Return the bytecode version being emitted for.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
|
inline |
Definition at line 412 of file BytecodeImplementation.h.
|
pure virtual |
Retrieve the dialect version by name if available.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
|
pure virtual |
Write an APFloat to the bytecode stream whose semantics will be known externally at read time.
This method is useful for encoding APFloat values when the semantics are known via external means, such as via a type.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
|
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.
|
pure virtual |
Write a reference to the given attribute.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
Referenced by writeAttributes().
|
inline |
Definition at line 298 of file BytecodeImplementation.h.
References writeAttribute(), and writeList().
|
inline |
Write out a list of elements, invoking the provided callback for each element.
Definition at line 288 of file BytecodeImplementation.h.
References writeVarInt().
Referenced by writeAttributes(), writeSignedVarInts(), and writeTypes().
|
pure virtual |
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
|
pure virtual |
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.
The blob is written as-is, with no additional compression or compaction.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
|
pure virtual |
Write a bool to the output stream.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
|
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.
|
pure virtual |
Write the given handle to a dialect resource.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
|
pure virtual |
Write a signed variable width integer to the output stream.
This should be the preferred method for emitting signed integers whenever possible.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
Referenced by writeSignedVarInts().
|
inline |
Definition at line 324 of file BytecodeImplementation.h.
References writeList(), and writeSignedVarInt().
|
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().
|
pure virtual |
Write a reference to the given type.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
Referenced by writeTypes().
|
inline |
Definition at line 305 of file BytecodeImplementation.h.
References writeList(), and writeType().
|
pure virtual |
Write a variable width integer to the output stream.
This should be the preferred method for emitting integers whenever possible.
Implemented in mlir::bytecode::detail::IRNumberingState::NumberingDialectWriter.
Referenced by writeList(), writeSparseArray(), and writeVarIntWithFlag().
|
inline |
Write a VarInt and a flag packed together.
Definition at line 329 of file BytecodeImplementation.h.
References writeVarInt().
Referenced by writeSparseArray().