From patchwork Tue Jan 15 10:16:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Bruel X-Patchwork-Id: 212066 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 9BE1C2C00A8 for ; Tue, 15 Jan 2013 21:16:52 +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=1358849812; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:Subject:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=xLVfjx3WN+AqyiuJdCCdoMpFC9w=; b=s3ZNsTGNJgGgJSw 73dC470m+3/zU6Wm3dfmUSA4iAIDCBiCct9tk/rAMpSMn+U6LpWLvLGAxM+DPKl3 +3StkhDHwNP1dtWOT67AEev4/4ho8BzNwzIVWAwJ1FRVFMYDxLyQVVG8rz0wwv4u OfvN2uzbi+7OXDoefzjHxhvnMBqQ= 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:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=T6PJMZH2nq6pz2oV6ZIM0wVCuyZiOBG0S6F6PGmYE9m5RSXar6hDP6n7i5NBKr 0tJJ0WMku3QnOl9nZnDKlb/d6OVZ/M5NTB/f6ZRRpDJ0Tb9cSdeQTvBsckWUefLG Kle+FOErC1AwSt9O6GEY6n8vmue3DILrmbUElrfd1dz2s=; Received: (qmail 27563 invoked by alias); 15 Jan 2013 10:16:42 -0000 Received: (qmail 27549 invoked by uid 22791); 15 Jan 2013 10:16:41 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from eu1sys200aog113.obsmtp.com (HELO eu1sys200aog113.obsmtp.com) (207.126.144.135) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Jan 2013 10:16:34 +0000 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob113.postini.com ([207.126.147.11]) with SMTP ID DSNKUPUsfPjflojwA9JpUGNAG7fW0JFzT7f7@postini.com; Tue, 15 Jan 2013 10:16:33 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A09AA12F; Tue, 15 Jan 2013 10:16:08 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas4.st.com [10.75.90.69]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E91A02D3D; Tue, 15 Jan 2013 10:16:07 +0000 (GMT) Received: from [164.129.122.89] (164.129.122.89) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.245.1; Tue, 15 Jan 2013 11:16:07 +0100 Message-ID: <50F52C66.3070404@st.com> Date: Tue, 15 Jan 2013 11:16:06 +0100 From: Christian Bruel User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" , Kaz Kojima , Subject: [SH] re-fix the sp_switch attribute 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. It seems that the .md part from the patch posted in http://gcc.gnu.org/ml/gcc-patches/2009-07/msg01797.html is missing after rev 150306 Thus compiling the sp_switch attribute documentation example still fail with an "unrecognizable insn" error. However, after re-applying the missing part (updated with new unspec enums), the test still fails with a "pcrel too far" assembly error because the new stack symbol constant pool entry was not emitted (dump_table not called properly) This patch fixes the sp_switch unspec pattern to be recognized by broken_move, where it is now handled to force a dump_table when necessary. The example from the documentation now compiles fine. Added it to the regression tests. OK for trunk ? ps: Added again the original ChangeLog entry for the missing .md part. Thanks, Christian 2013-01-12 Christian Bruel * config/sh/sh.c (sh_expand_prologue): Postpone new_stack mem symbol. (broken_move): Handle UNSPECV_SP_SWITCH_B. * config/sh/sh.md (sp_switch_1): Use set (reg:SI SP_REG). 2013-01-13 Christian Bruel * gcc.target/sh/sh-switch.c: New testcase. 2013-01-12 DJ Delorie * config/sh/sh.md (UNSPECV_SP_SWITCH_B): New. (UNSPECV_SP_SWITCH_E): New. (sp_switch_1): Change to an unspec. (sp_switch_2): Change to an unspec. Don't use post-inc when we replace $r15. Index: gcc/testsuite/gcc.target/sh/sp-switch.c =================================================================== --- gcc/testsuite/gcc.target/sh/sp-switch.c (revision 0) +++ gcc/testsuite/gcc.target/sh/sp-switch.c (revision 0) @@ -0,0 +1,10 @@ +/* { dg-do compile { target "sh-*-*" } } */ +/* { dg-final { scan-assembler "mov\tr0,r15" } } */ +/* { dg-final { scan-assembler ".long\t_alt_stack" } } */ + +void *alt_stack; +void f() __attribute__ ((interrupt_handler, sp_switch ("alt_stack"))); + +void f() +{ +} Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c (revision 195142) +++ gcc/config/sh/sh.c (working copy) @@ -4926,6 +4926,8 @@ broken_move (rtx insn) order bits end up as. */ && GET_MODE (SET_DEST (pat)) != QImode && (CONSTANT_P (SET_SRC (pat)) + || (GET_CODE (SET_SRC (pat)) == UNSPEC_VOLATILE + && XINT (SET_SRC (pat), 1) == UNSPECV_SP_SWITCH_B) /* Match mova_const. */ || (GET_CODE (SET_SRC (pat)) == UNSPEC && XINT (SET_SRC (pat), 1) == UNSPEC_MOVA @@ -6422,6 +6424,14 @@ sh_reorg (void) gen_rtvec (1, newsrc), UNSPEC_MOVA); } + else if (GET_CODE (src) == UNSPEC_VOLATILE + && XINT (src, 1) == UNSPECV_SP_SWITCH_B) + { + newsrc = XVECEXP (src, 0, 0); + XVECEXP (src, 0, 0) = gen_const_mem (mode, newsrc); + INSN_CODE (scan) = -1; + continue; + } else { lab = add_constant (src, mode, 0); @@ -7624,7 +7634,6 @@ sh_expand_prologue (void) lab = add_constant (sp_switch, SImode, 0); newsrc = gen_rtx_LABEL_REF (VOIDmode, lab); - newsrc = gen_const_mem (SImode, newsrc); emit_insn (gen_sp_switch_1 (newsrc)); } Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 195142) +++ gcc/config/sh/sh.md (working copy) @@ -174,6 +174,8 @@ (UNSPECV_CONST_END 11) (UNSPECV_EH_RETURN 12) (UNSPECV_GBR 13) + (UNSPECV_SP_SWITCH_B 14) + (UNSPECV_SP_SWITCH_E 15) ]) ;; ------------------------------------------------------------------------- @@ -13587,7 +13589,8 @@ label: ;; Switch to a new stack with its address in sp_switch (a SYMBOL_REF). (define_insn "sp_switch_1" - [(const_int 1) (match_operand:SI 0 "symbol_ref_operand" "s")] + [(set (reg:SI SP_REG) (unspec_volatile [(match_operand:SI 0 "" "")] + UNSPECV_SP_SWITCH_B))] "TARGET_SH1" { return "mov.l r0,@-r15" "\n" @@ -13601,10 +13604,11 @@ label: ;; Switch back to the original stack for interrupt functions with the ;; sp_switch attribute. (define_insn "sp_switch_2" - [(const_int 2)] + [(unspec_volatile [(const_int 0)] + UNSPECV_SP_SWITCH_E)] "TARGET_SH1" { - return "mov.l @r15+,r15" "\n" + return "mov.l @r15,r15" "\n" " mov.l @r15+,r0"; } [(set_attr "length" "4")])