pan/bi: Add interference per clause

With new helpers.

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-06 12:25:45 -05:00 committed by Marge Bot
parent 108e10f32a
commit c578ca7393

View file

@ -30,17 +30,9 @@
#include "util/u_memory.h" #include "util/u_memory.h"
static void static void
bi_compute_interference(bi_context *ctx, struct lcra_state *l) bi_mark_interference(bi_block *block, bi_clause *clause, struct lcra_state *l, uint16_t *live, unsigned node_count, bool is_blend)
{ {
unsigned node_count = bi_max_temp(ctx); bi_foreach_instr_in_clause_rev(block, clause, ins) {
bi_compute_liveness(ctx);
bi_foreach_block(ctx, _blk) {
bi_block *blk = (bi_block *) _blk;
uint16_t *live = mem_dup(_blk->live_out, node_count * sizeof(uint16_t));
bi_foreach_instr_in_block_rev(blk, ins) {
/* Mark all registers live after the instruction as /* Mark all registers live after the instruction as
* interfering with the destination */ * interfering with the destination */
@ -48,16 +40,18 @@ bi_compute_interference(bi_context *ctx, struct lcra_state *l)
if (bi_get_node(ins->dest[d]) >= node_count) if (bi_get_node(ins->dest[d]) >= node_count)
continue; continue;
for (unsigned i = 0; i < node_count; ++i) { for (unsigned i = 1; i < node_count; ++i) {
if (live[i]) if (live[i]) {
lcra_add_node_interference(l, bi_get_node(ins->dest[d]), bi_writemask(ins), i, live[i]); lcra_add_node_interference(l, bi_get_node(ins->dest[d]),
bi_writemask(ins), i, live[i]);
}
} }
} }
if (!ctx->is_blend && ins->op == BI_OPCODE_BLEND) { if (!is_blend && ins->op == BI_OPCODE_BLEND) {
/* Add blend shader interference: blend shaders might /* Add blend shader interference: blend shaders might
* clobber r0-r15. */ * clobber r0-r15. */
for (unsigned i = 0; i < node_count; ++i) { for (unsigned i = 1; i < node_count; ++i) {
if (!live[i]) if (!live[i])
continue; continue;
@ -72,6 +66,22 @@ bi_compute_interference(bi_context *ctx, struct lcra_state *l)
/* Update live_in */ /* Update live_in */
bi_liveness_ins_update(live, ins, node_count); bi_liveness_ins_update(live, ins, node_count);
} }
}
static void
bi_compute_interference(bi_context *ctx, struct lcra_state *l)
{
unsigned node_count = bi_max_temp(ctx);
bi_compute_liveness(ctx);
bi_foreach_block(ctx, _blk) {
bi_block *blk = (bi_block *) _blk;
uint16_t *live = mem_dup(_blk->live_out, node_count * sizeof(uint16_t));
bi_foreach_clause_in_block_rev(blk, clause) {
bi_mark_interference(blk, clause, l, live, node_count, ctx->is_blend);
}
free(live); free(live);
} }