__builtin_va_arg rfc
Richard Henderson
rth@cygnus.com
Fri Apr 23 02:44:00 GMT 1999
Beginning with a proof-of-concept patch Jim did some years ago,
here's a first cut at a version that properly isolates the ABI
issues to the back end.
I'm particularly interested in comments from the C++ folks
whether the struct creation bits in alpha.c for __builtin_va_list
are going to get me in trouble -- I don't set all of the same
bits that the C++ front end would for a struct.
Another point to note is that __builtin_va_arg sets neither
MEM_IN_STRUCT_P nor MEM_SCALAR_P, and does set a (single) unique
MEM_ALIAS_SET for every value to come out. This should put the
nail in the coffin of the semi-annual struct-via-varargs bug,
and improve performance a bit to boot.
Of course the changes to stdarg.h and varargs.h are temporary.
Unless of course we convert all 19 special-case targets. ;-)
The patch bootstraps on Alpha and i686, and checks out with no
torture or ph regressions on Alpha.
Comments?
r~
* c-decl.c (va_list_type_node): New global.
(init_decl_processing): Initialize it. Declare builtins for
va_list, varargs_start, stdargs_start, and va_end.
* c-parse.gperf (__builtin_va_arg): New.
* c-parse.in (VA_ARG): New terminal.
(unary_expr): Recognize __builtin_va_arg.
* c-tree.h (build_va_arg): Declare.
* c-typeck.c (build_va_arg): New function.
* tree.def (VA_ARG_EXPR): New code.
* expr.c (expand_expr): Handle it.
(expand_builtin_va_start): New function.
(expand_builtin_va_arg): New function.
(expand_builtin_va_end): New function.
(get_varargs_alias_set): New function.
(expand_builtin_next_arg): New function split out of ...
(expand_builtin): ... here. Handle va_start/va_end.
* expr.h (get_varargs_alias_set): Declare.
* tree.h (BUILT_IN_VARARGS_START): New.
(BUILT_IN_STDARG_START, BUILT_IN_VA_END): New.
(ptr_type_node, va_list_type_node): Declare.
* alpha.c (alpha_builtin_saveregs): Delete.
(alpha_build_va_list): New function.
(alpha_va_start, alpha_va_arg): New functions.
* alpha.h (SETUP_INCOMING_VARARGS): Set the alias set for the mems.
(EXPAND_BUILTIN_SAVEREGS): Delete.
(BUILD_VA_LIST_TYPE): New.
(EXPAND_BUILTIN_VA_START): New.
(EXPAND_BUILTIN_VA_ARG): New.
More information about the Gcc-patches
mailing list