MLIR 22.0.0git
mlir::BytecodeWriterConfig Class Reference

This class contains the configuration used for the bytecode writer. More...

#include "mlir/Bytecode/BytecodeWriter.h"

Classes

struct  Impl

Public Member Functions

 BytecodeWriterConfig (StringRef producer="MLIR" LLVM_VERSION_STRING)
 producer is an optional string that can be used to identify the producer of the bytecode when reading.
 BytecodeWriterConfig (FallbackAsmResourceMap &map, StringRef producer="MLIR" LLVM_VERSION_STRING)
 map is a fallback resource map, which when provided will attach resource printers for the fallback resources within the map.
 BytecodeWriterConfig (BytecodeWriterConfig &&)
 ~BytecodeWriterConfig ()
const ImplgetImpl () const
 Return an instance of the internal implementation.
void setDesiredBytecodeVersion (int64_t bytecodeVersion)
 Set the desired bytecode version to emit.
int64_t getDesiredBytecodeVersion () const
 Get the set desired bytecode version to emit.
llvm::StringMap< std::unique_ptr< DialectVersion > > & getDialectVersionMap () const
 A map containing the dialect versions to emit.
template<class T>
void setDialectVersion (std::unique_ptr< DialectVersion > dialectVersion) const
 Set a given dialect version to emit on the map.
void setDialectVersion (StringRef dialectName, std::unique_ptr< DialectVersion > dialectVersion) const
ArrayRef< std::unique_ptr< AttrTypeBytecodeWriter< Attribute > > > getAttributeWriterCallbacks () const
 Retrieve the callbacks.
ArrayRef< std::unique_ptr< AttrTypeBytecodeWriter< Type > > > getTypeWriterCallbacks () const
void attachAttributeCallback (std::unique_ptr< AttrTypeBytecodeWriter< Attribute > > callback)
 Attach a custom bytecode printer callback to the configuration for the emission of custom type/attributes encodings.
void attachTypeCallback (std::unique_ptr< AttrTypeBytecodeWriter< Type > > callback)
template<typename CallableT>
std::enable_if_t< std::is_convertible_v< CallableT, std::function< LogicalResult(Attribute, std::optional< StringRef > &, DialectBytecodeWriter &)> > > attachAttributeCallback (CallableT &&emitFn)
 Attach a custom bytecode printer callback to the configuration for the emission of custom type/attributes encodings.
template<typename CallableT>
std::enable_if_t< std::is_convertible_v< CallableT, std::function< LogicalResult(Type, std::optional< StringRef > &, DialectBytecodeWriter &)> > > attachTypeCallback (CallableT &&emitFn)
void setElideResourceDataFlag (bool shouldElideResourceData=true)
 Set a boolean flag to skip emission of resources into the bytecode file.
void attachResourcePrinter (std::unique_ptr< AsmResourcePrinter > printer)
 Attach the given resource printer to the writer configuration.
template<typename CallableT>
std::enable_if_t< std::is_convertible< CallableT, function_ref< void(Operation *, AsmResourceBuilder &)> >::value > attachResourcePrinter (StringRef name, CallableT &&printFn)
 Attach an resource printer, in the form of a callable, to the configuration.
void attachFallbackResourcePrinter (FallbackAsmResourceMap &map)
 Attach resource printers to the AsmState for the fallback resources in the given map.

Detailed Description

This class contains the configuration used for the bytecode writer.

It controls various aspects of bytecode generation, and contains all of the various bytecode writer hooks.

Definition at line 75 of file BytecodeWriter.h.

Constructor & Destructor Documentation

◆ BytecodeWriterConfig() [1/3]

BytecodeWriterConfig::BytecodeWriterConfig ( StringRef producer = "MLIR" LLVM_VERSION_STRING)

producer is an optional string that can be used to identify the producer of the bytecode when reading.

It has no functional effect on the bytecode serialization.

Definition at line 63 of file BytecodeWriter.cpp.

Referenced by BytecodeWriterConfig(), and BytecodeWriterConfig().

◆ BytecodeWriterConfig() [2/3]

BytecodeWriterConfig::BytecodeWriterConfig ( FallbackAsmResourceMap & map,
StringRef producer = "MLIR" LLVM_VERSION_STRING )

map is a fallback resource map, which when provided will attach resource printers for the fallback resources within the map.

Definition at line 65 of file BytecodeWriter.cpp.

References attachFallbackResourcePrinter(), and BytecodeWriterConfig().

◆ BytecodeWriterConfig() [3/3]

BytecodeWriterConfig::BytecodeWriterConfig ( BytecodeWriterConfig && config)

Definition at line 70 of file BytecodeWriter.cpp.

References BytecodeWriterConfig(), and mlir::config.

◆ ~BytecodeWriterConfig()

BytecodeWriterConfig::~BytecodeWriterConfig ( )
default

Member Function Documentation

◆ attachAttributeCallback() [1/2]

template<typename CallableT>
std::enable_if_t< std::is_convertible_v< CallableT, std::function< LogicalResult(Attribute, std::optional< StringRef > &, DialectBytecodeWriter &)> > > mlir::BytecodeWriterConfig::attachAttributeCallback ( CallableT && emitFn)
inline

Attach a custom bytecode printer callback to the configuration for the emission of custom type/attributes encodings.

Definition at line 140 of file BytecodeWriter.h.

References attachAttributeCallback(), and mlir::AttrTypeBytecodeWriter< T >::fromCallable().

◆ attachAttributeCallback() [2/2]

void BytecodeWriterConfig::attachAttributeCallback ( std::unique_ptr< AttrTypeBytecodeWriter< Attribute > > callback)

Attach a custom bytecode printer callback to the configuration for the emission of custom type/attributes encodings.

Definition at line 85 of file BytecodeWriter.cpp.

Referenced by attachAttributeCallback().

◆ attachFallbackResourcePrinter()

void mlir::BytecodeWriterConfig::attachFallbackResourcePrinter ( FallbackAsmResourceMap & map)
inline

Attach resource printers to the AsmState for the fallback resources in the given map.

Definition at line 175 of file BytecodeWriter.h.

References attachResourcePrinter(), and mlir::FallbackAsmResourceMap::getPrinters().

Referenced by BytecodeWriterConfig().

◆ attachResourcePrinter() [1/2]

void BytecodeWriterConfig::attachResourcePrinter ( std::unique_ptr< AsmResourcePrinter > printer)

Attach the given resource printer to the writer configuration.

Definition at line 95 of file BytecodeWriter.cpp.

Referenced by attachFallbackResourcePrinter(), and attachResourcePrinter().

◆ attachResourcePrinter() [2/2]

template<typename CallableT>
std::enable_if_t< std::is_convertible< CallableT, function_ref< void(Operation *, AsmResourceBuilder &)> >::value > mlir::BytecodeWriterConfig::attachResourcePrinter ( StringRef name,
CallableT && printFn )
inline

Attach an resource printer, in the form of a callable, to the configuration.

Definition at line 168 of file BytecodeWriter.h.

References attachResourcePrinter(), and mlir::AsmResourcePrinter::fromCallable().

◆ attachTypeCallback() [1/2]

template<typename CallableT>
std::enable_if_t< std::is_convertible_v< CallableT, std::function< LogicalResult(Type, std::optional< StringRef > &, DialectBytecodeWriter &)> > > mlir::BytecodeWriterConfig::attachTypeCallback ( CallableT && emitFn)
inline

◆ attachTypeCallback() [2/2]

void BytecodeWriterConfig::attachTypeCallback ( std::unique_ptr< AttrTypeBytecodeWriter< Type > > callback)

Definition at line 90 of file BytecodeWriter.cpp.

Referenced by attachTypeCallback().

◆ getAttributeWriterCallbacks()

ArrayRef< std::unique_ptr< AttrTypeBytecodeWriter< Attribute > > > BytecodeWriterConfig::getAttributeWriterCallbacks ( ) const

Retrieve the callbacks.

Definition at line 76 of file BytecodeWriter.cpp.

◆ getDesiredBytecodeVersion()

int64_t BytecodeWriterConfig::getDesiredBytecodeVersion ( ) const

Get the set desired bytecode version to emit.

Definition at line 109 of file BytecodeWriter.cpp.

◆ getDialectVersionMap()

llvm::StringMap< std::unique_ptr< DialectVersion > > & BytecodeWriterConfig::getDialectVersionMap ( ) const

A map containing the dialect versions to emit.

Definition at line 114 of file BytecodeWriter.cpp.

◆ getImpl()

const Impl & mlir::BytecodeWriterConfig::getImpl ( ) const
inline

Return an instance of the internal implementation.

Definition at line 93 of file BytecodeWriter.h.

◆ getTypeWriterCallbacks()

ArrayRef< std::unique_ptr< AttrTypeBytecodeWriter< Type > > > BytecodeWriterConfig::getTypeWriterCallbacks ( ) const

Definition at line 81 of file BytecodeWriter.cpp.

◆ setDesiredBytecodeVersion()

void BytecodeWriterConfig::setDesiredBytecodeVersion ( int64_t bytecodeVersion)

Set the desired bytecode version to emit.

This method does not validate the desired version. The bytecode writer entry point will return failure if it cannot emit the desired version.

Definition at line 105 of file BytecodeWriter.cpp.

Referenced by performActions().

◆ setDialectVersion() [1/2]

template<class T>
void mlir::BytecodeWriterConfig::setDialectVersion ( std::unique_ptr< DialectVersion > dialectVersion) const
inline

Set a given dialect version to emit on the map.

Definition at line 109 of file BytecodeWriter.h.

References setDialectVersion().

Referenced by setDialectVersion().

◆ setDialectVersion() [2/2]

void mlir::BytecodeWriterConfig::setDialectVersion ( StringRef dialectName,
std::unique_ptr< DialectVersion > dialectVersion ) const

◆ setElideResourceDataFlag()

void BytecodeWriterConfig::setElideResourceDataFlag ( bool shouldElideResourceData = true)

Set a boolean flag to skip emission of resources into the bytecode file.

Definition at line 100 of file BytecodeWriter.cpp.

Referenced by performActions().


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