xref: /llvm-project/mlir/test/mlir-pdll/CodeGen/MLIR/stmt.pdll (revision 95b4e88b1db348fbb074c945bd85c777cf807cc0)
1// RUN: mlir-pdll %s -I %S -split-input-file -x mlir | FileCheck %s
2
3//===----------------------------------------------------------------------===//
4// EraseStmt
5//===----------------------------------------------------------------------===//
6
7// CHECK: pdl.pattern @EraseStmt
8// CHECK: %[[OP:.*]] = operation
9// CHECK: rewrite %[[OP]]
10// CHECK:   erase %[[OP]]
11Pattern EraseStmt => erase op<>;
12
13// -----
14
15// CHECK: pdl.pattern @EraseStmtNested
16// CHECK: %[[OP:.*]] = operation
17// CHECK: rewrite %[[OP]]
18// CHECK:   erase %[[OP]]
19Pattern EraseStmtNested => rewrite root: Op with { erase root; };
20
21// -----
22
23//===----------------------------------------------------------------------===//
24// ReplaceStmt
25//===----------------------------------------------------------------------===//
26
27// CHECK: pdl.pattern @ReplaceStmt
28// CHECK: %[[OPERANDS:.*]] = operands
29// CHECK: %[[OP:.*]] = operation(%[[OPERANDS]]
30// CHECK: rewrite %[[OP]]
31// CHECK:   replace %[[OP]] with(%[[OPERANDS]] : !pdl.range<value>)
32Pattern ReplaceStmt => replace op<>(operands: ValueRange) with operands;
33
34// -----
35
36// CHECK: pdl.pattern @ReplaceStmtNested
37// CHECK: %[[OPERANDS:.*]] = operands
38// CHECK: %[[OP:.*]] = operation(%[[OPERANDS]]
39// CHECK: rewrite %[[OP]]
40// CHECK:   replace %[[OP]] with(%[[OPERANDS]] : !pdl.range<value>)
41Pattern ReplaceStmtNested {
42  let root = op<>(operands: ValueRange);
43  rewrite root with { replace root with operands; };
44}
45
46// -----
47
48//===----------------------------------------------------------------------===//
49// RewriteStmt
50//===----------------------------------------------------------------------===//
51
52// CHECK: pdl.pattern @RewriteStmtNested
53// CHECK: %[[OP:.*]] = operation
54// CHECK: rewrite %[[OP]]
55// CHECK:   erase %[[OP]]
56Pattern RewriteStmtNested {
57  rewrite root: Op with {
58    rewrite root with { erase root; };
59  };
60}
61
62