params_two.carbon 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/function/call/params_two.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/params_two.carbon
  10. fn Foo(a: i32, b: i32) {}
  11. fn Main() {
  12. Foo(1, 2);
  13. }
  14. // CHECK:STDOUT: --- params_two.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  18. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  19. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  20. // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
  21. // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
  22. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  23. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  24. // CHECK:STDOUT: %.1: i32 = int_value 1 [template]
  25. // CHECK:STDOUT: %.2: i32 = int_value 2 [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: imports {
  29. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  30. // CHECK:STDOUT: .Int32 = %import_ref
  31. // CHECK:STDOUT: import Core//prelude
  32. // CHECK:STDOUT: import Core//prelude/...
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  38. // CHECK:STDOUT: .Core = imports.%Core
  39. // CHECK:STDOUT: .Foo = %Foo.decl
  40. // CHECK:STDOUT: .Main = %Main.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core.import = import Core
  43. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
  44. // CHECK:STDOUT: %a.patt: i32 = binding_pattern a
  45. // CHECK:STDOUT: %a.param_patt: i32 = value_param_pattern %a.patt, runtime_param0
  46. // CHECK:STDOUT: %b.patt: i32 = binding_pattern b
  47. // CHECK:STDOUT: %b.param_patt: i32 = value_param_pattern %b.patt, runtime_param1
  48. // CHECK:STDOUT: } {
  49. // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32]
  50. // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32]
  51. // CHECK:STDOUT: %.loc11_11.2: type = converted %int.make_type_32.loc11_11, %.loc11_11.1 [template = i32]
  52. // CHECK:STDOUT: %int.make_type_32.loc11_19: init type = call constants.%Int32() [template = i32]
  53. // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32.loc11_19 [template = i32]
  54. // CHECK:STDOUT: %.loc11_19.2: type = converted %int.make_type_32.loc11_19, %.loc11_19.1 [template = i32]
  55. // CHECK:STDOUT: %a.param: i32 = value_param runtime_param0
  56. // CHECK:STDOUT: %a: i32 = bind_name a, %a.param
  57. // CHECK:STDOUT: %b.param: i32 = value_param runtime_param1
  58. // CHECK:STDOUT: %b: i32 = bind_name b, %b.param
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: fn @Foo(%a.param_patt: i32, %b.param_patt: i32) {
  64. // CHECK:STDOUT: !entry:
  65. // CHECK:STDOUT: return
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: fn @Main() {
  69. // CHECK:STDOUT: !entry:
  70. // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  71. // CHECK:STDOUT: %.loc14_7: i32 = int_value 1 [template = constants.%.1]
  72. // CHECK:STDOUT: %.loc14_10: i32 = int_value 2 [template = constants.%.2]
  73. // CHECK:STDOUT: %Foo.call: init %empty_tuple.type = call %Foo.ref(%.loc14_7, %.loc14_10)
  74. // CHECK:STDOUT: return
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: