From: "Marc Nieper-Wißkirchen" <marc.nieper@gmail.com>
To: Basile Starynkevitch <basile@starynkevitch.net>
Cc: "David Malcolm" <dmalcolm@redhat.com>,
"Anselm Schüler" <mail@anselmschueler.com>,
jit@gcc.gnu.org
Subject: Re: Interfacing with external code using libgccjit
Date: Fri, 16 Jun 2023 21:15:57 +0200 [thread overview]
Message-ID: <CAEYrNrRv++_ZAbGuqYBj7wHUnczaOC8hnBJ8xf7xb+hKVKYXNg@mail.gmail.com> (raw)
In-Reply-To: <a9bb3965-a89a-5030-7747-00edebaa207c@starynkevitch.net>
The simplest way IMO is to write a stub in C with ordinary functions
that calls into GMP and MPFR, and then call the C stub from libgccjit
code. When you enable LTO, the stub should be optimized away.
Am Fr., 16. Juni 2023 um 21:08 Uhr schrieb Basile Starynkevitch
<basile@starynkevitch.net>:
>
>
> On 6/16/23 19:27, David Malcolm via Jit wrote:
> > On Thu, 2023-06-15 at 21:59 +0200, Anselm Schüler wrote:
> >> Hi, I’m very new to libgccjit and was hoping to use it to implement a
> >> DSL that abstracts over some high-precision mathematics.
> > Hi!
> >
> >> However, to do that, I need to interface with a high-precision
> >> library
> >> such as GMP or MPFR.
> >> I’m wondering if that’s possible.
> > It ought to be possible, but you need some way to express the
> > declarations from the library's headers via the ligccjit API; we don't
> > yet have a convenient way to take a header and express it in libgccjit
> > form. As you note, doing it "by hand" is laborious; sorry that we
> > don't yet have an automated way of doing this. Possible approaches
> > would be to use a library that can parse C headers, such as:
> > https://github.com/vnmakarov/mir
> > or perhaps using libabigail to work with the ABI representation:
> > https://sourceware.org/libabigail/
> > (which would be parsing the debug data)
> >
>
> Another possible approach might be to use some GCC plugin (perhaps
> inspired by some code from https://github.com/bstarynk/bismon ...) to
> parse the GMP or MPFR header files, and later inject some constants
> (describing the external code, such as GMP or MPFR) into libgccjit
>
>
>
>
> Maybe future GCC support for C++ 2x modules could be also relevant
>
> Cheers
>
> --
> Basile Starynkevitch <basile@starynkevitch.net>
> (only mine opinions / les opinions sont miennes uniquement)
> 92340 Bourg-la-Reine, France
> web page: starynkevitch.net/Basile/
>
prev parent reply other threads:[~2023-06-16 19:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 19:59 Anselm Schüler
2023-06-16 17:27 ` David Malcolm
2023-06-16 19:07 ` Basile Starynkevitch
2023-06-16 19:15 ` Marc Nieper-Wißkirchen [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=CAEYrNrRv++_ZAbGuqYBj7wHUnczaOC8hnBJ8xf7xb+hKVKYXNg@mail.gmail.com \
--to=marc.nieper@gmail.com \
--cc=basile@starynkevitch.net \
--cc=dmalcolm@redhat.com \
--cc=jit@gcc.gnu.org \
--cc=mail@anselmschueler.com \
/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).