MLIR
20.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. More... | |
operator Operation * () const | |
This implicitly converts to Operation*. More... | |
Operation * | operator-> () const |
Shortcut of -> to access a member of Operation. More... | |
Operation * | getOperation () |
Return the operation that this refers to. More... | |
MLIRContext * | getContext () |
Return the context this operation belongs to. More... | |
void | print (raw_ostream &os, OpPrintingFlags flags=std::nullopt) |
Print the operation to the given stream. More... | |
void | print (raw_ostream &os, AsmState &asmState) |
void | dump () |
Dump this operation. More... | |
Location | getLoc () |
The source location the operation was defined or derived from. More... | |
bool | use_empty () |
Return true if there are no users of any results of this operation. More... | |
void | erase () |
Remove this operation from its parent block and delete it. More... | |
InFlightDiagnostic | emitOpError (const Twine &message={}) |
Emit an error with the op name prefixed, like "'dim' op " which is convenient for verifiers. More... | |
InFlightDiagnostic | emitError (const Twine &message={}) |
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers that may be listening. More... | |
InFlightDiagnostic | emitWarning (const Twine &message={}) |
Emit a warning about this operation, reporting up to any diagnostic handlers that may be listening. More... | |
InFlightDiagnostic | emitRemark (const Twine &message={}) |
Emit a remark about this operation, reporting up to any diagnostic handlers that may be listening. More... | |
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. More... | |
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. More... | |
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. More... | |
static void | populateDefaultAttrs (const OperationName &, NamedAttrList &) |
This hook populates any unset default attrs. More... | |
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. More... | |
LogicalResult | verifyRegions () |
OpState (Operation *state) | |
Mutability management is handled by the OpWrapper/OpConstWrapper classes, so we can cast it away here. More... | |
Static Protected Member Functions | |
static ParseResult | parse (OpAsmParser &parser, OperationState &result) |
Parse the custom form of an operation. More... | |
static void | print (Operation *op, OpAsmPrinter &p, StringRef defaultDialect) |
Print the operation. More... | |
static ParseResult | genericParseProperties (OpAsmParser &parser, Attribute &result) |
Parse properties as a Attribute. More... | |
static void | genericPrintProperties (OpAsmPrinter &p, Attribute properties, ArrayRef< StringRef > elidedProps={}) |
Print the properties as a Attribute with names not included within 'elidedProps'. More... | |
static void | printOpName (Operation *op, OpAsmPrinter &p, StringRef defaultDialect) |
Print an operation name, eliding the dialect prefix if necessary. More... | |
static EmptyProperties & | getEmptyProperties () |
For all op which don't have properties, we keep a single instance of EmptyProperties to be used where a reference to a properties is needed: this allow to bind a pointer to the reference without triggering UB. More... | |
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 96 of file OpDefinition.h.
|
inlineexplicitprotected |
Mutability management is handled by the OpWrapper/OpConstWrapper classes, so we can cast it away here.
Definition at line 240 of file OpDefinition.h.
|
inline |
Dump this operation.
Definition at line 122 of file OpDefinition.h.
References mlir::Operation::dump().
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 826 of file Operation.cpp.
Referenced by mlir::Op< ConcreteType, Traits >::parseProperties(), mlir::Op< ConcreteType, Traits >::setPropertiesFromAttr(), and verifyImageOperands().
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 832 of file Operation.cpp.
Referenced by mlir::spirv::verifyAccessChain().
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 844 of file Operation.cpp.
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 838 of file Operation.cpp.
|
inline |
Remove this operation from its parent block and delete it.
Definition at line 131 of file OpDefinition.h.
References mlir::Operation::erase().
|
staticprotected |
Parse properties as a Attribute.
Definition at line 791 of file Operation.cpp.
References mlir::AsmParser::parseAttribute(), mlir::AsmParser::parseGreater(), and mlir::AsmParser::parseOptionalLess().
Referenced by mlir::Op< ConcreteType, Traits >::parseProperties().
|
staticprotected |
Print the properties as a Attribute with names not included within 'elidedProps'.
Definition at line 802 of file Operation.cpp.
References mlir::NamedAttribute::getName(), and mlir::OpAsmPrinter::printOptionalAttrDict().
|
inlinestatic |
This hook returns any canonicalization pattern rewrites that the operation supports, for use by the canonicalization pass.
Definition at line 201 of file OpDefinition.h.
|
inline |
Return the context this operation belongs to.
Definition at line 111 of file OpDefinition.h.
References mlir::Operation::getContext(), and getOperation().
Referenced by mlir::affine::AffineDmaStartOp::getAffineMapAttrForMemRef(), and mlir::affine::AffineDmaWaitOp::getAffineMapAttrForMemRef().
|
inlinestaticprotected |
For all op which don't have properties, we keep a single instance of EmptyProperties
to be used where a reference to a properties is needed: this allow to bind a pointer to the reference without triggering UB.
Definition at line 245 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 125 of file OpDefinition.h.
References mlir::Operation::getLoc().
Referenced by createCtlzFunc(), and mlir::spirv::verifyAccessChain().
|
inline |
Return the operation that this refers to.
Definition at line 108 of file OpDefinition.h.
Referenced by getContext(), operator bool(), mlir::operator!=(), and mlir::operator==().
|
inlineexplicit |
Ops are pointer-like, so we allow conversion to bool.
Definition at line 99 of file OpDefinition.h.
References getOperation().
|
inline |
This implicitly converts to Operation*.
Definition at line 102 of file OpDefinition.h.
|
inline |
Shortcut of ->
to access a member of Operation.
Definition at line 105 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 762 of file Operation.cpp.
References mlir::AsmParser::emitError(), mlir::OperationName::getDialect(), mlir::AsmParser::getNameLoc(), mlir::Dialect::getParseOperationHook(), mlir::OperationName::getStringRef(), and mlir::OperationState::name.
|
inlinestatic |
This hook populates any unset default attrs.
Definition at line 205 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 771 of file Operation.cpp.
|
inline |
Definition at line 117 of file OpDefinition.h.
References mlir::Operation::print().
|
inline |
Print the operation to the given stream.
Definition at line 114 of file OpDefinition.h.
References mlir::Operation::print().
|
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 782 of file Operation.cpp.
|
inline |
Return true if there are no users of any results of this operation.
Definition at line 128 of file OpDefinition.h.
References mlir::Operation::use_empty().
|
inlineprotected |
If the concrete type didn't implement a custom verifier hook, just fall back to this one which accepts everything.
Definition at line 210 of file OpDefinition.h.
|
inlineprotected |
Definition at line 211 of file OpDefinition.h.
|
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 165 of file OpDefinition.h.
References mlir::Operation::walk().
|
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 *, const WalkStage &) : Walk all operation opaquely
Definition at line 193 of file OpDefinition.h.
References mlir::Operation::walk().