diff options
author | Matt Turner <[email protected]> | 2014-07-15 14:51:43 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2014-08-22 10:23:34 -0700 |
commit | 9cf06e27e1e42ad33f0c6f8dc201300d8d108169 (patch) | |
tree | 11ad6b4f3474720f65f07889eb403056023d3159 /src/mesa/drivers/dri/i965/brw_cfg.cpp | |
parent | 5e6ead5e8b0a79dce63f741dfca8328b7d4020f9 (diff) |
i965/cfg: Add functions to combine basic blocks.
Reviewed-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_cfg.cpp')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_cfg.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp index 3895469b055..8714b682be0 100644 --- a/src/mesa/drivers/dri/i965/brw_cfg.cpp +++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp @@ -92,6 +92,58 @@ bblock_t::is_successor_of(const bblock_t *block) const return false; } +static bool +ends_block(const backend_instruction *inst) +{ + enum opcode op = inst->opcode; + + return op == BRW_OPCODE_IF || + op == BRW_OPCODE_ELSE || + op == BRW_OPCODE_CONTINUE || + op == BRW_OPCODE_BREAK || + op == BRW_OPCODE_WHILE; +} + +static bool +starts_block(const backend_instruction *inst) +{ + enum opcode op = inst->opcode; + + return op == BRW_OPCODE_DO || + op == BRW_OPCODE_ENDIF; +} + +bool +bblock_t::can_combine_with(const bblock_t *that) const +{ + if ((const bblock_t *)this->link.next != that) + return false; + + if (ends_block(this->end) || + starts_block(that->start)) + return false; + + return true; +} + +void +bblock_t::combine_with(bblock_t *that) +{ + assert(this->can_combine_with(that)); + foreach_list_typed (bblock_link, link, link, &this->children) { + assert(link->block == that); + } + foreach_list_typed (bblock_link, link, link, &that->parents) { + assert(link->block == this); + } + + this->end_ip = that->end_ip; + this->end = that->end; + this->else_block = that->else_block; + + this->cfg->remove_block(that); +} + void bblock_t::dump(backend_visitor *v) { |