MLIR  19.0.0git
Public Types | Public Member Functions | List of all members
mlir::AsmResourceBlob Class Reference

The following classes enable support for parsing and printing resources within MLIR assembly formats. More...

#include "mlir/IR/AsmState.h"

Public Types

using DeleterFn = llvm::unique_function< void(void *data, size_t size, size_t align)>
 A deleter function that frees a blob given the data, allocation size, and allocation aligment. More...
 

Public Member Functions

 AsmResourceBlob ()=default
 
 AsmResourceBlob (ArrayRef< char > data, size_t dataAlignment, DeleterFn deleter, bool dataIsMutable)
 
template<typename T , typename DelT >
 AsmResourceBlob (ArrayRef< T > data, DelT &&deleteFn, bool dataIsMutable)
 Utility constructor that initializes a blob with a non-char type T. More...
 
 AsmResourceBlob (AsmResourceBlob &&)=default
 
AsmResourceBloboperator= (AsmResourceBlob &&rhs)
 
 AsmResourceBlob (const AsmResourceBlob &)=delete
 
AsmResourceBloboperator= (const AsmResourceBlob &)=delete
 
 ~AsmResourceBlob ()
 
size_t getDataAlignment () const
 Return the alignment of the underlying data. More...
 
ArrayRef< char > getData () const
 Return the raw underlying data of this blob. More...
 
template<typename T >
ArrayRef< T > getDataAs () const
 Return the underlying data as an array of the given type. More...
 
MutableArrayRef< char > getMutableData ()
 Return a mutable reference to the raw underlying data of this blob. More...
 
bool isMutable () const
 Return if the data of this blob is mutable. More...
 
DeleterFngetDeleter ()
 Return the deleter function of this blob. More...
 
const DeleterFngetDeleter () const
 

Detailed Description

The following classes enable support for parsing and printing resources within MLIR assembly formats.

Resources are a mechanism by which dialects, and external clients, may attach additional information when parsing or printing IR without that information being encoded in the IR itself. Resources are not uniqued within the MLIR context, are not attached directly to any operation, and are solely intended to live and be processed outside of the immediate IR.

Resources are encoded using a key-value pair nested within dictionaries anchored either on a dialect, or an externally registered entity. Dictionaries anchored on dialects use the dialect namespace directly, and dictionaries anchored on external entities use a provided unique identifier. The resource key is an identifier used to disambiguate the data. The resource value may be stored in various limited forms, but general encodings use a string (human readable) or blob format (binary). Within the textual format, an example may be of the form:

{-# // The dialect_resources section within the file-level metadata // dictionary is used to contain any dialect resource entries. dialect_resources: { // Here is a dictionary anchored on "foo_dialect", which is a dialect // namespace. foo_dialect: { // some_dialect_resource is a key to be interpreted by the dialect, // and used to initialize/configure/etc. some_dialect_resource: "Some important resource value" } }, // The external_resources section within the file-level metadata // dictionary is used to contain any non-dialect resource entries. external_resources: { // Here is a dictionary anchored on "mlir_reproducer", which is an // external entity representing MLIR's crash reproducer functionality. mlir_reproducer: { // pipeline is an entry that holds a crash reproducer pipeline // resource. pipeline: "func.func(canonicalize,cse)" } } #-} This class represents a processed binary blob of data. A resource blob is essentially a collection of data, potentially mutable, with an associated deleter function (used if the data needs to be destroyed).

Definition at line 88 of file AsmState.h.

Member Typedef Documentation

◆ DeleterFn

using mlir::AsmResourceBlob::DeleterFn = llvm::unique_function<void(void *data, size_t size, size_t align)>

A deleter function that frees a blob given the data, allocation size, and allocation aligment.

Definition at line 92 of file AsmState.h.

Constructor & Destructor Documentation

◆ AsmResourceBlob() [1/5]

mlir::AsmResourceBlob::AsmResourceBlob ( )
default

◆ AsmResourceBlob() [2/5]

mlir::AsmResourceBlob::AsmResourceBlob ( ArrayRef< char >  data,
size_t  dataAlignment,
DeleterFn  deleter,
bool  dataIsMutable 
)
inline

Definition at line 100 of file AsmState.h.

◆ AsmResourceBlob() [3/5]

template<typename T , typename DelT >
mlir::AsmResourceBlob::AsmResourceBlob ( ArrayRef< T >  data,
DelT &&  deleteFn,
bool  dataIsMutable 
)
inline

Utility constructor that initializes a blob with a non-char type T.

Definition at line 106 of file AsmState.h.

◆ AsmResourceBlob() [4/5]

mlir::AsmResourceBlob::AsmResourceBlob ( AsmResourceBlob &&  )
default

◆ AsmResourceBlob() [5/5]

mlir::AsmResourceBlob::AsmResourceBlob ( const AsmResourceBlob )
delete

◆ ~AsmResourceBlob()

mlir::AsmResourceBlob::~AsmResourceBlob ( )
inline

Definition at line 129 of file AsmState.h.

Member Function Documentation

◆ getData()

ArrayRef<char> mlir::AsmResourceBlob::getData ( ) const
inline

Return the raw underlying data of this blob.

Definition at line 142 of file AsmState.h.

Referenced by mlir::AsmResourceBuilder::buildBlob(), convertDenseResourceElementsAttr(), and mlir::detail::DenseResourceElementsAttrBase< T >::get().

◆ getDataAlignment()

size_t mlir::AsmResourceBlob::getDataAlignment ( ) const
inline

Return the alignment of the underlying data.

Definition at line 139 of file AsmState.h.

Referenced by mlir::AsmResourceBuilder::buildBlob(), and mlir::detail::DenseResourceElementsAttrBase< T >::get().

◆ getDataAs()

template<typename T >
ArrayRef<T> mlir::AsmResourceBlob::getDataAs ( ) const
inline

Return the underlying data as an array of the given type.

This is an inherrently unsafe operation, and should only be used when the data is known to be of the correct type.

Definition at line 148 of file AsmState.h.

◆ getDeleter() [1/2]

DeleterFn& mlir::AsmResourceBlob::getDeleter ( )
inline

Return the deleter function of this blob.

Definition at line 164 of file AsmState.h.

◆ getDeleter() [2/2]

const DeleterFn& mlir::AsmResourceBlob::getDeleter ( ) const
inline

Definition at line 165 of file AsmState.h.

◆ getMutableData()

MutableArrayRef<char> mlir::AsmResourceBlob::getMutableData ( )
inline

Return a mutable reference to the raw underlying data of this blob.

Asserts that the blob isMutable.

Definition at line 154 of file AsmState.h.

References isMutable().

Referenced by mlir::HeapAsmResourceBlob::allocateAndCopyWithAlign().

◆ isMutable()

bool mlir::AsmResourceBlob::isMutable ( ) const
inline

Return if the data of this blob is mutable.

Definition at line 161 of file AsmState.h.

Referenced by getMutableData().

◆ operator=() [1/2]

AsmResourceBlob& mlir::AsmResourceBlob::operator= ( AsmResourceBlob &&  rhs)
inline

Definition at line 115 of file AsmState.h.

◆ operator=() [2/2]

AsmResourceBlob& mlir::AsmResourceBlob::operator= ( const AsmResourceBlob )
delete

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