@@ -69,6 +69,8 @@ struct LoadOperation {
6969};
7070
7171// / A wrapper type for writing generic code against conversion instructions.
72+ // /
73+ // / Forwards a single operand in first operand position to a single result.
7274struct ConversionOperation {
7375 SingleValueInstruction *inst = nullptr ;
7476
@@ -259,19 +261,33 @@ class ForwardingOperation {
259261 case SILInstructionKind::LinearFunctionInst:
260262 case SILInstructionKind::DifferentiableFunctionInst:
261263 return nullptr ;
264+ case SILInstructionKind::MarkDependenceInst:
265+ return &forwardingInst->getOperandRef (MarkDependenceInst::Value);
266+ case SILInstructionKind::RefToBridgeObjectInst:
267+ return
268+ &forwardingInst->getOperandRef (RefToBridgeObjectInst::ConvertedOperand);
269+ case SILInstructionKind::TuplePackExtractInst:
270+ return &forwardingInst->getOperandRef (TuplePackExtractInst::TupleOperand);
271+ case SILInstructionKind::SelectEnumInst:
272+ // ignore trailing case operands
273+ return &forwardingInst->getOperandRef (0 );
262274 default :
263- if (forwardingInst->getNumRealOperands () == 0 ) {
275+ int numRealOperands = forwardingInst->getNumRealOperands ();
276+ if (numRealOperands == 0 ) {
264277 // This can happen with enum instructions that have no payload.
265278 return nullptr ;
266279 }
280+ assert (numRealOperands == 1 );
267281 return &forwardingInst->getOperandRef (0 );
268282 }
269283 }
270284
271285 ArrayRef<Operand> getForwardedOperands () const {
286+ // Some instructions have multiple real operands but only forward one.
272287 if (auto *singleForwardingOp = getSingleForwardingOperand ()) {
273288 return *singleForwardingOp;
274289 }
290+ // All others forward all operands (for enum, this may be zero operands).
275291 return forwardingInst->getAllOperands ();
276292 }
277293
0 commit comments