MLIR  20.0.0git
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
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. More...
 
void registerDynamicAttr (std::unique_ptr< DynamicAttrDefinition > &&attr)
 Add a new attribute defined at runtime to the dialect. More...
 
void registerDynamicOp (std::unique_ptr< DynamicOpDefinition > &&type)
 Add a new operation defined at runtime to the dialect. More...
 
DynamicTypeDefinitionlookupTypeDefinition (StringRef name) const
 Returns nullptr if the definition was not found. More...
 
DynamicTypeDefinitionlookupTypeDefinition (TypeID id) const
 Returns nullptr if the definition was not found. More...
 
DynamicAttrDefinitionlookupAttrDefinition (StringRef name) const
 Returns nullptr if the definition was not found. More...
 
DynamicAttrDefinitionlookupAttrDefinition (TypeID id) const
 Returns nullptr if the definition was not found. More...
 
- 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. More...
 
bool allowsUnknownOperations () const
 Returns true if this dialect allows for unregistered operations, i.e. More...
 
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. More...
 
virtual void getCanonicalizationPatterns (RewritePatternSet &results) const
 Register dialect-wide canonicalization patterns. More...
 
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. More...
 
virtual Attribute parseAttribute (DialectAsmParser &parser, Type type) const
 Parse an attribute registered to this dialect. More...
 
virtual void printAttribute (Attribute, DialectAsmPrinter &) const
 Print an attribute registered to this dialect. More...
 
virtual Type parseType (DialectAsmParser &parser) const
 Parse a type registered to this dialect. More...
 
virtual void printType (Type, DialectAsmPrinter &) const
 Print a type registered to this dialect. More...
 
virtual std::optional< ParseOpHookgetParseOperationHook (StringRef opName) const
 Return the hook to parse an operation registered to this dialect, if any. More...
 
virtual llvm::unique_function< void(Operation *, OpAsmPrinter &printer)> getOperationPrinter (Operation *op) const
 Print an operation registered to this dialect. More...
 
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. More...
 
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. More...
 
virtual LogicalResult verifyOperationAttribute (Operation *, NamedAttribute)
 Verify an attribute from this dialect on the given operation. More...
 
DialectInterfacegetRegisteredInterface (TypeID interfaceID)
 Lookup an interface for the given ID if one is registered, otherwise nullptr. More...
 
template<typename InterfaceT >
InterfaceT * getRegisteredInterface ()
 
virtual void * getRegisteredInterfaceForOp (TypeID interfaceID, OperationName opName)
 Lookup an op interface for the given ID if one is registered, otherwise nullptr. More...
 
template<typename InterfaceT >
InterfaceT::Concept * getRegisteredInterfaceForOp (OperationName opName)
 
void addInterface (std::unique_ptr< DialectInterface > interface)
 Register a dialect interface with this dialect instance. More...
 
template<typename... Args>
void addInterfaces ()
 Register a set of dialect interfaces with this dialect instance. More...
 
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. More...
 
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. More...
 
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. More...
 
bool hasPromisedInterface (TypeID interfaceRequestorID, TypeID interfaceID) const
 Checks if a promise has been made for the interface/requestor pair. More...
 
template<typename ConcreteT , typename InterfaceT >
bool hasPromisedInterface () const
 Checks if a promise has been made for the interface/requestor pair. More...
 

Static Public Member Functions

static bool classof (const Dialect *dialect)
 Check if the dialect is an extensible dialect. More...
 
- 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. More...
 

Protected Member Functions

OptionalParseResult parseOptionalDynamicType (StringRef typeName, AsmParser &parser, Type &resultType) const
 Parse the dynamic type 'typeName' in the dialect 'dialect'. More...
 
OptionalParseResult parseOptionalDynamicAttr (StringRef attrName, AsmParser &parser, Attribute &resultAttr) const
 Parse the dynamic attribute 'attrName' in the dialect 'dialect'. More...
 
- 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. More...
 
template<typename... Args>
void addOperations ()
 This method is used by derived classes to add their operations to the set. More...
 
template<typename... Args>
void addTypes ()
 Register a set of type classes with this dialect. More...
 
void addType (TypeID typeID, AbstractType &&typeInfo)
 Register a type instance with this dialect. More...
 
template<typename... Args>
void addAttributes ()
 Register a set of attribute classes with this dialect. More...
 
void addAttribute (TypeID typeID, AbstractAttribute &&attrInfo)
 Register an attribute instance with this dialect. More...
 
void allowUnknownOperations (bool allow=true)
 Enable support for unregistered operations. More...
 
void allowUnknownTypes (bool allow=true)
 Enable support for unregistered types. More...
 

Static Protected Member Functions

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

Additional Inherited Members

- Public Types inherited from mlir::Dialect
using ParseOpHook = function_ref< ParseResult(OpAsmParser &parser, OperationState &result)>
 Type for a callback provided by the dialect to parse a custom operation. More...
 

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 
)

Definition at line 383 of file ExtensibleDialect.cpp.

Member Function Documentation

◆ classof()

bool ExtensibleDialect::classof ( const Dialect dialect)
static

Check if the dialect is an extensible dialect.

Definition at line 468 of file ExtensibleDialect.cpp.

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.

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

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

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

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

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

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

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

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

◆ registerDynamicAttr()

void ExtensibleDialect::registerDynamicAttr ( std::unique_ptr< DynamicAttrDefinition > &&  attr)

◆ registerDynamicOp()

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

Add a new operation defined at runtime to the dialect.

Definition at line 461 of file ExtensibleDialect.cpp.

References mlir::RegisteredOperationName::insert().

Referenced by loadOperation().

◆ registerDynamicType()

void ExtensibleDialect::registerDynamicType ( std::unique_ptr< DynamicTypeDefinition > &&  type)

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