freedreno/ir3: track block predecessors
authorRob Clark <robdclark@gmail.com>
Wed, 31 Jan 2018 17:58:05 +0000 (12:58 -0500)
committerRob Clark <robdclark@gmail.com>
Sat, 10 Feb 2018 19:54:58 +0000 (14:54 -0500)
Useful in the following patches.

Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/ir3/ir3.h
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c

index 776239707c771579729f89d9fa0fcde4bc9cb009..dd13e3238000440cbc0bad6885fae0b551a3e8a3 100644 (file)
@@ -476,7 +476,7 @@ struct ir3_block {
        struct list_head node;
        struct ir3 *shader;
 
-       nir_block *nblock;
+       const nir_block *nblock;
 
        struct list_head instr_list;  /* list of ir3_instruction */
 
@@ -487,6 +487,9 @@ struct ir3_block {
        struct ir3_instruction *condition;
        struct ir3_block *successors[2];
 
+       unsigned predecessors_count;
+       struct ir3_block **predecessors;
+
        uint16_t start_ip, end_ip;
 
        /* Track instructions which do not write a register but other-
index 9cbf9ce47f15c46bad24a801b9b4c02375878683..1036d2f967c3e7fa2b2193bc4efaaf43ee3e9ad0 100644 (file)
@@ -138,7 +138,7 @@ static unsigned pointer_size(struct ir3_context *ctx)
 }
 
 static struct ir3_instruction * create_immed(struct ir3_block *block, uint32_t val);
-static struct ir3_block * get_block(struct ir3_context *ctx, nir_block *nblock);
+static struct ir3_block * get_block(struct ir3_context *ctx, const nir_block *nblock);
 
 
 static struct ir3_context *
@@ -2658,18 +2658,29 @@ emit_instr(struct ir3_context *ctx, nir_instr *instr)
 }
 
 static struct ir3_block *
-get_block(struct ir3_context *ctx, nir_block *nblock)
+get_block(struct ir3_context *ctx, const nir_block *nblock)
 {
        struct ir3_block *block;
-       struct hash_entry *entry;
-       entry = _mesa_hash_table_search(ctx->block_ht, nblock);
-       if (entry)
-               return entry->data;
+       struct hash_entry *hentry;
+       struct set_entry *sentry;
+       unsigned i;
+
+       hentry = _mesa_hash_table_search(ctx->block_ht, nblock);
+       if (hentry)
+               return hentry->data;
 
        block = ir3_block_create(ctx->ir);
        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;
+       set_foreach(nblock->predecessors, sentry) {
+               block->predecessors[i++] = get_block(ctx, sentry->key);
+       }
+
        return block;
 }
 
@@ -2786,6 +2797,10 @@ emit_stream_out(struct ir3_context *ctx)
         */
        orig_end_block = ctx->block;
 
+// TODO these blocks need to update predecessors..
+// maybe w/ store_global intrinsic, we could do this
+// stuff in nir->nir pass
+
        stream_out_block = ir3_block_create(ir);
        list_addtail(&stream_out_block->node, &ir->block_list);