more_param_ir.carbon 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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: %.1: Core.IntLiteral = int_value 32 [template]
  20. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  21. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  22. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  23. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  24. // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
  25. // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
  26. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  27. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  28. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type) [template]
  29. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%i32) [template]
  30. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 1 [template]
  31. // CHECK:STDOUT: %tuple.type.3: type = tuple_type (Core.IntLiteral) [template]
  32. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  33. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.1) [template]
  34. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  35. // CHECK:STDOUT: %.26: <witness> = interface_witness (%Convert.14) [template]
  36. // CHECK:STDOUT: %.27: <bound method> = bound_method %.2, %Convert.14 [template]
  37. // CHECK:STDOUT: %.28: <specific function> = specific_function %.27, @Convert.2(%.1) [template]
  38. // CHECK:STDOUT: %.29: %i32 = int_value 1 [template]
  39. // CHECK:STDOUT: %tuple: %tuple.type.2 = tuple_value (%.29) [template]
  40. // CHECK:STDOUT: %.30: Core.IntLiteral = int_value 0 [template]
  41. // CHECK:STDOUT: %.31: Core.IntLiteral = int_value 6 [template]
  42. // CHECK:STDOUT: %.32: <bound method> = bound_method %.31, %Convert.14 [template]
  43. // CHECK:STDOUT: %.33: <specific function> = specific_function %.32, @Convert.2(%.1) [template]
  44. // CHECK:STDOUT: %.34: %i32 = int_value 6 [template]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: imports {
  48. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  49. // CHECK:STDOUT: .Int = %import_ref.1
  50. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  51. // CHECK:STDOUT: import Core//prelude
  52. // CHECK:STDOUT: import Core//prelude/...
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: file {
  57. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  58. // CHECK:STDOUT: .Core = imports.%Core
  59. // CHECK:STDOUT: .Foo = %Foo.decl
  60. // CHECK:STDOUT: .Main = %Main.decl
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %Core.import = import Core
  63. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
  64. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  65. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  66. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  67. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
  68. // CHECK:STDOUT: } {
  69. // CHECK:STDOUT: %.loc11_11.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  70. // CHECK:STDOUT: %int.make_type_signed.loc11_11: init type = call constants.%Int(%.loc11_11.1) [template = constants.%i32]
  71. // CHECK:STDOUT: %.loc11_11.2: type = value_of_initializer %int.make_type_signed.loc11_11 [template = constants.%i32]
  72. // CHECK:STDOUT: %.loc11_11.3: type = converted %int.make_type_signed.loc11_11, %.loc11_11.2 [template = constants.%i32]
  73. // CHECK:STDOUT: %.loc11_19.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  74. // CHECK:STDOUT: %int.make_type_signed.loc11_19: init type = call constants.%Int(%.loc11_19.1) [template = constants.%i32]
  75. // CHECK:STDOUT: %.loc11_19.2: type = value_of_initializer %int.make_type_signed.loc11_19 [template = constants.%i32]
  76. // CHECK:STDOUT: %.loc11_19.3: type = converted %int.make_type_signed.loc11_19, %.loc11_19.2 [template = constants.%i32]
  77. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  78. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  79. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
  80. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: fn @Foo(%a.param_patt: %i32, %b.param_patt: %i32) {
  86. // CHECK:STDOUT: !entry:
  87. // CHECK:STDOUT: return
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn @Main() {
  91. // CHECK:STDOUT: !entry:
  92. // CHECK:STDOUT: %.loc14_11: Core.IntLiteral = int_value 32 [template = constants.%.1]
  93. // CHECK:STDOUT: %int.make_type_signed: init type = call constants.%Int(%.loc14_11) [template = constants.%i32]
  94. // CHECK:STDOUT: %.loc14_15.1: %tuple.type.1 = tuple_literal (%int.make_type_signed)
  95. // CHECK:STDOUT: %.loc14_15.2: type = value_of_initializer %int.make_type_signed [template = constants.%i32]
  96. // CHECK:STDOUT: %.loc14_15.3: type = converted %int.make_type_signed, %.loc14_15.2 [template = constants.%i32]
  97. // CHECK:STDOUT: %.loc14_15.4: type = converted %.loc14_15.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
  98. // CHECK:STDOUT: %x.var: ref %tuple.type.2 = var x
  99. // CHECK:STDOUT: %x: ref %tuple.type.2 = bind_name x, %x.var
  100. // CHECK:STDOUT: %.loc14_20: Core.IntLiteral = int_value 1 [template = constants.%.2]
  101. // CHECK:STDOUT: %.loc14_22.1: %tuple.type.3 = tuple_literal (%.loc14_20)
  102. // CHECK:STDOUT: %.loc14_22.2: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14]
  103. // CHECK:STDOUT: %.loc14_22.3: <bound method> = bound_method %.loc14_20, %.loc14_22.2 [template = constants.%.27]
  104. // CHECK:STDOUT: %.loc14_22.4: <specific function> = specific_function %.loc14_22.3, @Convert.2(constants.%.1) [template = constants.%.28]
  105. // CHECK:STDOUT: %int.convert_checked.loc14: init %i32 = call %.loc14_22.4(%.loc14_20) [template = constants.%.29]
  106. // CHECK:STDOUT: %.loc14_22.5: init %i32 = converted %.loc14_20, %int.convert_checked.loc14 [template = constants.%.29]
  107. // CHECK:STDOUT: %.loc14_22.6: init %tuple.type.2 = tuple_init (%.loc14_22.5) to %x.var [template = constants.%tuple]
  108. // CHECK:STDOUT: %.loc14_23: init %tuple.type.2 = converted %.loc14_22.1, %.loc14_22.6 [template = constants.%tuple]
  109. // CHECK:STDOUT: assign %x.var, %.loc14_23
  110. // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  111. // CHECK:STDOUT: %x.ref: ref %tuple.type.2 = name_ref x, %x
  112. // CHECK:STDOUT: %.loc16_9: Core.IntLiteral = int_value 0 [template = constants.%.30]
  113. // CHECK:STDOUT: %.loc16_8.1: ref %i32 = tuple_access %x.ref, element0
  114. // CHECK:STDOUT: %.loc16_12.1: Core.IntLiteral = int_value 6 [template = constants.%.31]
  115. // CHECK:STDOUT: %.loc16_8.2: %i32 = bind_value %.loc16_8.1
  116. // CHECK:STDOUT: %.loc16_12.2: %Convert.type.2 = interface_witness_access constants.%.26, element0 [template = constants.%Convert.14]
  117. // CHECK:STDOUT: %.loc16_12.3: <bound method> = bound_method %.loc16_12.1, %.loc16_12.2 [template = constants.%.32]
  118. // CHECK:STDOUT: %.loc16_12.4: <specific function> = specific_function %.loc16_12.3, @Convert.2(constants.%.1) [template = constants.%.33]
  119. // CHECK:STDOUT: %int.convert_checked.loc16: init %i32 = call %.loc16_12.4(%.loc16_12.1) [template = constants.%.34]
  120. // CHECK:STDOUT: %.loc16_12.5: %i32 = value_of_initializer %int.convert_checked.loc16 [template = constants.%.34]
  121. // CHECK:STDOUT: %.loc16_12.6: %i32 = converted %.loc16_12.1, %.loc16_12.5 [template = constants.%.34]
  122. // CHECK:STDOUT: %Foo.call: init %empty_tuple.type = call %Foo.ref(%.loc16_8.2, %.loc16_12.6)
  123. // CHECK:STDOUT: return
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: