[Mesa-dev] [PATCH 3/8] glsl: Fold implementation of ir_dereference_variable::constant_referenced into wrapper

Pohjolainen, Topi topi.pohjolainen at intel.com
Thu Mar 13 03:30:14 PDT 2014


On Wed, Mar 12, 2014 at 03:49:22PM -0700, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/glsl/ir_constant_expression.cpp | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
> index 4149a0e..c013dfd 100644
> --- a/src/glsl/ir_constant_expression.cpp
> +++ b/src/glsl/ir_constant_expression.cpp
> @@ -400,6 +400,12 @@ constant_referenced(const ir_dereference *deref,
>                      struct hash_table *variable_context,
>                      ir_constant *&store, int &offset)
>  {
> +   store = NULL;
> +   offset = 0;
> +
> +   if (variable_context == NULL)
> +      return false;
> +
>     switch (deref->ir_type) {
>     case ir_type_dereference_array:
>        ((ir_dereference_array *) deref)->constant_referenced(variable_context,
> @@ -411,15 +417,16 @@ constant_referenced(const ir_dereference *deref,
>                                                               store, offset);
>        break;
>  
> -   case ir_type_dereference_variable:
> -      ((ir_dereference_variable *) deref)->constant_referenced(variable_context,
> -                                                               store, offset);
> +   case ir_type_dereference_variable: {
> +      const ir_dereference_variable *const dv =
> +         (const ir_dereference_variable *) deref;

I was wondering why you introduced the explicit braces here as the surrounding
cases do not have them. But this is in order for the compiler to allow the
introduction of the new stack variable, right?

> +
> +      store = (ir_constant *) hash_table_find(variable_context, dv->var);
>        break;
> +   }
>  
>     default:
>        assert(!"Should not get here.");
> -      store = NULL;
> -      offset = 0;
>        break;
>     }
>  
> @@ -430,13 +437,7 @@ void
>  ir_dereference_variable::constant_referenced(struct hash_table *variable_context,
>  					     ir_constant *&store, int &offset) const
>  {
> -   if (variable_context) {
> -      store = (ir_constant *)hash_table_find(variable_context, var);
> -      offset = 0;
> -   } else {
> -      store = NULL;
> -      offset = 0;
> -   }
> +   ::constant_referenced(this, variable_context, store, offset);
>  }
>  
>  void
> -- 
> 1.8.1.4
> 
> _______________________________________________
> 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