@@ -383,33 +383,71 @@ struct Write : public Effect::Base<Write> {};
383
383
// SideEffect Utilities
384
384
// ===----------------------------------------------------------------------===//
385
385
386
- // / Returns true if `op` has only an effect of type `EffectTy`.
386
+ // / Return "true" if `op` has unknown effects. I.e., the effects of the
387
+ // / operation itself are unknown and the operation does not derive its effects
388
+ // / from its nested operations. (`HasRecursiveMemoryEffects` trait is not
389
+ // / implemented or it is unknown whether it is implemented or not.)
390
+ bool hasUnknownEffects (Operation *op);
391
+
392
+ // / Returns "true" if `op` has only an effect of type `EffectTy`. Returns
393
+ // / "false" if `op` has unknown effects or other/additional effects. Recursive
394
+ // / effects are not taken into account.
387
395
template <typename EffectTy>
388
396
bool hasSingleEffect (Operation *op);
389
397
390
- // / Returns true if `op` has only an effect of type `EffectTy` (and of no other
391
- // / type) on `value`.
398
+ // / Returns "true" if `op` has only an effect of type `EffectTy` on `value`.
399
+ // / Returns "false" if `op` has unknown effects or other/additional effects.
400
+ // / Recursive effects are not taken into account.
392
401
template <typename EffectTy>
393
402
bool hasSingleEffect (Operation *op, Value value);
394
403
395
- // / Returns true if `op` has only an effect of type `EffectTy` (and of no other
396
- // / type) on `value` of type `ValueTy`.
404
+ // / Returns "true" if `op` has only an effect of type `EffectTy` on `value` of
405
+ // / type `ValueTy`. Returns "false" if `op` has unknown effects or
406
+ // / other/additional effects. Recursive effects are not taken into account.
397
407
template <typename ValueTy, typename EffectTy>
398
408
bool hasSingleEffect (Operation *op, ValueTy value);
399
409
400
- // / Returns true if `op` has an effect of type `EffectTy`.
410
+ // / Returns "true" if `op` has an effect of type `EffectTy`. Returns "false" if
411
+ // / `op` has unknown effects. Recursive effects are not taken into account.
401
412
template <typename ... EffectTys>
402
413
bool hasEffect (Operation *op);
403
414
404
- // / Returns true if `op` has an effect of type `EffectTy` on `value`.
415
+ // / Returns "true" if `op` has an effect of type `EffectTy` on `value`. Returns
416
+ // / "false" if `op` has unknown effects. Recursive effects are not taken into
417
+ // / account.
405
418
template <typename ... EffectTys>
406
419
bool hasEffect (Operation *op, Value value);
407
420
408
- // / Returns true if `op` has an effect of type `EffectTy` on `value` of type
409
- // / `ValueTy`.
421
+ // / Returns "true" if `op` has an effect of type `EffectTy` on `value` of type
422
+ // / `ValueTy`. Returns "false" if `op` has unknown effects. Recursive effects
423
+ // / are not taken into account.
410
424
template <typename ValueTy, typename ... EffectTys>
411
425
bool hasEffect (Operation *op, ValueTy value);
412
426
427
+ // / Returns "true" if `op` might have an effect of type `EffectTy`. Returns
428
+ // / "true" if the op has unknown effects. Recursive effects are not taken into
429
+ // / account.
430
+ template <typename ... EffectTys>
431
+ bool mightHaveEffect (Operation *op) {
432
+ return hasUnknownEffects (op) || hasEffect<EffectTys...>(op);
433
+ }
434
+
435
+ // / Returns "true" if `op` might have an effect of type `EffectTy` on `value`.
436
+ // / Returns "true" if the op has unknown effects. Recursive effects are not
437
+ // / taken into account.
438
+ template <typename ... EffectTys>
439
+ bool mightHaveEffect (Operation *op, Value value) {
440
+ return hasUnknownEffects (op) || hasEffect<EffectTys...>(op, value);
441
+ }
442
+
443
+ // / Returns "true" if `op` might have an effect of type `EffectTy` on `value`
444
+ // / of type `ValueTy`. Returns "true" if the op has unknown effects. Recursive
445
+ // / effects are not taken into account.
446
+ template <typename ValueTy, typename ... EffectTys>
447
+ bool mightHaveEffect (Operation *op, ValueTy value) {
448
+ return hasUnknownEffects (op) || hasEffect<EffectTys...>(op, value);
449
+ }
450
+
413
451
// / Return true if the given operation is unused, and has no side effects on
414
452
// / memory that prevent erasing.
415
453
bool isOpTriviallyDead (Operation *op);
0 commit comments