array_in_place.carbon 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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); 2] = (F(), F());
  9. }
  10. // CHECK:STDOUT: --- array_in_place.carbon
  11. // CHECK:STDOUT:
  12. // CHECK:STDOUT: constants {
  13. // CHECK:STDOUT: %.1: type = tuple_type (type, type, type) [template]
  14. // CHECK:STDOUT: %.2: type = tuple_type (i32, i32, i32) [template]
  15. // CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
  16. // CHECK:STDOUT: %.4: type = array_type %.3, (i32, i32, i32) [template]
  17. // CHECK:STDOUT: %.5: type = ptr_type (i32, i32, i32) [template]
  18. // CHECK:STDOUT: %.6: type = ptr_type [(i32, i32, i32); 2] [template]
  19. // CHECK:STDOUT: %.7: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) [template]
  20. // CHECK:STDOUT: %.8: i32 = int_literal 0 [template]
  21. // CHECK:STDOUT: %.9: i32 = int_literal 1 [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: .F = %F
  28. // CHECK:STDOUT: .G = %G
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  31. // CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
  32. // CHECK:STDOUT: %.loc7_25.1: (type, type, type) = tuple_literal (i32, i32, i32)
  33. // CHECK:STDOUT: %.loc7_25.2: type = converted %.loc7_25.1, constants.%.2 [template = constants.%.2]
  34. // CHECK:STDOUT: @F.%return: ref (i32, i32, i32) = var <return slot>
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: %G: <function> = fn_decl @G [template] {}
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: fn @F() -> (i32, i32, i32);
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: fn @G() {
  42. // CHECK:STDOUT: !entry:
  43. // CHECK:STDOUT: %.loc10_25.1: (type, type, type) = tuple_literal (i32, i32, i32)
  44. // CHECK:STDOUT: %.loc10_28: i32 = int_literal 2 [template = constants.%.3]
  45. // CHECK:STDOUT: %.loc10_25.2: type = converted %.loc10_25.1, constants.%.2 [template = constants.%.2]
  46. // CHECK:STDOUT: %.loc10_29: type = array_type %.loc10_28, (i32, i32, i32) [template = constants.%.4]
  47. // CHECK:STDOUT: %v.var: ref [(i32, i32, i32); 2] = var v
  48. // CHECK:STDOUT: %v: ref [(i32, i32, i32); 2] = bind_name v, %v.var
  49. // CHECK:STDOUT: %F.ref.loc10_34: <function> = name_ref F, file.%F [template = file.%F]
  50. // CHECK:STDOUT: %.loc10_42.3: ref (i32, i32, i32) = splice_block %.loc10_42.2 {
  51. // CHECK:STDOUT: %.loc10_42.1: i32 = int_literal 0 [template = constants.%.8]
  52. // CHECK:STDOUT: %.loc10_42.2: ref (i32, i32, i32) = array_index %v.var, %.loc10_42.1
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %F.call.loc10_35: init (i32, i32, i32) = call %F.ref.loc10_34() to %.loc10_42.3
  55. // CHECK:STDOUT: %F.ref.loc10_39: <function> = name_ref F, file.%F [template = file.%F]
  56. // CHECK:STDOUT: %.loc10_42.6: ref (i32, i32, i32) = splice_block %.loc10_42.5 {
  57. // CHECK:STDOUT: %.loc10_42.4: i32 = int_literal 1 [template = constants.%.9]
  58. // CHECK:STDOUT: %.loc10_42.5: ref (i32, i32, i32) = array_index %v.var, %.loc10_42.4
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %F.call.loc10_40: init (i32, i32, i32) = call %F.ref.loc10_39() to %.loc10_42.6
  61. // CHECK:STDOUT: %.loc10_42.7: ((i32, i32, i32), (i32, i32, i32)) = tuple_literal (%F.call.loc10_35, %F.call.loc10_40)
  62. // CHECK:STDOUT: %.loc10_42.8: init [(i32, i32, i32); 2] = array_init (%F.call.loc10_35, %F.call.loc10_40) to %v.var
  63. // CHECK:STDOUT: %.loc10_43: init [(i32, i32, i32); 2] = converted %.loc10_42.7, %.loc10_42.8
  64. // CHECK:STDOUT: assign %v.var, %.loc10_43
  65. // CHECK:STDOUT: return
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: