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 06DDB3858D28 for ; Sat, 23 Oct 2021 21:20:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 06DDB3858D28 Received: from exdb6.ug.kth.se (exdb6.ug.kth.se [192.168.32.61]) (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 4HcDf54KTpzPR4L; Sat, 23 Oct 2021 23:20:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp-relay-2.sys.kth.se 4HcDf54KTpzPR4L Received: from exdb6.ug.kth.se (192.168.32.61) by exdb6.ug.kth.se (192.168.32.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.922.14; Sat, 23 Oct 2021 23:20:45 +0200 Received: from exdb6.ug.kth.se ([192.168.32.61]) by exdb6.ug.kth.se ([192.168.32.61]) with mapi id 15.02.0922.014; Sat, 23 Oct 2021 23:20:45 +0200 From: Petter Tomner To: David Malcolm , Antoni Boucher CC: "jit@gcc.gnu.org" Subject: SV: [PATCH] libgccjit: add some reflection functions in the jit C api Thread-Topic: [PATCH] libgccjit: add some reflection functions in the jit C api Thread-Index: AQHXtANA+ozkEGYut0+LrIiYoWkpY6vQJQiAgBEZzSE= Date: Sat, 23 Oct 2021 21:20:45 +0000 Message-ID: References: <20200902010120.crnx55ev635ceiey@bouanto-desktop.localdomain> <6fe2ea355403eb177c9632e076c11c792f23c791.camel@redhat.com> <9cd00fe5cb5c03184e3a5bd939447b30450a8ca7.camel@redhat.com> <20201015160226.cka4iq3w22jztopm@bouanto-desktop.localdomain> <20201015173952.ft7mu5ajbaxb3gke@bouanto-desktop.localdomain> <54ba5c58dbd2b8c7b1f3276c2b87cddf55e258bd.camel@redhat.com> <20201103221324.xw3jbvrw2uwdc4rz@bouanto-desktop.localdomain> <3388bb8c84e68cd7b0698dc154e7a5666c0d2cde.camel@redhat.com> <0e8b6450bcb23182b85342d8010c3bea0c297ba2.camel@zoho.com> <534254132a841b75d555a52ce952f84418f168c2.camel@redhat.com> <3c328b40570b10b22a8925fd64b2781dc9264358.camel@zoho.com> <715f6ebfe1627fc39d8ec3b15f1e38f8378f3db7.camel@redhat.com> <711092bc80237e32caa48f2060c93be30cb9c220.camel@zoho.com> , 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=-4.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_SHORT, 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, 23 Oct 2021 21:20:49 -0000 Hi! (Sorry, my mail client dropped the jit mailing-list. Resending the mail= to it) +gcc_jit_type * +gcc_jit_type_unqualified (gcc_jit_type *type) +{ + RETURN_NULL_IF_FAIL (type, NULL, NULL, "NULL type"); + + return (gcc_jit_type *)type->unqualified (); +} I think there is a problem with the current implementation of unqualified()= that might be kinda surprising to users, since it only removes one qualifier and also not "pointed to" qualif= iers. Unrelated to this patch that behavior should probably be documented, since = it effects many entry-points and makes cast to base type kinda mandatory when qualified types are mixed.= Casts uses a recursive check of types and is happy to cast any pointer to any pointer (no matter t= he level of pointerness) so they work. I guess the casts should get some shortcircuit for casts between same base = types really, to not bloat the GENERIC tree. I made a utility function in another patch for comparing types that do full= stripping (see bellow). Maybe something like that could be usefull? jit-recording.h: +/* Strip all qualifiers and count pointer depth, returning true + if the types and pointer depth are the same, otherwise false. */ +static inline bool +types_kinda_same (recording::type *a, recording::type *b) +{ + /* Handle trivial case here, to allow for inlining. */ + return a =3D=3D b || types_kinda_same_internal (a, b); +} jit-recording.c: +/* Strip qualifiers and count pointer depth, returning true + if the types' base type and pointer depth are + the same, otherwise false. + + Do not call this directly. Call 'types_kinda_same' */ +bool +types_kinda_same_internal (recording::type *a, recording::type *b) +{ + int ptr_depth[2] =3D {}; + recording::type *base_types[2]; + recording::type *types[2] =3D {a, b}; + + /* Strip qualifiers and count pointerness */ + for (int i =3D 0; i < 2; i++) + { + recording::type *t =3D types[i]; + while (true) + { + if (!t) + return false; /* Should only happen on bad input */ + + recording::type *pointed_to_type =3D t->is_pointer(); + if (pointed_to_type !=3D NULL) + { + ptr_depth[i]++; + t =3D pointed_to_type; + continue; + } + + /* unqualified() returns 'this' on base types */ + recording::type *next =3D t->unqualified (); + if (next =3D=3D t) + { + base_types[i] =3D t; + break; + } + t =3D next; + } + } + + return base_types[0] =3D=3D base_types[1] && + (ptr_depth[0] =3D=3D ptr_depth[1]); +} Fr=E5n: Jit f=F6r Antoni Boucher = via Jit Skickat: den 13 oktober 2021 04:09 Till: David Malcolm Kopia: Antoni Boucher via Jit; gcc-patches@gcc.gnu.org =C4mne: Re: [PATCH] libgccjit: add some reflection functions in the jit C a= pi =A0 =20 David: PING Le lundi 27 septembre 2021 =E0 20:53 -0400, Antoni Boucher a =E9crit=A0: > I fixed an issue (it would show an error message when > gcc_jit_type_dyncast_function_ptr_type was called on a type different > than a function pointer type). >=20 > Here's the updated patch. >=20 > Le vendredi 18 juin 2021 =E0 16:37 -0400, David Malcolm a =E9crit=A0: > > On Fri, 2021-06-18 at 15:41 -0400, Antoni Boucher wrote: > > > I have write access now. > >=20 > > Great. > >=20 > > > I'm not sure how I'm supposed to send my patches: > > > should I put it in personal branches and you'll merge them? > >=20 > > Please send them to this mailing list for review; once they're > > approved > > you can merge them. > >=20 > > >=20 > > > And for the MAINTAINERS file, should I just push to master right > > > away, > > > after sending it to the mailing list? > >=20 > > I think people just push the MAINTAINERS change and then let the > > list > > know, since it makes a good test that write access is working > > correctly. > >=20 > > Dave > >=20 > > >=20 > > > Thanks for your help! > > >=20 > > > Le vendredi 18 juin 2021 =E0 12:09 -0400, David Malcolm a =E9crit=A0: > > > > On Fri, 2021-06-18 at 11:55 -0400, Antoni Boucher wrote: > > > > > Le vendredi 11 juin 2021 =E0 14:00 -0400, David Malcolm a > > > > > =E9crit=A0: > > > > > > On Fri, 2021-06-11 at 08:15 -0400, Antoni Boucher wrote: > > > > > > > Thank you for your answer. > > > > > > > I attached the updated patch. > > > > > >=20 > > > > > > BTW you (or possibly me) dropped the mailing lists; was > > > > > > that > > > > > > deliberate? > > > > >=20 > > > > > Oh, my bad. > > > > >=20 > > > >=20 > > > > [...] > > > >=20 > > > >=20 > > > > > >=20 > > > > > >=20 > > > > > > > I have signed the FSF copyright attribution. > > > > > >=20 > > > > > > I can push changes on your behalf, but I'd prefer it if you > > > > > > did > > > > > > it, > > > > > > especially given that you have various other patches you > > > > > > want > > > > > > to > > > > > > get > > > > > > in. > > > > > >=20 > > > > > > Instructions on how to get push rights to the git repo are > > > > > > here: > > > > > > =A0 https://gcc.gnu.org/gitwrite.html > > > > > >=20 > > > > > > I can sponsor you. > > > > >=20 > > > > > Thanks. > > > > > I did sign up to get push rights. > > > > > Have you accepted my request to get those? > > > >=20 > > > > I did, but I didn't see any kind of notification.=A0 Did you get > > > > an > > > > email > > > > about it? > > > >=20 > > > >=20 > > > > Dave > > > >=20 > > >=20 > > >=20 > >=20 > >=20 >=20 =