From patchwork Fri May 20 14:58:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Suchanek X-Patchwork-Id: 624507 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 3rBB0d35L6z9t74 for ; Sat, 21 May 2016 00:59:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=b/+orGhu; dkim-atps=neutral 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:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=PfW J9/nDz+4wWTRW8r5IKAuPuSdfjzd6sa7riMzjv0fQq/CNBtIP9aPz5ULJ84ddCWg 41cWrlnNnU7rOwa+X08U4URoFxUrx3bEpnulmYjwr4a/hCx+9BgHg/7llnQT019/ S42spdX4Zj80knKQybnl/5w1jJ/p3DVtN4IyZk5s= 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:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=PLb18V/YA YE77FVJYlrr2xDTME8=; b=b/+orGhuCkD5Qqcvz9jfDZnE0hDJKaDFNaVbWkoaC jcQudEmBaAHHIXnBzYD7mwgFzITqRHQ1sMSJ0rfZaFMNIh/nWBvIGjGdX8a56QX0 qxPinocIUDXR6HI/z0UUnEdidxgp1iBjYVeD1cEqOZxytp+Ls90jUgaYA24O4gFu 44= Received: (qmail 102451 invoked by alias); 20 May 2016 14:59:05 -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 102354 invoked by uid 89); 20 May 2016 14:59:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Grow, 8386, Hx-languages-length:3328, Growing X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 May 2016 14:58:51 +0000 Received: from HHMAIL01.hh.imgtec.org (unknown [10.100.10.19]) by Websense Email with ESMTPS id 68622FEEA452B; Fri, 20 May 2016 15:58:45 +0100 (IST) Received: from hhmail02.hh.imgtec.org ([fe80::5400:d33e:81a4:f775]) by HHMAIL01.hh.imgtec.org ([fe80::710b:f219:72bc:e0b3%26]) with mapi id 14.03.0266.001; Fri, 20 May 2016 15:58:48 +0100 From: Robert Suchanek To: "Catherine_Moore@mentor.com" , Matthew Fortune CC: "gcc-patches@gcc.gnu.org" Subject: [PATCH][MIPS] Add -mgrow-frame-downwards option Date: Fri, 20 May 2016 14:58:47 +0000 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, The patch changes the default behaviour of the direction in which the local frame grows for MIPS16. The code size reduces by about 0.5% in average case for -Os, hence, it is good to turn the option on by default. Ok to apply? Regards, Robert gcc/ 2016-05-20 Matthew Fortune * config/mips/mips.h (FRAME_GROWS_DOWNWARD): Enable it conditionally for MIPS16. * config/mips/mips.opt: Add -mgrow-frame-downwards option. Enable it by default for MIPS16. * doc/invoke.texi: Document the option. --- gcc/config/mips/mips.h | 8 +++++++- gcc/config/mips/mips.opt | 4 ++++ gcc/doc/invoke.texi | 13 +++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 5020208..6ab7dd3 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -2311,7 +2311,13 @@ enum reg_class #define STACK_GROWS_DOWNWARD 1 -#define FRAME_GROWS_DOWNWARD flag_stack_protect +/* Growing the frame downwards allows us to put spills closest to + the stack pointer which is good as they are likely to be accessed + frequently. We can also arrange for normal stack usage to place + scalars last so that they too are close to the stack pointer. */ +#define FRAME_GROWS_DOWNWARD ((TARGET_MIPS16 \ + && TARGET_FRAME_GROWS_DOWNWARDS) \ + || flag_stack_protect) /* Size of the area allocated in the frame to save the GP. */ diff --git a/gcc/config/mips/mips.opt b/gcc/config/mips/mips.opt index 3b92ef5..53feb23 100644 --- a/gcc/config/mips/mips.opt +++ b/gcc/config/mips/mips.opt @@ -447,3 +447,7 @@ Enum(mips_cb_setting) String(always) Value(MIPS_CB_ALWAYS) minline-intermix Target Report Var(TARGET_INLINE_INTERMIX) Allow inlining even if the compression flags differ between caller and callee. + +mgrow-frame-downwards +Target Report Var(TARGET_FRAME_GROWS_DOWNWARDS) Init(1) +Change the behaviour to grow the frame downwards for MIPS16. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 2f6195e..6e5d620 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -838,6 +838,7 @@ Objective-C and Objective-C++ Dialects}. -minterlink-compressed -mno-interlink-compressed @gol -minterlink-mips16 -mno-interlink-mips16 @gol -minline-intermix -mno-inline-intermix @gol +-mgrow-frame-downwards -mno-grow-frame-downwards @gol -mabi=@var{abi} -mabicalls -mno-abicalls @gol -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot @gol -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float @gol @@ -17929,6 +17930,18 @@ vice-versa. When using this option it is necessary to protect functions that cannot be compiled as MIPS16 with a @code{noinline} attribute to ensure they are not inlined into a MIPS16 function. +@item -mgrow-frame-downwards +@itemx -mno-grow-frame-downwards +@opindex mgrow-frame-downwards +Grow the local frame down (up) for MIPS16. + +Growing the frame downwards allows us to get spill slots created at the lowest +address rather than the highest address in a local frame. The benefit of this +is smaller code size as accessing spill splots closer to the stack pointer +can be done using using 16-bit instructions. + +The option is enabled by default (to grow frame downwards) for MIPS16. + @item -mabi=32 @itemx -mabi=o64 @itemx -mabi=n32