16#include "llvm/ADT/STLExtras.h"
21#include "mlir/Dialect/Transform/IRDLExtension/IRDLExtensionOps.cpp.inc"
26IRDLCollectMatchingOp::apply(TransformRewriter &rewriter,
27 TransformResults &results, TransformState &state) {
28 auto dialect = cast<irdl::DialectOp>(getBody().front().front());
30 irdl::OperationOp operation = *body.
getOps<irdl::OperationOp>().begin();
33 DenseMap<irdl::TypeOp, std::unique_ptr<DynamicTypeDefinition>>(),
34 DenseMap<irdl::AttributeOp, std::unique_ptr<DynamicAttrDefinition>>());
36 auto handlerID =
getContext()->getDiagEngine().registerHandler(
39 for (
Operation *payload : state.getPayloadOps(getRoot())) {
41 if (succeeded(verifier(
target))) {
46 getContext()->getDiagEngine().eraseHandler(handlerID);
47 results.set(cast<OpResult>(getMatched()), matched);
51void IRDLCollectMatchingOp::getEffects(
58LogicalResult IRDLCollectMatchingOp::verify() {
60 if (!llvm::hasSingleElement(bodyBlock))
61 return emitOpError() <<
"expects a single operation in the body";
63 auto dialect = dyn_cast<irdl::DialectOp>(bodyBlock.
front());
65 return emitOpError() <<
"expects the body operation to be "
66 << irdl::DialectOp::getOperationName();
72 auto irdlOperations = dialect.getOps<irdl::OperationOp>();
73 if (!llvm::hasSingleElement(irdlOperations))
74 return emitOpError() <<
"expects IRDL to contain exactly one operation";
76 if (!dialect.getOps<irdl::TypeOp>().empty() ||
77 !dialect.getOps<irdl::AttributeOp>().empty()) {
78 return emitOpError() <<
"IRDL types and attributes are not yet supported";
p<< " : "<< getMemRefType()<< ", "<< getType();}static LogicalResult verifyVectorMemoryOp(Operation *op, MemRefType memrefType, VectorType vectorType) { if(memrefType.getElementType() !=vectorType.getElementType()) return op-> emitOpError("requires memref and vector types of the same elemental type")
Given a list of lists of parsed operands, populates uniqueOperands with unique operands.
Block represents an ordered list of Operations.
iterator_range< op_iterator< OpT > > getOps()
Return an iterator range over the operations within this block that are of 'OpT'.
The result of a transform IR operation application.
static DiagnosedSilenceableFailure success()
Constructs a DiagnosedSilenceableFailure in the success state.
This class contains all of the information necessary to report a diagnostic to the DiagnosticEngine.
Operation is the basic unit of execution within MLIR.
llvm::unique_function< LogicalResult(Operation *) const > createVerifier(OperationOp operation, const DenseMap< irdl::TypeOp, std::unique_ptr< DynamicTypeDefinition > > &typeDefs, const DenseMap< irdl::AttributeOp, std::unique_ptr< DynamicAttrDefinition > > &attrDefs)
Generate an op verifier function from the given IRDL operation definition.
Include the generated interface declarations.
llvm::DenseMap< KeyT, ValueT, KeyInfoT, BucketT > DenseMap