MLIR
20.0.0git
|
The definition of a dynamic attribute. More...
#include "mlir/IR/ExtensibleDialect.h"
Public Types | |
using | VerifierFn = llvm::unique_function< LogicalResult(function_ref< InFlightDiagnostic()>, ArrayRef< Attribute >) const > |
using | ParserFn = llvm::unique_function< ParseResult(AsmParser &parser, llvm::SmallVectorImpl< Attribute > &parsedAttributes) const > |
using | PrinterFn = llvm::unique_function< void(AsmPrinter &printer, ArrayRef< Attribute > params) const > |
Public Member Functions | |
void | setVerifyFn (VerifierFn &&verify) |
Sets the verifier function for this attribute. More... | |
void | setParseFn (ParserFn &&parse) |
Sets the static hook for parsing this attribute assembly. More... | |
void | setPrintFn (PrinterFn &&print) |
Sets the static hook for printing this attribute assembly. More... | |
LogicalResult | verify (function_ref< InFlightDiagnostic()> emitError, ArrayRef< Attribute > params) const |
Check that the attribute parameters are valid. More... | |
MLIRContext & | getContext () const |
Return the MLIRContext in which the dynamic attributes are uniqued. More... | |
StringRef | getName () const |
Return the name of the attribute, in the format 'attrname' and not 'dialectname.attrname'. More... | |
ExtensibleDialect * | getDialect () const |
Return the dialect defining the attribute. More... | |
Public Member Functions inherited from mlir::SelfOwningTypeID | |
SelfOwningTypeID ()=default | |
SelfOwningTypeID (const SelfOwningTypeID &)=delete | |
SelfOwningTypeID & | operator= (const SelfOwningTypeID &)=delete |
SelfOwningTypeID (SelfOwningTypeID &&)=delete | |
SelfOwningTypeID & | operator= (SelfOwningTypeID &&)=delete |
operator TypeID () const | |
Implicitly converts to the owned TypeID. More... | |
TypeID | getTypeID () const |
Return the TypeID owned by this object. More... | |
Static Public Member Functions | |
static std::unique_ptr< DynamicAttrDefinition > | get (StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier) |
Create a new attribute definition at runtime. More... | |
static std::unique_ptr< DynamicAttrDefinition > | get (StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier, ParserFn &&parser, PrinterFn &&printer) |
The definition of a dynamic attribute.
A dynamic attribute is an attribute that is defined at runtime, and that can be registered at runtime by an extensible dialect (a dialect inheriting ExtensibleDialect). This class stores the parser, the printer, and the verifier of the attribute. Each dynamic attribute definition refers to one instance of this class.
Definition at line 56 of file ExtensibleDialect.h.
using mlir::DynamicAttrDefinition::ParserFn = llvm::unique_function<ParseResult( AsmParser &parser, llvm::SmallVectorImpl<Attribute> &parsedAttributes) const> |
Definition at line 60 of file ExtensibleDialect.h.
using mlir::DynamicAttrDefinition::PrinterFn = llvm::unique_function<void( AsmPrinter &printer, ArrayRef<Attribute> params) const> |
Definition at line 63 of file ExtensibleDialect.h.
using mlir::DynamicAttrDefinition::VerifierFn = llvm::unique_function<LogicalResult( function_ref<InFlightDiagnostic()>, ArrayRef<Attribute>) const> |
Definition at line 58 of file ExtensibleDialect.h.
|
static |
Create a new attribute definition at runtime.
The attribute is registered only after passing it to the dialect using registerDynamicAttr.
Definition at line 177 of file ExtensibleDialect.cpp.
References typeOrAttrParser(), and typeOrAttrPrinter().
|
static |
Definition at line 184 of file ExtensibleDialect.cpp.
|
inline |
Return the MLIRContext in which the dynamic attributes are uniqued.
Definition at line 92 of file ExtensibleDialect.h.
Referenced by mlir::DynamicAttr::get().
|
inline |
Return the dialect defining the attribute.
Definition at line 99 of file ExtensibleDialect.h.
Referenced by mlir::irdl::DynParametricAttrConstraint::verify().
|
inline |
Return the name of the attribute, in the format 'attrname' and not 'dialectname.attrname'.
Definition at line 96 of file ExtensibleDialect.h.
Referenced by mlir::DynamicAttr::print(), and mlir::irdl::DynParametricAttrConstraint::verify().
|
inline |
Sets the static hook for parsing this attribute assembly.
Definition at line 80 of file ExtensibleDialect.h.
References mlir::query::parse().
|
inline |
Sets the static hook for printing this attribute assembly.
Definition at line 83 of file ExtensibleDialect.h.
References print().
|
inline |
Sets the verifier function for this attribute.
It should emits an error message and returns failure if a problem is detected, or returns success if everything is ok.
Definition at line 77 of file ExtensibleDialect.h.
References verify().
|
inline |
Check that the attribute parameters are valid.
Definition at line 86 of file ExtensibleDialect.h.
References mlir::emitError().
Referenced by mlir::DynamicAttr::getChecked(), and setVerifyFn().