From: David Malcolm <dmalcolm@redhat.com>
To: Eric Wong <e@80x24.org>, jit@gcc.gnu.org
Subject: Re: __attribute__((cleanup)) support in libgccjit?
Date: Thu, 08 Jun 2023 10:54:22 -0400 [thread overview]
Message-ID: <3765620ca62b16090873a01e16be1e27a7f42043.camel@redhat.com> (raw)
In-Reply-To: <20230608134626.M184090@dcvr>
On Thu, 2023-06-08 at 13:46 +0000, Eric Wong via Jit wrote:
> Hi, I'm considering libgccjit for use in a new GPL3+ scripting
> language and I am wondering if declaring locals with
> __attribute__((cleanup)) is supported by libgccjit.
>
> I find gcc_jit_lvalue_set_alignment in libgccjit.h, but not
> many other attributes for locals..
It varies attribute by attribute.
I took a look at this, and unfortunately it would need extra work on
libgccjit to make it support __attribute__((cleanup)).
Specifically, when the C and C++ frontends are building the
"generic/tree" representation of functions and see a local variable
with the attribute they add extra code to handle the cleanup:
C: in gcc/c/c-decl.c: finish_decl
C++: in gcc/cp/decl.c: cxx_maybe_build_cleanup
We'd need to implement something similar to the above in gcc/jit/jit-
playback.cc (and I'm already overtasked with analyzer work, alas).
Note that libgccjit doesn't have fine-grained scopes like C/C++ do;
locals exist at the level of a function frame.
>
> I'll likely use libgccjit regardless since it seems like it could
> make libffi redundant (or maybe I'm wrong on that bit...).
>
> I might steal LuaJIT's C parser to deal with parsing headers and
> structs; not sure if gcc exposes a C parser as a stable API...
Yeah, unfortunately we don't export C parsing as an API. If you need
to parse a header you'll need to either use a different C parser or
write a plugin to the GCC C frontend.
Hope this is helpful
Dave
prev parent reply other threads:[~2023-06-08 14:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-08 13:46 Eric Wong
2023-06-08 14:54 ` David Malcolm [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3765620ca62b16090873a01e16be1e27a7f42043.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=e@80x24.org \
--cc=jit@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).