From patchwork Wed Jul 13 21:42:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 104597 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 E2C08B6F62 for ; Thu, 14 Jul 2011 07:43:22 +1000 (EST) Received: (qmail 4768 invoked by alias); 13 Jul 2011 21:43:20 -0000 Received: (qmail 4758 invoked by uid 22791); 13 Jul 2011 21:43:19 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, TW_MX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e6.ny.us.ibm.com (HELO e6.ny.us.ibm.com) (32.97.182.146) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Jul 2011 21:43:02 +0000 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e6.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6DLIsXd029930 for ; Wed, 13 Jul 2011 17:18:54 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6DLh0cT1749050 for ; Wed, 13 Jul 2011 17:43:00 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p6DLh05C029520 for ; Wed, 13 Jul 2011 17:43:00 -0400 Received: from hungry-tiger.westford.ibm.com (hungry-tiger.westford.ibm.com [9.33.37.78]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p6DLh0Sl029399; Wed, 13 Jul 2011 17:43:00 -0400 Received: by hungry-tiger.westford.ibm.com (Postfix, from userid 500) id 72F3AF829B; Wed, 13 Jul 2011 17:42:58 -0400 (EDT) Date: Wed, 13 Jul 2011 17:42:58 -0400 From: Michael Meissner To: David Edelsohn Cc: Richard Guenther , Tristan Gingold , Michael Meissner , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Add -mno-r11 option to suppress load of ppc64 static chain in indirect calls Message-ID: <20110713214258.GA27569@hungry-tiger.westford.ibm.com> Mail-Followup-To: Michael Meissner , David Edelsohn , Richard Guenther , Tristan Gingold , gcc-patches@gcc.gnu.org References: <20110706222922.GA23641@hungry-tiger.westford.ibm.com> <20110707154743.GA3823@hungry-tiger.westford.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Thu, Jul 07, 2011 at 03:14:02PM -0400, David Edelsohn wrote: > On Thu, Jul 7, 2011 at 11:53 AM, Richard Guenther > wrote: > > > Well, that's up to the target maintainers to decide, maybe > > -mno-nested-functions instead? > > Is -mno-nested-functions or -mno-nested-function-pointers too > C-centric or GCC-centric? I don't know what wording would be more > informative, but the functionality is available in Pascal, PL/I, Ada, > GCC extensions and other languages. We're open to suggestions. > > > The compiler certainly can't figure out in _all_ cases - but it should be able to handle > > most of the cases (with LTO even more cases) ok, no? > > -mno-r11 is an assertion to the compiler that no function calls > through pointers will require the static chain. However, I agree that > the compiler conservatively should be able to figure out some cases > itself, which would be a good enhancement. I changed the switch to -mno-pointers-to-nested-functions as David requestion in private communications. [gcc] 2011-07-13 Michael Meissner * config/rs6000/rs6000.opt (-mpointers-to-nested-functions): Rename -mr11. * config/rs6000/rs6000.c (rs6000_trampoline_init): Ditto. (rs6000_call_indirect_aix): Ditto. * config/rs6000/rs6000.md (call_indirect_aix): Ditto. (call_indirect_aix_internal): Ditto. (call_indirect_aix_nor11): Ditto. (call_indirect_aix_internal2): Ditto. (call_value_indirect_aix): Ditto. (call_value_indirect_aix_internal): Ditto. (call_value_indirect_aix_nor11): Ditto. (call_value_indirect_aix_internal2): Ditto. * doc/invoke.texi (RS/6000 and PowerPC Options): Ditto. [gcc/testsuite] 2011-07-13 Michael Meissner * gcc.target/powerpc/no-r11-1.c: Change -mno-r11 to -mno-pointers-to-nested-functions. * gcc.target/powerpc/no-r11-2.c: Ditto. * gcc.target/powerpc/no-r11-3.c: Ditto. Index: gcc/config/rs6000/rs6000.opt =================================================================== --- gcc/config/rs6000/rs6000.opt (revision 176251) +++ gcc/config/rs6000/rs6000.opt (working copy) @@ -521,9 +521,9 @@ mxilinx-fpu Target Var(rs6000_xilinx_fpu) Save Specify Xilinx FPU. -mr11 -Target Report Var(TARGET_R11) Init(1) Save -Use/do not use r11 to hold the static link in calls. +mpointers-to-nested-functions +Target Report Var(TARGET_POINTERS_TO_NESTED_FUNCTIONS) Init(1) Save +Use/do not use r11 to hold the static link in calls to functions via pointers. msave-toc-indirect Target Undocumented Var(TARGET_SAVE_TOC_INDIRECT) Save Init(1) Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 176251) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -24409,7 +24409,7 @@ rs6000_trampoline_init (rtx m_tramp, tre { rtx fnmem, fn_reg, toc_reg; - if (!TARGET_R11) + if (!TARGET_POINTERS_TO_NESTED_FUNCTIONS) error ("-mno-r11 must not be used if you have trampolines"); fnmem = gen_const_mem (Pmode, force_reg (Pmode, fnaddr)); @@ -27741,7 +27741,7 @@ rs6000_call_indirect_aix (rtx value, rtx stack_toc_offset = GEN_INT (TOC_SAVE_OFFSET_32BIT); func_toc_offset = GEN_INT (AIX_FUNC_DESC_TOC_32BIT); func_sc_offset = GEN_INT (AIX_FUNC_DESC_SC_32BIT); - if (TARGET_R11) + if (TARGET_POINTERS_TO_NESTED_FUNCTIONS) { call_func = gen_call_indirect_aix32bit; call_value_func = gen_call_value_indirect_aix32bit; @@ -27757,7 +27757,7 @@ rs6000_call_indirect_aix (rtx value, rtx stack_toc_offset = GEN_INT (TOC_SAVE_OFFSET_64BIT); func_toc_offset = GEN_INT (AIX_FUNC_DESC_TOC_64BIT); func_sc_offset = GEN_INT (AIX_FUNC_DESC_SC_64BIT); - if (TARGET_R11) + if (TARGET_POINTERS_TO_NESTED_FUNCTIONS) { call_func = gen_call_indirect_aix64bit; call_value_func = gen_call_value_indirect_aix64bit; @@ -27800,7 +27800,7 @@ rs6000_call_indirect_aix (rtx value, rtx func_toc_offset)); /* If we have a static chain, load it up. */ - if (TARGET_R11) + if (TARGET_POINTERS_TO_NESTED_FUNCTIONS) { func_sc_mem = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, Index: gcc/config/rs6000/rs6000.md =================================================================== --- gcc/config/rs6000/rs6000.md (revision 176251) +++ gcc/config/rs6000/rs6000.md (working copy) @@ -12386,7 +12386,7 @@ (define_insn_and_split "call_indirect_ai (use (match_operand:P 3 "memory_operand" "m,m")) (use (reg:P STATIC_CHAIN_REGNUM)) (clobber (reg:P LR_REGNO))] - "DEFAULT_ABI == ABI_AIX && TARGET_R11" + "DEFAULT_ABI == ABI_AIX && TARGET_POINTERS_TO_NESTED_FUNCTIONS" "#" "&& reload_completed" [(set (reg:P TOC_REGNUM) (match_dup 2)) @@ -12409,7 +12409,8 @@ (define_insn "*call_indirect_aix 2,%2" [(set_attr "type" "jmpreg") (set_attr "length" "8")]) @@ -12426,7 +12427,7 @@ (define_insn_and_split "call_indirect_ai (use (match_operand:P 2 "memory_operand" "m,m")) (use (match_operand:P 3 "memory_operand" "m,m")) (clobber (reg:P LR_REGNO))] - "DEFAULT_ABI == ABI_AIX && !TARGET_R11" + "DEFAULT_ABI == ABI_AIX && !TARGET_POINTERS_TO_NESTED_FUNCTIONS" "#" "&& reload_completed" [(set (reg:P TOC_REGNUM) (match_dup 2)) @@ -12447,7 +12448,8 @@ (define_insn "*call_indirect_aix 2,%2" [(set_attr "type" "jmpreg") (set_attr "length" "8")]) @@ -12466,7 +12468,7 @@ (define_insn_and_split "call_value_indir (use (match_operand:P 4 "memory_operand" "m,m")) (use (reg:P STATIC_CHAIN_REGNUM)) (clobber (reg:P LR_REGNO))] - "DEFAULT_ABI == ABI_AIX && TARGET_R11" + "DEFAULT_ABI == ABI_AIX && TARGET_POINTERS_TO_NESTED_FUNCTIONS" "#" "&& reload_completed" [(set (reg:P TOC_REGNUM) (match_dup 3)) @@ -12491,7 +12493,8 @@ (define_insn "*call_value_indirect_aix

2,%3" [(set_attr "type" "jmpreg") (set_attr "length" "8")]) @@ -12510,7 +12513,7 @@ (define_insn_and_split "call_value_indir (use (match_operand:P 3 "memory_operand" "m,m")) (use (match_operand:P 4 "memory_operand" "m,m")) (clobber (reg:P LR_REGNO))] - "DEFAULT_ABI == ABI_AIX && !TARGET_R11" + "DEFAULT_ABI == ABI_AIX && !TARGET_POINTERS_TO_NESTED_FUNCTIONS" "#" "&& reload_completed" [(set (reg:P TOC_REGNUM) (match_dup 3)) @@ -12533,7 +12536,8 @@ (define_insn "*call_value_indirect_aix

2,%3" [(set_attr "type" "jmpreg") (set_attr "length" "8")]) Index: gcc/testsuite/gcc.target/powerpc/no-r11-1.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/no-r11-1.c (revision 176251) +++ gcc/testsuite/gcc.target/powerpc/no-r11-1.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ /* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ -/* { dg-options "-O2 -mno-r11" } */ +/* { dg-options "-O2 -mno-pointers-to-nested-functions" } */ int call_ptr (int (func) (void)) Index: gcc/testsuite/gcc.target/powerpc/no-r11-2.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/no-r11-2.c (revision 176251) +++ gcc/testsuite/gcc.target/powerpc/no-r11-2.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ /* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ -/* { dg-options "-O2 -mr11" } */ +/* { dg-options "-O2 -mpointers-to-nested-functions" } */ int call_ptr (int (func) (void)) Index: gcc/testsuite/gcc.target/powerpc/no-r11-3.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/no-r11-3.c (revision 176251) +++ gcc/testsuite/gcc.target/powerpc/no-r11-3.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */ /* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */ -/* { dg-options "-O2 -mno-r11" } */ +/* { dg-options "-O2 -mno-pointers-to-nested-functions" } */ extern void ext_call (int (func) (void));