4 scf_dialect : $ => prec.right(choice(
5 // operation ::= `scf.condition` `(` $condition `)` attr-dict
6 // ($args^ `:` type($args))?
8 field('condition', $._value_use_list_parens),
9 field('attributes', optional($.attribute)),
10 field('arguments', optional($._value_use_type_list))),
12 seq('scf.execute_region',
13 field('return', optional($._function_return)),
14 field('body', $.region),
15 field('attributes', optional($.attribute))),
17 seq('scf.if', field('condition', $.value_use),
18 field('return', optional($._function_return)),
19 field('trueblk', $.region),
21 optional(seq(token('else'), $.region)))),
23 // operation ::= `scf.index_switch` $arg attr-dict (`->`
25 // custom<SwitchCases>($cases, $caseRegions)
27 // `` `default` $defaultRegion
28 seq('scf.index_switch', field('flag', $._value_use_and_type),
29 field('attributes', optional($.attribute)),
30 field('result', optional($._function_return)),
31 $.scf_case_label, $.region,
32 repeat(seq($.scf_case_label, $.region))),
34 // scf.for %iv = %lb to %ub step %step {
37 seq('scf.for', field('iv', $.value_use), '=',
38 field('lb', $.value_use), token('to'),
39 field('ub', $.value_use),
40 field('step', seq(token('step'), $.value_use)),
42 optional(seq(token('iter_args'),
43 $._value_assignment_list))),
44 field('return', optional($._function_return)),
45 field('body', $.region),
46 field('attributes', optional($.attribute))),
48 seq('scf.forall', field('iv', $._value_use_list_parens),
50 seq(choice(seq('=', $._value_use_list_parens,
53 $._value_use_list_parens)),
54 field('step', optional(seq(token('step'),
55 $._value_use_list_parens))),
57 optional(seq(token('shared_outs'),
58 $._value_assignment_list))),
59 field('return', optional($._function_return)),
60 field('body', $.region),
61 field('attributes', optional($.attribute))),
63 seq('scf.forall.in_parallel', field('body', $.region),
64 field('attributes', optional($.attribute))),
66 seq('scf.parallel', field('iv', $._value_use_list_parens),
67 '=', field('lb', $._value_use_list_parens), token('to'),
68 field('ub', $._value_use_list_parens),
70 seq(token('step'), $._value_use_list_parens)),
71 field('init', optional(seq(token('init'),
72 $._value_use_list_parens))),
73 field('return', optional($._function_return)),
74 field('body', $.region),
75 field('attributes', optional($.attribute))),
77 seq('scf.reduce', field('operand', $._value_use_list_parens),
78 field('return', $._type_annotation),
79 field('body', $.region)),
81 // operation ::= `scf.reduce.return` $result attr-dict `:`
83 seq('scf.reduce.return', field('result', $.value_use),
84 field('attributes', optional($.attribute)),
85 field('return', $._type_annotation)),
87 // op ::= `scf.while` assignments `:` function-type region
89 // `attributes` attribute-dict
90 // initializer ::= /* empty */ | `(` assignment-list `)`
92 field('assignments', optional($._value_assignment_list)),
93 field('return', $._function_type_annotation),
94 field('condblk', $.region), 'do',
95 field('doblk', $.region),
97 optional(seq('attributes', $.attribute)))),
99 // operation ::= `scf.yield` attr-dict ($results^ `:`
101 seq('scf.yield', field('attributes', optional($.attribute)),
102 field('results', optional($._value_use_type_list))),
105 scf_case_label : $ => choice(seq(token('case'), $.integer_literal),