public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Nieper-Wißkirchen" <marc@nieper-wisskirchen.de>
To: Basile Starynkevitch <basile@starynkevitch.net>
Cc: jit@gcc.gnu.org, David Malcolm <dmalcolm@redhat.com>
Subject: Re: wish: gcc_jit_type_get_atomic
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <CAEYrNrSg=G0jHS3CnYqNHSSqQ8XmWVa4+e0P0Q7+Cyz5=gENtg@mail.gmail.com> (raw)
In-Reply-To: <573EF903.2050007@starynkevitch.net>

)Am Fr., 20. Mai 2016 um 13:46 Uhr schrieb Basile Starynkevitch
<basile@starynkevitch.net>:
>
> Hello All,
>
> In message https://gcc.gnu.org/ml/jit/2016-q2/msg00013.html David
> Malcolm nicely explained that
>
> > Client code might be able to implement it without explicit libgccjit support
> > by generating calls to the relevant builtins "by hand".
>
>
> But I am not sure to understand exactly how that can be done in (more or
> less portable)
> C code calling libgccjit-6. In particular I am thinking of coding in C
> some code which would use libgccjit-6 but would not be compiled by gcc-6
> (but some other C compiler, perhaps a future gcc-7, or clang, or tinycc,
> etc...)
>
> What I am understanding is that I should construct with GCCJIT an AST
> similar to the following C code:
>
> extern int a;

Is this well-defined by the standard? Or do we have to declare `a' as
an atomic int? (I know that this is currently impossible with
libgccjit, but implementing this is the easier part of the original
wish stated in this thread.)

> extern void show_int(int);
>
> int
> get_atomic_a ()
> {
>    return __atomic_load_n (&a, __ATOMIC_SEQ_CST);
> }
>
> void
> put_atomic_a(int x)
> {
>    __atomic_store_n(&a, x,  __ATOMIC_SEQ_CST);
> }
>
> void
> show_atomic_seq_cst(void)
> {
>    show_int(__ATOMIC_SEQ_CST);
> }
>
> Please notice that AFAIU, the __ATOMIC_SEQ_CST name is not standardized
> in C99 (or C11) -but I could be very wrong-. Also, there is no #include
> in the above code. On my Debian/Linux/x86-64 machine, __ATOMIC_SEQ_CST
> (I don't know how magic it is in GCC; is it a preprocessor symbol or
> some magic enum?) happens to be 5 (I examined the assembler code
> generated by gcc-6 -O1 -fverbose-asm -S on above C code). But can I be
> sure that it would be defined, and defined to the same value, with other
> C compilers.
>
> My feeling (but I might be wrong) is that GCCJIT should give some way to
> retrieve that __ATOMIC_SEQ_CST. Apparently it is a magic preprocessor
> symbol (perhaps GCC specific!) implemented in gcc/cppbuiltin.c (near
> line 68, defined as MEMMODEL_SEQ_CST); but if I understand correctly
> GCCJIT does not give access to the compiler's magic preprocessor symbols.

This is also one of my wishes. As soon as Andrea's patch
(https://gcc.gnu.org/ml/jit/2019-q1/msg00040.html), as a workaround,
one could write a simple C file defining `put_atomic_a' and
`get_atomic_a' and link its object file with LTO to the code generated
by libgccjit.

-- Marc

[...]

> I feel that GCCJIT might want to have a function like
> int gccjit_atomic_seq_cst_value(); // value of __ATOMIC_SEQ_CST in the
> GCC used by GCCJIT
> or perhaps a more general function
> int gccjit_compiler_magic_int(const char*);
> that I would call as gccjit_compiler_magic_int("__ATOMIC_SEQ_CST");
>
> Perhaps I am misunderstanding something obvious (I have a cold right now
> because of allergy, so my thinking is not the best), but I cannot
> understand today how exactly should I build in GCCJIT6 the
> gcc_jit_function-s equivalent to my get_atomic_a & put_atomic_a.... So
> please explain if you can!
>
> Regards.
>
> --
> Basile STARYNKEVITCHhttp://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} ***
>


-- 
Prof. Dr. Marc Nieper-Wißkirchen

Universität Augsburg
Institut für Mathematik
Universitätsstraße 14
86159 Augsburg

Tel: 0821/598-2146
Fax: 0821/598-2090

E-Mail: marc.nieper-wisskirchen@math.uni-augsburg.de
Web: www.math.uni-augsburg.de/alg/mitarbeiter/mnieper/

      parent reply	other threads:[~2019-01-16 10:55 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   ` Basile Starynkevitch
2016-01-01  0:00 ` Basile Starynkevitch
2016-01-01  0:00   ` Basile Starynkevitch
2019-01-01  0:00   ` Marc Nieper-Wißkirchen [this message]

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='CAEYrNrSg=G0jHS3CnYqNHSSqQ8XmWVa4+e0P0Q7+Cyz5=gENtg@mail.gmail.com' \
    --to=marc@nieper-wisskirchen.de \
    --cc=basile@starynkevitch.net \
    --cc=dmalcolm@redhat.com \
    --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).