import.carbon 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/builtin/import.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/builtin/import.carbon
  14. // --- core.carbon
  15. package Core library "[[@TEST_NAME]]";
  16. fn IntLiteral() -> type = "int_literal.make_type";
  17. fn Int(N: IntLiteral()) -> type = "int.make_type_signed";
  18. fn AsI32(a: IntLiteral()) -> i32 = "int.convert_checked";
  19. fn AsIntLiteral(a: i32) -> IntLiteral() = "int.convert_checked";
  20. fn TestAdd(a: i32, b: i32) -> i32 = "int.sadd";
  21. // --- use.carbon
  22. import Core library "core";
  23. var arr: array(i32, Core.AsIntLiteral(Core.TestAdd(Core.AsI32(1), Core.AsI32(2)))) = (Core.AsI32(1), Core.AsI32(2), Core.AsI32(3));
  24. // CHECK:STDOUT: --- core.carbon
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: constants {
  27. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  28. // CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [concrete]
  29. // CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [concrete]
  30. // CHECK:STDOUT: %pattern_type.dc0: type = pattern_type Core.IntLiteral [concrete]
  31. // CHECK:STDOUT: %Int.type: type = fn_type @Int [concrete]
  32. // CHECK:STDOUT: %Int: %Int.type = struct_value () [concrete]
  33. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  34. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
  35. // CHECK:STDOUT: %pattern_type.956: type = pattern_type %i32.builtin [concrete]
  36. // CHECK:STDOUT: %AsI32.type: type = fn_type @AsI32 [concrete]
  37. // CHECK:STDOUT: %AsI32: %AsI32.type = struct_value () [concrete]
  38. // CHECK:STDOUT: %AsIntLiteral.type: type = fn_type @AsIntLiteral [concrete]
  39. // CHECK:STDOUT: %AsIntLiteral: %AsIntLiteral.type = struct_value () [concrete]
  40. // CHECK:STDOUT: %TestAdd.type: type = fn_type @TestAdd [concrete]
  41. // CHECK:STDOUT: %TestAdd: %TestAdd.type = struct_value () [concrete]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  46. // CHECK:STDOUT: .IntLiteral = %IntLiteral.decl
  47. // CHECK:STDOUT: .Int = %Int.decl
  48. // CHECK:STDOUT: .AsI32 = %AsI32.decl
  49. // CHECK:STDOUT: .AsIntLiteral = %AsIntLiteral.decl
  50. // CHECK:STDOUT: .TestAdd = %TestAdd.decl
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %IntLiteral.decl: %IntLiteral.type = fn_decl @IntLiteral [concrete = constants.%IntLiteral] {
  53. // CHECK:STDOUT: %return.patt: %pattern_type.98f = return_slot_pattern [concrete]
  54. // CHECK:STDOUT: %return.param_patt: %pattern_type.98f = out_param_pattern %return.patt, call_param0 [concrete]
  55. // CHECK:STDOUT: } {
  56. // CHECK:STDOUT: %return.param: ref type = out_param call_param0
  57. // CHECK:STDOUT: %return: ref type = return_slot %return.param
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: %Int.decl: %Int.type = fn_decl @Int [concrete = constants.%Int] {
  60. // CHECK:STDOUT: %N.patt: %pattern_type.dc0 = binding_pattern N [concrete]
  61. // CHECK:STDOUT: %N.param_patt: %pattern_type.dc0 = value_param_pattern %N.patt, call_param0 [concrete]
  62. // CHECK:STDOUT: %return.patt: %pattern_type.98f = return_slot_pattern [concrete]
  63. // CHECK:STDOUT: %return.param_patt: %pattern_type.98f = out_param_pattern %return.patt, call_param1 [concrete]
  64. // CHECK:STDOUT: } {
  65. // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param call_param0
  66. // CHECK:STDOUT: %.loc6_22.1: type = splice_block %.loc6_22.3 [concrete = Core.IntLiteral] {
  67. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [concrete = constants.%IntLiteral]
  68. // CHECK:STDOUT: %IntLiteral.call: init type = call %IntLiteral.ref() [concrete = Core.IntLiteral]
  69. // CHECK:STDOUT: %.loc6_22.2: type = value_of_initializer %IntLiteral.call [concrete = Core.IntLiteral]
  70. // CHECK:STDOUT: %.loc6_22.3: type = converted %IntLiteral.call, %.loc6_22.2 [concrete = Core.IntLiteral]
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: %N: Core.IntLiteral = bind_name N, %N.param
  73. // CHECK:STDOUT: %return.param: ref type = out_param call_param1
  74. // CHECK:STDOUT: %return: ref type = return_slot %return.param
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %AsI32.decl: %AsI32.type = fn_decl @AsI32 [concrete = constants.%AsI32] {
  77. // CHECK:STDOUT: %a.patt: %pattern_type.dc0 = binding_pattern a [concrete]
  78. // CHECK:STDOUT: %a.param_patt: %pattern_type.dc0 = value_param_pattern %a.patt, call_param0 [concrete]
  79. // CHECK:STDOUT: %return.patt: %pattern_type.956 = return_slot_pattern [concrete]
  80. // CHECK:STDOUT: %return.param_patt: %pattern_type.956 = out_param_pattern %return.patt, call_param1 [concrete]
  81. // CHECK:STDOUT: } {
  82. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  83. // CHECK:STDOUT: %Int.call: init type = call constants.%Int(%int_32) [concrete = constants.%i32.builtin]
  84. // CHECK:STDOUT: %.loc8_30.1: type = value_of_initializer %Int.call [concrete = constants.%i32.builtin]
  85. // CHECK:STDOUT: %.loc8_30.2: type = converted %Int.call, %.loc8_30.1 [concrete = constants.%i32.builtin]
  86. // CHECK:STDOUT: %a.param: Core.IntLiteral = value_param call_param0
  87. // CHECK:STDOUT: %.loc8_24.1: type = splice_block %.loc8_24.3 [concrete = Core.IntLiteral] {
  88. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [concrete = constants.%IntLiteral]
  89. // CHECK:STDOUT: %IntLiteral.call: init type = call %IntLiteral.ref() [concrete = Core.IntLiteral]
  90. // CHECK:STDOUT: %.loc8_24.2: type = value_of_initializer %IntLiteral.call [concrete = Core.IntLiteral]
  91. // CHECK:STDOUT: %.loc8_24.3: type = converted %IntLiteral.call, %.loc8_24.2 [concrete = Core.IntLiteral]
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: %a: Core.IntLiteral = bind_name a, %a.param
  94. // CHECK:STDOUT: %return.param: ref %i32.builtin = out_param call_param1
  95. // CHECK:STDOUT: %return: ref %i32.builtin = return_slot %return.param
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT: %AsIntLiteral.decl: %AsIntLiteral.type = fn_decl @AsIntLiteral [concrete = constants.%AsIntLiteral] {
  98. // CHECK:STDOUT: %a.patt: %pattern_type.956 = binding_pattern a [concrete]
  99. // CHECK:STDOUT: %a.param_patt: %pattern_type.956 = value_param_pattern %a.patt, call_param0 [concrete]
  100. // CHECK:STDOUT: %return.patt: %pattern_type.dc0 = return_slot_pattern [concrete]
  101. // CHECK:STDOUT: %return.param_patt: %pattern_type.dc0 = out_param_pattern %return.patt, call_param1 [concrete]
  102. // CHECK:STDOUT: } {
  103. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, file.%IntLiteral.decl [concrete = constants.%IntLiteral]
  104. // CHECK:STDOUT: %IntLiteral.call: init type = call %IntLiteral.ref() [concrete = Core.IntLiteral]
  105. // CHECK:STDOUT: %.loc9_39.1: type = value_of_initializer %IntLiteral.call [concrete = Core.IntLiteral]
  106. // CHECK:STDOUT: %.loc9_39.2: type = converted %IntLiteral.call, %.loc9_39.1 [concrete = Core.IntLiteral]
  107. // CHECK:STDOUT: %a.param: %i32.builtin = value_param call_param0
  108. // CHECK:STDOUT: %.loc9_20.1: type = splice_block %.loc9_20.3 [concrete = constants.%i32.builtin] {
  109. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  110. // CHECK:STDOUT: %Int.call: init type = call constants.%Int(%int_32) [concrete = constants.%i32.builtin]
  111. // CHECK:STDOUT: %.loc9_20.2: type = value_of_initializer %Int.call [concrete = constants.%i32.builtin]
  112. // CHECK:STDOUT: %.loc9_20.3: type = converted %Int.call, %.loc9_20.2 [concrete = constants.%i32.builtin]
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %a: %i32.builtin = bind_name a, %a.param
  115. // CHECK:STDOUT: %return.param: ref Core.IntLiteral = out_param call_param1
  116. // CHECK:STDOUT: %return: ref Core.IntLiteral = return_slot %return.param
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT: %TestAdd.decl: %TestAdd.type = fn_decl @TestAdd [concrete = constants.%TestAdd] {
  119. // CHECK:STDOUT: %a.patt: %pattern_type.956 = binding_pattern a [concrete]
  120. // CHECK:STDOUT: %a.param_patt: %pattern_type.956 = value_param_pattern %a.patt, call_param0 [concrete]
  121. // CHECK:STDOUT: %b.patt: %pattern_type.956 = binding_pattern b [concrete]
  122. // CHECK:STDOUT: %b.param_patt: %pattern_type.956 = value_param_pattern %b.patt, call_param1 [concrete]
  123. // CHECK:STDOUT: %return.patt: %pattern_type.956 = return_slot_pattern [concrete]
  124. // CHECK:STDOUT: %return.param_patt: %pattern_type.956 = out_param_pattern %return.patt, call_param2 [concrete]
  125. // CHECK:STDOUT: } {
  126. // CHECK:STDOUT: %int_32.loc11_31: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  127. // CHECK:STDOUT: %Int.call.loc11_31: init type = call constants.%Int(%int_32.loc11_31) [concrete = constants.%i32.builtin]
  128. // CHECK:STDOUT: %.loc11_31.1: type = value_of_initializer %Int.call.loc11_31 [concrete = constants.%i32.builtin]
  129. // CHECK:STDOUT: %.loc11_31.2: type = converted %Int.call.loc11_31, %.loc11_31.1 [concrete = constants.%i32.builtin]
  130. // CHECK:STDOUT: %a.param: %i32.builtin = value_param call_param0
  131. // CHECK:STDOUT: %.loc11_15.1: type = splice_block %.loc11_15.3 [concrete = constants.%i32.builtin] {
  132. // CHECK:STDOUT: %int_32.loc11_15: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  133. // CHECK:STDOUT: %Int.call.loc11_15: init type = call constants.%Int(%int_32.loc11_15) [concrete = constants.%i32.builtin]
  134. // CHECK:STDOUT: %.loc11_15.2: type = value_of_initializer %Int.call.loc11_15 [concrete = constants.%i32.builtin]
  135. // CHECK:STDOUT: %.loc11_15.3: type = converted %Int.call.loc11_15, %.loc11_15.2 [concrete = constants.%i32.builtin]
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT: %a: %i32.builtin = bind_name a, %a.param
  138. // CHECK:STDOUT: %b.param: %i32.builtin = value_param call_param1
  139. // CHECK:STDOUT: %.loc11_23.1: type = splice_block %.loc11_23.3 [concrete = constants.%i32.builtin] {
  140. // CHECK:STDOUT: %int_32.loc11_23: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  141. // CHECK:STDOUT: %Int.call.loc11_23: init type = call constants.%Int(%int_32.loc11_23) [concrete = constants.%i32.builtin]
  142. // CHECK:STDOUT: %.loc11_23.2: type = value_of_initializer %Int.call.loc11_23 [concrete = constants.%i32.builtin]
  143. // CHECK:STDOUT: %.loc11_23.3: type = converted %Int.call.loc11_23, %.loc11_23.2 [concrete = constants.%i32.builtin]
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT: %b: %i32.builtin = bind_name b, %b.param
  146. // CHECK:STDOUT: %return.param: ref %i32.builtin = out_param call_param2
  147. // CHECK:STDOUT: %return: ref %i32.builtin = return_slot %return.param
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: fn @IntLiteral() -> type = "int_literal.make_type";
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: fn @Int(%N.param: Core.IntLiteral) -> type = "int.make_type_signed";
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: fn @AsI32(%a.param: Core.IntLiteral) -> %i32.builtin = "int.convert_checked";
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: fn @AsIntLiteral(%a.param: %i32.builtin) -> Core.IntLiteral = "int.convert_checked";
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: fn @TestAdd(%a.param: %i32.builtin, %b.param: %i32.builtin) -> %i32.builtin = "int.sadd";
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: --- use.carbon
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: constants {
  164. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  165. // CHECK:STDOUT: %Int.type: type = fn_type @Int [concrete]
  166. // CHECK:STDOUT: %Int: %Int.type = struct_value () [concrete]
  167. // CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
  168. // CHECK:STDOUT: %AsIntLiteral.type: type = fn_type @AsIntLiteral [concrete]
  169. // CHECK:STDOUT: %AsIntLiteral: %AsIntLiteral.type = struct_value () [concrete]
  170. // CHECK:STDOUT: %TestAdd.type: type = fn_type @TestAdd [concrete]
  171. // CHECK:STDOUT: %TestAdd: %TestAdd.type = struct_value () [concrete]
  172. // CHECK:STDOUT: %AsI32.type: type = fn_type @AsI32 [concrete]
  173. // CHECK:STDOUT: %AsI32: %AsI32.type = struct_value () [concrete]
  174. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  175. // CHECK:STDOUT: %int_1.f38: %i32.builtin = int_value 1 [concrete]
  176. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  177. // CHECK:STDOUT: %int_2.5a1: %i32.builtin = int_value 2 [concrete]
  178. // CHECK:STDOUT: %int_3.a0f: %i32.builtin = int_value 3 [concrete]
  179. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
  180. // CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32.builtin [concrete]
  181. // CHECK:STDOUT: %pattern_type.9e2: type = pattern_type %array_type [concrete]
  182. // CHECK:STDOUT: %tuple.type: type = tuple_type (%i32.builtin, %i32.builtin, %i32.builtin) [concrete]
  183. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete]
  184. // CHECK:STDOUT: %array: %array_type = tuple_value (%int_1.f38, %int_2.5a1, %int_3.a0f) [concrete]
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: imports {
  188. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  189. // CHECK:STDOUT: .Int = %Core.Int
  190. // CHECK:STDOUT: .AsIntLiteral = %Core.AsIntLiteral
  191. // CHECK:STDOUT: .TestAdd = %Core.TestAdd
  192. // CHECK:STDOUT: .AsI32 = %Core.AsI32
  193. // CHECK:STDOUT: import Core//core
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//core, Int, loaded [concrete = constants.%Int]
  196. // CHECK:STDOUT: %Core.AsIntLiteral: %AsIntLiteral.type = import_ref Core//core, AsIntLiteral, loaded [concrete = constants.%AsIntLiteral]
  197. // CHECK:STDOUT: %Core.TestAdd: %TestAdd.type = import_ref Core//core, TestAdd, loaded [concrete = constants.%TestAdd]
  198. // CHECK:STDOUT: %Core.AsI32: %AsI32.type = import_ref Core//core, AsI32, loaded [concrete = constants.%AsI32]
  199. // CHECK:STDOUT: }
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: file {
  202. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  203. // CHECK:STDOUT: .Core = imports.%Core
  204. // CHECK:STDOUT: .arr = %arr
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT: %Core.import = import Core
  207. // CHECK:STDOUT: name_binding_decl {
  208. // CHECK:STDOUT: %arr.patt: %pattern_type.9e2 = binding_pattern arr [concrete]
  209. // CHECK:STDOUT: %arr.var_patt: %pattern_type.9e2 = var_pattern %arr.patt [concrete]
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT: %arr.var: ref %array_type = var %arr.var_patt [concrete]
  212. // CHECK:STDOUT: %.loc4_82: type = splice_block %array_type [concrete = constants.%array_type] {
  213. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  214. // CHECK:STDOUT: %Int.call: init type = call constants.%Int(%int_32) [concrete = constants.%i32.builtin]
  215. // CHECK:STDOUT: %Core.ref.loc4_21: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  216. // CHECK:STDOUT: %AsIntLiteral.ref: %AsIntLiteral.type = name_ref AsIntLiteral, imports.%Core.AsIntLiteral [concrete = constants.%AsIntLiteral]
  217. // CHECK:STDOUT: %Core.ref.loc4_39: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  218. // CHECK:STDOUT: %TestAdd.ref: %TestAdd.type = name_ref TestAdd, imports.%Core.TestAdd [concrete = constants.%TestAdd]
  219. // CHECK:STDOUT: %Core.ref.loc4_52: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  220. // CHECK:STDOUT: %AsI32.ref.loc4_56: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32]
  221. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  222. // CHECK:STDOUT: %AsI32.call.loc4_64: init %i32.builtin = call %AsI32.ref.loc4_56(%int_1) [concrete = constants.%int_1.f38]
  223. // CHECK:STDOUT: %Core.ref.loc4_67: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  224. // CHECK:STDOUT: %AsI32.ref.loc4_71: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32]
  225. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  226. // CHECK:STDOUT: %AsI32.call.loc4_79: init %i32.builtin = call %AsI32.ref.loc4_71(%int_2) [concrete = constants.%int_2.5a1]
  227. // CHECK:STDOUT: %.loc4_64.1: %i32.builtin = value_of_initializer %AsI32.call.loc4_64 [concrete = constants.%int_1.f38]
  228. // CHECK:STDOUT: %.loc4_64.2: %i32.builtin = converted %AsI32.call.loc4_64, %.loc4_64.1 [concrete = constants.%int_1.f38]
  229. // CHECK:STDOUT: %.loc4_79.1: %i32.builtin = value_of_initializer %AsI32.call.loc4_79 [concrete = constants.%int_2.5a1]
  230. // CHECK:STDOUT: %.loc4_79.2: %i32.builtin = converted %AsI32.call.loc4_79, %.loc4_79.1 [concrete = constants.%int_2.5a1]
  231. // CHECK:STDOUT: %TestAdd.call: init %i32.builtin = call %TestAdd.ref(%.loc4_64.2, %.loc4_79.2) [concrete = constants.%int_3.a0f]
  232. // CHECK:STDOUT: %.loc4_80.1: %i32.builtin = value_of_initializer %TestAdd.call [concrete = constants.%int_3.a0f]
  233. // CHECK:STDOUT: %.loc4_80.2: %i32.builtin = converted %TestAdd.call, %.loc4_80.1 [concrete = constants.%int_3.a0f]
  234. // CHECK:STDOUT: %AsIntLiteral.call: init Core.IntLiteral = call %AsIntLiteral.ref(%.loc4_80.2) [concrete = constants.%int_3.1ba]
  235. // CHECK:STDOUT: %.loc4_16.1: type = value_of_initializer %Int.call [concrete = constants.%i32.builtin]
  236. // CHECK:STDOUT: %.loc4_16.2: type = converted %Int.call, %.loc4_16.1 [concrete = constants.%i32.builtin]
  237. // CHECK:STDOUT: %.loc4_81.1: Core.IntLiteral = value_of_initializer %AsIntLiteral.call [concrete = constants.%int_3.1ba]
  238. // CHECK:STDOUT: %.loc4_81.2: Core.IntLiteral = converted %AsIntLiteral.call, %.loc4_81.1 [concrete = constants.%int_3.1ba]
  239. // CHECK:STDOUT: %array_type: type = array_type %.loc4_81.2, %.loc4_16.2 [concrete = constants.%array_type]
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT: %arr: ref %array_type = bind_name arr, %arr.var [concrete = %arr.var]
  242. // CHECK:STDOUT: }
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: fn @Int = "int.make_type_signed" [from "core.carbon"];
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: fn @AsIntLiteral = "int.convert_checked" [from "core.carbon"];
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: fn @TestAdd = "int.sadd" [from "core.carbon"];
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: fn @AsI32 = "int.convert_checked" [from "core.carbon"];
  251. // CHECK:STDOUT:
  252. // CHECK:STDOUT: fn @__global_init() {
  253. // CHECK:STDOUT: !entry:
  254. // CHECK:STDOUT: %Core.ref.loc4_87: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  255. // CHECK:STDOUT: %AsI32.ref.loc4_91: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32]
  256. // CHECK:STDOUT: %int_1.loc4_98: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  257. // CHECK:STDOUT: %AsI32.call.loc4_99: init %i32.builtin = call %AsI32.ref.loc4_91(%int_1.loc4_98) [concrete = constants.%int_1.f38]
  258. // CHECK:STDOUT: %Core.ref.loc4_102: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  259. // CHECK:STDOUT: %AsI32.ref.loc4_106: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32]
  260. // CHECK:STDOUT: %int_2.loc4_113: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  261. // CHECK:STDOUT: %AsI32.call.loc4_114: init %i32.builtin = call %AsI32.ref.loc4_106(%int_2.loc4_113) [concrete = constants.%int_2.5a1]
  262. // CHECK:STDOUT: %Core.ref.loc4_117: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  263. // CHECK:STDOUT: %AsI32.ref.loc4_121: %AsI32.type = name_ref AsI32, imports.%Core.AsI32 [concrete = constants.%AsI32]
  264. // CHECK:STDOUT: %int_3: Core.IntLiteral = int_value 3 [concrete = constants.%int_3.1ba]
  265. // CHECK:STDOUT: %AsI32.call.loc4_129: init %i32.builtin = call %AsI32.ref.loc4_121(%int_3) [concrete = constants.%int_3.a0f]
  266. // CHECK:STDOUT: %.loc4_130.1: %tuple.type = tuple_literal (%AsI32.call.loc4_99, %AsI32.call.loc4_114, %AsI32.call.loc4_129)
  267. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0]
  268. // CHECK:STDOUT: %.loc4_130.2: ref %i32.builtin = array_index file.%arr.var, %int_0
  269. // CHECK:STDOUT: %.loc4_130.3: init %i32.builtin = initialize_from %AsI32.call.loc4_99 to %.loc4_130.2 [concrete = constants.%int_1.f38]
  270. // CHECK:STDOUT: %int_1.loc4_130: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  271. // CHECK:STDOUT: %.loc4_130.4: ref %i32.builtin = array_index file.%arr.var, %int_1.loc4_130
  272. // CHECK:STDOUT: %.loc4_130.5: init %i32.builtin = initialize_from %AsI32.call.loc4_114 to %.loc4_130.4 [concrete = constants.%int_2.5a1]
  273. // CHECK:STDOUT: %int_2.loc4_130: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  274. // CHECK:STDOUT: %.loc4_130.6: ref %i32.builtin = array_index file.%arr.var, %int_2.loc4_130
  275. // CHECK:STDOUT: %.loc4_130.7: init %i32.builtin = initialize_from %AsI32.call.loc4_129 to %.loc4_130.6 [concrete = constants.%int_3.a0f]
  276. // CHECK:STDOUT: %.loc4_130.8: init %array_type = array_init (%.loc4_130.3, %.loc4_130.5, %.loc4_130.7) to file.%arr.var [concrete = constants.%array]
  277. // CHECK:STDOUT: %.loc4_1: init %array_type = converted %.loc4_130.1, %.loc4_130.8 [concrete = constants.%array]
  278. // CHECK:STDOUT: assign file.%arr.var, %.loc4_1
  279. // CHECK:STDOUT: return
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT: