#include "util/bitscan.h"
#include "util/list.h"
+#include "util/set.h"
#include "util/u_debug.h"
#include "instr-a3xx.h"
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;
{
struct ir3_block *block;
struct hash_entry *hentry;
- unsigned i;
hentry = _mesa_hash_table_search(ctx->block_ht, nblock);
if (hentry)
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;
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
{
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");
}
/* (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);
}
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);
}