[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
This commit is contained in:
Rahul Joshi 2020-07-28 15:26:36 -07:00
parent 11bb7eef41
commit 706d992ced
5 changed files with 13 additions and 5 deletions

View File

@ -74,6 +74,9 @@ public:
BlockArgListType getArguments() { BlockArgListType getArguments() {
return empty() ? BlockArgListType() : front().getArguments(); return empty() ? BlockArgListType() : front().getArguments();
} }
ValueTypeRange<BlockArgListType> getArgumentTypes();
using args_iterator = BlockArgListType::iterator; using args_iterator = BlockArgListType::iterator;
using reverse_args_iterator = BlockArgListType::reverse_iterator; using reverse_args_iterator = BlockArgListType::reverse_iterator;
args_iterator args_begin() { return getArguments().begin(); } args_iterator args_begin() { return getArguments().begin(); }

View File

@ -76,7 +76,7 @@ WalkResult walkOperations(Operation *op,
// upon the type of the callback function. // upon the type of the callback function.
/// Walk all of the operations nested under and including the given operation. /// 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: /// Example:
/// op->walk([](Operation *op) { ... }); /// op->walk([](Operation *op) { ... });

View File

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

View File

@ -33,6 +33,11 @@ Location Region::getLoc() {
return container->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. /// Add one argument to the argument list for each type specified in the list.
iterator_range<Region::args_iterator> Region::addArguments(TypeRange types) { iterator_range<Region::args_iterator> Region::addArguments(TypeRange types) {
return front().addArguments(types); return front().addArguments(types);

View File

@ -334,7 +334,7 @@ LogicalResult mlir::inlineCall(InlinerInterface &interface,
mapper.map(regionArg, operand); 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); castBuilder.setInsertionPointAfter(call);
for (unsigned i = 0, e = callResults.size(); i != e; ++i) { for (unsigned i = 0, e = callResults.size(); i != e; ++i) {
Value callResult = callResults[i]; Value callResult = callResults[i];