Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 5414b7c

Browse files
author
Sven Verdoolaege
committed
codegenISL: outline collectIteratorMaps
There is no point for this function to be a lambda. It only makes the code harder to read and encourages the use of weird argument names to avoid compiler warnings as in 020faf0 (Compilation fix for -Werror=shadow-compatible-local, Mon May 7 15:12:13 2018 -0700).
1 parent 42d69ca commit 5414b7c

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

tc/core/polyhedral/codegen_llvm.cc

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -606,46 +606,46 @@ struct IslCodegenRes {
606606
isl::ast_node astNode;
607607
};
608608

609+
isl::ast_node collectIteratorMaps(
610+
isl::ast_node node,
611+
isl::ast_build build,
612+
IteratorMapsType& iteratorMapsInFun,
613+
const Scop& scopInFun,
614+
StmtSubscriptExprMapType& stmtSubscriptsInFun) {
615+
auto user = node.as<isl::ast_node_user>();
616+
CHECK(user);
617+
auto expr = user.get_expr().as<isl::ast_expr_op>();
618+
auto schedule = build.get_schedule();
619+
auto scheduleMap = isl::map::from_union_map(schedule);
620+
621+
auto stmtId = expr.get_arg(0).as<isl::ast_expr_id>().get_id();
622+
CHECK_EQ(0u, iteratorMapsInFun.count(stmtId)) << "entry exists: " << stmtId;
623+
auto iteratorMap = isl::pw_multi_aff(scheduleMap.reverse());
624+
auto iterators = scopInFun.halide.iterators.at(stmtId);
625+
auto& stmtIteratorMap = iteratorMapsInFun[stmtId];
626+
for (size_t i = 0; i < iterators.size(); ++i) {
627+
auto expr = build.expr_from(iteratorMap.get_pw_aff(i));
628+
stmtIteratorMap.emplace(iterators[i], expr);
629+
}
630+
auto& subscripts = stmtSubscriptsInFun[stmtId];
631+
auto provide =
632+
scopInFun.halide.statements.at(stmtId).as<Halide::Internal::Provide>();
633+
for (auto e : provide->args) {
634+
const auto& map = iteratorMap;
635+
auto space = map.get_space().params();
636+
auto aff = scopInFun.makeIslAffFromStmtExpr(stmtId, space, e);
637+
auto pulled = isl::pw_aff(aff).pullback(map);
638+
CHECK_EQ(pulled.n_piece(), 1);
639+
subscripts.push_back(build.expr_from(pulled));
640+
}
641+
return node.set_annotation(stmtId);
642+
}
643+
609644
IslCodegenRes codegenISL(const Scop& scop) {
610645
IteratorMapsType iteratorMaps;
611646
StmtSubscriptExprMapType stmtSubscripts;
612647
auto collect = [&iteratorMaps, &scop, &stmtSubscripts](
613648
isl::ast_node n, isl::ast_build b) -> isl::ast_node {
614-
auto collectIteratorMaps =
615-
[](isl::ast_node node,
616-
isl::ast_build build,
617-
IteratorMapsType& iteratorMapsInFun,
618-
const Scop& scopInFun,
619-
StmtSubscriptExprMapType& stmtSubscriptsInFun) -> isl::ast_node {
620-
auto user = node.as<isl::ast_node_user>();
621-
CHECK(user);
622-
auto expr = user.get_expr().as<isl::ast_expr_op>();
623-
auto schedule = build.get_schedule();
624-
auto scheduleMap = isl::map::from_union_map(schedule);
625-
626-
auto stmtId = expr.get_arg(0).as<isl::ast_expr_id>().get_id();
627-
CHECK_EQ(0u, iteratorMapsInFun.count(stmtId))
628-
<< "entry exists: " << stmtId;
629-
auto iteratorMap = isl::pw_multi_aff(scheduleMap.reverse());
630-
auto iterators = scopInFun.halide.iterators.at(stmtId);
631-
auto& stmtIteratorMap = iteratorMapsInFun[stmtId];
632-
for (size_t i = 0; i < iterators.size(); ++i) {
633-
auto expr = build.expr_from(iteratorMap.get_pw_aff(i));
634-
stmtIteratorMap.emplace(iterators[i], expr);
635-
}
636-
auto& subscripts = stmtSubscriptsInFun[stmtId];
637-
auto provide = scopInFun.halide.statements.at(stmtId)
638-
.as<Halide::Internal::Provide>();
639-
for (auto e : provide->args) {
640-
const auto& map = iteratorMap;
641-
auto space = map.get_space().params();
642-
auto aff = scopInFun.makeIslAffFromStmtExpr(stmtId, space, e);
643-
auto pulled = isl::pw_aff(aff).pullback(map);
644-
CHECK_EQ(pulled.n_piece(), 1);
645-
subscripts.push_back(build.expr_from(pulled));
646-
}
647-
return node.set_annotation(stmtId);
648-
};
649649

650650
auto& uv = iteratorMaps;
651651
return collectIteratorMaps(n, b, uv, scop, stmtSubscripts);

0 commit comments

Comments
 (0)