tuple.carbon 3.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. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/return/tuple.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/return/tuple.carbon
  10. fn Main() -> (i32, i32) {
  11. return (15, 35);
  12. }
  13. // CHECK:STDOUT: --- tuple.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  17. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  18. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  19. // CHECK:STDOUT: %.2: type = tuple_type (type, type) [template]
  20. // CHECK:STDOUT: %.3: type = tuple_type (i32, i32) [template]
  21. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  22. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  23. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  24. // CHECK:STDOUT: %.5: i32 = int_literal 15 [template]
  25. // CHECK:STDOUT: %.6: i32 = int_literal 35 [template]
  26. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.5, %.6) [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Core = %Core
  32. // CHECK:STDOUT: .Main = %Main.decl
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  35. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  36. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  37. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {
  38. // CHECK:STDOUT: %int.make_type_32.loc12_15: init type = call constants.%Int32() [template = i32]
  39. // CHECK:STDOUT: %int.make_type_32.loc12_20: init type = call constants.%Int32() [template = i32]
  40. // CHECK:STDOUT: %.loc12_23.1: %.2 = tuple_literal (%int.make_type_32.loc12_15, %int.make_type_32.loc12_20)
  41. // CHECK:STDOUT: %.loc12_23.2: type = value_of_initializer %int.make_type_32.loc12_15 [template = i32]
  42. // CHECK:STDOUT: %.loc12_23.3: type = converted %int.make_type_32.loc12_15, %.loc12_23.2 [template = i32]
  43. // CHECK:STDOUT: %.loc12_23.4: type = value_of_initializer %int.make_type_32.loc12_20 [template = i32]
  44. // CHECK:STDOUT: %.loc12_23.5: type = converted %int.make_type_32.loc12_20, %.loc12_23.4 [template = i32]
  45. // CHECK:STDOUT: %.loc12_23.6: type = converted %.loc12_23.1, constants.%.3 [template = constants.%.3]
  46. // CHECK:STDOUT: @Main.%return: ref %.3 = var <return slot>
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @Main() -> %return: %.3 {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: %.loc13_11: i32 = int_literal 15 [template = constants.%.5]
  55. // CHECK:STDOUT: %.loc13_15: i32 = int_literal 35 [template = constants.%.6]
  56. // CHECK:STDOUT: %.loc13_17.1: %.3 = tuple_literal (%.loc13_11, %.loc13_15)
  57. // CHECK:STDOUT: %.loc13_17.2: ref i32 = tuple_access %return, element0
  58. // CHECK:STDOUT: %.loc13_17.3: init i32 = initialize_from %.loc13_11 to %.loc13_17.2 [template = constants.%.5]
  59. // CHECK:STDOUT: %.loc13_17.4: ref i32 = tuple_access %return, element1
  60. // CHECK:STDOUT: %.loc13_17.5: init i32 = initialize_from %.loc13_15 to %.loc13_17.4 [template = constants.%.6]
  61. // CHECK:STDOUT: %.loc13_17.6: init %.3 = tuple_init (%.loc13_17.3, %.loc13_17.5) to %return [template = constants.%tuple]
  62. // CHECK:STDOUT: %.loc13_18: init %.3 = converted %.loc13_17.1, %.loc13_17.6 [template = constants.%tuple]
  63. // CHECK:STDOUT: return %.loc13_18 to %return
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: