more_param_ir.carbon 5.6 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/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: 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/operators
  39. // CHECK:STDOUT: import Core//prelude/types
  40. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  41. // CHECK:STDOUT: import Core//prelude/operators/as
  42. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  43. // CHECK:STDOUT: import Core//prelude/operators/comparison
  44. // CHECK:STDOUT: import Core//prelude/types/bool
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: file {
  50. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  51. // CHECK:STDOUT: .Core = imports.%Core
  52. // CHECK:STDOUT: .Foo = %Foo.decl
  53. // CHECK:STDOUT: .Main = %Main.decl
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %Core.import = import Core
  56. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
  57. // CHECK:STDOUT: %a.patt: i32 = binding_pattern a
  58. // CHECK:STDOUT: %b.patt: i32 = binding_pattern b
  59. // CHECK:STDOUT: } {
  60. // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32]
  61. // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32]
  62. // CHECK:STDOUT: %.loc11_11.2: type = converted %int.make_type_32.loc11_11, %.loc11_11.1 [template = i32]
  63. // CHECK:STDOUT: %a.param: i32 = param a, runtime_param0
  64. // CHECK:STDOUT: %a: i32 = bind_name a, %a.param
  65. // CHECK:STDOUT: %int.make_type_32.loc11_19: init type = call constants.%Int32() [template = i32]
  66. // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32.loc11_19 [template = i32]
  67. // CHECK:STDOUT: %.loc11_19.2: type = converted %int.make_type_32.loc11_19, %.loc11_19.1 [template = i32]
  68. // CHECK:STDOUT: %b.param: i32 = param b, runtime_param1
  69. // CHECK:STDOUT: %b: i32 = bind_name b, %b.param
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
  77. // CHECK:STDOUT: !entry:
  78. // CHECK:STDOUT: return
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: fn @Main() {
  82. // CHECK:STDOUT: !entry:
  83. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  84. // CHECK:STDOUT: %.loc14_15.1: %.2 = tuple_literal (%int.make_type_32)
  85. // CHECK:STDOUT: %.loc14_15.2: type = value_of_initializer %int.make_type_32 [template = i32]
  86. // CHECK:STDOUT: %.loc14_15.3: type = converted %int.make_type_32, %.loc14_15.2 [template = i32]
  87. // CHECK:STDOUT: %.loc14_15.4: type = converted %.loc14_15.1, constants.%.3 [template = constants.%.3]
  88. // CHECK:STDOUT: %x.var: ref %.3 = var x
  89. // CHECK:STDOUT: %x: ref %.3 = bind_name x, %x.var
  90. // CHECK:STDOUT: %.loc14_20: i32 = int_literal 1 [template = constants.%.4]
  91. // CHECK:STDOUT: %.loc14_22.1: %.3 = tuple_literal (%.loc14_20)
  92. // CHECK:STDOUT: %.loc14_22.2: init %.3 = tuple_init (%.loc14_20) to %x.var [template = constants.%tuple]
  93. // CHECK:STDOUT: %.loc14_23: init %.3 = converted %.loc14_22.1, %.loc14_22.2 [template = constants.%tuple]
  94. // CHECK:STDOUT: assign %x.var, %.loc14_23
  95. // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  96. // CHECK:STDOUT: %x.ref: ref %.3 = name_ref x, %x
  97. // CHECK:STDOUT: %.loc16_9: i32 = int_literal 0 [template = constants.%.5]
  98. // CHECK:STDOUT: %.loc16_8.1: ref i32 = tuple_access %x.ref, element0
  99. // CHECK:STDOUT: %.loc16_12: i32 = int_literal 6 [template = constants.%.6]
  100. // CHECK:STDOUT: %.loc16_8.2: i32 = bind_value %.loc16_8.1
  101. // CHECK:STDOUT: %Foo.call: init %.1 = call %Foo.ref(%.loc16_8.2, %.loc16_12)
  102. // CHECK:STDOUT: return
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: