From patchwork Thu Jan 13 17:20:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 78777 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 C2E9AB6F14 for ; Fri, 14 Jan 2011 04:19:53 +1100 (EST) Received: (qmail 16629 invoked by alias); 13 Jan 2011 17:19:49 -0000 Received: (qmail 16610 invoked by uid 22791); 13 Jan 2011 17:19:47 -0000 X-SWARE-Spam-Status: No, hits=-6.0 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; Thu, 13 Jan 2011 17:19:43 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0DHJf2i012607 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 13 Jan 2011 12:19:41 -0500 Received: from Gift.redhat.com (vpn2-8-112.ams2.redhat.com [10.36.8.112]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0DHJcs3022388 for ; Thu, 13 Jan 2011 12:19:40 -0500 From: Nick Clifton To: gcc-patches@gcc.gnu.org Subject: RX: Import patch Date: Thu, 13 Jan 2011 17:20:15 +0000 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 importing a RX backend patch from the mainline to the 4.5 branch. This patch fixes the promotion of returned small integer types: Cheers Nick gcc/ChangeLog 2011-01-13 Nick Clifton Import this fix from the mainline: 2010-10-19 Nick Clifton * config/rx/rx.c (rx_function_value): Small integer types are promoted to SImode. (rx_promote_function_mode): New function. (TARGET_PROMOTE_FUNCTION_MODE): Define. Index: gcc/config/rx/rx.c =================================================================== --- gcc/config/rx/rx.c (revision 168743) +++ gcc/config/rx/rx.c (working copy) @@ -821,9 +821,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 ATTRIBUTE_UNUSED, + 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) { @@ -2759,6 +2784,9 @@ #undef TARGET_CC_MODES_COMPATIBLE #define TARGET_CC_MODES_COMPATIBLE rx_cc_modes_compatible +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE rx_promote_function_mode + struct gcc_target targetm = TARGET_INITIALIZER; /* #include "gt-rx.h" */