nine_elements.carbon 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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/array/nine_elements.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/nine_elements.carbon
  10. var a: [i32; 9] = (1, 2, 3, 4, 5, 6, 7, 8, 9);
  11. // CHECK:STDOUT: --- nine_elements.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: i32 = int_literal 9 [template]
  18. // CHECK:STDOUT: %.3: type = array_type %.2, i32 [template]
  19. // CHECK:STDOUT: %.4: type = ptr_type %.3 [template]
  20. // CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
  21. // CHECK:STDOUT: %.6: i32 = int_literal 2 [template]
  22. // CHECK:STDOUT: %.7: i32 = int_literal 3 [template]
  23. // CHECK:STDOUT: %.8: i32 = int_literal 4 [template]
  24. // CHECK:STDOUT: %.9: i32 = int_literal 5 [template]
  25. // CHECK:STDOUT: %.10: i32 = int_literal 6 [template]
  26. // CHECK:STDOUT: %.11: i32 = int_literal 7 [template]
  27. // CHECK:STDOUT: %.12: i32 = int_literal 8 [template]
  28. // CHECK:STDOUT: %.13: type = tuple_type (i32, i32, i32, i32, i32, i32, i32, i32, i32) [template]
  29. // CHECK:STDOUT: %.14: i32 = int_literal 0 [template]
  30. // CHECK:STDOUT: %array: %.3 = tuple_value (%.5, %.6, %.7, %.8, %.9, %.10, %.11, %.12, %.2) [template]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: imports {
  34. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  35. // CHECK:STDOUT: .Int32 = %import_ref
  36. // CHECK:STDOUT: import Core//prelude
  37. // CHECK:STDOUT: import Core//prelude/operators
  38. // CHECK:STDOUT: import Core//prelude/types
  39. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  40. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  41. // CHECK:STDOUT: import Core//prelude/operators/comparison
  42. // CHECK:STDOUT: import Core//prelude/types/bool
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: file {
  48. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  49. // CHECK:STDOUT: .Core = imports.%Core
  50. // CHECK:STDOUT: .a = %a
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %Core.import = import Core
  53. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  54. // CHECK:STDOUT: %.loc11_14: i32 = int_literal 9 [template = constants.%.2]
  55. // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32 [template = i32]
  56. // CHECK:STDOUT: %.loc11_9.2: type = converted %int.make_type_32, %.loc11_9.1 [template = i32]
  57. // CHECK:STDOUT: %.loc11_15: type = array_type %.loc11_14, i32 [template = constants.%.3]
  58. // CHECK:STDOUT: %a.var: ref %.3 = var a
  59. // CHECK:STDOUT: %a: ref %.3 = bind_name a, %a.var
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: fn @__global_init() {
  65. // CHECK:STDOUT: !entry:
  66. // CHECK:STDOUT: %.loc11_20: i32 = int_literal 1 [template = constants.%.5]
  67. // CHECK:STDOUT: %.loc11_23: i32 = int_literal 2 [template = constants.%.6]
  68. // CHECK:STDOUT: %.loc11_26: i32 = int_literal 3 [template = constants.%.7]
  69. // CHECK:STDOUT: %.loc11_29: i32 = int_literal 4 [template = constants.%.8]
  70. // CHECK:STDOUT: %.loc11_32: i32 = int_literal 5 [template = constants.%.9]
  71. // CHECK:STDOUT: %.loc11_35: i32 = int_literal 6 [template = constants.%.10]
  72. // CHECK:STDOUT: %.loc11_38: i32 = int_literal 7 [template = constants.%.11]
  73. // CHECK:STDOUT: %.loc11_41: i32 = int_literal 8 [template = constants.%.12]
  74. // CHECK:STDOUT: %.loc11_44: i32 = int_literal 9 [template = constants.%.2]
  75. // CHECK:STDOUT: %.loc11_45.1: %.13 = tuple_literal (%.loc11_20, %.loc11_23, %.loc11_26, %.loc11_29, %.loc11_32, %.loc11_35, %.loc11_38, %.loc11_41, %.loc11_44)
  76. // CHECK:STDOUT: %.loc11_45.2: i32 = int_literal 0 [template = constants.%.14]
  77. // CHECK:STDOUT: %.loc11_45.3: ref i32 = array_index file.%a.var, %.loc11_45.2
  78. // CHECK:STDOUT: %.loc11_45.4: init i32 = initialize_from %.loc11_20 to %.loc11_45.3 [template = constants.%.5]
  79. // CHECK:STDOUT: %.loc11_45.5: i32 = int_literal 1 [template = constants.%.5]
  80. // CHECK:STDOUT: %.loc11_45.6: ref i32 = array_index file.%a.var, %.loc11_45.5
  81. // CHECK:STDOUT: %.loc11_45.7: init i32 = initialize_from %.loc11_23 to %.loc11_45.6 [template = constants.%.6]
  82. // CHECK:STDOUT: %.loc11_45.8: i32 = int_literal 2 [template = constants.%.6]
  83. // CHECK:STDOUT: %.loc11_45.9: ref i32 = array_index file.%a.var, %.loc11_45.8
  84. // CHECK:STDOUT: %.loc11_45.10: init i32 = initialize_from %.loc11_26 to %.loc11_45.9 [template = constants.%.7]
  85. // CHECK:STDOUT: %.loc11_45.11: i32 = int_literal 3 [template = constants.%.7]
  86. // CHECK:STDOUT: %.loc11_45.12: ref i32 = array_index file.%a.var, %.loc11_45.11
  87. // CHECK:STDOUT: %.loc11_45.13: init i32 = initialize_from %.loc11_29 to %.loc11_45.12 [template = constants.%.8]
  88. // CHECK:STDOUT: %.loc11_45.14: i32 = int_literal 4 [template = constants.%.8]
  89. // CHECK:STDOUT: %.loc11_45.15: ref i32 = array_index file.%a.var, %.loc11_45.14
  90. // CHECK:STDOUT: %.loc11_45.16: init i32 = initialize_from %.loc11_32 to %.loc11_45.15 [template = constants.%.9]
  91. // CHECK:STDOUT: %.loc11_45.17: i32 = int_literal 5 [template = constants.%.9]
  92. // CHECK:STDOUT: %.loc11_45.18: ref i32 = array_index file.%a.var, %.loc11_45.17
  93. // CHECK:STDOUT: %.loc11_45.19: init i32 = initialize_from %.loc11_35 to %.loc11_45.18 [template = constants.%.10]
  94. // CHECK:STDOUT: %.loc11_45.20: i32 = int_literal 6 [template = constants.%.10]
  95. // CHECK:STDOUT: %.loc11_45.21: ref i32 = array_index file.%a.var, %.loc11_45.20
  96. // CHECK:STDOUT: %.loc11_45.22: init i32 = initialize_from %.loc11_38 to %.loc11_45.21 [template = constants.%.11]
  97. // CHECK:STDOUT: %.loc11_45.23: i32 = int_literal 7 [template = constants.%.11]
  98. // CHECK:STDOUT: %.loc11_45.24: ref i32 = array_index file.%a.var, %.loc11_45.23
  99. // CHECK:STDOUT: %.loc11_45.25: init i32 = initialize_from %.loc11_41 to %.loc11_45.24 [template = constants.%.12]
  100. // CHECK:STDOUT: %.loc11_45.26: i32 = int_literal 8 [template = constants.%.12]
  101. // CHECK:STDOUT: %.loc11_45.27: ref i32 = array_index file.%a.var, %.loc11_45.26
  102. // CHECK:STDOUT: %.loc11_45.28: init i32 = initialize_from %.loc11_44 to %.loc11_45.27 [template = constants.%.2]
  103. // CHECK:STDOUT: %.loc11_45.29: init %.3 = array_init (%.loc11_45.4, %.loc11_45.7, %.loc11_45.10, %.loc11_45.13, %.loc11_45.16, %.loc11_45.19, %.loc11_45.22, %.loc11_45.25, %.loc11_45.28) to file.%a.var [template = constants.%array]
  104. // CHECK:STDOUT: %.loc11_46: init %.3 = converted %.loc11_45.1, %.loc11_45.29 [template = constants.%array]
  105. // CHECK:STDOUT: assign file.%a.var, %.loc11_46
  106. // CHECK:STDOUT: return
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: