MLIR
18.0.0git
|
This class defines a virtual interface for reading a bytecode stream, providing hooks into the bytecode reader. More...
#include "mlir/Bytecode/BytecodeImplementation.h"
Public Member Functions | |
virtual | ~DialectBytecodeReader ()=default |
virtual InFlightDiagnostic | emitError (const Twine &msg={}) const =0 |
Emit an error to the reader. 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 |
virtual MLIRContext * | getContext () const =0 |
Retrieve the context associated to the reader. More... | |
virtual uint64_t | getBytecodeVersion () const =0 |
Return the bytecode version being read. More... | |
template<typename T , typename CallbackFn > | |
LogicalResult | readList (SmallVectorImpl< T > &result, CallbackFn &&callback) |
Read out a list of elements, invoking the provided callback for each element. More... | |
virtual LogicalResult | readAttribute (Attribute &result)=0 |
Read a reference to the given attribute. More... | |
virtual LogicalResult | readOptionalAttribute (Attribute &attr)=0 |
Read an optional reference to the given attribute. More... | |
template<typename T > | |
LogicalResult | readAttributes (SmallVectorImpl< T > &attrs) |
template<typename T > | |
LogicalResult | readAttribute (T &result) |
template<typename T > | |
LogicalResult | readOptionalAttribute (T &result) |
virtual LogicalResult | readType (Type &result)=0 |
Read a reference to the given type. More... | |
template<typename T > | |
LogicalResult | readTypes (SmallVectorImpl< T > &types) |
template<typename T > | |
LogicalResult | readType (T &result) |
template<typename ResourceT > | |
FailureOr< ResourceT > | readResourceHandle () |
Read a handle to a dialect resource. More... | |
virtual LogicalResult | readVarInt (uint64_t &result)=0 |
Read a variable width integer. More... | |
virtual LogicalResult | readSignedVarInt (int64_t &result)=0 |
Read a signed variable width integer. More... | |
LogicalResult | readSignedVarInts (SmallVectorImpl< int64_t > &result) |
LogicalResult | readVarIntWithFlag (uint64_t &result, bool &flag) |
Parse a variable length encoded integer whose low bit is used to encode an unrelated flag, i.e: (integerValue << 1) | (flag ? 1 : 0) . More... | |
template<typename T > | |
LogicalResult | readSparseArray (MutableArrayRef< T > array) |
Read a "small" sparse array of integer <= 32 bits elements, where index/value pairs can be compressed when the array is small. More... | |
virtual FailureOr< APInt > | readAPIntWithKnownWidth (unsigned bitWidth)=0 |
Read an APInt that is known to have been encoded with the given width. More... | |
virtual FailureOr< APFloat > | readAPFloatWithKnownSemantics (const llvm::fltSemantics &semantics)=0 |
Read an APFloat that is known to have been encoded with the given semantics. More... | |
virtual LogicalResult | readString (StringRef &result)=0 |
Read a string from the bytecode. More... | |
virtual LogicalResult | readBlob (ArrayRef< char > &result)=0 |
Read a blob from the bytecode. More... | |
virtual LogicalResult | readBool (bool &result)=0 |
Read a bool from the bytecode. More... | |
This class defines a virtual interface for reading a bytecode stream, providing hooks into the bytecode reader.
As such, this class should only be derived and defined by the main bytecode reader, users (i.e. dialects) should generally only interact with this class via the BytecodeDialectInterface below.
Definition at line 47 of file BytecodeImplementation.h.
|
virtualdefault |
|
pure virtual |
Emit an error to the reader.
Referenced by mlir::BytecodeDialectInterface::readAttribute(), readAttribute(), readOptionalAttribute(), readResourceHandle(), readSparseArray(), mlir::BytecodeDialectInterface::readType(), readType(), and mlir::BytecodeDialectInterface::readVersion().
|
pure virtual |
Return the bytecode version being read.
|
pure virtual |
Retrieve the context associated to the reader.
|
inline |
Definition at line 58 of file BytecodeImplementation.h.
|
pure virtual |
Retrieve the dialect version by name if available.
|
pure virtual |
Read an APFloat that is known to have been encoded with the given semantics.
|
pure virtual |
Read an APInt that is known to have been encoded with the given width.
|
pure virtual |
Read a reference to the given attribute.
Referenced by readAttribute(), and readAttributes().
|
inline |
Definition at line 112 of file BytecodeImplementation.h.
References emitError(), mlir::failed(), mlir::failure(), readAttribute(), and mlir::success().
|
inline |
Definition at line 108 of file BytecodeImplementation.h.
References readAttribute(), and readList().
|
pure virtual |
Read a blob from the bytecode.
|
pure virtual |
Read a bool from the bytecode.
|
inline |
Read out a list of elements, invoking the provided callback for each element.
The callback function may be in any of the following forms:
Definition at line 73 of file BytecodeImplementation.h.
References mlir::failed(), mlir::failure(), readVarInt(), and mlir::success().
Referenced by readAttributes(), readSignedVarInts(), and readTypes().
|
pure virtual |
Read an optional reference to the given attribute.
Returns success even if the Attribute isn't present.
Referenced by readOptionalAttribute().
|
inline |
Definition at line 122 of file BytecodeImplementation.h.
References emitError(), mlir::failed(), mlir::failure(), readOptionalAttribute(), and mlir::success().
|
inline |
Read a handle to a dialect resource.
Definition at line 153 of file BytecodeImplementation.h.
References emitError(), mlir::failed(), and mlir::failure().
Referenced by mlir::readResourceHandle().
|
pure virtual |
Read a signed variable width integer.
Referenced by readSignedVarInts().
|
inline |
Definition at line 172 of file BytecodeImplementation.h.
References readList(), and readSignedVarInt().
|
inline |
Read a "small" sparse array of integer <= 32 bits elements, where index/value pairs can be compressed when the array is small.
Note that only some position of the array will be read and the ones not stored in the bytecode are gonne be left untouched. If the provided array is too small for the stored indices, an error will be returned.
Definition at line 194 of file BytecodeImplementation.h.
References emitError(), mlir::failed(), mlir::failure(), readVarInt(), readVarIntWithFlag(), and mlir::success().
|
pure virtual |
Read a string from the bytecode.
|
inline |
Definition at line 141 of file BytecodeImplementation.h.
References emitError(), mlir::failed(), mlir::failure(), readType(), and mlir::success().
|
pure virtual |
Read a reference to the given type.
Referenced by readType(), and readTypes().
|
inline |
Definition at line 137 of file BytecodeImplementation.h.
References readList(), and readType().
|
pure virtual |
Read a variable width integer.
Referenced by readList(), readSparseArray(), and readVarIntWithFlag().
|
inline |
Parse a variable length encoded integer whose low bit is used to encode an unrelated flag, i.e: (integerValue << 1) | (flag ? 1 : 0)
.
Definition at line 179 of file BytecodeImplementation.h.
References mlir::failed(), mlir::failure(), readVarInt(), and mlir::success().
Referenced by readSparseArray().