nir/print: Better function argument printing
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 13 Feb 2016 04:41:19 +0000 (20:41 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 12 Mar 2016 23:48:36 +0000 (15:48 -0800)
Since we aren't going to put the function parameters or the return variable
in the list of locals, it won't get a proper declaration.  This changes
nir_print to print the type along with each parameter or return variable.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/compiler/nir/nir_print.c

index 85799d64ec87c7ae948744c25329a278903e6715..bdfbd2600c030f6fc47b1537715c716311e3022d 100644 (file)
@@ -379,6 +379,14 @@ print_var(nir_variable *var, print_state *state)
    fprintf(fp, "%s", get_var_name(var, state));
 }
 
+static void
+print_arg(nir_variable *var, print_state *state)
+{
+   FILE *fp = state->fp;
+   glsl_print_type(var->type, fp);
+   fprintf(fp, " %s", get_var_name(var, state));
+}
+
 static void
 print_deref_var(nir_deref_var *deref, print_state *state)
 {
@@ -938,14 +946,14 @@ print_function_impl(nir_function_impl *impl, print_state *state)
       if (i != 0)
          fprintf(fp, ", ");
 
-      print_var(impl->params[i], state);
+      print_arg(impl->params[i], state);
    }
 
    if (impl->return_var != NULL) {
       if (impl->num_params != 0)
          fprintf(fp, ", ");
       fprintf(fp, "returning ");
-      print_var(impl->return_var, state);
+      print_arg(impl->return_var, state);
    }
 
    fprintf(fp, "{\n");