xor.carbon 2.0 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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.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/xor.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/xor.carbon
  12. // --- int_xor.carbon
  13. fn Xor(a: i32, b: i32) -> i32 = "int.xor";
  14. var arr: array(i32, Xor(12, 10));
  15. let arr_p: array(i32, 6)* = &arr;
  16. fn RuntimeCallIsValid(a: i32, b: i32) -> i32 {
  17. //@dump-sem-ir-begin
  18. return Xor(a, b);
  19. //@dump-sem-ir-end
  20. }
  21. // CHECK:STDOUT: --- int_xor.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  25. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  26. // CHECK:STDOUT: %Xor.type: type = fn_type @Xor [concrete]
  27. // CHECK:STDOUT: %Xor: %Xor.type = struct_value () [concrete]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: imports {
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: fn @RuntimeCallIsValid(%a.param: %i32, %b.param: %i32) -> %i32 {
  34. // CHECK:STDOUT: !entry:
  35. // CHECK:STDOUT: %Xor.ref: %Xor.type = name_ref Xor, file.%Xor.decl [concrete = constants.%Xor]
  36. // CHECK:STDOUT: %a.ref: %i32 = name_ref a, %a
  37. // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
  38. // CHECK:STDOUT: %int.xor: init %i32 = call %Xor.ref(%a.ref, %b.ref)
  39. // CHECK:STDOUT: %.loc9_19.1: %i32 = value_of_initializer %int.xor
  40. // CHECK:STDOUT: %.loc9_19.2: %i32 = converted %int.xor, %.loc9_19.1
  41. // CHECK:STDOUT: return %.loc9_19.2
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: fn @__global_init() {
  45. // CHECK:STDOUT: !entry:
  46. // CHECK:STDOUT: <elided>
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: