MLIR  20.0.0git
Public Member Functions | Static Public Member Functions | List of all members
mlir::DynamicDialect Class Reference

A dialect that can be defined at runtime. More...

#include "mlir/IR/ExtensibleDialect.h"

+ Inheritance diagram for mlir::DynamicDialect:

Public Member Functions

 DynamicDialect (StringRef name, MLIRContext *ctx)
 
TypeID getTypeID ()
 
virtual Type parseType (DialectAsmParser &parser) const override
 Parse a type registered to this dialect. More...
 
virtual void printType (Type type, DialectAsmPrinter &printer) const override
 Print a type registered to this dialect. More...
 
virtual Attribute parseAttribute (DialectAsmParser &parser, Type type) const override
 Parse an attribute registered to this dialect. More...
 
virtual void printAttribute (Attribute attr, DialectAsmPrinter &printer) const override
 Print an attribute registered to this dialect. 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...
 
- Public Member Functions inherited from mlir::ExtensibleDialect
 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 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::ExtensibleDialect
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...
 

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...
 
- Protected Member Functions inherited from mlir::ExtensibleDialect
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 inherited from mlir::ExtensibleDialect
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...
 

Detailed Description

A dialect that can be defined at runtime.

It can be extended with new operations, types, and attributes at runtime.

Definition at line 631 of file ExtensibleDialect.h.

Constructor & Destructor Documentation

◆ DynamicDialect()

DynamicDialect::DynamicDialect ( StringRef  name,
MLIRContext ctx 
)

Definition at line 532 of file ExtensibleDialect.cpp.

Member Function Documentation

◆ classof()

bool DynamicDialect::classof ( const Dialect dialect)
static

Check if the dialect is an extensible dialect.

Definition at line 538 of file ExtensibleDialect.cpp.

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

◆ getTypeID()

TypeID mlir::DynamicDialect::getTypeID ( )
inline

Definition at line 635 of file ExtensibleDialect.h.

References mlir::SelfOwningTypeID::getTypeID().

◆ parseAttribute()

Attribute DynamicDialect::parseAttribute ( DialectAsmParser parser,
Type  type 
) const
overridevirtual

Parse an attribute registered to this dialect.

If 'type' is nonnull, it refers to the expected type of the attribute.

Reimplemented from mlir::Dialect.

Definition at line 570 of file ExtensibleDialect.cpp.

References mlir::AsmParser::emitError(), mlir::AsmParser::getCurrentLocation(), mlir::AsmParser::parseKeyword(), and mlir::ExtensibleDialect::parseOptionalDynamicAttr().

◆ parseType()

Type DynamicDialect::parseType ( DialectAsmParser parser) const
overridevirtual

◆ printAttribute()

void DynamicDialect::printAttribute ( Attribute  ,
DialectAsmPrinter  
) const
overridevirtual

Print an attribute registered to this dialect.

Note: The type of the attribute need not be printed by this method as it is always printed by the caller.

Reimplemented from mlir::Dialect.

Definition at line 590 of file ExtensibleDialect.cpp.

References mlir::ExtensibleDialect::printIfDynamicAttr().

◆ printType()

void DynamicDialect::printType ( Type  ,
DialectAsmPrinter  
) const
overridevirtual

Print a type registered to this dialect.

Reimplemented from mlir::Dialect.

Definition at line 563 of file ExtensibleDialect.cpp.

References mlir::ExtensibleDialect::printIfDynamicType().


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