[Mesa-dev] [PATCH 7/7] nir: add helper macros for running NIR passes

Rob Clark robdclark at gmail.com
Sun Oct 25 05:58:29 PDT 2015


On Sun, Oct 25, 2015 at 8:05 AM, Erik Faye-Lund <kusmabite at gmail.com> wrote:
> On Sat, Oct 24, 2015 at 7:08 PM, Rob Clark <robdclark at gmail.com> wrote:
>> From: Rob Clark <robclark at freedesktop.org>
>>
>> +#define NIR_PASS_PROGRESS(pass, nir, ...) ({               \
>> +      assert(nir_shader_is_mutable(nir));                  \
>> +      bool __ret = pass(nir, ##__VA_ARGS__);               \
>> +      nir_validate_shader(nir);                            \
>> +      if (__nir_test_clone()) {                            \
>> +         nir = nir_shader_clone(ralloc_parent(nir), nir);  \
>> +         nir_validate_shader(nir);                         \
>> +      }                                                    \
>> +      __ret;                                               \
>> +   })
>> +
> <snip>0
>> +      progress |= NIR_PASS_PROGRESS(nir_copy_prop, nir);
>
> This does not generate valid C code, but rather what looks like a GCC
> extension. Is that really a good move?

hmm, bleh.. it's used a lot in linux kernel, but it is a GNU C extension:

https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html

well, I guess at least llvm must support it (since I've heard of
people building linux kernel w/ llvm), no idea about MSVC.  If it is
supported by MSVC, then maybe we could use it?  Or is there any other
compiler people use that doesn't?  It sure is a nice extension for
macros..

BR,
-R


More information about the mesa-dev mailing list