|
MLIR 23.0.0git
|
#include "mlir/IR/OperationSupport.h"
Classes | |
| class | Impl |
| struct | InterfaceConcept |
| This class represents a type erased version of an operation. More... | |
| struct | UnregisteredOpModel |
| Default implementation for unregistered operations. More... | |
Public Types | |
| using | FoldHookFn |
| using | HasTraitFn = llvm::unique_function<bool(TypeID) const> |
| using | ParseAssemblyFn |
| using | PopulateDefaultAttrsFn |
| using | PrintAssemblyFn |
| using | VerifyInvariantsFn |
| using | VerifyRegionInvariantsFn |
Public Member Functions | |
| OperationName (StringRef name, MLIRContext *context) | |
| bool | isRegistered () const |
| Return if this operation is registered. | |
| TypeID | getTypeID () const |
| Return the unique identifier of the derived Op class, or null if not registered. | |
| std::optional< RegisteredOperationName > | getRegisteredInfo () const |
| If this operation is registered, returns the registered information, std::nullopt otherwise. | |
| LogicalResult | foldHook (Operation *op, ArrayRef< Attribute > operands, SmallVectorImpl< OpFoldResult > &results) const |
| This hook implements a generalized folder for this operation. | |
| void | getCanonicalizationPatterns (RewritePatternSet &results, MLIRContext *context) const |
| This hook returns any canonicalization pattern rewrites that the operation supports, for use by the canonicalization pass. | |
| template<template< typename T > class Trait> | |
| bool | hasTrait () const |
| Returns true if the operation was registered with a particular trait, e.g. | |
| bool | hasTrait (TypeID traitID) const |
| template<template< typename T > class Trait> | |
| bool | mightHaveTrait () const |
| Returns true if the operation might have the provided trait. | |
| bool | mightHaveTrait (TypeID traitID) const |
| ParseAssemblyFn | getParseAssemblyFn () const |
| Return the static hook for parsing this operation assembly. | |
| void | populateDefaultAttrs (NamedAttrList &attrs) const |
| This hook implements the method to populate defaults attributes that are unset. | |
| void | printAssembly (Operation *op, OpAsmPrinter &p, StringRef defaultDialect) const |
| This hook implements the AsmPrinter for this operation. | |
| LogicalResult | verifyInvariants (Operation *op) const |
| These hooks implement the verifiers for this operation. | |
| LogicalResult | verifyRegionInvariants (Operation *op) const |
| ArrayRef< StringAttr > | getAttributeNames () const |
| Return the list of cached attribute names registered to this operation. | |
| template<typename T> | |
| T::Concept * | getInterface () const |
| Returns an instance of the concept object for the given interface if it was registered to this operation, null otherwise. | |
| template<typename... Models> | |
| void | attachInterface () |
| Attach the given models as implementations of the corresponding interfaces for the concrete operation. | |
| template<typename InterfaceT> | |
| bool | hasPromiseOrImplementsInterface () const |
| Returns true if InterfaceT has been promised by the dialect or implemented. | |
| template<typename T> | |
| bool | hasInterface () const |
| Returns true if this operation has the given interface registered to it. | |
| bool | hasInterface (TypeID interfaceID) const |
| template<typename T> | |
| bool | mightHaveInterface () const |
| Returns true if the operation might have the provided interface. | |
| bool | mightHaveInterface (TypeID interfaceID) const |
| std::optional< Attribute > | getInherentAttr (Operation *op, StringRef name) const |
| Lookup an inherent attribute by name, this method isn't recommended and may be removed in the future. | |
| void | setInherentAttr (Operation *op, StringAttr name, Attribute value) const |
| void | populateInherentAttrs (Operation *op, NamedAttrList &attrs) const |
| LogicalResult | verifyInherentAttrs (NamedAttrList &attributes, function_ref< InFlightDiagnostic()> emitError) const |
| This method exists for backward compatibility purpose when using properties to store inherent attributes, it enables validating the attributes when parsed from the older generic syntax pre-Properties. | |
| int | getOpPropertyByteSize () const |
| This hooks return the number of bytes to allocate for the op properties. | |
| TypeID | getOpPropertiesTypeID () const |
| Return the TypeID of the op properties. | |
| void | destroyOpProperties (PropertyRef properties) const |
| This hooks destroy the op properties. | |
| void | initOpProperties (PropertyRef storage, PropertyRef init) const |
| Initialize the op properties. | |
| void | populateDefaultProperties (PropertyRef properties) const |
| Set the default values on the ODS attribute in the properties. | |
| Attribute | getOpPropertiesAsAttribute (Operation *op) const |
| Return the op properties converted to an Attribute. | |
| LogicalResult | setOpPropertiesFromAttribute (OperationName opName, PropertyRef properties, Attribute attr, function_ref< InFlightDiagnostic()> emitError) const |
| Define the op properties from the provided Attribute. | |
| void | copyOpProperties (PropertyRef lhs, PropertyRef rhs) const |
| bool | compareOpProperties (PropertyRef lhs, PropertyRef rhs) const |
| llvm::hash_code | hashOpProperties (PropertyRef properties) const |
| Dialect * | getDialect () const |
| Return the dialect this operation is registered to if the dialect is loaded in the context, or nullptr if the dialect isn't loaded. | |
| StringRef | getDialectNamespace () const |
| Return the name of the dialect this operation is registered to. | |
| StringRef | stripDialect () const |
| Return the operation name with dialect name stripped, if it has one. | |
| MLIRContext * | getContext () |
| Return the context this operation is associated with. | |
| StringRef | getStringRef () const |
| Return the name of this operation. This always succeeds. | |
| StringAttr | getIdentifier () const |
| Return the name of this operation as a StringAttr. | |
| void | print (raw_ostream &os) const |
| void | dump () const |
| void * | getAsOpaquePointer () const |
| Represent the operation name as an opaque pointer. | |
| bool | operator== (const OperationName &rhs) const |
| bool | operator!= (const OperationName &rhs) const |
Static Public Member Functions | |
| static OperationName | getFromOpaquePointer (const void *pointer) |
Protected Member Functions | |
| OperationName (Impl *impl) | |
| Impl * | getImpl () const |
| void | setImpl (Impl *rhs) |
Definition at line 99 of file OperationSupport.h.
Definition at line 101 of file OperationSupport.h.
| using mlir::OperationName::HasTraitFn = llvm::unique_function<bool(TypeID) const> |
Definition at line 103 of file OperationSupport.h.
Definition at line 104 of file OperationSupport.h.
Definition at line 108 of file OperationSupport.h.
Definition at line 110 of file OperationSupport.h.
Definition at line 112 of file OperationSupport.h.
Definition at line 114 of file OperationSupport.h.
| OperationName::OperationName | ( | StringRef | name, |
| MLIRContext * | context ) |
Definition at line 805 of file MLIRContext.cpp.
References mlir::TypeID::get(), mlir::MLIRContext::getImpl(), mlir::MLIRContext::isMultithreadingEnabled(), mlir::MLIRContextImpl::operationInfoMutex, mlir::MLIRContextImpl::operations, and mlir::MLIRContextImpl::registeredOperationsByName.
Referenced by getFromOpaquePointer(), mlir::OperationName::InterfaceConcept::initProperties(), mlir::OperationName::UnregisteredOpModel::initProperties(), operator!=(), operator==(), mlir::OperationName::InterfaceConcept::populateDefaultAttrs(), mlir::OperationName::UnregisteredOpModel::populateDefaultAttrs(), mlir::OperationName::InterfaceConcept::populateDefaultProperties(), mlir::OperationName::UnregisteredOpModel::populateDefaultProperties(), setOpPropertiesFromAttribute(), mlir::OperationName::InterfaceConcept::setPropertiesFromAttr(), mlir::OperationName::UnregisteredOpModel::setPropertiesFromAttr(), mlir::OperationName::InterfaceConcept::verifyInherentAttrs(), and mlir::OperationName::UnregisteredOpModel::verifyInherentAttrs().
|
inlineprotected |
Definition at line 517 of file OperationSupport.h.
|
inline |
Attach the given models as implementations of the corresponding interfaces for the concrete operation.
Definition at line 370 of file OperationSupport.h.
References mlir::OperationName::Impl::getDialect(), getImpl(), mlir::OperationName::Impl::getInterfaceMap(), mlir::OperationName::Impl::getTypeID(), mlir::dialect_extension_detail::handleAdditionOfUndefinedPromisedInterface(), and mlir::detail::InterfaceMap::insertModels().
|
inline |
Definition at line 472 of file OperationSupport.h.
References mlir::OperationName::InterfaceConcept::compareProperties(), getImpl(), lhs, and rhs.
|
inline |
Definition at line 468 of file OperationSupport.h.
References mlir::OperationName::InterfaceConcept::copyProperties(), getImpl(), lhs, and rhs.
|
inline |
This hooks destroy the op properties.
Definition at line 441 of file OperationSupport.h.
References mlir::OperationName::InterfaceConcept::deleteProperties(), and getImpl().
| void OperationName::dump | ( | ) | const |
Definition at line 62 of file AsmPrinter.cpp.
References print().
|
inline |
This hook implements a generalized folder for this operation.
Operations can implement this to provide simplifications rules that are applied by the Builder::createOrFold API and the canonicalization pass.
This is an intentionally limited interface - implementations of this hook can only perform the following changes to the operation:
This allows expression of some simple in-place canonicalizations (e.g. "x+0 -> x", "min(x,y,x,z) -> min(x,y,z)", "x+y-x -> y", etc), as well as generalized constant folding.
Definition at line 280 of file OperationSupport.h.
References mlir::OperationName::InterfaceConcept::foldHook(), and getImpl().
|
inline |
Represent the operation name as an opaque pointer.
(Used to support PointerLikeTypeTraits).
Definition at line 507 of file OperationSupport.h.
Referenced by llvm::PointerLikeTypeTraits< mlir::OperationName >::getAsVoidPointer(), llvm::DenseMapInfo< mlir::OperationName >::getHashValue(), and mlir::hash_value().
|
inline |
Return the list of cached attribute names registered to this operation.
The order of attributes cached here is unique to each type of operation, and the interpretation of this attribute list should generally be driven by the respective operation. In many cases, this caching removes the need to use the raw string name of a known attribute.
For example the ODS generator, with an op defining the following attributes:
let arguments = (ins I32Attr:$attr1, I32Attr:$attr2);
... may produce an order here of ["attr1", "attr2"]. This allows for the ODS generator to directly access the cached name for a known attribute, greatly simplifying the cost and complexity of attribute usage produced by the generator.
Definition at line 355 of file OperationSupport.h.
References mlir::OperationName::Impl::getAttributeNames(), and getImpl().
|
inline |
This hook returns any canonicalization pattern rewrites that the operation supports, for use by the canonicalization pass.
Definition at line 287 of file OperationSupport.h.
References mlir::OperationName::InterfaceConcept::getCanonicalizationPatterns(), and getImpl().
|
inline |
Return the context this operation is associated with.
Definition at line 494 of file OperationSupport.h.
References getIdentifier().
Referenced by mlir::OperationName::Impl::Impl().
|
inline |
Return the dialect this operation is registered to if the dialect is loaded in the context, or nullptr if the dialect isn't loaded.
Definition at line 482 of file OperationSupport.h.
References mlir::OperationName::Impl::getDialect(), getImpl(), mlir::OperationName::Impl::getName(), and mlir::OperationName::Impl::isRegistered().
Referenced by mlir::Operation::getDialect(), getDialectNamespace(), and mlir::OpInterface< ConcreteType, Traits >::getInterfaceFor().
| StringRef OperationName::getDialectNamespace | ( | ) | const |
Return the name of the dialect this operation is registered to.
Definition at line 841 of file MLIRContext.cpp.
References getDialect(), and getStringRef().
|
inlinestatic |
Definition at line 508 of file OperationSupport.h.
References OperationName().
Referenced by llvm::DenseMapInfo< mlir::OperationName >::getEmptyKey(), llvm::PointerLikeTypeTraits< mlir::OperationName >::getFromVoidPointer(), mlir::Pattern::getRootKind(), and llvm::DenseMapInfo< mlir::OperationName >::getTombstoneKey().
|
inline |
Return the name of this operation as a StringAttr.
Definition at line 500 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::Impl::getName().
Referenced by cloneOpWithOperandsAndTypes(), getBaseValueForTypeLookup(), getContext(), getStringRef(), DropUnitDimFromElementwiseOps::matchAndRewrite(), scalarizeVectorOpHelper(), vectorizeOneOp(), and widenOp().
|
inlineprotected |
Definition at line 518 of file OperationSupport.h.
Referenced by attachInterface(), compareOpProperties(), copyOpProperties(), destroyOpProperties(), foldHook(), mlir::AffineMap::get(), mlir::AffineMap::get(), mlir::AffineMap::get(), mlir::AffineMap::get(), mlir::MLIRContext::getAffineUniquer(), getAttributeNames(), mlir::MLIRContext::getAttributeUniquer(), getCanonicalizationPatterns(), getDialect(), mlir::RegisteredOperationName::getDialect(), getIdentifier(), getInherentAttr(), getInterface(), getOpPropertiesAsAttribute(), getOpPropertiesTypeID(), getOpPropertyByteSize(), getParseAssemblyFn(), getTypeID(), mlir::MLIRContext::getTypeUniquer(), hashOpProperties(), hasInterface(), hasTrait(), initOpProperties(), isRegistered(), mightHaveTrait(), mlirDynamicOpTraitAttach(), populateDefaultAttrs(), populateDefaultProperties(), populateInherentAttrs(), printAssembly(), setInherentAttr(), setOpPropertiesFromAttribute(), verifyInherentAttrs(), verifyInvariants(), and verifyRegionInvariants().
|
inline |
Lookup an inherent attribute by name, this method isn't recommended and may be removed in the future.
Definition at line 410 of file OperationSupport.h.
References getImpl(), mlir::OperationName::InterfaceConcept::getInherentAttr(), and mlir::OperationName::Impl::name.
Referenced by mlir::Operation::getInherentAttr().
|
inline |
Returns an instance of the concept object for the given interface if it was registered to this operation, null otherwise.
This should not be used directly.
Definition at line 363 of file OperationSupport.h.
References getImpl(), mlir::OperationName::Impl::getInterfaceMap(), and mlir::detail::InterfaceMap::lookup().
Referenced by mlir::transform::detail::verifyParamProducerTransformOpTrait(), mlir::transform::FunctionalStyleTransformOpTrait< OpTy >::verifyTrait(), mlir::transform::NavigationTransformOpTrait< OpTy >::verifyTrait(), and mlir::transform::TransformEachOpTrait< OpTy >::verifyTrait().
Return the op properties converted to an Attribute.
Definition at line 456 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::getPropertiesAsAttr().
|
inline |
Return the TypeID of the op properties.
Definition at line 436 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::Impl::getPropertiesTypeID().
|
inline |
This hooks return the number of bytes to allocate for the op properties.
Definition at line 431 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::getOpPropertyByteSize().
|
inline |
Return the static hook for parsing this operation assembly.
Definition at line 313 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::getParseAssemblyFn().
|
inline |
If this operation is registered, returns the registered information, std::nullopt otherwise.
Definition at line 731 of file OperationSupport.h.
References isRegistered().
Referenced by mlir::Pass::canScheduleOn(), mlir::OpInterface< ConcreteType, Traits >::getInterfaceFor(), mlir::Operation::getRegisteredInfo(), and inferOperationTypes().
|
inline |
Return the name of this operation. This always succeeds.
Definition at line 497 of file OperationSupport.h.
References getIdentifier().
Referenced by addBodyWithPayloadOp(), AncestorKey::AncestorKey(), mlir::transform::detail::checkApplyToOne(), TosaProfileCompliance::checkInvalid(), mlir::Op< ConcreteType, Traits >::classof(), cloneOpWithOperandsAndTypes(), mlir::RewriterBase::eraseOpResults(), mlir::linalg::generateLibraryCallName(), getDialectNamespace(), getTargetShape(), inferOperationTypes(), mlir::detail::NameOpMatcher::match(), mlirLinalgFillBuiltinNamedOpRegion(), mlir::Diagnostic::operator<<(), print(), mlir::OpState::printOpName(), printShortForm(), reportNewIrLegalizationFatalError(), stripDialect(), mlir::transform::detail::verifyParamProducerTransformOpTrait(), and mlir::OpTrait::SingleBlockImplicitTerminator< TerminatorOpType >::Impl< ConcreteType >::verifyRegionTrait().
|
inline |
Return the unique identifier of the derived Op class, or null if not registered.
Definition at line 255 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::Impl::getTypeID().
Referenced by mlir::OpInterface< ConcreteType, Traits >::getInterfaceFor().
|
inline |
Definition at line 476 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::hashProperties().
|
inline |
Returns true if this operation has the given interface registered to it.
Definition at line 390 of file OperationSupport.h.
References mlir::TypeID::get(), and hasInterface().
Referenced by hasInterface(), hasPromiseOrImplementsInterface(), and mightHaveInterface().
Definition at line 393 of file OperationSupport.h.
References mlir::detail::InterfaceMap::contains(), getImpl(), and mlir::OperationName::Impl::getInterfaceMap().
|
inline |
Returns true if InterfaceT has been promised by the dialect or implemented.
Definition at line 382 of file OperationSupport.h.
References mlir::OperationName::Impl::getDialect(), mlir::OperationName::Impl::getTypeID(), hasInterface(), and mlir::dialect_extension_detail::hasPromisedInterface().
|
inline |
Returns true if the operation was registered with a particular trait, e.g.
hasTrait<OperandsAreSignlessIntegerLike>(). Returns false if the operation is unregistered.
Definition at line 296 of file OperationSupport.h.
References mlir::TypeID::get(), and hasTrait().
Referenced by hasTrait(), mlirOperationNameHasTrait(), and mlir::AsmParserState::Impl::PartialOpDef::PartialOpDef().
Definition at line 299 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::hasTrait().
|
inline |
Initialize the op properties.
Definition at line 446 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::initProperties().
|
inline |
Return if this operation is registered.
Definition at line 251 of file OperationSupport.h.
References getImpl(), mlir::OperationName::Impl::isRegistered(), and isRegistered().
Referenced by getRegisteredInfo(), mlir::Operation::isRegistered(), and isRegistered().
|
inline |
Returns true if the operation might have the provided interface.
This means that either the operation is unregistered, or it was registered with the provide interface.
Definition at line 401 of file OperationSupport.h.
References mlir::TypeID::get(), and mightHaveInterface().
Referenced by mightHaveInterface().
Definition at line 404 of file OperationSupport.h.
References hasInterface(), and mlir::OperationName::Impl::isRegistered().
|
inline |
Returns true if the operation might have the provided trait.
This means that either the operation is unregistered, or it was registered with the provide trait.
Definition at line 305 of file OperationSupport.h.
References mlir::TypeID::get(), and mightHaveTrait().
Referenced by mightHaveTrait().
Definition at line 308 of file OperationSupport.h.
References getImpl(), mlir::OperationName::InterfaceConcept::hasTrait(), and mlir::OperationName::Impl::isRegistered().
|
inline |
Definition at line 514 of file OperationSupport.h.
References OperationName(), and rhs.
|
inline |
Definition at line 513 of file OperationSupport.h.
References OperationName(), and rhs.
|
inline |
This hook implements the method to populate defaults attributes that are unset.
Definition at line 319 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::populateDefaultAttrs().
|
inline |
Set the default values on the ODS attribute in the properties.
Definition at line 451 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::populateDefaultProperties().
|
inline |
Definition at line 419 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::populateInherentAttrs().
Referenced by mlir::Operation::getAttrDictionary().
| void OperationName::print | ( | raw_ostream & | os | ) | const |
Definition at line 60 of file AsmPrinter.cpp.
References getStringRef().
Referenced by dump(), and mlir::operator<<().
|
inline |
This hook implements the AsmPrinter for this operation.
Definition at line 324 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::printAssembly().
Definition at line 519 of file OperationSupport.h.
References rhs.
|
inline |
Definition at line 415 of file OperationSupport.h.
References getImpl(), mlir::OperationName::Impl::name, and mlir::OperationName::InterfaceConcept::setInherentAttr().
Referenced by mlir::Operation::setInherentAttr().
|
inline |
Define the op properties from the provided Attribute.
Definition at line 461 of file OperationSupport.h.
References mlir::emitError(), getImpl(), OperationName(), and mlir::OperationName::InterfaceConcept::setPropertiesFromAttr().
|
inline |
Return the operation name with dialect name stripped, if it has one.
Definition at line 491 of file OperationSupport.h.
References getStringRef().
|
inline |
This method exists for backward compatibility purpose when using properties to store inherent attributes, it enables validating the attributes when parsed from the older generic syntax pre-Properties.
Definition at line 426 of file OperationSupport.h.
References mlir::emitError(), getImpl(), and mlir::OperationName::InterfaceConcept::verifyInherentAttrs().
|
inline |
These hooks implement the verifiers 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 332 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::verifyInvariants().
|
inline |
Definition at line 335 of file OperationSupport.h.
References getImpl(), and mlir::OperationName::InterfaceConcept::verifyRegionInvariants().