llvm-project/mlir/test/Dialect/Linalg/transform-op-replace.mlir
Nicolas Vasilache e1c5cbc09c [mlir][Linalg] Put a proper type on transform.structured.match op
This allows much better verification messages in consuming ops that properly declare
`TransformHandleTypeInterface` on their operands.

Downstream tests can be updated with a command resembling:

```
 git grep -l "structured\.match" mlir/test | xargs -i sed -i {} -e  "s/\(structured.match.*\)/\1 : (\!pdl.operation) -> \!pdl.operation/g"
```

Differential Revision: https://reviews.llvm.org/D142643
2023-01-26 08:51:34 -08:00

51 lines
1.3 KiB
MLIR

// RUN: mlir-opt -test-transform-dialect-interpreter %s -allow-unregistered-dialect -verify-diagnostics --split-input-file | FileCheck %s
// CHECK: func.func @foo() {
// CHECK: "dummy_op"() : () -> ()
// CHECK: }
// CHECK-NOT: func.func @bar
func.func @bar() {
"another_op"() : () -> ()
}
transform.sequence failures(propagate) {
^bb1(%arg1: !pdl.operation):
%0 = transform.structured.match ops{["func.func"]} in %arg1 : (!pdl.operation) -> !pdl.operation
transform.structured.replace %0 {
func.func @foo() {
"dummy_op"() : () -> ()
}
}
}
// -----
func.func @bar(%arg0: i1) {
"another_op"(%arg0) : (i1) -> ()
}
transform.sequence failures(propagate) {
^bb1(%arg1: !pdl.operation):
%0 = transform.structured.match ops{["another_op"]} in %arg1 : (!pdl.operation) -> !pdl.operation
// expected-error @+1 {{expected target without operands}}
transform.structured.replace %0 {
"dummy_op"() : () -> ()
}
}
// -----
func.func @bar() {
"another_op"() : () -> ()
}
transform.sequence failures(propagate) {
^bb1(%arg1: !pdl.operation):
%0 = transform.structured.match ops{["another_op"]} in %arg1 : (!pdl.operation) -> !pdl.operation
transform.structured.replace %0 {
^bb0(%a: i1):
// expected-error @+1 {{expected replacement without operands}}
"dummy_op"(%a) : (i1) -> ()
}
}