From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 115322 invoked by alias); 30 Mar 2017 00:48:09 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 115130 invoked by uid 89); 30 Mar 2017 00:48:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=disclaimer, contributions, dispatch, love X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6BD9181235 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dmalcolm@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6BD9181235 Message-ID: <1490834879.11099.103.camel@redhat.com> Subject: Re: small C++ API additions From: David Malcolm To: Joseph Jevnik , jit@gcc.gnu.org Date: Sun, 01 Jan 2017 00:00:00 -0000 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 30 Mar 2017 00:48:01 +0000 (UTC) X-SW-Source: 2017-q1/txt/msg00022.txt.bz2 On Wed, 2017-03-29 at 17:10 -0400, Joseph Jevnik wrote: > Hello all, > > I have been playing around with the C++ wrapper for gccjit and have > noticed a > few things missing from the C API. I have written up four small > patches to add > the missing features. > new-function-ptr-type.patch: Adds a method on 'context' to create a > new function > pointer type. > > new-union-type.patch: Adds a method on 'context' for creating a new > union > type. This also adds a 'union_' class like 'struct_' which subclasses > 'type'. > > set_fields.patch: Adds a method to 'struct_' for setting the fields > of an opaque > struct type. The C++ wrapper already allowed creation of opaque > structs but > didn't have a way to populate them for creating recusive structures > like linked > lists. > > operator-call.patch: Adds a variadic dispatch for > 'function::operator()' when > compiling with C++11 support. This extends 'function(a, b, c, ...) > for arbitrary > amounts of arguments without needing to create a vector to pass the > arguments > in. Right now this just dispatches through the vector case but could > be changed > to use a 'std::array' in the future. This is > mostly > just to simplify the API for fixed arity calls which have a lot of > arguments. Thanks! BTW, a nit: isn't the official value of __cplusplus for C++11 201103L, hence: #if __cplusplus >= 201103L rather than: #if __cplusplus >= 201100L for the parameter packs? I wonder if we need to generalize the C++ test suite so that it tests the API for various different versions of the C++ standard. > Currently all of these patches are missing tests. I found the C tests > but didn't > see anything for the C++ API. I would love to add some cases for > these but I > just don't know where to look. Have a look at gcc/testsuite/jit.dg/*.cc You can run individual test cases via (e.g.): make check-jit RUNTESTFLAGS="-v -v jit.exp=test-quadratic.cc" (see https://dmalcolm.fedorapeople.org/gcc/newbies-guide/working-with-t he-testsuite.html ) > This is my first time posting to any of the GCC mailing lists or > working on GCC > at all so please let me know if this is not the correct place to post > this or if > I have done something incorrectly. This is the correct mailing list, and an excellent start; thanks. Note that currently we're deep in feature freeze for gcc 7. That said, the C++ API to libgccjit is explicitly called out as having less stability guarantees than the rest of the project, so we may be able to violate that feature freeze. Please can you add tests and documentation and post the updated patches as separate emails (it's easier to deal with that way). For sufficiently large contributions, you need to either file a copyright assignment to the FSF, or to make a copyright disclaimer. See the instructions here: https://gcc.gnu.org/contribute.html#legal I'm not sure exactly what the threshold is for a contribution to be called "large", but I suspect that you've reached that threshold (especially after tests and docs are added to the patches). > Thank you for your time! Thanks again Dave