@@ -44,6 +44,7 @@ class DeadEndBlocks;
44
44
class ValueBaseUseIterator ;
45
45
class ConsumingUseIterator ;
46
46
class NonConsumingUseIterator ;
47
+ class TypeDependentUseIterator ;
47
48
class NonTypeDependentUseIterator ;
48
49
class SILValue ;
49
50
class SILModuleConventions ;
@@ -390,6 +391,8 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
390
391
using consuming_use_range = iterator_range<consuming_use_iterator>;
391
392
using non_consuming_use_iterator = NonConsumingUseIterator;
392
393
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>;
393
396
using non_typedependent_use_iterator = NonTypeDependentUseIterator;
394
397
using non_typedependent_use_range =
395
398
iterator_range<non_typedependent_use_iterator>;
@@ -403,6 +406,9 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
403
406
inline non_consuming_use_iterator non_consuming_use_begin () const ;
404
407
inline non_consuming_use_iterator non_consuming_use_end () const ;
405
408
409
+ inline typedependent_use_iterator typedependent_use_begin () const ;
410
+ inline typedependent_use_iterator typedependent_use_end () const ;
411
+
406
412
inline non_typedependent_use_iterator non_typedependent_use_begin () const ;
407
413
inline non_typedependent_use_iterator non_typedependent_use_end () const ;
408
414
@@ -430,6 +436,10 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
430
436
// / Returns a range of all non consuming uses
431
437
inline non_consuming_use_range getNonConsumingUses () const ;
432
438
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
+
433
443
// / Returns a range of uses that are not classified as a type dependent
434
444
// / operand of the user.
435
445
inline non_typedependent_use_range getNonTypeDependentUses () const ;
@@ -1104,6 +1114,7 @@ class Operand {
1104
1114
friend class ValueBaseUseIterator ;
1105
1115
friend class ConsumingUseIterator ;
1106
1116
friend class NonConsumingUseIterator ;
1117
+ friend class TypeDependentUseIterator ;
1107
1118
friend class NonTypeDependentUseIterator ;
1108
1119
template <unsigned N> friend class FixedOperandList ;
1109
1120
friend class TrailingOperandsList ;
@@ -1231,6 +1242,39 @@ ValueBase::non_consuming_use_end() const {
1231
1242
return ValueBase::non_consuming_use_iterator (nullptr );
1232
1243
}
1233
1244
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
+
1234
1278
class NonTypeDependentUseIterator : public ValueBaseUseIterator {
1235
1279
public:
1236
1280
explicit NonTypeDependentUseIterator (Operand *cur)
@@ -1311,6 +1355,11 @@ ValueBase::getNonConsumingUses() const {
1311
1355
return {non_consuming_use_begin (), non_consuming_use_end ()};
1312
1356
}
1313
1357
1358
+ inline ValueBase::typedependent_use_range
1359
+ ValueBase::getTypeDependentUses () const {
1360
+ return {typedependent_use_begin (), typedependent_use_end ()};
1361
+ }
1362
+
1314
1363
inline ValueBase::non_typedependent_use_range
1315
1364
ValueBase::getNonTypeDependentUses () const {
1316
1365
return {non_typedependent_use_begin (), non_typedependent_use_end ()};
0 commit comments