From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 062D0398580D for ; Fri, 2 Oct 2020 20:17:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 062D0398580D Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-19-RtJ4fLxKN3yxrhG1OwJAjg-1; Fri, 02 Oct 2020 16:17:04 -0400 X-MC-Unique: RtJ4fLxKN3yxrhG1OwJAjg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D896803F46; Fri, 2 Oct 2020 20:17:03 +0000 (UTC) Received: from ovpn-112-230.phx2.redhat.com (ovpn-112-230.phx2.redhat.com [10.3.112.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90F845D9D3; Fri, 2 Oct 2020 20:17:02 +0000 (UTC) Message-ID: <6fe2ea355403eb177c9632e076c11c792f23c791.camel@redhat.com> Subject: Re: [PATCH] libgccjit: add some reflection functions in the jit C api From: David Malcolm To: Antoni Boucher , gcc-patches@gcc.gnu.org, jit@gcc.gnu.org Date: Fri, 02 Oct 2020 16:17:01 -0400 In-Reply-To: <20200902010120.crnx55ev635ceiey@bouanto-desktop.localdomain> References: <20200902010120.crnx55ev635ceiey@bouanto-desktop.localdomain> User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Fri, 02 Oct 2020 20:17:18 -0000 On Tue, 2020-09-01 at 21:01 -0400, Antoni Boucher via Jit wrote: > Hello. > This WIP patch implements new reflection functions in the C API as > mentioned in bug 96889. > I'm looking forward for feedbacks on this patch. > It's WIP because I'll probably add a few more reflection functions. > Thanks. Sorry about the belated review, looks like I missed this one. At a high level, it seems reasonable. Do you have a copyright assignment in place for GCC contributions? See https://gcc.gnu.org/contribute.html [...] > diff --git a/gcc/jit/docs/topics/compatibility.rst b/gcc/jit/docs/topics/compatibility.rst > index bb3387fa583..7e786194ded 100644 > --- a/gcc/jit/docs/topics/compatibility.rst > +++ b/gcc/jit/docs/topics/compatibility.rst > @@ -219,3 +219,14 @@ entrypoints: > * :func:`gcc_jit_version_minor` > > * :func:`gcc_jit_version_patchlevel` > + > +.. _LIBGCCJIT_ABI_14: > + > +``LIBGCCJIT_ABI_14`` > +-------------------- > +``LIBGCCJIT_ABI_14`` covers the addition of reflection functions via API > +entrypoints: > + > + * :func:`gcc_jit_function_get_return_type` > + > + * :func:`gcc_jit_function_get_param_count` This will now need bumping to 15; 14 covers the addition of gcc_jit_global_set_initializer. [...] > +/* Public entrypoint. See description in libgccjit.h. > + > + After error-checking, the real work is done by the > + gcc::jit::recording::function::get_return_type method, in > + jit-recording.h. */ > + > +gcc_jit_type * > +gcc_jit_function_get_return_type (gcc_jit_function *func) > +{ This one is missing a: RETURN_NULL_IF_FAIL (func, NULL, NULL, "NULL function"); > + return (gcc_jit_type *)func->get_return_type (); > +} [...] > diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h > index 1c5a12e9c01..6999ce25ca2 100644 > --- a/gcc/jit/libgccjit.h > +++ b/gcc/jit/libgccjit.h [...] > @@ -1503,6 +1511,22 @@ gcc_jit_version_minor (void); > extern int > gcc_jit_version_patchlevel (void); > > +#define LIBGCCJIT_HAVE_gcc_jit_function_reflection > + > +/* Reflection functions to get the number of parameters and return types of > + a function from the C API. "return type", is better grammar, I think, given that "function" is singular. > + > + "vec_type" should be a vector type, created using gcc_jit_type_get_vector. This line about "vec_type" seems to be a leftover from a copy&paste. > + This API entrypoint was added in LIBGCCJIT_ABI_14; you can test for its > + presence using > + #ifdef LIBGCCJIT_HAVE_gcc_jit_function_reflection Version number will need bumping, as mentioned above. [...] > diff --git a/gcc/jit/libgccjit.map b/gcc/jit/libgccjit.map > index 6137dd4b4b0..b28f81a7a32 100644 > --- a/gcc/jit/libgccjit.map > +++ b/gcc/jit/libgccjit.map > @@ -186,4 +186,10 @@ LIBGCCJIT_ABI_13 { > gcc_jit_version_major; > gcc_jit_version_minor; > gcc_jit_version_patchlevel; > -} LIBGCCJIT_ABI_12; > \ No newline at end of file > +} LIBGCCJIT_ABI_12; > + > +LIBGCCJIT_ABI_14 { > + global: > + gcc_jit_function_get_return_type; > + gcc_jit_function_get_param_count; > +} LIBGCCJIT_ABI_13; Likewise. [...] Otherwise looks good to me. Bonus points for adding C++ bindings (and docs for them), but I don't know of anyone using the C++ bindings. Dave