@@ -43,6 +43,7 @@ class DeadEndBlocks;
4343class ValueBaseUseIterator ;
4444class ConsumingUseIterator ;
4545class NonConsumingUseIterator ;
46+ class NonTypeDependentUseIterator ;
4647class SILValue ;
4748
4849// / An enumeration which contains values for all the concrete ValueBase
@@ -387,6 +388,9 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
387388 using consuming_use_range = iterator_range<consuming_use_iterator>;
388389 using non_consuming_use_iterator = NonConsumingUseIterator;
389390 using non_consuming_use_range = iterator_range<non_consuming_use_iterator>;
391+ using non_typedependent_use_iterator = NonTypeDependentUseIterator;
392+ using non_typedependent_use_range =
393+ iterator_range<non_typedependent_use_iterator>;
390394
391395 inline use_iterator use_begin () const ;
392396 inline use_iterator use_end () const ;
@@ -397,6 +401,9 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
397401 inline non_consuming_use_iterator non_consuming_use_begin () const ;
398402 inline non_consuming_use_iterator non_consuming_use_end () const ;
399403
404+ inline non_typedependent_use_iterator non_typedependent_use_begin () const ;
405+ inline non_typedependent_use_iterator non_typedependent_use_end () const ;
406+
400407 // / Returns a range of all uses, which is useful for iterating over all uses.
401408 // / To ignore debug-info instructions use swift::getNonDebugUses instead
402409 // / (see comment in DebugUtils.h).
@@ -421,6 +428,10 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
421428 // / Returns a range of all non consuming uses
422429 inline non_consuming_use_range getNonConsumingUses () const ;
423430
431+ // / Returns a range of uses that are not classified as a type dependent
432+ // / operand of the user.
433+ inline non_typedependent_use_range getNonTypeDependentUses () const ;
434+
424435 template <class T >
425436 inline T *getSingleUserOfType () const ;
426437
@@ -1076,6 +1087,7 @@ class Operand {
10761087 friend class ValueBaseUseIterator ;
10771088 friend class ConsumingUseIterator ;
10781089 friend class NonConsumingUseIterator ;
1090+ friend class NonTypeDependentUseIterator ;
10791091 template <unsigned N> friend class FixedOperandList ;
10801092 friend class TrailingOperandsList ;
10811093};
@@ -1202,6 +1214,41 @@ ValueBase::non_consuming_use_end() const {
12021214 return ValueBase::non_consuming_use_iterator (nullptr );
12031215}
12041216
1217+ class NonTypeDependentUseIterator : public ValueBaseUseIterator {
1218+ public:
1219+ explicit NonTypeDependentUseIterator (Operand *cur)
1220+ : ValueBaseUseIterator(cur) {}
1221+ NonTypeDependentUseIterator &operator ++() {
1222+ assert (Cur && " incrementing past end()!" );
1223+ assert (!Cur->isTypeDependent ());
1224+ while ((Cur = Cur->NextUse )) {
1225+ if (!Cur->isTypeDependent ())
1226+ break ;
1227+ }
1228+ return *this ;
1229+ }
1230+
1231+ NonTypeDependentUseIterator operator ++(int unused) {
1232+ NonTypeDependentUseIterator copy = *this ;
1233+ ++*this ;
1234+ return copy;
1235+ }
1236+ };
1237+
1238+ inline ValueBase::non_typedependent_use_iterator
1239+ ValueBase::non_typedependent_use_begin () const {
1240+ auto cur = FirstUse;
1241+ while (cur && cur->isTypeDependent ()) {
1242+ cur = cur->NextUse ;
1243+ }
1244+ return ValueBase::non_typedependent_use_iterator (cur);
1245+ }
1246+
1247+ inline ValueBase::non_typedependent_use_iterator
1248+ ValueBase::non_typedependent_use_end () const {
1249+ return ValueBase::non_typedependent_use_iterator (nullptr );
1250+ }
1251+
12051252inline bool ValueBase::hasOneUse () const {
12061253 auto I = use_begin (), E = use_end ();
12071254 if (I == E) return false ;
@@ -1247,6 +1294,11 @@ ValueBase::getNonConsumingUses() const {
12471294 return {non_consuming_use_begin (), non_consuming_use_end ()};
12481295}
12491296
1297+ inline ValueBase::non_typedependent_use_range
1298+ ValueBase::getNonTypeDependentUses () const {
1299+ return {non_typedependent_use_begin (), non_typedependent_use_end ()};
1300+ }
1301+
12501302inline bool ValueBase::hasTwoUses () const {
12511303 auto iter = use_begin (), end = use_end ();
12521304 for (unsigned i = 0 ; i < 2 ; ++i) {
0 commit comments