[ELF] Refactor merge-* tests
[llvm-project.git] / mlir / utils / tree-sitter-mlir / dialect / scf.js
blobc39d856d5807178c2beb11e3198fddd25662b023
1 'use strict';
3 module.exports = {
4   scf_dialect : $ => prec.right(choice(
5                   // operation ::= `scf.condition` `(` $condition `)` attr-dict
6                   // ($args^ `:` type($args))?
7                   seq('scf.condition',
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),
20                       field('falseblk',
21                             optional(seq(token('else'), $.region)))),
23                   // operation ::= `scf.index_switch` $arg attr-dict (`->`
24                   // type($results)^)?
25                   //               custom<SwitchCases>($cases, $caseRegions)
26                   //               `\n`
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 {
35                   // ... // body
36                   // }
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)),
41                       field('iter_args',
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),
49                       field('bounds',
50                             seq(choice(seq('=', $._value_use_list_parens,
51                                            token('to')),
52                                        token('in')),
53                                 $._value_use_list_parens)),
54                       field('step', optional(seq(token('step'),
55                                                  $._value_use_list_parens))),
56                       field('shared_outs',
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),
69                       field('step',
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 `:`
82                   // type($result)
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
88                   // `do` region
89                   //        `attributes` attribute-dict
90                   // initializer ::= /* empty */ | `(` assignment-list `)`
91                   seq('scf.while',
92                       field('assignments', optional($._value_assignment_list)),
93                       field('return', $._function_type_annotation),
94                       field('condblk', $.region), 'do',
95                       field('doblk', $.region),
96                       field('attributes',
97                             optional(seq('attributes', $.attribute)))),
99                   // operation ::= `scf.yield` attr-dict ($results^ `:`
100                   // type($results))?
101                   seq('scf.yield', field('attributes', optional($.attribute)),
102                       field('results', optional($._value_use_type_list))),
103                   )),
105   scf_case_label : $ => choice(seq(token('case'), $.integer_literal),
106                                token('default'))