From patchwork Mon Jan 13 19:17:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 310343 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 386412C008F for ; Tue, 14 Jan 2014 06:18:00 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject; q=dns; s=default; b=pSDC9y3KeIvztu3 EDBNWzV4gyZvviPlGjW5lUUXhSiDnu8oo0l8f46Ts7OZXWd4oJ7uXywR5mUtpUrr XWjtPqtQoC1C9AlJNrXtb73mTM/NTm1sInq7/JgBBJPwa+YIEpEQmEobC6q6pDSI b9kqI3dpFLDUxECSoHI5ZrcmCY1M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :message-id:from:to:subject; s=default; bh=Yk+bgZpUPp9BZBmCSvFKE BLAxIY=; b=LvPE7DPuxcM72JrBWMMMKrIFU1ZnnTnrTRbL4RSMWtbFsUQBFyYhL FqPEFSxhHOV0PZtbxtwuLVfGr6JjqzB+bfyt/IH0ZYrujZXKFga654VFdsXnTPec /QNyOkaXg5RPrBgNNlDfrFeI0+EMY3a14rEtv7nC707F/WmrnGZR1Q= Received: (qmail 15967 invoked by alias); 13 Jan 2014 19:17:53 -0000 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 Received: (qmail 15957 invoked by uid 89); 13 Jan 2014 19:17:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 13 Jan 2014 19:17:51 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0DJHoHU006259 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Jan 2014 14:17:50 -0500 Received: from greed.delorie.com (ovpn-113-33.phx2.redhat.com [10.3.113.33]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0DJHnKH019364 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 13 Jan 2014 14:17:50 -0500 Received: from greed.delorie.com (greed.delorie.com [127.0.0.1]) by greed.delorie.com (8.14.4/8.14.4) with ESMTP id s0DJHmcR018852 for ; Mon, 13 Jan 2014 14:17:48 -0500 Received: (from dj@localhost) by greed.delorie.com (8.14.4/8.14.4/Submit) id s0DJHmbn018851; Mon, 13 Jan 2014 14:17:48 -0500 Date: Mon, 13 Jan 2014 14:17:48 -0500 Message-Id: <201401131917.s0DJHmbn018851@greed.delorie.com> From: DJ Delorie To: gcc-patches@gcc.gnu.org Subject: [msp430] fix call-via-sp and epilogue helper patterns X-IsSubscribed: yes The call change avoids a problem on hardware where indirect calls that use SP as a base register don't seem to do what you expect. The 'J' one fixes a link-time error wrt epilogue helper functions. Committed. * config/msp430/msp430.md (call_internal): Don't allow memory references with SP as the base register. (call_value_internal): Likewise. * config/msp430/constraints.md (Yc): New. For memory references that don't use SP as a base register. * config/msp430/msp430.c (msp430_print_operand): Add 'J' to mean "an integer without a # prefix" * config/msp430/msp430.md (epilogue_helper): Use it. Index: config/msp430/msp430.md =================================================================== --- config/msp430/msp430.md (revision 206582) +++ config/msp430/msp430.md (working copy) @@ -917,13 +917,13 @@ ) (define_insn "epilogue_helper" [(unspec_volatile [(match_operand 0 "immediate_operand" "i")] UNS_EPILOGUE_HELPER)] "" - "BR%Q0\t#__mspabi_func_epilog_%0" + "BR%Q0\t#__mspabi_func_epilog_%J0" ) (define_insn "prologue_start_marker" [(unspec_volatile [(const_int 0)] UNS_PROLOGUE_START_MARKER)] "" @@ -950,13 +950,13 @@ (match_operand 1 ""))] "" "" ) (define_insn "call_internal" - [(call (mem:HI (match_operand 0 "general_operand" "rmi")) + [(call (mem:HI (match_operand 0 "general_operand" "rYci")) (match_operand 1 ""))] "" "CALL%Q0\t%0" ) (define_expand "call_value" @@ -966,13 +966,13 @@ "" "" ) (define_insn "call_value_internal" [(set (match_operand 0 "register_operand" "=r") - (call (mem:HI (match_operand 1 "general_operand" "rmi")) + (call (mem:HI (match_operand 1 "general_operand" "rYci")) (match_operand 2 "")))] "" "CALL%Q0\t%1" ) (define_insn "msp_return" Index: config/msp430/constraints.md =================================================================== --- config/msp430/constraints.md (revision 206582) +++ config/msp430/constraints.md (working copy) @@ -67,6 +67,19 @@ (and (match_code "plus" "0") (and (match_code "reg" "00") (match_test ("CONST_INT_P (XEXP (XEXP (op, 0), 1))")) (match_test ("IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), -1 << 15, (1 << 15)-1)")))) (match_code "reg" "0") ))) + +(define_constraint "Yc" + "Memory reference, for CALL - we can't use SP" + (and (match_code "mem") + (match_code "mem" "0") + (not (ior + (and (match_code "plus" "00") + (and (match_code "reg" "000") + (match_test ("REGNO (XEXP (XEXP (op, 0), 0)) != SP_REGNO")))) + (and (match_code "reg" "0") + (match_test ("REGNO (XEXP (XEXP (op, 0), 0)) != SP_REGNO"))) + )))) + Index: config/msp430/msp430.c =================================================================== --- config/msp430/msp430.c (revision 206582) +++ config/msp430/msp430.c (working copy) @@ -1917,12 +1917,13 @@ msp430_print_operand_addr (FILE * file, /* A low 16-bits of int/lower of register pair B high 16-bits of int/higher of register pair C bits 32-47 of a 64-bit value/reg 3 of a DImode value D bits 48-63 of a 64-bit value/reg 4 of a DImode value H like %B (for backwards compatibility) I inverse of value + J an integer without a # prefix L like %A (for backwards compatibility) O offset of the top of the stack Q like X but generates an A postfix R inverse of condition code, unsigned. X X instruction postfix in large mode Y value - 4 @@ -1947,13 +1948,12 @@ msp430_print_operand (FILE * file, rtx o return; case 'Y': gcc_assert (CONST_INT_P (op)); /* Print the constant value, less four. */ fprintf (file, "#%ld", INTVAL (op) - 4); return; - /* case 'D': used for "decimal without '#'" */ case 'I': if (GET_CODE (op) == CONST_INT) { /* Inverse of constants */ int i = INTVAL (op); fprintf (file, "%d", ~i); @@ -2107,12 +2107,14 @@ msp430_print_operand (FILE * file, rtx o because builtins are expanded before the frame layout is determined. */ fprintf (file, "%d", msp430_initial_elimination_offset (ARG_POINTER_REGNUM, STACK_POINTER_REGNUM) - 2); return; + case 'J': + gcc_assert (GET_CODE (op) == CONST_INT); case 0: break; default: output_operand_lossage ("invalid operand prefix"); return; }