diff options
author | Matt Turner <[email protected]> | 2014-07-12 21:16:34 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2014-08-22 10:23:33 -0700 |
commit | dc527fbf7da580f256c318756f43af3be59d2a77 (patch) | |
tree | 0fa2edb7642cdd065348ed868befee07eccf252b | |
parent | 240adc13464af4ad59fb532a705713e06bdc12d9 (diff) |
i965: Add a basic-block aware backend_instruction::remove method.
Reviewed-by: Topi Pohjolainen <[email protected]>
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_shader.cpp | 46 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_shader.h | 4 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 28db29ac076..464790af9dd 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -732,6 +732,52 @@ backend_instruction::has_side_effects() const } } +#ifndef NDEBUG +static bool +inst_is_in_block(const bblock_t *block, const backend_instruction *inst) +{ + bool found = false; + foreach_inst_in_block (backend_instruction, i, block) { + if (inst == i) { + found = true; + } + } + return found; +} +#endif + +static void +adjust_later_block_ips(bblock_t *start_block, int ip_adjustment) +{ + for (bblock_t *block_iter = (bblock_t *)start_block->link.next; + !block_iter->link.is_tail_sentinel(); + block_iter = (bblock_t *)block_iter->link.next) { + block_iter->start_ip += ip_adjustment; + block_iter->end_ip += ip_adjustment; + } +} + +void +backend_instruction::remove(bblock_t *block) +{ + assert(inst_is_in_block(block, this) || !"Instruction not in block"); + + adjust_later_block_ips(block, -1); + + if (block->start_ip == block->end_ip) { + block->cfg->remove_block(block); + } else { + block->end_ip--; + + if (block->start == this) + block->start = (backend_instruction *)this->next; + if (block->end == this) + block->end = (backend_instruction *)this->prev; + } + + exec_node::remove(); +} + void backend_visitor::dump_instructions() { diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h index 5980cf0cd68..f5af4fd44e1 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.h +++ b/src/mesa/drivers/dri/i965/brw_shader.h @@ -78,6 +78,7 @@ struct backend_reg }; struct cfg_t; +struct bblock_t; #ifdef __cplusplus struct backend_instruction : public exec_node { @@ -89,6 +90,9 @@ struct backend_instruction : public exec_node { bool reads_accumulator_implicitly() const; bool writes_accumulator_implicitly(struct brw_context *brw) const; + using exec_node::remove; + void remove(bblock_t *block); + /** * True if the instruction has side effects other than writing to * its destination registers. You are expected not to reorder or |