int_neq.carbon 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // --- int_neq.carbon
  7. fn Neq(a: i32, b: i32) -> bool = "int.neq";
  8. // TODO: Use a test that will fail to compile if we get the wrong value.
  9. let b_true: bool = Neq(1, 2);
  10. let b_false: bool = Neq(1, 1);
  11. fn RuntimeCall(a: i32, b: i32) -> bool {
  12. return Neq(a, b);
  13. }
  14. // CHECK:STDOUT: --- int_neq.carbon
  15. // CHECK:STDOUT:
  16. // CHECK:STDOUT: constants {
  17. // CHECK:STDOUT: %.1: i32 = int_literal 1 [template]
  18. // CHECK:STDOUT: %.2: i32 = int_literal 2 [template]
  19. // CHECK:STDOUT: %.3: bool = bool_literal true [template]
  20. // CHECK:STDOUT: %.4: bool = bool_literal false [template]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: file {
  24. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  25. // CHECK:STDOUT: .Neq = %Neq
  26. // CHECK:STDOUT: .RuntimeCall = %RuntimeCall
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT: %Neq: <function> = fn_decl @Neq [template] {
  29. // CHECK:STDOUT: %a.loc2_8.1: i32 = param a
  30. // CHECK:STDOUT: @Neq.%a: i32 = bind_name a, %a.loc2_8.1
  31. // CHECK:STDOUT: %b.loc2_16.1: i32 = param b
  32. // CHECK:STDOUT: @Neq.%b: i32 = bind_name b, %b.loc2_16.1
  33. // CHECK:STDOUT: %return.var.loc2: ref bool = var <return slot>
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %Neq.ref.loc5: <function> = name_ref Neq, %Neq [template = %Neq]
  36. // CHECK:STDOUT: %.loc5_24: i32 = int_literal 1 [template = constants.%.1]
  37. // CHECK:STDOUT: %.loc5_27: i32 = int_literal 2 [template = constants.%.2]
  38. // CHECK:STDOUT: %.loc5_23.1: init bool = call %Neq.ref.loc5(%.loc5_24, %.loc5_27) [template = constants.%.3]
  39. // CHECK:STDOUT: %.loc5_29: bool = value_of_initializer %.loc5_23.1 [template = constants.%.3]
  40. // CHECK:STDOUT: %.loc5_23.2: bool = converted %.loc5_23.1, %.loc5_29 [template = constants.%.3]
  41. // CHECK:STDOUT: %b_true: bool = bind_name b_true, %.loc5_23.2
  42. // CHECK:STDOUT: %Neq.ref.loc6: <function> = name_ref Neq, %Neq [template = %Neq]
  43. // CHECK:STDOUT: %.loc6_25: i32 = int_literal 1 [template = constants.%.1]
  44. // CHECK:STDOUT: %.loc6_28: i32 = int_literal 1 [template = constants.%.1]
  45. // CHECK:STDOUT: %.loc6_24.1: init bool = call %Neq.ref.loc6(%.loc6_25, %.loc6_28) [template = constants.%.4]
  46. // CHECK:STDOUT: %.loc6_30: bool = value_of_initializer %.loc6_24.1 [template = constants.%.4]
  47. // CHECK:STDOUT: %.loc6_24.2: bool = converted %.loc6_24.1, %.loc6_30 [template = constants.%.4]
  48. // CHECK:STDOUT: %b_false: bool = bind_name b_false, %.loc6_24.2
  49. // CHECK:STDOUT: %RuntimeCall: <function> = fn_decl @RuntimeCall [template] {
  50. // CHECK:STDOUT: %a.loc8_16.1: i32 = param a
  51. // CHECK:STDOUT: @RuntimeCall.%a: i32 = bind_name a, %a.loc8_16.1
  52. // CHECK:STDOUT: %b.loc8_24.1: i32 = param b
  53. // CHECK:STDOUT: @RuntimeCall.%b: i32 = bind_name b, %b.loc8_24.1
  54. // CHECK:STDOUT: %return.var.loc8: ref bool = var <return slot>
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @Neq(%a: i32, %b: i32) -> bool = "int.neq";
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @RuntimeCall(%a: i32, %b: i32) -> bool {
  61. // CHECK:STDOUT: !entry:
  62. // CHECK:STDOUT: %Neq.ref: <function> = name_ref Neq, file.%Neq [template = file.%Neq]
  63. // CHECK:STDOUT: %a.ref: i32 = name_ref a, %a
  64. // CHECK:STDOUT: %b.ref: i32 = name_ref b, %b
  65. // CHECK:STDOUT: %.loc9_13.1: init bool = call %Neq.ref(%a.ref, %b.ref)
  66. // CHECK:STDOUT: %.loc9_19: bool = value_of_initializer %.loc9_13.1
  67. // CHECK:STDOUT: %.loc9_13.2: bool = converted %.loc9_13.1, %.loc9_19
  68. // CHECK:STDOUT: return %.loc9_13.2
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: