Skip to content

Expose va_arg and va_start#84

Open
folkertdev wants to merge 3 commits into
rust-lang:masterfrom
folkertdev:va-arg
Open

Expose va_arg and va_start#84
folkertdev wants to merge 3 commits into
rust-lang:masterfrom
folkertdev:va-arg

Conversation

@folkertdev

Copy link
Copy Markdown

The bits we need to hook up va_arg and va_start in the GCC backend. I got this to work on x86_64, I've tried to not bake in assumptions about other platforms (e.g. the layout of VaList), but this code is pretty dense.

I'll leave some comments on the non-boilerplate bits.

@folkertdev folkertdev left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk if this meets the GCC standards but for us it should do (for now)

Comment thread gcc/jit/dummy-frontend.cc
Comment on lines +1489 to +1504
static tree
jit_langhook_type_promotes_to (tree type)
{
/* The "default argument promotions" */

/* float is promoted to double. */
if (TYPE_MAIN_VARIANT (type) == float_type_node)
return double_type_node;

/* integers smaller than int are promoted to int. */
if (INTEGRAL_TYPE_P (type)
&& TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
return integer_type_node;

return type;
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c-variadic arguments are subject to the "default argument promotions", so this hook ends up getting called when we try to compile a c-variadic call.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I happen to know that _Complex is not subject to these rules, and I think f16 is not really a C type and this rule would also not apply here.

Comment thread gcc/jit/jit-builtins.cc Outdated
Comment thread gcc/jit/jit-playback.cc Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant