freedreno/ir3: convert block->predecessors to set
authorRob Clark <robdclark@chromium.org>
Fri, 28 Jun 2019 14:30:35 +0000 (07:30 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 28 Aug 2019 22:25:19 +0000 (15:25 -0700)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_compiler_nir.c
src/freedreno/ir3/ir3_legalize.c
src/freedreno/ir3/ir3_print.c
src/freedreno/ir3/ir3_sched.c

index 872a6fb0fc296ee0c3fb7b6fc2e5f3a3275a0d51..50c9b70ae14031878893d9238291d27fd482b6cc 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "util/bitscan.h"
 #include "util/list.h"
+#include "util/set.h"
 #include "util/u_debug.h"
 
 #include "instr-a3xx.h"
@@ -498,8 +499,7 @@ struct ir3_block {
        struct ir3_instruction *condition;
        struct ir3_block *successors[2];
 
-       unsigned predecessors_count;
-       struct ir3_block **predecessors;
+       struct set *predecessors;     /* set of ir3_block */
 
        uint16_t start_ip, end_ip;
 
index 3c58496097ab15f41f0f487eba7f4a74198a5ea3..0e5491151d3e0683959347f5e0aa43ee2268ff85 100644 (file)
@@ -2118,7 +2118,6 @@ get_block(struct ir3_context *ctx, const nir_block *nblock)
 {
        struct ir3_block *block;
        struct hash_entry *hentry;
-       unsigned i;
 
        hentry = _mesa_hash_table_search(ctx->block_ht, nblock);
        if (hentry)
@@ -2128,12 +2127,9 @@ get_block(struct ir3_context *ctx, const nir_block *nblock)
        block->nblock = nblock;
        _mesa_hash_table_insert(ctx->block_ht, nblock, block);
 
-       block->predecessors_count = nblock->predecessors->entries;
-       block->predecessors = ralloc_array_size(block,
-               sizeof(block->predecessors[0]), block->predecessors_count);
-       i = 0;
+       block->predecessors = _mesa_pointer_set_create(block);
        set_foreach(nblock->predecessors, sentry) {
-               block->predecessors[i++] = get_block(ctx, sentry->key);
+               _mesa_set_add(block->predecessors, get_block(ctx, sentry->key));
        }
 
        return block;
index ae5547b6a527ebfd29c99a5b886ceab7894a591d..e46d1214d605962f488f0ec16b0634c499b54358 100644 (file)
@@ -90,8 +90,9 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
        bool last_input_needs_ss = false;
 
        /* our input state is the OR of all predecessor blocks' state: */
-       for (unsigned i = 0; i < block->predecessors_count; i++) {
-               struct ir3_legalize_block_data *pbd = block->predecessors[i]->data;
+       set_foreach(block->predecessors, entry) {
+               struct ir3_block *predecessor = (struct ir3_block *)entry->key;
+               struct ir3_legalize_block_data *pbd = predecessor->data;
                struct ir3_legalize_state *pstate = &pbd->state;
 
                /* Our input (ss)/(sy) state is based on OR'ing the output
index b69941da29e2cc6a4838a893118712e09df5e60d..cc6572d90565f38f56c84a6a1b9e3375e2afa43c 100644 (file)
@@ -215,13 +215,15 @@ print_block(struct ir3_block *block, int lvl)
 {
        tab(lvl); printf("block%u {\n", block_id(block));
 
-       if (block->predecessors_count > 0) {
+       if (block->predecessors->entries > 0) {
+               unsigned i = 0;
                tab(lvl+1);
                printf("pred: ");
-               for (unsigned i = 0; i < block->predecessors_count; i++) {
-                       if (i)
+               set_foreach(block->predecessors, entry) {
+                       struct ir3_block *pred = (struct ir3_block *)entry->key;
+                       if (i++)
                                printf(", ");
-                       printf("block%u", block_id(block->predecessors[i]));
+                       printf("block%u", block_id(pred));
                }
                printf("\n");
        }
index f027d7b7a304a9eb745cd644717c217a397a3132..a311956e925cda30135ae6afb1b7109fa33b150d 100644 (file)
@@ -270,10 +270,11 @@ distance(struct ir3_block *block, struct ir3_instruction *instr,
                /* (ab)use block->data to prevent recursion: */
                block->data = block;
 
-               for (unsigned i = 0; i < block->predecessors_count; i++) {
+               set_foreach(block->predecessors, entry) {
+                       struct ir3_block *pred = (struct ir3_block *)entry->key;
                        unsigned n;
 
-                       n = distance(block->predecessors[i], instr, min, pred);
+                       n = distance(pred, instr, min, pred);
 
                        min = MIN2(min, n);
                }
@@ -880,8 +881,9 @@ sched_intra_block(struct ir3_sched_ctx *ctx, struct ir3_block *block)
        list_for_each_entry_safe (struct ir3_instruction, instr, &block->instr_list, node) {
                unsigned delay = 0;
 
-               for (unsigned i = 0; i < block->predecessors_count; i++) {
-                       unsigned d = delay_calc(block->predecessors[i], instr, false, true);
+               set_foreach(block->predecessors, entry) {
+                       struct ir3_block *pred = (struct ir3_block *)entry->key;
+                       unsigned d = delay_calc(pred, instr, false, true);
                        delay = MAX2(d, delay);
                }