import.carbon 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/builtin/no_prelude/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/builtin/no_prelude/import.carbon
  10. // --- core.carbon
  11. package Core library "[[@TEST_NAME]]";
  12. fn IntLiteral() -> type = "int_literal.make_type";
  13. fn Int(N: IntLiteral()) -> type = "int.make_type_signed";
  14. fn AsI32(a: IntLiteral()) -> i32 = "int.convert_checked";
  15. fn AsIntLiteral(a: i32) -> IntLiteral() = "int.convert_checked";
  16. fn TestAdd(a: i32, b: i32) -> i32 = "int.sadd";
  17. // --- use.carbon
  18. import Core library "core";
  19. var arr: [i32; Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))] = (Core.AsI32(1), Core.AsI32(2), Core.AsI32(3));
  20. // CHECK:STDOUT: --- core.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [template]
  24. // CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [template]
  25. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  26. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  27. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  28. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  29. // CHECK:STDOUT: %AsI32.type: type = fn_type @AsI32 [template]
  30. // CHECK:STDOUT: %AsI32: %AsI32.type = struct_value () [template]
  31. // CHECK:STDOUT: %AsIntLiteral.type: type = fn_type @AsIntLiteral [template]
  32. // CHECK:STDOUT: %AsIntLiteral: %AsIntLiteral.type = struct_value () [template]
  33. // CHECK:STDOUT: %TestAdd.type: type = fn_type @TestAdd [template]
  34. // CHECK:STDOUT: %TestAdd: %TestAdd.type = struct_value () [template]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  39. // CHECK:STDOUT: .IntLiteral = %IntLiteral.decl
  40. // CHECK:STDOUT: .Int = %Int.decl
  41. // CHECK:STDOUT: .AsI32 = %AsI32.decl
  42. // CHECK:STDOUT: .AsIntLiteral = %AsIntLiteral.decl
  43. // CHECK:STDOUT: .TestAdd = %TestAdd.decl
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %IntLiteral.decl: %IntLiteral.type = fn_decl @IntLiteral [template = constants.%IntLiteral] {
  46. // CHECK:STDOUT: %return.patt: type = return_slot_pattern
  47. // CHECK:STDOUT: %return.param_patt: type = out_param_pattern %return.patt, runtime_param0
  48. // CHECK:STDOUT: } {
  49. // CHECK:STDOUT: %return.param: ref type = out_param runtime_param0
  50. // CHECK:STDOUT: %return: ref type = return_slot %return.param
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %Int.decl: %Int.type = fn_decl @Int [template = constants.%Int] {
  53. // CHECK:STDOUT: %N.patt: Core.IntLiteral = binding_pattern N
  54. // CHECK:STDOUT: %N.param_patt: Core.IntLiteral = value_param_pattern %N.patt, runtime_param0
  55. // CHECK:STDOUT: %return.patt: type = return_slot_pattern
  56. // CHECK:STDOUT: %return.param_patt: type = out_param_pattern %return.patt, runtime_param1
  57. // CHECK:STDOUT: } {
  58. // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param runtime_param0
  59. // CHECK:STDOUT: %.loc6_22.1: type = splice_block %.loc6_22.3 [template = Core.IntLiteral] {
  60. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  61. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  62. // CHECK:STDOUT: %.loc6_22.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  63. // CHECK:STDOUT: %.loc6_22.3: type = converted %int_literal.make_type, %.loc6_22.2 [template = Core.IntLiteral]
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: %N: Core.IntLiteral = bind_name N, %N.param
  66. // CHECK:STDOUT: %return.param: ref type = out_param runtime_param1
  67. // CHECK:STDOUT: %return: ref type = return_slot %return.param
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: %AsI32.decl: %AsI32.type = fn_decl @AsI32 [template = constants.%AsI32] {
  70. // CHECK:STDOUT: %a.patt: Core.IntLiteral = binding_pattern a
  71. // CHECK:STDOUT: %a.param_patt: Core.IntLiteral = value_param_pattern %a.patt, runtime_param0
  72. // CHECK:STDOUT: %return.patt: %i32.builtin = return_slot_pattern
  73. // CHECK:STDOUT: %return.param_patt: %i32.builtin = out_param_pattern %return.patt, runtime_param1
  74. // CHECK:STDOUT: } {
  75. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  76. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%int_32) [template = constants.%i32.builtin]
  77. // CHECK:STDOUT: %.loc8_30.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32.builtin]
  78. // CHECK:STDOUT: %.loc8_30.2: type = converted %int.make_type_signed, %.loc8_30.1 [template = constants.%i32.builtin]
  79. // CHECK:STDOUT: %a.param: Core.IntLiteral = value_param runtime_param0
  80. // CHECK:STDOUT: %.loc8_24.1: type = splice_block %.loc8_24.3 [template = Core.IntLiteral] {
  81. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  82. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  83. // CHECK:STDOUT: %.loc8_24.2: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  84. // CHECK:STDOUT: %.loc8_24.3: type = converted %int_literal.make_type, %.loc8_24.2 [template = Core.IntLiteral]
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: %a: Core.IntLiteral = bind_name a, %a.param
  87. // CHECK:STDOUT: %return.param: ref %i32.builtin = out_param runtime_param1
  88. // CHECK:STDOUT: %return: ref %i32.builtin = return_slot %return.param
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT: %AsIntLiteral.decl: %AsIntLiteral.type = fn_decl @AsIntLiteral [template = constants.%AsIntLiteral] {
  91. // CHECK:STDOUT: %a.patt: %i32.builtin = binding_pattern a
  92. // CHECK:STDOUT: %a.param_patt: %i32.builtin = value_param_pattern %a.patt, runtime_param0
  93. // CHECK:STDOUT: %return.patt: Core.IntLiteral = return_slot_pattern
  94. // CHECK:STDOUT: %return.param_patt: Core.IntLiteral = out_param_pattern %return.patt, runtime_param1
  95. // CHECK:STDOUT: } {
  96. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [template = constants.%IntLiteral]
  97. // CHECK:STDOUT: %int_literal.make_type: init type = call %IntLiteral.ref() [template = Core.IntLiteral]
  98. // CHECK:STDOUT: %.loc9_39.1: type = value_of_initializer %int_literal.make_type [template = Core.IntLiteral]
  99. // CHECK:STDOUT: %.loc9_39.2: type = converted %int_literal.make_type, %.loc9_39.1 [template = Core.IntLiteral]
  100. // CHECK:STDOUT: %a.param: %i32.builtin = value_param runtime_param0
  101. // CHECK:STDOUT: %.loc9_20.1: type = splice_block %.loc9_20.3 [template = constants.%i32.builtin] {
  102. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  103. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%int_32) [template = constants.%i32.builtin]
  104. // CHECK:STDOUT: %.loc9_20.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32.builtin]
  105. // CHECK:STDOUT: %.loc9_20.3: type = converted %int.make_type_signed, %.loc9_20.2 [template = constants.%i32.builtin]
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT: %a: %i32.builtin = bind_name a, %a.param
  108. // CHECK:STDOUT: %return.param: ref Core.IntLiteral = out_param runtime_param1
  109. // CHECK:STDOUT: %return: ref Core.IntLiteral = return_slot %return.param
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT: %TestAdd.decl: %TestAdd.type = fn_decl @TestAdd [template = constants.%TestAdd] {
  112. // CHECK:STDOUT: %a.patt: %i32.builtin = binding_pattern a
  113. // CHECK:STDOUT: %a.param_patt: %i32.builtin = value_param_pattern %a.patt, runtime_param0
  114. // CHECK:STDOUT: %b.patt: %i32.builtin = binding_pattern b
  115. // CHECK:STDOUT: %b.param_patt: %i32.builtin = value_param_pattern %b.patt, runtime_param1
  116. // CHECK:STDOUT: %return.patt: %i32.builtin = return_slot_pattern
  117. // CHECK:STDOUT: %return.param_patt: %i32.builtin = out_param_pattern %return.patt, runtime_param2
  118. // CHECK:STDOUT: } {
  119. // CHECK:STDOUT: %int_32.loc11_31: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  120. // CHECK:STDOUT: %int.make_type_signed.loc11_31: init type = call constants.%Int(%int_32.loc11_31) [template = constants.%i32.builtin]
  121. // CHECK:STDOUT: %.loc11_31.1: type = value_of_initializer %int.make_type_signed.loc11_31 [template = constants.%i32.builtin]
  122. // CHECK:STDOUT: %.loc11_31.2: type = converted %int.make_type_signed.loc11_31, %.loc11_31.1 [template = constants.%i32.builtin]
  123. // CHECK:STDOUT: %a.param: %i32.builtin = value_param runtime_param0
  124. // CHECK:STDOUT: %.loc11_15.1: type = splice_block %.loc11_15.3 [template = constants.%i32.builtin] {
  125. // CHECK:STDOUT: %int_32.loc11_15: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  126. // CHECK:STDOUT: %int.make_type_signed.loc11_15: init type = call constants.%Int(%int_32.loc11_15) [template = constants.%i32.builtin]
  127. // CHECK:STDOUT: %.loc11_15.2: type = value_of_initializer %int.make_type_signed.loc11_15 [template = constants.%i32.builtin]
  128. // CHECK:STDOUT: %.loc11_15.3: type = converted %int.make_type_signed.loc11_15, %.loc11_15.2 [template = constants.%i32.builtin]
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %a: %i32.builtin = bind_name a, %a.param
  131. // CHECK:STDOUT: %b.param: %i32.builtin = value_param runtime_param1
  132. // CHECK:STDOUT: %.loc11_23.1: type = splice_block %.loc11_23.3 [template = constants.%i32.builtin] {
  133. // CHECK:STDOUT: %int_32.loc11_23: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  134. // CHECK:STDOUT: %int.make_type_signed.loc11_23: init type = call constants.%Int(%int_32.loc11_23) [template = constants.%i32.builtin]
  135. // CHECK:STDOUT: %.loc11_23.2: type = value_of_initializer %int.make_type_signed.loc11_23 [template = constants.%i32.builtin]
  136. // CHECK:STDOUT: %.loc11_23.3: type = converted %int.make_type_signed.loc11_23, %.loc11_23.2 [template = constants.%i32.builtin]
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT: %b: %i32.builtin = bind_name b, %b.param
  139. // CHECK:STDOUT: %return.param: ref %i32.builtin = out_param runtime_param2
  140. // CHECK:STDOUT: %return: ref %i32.builtin = return_slot %return.param
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: fn @IntLiteral() -> type = "int_literal.make_type";
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: fn @Int(%N.param_patt: Core.IntLiteral) -> type = "int.make_type_signed";
  147. // CHECK:STDOUT:
  148. // CHECK:STDOUT: fn @AsI32(%a.param_patt: Core.IntLiteral) -> %i32.builtin = "int.convert_checked";
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: fn @AsIntLiteral(%a.param_patt: %i32.builtin) -> Core.IntLiteral = "int.convert_checked";
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: fn @TestAdd(%a.param_patt: %i32.builtin, %b.param_patt: %i32.builtin) -> %i32.builtin = "int.sadd";
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: --- use.carbon
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: constants {
  157. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  158. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  159. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  160. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [template]
  161. // CHECK:STDOUT: %AsIntLiteral.type: type = fn_type @AsIntLiteral [template]
  162. // CHECK:STDOUT: %AsIntLiteral: %AsIntLiteral.type = struct_value () [template]
  163. // CHECK:STDOUT: %TestAdd.type: type = fn_type @TestAdd [template]
  164. // CHECK:STDOUT: %TestAdd: %TestAdd.type = struct_value () [template]
  165. // CHECK:STDOUT: %AsI32.type: type = fn_type @AsI32 [template]
  166. // CHECK:STDOUT: %AsI32: %AsI32.type = struct_value () [template]
  167. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  168. // CHECK:STDOUT: %int_1.f38: %i32.builtin = int_value 1 [template]
  169. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template]
  170. // CHECK:STDOUT: %int_2.5a1: %i32.builtin = int_value 2 [template]
  171. // CHECK:STDOUT: %int_3.a0f: %i32.builtin = int_value 3 [template]
  172. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [template]
  173. // CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32.builtin [template]
  174. // CHECK:STDOUT: %tuple.type: type = tuple_type (%i32.builtin, %i32.builtin, %i32.builtin) [template]
  175. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template]
  176. // CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.f38, %int_2.5a1, %int_3.a0f) [template]
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: imports {
  180. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  181. // CHECK:STDOUT: .Int = %Core.Int
  182. // CHECK:STDOUT: .AsIntLiteral = %Core.AsIntLiteral
  183. // CHECK:STDOUT: .TestAdd = %Core.TestAdd
  184. // CHECK:STDOUT: .AsI32 = %Core.AsI32
  185. // CHECK:STDOUT: import Core//core
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: %Core.AsIntLiteral: %AsIntLiteral.type = import_ref Core//core, AsIntLiteral, loaded [template = constants.%AsIntLiteral]
  188. // CHECK:STDOUT: %Core.TestAdd: %TestAdd.type = import_ref Core//core, TestAdd, loaded [template = constants.%TestAdd]
  189. // CHECK:STDOUT: %Core.AsI32: %AsI32.type = import_ref Core//core, AsI32, loaded [template = constants.%AsI32]
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: file {
  193. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  194. // CHECK:STDOUT: .Core = imports.%Core
  195. // CHECK:STDOUT: .arr = %arr
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT: %Core.import = import Core
  198. // CHECK:STDOUT: name_binding_decl {
  199. // CHECK:STDOUT: %arr.patt: %array_type = binding_pattern arr
  200. // CHECK:STDOUT: %.loc4_1: %array_type = var_pattern %arr.patt
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: %arr.var: ref %array_type = var arr
  203. // CHECK:STDOUT: %.loc4_77: type = splice_block %array_type [template = constants.%array_type] {
  204. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  205. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%int_32) [template = constants.%i32.builtin]
  206. // CHECK:STDOUT: %Core.ref.loc4_16: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  207. // CHECK:STDOUT: %AsIntLiteral.ref: %AsIntLiteral.type = name_ref AsIntLiteral, imports.%Core.AsIntLiteral [template = constants.%AsIntLiteral]
  208. // CHECK:STDOUT: %Core.ref.loc4_34: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  209. // CHECK:STDOUT: %TestAdd.ref: %TestAdd.type = name_ref TestAdd, imports.%Core.TestAdd [template = constants.%TestAdd]
  210. // CHECK:STDOUT: %Core.ref.loc4_47: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  211. // CHECK:STDOUT: %AsI32.ref.loc4_51: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [template = constants.%AsI32]
  212. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  213. // CHECK:STDOUT: %int.convert_checked.loc4_59: init %i32.builtin = call %AsI32.ref.loc4_51(%int_1) [template = constants.%int_1.f38]
  214. // CHECK:STDOUT: %Core.ref.loc4_62: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  215. // CHECK:STDOUT: %AsI32.ref.loc4_66: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [template = constants.%AsI32]
  216. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  217. // CHECK:STDOUT: %int.convert_checked.loc4_74: init %i32.builtin = call %AsI32.ref.loc4_66(%int_2) [template = constants.%int_2.5a1]
  218. // CHECK:STDOUT: %.loc4_59.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_59 [template = constants.%int_1.f38]
  219. // CHECK:STDOUT: %.loc4_59.2: %i32.builtin = converted %int.convert_checked.loc4_59, %.loc4_59.1 [template = constants.%int_1.f38]
  220. // CHECK:STDOUT: %.loc4_74.1: %i32.builtin = value_of_initializer %int.convert_checked.loc4_74 [template = constants.%int_2.5a1]
  221. // CHECK:STDOUT: %.loc4_74.2: %i32.builtin = converted %int.convert_checked.loc4_74, %.loc4_74.1 [template = constants.%int_2.5a1]
  222. // CHECK:STDOUT: %int.sadd: init %i32.builtin = call %TestAdd.ref(%.loc4_59.2, %.loc4_74.2) [template = constants.%int_3.a0f]
  223. // CHECK:STDOUT: %.loc4_75.1: %i32.builtin = value_of_initializer %int.sadd [template = constants.%int_3.a0f]
  224. // CHECK:STDOUT: %.loc4_75.2: %i32.builtin = converted %int.sadd, %.loc4_75.1 [template = constants.%int_3.a0f]
  225. // CHECK:STDOUT: %int.convert_checked.loc4_76: init Core.IntLiteral = call %AsIntLiteral.ref(%.loc4_75.2) [template = constants.%int_3.1ba]
  226. // CHECK:STDOUT: %.loc4_11.1: type = value_of_initializer %int.make_type_signed [template = constants.%i32.builtin]
  227. // CHECK:STDOUT: %.loc4_11.2: type = converted %int.make_type_signed, %.loc4_11.1 [template = constants.%i32.builtin]
  228. // CHECK:STDOUT: %.loc4_76.1: Core.IntLiteral = value_of_initializer %int.convert_checked.loc4_76 [template = constants.%int_3.1ba]
  229. // CHECK:STDOUT: %.loc4_76.2: Core.IntLiteral = converted %int.convert_checked.loc4_76, %.loc4_76.1 [template = constants.%int_3.1ba]
  230. // CHECK:STDOUT: %array_type: type = array_type %.loc4_76.2, %i32.builtin [template = constants.%array_type]
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: fn @Int(%N.param_patt: Core.IntLiteral) -> type = "int.make_type_signed" [from "core.carbon"];
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: fn @AsIntLiteral(%a.param_patt: %i32.builtin) -> Core.IntLiteral = "int.convert_checked" [from "core.carbon"];
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: fn @TestAdd(%a.param_patt: %i32.builtin, %b.param_patt: %i32.builtin) -> %i32.builtin = "int.sadd" [from "core.carbon"];
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: fn @AsI32(%a.param_patt: Core.IntLiteral) -> %i32.builtin = "int.convert_checked" [from "core.carbon"];
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: fn @__global_init() {
  244. // CHECK:STDOUT: !entry:
  245. // CHECK:STDOUT: %Core.ref.loc4_82: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  246. // CHECK:STDOUT: %AsI32.ref.loc4_86: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [template = constants.%AsI32]
  247. // CHECK:STDOUT: %int_1.loc4_93: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  248. // CHECK:STDOUT: %int.convert_checked.loc4_94: init %i32.builtin = call %AsI32.ref.loc4_86(%int_1.loc4_93) [template = constants.%int_1.f38]
  249. // CHECK:STDOUT: %Core.ref.loc4_97: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  250. // CHECK:STDOUT: %AsI32.ref.loc4_101: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [template = constants.%AsI32]
  251. // CHECK:STDOUT: %int_2.loc4_108: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  252. // CHECK:STDOUT: %int.convert_checked.loc4_109: init %i32.builtin = call %AsI32.ref.loc4_101(%int_2.loc4_108) [template = constants.%int_2.5a1]
  253. // CHECK:STDOUT: %Core.ref.loc4_112: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  254. // CHECK:STDOUT: %AsI32.ref.loc4_116: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [template = constants.%AsI32]
  255. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [template = constants.%int_3.1ba]
  256. // CHECK:STDOUT: %int.convert_checked.loc4_124: init %i32.builtin = call %AsI32.ref.loc4_116(%int_3) [template = constants.%int_3.a0f]
  257. // CHECK:STDOUT: %.loc4_125.1: %tuple.type = tuple_literal (%int.convert_checked.loc4_94, %int.convert_checked.loc4_109, %int.convert_checked.loc4_124)
  258. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [template = constants.%int_0]
  259. // CHECK:STDOUT: %.loc4_125.2: ref %i32.builtin = array_index file.%arr.var, %int_0
  260. // CHECK:STDOUT: %.loc4_125.3: init %i32.builtin = initialize_from %int.convert_checked.loc4_94 to %.loc4_125.2 [template = constants.%int_1.f38]
  261. // CHECK:STDOUT: %int_1.loc4_125: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  262. // CHECK:STDOUT: %.loc4_125.4: ref %i32.builtin = array_index file.%arr.var, %int_1.loc4_125
  263. // CHECK:STDOUT: %.loc4_125.5: init %i32.builtin = initialize_from %int.convert_checked.loc4_109 to %.loc4_125.4 [template = constants.%int_2.5a1]
  264. // CHECK:STDOUT: %int_2.loc4_125: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  265. // CHECK:STDOUT: %.loc4_125.6: ref %i32.builtin = array_index file.%arr.var, %int_2.loc4_125
  266. // CHECK:STDOUT: %.loc4_125.7: init %i32.builtin = initialize_from %int.convert_checked.loc4_124 to %.loc4_125.6 [template = constants.%int_3.a0f]
  267. // CHECK:STDOUT: %.loc4_125.8: init %array_type = array_init (%.loc4_125.3, %.loc4_125.5, %.loc4_125.7) to file.%arr.var [template = constants.%array]
  268. // CHECK:STDOUT: %.loc4_1: init %array_type = converted %.loc4_125.1, %.loc4_125.8 [template = constants.%array]
  269. // CHECK:STDOUT: assign file.%arr.var, %.loc4_1
  270. // CHECK:STDOUT: return
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT: