numeric_literals.carbon 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 F() {
  7. // 8 and 9 trigger special behavior in APInt when mishandling signed versus
  8. // unsigned, so we pay extra attention to those.
  9. var ints: [i32; 4] = (
  10. 8,
  11. 9,
  12. 0x8,
  13. 0b1000,
  14. );
  15. var floats: [f64; 6] = (
  16. 0.9,
  17. 8.0,
  18. 80.0,
  19. 1.0e7,
  20. 1.0e8,
  21. 1.0e-8,
  22. );
  23. }
  24. // CHECK:STDOUT: ; ModuleID = 'numeric_literals.carbon'
  25. // CHECK:STDOUT: source_filename = "numeric_literals.carbon"
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: @array.1.loc15_4 = internal constant [4 x i32] [i32 8, i32 9, i32 8, i32 8]
  28. // CHECK:STDOUT: @array.2.loc23_4 = internal constant [6 x double] [double 9.000000e-01, double 8.000000e+00, double 8.000000e+01, double 1.000000e+07, double 1.000000e+08, double 1.000000e-08]
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: define void @F() {
  31. // CHECK:STDOUT: entry:
  32. // CHECK:STDOUT: %ints.var = alloca [4 x i32], align 4
  33. // CHECK:STDOUT: %.loc15_3.3.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 0
  34. // CHECK:STDOUT: %.loc15_3.6.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 1
  35. // CHECK:STDOUT: %.loc15_3.9.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 2
  36. // CHECK:STDOUT: %.loc15_3.12.array.index = getelementptr inbounds [4 x i32], ptr %ints.var, i32 0, i32 3
  37. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %ints.var, ptr align 4 @array.1.loc15_4, i64 16, i1 false)
  38. // CHECK:STDOUT: %floats.var = alloca [6 x double], align 8
  39. // CHECK:STDOUT: %.loc23_3.3.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 0
  40. // CHECK:STDOUT: %.loc23_3.6.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 1
  41. // CHECK:STDOUT: %.loc23_3.9.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 2
  42. // CHECK:STDOUT: %.loc23_3.12.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 3
  43. // CHECK:STDOUT: %.loc23_3.15.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 4
  44. // CHECK:STDOUT: %.loc23_3.18.array.index = getelementptr inbounds [6 x double], ptr %floats.var, i32 0, i32 5
  45. // CHECK:STDOUT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %floats.var, ptr align 8 @array.2.loc23_4, i64 48, i1 false)
  46. // CHECK:STDOUT: ret void
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: ; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
  50. // CHECK:STDOUT: declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: ; uselistorder directives
  53. // CHECK:STDOUT: uselistorder ptr @llvm.memcpy.p0.p0.i64, { 1, 0 }
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }