[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wish: gcc_jit_type_get_atomic



On Thu, 2016-05-12 at 07:48 +0200, Basile Starynkevitch wrote:
> Hello all,
> 
> GCC JIT has gcc_jit_type_get_volatile to support the volatile
> qualifier.
> 
> But shouldn't it also have a gcc_jit_type_get_atomic to support the
> C11 
> _Atomic qualifier?
> http://en.cppreference.com/w/c/atomic

I looked at how the C frontend handles this, and sadly it's not trivial
to implement.

The flag in question is in tree.h:
  /* Nonzero in a type considered atomic as a whole.  */
  #define TYPE_ATOMIC(NODE) (TYPE_CHECK (NODE)->base.u.bits.atomic_flag)

c-typeck.c has build_atomic_assign, which handles assignments by
generating calls to various builtins (and various other logic).

So it's not just a matter of having the API set the flag on the type;
we would need to duplicate/refactor a lot of this c-typeck.c logic
also.

(also, looking at C's grokdeclarator, there's various validity checking
there, which would need emulating in libgccjit.c).

Client code might be able to implement it without explicit libgccjit support by generating calls to the relevant builtins "by hand".

Dave