* Question about code generation
@ 2024-05-10 9:33 Gerd Möllmann
2024-05-10 10:35 ` Eli Zaretskii
0 siblings, 1 reply; 11+ messages in thread
From: Gerd Möllmann @ 2024-05-10 9:33 UTC (permalink / raw)
To: Emacs Devel
I'm wondering if it has ever been considered or tried in the last 20
years to generate code for Emacs using C parse trees of its sources?
I'm thinking of things like GC marking functions, dump functions, copy
functions an alike for structs.
SWIG could be used for example which can produce parse trees as XML.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 9:33 Question about code generation Gerd Möllmann
@ 2024-05-10 10:35 ` Eli Zaretskii
2024-05-10 11:38 ` Gerd Möllmann
0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2024-05-10 10:35 UTC (permalink / raw)
To: Gerd Möllmann; +Cc: emacs-devel
> From: Gerd Möllmann <gerd.moellmann@gmail.com>
> Date: Fri, 10 May 2024 11:33:43 +0200
>
> I'm wondering if it has ever been considered or tried in the last 20
> years to generate code for Emacs using C parse trees of its sources?
Isn't that what the C compiler does?
But I guess I'm misunderstanding what you are asking about.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 10:35 ` Eli Zaretskii
@ 2024-05-10 11:38 ` Gerd Möllmann
2024-05-10 12:57 ` Helmut Eller
0 siblings, 1 reply; 11+ messages in thread
From: Gerd Möllmann @ 2024-05-10 11:38 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Gerd Möllmann <gerd.moellmann@gmail.com>
>> Date: Fri, 10 May 2024 11:33:43 +0200
>>
>> I'm wondering if it has ever been considered or tried in the last 20
>> years to generate code for Emacs using C parse trees of its sources?
>
> Isn't that what the C compiler does?
>
> 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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 11:38 ` Gerd Möllmann
@ 2024-05-10 12:57 ` Helmut Eller
2024-05-10 12:59 ` Gerd Möllmann
2024-05-10 15:16 ` Eli Zaretskii
0 siblings, 2 replies; 11+ messages in thread
From: Helmut Eller @ 2024-05-10 12:57 UTC (permalink / raw)
To: Gerd Möllmann; +Cc: Eli Zaretskii, emacs-devel
On Fri, May 10 2024, Gerd Möllmann wrote:
>> 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.
Would be nice to write things like:
struct foo {
void* bar [[emacs::igc_fix_obj]];
}
and then run a gcc or clang plugin over it and generate the needed code.
Can libgccjit be used to parse C code and could we write the plugin in
Emacs Lisp? That would be fun.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 12:57 ` Helmut Eller
@ 2024-05-10 12:59 ` Gerd Möllmann
2024-05-10 15:16 ` Eli Zaretskii
1 sibling, 0 replies; 11+ messages in thread
From: Gerd Möllmann @ 2024-05-10 12:59 UTC (permalink / raw)
To: Helmut Eller; +Cc: Eli Zaretskii, emacs-devel
Helmut Eller <eller.helmut@gmail.com> writes:
> On Fri, May 10 2024, Gerd Möllmann wrote:
>
>>> 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.
>
> Would be nice to write things like:
>
> struct foo {
> void* bar [[emacs::igc_fix_obj]];
> }
Yeah, exactly!
>
> and then run a gcc or clang plugin over it and generate the needed code.
>
> Can libgccjit be used to parse C code and could we write the plugin in
> Emacs Lisp? That would be fun.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 12:57 ` Helmut Eller
2024-05-10 12:59 ` Gerd Möllmann
@ 2024-05-10 15:16 ` Eli Zaretskii
2024-05-10 17:00 ` Andrea Corallo
1 sibling, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2024-05-10 15:16 UTC (permalink / raw)
To: Helmut Eller, Andrea Corallo; +Cc: gerd.moellmann, emacs-devel
> From: Helmut Eller <eller.helmut@gmail.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
> Date: Fri, 10 May 2024 14:57:17 +0200
>
> On Fri, May 10 2024, Gerd Möllmann wrote:
>
> >> 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.
>
> Would be nice to write things like:
>
> struct foo {
> void* bar [[emacs::igc_fix_obj]];
> }
>
> and then run a gcc or clang plugin over it and generate the needed code.
>
> 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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 15:16 ` Eli Zaretskii
@ 2024-05-10 17:00 ` Andrea Corallo
2024-05-10 17:21 ` tomas
0 siblings, 1 reply; 11+ messages in thread
From: Andrea Corallo @ 2024-05-10 17:00 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Helmut Eller, gerd.moellmann, emacs-devel
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Helmut Eller <eller.helmut@gmail.com>
>> Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
>> Date: Fri, 10 May 2024 14:57:17 +0200
>>
>> On Fri, May 10 2024, Gerd Möllmann wrote:
>>
>> >> 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.
>>
>> Would be nice to write things like:
>>
>> struct foo {
>> void* bar [[emacs::igc_fix_obj]];
>> }
>>
>> and then run a gcc or clang plugin over it and generate the needed code.
>>
>> 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
<https://gcc-python-plugin.readthedocs.io/en/latest/>, certanly not
Elisp :/ but probably quicker than doing it in C.
Thanks
Andrea
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 17:00 ` Andrea Corallo
@ 2024-05-10 17:21 ` tomas
2024-05-10 17:35 ` Andrea Corallo
0 siblings, 1 reply; 11+ messages in thread
From: tomas @ 2024-05-10 17:21 UTC (permalink / raw)
To: Andrea Corallo; +Cc: Eli Zaretskii, Helmut Eller, gerd.moellmann, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 832 bytes --]
On Fri, May 10, 2024 at 01:00:51PM -0400, Andrea Corallo wrote:
[...]
> 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
> <https://gcc-python-plugin.readthedocs.io/en/latest/>, certanly not
> Elisp :/ but probably quicker than doing it in C.
And then, there is MELT [1], by Basile Starynkevitch, which, AFAIR is
a Lispy GCC plugin.
Cheers
[1] https://gcc.gnu.org/wiki/MiddleEndLispTranslator
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 17:21 ` tomas
@ 2024-05-10 17:35 ` Andrea Corallo
2024-05-10 17:38 ` Andrea Corallo
2024-05-10 17:38 ` tomas
0 siblings, 2 replies; 11+ messages in thread
From: Andrea Corallo @ 2024-05-10 17:35 UTC (permalink / raw)
To: tomas; +Cc: Eli Zaretskii, Helmut Eller, gerd.moellmann, emacs-devel
<tomas@tuxteam.de> writes:
> On Fri, May 10, 2024 at 01:00:51PM -0400, Andrea Corallo wrote:
>
> [...]
>
>> 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
>> <https://gcc-python-plugin.readthedocs.io/en/latest/>, certanly not
>> Elisp :/ but probably quicker than doing it in C.
>
> And then, there is MELT [1], by Basile Starynkevitch, which, AFAIR is
> a Lispy GCC plugin.
>
> Cheers
>
> [1] https://gcc.gnu.org/wiki/MiddleEndLispTranslator
Is MELT still a thing? Should be inactive since 2017 according to
<http://starynkevitch.net/basile/gcc-melt/>
Andrea
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 17:35 ` Andrea Corallo
@ 2024-05-10 17:38 ` Andrea Corallo
2024-05-10 17:38 ` tomas
1 sibling, 0 replies; 11+ messages in thread
From: Andrea Corallo @ 2024-05-10 17:38 UTC (permalink / raw)
To: tomas; +Cc: Eli Zaretskii, Helmut Eller, gerd.moellmann, emacs-devel
Andrea Corallo <acorallo@gnu.org> writes:
> <tomas@tuxteam.de> writes:
>
>> On Fri, May 10, 2024 at 01:00:51PM -0400, Andrea Corallo wrote:
>>
>> [...]
>>
>>> 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
>>> <https://gcc-python-plugin.readthedocs.io/en/latest/>, certanly not
>>> Elisp :/ but probably quicker than doing it in C.
>>
>> And then, there is MELT [1], by Basile Starynkevitch, which, AFAIR is
>> a Lispy GCC plugin.
>>
>> Cheers
>>
>> [1] https://gcc.gnu.org/wiki/MiddleEndLispTranslator
>
> Is MELT still a thing? Should be inactive since 2017 according to
> <http://starynkevitch.net/basile/gcc-melt/>
And it's successor doesn't look very active either
<https://github.com/bstarynk/bismon>
Andrea
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Question about code generation
2024-05-10 17:35 ` Andrea Corallo
2024-05-10 17:38 ` Andrea Corallo
@ 2024-05-10 17:38 ` tomas
1 sibling, 0 replies; 11+ messages in thread
From: tomas @ 2024-05-10 17:38 UTC (permalink / raw)
To: Andrea Corallo; +Cc: Eli Zaretskii, Helmut Eller, gerd.moellmann, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 270 bytes --]
On Fri, May 10, 2024 at 01:35:18PM -0400, Andrea Corallo wrote:
> <tomas@tuxteam.de> writes:
[MELT]
> Is MELT still a thing? Should be inactive since 2017 according to
> <http://starynkevitch.net/basile/gcc-melt/>
Oh, that's sad.
Thanks & cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-05-10 17:38 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-10 9:33 Question about code generation Gerd Möllmann
2024-05-10 10:35 ` Eli Zaretskii
2024-05-10 11:38 ` Gerd Möllmann
2024-05-10 12:57 ` Helmut Eller
2024-05-10 12:59 ` Gerd Möllmann
2024-05-10 15:16 ` Eli Zaretskii
2024-05-10 17:00 ` Andrea Corallo
2024-05-10 17:21 ` tomas
2024-05-10 17:35 ` Andrea Corallo
2024-05-10 17:38 ` Andrea Corallo
2024-05-10 17:38 ` tomas
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.