pan/midgard: Decontextualize liveness analysis core
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 11 Mar 2020 12:09:29 +0000 (08:09 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 11 Mar 2020 20:28:20 +0000 (20:28 +0000)
We mostly just need the temp_count from it.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4150>

src/panfrost/midgard/midgard_liveness.c

index a1cb8436f111a1fad9ba2bb916692103d6160fbc..0769874a66d8f55f9de33451c4078cb286560cf0 100644 (file)
@@ -73,10 +73,10 @@ mir_liveness_ins_update(uint16_t *live, midgard_instruction *ins, unsigned max)
 /* live_out[s] = sum { p in succ[s] } ( live_in[p] ) */
 
 static void
-liveness_block_live_out(compiler_context *ctx, midgard_block *blk)
+liveness_block_live_out(midgard_block *blk, unsigned temp_count)
 {
         mir_foreach_successor(blk, succ) {
-                for (unsigned i = 0; i < ctx->temp_count; ++i)
+                for (unsigned i = 0; i < temp_count; ++i)
                         blk->live_out[i] |= succ->live_in[i];
         }
 }
@@ -86,21 +86,21 @@ liveness_block_live_out(compiler_context *ctx, midgard_block *blk)
  * returns whether progress was made. */
 
 static bool
-liveness_block_update(compiler_context *ctx, midgard_block *blk)
+liveness_block_update(midgard_block *blk, unsigned temp_count)
 {
         bool progress = false;
 
-        liveness_block_live_out(ctx, blk);
+        liveness_block_live_out(blk, temp_count);
 
-        uint16_t *live = ralloc_array(ctx, uint16_t, ctx->temp_count);
-        memcpy(live, blk->live_out, ctx->temp_count * sizeof(uint16_t));
+        uint16_t *live = ralloc_array(blk, uint16_t, temp_count);
+        memcpy(live, blk->live_out, temp_count * sizeof(uint16_t));
 
         mir_foreach_instr_in_block_rev(blk, ins)
-                mir_liveness_ins_update(live, ins, ctx->temp_count);
+                mir_liveness_ins_update(live, ins, temp_count);
 
         /* To figure out progress, diff live_in */
 
-        for (unsigned i = 0; (i < ctx->temp_count) && !progress; ++i)
+        for (unsigned i = 0; (i < temp_count) && !progress; ++i)
                 progress |= (blk->live_in[i] != live[i]);
 
         ralloc_free(blk->live_in);
@@ -123,6 +123,7 @@ mir_compute_liveness(compiler_context *ctx)
                 return;
 
         mir_compute_temp_count(ctx);
+        unsigned temp_count = ctx->temp_count;
 
         /* List of midgard_block */
         struct set *work_list = _mesa_set_create(ctx,
@@ -136,8 +137,8 @@ mir_compute_liveness(compiler_context *ctx)
         /* Allocate */
 
         mir_foreach_block(ctx, block) {
-                block->live_in = rzalloc_array(NULL, uint16_t, ctx->temp_count);
-                block->live_out = rzalloc_array(NULL, uint16_t, ctx->temp_count);
+                block->live_in = rzalloc_array(NULL, uint16_t, temp_count);
+                block->live_out = rzalloc_array(NULL, uint16_t, temp_count);
         }
 
         /* Initialize the work list with the exit block */
@@ -154,7 +155,7 @@ mir_compute_liveness(compiler_context *ctx)
                 _mesa_set_remove(work_list, cur);
 
                 /* Update its liveness information */
-                bool progress = liveness_block_update(ctx, blk);
+                bool progress = liveness_block_update(blk, temp_count);
 
                 /* If we made progress, we need to process the predecessors */