usub.carbon 29 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/usub.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/usub.carbon
  10. // --- int_sub.carbon
  11. fn Sub(a: i32, b: i32) -> i32 = "int.usub";
  12. var arr: [i32; Sub(3, 2)];
  13. let arr_p: [i32; 1]* = &arr;
  14. fn RuntimeCall(a: i32, b: i32) -> i32 {
  15. return Sub(a, b);
  16. }
  17. // --- overflow.carbon
  18. package Overflow;
  19. fn Sub(a: i32, b: i32) -> i32 = "int.usub";
  20. let a: i32 = Sub(0, 0x7FFFFFFF);
  21. let b: i32 = Sub(Sub(0, 0x7FFFFFFF), 1);
  22. let c: i32 = Sub(Sub(0, 0x7FFFFFFF), 2);
  23. // CHECK:STDOUT: --- int_sub.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  27. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  28. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  29. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  30. // CHECK:STDOUT: %Sub.type: type = fn_type @Sub [template]
  31. // CHECK:STDOUT: %Sub: %Sub.type = struct_value () [template]
  32. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 3 [template]
  33. // CHECK:STDOUT: %.3: Core.IntLiteral = int_value 2 [template]
  34. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  35. // CHECK:STDOUT: %Convert.type.6: type = fn_type @Convert.1, @ImplicitAs(Core.IntLiteral) [template]
  36. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.1) [template]
  37. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  38. // CHECK:STDOUT: %.23: <witness> = interface_witness (%Convert.14) [template]
  39. // CHECK:STDOUT: %.24: <bound method> = bound_method %.2, %Convert.14 [template]
  40. // CHECK:STDOUT: %.25: <specific function> = specific_function %.24, @Convert.2(%.1) [template]
  41. // CHECK:STDOUT: %.26: %i32 = int_value 3 [template]
  42. // CHECK:STDOUT: %.27: <bound method> = bound_method %.3, %Convert.14 [template]
  43. // CHECK:STDOUT: %.28: <specific function> = specific_function %.27, @Convert.2(%.1) [template]
  44. // CHECK:STDOUT: %.29: %i32 = int_value 2 [template]
  45. // CHECK:STDOUT: %.30: %i32 = int_value 1 [template]
  46. // CHECK:STDOUT: %Convert.type.15: type = fn_type @Convert.4, @impl.3(%.1) [template]
  47. // CHECK:STDOUT: %Convert.15: %Convert.type.15 = struct_value () [template]
  48. // CHECK:STDOUT: %.31: <witness> = interface_witness (%Convert.15) [template]
  49. // CHECK:STDOUT: %.32: <bound method> = bound_method %.30, %Convert.15 [template]
  50. // CHECK:STDOUT: %.33: <specific function> = specific_function %.32, @Convert.4(%.1) [template]
  51. // CHECK:STDOUT: %.34: Core.IntLiteral = int_value 1 [template]
  52. // CHECK:STDOUT: %.35: type = array_type %.34, %i32 [template]
  53. // CHECK:STDOUT: %.36: type = ptr_type %.35 [template]
  54. // CHECK:STDOUT: %RuntimeCall.type: type = fn_type @RuntimeCall [template]
  55. // CHECK:STDOUT: %RuntimeCall: %RuntimeCall.type = struct_value () [template]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: imports {
  59. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  60. // CHECK:STDOUT: .Int = %import_ref.1
  61. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  62. // CHECK:STDOUT: import Core//prelude
  63. // CHECK:STDOUT: import Core//prelude/...
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: file {
  68. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  69. // CHECK:STDOUT: .Core = imports.%Core
  70. // CHECK:STDOUT: .Sub = %Sub.decl
  71. // CHECK:STDOUT: .arr = %arr
  72. // CHECK:STDOUT: .arr_p = @__global_init.%arr_p
  73. // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: %Core.import = import Core
  76. // CHECK:STDOUT: %Sub.decl: %Sub.type = fn_decl @Sub [template = constants.%Sub] {
  77. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  78. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  79. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  80. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
  81. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  82. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param2
  83. // CHECK:STDOUT: } {
  84. // CHECK:STDOUT: %.loc2_11.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  85. // CHECK:STDOUT: %int.make_type_signed.loc2_11: init type = call constants.%Int(%.loc2_11.1) [template = constants.%i32]
  86. // CHECK:STDOUT: %.loc2_11.2: type = value_of_initializer %int.make_type_signed.loc2_11 [template = constants.%i32]
  87. // CHECK:STDOUT: %.loc2_11.3: type = converted %int.make_type_signed.loc2_11, %.loc2_11.2 [template = constants.%i32]
  88. // CHECK:STDOUT: %.loc2_19.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  89. // CHECK:STDOUT: %int.make_type_signed.loc2_19: init type = call constants.%Int(%.loc2_19.1) [template = constants.%i32]
  90. // CHECK:STDOUT: %.loc2_19.2: type = value_of_initializer %int.make_type_signed.loc2_19 [template = constants.%i32]
  91. // CHECK:STDOUT: %.loc2_19.3: type = converted %int.make_type_signed.loc2_19, %.loc2_19.2 [template = constants.%i32]
  92. // CHECK:STDOUT: %.loc2_27.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  93. // CHECK:STDOUT: %int.make_type_signed.loc2_27: init type = call constants.%Int(%.loc2_27.1) [template = constants.%i32]
  94. // CHECK:STDOUT: %.loc2_27.2: type = value_of_initializer %int.make_type_signed.loc2_27 [template = constants.%i32]
  95. // CHECK:STDOUT: %.loc2_27.3: type = converted %int.make_type_signed.loc2_27, %.loc2_27.2 [template = constants.%i32]
  96. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  97. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  98. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
  99. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  100. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param2
  101. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %.loc4_11.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  104. // CHECK:STDOUT: %int.make_type_signed.loc4: init type = call constants.%Int(%.loc4_11.1) [template = constants.%i32]
  105. // CHECK:STDOUT: %Sub.ref: %Sub.type = name_ref Sub, %Sub.decl [template = constants.%Sub]
  106. // CHECK:STDOUT: %.loc4_20.1: Core.IntLiteral = int_value 3 [template = constants.%.2]
  107. // CHECK:STDOUT: %.loc4_23.1: Core.IntLiteral = int_value 2 [template = constants.%.3]
  108. // CHECK:STDOUT: %.loc4_20.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  109. // CHECK:STDOUT: %.loc4_20.3: <bound method> = bound_method %.loc4_20.1, %.loc4_20.2 [template = constants.%.24]
  110. // CHECK:STDOUT: %.loc4_20.4: <specific function> = specific_function %.loc4_20.3, @Convert.2(constants.%.1) [template = constants.%.25]
  111. // CHECK:STDOUT: %int.convert_checked.loc4_20: init %i32 = call %.loc4_20.4(%.loc4_20.1) [template = constants.%.26]
  112. // CHECK:STDOUT: %.loc4_20.5: %i32 = value_of_initializer %int.convert_checked.loc4_20 [template = constants.%.26]
  113. // CHECK:STDOUT: %.loc4_20.6: %i32 = converted %.loc4_20.1, %.loc4_20.5 [template = constants.%.26]
  114. // CHECK:STDOUT: %.loc4_23.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  115. // CHECK:STDOUT: %.loc4_23.3: <bound method> = bound_method %.loc4_23.1, %.loc4_23.2 [template = constants.%.27]
  116. // CHECK:STDOUT: %.loc4_23.4: <specific function> = specific_function %.loc4_23.3, @Convert.2(constants.%.1) [template = constants.%.28]
  117. // CHECK:STDOUT: %int.convert_checked.loc4_23: init %i32 = call %.loc4_23.4(%.loc4_23.1) [template = constants.%.29]
  118. // CHECK:STDOUT: %.loc4_23.5: %i32 = value_of_initializer %int.convert_checked.loc4_23 [template = constants.%.29]
  119. // CHECK:STDOUT: %.loc4_23.6: %i32 = converted %.loc4_23.1, %.loc4_23.5 [template = constants.%.29]
  120. // CHECK:STDOUT: %int.usub: init %i32 = call %Sub.ref(%.loc4_20.6, %.loc4_23.6) [template = constants.%.30]
  121. // CHECK:STDOUT: %.loc4_11.2: type = value_of_initializer %int.make_type_signed.loc4 [template = constants.%i32]
  122. // CHECK:STDOUT: %.loc4_11.3: type = converted %int.make_type_signed.loc4, %.loc4_11.2 [template = constants.%i32]
  123. // CHECK:STDOUT: %.loc4_19.1: %Convert.type.6 = interface_witness_access constants.%.31, element0 [template = constants.%Convert.15]
  124. // CHECK:STDOUT: %.loc4_19.2: <bound method> = bound_method %int.usub, %.loc4_19.1 [template = constants.%.32]
  125. // CHECK:STDOUT: %.loc4_19.3: <specific function> = specific_function %.loc4_19.2, @Convert.4(constants.%.1) [template = constants.%.33]
  126. // CHECK:STDOUT: %.loc4_19.4: %i32 = value_of_initializer %int.usub [template = constants.%.30]
  127. // CHECK:STDOUT: %.loc4_19.5: %i32 = converted %int.usub, %.loc4_19.4 [template = constants.%.30]
  128. // CHECK:STDOUT: %int.convert_checked.loc4_19: init Core.IntLiteral = call %.loc4_19.3(%.loc4_19.5) [template = constants.%.34]
  129. // CHECK:STDOUT: %.loc4_19.6: Core.IntLiteral = value_of_initializer %int.convert_checked.loc4_19 [template = constants.%.34]
  130. // CHECK:STDOUT: %.loc4_19.7: Core.IntLiteral = converted %int.usub, %.loc4_19.6 [template = constants.%.34]
  131. // CHECK:STDOUT: %.loc4_25: type = array_type %.loc4_19.7, %i32 [template = constants.%.35]
  132. // CHECK:STDOUT: %arr.var: ref %.35 = var arr
  133. // CHECK:STDOUT: %arr: ref %.35 = bind_name arr, %arr.var
  134. // CHECK:STDOUT: %.loc5_13.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  135. // CHECK:STDOUT: %int.make_type_signed.loc5: init type = call constants.%Int(%.loc5_13.1) [template = constants.%i32]
  136. // CHECK:STDOUT: %.loc5_18: Core.IntLiteral = int_value 1 [template = constants.%.34]
  137. // CHECK:STDOUT: %.loc5_13.2: type = value_of_initializer %int.make_type_signed.loc5 [template = constants.%i32]
  138. // CHECK:STDOUT: %.loc5_13.3: type = converted %int.make_type_signed.loc5, %.loc5_13.2 [template = constants.%i32]
  139. // CHECK:STDOUT: %.loc5_19: type = array_type %.loc5_18, %i32 [template = constants.%.35]
  140. // CHECK:STDOUT: %.loc5_20: type = ptr_type %.35 [template = constants.%.36]
  141. // CHECK:STDOUT: %RuntimeCall.decl: %RuntimeCall.type = fn_decl @RuntimeCall [template = constants.%RuntimeCall] {
  142. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  143. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  144. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  145. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
  146. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  147. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param2
  148. // CHECK:STDOUT: } {
  149. // CHECK:STDOUT: %.loc7_19.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  150. // CHECK:STDOUT: %int.make_type_signed.loc7_19: init type = call constants.%Int(%.loc7_19.1) [template = constants.%i32]
  151. // CHECK:STDOUT: %.loc7_19.2: type = value_of_initializer %int.make_type_signed.loc7_19 [template = constants.%i32]
  152. // CHECK:STDOUT: %.loc7_19.3: type = converted %int.make_type_signed.loc7_19, %.loc7_19.2 [template = constants.%i32]
  153. // CHECK:STDOUT: %.loc7_27.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  154. // CHECK:STDOUT: %int.make_type_signed.loc7_27: init type = call constants.%Int(%.loc7_27.1) [template = constants.%i32]
  155. // CHECK:STDOUT: %.loc7_27.2: type = value_of_initializer %int.make_type_signed.loc7_27 [template = constants.%i32]
  156. // CHECK:STDOUT: %.loc7_27.3: type = converted %int.make_type_signed.loc7_27, %.loc7_27.2 [template = constants.%i32]
  157. // CHECK:STDOUT: %.loc7_35.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  158. // CHECK:STDOUT: %int.make_type_signed.loc7_35: init type = call constants.%Int(%.loc7_35.1) [template = constants.%i32]
  159. // CHECK:STDOUT: %.loc7_35.2: type = value_of_initializer %int.make_type_signed.loc7_35 [template = constants.%i32]
  160. // CHECK:STDOUT: %.loc7_35.3: type = converted %int.make_type_signed.loc7_35, %.loc7_35.2 [template = constants.%i32]
  161. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  162. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  163. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
  164. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  165. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param2
  166. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: fn @Sub(%a.param_patt: %i32, %b.param_patt: %i32) -> %i32 = "int.usub";
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: fn @RuntimeCall(%a.param_patt: %i32, %b.param_patt: %i32) -> %i32 {
  173. // CHECK:STDOUT: !entry:
  174. // CHECK:STDOUT: %Sub.ref: %Sub.type = name_ref Sub, file.%Sub.decl [template = constants.%Sub]
  175. // CHECK:STDOUT: %a.ref: %i32 = name_ref a, %a
  176. // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
  177. // CHECK:STDOUT: %int.usub: init %i32 = call %Sub.ref(%a.ref, %b.ref)
  178. // CHECK:STDOUT: %.loc8_19.1: %i32 = value_of_initializer %int.usub
  179. // CHECK:STDOUT: %.loc8_19.2: %i32 = converted %int.usub, %.loc8_19.1
  180. // CHECK:STDOUT: return %.loc8_19.2
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: fn @__global_init() {
  184. // CHECK:STDOUT: !entry:
  185. // CHECK:STDOUT: %arr.ref: ref %.35 = name_ref arr, file.%arr
  186. // CHECK:STDOUT: %.loc5: %.36 = addr_of %arr.ref
  187. // CHECK:STDOUT: %arr_p: %.36 = bind_name arr_p, %.loc5
  188. // CHECK:STDOUT: return
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: --- overflow.carbon
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: constants {
  194. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  195. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  196. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  197. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  198. // CHECK:STDOUT: %Sub.type: type = fn_type @Sub [template]
  199. // CHECK:STDOUT: %Sub: %Sub.type = struct_value () [template]
  200. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 0 [template]
  201. // CHECK:STDOUT: %.3: Core.IntLiteral = int_value 2147483647 [template]
  202. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  203. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.1) [template]
  204. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  205. // CHECK:STDOUT: %.23: <witness> = interface_witness (%Convert.14) [template]
  206. // CHECK:STDOUT: %.24: <bound method> = bound_method %.2, %Convert.14 [template]
  207. // CHECK:STDOUT: %.25: <specific function> = specific_function %.24, @Convert.2(%.1) [template]
  208. // CHECK:STDOUT: %.26: %i32 = int_value 0 [template]
  209. // CHECK:STDOUT: %.27: <bound method> = bound_method %.3, %Convert.14 [template]
  210. // CHECK:STDOUT: %.28: <specific function> = specific_function %.27, @Convert.2(%.1) [template]
  211. // CHECK:STDOUT: %.29: %i32 = int_value 2147483647 [template]
  212. // CHECK:STDOUT: %.30: %i32 = int_value -2147483647 [template]
  213. // CHECK:STDOUT: %.31: Core.IntLiteral = int_value 1 [template]
  214. // CHECK:STDOUT: %.32: <bound method> = bound_method %.31, %Convert.14 [template]
  215. // CHECK:STDOUT: %.33: <specific function> = specific_function %.32, @Convert.2(%.1) [template]
  216. // CHECK:STDOUT: %.34: %i32 = int_value 1 [template]
  217. // CHECK:STDOUT: %.35: %i32 = int_value -2147483648 [template]
  218. // CHECK:STDOUT: %.36: Core.IntLiteral = int_value 2 [template]
  219. // CHECK:STDOUT: %.37: <bound method> = bound_method %.36, %Convert.14 [template]
  220. // CHECK:STDOUT: %.38: <specific function> = specific_function %.37, @Convert.2(%.1) [template]
  221. // CHECK:STDOUT: %.39: %i32 = int_value 2 [template]
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: imports {
  225. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  226. // CHECK:STDOUT: .Int = %import_ref.1
  227. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  228. // CHECK:STDOUT: import Core//prelude
  229. // CHECK:STDOUT: import Core//prelude/...
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: file {
  234. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  235. // CHECK:STDOUT: .Core = imports.%Core
  236. // CHECK:STDOUT: .Sub = %Sub.decl
  237. // CHECK:STDOUT: .a = @__global_init.%a
  238. // CHECK:STDOUT: .b = @__global_init.%b
  239. // CHECK:STDOUT: .c = @__global_init.%c
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT: %Core.import = import Core
  242. // CHECK:STDOUT: %Sub.decl: %Sub.type = fn_decl @Sub [template = constants.%Sub] {
  243. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  244. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  245. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  246. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
  247. // CHECK:STDOUT: %return.patt: %i32 = return_slot_pattern
  248. // CHECK:STDOUT: %return.param_patt: %i32 = out_param_pattern %return.patt, runtime_param2
  249. // CHECK:STDOUT: } {
  250. // CHECK:STDOUT: %.loc4_11.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  251. // CHECK:STDOUT: %int.make_type_signed.loc4_11: init type = call constants.%Int(%.loc4_11.1) [template = constants.%i32]
  252. // CHECK:STDOUT: %.loc4_11.2: type = value_of_initializer %int.make_type_signed.loc4_11 [template = constants.%i32]
  253. // CHECK:STDOUT: %.loc4_11.3: type = converted %int.make_type_signed.loc4_11, %.loc4_11.2 [template = constants.%i32]
  254. // CHECK:STDOUT: %.loc4_19.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  255. // CHECK:STDOUT: %int.make_type_signed.loc4_19: init type = call constants.%Int(%.loc4_19.1) [template = constants.%i32]
  256. // CHECK:STDOUT: %.loc4_19.2: type = value_of_initializer %int.make_type_signed.loc4_19 [template = constants.%i32]
  257. // CHECK:STDOUT: %.loc4_19.3: type = converted %int.make_type_signed.loc4_19, %.loc4_19.2 [template = constants.%i32]
  258. // CHECK:STDOUT: %.loc4_27.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  259. // CHECK:STDOUT: %int.make_type_signed.loc4_27: init type = call constants.%Int(%.loc4_27.1) [template = constants.%i32]
  260. // CHECK:STDOUT: %.loc4_27.2: type = value_of_initializer %int.make_type_signed.loc4_27 [template = constants.%i32]
  261. // CHECK:STDOUT: %.loc4_27.3: type = converted %int.make_type_signed.loc4_27, %.loc4_27.2 [template = constants.%i32]
  262. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  263. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  264. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
  265. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  266. // CHECK:STDOUT: %return.param: ref %i32 = out_param runtime_param2
  267. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT: %.loc6_8.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  270. // CHECK:STDOUT: %int.make_type_signed.loc6: init type = call constants.%Int(%.loc6_8.1) [template = constants.%i32]
  271. // CHECK:STDOUT: %.loc6_8.2: type = value_of_initializer %int.make_type_signed.loc6 [template = constants.%i32]
  272. // CHECK:STDOUT: %.loc6_8.3: type = converted %int.make_type_signed.loc6, %.loc6_8.2 [template = constants.%i32]
  273. // CHECK:STDOUT: %.loc7_8.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  274. // CHECK:STDOUT: %int.make_type_signed.loc7: init type = call constants.%Int(%.loc7_8.1) [template = constants.%i32]
  275. // CHECK:STDOUT: %.loc7_8.2: type = value_of_initializer %int.make_type_signed.loc7 [template = constants.%i32]
  276. // CHECK:STDOUT: %.loc7_8.3: type = converted %int.make_type_signed.loc7, %.loc7_8.2 [template = constants.%i32]
  277. // CHECK:STDOUT: %.loc8_8.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  278. // CHECK:STDOUT: %int.make_type_signed.loc8: init type = call constants.%Int(%.loc8_8.1) [template = constants.%i32]
  279. // CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %int.make_type_signed.loc8 [template = constants.%i32]
  280. // CHECK:STDOUT: %.loc8_8.3: type = converted %int.make_type_signed.loc8, %.loc8_8.2 [template = constants.%i32]
  281. // CHECK:STDOUT: }
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: fn @Sub(%a.param_patt: %i32, %b.param_patt: %i32) -> %i32 = "int.usub";
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: fn @__global_init() {
  286. // CHECK:STDOUT: !entry:
  287. // CHECK:STDOUT: %Sub.ref.loc6: %Sub.type = name_ref Sub, file.%Sub.decl [template = constants.%Sub]
  288. // CHECK:STDOUT: %.loc6_18.1: Core.IntLiteral = int_value 0 [template = constants.%.2]
  289. // CHECK:STDOUT: %.loc6_21.1: Core.IntLiteral = int_value 2147483647 [template = constants.%.3]
  290. // CHECK:STDOUT: %.loc6_18.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  291. // CHECK:STDOUT: %.loc6_18.3: <bound method> = bound_method %.loc6_18.1, %.loc6_18.2 [template = constants.%.24]
  292. // CHECK:STDOUT: %.loc6_18.4: <specific function> = specific_function %.loc6_18.3, @Convert.2(constants.%.1) [template = constants.%.25]
  293. // CHECK:STDOUT: %int.convert_checked.loc6_18: init %i32 = call %.loc6_18.4(%.loc6_18.1) [template = constants.%.26]
  294. // CHECK:STDOUT: %.loc6_18.5: %i32 = value_of_initializer %int.convert_checked.loc6_18 [template = constants.%.26]
  295. // CHECK:STDOUT: %.loc6_18.6: %i32 = converted %.loc6_18.1, %.loc6_18.5 [template = constants.%.26]
  296. // CHECK:STDOUT: %.loc6_21.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  297. // CHECK:STDOUT: %.loc6_21.3: <bound method> = bound_method %.loc6_21.1, %.loc6_21.2 [template = constants.%.27]
  298. // CHECK:STDOUT: %.loc6_21.4: <specific function> = specific_function %.loc6_21.3, @Convert.2(constants.%.1) [template = constants.%.28]
  299. // CHECK:STDOUT: %int.convert_checked.loc6_21: init %i32 = call %.loc6_21.4(%.loc6_21.1) [template = constants.%.29]
  300. // CHECK:STDOUT: %.loc6_21.5: %i32 = value_of_initializer %int.convert_checked.loc6_21 [template = constants.%.29]
  301. // CHECK:STDOUT: %.loc6_21.6: %i32 = converted %.loc6_21.1, %.loc6_21.5 [template = constants.%.29]
  302. // CHECK:STDOUT: %int.usub.loc6: init %i32 = call %Sub.ref.loc6(%.loc6_18.6, %.loc6_21.6) [template = constants.%.30]
  303. // CHECK:STDOUT: %.loc6_32.1: %i32 = value_of_initializer %int.usub.loc6 [template = constants.%.30]
  304. // CHECK:STDOUT: %.loc6_32.2: %i32 = converted %int.usub.loc6, %.loc6_32.1 [template = constants.%.30]
  305. // CHECK:STDOUT: %a: %i32 = bind_name a, %.loc6_32.2
  306. // CHECK:STDOUT: %Sub.ref.loc7_14: %Sub.type = name_ref Sub, file.%Sub.decl [template = constants.%Sub]
  307. // CHECK:STDOUT: %Sub.ref.loc7_18: %Sub.type = name_ref Sub, file.%Sub.decl [template = constants.%Sub]
  308. // CHECK:STDOUT: %.loc7_22.1: Core.IntLiteral = int_value 0 [template = constants.%.2]
  309. // CHECK:STDOUT: %.loc7_25.1: Core.IntLiteral = int_value 2147483647 [template = constants.%.3]
  310. // CHECK:STDOUT: %.loc7_22.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  311. // CHECK:STDOUT: %.loc7_22.3: <bound method> = bound_method %.loc7_22.1, %.loc7_22.2 [template = constants.%.24]
  312. // CHECK:STDOUT: %.loc7_22.4: <specific function> = specific_function %.loc7_22.3, @Convert.2(constants.%.1) [template = constants.%.25]
  313. // CHECK:STDOUT: %int.convert_checked.loc7_22: init %i32 = call %.loc7_22.4(%.loc7_22.1) [template = constants.%.26]
  314. // CHECK:STDOUT: %.loc7_22.5: %i32 = value_of_initializer %int.convert_checked.loc7_22 [template = constants.%.26]
  315. // CHECK:STDOUT: %.loc7_22.6: %i32 = converted %.loc7_22.1, %.loc7_22.5 [template = constants.%.26]
  316. // CHECK:STDOUT: %.loc7_25.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  317. // CHECK:STDOUT: %.loc7_25.3: <bound method> = bound_method %.loc7_25.1, %.loc7_25.2 [template = constants.%.27]
  318. // CHECK:STDOUT: %.loc7_25.4: <specific function> = specific_function %.loc7_25.3, @Convert.2(constants.%.1) [template = constants.%.28]
  319. // CHECK:STDOUT: %int.convert_checked.loc7_25: init %i32 = call %.loc7_25.4(%.loc7_25.1) [template = constants.%.29]
  320. // CHECK:STDOUT: %.loc7_25.5: %i32 = value_of_initializer %int.convert_checked.loc7_25 [template = constants.%.29]
  321. // CHECK:STDOUT: %.loc7_25.6: %i32 = converted %.loc7_25.1, %.loc7_25.5 [template = constants.%.29]
  322. // CHECK:STDOUT: %int.usub.loc7_21: init %i32 = call %Sub.ref.loc7_18(%.loc7_22.6, %.loc7_25.6) [template = constants.%.30]
  323. // CHECK:STDOUT: %.loc7_38.1: Core.IntLiteral = int_value 1 [template = constants.%.31]
  324. // CHECK:STDOUT: %.loc7_21.1: %i32 = value_of_initializer %int.usub.loc7_21 [template = constants.%.30]
  325. // CHECK:STDOUT: %.loc7_21.2: %i32 = converted %int.usub.loc7_21, %.loc7_21.1 [template = constants.%.30]
  326. // CHECK:STDOUT: %.loc7_38.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  327. // CHECK:STDOUT: %.loc7_38.3: <bound method> = bound_method %.loc7_38.1, %.loc7_38.2 [template = constants.%.32]
  328. // CHECK:STDOUT: %.loc7_38.4: <specific function> = specific_function %.loc7_38.3, @Convert.2(constants.%.1) [template = constants.%.33]
  329. // CHECK:STDOUT: %int.convert_checked.loc7_38: init %i32 = call %.loc7_38.4(%.loc7_38.1) [template = constants.%.34]
  330. // CHECK:STDOUT: %.loc7_38.5: %i32 = value_of_initializer %int.convert_checked.loc7_38 [template = constants.%.34]
  331. // CHECK:STDOUT: %.loc7_38.6: %i32 = converted %.loc7_38.1, %.loc7_38.5 [template = constants.%.34]
  332. // CHECK:STDOUT: %int.usub.loc7_17: init %i32 = call %Sub.ref.loc7_14(%.loc7_21.2, %.loc7_38.6) [template = constants.%.35]
  333. // CHECK:STDOUT: %.loc7_40.1: %i32 = value_of_initializer %int.usub.loc7_17 [template = constants.%.35]
  334. // CHECK:STDOUT: %.loc7_40.2: %i32 = converted %int.usub.loc7_17, %.loc7_40.1 [template = constants.%.35]
  335. // CHECK:STDOUT: %b: %i32 = bind_name b, %.loc7_40.2
  336. // CHECK:STDOUT: %Sub.ref.loc8_14: %Sub.type = name_ref Sub, file.%Sub.decl [template = constants.%Sub]
  337. // CHECK:STDOUT: %Sub.ref.loc8_18: %Sub.type = name_ref Sub, file.%Sub.decl [template = constants.%Sub]
  338. // CHECK:STDOUT: %.loc8_22.1: Core.IntLiteral = int_value 0 [template = constants.%.2]
  339. // CHECK:STDOUT: %.loc8_25.1: Core.IntLiteral = int_value 2147483647 [template = constants.%.3]
  340. // CHECK:STDOUT: %.loc8_22.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  341. // CHECK:STDOUT: %.loc8_22.3: <bound method> = bound_method %.loc8_22.1, %.loc8_22.2 [template = constants.%.24]
  342. // CHECK:STDOUT: %.loc8_22.4: <specific function> = specific_function %.loc8_22.3, @Convert.2(constants.%.1) [template = constants.%.25]
  343. // CHECK:STDOUT: %int.convert_checked.loc8_22: init %i32 = call %.loc8_22.4(%.loc8_22.1) [template = constants.%.26]
  344. // CHECK:STDOUT: %.loc8_22.5: %i32 = value_of_initializer %int.convert_checked.loc8_22 [template = constants.%.26]
  345. // CHECK:STDOUT: %.loc8_22.6: %i32 = converted %.loc8_22.1, %.loc8_22.5 [template = constants.%.26]
  346. // CHECK:STDOUT: %.loc8_25.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  347. // CHECK:STDOUT: %.loc8_25.3: <bound method> = bound_method %.loc8_25.1, %.loc8_25.2 [template = constants.%.27]
  348. // CHECK:STDOUT: %.loc8_25.4: <specific function> = specific_function %.loc8_25.3, @Convert.2(constants.%.1) [template = constants.%.28]
  349. // CHECK:STDOUT: %int.convert_checked.loc8_25: init %i32 = call %.loc8_25.4(%.loc8_25.1) [template = constants.%.29]
  350. // CHECK:STDOUT: %.loc8_25.5: %i32 = value_of_initializer %int.convert_checked.loc8_25 [template = constants.%.29]
  351. // CHECK:STDOUT: %.loc8_25.6: %i32 = converted %.loc8_25.1, %.loc8_25.5 [template = constants.%.29]
  352. // CHECK:STDOUT: %int.usub.loc8_21: init %i32 = call %Sub.ref.loc8_18(%.loc8_22.6, %.loc8_25.6) [template = constants.%.30]
  353. // CHECK:STDOUT: %.loc8_38.1: Core.IntLiteral = int_value 2 [template = constants.%.36]
  354. // CHECK:STDOUT: %.loc8_21.1: %i32 = value_of_initializer %int.usub.loc8_21 [template = constants.%.30]
  355. // CHECK:STDOUT: %.loc8_21.2: %i32 = converted %int.usub.loc8_21, %.loc8_21.1 [template = constants.%.30]
  356. // CHECK:STDOUT: %.loc8_38.2: %Convert.type.2 = interface_witness_access constants.%.23, element0 [template = constants.%Convert.14]
  357. // CHECK:STDOUT: %.loc8_38.3: <bound method> = bound_method %.loc8_38.1, %.loc8_38.2 [template = constants.%.37]
  358. // CHECK:STDOUT: %.loc8_38.4: <specific function> = specific_function %.loc8_38.3, @Convert.2(constants.%.1) [template = constants.%.38]
  359. // CHECK:STDOUT: %int.convert_checked.loc8_38: init %i32 = call %.loc8_38.4(%.loc8_38.1) [template = constants.%.39]
  360. // CHECK:STDOUT: %.loc8_38.5: %i32 = value_of_initializer %int.convert_checked.loc8_38 [template = constants.%.39]
  361. // CHECK:STDOUT: %.loc8_38.6: %i32 = converted %.loc8_38.1, %.loc8_38.5 [template = constants.%.39]
  362. // CHECK:STDOUT: %int.usub.loc8_17: init %i32 = call %Sub.ref.loc8_14(%.loc8_21.2, %.loc8_38.6) [template = constants.%.29]
  363. // CHECK:STDOUT: %.loc8_40.1: %i32 = value_of_initializer %int.usub.loc8_17 [template = constants.%.29]
  364. // CHECK:STDOUT: %.loc8_40.2: %i32 = converted %int.usub.loc8_17, %.loc8_40.1 [template = constants.%.29]
  365. // CHECK:STDOUT: %c: %i32 = bind_name c, %.loc8_40.2
  366. // CHECK:STDOUT: return
  367. // CHECK:STDOUT: }
  368. // CHECK:STDOUT: