unary_op.carbon 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 Not(b: bool) -> bool {
  7. return not b;
  8. }
  9. let not_true: bool = not true;
  10. let not_false: bool = not false;
  11. // CHECK:STDOUT: --- unary_op.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %.1: bool = bool_literal true [template]
  15. // CHECK:STDOUT: %.2: bool = bool_literal false [template]
  16. // CHECK:STDOUT: }
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: file {
  19. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  20. // CHECK:STDOUT: .Not = %Not
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT: %Not: <function> = fn_decl @Not [template] {
  23. // CHECK:STDOUT: %b.loc7_8.1: bool = param b
  24. // CHECK:STDOUT: @Not.%b: bool = bind_name b, %b.loc7_8.1
  25. // CHECK:STDOUT: %return.var: ref bool = var <return slot>
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT: %.loc11_26: bool = bool_literal true [template = constants.%.1]
  28. // CHECK:STDOUT: %.loc11_22: bool = not %.loc11_26 [template = constants.%.2]
  29. // CHECK:STDOUT: %not_true: bool = bind_name not_true, %.loc11_22
  30. // CHECK:STDOUT: %.loc12_27: bool = bool_literal false [template = constants.%.2]
  31. // CHECK:STDOUT: %.loc12_23: bool = not %.loc12_27 [template = constants.%.1]
  32. // CHECK:STDOUT: %not_false: bool = bind_name not_false, %.loc12_23
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: fn @Not(%b: bool) -> bool {
  36. // CHECK:STDOUT: !entry:
  37. // CHECK:STDOUT: %b.ref: bool = name_ref b, %b
  38. // CHECK:STDOUT: %.loc8: bool = not %b.ref
  39. // CHECK:STDOUT: return %.loc8
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: