JIT patch: add gcc_jit_magic_int

Basile Starynkevitch basile@starynkevitch.net
Fri Jun 10 12:11:00 GMT 2016


On 06/07/2016 09:19 PM, Andrew Pinski wrote:
> On Mon, May 23, 2016 at 5:26 AM, Basile Starynkevitch
> <basile@starynkevitch.net> wrote:
>> Hello All,
>>
>> As I explained in https://gcc.gnu.org/ml/jit/2016-q2/msg00042.html it is
>> difficult (or tricky without using dirty tricks involving the GCC plugin
>> headers) to use GCCJIT to emit code equivalent to the following C file:
>>
>>     extern int a;
>>     int get_atomic_a (void) {
>>       return __atomic_load_n (&a, __ATOMIC_SEQ_CST);
>>     }
>>
>> The issue is that __ATOMIC_SEQ_CST is a magic preprocessor (but
>> non-standard!) symbol which might not be available
>> (or might have a different value) in the C code for GCCJIT building such an
>> AST.
>> So we need a function to retrieve some magic integral value from the GCCJIT
>> compiler.
> Huh?    Why can't you just use the enum:
> enum memmodel
> {
>    MEMMODEL_RELAXED = 0,
>    MEMMODEL_CONSUME = 1,
>    MEMMODEL_ACQUIRE = 2,
>    MEMMODEL_RELEASE = 3,
>    MEMMODEL_ACQ_REL = 4,
>    MEMMODEL_SEQ_CST = 5,
>    MEMMODEL_LAST = 6,
>    MEMMODEL_SYNC_ACQUIRE = MEMMODEL_ACQUIRE | MEMMODEL_SYNC,
>    MEMMODEL_SYNC_RELEASE = MEMMODEL_RELEASE | MEMMODEL_SYNC,
>    MEMMODEL_SYNC_SEQ_CST = MEMMODEL_SEQ_CST | MEMMODEL_SYNC
> };
>

(sorry for the late reply)

I think that Andrew Pinski is right, and that we should make that enum 
available in libgccjit.h.

David Malcolm, please tell us how should that be done? Would you accept 
a #include "coretypes.h" inside libgccjit.h? Or should I copy paste the 
enum memmodel into libgccjit.h?

Cheers.


-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***



More information about the Gcc-patches mailing list