diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h --- a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h +++ b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.h @@ -50,6 +50,13 @@ virtual Operation *findReplacementOp(Operation *op, ValueRange newValues) const; + /// Notify the listener that the pattern failed to match the given operation, + /// and provide a callback to populate a diagnostic with the reason why the + /// failure occurred. + LogicalResult + notifyMatchFailure(Location loc, + function_ref reasonCallback) override; + /// This function is called when a tracked payload op is dropped because no /// replacement op was found. Derived classes can implement this function for /// custom error handling. diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp --- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp +++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp @@ -181,6 +181,16 @@ return it->second.contains(op); } +LogicalResult transform::TrackingListener::notifyMatchFailure( + Location loc, function_ref reasonCallback) { + LLVM_DEBUG({ + Diagnostic diag(loc, DiagnosticSeverity::Remark); + reasonCallback(diag); + DBGS() << "Match Failure : " << diag.str() << "\n"; + }); + return failure(); +} + void transform::TrackingListener::notifyOperationInserted(Operation *op) { newOps[op->getName()].insert(op); }