diff --git a/src/panfrost/bifrost/bir.c b/src/panfrost/bifrost/bir.c index 40d919a7c53..8fa89f66f03 100644 --- a/src/panfrost/bifrost/bir.c +++ b/src/panfrost/bifrost/bir.c @@ -166,6 +166,51 @@ bi_get_component_count(bi_instruction *ins, signed src) } } +uint16_t +bi_bytemask_of_read_components_new(bi_instr *ins, bi_index node) +{ + uint16_t mask = 0x0; + bool reads_sr = bi_opcode_props[ins->op].sr_read; + + bi_foreach_src(ins, s) { + if (!bi_is_equiv(ins->src[s], node)) continue; + + /* assume we read a scalar */ + unsigned rmask = 0xF; + + if (s == 0 && reads_sr) { + /* Override for a staging register */ + unsigned count = bi_count_staging_registers(ins); + rmask = (1 << (count * 4)) - 1; + } + + mask |= (rmask << (4 * node.offset)); + } + + return mask; +} + +unsigned +bi_writemask_new(bi_instr *ins) +{ + /* Assume we write a scalar */ + unsigned mask = 0xF; + + if (bi_opcode_props[ins->op].sr_write) { + unsigned count = bi_count_staging_registers(ins); + + /* TODO: this special case is even more special, TEXC has a + * generic write mask stuffed in the desc... */ + if (ins->op == BI_OPCODE_TEXC) + count = 4; + + mask = (1 << (count * 4)) - 1; + } + + unsigned shift = ins->dest[0].offset * 4; /* 32-bit words */ + return (mask << shift); +} + uint16_t bi_bytemask_of_read_components(bi_instruction *ins, unsigned node) { diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 51dfbd38aa4..f67df52a57e 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -1077,6 +1077,8 @@ uint16_t bi_bytemask_of_read_components(bi_instruction *ins, unsigned node); uint64_t bi_get_immediate(bi_instruction *ins, unsigned index); bool bi_writes_component(bi_instruction *ins, unsigned comp); unsigned bi_writemask(bi_instruction *ins); +uint16_t bi_bytemask_of_read_components_new(bi_instr *ins, bi_index node); +unsigned bi_writemask_new(bi_instr *ins); void bi_rewrite_uses(bi_context *ctx, unsigned old, unsigned oldc, unsigned new, unsigned newc); void bi_print_instr(bi_instr *I, FILE *fp);