[PATCH] D77060: [MLIR] Replace OpBuilder(Block) with AtBlockBegin and AtBlockEnd

Theodore Popp via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 01:37:08 PDT 2020


tpopp updated this revision to Diff 253798.
tpopp added a comment.
Herald added a reviewer: mravishankar.
Herald added a reviewer: antiagainst.
Herald added a subscriber: bader.

Create AtBlockBegin and AtBlockEnd. Remove OpBuilder(Block).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77060/new/

https://reviews.llvm.org/D77060

Files:
  mlir/include/mlir/IR/Builders.h
  mlir/lib/Dialect/SPIRV/SPIRVOps.cpp


Index: mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
===================================================================
--- mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
+++ mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
@@ -2076,7 +2076,7 @@
   body().push_back(new Block());
   auto *mergeBlock = new Block();
   body().push_back(mergeBlock);
-  OpBuilder builder(mergeBlock);
+  OpBuilder builder = OpBuilder::AtBlockEnd(mergeBlock);
 
   // Add a spv._merge op into the merge block.
   builder.create<spirv::MergeOp>(getLoc());
@@ -2373,7 +2373,7 @@
   assert(body().empty() && "entry and merge block already exist");
   auto *mergeBlock = new Block();
   body().push_back(mergeBlock);
-  OpBuilder builder(mergeBlock);
+  OpBuilder builder = OpBuilder::AtBlockEnd(mergeBlock);
 
   // Add a spv._merge op into the merge block.
   builder.create<spirv::MergeOp>(getLoc());
Index: mlir/include/mlir/IR/Builders.h
===================================================================
--- mlir/include/mlir/IR/Builders.h
+++ mlir/include/mlir/IR/Builders.h
@@ -188,13 +188,21 @@
     setInsertionPoint(op);
   }
 
-  explicit OpBuilder(Block *block) : OpBuilder(block, block->end()) {}
-
   OpBuilder(Block *block, Block::iterator insertPoint)
       : OpBuilder(block->getParent()) {
     setInsertionPoint(block, insertPoint);
   }
 
+  /// Create a builder and set the insertion point to the specified location in
+  /// the Block.
+  static OpBuilder AtBlockBegin(Block *block) {
+    return OpBuilder(block, block->begin());
+  }
+
+  static OpBuilder AtBlockEnd(Block *block) {
+    return OpBuilder(block, block->end());
+  }
+
   /// This class represents a saved insertion point.
   class InsertPoint {
   public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77060.253798.patch
Type: text/x-patch
Size: 1692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200331/e58498b2/attachment-0001.bin>


More information about the llvm-commits mailing list