MLIR  20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
mlir::DynamicAttrDefinition Class Reference

The definition of a dynamic attribute. More...

#include "mlir/IR/ExtensibleDialect.h"

+ Inheritance diagram for mlir::DynamicAttrDefinition:

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...
 
MLIRContextgetContext () 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...
 
ExtensibleDialectgetDialect () const
 Return the dialect defining the attribute. More...
 
- Public Member Functions inherited from mlir::SelfOwningTypeID
 SelfOwningTypeID ()=default
 
 SelfOwningTypeID (const SelfOwningTypeID &)=delete
 
SelfOwningTypeIDoperator= (const SelfOwningTypeID &)=delete
 
 SelfOwningTypeID (SelfOwningTypeID &&)=delete
 
SelfOwningTypeIDoperator= (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< DynamicAttrDefinitionget (StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier)
 Create a new attribute definition at runtime. More...
 
static std::unique_ptr< DynamicAttrDefinitionget (StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier, ParserFn &&parser, PrinterFn &&printer)
 

Detailed Description

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.

Member Typedef Documentation

◆ ParserFn

using mlir::DynamicAttrDefinition::ParserFn = llvm::unique_function<ParseResult( AsmParser &parser, llvm::SmallVectorImpl<Attribute> &parsedAttributes) const>

Definition at line 60 of file ExtensibleDialect.h.

◆ PrinterFn

using mlir::DynamicAttrDefinition::PrinterFn = llvm::unique_function<void( AsmPrinter &printer, ArrayRef<Attribute> params) const>

Definition at line 63 of file ExtensibleDialect.h.

◆ VerifierFn

using mlir::DynamicAttrDefinition::VerifierFn = llvm::unique_function<LogicalResult( function_ref<InFlightDiagnostic()>, ArrayRef<Attribute>) const>

Definition at line 58 of file ExtensibleDialect.h.

Member Function Documentation

◆ get() [1/2]

std::unique_ptr< DynamicAttrDefinition > DynamicAttrDefinition::get ( StringRef  name,
ExtensibleDialect dialect,
VerifierFn &&  verifier 
)
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().

◆ get() [2/2]

std::unique_ptr< DynamicAttrDefinition > DynamicAttrDefinition::get ( StringRef  name,
ExtensibleDialect dialect,
VerifierFn &&  verifier,
ParserFn &&  parser,
PrinterFn &&  printer 
)
static

Definition at line 184 of file ExtensibleDialect.cpp.

◆ getContext()

MLIRContext& mlir::DynamicAttrDefinition::getContext ( ) const
inline

Return the MLIRContext in which the dynamic attributes are uniqued.

Definition at line 92 of file ExtensibleDialect.h.

Referenced by mlir::DynamicAttr::get().

◆ getDialect()

ExtensibleDialect* mlir::DynamicAttrDefinition::getDialect ( ) const
inline

Return the dialect defining the attribute.

Definition at line 99 of file ExtensibleDialect.h.

Referenced by mlir::irdl::DynParametricAttrConstraint::verify().

◆ getName()

StringRef mlir::DynamicAttrDefinition::getName ( ) const
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().

◆ setParseFn()

void mlir::DynamicAttrDefinition::setParseFn ( ParserFn &&  parse)
inline

Sets the static hook for parsing this attribute assembly.

Definition at line 80 of file ExtensibleDialect.h.

References mlir::query::parse().

◆ setPrintFn()

void mlir::DynamicAttrDefinition::setPrintFn ( PrinterFn &&  print)
inline

Sets the static hook for printing this attribute assembly.

Definition at line 83 of file ExtensibleDialect.h.

References print().

◆ setVerifyFn()

void mlir::DynamicAttrDefinition::setVerifyFn ( VerifierFn &&  verify)
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().

◆ verify()

LogicalResult mlir::DynamicAttrDefinition::verify ( function_ref< InFlightDiagnostic()>  emitError,
ArrayRef< Attribute params 
) const
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().


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