From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.devel Subject: Re: Question about code generation Date: Fri, 10 May 2024 13:00:51 -0400 Message-ID: References: <86r0ea3qf4.fsf@gnu.org> <877cg1hljm.fsf@gmail.com> <86h6f54rzw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21772"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Helmut Eller , gerd.moellmann@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 10 19:02:43 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s5Tdo-0005NF-D9 for ged-emacs-devel@m.gmane-mx.org; Fri, 10 May 2024 19:02:40 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Tcy-0007Vh-65; Fri, 10 May 2024 13:01:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5TcP-0007SY-7b for emacs-devel@gnu.org; Fri, 10 May 2024 13:01:20 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5TcA-0006tW-7y; Fri, 10 May 2024 13:01:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=qanAoY/zrEW4kwV18c57y3xzGFh3S4GD+76dVLfiVIA=; b=ejY1xyl7Em614gFuCoA5 jYy9axPdMYo1dby2oPJ2OC5Na2muk+0rvndZ8HeixkbW949bGRVSaCRFzepcWpT3G1pPKjGok3f3S bkzmIB53l+AFSPqaxkM/fNyhS8pGLjPsgQhsnQdZ+V22ZSfcDFq5vPgNvOdDU90Wn6ve2i0uvqeS7 BaLVm3PAOIMSb9QkzLCYbOxdPKv2DsrZdcIUwL5KvW8fPKFm4b1V7EN/L69uCkO5trBj3WbrMt4QY R0VL4FAizDQ/ZkYfhMIoVt4BWKIC9ZMRuxwHPrC6JBErJZguL4e6pUAoXauCRaXhsNlKNznHkH5cz uStkRlpMdEZY+w==; Original-Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1s5Tc4-0003Z0-Ja; Fri, 10 May 2024 13:00:54 -0400 In-Reply-To: <86h6f54rzw.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 10 May 2024 18:16:19 +0300") X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:319148 Archived-At: Eli Zaretskii writes: >> From: Helmut Eller >> Cc: Eli Zaretskii , emacs-devel@gnu.org >> Date: Fri, 10 May 2024 14:57:17 +0200 >>=20 >> On Fri, May 10 2024, Gerd M=C3=B6llmann wrote: >>=20 >> >> But I guess I'm misunderstanding what you are asking about. >> > >> > I was thinking of (making my life easier and) generating the fix_ >> > functions in igc.c, as an example, from knowledge that a C parser has >> > which members are in a given struct, what's their type, Lisp_Object, >> > pointer to something interesting, ... >> > >> > Together with meta infos passed to a code generator this could be used >> > for all sorts of things, I guess. >>=20 >> Would be nice to write things like: >>=20 >> struct foo { >> void* bar [[emacs::igc_fix_obj]]; >> } >>=20 >> and then run a gcc or clang plugin over it and generate the needed code. >>=20 >> Can libgccjit be used to parse C code and could we write the plugin in >> Emacs Lisp? That would be fun. > > AFAIU, libgccjit needs GIMPL, and you drive it by calling the > respective functions from libgccjit. But Andrea will tell for sure. I think in this case libgccjit goes the other way of what would be need here. Libgccjit allowed us to develop an Elisp front-end while here the frontend we need is already the C one that comes with GCC. What we want is a GCC plugin, essentially a custom pass that analyses say lisp.h and output something (in this case some C code). Not many people know that should be even possible to write it in python thanks to David Malcolm work , certanly not Elisp :/ but probably quicker than doing it in C. Thanks Andrea