freedreno/ir3: convert block->predecessors to set

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
Rob Clark 2019-06-28 07:30:35 -07:00 committed by Eric Anholt
parent cfbde3282d
commit 06bc4875ff
5 changed files with 19 additions and 18 deletions

View 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;

View 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;

View 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

View 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");
}

View 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);
}