div.carbon 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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/div.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/float/div.carbon
  10. // --- float_div.carbon
  11. fn Div(a: f64, b: f64) -> f64 = "float.div";
  12. fn RuntimeCallIsValid(a: f64, b: f64) -> f64 {
  13. return Div(a, b);
  14. }
  15. var a: f64 = Div(10.0, 2.5);
  16. let b: f64 = Div(1.0, 0.0);
  17. let c: f64 = Div(0.0, 0.0);
  18. // --- fail_bad_decl.carbon
  19. package FailBadDecl;
  20. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.div" [InvalidBuiltinSignature]
  21. // CHECK:STDERR: fn TooFew(a: f64) -> f64 = "float.div";
  22. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
  23. // CHECK:STDERR:
  24. fn TooFew(a: f64) -> f64 = "float.div";
  25. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+4]]:1: error: invalid signature for builtin function "float.div" [InvalidBuiltinSignature]
  26. // CHECK:STDERR: fn TooMany(a: f64, b: f64, c: f64) -> f64 = "float.div";
  27. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. // CHECK:STDERR:
  29. fn TooMany(a: f64, b: f64, c: f64) -> f64 = "float.div";
  30. // CHECK:STDERR: fail_bad_decl.carbon:[[@LINE+3]]:1: error: invalid signature for builtin function "float.div" [InvalidBuiltinSignature]
  31. // CHECK:STDERR: fn BadReturnType(a: f64, b: f64) -> bool = "float.div";
  32. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. fn BadReturnType(a: f64, b: f64) -> bool = "float.div";
  34. fn JustRight(a: f64, b: f64) -> f64 = "float.div";
  35. fn RuntimeCallIsValidTooFew(a: f64) -> f64 {
  36. return TooFew(a);
  37. }
  38. fn RuntimeCallIsValidTooMany(a: f64, b: f64, c: f64) -> f64 {
  39. return TooMany(a, b, c);
  40. }
  41. fn RuntimeCallIsValidBadReturnType(a: f64, b: f64) -> bool {
  42. return BadReturnType(a, b);
  43. }
  44. // CHECK:STDOUT: --- float_div.carbon
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: constants {
  47. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template]
  48. // CHECK:STDOUT: %Float.type: type = fn_type @Float [template]
  49. // CHECK:STDOUT: %Float: %Float.type = struct_value () [template]
  50. // CHECK:STDOUT: %Div.type: type = fn_type @Div [template]
  51. // CHECK:STDOUT: %Div: %Div.type = struct_value () [template]
  52. // CHECK:STDOUT: %RuntimeCallIsValid.type: type = fn_type @RuntimeCallIsValid [template]
  53. // CHECK:STDOUT: %RuntimeCallIsValid: %RuntimeCallIsValid.type = struct_value () [template]
  54. // CHECK:STDOUT: %float.9a5: f64 = float_literal 10 [template]
  55. // CHECK:STDOUT: %float.33c: f64 = float_literal 2.5 [template]
  56. // CHECK:STDOUT: %float.a5c: f64 = float_literal 4 [template]
  57. // CHECK:STDOUT: %float.f4e: f64 = float_literal 1 [template]
  58. // CHECK:STDOUT: %float.555: f64 = float_literal 0 [template]
  59. // CHECK:STDOUT: %float.bd4: f64 = float_literal +Inf [template]
  60. // CHECK:STDOUT: %float.8b7: f64 = float_literal NaN [template]
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: imports {
  64. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  65. // CHECK:STDOUT: .Float = %import_ref
  66. // CHECK:STDOUT: import Core//prelude
  67. // CHECK:STDOUT: import Core//prelude/...
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: file {
  72. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  73. // CHECK:STDOUT: .Core = imports.%Core
  74. // CHECK:STDOUT: .Div = %Div.decl
  75. // CHECK:STDOUT: .RuntimeCallIsValid = %RuntimeCallIsValid.decl
  76. // CHECK:STDOUT: .a = %a
  77. // CHECK:STDOUT: .b = @__global_init.%b
  78. // CHECK:STDOUT: .c = @__global_init.%c
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: %Core.import = import Core
  81. // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] {
  82. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  83. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  84. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  85. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  86. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  87. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param2
  88. // CHECK:STDOUT: } {
  89. // CHECK:STDOUT: %int_64.loc2_27: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  90. // CHECK:STDOUT: %float.make_type.loc2_27: init type = call constants.%Float(%int_64.loc2_27) [template = f64]
  91. // CHECK:STDOUT: %.loc2_27.1: type = value_of_initializer %float.make_type.loc2_27 [template = f64]
  92. // CHECK:STDOUT: %.loc2_27.2: type = converted %float.make_type.loc2_27, %.loc2_27.1 [template = f64]
  93. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  94. // CHECK:STDOUT: %.loc2_11.1: type = splice_block %.loc2_11.3 [template = f64] {
  95. // CHECK:STDOUT: %int_64.loc2_11: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  96. // CHECK:STDOUT: %float.make_type.loc2_11: init type = call constants.%Float(%int_64.loc2_11) [template = f64]
  97. // CHECK:STDOUT: %.loc2_11.2: type = value_of_initializer %float.make_type.loc2_11 [template = f64]
  98. // CHECK:STDOUT: %.loc2_11.3: type = converted %float.make_type.loc2_11, %.loc2_11.2 [template = f64]
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  101. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  102. // CHECK:STDOUT: %.loc2_19.1: type = splice_block %.loc2_19.3 [template = f64] {
  103. // CHECK:STDOUT: %int_64.loc2_19: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  104. // CHECK:STDOUT: %float.make_type.loc2_19: init type = call constants.%Float(%int_64.loc2_19) [template = f64]
  105. // CHECK:STDOUT: %.loc2_19.2: type = value_of_initializer %float.make_type.loc2_19 [template = f64]
  106. // CHECK:STDOUT: %.loc2_19.3: type = converted %float.make_type.loc2_19, %.loc2_19.2 [template = f64]
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  109. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2
  110. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: %RuntimeCallIsValid.decl: %RuntimeCallIsValid.type = fn_decl @RuntimeCallIsValid [template = constants.%RuntimeCallIsValid] {
  113. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  114. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  115. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  116. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  117. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  118. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param2
  119. // CHECK:STDOUT: } {
  120. // CHECK:STDOUT: %int_64.loc4_42: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  121. // CHECK:STDOUT: %float.make_type.loc4_42: init type = call constants.%Float(%int_64.loc4_42) [template = f64]
  122. // CHECK:STDOUT: %.loc4_42.1: type = value_of_initializer %float.make_type.loc4_42 [template = f64]
  123. // CHECK:STDOUT: %.loc4_42.2: type = converted %float.make_type.loc4_42, %.loc4_42.1 [template = f64]
  124. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  125. // CHECK:STDOUT: %.loc4_26.1: type = splice_block %.loc4_26.3 [template = f64] {
  126. // CHECK:STDOUT: %int_64.loc4_26: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  127. // CHECK:STDOUT: %float.make_type.loc4_26: init type = call constants.%Float(%int_64.loc4_26) [template = f64]
  128. // CHECK:STDOUT: %.loc4_26.2: type = value_of_initializer %float.make_type.loc4_26 [template = f64]
  129. // CHECK:STDOUT: %.loc4_26.3: type = converted %float.make_type.loc4_26, %.loc4_26.2 [template = f64]
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  132. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  133. // CHECK:STDOUT: %.loc4_34.1: type = splice_block %.loc4_34.3 [template = f64] {
  134. // CHECK:STDOUT: %int_64.loc4_34: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  135. // CHECK:STDOUT: %float.make_type.loc4_34: init type = call constants.%Float(%int_64.loc4_34) [template = f64]
  136. // CHECK:STDOUT: %.loc4_34.2: type = value_of_initializer %float.make_type.loc4_34 [template = f64]
  137. // CHECK:STDOUT: %.loc4_34.3: type = converted %float.make_type.loc4_34, %.loc4_34.2 [template = f64]
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  140. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2
  141. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT: %a.var: ref f64 = var a
  144. // CHECK:STDOUT: %a: ref f64 = bind_name a, %a.var
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: fn @Div(%a.param_patt: f64, %b.param_patt: f64) -> f64 = "float.div";
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: fn @RuntimeCallIsValid(%a.param_patt: f64, %b.param_patt: f64) -> f64 {
  150. // CHECK:STDOUT: !entry:
  151. // CHECK:STDOUT: %Div.ref: %Div.type = name_ref Div, file.%Div.decl [template = constants.%Div]
  152. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  153. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  154. // CHECK:STDOUT: %float.div: init f64 = call %Div.ref(%a.ref, %b.ref)
  155. // CHECK:STDOUT: %.loc5_19.1: f64 = value_of_initializer %float.div
  156. // CHECK:STDOUT: %.loc5_19.2: f64 = converted %float.div, %.loc5_19.1
  157. // CHECK:STDOUT: return %.loc5_19.2
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: fn @__global_init() {
  161. // CHECK:STDOUT: !entry:
  162. // CHECK:STDOUT: %Div.ref.loc8: %Div.type = name_ref Div, file.%Div.decl [template = constants.%Div]
  163. // CHECK:STDOUT: %float.loc8_18: f64 = float_literal 10 [template = constants.%float.9a5]
  164. // CHECK:STDOUT: %float.loc8_24: f64 = float_literal 2.5 [template = constants.%float.33c]
  165. // CHECK:STDOUT: %float.div.loc8: init f64 = call %Div.ref.loc8(%float.loc8_18, %float.loc8_24) [template = constants.%float.a5c]
  166. // CHECK:STDOUT: assign file.%a.var, %float.div.loc8
  167. // CHECK:STDOUT: %Div.ref.loc9: %Div.type = name_ref Div, file.%Div.decl [template = constants.%Div]
  168. // CHECK:STDOUT: %float.loc9_18: f64 = float_literal 1 [template = constants.%float.f4e]
  169. // CHECK:STDOUT: %float.loc9_23: f64 = float_literal 0 [template = constants.%float.555]
  170. // CHECK:STDOUT: %float.div.loc9: init f64 = call %Div.ref.loc9(%float.loc9_18, %float.loc9_23) [template = constants.%float.bd4]
  171. // CHECK:STDOUT: %.loc9_27.1: f64 = value_of_initializer %float.div.loc9 [template = constants.%float.bd4]
  172. // CHECK:STDOUT: %.loc9_27.2: f64 = converted %float.div.loc9, %.loc9_27.1 [template = constants.%float.bd4]
  173. // CHECK:STDOUT: %b: f64 = bind_name b, %.loc9_27.2
  174. // CHECK:STDOUT: %Div.ref.loc10: %Div.type = name_ref Div, file.%Div.decl [template = constants.%Div]
  175. // CHECK:STDOUT: %float.loc10_18: f64 = float_literal 0 [template = constants.%float.555]
  176. // CHECK:STDOUT: %float.loc10_23: f64 = float_literal 0 [template = constants.%float.555]
  177. // CHECK:STDOUT: %float.div.loc10: init f64 = call %Div.ref.loc10(%float.loc10_18, %float.loc10_23) [template = constants.%float.8b7]
  178. // CHECK:STDOUT: %.loc10_27.1: f64 = value_of_initializer %float.div.loc10 [template = constants.%float.8b7]
  179. // CHECK:STDOUT: %.loc10_27.2: f64 = converted %float.div.loc10, %.loc10_27.1 [template = constants.%float.8b7]
  180. // CHECK:STDOUT: %c: f64 = bind_name c, %.loc10_27.2
  181. // CHECK:STDOUT: return
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: --- fail_bad_decl.carbon
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: constants {
  187. // CHECK:STDOUT: %int_64: Core.IntLiteral = int_value 64 [template]
  188. // CHECK:STDOUT: %Float.type: type = fn_type @Float [template]
  189. // CHECK:STDOUT: %Float: %Float.type = struct_value () [template]
  190. // CHECK:STDOUT: %TooFew.type: type = fn_type @TooFew [template]
  191. // CHECK:STDOUT: %TooFew: %TooFew.type = struct_value () [template]
  192. // CHECK:STDOUT: %TooMany.type: type = fn_type @TooMany [template]
  193. // CHECK:STDOUT: %TooMany: %TooMany.type = struct_value () [template]
  194. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  195. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  196. // CHECK:STDOUT: %BadReturnType.type: type = fn_type @BadReturnType [template]
  197. // CHECK:STDOUT: %BadReturnType: %BadReturnType.type = struct_value () [template]
  198. // CHECK:STDOUT: %JustRight.type: type = fn_type @JustRight [template]
  199. // CHECK:STDOUT: %JustRight: %JustRight.type = struct_value () [template]
  200. // CHECK:STDOUT: %RuntimeCallIsValidTooFew.type: type = fn_type @RuntimeCallIsValidTooFew [template]
  201. // CHECK:STDOUT: %RuntimeCallIsValidTooFew: %RuntimeCallIsValidTooFew.type = struct_value () [template]
  202. // CHECK:STDOUT: %RuntimeCallIsValidTooMany.type: type = fn_type @RuntimeCallIsValidTooMany [template]
  203. // CHECK:STDOUT: %RuntimeCallIsValidTooMany: %RuntimeCallIsValidTooMany.type = struct_value () [template]
  204. // CHECK:STDOUT: %RuntimeCallIsValidBadReturnType.type: type = fn_type @RuntimeCallIsValidBadReturnType [template]
  205. // CHECK:STDOUT: %RuntimeCallIsValidBadReturnType: %RuntimeCallIsValidBadReturnType.type = struct_value () [template]
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: imports {
  209. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  210. // CHECK:STDOUT: .Float = %import_ref.20b
  211. // CHECK:STDOUT: .Bool = %import_ref.f7c
  212. // CHECK:STDOUT: import Core//prelude
  213. // CHECK:STDOUT: import Core//prelude/...
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: file {
  218. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  219. // CHECK:STDOUT: .Core = imports.%Core
  220. // CHECK:STDOUT: .TooFew = %TooFew.decl
  221. // CHECK:STDOUT: .TooMany = %TooMany.decl
  222. // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl
  223. // CHECK:STDOUT: .JustRight = %JustRight.decl
  224. // CHECK:STDOUT: .RuntimeCallIsValidTooFew = %RuntimeCallIsValidTooFew.decl
  225. // CHECK:STDOUT: .RuntimeCallIsValidTooMany = %RuntimeCallIsValidTooMany.decl
  226. // CHECK:STDOUT: .RuntimeCallIsValidBadReturnType = %RuntimeCallIsValidBadReturnType.decl
  227. // CHECK:STDOUT: }
  228. // CHECK:STDOUT: %Core.import = import Core
  229. // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] {
  230. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  231. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  232. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  233. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param1
  234. // CHECK:STDOUT: } {
  235. // CHECK:STDOUT: %int_64.loc8_22: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  236. // CHECK:STDOUT: %float.make_type.loc8_22: init type = call constants.%Float(%int_64.loc8_22) [template = f64]
  237. // CHECK:STDOUT: %.loc8_22.1: type = value_of_initializer %float.make_type.loc8_22 [template = f64]
  238. // CHECK:STDOUT: %.loc8_22.2: type = converted %float.make_type.loc8_22, %.loc8_22.1 [template = f64]
  239. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  240. // CHECK:STDOUT: %.loc8_14.1: type = splice_block %.loc8_14.3 [template = f64] {
  241. // CHECK:STDOUT: %int_64.loc8_14: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  242. // CHECK:STDOUT: %float.make_type.loc8_14: init type = call constants.%Float(%int_64.loc8_14) [template = f64]
  243. // CHECK:STDOUT: %.loc8_14.2: type = value_of_initializer %float.make_type.loc8_14 [template = f64]
  244. // CHECK:STDOUT: %.loc8_14.3: type = converted %float.make_type.loc8_14, %.loc8_14.2 [template = f64]
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  247. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param1
  248. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT: %TooMany.decl: %TooMany.type = fn_decl @TooMany [template = constants.%TooMany] {
  251. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  252. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  253. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  254. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  255. // CHECK:STDOUT: %c.patt: f64 = binding_pattern c
  256. // CHECK:STDOUT: %c.param_patt: f64 = value_param_pattern %c.patt, runtime_param2
  257. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  258. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param3
  259. // CHECK:STDOUT: } {
  260. // CHECK:STDOUT: %int_64.loc13_39: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  261. // CHECK:STDOUT: %float.make_type.loc13_39: init type = call constants.%Float(%int_64.loc13_39) [template = f64]
  262. // CHECK:STDOUT: %.loc13_39.1: type = value_of_initializer %float.make_type.loc13_39 [template = f64]
  263. // CHECK:STDOUT: %.loc13_39.2: type = converted %float.make_type.loc13_39, %.loc13_39.1 [template = f64]
  264. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  265. // CHECK:STDOUT: %.loc13_15.1: type = splice_block %.loc13_15.3 [template = f64] {
  266. // CHECK:STDOUT: %int_64.loc13_15: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  267. // CHECK:STDOUT: %float.make_type.loc13_15: init type = call constants.%Float(%int_64.loc13_15) [template = f64]
  268. // CHECK:STDOUT: %.loc13_15.2: type = value_of_initializer %float.make_type.loc13_15 [template = f64]
  269. // CHECK:STDOUT: %.loc13_15.3: type = converted %float.make_type.loc13_15, %.loc13_15.2 [template = f64]
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  272. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  273. // CHECK:STDOUT: %.loc13_23.1: type = splice_block %.loc13_23.3 [template = f64] {
  274. // CHECK:STDOUT: %int_64.loc13_23: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  275. // CHECK:STDOUT: %float.make_type.loc13_23: init type = call constants.%Float(%int_64.loc13_23) [template = f64]
  276. // CHECK:STDOUT: %.loc13_23.2: type = value_of_initializer %float.make_type.loc13_23 [template = f64]
  277. // CHECK:STDOUT: %.loc13_23.3: type = converted %float.make_type.loc13_23, %.loc13_23.2 [template = f64]
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  280. // CHECK:STDOUT: %c.param: f64 = value_param runtime_param2
  281. // CHECK:STDOUT: %.loc13_31.1: type = splice_block %.loc13_31.3 [template = f64] {
  282. // CHECK:STDOUT: %int_64.loc13_31: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  283. // CHECK:STDOUT: %float.make_type.loc13_31: init type = call constants.%Float(%int_64.loc13_31) [template = f64]
  284. // CHECK:STDOUT: %.loc13_31.2: type = value_of_initializer %float.make_type.loc13_31 [template = f64]
  285. // CHECK:STDOUT: %.loc13_31.3: type = converted %float.make_type.loc13_31, %.loc13_31.2 [template = f64]
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT: %c: f64 = bind_name c, %c.param
  288. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param3
  289. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT: %BadReturnType.decl: %BadReturnType.type = fn_decl @BadReturnType [template = constants.%BadReturnType] {
  292. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  293. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  294. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  295. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  296. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  297. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  298. // CHECK:STDOUT: } {
  299. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  300. // CHECK:STDOUT: %.loc17_37.1: type = value_of_initializer %bool.make_type [template = bool]
  301. // CHECK:STDOUT: %.loc17_37.2: type = converted %bool.make_type, %.loc17_37.1 [template = bool]
  302. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  303. // CHECK:STDOUT: %.loc17_21.1: type = splice_block %.loc17_21.3 [template = f64] {
  304. // CHECK:STDOUT: %int_64.loc17_21: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  305. // CHECK:STDOUT: %float.make_type.loc17_21: init type = call constants.%Float(%int_64.loc17_21) [template = f64]
  306. // CHECK:STDOUT: %.loc17_21.2: type = value_of_initializer %float.make_type.loc17_21 [template = f64]
  307. // CHECK:STDOUT: %.loc17_21.3: type = converted %float.make_type.loc17_21, %.loc17_21.2 [template = f64]
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  310. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  311. // CHECK:STDOUT: %.loc17_29.1: type = splice_block %.loc17_29.3 [template = f64] {
  312. // CHECK:STDOUT: %int_64.loc17_29: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  313. // CHECK:STDOUT: %float.make_type.loc17_29: init type = call constants.%Float(%int_64.loc17_29) [template = f64]
  314. // CHECK:STDOUT: %.loc17_29.2: type = value_of_initializer %float.make_type.loc17_29 [template = f64]
  315. // CHECK:STDOUT: %.loc17_29.3: type = converted %float.make_type.loc17_29, %.loc17_29.2 [template = f64]
  316. // CHECK:STDOUT: }
  317. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  318. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  319. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  320. // CHECK:STDOUT: }
  321. // CHECK:STDOUT: %JustRight.decl: %JustRight.type = fn_decl @JustRight [template = constants.%JustRight] {
  322. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  323. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  324. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  325. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  326. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  327. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param2
  328. // CHECK:STDOUT: } {
  329. // CHECK:STDOUT: %int_64.loc18_33: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  330. // CHECK:STDOUT: %float.make_type.loc18_33: init type = call constants.%Float(%int_64.loc18_33) [template = f64]
  331. // CHECK:STDOUT: %.loc18_33.1: type = value_of_initializer %float.make_type.loc18_33 [template = f64]
  332. // CHECK:STDOUT: %.loc18_33.2: type = converted %float.make_type.loc18_33, %.loc18_33.1 [template = f64]
  333. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  334. // CHECK:STDOUT: %.loc18_17.1: type = splice_block %.loc18_17.3 [template = f64] {
  335. // CHECK:STDOUT: %int_64.loc18_17: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  336. // CHECK:STDOUT: %float.make_type.loc18_17: init type = call constants.%Float(%int_64.loc18_17) [template = f64]
  337. // CHECK:STDOUT: %.loc18_17.2: type = value_of_initializer %float.make_type.loc18_17 [template = f64]
  338. // CHECK:STDOUT: %.loc18_17.3: type = converted %float.make_type.loc18_17, %.loc18_17.2 [template = f64]
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  341. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  342. // CHECK:STDOUT: %.loc18_25.1: type = splice_block %.loc18_25.3 [template = f64] {
  343. // CHECK:STDOUT: %int_64.loc18_25: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  344. // CHECK:STDOUT: %float.make_type.loc18_25: init type = call constants.%Float(%int_64.loc18_25) [template = f64]
  345. // CHECK:STDOUT: %.loc18_25.2: type = value_of_initializer %float.make_type.loc18_25 [template = f64]
  346. // CHECK:STDOUT: %.loc18_25.3: type = converted %float.make_type.loc18_25, %.loc18_25.2 [template = f64]
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  349. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param2
  350. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT: %RuntimeCallIsValidTooFew.decl: %RuntimeCallIsValidTooFew.type = fn_decl @RuntimeCallIsValidTooFew [template = constants.%RuntimeCallIsValidTooFew] {
  353. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  354. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  355. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  356. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param1
  357. // CHECK:STDOUT: } {
  358. // CHECK:STDOUT: %int_64.loc20_40: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  359. // CHECK:STDOUT: %float.make_type.loc20_40: init type = call constants.%Float(%int_64.loc20_40) [template = f64]
  360. // CHECK:STDOUT: %.loc20_40.1: type = value_of_initializer %float.make_type.loc20_40 [template = f64]
  361. // CHECK:STDOUT: %.loc20_40.2: type = converted %float.make_type.loc20_40, %.loc20_40.1 [template = f64]
  362. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  363. // CHECK:STDOUT: %.loc20_32.1: type = splice_block %.loc20_32.3 [template = f64] {
  364. // CHECK:STDOUT: %int_64.loc20_32: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  365. // CHECK:STDOUT: %float.make_type.loc20_32: init type = call constants.%Float(%int_64.loc20_32) [template = f64]
  366. // CHECK:STDOUT: %.loc20_32.2: type = value_of_initializer %float.make_type.loc20_32 [template = f64]
  367. // CHECK:STDOUT: %.loc20_32.3: type = converted %float.make_type.loc20_32, %.loc20_32.2 [template = f64]
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  370. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param1
  371. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT: %RuntimeCallIsValidTooMany.decl: %RuntimeCallIsValidTooMany.type = fn_decl @RuntimeCallIsValidTooMany [template = constants.%RuntimeCallIsValidTooMany] {
  374. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  375. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  376. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  377. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  378. // CHECK:STDOUT: %c.patt: f64 = binding_pattern c
  379. // CHECK:STDOUT: %c.param_patt: f64 = value_param_pattern %c.patt, runtime_param2
  380. // CHECK:STDOUT: %return.patt: f64 = return_slot_pattern
  381. // CHECK:STDOUT: %return.param_patt: f64 = out_param_pattern %return.patt, runtime_param3
  382. // CHECK:STDOUT: } {
  383. // CHECK:STDOUT: %int_64.loc24_57: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  384. // CHECK:STDOUT: %float.make_type.loc24_57: init type = call constants.%Float(%int_64.loc24_57) [template = f64]
  385. // CHECK:STDOUT: %.loc24_57.1: type = value_of_initializer %float.make_type.loc24_57 [template = f64]
  386. // CHECK:STDOUT: %.loc24_57.2: type = converted %float.make_type.loc24_57, %.loc24_57.1 [template = f64]
  387. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  388. // CHECK:STDOUT: %.loc24_33.1: type = splice_block %.loc24_33.3 [template = f64] {
  389. // CHECK:STDOUT: %int_64.loc24_33: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  390. // CHECK:STDOUT: %float.make_type.loc24_33: init type = call constants.%Float(%int_64.loc24_33) [template = f64]
  391. // CHECK:STDOUT: %.loc24_33.2: type = value_of_initializer %float.make_type.loc24_33 [template = f64]
  392. // CHECK:STDOUT: %.loc24_33.3: type = converted %float.make_type.loc24_33, %.loc24_33.2 [template = f64]
  393. // CHECK:STDOUT: }
  394. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  395. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  396. // CHECK:STDOUT: %.loc24_41.1: type = splice_block %.loc24_41.3 [template = f64] {
  397. // CHECK:STDOUT: %int_64.loc24_41: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  398. // CHECK:STDOUT: %float.make_type.loc24_41: init type = call constants.%Float(%int_64.loc24_41) [template = f64]
  399. // CHECK:STDOUT: %.loc24_41.2: type = value_of_initializer %float.make_type.loc24_41 [template = f64]
  400. // CHECK:STDOUT: %.loc24_41.3: type = converted %float.make_type.loc24_41, %.loc24_41.2 [template = f64]
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  403. // CHECK:STDOUT: %c.param: f64 = value_param runtime_param2
  404. // CHECK:STDOUT: %.loc24_49.1: type = splice_block %.loc24_49.3 [template = f64] {
  405. // CHECK:STDOUT: %int_64.loc24_49: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  406. // CHECK:STDOUT: %float.make_type.loc24_49: init type = call constants.%Float(%int_64.loc24_49) [template = f64]
  407. // CHECK:STDOUT: %.loc24_49.2: type = value_of_initializer %float.make_type.loc24_49 [template = f64]
  408. // CHECK:STDOUT: %.loc24_49.3: type = converted %float.make_type.loc24_49, %.loc24_49.2 [template = f64]
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT: %c: f64 = bind_name c, %c.param
  411. // CHECK:STDOUT: %return.param: ref f64 = out_param runtime_param3
  412. // CHECK:STDOUT: %return: ref f64 = return_slot %return.param
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT: %RuntimeCallIsValidBadReturnType.decl: %RuntimeCallIsValidBadReturnType.type = fn_decl @RuntimeCallIsValidBadReturnType [template = constants.%RuntimeCallIsValidBadReturnType] {
  415. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  416. // CHECK:STDOUT: %a.param_patt: f64 = value_param_pattern %a.patt, runtime_param0
  417. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  418. // CHECK:STDOUT: %b.param_patt: f64 = value_param_pattern %b.patt, runtime_param1
  419. // CHECK:STDOUT: %return.patt: bool = return_slot_pattern
  420. // CHECK:STDOUT: %return.param_patt: bool = out_param_pattern %return.patt, runtime_param2
  421. // CHECK:STDOUT: } {
  422. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  423. // CHECK:STDOUT: %.loc28_55.1: type = value_of_initializer %bool.make_type [template = bool]
  424. // CHECK:STDOUT: %.loc28_55.2: type = converted %bool.make_type, %.loc28_55.1 [template = bool]
  425. // CHECK:STDOUT: %a.param: f64 = value_param runtime_param0
  426. // CHECK:STDOUT: %.loc28_39.1: type = splice_block %.loc28_39.3 [template = f64] {
  427. // CHECK:STDOUT: %int_64.loc28_39: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  428. // CHECK:STDOUT: %float.make_type.loc28_39: init type = call constants.%Float(%int_64.loc28_39) [template = f64]
  429. // CHECK:STDOUT: %.loc28_39.2: type = value_of_initializer %float.make_type.loc28_39 [template = f64]
  430. // CHECK:STDOUT: %.loc28_39.3: type = converted %float.make_type.loc28_39, %.loc28_39.2 [template = f64]
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  433. // CHECK:STDOUT: %b.param: f64 = value_param runtime_param1
  434. // CHECK:STDOUT: %.loc28_47.1: type = splice_block %.loc28_47.3 [template = f64] {
  435. // CHECK:STDOUT: %int_64.loc28_47: Core.IntLiteral = int_value 64 [template = constants.%int_64]
  436. // CHECK:STDOUT: %float.make_type.loc28_47: init type = call constants.%Float(%int_64.loc28_47) [template = f64]
  437. // CHECK:STDOUT: %.loc28_47.2: type = value_of_initializer %float.make_type.loc28_47 [template = f64]
  438. // CHECK:STDOUT: %.loc28_47.3: type = converted %float.make_type.loc28_47, %.loc28_47.2 [template = f64]
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  441. // CHECK:STDOUT: %return.param: ref bool = out_param runtime_param2
  442. // CHECK:STDOUT: %return: ref bool = return_slot %return.param
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: fn @TooFew(%a.param_patt: f64) -> f64;
  447. // CHECK:STDOUT:
  448. // CHECK:STDOUT: fn @TooMany(%a.param_patt: f64, %b.param_patt: f64, %c.param_patt: f64) -> f64;
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: fn @BadReturnType(%a.param_patt: f64, %b.param_patt: f64) -> bool;
  451. // CHECK:STDOUT:
  452. // CHECK:STDOUT: fn @JustRight(%a.param_patt: f64, %b.param_patt: f64) -> f64 = "float.div";
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: fn @RuntimeCallIsValidTooFew(%a.param_patt: f64) -> f64 {
  455. // CHECK:STDOUT: !entry:
  456. // CHECK:STDOUT: %TooFew.ref: %TooFew.type = name_ref TooFew, file.%TooFew.decl [template = constants.%TooFew]
  457. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  458. // CHECK:STDOUT: %TooFew.call: init f64 = call %TooFew.ref(%a.ref)
  459. // CHECK:STDOUT: %.loc21_19.1: f64 = value_of_initializer %TooFew.call
  460. // CHECK:STDOUT: %.loc21_19.2: f64 = converted %TooFew.call, %.loc21_19.1
  461. // CHECK:STDOUT: return %.loc21_19.2
  462. // CHECK:STDOUT: }
  463. // CHECK:STDOUT:
  464. // CHECK:STDOUT: fn @RuntimeCallIsValidTooMany(%a.param_patt: f64, %b.param_patt: f64, %c.param_patt: f64) -> f64 {
  465. // CHECK:STDOUT: !entry:
  466. // CHECK:STDOUT: %TooMany.ref: %TooMany.type = name_ref TooMany, file.%TooMany.decl [template = constants.%TooMany]
  467. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  468. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  469. // CHECK:STDOUT: %c.ref: f64 = name_ref c, %c
  470. // CHECK:STDOUT: %TooMany.call: init f64 = call %TooMany.ref(%a.ref, %b.ref, %c.ref)
  471. // CHECK:STDOUT: %.loc25_26.1: f64 = value_of_initializer %TooMany.call
  472. // CHECK:STDOUT: %.loc25_26.2: f64 = converted %TooMany.call, %.loc25_26.1
  473. // CHECK:STDOUT: return %.loc25_26.2
  474. // CHECK:STDOUT: }
  475. // CHECK:STDOUT:
  476. // CHECK:STDOUT: fn @RuntimeCallIsValidBadReturnType(%a.param_patt: f64, %b.param_patt: f64) -> bool {
  477. // CHECK:STDOUT: !entry:
  478. // CHECK:STDOUT: %BadReturnType.ref: %BadReturnType.type = name_ref BadReturnType, file.%BadReturnType.decl [template = constants.%BadReturnType]
  479. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  480. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  481. // CHECK:STDOUT: %BadReturnType.call: init bool = call %BadReturnType.ref(%a.ref, %b.ref)
  482. // CHECK:STDOUT: %.loc29_29.1: bool = value_of_initializer %BadReturnType.call
  483. // CHECK:STDOUT: %.loc29_29.2: bool = converted %BadReturnType.call, %.loc29_29.1
  484. // CHECK:STDOUT: return %.loc29_29.2
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT: