i965/cfg: Embed link in bblock_t for main block list.
authorMatt Turner <mattst88@gmail.com>
Fri, 11 Jul 2014 23:17:47 +0000 (16:17 -0700)
committerMatt Turner <mattst88@gmail.com>
Tue, 19 Aug 2014 01:56:30 +0000 (18:56 -0700)
The next patch adds a foreach_block (block, cfg) macro, which works
better if it provides a direct bblock_t pointer, rather than a
bblock_link pointer that you have to use to find the actual block.

Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_cfg.cpp
src/mesa/drivers/dri/i965/brw_cfg.h

index 07111f5ac42bc067f0d1017580a0948a6b549a87..4a5c912daf858a8395e769285c01884aaf0f08ea 100644 (file)
@@ -67,8 +67,8 @@ bblock_t::bblock_t() :
 void
 bblock_t::add_successor(void *mem_ctx, bblock_t *successor)
 {
-   successor->parents.push_tail(link(mem_ctx, this));
-   children.push_tail(link(mem_ctx, successor));
+   successor->parents.push_tail(::link(mem_ctx, this));
+   children.push_tail(::link(mem_ctx, successor));
 }
 
 void
@@ -285,7 +285,7 @@ cfg_t::set_next_block(bblock_t **cur, bblock_t *block, int ip)
 
    block->start_ip = ip;
    block->block_num = num_blocks++;
-   block_list.push_tail(link(mem_ctx, block));
+   block_list.push_tail(&block->link);
    *cur = block;
 }
 
@@ -295,8 +295,8 @@ cfg_t::make_block_array()
    blocks = ralloc_array(mem_ctx, bblock_t *, num_blocks);
 
    int i = 0;
-   foreach_list_typed(bblock_link, link, link, &block_list) {
-      blocks[i++] = link->block;
+   foreach_list_typed(bblock_t, block, link, &block_list) {
+      blocks[i++] = block;
    }
    assert(i == num_blocks);
 }
index 01fcc1befdc8150c4920697c7711028b8228e36a..324df6caf6c888b434a0429edc4d80ec980b409e 100644 (file)
@@ -61,6 +61,8 @@ struct bblock_t {
    void dump(backend_visitor *v);
 #endif
 
+   struct exec_node link;
+
    struct backend_instruction *start;
    struct backend_instruction *end;