From patchwork Fri Dec 13 09:58:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 300978 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 630022C0090 for ; Fri, 13 Dec 2013 21:22:43 +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:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=S+UFSUwv2i2TcgZqW1tAbDGsubR5kRIa4LyxrVrJmTvHquiIh5pWw VgHS0ehdEjz3ggJVGVMIj1xMLCEXx4zrImZiwMDbxMtokJzRAJkI61FAjrthgmbL xw+TGzM3sh+agwzmjGdmxT4xvYIfdsEk+9fLpTFbcG/mcZU0dqefO0= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=EnAGdimlYy/rczsmIGXSt/e8LkM=; b=h+un3ZT+Bi5mQGXtAzRT MHGGPhU11GfVo9vTLpXxIXOWudjaZaDlYfjVFdzGIzBFEAD1ptQhEnJ7f3+IZtwk 3LLKz2uR5fwLseR5MPu7LCuPAln5NXSJrZ5YUxSukgmRUkrrIKKWivHV8Zd1Wfa/ y8rU35JZYgN5iwdRyRC9kJk= Received: (qmail 24303 invoked by alias); 13 Dec 2013 10:22:37 -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 24290 invoked by uid 89); 13 Dec 2013 10:22:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 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; Fri, 13 Dec 2013 10:22:36 +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.14.4/8.14.4) with ESMTP id rBDAKtXh020177 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Dec 2013 05:22:33 -0500 Received: from Cadeux.redhat.com (vpn1-5-6.ams2.redhat.com [10.36.5.6]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBDA1ac3007062 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) for ; Fri, 13 Dec 2013 05:01:37 -0500 From: Nick Clifton To: gcc-patches@gcc.gnu.org Subject: Commit: MSP430: Add wakeup function attribute Date: Fri, 13 Dec 2013 09:58:57 +0000 Message-ID: <8761qtkr6m.fsf@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes [This time with the patch attached] Hi Guys, I have applied the patch below to add support for a wakeup function attribute to the MSP430 backend. The wakeup attribute applies to interrupt functions, and it makes them wake the processor from low power sleep states when the interrupt handler exits. Cheers Nick gcc/ChangeLog 2013-12-13 Nick Clifton * config/msp430/msp430.c (is_wakeup_func): New function. Returns true if the current function has the wakeup attribute. (msp430_start_function): Note if the function has the wakeup attribute. (msp430_attribute_table): Add wakeup attribute. (msp430_expand_epilogue): Add support for wakeup functions. * config/msp430/msp430.md (disable_interrupts): Emit a NOP after the DINT instruction. * doc/extend.texi: Document the wakeup attribute. Index: config/msp430/msp430.c =================================================================== --- config/msp430/msp430.c (revision 205957) +++ config/msp430/msp430.c (working copy) @@ -966,6 +966,12 @@ return is_attr_func ("interrupt"); } +static bool +is_wakeup_func (void) +{ + return msp430_is_interrupt_func () && is_attr_func ("wakeup"); +} + static inline bool is_naked_func (void) { @@ -1005,6 +1011,8 @@ fprintf (outfile, "reentrant "); if (is_critical_func ()) fprintf (outfile, "critical "); + if (is_wakeup_func ()) + fprintf (outfile, "wakeup "); fprintf (outfile, "\n"); } @@ -1131,6 +1139,7 @@ { "naked", 0, 0, true, false, false, msp430_attr, false }, { "reentrant", 0, 0, true, false, false, msp430_attr, false }, { "critical", 0, 0, true, false, false, msp430_attr, false }, + { "wakeup", 0, 0, true, false, false, msp430_attr, false }, { NULL, 0, 0, false, false, false, NULL, false } }; @@ -1409,6 +1418,14 @@ emit_insn (gen_epilogue_start_marker ()); + if (is_wakeup_func ()) + /* Clear the SCG1, SCG0, OSCOFF and CPUOFF bits in the saved copy of the + status register current residing on the stack. When this function + executes its RETI instruction the SR will be updated with this saved + value, thus ensuring that the processor is woken up from any low power + state in which it may be residing. */ + emit_insn (gen_bic_SR (GEN_INT (0xf0))); + fs = cfun->machine->framesize_locals + cfun->machine->framesize_outgoing; increment_stack (fs); Index: config/msp430/msp430.md =================================================================== --- config/msp430/msp430.md (revision 205957) +++ config/msp430/msp430.md (working copy) @@ -1253,11 +1253,11 @@ "1" "NOP" ) - + (define_insn "disable_interrupts" [(unspec_volatile [(const_int 0)] UNS_DINT)] "" - "DINT" + "DINT \; NOP" ) (define_insn "enable_interrupts" Index: doc/extend.texi =================================================================== --- doc/extend.texi (revision 205957) +++ doc/extend.texi (working copy) @@ -2919,6 +2919,13 @@ or @code{critical} attributes. They can have the @code{interrupt} attribute. +@item wakeup +@cindex @code{wakeup} attribute +This attribute only applies to interrupt functions. It is silently +ignored if applied to a non-interrupt function. A wakeup interrupt +function will rouse the processor from any low-power state that it +might be in when the function exits. + @end table On Epiphany targets one or more optional parameters can be added like this: