4 arith_dialect : $ => choice(
5 // operation ::= `arith.constant` attr-dict $value
7 field('attributes', optional($.attribute)),
8 field('value', $._literal_and_type)),
10 // operation ::= `arith.addi` $lhs `,` $rhs attr-dict `:`
11 // type($result) operation ::= `arith.subi` $lhs `,` $rhs
12 // attr-dict `:` type($result) operation ::= `arith.divsi`
13 // $lhs `,` $rhs attr-dict `:` type($result) operation ::=
14 // `arith.divui` $lhs `,` $rhs attr-dict `:` type($result)
15 // operation ::= `arith.ceildivsi` $lhs `,` $rhs attr-dict
16 // `:` type($result) operation ::= `arith.ceildivui` $lhs
17 // `,` $rhs attr-dict `:` type($result) operation ::=
18 // `arith.floordivsi` $lhs `,` $rhs attr-dict `:`
19 // type($result) operation ::= `arith.remsi` $lhs `,` $rhs
20 // attr-dict `:` type($result) operation ::= `arith.remui`
21 // $lhs `,` $rhs attr-dict `:` type($result) operation ::=
22 // `arith.muli` $lhs `,` $rhs attr-dict `:` type($result)
23 // operation ::= `arith.mulsi_extended` $lhs `,` $rhs
24 // attr-dict `:` type($lhs) operation ::=
25 // `arith.mului_extended` $lhs `,` $rhs attr-dict `:`
26 // type($lhs) operation ::= `arith.andi` $lhs `,` $rhs
27 // attr-dict `:` type($result) operation ::= `arith.ori`
28 // $lhs `,` $rhs attr-dict `:` type($result) operation ::=
29 // `arith.xori` $lhs `,` $rhs attr-dict `:` type($result)
30 // operation ::= `arith.maxsi` $lhs `,` $rhs attr-dict `:`
31 // type($result) operation ::= `arith.maxui` $lhs `,` $rhs
32 // attr-dict `:` type($result) operation ::= `arith.minsi`
33 // $lhs `,` $rhs attr-dict `:` type($result) operation ::=
34 // `arith.minui` $lhs `,` $rhs attr-dict `:` type($result)
35 // operation ::= `arith.shli` $lhs `,` $rhs attr-dict `:`
36 // type($result) operation ::= `arith.shrsi` $lhs `,` $rhs
37 // attr-dict `:` type($result) operation ::= `arith.shrui`
38 // $lhs `,` $rhs attr-dict `:` type($result)
39 seq(choice('arith.addi', 'arith.subi', 'arith.divsi',
40 'arith.divui', 'arith.ceildivsi',
41 'arith.ceildivui', 'arith.floordivsi',
42 'arith.remsi', 'arith.remui', 'arith.muli',
43 'arith.mulsi_extended', 'arith.mului_extended',
44 'arith.andi', 'arith.ori', 'arith.xori',
45 'arith.maxsi', 'arith.maxui', 'arith.minsi',
46 'arith.minui', 'arith.shli', 'arith.shrsi',
48 field('lhs', $.value_use), ',',
49 field('rhs', $.value_use),
50 field('attributes', optional($.attribute)),
51 field('return', $._type_annotation)),
53 // operation ::= `arith.addui_extended` $lhs `,` $rhs
54 // attr-dict `:` type($sum)
55 // `,` type($overflow)
56 seq('arith.addui_extended', field('lhs', $.value_use), ',',
57 field('rhs', $.value_use),
58 field('attributes', optional($.attribute)),
59 field('return', seq(':', $.type, ',', $.type))),
61 // operation ::= `arith.addf` $lhs `,` $rhs (`fastmath` ``
63 // attr-dict `:` type($result)
64 // operation ::= `arith.divf` $lhs `,` $rhs (`fastmath` ``
66 // attr-dict `:` type($result)
67 // operation ::= `arith.maximumf` $lhs `,` $rhs (`fastmath` ``
69 // attr-dict `:` type($result)
70 // operation ::= `arith.minimumf` $lhs `,` $rhs (`fastmath` ``
72 // attr-dict `:` type($result)
73 // operation ::= `arith.mulf` $lhs `,` $rhs (`fastmath` ``
75 // attr-dict `:` type($result)
76 // operation ::= `arith.remf` $lhs `,` $rhs (`fastmath` ``
78 // attr-dict `:` type($result)
79 // operation ::= `arith.subf` $lhs `,` $rhs (`fastmath` ``
81 // attr-dict `:` type($result)
82 seq(choice('arith.addf', 'arith.divf', 'arith.maximumf',
83 'arith.minimumf', 'arith.mulf', 'arith.remf',
85 field('lhs', $.value_use), ',',
86 field('rhs', $.value_use),
87 field('fastmath', optional($.fastmath_attr)),
88 field('attributes', optional($.attribute)),
89 field('return', $._type_annotation)),
91 // operation ::= `arith.negf` $operand (`fastmath` ``
93 // attr-dict `:` type($result)
94 seq(choice('arith.negf'), field('operand', $.value_use),
95 field('fastmath', optional($.fastmath_attr)),
96 field('attributes', optional($.attribute)),
97 field('return', $._type_annotation)),
99 // operation ::= `arith.cmpi` $predicate `,` $lhs `,` $rhs
100 // attr-dict `:` type($lhs) operation ::= `arith.cmpf`
101 // $predicate `,` $lhs `,` $rhs attr-dict `:` type($lhs)
102 seq(choice('arith.cmpi', 'arith.cmpf'),
104 choice('eq', 'ne', 'oeq', 'olt', 'ole', 'ogt',
105 'oge', 'slt', 'sle', 'sgt', 'sge', 'ult',
106 'ule', 'ugt', 'uge', $.string_literal)),
107 ',', field('lhs', $.value_use), ',',
108 field('rhs', $.value_use),
109 field('attributes', optional($.attribute)),
110 field('return', $._type_annotation)),
112 // operation ::= `arith.extf` $in attr-dict `:` type($in)
113 // `to` type($out) operation ::= `arith.extsi` $in attr-dict
114 // `:` type($in) `to` type($out) operation ::= `arith.extui`
115 // $in attr-dict `:` type($in) `to` type($out) operation ::=
116 // `arith.fptosi` $in attr-dict `:` type($in) `to`
117 // type($out) operation ::= `arith.fptoui` $in attr-dict `:`
118 // type($in) `to` type($out) operation ::=
119 // `arith.index_cast` $in attr-dict `:` type($in) `to`
120 // type($out) operation ::= `arith.index_castui` $in
121 // attr-dict `:` type($in) `to` type($out) operation ::=
122 // `arith.sitofp` $in attr-dict `:` type($in) `to`
123 // type($out) operation ::= `arith.uitofp` $in attr-dict `:`
124 // type($in) `to` type($out) operation ::= `arith.bitcast`
125 // $in attr-dict `:` type($in) `to` type($out) operation ::=
126 // `arith.truncf` $in attr-dict `:` type($in) `to`
127 // type($out) operation ::= `arith.trunci` $in attr-dict `:`
128 // type($in) `to` type($out)
129 seq(choice('arith.extf', 'arith.extsi', 'arith.extui',
130 'arith.fptosi', 'arith.fptoui',
131 'arith.index_cast', 'arith.index_castui',
132 'arith.sitofp', 'arith.uitofp', 'arith.bitcast',
133 'arith.truncf', 'arith.trunci'),
134 field('in', $.value_use),
135 field('attributes', optional($.attribute)),
136 field('return', $._type_annotation)),
138 seq('arith.select', field('cond', $.value_use), ',',
139 field('trueblk', $.value_use), ',',
140 field('falseblk', $.value_use),
141 field('return', $._type_annotation)))