MLIR 22.0.0git
mlir::ExtensibleDialect Class Reference

A dialect that can be extended with new operations/types/attributes at runtime. More...

#include "mlir/IR/ExtensibleDialect.h"

Inheritance diagram for mlir::ExtensibleDialect:

Public Member Functions

 ExtensibleDialect (StringRef name, MLIRContext *ctx, TypeID typeID)
void registerDynamicType (std::unique_ptr< DynamicTypeDefinition > &&type)
 Add a new type defined at runtime to the dialect.
void registerDynamicAttr (std::unique_ptr< DynamicAttrDefinition > &&attr)
 Add a new attribute defined at runtime to the dialect.
void registerDynamicOp (std::unique_ptr< DynamicOpDefinition > &&type)
 Add a new operation defined at runtime to the dialect.
DynamicTypeDefinitionlookupTypeDefinition (StringRef name) const
 Returns nullptr if the definition was not found.
DynamicTypeDefinitionlookupTypeDefinition (TypeID id) const
 Returns nullptr if the definition was not found.
DynamicAttrDefinitionlookupAttrDefinition (StringRef name) const
 Returns nullptr if the definition was not found.
DynamicAttrDefinitionlookupAttrDefinition (TypeID id) const
 Returns nullptr if the definition was not found.
Public Member Functions inherited from mlir::Dialect
virtual ~Dialect ()
MLIRContextgetContext () const
StringRef getNamespace () const
TypeID getTypeID () const
 Returns the unique identifier that corresponds to this dialect.
bool allowsUnknownOperations () const
 Returns true if this dialect allows for unregistered operations, i.e.
bool allowsUnknownTypes () const
 Return true if this dialect allows for unregistered types, i.e., types prefixed with the dialect namespace but not registered with addType.
virtual void getCanonicalizationPatterns (RewritePatternSet &results) const
 Register dialect-wide canonicalization patterns.
virtual OperationmaterializeConstant (OpBuilder &builder, Attribute value, Type type, Location loc)
 Registered hook to materialize a single constant operation from a given attribute value with the desired resultant type.
virtual Attribute parseAttribute (DialectAsmParser &parser, Type type) const
 Parse an attribute registered to this dialect.
virtual void printAttribute (Attribute, DialectAsmPrinter &) const
 Print an attribute registered to this dialect.
virtual Type parseType (DialectAsmParser &parser) const
 Parse a type registered to this dialect.
virtual void printType (Type, DialectAsmPrinter &) const
 Print a type registered to this dialect.
virtual std::optional< ParseOpHookgetParseOperationHook (StringRef opName) const
 Return the hook to parse an operation registered to this dialect, if any.
virtual llvm::unique_function< void(Operation *, OpAsmPrinter &printer)> getOperationPrinter (Operation *op) const
 Print an operation registered to this dialect.
virtual LogicalResult verifyRegionArgAttribute (Operation *, unsigned regionIndex, unsigned argIndex, NamedAttribute)
 Verify an attribute from this dialect on the argument at 'argIndex' for the region at 'regionIndex' on the given operation.
virtual LogicalResult verifyRegionResultAttribute (Operation *, unsigned regionIndex, unsigned resultIndex, NamedAttribute)
 Verify an attribute from this dialect on the result at 'resultIndex' for the region at 'regionIndex' on the given operation.
virtual LogicalResult verifyOperationAttribute (Operation *, NamedAttribute)
 Verify an attribute from this dialect on the given operation.
DialectInterfacegetRegisteredInterface (TypeID interfaceID)
 Lookup an interface for the given ID if one is registered, otherwise nullptr.
template<typename InterfaceT>
InterfaceT * getRegisteredInterface ()
virtual voidgetRegisteredInterfaceForOp (TypeID interfaceID, OperationName opName)
 Lookup an op interface for the given ID if one is registered, otherwise nullptr.
template<typename InterfaceT>
InterfaceT::Concept * getRegisteredInterfaceForOp (OperationName opName)
void addInterface (std::unique_ptr< DialectInterface > interface)
 Register a dialect interface with this dialect instance.
template<typename... Args>
void addInterfaces ()
 Register a set of dialect interfaces with this dialect instance.
template<typename InterfaceT, typename... Args>
InterfaceT & addInterface (Args &&...args)
template<typename InterfaceT, typename ConcreteT>
void declarePromisedInterface ()
 Declare that the given interface will be implemented, but has a delayed registration.
template<typename InterfaceT, typename... ConcreteT>
void declarePromisedInterfaces ()
void handleUseOfUndefinedPromisedInterface (TypeID interfaceRequestorID, TypeID interfaceID, StringRef interfaceName="")
 Checks if the given interface, which is attempting to be used, is a promised interface of this dialect that has yet to be implemented.
void handleAdditionOfUndefinedPromisedInterface (TypeID interfaceRequestorID, TypeID interfaceID)
 Checks if the given interface, which is attempting to be attached to a construct owned by this dialect, is a promised interface of this dialect that has yet to be implemented.
bool hasPromisedInterface (TypeID interfaceRequestorID, TypeID interfaceID) const
 Checks if a promise has been made for the interface/requestor pair.
template<typename ConcreteT, typename InterfaceT>
bool hasPromisedInterface () const
 Checks if a promise has been made for the interface/requestor pair.

Static Public Member Functions

static bool classof (const Dialect *dialect)
 Check if the dialect is an extensible dialect.
Static Public Member Functions inherited from mlir::Dialect
static bool isValidNamespace (StringRef str)
 Utility function that returns if the given string is a valid dialect namespace.

Protected Member Functions

OptionalParseResult parseOptionalDynamicType (StringRef typeName, AsmParser &parser, Type &resultType) const
 Parse the dynamic type 'typeName' in the dialect 'dialect'.
OptionalParseResult parseOptionalDynamicAttr (StringRef attrName, AsmParser &parser, Attribute &resultAttr) const
 Parse the dynamic attribute 'attrName' in the dialect 'dialect'.
Protected Member Functions inherited from mlir::Dialect
 Dialect (StringRef name, MLIRContext *context, TypeID id)
 The constructor takes a unique namespace for this dialect as well as the context to bind to.
template<typename... Args>
void addOperations ()
 This method is used by derived classes to add their operations to the set.
template<typename... Args>
void addTypes ()
 Register a set of type classes with this dialect.
void addType (TypeID typeID, AbstractType &&typeInfo)
 Register a type instance with this dialect.
template<typename... Args>
void addAttributes ()
 Register a set of attribute classes with this dialect.
void addAttribute (TypeID typeID, AbstractAttribute &&attrInfo)
 Register an attribute instance with this dialect.
void allowUnknownOperations (bool allow=true)
 Enable support for unregistered operations.
void allowUnknownTypes (bool allow=true)
 Enable support for unregistered types.

Static Protected Member Functions

static LogicalResult printIfDynamicType (Type type, AsmPrinter &printer)
 If 'type' is a dynamic type, print it.
static LogicalResult printIfDynamicAttr (Attribute attr, AsmPrinter &printer)
 If 'attr' is a dynamic attribute, print it.

Additional Inherited Members

Public Types inherited from mlir::Dialect
using ParseOpHook
 Type for a callback provided by the dialect to parse a custom operation.

Detailed Description

A dialect that can be extended with new operations/types/attributes at runtime.

Definition at line 531 of file ExtensibleDialect.h.

Constructor & Destructor Documentation

◆ ExtensibleDialect()

ExtensibleDialect::ExtensibleDialect ( StringRef name,
MLIRContext * ctx,
TypeID typeID )

Member Function Documentation

◆ classof()

bool ExtensibleDialect::classof ( const Dialect * dialect)
static

Check if the dialect is an extensible dialect.

Definition at line 467 of file ExtensibleDialect.cpp.

References mlir::Dialect::Dialect(), and mlir::Dialect::getRegisteredInterface().

Referenced by llvm::isa_impl< mlir::ExtensibleDialect, mlir::Dialect >::doit().

◆ lookupAttrDefinition() [1/2]

DynamicAttrDefinition * mlir::ExtensibleDialect::lookupAttrDefinition ( StringRef name) const
inline

Returns nullptr if the definition was not found.

Definition at line 561 of file ExtensibleDialect.h.

Referenced by parseOptionalDynamicAttr().

◆ lookupAttrDefinition() [2/2]

DynamicAttrDefinition * mlir::ExtensibleDialect::lookupAttrDefinition ( TypeID id) const
inline

Returns nullptr if the definition was not found.

Definition at line 566 of file ExtensibleDialect.h.

References mlir::DynamicAttrDefinition::get().

◆ lookupTypeDefinition() [1/2]

DynamicTypeDefinition * mlir::ExtensibleDialect::lookupTypeDefinition ( StringRef name) const
inline

Returns nullptr if the definition was not found.

Definition at line 548 of file ExtensibleDialect.h.

Referenced by parseOptionalDynamicType().

◆ lookupTypeDefinition() [2/2]

DynamicTypeDefinition * mlir::ExtensibleDialect::lookupTypeDefinition ( TypeID id) const
inline

Returns nullptr if the definition was not found.

Definition at line 553 of file ExtensibleDialect.h.

References mlir::DynamicTypeDefinition::get().

◆ parseOptionalDynamicAttr()

OptionalParseResult ExtensibleDialect::parseOptionalDynamicAttr ( StringRef attrName,
AsmParser & parser,
Attribute & resultAttr ) const
protected

Parse the dynamic attribute 'attrName' in the dialect 'dialect'.

attrname should not be prefixed with the dialect name. If the dynamic attribute does not exist, return no value. Otherwise, parse it, and return the parse result. If the parsing succeed, put the resulting attribute in 'resultAttr'.

Definition at line 494 of file ExtensibleDialect.cpp.

References lookupAttrDefinition(), mlir::DynamicAttr::parse(), and success().

Referenced by mlir::DynamicDialect::parseAttribute().

◆ parseOptionalDynamicType()

OptionalParseResult ExtensibleDialect::parseOptionalDynamicType ( StringRef typeName,
AsmParser & parser,
Type & resultType ) const
protected

Parse the dynamic type 'typeName' in the dialect 'dialect'.

typename should not be prefixed with the dialect name. If the dynamic type does not exist, return no value. Otherwise, parse it, and return the parse result. If the parsing succeed, put the resulting type in 'resultType'.

Definition at line 472 of file ExtensibleDialect.cpp.

References lookupTypeDefinition(), mlir::DynamicType::parse(), and success().

Referenced by mlir::DynamicDialect::parseType().

◆ printIfDynamicAttr()

LogicalResult ExtensibleDialect::printIfDynamicAttr ( Attribute attr,
AsmPrinter & printer )
staticprotected

If 'attr' is a dynamic attribute, print it.

Returns success if the attribute was printed, and failure if the attribute was not a dynamic attribute.

Definition at line 507 of file ExtensibleDialect.cpp.

References success().

Referenced by mlir::DynamicDialect::printAttribute().

◆ printIfDynamicType()

LogicalResult ExtensibleDialect::printIfDynamicType ( Type type,
AsmPrinter & printer )
staticprotected

If 'type' is a dynamic type, print it.

Returns success if the type was printed, and failure if the type was not a dynamic type.

Definition at line 485 of file ExtensibleDialect.cpp.

References success().

Referenced by mlir::DynamicDialect::printType().

◆ registerDynamicAttr()

◆ registerDynamicOp()

void ExtensibleDialect::registerDynamicOp ( std::unique_ptr< DynamicOpDefinition > && type)

Add a new operation defined at runtime to the dialect.

Definition at line 460 of file ExtensibleDialect.cpp.

References mlir::RegisteredOperationName::insert().

Referenced by loadOperation().

◆ registerDynamicType()


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