mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-24 22:30:31 +01:00
pan/midgard: Begin tracking liveness metadata
This will allow us to explicitly invalidate liveness analysis results so we can cache liveness results. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
parent
846e5d5ba8
commit
3450c013c5
4 changed files with 39 additions and 5 deletions
|
|
@ -288,8 +288,14 @@ typedef struct compiler_context {
|
|||
unsigned sysvals[MAX_SYSVAL_COUNT];
|
||||
unsigned sysval_count;
|
||||
struct hash_table_u64 *sysval_to_id;
|
||||
|
||||
/* Bitmask of valid metadata */
|
||||
unsigned metadata;
|
||||
} compiler_context;
|
||||
|
||||
/* Per-block live_in/live_out */
|
||||
#define MIDGARD_METADATA_LIVENESS (1 << 0)
|
||||
|
||||
/* Helpers for manipulating the above structures (forming the driver IR) */
|
||||
|
||||
/* Append instruction to end of current block */
|
||||
|
|
@ -606,6 +612,7 @@ struct ra_graph* allocate_registers(compiler_context *ctx, bool *spilled);
|
|||
void install_registers(compiler_context *ctx, struct ra_graph *g);
|
||||
void mir_liveness_ins_update(uint8_t *live, midgard_instruction *ins, unsigned max);
|
||||
void mir_compute_liveness(compiler_context *ctx);
|
||||
void mir_invalidate_liveness(compiler_context *ctx);
|
||||
bool mir_is_live_after(compiler_context *ctx, midgard_block *block, midgard_instruction *start, int src);
|
||||
|
||||
void mir_create_pipeline_registers(compiler_context *ctx);
|
||||
|
|
|
|||
|
|
@ -113,6 +113,10 @@ liveness_block_update(compiler_context *ctx, midgard_block *blk)
|
|||
void
|
||||
mir_compute_liveness(compiler_context *ctx)
|
||||
{
|
||||
/* If we already have fresh liveness, nothing to do */
|
||||
if (ctx->metadata & MIDGARD_METADATA_LIVENESS)
|
||||
return;
|
||||
|
||||
/* List of midgard_block */
|
||||
struct set *work_list = _mesa_set_create(ctx,
|
||||
_mesa_hash_pointer,
|
||||
|
|
@ -148,6 +152,33 @@ mir_compute_liveness(compiler_context *ctx)
|
|||
_mesa_set_add(work_list, pred);
|
||||
}
|
||||
} while((cur = _mesa_set_next_entry(work_list, NULL)) != NULL);
|
||||
|
||||
/* Liveness is now valid */
|
||||
ctx->metadata |= MIDGARD_METADATA_LIVENESS;
|
||||
}
|
||||
|
||||
/* Once liveness data is no longer valid, call this */
|
||||
|
||||
void
|
||||
mir_invalidate_liveness(compiler_context *ctx)
|
||||
{
|
||||
/* If we didn't already compute liveness, there's nothing to do */
|
||||
if (!(ctx->metadata & MIDGARD_METADATA_LIVENESS))
|
||||
return;
|
||||
|
||||
/* It's now invalid regardless */
|
||||
ctx->metadata &= ~MIDGARD_METADATA_LIVENESS;
|
||||
|
||||
mir_foreach_block(ctx, block) {
|
||||
if (block->live_in)
|
||||
free(block->live_in);
|
||||
|
||||
if (block->live_out)
|
||||
free(block->live_out);
|
||||
|
||||
block->live_in = NULL;
|
||||
block->live_out = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine if a variable is live in the successors of a block */
|
||||
|
|
|
|||
|
|
@ -574,11 +574,6 @@ mir_compute_interference(
|
|||
|
||||
free(live);
|
||||
}
|
||||
|
||||
mir_foreach_block(ctx, blk) {
|
||||
free(blk->live_in);
|
||||
free(blk->live_out);
|
||||
}
|
||||
}
|
||||
|
||||
/* This routine performs the actual register allocation. It should be succeeded
|
||||
|
|
|
|||
|
|
@ -1393,6 +1393,7 @@ schedule_program(compiler_context *ctx)
|
|||
mir_spill_register(ctx, g, &spill_count);
|
||||
|
||||
mir_squeeze_index(ctx);
|
||||
mir_invalidate_liveness(ctx);
|
||||
|
||||
g = NULL;
|
||||
g = allocate_registers(ctx, &spilled);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue