4 affine_dialect : $ => prec.right(choice(
7 seq($.attribute, $._dim_and_symbol_use_list)),
8 field('attributes', optional($.attribute))),
10 // operation ::= `affine.delinearize_index` $linear_index
12 // `(` $basis `)` attr-dict `:`
14 seq('affine.delinearlize_index',
15 field('operand', $.value_use), 'into',
16 field('basis', $._value_use_list_parens),
17 field('attributes', optional($.attribute)),
18 field('return', $._type_annotation)),
20 // operation ::= `affine.dma_start` ssa-use `[`
21 // multi-dim-affine-map-of-ssa-ids `]`,
22 // `[` multi-dim-affine-map-of-ssa-ids `]`,
23 // `[` multi-dim-affine-map-of-ssa-ids `]`,
24 // ssa-use `:` memref-type
25 seq(choice('affine.dma_start', 'affine.dma_wait'),
27 seq($.value_use, $._multi_dim_affine_expr_sq,
28 repeat(seq(',', $.value_use,
29 $._multi_dim_affine_expr_sq)))),
30 ',', field('numElements', $._value_use_list),
31 field('return', $._type_annotation)),
33 // operation ::= `affine.for` ssa-id `=` lower-bound `to`
35 // (`step` integer-literal)? `{` op* `}`
36 seq('affine.for', field('iv', $.value_use), '=',
38 seq(optional(token('max')), $._bound)),
41 seq(optional(token('min')), $._bound)),
43 optional(seq(token('step'), $.integer_literal))),
45 optional(seq(token('iter_args'),
46 $._value_assignment_list))),
47 field('return', optional($._function_return)),
48 field('body', $.region),
49 field('attributes', optional($.attribute))),
51 // operation ::= `affine.if` if-op-cond `{` op* `}`
52 // (`else` `{` op* `}`)? if-op-cond ::= integer-set-attr
53 // dim-and-symbol-use-list
56 seq($.attribute, $._dim_and_symbol_use_list)),
57 field('return', optional($._function_return)),
58 field('trueblk', $.region),
60 optional(seq(token('else'), $.region))),
61 field('attributes', optional($.attribute))),
63 // operation ::= `affine.load` ssa-use `[`
64 // multi-dim-affine-map-of-ssa-ids `]`
66 seq(choice('affine.load', 'affine.vector_load'),
67 field('operand', $.value_use),
68 field('multiDimAffineMap',
69 $._multi_dim_affine_expr_sq),
70 field('return', $._type_annotation)),
72 // operation ::= `affine.min` affine-map-attribute
73 // dim-and-symbol-use-list
74 seq(choice('affine.min', 'affine.max'),
76 seq($.attribute, $._dim_and_symbol_use_list))),
78 seq('affine.parallel',
79 field('iv', $._value_use_list_parens), '=',
80 field('lowerBound', $._multi_dim_affine_expr_parens),
82 field('upperBound', $._multi_dim_affine_expr_parens),
84 optional(seq(token('step'),
85 $._multi_dim_affine_expr_parens))),
87 optional(seq(token('reduce'), '(',
89 repeat(seq(',', $.string_literal)),
91 field('return', optional($._function_return)),
92 field('body', $.region)),
94 seq('affine.prefetch', field('source', $.value_use),
96 optional($._multi_dim_affine_expr_sq)),
97 ',', field('isWrite', $.isWrite_attr), ',',
98 field('localityHint', $.localityHint_attr), ',',
99 field('isDataCache', $.isDataCache_attr),
100 field('attributes', optional($.attribute)),
101 field('return', $._type_annotation)),
103 // operation ::= `affine.store` ssa-use, ssa-use `[`
104 // multi-dim-affine-map-of-ssa-ids `]`
106 seq(choice('affine.store', 'affine.vector_store'),
107 field('source', $.value_use), ',',
108 field('destination', $.value_use),
109 field('multiDimAffineMap',
110 $._multi_dim_affine_expr_sq),
111 field('return', $._type_annotation)),
113 // operation ::= `affine.yield` attr-dict ($operands^ `:`
116 field('attributes', optional($.attribute)),
117 field('results', optional($._value_use_type_list)))))