negate.carbon 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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 RuntimeCallIsValid(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" [InvalidBuiltinSignature]
  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" [InvalidBuiltinSignature]
  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" [InvalidBuiltinSignature]
  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 RuntimeCallIsValidTooFew(a: f64) -> f64 {
  35. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:10: error: 1 argument passed to function expecting 0 arguments [CallArgCountMismatch]
  36. // CHECK:STDERR: return TooFew(a);
  37. // CHECK:STDERR: ^~~~~~~~~
  38. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-17]]:1: note: calling function declared here [InCallToEntity]
  39. // CHECK:STDERR: fn TooFew() -> f64 = "float.negate";
  40. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  41. // CHECK:STDERR:
  42. return TooFew(a);
  43. }
  44. fn RuntimeCallIsValidTooMany(a: f64, b: f64, c: f64) -> f64 {
  45. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:10: error: 3 arguments passed to function expecting 2 arguments [CallArgCountMismatch]
  46. // CHECK:STDERR: return TooMany(a, b, c);
  47. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  48. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-23]]:1: note: calling function declared here [InCallToEntity]
  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 RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool {
  55. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+7]]:10: error: 2 arguments passed to function expecting 1 argument [CallArgCountMismatch]
  56. // CHECK:STDERR: return BadReturnType(a, b);
  57. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  58. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE-29]]:1: note: calling function declared here [InCallToEntity]
  59. // CHECK:STDERR: fn BadReturnType(a: f64) -> bool = "float.negate";
  60. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61. // CHECK:STDERR:
  62. return BadReturnType(a, b);
  63. }
  64. // CHECK:STDOUT: --- float_negate.carbon
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: constants {
  67. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template]
  68. // CHECK:STDOUT: %Float.type: type = fn_type @Float [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: %RuntimeCallIsValid.type: type = fn_type @RuntimeCallIsValid [template]
  73. // CHECK:STDOUT: %RuntimeCallIsValid: %RuntimeCallIsValid.type = struct_value () [template]
  74. // CHECK:STDOUT: %float.e93: f64 = float_literal 1.5 [template]
  75. // CHECK:STDOUT: %float.928: f64 = float_literal -1.5 [template]
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: imports {
  79. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  80. // CHECK:STDOUT: .Float = %Core.Float
  81. // CHECK:STDOUT: import Core//prelude
  82. // CHECK:STDOUT: import Core//prelude/...
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT:
  86. // CHECK:STDOUT: file {
  87. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  88. // CHECK:STDOUT: .Core = imports.%Core
  89. // CHECK:STDOUT: .Negate = %Negate.decl
  90. // CHECK:STDOUT: .RuntimeCallIsValid = %RuntimeCallIsValid.decl
  91. // CHECK:STDOUT: .a = %a
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: %Core.import = import Core
  94. // CHECK:STDOUT: %Negate.decl: %Negate.type = fn_decl @Negate [template = constants.%Negate] {
  95. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  96. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  97. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  98. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param1
  99. // CHECK:STDOUT: } {
  100. // CHECK:STDOUT: %int_64.loc2_22: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  101. // CHECK:STDOUT: %float.make_type.loc2_22: init type = call constants.%Float(%int_64.loc2_22) [template = f64]
  102. // CHECK:STDOUT: %.loc2_22.1: type = value_of_initializer %float.make_type.loc2_22 [template = f64]
  103. // CHECK:STDOUT: %.loc2_22.2: type = converted %float.make_type.loc2_22, %.loc2_22.1 [template = f64]
  104. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  105. // CHECK:STDOUT: %.loc2_14.1: type = splice_block %.loc2_14.3 [template = f64] {
  106. // CHECK:STDOUT: %int_64.loc2_14: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  107. // CHECK:STDOUT: %float.make_type.loc2_14: init type = call constants.%Float(%int_64.loc2_14) [template = f64]
  108. // CHECK:STDOUT: %.loc2_14.2: type = value_of_initializer %float.make_type.loc2_14 [template = f64]
  109. // CHECK:STDOUT: %.loc2_14.3: type = converted %float.make_type.loc2_14, %.loc2_14.2 [template = f64]
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  112. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param1
  113. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: %RuntimeCallIsValid.decl: %RuntimeCallIsValid.type = fn_decl @RuntimeCallIsValid [template = constants.%RuntimeCallIsValid] {
  116. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  117. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  118. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  119. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  120. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  121. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param2
  122. // CHECK:STDOUT: } {
  123. // CHECK:STDOUT: %int_64.loc4_42: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  124. // CHECK:STDOUT: %float.make_type.loc4_42: init type = call constants.%Float(%int_64.loc4_42) [template = f64]
  125. // CHECK:STDOUT: %.loc4_42.1: type = value_of_initializer %float.make_type.loc4_42 [template = f64]
  126. // CHECK:STDOUT: %.loc4_42.2: type = converted %float.make_type.loc4_42, %.loc4_42.1 [template = f64]
  127. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  128. // CHECK:STDOUT: %.loc4_26.1: type = splice_block %.loc4_26.3 [template = f64] {
  129. // CHECK:STDOUT: %int_64.loc4_26: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  130. // CHECK:STDOUT: %float.make_type.loc4_26: init type = call constants.%Float(%int_64.loc4_26) [template = f64]
  131. // CHECK:STDOUT: %.loc4_26.2: type = value_of_initializer %float.make_type.loc4_26 [template = f64]
  132. // CHECK:STDOUT: %.loc4_26.3: type = converted %float.make_type.loc4_26, %.loc4_26.2 [template = f64]
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  135. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  136. // CHECK:STDOUT: %.loc4_34.1: type = splice_block %.loc4_34.3 [template = f64] {
  137. // CHECK:STDOUT: %int_64.loc4_34: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  138. // CHECK:STDOUT: %float.make_type.loc4_34: init type = call constants.%Float(%int_64.loc4_34) [template = f64]
  139. // CHECK:STDOUT: %.loc4_34.2: type = value_of_initializer %float.make_type.loc4_34 [template = f64]
  140. // CHECK:STDOUT: %.loc4_34.3: type = converted %float.make_type.loc4_34, %.loc4_34.2 [template = f64]
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  143. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2
  144. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT: name_binding_decl {
  147. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT: %.loc8_8.1: type = splice_block %.loc8_8.3 [template = f64] {
  150. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  151. // CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64]
  152. // CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %float.make_type [template = f64]
  153. // CHECK:STDOUT: %.loc8_8.3: type = converted %float.make_type, %.loc8_8.2 [template = f64]
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT: %.loc8_24.1: ref f64 = temporary_storage
  156. // CHECK:STDOUT: %.loc8_24.2: ref f64 = temporary %.loc8_24.1, @__global_init.%float.negate
  157. // CHECK:STDOUT: %a: ref f64 = bind_name a, %.loc8_24.2
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: fn @Negate(%a.param_patt: f64) -> f64 = "float.negate";
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: fn @RuntimeCallIsValid(%a.param_patt: f64, %b.param_patt: f64) -> f64 {
  163. // CHECK:STDOUT: !entry:
  164. // CHECK:STDOUT: %Negate.ref: %Negate.type = name_ref Negate, file.%Negate.decl [template = constants.%Negate]
  165. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  166. // CHECK:STDOUT: %float.negate: init f64 = call %Negate.ref(%a.ref)
  167. // CHECK:STDOUT: %.loc5_19.1: f64 = value_of_initializer %float.negate
  168. // CHECK:STDOUT: %.loc5_19.2: f64 = converted %float.negate, %.loc5_19.1
  169. // CHECK:STDOUT: return %.loc5_19.2
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: fn @__global_init() {
  173. // CHECK:STDOUT: !entry:
  174. // CHECK:STDOUT: %Negate.ref: %Negate.type = name_ref Negate, file.%Negate.decl [template = constants.%Negate]
  175. // CHECK:STDOUT: %float: f64 = float_literal 1.5 [template = constants.%float.e93]
  176. // CHECK:STDOUT: %float.negate: init f64 = call %Negate.ref(%float) [template = constants.%float.928]
  177. // CHECK:STDOUT: return
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: --- fail_bad_decl.carbon
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: constants {
  183. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template]
  184. // CHECK:STDOUT: %Float.type: type = fn_type @Float [template]
  185. // CHECK:STDOUT: %Float: %Float.type = struct_value () [template]
  186. // CHECK:STDOUT: %TooFew.type: type = fn_type @TooFew [template]
  187. // CHECK:STDOUT: %TooFew: %TooFew.type = struct_value () [template]
  188. // CHECK:STDOUT: %TooMany.type: type = fn_type @TooMany [template]
  189. // CHECK:STDOUT: %TooMany: %TooMany.type = struct_value () [template]
  190. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  191. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  192. // CHECK:STDOUT: %BadReturnType.type: type = fn_type @BadReturnType [template]
  193. // CHECK:STDOUT: %BadReturnType: %BadReturnType.type = struct_value () [template]
  194. // CHECK:STDOUT: %JustRight.type: type = fn_type @JustRight [template]
  195. // CHECK:STDOUT: %JustRight: %JustRight.type = struct_value () [template]
  196. // CHECK:STDOUT: %RuntimeCallIsValidTooFew.type: type = fn_type @RuntimeCallIsValidTooFew [template]
  197. // CHECK:STDOUT: %RuntimeCallIsValidTooFew: %RuntimeCallIsValidTooFew.type = struct_value () [template]
  198. // CHECK:STDOUT: %RuntimeCallIsValidTooMany.type: type = fn_type @RuntimeCallIsValidTooMany [template]
  199. // CHECK:STDOUT: %RuntimeCallIsValidTooMany: %RuntimeCallIsValidTooMany.type = struct_value () [template]
  200. // CHECK:STDOUT: %RuntimeCallIsValidBadReturnType.type: type = fn_type @RuntimeCallIsValidBadReturnType [template]
  201. // CHECK:STDOUT: %RuntimeCallIsValidBadReturnType: %RuntimeCallIsValidBadReturnType.type = struct_value () [template]
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: imports {
  205. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  206. // CHECK:STDOUT: .Float = %Core.Float
  207. // CHECK:STDOUT: .Bool = %Core.Bool
  208. // CHECK:STDOUT: import Core//prelude
  209. // CHECK:STDOUT: import Core//prelude/...
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: file {
  214. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  215. // CHECK:STDOUT: .Core = imports.%Core
  216. // CHECK:STDOUT: .TooFew = %TooFew.decl
  217. // CHECK:STDOUT: .TooMany = %TooMany.decl
  218. // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl
  219. // CHECK:STDOUT: .JustRight = %JustRight.decl
  220. // CHECK:STDOUT: .RuntimeCallIsValidTooFew = %RuntimeCallIsValidTooFew.decl
  221. // CHECK:STDOUT: .RuntimeCallIsValidTooMany = %RuntimeCallIsValidTooMany.decl
  222. // CHECK:STDOUT: .RuntimeCallIsValidBadReturnType = %RuntimeCallIsValidBadReturnType.decl
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT: %Core.import = import Core
  225. // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] {
  226. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  227. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param0
  228. // CHECK:STDOUT: } {
  229. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  230. // CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64]
  231. // CHECK:STDOUT: %.loc8_16.1: type = value_of_initializer %float.make_type [template = f64]
  232. // CHECK:STDOUT: %.loc8_16.2: type = converted %float.make_type, %.loc8_16.1 [template = f64]
  233. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param0
  234. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT: %TooMany.decl: %TooMany.type = fn_decl @TooMany [template = constants.%TooMany] {
  237. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  238. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  239. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  240. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  241. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  242. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param2
  243. // CHECK:STDOUT: } {
  244. // CHECK:STDOUT: %int_64.loc13_31: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  245. // CHECK:STDOUT: %float.make_type.loc13_31: init type = call constants.%Float(%int_64.loc13_31) [template = f64]
  246. // CHECK:STDOUT: %.loc13_31.1: type = value_of_initializer %float.make_type.loc13_31 [template = f64]
  247. // CHECK:STDOUT: %.loc13_31.2: type = converted %float.make_type.loc13_31, %.loc13_31.1 [template = f64]
  248. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  249. // CHECK:STDOUT: %.loc13_15.1: type = splice_block %.loc13_15.3 [template = f64] {
  250. // CHECK:STDOUT: %int_64.loc13_15: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  251. // CHECK:STDOUT: %float.make_type.loc13_15: init type = call constants.%Float(%int_64.loc13_15) [template = f64]
  252. // CHECK:STDOUT: %.loc13_15.2: type = value_of_initializer %float.make_type.loc13_15 [template = f64]
  253. // CHECK:STDOUT: %.loc13_15.3: type = converted %float.make_type.loc13_15, %.loc13_15.2 [template = f64]
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  256. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  257. // CHECK:STDOUT: %.loc13_23.1: type = splice_block %.loc13_23.3 [template = f64] {
  258. // CHECK:STDOUT: %int_64.loc13_23: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  259. // CHECK:STDOUT: %float.make_type.loc13_23: init type = call constants.%Float(%int_64.loc13_23) [template = f64]
  260. // CHECK:STDOUT: %.loc13_23.2: type = value_of_initializer %float.make_type.loc13_23 [template = f64]
  261. // CHECK:STDOUT: %.loc13_23.3: type = converted %float.make_type.loc13_23, %.loc13_23.2 [template = f64]
  262. // CHECK:STDOUT: }
  263. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  264. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2
  265. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT: %BadReturnType.decl: %BadReturnType.type = fn_decl @BadReturnType [template = constants.%BadReturnType] {
  268. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  269. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  270. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  271. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param1
  272. // CHECK:STDOUT: } {
  273. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  274. // CHECK:STDOUT: %.loc18_29.1: type = value_of_initializer %bool.make_type [template = bool]
  275. // CHECK:STDOUT: %.loc18_29.2: type = converted %bool.make_type, %.loc18_29.1 [template = bool]
  276. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  277. // CHECK:STDOUT: %.loc18_21.1: type = splice_block %.loc18_21.3 [template = f64] {
  278. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  279. // CHECK:STDOUT: %float.make_type: init type = call constants.%Float(%int_64) [template = f64]
  280. // CHECK:STDOUT: %.loc18_21.2: type = value_of_initializer %float.make_type [template = f64]
  281. // CHECK:STDOUT: %.loc18_21.3: type = converted %float.make_type, %.loc18_21.2 [template = f64]
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  284. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param1
  285. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT: %JustRight.decl: %JustRight.type = fn_decl @JustRight [template = constants.%JustRight] {
  288. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  289. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  290. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  291. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param1
  292. // CHECK:STDOUT: } {
  293. // CHECK:STDOUT: %int_64.loc19_25: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  294. // CHECK:STDOUT: %float.make_type.loc19_25: init type = call constants.%Float(%int_64.loc19_25) [template = f64]
  295. // CHECK:STDOUT: %.loc19_25.1: type = value_of_initializer %float.make_type.loc19_25 [template = f64]
  296. // CHECK:STDOUT: %.loc19_25.2: type = converted %float.make_type.loc19_25, %.loc19_25.1 [template = f64]
  297. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  298. // CHECK:STDOUT: %.loc19_17.1: type = splice_block %.loc19_17.3 [template = f64] {
  299. // CHECK:STDOUT: %int_64.loc19_17: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  300. // CHECK:STDOUT: %float.make_type.loc19_17: init type = call constants.%Float(%int_64.loc19_17) [template = f64]
  301. // CHECK:STDOUT: %.loc19_17.2: type = value_of_initializer %float.make_type.loc19_17 [template = f64]
  302. // CHECK:STDOUT: %.loc19_17.3: type = converted %float.make_type.loc19_17, %.loc19_17.2 [template = f64]
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  305. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param1
  306. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT: %RuntimeCallIsValidTooFew.decl: %RuntimeCallIsValidTooFew.type = fn_decl @RuntimeCallIsValidTooFew [template = constants.%RuntimeCallIsValidTooFew] {
  309. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  310. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  311. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  312. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param1
  313. // CHECK:STDOUT: } {
  314. // CHECK:STDOUT: %int_64.loc21_40: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  315. // CHECK:STDOUT: %float.make_type.loc21_40: init type = call constants.%Float(%int_64.loc21_40) [template = f64]
  316. // CHECK:STDOUT: %.loc21_40.1: type = value_of_initializer %float.make_type.loc21_40 [template = f64]
  317. // CHECK:STDOUT: %.loc21_40.2: type = converted %float.make_type.loc21_40, %.loc21_40.1 [template = f64]
  318. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  319. // CHECK:STDOUT: %.loc21_32.1: type = splice_block %.loc21_32.3 [template = f64] {
  320. // CHECK:STDOUT: %int_64.loc21_32: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  321. // CHECK:STDOUT: %float.make_type.loc21_32: init type = call constants.%Float(%int_64.loc21_32) [template = f64]
  322. // CHECK:STDOUT: %.loc21_32.2: type = value_of_initializer %float.make_type.loc21_32 [template = f64]
  323. // CHECK:STDOUT: %.loc21_32.3: type = converted %float.make_type.loc21_32, %.loc21_32.2 [template = f64]
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  326. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param1
  327. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT: %RuntimeCallIsValidTooMany.decl: %RuntimeCallIsValidTooMany.type = fn_decl @RuntimeCallIsValidTooMany [template = constants.%RuntimeCallIsValidTooMany] {
  330. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  331. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  332. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  333. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  334. // CHECK:STDOUT: %c.patt: f64 = binding_pattern c
  335. // CHECK:STDOUT: %c.param_patt: f64 = value_param_pattern %c.patt, runtime_param2
  336. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  337. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param3
  338. // CHECK:STDOUT: } {
  339. // CHECK:STDOUT: %int_64.loc32_57: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  340. // CHECK:STDOUT: %float.make_type.loc32_57: init type = call constants.%Float(%int_64.loc32_57) [template = f64]
  341. // CHECK:STDOUT: %.loc32_57.1: type = value_of_initializer %float.make_type.loc32_57 [template = f64]
  342. // CHECK:STDOUT: %.loc32_57.2: type = converted %float.make_type.loc32_57, %.loc32_57.1 [template = f64]
  343. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  344. // CHECK:STDOUT: %.loc32_33.1: type = splice_block %.loc32_33.3 [template = f64] {
  345. // CHECK:STDOUT: %int_64.loc32_33: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  346. // CHECK:STDOUT: %float.make_type.loc32_33: init type = call constants.%Float(%int_64.loc32_33) [template = f64]
  347. // CHECK:STDOUT: %.loc32_33.2: type = value_of_initializer %float.make_type.loc32_33 [template = f64]
  348. // CHECK:STDOUT: %.loc32_33.3: type = converted %float.make_type.loc32_33, %.loc32_33.2 [template = f64]
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  351. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  352. // CHECK:STDOUT: %.loc32_41.1: type = splice_block %.loc32_41.3 [template = f64] {
  353. // CHECK:STDOUT: %int_64.loc32_41: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  354. // CHECK:STDOUT: %float.make_type.loc32_41: init type = call constants.%Float(%int_64.loc32_41) [template = f64]
  355. // CHECK:STDOUT: %.loc32_41.2: type = value_of_initializer %float.make_type.loc32_41 [template = f64]
  356. // CHECK:STDOUT: %.loc32_41.3: type = converted %float.make_type.loc32_41, %.loc32_41.2 [template = f64]
  357. // CHECK:STDOUT: }
  358. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  359. // CHECK:STDOUT: %c.param: f64 = value_param runtime_param2
  360. // CHECK:STDOUT: %.loc32_49.1: type = splice_block %.loc32_49.3 [template = f64] {
  361. // CHECK:STDOUT: %int_64.loc32_49: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  362. // CHECK:STDOUT: %float.make_type.loc32_49: init type = call constants.%Float(%int_64.loc32_49) [template = f64]
  363. // CHECK:STDOUT: %.loc32_49.2: type = value_of_initializer %float.make_type.loc32_49 [template = f64]
  364. // CHECK:STDOUT: %.loc32_49.3: type = converted %float.make_type.loc32_49, %.loc32_49.2 [template = f64]
  365. // CHECK:STDOUT: }
  366. // CHECK:STDOUT: %c: f64 = bind_name c, %c.param
  367. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param3
  368. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT: %RuntimeCallIsValidBadReturnType.decl: %RuntimeCallIsValidBadReturnType.type = fn_decl @RuntimeCallIsValidBadReturnType [template = constants.%RuntimeCallIsValidBadReturnType] {
  371. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  372. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  373. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  374. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  375. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  376. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  377. // CHECK:STDOUT: } {
  378. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  379. // CHECK:STDOUT: %.loc43_55.1: type = value_of_initializer %bool.make_type [template = bool]
  380. // CHECK:STDOUT: %.loc43_55.2: type = converted %bool.make_type, %.loc43_55.1 [template = bool]
  381. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  382. // CHECK:STDOUT: %.loc43_39.1: type = splice_block %.loc43_39.3 [template = f64] {
  383. // CHECK:STDOUT: %int_64.loc43_39: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  384. // CHECK:STDOUT: %float.make_type.loc43_39: init type = call constants.%Float(%int_64.loc43_39) [template = f64]
  385. // CHECK:STDOUT: %.loc43_39.2: type = value_of_initializer %float.make_type.loc43_39 [template = f64]
  386. // CHECK:STDOUT: %.loc43_39.3: type = converted %float.make_type.loc43_39, %.loc43_39.2 [template = f64]
  387. // CHECK:STDOUT: }
  388. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  389. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  390. // CHECK:STDOUT: %.loc43_47.1: type = splice_block %.loc43_47.3 [template = f64] {
  391. // CHECK:STDOUT: %int_64.loc43_47: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  392. // CHECK:STDOUT: %float.make_type.loc43_47: init type = call constants.%Float(%int_64.loc43_47) [template = f64]
  393. // CHECK:STDOUT: %.loc43_47.2: type = value_of_initializer %float.make_type.loc43_47 [template = f64]
  394. // CHECK:STDOUT: %.loc43_47.3: type = converted %float.make_type.loc43_47, %.loc43_47.2 [template = f64]
  395. // CHECK:STDOUT: }
  396. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  397. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  398. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: fn @TooFew() -> f64;
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: fn @TooMany(%a.param_patt: f64, %b.param_patt: f64) -> f64;
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: fn @BadReturnType(%a.param_patt: f64) -> bool;
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: fn @JustRight(%a.param_patt: f64) -> f64 = "float.negate";
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: fn @RuntimeCallIsValidTooFew(%a.param_patt: f64) -> f64 {
  411. // CHECK:STDOUT: !entry:
  412. // CHECK:STDOUT: %TooFew.ref: %TooFew.type = name_ref TooFew, file.%TooFew.decl [template = constants.%TooFew]
  413. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  414. // CHECK:STDOUT: return <error>
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: fn @RuntimeCallIsValidTooMany(%a.param_patt: f64, %b.param_patt: f64, %c.param_patt: f64) -> f64 {
  418. // CHECK:STDOUT: !entry:
  419. // CHECK:STDOUT: %TooMany.ref: %TooMany.type = name_ref TooMany, file.%TooMany.decl [template = constants.%TooMany]
  420. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  421. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  422. // CHECK:STDOUT: %c.ref: f64 = name_ref c, %c
  423. // CHECK:STDOUT: return <error>
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: fn @RuntimeCallIsValidBadReturnType(%a.param_patt: f64, %b.param_patt: f64) -> bool {
  427. // CHECK:STDOUT: !entry:
  428. // CHECK:STDOUT: %BadReturnType.ref: %BadReturnType.type = name_ref BadReturnType, file.%BadReturnType.decl [template = constants.%BadReturnType]
  429. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  430. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  431. // CHECK:STDOUT: return <error>
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT: