[flang-commits] [mlir] [flang] [mlir][IR] Add rewriter API for moving operations (PR #78988)
Mehdi Amini via flang-commits
flang-commits at lists.llvm.org
Mon Jan 22 10:03:00 PST 2024
================
@@ -366,3 +366,31 @@ void RewriterBase::cloneRegionBefore(Region ®ion, Region &parent,
void RewriterBase::cloneRegionBefore(Region ®ion, Block *before) {
cloneRegionBefore(region, *before->getParent(), before->getIterator());
}
+
+void RewriterBase::moveOpBefore(Operation *op, Operation *existingOp) {
+ moveOpBefore(op, existingOp->getBlock(), existingOp->getIterator());
+}
+
+void RewriterBase::moveOpBefore(Operation *op, Block *block,
+ Block::iterator iterator) {
+ Block *currentBlock = op->getBlock();
+ Block::iterator currentIterator = op->getIterator();
+ op->moveBefore(block, iterator);
+ if (listener)
+ listener->notifyOperationInserted(
+ op, /*previous=*/InsertPoint(currentBlock, currentIterator));
----------------
joker-eph wrote:
It's not clear to me that this is enough to implement a "moveOpBefore" safely.
See: https://discourse.llvm.org/t/what-is-the-extent-of-the-changes-that-can-be-done-in-a-patternrewriter/76343/2
https://github.com/llvm/llvm-project/pull/78988
More information about the flang-commits
mailing list