[Mesa-dev] [PATCH 1/4] nir: Avoid C99 field initializers.

Jason Ekstrand jason at jlekstrand.net
Thu Apr 28 17:43:12 UTC 2016


On Thu, Apr 28, 2016 at 8:49 AM, Jose Fonseca <jfonseca at vmware.com> wrote:

> On 28/04/16 15:37, Connor Abbott wrote:
>
>> For the series:
>>
>> Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>
>>
>> For the zero-sized array thing... we could make it a statically-sized
>> array, since we never have more than 4 arguments to an ALU
>> instruction, but that would be wasteful of memory. Also, we always
>> have at least 1 argument, so we could make the size 1 to shut up the
>> warning, but that would be more confusing and introduce undefined
>> behavior in C99 that the compiler is likely to actually take advantage
>> of. I don't see any options better than just accepting the warning
>> and/or shutting that specific warning off.
>>
>
> I feared so.  Thanks for looking into it though.
>

Can you be a bit more specific about the issues that MSVC has with
zero-length arrays?  Can it "accept nir_src src[0]" instead of "src[]"?


> Jose
>
>
>
>>
>> On Thu, Apr 28, 2016 at 7:27 AM, Jose Fonseca <jfonseca at vmware.com>
>> wrote:
>>
>>> As they are not standard C++ and are not supported by MSVC C++ compiler.
>>>
>>> Just have nir_imm_double match nir_imm_float above.
>>> ---
>>>   src/compiler/nir/nir_builder.h | 9 ++++++---
>>>   1 file changed, 6 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/src/compiler/nir/nir_builder.h
>>> b/src/compiler/nir/nir_builder.h
>>> index a14f9ef..4fa9779 100644
>>> --- a/src/compiler/nir/nir_builder.h
>>> +++ b/src/compiler/nir/nir_builder.h
>>> @@ -117,9 +117,12 @@ nir_imm_float(nir_builder *build, float x)
>>>   static inline nir_ssa_def *
>>>   nir_imm_double(nir_builder *build, double x)
>>>   {
>>> -   nir_const_value v = { { .f64 = {x, 0, 0, 0} } };
>>> -   nir_ssa_def *def = nir_build_imm(build, 1, 64, v);
>>> -   return def;
>>> +   nir_const_value v;
>>> +
>>> +   memset(&v, 0, sizeof(v));
>>> +   v.f64[0] = x;
>>> +
>>> +   return nir_build_imm(build, 1, 64, v);
>>>   }
>>>
>>>   static inline nir_ssa_def *
>>> --
>>> 2.5.0
>>>
>>>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160428/100e7696/attachment-0001.html>


More information about the mesa-dev mailing list