convert_checked.carbon 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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/builtins/int/convert_checked.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/convert_checked.carbon
  10. // --- int_ops.carbon
  11. library "[[@TEST_NAME]]";
  12. fn NegateI32(a: i32) -> i32 = "int.snegate";
  13. fn SubI32(a: i32, b: i32) -> i32 = "int.ssub";
  14. fn AddU32(a: u32, b: u32) -> u32 = "int.uadd";
  15. fn IntLiteral() -> type = "int_literal.make_type";
  16. // Size preserving
  17. fn Int32ToInt32(a: i32) -> i32 = "int.convert_checked";
  18. fn Int32ToUint32(a: i32) -> u32 = "int.convert_checked";
  19. fn Uint32ToInt32(a: u32) -> i32 = "int.convert_checked";
  20. fn Uint32ToUint32(a: u32) -> u32 = "int.convert_checked";
  21. fn IntLiteralToIntLiteral(a: IntLiteral()) -> IntLiteral() =
  22. "int.convert_checked";
  23. // Narrowing
  24. fn Int32ToInt16(a: i32) -> i16 = "int.convert_checked";
  25. fn Int32ToUint16(a: i32) -> u16 = "int.convert_checked";
  26. fn Uint32ToInt16(a: u32) -> i16 = "int.convert_checked";
  27. fn Uint32ToUint16(a: u32) -> u16 = "int.convert_checked";
  28. fn IntLiteralToInt16(a: IntLiteral()) -> i16 = "int.convert_checked";
  29. fn IntLiteralToUint16(a: IntLiteral()) -> u16 = "int.convert_checked";
  30. // Widening
  31. fn Int32ToInt64(a: i32) -> i64 = "int.convert_checked";
  32. fn Int32ToUint64(a: i32) -> u64 = "int.convert_checked";
  33. fn Uint32ToInt64(a: u32) -> i64 = "int.convert_checked";
  34. fn Uint32ToUint64(a: u32) -> u64 = "int.convert_checked";
  35. fn Int32ToIntLiteral(a: i32) -> IntLiteral() = "int.convert_checked";
  36. fn Uint32ToUintLiteral(a: u32) -> IntLiteral() = "int.convert_checked";
  37. // --- runtime_call.carbon
  38. library "[[@TEST_NAME]]";
  39. import library "int_ops";
  40. //@dump-sem-ir-begin
  41. let SizePreserving: u32 = Int32ToUint32(1);
  42. let Narrowing: i16 = Int32ToInt16(1);
  43. let Widening: i64 = Int32ToInt64(1);
  44. //@dump-sem-ir-end
  45. // --- identity.carbon
  46. library "[[@TEST_NAME]]";
  47. import library "int_ops";
  48. let a: i32 = Int32ToInt32(0);
  49. let b: i32 = Int32ToInt32(0x7FFF_FFFF);
  50. let c: i32 = Int32ToInt32(SubI32(NegateI32(0x7FFF_FFFF), 1));
  51. let d: IntLiteral() = IntLiteralToIntLiteral(Int32ToIntLiteral(NegateI32(1)));
  52. // --- same_size.carbon
  53. library "[[@TEST_NAME]]";
  54. import library "int_ops";
  55. let max: u32 = Int32ToUint32(0x7FFF_FFFF);
  56. let max_roundtrip: i32 = Uint32ToInt32(Int32ToUint32(0x7FFF_FFFF));
  57. // --- truncate.carbon
  58. library "[[@TEST_NAME]]";
  59. import library "int_ops";
  60. let a: u16 = Int32ToUint16(0);
  61. let b: u16 = Int32ToUint16(0xFFFF);
  62. let c: i16 = Int32ToInt16(0x7FFF);
  63. let d: i16 = Int32ToInt16(NegateI32(0x8000));
  64. let e: u16 = Uint32ToUint16(Int32ToUint32(0));
  65. let f: u16 = Uint32ToUint16(Int32ToUint32(0xFFFF));
  66. let g: i16 = Uint32ToInt16(Int32ToUint32(0));
  67. let h: i16 = Uint32ToInt16(Int32ToUint32(0x7FFF));
  68. let lit_i16_min: i16 = IntLiteralToInt16(Int32ToIntLiteral(NegateI32(0x8000)));
  69. let lit_i16_max: i16 = IntLiteralToInt16(Int32ToIntLiteral(0x7FFF));
  70. let lit_u16_min: u16 = IntLiteralToUint16(Int32ToIntLiteral(0));
  71. let lit_u16_max: u16 = IntLiteralToUint16(Int32ToIntLiteral(0xFFFF));
  72. // --- zero_extend.carbon
  73. library "[[@TEST_NAME]]";
  74. import library "int_ops";
  75. let a: u64 = Uint32ToUint64(Int32ToUint32(0));
  76. let b: u64 = Uint32ToUint64(
  77. AddU32(
  78. AddU32(Int32ToUint32(0x7FFF_FFFF), Int32ToUint32(0x7FFF_FFFF)),
  79. Int32ToUint32(1)));
  80. let c: i64 = Uint32ToInt64(Int32ToUint32(0));
  81. let d: i64 = Uint32ToInt64(
  82. AddU32(
  83. AddU32(Int32ToUint32(0x7FFF_FFFF), Int32ToUint32(0x7FFF_FFFF)),
  84. Int32ToUint32(1)));
  85. // --- sign_extend.carbon
  86. library "[[@TEST_NAME]]";
  87. import library "int_ops";
  88. let a: u64 = Int32ToUint64(0);
  89. let b: u64 = Int32ToUint64(0x7FFF_FFFF);
  90. let c: i64 = Int32ToInt64(SubI32(NegateI32(0x7FFF_FFFF), 1));
  91. let d: i64 = Int32ToInt64(0x7FFF_FFFF);
  92. // --- fail_too_large_u32_for_i32.carbon
  93. library "[[@TEST_NAME]]";
  94. import library "int_ops";
  95. let max_plus_one: i32 =
  96. // CHECK:STDERR: fail_too_large_u32_for_i32.carbon:[[@LINE+4]]:3: error: integer value 2147483648 too large for type `i32` [IntTooLargeForType]
  97. // CHECK:STDERR: Uint32ToInt32(
  98. // CHECK:STDERR: ^~~~~~~~~~~~~~
  99. // CHECK:STDERR:
  100. Uint32ToInt32(
  101. AddU32(Int32ToUint32(0x7FFF_FFFF),
  102. Int32ToUint32(1)));
  103. // --- fail_too_large_i32_for_i16.carbon
  104. library "[[@TEST_NAME]]";
  105. import library "int_ops";
  106. // CHECK:STDERR: fail_too_large_i32_for_i16.carbon:[[@LINE+4]]:25: error: integer value 32768 too large for type `i16` [IntTooLargeForType]
  107. // CHECK:STDERR: let max_plus_one: i16 = Int32ToInt16(0x8000);
  108. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  109. // CHECK:STDERR:
  110. let max_plus_one: i16 = Int32ToInt16(0x8000);
  111. // --- fail_too_large_i32_for_u16.carbon
  112. library "[[@TEST_NAME]]";
  113. import library "int_ops";
  114. // CHECK:STDERR: fail_too_large_i32_for_u16.carbon:[[@LINE+4]]:25: error: integer value 65536 too large for type `u16` [IntTooLargeForType]
  115. // CHECK:STDERR: let max_plus_one: u16 = Int32ToUint16(0x1_0000);
  116. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  117. // CHECK:STDERR:
  118. let max_plus_one: u16 = Int32ToUint16(0x1_0000);
  119. // --- fail_too_large_u32_for_i16.carbon
  120. library "[[@TEST_NAME]]";
  121. import library "int_ops";
  122. // CHECK:STDERR: fail_too_large_u32_for_i16.carbon:[[@LINE+4]]:25: error: integer value 32768 too large for type `i16` [IntTooLargeForType]
  123. // CHECK:STDERR: let max_plus_one: i16 = Uint32ToInt16(Int32ToUint32(0x8000));
  124. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  125. // CHECK:STDERR:
  126. let max_plus_one: i16 = Uint32ToInt16(Int32ToUint32(0x8000));
  127. // --- fail_too_large_u32_for_u16.carbon
  128. library "[[@TEST_NAME]]";
  129. import library "int_ops";
  130. // CHECK:STDERR: fail_too_large_u32_for_u16.carbon:[[@LINE+4]]:25: error: integer value 65536 too large for type `u16` [IntTooLargeForType]
  131. // CHECK:STDERR: let max_plus_one: u16 = Uint32ToUint16(Int32ToUint32(0x1_0000));
  132. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  133. // CHECK:STDERR:
  134. let max_plus_one: u16 = Uint32ToUint16(Int32ToUint32(0x1_0000));
  135. // --- fail_negative_i32_to_u16.carbon
  136. library "[[@TEST_NAME]]";
  137. import library "int_ops";
  138. // CHECK:STDERR: fail_negative_i32_to_u16.carbon:[[@LINE+4]]:29: error: negative integer value -1 converted to unsigned type `u16` [NegativeIntInUnsignedType]
  139. // CHECK:STDERR: let minus_one_to_u16: u16 = Int32ToUint16(SubI32(0, 1));
  140. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  141. // CHECK:STDERR:
  142. let minus_one_to_u16: u16 = Int32ToUint16(SubI32(0, 1));
  143. // --- fail_negative_i32_to_u32.carbon
  144. library "[[@TEST_NAME]]";
  145. import library "int_ops";
  146. // CHECK:STDERR: fail_negative_i32_to_u32.carbon:[[@LINE+4]]:29: error: negative integer value -1 converted to unsigned type `u32` [NegativeIntInUnsignedType]
  147. // CHECK:STDERR: let minus_one_to_u32: u32 = Int32ToUint32(SubI32(0, 1));
  148. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  149. // CHECK:STDERR:
  150. let minus_one_to_u32: u32 = Int32ToUint32(SubI32(0, 1));
  151. // --- fail_negative_i32_to_u64.carbon
  152. library "[[@TEST_NAME]]";
  153. import library "int_ops";
  154. // CHECK:STDERR: fail_negative_i32_to_u64.carbon:[[@LINE+4]]:29: error: negative integer value -1 converted to unsigned type `u64` [NegativeIntInUnsignedType]
  155. // CHECK:STDERR: let minus_one_to_u64: u64 = Int32ToUint64(SubI32(0, 1));
  156. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  157. // CHECK:STDERR:
  158. let minus_one_to_u64: u64 = Int32ToUint64(SubI32(0, 1));
  159. // --- fail_too_small_i32_for_i16.carbon
  160. library "[[@TEST_NAME]]";
  161. import library "int_ops";
  162. // CHECK:STDERR: fail_too_small_i32_for_i16.carbon:[[@LINE+4]]:26: error: integer value -32769 too large for type `i16` [IntTooLargeForType]
  163. // CHECK:STDERR: let min_minus_one: i16 = Int32ToInt16(NegateI32(0x8001));
  164. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  165. // CHECK:STDERR:
  166. let min_minus_one: i16 = Int32ToInt16(NegateI32(0x8001));
  167. // --- fail_not_constant.carbon
  168. library "[[@TEST_NAME]]";
  169. import library "int_ops";
  170. let not_constant: i32 = 0;
  171. // CHECK:STDERR: fail_not_constant.carbon:[[@LINE+8]]:40: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction]
  172. // CHECK:STDERR: let convert_not_constant_narrow: i16 = Int32ToInt16(not_constant);
  173. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
  174. // CHECK:STDERR: fail_not_constant.carbon:[[@LINE-7]]:1: in import [InImport]
  175. // CHECK:STDERR: int_ops.carbon:18:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere]
  176. // CHECK:STDERR: fn Int32ToInt16(a: i32) -> i16 = "int.convert_checked";
  177. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  178. // CHECK:STDERR:
  179. let convert_not_constant_narrow: i16 = Int32ToInt16(not_constant);
  180. // CHECK:STDERR: fail_not_constant.carbon:[[@LINE+8]]:38: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction]
  181. // CHECK:STDERR: let convert_not_constant_same: i32 = Int32ToInt32(not_constant);
  182. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
  183. // CHECK:STDERR: fail_not_constant.carbon:[[@LINE-17]]:1: in import [InImport]
  184. // CHECK:STDERR: int_ops.carbon:10:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere]
  185. // CHECK:STDERR: fn Int32ToInt32(a: i32) -> i32 = "int.convert_checked";
  186. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  187. // CHECK:STDERR:
  188. let convert_not_constant_same: i32 = Int32ToInt32(not_constant);
  189. // CHECK:STDERR: fail_not_constant.carbon:[[@LINE+8]]:39: error: non-constant call to compile-time-only function [NonConstantCallToCompTimeOnlyFunction]
  190. // CHECK:STDERR: let convert_not_constant_widen: i64 = Int32ToInt64(not_constant);
  191. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
  192. // CHECK:STDERR: fail_not_constant.carbon:[[@LINE-27]]:1: in import [InImport]
  193. // CHECK:STDERR: int_ops.carbon:26:1: note: compile-time-only function declared here [CompTimeOnlyFunctionHere]
  194. // CHECK:STDERR: fn Int32ToInt64(a: i32) -> i64 = "int.convert_checked";
  195. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  196. // CHECK:STDERR:
  197. let convert_not_constant_widen: i64 = Int32ToInt64(not_constant);
  198. // CHECK:STDOUT: --- runtime_call.carbon
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: constants {
  201. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  202. // CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [concrete]
  203. // CHECK:STDOUT: %pattern_type.4a9: type = pattern_type %u32 [concrete]
  204. // CHECK:STDOUT: %Int32ToUint32.type: type = fn_type @Int32ToUint32 [concrete]
  205. // CHECK:STDOUT: %Int32ToUint32: %Int32ToUint32.type = struct_value () [concrete]
  206. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  207. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  208. // CHECK:STDOUT: %ImplicitAs.type.9ba: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  209. // CHECK:STDOUT: %Convert.type.6da: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  210. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  211. // CHECK:STDOUT: %Convert.type.0b2: type = fn_type @Convert.2, @impl.c81(%To.c80) [symbolic]
  212. // CHECK:STDOUT: %Convert.6d7: %Convert.type.0b2 = struct_value () [symbolic]
  213. // CHECK:STDOUT: %ImplicitAs.impl_witness.e34: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.e36, @impl.c81(%int_32) [concrete]
  214. // CHECK:STDOUT: %Convert.type.ed5: type = fn_type @Convert.2, @impl.c81(%int_32) [concrete]
  215. // CHECK:STDOUT: %Convert.16d: %Convert.type.ed5 = struct_value () [concrete]
  216. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.9ba = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.e34) [concrete]
  217. // CHECK:STDOUT: %.d6a: type = fn_type_with_self_type %Convert.type.6da, %ImplicitAs.facet [concrete]
  218. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.16d [concrete]
  219. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.16d, @Convert.2(%int_32) [concrete]
  220. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  221. // CHECK:STDOUT: %int_1.47b: %i32 = int_value 1 [concrete]
  222. // CHECK:STDOUT: %int_1.c1d: %u32 = int_value 1 [concrete]
  223. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  224. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  225. // CHECK:STDOUT: %pattern_type.88f: type = pattern_type %i16 [concrete]
  226. // CHECK:STDOUT: %Int32ToInt16.type: type = fn_type @Int32ToInt16 [concrete]
  227. // CHECK:STDOUT: %Int32ToInt16: %Int32ToInt16.type = struct_value () [concrete]
  228. // CHECK:STDOUT: %int_1.c22: %i16 = int_value 1 [concrete]
  229. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete]
  230. // CHECK:STDOUT: %i64: type = class_type @Int, @Int(%int_64) [concrete]
  231. // CHECK:STDOUT: %pattern_type.a10: type = pattern_type %i64 [concrete]
  232. // CHECK:STDOUT: %Int32ToInt64.type: type = fn_type @Int32ToInt64 [concrete]
  233. // CHECK:STDOUT: %Int32ToInt64: %Int32ToInt64.type = struct_value () [concrete]
  234. // CHECK:STDOUT: %int_1.a95: %i64 = int_value 1 [concrete]
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: imports {
  238. // CHECK:STDOUT: %Main.Int32ToUint32: %Int32ToUint32.type = import_ref Main//int_ops, Int32ToUint32, loaded [concrete = constants.%Int32ToUint32]
  239. // CHECK:STDOUT: %Main.Int32ToInt16: %Int32ToInt16.type = import_ref Main//int_ops, Int32ToInt16, loaded [concrete = constants.%Int32ToInt16]
  240. // CHECK:STDOUT: %Main.Int32ToInt64: %Int32ToInt64.type = import_ref Main//int_ops, Int32ToInt64, loaded [concrete = constants.%Int32ToInt64]
  241. // CHECK:STDOUT: %Core.import_ref.a86: @impl.c81.%Convert.type (%Convert.type.0b2) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.c81.%Convert (constants.%Convert.6d7)]
  242. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.e36 = impl_witness_table (%Core.import_ref.a86), @impl.c81 [concrete]
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: file {
  246. // CHECK:STDOUT: name_binding_decl {
  247. // CHECK:STDOUT: %SizePreserving.patt: %pattern_type.4a9 = binding_pattern SizePreserving [concrete]
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT: %.loc6_21: type = splice_block %u32 [concrete = constants.%u32] {
  250. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  251. // CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(constants.%int_32) [concrete = constants.%u32]
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT: %.loc6_42.1: ref %u32 = temporary_storage
  254. // CHECK:STDOUT: %.loc6_42.2: ref %u32 = temporary %.loc6_42.1, @__global_init.%int.convert_checked.loc6_42
  255. // CHECK:STDOUT: %SizePreserving: ref %u32 = bind_name SizePreserving, %.loc6_42.2
  256. // CHECK:STDOUT: name_binding_decl {
  257. // CHECK:STDOUT: %Narrowing.patt: %pattern_type.88f = binding_pattern Narrowing [concrete]
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT: %.loc7_16: type = splice_block %i16 [concrete = constants.%i16] {
  260. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  261. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  262. // CHECK:STDOUT: }
  263. // CHECK:STDOUT: %.loc7_36.1: ref %i16 = temporary_storage
  264. // CHECK:STDOUT: %.loc7_36.2: ref %i16 = temporary %.loc7_36.1, @__global_init.%int.convert_checked.loc7_36
  265. // CHECK:STDOUT: %Narrowing: ref %i16 = bind_name Narrowing, %.loc7_36.2
  266. // CHECK:STDOUT: name_binding_decl {
  267. // CHECK:STDOUT: %Widening.patt: %pattern_type.a10 = binding_pattern Widening [concrete]
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT: %.loc8_15: type = splice_block %i64 [concrete = constants.%i64] {
  270. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [concrete = constants.%int_64]
  271. // CHECK:STDOUT: %i64: type = class_type @Int, @Int(constants.%int_64) [concrete = constants.%i64]
  272. // CHECK:STDOUT: }
  273. // CHECK:STDOUT: %.loc8_35.1: ref %i64 = temporary_storage
  274. // CHECK:STDOUT: %.loc8_35.2: ref %i64 = temporary %.loc8_35.1, @__global_init.%int.convert_checked.loc8_35
  275. // CHECK:STDOUT: %Widening: ref %i64 = bind_name Widening, %.loc8_35.2
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: fn @__global_init() {
  279. // CHECK:STDOUT: !entry:
  280. // CHECK:STDOUT: %Int32ToUint32.ref: %Int32ToUint32.type = name_ref Int32ToUint32, imports.%Main.Int32ToUint32 [concrete = constants.%Int32ToUint32]
  281. // CHECK:STDOUT: %int_1.loc6: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  282. // CHECK:STDOUT: %impl.elem0.loc6: %.d6a = impl_witness_access constants.%ImplicitAs.impl_witness.e34, element0 [concrete = constants.%Convert.16d]
  283. // CHECK:STDOUT: %bound_method.loc6_41.1: <bound method> = bound_method %int_1.loc6, %impl.elem0.loc6 [concrete = constants.%Convert.bound]
  284. // CHECK:STDOUT: %specific_fn.loc6: <specific function> = specific_function %impl.elem0.loc6, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  285. // CHECK:STDOUT: %bound_method.loc6_41.2: <bound method> = bound_method %int_1.loc6, %specific_fn.loc6 [concrete = constants.%bound_method]
  286. // CHECK:STDOUT: %int.convert_checked.loc6_41: init %i32 = call %bound_method.loc6_41.2(%int_1.loc6) [concrete = constants.%int_1.47b]
  287. // CHECK:STDOUT: %.loc6_41.1: %i32 = value_of_initializer %int.convert_checked.loc6_41 [concrete = constants.%int_1.47b]
  288. // CHECK:STDOUT: %.loc6_41.2: %i32 = converted %int_1.loc6, %.loc6_41.1 [concrete = constants.%int_1.47b]
  289. // CHECK:STDOUT: %int.convert_checked.loc6_42: init %u32 = call %Int32ToUint32.ref(%.loc6_41.2) [concrete = constants.%int_1.c1d]
  290. // CHECK:STDOUT: %Int32ToInt16.ref: %Int32ToInt16.type = name_ref Int32ToInt16, imports.%Main.Int32ToInt16 [concrete = constants.%Int32ToInt16]
  291. // CHECK:STDOUT: %int_1.loc7: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  292. // CHECK:STDOUT: %impl.elem0.loc7: %.d6a = impl_witness_access constants.%ImplicitAs.impl_witness.e34, element0 [concrete = constants.%Convert.16d]
  293. // CHECK:STDOUT: %bound_method.loc7_35.1: <bound method> = bound_method %int_1.loc7, %impl.elem0.loc7 [concrete = constants.%Convert.bound]
  294. // CHECK:STDOUT: %specific_fn.loc7: <specific function> = specific_function %impl.elem0.loc7, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  295. // CHECK:STDOUT: %bound_method.loc7_35.2: <bound method> = bound_method %int_1.loc7, %specific_fn.loc7 [concrete = constants.%bound_method]
  296. // CHECK:STDOUT: %int.convert_checked.loc7_35: init %i32 = call %bound_method.loc7_35.2(%int_1.loc7) [concrete = constants.%int_1.47b]
  297. // CHECK:STDOUT: %.loc7_35.1: %i32 = value_of_initializer %int.convert_checked.loc7_35 [concrete = constants.%int_1.47b]
  298. // CHECK:STDOUT: %.loc7_35.2: %i32 = converted %int_1.loc7, %.loc7_35.1 [concrete = constants.%int_1.47b]
  299. // CHECK:STDOUT: %int.convert_checked.loc7_36: init %i16 = call %Int32ToInt16.ref(%.loc7_35.2) [concrete = constants.%int_1.c22]
  300. // CHECK:STDOUT: %Int32ToInt64.ref: %Int32ToInt64.type = name_ref Int32ToInt64, imports.%Main.Int32ToInt64 [concrete = constants.%Int32ToInt64]
  301. // CHECK:STDOUT: %int_1.loc8: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  302. // CHECK:STDOUT: %impl.elem0.loc8: %.d6a = impl_witness_access constants.%ImplicitAs.impl_witness.e34, element0 [concrete = constants.%Convert.16d]
  303. // CHECK:STDOUT: %bound_method.loc8_34.1: <bound method> = bound_method %int_1.loc8, %impl.elem0.loc8 [concrete = constants.%Convert.bound]
  304. // CHECK:STDOUT: %specific_fn.loc8: <specific function> = specific_function %impl.elem0.loc8, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  305. // CHECK:STDOUT: %bound_method.loc8_34.2: <bound method> = bound_method %int_1.loc8, %specific_fn.loc8 [concrete = constants.%bound_method]
  306. // CHECK:STDOUT: %int.convert_checked.loc8_34: init %i32 = call %bound_method.loc8_34.2(%int_1.loc8) [concrete = constants.%int_1.47b]
  307. // CHECK:STDOUT: %.loc8_34.1: %i32 = value_of_initializer %int.convert_checked.loc8_34 [concrete = constants.%int_1.47b]
  308. // CHECK:STDOUT: %.loc8_34.2: %i32 = converted %int_1.loc8, %.loc8_34.1 [concrete = constants.%int_1.47b]
  309. // CHECK:STDOUT: %int.convert_checked.loc8_35: init %i64 = call %Int32ToInt64.ref(%.loc8_34.2) [concrete = constants.%int_1.a95]
  310. // CHECK:STDOUT: <elided>
  311. // CHECK:STDOUT: }
  312. // CHECK:STDOUT: