compiler: add glsl_print_type

Move it from the glsl compiler. For debugging.

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6328>
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index e2e46ad..2ec78f7 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -2536,9 +2536,6 @@
                            struct _mesa_glsl_parse_state *state);
 
 extern void
-ir_print_type(FILE *f, const struct glsl_type *t);
-
-extern void
 fprint_ir(FILE *f, const void *instruction);
 
 extern const struct gl_builtin_uniform_desc *
diff --git a/src/compiler/glsl/ir_print_visitor.cpp b/src/compiler/glsl/ir_print_visitor.cpp
index 034ee16..7e5e644 100644
--- a/src/compiler/glsl/ir_print_visitor.cpp
+++ b/src/compiler/glsl/ir_print_visitor.cpp
@@ -59,7 +59,7 @@
 
 	 for (unsigned j = 0; j < s->length; j++) {
 	    fprintf(f, "\t((");
-	    ir_print_type(f, s->fields.structure[j].type);
+	    glsl_print_type(f, s->fields.structure[j].type);
 	    fprintf(f, ")(%s))\n", s->fields.structure[j].name);
 	 }
 
@@ -141,20 +141,6 @@
    return name;
 }
 
-extern "C" void
-ir_print_type(FILE *f, const glsl_type *t)
-{
-   if (t->is_array()) {
-      fprintf(f, "(array ");
-      ir_print_type(f, t->fields.array);
-      fprintf(f, " %u)", t->length);
-   } else if (t->is_struct() && !is_gl_identifier(t->name)) {
-      fprintf(f, "%s@%p", t->name, (void *) t);
-   } else {
-      fprintf(f, "%s", t->name);
-   }
-}
-
 void ir_print_visitor::visit(ir_rvalue *)
 {
    fprintf(f, "error");
@@ -224,7 +210,7 @@
            stream,
            interp[ir->data.interpolation], precision[ir->data.precision]);
 
-   ir_print_type(f, ir->type);
+   glsl_print_type(f, ir->type);
    fprintf(f, " %s)", unique_name(ir));
 
    if (ir->constant_initializer) {
@@ -245,7 +231,7 @@
    fprintf(f, "(signature ");
    indentation++;
 
-   ir_print_type(f, ir->return_type);
+   glsl_print_type(f, ir->return_type);
    fprintf(f, "\n");
    indent();
 
@@ -299,7 +285,7 @@
 {
    fprintf(f, "(expression ");
 
-   ir_print_type(f, ir->type);
+   glsl_print_type(f, ir->type);
 
    fprintf(f, " %s ", ir_expression_operation_strings[ir->operation]);
 
@@ -323,7 +309,7 @@
       return;
    }
 
-   ir_print_type(f, ir->type);
+   glsl_print_type(f, ir->type);
    fprintf(f, " ");
 
    ir->sampler->accept(this);
@@ -487,7 +473,7 @@
 void ir_print_visitor::visit(ir_constant *ir)
 {
    fprintf(f, "(constant ");
-   ir_print_type(f, ir->type);
+   glsl_print_type(f, ir->type);
    fprintf(f, " (");
 
    if (ir->type->is_array()) {
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index d631584..051d8e8 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -2971,4 +2971,18 @@
    }
 }
 
+void
+glsl_print_type(FILE *f, const glsl_type *t)
+{
+   if (t->is_array()) {
+      fprintf(f, "(array ");
+      glsl_print_type(f, t->fields.array);
+      fprintf(f, " %u)", t->length);
+   } else if (t->is_struct() && !is_gl_identifier(t->name)) {
+      fprintf(f, "%s@%p", t->name, (void *) t);
+   } else {
+      fprintf(f, "%s", t->name);
+   }
+}
+
 }
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index df5ca46..6a57c70 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -27,6 +27,7 @@
 
 #include <string.h>
 #include <assert.h>
+#include <stdio.h>
 
 #include "shader_enums.h"
 #include "c11/threads.h"
@@ -56,6 +57,9 @@
 extern void
 _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state);
 
+void
+glsl_print_type(FILE *f, const struct glsl_type *t);
+
 void encode_type_to_blob(struct blob *blob, const struct glsl_type *type);
 
 const struct glsl_type *decode_type_from_blob(struct blob_reader *blob);