From patchwork Thu Aug 19 16:08:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 62191 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 D2E31B70EF for ; Fri, 20 Aug 2010 02:08:59 +1000 (EST) Received: (qmail 11575 invoked by alias); 19 Aug 2010 16:08:55 -0000 Received: (qmail 11558 invoked by uid 22791); 19 Aug 2010 16:08:53 -0000 X-SWARE-Spam-Status: No, hits=-0.9 required=5.0 tests=AWL, BAYES_00, SUBJ_ALL_CAPS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 Aug 2010 16:08:47 +0000 Received: (qmail 31781 invoked from network); 19 Aug 2010 16:08:45 -0000 Received: from unknown (HELO ?192.168.0.104?) (ams@127.0.0.2) by mail.codesourcery.com with ESMTPA; 19 Aug 2010 16:08:45 -0000 Message-ID: <4C6D570A.5020808@codesourcery.com> Date: Thu, 19 Aug 2010 17:08:42 +0100 From: Andrew Stubbs User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/3] SH-2A FDPIC: PIC_OFFSET_TABLE_REG_CALL_CLOBBERED 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 This patch modifies PIC_OFFSET_TABLE_REG_CALL_CLOBBERED such that it's value can be modified at run time. The reason for this is that we want to build compilers that support both regular and FDPIC code, and the ABI is different in each. This feature is required by our SH-2A FDPIC (to follow), but has been split out here because parts of it are target independent, and parts touch other back ends. OK to commit? Andrew Stubbs 2010-08-19 Joseph Myers gcc/ * doc/tm.texi.in (PIC_OFFSET_TABLE_REG_CALL_CLOBBERED): Document to be zero or nonzero. * doc/tm.texi: Regenerate. * defaults.h (PIC_OFFSET_TABLE_REG_CALL_CLOBBERED): Define. * df-scan.c (df_get_exit_block_use_set), reginfo.c (init_reg_sets_1), rtlanal.c (rtx_unstable_p, rtx_varies_p): Handle new PIC_OFFSET_TABLE_REG_CALL_CLOBBERED semantics. * config/ia64/ia64.h (PIC_OFFSET_TABLE_REG_CALL_CLOBBERED): Define to 1. --- src/gcc-mainline/gcc/config/ia64/ia64.h | 2 +- src/gcc-mainline/gcc/defaults.h | 4 ++++ src/gcc-mainline/gcc/df-scan.c | 5 ++--- src/gcc-mainline/gcc/doc/tm.texi | 5 +++-- src/gcc-mainline/gcc/doc/tm.texi.in | 5 +++-- src/gcc-mainline/gcc/reginfo.c | 5 ++--- src/gcc-mainline/gcc/rtlanal.c | 9 ++------- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/gcc-mainline/gcc/config/ia64/ia64.h b/src/gcc-mainline/gcc/config/ia64/ia64.h index 39fa25c..b43d075 100644 --- a/src/gcc-mainline/gcc/config/ia64/ia64.h +++ b/src/gcc-mainline/gcc/config/ia64/ia64.h @@ -1359,7 +1359,7 @@ do { \ /* Define this macro if the register defined by `PIC_OFFSET_TABLE_REGNUM' is clobbered by calls. */ -#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED +#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED 1 /* The Overall Framework of an Assembler File. */ diff --git a/src/gcc-mainline/gcc/defaults.h b/src/gcc-mainline/gcc/defaults.h index 7aa227c..aaf6ea6 100644 --- a/src/gcc-mainline/gcc/defaults.h +++ b/src/gcc-mainline/gcc/defaults.h @@ -722,6 +722,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM #endif +#ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED +#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED 0 +#endif + #ifndef TARGET_DLLIMPORT_DECL_ATTRIBUTES #define TARGET_DLLIMPORT_DECL_ATTRIBUTES 0 #endif diff --git a/src/gcc-mainline/gcc/df-scan.c b/src/gcc-mainline/gcc/df-scan.c index b4633ab..8b17ae2 100644 --- a/src/gcc-mainline/gcc/df-scan.c +++ b/src/gcc-mainline/gcc/df-scan.c @@ -4032,14 +4032,13 @@ df_get_exit_block_use_set (bitmap exit_block_uses) #endif } -#ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED /* Many architectures have a GP register even without flag_pic. Assume the pic register is not in use, or will be handled by other means, if it is not fixed. */ - if ((unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM + if (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED + && (unsigned) PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM && fixed_regs[PIC_OFFSET_TABLE_REGNUM]) bitmap_set_bit (exit_block_uses, PIC_OFFSET_TABLE_REGNUM); -#endif /* Mark all global registers, and all registers used by the epilogue as being live at the end of the function since they diff --git a/src/gcc-mainline/gcc/doc/tm.texi b/src/gcc-mainline/gcc/doc/tm.texi index 3e38618..7e8765b 100644 --- a/src/gcc-mainline/gcc/doc/tm.texi +++ b/src/gcc-mainline/gcc/doc/tm.texi @@ -7128,8 +7128,9 @@ when @code{flag_pic} is true). @end defmac @defmac PIC_OFFSET_TABLE_REG_CALL_CLOBBERED -Define this macro if the register defined by -@code{PIC_OFFSET_TABLE_REGNUM} is clobbered by calls. Do not define +A C expression that is nonzero if the register defined by +@code{PIC_OFFSET_TABLE_REGNUM} is clobbered by calls. If not defined, +the default is zero. Do not define this macro if @code{PIC_OFFSET_TABLE_REGNUM} is not defined. @end defmac diff --git a/src/gcc-mainline/gcc/doc/tm.texi.in b/src/gcc-mainline/gcc/doc/tm.texi.in index 6358916..4d13cbe 100644 --- a/src/gcc-mainline/gcc/doc/tm.texi.in +++ b/src/gcc-mainline/gcc/doc/tm.texi.in @@ -7123,8 +7123,9 @@ when @code{flag_pic} is true). @end defmac @defmac PIC_OFFSET_TABLE_REG_CALL_CLOBBERED -Define this macro if the register defined by -@code{PIC_OFFSET_TABLE_REGNUM} is clobbered by calls. Do not define +A C expression that is nonzero if the register defined by +@code{PIC_OFFSET_TABLE_REGNUM} is clobbered by calls. If not defined, +the default is zero. Do not define this macro if @code{PIC_OFFSET_TABLE_REGNUM} is not defined. @end defmac diff --git a/src/gcc-mainline/gcc/reginfo.c b/src/gcc-mainline/gcc/reginfo.c index 0fc86d3..89965da 100644 --- a/src/gcc-mainline/gcc/reginfo.c +++ b/src/gcc-mainline/gcc/reginfo.c @@ -495,10 +495,9 @@ init_reg_sets_1 (void) else if (i == ARG_POINTER_REGNUM && fixed_regs[i]) ; #endif -#ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED - else if (i == (unsigned) PIC_OFFSET_TABLE_REGNUM && fixed_regs[i]) + else if (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED + && i == (unsigned) PIC_OFFSET_TABLE_REGNUM && fixed_regs[i]) ; -#endif else if (CALL_REALLY_USED_REGNO_P (i)) { SET_HARD_REG_BIT (regs_invalidated_by_call, i); diff --git a/src/gcc-mainline/gcc/rtlanal.c b/src/gcc-mainline/gcc/rtlanal.c index f9e6871..4331f41 100644 --- a/src/gcc-mainline/gcc/rtlanal.c +++ b/src/gcc-mainline/gcc/rtlanal.c @@ -118,13 +118,11 @@ rtx_unstable_p (const_rtx x) /* The arg pointer varies if it is not a fixed register. */ || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM])) return 0; -#ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED /* ??? When call-clobbered, the value is stable modulo the restore that must happen after a call. This currently screws up local-alloc into believing that the restore is not needed. */ - if (x == pic_offset_table_rtx) + if (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED && x == pic_offset_table_rtx) return 0; -#endif return 1; case ASM_OPERANDS: @@ -197,14 +195,11 @@ rtx_varies_p (const_rtx x, bool for_alias) || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM])) return 0; if (x == pic_offset_table_rtx -#ifdef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED /* ??? When call-clobbered, the value is stable modulo the restore that must happen after a call. This currently screws up local-alloc into believing that the restore is not needed, so we must return 0 only if we are called from alias analysis. */ - && for_alias -#endif - ) + && (!PIC_OFFSET_TABLE_REG_CALL_CLOBBERED || for_alias)) return 0; return 1;