[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 04:24:02 PDT 2020


tpopp updated this revision to Diff 253835.
tpopp added a comment.

Follow naming convention for atBlockBegin and atBlockEnd.


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.253835.patch
Type: text/x-patch
Size: 1692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200331/481f107c/attachment-0001.bin>


More information about the llvm-commits mailing list