diff --git a/src/intel/compiler/brw_builder.h b/src/intel/compiler/brw_builder.h index a63a34a78e3..947513f6bc3 100644 --- a/src/intel/compiler/brw_builder.h +++ b/src/intel/compiler/brw_builder.h @@ -362,7 +362,7 @@ public: #endif if (block) - static_cast(cursor)->insert_before(block, inst); + block->insert_before(inst, cursor); else cursor->insert_before(inst); diff --git a/src/intel/compiler/brw_cfg.cpp b/src/intel/compiler/brw_cfg.cpp index b4702dbc7ca..6b9fa46b075 100644 --- a/src/intel/compiler/brw_cfg.cpp +++ b/src/intel/compiler/brw_cfg.cpp @@ -77,6 +77,42 @@ bblock_t::add_successor(void *mem_ctx, bblock_t *successor, children.push_tail(::link(mem_ctx, successor, kind)); } +void +bblock_t::insert_before(brw_inst *inst, exec_node *ref) +{ + assert(inst != ref); + assert(!inst->block || inst->block == this); + + num_instructions++; + cfg->total_instructions++; + + ref->exec_node::insert_before(inst); + inst->block = this; +} + +void +bblock_t::remove(brw_inst *inst) +{ + if (exec_list_is_singular(&instructions)) { + inst->opcode = BRW_OPCODE_NOP; + inst->resize_sources(0); + inst->dst = brw_reg(); + inst->size_written = 0; + return; + } + + assert(num_instructions > 0); + assert(cfg->total_instructions > 0); + num_instructions--; + cfg->total_instructions--; + + inst->exec_node::remove(); + inst->block = NULL; + + if (num_instructions == 0) + cfg->remove_block(this); +} + static void append_inst(bblock_t *block, brw_inst *inst) { diff --git a/src/intel/compiler/brw_cfg.h b/src/intel/compiler/brw_cfg.h index 7ffa8ea80e4..17f37460d66 100644 --- a/src/intel/compiler/brw_cfg.h +++ b/src/intel/compiler/brw_cfg.h @@ -94,6 +94,9 @@ struct bblock_t { brw_inst *last_non_control_flow_inst(); + void insert_before(brw_inst *inst, exec_node *ref); + void remove(brw_inst *inst); + struct exec_node link; struct cfg_t *cfg; diff --git a/src/intel/compiler/brw_inst.cpp b/src/intel/compiler/brw_inst.cpp index 2b1ee63d9c2..c378f25d847 100644 --- a/src/intel/compiler/brw_inst.cpp +++ b/src/intel/compiler/brw_inst.cpp @@ -962,43 +962,11 @@ brw_inst::is_volatile() const opcode == SHADER_OPCODE_SEND_GATHER) && send_is_volatile); } -void -brw_inst::insert_before(bblock_t *block, brw_inst *inst) -{ - assert(this != inst); - - assert(!inst->block || inst->block == block); - - exec_node::insert_before(inst); - - inst->block = block; - inst->block->num_instructions++; - inst->block->cfg->total_instructions++; -} - void brw_inst::remove() { assert(block); - - if (exec_list_is_singular(&block->instructions)) { - this->opcode = BRW_OPCODE_NOP; - this->resize_sources(0); - this->dst = brw_reg(); - this->size_written = 0; - return; - } - - assert(block->num_instructions > 0); - assert(block->cfg->total_instructions > 0); - block->num_instructions--; - block->cfg->total_instructions--; - - if (block->num_instructions == 0) - block->cfg->remove_block(block); - - exec_node::remove(); - block = NULL; + block->remove(this); } enum brw_reg_type diff --git a/src/intel/compiler/brw_inst.h b/src/intel/compiler/brw_inst.h index 30b2b9d8624..30d641907ef 100644 --- a/src/intel/compiler/brw_inst.h +++ b/src/intel/compiler/brw_inst.h @@ -92,7 +92,6 @@ public: bool uses_indirect_addressing() const; void remove(); - void insert_before(bblock_t *block, brw_inst *inst); /** * True if the instruction has side effects other than writing to