JIT patch: add gcc_jit_magic_int
Basile Starynkevitch
basile@starynkevitch.net
Fri Jan 1 00:00:00 GMT 2016
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.
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} ***
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trunk236583-jitmagicint.diff
Type: text/x-patch
Size: 3493 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/jit/attachments/20160101/84042341/attachment.bin>
More information about the Jit
mailing list