From: Andrea Corallo <andrea.corallo@arm.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: jit@gcc.gnu.org, nd@arm.com, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] libgccjit: Add new gcc_jit_context_new_blob entry point
Date: Wed, 01 Jul 2020 18:14:52 +0200 [thread overview]
Message-ID: <gkrblkz8b5v.fsf@arm.com> (raw)
In-Reply-To: <87zh9kumwi.fsf@arm.com> (Andrea Corallo's message of "Wed, 03 Jun 2020 17:36:29 +0100")
Andrea Corallo <andrea.corallo@arm.com> writes:
>> It occurred to me that the entrypoint is combining two things:
>> - creating a global char[]
>> - creating an initializer for that global
>>
>> which got me wondering if we should instead have a way to add
>> initializers for globals.
>>
>> My first thought was something like:
>>
>> gcc_jit_context_new_global_with_initializer
>>
>> which would be like gcc_jit_context_new_global but would have an
>> additional gcc_jit_rvalue *init_value param?
>> The global would have to be of kind GCC_JIT_GLOBAL_EXPORTED or
>> GCC_JIT_GLOBAL_INTERNAL, not GCC_JIT_GLOBAL_IMPORTED.
>>
>> Alternatively, maybe it would be better to have
>>
>> gcc_jit_global_set_initializer (gcc_jit_lvalue *global,
>> gcc_jit_rvalue *init_val);
>>
>> to make the API more flexible.
>>
>> But even if we had this, we'd still need some way to create the rvalue
>> for that initial value. Also, maybe there ought to be a distinction
>> between rvalues that can vary at runtime vs those that can be computed
>> at compile-time (and are thus suitable for use in static
>> initialization).
>>
>> I suspect you may have gone through the same thought process and come
>> up with a simpler approach. (I'm mostly just "thinking out loud"
>> here, sorry if it isn't very coherent).
>
> Yes I had kind of similar thoughs.
>
> Ideally would be good to have a generic solution, the complication is
> that as you mentioned not every rvalue is suitable for initializing
> every global, but rather the opposite. My fear was that the space to be
> covered would be non trivial for a robust solution in this case.
>
> Also I believe we currently have no way to express in libgccjit rvalues
> an array with some content, so how to use this as initializer? Perhaps
> also we should have a new type gcc_jit_initializer?
>
> On the other hand I thought that for simple things like integers the
> problem is tipically already solved with an assignment in some init code
> (infact I think so far nobody complained) while the real standing
> limitation is for blobs (perhaps I'm wrong). And in the end if you can
> stuff some data in, you can use it later for any scope.
>
> Another "hybrid" solution would be to have specific entry point for each
> type of the subset we want to allow for static initialization. This way
> we still control the creation of the initializer internally so it's
> safe. In this view this blob entry point would be just one of these
> (probably with a different name like
> 'gcc_jit_context_new_glob_init_char_array').
>
Hi Dave,
wanted to ask if you formed an opinion about the patch and/or more in
general the problem of static initialize data.
Thanks
Andrea
next prev parent reply other threads:[~2020-07-01 16:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 10:11 Andrea Corallo
2020-06-03 15:03 ` David Malcolm
2020-06-03 16:36 ` Andrea Corallo
2020-07-01 16:14 ` Andrea Corallo [this message]
2020-07-14 10:00 ` Andrea Corallo
2020-07-24 22:05 ` David Malcolm
2020-07-24 22:12 ` David Malcolm
2020-08-03 8:07 ` Andrea Corallo
2020-08-06 19:53 ` David Malcolm
2020-08-19 7:17 ` [PATCH V2] " Andrea Corallo
2020-09-09 7:51 ` Andrea Corallo
2020-09-10 22:22 ` David Malcolm
2020-09-11 10:31 ` Andrea Corallo
2020-09-11 11:27 ` David Malcolm
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=gkrblkz8b5v.fsf@arm.com \
--to=andrea.corallo@arm.com \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jit@gcc.gnu.org \
--cc=nd@arm.com \
/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).