Debian Codegraph @

mlir/utils/tree-sitter-mlir/test/corpus/func.txt

raw
1 ================================================================================
2 Function prototype
3 ================================================================================
4 func.func @abort()
5 --------------------------------------------------------------------------------
6
7 (toplevel
8 (operation
9 (custom_operation
10 (func_dialect
11 (symbol_ref_id)
12 (func_arg_list)))))
13
14 ================================================================================
15 Simple function using func, arith dialects
16 ================================================================================
17 func.func @test_addi(%arg0 : i64, %arg1 : i64) -> i64 {
18 %0 = arith.addi %arg0, %arg1 : i64
19 return %0 : i64
20 }
21 --------------------------------------------------------------------------------
22
23 (toplevel
24 (operation
25 (custom_operation
26 (func_dialect
27 (symbol_ref_id)
28 (func_arg_list
29 (value_use)
30 (type
31 (builtin_type
32 (integer_type)))
33 (value_use)
34 (type
35 (builtin_type
36 (integer_type))))
37 (func_return
38 (type_list_attr_parens
39 (type
40 (builtin_type
41 (integer_type)))))
42 (region
43 (entry_block
44 (operation
45 (op_result
46 (value_use))
47 (custom_operation
48 (arith_dialect
49 (value_use)
50 (value_use)
51 (type
52 (builtin_type
53 (integer_type))))))
54 (operation
55 (custom_operation
56 (func_dialect
57 (value_use)
58 (type
59 (builtin_type
60 (integer_type))))))))))))
61
62 ================================================================================
63 Function with multiple return values
64 ================================================================================
65 func.func @count(%x: i64) -> (i64, i64) {
66 return %x, %x: i64, i64
67 }
68 --------------------------------------------------------------------------------
69
70 (toplevel
71 (operation
72 (custom_operation
73 (func_dialect
74 (symbol_ref_id)
75 (func_arg_list
76 (value_use)
77 (type
78 (builtin_type
79 (integer_type))))
80 (func_return
81 (type_list_attr_parens
82 (type
83 (builtin_type
84 (integer_type)))
85 (type
86 (builtin_type
87 (integer_type)))))
88 (region
89 (entry_block
90 (operation
91 (custom_operation
92 (func_dialect
93 (value_use)
94 (value_use)
95 (type
96 (builtin_type
97 (integer_type)))
98 (type
99 (builtin_type
100 (integer_type))))))))))))
101
102 ================================================================================
103 Variadic function
104 ================================================================================
105 llvm.func @variadic(...)
106 --------------------------------------------------------------------------------
107
108 (toplevel
109 (operation
110 (custom_operation
111 (llvm_dialect
112 (symbol_ref_id)
113 (func_arg_list
114 (variadic))))))
115
116 ================================================================================
117 Variadic function with other arguments
118 ================================================================================
119 llvm.func @variadic_args(i32, i32, ...)
120 --------------------------------------------------------------------------------
121
122 (toplevel
123 (operation
124 (custom_operation
125 (llvm_dialect
126 (symbol_ref_id)
127 (func_arg_list
128 (type
129 (builtin_type
130 (integer_type)))
131 (type
132 (builtin_type
133 (integer_type)))
134 (variadic))))))
135
136 ================================================================================
137 Generic operation in a module, with attributes
138 ================================================================================
139 module {
140 "llvm.func"() ({
141 }) {sym_name = "foo", function_type = !llvm.func<void ()>} : () -> ()
142 }
143 --------------------------------------------------------------------------------
144
145 (toplevel
146 (operation
147 (custom_operation
148 (builtin_dialect
149 (region
150 (entry_block
151 (operation
152 (generic_operation
153 (string_literal)
154 (region)
155 (attribute
156 (dictionary_attribute
157 (attribute_entry
158 (bare_id)
159 (attribute_value
160 (string_literal)))
161 (attribute_entry
162 (bare_id)
163 (attribute_value
164 (type
165 (dialect_type
166 (pretty_dialect_item
167 (dialect_namespace)
168 (dialect_ident)
169 (pretty_dialect_item_body))))))))
170 (function_type)))))))))
171
172 ================================================================================
173 Generic operation with successor and region
174 ================================================================================
175 func.func @terminator_with_regions() {
176 "region"()[^bb2] ({}) : () -> ()
177 ^bb2:
178 return
179 }
180 --------------------------------------------------------------------------------
181
182 (toplevel
183 (operation
184 (custom_operation
185 (func_dialect
186 (symbol_ref_id)
187 (func_arg_list)
188 (region
189 (entry_block
190 (operation
191 (generic_operation
192 (string_literal)
193 (successor
194 (caret_id))
195 (region)
196 (function_type))))
197 (block
198 (block_label
199 (caret_id))
200 (operation
201 (custom_operation
202 (func_dialect)))))))))
203
204 ================================================================================
205 Function with private specifier, and func.call
206 ================================================================================
207 func.func private @source() -> tensor<f32>
208 func.func @call_source() -> tensor<f32> {
209 %0 = call @source() : () -> tensor<f32>
210 return %0 : tensor<f32>
211 }
212 --------------------------------------------------------------------------------
213
214 (toplevel
215 (operation
216 (custom_operation
217 (func_dialect
218 (symbol_ref_id)
219 (func_arg_list)
220 (func_return
221 (type_list_attr_parens
222 (type
223 (builtin_type
224 (tensor_type
225 (dim_list
226 (float_type))))))))))
227 (operation
228 (custom_operation
229 (func_dialect
230 (symbol_ref_id)
231 (func_arg_list)
232 (func_return
233 (type_list_attr_parens
234 (type
235 (builtin_type
236 (tensor_type
237 (dim_list
238 (float_type)))))))
239 (region
240 (entry_block
241 (operation
242 (op_result
243 (value_use))
244 (custom_operation
245 (func_dialect
246 (symbol_ref_id)
247 (function_type
248 (type
249 (builtin_type
250 (tensor_type
251 (dim_list
252 (float_type)))))))))
253 (operation
254 (custom_operation
255 (func_dialect
256 (value_use)
257 (type
258 (builtin_type
259 (tensor_type
260 (dim_list
261 (float_type))))))))))))))