MLIR 22.0.0git
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
using ParserFn
using PrinterFn

Public Member Functions

void setVerifyFn (VerifierFn &&verify)
 Sets the verifier function for this attribute.
void setParseFn (ParserFn &&parse)
 Sets the static hook for parsing this attribute assembly.
void setPrintFn (PrinterFn &&print)
 Sets the static hook for printing this attribute assembly.
LogicalResult verify (function_ref< InFlightDiagnostic()> emitError, ArrayRef< Attribute > params) const
 Check that the attribute parameters are valid.
MLIRContextgetContext () const
 Return the MLIRContext in which the dynamic attributes are uniqued.
StringRef getName () const
 Return the name of the attribute, in the format 'attrname' and not 'dialectname.attrname'.
ExtensibleDialectgetDialect () const
 Return the dialect defining the attribute.
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.
TypeID getTypeID () const
 Return the TypeID owned by this object.

Static Public Member Functions

static std::unique_ptr< DynamicAttrDefinitionget (StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier)
 Create a new attribute definition at runtime.
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

Initial value:
llvm::unique_function<ParseResult(
AsmParser &parser, llvm::SmallVectorImpl<Attribute> &parsedAttributes)
const>
This base class exposes generic asm parser hooks, usable across the various derived parsers.

Definition at line 60 of file ExtensibleDialect.h.

◆ PrinterFn

Initial value:
llvm::unique_function<void(
AsmPrinter &printer, ArrayRef<Attribute> params) const>
This base class exposes generic asm printer hooks, usable across the various derived printers.

Definition at line 63 of file ExtensibleDialect.h.

◆ VerifierFn

Initial value:
llvm::unique_function<LogicalResult(
This class represents a diagnostic that is inflight and set to be reported.
llvm::function_ref< Fn > function_ref
Definition LLVM.h:152

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 176 of file ExtensibleDialect.cpp.

References get(), typeOrAttrParser(), and typeOrAttrPrinter().

Referenced by get(), mlir::ExtensibleDialect::lookupAttrDefinition(), and preallocateAttrDefs().

◆ get() [2/2]

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

Definition at line 183 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.

◆ 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().

◆ 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.

◆ 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: