From patchwork Wed Mar 23 19:13:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Sokolov X-Patchwork-Id: 88109 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 7AD99B6EF0 for ; Thu, 24 Mar 2011 06:14:17 +1100 (EST) Received: (qmail 6756 invoked by alias); 23 Mar 2011 19:14:12 -0000 Received: (qmail 6746 invoked by uid 22791); 23 Mar 2011 19:14:10 -0000 X-SWARE-Spam-Status: No, hits=0.8 required=5.0 tests=AWL, BAYES_00, KAM_THEBAT, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from contrabass.post.ru (HELO contrabass.corbina.net) (85.21.78.5) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Mar 2011 19:14:04 +0000 Received: from corbina.ru (mail.post.ru [195.14.50.16]) by contrabass.corbina.net (Postfix) with ESMTP id D13F0CBFB7; Wed, 23 Mar 2011 22:14:02 +0300 (MSK) Received: from [95.26.144.10] (account aesok@post.ru HELO Vista.corbina.ru) by corbina.ru (CommuniGate Pro SMTP 5.1.14) with ESMTPA id 310817127; Wed, 23 Mar 2011 22:14:02 +0300 Date: Wed, 23 Mar 2011 22:13:09 +0300 From: Anatoly Sokolov Message-ID: <1409384763.20110323221309@post.ru> To: gcc-patches CC: echristo@apple.com, rdsandiford@googlemail.com Subject: [MIPS] Hookize FUNCTION_VALUE, LIBCALL_VALUE and FUNCTION_VALUE_REGNO_P MIME-Version: 1.0 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 Hello. This patch removes obsolete FUNCTION_VALUE, LIBCALL_VALUE and FUNCTION_VALUE_REGNO_P macros from MIPS back end in the GCC and introduces equivalent TARGET_FUNCTION_VALUE, TARGET_LIBCALL_VALUE and TARGET_FUNCTION_VALUE_REGNO_P target hooks. Bootstrapped and regression tested on mips64el-unknown-linux-gnu. OK to install? * config/mips/mips.h (LIBCALL_VALUE, FUNCTION_VALUE, FUNCTION_VALUE_REGNO_P): Remove macros. * config/mips/mips-protos.h (mips_function_value): Remove. * config/mips/mips.c (mips_function_value): Rename to... (mips_function_value_1): ... this. Make static. Handle receiving the function type in 'fn_decl_or_type' argument. (mips_function_value, mips_libcall_value, mips_function_value_regno_p): New function. (TARGET_FUNCTION_VALUE, TARGET_LIBCALL_VALUE, TARGET_FUNCTION_VALUE_REGNO_P): Define. Anatoly. Index: gcc/config/mips/mips-protos.h =================================================================== --- gcc/config/mips/mips-protos.h (revision 171355) +++ gcc/config/mips/mips-protos.h (working copy) @@ -277,7 +277,6 @@ extern void mips_expand_before_return (void); extern void mips_expand_epilogue (bool); extern bool mips_can_use_return_insn (void); -extern rtx mips_function_value (const_tree, const_tree, enum machine_mode); extern bool mips_cannot_change_mode_class (enum machine_mode, enum machine_mode, enum reg_class); Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c (revision 171355) +++ gcc/config/mips/mips.c (working copy) @@ -5247,18 +5247,24 @@ } -/* Implement FUNCTION_VALUE and LIBCALL_VALUE. For normal calls, - VALTYPE is the return type and MODE is VOIDmode. For libcalls, - VALTYPE is null and MODE is the mode of the return value. */ +/* Implement TARGET_FUNCTION_VALUE and TERGET_LIBCALL_VALUE. + For normal calls, VALTYPE is the return type and MODE is VOIDmode. + For libcalls, VALTYPE is null and MODE is the mode of the return value. */ -rtx -mips_function_value (const_tree valtype, const_tree func, enum machine_mode mode) +static rtx +mips_function_value_1 (const_tree valtype, const_tree fn_decl_or_type, + enum machine_mode mode) { if (valtype) { tree fields[2]; int unsigned_p; + const_tree func = fn_decl_or_type; + if (fn_decl_or_type + && !DECL_P (fn_decl_or_type)) + func = NULL; + mode = TYPE_MODE (valtype); unsigned_p = TYPE_UNSIGNED (valtype); @@ -5324,6 +5330,42 @@ return gen_rtx_REG (mode, GP_RETURN); } +/* Implement TARGET_FUNCTION_VALUE. */ + +static rtx +mips_function_value (const_tree valtype, const_tree fn_decl_or_type, + bool outgoing ATTRIBUTE_UNUSED) +{ + return mips_function_value_1 (valtype, fn_decl_or_type, VOIDmode); +} + +/* Implement TARGET_LIBCALL_VALUE. */ + +static rtx +mips_libcall_value (enum machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED) +{ + return mips_function_value_1 (NULL_TREE, NULL_TREE, mode); +} + +/* Implement TARGET_FUNCTION_VALUE_REGNO_P. + + Returns true if N is a possible register number for a function value. + On the MIPS, R2 R3 and F0 F2 are the only register thus used. + Currently, R2 and F0 are only implemented here (C has no complex type) */ + +static bool +mips_function_value_regno_p (const unsigned int regno) +{ + if (regno == GP_RETURN + || regno == FP_RETURN + || (LONG_DOUBLE_TYPE_SIZE == 128 + && FP_RETURN != GP_RETURN + && regno == FP_RETURN + 2)) + return true; + + return false; +} + /* Implement TARGET_RETURN_IN_MEMORY. Under the o32 and o64 ABIs, all BLKmode objects are returned in memory. Under the n32, n64 and embedded ABIs, small structures are returned in a register. @@ -16521,6 +16563,12 @@ #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true +#undef TARGET_FUNCTION_VALUE +#define TARGET_FUNCTION_VALUE mips_function_value +#undef TARGET_LIBCALL_VALUE +#define TARGET_LIBCALL_VALUE mips_libcall_value +#undef TARGET_FUNCTION_VALUE_REGNO_P +#define TARGET_FUNCTION_VALUE_REGNO_P mips_function_value_regno_p #undef TARGET_RETURN_IN_MEMORY #define TARGET_RETURN_IN_MEMORY mips_return_in_memory #undef TARGET_RETURN_IN_MSB Index: gcc/config/mips/mips.h =================================================================== --- gcc/config/mips/mips.h (revision 171355) +++ gcc/config/mips/mips.h (working copy) @@ -2150,20 +2150,6 @@ #define FP_ARG_FIRST (FP_REG_FIRST + 12) #define FP_ARG_LAST (FP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1) -#define LIBCALL_VALUE(MODE) \ - mips_function_value (NULL_TREE, NULL_TREE, MODE) - -#define FUNCTION_VALUE(VALTYPE, FUNC) \ - mips_function_value (VALTYPE, FUNC, VOIDmode) - -/* 1 if N is a possible register number for a function value. - On the MIPS, R2 R3 and F0 F2 are the only register thus used. - Currently, R2 and F0 are only implemented here (C has no complex type) */ - -#define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_RETURN || (N) == FP_RETURN \ - || (LONG_DOUBLE_TYPE_SIZE == 128 && FP_RETURN != GP_RETURN \ - && (N) == FP_RETURN + 2)) - /* 1 if N is a possible register number for function argument passing. We have no FP argument registers when soft-float. When FP registers are 32 bits, we can't directly reference the odd numbered ones. */