nine_elements.carbon 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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: %Int32: %Int32.type = struct_value () [template]
  16. // CHECK:STDOUT: %.1: i32 = int_value 9 [template]
  17. // CHECK:STDOUT: %.2: type = array_type %.1, i32 [template]
  18. // CHECK:STDOUT: %.4: i32 = int_value 1 [template]
  19. // CHECK:STDOUT: %.5: i32 = int_value 2 [template]
  20. // CHECK:STDOUT: %.6: i32 = int_value 3 [template]
  21. // CHECK:STDOUT: %.7: i32 = int_value 4 [template]
  22. // CHECK:STDOUT: %.8: i32 = int_value 5 [template]
  23. // CHECK:STDOUT: %.9: i32 = int_value 6 [template]
  24. // CHECK:STDOUT: %.10: i32 = int_value 7 [template]
  25. // CHECK:STDOUT: %.11: i32 = int_value 8 [template]
  26. // CHECK:STDOUT: %tuple.type: type = tuple_type (i32, i32, i32, i32, i32, i32, i32, i32, i32) [template]
  27. // CHECK:STDOUT: %.12: i32 = int_value 0 [template]
  28. // CHECK:STDOUT: %array: %.2 = tuple_value (%.4, %.5, %.6, %.7, %.8, %.9, %.10, %.11, %.1) [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/...
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  41. // CHECK:STDOUT: .Core = imports.%Core
  42. // CHECK:STDOUT: .a = %a
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Core.import = import Core
  45. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  46. // CHECK:STDOUT: %.loc11_14: i32 = int_value 9 [template = constants.%.1]
  47. // CHECK:STDOUT: %.loc11_9.1: type = value_of_initializer %int.make_type_32 [template = i32]
  48. // CHECK:STDOUT: %.loc11_9.2: type = converted %int.make_type_32, %.loc11_9.1 [template = i32]
  49. // CHECK:STDOUT: %.loc11_15: type = array_type %.loc11_14, i32 [template = constants.%.2]
  50. // CHECK:STDOUT: %a.var: ref %.2 = var a
  51. // CHECK:STDOUT: %a: ref %.2 = bind_name a, %a.var
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: fn @__global_init() {
  55. // CHECK:STDOUT: !entry:
  56. // CHECK:STDOUT: %.loc11_20: i32 = int_value 1 [template = constants.%.4]
  57. // CHECK:STDOUT: %.loc11_23: i32 = int_value 2 [template = constants.%.5]
  58. // CHECK:STDOUT: %.loc11_26: i32 = int_value 3 [template = constants.%.6]
  59. // CHECK:STDOUT: %.loc11_29: i32 = int_value 4 [template = constants.%.7]
  60. // CHECK:STDOUT: %.loc11_32: i32 = int_value 5 [template = constants.%.8]
  61. // CHECK:STDOUT: %.loc11_35: i32 = int_value 6 [template = constants.%.9]
  62. // CHECK:STDOUT: %.loc11_38: i32 = int_value 7 [template = constants.%.10]
  63. // CHECK:STDOUT: %.loc11_41: i32 = int_value 8 [template = constants.%.11]
  64. // CHECK:STDOUT: %.loc11_44: i32 = int_value 9 [template = constants.%.1]
  65. // CHECK:STDOUT: %.loc11_45.1: %tuple.type = tuple_literal (%.loc11_20, %.loc11_23, %.loc11_26, %.loc11_29, %.loc11_32, %.loc11_35, %.loc11_38, %.loc11_41, %.loc11_44)
  66. // CHECK:STDOUT: %.loc11_45.2: i32 = int_value 0 [template = constants.%.12]
  67. // CHECK:STDOUT: %.loc11_45.3: ref i32 = array_index file.%a.var, %.loc11_45.2
  68. // CHECK:STDOUT: %.loc11_45.4: init i32 = initialize_from %.loc11_20 to %.loc11_45.3 [template = constants.%.4]
  69. // CHECK:STDOUT: %.loc11_45.5: i32 = int_value 1 [template = constants.%.4]
  70. // CHECK:STDOUT: %.loc11_45.6: ref i32 = array_index file.%a.var, %.loc11_45.5
  71. // CHECK:STDOUT: %.loc11_45.7: init i32 = initialize_from %.loc11_23 to %.loc11_45.6 [template = constants.%.5]
  72. // CHECK:STDOUT: %.loc11_45.8: i32 = int_value 2 [template = constants.%.5]
  73. // CHECK:STDOUT: %.loc11_45.9: ref i32 = array_index file.%a.var, %.loc11_45.8
  74. // CHECK:STDOUT: %.loc11_45.10: init i32 = initialize_from %.loc11_26 to %.loc11_45.9 [template = constants.%.6]
  75. // CHECK:STDOUT: %.loc11_45.11: i32 = int_value 3 [template = constants.%.6]
  76. // CHECK:STDOUT: %.loc11_45.12: ref i32 = array_index file.%a.var, %.loc11_45.11
  77. // CHECK:STDOUT: %.loc11_45.13: init i32 = initialize_from %.loc11_29 to %.loc11_45.12 [template = constants.%.7]
  78. // CHECK:STDOUT: %.loc11_45.14: i32 = int_value 4 [template = constants.%.7]
  79. // CHECK:STDOUT: %.loc11_45.15: ref i32 = array_index file.%a.var, %.loc11_45.14
  80. // CHECK:STDOUT: %.loc11_45.16: init i32 = initialize_from %.loc11_32 to %.loc11_45.15 [template = constants.%.8]
  81. // CHECK:STDOUT: %.loc11_45.17: i32 = int_value 5 [template = constants.%.8]
  82. // CHECK:STDOUT: %.loc11_45.18: ref i32 = array_index file.%a.var, %.loc11_45.17
  83. // CHECK:STDOUT: %.loc11_45.19: init i32 = initialize_from %.loc11_35 to %.loc11_45.18 [template = constants.%.9]
  84. // CHECK:STDOUT: %.loc11_45.20: i32 = int_value 6 [template = constants.%.9]
  85. // CHECK:STDOUT: %.loc11_45.21: ref i32 = array_index file.%a.var, %.loc11_45.20
  86. // CHECK:STDOUT: %.loc11_45.22: init i32 = initialize_from %.loc11_38 to %.loc11_45.21 [template = constants.%.10]
  87. // CHECK:STDOUT: %.loc11_45.23: i32 = int_value 7 [template = constants.%.10]
  88. // CHECK:STDOUT: %.loc11_45.24: ref i32 = array_index file.%a.var, %.loc11_45.23
  89. // CHECK:STDOUT: %.loc11_45.25: init i32 = initialize_from %.loc11_41 to %.loc11_45.24 [template = constants.%.11]
  90. // CHECK:STDOUT: %.loc11_45.26: i32 = int_value 8 [template = constants.%.11]
  91. // CHECK:STDOUT: %.loc11_45.27: ref i32 = array_index file.%a.var, %.loc11_45.26
  92. // CHECK:STDOUT: %.loc11_45.28: init i32 = initialize_from %.loc11_44 to %.loc11_45.27 [template = constants.%.1]
  93. // CHECK:STDOUT: %.loc11_45.29: init %.2 = 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]
  94. // CHECK:STDOUT: %.loc11_46: init %.2 = converted %.loc11_45.1, %.loc11_45.29 [template = constants.%array]
  95. // CHECK:STDOUT: assign file.%a.var, %.loc11_46
  96. // CHECK:STDOUT: return
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT: