diff options
| author | River Riddle <riverriddle@google.com> | 2019-01-26 12:40:12 -0800 |
|---|---|---|
| committer | jpienaar <jpienaar@google.com> | 2019-03-29 15:40:23 -0700 |
| commit | 36babbd7815519db5d26f55695fa3ec500997bcd (patch) | |
| tree | 9686f3f296ff2d849ffb2f69434e50b4e6fce901 /mlir/lib/EDSC/MLIREmitter.cpp | |
| parent | 0e7a8a9027c5f5862c3c78f41c777ba2930f9b23 (diff) | |
| download | bcm5719-llvm-36babbd7815519db5d26f55695fa3ec500997bcd.tar.gz bcm5719-llvm-36babbd7815519db5d26f55695fa3ec500997bcd.zip | |
Change the ForInst induction variable to be a block argument of the body instead of the ForInst itself. This is a necessary step in converting ForInst into an operation.
PiperOrigin-RevId: 231064139
Diffstat (limited to 'mlir/lib/EDSC/MLIREmitter.cpp')
| -rw-r--r-- | mlir/lib/EDSC/MLIREmitter.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/mlir/lib/EDSC/MLIREmitter.cpp b/mlir/lib/EDSC/MLIREmitter.cpp index 56f211ec578..c2a6dc1f90a 100644 --- a/mlir/lib/EDSC/MLIREmitter.cpp +++ b/mlir/lib/EDSC/MLIREmitter.cpp @@ -133,9 +133,7 @@ static void printDefininingStatement(llvm::raw_ostream &os, const Value &v) { inst->print(os); return; } - // &v is required here otherwise we get: - // non-pointer operand type 'const mlir::ForInst' incompatible with nullptr - if (auto *forInst = dyn_cast<ForInst>(&v)) { + if (auto *forInst = getForInductionVarOwner(&v)) { forInst->print(os); } else { os << "unknown_ssa_value"; @@ -296,7 +294,7 @@ Value *MLIREmitter::emit(Expr e) { exprs[1]->getDefiningInst()->cast<ConstantIndexOp>()->getValue(); auto step = exprs[2]->getDefiningInst()->cast<ConstantIndexOp>()->getValue(); - res = builder->createFor(location, lb, ub, step); + res = builder->createFor(location, lb, ub, step)->getInductionVar(); } } @@ -347,7 +345,8 @@ void MLIREmitter::emitStmt(const Stmt &stmt) { bind(stmt.getLHS(), val); if (stmt.getRHS().getKind() == ExprKind::For) { // Step into the loop. - builder->setInsertionPointToStart(cast<ForInst>(val)->getBody()); + builder->setInsertionPointToStart( + getForInductionVarOwner(val)->getBody()); } } emitStmts(stmt.getEnclosedStmts()); |

