[Mlir-commits] [mlir] 80aed2e - [mlir][Transform] Allow printing inside matchers
Quinn Dawkins
llvmlistbot at llvm.org
Mon Jul 24 07:08:11 PDT 2023
Author: Quinn Dawkins
Date: 2023-07-24T10:00:23-04:00
New Revision: 80aed2ea4586edfa1eb00b527a259292e73e27ae
URL: https://github.com/llvm/llvm-project/commit/80aed2ea4586edfa1eb00b527a259292e73e27ae
DIFF: https://github.com/llvm/llvm-project/commit/80aed2ea4586edfa1eb00b527a259292e73e27ae.diff
LOG: [mlir][Transform] Allow printing inside matchers
Enables printf style debugging of matchers through `transform.print`
within the body of a matcher.
Differential Revision: https://reviews.llvm.org/D156078
Added:
Modified:
mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
index 9e0b7b95d006cc..7c37416b09adbe 100644
--- a/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
+++ b/mlir/include/mlir/Dialect/Transform/IR/TransformOps.td
@@ -830,7 +830,8 @@ def ParamConstantOp : Op<Transform_Dialect, "param.constant", [
def PrintOp : TransformDialectOp<"print",
[DeclareOpInterfaceMethods<TransformOpInterface>,
- DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+ DeclareOpInterfaceMethods<MemoryEffectsOpInterface>,
+ MatchOpInterface]> {
let summary = "Dump each payload op";
let description = [{
This op dumps each payload op that is associated with the `target` operand
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index d6f85b5218277e..063e1e44fd604c 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -50,6 +50,34 @@ module attributes { transform.with_named_sequence } {
// -----
+module attributes { transform.with_named_sequence } {
+ transform.named_sequence @do_nothing(%arg0: !transform.any_op {transform.readonly}) {
+ transform.yield
+ }
+
+ transform.named_sequence @print_in_matcher(%arg0: !transform.any_op {transform.readonly}) -> !transform.any_op {
+ transform.print %arg0 : !transform.any_op
+ transform.yield %arg0 : !transform.any_op
+ }
+
+ transform.sequence failures(propagate) attributes { transform.target_tag = "transform" } {
+ ^bb0(%arg0: !transform.any_op):
+ transform.foreach_match in %arg0
+ @print_in_matcher -> @do_nothing
+ : (!transform.any_op) -> !transform.any_op
+ }
+
+ func.func @payload() attributes { transform.target_tag = "start_here" } {
+ // CHECK: [[ IR Printer ]]
+ // CHECK: test.print_me
+ %0 = "test.print_me"() : () -> (i1)
+ return
+ }
+}
+
+// -----
+
+
module attributes { transform.with_named_sequence } {
transform.named_sequence @do_nothing(%arg0: !transform.any_op {transform.readonly}) {
transform.yield
More information about the Mlir-commits
mailing list