[Mesa-dev] [PATCH 03/21] nir: Add a helper for creating a "bare" nir_function_impl

Jordan Justen jordan.l.justen at intel.com
Sun Feb 14 04:43:34 UTC 2016


On 2016-02-13 18:14:20, Jason Ekstrand wrote:
> ---
>  src/compiler/nir/nir.c | 32 ++++++++++++++++++++++----------
>  src/compiler/nir/nir.h |  2 ++
>  2 files changed, 24 insertions(+), 10 deletions(-)
> 
> diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
> index acb2692..0e4d981 100644
> --- a/src/compiler/nir/nir.c
> +++ b/src/compiler/nir/nir.c
> @@ -258,16 +258,11 @@ cf_init(nir_cf_node *node, nir_cf_node_type type)
>  }
>  
>  nir_function_impl *
> -nir_function_impl_create(nir_function *function)
> +nir_function_impl_create_bare(nir_shader *shader)
>  {
> -   assert(function->impl == NULL);
> -
> -   void *mem_ctx = ralloc_parent(function);
> +   nir_function_impl *impl = ralloc(shader, nir_function_impl);
>  
> -   nir_function_impl *impl = ralloc(mem_ctx, nir_function_impl);
> -
> -   function->impl = impl;
> -   impl->function = function;
> +   impl->function = NULL;
>  
>     cf_init(&impl->cf_node, nir_cf_node_function);
>  
> @@ -282,8 +277,8 @@ nir_function_impl_create(nir_function *function)
>     impl->valid_metadata = nir_metadata_none;
>  
>     /* create start & end blocks */
> -   nir_block *start_block = nir_block_create(mem_ctx);
> -   nir_block *end_block = nir_block_create(mem_ctx);
> +   nir_block *start_block = nir_block_create(shader);
> +   nir_block *end_block = nir_block_create(shader);
>     start_block->cf_node.parent = &impl->cf_node;
>     end_block->cf_node.parent = &impl->cf_node;
>     impl->end_block = end_block;
> @@ -295,6 +290,23 @@ nir_function_impl_create(nir_function *function)
>     return impl;
>  }
>  
> +nir_function_impl *
> +nir_function_impl_create(nir_function *function)
> +{
> +   assert(function->impl == NULL);
> +
> +   nir_function_impl *impl = nir_function_impl_create_bare(function->shader);
> +
> +   function->impl = impl;
> +   impl->function = function;
> +
> +   impl->num_params = function->num_params;
> +   impl->params = ralloc_array(function->shader,
> +                               nir_variable *, impl->num_params);

Initializing num_params & params is new in nir_function_impl_create as
of this change, right? It's not mentioned in the commit message...

-Jordan

> +
> +   return impl;
> +}
> +
>  nir_block *
>  nir_block_create(nir_shader *shader)
>  {
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index ef3b79e..ff09075 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -1732,6 +1732,8 @@ nir_variable *nir_local_variable_create(nir_function_impl *impl,
>  nir_function *nir_function_create(nir_shader *shader, const char *name);
>  
>  nir_function_impl *nir_function_impl_create(nir_function *func);
> +/** creates a function_impl that isn't tied to any particular function */
> +nir_function_impl *nir_function_impl_create_bare(nir_shader *shader);
>  
>  nir_block *nir_block_create(nir_shader *shader);
>  nir_if *nir_if_create(nir_shader *shader);
> -- 
> 2.5.0.400.gff86faf
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list