@@ -44,6 +44,7 @@ class DeadEndBlocks;
4444class ValueBaseUseIterator ;
4545class ConsumingUseIterator ;
4646class NonConsumingUseIterator ;
47+ class TypeDependentUseIterator ;
4748class NonTypeDependentUseIterator ;
4849class SILValue ;
4950class SILModuleConventions ;
@@ -390,6 +391,8 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
390391 using consuming_use_range = iterator_range<consuming_use_iterator>;
391392 using non_consuming_use_iterator = NonConsumingUseIterator;
392393 using non_consuming_use_range = iterator_range<non_consuming_use_iterator>;
394+ using typedependent_use_iterator = TypeDependentUseIterator;
395+ using typedependent_use_range = iterator_range<typedependent_use_iterator>;
393396 using non_typedependent_use_iterator = NonTypeDependentUseIterator;
394397 using non_typedependent_use_range =
395398 iterator_range<non_typedependent_use_iterator>;
@@ -403,6 +406,9 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
403406 inline non_consuming_use_iterator non_consuming_use_begin () const ;
404407 inline non_consuming_use_iterator non_consuming_use_end () const ;
405408
409+ inline typedependent_use_iterator typedependent_use_begin () const ;
410+ inline typedependent_use_iterator typedependent_use_end () const ;
411+
406412 inline non_typedependent_use_iterator non_typedependent_use_begin () const ;
407413 inline non_typedependent_use_iterator non_typedependent_use_end () const ;
408414
@@ -430,6 +436,10 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
430436 // / Returns a range of all non consuming uses
431437 inline non_consuming_use_range getNonConsumingUses () const ;
432438
439+ // / Returns a range of uses that are classified as a type dependent
440+ // / operand of the user.
441+ inline typedependent_use_range getTypeDependentUses () const ;
442+
433443 // / Returns a range of uses that are not classified as a type dependent
434444 // / operand of the user.
435445 inline non_typedependent_use_range getNonTypeDependentUses () const ;
@@ -1104,6 +1114,7 @@ class Operand {
11041114 friend class ValueBaseUseIterator ;
11051115 friend class ConsumingUseIterator ;
11061116 friend class NonConsumingUseIterator ;
1117+ friend class TypeDependentUseIterator ;
11071118 friend class NonTypeDependentUseIterator ;
11081119 template <unsigned N> friend class FixedOperandList ;
11091120 friend class TrailingOperandsList ;
@@ -1231,6 +1242,39 @@ ValueBase::non_consuming_use_end() const {
12311242 return ValueBase::non_consuming_use_iterator (nullptr );
12321243}
12331244
1245+ class TypeDependentUseIterator : public ValueBaseUseIterator {
1246+ public:
1247+ explicit TypeDependentUseIterator (Operand *cur) : ValueBaseUseIterator(cur) {}
1248+ TypeDependentUseIterator &operator ++() {
1249+ assert (Cur && " incrementing past end()!" );
1250+ while ((Cur = Cur->NextUse )) {
1251+ if (Cur->isTypeDependent ())
1252+ break ;
1253+ }
1254+ return *this ;
1255+ }
1256+
1257+ TypeDependentUseIterator operator ++(int unused) {
1258+ TypeDependentUseIterator copy = *this ;
1259+ ++*this ;
1260+ return copy;
1261+ }
1262+ };
1263+
1264+ inline ValueBase::typedependent_use_iterator
1265+ ValueBase::typedependent_use_begin () const {
1266+ auto cur = FirstUse;
1267+ while (cur && !cur->isTypeDependent ()) {
1268+ cur = cur->NextUse ;
1269+ }
1270+ return ValueBase::typedependent_use_iterator (cur);
1271+ }
1272+
1273+ inline ValueBase::typedependent_use_iterator
1274+ ValueBase::typedependent_use_end () const {
1275+ return ValueBase::typedependent_use_iterator (nullptr );
1276+ }
1277+
12341278class NonTypeDependentUseIterator : public ValueBaseUseIterator {
12351279public:
12361280 explicit NonTypeDependentUseIterator (Operand *cur)
@@ -1311,6 +1355,11 @@ ValueBase::getNonConsumingUses() const {
13111355 return {non_consuming_use_begin (), non_consuming_use_end ()};
13121356}
13131357
1358+ inline ValueBase::typedependent_use_range
1359+ ValueBase::getTypeDependentUses () const {
1360+ return {typedependent_use_begin (), typedependent_use_end ()};
1361+ }
1362+
13141363inline ValueBase::non_typedependent_use_range
13151364ValueBase::getNonTypeDependentUses () const {
13161365 return {non_typedependent_use_begin (), non_typedependent_use_end ()};
0 commit comments