[MLIR] Change return type of ParallelOp::getInductionVars to ValueRange.

The current return type sometimes leads to code like
to_vector<2>(ValueRange(loop.getInductionIvs())). It would be nice to
shorten it. Users who need access to Block::BlockArgListType (if there
are any), can always call getBody()->getArguments(); if needed.

Also remove getNumInductionVars(), since there is getNumLoops().

Differential Revision: https://reviews.llvm.org/D77526
This commit is contained in:
Alexander Belyaev 2020-04-06 09:06:21 +02:00
parent 6000478f39
commit c2d03e4ef1
2 changed files with 3 additions and 6 deletions

View File

@ -312,10 +312,7 @@ def ParallelOp : Loop_Op<"parallel",
let extraClassDeclaration = [{
Block *getBody() { return &region().front(); }
unsigned getNumInductionVars() {
return getBody()->getNumArguments();
}
Block::BlockArgListType getInductionVars() {
ValueRange getInductionVars() {
return getBody()->getArguments();
}
unsigned getNumLoops() { return step().size(); }

View File

@ -130,8 +130,8 @@ static void mapParallelOp(ParallelOp parallelOp,
MLIRContext *ctx = parallelOp.getContext();
Builder b(ctx);
SmallVector<ParallelLoopDimMapping, 4> attrs;
attrs.reserve(parallelOp.getNumInductionVars());
for (int i = 0, e = parallelOp.getNumInductionVars(); i < e; ++i) {
attrs.reserve(parallelOp.getNumLoops());
for (int i = 0, e = parallelOp.getNumLoops(); i < e; ++i) {
attrs.push_back(getParallelLoopDimMappingAttr(
getHardwareIdForMapping(mappingLevel, i), b.getDimIdentityMap(),
b.getDimIdentityMap()));