nested_tuple_in_place.carbon 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 F() -> (i32, i32, i32);
  7. fn G() {
  8. var v: ((i32, i32, i32), (i32, i32, i32)) = (F(), F());
  9. }
  10. fn H() {
  11. var v: (i32, (i32, i32, i32), i32) = (1, F(), 2);
  12. }
  13. // CHECK:STDOUT: --- nested_tuple_in_place.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %.1: type = tuple_type (type, type, type) [template]
  17. // CHECK:STDOUT: %.2: type = tuple_type (i32, i32, i32) [template]
  18. // CHECK:STDOUT: %.3: type = ptr_type (i32, i32, i32) [template]
  19. // CHECK:STDOUT: %.4: type = tuple_type ((type, type, type), (type, type, type)) [template]
  20. // CHECK:STDOUT: %.5: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) [template]
  21. // CHECK:STDOUT: %.6: type = tuple_type ((i32, i32, i32)*, (i32, i32, i32)*) [template]
  22. // CHECK:STDOUT: %.7: type = ptr_type ((i32, i32, i32)*, (i32, i32, i32)*) [template]
  23. // CHECK:STDOUT: %.8: type = tuple_type (type, (type, type, type), type) [template]
  24. // CHECK:STDOUT: %.9: type = tuple_type (i32, (i32, i32, i32), i32) [template]
  25. // CHECK:STDOUT: %.10: type = tuple_type (i32, (i32, i32, i32)*, i32) [template]
  26. // CHECK:STDOUT: %.11: type = ptr_type (i32, (i32, i32, i32)*, i32) [template]
  27. // CHECK:STDOUT: %.12: i32 = int_literal 1 [template]
  28. // CHECK:STDOUT: %.13: i32 = int_literal 2 [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: file {
  32. // CHECK:STDOUT: package: <namespace> = namespace package, {.F = %F, .G = %G, .H = %H} [template]
  33. // CHECK:STDOUT: %F: <function> = fn_decl @F [template]
  34. // CHECK:STDOUT: %G: <function> = fn_decl @G [template]
  35. // CHECK:STDOUT: %H: <function> = fn_decl @H [template]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: fn @F() -> %return: (i32, i32, i32);
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: fn @G() {
  41. // CHECK:STDOUT: !entry:
  42. // CHECK:STDOUT: %.loc10_25.1: (type, type, type) = tuple_literal (i32, i32, i32)
  43. // CHECK:STDOUT: %.loc10_42.1: (type, type, type) = tuple_literal (i32, i32, i32)
  44. // CHECK:STDOUT: %.loc10_43.1: ((type, type, type), (type, type, type)) = tuple_literal (%.loc10_25.1, %.loc10_42.1)
  45. // CHECK:STDOUT: %.loc10_25.2: type = converted %.loc10_25.1, constants.%.2 [template = constants.%.2]
  46. // CHECK:STDOUT: %.loc10_42.2: type = converted %.loc10_42.1, constants.%.2 [template = constants.%.2]
  47. // CHECK:STDOUT: %.loc10_43.2: type = converted %.loc10_43.1, constants.%.5 [template = constants.%.5]
  48. // CHECK:STDOUT: %v.var: ref ((i32, i32, i32), (i32, i32, i32)) = var v
  49. // CHECK:STDOUT: %v: ref ((i32, i32, i32), (i32, i32, i32)) = bind_name v, %v.var
  50. // CHECK:STDOUT: %F.ref.loc10_48: <function> = name_ref F, file.%F [template = file.%F]
  51. // CHECK:STDOUT: %.loc10_56.1: ref (i32, i32, i32) = tuple_access %v.var, element0
  52. // CHECK:STDOUT: %.loc10_49: init (i32, i32, i32) = call %F.ref.loc10_48() to %.loc10_56.1
  53. // CHECK:STDOUT: %F.ref.loc10_53: <function> = name_ref F, file.%F [template = file.%F]
  54. // CHECK:STDOUT: %.loc10_56.2: ref (i32, i32, i32) = tuple_access %v.var, element1
  55. // CHECK:STDOUT: %.loc10_54: init (i32, i32, i32) = call %F.ref.loc10_53() to %.loc10_56.2
  56. // CHECK:STDOUT: %.loc10_56.3: ((i32, i32, i32), (i32, i32, i32)) = tuple_literal (%.loc10_49, %.loc10_54)
  57. // CHECK:STDOUT: %.loc10_56.4: init ((i32, i32, i32), (i32, i32, i32)) = tuple_init (%.loc10_49, %.loc10_54) to %v.var
  58. // CHECK:STDOUT: %.loc10_56.5: init ((i32, i32, i32), (i32, i32, i32)) = converted %.loc10_56.3, %.loc10_56.4
  59. // CHECK:STDOUT: assign %v.var, %.loc10_56.5
  60. // CHECK:STDOUT: return
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: fn @H() {
  64. // CHECK:STDOUT: !entry:
  65. // CHECK:STDOUT: %.loc14_30.1: (type, type, type) = tuple_literal (i32, i32, i32)
  66. // CHECK:STDOUT: %.loc14_36.1: (type, (type, type, type), type) = tuple_literal (i32, %.loc14_30.1, i32)
  67. // CHECK:STDOUT: %.loc14_30.2: type = converted %.loc14_30.1, constants.%.2 [template = constants.%.2]
  68. // CHECK:STDOUT: %.loc14_36.2: type = converted %.loc14_36.1, constants.%.9 [template = constants.%.9]
  69. // CHECK:STDOUT: %v.var: ref (i32, (i32, i32, i32), i32) = var v
  70. // CHECK:STDOUT: %v: ref (i32, (i32, i32, i32), i32) = bind_name v, %v.var
  71. // CHECK:STDOUT: %.loc14_41: i32 = int_literal 1 [template = constants.%.12]
  72. // CHECK:STDOUT: %F.ref: <function> = name_ref F, file.%F [template = file.%F]
  73. // CHECK:STDOUT: %.loc14_50.1: ref (i32, i32, i32) = tuple_access %v.var, element1
  74. // CHECK:STDOUT: %.loc14_45: init (i32, i32, i32) = call %F.ref() to %.loc14_50.1
  75. // CHECK:STDOUT: %.loc14_49: i32 = int_literal 2 [template = constants.%.13]
  76. // CHECK:STDOUT: %.loc14_50.2: (i32, (i32, i32, i32), i32) = tuple_literal (%.loc14_41, %.loc14_45, %.loc14_49)
  77. // CHECK:STDOUT: %.loc14_50.3: ref i32 = tuple_access %v.var, element0
  78. // CHECK:STDOUT: %.loc14_50.4: init i32 = initialize_from %.loc14_41 to %.loc14_50.3
  79. // CHECK:STDOUT: %.loc14_50.5: ref i32 = tuple_access %v.var, element2
  80. // CHECK:STDOUT: %.loc14_50.6: init i32 = initialize_from %.loc14_49 to %.loc14_50.5
  81. // CHECK:STDOUT: %.loc14_50.7: init (i32, (i32, i32, i32), i32) = tuple_init (%.loc14_50.4, %.loc14_45, %.loc14_50.6) to %v.var
  82. // CHECK:STDOUT: %.loc14_50.8: init (i32, (i32, i32, i32), i32) = converted %.loc14_50.2, %.loc14_50.7
  83. // CHECK:STDOUT: assign %v.var, %.loc14_50.8
  84. // CHECK:STDOUT: return
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: