params_two.carbon 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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: %int_32: Core.IntLiteral = int_value 32 [template]
  18. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  19. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [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: %int_1.5b8: Core.IntLiteral = int_value 1 [template]
  25. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [template]
  26. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [template]
  27. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  28. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.1(%int_32) [template]
  29. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  30. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [template]
  31. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, %impl_witness.d39 [template]
  32. // CHECK:STDOUT: %.a0b: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [template]
  33. // CHECK:STDOUT: %Convert.bound.ab5: <bound method> = bound_method %int_1.5b8, %Convert.956 [template]
  34. // CHECK:STDOUT: %Convert.specific_fn.70c: <specific function> = specific_function %Convert.bound.ab5, @Convert.2(%int_32) [template]
  35. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [template]
  36. // CHECK:STDOUT: %Convert.bound.ef9: <bound method> = bound_method %int_2.ecc, %Convert.956 [template]
  37. // CHECK:STDOUT: %Convert.specific_fn.787: <specific function> = specific_function %Convert.bound.ef9, @Convert.2(%int_32) [template]
  38. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [template]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: imports {
  42. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  43. // CHECK:STDOUT: .Int = %Core.Int
  44. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  45. // CHECK:STDOUT: import Core//prelude
  46. // CHECK:STDOUT: import Core//prelude/...
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: file {
  51. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  52. // CHECK:STDOUT: .Core = imports.%Core
  53. // CHECK:STDOUT: .Foo = %Foo.decl
  54. // CHECK:STDOUT: .Main = %Main.decl
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %Core.import = import Core
  57. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
  58. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  59. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  60. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  61. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
  62. // CHECK:STDOUT: } {
  63. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  64. // CHECK:STDOUT: %.loc11_11: type = splice_block %i32.loc11_11 [template = constants.%i32] {
  65. // CHECK:STDOUT: %int_32.loc11_11: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  66. // CHECK:STDOUT: %i32.loc11_11: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  69. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
  70. // CHECK:STDOUT: %.loc11_19: type = splice_block %i32.loc11_19 [template = constants.%i32] {
  71. // CHECK:STDOUT: %int_32.loc11_19: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  72. // CHECK:STDOUT: %i32.loc11_19: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @Foo(%a.param_patt: %i32, %b.param_patt: %i32) {
  80. // CHECK:STDOUT: !entry:
  81. // CHECK:STDOUT: return
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: fn @Main() {
  85. // CHECK:STDOUT: !entry:
  86. // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  87. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.5b8]
  88. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.ecc]
  89. // CHECK:STDOUT: %impl.elem0.loc14_7: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  90. // CHECK:STDOUT: %bound_method.loc14_7: <bound method> = bound_method %int_1, %impl.elem0.loc14_7 [template = constants.%Convert.bound.ab5]
  91. // CHECK:STDOUT: %specific_fn.loc14_7: <specific function> = specific_function %bound_method.loc14_7, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.70c]
  92. // CHECK:STDOUT: %int.convert_checked.loc14_7: init %i32 = call %specific_fn.loc14_7(%int_1) [template = constants.%int_1.5d2]
  93. // CHECK:STDOUT: %.loc14_7.1: %i32 = value_of_initializer %int.convert_checked.loc14_7 [template = constants.%int_1.5d2]
  94. // CHECK:STDOUT: %.loc14_7.2: %i32 = converted %int_1, %.loc14_7.1 [template = constants.%int_1.5d2]
  95. // CHECK:STDOUT: %impl.elem0.loc14_10: %.a0b = impl_witness_access constants.%impl_witness.d39, element0 [template = constants.%Convert.956]
  96. // CHECK:STDOUT: %bound_method.loc14_10: <bound method> = bound_method %int_2, %impl.elem0.loc14_10 [template = constants.%Convert.bound.ef9]
  97. // CHECK:STDOUT: %specific_fn.loc14_10: <specific function> = specific_function %bound_method.loc14_10, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.787]
  98. // CHECK:STDOUT: %int.convert_checked.loc14_10: init %i32 = call %specific_fn.loc14_10(%int_2) [template = constants.%int_2.ef8]
  99. // CHECK:STDOUT: %.loc14_10.1: %i32 = value_of_initializer %int.convert_checked.loc14_10 [template = constants.%int_2.ef8]
  100. // CHECK:STDOUT: %.loc14_10.2: %i32 = converted %int_2, %.loc14_10.1 [template = constants.%int_2.ef8]
  101. // CHECK:STDOUT: %Foo.call: init %empty_tuple.type = call %Foo.ref(%.loc14_7.2, %.loc14_10.2)
  102. // CHECK:STDOUT: return
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: