@@ -44,6 +44,7 @@ class DeadEndBlocks;
4444class ValueBaseUseIterator ;
4545class ConsumingUseIterator ;
4646class NonConsumingUseIterator ;
47+ class TypeDependentUseIterator ;
4748class NonTypeDependentUseIterator ;
4849class SILValue ;
4950class SILModuleConventions ;
@@ -376,6 +377,8 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
376377 // / same type as the result of this instruction.
377378 void replaceAllUsesWithUndef ();
378379
380+ void replaceAllTypeDependentUsesWith (ValueBase *RHS);
381+
379382 // / Is this value a direct result of the given instruction?
380383 bool isResultOf (SILInstruction *I) const ;
381384
@@ -390,6 +393,8 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
390393 using consuming_use_range = iterator_range<consuming_use_iterator>;
391394 using non_consuming_use_iterator = NonConsumingUseIterator;
392395 using non_consuming_use_range = iterator_range<non_consuming_use_iterator>;
396+ using typedependent_use_iterator = TypeDependentUseIterator;
397+ using typedependent_use_range = iterator_range<typedependent_use_iterator>;
393398 using non_typedependent_use_iterator = NonTypeDependentUseIterator;
394399 using non_typedependent_use_range =
395400 iterator_range<non_typedependent_use_iterator>;
@@ -403,6 +408,9 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
403408 inline non_consuming_use_iterator non_consuming_use_begin () const ;
404409 inline non_consuming_use_iterator non_consuming_use_end () const ;
405410
411+ inline typedependent_use_iterator typedependent_use_begin () const ;
412+ inline typedependent_use_iterator typedependent_use_end () const ;
413+
406414 inline non_typedependent_use_iterator non_typedependent_use_begin () const ;
407415 inline non_typedependent_use_iterator non_typedependent_use_end () const ;
408416
@@ -430,6 +438,10 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
430438 // / Returns a range of all non consuming uses
431439 inline non_consuming_use_range getNonConsumingUses () const ;
432440
441+ // / Returns a range of uses that are classified as a type dependent
442+ // / operand of the user.
443+ inline typedependent_use_range getTypeDependentUses () const ;
444+
433445 // / Returns a range of uses that are not classified as a type dependent
434446 // / operand of the user.
435447 inline non_typedependent_use_range getNonTypeDependentUses () const ;
@@ -1104,6 +1116,7 @@ class Operand {
11041116 friend class ValueBaseUseIterator ;
11051117 friend class ConsumingUseIterator ;
11061118 friend class NonConsumingUseIterator ;
1119+ friend class TypeDependentUseIterator ;
11071120 friend class NonTypeDependentUseIterator ;
11081121 template <unsigned N> friend class FixedOperandList ;
11091122 friend class TrailingOperandsList ;
@@ -1231,6 +1244,39 @@ ValueBase::non_consuming_use_end() const {
12311244 return ValueBase::non_consuming_use_iterator (nullptr );
12321245}
12331246
1247+ class TypeDependentUseIterator : public ValueBaseUseIterator {
1248+ public:
1249+ explicit TypeDependentUseIterator (Operand *cur) : ValueBaseUseIterator(cur) {}
1250+ TypeDependentUseIterator &operator ++() {
1251+ assert (Cur && " incrementing past end()!" );
1252+ while ((Cur = Cur->NextUse )) {
1253+ if (Cur->isTypeDependent ())
1254+ break ;
1255+ }
1256+ return *this ;
1257+ }
1258+
1259+ TypeDependentUseIterator operator ++(int unused) {
1260+ TypeDependentUseIterator copy = *this ;
1261+ ++*this ;
1262+ return copy;
1263+ }
1264+ };
1265+
1266+ inline ValueBase::typedependent_use_iterator
1267+ ValueBase::typedependent_use_begin () const {
1268+ auto cur = FirstUse;
1269+ while (cur && !cur->isTypeDependent ()) {
1270+ cur = cur->NextUse ;
1271+ }
1272+ return ValueBase::typedependent_use_iterator (cur);
1273+ }
1274+
1275+ inline ValueBase::typedependent_use_iterator
1276+ ValueBase::typedependent_use_end () const {
1277+ return ValueBase::typedependent_use_iterator (nullptr );
1278+ }
1279+
12341280class NonTypeDependentUseIterator : public ValueBaseUseIterator {
12351281public:
12361282 explicit NonTypeDependentUseIterator (Operand *cur)
@@ -1311,6 +1357,11 @@ ValueBase::getNonConsumingUses() const {
13111357 return {non_consuming_use_begin (), non_consuming_use_end ()};
13121358}
13131359
1360+ inline ValueBase::typedependent_use_range
1361+ ValueBase::getTypeDependentUses () const {
1362+ return {typedependent_use_begin (), typedependent_use_end ()};
1363+ }
1364+
13141365inline ValueBase::non_typedependent_use_range
13151366ValueBase::getNonTypeDependentUses () const {
13161367 return {non_typedependent_use_begin (), non_typedependent_use_end ()};
0 commit comments