* alloca and labels as values
@ 2018-01-01 0:00 Marc Nieper-Wißkirchen
2018-01-01 0:00 ` David Malcolm
0 siblings, 1 reply; 5+ messages in thread
From: Marc Nieper-Wißkirchen @ 2018-01-01 0:00 UTC (permalink / raw)
To: jit
Hi,
let me first say that libgccjit is a great project and that I like the
API very much!
Is `alloca' currently possible with libgccjit? I haven't found anything
about it in the documentation. If it isn't possible at the moment, I'd
love to see it added to libgccjit very soon. (One use case would be a
compiler like the Chicken Scheme compiler that employs Cheney-on-the-MTA
where the youngest heap generation is allocated on the stack.)
Another thing that may be missing is label values as implemented by the
GCC C/C++ frontends.
Thanks!
Marc
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: alloca and labels as values
2018-01-01 0:00 alloca and labels as values Marc Nieper-Wißkirchen
@ 2018-01-01 0:00 ` David Malcolm
0 siblings, 0 replies; 5+ messages in thread
From: David Malcolm @ 2018-01-01 0:00 UTC (permalink / raw)
To: Marc Nieper-Wißkirchen, jit
On Mon, 2018-12-17 at 08:07 +0100, Marc Nieper-WiÃkirchen wrote:
> Hi,
>
> let me first say that libgccjit is a great project and that I like
> the
> API very much!
Thanks.
> Is `alloca' currently possible with libgccjit? I haven't found
> anything
> about it in the documentation. If it isn't possible at the moment,
> I'd
> love to see it added to libgccjit very soon. (One use case would be
> a
> compiler like the Chicken Scheme compiler that employs Cheney-on-the-
> MTA
> where the youngest heap generation is allocated on the stack.)
I haven't tested this, but I believe you ought to be able to access it
via the "__builtin_alloca" builtin, via something like:
gcc_jit_function *fn_alloca
= gcc_jit_context_get_builtin_function (ctxt, "__builtin_alloca");
gcc_jit_rvalue *call =
gcc_jit_context_new_call (ctxt,
loc,
fn_alloc_a,
1, &size_t_arg);
gcc_jit_block_add_assignment (block, loc,
dst_lvalue,
call);
...or something like that.
> Another thing that may be missing is label values as implemented by
> the
> GCC C/C++ frontends.
Probably. IIRC that isn't implemented.
> Thanks!
>
> Marc
Dave
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: alloca and labels as values
2018-01-01 0:00 ` David Malcolm
@ 2019-01-01 0:00 ` Marc Nieper-Wißkirchen
0 siblings, 0 replies; 5+ messages in thread
From: Marc Nieper-Wißkirchen @ 2019-01-01 0:00 UTC (permalink / raw)
To: David Malcolm; +Cc: jit
Am Di., 18. Dez. 2018 um 15:02 Uhr schrieb David Malcolm <dmalcolm@redhat.com>:
[...]
> On Tue, 2018-12-18 at 08:12 +0100, Marc Nieper-Wißkirchen wrote:
> > > > Is `alloca' currently possible with libgccjit? I haven't found
[...]
> > > I haven't tested this, but I believe you ought to be able to
> > access it
> > > via the "__builtin_alloca" builtin, via something like:
[...]
> > That was helpful; thank you very much. I overlooked the procedure
> > `gcc_jit_context_get_builtin_function' in the documentation. Is there
> > a
> > way to determine which builtins are supported by a specific version
> > of
> > the library or would I have to add a few scripts to my project's
> > `configure.ac' myself?
>
> I think you'd need a configure check.
[...]
Having thought about it once more I think the configure check I asked
about makes no sense. Configure can tell me the available builtins of
the host compiler but nothing about the available builtins of the
target system that eventually runs libgccjit (if we don't want to give
up the option of cross-compiling).
What we need, I think, is that <libgccjit.h> exports a number of
macros that define the
Thus we need that libgccjit's header defines a number of macros that
define the capabilities of the GCC embedded in libgccjit.so.
Concretely, source code that uses libgccjit can test the feature macro
__GNUC__. This, however, returns the GCC version of the build system.
What is missing is another macro like GCC_JIT_GNUC that is defined in
<libgccjit.h> and returns the GCC version of the libgccjit library.
It may also be worth to reflect some macros from
https://gcc.gnu.org/onlinedocs/gccint/Target-Macros.html as
GCC_JIT_XXX macros in <libgccjit.h>.
-- Marc
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: alloca and labels as values
@ 2018-01-01 0:00 Marc Nieper-Wißkirchen
2018-01-01 0:00 ` David Malcolm
0 siblings, 1 reply; 5+ messages in thread
From: Marc Nieper-Wißkirchen @ 2018-01-01 0:00 UTC (permalink / raw)
To: jit
> > Is `alloca' currently possible with libgccjit? I haven't found
> > anything
> > about it in the documentation. If it isn't possible at the moment,
> > I'd
> > love to see it added to libgccjit very soon. (One use case would be
> > a
> > compiler like the Chicken Scheme compiler that employs Cheney-on-the-
> > MTA
> > where the youngest heap generation is allocated on the stack.)
>
> I haven't tested this, but I believe you ought to be able to access it
> via the "__builtin_alloca" builtin, via something like:
>
>
> gcc_jit_function *fn_alloca
> Â = gcc_jit_context_get_builtin_function (ctxt, "__builtin_alloca");
>
>
> gcc_jit_rvalue *call =
> Â Â Â Â gcc_jit_context_new_call (ctxt,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â loc,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â fn_alloc_a,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1, &size_t_arg);
>
> Â gcc_jit_block_add_assignment (block, loc,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â dst_lvalue,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â call);
>
> ...or something like that.
That was helpful; thank you very much. I overlooked the procedure
`gcc_jit_context_get_builtin_function' in the documentation. Is there a
way to determine which builtins are supported by a specific version of
the library or would I have to add a few scripts to my project's
`configure.ac <http://configure.ac>' myself?
-- Marc
P.S.: Another thing I wasn't able to find so far was how to declare
variables as thread local (i.e. GCC's __thread or C11's thread_local).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: alloca and labels as values
2018-01-01 0:00 Marc Nieper-Wißkirchen
@ 2018-01-01 0:00 ` David Malcolm
2019-01-01 0:00 ` Marc Nieper-Wißkirchen
0 siblings, 1 reply; 5+ messages in thread
From: David Malcolm @ 2018-01-01 0:00 UTC (permalink / raw)
To: Marc Nieper-Wißkirchen, jit
On Tue, 2018-12-18 at 08:12 +0100, Marc Nieper-WiÃkirchen wrote:
> > > Is `alloca' currently possible with libgccjit? I haven't found
>
> > > anything
> > > about it in the documentation. If it isn't possible at the
> moment,
> > > I'd
> > > love to see it added to libgccjit very soon. (One use case would
> be
> > > a
> > > compiler like the Chicken Scheme compiler that employs Cheney-
> on-the-
> > > MTA
> > > where the youngest heap generation is allocated on the stack.)
> >
> > I haven't tested this, but I believe you ought to be able to
> access it
> > via the "__builtin_alloca" builtin, via something like:
> >
> >
> > gcc_jit_function *fn_alloca
> > = gcc_jit_context_get_builtin_function (ctxt,
> "__builtin_alloca");
> >
> >
> > gcc_jit_rvalue *call =
> > gcc_jit_context_new_call (ctxt,
> > loc,
> > fn_alloc_a,
> > 1, &size_t_arg);
> >
> > gcc_jit_block_add_assignment (block, loc,
> > dst_lvalue,
> > call);
> >
> > ...or something like that.
>
>
> That was helpful; thank you very much. I overlooked the procedure
> `gcc_jit_context_get_builtin_function' in the documentation. Is there
> a
> way to determine which builtins are supported by a specific version
> of
> the library or would I have to add a few scripts to my project's
> `configure.ac <http://configure.ac>' myself?
I think you'd need a configure check.
> -- Marc
>
> P.S.: Another thing I wasn't able to find so far was how to declare
> variables as thread local (i.e. GCC's __thread or C11's
> thread_local).
There isn't currently a way to do thread local variables. I suspect
that something like a variant of gcc_jit_context_new_global could do
it, e.g. "gcc_jit_context_new_thread_local" or somesuch. Or maybe a
way to mark the result of gcc_jit_context_new_global as being thread-
local.
Dave
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-12 14:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-01 0:00 alloca and labels as values Marc Nieper-Wißkirchen
2018-01-01 0:00 ` David Malcolm
2018-01-01 0:00 Marc Nieper-Wißkirchen
2018-01-01 0:00 ` David Malcolm
2019-01-01 0:00 ` Marc Nieper-Wißkirchen
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).