convert_checked.carbon 22 KB

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