more_param_ir.carbon 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/more_param_ir.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/more_param_ir.carbon
  10. fn Foo(a: i32, b: i32) {}
  11. fn Main() {
  12. var x: (i32,) = (1,);
  13. // Generates multiple IR instructions for the first parameter.
  14. Foo(x.0, 6);
  15. }
  16. // CHECK:STDOUT: --- more_param_ir.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  20. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  22. // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
  23. // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
  24. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  25. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  26. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type) [template]
  27. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (i32) [template]
  28. // CHECK:STDOUT: %.1: i32 = int_value 1 [template]
  29. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%.1) [template]
  30. // CHECK:STDOUT: %.2: i32 = int_value 0 [template]
  31. // CHECK:STDOUT: %.3: i32 = int_value 6 [template]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: imports {
  35. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  36. // CHECK:STDOUT: .Int32 = %import_ref
  37. // CHECK:STDOUT: import Core//prelude
  38. // CHECK:STDOUT: import Core//prelude/...
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  44. // CHECK:STDOUT: .Core = imports.%Core
  45. // CHECK:STDOUT: .Foo = %Foo.decl
  46. // CHECK:STDOUT: .Main = %Main.decl
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: %Core.import = import Core
  49. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
  50. // CHECK:STDOUT: %a.patt: i32 = binding_pattern a
  51. // CHECK:STDOUT: %a.param_patt: i32 = value_param_pattern %a.patt, runtime_param0
  52. // CHECK:STDOUT: %b.patt: i32 = binding_pattern b
  53. // CHECK:STDOUT: %b.param_patt: i32 = value_param_pattern %b.patt, runtime_param1
  54. // CHECK:STDOUT: } {
  55. // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32]
  56. // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32]
  57. // CHECK:STDOUT: %.loc11_11.2: type = converted %int.make_type_32.loc11_11, %.loc11_11.1 [template = i32]
  58. // CHECK:STDOUT: %int.make_type_32.loc11_19: init type = call constants.%Int32() [template = i32]
  59. // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32.loc11_19 [template = i32]
  60. // CHECK:STDOUT: %.loc11_19.2: type = converted %int.make_type_32.loc11_19, %.loc11_19.1 [template = i32]
  61. // CHECK:STDOUT: %a.param: i32 = value_param runtime_param0
  62. // CHECK:STDOUT: %a: i32 = bind_name a, %a.param
  63. // CHECK:STDOUT: %b.param: i32 = value_param runtime_param1
  64. // CHECK:STDOUT: %b: i32 = bind_name b, %b.param
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: fn @Foo(%a.param_patt: i32, %b.param_patt: i32) {
  70. // CHECK:STDOUT: !entry:
  71. // CHECK:STDOUT: return
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: fn @Main() {
  75. // CHECK:STDOUT: !entry:
  76. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  77. // CHECK:STDOUT: %.loc14_15.1: %tuple.type.1 = tuple_literal (%int.make_type_32)
  78. // CHECK:STDOUT: %.loc14_15.2: type = value_of_initializer %int.make_type_32 [template = i32]
  79. // CHECK:STDOUT: %.loc14_15.3: type = converted %int.make_type_32, %.loc14_15.2 [template = i32]
  80. // CHECK:STDOUT: %.loc14_15.4: type = converted %.loc14_15.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  81. // CHECK:STDOUT: %x.var: ref %tuple.type.2 = var x
  82. // CHECK:STDOUT: %x: ref %tuple.type.2 = bind_name x, %x.var
  83. // CHECK:STDOUT: %.loc14_20: i32 = int_value 1 [template = constants.%.1]
  84. // CHECK:STDOUT: %.loc14_22.1: %tuple.type.2 = tuple_literal (%.loc14_20)
  85. // CHECK:STDOUT: %.loc14_22.2: init %tuple.type.2 = tuple_init (%.loc14_20) to %x.var [template = constants.%tuple]
  86. // CHECK:STDOUT: %.loc14_23: init %tuple.type.2 = converted %.loc14_22.1, %.loc14_22.2 [template = constants.%tuple]
  87. // CHECK:STDOUT: assign %x.var, %.loc14_23
  88. // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  89. // CHECK:STDOUT: %x.ref: ref %tuple.type.2 = name_ref x, %x
  90. // CHECK:STDOUT: %.loc16_9: i32 = int_value 0 [template = constants.%.2]
  91. // CHECK:STDOUT: %.loc16_8.1: ref i32 = tuple_access %x.ref, element0
  92. // CHECK:STDOUT: %.loc16_12: i32 = int_value 6 [template = constants.%.3]
  93. // CHECK:STDOUT: %.loc16_8.2: i32 = bind_value %.loc16_8.1
  94. // CHECK:STDOUT: %Foo.call: init %empty_tuple.type = call %Foo.ref(%.loc16_8.2, %.loc16_12)
  95. // CHECK:STDOUT: return
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT: