more_param_ir.carbon 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. fn Foo(a: i32, b: i32) {}
  7. fn Main() {
  8. var x: (i32,) = (1,);
  9. // Generates multiple IR instructions for the first parameter.
  10. Foo(x[0], 6);
  11. }
  12. // CHECK:STDOUT: --- more_param_ir.carbon
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: constants {
  15. // CHECK:STDOUT: %Foo: type = fn_type @Foo [template]
  16. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  17. // CHECK:STDOUT: %struct.1: Foo = struct_value () [template]
  18. // CHECK:STDOUT: %Main: type = fn_type @Main [template]
  19. // CHECK:STDOUT: %struct.2: Main = struct_value () [template]
  20. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  21. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  22. // CHECK:STDOUT: %.4: i32 = int_literal 1 [template]
  23. // CHECK:STDOUT: %tuple: (i32,) = tuple_value (%.4) [template]
  24. // CHECK:STDOUT: %.5: i32 = int_literal 0 [template]
  25. // CHECK:STDOUT: %.6: i32 = int_literal 6 [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .Core = %Core
  31. // CHECK:STDOUT: .Foo = %Foo.decl
  32. // CHECK:STDOUT: .Main = %Main.decl
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  35. // CHECK:STDOUT: %Foo.decl: Foo = fn_decl @Foo [template = constants.%struct.1] {
  36. // CHECK:STDOUT: %a.loc7_8.1: i32 = param a
  37. // CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc7_8.1
  38. // CHECK:STDOUT: %b.loc7_16.1: i32 = param b
  39. // CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc7_16.1
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.2] {}
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
  45. // CHECK:STDOUT: !entry:
  46. // CHECK:STDOUT: return
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @Main() {
  50. // CHECK:STDOUT: !entry:
  51. // CHECK:STDOUT: %.loc10_15.1: (type,) = tuple_literal (i32)
  52. // CHECK:STDOUT: %.loc10_15.2: type = converted %.loc10_15.1, constants.%.3 [template = constants.%.3]
  53. // CHECK:STDOUT: %x.var: ref (i32,) = var x
  54. // CHECK:STDOUT: %x: ref (i32,) = bind_name x, %x.var
  55. // CHECK:STDOUT: %.loc10_20: i32 = int_literal 1 [template = constants.%.4]
  56. // CHECK:STDOUT: %.loc10_22.1: (i32,) = tuple_literal (%.loc10_20)
  57. // CHECK:STDOUT: %.loc10_22.2: init (i32,) = tuple_init (%.loc10_20) to %x.var [template = constants.%tuple]
  58. // CHECK:STDOUT: %.loc10_23: init (i32,) = converted %.loc10_22.1, %.loc10_22.2 [template = constants.%tuple]
  59. // CHECK:STDOUT: assign %x.var, %.loc10_23
  60. // CHECK:STDOUT: %Foo.ref: Foo = name_ref Foo, file.%Foo.decl [template = constants.%struct.1]
  61. // CHECK:STDOUT: %x.ref: ref (i32,) = name_ref x, %x
  62. // CHECK:STDOUT: %.loc12_9: i32 = int_literal 0 [template = constants.%.5]
  63. // CHECK:STDOUT: %.loc12_10.1: ref i32 = tuple_index %x.ref, %.loc12_9
  64. // CHECK:STDOUT: %.loc12_13: i32 = int_literal 6 [template = constants.%.6]
  65. // CHECK:STDOUT: %.loc12_10.2: i32 = bind_value %.loc12_10.1
  66. // CHECK:STDOUT: %Foo.call: init () = call %Foo.ref(%.loc12_10.2, %.loc12_13)
  67. // CHECK:STDOUT: return
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: