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

The definition of a dynamic type. More...

#include "mlir/IR/ExtensibleDialect.h"

+ Inheritance diagram for mlir::DynamicTypeDefinition:

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 type. More...
 
void setParseFn (ParserFn &&parse)
 Sets the static hook for parsing this type assembly. More...
 
void setPrintFn (PrinterFn &&print)
 Sets the static hook for printing this type assembly. More...
 
LogicalResult verify (function_ref< InFlightDiagnostic()> emitError, ArrayRef< Attribute > params) const
 Check that the type parameters are valid. More...
 
MLIRContextgetContext () const
 Return the MLIRContext in which the dynamic types is uniqued. More...
 
StringRef getName () const
 Return the name of the type, in the format 'typename' and not 'dialectname.typename'. More...
 
ExtensibleDialectgetDialect () const
 Return the dialect defining the type. 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< DynamicTypeDefinitionget (StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier)
 Create a new dynamic type definition. More...
 
static std::unique_ptr< DynamicTypeDefinitionget (StringRef name, ExtensibleDialect *dialect, VerifierFn &&verifier, ParserFn &&parser, PrinterFn &&printer)
 

Detailed Description

The definition of a dynamic type.

A dynamic type is a type 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 type. Each dynamic type definition refers to one instance of this class.

Definition at line 213 of file ExtensibleDialect.h.

Member Typedef Documentation

◆ ParserFn

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

Definition at line 217 of file ExtensibleDialect.h.

◆ PrinterFn

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

Definition at line 220 of file ExtensibleDialect.h.

◆ VerifierFn

Definition at line 215 of file ExtensibleDialect.h.

Member Function Documentation

◆ get() [1/2]

std::unique_ptr< DynamicTypeDefinition > DynamicTypeDefinition::get ( StringRef  name,
ExtensibleDialect dialect,
VerifierFn &&  verifier 
)
static

Create a new dynamic type definition.

The type is registered only after passing it to the dialect using registerDynamicType.

Definition at line 61 of file ExtensibleDialect.cpp.

References typeOrAttrParser(), and typeOrAttrPrinter().

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

◆ get() [2/2]

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

Definition at line 68 of file ExtensibleDialect.cpp.

◆ getContext()

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

Return the MLIRContext in which the dynamic types is uniqued.

Definition at line 249 of file ExtensibleDialect.h.

Referenced by mlir::DynamicType::get(), and mlir::DynamicType::getChecked().

◆ getDialect()

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

Return the dialect defining the type.

Definition at line 256 of file ExtensibleDialect.h.

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

◆ getName()

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

Return the name of the type, in the format 'typename' and not 'dialectname.typename'.

Definition at line 253 of file ExtensibleDialect.h.

Referenced by mlir::DynamicType::print(), mlir::ExtensibleDialect::registerDynamicType(), and mlir::irdl::DynParametricTypeConstraint::verify().

◆ setParseFn()

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

Sets the static hook for parsing this type assembly.

Definition at line 237 of file ExtensibleDialect.h.

References mlir::query::parse().

◆ setPrintFn()

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

Sets the static hook for printing this type assembly.

Definition at line 240 of file ExtensibleDialect.h.

References print().

◆ setVerifyFn()

void mlir::DynamicTypeDefinition::setVerifyFn ( VerifierFn &&  verify)
inline

Sets the verifier function for this type.

It should emits an error message and returns failure if a problem is detected, or returns success if everything is ok.

Definition at line 234 of file ExtensibleDialect.h.

References verify().

◆ verify()

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

Check that the type parameters are valid.

Definition at line 243 of file ExtensibleDialect.h.

References mlir::emitError().

Referenced by mlir::DynamicType::get(), mlir::DynamicType::getChecked(), and setVerifyFn().


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