From: Alyssa Rosenzweig Date: Thu, 10 Dec 2020 21:05:11 +0000 (-0500) Subject: pan/bi: Schedule new instructions singletons X-Git-Tag: upstream/21.0.0~928 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f6e317045282515bf222a3985c6a4825b616fff;p=platform%2Fupstream%2Fmesa.git pan/bi: Schedule new instructions singletons We'll let the routines coexist for a moment, just to keep the commits digestible, but this is modified from bi_make_singleton. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index 45a480e..96613b6 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -187,6 +187,85 @@ bi_back_to_back(bi_block *block) /* Insert a clause wrapping a single instruction */ bi_clause * +bi_singleton(void *memctx, bi_instr *ins, + bi_block *block, + unsigned scoreboard_id, + unsigned dependencies, + bool osrb) +{ + bi_clause *u = rzalloc(memctx, bi_clause); + u->bundle_count = 1; + + ASSERTED bool can_fma = bi_opcode_props[ins->op].fma; + bool can_add = bi_opcode_props[ins->op].add; + assert(can_fma || can_add); + + if (can_add) + u->bundles[0].add = (bi_instruction *) ins; + else + u->bundles[0].fma = (bi_instruction *) ins; + + u->scoreboard_id = scoreboard_id; + u->staging_barrier = osrb; + u->dependencies = dependencies; + + if (ins->op == BI_OPCODE_ATEST) + u->dependencies |= (1 << 6); + + if (ins->op == BI_OPCODE_BLEND) + u->dependencies |= (1 << 6) | (1 << 7); + + /* Let's be optimistic, we'll fix up later */ + u->flow_control = BIFROST_FLOW_NBTB; + + /* Build up a combined constant, count in 32-bit words */ + uint64_t combined_constant = 0; + unsigned constant_count = 0; + + bi_foreach_src(ins, s) { + if (ins->src[s].type != BI_INDEX_CONSTANT) continue; + unsigned value = ins->src[s].value; + + /* Allow fast zero */ + if (value == 0 && u->bundles[0].fma) continue; + + if (constant_count == 0) { + combined_constant = ins->src[s].value; + } else if (constant_count == 1) { + /* Allow reuse */ + if (combined_constant == value) + continue; + + combined_constant |= ((uint64_t) value) << 32ull; + } else { + /* No more room! */ + assert((combined_constant & 0xffffffff) == value || + (combined_constant >> 32ull) == value); + } + + constant_count++; + } + + if (ins->branch_target) + u->branch_constant = true; + + /* XXX: Investigate errors when constants are not used */ + if (constant_count || u->branch_constant || true) { + /* Clause in 64-bit, above in 32-bit */ + u->constant_count = 1; + u->constants[0] = combined_constant; + } + + u->next_clause_prefetch = (ins->op != BI_OPCODE_JUMP); + u->message_type = bi_message_type_for_instr(ins); + u->block = block; + + return u; +} + +/* Insert a clause wrapping a single instruction */ + +bi_clause * bi_make_singleton(void *memctx, bi_instruction *ins, bi_block *block, unsigned scoreboard_id, diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index f67df52..0debc16 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -1090,6 +1090,13 @@ bool bi_opt_dead_code_eliminate(bi_context *ctx, bi_block *block); void bi_schedule(bi_context *ctx); void bi_register_allocate(bi_context *ctx); +bi_clause * +bi_singleton(void *memctx, bi_instr *ins, + bi_block *block, + unsigned scoreboard_id, + unsigned dependencies, + bool osrb); + bi_clause *bi_make_singleton(void *memctx, bi_instruction *ins, bi_block *block, unsigned scoreboard_id,