From 63271dca9a0710502178e63268324328f4be0ad4 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 6 Jan 2021 14:55:50 -0500 Subject: [PATCH] pan/bi: Choose instructions to schedule In the future we'll want a heuristic minimizing register pressure but for in-order this will suffice. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bi_schedule.c | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index 2ae7ce0a2bb..af6e475b10f 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -764,6 +764,39 @@ bi_instr_schedulable(bi_instr *instr, return true; } +static signed +bi_instr_cost(bi_instr *instr) +{ + /* TODO: stub */ + return 0; +} + +static unsigned +bi_choose_index(struct bi_worklist st, + struct bi_clause_state *clause, + struct bi_tuple_state *tuple, + bool fma) +{ + unsigned i, best_idx = ~0; + signed best_cost = INT_MAX; + + BITSET_FOREACH_SET(i, st.worklist, st.count) { + bi_instr *instr = st.instructions[i]; + + if (!bi_instr_schedulable(instr, clause, tuple, fma)) + continue; + + signed cost = bi_instr_cost(instr); + + if (cost <= best_cost) { + best_idx = i; + best_cost = cost; + } + } + + return best_idx; +} + #ifndef NDEBUG