From: David Malcolm <dmalcolm@redhat.com>
To: "정인배(Inbae Jeong)" <kukyakya@gmail.com>,
"Florian Weimer" <fw@deneb.enyo.de>
Cc: jit@gcc.gnu.org
Subject: Re: Alignment not supported?
Date: Sun, 01 Jan 2017 00:00:00 -0000 [thread overview]
Message-ID: <1490622483.11099.31.camel@redhat.com> (raw)
In-Reply-To: <CAMMwVi14eZ3sNr6RERkt_gpu0O5uu0Zwn-D_mwR9dRPoOafgvg@mail.gmail.com>
On Sat, 2017-03-25 at 23:05 +0900, ì ì¸ë°°(Inbae Jeong) wrote:
> Sorry for being too short. It's JIT mailing list so I thought
> everyone
> would expect it to be related to gccjit.
>
> I'm writing a small JITed interpreter and trying to call an external
> C
> function (actually it is an external "C" C++ function) of which one
> of
> the parameters is a struct containing an aligned member variable.
>
> To make a struct type with gccjit, it will be somewhat like this:
>
> struct my_arg {
> int a;
> alignas(32) int b;
> };
>
> 1: gcc_jit_type *int_type = gcc_jit_context_get_type(ctxt,
> GCC_JIT_TYPE_INT)
> 2: gcc_jit_field *field_a = gcc_jit_context_new_field(ctxt, NULL,
> int_type, "a");
> 3: gcc_jit_field *field_b = gcc_jit_context_new_field(ctxt, NULL,
> int_type, "b"); // How do I specify the alignment?
> 4: gcc_jit_field *fields[2] = {field_a, field_b};
> 5: gcc_jit_struct *my_arg = gcc_jit_context_new_struct_type(ctxt,
> NULL, "my_arg", 2, fields);
>
>
> Maybe the alignment should be specified in line 3 or a new int type
> has to be made with alignment specification, if supported. However I
> don't see anything about alignment in the gccjit manual.
I don't think that there's currently a way to do this from libgccjit.
My first thought was that we could add a way to expose attributes on types from the API, something like:
extern gcc_jit_type *
gcc_jit_type_add_attribute (gcc_jit_type *type,
const char *attribute_name,
/* some extra params */ );
but it's not clear to me what those extra params should look like here.
It could be variadic, but variadic functions make for an error-prone API that's easy to crash, and they're a pain to deal with in language bindings.
Maybe:
extern gcc_jit_type *
gcc_jit_type_add_attribute_int (gcc_jit_type *type,
const char *attribute_name,
int attr_param);
(perhaps adding other suffixes for other type signatures; this is a C API, so there we can't use overloads; the C++ bindings could use them, though).
Alternatively, we could have a special-case entrypoint:
extern gcc_jit_type *
gcc_jit_type_set_alignment (gcc_jit_type *type,
int alignment);
and hide the fact that it's an attribute internally.
I'm not yet sure which approach I prefer (and maybe I need to poke at this from the implementation side to see what's implementable).
What other attributes might people want to use? Thoughts?
Dave
next prev parent reply other threads:[~2017-03-27 13:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-01 0:00 정인배(Inbae Jeong)
2017-01-01 0:00 ` Florian Weimer
2017-01-01 0:00 ` 정인배(Inbae Jeong)
2017-01-01 0:00 ` [PATCH] Work-in-progress: gcc_jit_type_get_aligned David Malcolm
2017-01-01 0:00 ` Florian Weimer
2017-01-01 0:00 ` [PATCH] Add gcc_jit_type_get_aligned David Malcolm
2017-01-01 0:00 ` David Malcolm
2017-01-01 0:00 ` Alignment not supported? Florian Weimer
2017-01-01 0:00 ` David Malcolm [this message]
2017-01-01 0:00 ` Florian Weimer
2017-01-01 0:00 ` David Malcolm
2017-01-01 0:00 ` Florian Weimer
2017-01-01 0:00 ` David Malcolm
2017-01-01 0:00 ` Florian Weimer
2017-01-01 0:00 ` David Malcolm
2017-01-01 0:00 ` Florian Weimer
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=1490622483.11099.31.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=fw@deneb.enyo.de \
--cc=jit@gcc.gnu.org \
--cc=kukyakya@gmail.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).