or.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/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/or.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/or.carbon
  12. // --- int_or.carbon
  13. fn Or(a: i32, b: i32) -> i32 = "int.or";
  14. var arr: array(i32, Or(12, 10));
  15. let arr_p: array(i32, 14)* = &arr;
  16. fn RuntimeCallIsValid(a: i32, b: i32) -> i32 {
  17. //@dump-sem-ir-begin
  18. return Or(a, b);
  19. //@dump-sem-ir-end
  20. }
  21. // CHECK:STDOUT: --- int_or.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: %Or.type: type = fn_type @Or [concrete]
  27. // CHECK:STDOUT: %Or: %Or.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: %Or.ref: %Or.type = name_ref Or, file.%Or.decl [concrete = constants.%Or]
  36. // CHECK:STDOUT: %a.ref: %i32 = name_ref a, %a
  37. // CHECK:STDOUT: %b.ref: %i32 = name_ref b, %b
  38. // CHECK:STDOUT: %Or.call: init %i32 = call %Or.ref(%a.ref, %b.ref)
  39. // CHECK:STDOUT: return %Or.call to %return
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @__global_init() {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: <elided>
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: