@@ -612,6 +612,16 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
612
612
// / Return the array of mutable type dependent operands for this instruction.
613
613
MutableArrayRef<Operand> getTypeDependentOperands ();
614
614
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
+
615
625
unsigned getNumOperands () const { return getAllOperands ().size (); }
616
626
617
627
unsigned getNumTypeDependentOperands () const {
@@ -1005,6 +1015,18 @@ struct SILInstruction::OperandRefToValue {
1005
1015
}
1006
1016
};
1007
1017
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
+
1008
1030
struct SILInstruction ::NonTypeDependentOperandToValue {
1009
1031
const SILInstruction &i;
1010
1032
@@ -1036,6 +1058,11 @@ struct SILInstruction::OperandToTransformedValue {
1036
1058
}
1037
1059
};
1038
1060
1061
+ inline SILInstruction::RealOperandRange
1062
+ SILInstruction::getRealOperands () const {
1063
+ return RealOperandRange (getAllOperands (), FilterOperandToRealOperand (*this ));
1064
+ }
1065
+
1039
1066
inline SILInstruction::OperandValueRange
1040
1067
SILInstruction::getOperandValues (ArrayRef<Operand*> operands) {
1041
1068
return OperandValueRange (operands, OperandToValue ());
0 commit comments