more_param_ir.carbon 2.9 KB

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