1// RUN: mlir-opt %s -split-input-file -verify-diagnostics
2
3// expected-error @below {{expects the entry block to have one argument of type '!pdl.operation'}}
4transform.sequence {
5}
6
7// -----
8
9// expected-note @below {{nested in another possible top-level op}}
10transform.sequence {
11^bb0(%arg0: !pdl.operation):
12  // expected-error @below {{expects the root operation to be provided for a nested op}}
13  transform.sequence {
14  ^bb1(%arg1: !pdl.operation):
15  }
16}
17
18// -----
19
20// expected-error @below {{expected children ops to implement TransformOpInterface}}
21transform.sequence {
22^bb0(%arg0: !pdl.operation):
23  // expected-note @below {{op without interface}}
24  arith.constant 42.0 : f32
25}
26
27// -----
28
29// expected-error @below {{expects the types of the terminator operands to match the types of the resul}}
30%0 = transform.sequence {
31^bb0(%arg0: !pdl.operation):
32  // expected-note @below {{terminator}}
33  transform.yield
34} : !pdl.operation
35
36// -----
37
38// expected-note @below {{nested in another possible top-level op}}
39transform.with_pdl_patterns {
40^bb0(%arg0: !pdl.operation):
41  // expected-error @below {{expects the root operation to be provided for a nested op}}
42  transform.sequence {
43  ^bb1(%arg1: !pdl.operation):
44  }
45}
46
47// -----
48
49// expected-error @below {{expects only one non-pattern op in its body}}
50transform.with_pdl_patterns {
51^bb0(%arg0: !pdl.operation):
52  // expected-note @below {{first non-pattern op}}
53  transform.sequence {
54  ^bb1(%arg1: !pdl.operation):
55  }
56  // expected-note @below {{second non-pattern op}}
57  transform.sequence {
58  ^bb1(%arg1: !pdl.operation):
59  }
60}
61
62// -----
63
64// expected-error @below {{expects only pattern and top-level transform ops in its body}}
65transform.with_pdl_patterns {
66^bb0(%arg0: !pdl.operation):
67  // expected-note @below {{offending op}}
68  "test.something"() : () -> ()
69}
70
71// -----
72
73// expected-note @below {{parent operation}}
74transform.with_pdl_patterns {
75^bb0(%arg0: !pdl.operation):
76   // expected-error @below {{op cannot be nested}}
77  transform.with_pdl_patterns %arg0 {
78  ^bb1(%arg1: !pdl.operation):
79  }
80}
81
82// -----
83
84// expected-error @below {{expects one region}}
85"transform.test_transform_unrestricted_op_no_interface"() : () -> ()
86
87// -----
88
89// expected-error @below {{expects a single-block region}}
90"transform.test_transform_unrestricted_op_no_interface"() ({
91^bb0(%arg0: !pdl.operation):
92  "test.potential_terminator"() : () -> ()
93^bb1:
94  "test.potential_terminator"() : () -> ()
95}) : () -> ()
96
97// -----
98
99transform.sequence {
100^bb0(%arg0: !pdl.operation):
101  // expected-error @below {{result #0 has more than one potential consumer}}
102  %0 = test_produce_param_or_forward_operand 42
103  // expected-note @below {{used here as operand #0}}
104  test_consume_operand_if_matches_param_or_fail %0[42]
105  // expected-note @below {{used here as operand #0}}
106  test_consume_operand_if_matches_param_or_fail %0[42]
107}
108
109// -----
110
111transform.sequence {
112^bb0(%arg0: !pdl.operation):
113  // expected-error @below {{result #0 has more than one potential consumer}}
114  %0 = test_produce_param_or_forward_operand 42
115  // expected-note @below {{used here as operand #0}}
116  test_consume_operand_if_matches_param_or_fail %0[42]
117  // expected-note @below {{used here as operand #0}}
118  transform.sequence %0 {
119  ^bb1(%arg1: !pdl.operation):
120    test_consume_operand_if_matches_param_or_fail %arg1[42]
121  }
122}
123
124// -----
125
126transform.sequence {
127^bb0(%arg0: !pdl.operation):
128  // expected-error @below {{result #0 has more than one potential consumer}}
129  %0 = test_produce_param_or_forward_operand 42
130  // expected-note @below {{used here as operand #0}}
131  test_consume_operand_if_matches_param_or_fail %0[42]
132  transform.sequence %0 {
133  ^bb1(%arg1: !pdl.operation):
134    // expected-note @below {{used here as operand #0}}
135    test_consume_operand_if_matches_param_or_fail %0[42]
136  }
137}
138
139// -----
140
141transform.sequence {
142^bb0(%arg0: !pdl.operation):
143  // expected-error @below {{result #0 has more than one potential consumer}}
144  %0 = test_produce_param_or_forward_operand 42
145  // expected-note @below {{used here as operand #0}}
146  test_consume_operand_if_matches_param_or_fail %0[42]
147  // expected-note @below {{used here as operand #0}}
148  transform.sequence %0 {
149  ^bb1(%arg1: !pdl.operation):
150    transform.sequence %arg1 {
151    ^bb2(%arg2: !pdl.operation):
152      test_consume_operand_if_matches_param_or_fail %arg2[42]
153    }
154  }
155}
156