@@ -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
@@ -1071,6 +1082,7 @@ class Operand {
1071
1082
friend class ValueBaseUseIterator ;
1072
1083
friend class ConsumingUseIterator ;
1073
1084
friend class NonConsumingUseIterator ;
1085
+ friend class NonTypeDependentUseIterator ;
1074
1086
template <unsigned N> friend class FixedOperandList ;
1075
1087
friend class TrailingOperandsList ;
1076
1088
};
@@ -1197,6 +1209,41 @@ ValueBase::non_consuming_use_end() const {
1197
1209
return ValueBase::non_consuming_use_iterator (nullptr );
1198
1210
}
1199
1211
1212
+ class NonTypeDependentUseIterator : public ValueBaseUseIterator {
1213
+ public:
1214
+ explicit NonTypeDependentUseIterator (Operand *cur)
1215
+ : ValueBaseUseIterator(cur) {}
1216
+ NonTypeDependentUseIterator &operator ++() {
1217
+ assert (Cur && " incrementing past end()!" );
1218
+ assert (!Cur->isTypeDependent ());
1219
+ while ((Cur = Cur->NextUse )) {
1220
+ if (!Cur->isTypeDependent ())
1221
+ break ;
1222
+ }
1223
+ return *this ;
1224
+ }
1225
+
1226
+ NonTypeDependentUseIterator operator ++(int unused) {
1227
+ NonTypeDependentUseIterator copy = *this ;
1228
+ ++*this ;
1229
+ return copy;
1230
+ }
1231
+ };
1232
+
1233
+ inline ValueBase::non_typedependent_use_iterator
1234
+ ValueBase::non_typedependent_use_begin () const {
1235
+ auto cur = FirstUse;
1236
+ while (cur && cur->isTypeDependent ()) {
1237
+ cur = cur->NextUse ;
1238
+ }
1239
+ return ValueBase::non_typedependent_use_iterator (cur);
1240
+ }
1241
+
1242
+ inline ValueBase::non_typedependent_use_iterator
1243
+ ValueBase::non_typedependent_use_end () const {
1244
+ return ValueBase::non_typedependent_use_iterator (nullptr );
1245
+ }
1246
+
1200
1247
inline bool ValueBase::hasOneUse () const {
1201
1248
auto I = use_begin (), E = use_end ();
1202
1249
if (I == E) return false ;
@@ -1242,6 +1289,11 @@ ValueBase::getNonConsumingUses() const {
1242
1289
return {non_consuming_use_begin (), non_consuming_use_end ()};
1243
1290
}
1244
1291
1292
+ inline ValueBase::non_typedependent_use_range
1293
+ ValueBase::getNonTypeDependentUses () const {
1294
+ return {non_typedependent_use_begin (), non_typedependent_use_end ()};
1295
+ }
1296
+
1245
1297
inline bool ValueBase::hasTwoUses () const {
1246
1298
auto iter = use_begin (), end = use_end ();
1247
1299
for (unsigned i = 0 ; i < 2 ; ++i) {
0 commit comments