From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-relay-2.sys.kth.se (smtp-relay-2.sys.kth.se [130.237.32.40]) by sourceware.org (Postfix) with ESMTPS id 61E073858D39; Sat, 11 Dec 2021 15:51:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 61E073858D39 Received: from exdb3.ug.kth.se (exdb3.ug.kth.se [192.168.32.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp-relay-2.sys.kth.se (Postfix) with ESMTPS id 4JBC1l1LvXzPNQT; Sat, 11 Dec 2021 16:51:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp-relay-2.sys.kth.se 4JBC1l1LvXzPNQT Received: from exdb6.ug.kth.se (192.168.32.61) by exdb3.ug.kth.se (192.168.32.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.14; Sat, 11 Dec 2021 16:51:38 +0100 Received: from exdb6.ug.kth.se ([192.168.32.61]) by exdb6.ug.kth.se ([192.168.32.61]) with mapi id 15.02.0986.014; Sat, 11 Dec 2021 16:51:38 +0100 From: Petter Tomner To: =?iso-8859-1?Q?Marc_Nieper-Wi=DFkirchen?= CC: "gcc-patches@gcc.gnu.org" , "jit@gcc.gnu.org" Subject: SV: [PATCH] jit: Add support for global rvalue initialization and ctors Thread-Topic: [PATCH] jit: Add support for global rvalue initialization and ctors Thread-Index: AQHX5Vuu9//2bIWgFE2G8blT/CeNBawsEfgAgAFs6iA= Date: Sat, 11 Dec 2021 15:51:38 +0000 Message-ID: <4abd5fbec6e0409d9c26624386951b40@kth.se> References: <1d9576bd20cb472da2fe014af22e9551@kth.se>, In-Reply-To: Accept-Language: sv-SE, en-US Content-Language: sv-SE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.32.250] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: jit@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Jit mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Dec 2021 15:51:42 -0000 Hi! Ye that should work since the lvalue:s are always created first.=20 I haven't tried it, but I should add it to the testcase, together with=20 some circular linked list thing, to see that nothing gets stuck running in a circle. Maybe I should verify this does not blow up the lib, too: extern const int bar; const int foo =3D bar; const int bar =3D foo; Hopefully my patch will complain about "not constant", and not try to go all in C++ on it. Regards, Petter Fr=E5n: Marc Nieper-Wi=DFkirchen Skickat: den 10 december 2021 19:49 Till: Petter Tomner Kopia: gcc-patches@gcc.gnu.org; jit@gcc.gnu.org =C4mne: Re: [PATCH] jit: Add support for global rvalue initialization and c= tors =A0=20 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, wh= ich contains forward references in the struct initializers? struct=A0bar bar; struct=A0foo foo; struct=A0foo { =A0=A0struct=A0bar=A0*b;=A0 }; struct=A0bar { =A0=A0struct=A0foo=A0*f; }; struct=A0bar=A0bar=A0=3D=A0{.f=A0=3D=A0&foo}; struct=A0foo=A0foo=A0=3D=A0{.b=A0=3D=A0&bar};=20 Thanks, Marc =20 Am Mo., 29. Nov. 2021 um 21:04=A0Uhr schrieb Petter Tomner via Jit : 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 globa= l variables with gcc_jit_global_set_initializer_rvalue. If no fields are specified for a struct or union to the constructors, defin= ition order is assumed. There can be gaps in the fields specified to the struct constructor, but th= ey need to be in order. For pointer arithmetic to work with setting DECL_INITIAL, alot of folding i= s added. make check-jit runs fine on gnu-linux-x64 Debian. Regards, =