1// RUN: mlir-tblgen -gen-op-decls -asmformat-error-is-fatal=false -I %S/../../include %s -o=%t 2>&1 | FileCheck %s
2
3// This file contains tests for the specification of the declarative op format.
4
5include "mlir/IR/OpBase.td"
6
7def TestDialect : Dialect {
8  let name = "test";
9}
10class TestFormat_Op<string name, string fmt, list<OpTrait> traits = []>
11    : Op<TestDialect, name, traits> {
12  let assemblyFormat = fmt;
13}
14
15//===----------------------------------------------------------------------===//
16// Directives
17//===----------------------------------------------------------------------===//
18
19//===----------------------------------------------------------------------===//
20// attr-dict
21
22// CHECK: error: 'attr-dict' directive not found
23def DirectiveAttrDictInvalidA : TestFormat_Op<"attrdict_invalid_a", [{
24}]>;
25// CHECK: error: 'attr-dict' directive has already been seen
26def DirectiveAttrDictInvalidB : TestFormat_Op<"attrdict_invalid_b", [{
27  attr-dict attr-dict
28}]>;
29// CHECK: error: 'attr-dict' directive has already been seen
30def DirectiveAttrDictInvalidC : TestFormat_Op<"attrdict_invalid_c", [{
31  attr-dict attr-dict-with-keyword
32}]>;
33// CHECK: error: 'attr-dict' directive can only be used as a top-level directive
34def DirectiveAttrDictInvalidD : TestFormat_Op<"attrdict_invalid_d", [{
35  type(attr-dict)
36}]>;
37// CHECK-NOT: error
38def DirectiveAttrDictValidA : TestFormat_Op<"attrdict_valid_a", [{
39  attr-dict
40}]>;
41def DirectiveAttrDictValidB : TestFormat_Op<"attrdict_valid_b", [{
42  attr-dict-with-keyword
43}]>;
44
45//===----------------------------------------------------------------------===//
46// custom
47
48// CHECK: error: expected '<' before custom directive name
49def DirectiveCustomInvalidA : TestFormat_Op<"custom_invalid_a", [{
50  custom(
51}]>;
52// CHECK: error: expected custom directive name identifier
53def DirectiveCustomInvalidB : TestFormat_Op<"custom_invalid_b", [{
54  custom<>
55}]>;
56// CHECK: error: expected '>' after custom directive name
57def DirectiveCustomInvalidC : TestFormat_Op<"custom_invalid_c", [{
58  custom<MyDirective(
59}]>;
60// CHECK: error: expected '(' before custom directive parameters
61def DirectiveCustomInvalidD : TestFormat_Op<"custom_invalid_d", [{
62  custom<MyDirective>)
63}]>;
64// CHECK: error: only variables and types may be used as parameters to a custom directive
65def DirectiveCustomInvalidE : TestFormat_Op<"custom_invalid_e", [{
66  custom<MyDirective>(operands)
67}]>;
68// CHECK: error: expected ')' after custom directive parameters
69def DirectiveCustomInvalidF : TestFormat_Op<"custom_invalid_f", [{
70  custom<MyDirective>($operand<
71}]>, Arguments<(ins I64:$operand)>;
72// CHECK: error: type directives within a custom directive may only refer to variables
73def DirectiveCustomInvalidH : TestFormat_Op<"custom_invalid_h", [{
74  custom<MyDirective>(type(operands))
75}]>;
76
77// CHECK-NOT: error
78def DirectiveCustomValidA : TestFormat_Op<"custom_valid_a", [{
79  custom<MyDirective>($operand) attr-dict
80}]>, Arguments<(ins Optional<I64>:$operand)>;
81def DirectiveCustomValidB : TestFormat_Op<"custom_valid_b", [{
82  custom<MyDirective>($operand, type($operand), type($result)) attr-dict
83}]>, Arguments<(ins I64:$operand)>, Results<(outs I64:$result)>;
84def DirectiveCustomValidC : TestFormat_Op<"custom_valid_c", [{
85  custom<MyDirective>($attr) attr-dict
86}]>, Arguments<(ins I64Attr:$attr)>;
87
88//===----------------------------------------------------------------------===//
89// functional-type
90
91// CHECK: error: 'functional-type' is only valid as a top-level directive
92def DirectiveFunctionalTypeInvalidA : TestFormat_Op<"functype_invalid_a", [{
93  functional-type(functional-type)
94}]>;
95// CHECK: error: expected '(' before argument list
96def DirectiveFunctionalTypeInvalidB : TestFormat_Op<"functype_invalid_b", [{
97  functional-type
98}]>;
99// CHECK: error: expected directive, literal, variable, or optional group
100def DirectiveFunctionalTypeInvalidC : TestFormat_Op<"functype_invalid_c", [{
101  functional-type(
102}]>;
103// CHECK: error: expected ',' after inputs argument
104def DirectiveFunctionalTypeInvalidD : TestFormat_Op<"functype_invalid_d", [{
105  functional-type(operands
106}]>;
107// CHECK: error: expected directive, literal, variable, or optional group
108def DirectiveFunctionalTypeInvalidE : TestFormat_Op<"functype_invalid_e", [{
109  functional-type(operands,
110}]>;
111// CHECK: error: expected ')' after argument list
112def DirectiveFunctionalTypeInvalidF : TestFormat_Op<"functype_invalid_f", [{
113  functional-type(operands, results
114}]>;
115// CHECK-NOT: error
116def DirectiveFunctionalTypeValid : TestFormat_Op<"functype_invalid_a", [{
117  functional-type(operands, results) attr-dict
118}]>;
119
120//===----------------------------------------------------------------------===//
121// operands
122
123// CHECK: error: 'operands' directive creates overlap in format
124def DirectiveOperandsInvalidA : TestFormat_Op<"operands_invalid_a", [{
125  operands operands
126}]>;
127// CHECK: error: 'operands' directive creates overlap in format
128def DirectiveOperandsInvalidB : TestFormat_Op<"operands_invalid_b", [{
129  $operand operands
130}]>, Arguments<(ins I64:$operand)>;
131// CHECK-NOT: error:
132def DirectiveOperandsValid : TestFormat_Op<"operands_valid", [{
133  operands attr-dict
134}]>;
135
136//===----------------------------------------------------------------------===//
137// regions
138
139// CHECK: error: 'regions' directive creates overlap in format
140def DirectiveRegionsInvalidA : TestFormat_Op<"regions_invalid_a", [{
141  regions regions attr-dict
142}]>;
143// CHECK: error: 'regions' directive creates overlap in format
144def DirectiveRegionsInvalidB : TestFormat_Op<"regions_invalid_b", [{
145  $region regions attr-dict
146}]> {
147  let regions = (region AnyRegion:$region);
148}
149// CHECK: error: 'regions' is only valid as a top-level directive
150def DirectiveRegionsInvalidC : TestFormat_Op<"regions_invalid_c", [{
151  type(regions)
152}]>;
153// CHECK-NOT: error:
154def DirectiveRegionsValid : TestFormat_Op<"regions_valid", [{
155  regions attr-dict
156}]>;
157
158//===----------------------------------------------------------------------===//
159// results
160
161// CHECK: error: 'results' directive can not be used as a top-level directive
162def DirectiveResultsInvalidA : TestFormat_Op<"results_invalid_a", [{
163  results
164}]>;
165
166//===----------------------------------------------------------------------===//
167// successors
168
169// CHECK: error: 'successors' is only valid as a top-level directive
170def DirectiveSuccessorsInvalidA : TestFormat_Op<"successors_invalid_a", [{
171  type(successors)
172}]>;
173
174//===----------------------------------------------------------------------===//
175// type
176
177// CHECK: error: expected '(' before argument list
178def DirectiveTypeInvalidA : TestFormat_Op<"type_invalid_a", [{
179  type
180}]>;
181// CHECK: error: expected directive, literal, variable, or optional group
182def DirectiveTypeInvalidB : TestFormat_Op<"type_invalid_b", [{
183  type(
184}]>;
185// CHECK: error: expected ')' after argument list
186def DirectiveTypeInvalidC : TestFormat_Op<"type_invalid_c", [{
187  type(operands
188}]>;
189// CHECK-NOT: error:
190def DirectiveTypeValid : TestFormat_Op<"type_valid", [{
191  type(operands) attr-dict
192}]>;
193
194//===----------------------------------------------------------------------===//
195// functional-type/type operands
196
197// CHECK: error: 'type' directive operand expects variable or directive operand
198def DirectiveTypeZOperandInvalidA : TestFormat_Op<"type_operand_invalid_a", [{
199  type(`literal`)
200}]>;
201// CHECK: error: 'operands' 'type' is already bound
202def DirectiveTypeZOperandInvalidB : TestFormat_Op<"type_operand_invalid_b", [{
203  type(operands) type(operands)
204}]>;
205// CHECK: error: 'operands' 'type' is already bound
206def DirectiveTypeZOperandInvalidC : TestFormat_Op<"type_operand_invalid_c", [{
207  type($operand) type(operands)
208}]>, Arguments<(ins I64:$operand)>;
209// CHECK: error: 'type' of 'operand' is already bound
210def DirectiveTypeZOperandInvalidD : TestFormat_Op<"type_operand_invalid_d", [{
211  type(operands) type($operand)
212}]>, Arguments<(ins I64:$operand)>;
213// CHECK: error: 'type' of 'operand' is already bound
214def DirectiveTypeZOperandInvalidE : TestFormat_Op<"type_operand_invalid_e", [{
215  type($operand) type($operand)
216}]>, Arguments<(ins I64:$operand)>;
217// CHECK: error: 'results' 'type' is already bound
218def DirectiveTypeZOperandInvalidF : TestFormat_Op<"type_operand_invalid_f", [{
219  type(results) type(results)
220}]>;
221// CHECK: error: 'results' 'type' is already bound
222def DirectiveTypeZOperandInvalidG : TestFormat_Op<"type_operand_invalid_g", [{
223  type($result) type(results)
224}]>, Results<(outs I64:$result)>;
225// CHECK: error: 'type' of 'result' is already bound
226def DirectiveTypeZOperandInvalidH : TestFormat_Op<"type_operand_invalid_h", [{
227  type(results) type($result)
228}]>, Results<(outs I64:$result)>;
229// CHECK: error: 'type' of 'result' is already bound
230def DirectiveTypeZOperandInvalidI : TestFormat_Op<"type_operand_invalid_i", [{
231  type($result) type($result)
232}]>, Results<(outs I64:$result)>;
233
234//===----------------------------------------------------------------------===//
235// type_ref
236
237// CHECK: error: 'type_ref' of 'operand' is not bound by a prior 'type' directive
238def DirectiveTypeZZTypeRefOperandInvalidC : TestFormat_Op<"type_ref_operand_invalid_c", [{
239  type_ref($operand) type(operands)
240}]>, Arguments<(ins I64:$operand)>;
241// CHECK: error: 'operands' 'type_ref' is not bound by a prior 'type' directive
242def DirectiveTypeZZTypeRefOperandInvalidD : TestFormat_Op<"type_ref_operand_invalid_d", [{
243  type_ref(operands) type($operand)
244}]>, Arguments<(ins I64:$operand)>;
245// CHECK: error: 'type_ref' of 'operand' is not bound by a prior 'type' directive
246def DirectiveTypeZZTypeRefOperandInvalidE : TestFormat_Op<"type_ref_operand_invalid_e", [{
247  type_ref($operand) type($operand)
248}]>, Arguments<(ins I64:$operand)>;
249// CHECK: error: 'type_ref' of 'result' is not bound by a prior 'type' directive
250def DirectiveTypeZZTypeRefOperandInvalidG : TestFormat_Op<"type_ref_operand_invalid_g", [{
251  type_ref($result) type(results)
252}]>, Results<(outs I64:$result)>;
253// CHECK: error: 'results' 'type_ref' is not bound by a prior 'type' directive
254def DirectiveTypeZZTypeRefOperandInvalidH : TestFormat_Op<"type_ref_operand_invalid_h", [{
255  type_ref(results) type($result)
256}]>, Results<(outs I64:$result)>;
257// CHECK: error: 'type_ref' of 'result' is not bound by a prior 'type' directive
258def DirectiveTypeZZTypeRefOperandInvalidI : TestFormat_Op<"type_ref_operand_invalid_i", [{
259  type_ref($result) type($result)
260}]>, Results<(outs I64:$result)>;
261
262// CHECK-NOT: error
263def DirectiveTypeZZTypeRefOperandB : TestFormat_Op<"type_ref_operand_valid_b", [{
264  type_ref(operands) attr-dict
265}]>;
266// CHECK-NOT: error
267def DirectiveTypeZZTypeRefOperandD : TestFormat_Op<"type_ref_operand_valid_d", [{
268  type(operands) type_ref($operand) attr-dict
269}]>, Arguments<(ins I64:$operand)>;
270// CHECK-NOT: error
271def DirectiveTypeZZTypeRefOperandE : TestFormat_Op<"type_ref_operand_valid_e", [{
272  type($operand) type_ref($operand) attr-dict
273}]>, Arguments<(ins I64:$operand)>;
274// CHECK-NOT: error
275def DirectiveTypeZZTypeRefOperandF : TestFormat_Op<"type_ref_operand_valid_f", [{
276  type(results) type_ref(results) attr-dict
277}]>;
278// CHECK-NOT: error
279def DirectiveTypeZZTypeRefOperandG : TestFormat_Op<"type_ref_operand_valid_g", [{
280  type($result) type_ref(results) attr-dict
281}]>, Results<(outs I64:$result)>;
282// CHECK-NOT: error
283def DirectiveTypeZZTypeRefOperandH : TestFormat_Op<"type_ref_operand_valid_h", [{
284  type(results) type_ref($result) attr-dict
285}]>, Results<(outs I64:$result)>;
286// CHECK-NOT: error
287def DirectiveTypeZZTypeRefOperandI : TestFormat_Op<"type_ref_operand_valid_i", [{
288  type($result) type_ref($result) attr-dict
289}]>, Results<(outs I64:$result)>;
290
291// CHECK-NOT: error:
292def DirectiveTypeZZZOperandValid : TestFormat_Op<"type_operand_valid", [{
293  type(operands) type(results) attr-dict
294}]>;
295
296//===----------------------------------------------------------------------===//
297// Literals
298//===----------------------------------------------------------------------===//
299
300// Test all of the valid literals.
301// CHECK: error: expected valid literal
302def LiteralInvalidA : TestFormat_Op<"literal_invalid_a", [{
303  `1`
304}]>;
305// CHECK: error: unexpected end of file in literal
306// CHECK: error: expected directive, literal, variable, or optional group
307def LiteralInvalidB : TestFormat_Op<"literal_invalid_b", [{
308  `
309}]>;
310// CHECK-NOT: error
311def LiteralValid : TestFormat_Op<"literal_valid", [{
312  `_` `:` `,` `=` `<` `>` `(` `)` `[` `]` `?` `+` `*` ` ` `` `->` `abc$._`
313  attr-dict
314}]>;
315
316//===----------------------------------------------------------------------===//
317// Optional Groups
318//===----------------------------------------------------------------------===//
319
320// CHECK: error: optional groups can only be used as top-level elements
321def OptionalInvalidA : TestFormat_Op<"optional_invalid_a", [{
322  type(($attr^)?) attr-dict
323}]>, Arguments<(ins OptionalAttr<I64Attr>:$attr)>;
324// CHECK: error: expected directive, literal, variable, or optional group
325def OptionalInvalidB : TestFormat_Op<"optional_invalid_b", [{
326  () attr-dict
327}]>, Arguments<(ins OptionalAttr<I64Attr>:$attr)>;
328// CHECK: error: optional group specified no anchor element
329def OptionalInvalidC : TestFormat_Op<"optional_invalid_c", [{
330  ($attr)? attr-dict
331}]>, Arguments<(ins OptionalAttr<I64Attr>:$attr)>;
332// CHECK: error: first parsable element of an operand group must be an attribute, literal, operand, or region
333def OptionalInvalidD : TestFormat_Op<"optional_invalid_d", [{
334  (type($operand) $operand^)? attr-dict
335}]>, Arguments<(ins Optional<I64>:$operand)>;
336// CHECK: error: type directive can only refer to variables within the optional group
337def OptionalInvalidE : TestFormat_Op<"optional_invalid_e", [{
338  (`,` $attr^ type(operands))? attr-dict
339}]>, Arguments<(ins OptionalAttr<I64Attr>:$attr)>;
340// CHECK: error: only one element can be marked as the anchor of an optional group
341def OptionalInvalidF : TestFormat_Op<"optional_invalid_f", [{
342  ($attr^ $attr2^) attr-dict
343}]>, Arguments<(ins OptionalAttr<I64Attr>:$attr, OptionalAttr<I64Attr>:$attr2)>;
344// CHECK: error: only optional attributes can be used to anchor an optional group
345def OptionalInvalidG : TestFormat_Op<"optional_invalid_g", [{
346  ($attr^) attr-dict
347}]>, Arguments<(ins I64Attr:$attr)>;
348// CHECK: error: only variable length operands can be used within an optional group
349def OptionalInvalidH : TestFormat_Op<"optional_invalid_h", [{
350  ($arg^) attr-dict
351}]>, Arguments<(ins I64:$arg)>;
352// CHECK: error: only variables can be used to anchor an optional group
353def OptionalInvalidI : TestFormat_Op<"optional_invalid_i", [{
354  ($arg type($arg)^) attr-dict
355}]>, Arguments<(ins Variadic<I64>:$arg)>;
356// CHECK: error: only literals, types, and variables can be used within an optional group
357def OptionalInvalidJ : TestFormat_Op<"optional_invalid_j", [{
358  (attr-dict)
359}]>;
360// CHECK: error: expected '?' after optional group
361def OptionalInvalidK : TestFormat_Op<"optional_invalid_k", [{
362  ($arg^)
363}]>, Arguments<(ins Variadic<I64>:$arg)>;
364// CHECK: error: only variables can be used to anchor an optional group
365def OptionalInvalidL : TestFormat_Op<"optional_invalid_l", [{
366  (custom<MyDirective>($arg)^)?
367}]>, Arguments<(ins I64:$arg)>;
368// CHECK: error: only variables can be used to anchor an optional group
369def OptionalInvalidM : TestFormat_Op<"optional_invalid_m", [{
370  (` `^)?
371}]>, Arguments<(ins)>;
372
373// CHECK-NOT: error
374def OptionalValidA : TestFormat_Op<"optional_valid_a", [{
375  (` ` `` $arg^)?
376}]>;
377
378//===----------------------------------------------------------------------===//
379// Variables
380//===----------------------------------------------------------------------===//
381
382// CHECK: error: expected variable to refer to an argument, region, result, or successor
383def VariableInvalidA : TestFormat_Op<"variable_invalid_a", [{
384  $unknown_arg attr-dict
385}]>;
386// CHECK: error: attribute 'attr' is already bound
387def VariableInvalidB : TestFormat_Op<"variable_invalid_b", [{
388  $attr $attr attr-dict
389}]>, Arguments<(ins I64Attr:$attr)>;
390// CHECK: error: operand 'operand' is already bound
391def VariableInvalidC : TestFormat_Op<"variable_invalid_c", [{
392  $operand $operand attr-dict
393}]>, Arguments<(ins I64:$operand)>;
394// CHECK: error: operand 'operand' is already bound
395def VariableInvalidD : TestFormat_Op<"variable_invalid_d", [{
396  operands $operand attr-dict
397}]>, Arguments<(ins I64:$operand)>;
398// CHECK: error: results can not be used at the top level
399def VariableInvalidE : TestFormat_Op<"variable_invalid_e", [{
400  $result attr-dict
401}]>, Results<(outs I64:$result)>;
402// CHECK: error: successor 'successor' is already bound
403def VariableInvalidF : TestFormat_Op<"variable_invalid_f", [{
404  $successor $successor attr-dict
405}]> {
406  let successors = (successor AnySuccessor:$successor);
407}
408// CHECK: error: successor 'successor' is already bound
409def VariableInvalidG : TestFormat_Op<"variable_invalid_g", [{
410  successors $successor attr-dict
411}]> {
412  let successors = (successor AnySuccessor:$successor);
413}
414// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr` which does not have a buildable type
415def VariableInvalidH : TestFormat_Op<"variable_invalid_h", [{
416  $attr `:` attr-dict
417}]>, Arguments<(ins ElementsAttr:$attr)>;
418// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr` which does not have a buildable type
419def VariableInvalidI : TestFormat_Op<"variable_invalid_i", [{
420  (`foo` $attr^)? `:` attr-dict
421}]>, Arguments<(ins OptionalAttr<ElementsAttr>:$attr)>;
422// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr` which does not have a buildable type
423def VariableInvalidJ : TestFormat_Op<"variable_invalid_j", [{
424  $attr ` ` `:` attr-dict
425}]>, Arguments<(ins ElementsAttr:$attr)>;
426// CHECK: error: region 'region' is already bound
427def VariableInvalidK : TestFormat_Op<"variable_invalid_k", [{
428  $region $region attr-dict
429}]> {
430  let regions = (region AnyRegion:$region);
431}
432// CHECK: error: region 'region' is already bound
433def VariableInvalidL : TestFormat_Op<"variable_invalid_l", [{
434  regions $region attr-dict
435}]> {
436  let regions = (region AnyRegion:$region);
437}
438// CHECK: error: regions can only be used at the top level
439def VariableInvalidM : TestFormat_Op<"variable_invalid_m", [{
440  type($region)
441}]> {
442  let regions = (region AnyRegion:$region);
443}
444// CHECK: error: region #0, named 'region', not found
445def VariableInvalidN : TestFormat_Op<"variable_invalid_n", [{
446  attr-dict
447}]> {
448  let regions = (region AnyRegion:$region);
449}
450// CHECK-NOT: error:
451def VariableValidA : TestFormat_Op<"variable_valid_a", [{
452  $attr `:` attr-dict
453}]>, Arguments<(ins OptionalAttr<I1Attr>:$attr)>;
454def VariableValidB : TestFormat_Op<"variable_valid_b", [{
455  (`foo` $attr^)? `:` attr-dict
456}]>, Arguments<(ins OptionalAttr<I1Attr>:$attr)>;
457
458//===----------------------------------------------------------------------===//
459// Coverage Checks
460//===----------------------------------------------------------------------===//
461
462// CHECK: error: type of result #0, named 'result', is not buildable and a buildable type cannot be inferred
463// CHECK: note: suggest adding a type constraint to the operation or adding a 'type($result)' directive to the custom assembly format
464def ZCoverageInvalidA : TestFormat_Op<"variable_invalid_a", [{
465  attr-dict
466}]>, Arguments<(ins AnyMemRef:$operand)>, Results<(outs AnyMemRef:$result)>;
467// CHECK: error: operand #0, named 'operand', not found
468// CHECK: note: suggest adding a '$operand' directive to the custom assembly format
469def ZCoverageInvalidB : TestFormat_Op<"variable_invalid_b", [{
470  type($result) attr-dict
471}]>, Arguments<(ins AnyMemRef:$operand)>, Results<(outs AnyMemRef:$result)>;
472// CHECK: error: type of operand #0, named 'operand', is not buildable and a buildable type cannot be inferred
473// CHECK: note: suggest adding a type constraint to the operation or adding a 'type($operand)' directive to the custom assembly format
474def ZCoverageInvalidC : TestFormat_Op<"variable_invalid_c", [{
475  $operand type($result) attr-dict
476}]>, Arguments<(ins AnyMemRef:$operand)>, Results<(outs AnyMemRef:$result)>;
477// CHECK: error: type of operand #0, named 'operand', is not buildable and a buildable type cannot be inferred
478// CHECK: note: suggest adding a type constraint to the operation or adding a 'type($operand)' directive to the custom assembly format
479def ZCoverageInvalidD : TestFormat_Op<"variable_invalid_d", [{
480  operands attr-dict
481}]>, Arguments<(ins Variadic<I64>:$operand)>;
482// CHECK: error: type of result #0, named 'result', is not buildable and a buildable type cannot be inferred
483// CHECK: note: suggest adding a type constraint to the operation or adding a 'type($result)' directive to the custom assembly format
484def ZCoverageInvalidE : TestFormat_Op<"variable_invalid_e", [{
485  attr-dict
486}]>, Results<(outs Variadic<I64>:$result)>;
487// CHECK: error: successor #0, named 'successor', not found
488// CHECK: note: suggest adding a '$successor' directive to the custom assembly format
489def ZCoverageInvalidF : TestFormat_Op<"variable_invalid_f", [{
490	 attr-dict
491}]> {
492  let successors = (successor AnySuccessor:$successor);
493}
494// CHECK: error: type of operand #0, named 'operand', is not buildable and a buildable type cannot be inferred
495// CHECK: note: suggest adding a type constraint to the operation or adding a 'type($operand)' directive to the custom assembly format
496def ZCoverageInvalidG : TestFormat_Op<"variable_invalid_g", [{
497  operands attr-dict
498}]>, Arguments<(ins Optional<I64>:$operand)>;
499// CHECK: error: type of result #0, named 'result', is not buildable and a buildable type cannot be inferred
500// CHECK: note: suggest adding a type constraint to the operation or adding a 'type($result)' directive to the custom assembly format
501def ZCoverageInvalidH : TestFormat_Op<"variable_invalid_h", [{
502  attr-dict
503}]>, Results<(outs Optional<I64>:$result)>;
504
505// CHECK-NOT: error
506def ZCoverageValidA : TestFormat_Op<"variable_valid_a", [{
507  $operand type($operand) type($result) attr-dict
508}]>, Arguments<(ins AnyMemRef:$operand)>, Results<(outs AnyMemRef:$result)>;
509def ZCoverageValidB : TestFormat_Op<"variable_valid_b", [{
510  $operand type(operands) type(results) attr-dict
511}]>, Arguments<(ins AnyMemRef:$operand)>, Results<(outs AnyMemRef:$result)>;
512def ZCoverageValidC : TestFormat_Op<"variable_valid_c", [{
513  operands functional-type(operands, results) attr-dict
514}]>, Arguments<(ins AnyMemRef:$operand)>, Results<(outs AnyMemRef:$result)>;
515
516// Check that we can infer type equalities from certain traits.
517def ZCoverageValidD : TestFormat_Op<"variable_valid_d", [{
518  operands type($result) attr-dict
519}], [SameOperandsAndResultType]>, Arguments<(ins AnyMemRef:$operand)>,
520     Results<(outs AnyMemRef:$result)>;
521def ZCoverageValidE : TestFormat_Op<"variable_valid_e", [{
522  $operand type($operand) attr-dict
523}], [SameOperandsAndResultType]>, Arguments<(ins AnyMemRef:$operand)>,
524     Results<(outs AnyMemRef:$result)>;
525def ZCoverageValidF : TestFormat_Op<"variable_valid_f", [{
526  operands type($other) attr-dict
527}], [SameTypeOperands]>, Arguments<(ins AnyMemRef:$operand, AnyMemRef:$other)>;
528def ZCoverageValidG : TestFormat_Op<"variable_valid_g", [{
529  operands type($other) attr-dict
530}], [AllTypesMatch<["operand", "other"]>]>,
531     Arguments<(ins AnyMemRef:$operand, AnyMemRef:$other)>;
532def ZCoverageValidH : TestFormat_Op<"variable_valid_h", [{
533  operands type($result) attr-dict
534}], [AllTypesMatch<["operand", "result"]>]>,
535     Arguments<(ins AnyMemRef:$operand)>, Results<(outs AnyMemRef:$result)>;
536
537