div.carbon 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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 RuntimeCall(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"
  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"
  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"
  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 RuntimeCallTooFew(a: f64) -> f64 {
  36. return TooFew(a);
  37. }
  38. fn RuntimeCallTooMany(a: f64, b: f64, c: f64) -> f64 {
  39. return TooMany(a, b, c);
  40. }
  41. fn RuntimeCallBadReturnType(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: %.1: i32 = int_literal 64 [template]
  48. // CHECK:STDOUT: %Float.type: type = fn_type @Float [template]
  49. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  50. // CHECK:STDOUT: %Float: %Float.type = struct_value () [template]
  51. // CHECK:STDOUT: %Div.type: type = fn_type @Div [template]
  52. // CHECK:STDOUT: %Div: %Div.type = struct_value () [template]
  53. // CHECK:STDOUT: %RuntimeCall.type: type = fn_type @RuntimeCall [template]
  54. // CHECK:STDOUT: %RuntimeCall: %RuntimeCall.type = struct_value () [template]
  55. // CHECK:STDOUT: %.3: f64 = float_literal 10 [template]
  56. // CHECK:STDOUT: %.4: f64 = float_literal 2.5 [template]
  57. // CHECK:STDOUT: %.5: f64 = float_literal 4 [template]
  58. // CHECK:STDOUT: %.6: f64 = float_literal 1 [template]
  59. // CHECK:STDOUT: %.7: f64 = float_literal 0 [template]
  60. // CHECK:STDOUT: %.8: f64 = float_literal +Inf [template]
  61. // CHECK:STDOUT: %.9: f64 = float_literal NaN [template]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: imports {
  65. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  66. // CHECK:STDOUT: .Float = %import_ref
  67. // CHECK:STDOUT: import Core//prelude
  68. // CHECK:STDOUT: import Core//prelude/operators
  69. // CHECK:STDOUT: import Core//prelude/types
  70. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  71. // CHECK:STDOUT: import Core//prelude/operators/as
  72. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  73. // CHECK:STDOUT: import Core//prelude/operators/comparison
  74. // CHECK:STDOUT: import Core//prelude/types/bool
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %import_ref: %Float.type = import_ref Core//prelude/types, inst+35, loaded [template = constants.%Float]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: file {
  80. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  81. // CHECK:STDOUT: .Core = imports.%Core
  82. // CHECK:STDOUT: .Div = %Div.decl
  83. // CHECK:STDOUT: .RuntimeCall = %RuntimeCall.decl
  84. // CHECK:STDOUT: .a = %a
  85. // CHECK:STDOUT: .b = @__global_init.%b
  86. // CHECK:STDOUT: .c = @__global_init.%c
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: %Core.import = import Core
  89. // CHECK:STDOUT: %Div.decl: %Div.type = fn_decl @Div [template = constants.%Div] {
  90. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  91. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  92. // CHECK:STDOUT: } {
  93. // CHECK:STDOUT: %.loc2_11.1: i32 = int_literal 64 [template = constants.%.1]
  94. // CHECK:STDOUT: %float.make_type.loc2_11: init type = call constants.%Float(%.loc2_11.1) [template = f64]
  95. // CHECK:STDOUT: %.loc2_11.2: type = value_of_initializer %float.make_type.loc2_11 [template = f64]
  96. // CHECK:STDOUT: %.loc2_11.3: type = converted %float.make_type.loc2_11, %.loc2_11.2 [template = f64]
  97. // CHECK:STDOUT: %a.param: f64 = param a, runtime_param0
  98. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  99. // CHECK:STDOUT: %.loc2_19.1: i32 = int_literal 64 [template = constants.%.1]
  100. // CHECK:STDOUT: %float.make_type.loc2_19: init type = call constants.%Float(%.loc2_19.1) [template = f64]
  101. // CHECK:STDOUT: %.loc2_19.2: type = value_of_initializer %float.make_type.loc2_19 [template = f64]
  102. // CHECK:STDOUT: %.loc2_19.3: type = converted %float.make_type.loc2_19, %.loc2_19.2 [template = f64]
  103. // CHECK:STDOUT: %b.param: f64 = param b, runtime_param1
  104. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  105. // CHECK:STDOUT: %.loc2_27.1: i32 = int_literal 64 [template = constants.%.1]
  106. // CHECK:STDOUT: %float.make_type.loc2_27: init type = call constants.%Float(%.loc2_27.1) [template = f64]
  107. // CHECK:STDOUT: %.loc2_27.2: type = value_of_initializer %float.make_type.loc2_27 [template = f64]
  108. // CHECK:STDOUT: %.loc2_27.3: type = converted %float.make_type.loc2_27, %.loc2_27.2 [template = f64]
  109. // CHECK:STDOUT: %return: ref f64 = var <return slot>
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT: %RuntimeCall.decl: %RuntimeCall.type = fn_decl @RuntimeCall [template = constants.%RuntimeCall] {
  112. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  113. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  114. // CHECK:STDOUT: } {
  115. // CHECK:STDOUT: %.loc4_19.1: i32 = int_literal 64 [template = constants.%.1]
  116. // CHECK:STDOUT: %float.make_type.loc4_19: init type = call constants.%Float(%.loc4_19.1) [template = f64]
  117. // CHECK:STDOUT: %.loc4_19.2: type = value_of_initializer %float.make_type.loc4_19 [template = f64]
  118. // CHECK:STDOUT: %.loc4_19.3: type = converted %float.make_type.loc4_19, %.loc4_19.2 [template = f64]
  119. // CHECK:STDOUT: %a.param: f64 = param a, runtime_param0
  120. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  121. // CHECK:STDOUT: %.loc4_27.1: i32 = int_literal 64 [template = constants.%.1]
  122. // CHECK:STDOUT: %float.make_type.loc4_27: init type = call constants.%Float(%.loc4_27.1) [template = f64]
  123. // CHECK:STDOUT: %.loc4_27.2: type = value_of_initializer %float.make_type.loc4_27 [template = f64]
  124. // CHECK:STDOUT: %.loc4_27.3: type = converted %float.make_type.loc4_27, %.loc4_27.2 [template = f64]
  125. // CHECK:STDOUT: %b.param: f64 = param b, runtime_param1
  126. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  127. // CHECK:STDOUT: %.loc4_35.1: i32 = int_literal 64 [template = constants.%.1]
  128. // CHECK:STDOUT: %float.make_type.loc4_35: init type = call constants.%Float(%.loc4_35.1) [template = f64]
  129. // CHECK:STDOUT: %.loc4_35.2: type = value_of_initializer %float.make_type.loc4_35 [template = f64]
  130. // CHECK:STDOUT: %.loc4_35.3: type = converted %float.make_type.loc4_35, %.loc4_35.2 [template = f64]
  131. // CHECK:STDOUT: %return: ref f64 = var <return slot>
  132. // CHECK:STDOUT: }
  133. // CHECK:STDOUT: %.loc8_8.1: i32 = int_literal 64 [template = constants.%.1]
  134. // CHECK:STDOUT: %float.make_type.loc8: init type = call constants.%Float(%.loc8_8.1) [template = f64]
  135. // CHECK:STDOUT: %.loc8_8.2: type = value_of_initializer %float.make_type.loc8 [template = f64]
  136. // CHECK:STDOUT: %.loc8_8.3: type = converted %float.make_type.loc8, %.loc8_8.2 [template = f64]
  137. // CHECK:STDOUT: %a.var: ref f64 = var a
  138. // CHECK:STDOUT: %a: ref f64 = bind_name a, %a.var
  139. // CHECK:STDOUT: %.loc9_8.1: i32 = int_literal 64 [template = constants.%.1]
  140. // CHECK:STDOUT: %float.make_type.loc9: init type = call constants.%Float(%.loc9_8.1) [template = f64]
  141. // CHECK:STDOUT: %.loc9_8.2: type = value_of_initializer %float.make_type.loc9 [template = f64]
  142. // CHECK:STDOUT: %.loc9_8.3: type = converted %float.make_type.loc9, %.loc9_8.2 [template = f64]
  143. // CHECK:STDOUT: %.loc10_8.1: i32 = int_literal 64 [template = constants.%.1]
  144. // CHECK:STDOUT: %float.make_type.loc10: init type = call constants.%Float(%.loc10_8.1) [template = f64]
  145. // CHECK:STDOUT: %.loc10_8.2: type = value_of_initializer %float.make_type.loc10 [template = f64]
  146. // CHECK:STDOUT: %.loc10_8.3: type = converted %float.make_type.loc10, %.loc10_8.2 [template = f64]
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT:
  149. // CHECK:STDOUT: fn @Float(%size: i32) -> type = "float.make_type";
  150. // CHECK:STDOUT:
  151. // CHECK:STDOUT: fn @Div(%a: f64, %b: f64) -> f64 = "float.div";
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: fn @RuntimeCall(%a: f64, %b: f64) -> f64 {
  154. // CHECK:STDOUT: !entry:
  155. // CHECK:STDOUT: %Div.ref: %Div.type = name_ref Div, file.%Div.decl [template = constants.%Div]
  156. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  157. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  158. // CHECK:STDOUT: %float.div: init f64 = call %Div.ref(%a.ref, %b.ref)
  159. // CHECK:STDOUT: %.loc5_19.1: f64 = value_of_initializer %float.div
  160. // CHECK:STDOUT: %.loc5_19.2: f64 = converted %float.div, %.loc5_19.1
  161. // CHECK:STDOUT: return %.loc5_19.2
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: fn @__global_init() {
  165. // CHECK:STDOUT: !entry:
  166. // CHECK:STDOUT: %Div.ref.loc8: %Div.type = name_ref Div, file.%Div.decl [template = constants.%Div]
  167. // CHECK:STDOUT: %.loc8_18: f64 = float_literal 10 [template = constants.%.3]
  168. // CHECK:STDOUT: %.loc8_24: f64 = float_literal 2.5 [template = constants.%.4]
  169. // CHECK:STDOUT: %float.div.loc8: init f64 = call %Div.ref.loc8(%.loc8_18, %.loc8_24) [template = constants.%.5]
  170. // CHECK:STDOUT: assign file.%a.var, %float.div.loc8
  171. // CHECK:STDOUT: %Div.ref.loc9: %Div.type = name_ref Div, file.%Div.decl [template = constants.%Div]
  172. // CHECK:STDOUT: %.loc9_18: f64 = float_literal 1 [template = constants.%.6]
  173. // CHECK:STDOUT: %.loc9_23: f64 = float_literal 0 [template = constants.%.7]
  174. // CHECK:STDOUT: %float.div.loc9: init f64 = call %Div.ref.loc9(%.loc9_18, %.loc9_23) [template = constants.%.8]
  175. // CHECK:STDOUT: %.loc9_27.1: f64 = value_of_initializer %float.div.loc9 [template = constants.%.8]
  176. // CHECK:STDOUT: %.loc9_27.2: f64 = converted %float.div.loc9, %.loc9_27.1 [template = constants.%.8]
  177. // CHECK:STDOUT: %b: f64 = bind_name b, %.loc9_27.2
  178. // CHECK:STDOUT: %Div.ref.loc10: %Div.type = name_ref Div, file.%Div.decl [template = constants.%Div]
  179. // CHECK:STDOUT: %.loc10_18: f64 = float_literal 0 [template = constants.%.7]
  180. // CHECK:STDOUT: %.loc10_23: f64 = float_literal 0 [template = constants.%.7]
  181. // CHECK:STDOUT: %float.div.loc10: init f64 = call %Div.ref.loc10(%.loc10_18, %.loc10_23) [template = constants.%.9]
  182. // CHECK:STDOUT: %.loc10_27.1: f64 = value_of_initializer %float.div.loc10 [template = constants.%.9]
  183. // CHECK:STDOUT: %.loc10_27.2: f64 = converted %float.div.loc10, %.loc10_27.1 [template = constants.%.9]
  184. // CHECK:STDOUT: %c: f64 = bind_name c, %.loc10_27.2
  185. // CHECK:STDOUT: return
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: --- fail_bad_decl.carbon
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: constants {
  191. // CHECK:STDOUT: %.1: i32 = int_literal 64 [template]
  192. // CHECK:STDOUT: %Float.type: type = fn_type @Float [template]
  193. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  194. // CHECK:STDOUT: %Float: %Float.type = struct_value () [template]
  195. // CHECK:STDOUT: %TooFew.type: type = fn_type @TooFew [template]
  196. // CHECK:STDOUT: %TooFew: %TooFew.type = struct_value () [template]
  197. // CHECK:STDOUT: %TooMany.type: type = fn_type @TooMany [template]
  198. // CHECK:STDOUT: %TooMany: %TooMany.type = struct_value () [template]
  199. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  200. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  201. // CHECK:STDOUT: %BadReturnType.type: type = fn_type @BadReturnType [template]
  202. // CHECK:STDOUT: %BadReturnType: %BadReturnType.type = struct_value () [template]
  203. // CHECK:STDOUT: %JustRight.type: type = fn_type @JustRight [template]
  204. // CHECK:STDOUT: %JustRight: %JustRight.type = struct_value () [template]
  205. // CHECK:STDOUT: %RuntimeCallTooFew.type: type = fn_type @RuntimeCallTooFew [template]
  206. // CHECK:STDOUT: %RuntimeCallTooFew: %RuntimeCallTooFew.type = struct_value () [template]
  207. // CHECK:STDOUT: %RuntimeCallTooMany.type: type = fn_type @RuntimeCallTooMany [template]
  208. // CHECK:STDOUT: %RuntimeCallTooMany: %RuntimeCallTooMany.type = struct_value () [template]
  209. // CHECK:STDOUT: %RuntimeCallBadReturnType.type: type = fn_type @RuntimeCallBadReturnType [template]
  210. // CHECK:STDOUT: %RuntimeCallBadReturnType: %RuntimeCallBadReturnType.type = struct_value () [template]
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: imports {
  214. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  215. // CHECK:STDOUT: .Float = %import_ref.1
  216. // CHECK:STDOUT: .Bool = %import_ref.2
  217. // CHECK:STDOUT: import Core//prelude
  218. // CHECK:STDOUT: import Core//prelude/operators
  219. // CHECK:STDOUT: import Core//prelude/types
  220. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  221. // CHECK:STDOUT: import Core//prelude/operators/as
  222. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  223. // CHECK:STDOUT: import Core//prelude/operators/comparison
  224. // CHECK:STDOUT: import Core//prelude/types/bool
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT: %import_ref.1: %Float.type = import_ref Core//prelude/types, inst+35, loaded [template = constants.%Float]
  227. // CHECK:STDOUT: %import_ref.2: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: file {
  231. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  232. // CHECK:STDOUT: .Core = imports.%Core
  233. // CHECK:STDOUT: .TooFew = %TooFew.decl
  234. // CHECK:STDOUT: .TooMany = %TooMany.decl
  235. // CHECK:STDOUT: .BadReturnType = %BadReturnType.decl
  236. // CHECK:STDOUT: .JustRight = %JustRight.decl
  237. // CHECK:STDOUT: .RuntimeCallTooFew = %RuntimeCallTooFew.decl
  238. // CHECK:STDOUT: .RuntimeCallTooMany = %RuntimeCallTooMany.decl
  239. // CHECK:STDOUT: .RuntimeCallBadReturnType = %RuntimeCallBadReturnType.decl
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT: %Core.import = import Core
  242. // CHECK:STDOUT: %TooFew.decl: %TooFew.type = fn_decl @TooFew [template = constants.%TooFew] {
  243. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  244. // CHECK:STDOUT: } {
  245. // CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 64 [template = constants.%.1]
  246. // CHECK:STDOUT: %float.make_type.loc8_14: init type = call constants.%Float(%.loc8_14.1) [template = f64]
  247. // CHECK:STDOUT: %.loc8_14.2: type = value_of_initializer %float.make_type.loc8_14 [template = f64]
  248. // CHECK:STDOUT: %.loc8_14.3: type = converted %float.make_type.loc8_14, %.loc8_14.2 [template = f64]
  249. // CHECK:STDOUT: %a.param: f64 = param a, runtime_param0
  250. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  251. // CHECK:STDOUT: %.loc8_22.1: i32 = int_literal 64 [template = constants.%.1]
  252. // CHECK:STDOUT: %float.make_type.loc8_22: init type = call constants.%Float(%.loc8_22.1) [template = f64]
  253. // CHECK:STDOUT: %.loc8_22.2: type = value_of_initializer %float.make_type.loc8_22 [template = f64]
  254. // CHECK:STDOUT: %.loc8_22.3: type = converted %float.make_type.loc8_22, %.loc8_22.2 [template = f64]
  255. // CHECK:STDOUT: %return: ref f64 = var <return slot>
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT: %TooMany.decl: %TooMany.type = fn_decl @TooMany [template = constants.%TooMany] {
  258. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  259. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  260. // CHECK:STDOUT: %c.patt: f64 = binding_pattern c
  261. // CHECK:STDOUT: } {
  262. // CHECK:STDOUT: %.loc13_15.1: i32 = int_literal 64 [template = constants.%.1]
  263. // CHECK:STDOUT: %float.make_type.loc13_15: init type = call constants.%Float(%.loc13_15.1) [template = f64]
  264. // CHECK:STDOUT: %.loc13_15.2: type = value_of_initializer %float.make_type.loc13_15 [template = f64]
  265. // CHECK:STDOUT: %.loc13_15.3: type = converted %float.make_type.loc13_15, %.loc13_15.2 [template = f64]
  266. // CHECK:STDOUT: %a.param: f64 = param a, runtime_param0
  267. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  268. // CHECK:STDOUT: %.loc13_23.1: i32 = int_literal 64 [template = constants.%.1]
  269. // CHECK:STDOUT: %float.make_type.loc13_23: init type = call constants.%Float(%.loc13_23.1) [template = f64]
  270. // CHECK:STDOUT: %.loc13_23.2: type = value_of_initializer %float.make_type.loc13_23 [template = f64]
  271. // CHECK:STDOUT: %.loc13_23.3: type = converted %float.make_type.loc13_23, %.loc13_23.2 [template = f64]
  272. // CHECK:STDOUT: %b.param: f64 = param b, runtime_param1
  273. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  274. // CHECK:STDOUT: %.loc13_31.1: i32 = int_literal 64 [template = constants.%.1]
  275. // CHECK:STDOUT: %float.make_type.loc13_31: init type = call constants.%Float(%.loc13_31.1) [template = f64]
  276. // CHECK:STDOUT: %.loc13_31.2: type = value_of_initializer %float.make_type.loc13_31 [template = f64]
  277. // CHECK:STDOUT: %.loc13_31.3: type = converted %float.make_type.loc13_31, %.loc13_31.2 [template = f64]
  278. // CHECK:STDOUT: %c.param: f64 = param c, runtime_param2
  279. // CHECK:STDOUT: %c: f64 = bind_name c, %c.param
  280. // CHECK:STDOUT: %.loc13_39.1: i32 = int_literal 64 [template = constants.%.1]
  281. // CHECK:STDOUT: %float.make_type.loc13_39: init type = call constants.%Float(%.loc13_39.1) [template = f64]
  282. // CHECK:STDOUT: %.loc13_39.2: type = value_of_initializer %float.make_type.loc13_39 [template = f64]
  283. // CHECK:STDOUT: %.loc13_39.3: type = converted %float.make_type.loc13_39, %.loc13_39.2 [template = f64]
  284. // CHECK:STDOUT: %return: ref f64 = var <return slot>
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT: %BadReturnType.decl: %BadReturnType.type = fn_decl @BadReturnType [template = constants.%BadReturnType] {
  287. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  288. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  289. // CHECK:STDOUT: } {
  290. // CHECK:STDOUT: %.loc17_21.1: i32 = int_literal 64 [template = constants.%.1]
  291. // CHECK:STDOUT: %float.make_type.loc17_21: init type = call constants.%Float(%.loc17_21.1) [template = f64]
  292. // CHECK:STDOUT: %.loc17_21.2: type = value_of_initializer %float.make_type.loc17_21 [template = f64]
  293. // CHECK:STDOUT: %.loc17_21.3: type = converted %float.make_type.loc17_21, %.loc17_21.2 [template = f64]
  294. // CHECK:STDOUT: %a.param: f64 = param a, runtime_param0
  295. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  296. // CHECK:STDOUT: %.loc17_29.1: i32 = int_literal 64 [template = constants.%.1]
  297. // CHECK:STDOUT: %float.make_type.loc17_29: init type = call constants.%Float(%.loc17_29.1) [template = f64]
  298. // CHECK:STDOUT: %.loc17_29.2: type = value_of_initializer %float.make_type.loc17_29 [template = f64]
  299. // CHECK:STDOUT: %.loc17_29.3: type = converted %float.make_type.loc17_29, %.loc17_29.2 [template = f64]
  300. // CHECK:STDOUT: %b.param: f64 = param b, runtime_param1
  301. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  302. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  303. // CHECK:STDOUT: %.loc17_37.1: type = value_of_initializer %bool.make_type [template = bool]
  304. // CHECK:STDOUT: %.loc17_37.2: type = converted %bool.make_type, %.loc17_37.1 [template = bool]
  305. // CHECK:STDOUT: %return: ref bool = var <return slot>
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT: %JustRight.decl: %JustRight.type = fn_decl @JustRight [template = constants.%JustRight] {
  308. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  309. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  310. // CHECK:STDOUT: } {
  311. // CHECK:STDOUT: %.loc18_17.1: i32 = int_literal 64 [template = constants.%.1]
  312. // CHECK:STDOUT: %float.make_type.loc18_17: init type = call constants.%Float(%.loc18_17.1) [template = f64]
  313. // CHECK:STDOUT: %.loc18_17.2: type = value_of_initializer %float.make_type.loc18_17 [template = f64]
  314. // CHECK:STDOUT: %.loc18_17.3: type = converted %float.make_type.loc18_17, %.loc18_17.2 [template = f64]
  315. // CHECK:STDOUT: %a.param: f64 = param a, runtime_param0
  316. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  317. // CHECK:STDOUT: %.loc18_25.1: i32 = int_literal 64 [template = constants.%.1]
  318. // CHECK:STDOUT: %float.make_type.loc18_25: init type = call constants.%Float(%.loc18_25.1) [template = f64]
  319. // CHECK:STDOUT: %.loc18_25.2: type = value_of_initializer %float.make_type.loc18_25 [template = f64]
  320. // CHECK:STDOUT: %.loc18_25.3: type = converted %float.make_type.loc18_25, %.loc18_25.2 [template = f64]
  321. // CHECK:STDOUT: %b.param: f64 = param b, runtime_param1
  322. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  323. // CHECK:STDOUT: %.loc18_33.1: i32 = int_literal 64 [template = constants.%.1]
  324. // CHECK:STDOUT: %float.make_type.loc18_33: init type = call constants.%Float(%.loc18_33.1) [template = f64]
  325. // CHECK:STDOUT: %.loc18_33.2: type = value_of_initializer %float.make_type.loc18_33 [template = f64]
  326. // CHECK:STDOUT: %.loc18_33.3: type = converted %float.make_type.loc18_33, %.loc18_33.2 [template = f64]
  327. // CHECK:STDOUT: %return: ref f64 = var <return slot>
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT: %RuntimeCallTooFew.decl: %RuntimeCallTooFew.type = fn_decl @RuntimeCallTooFew [template = constants.%RuntimeCallTooFew] {
  330. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  331. // CHECK:STDOUT: } {
  332. // CHECK:STDOUT: %.loc20_25.1: i32 = int_literal 64 [template = constants.%.1]
  333. // CHECK:STDOUT: %float.make_type.loc20_25: init type = call constants.%Float(%.loc20_25.1) [template = f64]
  334. // CHECK:STDOUT: %.loc20_25.2: type = value_of_initializer %float.make_type.loc20_25 [template = f64]
  335. // CHECK:STDOUT: %.loc20_25.3: type = converted %float.make_type.loc20_25, %.loc20_25.2 [template = f64]
  336. // CHECK:STDOUT: %a.param: f64 = param a, runtime_param0
  337. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  338. // CHECK:STDOUT: %.loc20_33.1: i32 = int_literal 64 [template = constants.%.1]
  339. // CHECK:STDOUT: %float.make_type.loc20_33: init type = call constants.%Float(%.loc20_33.1) [template = f64]
  340. // CHECK:STDOUT: %.loc20_33.2: type = value_of_initializer %float.make_type.loc20_33 [template = f64]
  341. // CHECK:STDOUT: %.loc20_33.3: type = converted %float.make_type.loc20_33, %.loc20_33.2 [template = f64]
  342. // CHECK:STDOUT: %return: ref f64 = var <return slot>
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT: %RuntimeCallTooMany.decl: %RuntimeCallTooMany.type = fn_decl @RuntimeCallTooMany [template = constants.%RuntimeCallTooMany] {
  345. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  346. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  347. // CHECK:STDOUT: %c.patt: f64 = binding_pattern c
  348. // CHECK:STDOUT: } {
  349. // CHECK:STDOUT: %.loc24_26.1: i32 = int_literal 64 [template = constants.%.1]
  350. // CHECK:STDOUT: %float.make_type.loc24_26: init type = call constants.%Float(%.loc24_26.1) [template = f64]
  351. // CHECK:STDOUT: %.loc24_26.2: type = value_of_initializer %float.make_type.loc24_26 [template = f64]
  352. // CHECK:STDOUT: %.loc24_26.3: type = converted %float.make_type.loc24_26, %.loc24_26.2 [template = f64]
  353. // CHECK:STDOUT: %a.param: f64 = param a, runtime_param0
  354. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  355. // CHECK:STDOUT: %.loc24_34.1: i32 = int_literal 64 [template = constants.%.1]
  356. // CHECK:STDOUT: %float.make_type.loc24_34: init type = call constants.%Float(%.loc24_34.1) [template = f64]
  357. // CHECK:STDOUT: %.loc24_34.2: type = value_of_initializer %float.make_type.loc24_34 [template = f64]
  358. // CHECK:STDOUT: %.loc24_34.3: type = converted %float.make_type.loc24_34, %.loc24_34.2 [template = f64]
  359. // CHECK:STDOUT: %b.param: f64 = param b, runtime_param1
  360. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  361. // CHECK:STDOUT: %.loc24_42.1: i32 = int_literal 64 [template = constants.%.1]
  362. // CHECK:STDOUT: %float.make_type.loc24_42: init type = call constants.%Float(%.loc24_42.1) [template = f64]
  363. // CHECK:STDOUT: %.loc24_42.2: type = value_of_initializer %float.make_type.loc24_42 [template = f64]
  364. // CHECK:STDOUT: %.loc24_42.3: type = converted %float.make_type.loc24_42, %.loc24_42.2 [template = f64]
  365. // CHECK:STDOUT: %c.param: f64 = param c, runtime_param2
  366. // CHECK:STDOUT: %c: f64 = bind_name c, %c.param
  367. // CHECK:STDOUT: %.loc24_50.1: i32 = int_literal 64 [template = constants.%.1]
  368. // CHECK:STDOUT: %float.make_type.loc24_50: init type = call constants.%Float(%.loc24_50.1) [template = f64]
  369. // CHECK:STDOUT: %.loc24_50.2: type = value_of_initializer %float.make_type.loc24_50 [template = f64]
  370. // CHECK:STDOUT: %.loc24_50.3: type = converted %float.make_type.loc24_50, %.loc24_50.2 [template = f64]
  371. // CHECK:STDOUT: %return: ref f64 = var <return slot>
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT: %RuntimeCallBadReturnType.decl: %RuntimeCallBadReturnType.type = fn_decl @RuntimeCallBadReturnType [template = constants.%RuntimeCallBadReturnType] {
  374. // CHECK:STDOUT: %a.patt: f64 = binding_pattern a
  375. // CHECK:STDOUT: %b.patt: f64 = binding_pattern b
  376. // CHECK:STDOUT: } {
  377. // CHECK:STDOUT: %.loc28_32.1: i32 = int_literal 64 [template = constants.%.1]
  378. // CHECK:STDOUT: %float.make_type.loc28_32: init type = call constants.%Float(%.loc28_32.1) [template = f64]
  379. // CHECK:STDOUT: %.loc28_32.2: type = value_of_initializer %float.make_type.loc28_32 [template = f64]
  380. // CHECK:STDOUT: %.loc28_32.3: type = converted %float.make_type.loc28_32, %.loc28_32.2 [template = f64]
  381. // CHECK:STDOUT: %a.param: f64 = param a, runtime_param0
  382. // CHECK:STDOUT: %a: f64 = bind_name a, %a.param
  383. // CHECK:STDOUT: %.loc28_40.1: i32 = int_literal 64 [template = constants.%.1]
  384. // CHECK:STDOUT: %float.make_type.loc28_40: init type = call constants.%Float(%.loc28_40.1) [template = f64]
  385. // CHECK:STDOUT: %.loc28_40.2: type = value_of_initializer %float.make_type.loc28_40 [template = f64]
  386. // CHECK:STDOUT: %.loc28_40.3: type = converted %float.make_type.loc28_40, %.loc28_40.2 [template = f64]
  387. // CHECK:STDOUT: %b.param: f64 = param b, runtime_param1
  388. // CHECK:STDOUT: %b: f64 = bind_name b, %b.param
  389. // CHECK:STDOUT: %bool.make_type: init type = call constants.%Bool() [template = bool]
  390. // CHECK:STDOUT: %.loc28_48.1: type = value_of_initializer %bool.make_type [template = bool]
  391. // CHECK:STDOUT: %.loc28_48.2: type = converted %bool.make_type, %.loc28_48.1 [template = bool]
  392. // CHECK:STDOUT: %return: ref bool = var <return slot>
  393. // CHECK:STDOUT: }
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT:
  396. // CHECK:STDOUT: fn @Float(%size: i32) -> type = "float.make_type";
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: fn @TooFew(%a: f64) -> f64;
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: fn @TooMany(%a: f64, %b: f64, %c: f64) -> f64;
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: fn @BadReturnType(%a: f64, %b: f64) -> bool;
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: fn @JustRight(%a: f64, %b: f64) -> f64 = "float.div";
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: fn @RuntimeCallTooFew(%a: f64) -> f64 {
  409. // CHECK:STDOUT: !entry:
  410. // CHECK:STDOUT: %TooFew.ref: %TooFew.type = name_ref TooFew, file.%TooFew.decl [template = constants.%TooFew]
  411. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  412. // CHECK:STDOUT: %TooFew.call: init f64 = call %TooFew.ref(%a.ref)
  413. // CHECK:STDOUT: %.loc21_19.1: f64 = value_of_initializer %TooFew.call
  414. // CHECK:STDOUT: %.loc21_19.2: f64 = converted %TooFew.call, %.loc21_19.1
  415. // CHECK:STDOUT: return %.loc21_19.2
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: fn @RuntimeCallTooMany(%a: f64, %b: f64, %c: f64) -> f64 {
  419. // CHECK:STDOUT: !entry:
  420. // CHECK:STDOUT: %TooMany.ref: %TooMany.type = name_ref TooMany, file.%TooMany.decl [template = constants.%TooMany]
  421. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  422. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  423. // CHECK:STDOUT: %c.ref: f64 = name_ref c, %c
  424. // CHECK:STDOUT: %TooMany.call: init f64 = call %TooMany.ref(%a.ref, %b.ref, %c.ref)
  425. // CHECK:STDOUT: %.loc25_26.1: f64 = value_of_initializer %TooMany.call
  426. // CHECK:STDOUT: %.loc25_26.2: f64 = converted %TooMany.call, %.loc25_26.1
  427. // CHECK:STDOUT: return %.loc25_26.2
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: fn @RuntimeCallBadReturnType(%a: f64, %b: f64) -> bool {
  431. // CHECK:STDOUT: !entry:
  432. // CHECK:STDOUT: %BadReturnType.ref: %BadReturnType.type = name_ref BadReturnType, file.%BadReturnType.decl [template = constants.%BadReturnType]
  433. // CHECK:STDOUT: %a.ref: f64 = name_ref a, %a
  434. // CHECK:STDOUT: %b.ref: f64 = name_ref b, %b
  435. // CHECK:STDOUT: %BadReturnType.call: init bool = call %BadReturnType.ref(%a.ref, %b.ref)
  436. // CHECK:STDOUT: %.loc29_29.1: bool = value_of_initializer %BadReturnType.call
  437. // CHECK:STDOUT: %.loc29_29.2: bool = converted %BadReturnType.call, %.loc29_29.1
  438. // CHECK:STDOUT: return %.loc29_29.2
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT: