262 lines · plain
1================================================================================2Function prototype3================================================================================4func.func @abort()5--------------------------------------------------------------------------------6 7(toplevel8 (operation9 (custom_operation10 (func_dialect11 (symbol_ref_id)12 (func_arg_list)))))13 14================================================================================15Simple function using func, arith dialects16================================================================================17func.func @test_addi(%arg0 : i64, %arg1 : i64) -> i64 {18 %0 = arith.addi %arg0, %arg1 : i6419 return %0 : i6420}21--------------------------------------------------------------------------------22 23(toplevel24 (operation25 (custom_operation26 (func_dialect27 (symbol_ref_id)28 (func_arg_list29 (value_use)30 (type31 (builtin_type32 (integer_type)))33 (value_use)34 (type35 (builtin_type36 (integer_type))))37 (func_return38 (type_list_attr_parens39 (type40 (builtin_type41 (integer_type)))))42 (region43 (entry_block44 (operation45 (op_result46 (value_use))47 (custom_operation48 (arith_dialect49 (value_use)50 (value_use)51 (type52 (builtin_type53 (integer_type))))))54 (operation55 (custom_operation56 (func_dialect57 (value_use)58 (type59 (builtin_type60 (integer_type))))))))))))61 62================================================================================63Function with multiple return values64================================================================================65func.func @count(%x: i64) -> (i64, i64) {66 return %x, %x: i64, i6467}68--------------------------------------------------------------------------------69 70(toplevel71 (operation72 (custom_operation73 (func_dialect74 (symbol_ref_id)75 (func_arg_list76 (value_use)77 (type78 (builtin_type79 (integer_type))))80 (func_return81 (type_list_attr_parens82 (type83 (builtin_type84 (integer_type)))85 (type86 (builtin_type87 (integer_type)))))88 (region89 (entry_block90 (operation91 (custom_operation92 (func_dialect93 (value_use)94 (value_use)95 (type96 (builtin_type97 (integer_type)))98 (type99 (builtin_type100 (integer_type))))))))))))101 102================================================================================103Variadic function104================================================================================105llvm.func @variadic(...)106--------------------------------------------------------------------------------107 108(toplevel109 (operation110 (custom_operation111 (llvm_dialect112 (symbol_ref_id)113 (func_arg_list114 (variadic))))))115 116================================================================================117Variadic function with other arguments118================================================================================119llvm.func @variadic_args(i32, i32, ...)120--------------------------------------------------------------------------------121 122(toplevel123 (operation124 (custom_operation125 (llvm_dialect126 (symbol_ref_id)127 (func_arg_list128 (type129 (builtin_type130 (integer_type)))131 (type132 (builtin_type133 (integer_type)))134 (variadic))))))135 136================================================================================137Generic operation in a module, with attributes138================================================================================139module {140 "llvm.func"() ({141 }) {sym_name = "foo", function_type = !llvm.func<void ()>} : () -> ()142}143--------------------------------------------------------------------------------144 145(toplevel146 (operation147 (custom_operation148 (builtin_dialect149 (region150 (entry_block151 (operation152 (generic_operation153 (string_literal)154 (region)155 (attribute156 (dictionary_attribute157 (attribute_entry158 (bare_id)159 (attribute_value160 (string_literal)))161 (attribute_entry162 (bare_id)163 (attribute_value164 (type165 (dialect_type166 (pretty_dialect_item167 (dialect_namespace)168 (dialect_ident)169 (pretty_dialect_item_body))))))))170 (function_type)))))))))171 172================================================================================173Generic operation with successor and region174================================================================================175func.func @terminator_with_regions() {176 "region"()[^bb2] ({}) : () -> ()177^bb2:178 return179}180--------------------------------------------------------------------------------181 182(toplevel183 (operation184 (custom_operation185 (func_dialect186 (symbol_ref_id)187 (func_arg_list)188 (region189 (entry_block190 (operation191 (generic_operation192 (string_literal)193 (successor194 (caret_id))195 (region)196 (function_type))))197 (block198 (block_label199 (caret_id))200 (operation201 (custom_operation202 (func_dialect)))))))))203 204================================================================================205Function with private specifier, and func.call206================================================================================207func.func private @source() -> tensor<f32>208func.func @call_source() -> tensor<f32> {209 %0 = call @source() : () -> tensor<f32>210 return %0 : tensor<f32>211}212--------------------------------------------------------------------------------213 214(toplevel215 (operation216 (custom_operation217 (func_dialect218 (symbol_ref_id)219 (func_arg_list)220 (func_return221 (type_list_attr_parens222 (type223 (builtin_type224 (tensor_type225 (dim_list226 (float_type))))))))))227 (operation228 (custom_operation229 (func_dialect230 (symbol_ref_id)231 (func_arg_list)232 (func_return233 (type_list_attr_parens234 (type235 (builtin_type236 (tensor_type237 (dim_list238 (float_type)))))))239 (region240 (entry_block241 (operation242 (op_result243 (value_use))244 (custom_operation245 (func_dialect246 (symbol_ref_id)247 (function_type248 (type249 (builtin_type250 (tensor_type251 (dim_list252 (float_type)))))))))253 (operation254 (custom_operation255 (func_dialect256 (value_use)257 (type258 (builtin_type259 (tensor_type260 (dim_list261 (float_type))))))))))))))262