nir: Add nir_foreach_function_impl helper
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 22 Jun 2023 16:38:16 +0000 (12:38 -0400)
committerMarge Bot <emma+marge@anholt.net>
Tue, 27 Jun 2023 22:44:04 +0000 (22:44 +0000)
commit19daa9283c146a8c50fdc0250e73a0bc366c826b
treebc6ef3d136f13ee8c1894e85decd6fe51eb82dac
parenta8044110bf627c868cae49fc56505325c85b41bc
nir: Add nir_foreach_function_impl helper

Most users of nir_foreach_function actually want the nir_function_impl, not the
nir_function, and want to skip empty functions (though some graphics-specific
passes sometimes fail to do that part). Add a nir_foreach_function_impl macro
to make that case more ergonomic.

   nir_foreach_function_impl(impl, shader) {
      ...
      foo(impl)
   }

is equivalent to:

   nir_foreach_function(func, shader) {
      if (func->impl) {
         ...
         foo(func->impl);
      }
   }

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23807>
src/compiler/nir/nir.h