From patchwork Tue Jan 17 15:37:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 136494 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 3946BB6F68 for ; Wed, 18 Jan 2012 02:40:30 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1327419631; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: From:To:Subject:Date:Message-ID:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=mg/p9DdLPDuFKAad+52x qzfDrW8=; b=U2IkGKBZyU+URA0IDU6QQdeSKjch8u1R3oV0TeX2t7PYTNN2mmur i73mvqSmXd5fUrWEFYMjYnA4wCjifIzgLPozf6RNQArwzDHeYm9RM2jK83LfKFTp cFyYGAASTY+wVyAMtpHtm5p/HUC1NZ8/qRnVZ8sg5Jrn/rp98wbeF5M= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=fA30ySEo+QwSz6r3n+/8e1rGPuBq2Gi4TefLnnMr0Ttbwfcb4SYO83Pj1FOvDk 0PunYsbiAoJEJla42OXQoOiMaTRfr6pHyulSVJgOi3D0ULLJI4pL2ctp6JME7i1o 1Za8Vt/cVF0pDzXtRQLEMvdVdpdGd4V9lsOmApvkkG8/k=; Received: (qmail 9642 invoked by alias); 17 Jan 2012 15:40:27 -0000 Received: (qmail 9627 invoked by uid 22791); 17 Jan 2012 15:40:26 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, 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, 17 Jan 2012 15:40:13 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0HFeDpM010232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Jan 2012 10:40:13 -0500 Received: from Gift.redhat.com (vpn1-7-167.ams2.redhat.com [10.36.7.167]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q0HFdHbf030562 for ; Tue, 17 Jan 2012 10:39:51 -0500 From: Nick Clifton To: gcc-patches@gcc.gnu.org Subject: Commit: RX: Predicate return pattern Date: Tue, 17 Jan 2012 15:37:56 +0000 Message-ID: <8739be5oh7.fsf@redhat.com> 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, As pointed out by Richard Henderson the new return pattern in the RX backend should only be used when it is possible to return with just a simple RTS instruction, so I am checking in the patch below to implement this. Cheers Nick gcc/ChangeLog 2012-01-17 Nick Clifton * config/rx/rx.c (rx_can_use_simple_return): New function. * config/rx/rx-protos.h (rx_can_use_simple_return): Prototype. * config/rx/rx.md (return): Predicate on rx_can_use_simple_return. Index: gcc/config/rx/rx-protos.h =================================================================== --- gcc/config/rx/rx-protos.h (revision 183234) +++ gcc/config/rx/rx-protos.h (working copy) @@ -21,6 +22,8 @@ #ifndef GCC_RX_PROTOS_H #define GCC_RX_PROTOS_H +extern bool rx_can_use_simple_return (void); +extern void rx_expand_epilogue (bool); extern void rx_expand_prologue (void); extern int rx_initial_elimination_offset (int, int); @@ -29,7 +32,6 @@ extern int rx_align_for_label (rtx, int); extern void rx_emit_stack_popm (rtx *, bool); extern void rx_emit_stack_pushm (rtx *); -extern void rx_expand_epilogue (bool); extern char * rx_gen_move_template (rtx *, bool); extern bool rx_is_legitimate_constant (enum machine_mode, rtx); extern bool rx_is_restricted_memory_address (rtx, Index: gcc/config/rx/rx.md =================================================================== --- gcc/config/rx/rx.md (revision 183234) +++ gcc/config/rx/rx.md (working copy) @@ -342,7 +343,7 @@ (define_expand "return" [(return)] - "" + "rx_can_use_simple_return ()" "rx_expand_epilogue (false); DONE;" ) Index: gcc/config/rx/rx.c =================================================================== --- gcc/config/rx/rx.c (revision 183234) +++ gcc/config/rx/rx.c (working copy) @@ -1818,7 +1819,31 @@ return vector; } - + +/* Returns true if a simple return insn can be used. */ + +bool +rx_can_use_simple_return (void) +{ + unsigned int low; + unsigned int high; + unsigned int frame_size; + unsigned int stack_size; + unsigned int register_mask; + + if (is_naked_func (NULL_TREE) + || is_fast_interrupt_func (NULL_TREE) + || is_interrupt_func (NULL_TREE)) + return false; + + rx_get_stack_layout (& low, & high, & register_mask, + & frame_size, & stack_size); + + return (register_mask == 0 + && (frame_size + stack_size) == 0 + && low == 0); +} + void rx_expand_epilogue (bool is_sibcall) {