2020
2121#include " tc/core/check.h"
2222#include " tc/core/constants.h"
23+ #include " tc/core/polyhedral/body.h"
2324#include " tc/core/polyhedral/schedule_isl_conversion.h"
2425#include " tc/core/polyhedral/schedule_transforms.h"
2526#include " tc/core/polyhedral/schedule_tree.h"
@@ -360,7 +361,7 @@ onDomains(isl::aff f, isl::union_set domain, const IterationDomainMap& map) {
360361 * from outermost to innermost.
361362 * Return the schedule corresponding to the subtree at "s".
362363 *
363- * "reads" and "writes" collect the accesses found along the way.
364+ * "body" collects the accesses found along the way.
364365 * "accesses" collects the mapping from Call (for the reads) and Provide nodes
365366 * (for the writes) to the corresponding tag in the access relations.
366367 * "statements" collects the mapping from instance set tuple identifiers
@@ -372,8 +373,7 @@ isl::schedule makeScheduleTreeHelper(
372373 const Stmt& s,
373374 isl::set set,
374375 isl::id_list outer,
375- isl::union_map* reads,
376- isl::union_map* writes,
376+ Body* body,
377377 AccessMap* accesses,
378378 StatementMap* statements,
379379 IterationDomainMap* domains) {
@@ -406,19 +406,19 @@ isl::schedule makeScheduleTreeHelper(
406406
407407 // Recursively descend.
408408 auto outerNext = outer.add (isl::id (set.get_ctx (), op->name ));
409- auto body = makeScheduleTreeHelper (
410- op->body , set, outerNext, reads, writes , accesses, statements, domains);
409+ auto bodySchedule = makeScheduleTreeHelper (
410+ op->body , set, outerNext, body , accesses, statements, domains);
411411
412412 // Create an affine function that defines an ordering for all
413413 // the statements in the body of this loop over the values of
414414 // this loop. Start from a parametric expression equal
415415 // to the current loop iterator and then convert it to
416416 // a function on the statements in the domain of the body schedule.
417417 auto aff = isl::aff::param_on_domain_space (space, id);
418- auto domain = body .get_domain ();
418+ auto domain = bodySchedule .get_domain ();
419419 auto mupa = isl::multi_union_pw_aff (onDomains (aff, domain, *domains));
420420
421- schedule = body .insert_partial_schedule (mupa);
421+ schedule = bodySchedule .insert_partial_schedule (mupa);
422422 } else if (auto op = s.as <Halide::Internal::Block>()) {
423423 std::vector<Stmt> stmts;
424424 stmts.push_back (op->first );
@@ -429,7 +429,7 @@ isl::schedule makeScheduleTreeHelper(
429429 std::vector<isl::schedule> schedules;
430430 for (Stmt stmt : stmts) {
431431 schedules.push_back (makeScheduleTreeHelper (
432- stmt, set, outer, reads, writes , accesses, statements, domains));
432+ stmt, set, outer, body , accesses, statements, domains));
433433 }
434434 schedule = schedules[0 ].sequence (schedules[1 ]);
435435
@@ -453,8 +453,8 @@ isl::schedule makeScheduleTreeHelper(
453453 std::tie (newReads, newWrites) =
454454 extractAccesses (iterationDomain, op, accesses);
455455
456- * reads = reads-> unite (newReads);
457- * writes = writes-> unite (newWrites);
456+ body-> reads = body-> reads . unite (newReads);
457+ body-> writes = body-> writes . unite (newWrites);
458458
459459 } else {
460460 LOG (FATAL) << " Unhandled Halide stmt: " << s;
@@ -465,20 +465,20 @@ isl::schedule makeScheduleTreeHelper(
465465ScheduleTreeAndAccesses makeScheduleTree (isl::space paramSpace, const Stmt& s) {
466466 ScheduleTreeAndAccesses result;
467467
468- result. writes = result. reads = isl::union_map::empty (paramSpace);
468+ Body body (paramSpace);
469469
470470 // Walk the IR building a schedule tree
471471 isl::id_list outer (paramSpace.get_ctx (), 0 );
472472 auto schedule = makeScheduleTreeHelper (
473473 s,
474474 isl::set::universe (paramSpace),
475475 outer,
476- &result.reads ,
477- &result.writes ,
476+ &body,
478477 &result.accesses ,
479478 &result.statements ,
480479 &result.domains );
481480
481+ result.body = body;
482482 result.tree = fromIslSchedule (schedule);
483483
484484 return result;
0 commit comments