nested_tuple.carbon 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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/tuple/nested_tuple.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuple/nested_tuple.carbon
  10. var x: ((i32, i32), i32) = ((12, 76), 6);
  11. // CHECK:STDOUT: --- nested_tuple.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  15. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  16. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  17. // CHECK:STDOUT: %.2: type = tuple_type (type, type) [template]
  18. // CHECK:STDOUT: %.3: type = tuple_type (%.2, type) [template]
  19. // CHECK:STDOUT: %.4: type = tuple_type (i32, i32) [template]
  20. // CHECK:STDOUT: %.5: type = tuple_type (%.4, i32) [template]
  21. // CHECK:STDOUT: %.6: type = ptr_type %.4 [template]
  22. // CHECK:STDOUT: %.7: type = tuple_type (%.6, i32) [template]
  23. // CHECK:STDOUT: %.8: type = ptr_type %.7 [template]
  24. // CHECK:STDOUT: %.9: i32 = int_literal 12 [template]
  25. // CHECK:STDOUT: %.10: i32 = int_literal 76 [template]
  26. // CHECK:STDOUT: %.11: i32 = int_literal 6 [template]
  27. // CHECK:STDOUT: %tuple.1: %.4 = tuple_value (%.9, %.10) [template]
  28. // CHECK:STDOUT: %tuple.2: %.5 = tuple_value (%tuple.1, %.11) [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  33. // CHECK:STDOUT: .Int32 = %import_ref
  34. // CHECK:STDOUT: import Core//prelude
  35. // CHECK:STDOUT: import Core//prelude/operators
  36. // CHECK:STDOUT: import Core//prelude/types
  37. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  38. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  39. // CHECK:STDOUT: import Core//prelude/operators/comparison
  40. // CHECK:STDOUT: import Core//prelude/types/bool
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT:
  45. // CHECK:STDOUT: file {
  46. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  47. // CHECK:STDOUT: .Core = imports.%Core
  48. // CHECK:STDOUT: .x = %x
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %Core.import = import Core
  51. // CHECK:STDOUT: %int.make_type_32.loc11_10: init type = call constants.%Int32() [template = i32]
  52. // CHECK:STDOUT: %int.make_type_32.loc11_15: init type = call constants.%Int32() [template = i32]
  53. // CHECK:STDOUT: %.loc11_18: %.2 = tuple_literal (%int.make_type_32.loc11_10, %int.make_type_32.loc11_15)
  54. // CHECK:STDOUT: %int.make_type_32.loc11_21: init type = call constants.%Int32() [template = i32]
  55. // CHECK:STDOUT: %.loc11_24.1: %.3 = tuple_literal (%.loc11_18, %int.make_type_32.loc11_21)
  56. // CHECK:STDOUT: %.loc11_24.2: type = value_of_initializer %int.make_type_32.loc11_10 [template = i32]
  57. // CHECK:STDOUT: %.loc11_24.3: type = converted %int.make_type_32.loc11_10, %.loc11_24.2 [template = i32]
  58. // CHECK:STDOUT: %.loc11_24.4: type = value_of_initializer %int.make_type_32.loc11_15 [template = i32]
  59. // CHECK:STDOUT: %.loc11_24.5: type = converted %int.make_type_32.loc11_15, %.loc11_24.4 [template = i32]
  60. // CHECK:STDOUT: %.loc11_24.6: type = converted %.loc11_18, constants.%.4 [template = constants.%.4]
  61. // CHECK:STDOUT: %.loc11_24.7: type = value_of_initializer %int.make_type_32.loc11_21 [template = i32]
  62. // CHECK:STDOUT: %.loc11_24.8: type = converted %int.make_type_32.loc11_21, %.loc11_24.7 [template = i32]
  63. // CHECK:STDOUT: %.loc11_24.9: type = converted %.loc11_24.1, constants.%.5 [template = constants.%.5]
  64. // CHECK:STDOUT: %x.var: ref %.5 = var x
  65. // CHECK:STDOUT: %x: ref %.5 = bind_name x, %x.var
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: fn @__global_init() {
  71. // CHECK:STDOUT: !entry:
  72. // CHECK:STDOUT: %.loc11_30: i32 = int_literal 12 [template = constants.%.9]
  73. // CHECK:STDOUT: %.loc11_34: i32 = int_literal 76 [template = constants.%.10]
  74. // CHECK:STDOUT: %.loc11_36.1: %.4 = tuple_literal (%.loc11_30, %.loc11_34)
  75. // CHECK:STDOUT: %.loc11_39: i32 = int_literal 6 [template = constants.%.11]
  76. // CHECK:STDOUT: %.loc11_40.1: %.5 = tuple_literal (%.loc11_36.1, %.loc11_39)
  77. // CHECK:STDOUT: %.loc11_40.2: ref %.4 = tuple_access file.%x.var, element0
  78. // CHECK:STDOUT: %.loc11_36.2: ref i32 = tuple_access %.loc11_40.2, element0
  79. // CHECK:STDOUT: %.loc11_36.3: init i32 = initialize_from %.loc11_30 to %.loc11_36.2 [template = constants.%.9]
  80. // CHECK:STDOUT: %.loc11_36.4: ref i32 = tuple_access %.loc11_40.2, element1
  81. // CHECK:STDOUT: %.loc11_36.5: init i32 = initialize_from %.loc11_34 to %.loc11_36.4 [template = constants.%.10]
  82. // CHECK:STDOUT: %.loc11_36.6: init %.4 = tuple_init (%.loc11_36.3, %.loc11_36.5) to %.loc11_40.2 [template = constants.%tuple.1]
  83. // CHECK:STDOUT: %.loc11_40.3: init %.4 = converted %.loc11_36.1, %.loc11_36.6 [template = constants.%tuple.1]
  84. // CHECK:STDOUT: %.loc11_40.4: ref i32 = tuple_access file.%x.var, element1
  85. // CHECK:STDOUT: %.loc11_40.5: init i32 = initialize_from %.loc11_39 to %.loc11_40.4 [template = constants.%.11]
  86. // CHECK:STDOUT: %.loc11_40.6: init %.5 = tuple_init (%.loc11_40.3, %.loc11_40.5) to file.%x.var [template = constants.%tuple.2]
  87. // CHECK:STDOUT: %.loc11_41: init %.5 = converted %.loc11_40.1, %.loc11_40.6 [template = constants.%tuple.2]
  88. // CHECK:STDOUT: assign file.%x.var, %.loc11_41
  89. // CHECK:STDOUT: return
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT: