@@ -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
@@ -1076,6 +1087,7 @@ class Operand {
1076
1087
friend class ValueBaseUseIterator ;
1077
1088
friend class ConsumingUseIterator ;
1078
1089
friend class NonConsumingUseIterator ;
1090
+ friend class NonTypeDependentUseIterator ;
1079
1091
template <unsigned N> friend class FixedOperandList ;
1080
1092
friend class TrailingOperandsList ;
1081
1093
};
@@ -1202,6 +1214,41 @@ ValueBase::non_consuming_use_end() const {
1202
1214
return ValueBase::non_consuming_use_iterator (nullptr );
1203
1215
}
1204
1216
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
+
1205
1252
inline bool ValueBase::hasOneUse () const {
1206
1253
auto I = use_begin (), E = use_end ();
1207
1254
if (I == E) return false ;
@@ -1247,6 +1294,11 @@ ValueBase::getNonConsumingUses() const {
1247
1294
return {non_consuming_use_begin (), non_consuming_use_end ()};
1248
1295
}
1249
1296
1297
+ inline ValueBase::non_typedependent_use_range
1298
+ ValueBase::getNonTypeDependentUses () const {
1299
+ return {non_typedependent_use_begin (), non_typedependent_use_end ()};
1300
+ }
1301
+
1250
1302
inline bool ValueBase::hasTwoUses () const {
1251
1303
auto iter = use_begin (), end = use_end ();
1252
1304
for (unsigned i = 0 ; i < 2 ; ++i) {
0 commit comments