Files
clang-p2996/mlir/test/Dialect/Linalg/transform-op-replace.mlir
Matthias Springer 504a7516a1 [mlir][linalg][transform] Add structured.replace op
This op is useful for debugging/experiments and allows users to replace ops (without arguments + IsolatedFromAbove) with the given op in the region of transform op.

Differential Revision: https://reviews.llvm.org/D139026
2022-12-01 09:04:35 +01:00

51 lines
1.2 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
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
// 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
transform.structured.replace %0 {
^bb0(%a: i1):
// expected-error @+1 {{expected replacement without operands}}
"dummy_op"(%a) : (i1) -> ()
}
}