From: Alyssa Rosenzweig Date: Sun, 22 Sep 2019 12:50:22 +0000 (-0400) Subject: pan/midgard: Add mir_update_worklist helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b5396369d2f4cc4bbff3bd2bf0639257ffb6fde5;p=mesa.git pan/midgard: Add mir_update_worklist helper After we've chosen an instruction, popped it off, and processed it, it's time to update the worklist, removing that instruction from the dependency graph to allow its dependents to be put onto the worklist. Signed-off-by: Alyssa Rosenzweig --- diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index 046480ba2ac..8f324805cdb 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -767,6 +767,45 @@ mir_initialize_worklist(BITSET_WORD *worklist, midgard_instruction **instruction } } +/* Update the worklist after an instruction terminates. Remove its edges from + * the graph and if that causes any node to have no dependencies, add it to the + * worklist */ + +static void +mir_update_worklist( + BITSET_WORD *worklist, unsigned count, + midgard_instruction **instructions, midgard_instruction *done) +{ + /* Sanity check: if no instruction terminated, there is nothing to do. + * If the instruction that terminated had dependencies, that makes no + * sense and means we messed up the worklist. Finally, as the purpose + * of this routine is to update dependents, we abort early if there are + * no dependents defined. */ + + if (!done) + return; + + assert(done->nr_dependencies == 0); + + if (!done->dependents) + return; + + /* We have an instruction with dependents. Iterate each dependent to + * remove one dependency (`done`), adding dependents to the worklist + * where possible. */ + + unsigned i; + BITSET_WORD tmp; + BITSET_FOREACH_SET(i, tmp, done->dependents, count) { + assert(instructions[i]->nr_dependencies); + + if (!(--instructions[i]->nr_dependencies)) + BITSET_SET(worklist, i); + } + + free(done->dependents); +} + /* While scheduling, we need to choose instructions satisfying certain * criteria. As we schedule backwards, we choose the *last* instruction in the * worklist to simulate in-order scheduling. Chosen instructions must satisfy a