1// RUN: mlir-opt %s --test-transform-dialect-interpreter --split-input-file --verify-diagnostics
2
3// expected-remark @below {{applying transformation}}
4transform.test_transform_op
5
6// -----
7
8%0 = transform.test_produce_param_or_forward_operand 42 { foo = "bar" }
9// expected-remark @below {{succeeded}}
10transform.test_consume_operand_if_matches_param_or_fail %0[42]
11
12// -----
13
14%0 = transform.test_produce_param_or_forward_operand 42 { foo = "bar" }
15// expected-error @below {{expected the operand to be associated with 21 got 42}}
16transform.test_consume_operand_if_matches_param_or_fail %0[21]
17
18// -----
19
20// expected-error @below {{operation tracked by two handles}}
21%0 = transform.test_produce_param_or_forward_operand 42
22// expected-note @below {{handle}}
23%1 = transform.test_produce_param_or_forward_operand from %0
24// expected-note @below {{handle}}
25%2 = transform.test_produce_param_or_forward_operand from %0
26transform.test_consume_operand_if_matches_param_or_fail %1[42]
27transform.test_consume_operand_if_matches_param_or_fail %2[42]
28
29// -----
30
31transform.sequence {
32^bb0(%arg0: !pdl.operation):
33  sequence %arg0 {
34  ^bb0(%arg1: !pdl.operation):
35    // expected-remark @below {{applying transformation "a"}}
36    test_transform_op "a"
37    // expected-remark @below {{applying transformation "b"}}
38    test_transform_op "b"
39    // expected-remark @below {{applying transformation "c"}}
40    test_transform_op "c"
41  }
42  // expected-remark @below {{applying transformation "d"}}
43  test_transform_op "d"
44  // expected-remark @below {{applying transformation "e"}}
45  test_transform_op "e"
46}
47
48// -----
49
50transform.sequence {
51^bb0(%arg0: !pdl.operation):
52  %0 = test_produce_param_or_forward_operand 42
53  sequence %0 {
54  ^bb0(%arg1: !pdl.operation):
55    // expected-remark @below {{succeeded}}
56    test_consume_operand_if_matches_param_or_fail %arg1[42]
57  }
58}
59
60// -----
61
62transform.sequence {
63^bb0(%arg0: !pdl.operation):
64  %0 = sequence %arg0 {
65  ^bb0(%arg1: !pdl.operation):
66    %1 = test_produce_param_or_forward_operand 42
67    yield %1 : !pdl.operation
68  } : !pdl.operation
69  // expected-remark @below {{succeeded}}
70  test_consume_operand_if_matches_param_or_fail %0[42]
71}
72
73// -----
74
75transform.with_pdl_patterns {
76^bb0(%arg0: !pdl.operation):
77  sequence %arg0 {
78  ^bb0(%arg1: !pdl.operation):
79    %0 = pdl_match @some in %arg1
80    test_print_remark_at_operand %0, "matched"
81  }
82
83  pdl.pattern @some : benefit(1) {
84    %0 = pdl.operation "test.some_op"
85    pdl.rewrite %0 with "transform.dialect"
86  }
87
88  pdl.pattern @other : benefit(1) {
89    %0 = pdl.operation "test.other_op"
90    pdl.rewrite %0 with "transform.dialect"
91  }
92}
93
94// expected-remark @below {{matched}}
95"test.some_op"() : () -> ()
96"test.other_op"() : () -> ()
97// expected-remark @below {{matched}}
98"test.some_op"() : () -> ()
99
100