4 memref_dialect : $ => choice(
5 // operation ::= `memref.assume_alignment` $memref `,`
6 // $alignment attr-dict `:` type($memref)
7 seq('memref.assume_alignment',
8 field('memref', $.value_use), ',',
9 field('alignment', $.integer_literal),
10 field('attributes', optional($.attribute)),
11 field('return', $._type_annotation)),
13 // operation ::= `memref.alloc` `(`$dynamicSizes`)` (`` `[`
14 // $symbolOperands^ `]`)? attr-dict
16 // operation ::= `memref.alloca` `(`$dynamicSizes`)` (``
17 // `[` $symbolOperands^ `]`)? attr-dict
19 seq(choice('memref.alloc', 'memref.alloca'),
20 field('dynamicSizes', $._value_use_list_parens),
21 field('symbolOperands', optional($._dense_idx_list)),
22 field('attributes', optional($.attribute)),
23 field('return', $._type_annotation)),
25 // operation ::= `memref.cast` $source attr-dict `:`
26 // type($source) `to` type($dest)
27 seq('memref.cast', field('in', $.value_use),
28 field('attributes', optional($.attribute)),
29 field('return', $._type_annotation)),
31 // operation ::= `memref.copy` $source `,` $target
33 // `:` type($source) `to` type($target)
34 seq('memref.copy', field('source', $.value_use), ',',
35 field('target', $.value_use),
36 field('attributes', optional($.attribute)),
37 field('return', $._type_annotation)),
39 // operation ::= `memref.collapse_shape` $src
40 // $reassociation attr-dict
41 // `:` type($src) `into` type($result)
42 // operation ::= `memref.expand_shape` $src $reassociation
44 // `:` type($src) `into` type($result)
45 seq(choice('memref.collapse_shape', 'memref.expand_shape'),
46 field('source', $.value_use),
47 field('reassociation', $.nested_idx_list),
48 field('attributes', optional($.attribute)),
49 field('return', $._type_annotation)),
51 // operation ::= `memref.dealloc` $memref attr-dict `:`
53 seq('memref.dealloc', field('memref', $.value_use),
54 field('attributes', optional($.attribute)),
55 field('return', $._type_annotation)),
57 // operation ::= `memref.dim` attr-dict $source `,` $index
60 field('attributes', optional($.attribute)),
61 field('source', $.value_use), ',',
62 field('index', $.value_use),
63 field('return', $._type_annotation)),
65 // operation ::= `memref.load` $memref `[` $indices `]`
66 // attr-dict `:` type($memref)
68 field('memref', seq($.value_use, $._dense_idx_list)),
69 field('attributes', optional($.attribute)),
70 field('return', $._type_annotation)),
72 seq('memref.prefetch', field('source', $.value_use),
73 field('indices', optional($._dense_idx_list)), ',',
74 field('isWrite', $.isWrite_attr), ',',
75 field('localityHint', $.localityHint_attr), ',',
76 field('isDataCache', $.isDataCache_attr),
77 field('attributes', optional($.attribute)),
78 field('return', $._type_annotation)),
80 // operation ::= `memref.rank` $memref attr-dict `:`
82 seq('memref.rank', field('memref', $.value_use),
83 field('attributes', optional($.attribute)),
84 field('return', $._type_annotation)),
86 // operation ::= `memref.realloc` $source (`(`
87 // $dynamicResultSize^ `)`)? attr-dict
88 // `:` type($source) `to` type(results)
89 seq('memref.realloc', field('source', $.value_use),
90 field('dynamicResultSize',
91 optional($._value_use_list_parens)),
92 field('attributes', optional($.attribute)),
93 field('return', $._type_annotation)),
95 // operation ::= `memref.reinterpret_cast` $source `to`
97 // custom<DynamicIndexList>($offsets,
99 // `` `,` `sizes` `` `:`
100 // custom<DynamicIndexList>($sizes,
102 // `` `,` `strides` `` `:`
103 // custom<DynamicIndexList>($strides,
104 // $static_strides) attr-dict `:`
105 // type($source) `to` type($result)
106 seq('memref.reinterpret_cast',
107 field('source', $.value_use), token('to'),
108 field('offset', seq(token('offset'), ':',
109 $._dense_idx_list, ',')),
110 field('sizes', seq(token('sizes'), ':',
111 $._dense_idx_list, ',')),
113 seq(token('strides'), ':', $._dense_idx_list)),
114 field('attributes', optional($.attribute)),
115 field('return', $._type_annotation)),
117 // operation ::= `memref.reshape` $source `(` $shape `)`
119 // `:` functional-type(operands, results)
120 seq('memref.reshape', field('source', $.value_use),
121 field('shape', seq('(', $.value_use, ')')),
122 field('attributes', optional($.attribute)),
123 field('return', $._function_type_annotation)),
125 // operation ::= `memref.store` $value `,` $memref `[`
126 // $indices `]` attr-dict
128 seq('memref.store', field('source', $.value_use), ',',
129 field('destination', $.value_use),
130 field('indices', $._dense_idx_list),
131 field('attributes', optional($.attribute)),
132 field('return', $._type_annotation)),
134 // operation ::= `memref.subview` $source ``
135 // custom<DynamicIndexList>($offsets,
137 // custom<DynamicIndexList>($sizes,
139 // custom<DynamicIndexList>($strides,
140 // $static_strides) attr-dict `:`
141 // type($source) `to` type($result)
142 seq('memref.subview', field('source', $.value_use),
143 field('offsets', $._dense_idx_list),
144 field('sizes', $._dense_idx_list),
145 field('strides', $._dense_idx_list),
146 field('attributes', optional($.attribute)),
147 field('return', $._type_annotation)),
149 // operation ::= `memref.view` $source `[` $byte_shift `]`
150 // `` `[` $sizes `]` attr-dict
151 // `:` type($source) `to` type(results)
152 seq('memref.view', field('source', $.value_use),
153 field('byte_shift', $._dense_idx_list),
154 field('sizes', $._dense_idx_list),
155 field('attributes', optional($.attribute)),
156 field('return', $._type_annotation)))