numeric_literals.carbon 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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: define void @F() {
  28. // CHECK:STDOUT: %ints = alloca [4 x i32], align 4
  29. // CHECK:STDOUT: %array.index = getelementptr inbounds [4 x i32], ptr %ints, i32 0, i32 0
  30. // CHECK:STDOUT: store i32 8, ptr %array.index, align 4
  31. // CHECK:STDOUT: %array.index1 = getelementptr inbounds [4 x i32], ptr %ints, i32 0, i32 1
  32. // CHECK:STDOUT: store i32 9, ptr %array.index1, align 4
  33. // CHECK:STDOUT: %array.index2 = getelementptr inbounds [4 x i32], ptr %ints, i32 0, i32 2
  34. // CHECK:STDOUT: store i32 8, ptr %array.index2, align 4
  35. // CHECK:STDOUT: %array.index3 = getelementptr inbounds [4 x i32], ptr %ints, i32 0, i32 3
  36. // CHECK:STDOUT: store i32 8, ptr %array.index3, align 4
  37. // CHECK:STDOUT: %floats = alloca [6 x double], align 8
  38. // CHECK:STDOUT: %array.index4 = getelementptr inbounds [6 x double], ptr %floats, i32 0, i32 0
  39. // CHECK:STDOUT: store double 9.000000e-01, ptr %array.index4, align 8
  40. // CHECK:STDOUT: %array.index5 = getelementptr inbounds [6 x double], ptr %floats, i32 0, i32 1
  41. // CHECK:STDOUT: store double 8.000000e+00, ptr %array.index5, align 8
  42. // CHECK:STDOUT: %array.index6 = getelementptr inbounds [6 x double], ptr %floats, i32 0, i32 2
  43. // CHECK:STDOUT: store double 8.000000e+01, ptr %array.index6, align 8
  44. // CHECK:STDOUT: %array.index7 = getelementptr inbounds [6 x double], ptr %floats, i32 0, i32 3
  45. // CHECK:STDOUT: store double 1.000000e+07, ptr %array.index7, align 8
  46. // CHECK:STDOUT: %array.index8 = getelementptr inbounds [6 x double], ptr %floats, i32 0, i32 4
  47. // CHECK:STDOUT: store double 1.000000e+08, ptr %array.index8, align 8
  48. // CHECK:STDOUT: %array.index9 = getelementptr inbounds [6 x double], ptr %floats, i32 0, i32 5
  49. // CHECK:STDOUT: store double 1.000000e-08, ptr %array.index9, align 8
  50. // CHECK:STDOUT: ret void
  51. // CHECK:STDOUT: }