[Mlir-commits] [mlir] c832145 - [mlir] Allow constructing a ValueRange from an ArrayRef<BlockArgument>
River Riddle
llvmlistbot at llvm.org
Wed Feb 12 09:54:42 PST 2020
Author: River Riddle
Date: 2020-02-12T09:48:44-08:00
New Revision: c832145960736a7d531d264dcba59967d38bfc81
URL: https://github.com/llvm/llvm-project/commit/c832145960736a7d531d264dcba59967d38bfc81
DIFF: https://github.com/llvm/llvm-project/commit/c832145960736a7d531d264dcba59967d38bfc81.diff
LOG: [mlir] Allow constructing a ValueRange from an ArrayRef<BlockArgument>
Summary: This was a missed case when ValueRange was originally added, and allows for constructing a ValueRange from the arguments of a block.
Differential Revision: https://reviews.llvm.org/D74363
Added:
Modified:
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
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/FunctionSupport.h b/mlir/include/mlir/IR/FunctionSupport.h
index 94b9ec8cc816..0787aad534d7 100644
--- a/mlir/include/mlir/IR/FunctionSupport.h
+++ b/mlir/include/mlir/IR/FunctionSupport.h
@@ -220,13 +220,11 @@ class FunctionLike : public OpTrait::TraitBase<ConcreteType, FunctionLike> {
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
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index 544cfe829b3c..9b41567a300b 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -658,6 +658,8 @@ class ValueRange final
: 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);
diff --git a/mlir/lib/Dialect/LoopOps/LoopOps.cpp b/mlir/lib/Dialect/LoopOps/LoopOps.cpp
index 1ce3bbfd0875..3550039b1423 100644
--- a/mlir/lib/Dialect/LoopOps/LoopOps.cpp
+++ b/mlir/lib/Dialect/LoopOps/LoopOps.cpp
@@ -332,10 +332,9 @@ static ParseResult parseParallelOp(OpAsmParser &parser,
}
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())
diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp
index 2cf808642905..ea7c0b530ff8 100644
--- a/mlir/test/EDSC/builder-api-test.cpp
+++ b/mlir/test/EDSC/builder-api-test.cpp
@@ -897,10 +897,9 @@ TEST_FUNC(linalg_dilated_conv_nhwc) {
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();
More information about the Mlir-commits
mailing list