summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>2019-10-03 21:16:56 -0400
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>2019-10-03 22:29:51 -0400
commit3450c013c5a90c1689287c69aaf0e41eae147bc3 (patch)
treec4724402d5d8ffa12341fd65286fbf702b8a8478 /src
parent846e5d5ba82abea9fcba3a7a763f5d57a03269b3 (diff)
downloadmesa-3450c013c5a90c1689287c69aaf0e41eae147bc3.tar.gz
mesa-3450c013c5a90c1689287c69aaf0e41eae147bc3.tar.bz2
mesa-3450c013c5a90c1689287c69aaf0e41eae147bc3.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/panfrost/midgard/compiler.h7
-rw-r--r--src/panfrost/midgard/midgard_liveness.c31
-rw-r--r--src/panfrost/midgard/midgard_ra.c5
-rw-r--r--src/panfrost/midgard/midgard_schedule.c1
4 files changed, 39 insertions, 5 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index 5d5c26e3db9..a4d78c2239b 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -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);
diff --git a/src/panfrost/midgard/midgard_liveness.c b/src/panfrost/midgard/midgard_liveness.c
index ebc6390fe40..b432ca43b47 100644
--- a/src/panfrost/midgard/midgard_liveness.c
+++ b/src/panfrost/midgard/midgard_liveness.c
@@ -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 */
diff --git a/src/panfrost/midgard/midgard_ra.c b/src/panfrost/midgard/midgard_ra.c
index dacc0d9106e..afee5b82745 100644
--- a/src/panfrost/midgard/midgard_ra.c
+++ b/src/panfrost/midgard/midgard_ra.c
@@ -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
diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c
index d5fd17bc6db..a4ffa54c532 100644
--- a/src/panfrost/midgard/midgard_schedule.c
+++ b/src/panfrost/midgard/midgard_schedule.c
@@ -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);