pan/bi: Add new style read/writemask helpers

In the medium term we'll want to overhaul these masks entirely since
they don't make much sense anymore, but as a stop gap, this will let us
reuse the existing liveness, RA, and DCE infrastructure.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8135>
This commit is contained in:
Alyssa Rosenzweig 2020-12-11 10:52:11 -05:00 committed by Marge Bot
parent de3c66c2ba
commit 226dfa9490
2 changed files with 47 additions and 0 deletions

View File

@ -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)
{

View File

@ -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);