summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Block.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/IR/Block.cpp')
-rw-r--r--mlir/lib/IR/Block.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp
index ea92422cd0e..63e85802b73 100644
--- a/mlir/lib/IR/Block.cpp
+++ b/mlir/lib/IR/Block.cpp
@@ -57,7 +57,15 @@ bool Block::isEntryBlock() { return this == &getParent()->front(); }
void Block::insertBefore(Block *block) {
assert(!getParent() && "already inserted into a block!");
assert(block->getParent() && "cannot insert before a block without a parent");
- block->getParent()->getBlocks().insert(Region::iterator(block), this);
+ block->getParent()->getBlocks().insert(block->getIterator(), this);
+}
+
+/// Unlink this block from its current region and insert it right before the
+/// specific block.
+void Block::moveBefore(Block *block) {
+ assert(block->getParent() && "cannot insert before a block without a parent");
+ block->getParent()->getBlocks().splice(
+ block->getIterator(), getParent()->getBlocks(), getIterator());
}
/// Unlink this Block from its parent Region and delete it.
OpenPOWER on IntegriCloud