base.carbon 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. var a: [i32; 1] = (1,);
  7. var b: [f64; 2] = (11.1, 2.2,);
  8. var c: [(); 5] = ((), (), (), (), (),);
  9. // CHECK:STDOUT: --- base.carbon
  10. // CHECK:STDOUT:
  11. // CHECK:STDOUT: constants {
  12. // CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
  13. // CHECK:STDOUT: %.2: type = array_type %.1, i32 [template]
  14. // CHECK:STDOUT: %.3: type = ptr_type [i32; 1] [template]
  15. // CHECK:STDOUT: %.4: type = tuple_type (i32) [template]
  16. // CHECK:STDOUT: %.5: i32 = int_literal 0 [template]
  17. // CHECK:STDOUT: %.6: [i32; 1] = tuple_value (%.1) [template]
  18. // CHECK:STDOUT: %.7: i32 = int_literal 2 [template]
  19. // CHECK:STDOUT: %.8: type = array_type %.7, f64 [template]
  20. // CHECK:STDOUT: %.9: type = ptr_type [f64; 2] [template]
  21. // CHECK:STDOUT: %.10: f64 = real_literal 111e-1 [template]
  22. // CHECK:STDOUT: %.11: f64 = real_literal 22e-1 [template]
  23. // CHECK:STDOUT: %.12: type = tuple_type (f64, f64) [template]
  24. // CHECK:STDOUT: %.13: i32 = int_literal 1 [template]
  25. // CHECK:STDOUT: %.14: [f64; 2] = tuple_value (%.10, %.11) [template]
  26. // CHECK:STDOUT: %.15: type = tuple_type () [template]
  27. // CHECK:STDOUT: %.16: i32 = int_literal 5 [template]
  28. // CHECK:STDOUT: %.17: type = array_type %.16, () [template]
  29. // CHECK:STDOUT: %.18: type = ptr_type [(); 5] [template]
  30. // CHECK:STDOUT: %.19: type = tuple_type ((), (), (), (), ()) [template]
  31. // CHECK:STDOUT: %.20: () = tuple_value () [template]
  32. // CHECK:STDOUT: %.21: i32 = int_literal 2 [template]
  33. // CHECK:STDOUT: %.22: i32 = int_literal 3 [template]
  34. // CHECK:STDOUT: %.23: i32 = int_literal 4 [template]
  35. // CHECK:STDOUT: %.24: [(); 5] = tuple_value (%.20, %.20, %.20, %.20, %.20) [template]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: file {
  39. // CHECK:STDOUT: package: <namespace> = namespace {.a = %a, .b = %b, .c = %c} [template]
  40. // CHECK:STDOUT: %.loc7_14: i32 = int_literal 1 [template = constants.%.1]
  41. // CHECK:STDOUT: %.loc7_15: type = array_type %.loc7_14, i32 [template = constants.%.2]
  42. // CHECK:STDOUT: %a.var: ref [i32; 1] = var a
  43. // CHECK:STDOUT: %a: ref [i32; 1] = bind_name a, %a.var
  44. // CHECK:STDOUT: %.loc8_14: i32 = int_literal 2 [template = constants.%.7]
  45. // CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, f64 [template = constants.%.8]
  46. // CHECK:STDOUT: %b.var: ref [f64; 2] = var b
  47. // CHECK:STDOUT: %b: ref [f64; 2] = bind_name b, %b.var
  48. // CHECK:STDOUT: %.loc9_10.1: () = tuple_literal ()
  49. // CHECK:STDOUT: %.loc9_13: i32 = int_literal 5 [template = constants.%.16]
  50. // CHECK:STDOUT: %.loc9_10.2: type = converted %.loc9_10.1, constants.%.15 [template = constants.%.15]
  51. // CHECK:STDOUT: %.loc9_14: type = array_type %.loc9_13, () [template = constants.%.17]
  52. // CHECK:STDOUT: %c.var: ref [(); 5] = var c
  53. // CHECK:STDOUT: %c: ref [(); 5] = bind_name c, %c.var
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @__global_init() {
  57. // CHECK:STDOUT: !entry:
  58. // CHECK:STDOUT: %.loc7_20: i32 = int_literal 1 [template = constants.%.1]
  59. // CHECK:STDOUT: %.loc7_22.1: (i32,) = tuple_literal (%.loc7_20)
  60. // CHECK:STDOUT: %.loc7_22.2: i32 = int_literal 0 [template = constants.%.5]
  61. // CHECK:STDOUT: %.loc7_22.3: ref i32 = array_index file.%a.var, %.loc7_22.2
  62. // CHECK:STDOUT: %.loc7_22.4: init i32 = initialize_from %.loc7_20 to %.loc7_22.3 [template = constants.%.1]
  63. // CHECK:STDOUT: %.loc7_22.5: init [i32; 1] = array_init (%.loc7_22.4) to file.%a.var [template = constants.%.6]
  64. // CHECK:STDOUT: %.loc7_22.6: init [i32; 1] = converted %.loc7_22.1, %.loc7_22.5 [template = constants.%.6]
  65. // CHECK:STDOUT: assign file.%a.var, %.loc7_22.6
  66. // CHECK:STDOUT: %.loc8_20: f64 = real_literal 111e-1 [template = constants.%.10]
  67. // CHECK:STDOUT: %.loc8_26: f64 = real_literal 22e-1 [template = constants.%.11]
  68. // CHECK:STDOUT: %.loc8_30.1: (f64, f64) = tuple_literal (%.loc8_20, %.loc8_26)
  69. // CHECK:STDOUT: %.loc8_30.2: i32 = int_literal 0 [template = constants.%.5]
  70. // CHECK:STDOUT: %.loc8_30.3: ref f64 = array_index file.%b.var, %.loc8_30.2
  71. // CHECK:STDOUT: %.loc8_30.4: init f64 = initialize_from %.loc8_20 to %.loc8_30.3 [template = constants.%.10]
  72. // CHECK:STDOUT: %.loc8_30.5: i32 = int_literal 1 [template = constants.%.13]
  73. // CHECK:STDOUT: %.loc8_30.6: ref f64 = array_index file.%b.var, %.loc8_30.5
  74. // CHECK:STDOUT: %.loc8_30.7: init f64 = initialize_from %.loc8_26 to %.loc8_30.6 [template = constants.%.11]
  75. // CHECK:STDOUT: %.loc8_30.8: init [f64; 2] = array_init (%.loc8_30.4, %.loc8_30.7) to file.%b.var [template = constants.%.14]
  76. // CHECK:STDOUT: %.loc8_30.9: init [f64; 2] = converted %.loc8_30.1, %.loc8_30.8 [template = constants.%.14]
  77. // CHECK:STDOUT: assign file.%b.var, %.loc8_30.9
  78. // CHECK:STDOUT: %.loc9_20.1: () = tuple_literal ()
  79. // CHECK:STDOUT: %.loc9_24.1: () = tuple_literal ()
  80. // CHECK:STDOUT: %.loc9_28.1: () = tuple_literal ()
  81. // CHECK:STDOUT: %.loc9_32.1: () = tuple_literal ()
  82. // CHECK:STDOUT: %.loc9_36.1: () = tuple_literal ()
  83. // CHECK:STDOUT: %.loc9_38.1: ((), (), (), (), ()) = tuple_literal (%.loc9_20.1, %.loc9_24.1, %.loc9_28.1, %.loc9_32.1, %.loc9_36.1)
  84. // CHECK:STDOUT: %.loc9_38.2: i32 = int_literal 0 [template = constants.%.5]
  85. // CHECK:STDOUT: %.loc9_38.3: ref () = array_index file.%c.var, %.loc9_38.2
  86. // CHECK:STDOUT: %.loc9_20.2: init () = tuple_init () to %.loc9_38.3 [template = constants.%.20]
  87. // CHECK:STDOUT: %.loc9_20.3: init () = converted %.loc9_20.1, %.loc9_20.2 [template = constants.%.20]
  88. // CHECK:STDOUT: %.loc9_38.4: i32 = int_literal 1 [template = constants.%.13]
  89. // CHECK:STDOUT: %.loc9_38.5: ref () = array_index file.%c.var, %.loc9_38.4
  90. // CHECK:STDOUT: %.loc9_24.2: init () = tuple_init () to %.loc9_38.5 [template = constants.%.20]
  91. // CHECK:STDOUT: %.loc9_24.3: init () = converted %.loc9_24.1, %.loc9_24.2 [template = constants.%.20]
  92. // CHECK:STDOUT: %.loc9_38.6: i32 = int_literal 2 [template = constants.%.21]
  93. // CHECK:STDOUT: %.loc9_38.7: ref () = array_index file.%c.var, %.loc9_38.6
  94. // CHECK:STDOUT: %.loc9_28.2: init () = tuple_init () to %.loc9_38.7 [template = constants.%.20]
  95. // CHECK:STDOUT: %.loc9_28.3: init () = converted %.loc9_28.1, %.loc9_28.2 [template = constants.%.20]
  96. // CHECK:STDOUT: %.loc9_38.8: i32 = int_literal 3 [template = constants.%.22]
  97. // CHECK:STDOUT: %.loc9_38.9: ref () = array_index file.%c.var, %.loc9_38.8
  98. // CHECK:STDOUT: %.loc9_32.2: init () = tuple_init () to %.loc9_38.9 [template = constants.%.20]
  99. // CHECK:STDOUT: %.loc9_32.3: init () = converted %.loc9_32.1, %.loc9_32.2 [template = constants.%.20]
  100. // CHECK:STDOUT: %.loc9_38.10: i32 = int_literal 4 [template = constants.%.23]
  101. // CHECK:STDOUT: %.loc9_38.11: ref () = array_index file.%c.var, %.loc9_38.10
  102. // CHECK:STDOUT: %.loc9_36.2: init () = tuple_init () to %.loc9_38.11 [template = constants.%.20]
  103. // CHECK:STDOUT: %.loc9_36.3: init () = converted %.loc9_36.1, %.loc9_36.2 [template = constants.%.20]
  104. // CHECK:STDOUT: %.loc9_38.12: init [(); 5] = array_init (%.loc9_20.3, %.loc9_24.3, %.loc9_28.3, %.loc9_32.3, %.loc9_36.3) to file.%c.var [template = constants.%.24]
  105. // CHECK:STDOUT: %.loc9_38.13: init [(); 5] = converted %.loc9_38.1, %.loc9_38.12 [template = constants.%.24]
  106. // CHECK:STDOUT: assign file.%c.var, %.loc9_38.13
  107. // CHECK:STDOUT: return
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT: