bit_and.carbon 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/overloaded/bit_and.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/bit_and.carbon
  13. // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate.
  14. package User;
  15. class C {};
  16. impl C as Core.BitAndWith(C) where .Result = C {
  17. fn Op[self: C](other: C) -> C {
  18. return {};
  19. }
  20. }
  21. impl C as Core.BitAndAssignWith(C) {
  22. fn Op[addr self: C*](other: C) {}
  23. }
  24. fn TestOp(a: C, b: C) -> C {
  25. //@dump-sem-ir-begin
  26. return a & b;
  27. //@dump-sem-ir-end
  28. }
  29. fn TestAssign(a: C*, b: C) {
  30. //@dump-sem-ir-begin
  31. *a &= b;
  32. //@dump-sem-ir-end
  33. }
  34. // CHECK:STDOUT: --- bit_and.carbon
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: constants {
  37. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  38. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  39. // CHECK:STDOUT: %BitAndWith.type.e40: type = facet_type <@BitAndWith, @BitAndWith(%C)> [concrete]
  40. // CHECK:STDOUT: %Op.type.914: type = fn_type @Op.1, @BitAndWith(%C) [concrete]
  41. // CHECK:STDOUT: %BitAndWith.impl_witness: <witness> = impl_witness file.%BitAndWith.impl_witness_table [concrete]
  42. // CHECK:STDOUT: %Op.type.bcc: type = fn_type @Op.6 [concrete]
  43. // CHECK:STDOUT: %Op.c46: %Op.type.bcc = struct_value () [concrete]
  44. // CHECK:STDOUT: %BitAndWith.facet.783: %BitAndWith.type.e40 = facet_value %C, (%BitAndWith.impl_witness) [concrete]
  45. // CHECK:STDOUT: %BitAndAssignWith.type.e85: type = facet_type <@BitAndAssignWith, @BitAndAssignWith(%C)> [concrete]
  46. // CHECK:STDOUT: %Op.type.73d: type = fn_type @Op.7, @BitAndAssignWith(%C) [concrete]
  47. // CHECK:STDOUT: %BitAndAssignWith.impl_witness: <witness> = impl_witness file.%BitAndAssignWith.impl_witness_table [concrete]
  48. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  49. // CHECK:STDOUT: %Op.type.115: type = fn_type @Op.8 [concrete]
  50. // CHECK:STDOUT: %Op.270: %Op.type.115 = struct_value () [concrete]
  51. // CHECK:STDOUT: %BitAndAssignWith.facet: %BitAndAssignWith.type.e85 = facet_value %C, (%BitAndAssignWith.impl_witness) [concrete]
  52. // CHECK:STDOUT: %.04a: type = fn_type_with_self_type %Op.type.914, %BitAndWith.facet.783 [concrete]
  53. // CHECK:STDOUT: %.554: type = fn_type_with_self_type %Op.type.73d, %BitAndAssignWith.facet [concrete]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: imports {
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: fn @TestOp(%a.param: %C, %b.param: %C) -> %return.param: %C {
  60. // CHECK:STDOUT: !entry:
  61. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  62. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  63. // CHECK:STDOUT: %impl.elem1: %.04a = impl_witness_access constants.%BitAndWith.impl_witness, element1 [concrete = constants.%Op.c46]
  64. // CHECK:STDOUT: %bound_method.loc31: <bound method> = bound_method %a.ref, %impl.elem1
  65. // CHECK:STDOUT: <elided>
  66. // CHECK:STDOUT: %Op.call: init %C = call %bound_method.loc31(%a.ref, %b.ref) to %.loc29
  67. // CHECK:STDOUT: <elided>
  68. // CHECK:STDOUT: return %Op.call to %return
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: fn @TestAssign(%a.param: %ptr.019, %b.param: %C) {
  72. // CHECK:STDOUT: !entry:
  73. // CHECK:STDOUT: %a.ref: %ptr.019 = name_ref a, %a
  74. // CHECK:STDOUT: %.loc37: ref %C = deref %a.ref
  75. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  76. // CHECK:STDOUT: %impl.elem0: %.554 = impl_witness_access constants.%BitAndAssignWith.impl_witness, element0 [concrete = constants.%Op.270]
  77. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc37, %impl.elem0
  78. // CHECK:STDOUT: %addr: %ptr.019 = addr_of %.loc37
  79. // CHECK:STDOUT: %Op.call: init %empty_tuple.type = call %bound_method(%addr, %b.ref)
  80. // CHECK:STDOUT: <elided>
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: