nir: Add an internal flag to shader_info

Don't print the shader if it's marked internal, unless NIR_PRINT
has been explicitly set to 2 (or higher).

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6035>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 1741f4f..368e7be 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3937,11 +3937,14 @@
 }
 
 static inline bool
-should_print_nir(void)
+should_print_nir(nir_shader *shader)
 {
    static int should_print = -1;
    if (should_print < 0)
-      should_print = env_var_as_boolean("NIR_PRINT", false);
+      should_print = env_var_as_unsigned("NIR_PRINT", 0);
+
+   if (should_print == 1)
+      return !shader->info.internal;
 
    return should_print;
 }
@@ -3953,7 +3956,7 @@
 static inline bool should_skip_nir(UNUSED const char *pass_name) { return false; }
 static inline bool should_clone_nir(void) { return false; }
 static inline bool should_serialize_deserialize_nir(void) { return false; }
-static inline bool should_print_nir(void) { return false; }
+static inline bool should_print_nir(nir_shader *shader) { return false; }
 #endif /* NDEBUG */
 
 #define _PASS(pass, nir, do_pass) do {                               \
@@ -3974,21 +3977,21 @@
 
 #define NIR_PASS(progress, nir, pass, ...) _PASS(pass, nir,          \
    nir_metadata_set_validation_flag(nir);                            \
-   if (should_print_nir())                                           \
+   if (should_print_nir(nir))                                           \
       printf("%s\n", #pass);                                         \
    if (pass(nir, ##__VA_ARGS__)) {                                   \
       progress = true;                                               \
-      if (should_print_nir())                                        \
+      if (should_print_nir(nir))                                        \
          nir_print_shader(nir, stdout);                              \
       nir_metadata_check_validation_flag(nir);                       \
    }                                                                 \
 )
 
 #define NIR_PASS_V(nir, pass, ...) _PASS(pass, nir,                  \
-   if (should_print_nir())                                           \
+   if (should_print_nir(nir))                                           \
       printf("%s\n", #pass);                                         \
    pass(nir, ##__VA_ARGS__);                                         \
-   if (should_print_nir())                                           \
+   if (should_print_nir(nir))                                           \
       nir_print_shader(nir, stdout);                                 \
 )
 
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 23d174a..bee2847 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -98,6 +98,9 @@
    /* Descriptive name provided by the client; may be NULL */
    const char *label;
 
+   /* Shader is internal, and should be ignored by things like NIR_PRINT */
+   bool internal;
+
    /** The shader stage, such as MESA_SHADER_VERTEX. */
    gl_shader_stage stage:8;