|
MLIR 24.0.0git
|
This is the concrete base class that holds the operation pointer and has non-generic methods that only depend on State (to avoid having them instantiated on template types that don't affect them. More...
#include "mlir/IR/OpDefinition.h"
Public Member Functions | |
| operator bool () | |
| Ops are pointer-like, so we allow conversion to bool. | |
| operator Operation * () const | |
| This implicitly converts to Operation*. | |
| Operation * | operator-> () const |
| Shortcut of -> to access a member of Operation. | |
| Operation * | getOperation () |
| Return the operation that this refers to. | |
| MLIRContext * | getContext () |
| Return the context this operation belongs to. | |
| void | print (raw_ostream &os, OpPrintingFlags flags={}) |
| Print the operation to the given stream. | |
| void | print (raw_ostream &os, AsmState &asmState) |
| LLVM_DUMP_METHOD void | dump () |
| Dump this operation. | |
| Location | getLoc () |
| The source location the operation was defined or derived from. | |
| bool | use_empty () |
| Return true if there are no users of any results of this operation. | |
| void | erase () |
| Remove this operation from its parent block and delete it. | |
| InFlightDiagnostic | emitOpError (const Twine &message={}) |
| Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers. | |
| InFlightDiagnostic | emitError (const Twine &message={}) |
| Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers that may be listening. | |
| InFlightDiagnostic | emitWarning (const Twine &message={}) |
| Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening. | |
| InFlightDiagnostic | emitRemark (const Twine &message={}) |
| Emit a remark about this operation, reporting up to any diagnostic handlers that may be listening. | |
| template<WalkOrder Order = WalkOrder::PostOrder, typename Iterator = ForwardIterator, typename FnT, typename RetT = detail::walkResultType<FnT>> | |
| std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, RetT > | walk (FnT &&callback) |
| Walk the operation by calling the callback for each nested operation (including this one), block or region, depending on the callback provided. | |
| template<typename FnT, typename RetT = detail::walkResultType<FnT>> | |
| std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==2, RetT > | walk (FnT &&callback) |
| Generic walker with a stage aware callback. | |
Static Public Member Functions | |
| static void | getCanonicalizationPatterns (RewritePatternSet &results, MLIRContext *context) |
| This hook returns any canonicalization pattern rewrites that the operation supports, for use by the canonicalization pass. | |
| static void | populateDefaultAttrs (const OperationName &, NamedAttrList &) |
| This hook populates any unset default attrs. | |
Protected Member Functions | |
| LogicalResult | verify () |
| If the concrete type didn't implement a custom verifier hook, just fall back to this one which accepts everything. | |
| LogicalResult | verifyRegions () |
| OpState (Operation *state) | |
| Mutability management is handled by the OpWrapper/OpConstWrapper classes, so we can cast it away here. | |
Static Protected Member Functions | |
| static ParseResult | parse (OpAsmParser &parser, OperationState &result) |
| Parse the custom form of an operation. | |
| static void | print (Operation *op, OpAsmPrinter &p, StringRef defaultDialect) |
| Print the operation. | |
| static ParseResult | genericParseProperties (OpAsmParser &parser, Attribute &result) |
| Parse properties as a Attribute. | |
| static void | genericPrintProperties (OpAsmPrinter &p, Attribute properties, ArrayRef< StringRef > elidedProps={}) |
| Print the properties as a Attribute with names not included within 'elidedProps'. | |
| static void | printOpName (Operation *op, OpAsmPrinter &p, StringRef defaultDialect) |
| Print an operation name, eliding the dialect prefix if necessary. | |
| static EmptyProperties & | getEmptyProperties () |
| For all ops which don't have properties, we keep a single instance of EmptyProperties to be used where a pointer to a struct of properties is needed: this allows binding a pointer to the reference without triggering UB. | |
This is the concrete base class that holds the operation pointer and has non-generic methods that only depend on State (to avoid having them instantiated on template types that don't affect them.
This also has the fallback implementations of customization hooks for when they aren't customized.
Definition at line 100 of file OpDefinition.h.
|
inlineexplicitprotected |
Mutability management is handled by the OpWrapper/OpConstWrapper classes, so we can cast it away here.
Definition at line 246 of file OpDefinition.h.
Referenced by mlir::Op< ConcreteType, Traits >::Op(), mlir::Op< ConcreteType, Traits >::Op(), and mlir::Op< ConcreteType, Traits >::Op().
| void OpState::dump | ( | ) |
Dump this operation.
Definition at line 787 of file Operation.cpp.
| InFlightDiagnostic OpState::emitError | ( | const Twine & | message = {} | ) |
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers that may be listening.
Definition at line 840 of file Operation.cpp.
References getOperation().
Referenced by checkDataOperands(), checkDeclareOperands(), checkNoModifier(), checkValidModifier(), checkVarAndAccVar(), checkVarAndVarType(), checkWaitAndAsyncConflict(), mlir::spirv::ElementwiseOpPattern< Op, SPIRVOp >::matchAndRewrite(), mlir::Op< ConcreteType, Traits >::parseProperties(), mlir::Op< ConcreteType, Traits >::setPropertiesFromAttr(), verifyExtOp(), and verifyTruncateOp().
| InFlightDiagnostic OpState::emitOpError | ( | const Twine & | message = {} | ) |
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers.
Definition at line 846 of file Operation.cpp.
References getOperation().
Referenced by mlir::spirv::verifyAccessChain(), verifyDeviceTypeAndSegmentCountMatch(), and verifyDeviceTypeCountMatch().
| InFlightDiagnostic OpState::emitRemark | ( | const Twine & | message = {} | ) |
Emit a remark about this operation, reporting up to any diagnostic handlers that may be listening.
Definition at line 858 of file Operation.cpp.
References getOperation().
| InFlightDiagnostic OpState::emitWarning | ( | const Twine & | message = {} | ) |
Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening.
Definition at line 852 of file Operation.cpp.
References getOperation().
|
inline |
Remove this operation from its parent block and delete it.
Definition at line 137 of file OpDefinition.h.
|
staticprotected |
Parse properties as a Attribute.
Definition at line 801 of file Operation.cpp.
References mlir::AsmParser::parseAttribute(), mlir::AsmParser::parseGreater(), mlir::AsmParser::parseOptionalLess(), result, and success().
Referenced by mlir::Op< ConcreteType, Traits >::parseProperties().
|
staticprotected |
Print the properties as a Attribute with names not included within 'elidedProps'.
A leading space is printed as part of the properties, so that nothing is emitted at all when every property is elided.
Definition at line 813 of file Operation.cpp.
References mlir::NamedAttribute::getName(), and mlir::AsmPrinter::printNamedAttribute().
|
inlinestatic |
This hook returns any canonicalization pattern rewrites that the operation supports, for use by the canonicalization pass.
Definition at line 207 of file OpDefinition.h.
|
inline |
Return the context this operation belongs to.
Definition at line 115 of file OpDefinition.h.
References mlir::Operation::getContext(), and getOperation().
|
inlinestaticprotected |
For all ops which don't have properties, we keep a single instance of EmptyProperties to be used where a pointer to a struct of properties is needed: this allows binding a pointer to the reference without triggering UB.
Definition at line 252 of file OpDefinition.h.
Referenced by mlir::Op< ConcreteType, Traits >::getProperties().
|
inline |
The source location the operation was defined or derived from.
Definition at line 131 of file OpDefinition.h.
Referenced by checkDeclareOperands(), mlir::tosa::checkHasDynamicBatchDims(), getGridAndVerifyAxes(), ConvertNativeFuncPattern< Op >::matchAndRewrite(), mlir::gpu::index_lowering::OpLowering< Op, XOp, YOp, ZOp >::matchAndRewrite(), mlir::spirv::ElementwiseOpPattern< Op, SPIRVOp >::matchAndRewrite(), and mlir::spirv::verifyAccessChain().
|
inline |
Return the operation that this refers to.
Definition at line 112 of file OpDefinition.h.
Referenced by emitError(), emitOpError(), emitRemark(), emitWarning(), getContext(), and operator bool().
|
inlineexplicit |
Ops are pointer-like, so we allow conversion to bool.
Definition at line 103 of file OpDefinition.h.
References getOperation().
|
inline |
This implicitly converts to Operation*.
Definition at line 106 of file OpDefinition.h.
|
inline |
Shortcut of -> to access a member of Operation.
Definition at line 109 of file OpDefinition.h.
|
staticprotected |
Parse the custom form of an operation.
Unless overridden, this method will first try to get an operation parser from the op's dialect. Otherwise the custom assembly form of an op is always rejected. Op implementations should implement this to return failure. On success, they should fill in result with the fields to use.
Definition at line 768 of file Operation.cpp.
References mlir::AsmParser::emitError(), mlir::AsmParser::getNameLoc(), and result.
|
inlinestatic |
This hook populates any unset default attrs.
Definition at line 211 of file OpDefinition.h.
|
staticprotected |
Print the operation.
Unless overridden, this method will first try to get an operation printer from the dialect. Otherwise, it prints the operation in generic form.
Definition at line 777 of file Operation.cpp.
References mlir::Operation::getDialect(), mlir::Dialect::getOperationPrinter(), mlir::OpAsmPrinter::printGenericOp(), and printOpName().
|
inline |
Definition at line 121 of file OpDefinition.h.
|
inline |
Print the operation to the given stream.
Definition at line 118 of file OpDefinition.h.
Referenced by mlir::operator<<().
|
staticprotected |
Print an operation name, eliding the dialect prefix if necessary.
Print an operation name, eliding the dialect prefix if necessary and doesn't lead to ambiguities.
Definition at line 792 of file Operation.cpp.
References mlir::Operation::getName(), mlir::AsmPrinter::getStream(), and mlir::OperationName::getStringRef().
Referenced by print().
|
inline |
Return true if there are no users of any results of this operation.
Definition at line 134 of file OpDefinition.h.
|
inlineprotected |
If the concrete type didn't implement a custom verifier hook, just fall back to this one which accepts everything.
Definition at line 216 of file OpDefinition.h.
References success().
|
inlineprotected |
Definition at line 217 of file OpDefinition.h.
References success().
|
inline |
Walk the operation by calling the callback for each nested operation (including this one), block or region, depending on the callback provided.
The order in which regions, blocks and operations the same nesting level are visited (e.g., lexicographical or reverse lexicographical order) is determined by 'Iterator'. The walk order for enclosing regions, blocks and operations with respect to their nested ones is specified by 'Order' (post-order by default). A callback on a block or operation is allowed to erase that block or operation if either:
Definition at line 171 of file OpDefinition.h.
|
inline |
Generic walker with a stage aware callback.
Walk the operation by calling the callback for each nested operation (including this one) N+1 times, where N is the number of regions attached to that operation.
The callback method can take any of the following forms: void(Operation <em>, const WalkStage &) : Walk all operation opaquely
|OpT, const WalkStage &stage) : Walk operations, but allow for interruption/skipping.
Definition at line 199 of file OpDefinition.h.