agx: Add try_coalesce_with helper
Common logic the next few patches will use to try to assign something to the same register as something else. "If it's already been assigned a register and that register is free now, use it, otherwise bail." Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24258>
This commit is contained in:
committed by
Marge Bot
parent
42fbbd2a73
commit
6cc8d7b52a
@@ -739,6 +739,25 @@ affinity_base_of_collect(struct ra_ctx *rctx, agx_instr *collect, unsigned src)
|
||||
return ~0;
|
||||
}
|
||||
|
||||
static bool
|
||||
try_coalesce_with(struct ra_ctx *rctx, agx_index ssa, unsigned count,
|
||||
bool may_be_unvisited, unsigned *out)
|
||||
{
|
||||
assert(ssa.type == AGX_INDEX_NORMAL);
|
||||
if (!BITSET_TEST(rctx->visited, ssa.value)) {
|
||||
assert(may_be_unvisited);
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned base = rctx->ssa_to_reg[ssa.value];
|
||||
if (BITSET_TEST_RANGE(rctx->used_regs, base, base + count - 1))
|
||||
return false;
|
||||
|
||||
assert(base + count <= rctx->bound && "invariant");
|
||||
*out = base;
|
||||
return true;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
pick_regs(struct ra_ctx *rctx, agx_instr *I, unsigned d)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user