pan/mdg: Deduplicate nir_find_variable_with_driver_location

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7446>
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index acbf296..8c64151 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -210,17 +210,6 @@
                                             NULL);
 }
 
-static const nir_variable *
-search_var(nir_shader *nir, nir_variable_mode mode, unsigned driver_loc)
-{
-        nir_foreach_variable_with_modes(var, nir, mode) {
-                if (var->data.driver_location == driver_loc)
-                        return var;
-        }
-
-        return NULL;
-}
-
 /* Midgard can write all of color, depth and stencil in a single writeout
  * operation, so we merge depth/stencil stores with color stores.
  * If there are no color stores, we add a write to the "depth RT".
@@ -284,7 +273,7 @@
                                 if (intr->intrinsic != nir_intrinsic_store_output)
                                         continue;
 
-                                const nir_variable *var = search_var(nir, nir_var_shader_out, nir_intrinsic_base(intr));
+                                const nir_variable *var = nir_find_variable_with_driver_location(nir, nir_var_shader_out, nir_intrinsic_base(intr));
                                 assert(var);
 
                                 if (var->data.location != FRAG_RESULT_COLOR &&
@@ -423,7 +412,7 @@
                                 if (intr->intrinsic != nir_intrinsic_store_output)
                                         continue;
 
-                                const nir_variable *var = search_var(nir, nir_var_shader_out, nir_intrinsic_base(intr));
+                                const nir_variable *var = nir_find_variable_with_driver_location(nir, nir_var_shader_out, nir_intrinsic_base(intr));
 
                                 if (var->data.index) {
                                         if (!last_writeout)
@@ -1678,7 +1667,7 @@
                 return ctx->blend_rt;
 
         const nir_variable *var;
-        var = search_var(ctx->nir, nir_var_shader_out, nir_intrinsic_base(instr));
+        var = nir_find_variable_with_driver_location(ctx->nir, nir_var_shader_out, nir_intrinsic_base(instr));
         assert(var);
 
         unsigned loc = var->data.location;
@@ -1884,7 +1873,7 @@
                                 nir_intrinsic_store_combined_output_pan;
 
                         const nir_variable *var;
-                        var = search_var(ctx->nir, nir_var_shader_out,
+                        var = nir_find_variable_with_driver_location(ctx->nir, nir_var_shader_out,
                                          nir_intrinsic_base(instr));
                         assert(var);