negate.carbon 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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/float/negate.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/float/negate.carbon
  10. // --- float_negate.carbon
  11. fn Negate(a: f64) -> f64 = "float.negate";
  12. fn RuntimeCall(a: f64, b: f64) -> f64 {
  13. return Negate(a);
  14. }
  15. let a: f64 = Negate(1.5);
  16. // --- fail_bad_decl.carbon
  17. package FailBadDecl;
  18. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.negate".
  19. // CHECK:STDERR: fn TooFew() -> f64 = "float.negate";
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  21. // CHECK:STDERR:
  22. fn TooFew() -> f64 = "float.negate";
  23. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.negate".
  24. // CHECK:STDERR: fn TooMany(a: f64, b: f64) -> f64 = "float.negate";
  25. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  26. // CHECK:STDERR:
  27. fn TooMany(a: f64, b: f64) -> f64 = "float.negate";
  28. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: ERROR: Invalid signature for builtin function "float.negate".
  29. // CHECK:STDERR: fn BadReturnType(a: f64) -> bool = "float.negate";
  30. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. // CHECK:STDERR:
  32. fn BadReturnType(a: f64) -> bool = "float.negate";
  33. fn JustRight(a: f64) -> f64 = "float.negate";
  34. fn RuntimeCallTooFew(a: f64) -> f64 {
  35. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:10: ERROR: 1 argument(s) passed to function expecting 0 argument(s).
  36. // CHECK:STDERR: return TooFew(a);
  37. // CHECK:STDERR: ^~~~~~~
  38. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-17]]:1: Calling function declared here.
  39. // CHECK:STDERR: fn TooFew() -> f64 = "float.negate";
  40. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  41. // CHECK:STDERR:
  42. return TooFew(a);
  43. }
  44. fn RuntimeCallTooMany(a: f64, b: f64, c: f64) -> f64 {
  45. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:10: ERROR: 3 argument(s) passed to function expecting 2 argument(s).
  46. // CHECK:STDERR: return TooMany(a, b, c);
  47. // CHECK:STDERR: ^~~~~~~~
  48. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-23]]:1: Calling function declared here.
  49. // CHECK:STDERR: fn TooMany(a: f64, b: f64) -> f64 = "float.negate";
  50. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  51. // CHECK:STDERR:
  52. return TooMany(a, b, c);
  53. }
  54. fn RuntimeCallBadReturnType(a: f64, b: f64) -> bool {
  55. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+6]]:10: ERROR: 2 argument(s) passed to function expecting 1 argument(s).
  56. // CHECK:STDERR: return BadReturnType(a, b);
  57. // CHECK:STDERR: ^~~~~~~~~~~~~~
  58. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-29]]:1: Calling function declared here.
  59. // CHECK:STDERR: fn BadReturnType(a: f64) -> bool = "float.negate";
  60. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61. return BadReturnType(a, b);
  62. }
  63. // CHECK:STDOUT: --- float_negate.carbon
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: constants {
  66. // CHECK:STDOUT: %.1: i32 = int_literal 64 [template]
  67. // CHECK:STDOUT: %Float.type: type = fn_type @Float [template]
  68. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  69. // CHECK:STDOUT: %Float: %Float.type = struct_value () [template]
  70. // CHECK:STDOUT: %Negate.type: type = fn_type @Negate [template]
  71. // CHECK:STDOUT: %Negate: %Negate.type = struct_value () [template]
  72. // CHECK:STDOUT: %RuntimeCall.type: type = fn_type @RuntimeCall [template]
  73. // CHECK:STDOUT: %RuntimeCall: %RuntimeCall.type = struct_value () [template]
  74. // CHECK:STDOUT: %.3: f64 = float_literal 1.5 [template]
  75. // CHECK:STDOUT: %.4: f64 = float_literal -1.5 [template]
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: file {
  79. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  80. // CHECK:STDOUT: .Core = %Core
  81. // CHECK:STDOUT: .Negate = %Negate.decl
  82. // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl
  83. // CHECK:STDOUT: .a = @__global_init.%a
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  86. // CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  87. // CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  88. // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] {
  89. // CHECK:STDOUT: %.loc2_14.1: i32 = int_literal 64 [template = constants.%.1]
  90. // CHECK:STDOUT: %float.make_type.loc2_14: init type = call constants.%Float(%.loc2_14.1) [template = f64]
  91. // CHECK:STDOUT: %.loc2_14.2: type = value_of_initializer %float.make_type.loc2_14 [template = f64]
  92. // CHECK:STDOUT: %.loc2_14.3: type = converted %float.make_type.loc2_14, %.loc2_14.2 [template = f64]
  93. // CHECK:STDOUT: %a.loc2_11.1: f64 = param a
  94. // CHECK:STDOUT: @Negate.%a: f64 = bind_name a, %a.loc2_11.1
  95. // CHECK:STDOUT: %.loc2_22.1: i32 = int_literal 64 [template = constants.%.1]
  96. // CHECK:STDOUT: %float.make_type.loc2_22: init type = call constants.%Float(%.loc2_22.1) [template = f64]
  97. // CHECK:STDOUT: %.loc2_22.2: type = value_of_initializer %float.make_type.loc2_22 [template = f64]
  98. // CHECK:STDOUT: %.loc2_22.3: type = converted %float.make_type.loc2_22, %.loc2_22.2 [template = f64]
  99. // CHECK:STDOUT: @Negate.%return: ref f64 = var <return slot>
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  102. // CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  103. // CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  104. // CHECK:STDOUT: %RuntimeCall.decl: %RuntimeCall.type = fn_decl @RuntimeCall [template = constants.%RuntimeCall] {
  105. // CHECK:STDOUT: %.loc4_19.1: i32 = int_literal 64 [template = constants.%.1]
  106. // CHECK:STDOUT: %float.make_type.loc4_19: init type = call constants.%Float(%.loc4_19.1) [template = f64]
  107. // CHECK:STDOUT: %.loc4_19.2: type = value_of_initializer %float.make_type.loc4_19 [template = f64]
  108. // CHECK:STDOUT: %.loc4_19.3: type = converted %float.make_type.loc4_19, %.loc4_19.2 [template = f64]
  109. // CHECK:STDOUT: %a.loc4_16.1: f64 = param a
  110. // CHECK:STDOUT: @RuntimeCall.%a: f64 = bind_name a, %a.loc4_16.1
  111. // CHECK:STDOUT: %.loc4_27.1: i32 = int_literal 64 [template = constants.%.1]
  112. // CHECK:STDOUT: %float.make_type.loc4_27: init type = call constants.%Float(%.loc4_27.1) [template = f64]
  113. // CHECK:STDOUT: %.loc4_27.2: type = value_of_initializer %float.make_type.loc4_27 [template = f64]
  114. // CHECK:STDOUT: %.loc4_27.3: type = converted %float.make_type.loc4_27, %.loc4_27.2 [template = f64]
  115. // CHECK:STDOUT: %b.loc4_24.1: f64 = param b
  116. // CHECK:STDOUT: @RuntimeCall.%b: f64 = bind_name b, %b.loc4_24.1
  117. // CHECK:STDOUT: %.loc4_35.1: i32 = int_literal 64 [template = constants.%.1]
  118. // CHECK:STDOUT: %float.make_type.loc4_35: init type = call constants.%Float(%.loc4_35.1) [template = f64]
  119. // CHECK:STDOUT: %.loc4_35.2: type = value_of_initializer %float.make_type.loc4_35 [template = f64]
  120. // CHECK:STDOUT: %.loc4_35.3: type = converted %float.make_type.loc4_35, %.loc4_35.2 [template = f64]
  121. // CHECK:STDOUT: @RuntimeCall.%return: ref f64 = var <return slot>
  122. // CHECK:STDOUT: }
  123. // CHECK:STDOUT: %.loc8_8.1: i32 = int_literal 64 [template = constants.%.1]
  124. // CHECK:STDOUT: %import_ref.6: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  125. // CHECK:STDOUT: %float.make_type.loc8: init type = call constants.%Float(%.loc8_8.1) [template = f64]
  126. // CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %float.make_type.loc8 [template = f64]
  127. // CHECK:STDOUT: %.loc8_8.3: type = converted %float.make_type.loc8, %.loc8_8.2 [template = f64]
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: fn @Float(%size: i32) -> type = "float.make_type";
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: fn @Negate(%a: f64) -> f64 = "float.negate";
  133. // CHECK:STDOUT:
  134. // CHECK:STDOUT: fn @RuntimeCall(%a: f64, %b: f64) -> f64 {
  135. // CHECK:STDOUT: !entry:
  136. // CHECK:STDOUT: %Negate.ref: %Negate.type = name_ref Negate, file.%Negate.decl [template = constants.%Negate]
  137. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  138. // CHECK:STDOUT: %float.negate: init f64 = call %Negate.ref(%a.ref)
  139. // CHECK:STDOUT: %.loc5_19.1: f64 = value_of_initializer %float.negate
  140. // CHECK:STDOUT: %.loc5_19.2: f64 = converted %float.negate, %.loc5_19.1
  141. // CHECK:STDOUT: return %.loc5_19.2
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: fn @__global_init() {
  145. // CHECK:STDOUT: !entry:
  146. // CHECK:STDOUT: %Negate.ref: %Negate.type = name_ref Negate, file.%Negate.decl [template = constants.%Negate]
  147. // CHECK:STDOUT: %.loc8_21: f64 = float_literal 1.5 [template = constants.%.3]
  148. // CHECK:STDOUT: %float.negate: init f64 = call %Negate.ref(%.loc8_21) [template = constants.%.4]
  149. // CHECK:STDOUT: %.loc8_25.1: f64 = value_of_initializer %float.negate [template = constants.%.4]
  150. // CHECK:STDOUT: %.loc8_25.2: f64 = converted %float.negate, %.loc8_25.1 [template = constants.%.4]
  151. // CHECK:STDOUT: %a: f64 = bind_name a, %.loc8_25.2
  152. // CHECK:STDOUT: return
  153. // CHECK:STDOUT: }
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: --- fail_bad_decl.carbon
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: constants {
  158. // CHECK:STDOUT: %.1: i32 = int_literal 64 [template]
  159. // CHECK:STDOUT: %Float.type: type = fn_type @Float [template]
  160. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  161. // CHECK:STDOUT: %Float: %Float.type = struct_value () [template]
  162. // CHECK:STDOUT: %TooFew.type: type = fn_type @TooFew [template]
  163. // CHECK:STDOUT: %TooFew: %TooFew.type = struct_value () [template]
  164. // CHECK:STDOUT: %TooMany.type: type = fn_type @TooMany [template]
  165. // CHECK:STDOUT: %TooMany: %TooMany.type = struct_value () [template]
  166. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  167. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  168. // CHECK:STDOUT: %BadReturnType.type: type = fn_type @BadReturnType [template]
  169. // CHECK:STDOUT: %BadReturnType: %BadReturnType.type = struct_value () [template]
  170. // CHECK:STDOUT: %JustRight.type: type = fn_type @JustRight [template]
  171. // CHECK:STDOUT: %JustRight: %JustRight.type = struct_value () [template]
  172. // CHECK:STDOUT: %RuntimeCallTooFew.type: type = fn_type @RuntimeCallTooFew [template]
  173. // CHECK:STDOUT: %RuntimeCallTooFew: %RuntimeCallTooFew.type = struct_value () [template]
  174. // CHECK:STDOUT: %RuntimeCallTooMany.type: type = fn_type @RuntimeCallTooMany [template]
  175. // CHECK:STDOUT: %RuntimeCallTooMany: %RuntimeCallTooMany.type = struct_value () [template]
  176. // CHECK:STDOUT: %RuntimeCallBadReturnType.type: type = fn_type @RuntimeCallBadReturnType [template]
  177. // CHECK:STDOUT: %RuntimeCallBadReturnType: %RuntimeCallBadReturnType.type = struct_value () [template]
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: file {
  181. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  182. // CHECK:STDOUT: .Core = %Core
  183. // CHECK:STDOUT: .TooFew = %TooFew.decl
  184. // CHECK:STDOUT: .TooMany = %TooMany.decl
  185. // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl
  186. // CHECK:STDOUT: .JustRight = %JustRight.decl
  187. // CHECK:STDOUT: .RuntimeCallTooFew = %RuntimeCallTooFew.decl
  188. // CHECK:STDOUT: .RuntimeCallTooMany = %RuntimeCallTooMany.decl
  189. // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  192. // CHECK:STDOUT: %import_ref.1: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  193. // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] {
  194. // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 64 [template = constants.%.1]
  195. // CHECK:STDOUT: %float.make_type.loc8: init type = call constants.%Float(%.loc8_16.1) [template = f64]
  196. // CHECK:STDOUT: %.loc8_16.2: type = value_of_initializer %float.make_type.loc8 [template = f64]
  197. // CHECK:STDOUT: %.loc8_16.3: type = converted %float.make_type.loc8, %.loc8_16.2 [template = f64]
  198. // CHECK:STDOUT: @TooFew.%return: ref f64 = var <return slot>
  199. // CHECK:STDOUT: }
  200. // CHECK:STDOUT: %import_ref.2: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  201. // CHECK:STDOUT: %import_ref.3: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  202. // CHECK:STDOUT: %import_ref.4: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  203. // CHECK:STDOUT: %TooMany.decl: %TooMany.type = fn_decl @TooMany [template = constants.%TooMany] {
  204. // CHECK:STDOUT: %.loc13_15.1: i32 = int_literal 64 [template = constants.%.1]
  205. // CHECK:STDOUT: %float.make_type.loc13_15: init type = call constants.%Float(%.loc13_15.1) [template = f64]
  206. // CHECK:STDOUT: %.loc13_15.2: type = value_of_initializer %float.make_type.loc13_15 [template = f64]
  207. // CHECK:STDOUT: %.loc13_15.3: type = converted %float.make_type.loc13_15, %.loc13_15.2 [template = f64]
  208. // CHECK:STDOUT: %a.loc13_12.1: f64 = param a
  209. // CHECK:STDOUT: @TooMany.%a: f64 = bind_name a, %a.loc13_12.1
  210. // CHECK:STDOUT: %.loc13_23.1: i32 = int_literal 64 [template = constants.%.1]
  211. // CHECK:STDOUT: %float.make_type.loc13_23: init type = call constants.%Float(%.loc13_23.1) [template = f64]
  212. // CHECK:STDOUT: %.loc13_23.2: type = value_of_initializer %float.make_type.loc13_23 [template = f64]
  213. // CHECK:STDOUT: %.loc13_23.3: type = converted %float.make_type.loc13_23, %.loc13_23.2 [template = f64]
  214. // CHECK:STDOUT: %b.loc13_20.1: f64 = param b
  215. // CHECK:STDOUT: @TooMany.%b: f64 = bind_name b, %b.loc13_20.1
  216. // CHECK:STDOUT: %.loc13_31.1: i32 = int_literal 64 [template = constants.%.1]
  217. // CHECK:STDOUT: %float.make_type.loc13_31: init type = call constants.%Float(%.loc13_31.1) [template = f64]
  218. // CHECK:STDOUT: %.loc13_31.2: type = value_of_initializer %float.make_type.loc13_31 [template = f64]
  219. // CHECK:STDOUT: %.loc13_31.3: type = converted %float.make_type.loc13_31, %.loc13_31.2 [template = f64]
  220. // CHECK:STDOUT: @TooMany.%return: ref f64 = var <return slot>
  221. // CHECK:STDOUT: }
  222. // CHECK:STDOUT: %import_ref.5: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  223. // CHECK:STDOUT: %import_ref.6: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool]
  224. // CHECK:STDOUT: %BadReturnType.decl: %BadReturnType.type = fn_decl @BadReturnType [template = constants.%BadReturnType] {
  225. // CHECK:STDOUT: %.loc18_21.1: i32 = int_literal 64 [template = constants.%.1]
  226. // CHECK:STDOUT: %float.make_type.loc18: init type = call constants.%Float(%.loc18_21.1) [template = f64]
  227. // CHECK:STDOUT: %.loc18_21.2: type = value_of_initializer %float.make_type.loc18 [template = f64]
  228. // CHECK:STDOUT: %.loc18_21.3: type = converted %float.make_type.loc18, %.loc18_21.2 [template = f64]
  229. // CHECK:STDOUT: %a.loc18_18.1: f64 = param a
  230. // CHECK:STDOUT: @BadReturnType.%a: f64 = bind_name a, %a.loc18_18.1
  231. // CHECK:STDOUT: %bool.make_type.loc18: init type = call constants.%Bool() [template = bool]
  232. // CHECK:STDOUT: %.loc18_29.1: type = value_of_initializer %bool.make_type.loc18 [template = bool]
  233. // CHECK:STDOUT: %.loc18_29.2: type = converted %bool.make_type.loc18, %.loc18_29.1 [template = bool]
  234. // CHECK:STDOUT: @BadReturnType.%return: ref bool = var <return slot>
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT: %import_ref.7: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  237. // CHECK:STDOUT: %import_ref.8: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  238. // CHECK:STDOUT: %JustRight.decl: %JustRight.type = fn_decl @JustRight [template = constants.%JustRight] {
  239. // CHECK:STDOUT: %.loc19_17.1: i32 = int_literal 64 [template = constants.%.1]
  240. // CHECK:STDOUT: %float.make_type.loc19_17: init type = call constants.%Float(%.loc19_17.1) [template = f64]
  241. // CHECK:STDOUT: %.loc19_17.2: type = value_of_initializer %float.make_type.loc19_17 [template = f64]
  242. // CHECK:STDOUT: %.loc19_17.3: type = converted %float.make_type.loc19_17, %.loc19_17.2 [template = f64]
  243. // CHECK:STDOUT: %a.loc19_14.1: f64 = param a
  244. // CHECK:STDOUT: @JustRight.%a: f64 = bind_name a, %a.loc19_14.1
  245. // CHECK:STDOUT: %.loc19_25.1: i32 = int_literal 64 [template = constants.%.1]
  246. // CHECK:STDOUT: %float.make_type.loc19_25: init type = call constants.%Float(%.loc19_25.1) [template = f64]
  247. // CHECK:STDOUT: %.loc19_25.2: type = value_of_initializer %float.make_type.loc19_25 [template = f64]
  248. // CHECK:STDOUT: %.loc19_25.3: type = converted %float.make_type.loc19_25, %.loc19_25.2 [template = f64]
  249. // CHECK:STDOUT: @JustRight.%return: ref f64 = var <return slot>
  250. // CHECK:STDOUT: }
  251. // CHECK:STDOUT: %import_ref.9: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  252. // CHECK:STDOUT: %import_ref.10: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  253. // CHECK:STDOUT: %RuntimeCallTooFew.decl: %RuntimeCallTooFew.type = fn_decl @RuntimeCallTooFew [template = constants.%RuntimeCallTooFew] {
  254. // CHECK:STDOUT: %.loc21_25.1: i32 = int_literal 64 [template = constants.%.1]
  255. // CHECK:STDOUT: %float.make_type.loc21_25: init type = call constants.%Float(%.loc21_25.1) [template = f64]
  256. // CHECK:STDOUT: %.loc21_25.2: type = value_of_initializer %float.make_type.loc21_25 [template = f64]
  257. // CHECK:STDOUT: %.loc21_25.3: type = converted %float.make_type.loc21_25, %.loc21_25.2 [template = f64]
  258. // CHECK:STDOUT: %a.loc21_22.1: f64 = param a
  259. // CHECK:STDOUT: @RuntimeCallTooFew.%a: f64 = bind_name a, %a.loc21_22.1
  260. // CHECK:STDOUT: %.loc21_33.1: i32 = int_literal 64 [template = constants.%.1]
  261. // CHECK:STDOUT: %float.make_type.loc21_33: init type = call constants.%Float(%.loc21_33.1) [template = f64]
  262. // CHECK:STDOUT: %.loc21_33.2: type = value_of_initializer %float.make_type.loc21_33 [template = f64]
  263. // CHECK:STDOUT: %.loc21_33.3: type = converted %float.make_type.loc21_33, %.loc21_33.2 [template = f64]
  264. // CHECK:STDOUT: @RuntimeCallTooFew.%return: ref f64 = var <return slot>
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT: %import_ref.11: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  267. // CHECK:STDOUT: %import_ref.12: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  268. // CHECK:STDOUT: %import_ref.13: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  269. // CHECK:STDOUT: %import_ref.14: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  270. // CHECK:STDOUT: %RuntimeCallTooMany.decl: %RuntimeCallTooMany.type = fn_decl @RuntimeCallTooMany [template = constants.%RuntimeCallTooMany] {
  271. // CHECK:STDOUT: %.loc32_26.1: i32 = int_literal 64 [template = constants.%.1]
  272. // CHECK:STDOUT: %float.make_type.loc32_26: init type = call constants.%Float(%.loc32_26.1) [template = f64]
  273. // CHECK:STDOUT: %.loc32_26.2: type = value_of_initializer %float.make_type.loc32_26 [template = f64]
  274. // CHECK:STDOUT: %.loc32_26.3: type = converted %float.make_type.loc32_26, %.loc32_26.2 [template = f64]
  275. // CHECK:STDOUT: %a.loc32_23.1: f64 = param a
  276. // CHECK:STDOUT: @RuntimeCallTooMany.%a: f64 = bind_name a, %a.loc32_23.1
  277. // CHECK:STDOUT: %.loc32_34.1: i32 = int_literal 64 [template = constants.%.1]
  278. // CHECK:STDOUT: %float.make_type.loc32_34: init type = call constants.%Float(%.loc32_34.1) [template = f64]
  279. // CHECK:STDOUT: %.loc32_34.2: type = value_of_initializer %float.make_type.loc32_34 [template = f64]
  280. // CHECK:STDOUT: %.loc32_34.3: type = converted %float.make_type.loc32_34, %.loc32_34.2 [template = f64]
  281. // CHECK:STDOUT: %b.loc32_31.1: f64 = param b
  282. // CHECK:STDOUT: @RuntimeCallTooMany.%b: f64 = bind_name b, %b.loc32_31.1
  283. // CHECK:STDOUT: %.loc32_42.1: i32 = int_literal 64 [template = constants.%.1]
  284. // CHECK:STDOUT: %float.make_type.loc32_42: init type = call constants.%Float(%.loc32_42.1) [template = f64]
  285. // CHECK:STDOUT: %.loc32_42.2: type = value_of_initializer %float.make_type.loc32_42 [template = f64]
  286. // CHECK:STDOUT: %.loc32_42.3: type = converted %float.make_type.loc32_42, %.loc32_42.2 [template = f64]
  287. // CHECK:STDOUT: %c.loc32_39.1: f64 = param c
  288. // CHECK:STDOUT: @RuntimeCallTooMany.%c: f64 = bind_name c, %c.loc32_39.1
  289. // CHECK:STDOUT: %.loc32_50.1: i32 = int_literal 64 [template = constants.%.1]
  290. // CHECK:STDOUT: %float.make_type.loc32_50: init type = call constants.%Float(%.loc32_50.1) [template = f64]
  291. // CHECK:STDOUT: %.loc32_50.2: type = value_of_initializer %float.make_type.loc32_50 [template = f64]
  292. // CHECK:STDOUT: %.loc32_50.3: type = converted %float.make_type.loc32_50, %.loc32_50.2 [template = f64]
  293. // CHECK:STDOUT: @RuntimeCallTooMany.%return: ref f64 = var <return slot>
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT: %import_ref.15: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  296. // CHECK:STDOUT: %import_ref.16: %Float.type = import_ref ir3, inst+31, loaded [template = constants.%Float]
  297. // CHECK:STDOUT: %import_ref.17: %Bool.type = import_ref ir7, inst+2, loaded [template = constants.%Bool]
  298. // CHECK:STDOUT: %RuntimeCallBadReturnType.decl: %RuntimeCallBadReturnType.type = fn_decl @RuntimeCallBadReturnType [template = constants.%RuntimeCallBadReturnType] {
  299. // CHECK:STDOUT: %.loc43_32.1: i32 = int_literal 64 [template = constants.%.1]
  300. // CHECK:STDOUT: %float.make_type.loc43_32: init type = call constants.%Float(%.loc43_32.1) [template = f64]
  301. // CHECK:STDOUT: %.loc43_32.2: type = value_of_initializer %float.make_type.loc43_32 [template = f64]
  302. // CHECK:STDOUT: %.loc43_32.3: type = converted %float.make_type.loc43_32, %.loc43_32.2 [template = f64]
  303. // CHECK:STDOUT: %a.loc43_29.1: f64 = param a
  304. // CHECK:STDOUT: @RuntimeCallBadReturnType.%a: f64 = bind_name a, %a.loc43_29.1
  305. // CHECK:STDOUT: %.loc43_40.1: i32 = int_literal 64 [template = constants.%.1]
  306. // CHECK:STDOUT: %float.make_type.loc43_40: init type = call constants.%Float(%.loc43_40.1) [template = f64]
  307. // CHECK:STDOUT: %.loc43_40.2: type = value_of_initializer %float.make_type.loc43_40 [template = f64]
  308. // CHECK:STDOUT: %.loc43_40.3: type = converted %float.make_type.loc43_40, %.loc43_40.2 [template = f64]
  309. // CHECK:STDOUT: %b.loc43_37.1: f64 = param b
  310. // CHECK:STDOUT: @RuntimeCallBadReturnType.%b: f64 = bind_name b, %b.loc43_37.1
  311. // CHECK:STDOUT: %bool.make_type.loc43: init type = call constants.%Bool() [template = bool]
  312. // CHECK:STDOUT: %.loc43_48.1: type = value_of_initializer %bool.make_type.loc43 [template = bool]
  313. // CHECK:STDOUT: %.loc43_48.2: type = converted %bool.make_type.loc43, %.loc43_48.1 [template = bool]
  314. // CHECK:STDOUT: @RuntimeCallBadReturnType.%return: ref bool = var <return slot>
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT: }
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: fn @Float(%size: i32) -> type = "float.make_type";
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: fn @TooFew() -> f64;
  321. // CHECK:STDOUT:
  322. // CHECK:STDOUT: fn @TooMany(%a: f64, %b: f64) -> f64;
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: fn @BadReturnType(%a: f64) -> bool;
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: fn @JustRight(%a: f64) -> f64 = "float.negate";
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: fn @RuntimeCallTooFew(%a: f64) -> f64 {
  331. // CHECK:STDOUT: !entry:
  332. // CHECK:STDOUT: %TooFew.ref: %TooFew.type = name_ref TooFew, file.%TooFew.decl [template = constants.%TooFew]
  333. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  334. // CHECK:STDOUT: %TooFew.call: init f64 = call %TooFew.ref(<invalid>) [template = <error>]
  335. // CHECK:STDOUT: %.loc29_19.1: f64 = value_of_initializer %TooFew.call [template = <error>]
  336. // CHECK:STDOUT: %.loc29_19.2: f64 = converted %TooFew.call, %.loc29_19.1 [template = <error>]
  337. // CHECK:STDOUT: return %.loc29_19.2
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: fn @RuntimeCallTooMany(%a: f64, %b: f64, %c: f64) -> f64 {
  341. // CHECK:STDOUT: !entry:
  342. // CHECK:STDOUT: %TooMany.ref: %TooMany.type = name_ref TooMany, file.%TooMany.decl [template = constants.%TooMany]
  343. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  344. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  345. // CHECK:STDOUT: %c.ref: f64 = name_ref c, %c
  346. // CHECK:STDOUT: %TooMany.call: init f64 = call %TooMany.ref(<invalid>) [template = <error>]
  347. // CHECK:STDOUT: %.loc40_26.1: f64 = value_of_initializer %TooMany.call [template = <error>]
  348. // CHECK:STDOUT: %.loc40_26.2: f64 = converted %TooMany.call, %.loc40_26.1 [template = <error>]
  349. // CHECK:STDOUT: return %.loc40_26.2
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: fn @RuntimeCallBadReturnType(%a: f64, %b: f64) -> bool {
  353. // CHECK:STDOUT: !entry:
  354. // CHECK:STDOUT: %BadReturnType.ref: %BadReturnType.type = name_ref BadReturnType, file.%BadReturnType.decl [template = constants.%BadReturnType]
  355. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  356. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  357. // CHECK:STDOUT: %BadReturnType.call: init bool = call %BadReturnType.ref(<invalid>) [template = <error>]
  358. // CHECK:STDOUT: %.loc50_29.1: bool = value_of_initializer %BadReturnType.call [template = <error>]
  359. // CHECK:STDOUT: %.loc50_29.2: bool = converted %BadReturnType.call, %.loc50_29.1 [template = <error>]
  360. // CHECK:STDOUT: return %.loc50_29.2
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT: