[Mlir-commits] [mlir] 706d992 - [NFC] Add getArgumentTypes() to Region

Rahul Joshi llvmlistbot at llvm.org
Tue Jul 28 18:28:08 PDT 2020


Author: Rahul Joshi
Date: 2020-07-28T18:27:42-07:00
New Revision: 706d992cedaf2ca3190e4445015da62faf2db544

URL: https://github.com/llvm/llvm-project/commit/706d992cedaf2ca3190e4445015da62faf2db544
DIFF: https://github.com/llvm/llvm-project/commit/706d992cedaf2ca3190e4445015da62faf2db544.diff

LOG: [NFC] Add getArgumentTypes() to Region

- Add getArgumentTypes() to Region (missed from before)
- Adopt Region argument API in `hasMultiplyAddBody`
- Fix 2 typos in comments

Differential Revision: https://reviews.llvm.org/D84807

Added: 
    

Modified: 
    mlir/include/mlir/IR/Region.h
    mlir/include/mlir/IR/Visitors.h
    mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
    mlir/lib/IR/Region.cpp
    mlir/lib/Transforms/Utils/InliningUtils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h
index 5671f2b5581e..9b6f54fec936 100644
--- a/mlir/include/mlir/IR/Region.h
+++ b/mlir/include/mlir/IR/Region.h
@@ -74,6 +74,9 @@ class Region {
   BlockArgListType getArguments() {
     return empty() ? BlockArgListType() : front().getArguments();
   }
+
+  ValueTypeRange<BlockArgListType> getArgumentTypes();
+
   using args_iterator = BlockArgListType::iterator;
   using reverse_args_iterator = BlockArgListType::reverse_iterator;
   args_iterator args_begin() { return getArguments().begin(); }

diff  --git a/mlir/include/mlir/IR/Visitors.h b/mlir/include/mlir/IR/Visitors.h
index 09b7441aece1..8554b7a7b885 100644
--- a/mlir/include/mlir/IR/Visitors.h
+++ b/mlir/include/mlir/IR/Visitors.h
@@ -76,7 +76,7 @@ WalkResult walkOperations(Operation *op,
 // upon the type of the callback function.
 
 /// Walk all of the operations nested under and including the given operation.
-/// This method is selected for callbacks that operation on Operation*.
+/// This method is selected for callbacks that operate on Operation*.
 ///
 /// Example:
 ///   op->walk([](Operation *op) { ... });

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
index 23d89c21e6e0..559d41146903 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
@@ -43,9 +43,9 @@ static bool hasMultiplyAddBody(Region &r) {
     return false;
 
   using mlir::matchers::m_Val;
-  auto a = m_Val(r.front().getArgument(0));
-  auto b = m_Val(r.front().getArgument(1));
-  auto c = m_Val(r.front().getArgument(2));
+  auto a = m_Val(r.getArgument(0));
+  auto b = m_Val(r.getArgument(1));
+  auto c = m_Val(r.getArgument(2));
   // TODO: Update this detection once we have  matcher support for specifying
   // that any permutation of operands matches.
   auto pattern1 = m_Op<YieldOp>(m_Op<AddFOp>(m_Op<MulFOp>(a, b), c));

diff  --git a/mlir/lib/IR/Region.cpp b/mlir/lib/IR/Region.cpp
index b616eaa15422..76101382cd58 100644
--- a/mlir/lib/IR/Region.cpp
+++ b/mlir/lib/IR/Region.cpp
@@ -33,6 +33,11 @@ Location Region::getLoc() {
   return container->getLoc();
 }
 
+/// Return a range containing the types of the arguments for this region.
+auto Region::getArgumentTypes() -> ValueTypeRange<BlockArgListType> {
+  return ValueTypeRange<BlockArgListType>(getArguments());
+}
+
 /// Add one argument to the argument list for each type specified in the list.
 iterator_range<Region::args_iterator> Region::addArguments(TypeRange types) {
   return front().addArguments(types);

diff  --git a/mlir/lib/Transforms/Utils/InliningUtils.cpp b/mlir/lib/Transforms/Utils/InliningUtils.cpp
index 31f24a43c2b8..4b7ae8024115 100644
--- a/mlir/lib/Transforms/Utils/InliningUtils.cpp
+++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp
@@ -334,7 +334,7 @@ LogicalResult mlir::inlineCall(InlinerInterface &interface,
     mapper.map(regionArg, operand);
   }
 
-  // Ensure that the resultant values of the call, match the callable.
+  // Ensure that the resultant values of the call match the callable.
   castBuilder.setInsertionPointAfter(call);
   for (unsigned i = 0, e = callResults.size(); i != e; ++i) {
     Value callResult = callResults[i];


        


More information about the Mlir-commits mailing list