diff options
author | Matt Turner <[email protected]> | 2014-05-12 14:40:40 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2014-05-15 15:45:40 -0700 |
commit | 58bcf5996dc60043eee5946a6f2f96256768fc9f (patch) | |
tree | a188741f3a9bd7c43ca83d1eeca5540125736a1b /src/mesa/drivers/dri/i965/brw_cfg.cpp | |
parent | a77023c992fa37c609be56869c1bb5c00ec294b9 (diff) |
i965/cfg: Embed exec_node in bblock_link.
In order to remove bblock_link's inheritance of exec_node. Also makes
linked list walk code much nicer.
Acked-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_cfg.cpp')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_cfg.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp index 53281c6faa0..a806714c203 100644 --- a/src/mesa/drivers/dri/i965/brw_cfg.cpp +++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp @@ -38,11 +38,18 @@ pop_stack(exec_list *list) { bblock_link *link = (bblock_link *)list->get_tail(); bblock_t *block = link->block; - link->remove(); + link->link.remove(); return block; } +static exec_node * +link(void *mem_ctx, bblock_t *block) +{ + bblock_link *l = new(mem_ctx) bblock_link(block); + return &l->link; +} + bblock_t::bblock_t() : start_ip(0), end_ip(0), block_num(0) { @@ -60,8 +67,8 @@ bblock_t::bblock_t() : void bblock_t::add_successor(void *mem_ctx, bblock_t *successor) { - successor->parents.push_tail(new(mem_ctx) bblock_link(this)); - children.push_tail(new(mem_ctx) bblock_link(successor)); + successor->parents.push_tail(link(mem_ctx, this)); + children.push_tail(link(mem_ctx, successor)); } void @@ -113,8 +120,8 @@ cfg_t::cfg_t(exec_list *instructions) /* Push our information onto a stack so we can recover from * nested ifs. */ - if_stack.push_tail(new(mem_ctx) bblock_link(cur_if)); - else_stack.push_tail(new(mem_ctx) bblock_link(cur_else)); + if_stack.push_tail(link(mem_ctx, cur_if)); + else_stack.push_tail(link(mem_ctx, cur_else)); cur_if = cur; cur_else = NULL; @@ -190,8 +197,8 @@ cfg_t::cfg_t(exec_list *instructions) /* Push our information onto a stack so we can recover from * nested loops. */ - do_stack.push_tail(new(mem_ctx) bblock_link(cur_do)); - while_stack.push_tail(new(mem_ctx) bblock_link(cur_while)); + do_stack.push_tail(link(mem_ctx, cur_do)); + while_stack.push_tail(link(mem_ctx, cur_while)); /* Set up the block just after the while. Don't know when exactly * it will start, yet. @@ -275,7 +282,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(new(mem_ctx) bblock_link(block)); + block_list.push_tail(link(mem_ctx, block)); *cur = block; } @@ -285,8 +292,7 @@ cfg_t::make_block_array() blocks = ralloc_array(mem_ctx, bblock_t *, num_blocks); int i = 0; - foreach_list(block_node, &block_list) { - bblock_link *link = (bblock_link *)block_node; + foreach_list_typed(bblock_link, link, link, &block_list) { blocks[i++] = link->block; } assert(i == num_blocks); @@ -298,16 +304,14 @@ cfg_t::dump(backend_visitor *v) for (int b = 0; b < this->num_blocks; b++) { bblock_t *block = this->blocks[b]; fprintf(stderr, "START B%d", b); - foreach_list(node, &block->parents) { - bblock_link *link = (bblock_link *)node; + foreach_list_typed(bblock_link, link, link, &block->parents) { fprintf(stderr, " <-B%d", link->block->block_num); } fprintf(stderr, "\n"); block->dump(v); fprintf(stderr, "END B%d", b); - foreach_list(node, &block->children) { - bblock_link *link = (bblock_link *)node; + foreach_list_typed(bblock_link, link, link, &block->children) { fprintf(stderr, " ->B%d", link->block->block_num); } |