From patchwork Fri Oct 8 13:58:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 67201 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C51BFB70CB for ; Sat, 9 Oct 2010 00:59:28 +1100 (EST) Received: (qmail 8127 invoked by alias); 8 Oct 2010 13:58:38 -0000 Received: (qmail 7884 invoked by uid 22791); 8 Oct 2010 13:58:31 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Oct 2010 13:58:25 +0000 Received: (qmail 30845 invoked from network); 8 Oct 2010 13:58:22 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Oct 2010 13:58:22 -0000 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: rth@redhat.com Subject: [alpha] hookize FUNCTION_ARG &co. Date: Fri, 8 Oct 2010 09:58:20 -0400 Message-Id: <1286546300-17366-1-git-send-email-froydnj@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The patch below hookizes FUNCTION_ARG and related macros for the alpha backend. The only odd thing is the deletion of the TARGET_ABI_UNICOSMK hunk in alpha_function_arg, which I suppose could (ought to?) be left in. AFAICS, though, that code is dead. Tested by inspection with cross to alpha-linux-gnu. I plan to commit this under the obvious rule after waiting a week for comments/approval. * config/alpha/alpha-protos.h (function_arg): Delete. * config/alpha/alpha.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete. * config/alpha/vms.h (FUNCTION_ARG_ADVANCE): Delete. * config/alpha/alpha.c (function_arg): Rename to... (alpha_function_arg): ...this. Make static. Take a const_tree and a bool. Delete TARGET_ABI_UNICOSMK code. (alpha_function_arg_advance): New function. (TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define. --- gcc/config/alpha/alpha-protos.h | 1 - gcc/config/alpha/alpha.c | 112 ++++++++++++++------------------------- gcc/config/alpha/alpha.h | 28 ---------- gcc/config/alpha/vms.h | 12 ---- 4 files changed, 39 insertions(+), 114 deletions(-) diff --git a/gcc/config/alpha/alpha-protos.h b/gcc/config/alpha/alpha-protos.h index 4b5e673..7477169 100644 --- a/gcc/config/alpha/alpha-protos.h +++ b/gcc/config/alpha/alpha-protos.h @@ -74,7 +74,6 @@ extern void print_operand_address (FILE *, rtx); extern void alpha_initialize_trampoline (rtx, rtx, rtx, int, int, int); extern rtx alpha_va_arg (tree, tree); -extern rtx function_arg (CUMULATIVE_ARGS, enum machine_mode, tree, int); extern rtx function_value (const_tree, const_tree, enum machine_mode); extern void alpha_start_function (FILE *, const char *, tree); diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 46627e3..def7ef2 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -5634,9 +5634,9 @@ alpha_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value) On Alpha the first 6 words of args are normally in registers and the rest are pushed. */ -rtx -function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, tree type, - int named ATTRIBUTE_UNUSED) +static rtx +alpha_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, + const_tree type, bool named ATTRIBUTE_UNUSED) { int basereg; int num_args; @@ -5661,87 +5661,22 @@ function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, tree type, } /* ??? Irritatingly, the definition of CUMULATIVE_ARGS is different for - the three platforms, so we can't avoid conditional compilation. */ + the two platforms, so we can't avoid conditional compilation. */ #if TARGET_ABI_OPEN_VMS { if (mode == VOIDmode) return alpha_arg_info_reg_val (cum); - num_args = cum.num_args; + num_args = cum->num_args; if (num_args >= 6 || targetm.calls.must_pass_in_stack (mode, type)) return NULL_RTX; } -#elif TARGET_ABI_UNICOSMK - { - int size; - - /* If this is the last argument, generate the call info word (CIW). */ - /* ??? We don't include the caller's line number in the CIW because - I don't know how to determine it if debug infos are turned off. */ - if (mode == VOIDmode) - { - int i; - HOST_WIDE_INT lo; - HOST_WIDE_INT hi; - rtx ciw; - - lo = 0; - - for (i = 0; i < cum.num_reg_words && i < 5; i++) - if (cum.reg_args_type[i]) - lo |= (1 << (7 - i)); - - if (cum.num_reg_words == 6 && cum.reg_args_type[5]) - lo |= 7; - else - lo |= cum.num_reg_words; - -#if HOST_BITS_PER_WIDE_INT == 32 - hi = (cum.num_args << 20) | cum.num_arg_words; -#else - lo = lo | ((HOST_WIDE_INT) cum.num_args << 52) - | ((HOST_WIDE_INT) cum.num_arg_words << 32); - hi = 0; -#endif - ciw = immed_double_const (lo, hi, DImode); - - return gen_rtx_UNSPEC (DImode, gen_rtvec (1, ciw), - UNSPEC_UMK_LOAD_CIW); - } - - size = ALPHA_ARG_SIZE (mode, type, named); - num_args = cum.num_reg_words; - if (cum.force_stack - || cum.num_reg_words + size > 6 - || targetm.calls.must_pass_in_stack (mode, type)) - return NULL_RTX; - else if (type && TYPE_MODE (type) == BLKmode) - { - rtx reg1, reg2; - - reg1 = gen_rtx_REG (DImode, num_args + 16); - reg1 = gen_rtx_EXPR_LIST (DImode, reg1, const0_rtx); - - /* The argument fits in two registers. Note that we still need to - reserve a register for empty structures. */ - if (size == 0) - return NULL_RTX; - else if (size == 1) - return gen_rtx_PARALLEL (mode, gen_rtvec (1, reg1)); - else - { - reg2 = gen_rtx_REG (DImode, num_args + 17); - reg2 = gen_rtx_EXPR_LIST (DImode, reg2, GEN_INT (8)); - return gen_rtx_PARALLEL (mode, gen_rtvec (2, reg1, reg2)); - } - } - } #elif TARGET_ABI_OSF { - if (cum >= 6) + if (*cum >= 6) return NULL_RTX; - num_args = cum; + num_args = *cum; /* VOID is passed as a special flag for "last argument". */ if (type == void_type_node) @@ -5756,6 +5691,33 @@ function_arg (CUMULATIVE_ARGS cum, enum machine_mode mode, tree type, return gen_rtx_REG (mode, num_args + basereg); } +/* Update the data in CUM to advance over an argument + of mode MODE and data type TYPE. + (TYPE is null for libcalls where that information may not be available.) */ + +static void +alpha_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode, + const_tree type, bool named) +{ +#if TARGET_ABI_OPEN_VMS + if (targetm.calls.must_pass_in_stack (mode, type)) + cum->num_args += 6; + else + { + if (cum->num_args < 6) + cum->atypes[cum->num_args] = alpha_arg_type (mode); + + cum->num_args += ALPHA_ARG_SIZE (mode, type, named); + } +#elif TARGET_ABI_OSF + *cum += (targetm.calls.must_pass_in_stack (mode, type) + ? 6 + : ALPHA_ARG_SIZE (mode, type, named)); +#else +#error Unhandled ABI +#endif +} + static int alpha_arg_partial_bytes (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED, enum machine_mode mode ATTRIBUTE_UNUSED, @@ -6183,7 +6145,7 @@ alpha_setup_incoming_varargs (CUMULATIVE_ARGS *pcum, enum machine_mode mode, CUMULATIVE_ARGS cum = *pcum; /* Skip the current argument. */ - FUNCTION_ARG_ADVANCE (cum, mode, type, 1); + targetm.calls.function_arg_advance (cum, mode, type, true); #if TARGET_ABI_UNICOSMK /* On Unicos/Mk, the standard subroutine __T3E_MISMATCH stores all register @@ -11149,6 +11111,10 @@ alpha_init_libfuncs (void) #define TARGET_GIMPLIFY_VA_ARG_EXPR alpha_gimplify_va_arg #undef TARGET_ARG_PARTIAL_BYTES #define TARGET_ARG_PARTIAL_BYTES alpha_arg_partial_bytes +#undef TARGET_FUNCTION_ARG +#define TARGET_FUNCTION_ARG alpha_function_arg +#undef TARGET_FUNCTION_ARG_ADVANCE +#define TARGET_FUNCTION_ARG_ADVANCE alpha_function_arg_advance #undef TARGET_TRAMPOLINE_INIT #define TARGET_TRAMPOLINE_INIT alpha_trampoline_init diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h index bdf3159..66e215a 100644 --- a/gcc/config/alpha/alpha.h +++ b/gcc/config/alpha/alpha.h @@ -749,34 +749,6 @@ extern int alpha_memory_latency; : (((MODE) == BLKmode ? int_size_in_bytes (TYPE) : GET_MODE_SIZE (MODE)) \ + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD) -/* Update the data in CUM to advance over an argument - of mode MODE and data type TYPE. - (TYPE is null for libcalls where that information may not be available.) */ - -#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ - ((CUM) += \ - (targetm.calls.must_pass_in_stack (MODE, TYPE)) \ - ? 6 : ALPHA_ARG_SIZE (MODE, TYPE, NAMED)) - -/* Determine where to put an argument to a function. - Value is zero to push the argument on the stack, - or a hard register in which to store the argument. - - MODE is the argument's machine mode. - TYPE is the data type of the argument (as a tree). - This is null for libcalls where that information may - not be available. - CUM is a variable of type CUMULATIVE_ARGS which gives info about - the preceding args and about the function being called. - NAMED is nonzero if this argument is a named parameter - (otherwise it is an extra parameter matching an ellipsis). - - On Alpha the first 6 words of args are normally in registers - and the rest are pushed. */ - -#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ - function_arg((CUM), (MODE), (TYPE), (NAMED)) - /* Make (or fake) .linkage entry for function call. IS_LOCAL is 0 if name is used in call, 1 if name is used in definition. */ diff --git a/gcc/config/alpha/vms.h b/gcc/config/alpha/vms.h index 38b2068..2c151a7 100644 --- a/gcc/config/alpha/vms.h +++ b/gcc/config/alpha/vms.h @@ -175,18 +175,6 @@ typedef struct {int num_args; enum avms_arg_type atypes[6];} avms_arg_info; (CUM).atypes[0] = (CUM).atypes[1] = (CUM).atypes[2] = I64; \ (CUM).atypes[3] = (CUM).atypes[4] = (CUM).atypes[5] = I64; -#undef FUNCTION_ARG_ADVANCE -#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ - if (targetm.calls.must_pass_in_stack (MODE, TYPE)) \ - (CUM).num_args += 6; \ - else \ - { \ - if ((CUM).num_args < 6) \ - (CUM).atypes[(CUM).num_args] = alpha_arg_type (MODE); \ - \ - (CUM).num_args += ALPHA_ARG_SIZE (MODE, TYPE, NAMED); \ - } - #define DEFAULT_PCC_STRUCT_RETURN 0 #undef ASM_WEAKEN_LABEL