bool.carbon 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/bool.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/primitives/bool.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/primitives/bool.carbon
  12. fn F() -> bool {
  13. return false;
  14. }
  15. fn T() -> bool {
  16. return true;
  17. }
  18. fn LoadStore(p: bool*, b: bool) -> bool {
  19. let v: bool = *p;
  20. *p = b;
  21. return v;
  22. }
  23. // CHECK:STDOUT: ; ModuleID = 'bool.carbon'
  24. // CHECK:STDOUT: source_filename = "bool.carbon"
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: ; Function Attrs: nounwind
  27. // CHECK:STDOUT: define i1 @_CF.Main() #0 !dbg !4 {
  28. // CHECK:STDOUT: entry:
  29. // CHECK:STDOUT: ret i1 false, !dbg !7
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: ; Function Attrs: nounwind
  33. // CHECK:STDOUT: define i1 @_CT.Main() #0 !dbg !8 {
  34. // CHECK:STDOUT: entry:
  35. // CHECK:STDOUT: ret i1 true, !dbg !9
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: ; Function Attrs: nounwind
  39. // CHECK:STDOUT: define i1 @_CLoadStore.Main(ptr %p, i1 %b) #0 !dbg !10 {
  40. // CHECK:STDOUT: entry:
  41. // CHECK:STDOUT: %.loc22_17.2 = load i8, ptr %p, align 1, !dbg !11
  42. // CHECK:STDOUT: %.loc22_17.21 = trunc i8 %.loc22_17.2 to i1, !dbg !11
  43. // CHECK:STDOUT: %0 = zext i1 %b to i8, !dbg !12
  44. // CHECK:STDOUT: store i8 %0, ptr %p, align 1, !dbg !12
  45. // CHECK:STDOUT: ret i1 %.loc22_17.21, !dbg !13
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: attributes #0 = { nounwind }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  51. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  54. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  55. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  56. // CHECK:STDOUT: !3 = !DIFile(filename: "bool.carbon", directory: "")
  57. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "F", linkageName: "_CF.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  58. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  59. // CHECK:STDOUT: !6 = !{}
  60. // CHECK:STDOUT: !7 = !DILocation(line: 14, column: 3, scope: !4)
  61. // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "T", linkageName: "_CT.Main", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  62. // CHECK:STDOUT: !9 = !DILocation(line: 18, column: 3, scope: !8)
  63. // CHECK:STDOUT: !10 = distinct !DISubprogram(name: "LoadStore", linkageName: "_CLoadStore.Main", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  64. // CHECK:STDOUT: !11 = !DILocation(line: 22, column: 17, scope: !10)
  65. // CHECK:STDOUT: !12 = !DILocation(line: 23, column: 3, scope: !10)
  66. // CHECK:STDOUT: !13 = !DILocation(line: 24, column: 3, scope: !10)