right_shift.carbon 4.2 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/right_shift.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/right_shift.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.RightShiftWith(C) where .Result = C {
  17. fn Op[self: C](other: C) -> C {
  18. return {};
  19. }
  20. }
  21. impl C as Core.RightShiftAssignWith(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: --- right_shift.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: %RightShiftWith.type.bd6: type = facet_type <@RightShiftWith, @RightShiftWith(%C)> [concrete]
  40. // CHECK:STDOUT: %Op.type.19b: type = fn_type @Op.1, @RightShiftWith(%C) [concrete]
  41. // CHECK:STDOUT: %RightShiftWith.impl_witness: <witness> = impl_witness file.%RightShiftWith.impl_witness_table [concrete]
  42. // CHECK:STDOUT: %Op.type.873: type = fn_type @Op.6 [concrete]
  43. // CHECK:STDOUT: %Op.909: %Op.type.873 = struct_value () [concrete]
  44. // CHECK:STDOUT: %RightShiftWith.facet.fb0: %RightShiftWith.type.bd6 = facet_value %C, (%RightShiftWith.impl_witness) [concrete]
  45. // CHECK:STDOUT: %RightShiftAssignWith.type.cd0: type = facet_type <@RightShiftAssignWith, @RightShiftAssignWith(%C)> [concrete]
  46. // CHECK:STDOUT: %Op.type.ae9: type = fn_type @Op.7, @RightShiftAssignWith(%C) [concrete]
  47. // CHECK:STDOUT: %RightShiftAssignWith.impl_witness: <witness> = impl_witness file.%RightShiftAssignWith.impl_witness_table [concrete]
  48. // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete]
  49. // CHECK:STDOUT: %Op.type.e0c: type = fn_type @Op.8 [concrete]
  50. // CHECK:STDOUT: %Op.6a2: %Op.type.e0c = struct_value () [concrete]
  51. // CHECK:STDOUT: %RightShiftAssignWith.facet: %RightShiftAssignWith.type.cd0 = facet_value %C, (%RightShiftAssignWith.impl_witness) [concrete]
  52. // CHECK:STDOUT: %.982: type = fn_type_with_self_type %Op.type.19b, %RightShiftWith.facet.fb0 [concrete]
  53. // CHECK:STDOUT: %.d41: type = fn_type_with_self_type %Op.type.ae9, %RightShiftAssignWith.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: %.982 = impl_witness_access constants.%RightShiftWith.impl_witness, element1 [concrete = constants.%Op.909]
  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: %.d41 = impl_witness_access constants.%RightShiftAssignWith.impl_witness, element0 [concrete = constants.%Op.6a2]
  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: