base.carbon 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. fn Run() {
  7. var a: [i32; 1] = (1,);
  8. var b: [f64; 2] = (11.1, 2.2,);
  9. var c: [(); 5] = ((), (), (), (), (),);
  10. var d: (i32, i32, i32) = (1, 2, 3);
  11. var e: [i32; 3] = d;
  12. }
  13. // CHECK:STDOUT: ; ModuleID = 'base.carbon'
  14. // CHECK:STDOUT: source_filename = "base.carbon"
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: define void @main() {
  17. // CHECK:STDOUT: %a = alloca [1 x i32], align 4
  18. // CHECK:STDOUT: %array.index = getelementptr inbounds [1 x i32], ptr %a, i32 0, i32 0
  19. // CHECK:STDOUT: store i32 1, ptr %array.index, align 4
  20. // CHECK:STDOUT: %b = alloca [2 x double], align 8
  21. // CHECK:STDOUT: %array.index1 = getelementptr inbounds [2 x double], ptr %b, i32 0, i32 0
  22. // CHECK:STDOUT: store double 0x4026333333333334, ptr %array.index1, align 8
  23. // CHECK:STDOUT: %array.index2 = getelementptr inbounds [2 x double], ptr %b, i32 0, i32 1
  24. // CHECK:STDOUT: store double 2.200000e+00, ptr %array.index2, align 8
  25. // CHECK:STDOUT: %c = alloca [5 x {}], align 8
  26. // CHECK:STDOUT: %array.index3 = getelementptr inbounds [5 x {}], ptr %c, i32 0, i32 0
  27. // CHECK:STDOUT: %array.index4 = getelementptr inbounds [5 x {}], ptr %c, i32 0, i32 1
  28. // CHECK:STDOUT: %array.index5 = getelementptr inbounds [5 x {}], ptr %c, i32 0, i32 2
  29. // CHECK:STDOUT: %array.index6 = getelementptr inbounds [5 x {}], ptr %c, i32 0, i32 3
  30. // CHECK:STDOUT: %array.index7 = getelementptr inbounds [5 x {}], ptr %c, i32 0, i32 4
  31. // CHECK:STDOUT: %d = alloca { i32, i32, i32 }, align 8
  32. // CHECK:STDOUT: %tuple.elem = getelementptr inbounds { i32, i32, i32 }, ptr %d, i32 0, i32 0
  33. // CHECK:STDOUT: store i32 1, ptr %tuple.elem, align 4
  34. // CHECK:STDOUT: %tuple.elem8 = getelementptr inbounds { i32, i32, i32 }, ptr %d, i32 0, i32 1
  35. // CHECK:STDOUT: store i32 2, ptr %tuple.elem8, align 4
  36. // CHECK:STDOUT: %tuple.elem9 = getelementptr inbounds { i32, i32, i32 }, ptr %d, i32 0, i32 2
  37. // CHECK:STDOUT: store i32 3, ptr %tuple.elem9, align 4
  38. // CHECK:STDOUT: %e = alloca [3 x i32], align 4
  39. // CHECK:STDOUT: %tuple.elem10 = getelementptr inbounds { i32, i32, i32 }, ptr %d, i32 0, i32 0
  40. // CHECK:STDOUT: %1 = load i32, ptr %tuple.elem10, align 4
  41. // CHECK:STDOUT: %array.index11 = getelementptr inbounds [3 x i32], ptr %e, i32 0, i32 0
  42. // CHECK:STDOUT: store i32 %1, ptr %array.index11, align 4
  43. // CHECK:STDOUT: %tuple.elem12 = getelementptr inbounds { i32, i32, i32 }, ptr %d, i32 0, i32 1
  44. // CHECK:STDOUT: %2 = load i32, ptr %tuple.elem12, align 4
  45. // CHECK:STDOUT: %array.index13 = getelementptr inbounds [3 x i32], ptr %e, i32 0, i32 1
  46. // CHECK:STDOUT: store i32 %2, ptr %array.index13, align 4
  47. // CHECK:STDOUT: %tuple.elem14 = getelementptr inbounds { i32, i32, i32 }, ptr %d, i32 0, i32 2
  48. // CHECK:STDOUT: %3 = load i32, ptr %tuple.elem14, align 4
  49. // CHECK:STDOUT: %array.index15 = getelementptr inbounds [3 x i32], ptr %e, i32 0, i32 2
  50. // CHECK:STDOUT: store i32 %3, ptr %array.index15, align 4
  51. // CHECK:STDOUT: ret void
  52. // CHECK:STDOUT: }