MLIR  20.0.0git
Public Member Functions | List of all members
mlir::DialectBytecodeReader Class Referenceabstract

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 MLIRContextgetContext () 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...
 

Detailed Description

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 46 of file BytecodeImplementation.h.

Constructor & Destructor Documentation

◆ ~DialectBytecodeReader()

virtual mlir::DialectBytecodeReader::~DialectBytecodeReader ( )
virtualdefault

Member Function Documentation

◆ emitError()

virtual InFlightDiagnostic mlir::DialectBytecodeReader::emitError ( const Twine &  msg = {}) const
pure virtual

◆ getBytecodeVersion()

virtual uint64_t mlir::DialectBytecodeReader::getBytecodeVersion ( ) const
pure virtual

Return the bytecode version being read.

◆ getContext()

virtual MLIRContext* mlir::DialectBytecodeReader::getContext ( ) const
pure virtual

Retrieve the context associated to the reader.

◆ getDialectVersion() [1/2]

template<class T >
FailureOr<const DialectVersion *> mlir::DialectBytecodeReader::getDialectVersion ( ) const
inline

Definition at line 57 of file BytecodeImplementation.h.

◆ getDialectVersion() [2/2]

virtual FailureOr<const DialectVersion *> mlir::DialectBytecodeReader::getDialectVersion ( StringRef  dialectName) const
pure virtual

Retrieve the dialect version by name if available.

◆ readAPFloatWithKnownSemantics()

virtual FailureOr<APFloat> mlir::DialectBytecodeReader::readAPFloatWithKnownSemantics ( const llvm::fltSemantics &  semantics)
pure virtual

Read an APFloat that is known to have been encoded with the given semantics.

◆ readAPIntWithKnownWidth()

virtual FailureOr<APInt> mlir::DialectBytecodeReader::readAPIntWithKnownWidth ( unsigned  bitWidth)
pure virtual

Read an APInt that is known to have been encoded with the given width.

◆ readAttribute() [1/2]

virtual LogicalResult mlir::DialectBytecodeReader::readAttribute ( Attribute result)
pure virtual

Read a reference to the given attribute.

Referenced by readAttribute(), and readAttributes().

◆ readAttribute() [2/2]

template<typename T >
LogicalResult mlir::DialectBytecodeReader::readAttribute ( T &  result)
inline

Definition at line 111 of file BytecodeImplementation.h.

References emitError(), and readAttribute().

◆ readAttributes()

template<typename T >
LogicalResult mlir::DialectBytecodeReader::readAttributes ( SmallVectorImpl< T > &  attrs)
inline

Definition at line 107 of file BytecodeImplementation.h.

References readAttribute(), and readList().

◆ readBlob()

virtual LogicalResult mlir::DialectBytecodeReader::readBlob ( ArrayRef< char > &  result)
pure virtual

Read a blob from the bytecode.

◆ readBool()

virtual LogicalResult mlir::DialectBytecodeReader::readBool ( bool &  result)
pure virtual

Read a bool from the bytecode.

◆ readList()

template<typename T , typename CallbackFn >
LogicalResult mlir::DialectBytecodeReader::readList ( SmallVectorImpl< T > &  result,
CallbackFn &&  callback 
)
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:

  • LogicalResult(T &)
  • FailureOr<T>()

Definition at line 72 of file BytecodeImplementation.h.

References readVarInt().

Referenced by readAttributes(), readSignedVarInts(), and readTypes().

◆ readOptionalAttribute() [1/2]

virtual LogicalResult mlir::DialectBytecodeReader::readOptionalAttribute ( Attribute attr)
pure virtual

Read an optional reference to the given attribute.

Returns success even if the Attribute isn't present.

Referenced by readOptionalAttribute().

◆ readOptionalAttribute() [2/2]

template<typename T >
LogicalResult mlir::DialectBytecodeReader::readOptionalAttribute ( T &  result)
inline

Definition at line 121 of file BytecodeImplementation.h.

References emitError(), and readOptionalAttribute().

◆ readResourceHandle()

template<typename ResourceT >
FailureOr<ResourceT> mlir::DialectBytecodeReader::readResourceHandle ( )
inline

Read a handle to a dialect resource.

Definition at line 152 of file BytecodeImplementation.h.

References emitError().

Referenced by mlir::readResourceHandle().

◆ readSignedVarInt()

virtual LogicalResult mlir::DialectBytecodeReader::readSignedVarInt ( int64_t &  result)
pure virtual

Read a signed variable width integer.

Referenced by readSignedVarInts().

◆ readSignedVarInts()

LogicalResult mlir::DialectBytecodeReader::readSignedVarInts ( SmallVectorImpl< int64_t > &  result)
inline

Definition at line 171 of file BytecodeImplementation.h.

References readList(), and readSignedVarInt().

◆ readSparseArray()

template<typename T >
LogicalResult mlir::DialectBytecodeReader::readSparseArray ( MutableArrayRef< T >  array)
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 193 of file BytecodeImplementation.h.

References emitError(), readVarInt(), and readVarIntWithFlag().

◆ readString()

virtual LogicalResult mlir::DialectBytecodeReader::readString ( StringRef &  result)
pure virtual

Read a string from the bytecode.

◆ readType() [1/2]

template<typename T >
LogicalResult mlir::DialectBytecodeReader::readType ( T &  result)
inline

Definition at line 140 of file BytecodeImplementation.h.

References emitError(), and readType().

◆ readType() [2/2]

virtual LogicalResult mlir::DialectBytecodeReader::readType ( Type result)
pure virtual

Read a reference to the given type.

Referenced by readType(), and readTypes().

◆ readTypes()

template<typename T >
LogicalResult mlir::DialectBytecodeReader::readTypes ( SmallVectorImpl< T > &  types)
inline

Definition at line 136 of file BytecodeImplementation.h.

References readList(), and readType().

◆ readVarInt()

virtual LogicalResult mlir::DialectBytecodeReader::readVarInt ( uint64_t &  result)
pure virtual

Read a variable width integer.

Referenced by readList(), readSparseArray(), and readVarIntWithFlag().

◆ readVarIntWithFlag()

LogicalResult mlir::DialectBytecodeReader::readVarIntWithFlag ( uint64_t &  result,
bool &  flag 
)
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 178 of file BytecodeImplementation.h.

References readVarInt().

Referenced by readSparseArray().


The documentation for this class was generated from the following file: