PATCH (v2) trunk GCCJIT: adding gcc_jit_context_new_rvalue_from_long_long, etc...

Basile Starynkevitch basile@starynkevitch.net
Thu Jul 16 09:25:00 GMT 2015


On 07/15/2015 21:16, David Malcolm wrote:
> Perhaps, but note that nothing in a regular gcc bootstrap uses
> libgccjit, so you *might* still have a latent linking error that shows
> up only at run time.   Running the jit testsuite is the best way to be
> sure.
>
>> And I'm testing that on
>> x86-64/Linux where the patch is almost useless.
>>
>> Thanks for your other comments. I'm trying to understand them and I am
>> working on that.
>>
>> Cheers
>>

Here (attached gcc-jitlonglong-r225860.diff)
is an improved version of my patch against trunk r225860.
Thanks to David Malcom for the kind help.

### gcc/jit/ ChangeLog entry

2015-07-16  Basile Starynkevitch  <basile@starynkevitch.net>

     * jit-playback.c: Mention that it is in C++.
     (new_rvalue_from_const <long>): New.

     * jit-recording.c: Mention that it is in C++.
     (recording::memento_of_new_rvalue_from_const <long long>): New
     instanciated template.
     (memento_of_new_rvalue_from_const <long long>::make_debug_string):
     New specialized function.
     (memento_of_new_rvalue_from_const <long long>::get_wide_int): New
     specialized function.
     (recording::memento_of_new_rvalue_from_const <long
     long>::write_reproducer): Likewise.

     * libgccjit.c: Mention that it is in C++.
     (gcc_jit_context_new_rvalue_from_long_long): New function.
     (gcc_jit_context_new_rvalue_from_int32): New function.
     (gcc_jit_context_new_rvalue_from_int64): New function.
     (gcc_jit_context_new_rvalue_from_intptr): New function.

     * libgccjit.h: #include <stdint.h>
     (gcc_jit_context_new_rvalue_from_long_long): New declaration.
     In the declarations of the functions below, a short comment
     explains that they are convenience functions.
     (gcc_jit_context_new_rvalue_from_int32): New declaration.
     (gcc_jit_context_new_rvalue_from_int64): New declaration.
     (gcc_jit_context_new_rvalue_from_intptr): New declaration.

     * libgccjit.map: Add LIBGCCJIT_ABI_4 for new functions
     e.g. gcc_jit_context_new_rvalue_from_long_long, ....


## gcc/testsuite/ChangeLog entry
     * test-constants.c (make_test_of_long_long_constant): New function.
     (make_tests_of_long_long_constants): New.
     (verify_long_long_constants): New.
     (create_code): Call make_tests_of_long_long_constants.
     (verify_code): Call verify_long_long_constants.


I have mixed feelings about adding the 
gcc_jit_context_new_rvalue_from_int32 
gcc_jit_context_new_rvalue_from_int64 & 
gcc_jit_context_new_rvalue_from_intptr functions.
On one hand, their name is very suggestive, and most programmers know 
about <stdint.h>. I should confess that I discovered only recently that 
long long is guaranteed by C99 standard to be at least 64 bits (I 
thought that the standard just required that long long is at least as 
big as long).
On the other hand, we are adding more functions to the ABI, and indeed 
the gcc_jit_context_new_rvalue_from_long_long is in principle enough. 
Perhaps we should simply document that for int32_t, int64_t, intptr_t 
types, the GCCJIT user should test the sizeof intptr_t and call the 
appropriate function?

BTW some bytecodes or VMs (in particular the JVM) are hardcoding the 
size of some integers, so dealing explicitly with int32_t & int64_t 
definitely makes sense.

The patch is passing the test that I have added, on Debian/x86-64.

Comments are welcome, including perhaps an Ok for trunk...

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: gcc-jitlonglong-r225860.diff
Type: text/x-patch
Size: 13373 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150716/bddeaeac/attachment.bin>


More information about the Gcc-patches mailing list