// Part of the Carbon Language project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE // TIP: To test this file alone, run: // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/operators/overloaded/right_shift.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/right_shift.carbon // This file was generated from binary_op.carbon.tmpl. Run make_tests.sh to regenerate. package User; class C {}; impl C as Core.RightShift { fn Op[self: C](other: C) -> C { return {}; } } impl C as Core.RightShiftAssign { fn Op[addr self: C*](other: C) {} } fn TestOp(a: C, b: C) -> C { return a >> b; } fn TestAssign(a: C*, b: C) { *a >>= b; } // CHECK:STDOUT: --- right_shift.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %C: type = class_type @C [concrete] // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete] // CHECK:STDOUT: %RightShift.type: type = facet_type <@RightShift> [concrete] // CHECK:STDOUT: %Op.type.4f4: type = fn_type @Op.1 [concrete] // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete] // CHECK:STDOUT: %RightShift.impl_witness: = impl_witness file.%RightShift.impl_witness_table [concrete] // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete] // CHECK:STDOUT: %Op.type.092: type = fn_type @Op.2 [concrete] // CHECK:STDOUT: %Op.79a: %Op.type.092 = struct_value () [concrete] // CHECK:STDOUT: %RightShift.facet: %RightShift.type = facet_value %C, (%RightShift.impl_witness) [concrete] // CHECK:STDOUT: %C.val: %C = struct_value () [concrete] // CHECK:STDOUT: %RightShiftAssign.type: type = facet_type <@RightShiftAssign> [concrete] // CHECK:STDOUT: %Op.type.6f6: type = fn_type @Op.3 [concrete] // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete] // CHECK:STDOUT: %RightShiftAssign.impl_witness: = impl_witness file.%RightShiftAssign.impl_witness_table [concrete] // CHECK:STDOUT: %ptr.019: type = ptr_type %C [concrete] // CHECK:STDOUT: %pattern_type.44a: type = pattern_type %ptr.019 [concrete] // CHECK:STDOUT: %Op.type.aab: type = fn_type @Op.4 [concrete] // CHECK:STDOUT: %Op.7b2: %Op.type.aab = struct_value () [concrete] // CHECK:STDOUT: %RightShiftAssign.facet: %RightShiftAssign.type = facet_value %C, (%RightShiftAssign.impl_witness) [concrete] // CHECK:STDOUT: %TestOp.type: type = fn_type @TestOp [concrete] // CHECK:STDOUT: %TestOp: %TestOp.type = struct_value () [concrete] // CHECK:STDOUT: %.17b: type = fn_type_with_self_type %Op.type.4f4, %RightShift.facet [concrete] // CHECK:STDOUT: %TestAssign.type: type = fn_type @TestAssign [concrete] // CHECK:STDOUT: %TestAssign: %TestAssign.type = struct_value () [concrete] // CHECK:STDOUT: %.285: type = fn_type_with_self_type %Op.type.6f6, %RightShiftAssign.facet [concrete] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [concrete] { // CHECK:STDOUT: .RightShift = %Core.RightShift // CHECK:STDOUT: .RightShiftAssign = %Core.RightShiftAssign // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %Core.RightShift: type = import_ref Core//prelude/operators/bitwise, RightShift, loaded [concrete = constants.%RightShift.type] // CHECK:STDOUT: %Core.RightShiftAssign: type = import_ref Core//prelude/operators/bitwise, RightShiftAssign, loaded [concrete = constants.%RightShiftAssign.type] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [concrete] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .C = %C.decl // CHECK:STDOUT: .TestOp = %TestOp.decl // CHECK:STDOUT: .TestAssign = %TestAssign.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {} // CHECK:STDOUT: impl_decl @impl.3c1 [concrete] {} { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %RightShift.ref: type = name_ref RightShift, imports.%Core.RightShift [concrete = constants.%RightShift.type] // CHECK:STDOUT: } // CHECK:STDOUT: %RightShift.impl_witness_table = impl_witness_table (@impl.3c1.%Op.decl), @impl.3c1 [concrete] // CHECK:STDOUT: %RightShift.impl_witness: = impl_witness %RightShift.impl_witness_table [concrete = constants.%RightShift.impl_witness] // CHECK:STDOUT: impl_decl @impl.4f0 [concrete] {} { // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %Core.ref: = name_ref Core, imports.%Core [concrete = imports.%Core] // CHECK:STDOUT: %RightShiftAssign.ref: type = name_ref RightShiftAssign, imports.%Core.RightShiftAssign [concrete = constants.%RightShiftAssign.type] // CHECK:STDOUT: } // CHECK:STDOUT: %RightShiftAssign.impl_witness_table = impl_witness_table (@impl.4f0.%Op.decl), @impl.4f0 [concrete] // CHECK:STDOUT: %RightShiftAssign.impl_witness: = impl_witness %RightShiftAssign.impl_witness_table [concrete = constants.%RightShiftAssign.impl_witness] // CHECK:STDOUT: %TestOp.decl: %TestOp.type = fn_decl @TestOp [concrete = constants.%TestOp] { // CHECK:STDOUT: %a.patt: %pattern_type.c48 = binding_pattern a [concrete] // CHECK:STDOUT: %a.param_patt: %pattern_type.c48 = value_param_pattern %a.patt, call_param0 [concrete] // CHECK:STDOUT: %b.patt: %pattern_type.c48 = binding_pattern b [concrete] // CHECK:STDOUT: %b.param_patt: %pattern_type.c48 = value_param_pattern %b.patt, call_param1 [concrete] // CHECK:STDOUT: %return.patt: %pattern_type.c48 = return_slot_pattern [concrete] // CHECK:STDOUT: %return.param_patt: %pattern_type.c48 = out_param_pattern %return.patt, call_param2 [concrete] // CHECK:STDOUT: } { // CHECK:STDOUT: %C.ref.loc26_26: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %a.param: %C = value_param call_param0 // CHECK:STDOUT: %C.ref.loc26_14: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %a: %C = bind_name a, %a.param // CHECK:STDOUT: %b.param: %C = value_param call_param1 // CHECK:STDOUT: %C.ref.loc26_20: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %b: %C = bind_name b, %b.param // CHECK:STDOUT: %return.param: ref %C = out_param call_param2 // CHECK:STDOUT: %return: ref %C = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %TestAssign.decl: %TestAssign.type = fn_decl @TestAssign [concrete = constants.%TestAssign] { // CHECK:STDOUT: %a.patt: %pattern_type.44a = binding_pattern a [concrete] // CHECK:STDOUT: %a.param_patt: %pattern_type.44a = value_param_pattern %a.patt, call_param0 [concrete] // CHECK:STDOUT: %b.patt: %pattern_type.c48 = binding_pattern b [concrete] // CHECK:STDOUT: %b.param_patt: %pattern_type.c48 = value_param_pattern %b.patt, call_param1 [concrete] // CHECK:STDOUT: } { // CHECK:STDOUT: %a.param: %ptr.019 = value_param call_param0 // CHECK:STDOUT: %.loc30: type = splice_block %ptr [concrete = constants.%ptr.019] { // CHECK:STDOUT: %C.ref.loc30_18: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %ptr: type = ptr_type %C.ref.loc30_18 [concrete = constants.%ptr.019] // CHECK:STDOUT: } // CHECK:STDOUT: %a: %ptr.019 = bind_name a, %a.param // CHECK:STDOUT: %b.param: %C = value_param call_param1 // CHECK:STDOUT: %C.ref.loc30_25: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %b: %C = bind_name b, %b.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl.3c1: %C.ref as %RightShift.ref { // CHECK:STDOUT: %Op.decl: %Op.type.092 = fn_decl @Op.2 [concrete = constants.%Op.79a] { // CHECK:STDOUT: %self.patt: %pattern_type.c48 = binding_pattern self [concrete] // CHECK:STDOUT: %self.param_patt: %pattern_type.c48 = value_param_pattern %self.patt, call_param0 [concrete] // CHECK:STDOUT: %other.patt: %pattern_type.c48 = binding_pattern other [concrete] // CHECK:STDOUT: %other.param_patt: %pattern_type.c48 = value_param_pattern %other.patt, call_param1 [concrete] // CHECK:STDOUT: %return.patt: %pattern_type.c48 = return_slot_pattern [concrete] // CHECK:STDOUT: %return.param_patt: %pattern_type.c48 = out_param_pattern %return.patt, call_param2 [concrete] // CHECK:STDOUT: } { // CHECK:STDOUT: %C.ref.loc18_31: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %self.param: %C = value_param call_param0 // CHECK:STDOUT: %C.ref.loc18_15: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %self: %C = bind_name self, %self.param // CHECK:STDOUT: %other.param: %C = value_param call_param1 // CHECK:STDOUT: %C.ref.loc18_25: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %other: %C = bind_name other, %other.param // CHECK:STDOUT: %return.param: ref %C = out_param call_param2 // CHECK:STDOUT: %return: ref %C = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .C = // CHECK:STDOUT: .Op = %Op.decl // CHECK:STDOUT: witness = file.%RightShift.impl_witness // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: impl @impl.4f0: %C.ref as %RightShiftAssign.ref { // CHECK:STDOUT: %Op.decl: %Op.type.aab = fn_decl @Op.4 [concrete = constants.%Op.7b2] { // CHECK:STDOUT: %self.patt: %pattern_type.44a = binding_pattern self [concrete] // CHECK:STDOUT: %self.param_patt: %pattern_type.44a = value_param_pattern %self.patt, call_param0 [concrete] // CHECK:STDOUT: %.loc23_9: %pattern_type.f6d = addr_pattern %self.param_patt [concrete] // CHECK:STDOUT: %other.patt: %pattern_type.c48 = binding_pattern other [concrete] // CHECK:STDOUT: %other.param_patt: %pattern_type.c48 = value_param_pattern %other.patt, call_param1 [concrete] // CHECK:STDOUT: } { // CHECK:STDOUT: %self.param: %ptr.019 = value_param call_param0 // CHECK:STDOUT: %.loc23_21: type = splice_block %ptr [concrete = constants.%ptr.019] { // CHECK:STDOUT: %C.ref.loc23_20: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %ptr: type = ptr_type %C.ref.loc23_20 [concrete = constants.%ptr.019] // CHECK:STDOUT: } // CHECK:STDOUT: %self: %ptr.019 = bind_name self, %self.param // CHECK:STDOUT: %other.param: %C = value_param call_param1 // CHECK:STDOUT: %C.ref.loc23_31: type = name_ref C, file.%C.decl [concrete = constants.%C] // CHECK:STDOUT: %other: %C = bind_name other, %other.param // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .C = // CHECK:STDOUT: .Op = %Op.decl // CHECK:STDOUT: witness = file.%RightShiftAssign.impl_witness // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type] // CHECK:STDOUT: %complete_type: = complete_type_witness %empty_struct_type [concrete = constants.%complete_type] // CHECK:STDOUT: complete_type_witness = %complete_type // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%C // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.2(%self.param: %C, %other.param: %C) -> %return.param: %C { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc19_13.1: %empty_struct_type = struct_literal () // CHECK:STDOUT: %.loc19_13.2: init %C = class_init (), %return [concrete = constants.%C.val] // CHECK:STDOUT: %.loc19_14: init %C = converted %.loc19_13.1, %.loc19_13.2 [concrete = constants.%C.val] // CHECK:STDOUT: return %.loc19_14 to %return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Op.4(%self.param: %ptr.019, %other.param: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestOp(%a.param: %C, %b.param: %C) -> %return.param: %C { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: %C = name_ref a, %a // CHECK:STDOUT: %b.ref: %C = name_ref b, %b // CHECK:STDOUT: %impl.elem0: %.17b = impl_witness_access constants.%RightShift.impl_witness, element0 [concrete = constants.%Op.79a] // CHECK:STDOUT: %bound_method: = bound_method %a.ref, %impl.elem0 // CHECK:STDOUT: %.loc26: ref %C = splice_block %return {} // CHECK:STDOUT: %Op.call: init %C = call %bound_method(%a.ref, %b.ref) to %.loc26 // CHECK:STDOUT: return %Op.call to %return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @TestAssign(%a.param: %ptr.019, %b.param: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a.ref: %ptr.019 = name_ref a, %a // CHECK:STDOUT: %.loc31: ref %C = deref %a.ref // CHECK:STDOUT: %b.ref: %C = name_ref b, %b // CHECK:STDOUT: %impl.elem0: %.285 = impl_witness_access constants.%RightShiftAssign.impl_witness, element0 [concrete = constants.%Op.7b2] // CHECK:STDOUT: %bound_method: = bound_method %.loc31, %impl.elem0 // CHECK:STDOUT: %addr: %ptr.019 = addr_of %.loc31 // CHECK:STDOUT: %Op.call: init %empty_tuple.type = call %bound_method(%addr, %b.ref) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: