@@ -612,6 +612,16 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
612612 // / Return the array of mutable type dependent operands for this instruction.
613613 MutableArrayRef<Operand> getTypeDependentOperands ();
614614
615+ private:
616+ struct FilterOperandToRealOperand ;
617+
618+ public:
619+ using RealOperandRange =
620+ OptionalTransformRange<ArrayRef<Operand>, FilterOperandToRealOperand>;
621+
622+ // / The array of real (i.e. not type-dependent) operands.
623+ RealOperandRange getRealOperands () const ;
624+
615625 unsigned getNumOperands () const { return getAllOperands ().size (); }
616626
617627 unsigned getNumTypeDependentOperands () const {
@@ -1005,6 +1015,18 @@ struct SILInstruction::OperandRefToValue {
10051015 }
10061016};
10071017
1018+ struct SILInstruction ::FilterOperandToRealOperand {
1019+ const SILInstruction &i;
1020+
1021+ FilterOperandToRealOperand (const SILInstruction &i) : i(i) {}
1022+
1023+ llvm::Optional<Operand *> operator ()(const Operand &use) const {
1024+ if (i.isTypeDependentOperand (use))
1025+ return llvm::None;
1026+ return {const_cast <Operand *>(&use)};
1027+ }
1028+ };
1029+
10081030struct SILInstruction ::NonTypeDependentOperandToValue {
10091031 const SILInstruction &i;
10101032
@@ -1036,6 +1058,11 @@ struct SILInstruction::OperandToTransformedValue {
10361058 }
10371059};
10381060
1061+ inline SILInstruction::RealOperandRange
1062+ SILInstruction::getRealOperands () const {
1063+ return RealOperandRange (getAllOperands (), FilterOperandToRealOperand (*this ));
1064+ }
1065+
10391066inline SILInstruction::OperandValueRange
10401067SILInstruction::getOperandValues (ArrayRef<Operand*> operands) {
10411068 return OperandValueRange (operands, OperandToValue ());
0 commit comments