base.carbon 8.8 KB

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