MLIR  20.0.0git
Classes | Public Member Functions | List of all members
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. More...
 
 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. More...
 
 ~BytecodeWriterConfig ()
 
const ImplgetImpl () const
 Return an instance of the internal implementation. More...
 
void setDesiredBytecodeVersion (int64_t bytecodeVersion)
 Set the desired bytecode version to emit. More...
 
int64_t getDesiredBytecodeVersion () const
 Get the set desired bytecode version to emit. More...
 
llvm::StringMap< std::unique_ptr< DialectVersion > > & getDialectVersionMap () const
 A map containing the dialect versions to emit. More...
 
template<class T >
void setDialectVersion (std::unique_ptr< DialectVersion > dialectVersion) const
 Set a given dialect version to emit on the map. More...
 
void setDialectVersion (StringRef dialectName, std::unique_ptr< DialectVersion > dialectVersion) const
 
ArrayRef< std::unique_ptr< AttrTypeBytecodeWriter< Attribute > > > getAttributeWriterCallbacks () const
 Retrieve the callbacks. More...
 
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. More...
 
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. More...
 
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. More...
 
void attachResourcePrinter (std::unique_ptr< AsmResourcePrinter > printer)
 Attach the given resource printer to the writer configuration. More...
 
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. More...
 
void attachFallbackResourcePrinter (FallbackAsmResourceMap &map)
 Attach resource printers to the AsmState for the fallback resources in the given map. More...
 

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/2]

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 62 of file BytecodeWriter.cpp.

◆ BytecodeWriterConfig() [2/2]

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 64 of file BytecodeWriter.cpp.

References attachFallbackResourcePrinter().

◆ ~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 139 of file BytecodeWriter.h.

References attachAttributeCallback().

◆ 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 81 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 174 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 91 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 167 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

Definition at line 147 of file BytecodeWriter.h.

References attachTypeCallback().

◆ attachTypeCallback() [2/2]

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

Definition at line 86 of file BytecodeWriter.cpp.

Referenced by attachTypeCallback().

◆ getAttributeWriterCallbacks()

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

Retrieve the callbacks.

Definition at line 72 of file BytecodeWriter.cpp.

◆ getDesiredBytecodeVersion()

int64_t BytecodeWriterConfig::getDesiredBytecodeVersion ( ) const

Get the set desired bytecode version to emit.

Definition at line 105 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 110 of file BytecodeWriter.cpp.

◆ getImpl()

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

Return an instance of the internal implementation.

Definition at line 92 of file BytecodeWriter.h.

◆ getTypeWriterCallbacks()

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

Definition at line 77 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 101 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 108 of file BytecodeWriter.h.

◆ 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 96 of file BytecodeWriter.cpp.

Referenced by performActions().


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