@@ -43,6 +43,7 @@ class DeadEndBlocks;
43
43
class ValueBaseUseIterator ;
44
44
class ConsumingUseIterator ;
45
45
class NonConsumingUseIterator ;
46
+ class NonTypeDependentUseIterator ;
46
47
class SILValue ;
47
48
48
49
// / An enumeration which contains values for all the concrete ValueBase
@@ -387,6 +388,9 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
387
388
using consuming_use_range = iterator_range<consuming_use_iterator>;
388
389
using non_consuming_use_iterator = NonConsumingUseIterator;
389
390
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>;
390
394
391
395
inline use_iterator use_begin () const ;
392
396
inline use_iterator use_end () const ;
@@ -397,6 +401,9 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
397
401
inline non_consuming_use_iterator non_consuming_use_begin () const ;
398
402
inline non_consuming_use_iterator non_consuming_use_end () const ;
399
403
404
+ inline non_typedependent_use_iterator non_typedependent_use_begin () const ;
405
+ inline non_typedependent_use_iterator non_typedependent_use_end () const ;
406
+
400
407
// / Returns a range of all uses, which is useful for iterating over all uses.
401
408
// / To ignore debug-info instructions use swift::getNonDebugUses instead
402
409
// / (see comment in DebugUtils.h).
@@ -421,6 +428,10 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
421
428
// / Returns a range of all non consuming uses
422
429
inline non_consuming_use_range getNonConsumingUses () const ;
423
430
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
+
424
435
template <class T >
425
436
inline T *getSingleUserOfType () const ;
426
437
@@ -1061,6 +1072,7 @@ class Operand {
1061
1072
friend class ValueBaseUseIterator ;
1062
1073
friend class ConsumingUseIterator ;
1063
1074
friend class NonConsumingUseIterator ;
1075
+ friend class NonTypeDependentUseIterator ;
1064
1076
template <unsigned N> friend class FixedOperandList ;
1065
1077
friend class TrailingOperandsList ;
1066
1078
};
@@ -1187,6 +1199,41 @@ ValueBase::non_consuming_use_end() const {
1187
1199
return ValueBase::non_consuming_use_iterator (nullptr );
1188
1200
}
1189
1201
1202
+ class NonTypeDependentUseIterator : public ValueBaseUseIterator {
1203
+ public:
1204
+ explicit NonTypeDependentUseIterator (Operand *cur)
1205
+ : ValueBaseUseIterator(cur) {}
1206
+ NonTypeDependentUseIterator &operator ++() {
1207
+ assert (Cur && " incrementing past end()!" );
1208
+ assert (!Cur->isTypeDependent ());
1209
+ while ((Cur = Cur->NextUse )) {
1210
+ if (!Cur->isTypeDependent ())
1211
+ break ;
1212
+ }
1213
+ return *this ;
1214
+ }
1215
+
1216
+ NonTypeDependentUseIterator operator ++(int unused) {
1217
+ NonTypeDependentUseIterator copy = *this ;
1218
+ ++*this ;
1219
+ return copy;
1220
+ }
1221
+ };
1222
+
1223
+ inline ValueBase::non_typedependent_use_iterator
1224
+ ValueBase::non_typedependent_use_begin () const {
1225
+ auto cur = FirstUse;
1226
+ while (cur && cur->isTypeDependent ()) {
1227
+ cur = cur->NextUse ;
1228
+ }
1229
+ return ValueBase::non_typedependent_use_iterator (cur);
1230
+ }
1231
+
1232
+ inline ValueBase::non_typedependent_use_iterator
1233
+ ValueBase::non_typedependent_use_end () const {
1234
+ return ValueBase::non_typedependent_use_iterator (nullptr );
1235
+ }
1236
+
1190
1237
inline bool ValueBase::hasOneUse () const {
1191
1238
auto I = use_begin (), E = use_end ();
1192
1239
if (I == E) return false ;
@@ -1232,6 +1279,11 @@ ValueBase::getNonConsumingUses() const {
1232
1279
return {non_consuming_use_begin (), non_consuming_use_end ()};
1233
1280
}
1234
1281
1282
+ inline ValueBase::non_typedependent_use_range
1283
+ ValueBase::getNonTypeDependentUses () const {
1284
+ return {non_typedependent_use_begin (), non_typedependent_use_end ()};
1285
+ }
1286
+
1235
1287
inline bool ValueBase::hasTwoUses () const {
1236
1288
auto iter = use_begin (), end = use_end ();
1237
1289
for (unsigned i = 0 ; i < 2 ; ++i) {
0 commit comments