[PATCH] D74363: [mlir] Allow constructing a ValueRange from an ArrayRef<BlockArgument>

River Riddle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 09:57:06 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc83214596073: [mlir] Allow constructing a ValueRange from an ArrayRef<BlockArgument> (authored by rriddle).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74363

Files:
  mlir/include/mlir/IR/FunctionSupport.h
  mlir/include/mlir/IR/OperationSupport.h
  mlir/lib/Dialect/LoopOps/LoopOps.cpp
  mlir/test/EDSC/builder-api-test.cpp


Index: mlir/test/EDSC/builder-api-test.cpp
===================================================================
--- mlir/test/EDSC/builder-api-test.cpp
+++ mlir/test/EDSC/builder-api-test.cpp
@@ -897,10 +897,9 @@
 
   OpBuilder builder(f.getBody());
   ScopedContext scope(builder, f.getLoc());
-  linalg_dilated_conv_nhwc(
-      makeValueHandles(llvm::to_vector<3>(f.getArguments())),
-      /*depth_multiplier=*/7,
-      /*strides=*/{3, 4}, /*dilations=*/{5, 6});
+  linalg_dilated_conv_nhwc(makeValueHandles(f.getArguments()),
+                           /*depth_multiplier=*/7,
+                           /*strides=*/{3, 4}, /*dilations=*/{5, 6});
 
   f.print(llvm::outs());
   f.erase();
Index: mlir/lib/Dialect/LoopOps/LoopOps.cpp
===================================================================
--- mlir/lib/Dialect/LoopOps/LoopOps.cpp
+++ mlir/lib/Dialect/LoopOps/LoopOps.cpp
@@ -332,10 +332,9 @@
 }
 
 static void print(OpAsmPrinter &p, ParallelOp op) {
-  p << op.getOperationName() << " (";
-  p.printOperands(op.getBody()->getArguments());
-  p << ") = (" << op.lowerBound() << ") to (" << op.upperBound() << ") step ("
-    << op.step() << ")";
+  p << op.getOperationName() << " (" << op.getBody()->getArguments() << ") = ("
+    << op.lowerBound() << ") to (" << op.upperBound() << ") step (" << op.step()
+    << ")";
   p.printRegion(op.region(), /*printEntryBlockArgs=*/false);
   p.printOptionalAttrDict(op.getAttrs());
   if (!op.results().empty())
Index: mlir/include/mlir/IR/OperationSupport.h
===================================================================
--- mlir/include/mlir/IR/OperationSupport.h
+++ mlir/include/mlir/IR/OperationSupport.h
@@ -658,6 +658,8 @@
       : ValueRange(OperandRange(values)) {}
   ValueRange(iterator_range<ResultRange::iterator> values)
       : ValueRange(ResultRange(values)) {}
+  ValueRange(ArrayRef<BlockArgument> values)
+      : ValueRange(ArrayRef<Value>(values.data(), values.size())) {}
   ValueRange(ArrayRef<Value> values = llvm::None);
   ValueRange(OperandRange values);
   ValueRange(ResultRange values);
Index: mlir/include/mlir/IR/FunctionSupport.h
===================================================================
--- mlir/include/mlir/IR/FunctionSupport.h
+++ mlir/include/mlir/IR/FunctionSupport.h
@@ -220,13 +220,11 @@
     return getBlocks().front().getArgument(idx);
   }
 
-  // Supports non-const operand iteration.
+  /// Support argument iteration.
   using args_iterator = Block::args_iterator;
   args_iterator args_begin() { return front().args_begin(); }
   args_iterator args_end() { return front().args_end(); }
-  iterator_range<args_iterator> getArguments() {
-    return {args_begin(), args_end()};
-  }
+  Block::BlockArgListType getArguments() { return front().getArguments(); }
 
   //===--------------------------------------------------------------------===//
   // Argument Attributes


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74363.244213.patch
Type: text/x-patch
Size: 2895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200212/17b7dfd3/attachment.bin>


More information about the llvm-commits mailing list