public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Basile Starynkevitch <basile@starynkevitch.net>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	jit@gcc.gnu.org,  David Malcolm <dmalcolm@redhat.com>
Subject: Re: JIT patch: add gcc_jit_magic_int
Date: Fri, 01 Jan 2016 00:00:00 -0000	[thread overview]
Message-ID: <CA+=Sn1mSpYXpGG=zOuMq5MxxGz4WeSCT3voY1D4n85KFTiq7TA@mail.gmail.com> (raw)
In-Reply-To: <CA+=Sn1nUirNU3jqDLN20i9tcwEQk+3Sd-EZ=cRm2Rb_FA_EpLA@mail.gmail.com>

On Tue, Jun 7, 2016 at 12:22 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Tue, Jun 7, 2016 at 12:19 PM, Andrew Pinski <pinskia@gmail.com> 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
>> };
>>
>>
>> For the values?  I don't understand why you need to have a direct
>> relationship to preprocessed macros to these values here.
>> Have your own lookup table inside your own JIT rather than a generic
>> way of doing it.
>> Having a generic way seems more incorrect way of doing it and even
>> says that the JIT is supposed to JITting C code but it is not JITing C
>> code.
>
>
> That is move enum memmodel to be included in the JIT API too.

Or rather have an API which the __atomic_* for you and all you need to
supply is the the "JIT" memory model and the locations.

Thanks,
Andrew

>
>>
>> Thanks,
>> Andrew Pinski
>>
>>>
>>> The attached patch (relative to trunk svn 236583) is a first attempt to
>>> solve that issue
>>>  (and also give ability to query some other magic numbers).
>>>
>>> Proposed ChangeLog entry (in gcc/jit/)
>>>
>>> 2016-05-23  Basile Starynkevitch  <basile@starynkevitch.net>
>>>         * libgccjit.h (LIBGCCJIT_HAVE_gcc_jit_magic_int): New macro.
>>>         (gcc_jit_magic_int): New public function declaration.
>>>
>>>         * libgccjit.c: Include "cppbuiltin.h", "options.h", "flag-types.h"
>>>         (gcc_jit_magic_int): New function.
>>>
>>>         * libgccjit.map: Add gcc_jit_magic_int to LIBGCCJIT_ABI_6.
>>>
>>> Comments (or an ok to commit) are welcome. (I am not sure that
>>> __SANITIZE_ADDRESS__ is correctly handled,
>>> because I would believe that optimization flags are not globals in GCCJIT)
>>>
>>> Regards.
>>>
>>> --
>>> 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} ***
>>>

  reply	other threads:[~2016-06-07 20:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-01  0:00 Basile Starynkevitch
2016-01-01  0:00 ` David Malcolm
2016-01-01  0:00 ` Andrew Pinski
2016-01-01  0:00   ` Andrew Pinski
2016-01-01  0:00     ` Andrew Pinski [this message]
2016-01-01  0:00   ` Basile Starynkevitch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+=Sn1mSpYXpGG=zOuMq5MxxGz4WeSCT3voY1D4n85KFTiq7TA@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=basile@starynkevitch.net \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).