nir: Create function parameters in function_impl_create
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 15 Feb 2016 05:42:34 +0000 (21:42 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 12 Mar 2016 23:48:36 +0000 (15:48 -0800)
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/compiler/nir/nir.c

index 2242317..cd78475 100644 (file)
@@ -300,6 +300,26 @@ nir_function_impl_create(nir_function *function)
    function->impl = impl;
    impl->function = function;
 
+   impl->num_params = function->num_params;
+   impl->params = ralloc_array(function->shader,
+                               nir_variable *, impl->num_params);
+
+   for (unsigned i = 0; i < impl->num_params; i++) {
+      impl->params[i] = rzalloc(function->shader, nir_variable);
+      impl->params[i]->type = function->params[i].type;
+      impl->params[i]->data.mode = nir_var_param;
+      impl->params[i]->data.location = i;
+   }
+
+   if (!glsl_type_is_void(function->return_type)) {
+      impl->return_var = rzalloc(function->shader, nir_variable);
+      impl->return_var->type = function->return_type;
+      impl->return_var->data.mode = nir_var_param;
+      impl->return_var->data.location = -1;
+   } else {
+      impl->return_var = NULL;
+   }
+
    return impl;
 }