public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Marc Nieper-Wißkirchen" <marc.nieper+gnu@gmail.com>
To: Petter Tomner <tomner@kth.se>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"jit@gcc.gnu.org" <jit@gcc.gnu.org>
Subject: Re: [PATCH] jit: Add support for global rvalue initialization and ctors
Date: Fri, 10 Dec 2021 19:49:56 +0100	[thread overview]
Message-ID: <CAEYrNrQD+M9EXX2-CoQCjd6qw6m5U=jj-0jqywTFQwDY2=dfVg@mail.gmail.com> (raw)
In-Reply-To: <1d9576bd20cb472da2fe014af22e9551@kth.se>

 Hi,

I would favor adding support for this kind of initialization to libgccjit.

Does it also support the libgccjit equivalent of the following C module,
which contains forward references in the struct initializers?

struct bar bar;
struct foo foo;

struct foo
{
  struct bar *b;
};

struct bar
{
  struct foo *f;
};

struct bar bar = {.f = &foo};
struct foo foo = {.b = &bar};

Thanks,

Marc

Am Mo., 29. Nov. 2021 um 21:04 Uhr schrieb Petter Tomner via Jit <
jit@gcc.gnu.org>:

> Hi!
>
> I have wrapped up the patch than adds support for initialization of global
> variables
> with rvalues aswell as rvalue constructors for structs, arrays and unions.
>
> New entrypoints are:
>
> gcc_jit_global_set_initializer_rvalue
>
> Which sets the initial value of a global to a rvalue.
>
> And:
>
> gcc_jit_context_new_array_constructor
> gcc_jit_context_new_struct_constructor
> gcc_jit_context_new_union_constructor
>
> Those three makes a constructor with a rvalue that e.g. can be assigned to
> a local or returned
> from a function, or most importantly used to set the initial value of
> global variables
> with gcc_jit_global_set_initializer_rvalue.
>
> If no fields are specified for a struct or union to the constructors,
> definition order is assumed.
>
> There can be gaps in the fields specified to the struct constructor, but
> they need to be in order.
>
> For pointer arithmetic to work with setting DECL_INITIAL, alot of folding
> is added.
>
> make check-jit runs fine on gnu-linux-x64 Debian.
>
> Regards,

  parent reply	other threads:[~2021-12-10 18:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-29 20:03 Petter Tomner
2021-11-30 17:09 ` SV: " Petter Tomner
2021-12-10 18:49 ` Marc Nieper-Wißkirchen [this message]
2021-12-11 15:51   ` Petter Tomner
2021-12-15 14:13     ` Petter Tomner
2022-01-24 13:43       ` Marc Nieper-Wißkirchen
2022-01-27 20:01         ` SV: " Petter Tomner

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='CAEYrNrQD+M9EXX2-CoQCjd6qw6m5U=jj-0jqywTFQwDY2=dfVg@mail.gmail.com' \
    --to=marc.nieper+gnu@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jit@gcc.gnu.org \
    --cc=tomner@kth.se \
    /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).