From bc092c4a3c9f4ef9a79f5444a4963f1d1fb1ba0a Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 6 Sep 1999 15:05:26 -0700 Subject: [PATCH] v850.h (EXPAND_BUILTIN_VA_ARG): New. * v850.h (EXPAND_BUILTIN_VA_ARG): New. * v850.c (v850_va_arg): New. From-SVN: r29146 --- gcc/ChangeLog | 5 +++++ gcc/config/v850/v850.c | 42 ++++++++++++++++++++++++++++++++++++++++++ gcc/config/v850/v850.h | 5 +++++ 3 files changed, 52 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4871d1ae99f..fb9af085898 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Mon Sep 6 15:04:55 1999 Richard Henderson + + * v850.h (EXPAND_BUILTIN_VA_ARG): New. + * v850.c (v850_va_arg): New. + Tue Sep 7 09:36:01 1999 Michael Hayes * haifa-sched.c: Tidy comments. diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index 44148b0dbb7..2b9b5981315 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -3150,3 +3150,45 @@ v850_set_default_decl_attr (decl) } } } + +/* Implement `va_arg'. */ + +rtx +v850_va_arg (valist, type) + tree valist, type; +{ + HOST_WIDE_INT size, rsize, align; + tree addr, incr; + rtx addr_rtx; + int indirect; + + /* Round up sizeof(type) to a word. */ + size = int_size_in_bytes (type); + rsize = (size + UNITS_PER_WORD - 1) & -UNITS_PER_WORD; + indirect = 0; + + if (size > 8) + { + size = rsize = UNITS_PER_WORD; + indirect = 1; + } + + addr = save_expr (valist); + incr = fold (build (PLUS_EXPR, ptr_type_node, valist, + build_int_2 (rsize, 0))); + + incr = build (MODIFY_EXPR, ptr_type_node, valist, incr); + TREE_SIDE_EFFECTS (incr) = 1; + expand_expr (incr, const0_rtx, VOIDmode, EXPAND_NORMAL); + + addr_rtx = expand_expr (addr, NULL, Pmode, EXPAND_NORMAL); + + if (indirect) + { + addr_rtx = force_reg (Pmode, addr_rtx); + addr_rtx = gen_rtx_MEM (Pmode, addr_rtx); + MEM_ALIAS_SET (addr_rtx) = get_varargs_alias_set (); + } + + return addr_rtx; +} diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h index 92483cc80cd..b045f830d39 100644 --- a/gcc/config/v850/v850.h +++ b/gcc/config/v850/v850.h @@ -735,6 +735,10 @@ extern int current_function_anonymous_args; #define SETUP_INCOMING_VARARGS(CUM, MODE, TYPE, PAS, SECOND) \ current_function_anonymous_args = (!TARGET_GHS ? 1 : 0); +/* Implement `va_arg'. */ +#define EXPAND_BUILTIN_VA_ARG(valist, type) \ + v850_va_arg (valist, type) + #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \ ((TYPE) && int_size_in_bytes (TYPE) > 8) @@ -1663,3 +1667,4 @@ extern int v850_handle_pragma PROTO ((int (*)(void), void (*)(int) extern void v850_encode_data_area (); extern void v850_set_default_decl_attr (); extern v850_data_area v850_get_data_area (); +extern struct rtx_def *v850_va_arg ();