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

The definition of a dynamic op. More...

#include "mlir/IR/ExtensibleDialect.h"

+ Inheritance diagram for mlir::DynamicOpDefinition:

Public Types

using GetCanonicalizationPatternsFn = llvm::unique_function< void(RewritePatternSet &, MLIRContext *) const >
 

Public Member Functions

TypeID getTypeID ()
 Returns the op typeID. More...
 
void setVerifyFn (OperationName::VerifyInvariantsFn &&verify)
 Sets the verifier function for this operation. More...
 
void setVerifyRegionFn (OperationName::VerifyRegionInvariantsFn &&verify)
 Sets the region verifier function for this operation. More...
 
void setParseFn (OperationName::ParseAssemblyFn &&parse)
 Sets the static hook for parsing this op assembly. More...
 
void setPrintFn (OperationName::PrintAssemblyFn &&print)
 Sets the static hook for printing this op assembly. More...
 
void setFoldHookFn (OperationName::FoldHookFn &&foldHook)
 Sets the hook implementing a generalized folder for the op. More...
 
void setGetCanonicalizationPatternsFn (GetCanonicalizationPatternsFn &&getCanonicalizationPatterns)
 Set the hook returning any canonicalization pattern rewrites that the op supports, for use by the canonicalization pass. More...
 
void setPopulateDefaultAttrsFn (OperationName::PopulateDefaultAttrsFn &&populateDefaultAttrs)
 Set the hook populating default attributes. More...
 
LogicalResult foldHook (Operation *op, ArrayRef< Attribute > attrs, SmallVectorImpl< OpFoldResult > &results) final
 
void getCanonicalizationPatterns (RewritePatternSet &set, MLIRContext *context) final
 
bool hasTrait (TypeID id) final
 
OperationName::ParseAssemblyFn getParseAssemblyFn () final
 
void populateDefaultAttrs (const OperationName &name, NamedAttrList &attrs) final
 
void printAssembly (Operation *op, OpAsmPrinter &printer, StringRef name) final
 
LogicalResult verifyInvariants (Operation *op) final
 
LogicalResult verifyRegionInvariants (Operation *op) final
 
std::optional< AttributegetInherentAttr (Operation *op, StringRef name) final
 Implementation for properties (unsupported right now here). More...
 
void setInherentAttr (Operation *op, StringAttr name, Attribute value) final
 
void populateInherentAttrs (Operation *op, NamedAttrList &attrs) final
 
LogicalResult verifyInherentAttrs (OperationName opName, NamedAttrList &attributes, function_ref< InFlightDiagnostic()> emitError) final
 
int getOpPropertyByteSize () final
 
void initProperties (OperationName opName, OpaqueProperties storage, OpaqueProperties init) final
 
void deleteProperties (OpaqueProperties prop) final
 
void populateDefaultProperties (OperationName opName, OpaqueProperties properties) final
 
LogicalResult setPropertiesFromAttr (OperationName opName, OpaqueProperties properties, Attribute attr, function_ref< InFlightDiagnostic()> emitError) final
 
Attribute getPropertiesAsAttr (Operation *op) final
 
void copyProperties (OpaqueProperties lhs, OpaqueProperties rhs) final
 
bool compareProperties (OpaqueProperties, OpaqueProperties) final
 
llvm::hash_code hashProperties (OpaqueProperties prop) final
 
- Public Member Functions inherited from mlir::OperationName::Impl
 Impl (StringRef, Dialect *dialect, TypeID typeID, detail::InterfaceMap interfaceMap)
 
 Impl (StringAttr name, Dialect *dialect, TypeID typeID, detail::InterfaceMap interfaceMap)
 
bool isRegistered () const
 Returns true if this is a registered operation. More...
 
detail::InterfaceMapgetInterfaceMap ()
 
DialectgetDialect () const
 
StringAttr getName () const
 
TypeID getTypeID () const
 
ArrayRef< StringAttr > getAttributeNames () const
 
- Public Member Functions inherited from mlir::OperationName::InterfaceConcept
virtual ~InterfaceConcept ()=default
 

Static Public Member Functions

static std::unique_ptr< DynamicOpDefinitionget (StringRef name, ExtensibleDialect *dialect, OperationName::VerifyInvariantsFn &&verifyFn, OperationName::VerifyRegionInvariantsFn &&verifyRegionFn)
 Create a new op at runtime. More...
 
static std::unique_ptr< DynamicOpDefinitionget (StringRef name, ExtensibleDialect *dialect, OperationName::VerifyInvariantsFn &&verifyFn, OperationName::VerifyRegionInvariantsFn &&verifyRegionFn, OperationName::ParseAssemblyFn &&parseFn, OperationName::PrintAssemblyFn &&printFn)
 
static std::unique_ptr< DynamicOpDefinitionget (StringRef name, ExtensibleDialect *dialect, OperationName::VerifyInvariantsFn &&verifyFn, OperationName::VerifyRegionInvariantsFn &&verifyRegionFn, OperationName::ParseAssemblyFn &&parseFn, OperationName::PrintAssemblyFn &&printFn, OperationName::FoldHookFn &&foldHookFn, GetCanonicalizationPatternsFn &&getCanonicalizationPatternsFn, OperationName::PopulateDefaultAttrsFn &&populateDefaultAttrsFn)
 

Additional Inherited Members

- Protected Attributes inherited from mlir::OperationName::Impl
StringAttr name
 The name of the operation. More...
 
TypeID typeID
 The unique identifier of the derived Op class. More...
 
Dialectdialect
 The following fields are only populated when the operation is registered. More...
 
detail::InterfaceMap interfaceMap
 A map of interfaces that were registered to this operation. More...
 
ArrayRef< StringAttr > attributeNames
 A list of attribute names registered to this operation in StringAttr form. More...
 

Detailed Description

The definition of a dynamic op.

A dynamic op is an op that is defined at runtime, and that can be registered at runtime by an extensible dialect (a dialect inheriting ExtensibleDialect). This class implements the method exposed by the OperationName class, and in addition defines the TypeID of the op that will be defined. Each dynamic operation definition refers to one instance of this class.

Definition at line 367 of file ExtensibleDialect.h.

Member Typedef Documentation

◆ GetCanonicalizationPatternsFn

Definition at line 369 of file ExtensibleDialect.h.

Member Function Documentation

◆ compareProperties()

bool mlir::DynamicOpDefinition::compareProperties ( OpaqueProperties  ,
OpaqueProperties   
)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 497 of file ExtensibleDialect.h.

◆ copyProperties()

void mlir::DynamicOpDefinition::copyProperties ( OpaqueProperties  lhs,
OpaqueProperties  rhs 
)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 496 of file ExtensibleDialect.h.

◆ deleteProperties()

void mlir::DynamicOpDefinition::deleteProperties ( OpaqueProperties  prop)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 484 of file ExtensibleDialect.h.

◆ foldHook()

LogicalResult mlir::DynamicOpDefinition::foldHook ( Operation op,
ArrayRef< Attribute attrs,
SmallVectorImpl< OpFoldResult > &  results 
)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 440 of file ExtensibleDialect.h.

Referenced by setFoldHookFn().

◆ get() [1/3]

std::unique_ptr< DynamicOpDefinition > DynamicOpDefinition::get ( StringRef  name,
ExtensibleDialect dialect,
OperationName::VerifyInvariantsFn &&  verifyFn,
OperationName::VerifyRegionInvariantsFn &&  verifyRegionFn 
)
static

Create a new op at runtime.

The op is registered only after passing it to the dialect using registerDynamicOp.

Definition at line 310 of file ExtensibleDialect.cpp.

References mlir::OperationName::Impl::dialect, mlir::AsmParser::emitError(), mlir::AsmParser::getCurrentLocation(), and mlir::OperationName::Impl::name.

Referenced by get(), and loadOperation().

◆ get() [2/3]

std::unique_ptr< DynamicOpDefinition > DynamicOpDefinition::get ( StringRef  name,
ExtensibleDialect dialect,
OperationName::VerifyInvariantsFn &&  verifyFn,
OperationName::VerifyRegionInvariantsFn &&  verifyRegionFn,
OperationName::ParseAssemblyFn &&  parseFn,
OperationName::PrintAssemblyFn &&  printFn 
)
static

◆ get() [3/3]

std::unique_ptr< DynamicOpDefinition > DynamicOpDefinition::get ( StringRef  name,
ExtensibleDialect dialect,
OperationName::VerifyInvariantsFn &&  verifyFn,
OperationName::VerifyRegionInvariantsFn &&  verifyRegionFn,
OperationName::ParseAssemblyFn &&  parseFn,
OperationName::PrintAssemblyFn &&  printFn,
OperationName::FoldHookFn &&  foldHookFn,
GetCanonicalizationPatternsFn &&  getCanonicalizationPatternsFn,
OperationName::PopulateDefaultAttrsFn &&  populateDefaultAttrsFn 
)
static

◆ getCanonicalizationPatterns()

void mlir::DynamicOpDefinition::getCanonicalizationPatterns ( RewritePatternSet set,
MLIRContext context 
)
inlinefinalvirtual

◆ getInherentAttr()

std::optional<Attribute> mlir::DynamicOpDefinition::getInherentAttr ( Operation op,
StringRef  name 
)
inlinefinalvirtual

Implementation for properties (unsupported right now here).

Implements mlir::OperationName::InterfaceConcept.

Definition at line 468 of file ExtensibleDialect.h.

◆ getOpPropertyByteSize()

int mlir::DynamicOpDefinition::getOpPropertyByteSize ( )
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 481 of file ExtensibleDialect.h.

◆ getParseAssemblyFn()

OperationName::ParseAssemblyFn mlir::DynamicOpDefinition::getParseAssemblyFn ( )
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 449 of file ExtensibleDialect.h.

◆ getPropertiesAsAttr()

Attribute mlir::DynamicOpDefinition::getPropertiesAsAttr ( Operation op)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 495 of file ExtensibleDialect.h.

◆ getTypeID()

TypeID mlir::DynamicOpDefinition::getTypeID ( )
inline

Returns the op typeID.

Definition at line 395 of file ExtensibleDialect.h.

References mlir::OperationName::Impl::typeID.

◆ hashProperties()

llvm::hash_code mlir::DynamicOpDefinition::hashProperties ( OpaqueProperties  prop)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 498 of file ExtensibleDialect.h.

◆ hasTrait()

bool mlir::DynamicOpDefinition::hasTrait ( TypeID  id)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 448 of file ExtensibleDialect.h.

◆ initProperties()

void mlir::DynamicOpDefinition::initProperties ( OperationName  opName,
OpaqueProperties  storage,
OpaqueProperties  init 
)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 482 of file ExtensibleDialect.h.

◆ populateDefaultAttrs()

void mlir::DynamicOpDefinition::populateDefaultAttrs ( const OperationName name,
NamedAttrList attrs 
)
inlinefinalvirtual

◆ populateDefaultProperties()

void mlir::DynamicOpDefinition::populateDefaultProperties ( OperationName  opName,
OpaqueProperties  properties 
)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 485 of file ExtensibleDialect.h.

◆ populateInherentAttrs()

void mlir::DynamicOpDefinition::populateInherentAttrs ( Operation op,
NamedAttrList attrs 
)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 475 of file ExtensibleDialect.h.

◆ printAssembly()

void mlir::DynamicOpDefinition::printAssembly ( Operation op,
OpAsmPrinter printer,
StringRef  name 
)
inlinefinalvirtual

◆ setFoldHookFn()

void mlir::DynamicOpDefinition::setFoldHookFn ( OperationName::FoldHookFn &&  foldHook)
inline

Sets the hook implementing a generalized folder for the op.

See RegisteredOperationName::foldHook for more details

Definition at line 423 of file ExtensibleDialect.h.

References foldHook().

◆ setGetCanonicalizationPatternsFn()

void mlir::DynamicOpDefinition::setGetCanonicalizationPatternsFn ( GetCanonicalizationPatternsFn &&  getCanonicalizationPatterns)
inline

Set the hook returning any canonicalization pattern rewrites that the op supports, for use by the canonicalization pass.

Definition at line 429 of file ExtensibleDialect.h.

References getCanonicalizationPatterns().

◆ setInherentAttr()

void mlir::DynamicOpDefinition::setInherentAttr ( Operation op,
StringAttr  name,
Attribute  value 
)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 472 of file ExtensibleDialect.h.

◆ setParseFn()

void mlir::DynamicOpDefinition::setParseFn ( OperationName::ParseAssemblyFn &&  parse)
inline

Sets the static hook for parsing this op assembly.

Definition at line 412 of file ExtensibleDialect.h.

References mlir::query::parse().

◆ setPopulateDefaultAttrsFn()

void mlir::DynamicOpDefinition::setPopulateDefaultAttrsFn ( OperationName::PopulateDefaultAttrsFn &&  populateDefaultAttrs)
inline

Set the hook populating default attributes.

Definition at line 435 of file ExtensibleDialect.h.

References populateDefaultAttrs().

◆ setPrintFn()

void mlir::DynamicOpDefinition::setPrintFn ( OperationName::PrintAssemblyFn &&  print)
inline

Sets the static hook for printing this op assembly.

Definition at line 417 of file ExtensibleDialect.h.

References print().

◆ setPropertiesFromAttr()

LogicalResult mlir::DynamicOpDefinition::setPropertiesFromAttr ( OperationName  opName,
OpaqueProperties  properties,
Attribute  attr,
function_ref< InFlightDiagnostic()>  emitError 
)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 489 of file ExtensibleDialect.h.

References mlir::emitError().

◆ setVerifyFn()

void mlir::DynamicOpDefinition::setVerifyFn ( OperationName::VerifyInvariantsFn &&  verify)
inline

Sets the verifier function for this operation.

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

Definition at line 400 of file ExtensibleDialect.h.

References mlir::verify().

◆ setVerifyRegionFn()

void mlir::DynamicOpDefinition::setVerifyRegionFn ( OperationName::VerifyRegionInvariantsFn &&  verify)
inline

Sets the region verifier function for this operation.

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

Definition at line 407 of file ExtensibleDialect.h.

References mlir::verify().

◆ verifyInherentAttrs()

LogicalResult mlir::DynamicOpDefinition::verifyInherentAttrs ( OperationName  opName,
NamedAttrList attributes,
function_ref< InFlightDiagnostic()>  emitError 
)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 477 of file ExtensibleDialect.h.

◆ verifyInvariants()

LogicalResult mlir::DynamicOpDefinition::verifyInvariants ( Operation op)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 462 of file ExtensibleDialect.h.

◆ verifyRegionInvariants()

LogicalResult mlir::DynamicOpDefinition::verifyRegionInvariants ( Operation op)
inlinefinalvirtual

Implements mlir::OperationName::InterfaceConcept.

Definition at line 463 of file ExtensibleDialect.h.


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