nested_tuple_in_place.carbon 5.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 [template] {
  33. // CHECK:STDOUT: .F = %F
  34. // CHECK:STDOUT: .G = %G
  35. // CHECK:STDOUT: .H = %H
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
  38. // CHECK:STDOUT: %.loc7_25.1: (type, type, type) = tuple_literal (i32, i32, i32)
  39. // CHECK:STDOUT: %.loc7_25.2: type = converted %.loc7_25.1, constants.%.2 [template = constants.%.2]
  40. // CHECK:STDOUT: @F.%return: ref (i32, i32, i32) = var <return slot>
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %G: <function> = fn_decl @G [template] {}
  43. // CHECK:STDOUT: %H: <function> = fn_decl @H [template] {}
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: fn @F() -> %return: (i32, i32, i32);
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: fn @G() {
  49. // CHECK:STDOUT: !entry:
  50. // CHECK:STDOUT: %.loc10_25.1: (type, type, type) = tuple_literal (i32, i32, i32)
  51. // CHECK:STDOUT: %.loc10_42.1: (type, type, type) = tuple_literal (i32, i32, i32)
  52. // CHECK:STDOUT: %.loc10_43.1: ((type, type, type), (type, type, type)) = tuple_literal (%.loc10_25.1, %.loc10_42.1)
  53. // CHECK:STDOUT: %.loc10_25.2: type = converted %.loc10_25.1, constants.%.2 [template = constants.%.2]
  54. // CHECK:STDOUT: %.loc10_42.2: type = converted %.loc10_42.1, constants.%.2 [template = constants.%.2]
  55. // CHECK:STDOUT: %.loc10_43.2: type = converted %.loc10_43.1, constants.%.5 [template = constants.%.5]
  56. // CHECK:STDOUT: %v.var: ref ((i32, i32, i32), (i32, i32, i32)) = var v
  57. // CHECK:STDOUT: %v: ref ((i32, i32, i32), (i32, i32, i32)) = bind_name v, %v.var
  58. // CHECK:STDOUT: %F.ref.loc10_48: <function> = name_ref F, file.%F [template = file.%F]
  59. // CHECK:STDOUT: %.loc10_56.1: ref (i32, i32, i32) = tuple_access %v.var, element0
  60. // CHECK:STDOUT: %.loc10_49: init (i32, i32, i32) = call %F.ref.loc10_48() to %.loc10_56.1
  61. // CHECK:STDOUT: %F.ref.loc10_53: <function> = name_ref F, file.%F [template = file.%F]
  62. // CHECK:STDOUT: %.loc10_56.2: ref (i32, i32, i32) = tuple_access %v.var, element1
  63. // CHECK:STDOUT: %.loc10_54: init (i32, i32, i32) = call %F.ref.loc10_53() to %.loc10_56.2
  64. // CHECK:STDOUT: %.loc10_56.3: ((i32, i32, i32), (i32, i32, i32)) = tuple_literal (%.loc10_49, %.loc10_54)
  65. // CHECK:STDOUT: %.loc10_56.4: init ((i32, i32, i32), (i32, i32, i32)) = tuple_init (%.loc10_49, %.loc10_54) to %v.var
  66. // CHECK:STDOUT: %.loc10_56.5: init ((i32, i32, i32), (i32, i32, i32)) = converted %.loc10_56.3, %.loc10_56.4
  67. // CHECK:STDOUT: assign %v.var, %.loc10_56.5
  68. // CHECK:STDOUT: return
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @H() {
  72. // CHECK:STDOUT: !entry:
  73. // CHECK:STDOUT: %.loc14_30.1: (type, type, type) = tuple_literal (i32, i32, i32)
  74. // CHECK:STDOUT: %.loc14_36.1: (type, (type, type, type), type) = tuple_literal (i32, %.loc14_30.1, i32)
  75. // CHECK:STDOUT: %.loc14_30.2: type = converted %.loc14_30.1, constants.%.2 [template = constants.%.2]
  76. // CHECK:STDOUT: %.loc14_36.2: type = converted %.loc14_36.1, constants.%.9 [template = constants.%.9]
  77. // CHECK:STDOUT: %v.var: ref (i32, (i32, i32, i32), i32) = var v
  78. // CHECK:STDOUT: %v: ref (i32, (i32, i32, i32), i32) = bind_name v, %v.var
  79. // CHECK:STDOUT: %.loc14_41: i32 = int_literal 1 [template = constants.%.12]
  80. // CHECK:STDOUT: %F.ref: <function> = name_ref F, file.%F [template = file.%F]
  81. // CHECK:STDOUT: %.loc14_50.1: ref (i32, i32, i32) = tuple_access %v.var, element1
  82. // CHECK:STDOUT: %.loc14_45: init (i32, i32, i32) = call %F.ref() to %.loc14_50.1
  83. // CHECK:STDOUT: %.loc14_49: i32 = int_literal 2 [template = constants.%.13]
  84. // CHECK:STDOUT: %.loc14_50.2: (i32, (i32, i32, i32), i32) = tuple_literal (%.loc14_41, %.loc14_45, %.loc14_49)
  85. // CHECK:STDOUT: %.loc14_50.3: ref i32 = tuple_access %v.var, element0
  86. // CHECK:STDOUT: %.loc14_50.4: init i32 = initialize_from %.loc14_41 to %.loc14_50.3 [template = constants.%.12]
  87. // CHECK:STDOUT: %.loc14_50.5: ref i32 = tuple_access %v.var, element2
  88. // CHECK:STDOUT: %.loc14_50.6: init i32 = initialize_from %.loc14_49 to %.loc14_50.5 [template = constants.%.13]
  89. // CHECK:STDOUT: %.loc14_50.7: init (i32, (i32, i32, i32), i32) = tuple_init (%.loc14_50.4, %.loc14_45, %.loc14_50.6) to %v.var
  90. // CHECK:STDOUT: %.loc14_50.8: init (i32, (i32, i32, i32), i32) = converted %.loc14_50.2, %.loc14_50.7
  91. // CHECK:STDOUT: assign %v.var, %.loc14_50.8
  92. // CHECK:STDOUT: return
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT: