[NFC] Add getArgumentTypes() to Region
authorRahul Joshi <jurahul@google.com>
Tue, 28 Jul 2020 22:26:36 +0000 (15:26 -0700)
committerRahul Joshi <jurahul@google.com>
Wed, 29 Jul 2020 01:27:42 +0000 (18:27 -0700)
- 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

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

index 5671f2b..9b6f54f 100644 (file)
@@ -74,6 +74,9 @@ public:
   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(); }
index 09b7441..8554b7a 100644 (file)
@@ -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) { ... });
index 23d89c2..559d411 100644 (file)
@@ -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));
index b616eaa..7610138 100644 (file)
@@ -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);
index 31f24a4..4b7ae80 100644 (file)
@@ -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];