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 */
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);
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,
_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 */