more_param_ir.carbon 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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: %.1: 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: %.2: type = tuple_type (type) [template]
  27. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  28. // CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
  29. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.4) [template]
  30. // CHECK:STDOUT: %.5: i32 = int_literal 0 [template]
  31. // CHECK:STDOUT: %.6: i32 = int_literal 6 [template]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .Core = %Core
  37. // CHECK:STDOUT: .Foo = %Foo.decl
  38. // CHECK:STDOUT: .Main = %Main.decl
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  41. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  42. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  43. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
  44. // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32]
  45. // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32]
  46. // CHECK:STDOUT: %.loc11_11.2: type = converted %int.make_type_32.loc11_11, %.loc11_11.1 [template = i32]
  47. // CHECK:STDOUT: %a.loc11_8.1: i32 = param a
  48. // CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc11_8.1
  49. // CHECK:STDOUT: %int.make_type_32.loc11_19: init type = call constants.%Int32() [template = i32]
  50. // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32.loc11_19 [template = i32]
  51. // CHECK:STDOUT: %.loc11_19.2: type = converted %int.make_type_32.loc11_19, %.loc11_19.1 [template = i32]
  52. // CHECK:STDOUT: %b.loc11_16.1: i32 = param b
  53. // CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc11_16.1
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {}
  56. // CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  60. // CHECK:STDOUT:
  61. // CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
  62. // CHECK:STDOUT: !entry:
  63. // CHECK:STDOUT: return
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: fn @Main() {
  67. // CHECK:STDOUT: !entry:
  68. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  69. // CHECK:STDOUT: %.loc14_15.1: %.2 = tuple_literal (%int.make_type_32)
  70. // CHECK:STDOUT: %.loc14_15.2: type = value_of_initializer %int.make_type_32 [template = i32]
  71. // CHECK:STDOUT: %.loc14_15.3: type = converted %int.make_type_32, %.loc14_15.2 [template = i32]
  72. // CHECK:STDOUT: %.loc14_15.4: type = converted %.loc14_15.1, constants.%.3 [template = constants.%.3]
  73. // CHECK:STDOUT: %x.var: ref %.3 = var x
  74. // CHECK:STDOUT: %x: ref %.3 = bind_name x, %x.var
  75. // CHECK:STDOUT: %.loc14_20: i32 = int_literal 1 [template = constants.%.4]
  76. // CHECK:STDOUT: %.loc14_22.1: %.3 = tuple_literal (%.loc14_20)
  77. // CHECK:STDOUT: %.loc14_22.2: init %.3 = tuple_init (%.loc14_20) to %x.var [template = constants.%tuple]
  78. // CHECK:STDOUT: %.loc14_23: init %.3 = converted %.loc14_22.1, %.loc14_22.2 [template = constants.%tuple]
  79. // CHECK:STDOUT: assign %x.var, %.loc14_23
  80. // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  81. // CHECK:STDOUT: %x.ref: ref %.3 = name_ref x, %x
  82. // CHECK:STDOUT: %.loc16_9: i32 = int_literal 0 [template = constants.%.5]
  83. // CHECK:STDOUT: %.loc16_10.1: ref i32 = tuple_index %x.ref, %.loc16_9
  84. // CHECK:STDOUT: %.loc16_13: i32 = int_literal 6 [template = constants.%.6]
  85. // CHECK:STDOUT: %.loc16_10.2: i32 = bind_value %.loc16_10.1
  86. // CHECK:STDOUT: %Foo.call: init %.1 = call %Foo.ref(%.loc16_10.2, %.loc16_13)
  87. // CHECK:STDOUT: return
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT: