base.carbon 7.5 KB

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