neq.carbon 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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/primitives.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/check/testdata/builtins/int/neq.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/neq.carbon
  12. // --- int_neq.carbon
  13. fn Neq(a: i32, b: i32) -> bool = "int.neq";
  14. class True {}
  15. class False {}
  16. fn F(true_: True, false_: False) {
  17. false_ as (if Neq(1, 1) then True else False);
  18. true_ as (if Neq(1, 2) then True else False);
  19. }
  20. fn RuntimeCallIsValid(a: i32, b: i32) -> bool {
  21. //@dump-sem-ir-begin
  22. return Neq(a, b);
  23. //@dump-sem-ir-end
  24. }
  25. // CHECK:STDOUT: --- int_neq.carbon
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: constants {
  28. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  29. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  30. // CHECK:STDOUT: %Neq.type: type = fn_type @Neq [concrete]
  31. // CHECK:STDOUT: %Neq: %Neq.type = struct_value () [concrete]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: imports {
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: fn @RuntimeCallIsValid(%a.param: %i32, %b.param: %i32) -> bool {
  38. // CHECK:STDOUT: !entry:
  39. // CHECK:STDOUT: %Neq.ref: %Neq.type = name_ref Neq, file.%Neq.decl [concrete = constants.%Neq]
  40. // CHECK:STDOUT: %a.ref: %i32 = name_ref a, %a
  41. // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
  42. // CHECK:STDOUT: %Neq.call: init bool = call %Neq.ref(%a.ref, %b.ref)
  43. // CHECK:STDOUT: return %Neq.call to %return
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: