From 06bc4875fff8ad144dbebebe53241da4655aecc6 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Fri, 28 Jun 2019 07:30:35 -0700 Subject: [PATCH] freedreno/ir3: convert block->predecessors to set Signed-off-by: Rob Clark Reviewed-by: Eric Anholt --- src/freedreno/ir3/ir3.h | 4 ++-- src/freedreno/ir3/ir3_compiler_nir.c | 8 ++------ src/freedreno/ir3/ir3_legalize.c | 5 +++-- src/freedreno/ir3/ir3_print.c | 10 ++++++---- src/freedreno/ir3/ir3_sched.c | 10 ++++++---- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h index 872a6fb..50c9b70 100644 --- a/src/freedreno/ir3/ir3.h +++ b/src/freedreno/ir3/ir3.h @@ -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; diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 3c58496..0e54911 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -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; diff --git a/src/freedreno/ir3/ir3_legalize.c b/src/freedreno/ir3/ir3_legalize.c index ae5547b..e46d121 100644 --- a/src/freedreno/ir3/ir3_legalize.c +++ b/src/freedreno/ir3/ir3_legalize.c @@ -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 diff --git a/src/freedreno/ir3/ir3_print.c b/src/freedreno/ir3/ir3_print.c index b69941d..cc6572d 100644 --- a/src/freedreno/ir3/ir3_print.c +++ b/src/freedreno/ir3/ir3_print.c @@ -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"); } diff --git a/src/freedreno/ir3/ir3_sched.c b/src/freedreno/ir3/ir3_sched.c index f027d7b..a311956 100644 --- a/src/freedreno/ir3/ir3_sched.c +++ b/src/freedreno/ir3/ir3_sched.c @@ -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); } -- 2.7.4