Mesa (main): pan/bi: Clean up useless casts

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jul 18 02:03:17 UTC 2021


Module: Mesa
Branch: main
Commit: 84e2e5f23c7d01f09d68c10a95e59a35f37939af
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=84e2e5f23c7d01f09d68c10a95e59a35f37939af

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Fri Jul 16 18:40:39 2021 -0400

pan/bi: Clean up useless casts

Left over from removing inheritance with sed instead of coccinelle.

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

---

 src/panfrost/bifrost/bi_helper_invocations.c | 17 +++++++----------
 src/panfrost/bifrost/bi_layout.c             |  8 ++------
 src/panfrost/bifrost/bi_opt_cse.c            |  2 +-
 src/panfrost/bifrost/bi_opt_dce.c            | 17 ++++++-----------
 src/panfrost/bifrost/bi_pack.c               |  6 ++----
 src/panfrost/bifrost/bi_print.c              |  2 +-
 src/panfrost/bifrost/bi_ra.c                 |  5 ++---
 src/panfrost/bifrost/bi_schedule.c           |  3 +--
 src/panfrost/bifrost/bi_scoreboard.c         |  6 ++----
 src/panfrost/bifrost/bifrost_compile.c       | 17 ++++++-----------
 src/panfrost/bifrost/bir.c                   | 12 +++++-------
 11 files changed, 35 insertions(+), 60 deletions(-)

diff --git a/src/panfrost/bifrost/bi_helper_invocations.c b/src/panfrost/bifrost/bi_helper_invocations.c
index be926321f52..946ae8c2dab 100644
--- a/src/panfrost/bifrost/bi_helper_invocations.c
+++ b/src/panfrost/bifrost/bi_helper_invocations.c
@@ -120,8 +120,8 @@ static bool
 bi_block_terminates_helpers(bi_block *block)
 {
         /* Can't terminate if a successor needs helpers */
-        bi_foreach_successor((block), succ) {
-                if (((bi_block *) succ)->pass_flags & 1)
+        bi_foreach_successor(block, succ) {
+                if (succ->pass_flags & 1)
                         return false;
         }
 
@@ -148,12 +148,11 @@ bi_analyze_helper_terminate(bi_context *ctx)
                         _mesa_hash_pointer,
                         _mesa_key_pointer_equal);
 
-        bi_foreach_block(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
+        bi_foreach_block(ctx, block) {
                 block->pass_flags = bi_block_uses_helpers(block) ? 1 : 0;
 
                 if (block->pass_flags & 1)
-                        _mesa_set_add(worklist, _block);
+                        _mesa_set_add(worklist, block);
         }
 
         /* Next, propagate back. Since there are a finite number of blocks, the
@@ -172,7 +171,7 @@ bi_analyze_helper_terminate(bi_context *ctx)
                 /* Its predecessors also require helpers */
                 bi_foreach_predecessor(blk, pred) {
                         if (!_mesa_set_search(visited, pred)) {
-                                ((bi_block *) pred)->pass_flags |= 1;
+                                pred->pass_flags |= 1;
                                 _mesa_set_add(worklist, pred);
                         }
                 }
@@ -184,9 +183,7 @@ bi_analyze_helper_terminate(bi_context *ctx)
         _mesa_set_destroy(worklist, NULL);
 
         /* Finally, mark clauses requiring helpers */
-        bi_foreach_block(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
-
+        bi_foreach_block(ctx, block) {
                 /* At the end, there are helpers iff we don't terminate */
                 bool helpers = !bi_block_terminates_helpers(block);
 
@@ -261,7 +258,7 @@ bi_analyze_helper_requirements(bi_context *ctx)
                 bi_block *blk = (struct bi_block *) cur->key;
                 _mesa_set_remove(work_list, cur);
 
-                bool progress = bi_helper_block_update(deps, (bi_block *) blk);
+                bool progress = bi_helper_block_update(deps, blk);
 
                 if (progress || !_mesa_set_search(visited, blk)) {
                         bi_foreach_predecessor(blk, pred)
diff --git a/src/panfrost/bifrost/bi_layout.c b/src/panfrost/bifrost/bi_layout.c
index aae81ba7d0d..500bda128c6 100644
--- a/src/panfrost/bifrost/bi_layout.c
+++ b/src/panfrost/bifrost/bi_layout.c
@@ -124,9 +124,7 @@ bi_block_offset(bi_context *ctx, bi_clause *start, bi_block *target)
 
                 /* We then need to jump through every clause of every following
                  * block until the target */
-                bi_foreach_block_from(ctx, start->block, _blk) {
-                        bi_block *blk = (bi_block *) _blk;
-
+                bi_foreach_block_from(ctx, start->block, blk) {
                         /* Don't double-count the first block */
                         if (blk == start->block)
                                 continue;
@@ -153,9 +151,7 @@ bi_block_offset(bi_context *ctx, bi_clause *start, bi_block *target)
                 /* And jump back every clause of preceding blocks up through
                  * and including the target to get to the beginning of the
                  * target */
-                bi_foreach_block_from_rev(ctx, start->block, _blk) {
-                        bi_block *blk = (bi_block *) _blk;
-
+                bi_foreach_block_from_rev(ctx, start->block, blk) {
                         if (blk == start->block)
                                 continue;
 
diff --git a/src/panfrost/bifrost/bi_opt_cse.c b/src/panfrost/bifrost/bi_opt_cse.c
index 832bae0313c..4d70a44c1b5 100644
--- a/src/panfrost/bifrost/bi_opt_cse.c
+++ b/src/panfrost/bifrost/bi_opt_cse.c
@@ -157,7 +157,7 @@ bi_opt_cse(bi_context *ctx)
                 bi_index *replacement = calloc(sizeof(bi_index), ((ctx->ssa_alloc + 1) << 2));
                 _mesa_set_clear(instr_set, NULL);
 
-                bi_foreach_instr_in_block((bi_block *) block, instr) {
+                bi_foreach_instr_in_block(block, instr) {
                         /* Rewrite before trying to CSE anything so we converge
                          * locally in one iteration */
                         bi_foreach_src(instr, s) {
diff --git a/src/panfrost/bifrost/bi_opt_dce.c b/src/panfrost/bifrost/bi_opt_dce.c
index a568f4f3481..254cd681c45 100644
--- a/src/panfrost/bifrost/bi_opt_dce.c
+++ b/src/panfrost/bifrost/bi_opt_dce.c
@@ -35,11 +35,10 @@ bi_opt_dead_code_eliminate(bi_context *ctx)
         bi_invalidate_liveness(ctx);
         bi_compute_liveness(ctx);
 
-        bi_foreach_block_rev(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
-                uint16_t *live = rzalloc_array(_block, uint16_t, temp_count);
+        bi_foreach_block_rev(ctx, block) {
+                uint16_t *live = rzalloc_array(block, uint16_t, temp_count);
 
-                bi_foreach_successor(_block, succ) {
+                bi_foreach_successor(block, succ) {
                         for (unsigned i = 0; i < temp_count; ++i)
                                 live[i] |= succ->live_in[i];
                 }
@@ -94,10 +93,8 @@ bi_postra_liveness_ins(uint64_t live, bi_instr *ins)
 static bool
 bi_postra_liveness_block(bi_block *blk)
 {
-        bi_foreach_successor((blk), _succ) {
-                bi_block *succ = (bi_block *) _succ;
+        bi_foreach_successor(blk, succ)
                 blk->reg_live_out |= succ->reg_live_in;
-        }
 
         uint64_t live = blk->reg_live_out;
 
@@ -129,8 +126,7 @@ bi_postra_liveness(bi_context *ctx)
         struct set_entry *cur;
         cur = _mesa_set_add(work_list, pan_exit_block(&ctx->blocks));
 
-        bi_foreach_block(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
+        bi_foreach_block(ctx, block) {
                 block->reg_live_out = block->reg_live_in = 0;
         }
 
@@ -160,8 +156,7 @@ bi_opt_dce_post_ra(bi_context *ctx)
 {
         bi_postra_liveness(ctx);
 
-        bi_foreach_block_rev(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
+        bi_foreach_block_rev(ctx, block) {
                 uint64_t live = block->reg_live_out;
 
                 bi_foreach_instr_in_block_rev(block, ins) {
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c
index ebe3ac1da4d..01b7ea5d20f 100644
--- a/src/panfrost/bifrost/bi_pack.c
+++ b/src/panfrost/bifrost/bi_pack.c
@@ -714,9 +714,7 @@ bi_pack(bi_context *ctx, struct util_dynarray *emission)
 {
         unsigned previous_size = emission->size;
 
-        bi_foreach_block(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
-
+        bi_foreach_block(ctx, block) {
                 bi_assign_branch_offset(ctx, block);
 
                 bi_foreach_clause_in_block(block, clause) {
@@ -732,7 +730,7 @@ bi_pack(bi_context *ctx, struct util_dynarray *emission)
                                 next = bi_next_clause(ctx, block->successors[0], NULL);
                                 next_2 = bi_next_clause(ctx, block->successors[1], NULL);
                         } else {
-                                next = bi_next_clause(ctx, _block, clause);
+                                next = bi_next_clause(ctx, block, clause);
                         }
 
 
diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c
index d27ae71a430..c242a939dc3 100644
--- a/src/panfrost/bifrost/bi_print.c
+++ b/src/panfrost/bifrost/bi_print.c
@@ -163,5 +163,5 @@ void
 bi_print_shader(bi_context *ctx, FILE *fp)
 {
         bi_foreach_block(ctx, block)
-                bi_print_block((bi_block *) block, fp);
+                bi_print_block(block, fp);
 }
diff --git a/src/panfrost/bifrost/bi_ra.c b/src/panfrost/bifrost/bi_ra.c
index 628ad88c4de..f62a6509ecb 100644
--- a/src/panfrost/bifrost/bi_ra.c
+++ b/src/panfrost/bifrost/bi_ra.c
@@ -264,9 +264,8 @@ bi_compute_interference(bi_context *ctx, struct lcra_state *l, bool full_regs)
         bi_compute_liveness(ctx);
         bi_postra_liveness(ctx);
 
-        bi_foreach_block_rev(ctx, _blk) {
-                bi_block *blk = (bi_block *) _blk;
-                uint16_t *live = mem_dup(_blk->live_out, node_count * sizeof(uint16_t));
+        bi_foreach_block_rev(ctx, blk) {
+                uint16_t *live = mem_dup(blk->live_out, node_count * sizeof(uint16_t));
 
                 bi_mark_interference(blk, l, live, blk->reg_live_out,
                                 node_count, ctx->inputs->is_blend, !full_regs);
diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c
index 63f15e8cba1..c22cd74b4ca 100644
--- a/src/panfrost/bifrost/bi_schedule.c
+++ b/src/panfrost/bifrost/bi_schedule.c
@@ -1928,8 +1928,7 @@ bi_schedule(bi_context *ctx)
         bi_postra_liveness(ctx);
 
         bi_foreach_block(ctx, block) {
-                bi_block *bblock = (bi_block *) block;
-                bi_schedule_block(ctx, bblock);
+                bi_schedule_block(ctx, block);
         }
 
         bi_opt_dce_post_ra(ctx);
diff --git a/src/panfrost/bifrost/bi_scoreboard.c b/src/panfrost/bifrost/bi_scoreboard.c
index 05b731a5356..1e7ca0ed672 100644
--- a/src/panfrost/bifrost/bi_scoreboard.c
+++ b/src/panfrost/bifrost/bi_scoreboard.c
@@ -95,14 +95,12 @@ bi_assign_scoreboard(bi_context *ctx)
         struct bi_scoreboard_state st = {};
 
         /* Assign slots */
-        bi_foreach_block(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
-
+        bi_foreach_block(ctx, block) {
                 bi_foreach_clause_in_block(block, clause) {
                         unsigned slot = bi_choose_scoreboard_slot(&st, clause->message);
                         clause->scoreboard_id = slot;
 
-                        bi_clause *next = bi_next_clause(ctx, _block, clause);
+                        bi_clause *next = bi_next_clause(ctx, block, clause);
                         if (next)
                                 next->dependencies |= (1 << slot);
                 }
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index a370c818b7c..4b347fe3cfa 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -74,13 +74,13 @@ bi_block_add_successor(bi_block *block, bi_block *successor)
 
         for (unsigned i = 0; i < ARRAY_SIZE(block->successors); ++i) {
                 if (block->successors[i]) {
-                       if (block->successors[i] == (bi_block *) successor)
+                       if (block->successors[i] == successor)
                                return;
                        else
                                continue;
                 }
 
-                block->successors[i] = (void *) successor;
+                block->successors[i] = successor;
                 _mesa_set_add(successor->predecessors, block);
                 return;
         }
@@ -3042,9 +3042,7 @@ bi_print_stats(bi_context *ctx, unsigned size, FILE *fp)
          * cycle counts are surely more complicated.
          */
 
-        bi_foreach_block(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
-
+        bi_foreach_block(ctx, block) {
                 bi_foreach_clause_in_block(block, clause) {
                         stats.nr_clauses++;
                         stats.nr_tuples += clause->tuple_count;
@@ -3567,9 +3565,7 @@ bifrost_compile_shader_nir(nir_shader *nir,
 
         unsigned block_source_count = 0;
 
-        bi_foreach_block(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
-
+        bi_foreach_block(ctx, block) {
                 /* Name blocks now that we're done emitting so the order is
                  * consistent */
                 block->name = block_source_count++;
@@ -3584,7 +3580,7 @@ bifrost_compile_shader_nir(nir_shader *nir,
 
         if (need_dummy_atest) {
                 bi_block *end = list_last_entry(&ctx->blocks, bi_block, link);
-                bi_builder b = bi_init_builder(ctx, bi_after_block((bi_block *) end));
+                bi_builder b = bi_init_builder(ctx, bi_after_block(end));
                 bi_emit_atest(&b, bi_zero());
         }
 
@@ -3602,8 +3598,7 @@ bifrost_compile_shader_nir(nir_shader *nir,
         bi_opt_cse(ctx);
         bi_opt_dead_code_eliminate(ctx);
 
-        bi_foreach_block(ctx, _block) {
-                bi_block *block = (bi_block *) _block;
+        bi_foreach_block(ctx, block) {
                 bi_lower_branch(block);
         }
 
diff --git a/src/panfrost/bifrost/bir.c b/src/panfrost/bifrost/bir.c
index e4993a3913f..abe16c09cf5 100644
--- a/src/panfrost/bifrost/bir.c
+++ b/src/panfrost/bifrost/bir.c
@@ -122,21 +122,19 @@ bi_next_clause(bi_context *ctx, bi_block *block, bi_clause *clause)
                 return NULL;
 
         /* Try the first clause in this block if we're starting from scratch */
-        if (!clause && !list_is_empty(&((bi_block *) block)->clauses))
-                return list_first_entry(&((bi_block *) block)->clauses, bi_clause, link);
+        if (!clause && !list_is_empty(&block->clauses))
+                return list_first_entry(&block->clauses, bi_clause, link);
 
         /* Try the next clause in this block */
-        if (clause && clause->link.next != &((bi_block *) block)->clauses)
+        if (clause && clause->link.next != &block->clauses)
                 return list_first_entry(&(clause->link), bi_clause, link);
 
         /* Try the next block, or the one after that if it's empty, etc .*/
         bi_block *next_block = bi_next_block(block);
 
         bi_foreach_block_from(ctx, next_block, block) {
-                bi_block *blk = (bi_block *) block;
-
-                if (!list_is_empty(&blk->clauses))
-                        return list_first_entry(&(blk->clauses), bi_clause, link);
+                if (!list_is_empty(&block->clauses))
+                        return list_first_entry(&block->clauses, bi_clause, link);
         }
 
         return NULL;



More information about the mesa-commit mailing list