vc4: Convert to use nir_foreach_function_impl when possible
authorYonggang Luo <luoyonggang@gmail.com>
Thu, 29 Jun 2023 18:54:48 +0000 (02:54 +0800)
committerMarge Bot <emma+marge@anholt.net>
Tue, 4 Jul 2023 10:47:26 +0000 (10:47 +0000)
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23988>

src/gallium/drivers/vc4/vc4_nir_lower_blend.c
src/gallium/drivers/vc4/vc4_nir_lower_io.c
src/gallium/drivers/vc4/vc4_program.c

index e2da995..e90a57e 100644 (file)
@@ -598,16 +598,14 @@ vc4_nir_lower_blend_block(nir_block *block, struct vc4_compile *c)
 void
 vc4_nir_lower_blend(nir_shader *s, struct vc4_compile *c)
 {
-        nir_foreach_function(function, s) {
-                if (function->impl) {
-                        nir_foreach_block(block, function->impl) {
-                                vc4_nir_lower_blend_block(block, c);
-                        }
-
-                        nir_metadata_preserve(function->impl,
-                                              nir_metadata_block_index |
-                                              nir_metadata_dominance);
+        nir_foreach_function_impl(impl, s) {
+                nir_foreach_block(block, impl) {
+                        vc4_nir_lower_blend_block(block, c);
                 }
+
+                nir_metadata_preserve(impl,
+                                      nir_metadata_block_index |
+                                      nir_metadata_dominance);
         }
 
         /* If we didn't do alpha-to-coverage on the output color, we still
index 75cf04a..74419bf 100644 (file)
@@ -372,8 +372,7 @@ vc4_nir_lower_io_impl(struct vc4_compile *c, nir_function_impl *impl)
 void
 vc4_nir_lower_io(nir_shader *s, struct vc4_compile *c)
 {
-        nir_foreach_function(function, s) {
-                if (function->impl)
-                        vc4_nir_lower_io_impl(c, function->impl);
+        nir_foreach_function_impl(impl, s) {
+                vc4_nir_lower_io_impl(c, impl);
         }
 }
index c3df853..4bc8b91 100644 (file)
@@ -2200,10 +2200,8 @@ static int
 count_nir_instrs(nir_shader *nir)
 {
         int count = 0;
-        nir_foreach_function(function, nir) {
-                if (!function->impl)
-                        continue;
-                nir_foreach_block(block, function->impl) {
+        nir_foreach_function_impl(impl, nir) {
+                nir_foreach_block(block, impl) {
                         nir_foreach_instr(instr, block)
                                 count++;
                 }