[RFC] Setting data segment and loong constants - WIP

Petter Tomner tomner@kth.se
Wed Oct 6 08:23:20 GMT 2021


Hi,

I have two patches I am working with and I wanted to share the concept
if anyone has feedback. Both are dependent on my patch pending review
on complex types:
https://gcc.gnu.org/pipermail/jit/2021q3/001365.html

So essentially it is one patch with:

gcc_jit_context_new_rvalue_from_long_long (...)
gcc_jit_context_new_rvalue_from_long_double (...)
gcc_jit_context_new_rvalue_from_complex_long_double (...)

Those do what it seems. long_long is for making 64bit constants on
32bit machines without silly workarounds. 


And one patch adding support for setting initial values of global
variables:

gcc_jit_lvalue *
gcc_jit_global_set_initializer_rvalue (gcc_jit_lvalue *global,
                                 gcc_jit_rvalue *init_value);

gcc_jit_rvalue *
gcc_jit_context_new_constructor (gcc_jit_context *ctxt,
                                 gcc_jit_location *loc,
                                 gcc_jit_type *type,
                                 int arr_length,
                                 gcc_jit_field **fields,
                                 gcc_jit_rvalue **values);


gcc_jit_global_set_initializer_rvalue() assigns the rvalue to
DECL_INITIAL (global).

There is another patch in the mailing list for this
(https://gcc.gnu.org/pipermail/jit/2021q2/001308.html)
but it has problems with that the rvalue need to be created before
the global, for replay order. Also it has no constructor support.

gcc_jit_context_new_constructor() is needed for setting init values
of global array, struct or union variables. But it could also be used for 
locals, in theory. Each field in fields is set to its corresponding rvalue 
in values, by index. They do not need to be in the same order as in a 
struct definition. Unspecified fields are set to 0.

Any thoughts?

I attached a WIP patch mess if someone wants a looksie. Needs more work
on error handling and array and union ctor functionality.

Regards,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WIP-patches.patch
Type: text/x-patch
Size: 164286 bytes
Desc: WIP-patches.patch
URL: <https://gcc.gnu.org/pipermail/jit/attachments/20211006/c96562d0/attachment-0001.bin>


More information about the Jit mailing list