@@ -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 ;
@@ -376,6 +377,8 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
376
377
// / same type as the result of this instruction.
377
378
void replaceAllUsesWithUndef ();
378
379
380
+ void replaceAllTypeDependentUsesWith (ValueBase *RHS);
381
+
379
382
// / Is this value a direct result of the given instruction?
380
383
bool isResultOf (SILInstruction *I) const ;
381
384
@@ -390,6 +393,8 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
390
393
using consuming_use_range = iterator_range<consuming_use_iterator>;
391
394
using non_consuming_use_iterator = NonConsumingUseIterator;
392
395
using non_consuming_use_range = iterator_range<non_consuming_use_iterator>;
396
+ using typedependent_use_iterator = TypeDependentUseIterator;
397
+ using typedependent_use_range = iterator_range<typedependent_use_iterator>;
393
398
using non_typedependent_use_iterator = NonTypeDependentUseIterator;
394
399
using non_typedependent_use_range =
395
400
iterator_range<non_typedependent_use_iterator>;
@@ -403,6 +408,9 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
403
408
inline non_consuming_use_iterator non_consuming_use_begin () const ;
404
409
inline non_consuming_use_iterator non_consuming_use_end () const ;
405
410
411
+ inline typedependent_use_iterator typedependent_use_begin () const ;
412
+ inline typedependent_use_iterator typedependent_use_end () const ;
413
+
406
414
inline non_typedependent_use_iterator non_typedependent_use_begin () const ;
407
415
inline non_typedependent_use_iterator non_typedependent_use_end () const ;
408
416
@@ -430,6 +438,10 @@ class ValueBase : public SILNode, public SILAllocated<ValueBase> {
430
438
// / Returns a range of all non consuming uses
431
439
inline non_consuming_use_range getNonConsumingUses () const ;
432
440
441
+ // / Returns a range of uses that are classified as a type dependent
442
+ // / operand of the user.
443
+ inline typedependent_use_range getTypeDependentUses () const ;
444
+
433
445
// / Returns a range of uses that are not classified as a type dependent
434
446
// / operand of the user.
435
447
inline non_typedependent_use_range getNonTypeDependentUses () const ;
@@ -1104,6 +1116,7 @@ class Operand {
1104
1116
friend class ValueBaseUseIterator ;
1105
1117
friend class ConsumingUseIterator ;
1106
1118
friend class NonConsumingUseIterator ;
1119
+ friend class TypeDependentUseIterator ;
1107
1120
friend class NonTypeDependentUseIterator ;
1108
1121
template <unsigned N> friend class FixedOperandList ;
1109
1122
friend class TrailingOperandsList ;
@@ -1231,6 +1244,39 @@ ValueBase::non_consuming_use_end() const {
1231
1244
return ValueBase::non_consuming_use_iterator (nullptr );
1232
1245
}
1233
1246
1247
+ class TypeDependentUseIterator : public ValueBaseUseIterator {
1248
+ public:
1249
+ explicit TypeDependentUseIterator (Operand *cur) : ValueBaseUseIterator(cur) {}
1250
+ TypeDependentUseIterator &operator ++() {
1251
+ assert (Cur && " incrementing past end()!" );
1252
+ while ((Cur = Cur->NextUse )) {
1253
+ if (Cur->isTypeDependent ())
1254
+ break ;
1255
+ }
1256
+ return *this ;
1257
+ }
1258
+
1259
+ TypeDependentUseIterator operator ++(int unused) {
1260
+ TypeDependentUseIterator copy = *this ;
1261
+ ++*this ;
1262
+ return copy;
1263
+ }
1264
+ };
1265
+
1266
+ inline ValueBase::typedependent_use_iterator
1267
+ ValueBase::typedependent_use_begin () const {
1268
+ auto cur = FirstUse;
1269
+ while (cur && !cur->isTypeDependent ()) {
1270
+ cur = cur->NextUse ;
1271
+ }
1272
+ return ValueBase::typedependent_use_iterator (cur);
1273
+ }
1274
+
1275
+ inline ValueBase::typedependent_use_iterator
1276
+ ValueBase::typedependent_use_end () const {
1277
+ return ValueBase::typedependent_use_iterator (nullptr );
1278
+ }
1279
+
1234
1280
class NonTypeDependentUseIterator : public ValueBaseUseIterator {
1235
1281
public:
1236
1282
explicit NonTypeDependentUseIterator (Operand *cur)
@@ -1311,6 +1357,11 @@ ValueBase::getNonConsumingUses() const {
1311
1357
return {non_consuming_use_begin (), non_consuming_use_end ()};
1312
1358
}
1313
1359
1360
+ inline ValueBase::typedependent_use_range
1361
+ ValueBase::getTypeDependentUses () const {
1362
+ return {typedependent_use_begin (), typedependent_use_end ()};
1363
+ }
1364
+
1314
1365
inline ValueBase::non_typedependent_use_range
1315
1366
ValueBase::getNonTypeDependentUses () const {
1316
1367
return {non_typedependent_use_begin (), non_typedependent_use_end ()};
0 commit comments