sub.carbon 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. // --- float_sub.carbon
  7. fn Sub(a: f64, b: f64) -> f64 = "float.sub";
  8. fn RuntimeCall(a: f64, b: f64) -> f64 {
  9. return Sub(a, b);
  10. }
  11. var x: f64 = Sub(2.0, 0.5);
  12. // --- fail_bad_decl.carbon
  13. package FailBadDecl;
  14. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.sub".
  15. // CHECK:STDERR: fn TooFew(a: f64) -> f64 = "float.sub";
  16. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
  17. // CHECK:STDERR:
  18. fn TooFew(a: f64) -> f64 = "float.sub";
  19. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.sub".
  20. // CHECK:STDERR: fn TooMany(a: f64, b: f64, c: f64) -> f64 = "float.sub";
  21. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22. // CHECK:STDERR:
  23. fn TooMany(a: f64, b: f64, c: f64) -> f64 = "float.sub";
  24. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+3]]:1: ERROR: Invalid signature for builtin function "float.sub".
  25. // CHECK:STDERR: fn BadReturnType(a: f64, b: f64) -> bool = "float.sub";
  26. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  27. fn BadReturnType(a: f64, b: f64) -> bool = "float.sub";
  28. fn JustRight(a: f64, b: f64) -> f64 = "float.sub";
  29. fn RuntimeCallTooFew(a: f64) -> f64 {
  30. return TooFew(a);
  31. }
  32. fn RuntimeCallTooMany(a: f64, b: f64, c: f64) -> f64 {
  33. return TooMany(a, b, c);
  34. }
  35. fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool {
  36. return BadReturnType(a, b);
  37. }
  38. // CHECK:STDOUT: --- float_sub.carbon
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: constants {
  41. // CHECK:STDOUT: %.1: i32 = int_literal 64 [template]
  42. // CHECK:STDOUT: %Float: type = fn_type @Float [template]
  43. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  44. // CHECK:STDOUT: %struct.1: Float = struct_value () [template]
  45. // CHECK:STDOUT: %Sub: type = fn_type @Sub [template]
  46. // CHECK:STDOUT: %struct.2: Sub = struct_value () [template]
  47. // CHECK:STDOUT: %RuntimeCall: type = fn_type @RuntimeCall [template]
  48. // CHECK:STDOUT: %struct.3: RuntimeCall = struct_value () [template]
  49. // CHECK:STDOUT: %.3: f64 = float_literal 2 [template]
  50. // CHECK:STDOUT: %.4: f64 = float_literal 0.5 [template]
  51. // CHECK:STDOUT: %.5: f64 = float_literal 1.5 [template]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: file {
  55. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  56. // CHECK:STDOUT: .Core = %Core
  57. // CHECK:STDOUT: .Sub = %Sub.decl
  58. // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl
  59. // CHECK:STDOUT: .x = %x
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  62. // CHECK:STDOUT: %import_ref.1: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  63. // CHECK:STDOUT: %import_ref.2: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  64. // CHECK:STDOUT: %import_ref.3: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  65. // CHECK:STDOUT: %Sub.decl: Sub = fn_decl @Sub [template = constants.%struct.2] {
  66. // CHECK:STDOUT: %.loc2_11.1: i32 = int_literal 64 [template = constants.%.1]
  67. // CHECK:STDOUT: %float.make_type.loc2_11: init type = call constants.%struct.1(%.loc2_11.1) [template = f64]
  68. // CHECK:STDOUT: %.loc2_11.2: type = value_of_initializer %float.make_type.loc2_11 [template = f64]
  69. // CHECK:STDOUT: %.loc2_11.3: type = converted %float.make_type.loc2_11, %.loc2_11.2 [template = f64]
  70. // CHECK:STDOUT: %a.loc2_8.1: f64 = param a
  71. // CHECK:STDOUT: @Sub.%a: f64 = bind_name a, %a.loc2_8.1
  72. // CHECK:STDOUT: %.loc2_19.1: i32 = int_literal 64 [template = constants.%.1]
  73. // CHECK:STDOUT: %float.make_type.loc2_19: init type = call constants.%struct.1(%.loc2_19.1) [template = f64]
  74. // CHECK:STDOUT: %.loc2_19.2: type = value_of_initializer %float.make_type.loc2_19 [template = f64]
  75. // CHECK:STDOUT: %.loc2_19.3: type = converted %float.make_type.loc2_19, %.loc2_19.2 [template = f64]
  76. // CHECK:STDOUT: %b.loc2_16.1: f64 = param b
  77. // CHECK:STDOUT: @Sub.%b: f64 = bind_name b, %b.loc2_16.1
  78. // CHECK:STDOUT: %.loc2_27.1: i32 = int_literal 64 [template = constants.%.1]
  79. // CHECK:STDOUT: %float.make_type.loc2_27: init type = call constants.%struct.1(%.loc2_27.1) [template = f64]
  80. // CHECK:STDOUT: %.loc2_27.2: type = value_of_initializer %float.make_type.loc2_27 [template = f64]
  81. // CHECK:STDOUT: %.loc2_27.3: type = converted %float.make_type.loc2_27, %.loc2_27.2 [template = f64]
  82. // CHECK:STDOUT: @Sub.%return: ref f64 = var <return slot>
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: %import_ref.4: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  85. // CHECK:STDOUT: %import_ref.5: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  86. // CHECK:STDOUT: %import_ref.6: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  87. // CHECK:STDOUT: %RuntimeCall.decl: RuntimeCall = fn_decl @RuntimeCall [template = constants.%struct.3] {
  88. // CHECK:STDOUT: %.loc4_19.1: i32 = int_literal 64 [template = constants.%.1]
  89. // CHECK:STDOUT: %float.make_type.loc4_19: init type = call constants.%struct.1(%.loc4_19.1) [template = f64]
  90. // CHECK:STDOUT: %.loc4_19.2: type = value_of_initializer %float.make_type.loc4_19 [template = f64]
  91. // CHECK:STDOUT: %.loc4_19.3: type = converted %float.make_type.loc4_19, %.loc4_19.2 [template = f64]
  92. // CHECK:STDOUT: %a.loc4_16.1: f64 = param a
  93. // CHECK:STDOUT: @RuntimeCall.%a: f64 = bind_name a, %a.loc4_16.1
  94. // CHECK:STDOUT: %.loc4_27.1: i32 = int_literal 64 [template = constants.%.1]
  95. // CHECK:STDOUT: %float.make_type.loc4_27: init type = call constants.%struct.1(%.loc4_27.1) [template = f64]
  96. // CHECK:STDOUT: %.loc4_27.2: type = value_of_initializer %float.make_type.loc4_27 [template = f64]
  97. // CHECK:STDOUT: %.loc4_27.3: type = converted %float.make_type.loc4_27, %.loc4_27.2 [template = f64]
  98. // CHECK:STDOUT: %b.loc4_24.1: f64 = param b
  99. // CHECK:STDOUT: @RuntimeCall.%b: f64 = bind_name b, %b.loc4_24.1
  100. // CHECK:STDOUT: %.loc4_35.1: i32 = int_literal 64 [template = constants.%.1]
  101. // CHECK:STDOUT: %float.make_type.loc4_35: init type = call constants.%struct.1(%.loc4_35.1) [template = f64]
  102. // CHECK:STDOUT: %.loc4_35.2: type = value_of_initializer %float.make_type.loc4_35 [template = f64]
  103. // CHECK:STDOUT: %.loc4_35.3: type = converted %float.make_type.loc4_35, %.loc4_35.2 [template = f64]
  104. // CHECK:STDOUT: @RuntimeCall.%return: ref f64 = var <return slot>
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: %.loc8_8.1: i32 = int_literal 64 [template = constants.%.1]
  107. // CHECK:STDOUT: %import_ref.7: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  108. // CHECK:STDOUT: %float.make_type.loc8: init type = call constants.%struct.1(%.loc8_8.1) [template = f64]
  109. // CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %float.make_type.loc8 [template = f64]
  110. // CHECK:STDOUT: %.loc8_8.3: type = converted %float.make_type.loc8, %.loc8_8.2 [template = f64]
  111. // CHECK:STDOUT: %x.var: ref f64 = var x
  112. // CHECK:STDOUT: %x: ref f64 = bind_name x, %x.var
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: fn @Float(%size: i32) -> type = "float.make_type";
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: fn @Sub(%a: f64, %b: f64) -> f64 = "float.sub";
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: fn @RuntimeCall(%a: f64, %b: f64) -> f64 {
  120. // CHECK:STDOUT: !entry:
  121. // CHECK:STDOUT: %Sub.ref: Sub = name_ref Sub, file.%Sub.decl [template = constants.%struct.2]
  122. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  123. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  124. // CHECK:STDOUT: %float.sub: init f64 = call %Sub.ref(%a.ref, %b.ref)
  125. // CHECK:STDOUT: %.loc5_19.1: f64 = value_of_initializer %float.sub
  126. // CHECK:STDOUT: %.loc5_19.2: f64 = converted %float.sub, %.loc5_19.1
  127. // CHECK:STDOUT: return %.loc5_19.2
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: fn @__global_init() {
  131. // CHECK:STDOUT: !entry:
  132. // CHECK:STDOUT: %Sub.ref: Sub = name_ref Sub, file.%Sub.decl [template = constants.%struct.2]
  133. // CHECK:STDOUT: %.loc8_18: f64 = float_literal 2 [template = constants.%.3]
  134. // CHECK:STDOUT: %.loc8_23: f64 = float_literal 0.5 [template = constants.%.4]
  135. // CHECK:STDOUT: %float.sub: init f64 = call %Sub.ref(%.loc8_18, %.loc8_23) [template = constants.%.5]
  136. // CHECK:STDOUT: assign file.%x.var, %float.sub
  137. // CHECK:STDOUT: return
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: --- fail_bad_decl.carbon
  141. // CHECK:STDOUT:
  142. // CHECK:STDOUT: constants {
  143. // CHECK:STDOUT: %.1: i32 = int_literal 64 [template]
  144. // CHECK:STDOUT: %Float: type = fn_type @Float [template]
  145. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  146. // CHECK:STDOUT: %struct.1: Float = struct_value () [template]
  147. // CHECK:STDOUT: %TooFew: type = fn_type @TooFew [template]
  148. // CHECK:STDOUT: %struct.2: TooFew = struct_value () [template]
  149. // CHECK:STDOUT: %TooMany: type = fn_type @TooMany [template]
  150. // CHECK:STDOUT: %struct.3: TooMany = struct_value () [template]
  151. // CHECK:STDOUT: %Bool: type = fn_type @Bool [template]
  152. // CHECK:STDOUT: %struct.4: Bool = struct_value () [template]
  153. // CHECK:STDOUT: %BadReturnType: type = fn_type @BadReturnType [template]
  154. // CHECK:STDOUT: %struct.5: BadReturnType = struct_value () [template]
  155. // CHECK:STDOUT: %JustRight: type = fn_type @JustRight [template]
  156. // CHECK:STDOUT: %struct.6: JustRight = struct_value () [template]
  157. // CHECK:STDOUT: %RuntimeCallTooFew: type = fn_type @RuntimeCallTooFew [template]
  158. // CHECK:STDOUT: %struct.7: RuntimeCallTooFew = struct_value () [template]
  159. // CHECK:STDOUT: %RuntimeCallTooMany: type = fn_type @RuntimeCallTooMany [template]
  160. // CHECK:STDOUT: %struct.8: RuntimeCallTooMany = struct_value () [template]
  161. // CHECK:STDOUT: %RuntimeCallBadReturnType: type = fn_type @RuntimeCallBadReturnType [template]
  162. // CHECK:STDOUT: %struct.9: RuntimeCallBadReturnType = struct_value () [template]
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: file {
  166. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  167. // CHECK:STDOUT: .Core = %Core
  168. // CHECK:STDOUT: .TooFew = %TooFew.decl
  169. // CHECK:STDOUT: .TooMany = %TooMany.decl
  170. // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl
  171. // CHECK:STDOUT: .JustRight = %JustRight.decl
  172. // CHECK:STDOUT: .RuntimeCallTooFew = %RuntimeCallTooFew.decl
  173. // CHECK:STDOUT: .RuntimeCallTooMany = %RuntimeCallTooMany.decl
  174. // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  177. // CHECK:STDOUT: %import_ref.1: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  178. // CHECK:STDOUT: %import_ref.2: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  179. // CHECK:STDOUT: %TooFew.decl: TooFew = fn_decl @TooFew [template = constants.%struct.2] {
  180. // CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 64 [template = constants.%.1]
  181. // CHECK:STDOUT: %float.make_type.loc8_14: init type = call constants.%struct.1(%.loc8_14.1) [template = f64]
  182. // CHECK:STDOUT: %.loc8_14.2: type = value_of_initializer %float.make_type.loc8_14 [template = f64]
  183. // CHECK:STDOUT: %.loc8_14.3: type = converted %float.make_type.loc8_14, %.loc8_14.2 [template = f64]
  184. // CHECK:STDOUT: %a.loc8_11.1: f64 = param a
  185. // CHECK:STDOUT: @TooFew.%a: f64 = bind_name a, %a.loc8_11.1
  186. // CHECK:STDOUT: %.loc8_22.1: i32 = int_literal 64 [template = constants.%.1]
  187. // CHECK:STDOUT: %float.make_type.loc8_22: init type = call constants.%struct.1(%.loc8_22.1) [template = f64]
  188. // CHECK:STDOUT: %.loc8_22.2: type = value_of_initializer %float.make_type.loc8_22 [template = f64]
  189. // CHECK:STDOUT: %.loc8_22.3: type = converted %float.make_type.loc8_22, %.loc8_22.2 [template = f64]
  190. // CHECK:STDOUT: @TooFew.%return: ref f64 = var <return slot>
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT: %import_ref.3: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  193. // CHECK:STDOUT: %import_ref.4: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  194. // CHECK:STDOUT: %import_ref.5: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  195. // CHECK:STDOUT: %import_ref.6: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  196. // CHECK:STDOUT: %TooMany.decl: TooMany = fn_decl @TooMany [template = constants.%struct.3] {
  197. // CHECK:STDOUT: %.loc13_15.1: i32 = int_literal 64 [template = constants.%.1]
  198. // CHECK:STDOUT: %float.make_type.loc13_15: init type = call constants.%struct.1(%.loc13_15.1) [template = f64]
  199. // CHECK:STDOUT: %.loc13_15.2: type = value_of_initializer %float.make_type.loc13_15 [template = f64]
  200. // CHECK:STDOUT: %.loc13_15.3: type = converted %float.make_type.loc13_15, %.loc13_15.2 [template = f64]
  201. // CHECK:STDOUT: %a.loc13_12.1: f64 = param a
  202. // CHECK:STDOUT: @TooMany.%a: f64 = bind_name a, %a.loc13_12.1
  203. // CHECK:STDOUT: %.loc13_23.1: i32 = int_literal 64 [template = constants.%.1]
  204. // CHECK:STDOUT: %float.make_type.loc13_23: init type = call constants.%struct.1(%.loc13_23.1) [template = f64]
  205. // CHECK:STDOUT: %.loc13_23.2: type = value_of_initializer %float.make_type.loc13_23 [template = f64]
  206. // CHECK:STDOUT: %.loc13_23.3: type = converted %float.make_type.loc13_23, %.loc13_23.2 [template = f64]
  207. // CHECK:STDOUT: %b.loc13_20.1: f64 = param b
  208. // CHECK:STDOUT: @TooMany.%b: f64 = bind_name b, %b.loc13_20.1
  209. // CHECK:STDOUT: %.loc13_31.1: i32 = int_literal 64 [template = constants.%.1]
  210. // CHECK:STDOUT: %float.make_type.loc13_31: init type = call constants.%struct.1(%.loc13_31.1) [template = f64]
  211. // CHECK:STDOUT: %.loc13_31.2: type = value_of_initializer %float.make_type.loc13_31 [template = f64]
  212. // CHECK:STDOUT: %.loc13_31.3: type = converted %float.make_type.loc13_31, %.loc13_31.2 [template = f64]
  213. // CHECK:STDOUT: %c.loc13_28.1: f64 = param c
  214. // CHECK:STDOUT: @TooMany.%c: f64 = bind_name c, %c.loc13_28.1
  215. // CHECK:STDOUT: %.loc13_39.1: i32 = int_literal 64 [template = constants.%.1]
  216. // CHECK:STDOUT: %float.make_type.loc13_39: init type = call constants.%struct.1(%.loc13_39.1) [template = f64]
  217. // CHECK:STDOUT: %.loc13_39.2: type = value_of_initializer %float.make_type.loc13_39 [template = f64]
  218. // CHECK:STDOUT: %.loc13_39.3: type = converted %float.make_type.loc13_39, %.loc13_39.2 [template = f64]
  219. // CHECK:STDOUT: @TooMany.%return: ref f64 = var <return slot>
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT: %import_ref.7: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  222. // CHECK:STDOUT: %import_ref.8: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  223. // CHECK:STDOUT: %import_ref.9: Bool = import_ref ir7, inst+2, loaded [template = constants.%struct.4]
  224. // CHECK:STDOUT: %BadReturnType.decl: BadReturnType = fn_decl @BadReturnType [template = constants.%struct.5] {
  225. // CHECK:STDOUT: %.loc17_21.1: i32 = int_literal 64 [template = constants.%.1]
  226. // CHECK:STDOUT: %float.make_type.loc17_21: init type = call constants.%struct.1(%.loc17_21.1) [template = f64]
  227. // CHECK:STDOUT: %.loc17_21.2: type = value_of_initializer %float.make_type.loc17_21 [template = f64]
  228. // CHECK:STDOUT: %.loc17_21.3: type = converted %float.make_type.loc17_21, %.loc17_21.2 [template = f64]
  229. // CHECK:STDOUT: %a.loc17_18.1: f64 = param a
  230. // CHECK:STDOUT: @BadReturnType.%a: f64 = bind_name a, %a.loc17_18.1
  231. // CHECK:STDOUT: %.loc17_29.1: i32 = int_literal 64 [template = constants.%.1]
  232. // CHECK:STDOUT: %float.make_type.loc17_29: init type = call constants.%struct.1(%.loc17_29.1) [template = f64]
  233. // CHECK:STDOUT: %.loc17_29.2: type = value_of_initializer %float.make_type.loc17_29 [template = f64]
  234. // CHECK:STDOUT: %.loc17_29.3: type = converted %float.make_type.loc17_29, %.loc17_29.2 [template = f64]
  235. // CHECK:STDOUT: %b.loc17_26.1: f64 = param b
  236. // CHECK:STDOUT: @BadReturnType.%b: f64 = bind_name b, %b.loc17_26.1
  237. // CHECK:STDOUT: %bool.make_type.loc17: init type = call constants.%struct.4() [template = bool]
  238. // CHECK:STDOUT: %.loc17_37.1: type = value_of_initializer %bool.make_type.loc17 [template = bool]
  239. // CHECK:STDOUT: %.loc17_37.2: type = converted %bool.make_type.loc17, %.loc17_37.1 [template = bool]
  240. // CHECK:STDOUT: @BadReturnType.%return: ref bool = var <return slot>
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT: %import_ref.10: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  243. // CHECK:STDOUT: %import_ref.11: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  244. // CHECK:STDOUT: %import_ref.12: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  245. // CHECK:STDOUT: %JustRight.decl: JustRight = fn_decl @JustRight [template = constants.%struct.6] {
  246. // CHECK:STDOUT: %.loc18_17.1: i32 = int_literal 64 [template = constants.%.1]
  247. // CHECK:STDOUT: %float.make_type.loc18_17: init type = call constants.%struct.1(%.loc18_17.1) [template = f64]
  248. // CHECK:STDOUT: %.loc18_17.2: type = value_of_initializer %float.make_type.loc18_17 [template = f64]
  249. // CHECK:STDOUT: %.loc18_17.3: type = converted %float.make_type.loc18_17, %.loc18_17.2 [template = f64]
  250. // CHECK:STDOUT: %a.loc18_14.1: f64 = param a
  251. // CHECK:STDOUT: @JustRight.%a: f64 = bind_name a, %a.loc18_14.1
  252. // CHECK:STDOUT: %.loc18_25.1: i32 = int_literal 64 [template = constants.%.1]
  253. // CHECK:STDOUT: %float.make_type.loc18_25: init type = call constants.%struct.1(%.loc18_25.1) [template = f64]
  254. // CHECK:STDOUT: %.loc18_25.2: type = value_of_initializer %float.make_type.loc18_25 [template = f64]
  255. // CHECK:STDOUT: %.loc18_25.3: type = converted %float.make_type.loc18_25, %.loc18_25.2 [template = f64]
  256. // CHECK:STDOUT: %b.loc18_22.1: f64 = param b
  257. // CHECK:STDOUT: @JustRight.%b: f64 = bind_name b, %b.loc18_22.1
  258. // CHECK:STDOUT: %.loc18_33.1: i32 = int_literal 64 [template = constants.%.1]
  259. // CHECK:STDOUT: %float.make_type.loc18_33: init type = call constants.%struct.1(%.loc18_33.1) [template = f64]
  260. // CHECK:STDOUT: %.loc18_33.2: type = value_of_initializer %float.make_type.loc18_33 [template = f64]
  261. // CHECK:STDOUT: %.loc18_33.3: type = converted %float.make_type.loc18_33, %.loc18_33.2 [template = f64]
  262. // CHECK:STDOUT: @JustRight.%return: ref f64 = var <return slot>
  263. // CHECK:STDOUT: }
  264. // CHECK:STDOUT: %import_ref.13: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  265. // CHECK:STDOUT: %import_ref.14: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  266. // CHECK:STDOUT: %RuntimeCallTooFew.decl: RuntimeCallTooFew = fn_decl @RuntimeCallTooFew [template = constants.%struct.7] {
  267. // CHECK:STDOUT: %.loc20_25.1: i32 = int_literal 64 [template = constants.%.1]
  268. // CHECK:STDOUT: %float.make_type.loc20_25: init type = call constants.%struct.1(%.loc20_25.1) [template = f64]
  269. // CHECK:STDOUT: %.loc20_25.2: type = value_of_initializer %float.make_type.loc20_25 [template = f64]
  270. // CHECK:STDOUT: %.loc20_25.3: type = converted %float.make_type.loc20_25, %.loc20_25.2 [template = f64]
  271. // CHECK:STDOUT: %a.loc20_22.1: f64 = param a
  272. // CHECK:STDOUT: @RuntimeCallTooFew.%a: f64 = bind_name a, %a.loc20_22.1
  273. // CHECK:STDOUT: %.loc20_33.1: i32 = int_literal 64 [template = constants.%.1]
  274. // CHECK:STDOUT: %float.make_type.loc20_33: init type = call constants.%struct.1(%.loc20_33.1) [template = f64]
  275. // CHECK:STDOUT: %.loc20_33.2: type = value_of_initializer %float.make_type.loc20_33 [template = f64]
  276. // CHECK:STDOUT: %.loc20_33.3: type = converted %float.make_type.loc20_33, %.loc20_33.2 [template = f64]
  277. // CHECK:STDOUT: @RuntimeCallTooFew.%return: ref f64 = var <return slot>
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT: %import_ref.15: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  280. // CHECK:STDOUT: %import_ref.16: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  281. // CHECK:STDOUT: %import_ref.17: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  282. // CHECK:STDOUT: %import_ref.18: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  283. // CHECK:STDOUT: %RuntimeCallTooMany.decl: RuntimeCallTooMany = fn_decl @RuntimeCallTooMany [template = constants.%struct.8] {
  284. // CHECK:STDOUT: %.loc24_26.1: i32 = int_literal 64 [template = constants.%.1]
  285. // CHECK:STDOUT: %float.make_type.loc24_26: init type = call constants.%struct.1(%.loc24_26.1) [template = f64]
  286. // CHECK:STDOUT: %.loc24_26.2: type = value_of_initializer %float.make_type.loc24_26 [template = f64]
  287. // CHECK:STDOUT: %.loc24_26.3: type = converted %float.make_type.loc24_26, %.loc24_26.2 [template = f64]
  288. // CHECK:STDOUT: %a.loc24_23.1: f64 = param a
  289. // CHECK:STDOUT: @RuntimeCallTooMany.%a: f64 = bind_name a, %a.loc24_23.1
  290. // CHECK:STDOUT: %.loc24_34.1: i32 = int_literal 64 [template = constants.%.1]
  291. // CHECK:STDOUT: %float.make_type.loc24_34: init type = call constants.%struct.1(%.loc24_34.1) [template = f64]
  292. // CHECK:STDOUT: %.loc24_34.2: type = value_of_initializer %float.make_type.loc24_34 [template = f64]
  293. // CHECK:STDOUT: %.loc24_34.3: type = converted %float.make_type.loc24_34, %.loc24_34.2 [template = f64]
  294. // CHECK:STDOUT: %b.loc24_31.1: f64 = param b
  295. // CHECK:STDOUT: @RuntimeCallTooMany.%b: f64 = bind_name b, %b.loc24_31.1
  296. // CHECK:STDOUT: %.loc24_42.1: i32 = int_literal 64 [template = constants.%.1]
  297. // CHECK:STDOUT: %float.make_type.loc24_42: init type = call constants.%struct.1(%.loc24_42.1) [template = f64]
  298. // CHECK:STDOUT: %.loc24_42.2: type = value_of_initializer %float.make_type.loc24_42 [template = f64]
  299. // CHECK:STDOUT: %.loc24_42.3: type = converted %float.make_type.loc24_42, %.loc24_42.2 [template = f64]
  300. // CHECK:STDOUT: %c.loc24_39.1: f64 = param c
  301. // CHECK:STDOUT: @RuntimeCallTooMany.%c: f64 = bind_name c, %c.loc24_39.1
  302. // CHECK:STDOUT: %.loc24_50.1: i32 = int_literal 64 [template = constants.%.1]
  303. // CHECK:STDOUT: %float.make_type.loc24_50: init type = call constants.%struct.1(%.loc24_50.1) [template = f64]
  304. // CHECK:STDOUT: %.loc24_50.2: type = value_of_initializer %float.make_type.loc24_50 [template = f64]
  305. // CHECK:STDOUT: %.loc24_50.3: type = converted %float.make_type.loc24_50, %.loc24_50.2 [template = f64]
  306. // CHECK:STDOUT: @RuntimeCallTooMany.%return: ref f64 = var <return slot>
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT: %import_ref.19: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  309. // CHECK:STDOUT: %import_ref.20: Float = import_ref ir3, inst+31, loaded [template = constants.%struct.1]
  310. // CHECK:STDOUT: %import_ref.21: Bool = import_ref ir7, inst+2, loaded [template = constants.%struct.4]
  311. // CHECK:STDOUT: %RuntimeCallBadReturnType.decl: RuntimeCallBadReturnType = fn_decl @RuntimeCallBadReturnType [template = constants.%struct.9] {
  312. // CHECK:STDOUT: %.loc28_32.1: i32 = int_literal 64 [template = constants.%.1]
  313. // CHECK:STDOUT: %float.make_type.loc28_32: init type = call constants.%struct.1(%.loc28_32.1) [template = f64]
  314. // CHECK:STDOUT: %.loc28_32.2: type = value_of_initializer %float.make_type.loc28_32 [template = f64]
  315. // CHECK:STDOUT: %.loc28_32.3: type = converted %float.make_type.loc28_32, %.loc28_32.2 [template = f64]
  316. // CHECK:STDOUT: %a.loc28_29.1: f64 = param a
  317. // CHECK:STDOUT: @RuntimeCallBadReturnType.%a: f64 = bind_name a, %a.loc28_29.1
  318. // CHECK:STDOUT: %.loc28_40.1: i32 = int_literal 64 [template = constants.%.1]
  319. // CHECK:STDOUT: %float.make_type.loc28_40: init type = call constants.%struct.1(%.loc28_40.1) [template = f64]
  320. // CHECK:STDOUT: %.loc28_40.2: type = value_of_initializer %float.make_type.loc28_40 [template = f64]
  321. // CHECK:STDOUT: %.loc28_40.3: type = converted %float.make_type.loc28_40, %.loc28_40.2 [template = f64]
  322. // CHECK:STDOUT: %b.loc28_37.1: f64 = param b
  323. // CHECK:STDOUT: @RuntimeCallBadReturnType.%b: f64 = bind_name b, %b.loc28_37.1
  324. // CHECK:STDOUT: %bool.make_type.loc28: init type = call constants.%struct.4() [template = bool]
  325. // CHECK:STDOUT: %.loc28_48.1: type = value_of_initializer %bool.make_type.loc28 [template = bool]
  326. // CHECK:STDOUT: %.loc28_48.2: type = converted %bool.make_type.loc28, %.loc28_48.1 [template = bool]
  327. // CHECK:STDOUT: @RuntimeCallBadReturnType.%return: ref bool = var <return slot>
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT:
  331. // CHECK:STDOUT: fn @Float(%size: i32) -> type = "float.make_type";
  332. // CHECK:STDOUT:
  333. // CHECK:STDOUT: fn @TooFew(%a: f64) -> f64;
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: fn @TooMany(%a: f64, %b: f64, %c: f64) -> f64;
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  338. // CHECK:STDOUT:
  339. // CHECK:STDOUT: fn @BadReturnType(%a: f64, %b: f64) -> bool;
  340. // CHECK:STDOUT:
  341. // CHECK:STDOUT: fn @JustRight(%a: f64, %b: f64) -> f64 = "float.sub";
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: fn @RuntimeCallTooFew(%a: f64) -> f64 {
  344. // CHECK:STDOUT: !entry:
  345. // CHECK:STDOUT: %TooFew.ref: TooFew = name_ref TooFew, file.%TooFew.decl [template = constants.%struct.2]
  346. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  347. // CHECK:STDOUT: %TooFew.call: init f64 = call %TooFew.ref(%a.ref)
  348. // CHECK:STDOUT: %.loc21_19.1: f64 = value_of_initializer %TooFew.call
  349. // CHECK:STDOUT: %.loc21_19.2: f64 = converted %TooFew.call, %.loc21_19.1
  350. // CHECK:STDOUT: return %.loc21_19.2
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: fn @RuntimeCallTooMany(%a: f64, %b: f64, %c: f64) -> f64 {
  354. // CHECK:STDOUT: !entry:
  355. // CHECK:STDOUT: %TooMany.ref: TooMany = name_ref TooMany, file.%TooMany.decl [template = constants.%struct.3]
  356. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  357. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  358. // CHECK:STDOUT: %c.ref: f64 = name_ref c, %c
  359. // CHECK:STDOUT: %TooMany.call: init f64 = call %TooMany.ref(%a.ref, %b.ref, %c.ref)
  360. // CHECK:STDOUT: %.loc25_26.1: f64 = value_of_initializer %TooMany.call
  361. // CHECK:STDOUT: %.loc25_26.2: f64 = converted %TooMany.call, %.loc25_26.1
  362. // CHECK:STDOUT: return %.loc25_26.2
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: fn @RuntimeCallBadReturnType(%a: f64, %b: f64) -> bool {
  366. // CHECK:STDOUT: !entry:
  367. // CHECK:STDOUT: %BadReturnType.ref: BadReturnType = name_ref BadReturnType, file.%BadReturnType.decl [template = constants.%struct.5]
  368. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  369. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  370. // CHECK:STDOUT: %BadReturnType.call: init bool = call %BadReturnType.ref(%a.ref, %b.ref)
  371. // CHECK:STDOUT: %.loc29_29.1: bool = value_of_initializer %BadReturnType.call
  372. // CHECK:STDOUT: %.loc29_29.2: bool = converted %BadReturnType.call, %.loc29_29.1
  373. // CHECK:STDOUT: return %.loc29_29.2
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT: