pan/bi: Pull out bi_count_read_registers helper

I want to transition away from the ad hoc masks anyway.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8723>
This commit is contained in:
Alyssa Rosenzweig 2021-01-20 16:40:52 -05:00 committed by Marge Bot
parent a69c73988b
commit 2492074d3d
2 changed files with 12 additions and 10 deletions

View file

@ -83,24 +83,25 @@ bi_count_staging_registers(bi_instr *ins)
unreachable("Invalid sr_count");
}
unsigned
bi_count_read_registers(bi_instr *ins, unsigned s)
{
if (s == 0 && bi_opcode_props[ins->op].sr_read)
return bi_count_staging_registers(ins);
else
return 1;
}
uint16_t
bi_bytemask_of_read_components(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;
}
unsigned count = bi_count_read_registers(ins, s);
unsigned rmask = (1 << (4 * count)) - 1;
mask |= (rmask << (4 * node.offset));
}

View file

@ -689,6 +689,7 @@ pan_next_block(pan_block *block)
/* BIR manipulation */
bool bi_has_arg(bi_instr *ins, bi_index arg);
unsigned bi_count_read_registers(bi_instr *ins, unsigned src);
uint16_t bi_bytemask_of_read_components(bi_instr *ins, bi_index node);
unsigned bi_writemask(bi_instr *ins);