[Mesa-dev] [PATCH 10/20] i965: Add a basic-block aware backend_instruction::remove method.

Pohjolainen, Topi topi.pohjolainen at intel.com
Tue Aug 5 10:31:25 PDT 2014


On Thu, Jul 24, 2014 at 07:54:17PM -0700, Matt Turner wrote:
> ---
>  src/mesa/drivers/dri/i965/brw_cfg.h      |  1 +
>  src/mesa/drivers/dri/i965/brw_shader.cpp | 32 ++++++++++++++++++++++++++++++++
>  src/mesa/drivers/dri/i965/brw_shader.h   |  4 ++++
>  3 files changed, 37 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h
> index 35ee29a..e1ec43b 100644
> --- a/src/mesa/drivers/dri/i965/brw_cfg.h
> +++ b/src/mesa/drivers/dri/i965/brw_cfg.h
> @@ -64,6 +64,7 @@ struct bblock_t {
>  #endif
>  
>     struct exec_node link;
> +   struct cfg_t *cfg;

This is needed already in patch number 9.

>  
>     struct backend_instruction *start;
>     struct backend_instruction *end;
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
> index 0deb090..47535a9 100644
> --- a/src/mesa/drivers/dri/i965/brw_shader.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
> @@ -740,6 +740,38 @@ backend_instruction::has_side_effects() const
>  }
>  
>  void
> +backend_instruction::remove(bblock_t *block)
> +{
> +   bool found = false; (void) found;
> +   foreach_inst_in_block (backend_instruction, i, block) {
> +      if (this == i) {
> +         found = true;
> +      }
> +   }
> +   assert(found || !"Instruction not in block");
> +
> +   for (bblock_t *block_iter = (bblock_t *)block->link.next;
> +        !block_iter->link.is_tail_sentinel();
> +        block_iter = (bblock_t *)block_iter->link.next) {
> +      block_iter->start_ip--;
> +      block_iter->end_ip--;
> +   }
> +
> +   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;
> +   }
> +
> +   this->remove();
> +}
> +
> +void
>  backend_visitor::dump_instructions()
>  {
>     dump_instructions(NULL);
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
> index 40689eb..4b80ea9 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
> -- 
> 1.8.5.5
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list