From patchwork Tue Oct 19 10:25:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 68303 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 1AEB4B70DD for ; Tue, 19 Oct 2010 21:25:42 +1100 (EST) Received: (qmail 2514 invoked by alias); 19 Oct 2010 10:25:39 -0000 Received: (qmail 2492 invoked by uid 22791); 19 Oct 2010 10:25:39 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_FN, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Oct 2010 10:25:34 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9JAPXAd000697 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 19 Oct 2010 06:25:33 -0400 Received: from Gift.redhat.com (vpn1-7-9.ams2.redhat.com [10.36.7.9]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9JAPTFG022488 for ; Tue, 19 Oct 2010 06:25:32 -0400 From: Nick Clifton To: gcc-patches@gcc.gnu.org Subject: RX: Promote small integers to SImode Date: Tue, 19 Oct 2010 11:25:28 +0100 Message-ID: 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 Hi Guys, I am applying the patch below to fix a small problem with the RX GCC port. The RX ABI specifies that functions that return small integers (less than 32-bits) should promote them to 32-bits, so this patch implements the TARGET_PROMOTE_FUNCTION_MODE macro and also updates rx_function_value to describe this behaviour. This actually makes no change to gcc's current behaviour, but I have put it in to ensure compatibility with Renesas's own C compiler. Cheers Nick gcc/ChangeLog 2010-10-19 Nick Clifton * config/rx/rx.c (rx_function_value): Small integer types are promotes to SImode. (rx_promote_function_mode): New function. (TARGET_PROMOTE_FUNCTION_MODE): Define. Index: config/rx/rx.c =================================================================== --- config/rx/rx.c (revision 165680) +++ config/rx/rx.c (working copy) @@ -830,9 +830,34 @@ const_tree fn_decl_or_type ATTRIBUTE_UNUSED, bool outgoing ATTRIBUTE_UNUSED) { - return gen_rtx_REG (TYPE_MODE (ret_type), FUNC_RETURN_REGNUM); + enum machine_mode mode = TYPE_MODE (ret_type); + + /* RX ABI specifies that small integer types are + promoted to int when returned by a function. */ + if (GET_MODE_SIZE (mode) > 0 && GET_MODE_SIZE (mode) < 4) + return gen_rtx_REG (SImode, FUNC_RETURN_REGNUM); + + return gen_rtx_REG (mode, FUNC_RETURN_REGNUM); } +/* TARGET_PROMOTE_FUNCTION_MODE must behave in the same way with + regard to function returns as does TARGET_FUNCTION_VALUE. */ + +static enum machine_mode +rx_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, + enum machine_mode mode, + int * punsignedp, + const_tree funtype ATTRIBUTE_UNUSED, + int for_return) +{ + if (for_return != 1 + || GET_MODE_SIZE (mode) >= 4 + || GET_MODE_SIZE (mode) < 1) + return mode; + + return SImode; +} + static bool rx_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) { @@ -2825,6 +2850,9 @@ #undef TARGET_OPTION_OVERRIDE #define TARGET_OPTION_OVERRIDE rx_option_override +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE rx_promote_function_mode + #undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE #define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE rx_override_options_after_change