MLIR  16.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:
+ Collaboration 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

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 54 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 62 of file ExtensibleDialect.h.

◆ VerifierFn

Definition at line 57 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 178 of file ExtensibleDialect.cpp.

References typeOrAttrParser(), and typeOrAttrPrinter().

Referenced by mlir::ExtensibleDialect::lookupAttrDefinition().

◆ get() [2/2]

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

◆ getContext()

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

Return the MLIRContext in which the dynamic attributes are uniqued.

Definition at line 79 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 86 of file ExtensibleDialect.h.

◆ getName()

StringRef mlir::DynamicAttrDefinition::getName ( ) const
inline

Return the name of the attribute, in the format 'attrname' and not 'dialectname.attrname'.

Definition at line 83 of file ExtensibleDialect.h.

◆ verify()

LogicalResult mlir::DynamicAttrDefinition::verify ( function_ref< InFlightDiagnostic()>  emitError,
ArrayRef< Attribute params 
) const
inline

Check that the attribute parameters are valid.

Definition at line 73 of file ExtensibleDialect.h.

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


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