From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25879 invoked by alias); 9 Dec 2004 16:44:55 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 25851 invoked from network); 9 Dec 2004 16:44:51 -0000 Received: from unknown (209.128.65.135) by sourceware.org with QMTP; 9 Dec 2004 16:44:51 -0000 Received: (qmail 20169 invoked by uid 10); 9 Dec 2004 16:44:50 -0000 Received: (qmail 11076 invoked by uid 500); 9 Dec 2004 16:44:42 -0000 From: Ian Lance Taylor To: Richard Sandiford Cc: binutils@sourceware.org Subject: Re: News MIPS option -mno-shared References: <20041209153403.5294.qmail@gossamer.airs.com> Date: Thu, 09 Dec 2004 16:44:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-12/txt/msg00100.txt.bz2 Richard Sandiford writes: > Ian Lance Taylor writes: > > This patch adds a new option to the MIPS assembler: -mno-shared. > > Normally the .cpload pseudo-op generates code which looks like this: > > > > lui $gp,%hi(_gp_disp) > > addiu $gp,$gp,%lo(_gp_disp) > > addu $gp,$gp,.cpload argument > > > > With -mno-shared, the .cpload pseudo-op will generate code that looks > > like this: > > > > lui $gp,%hi(_gp) > > addiu $gp,$gp,%lo(_gp) > > > > The idea is that you can use -KPIC -mno-shared and get code which > > still uses the usual Unix calling convention, but is slightly more > > efficient at each function entry. > > Yeah, this has been on my to-do list for a while ;) Are you going to > do the same thing for n32 or are you only interested in o32? For n32 the patch is to gcc, not the binutils. I have that patch, but it's a new feature and as such is not going to be acceptable in stage 3. I'll submit it when gcc goes back to stage 1. The gcc patch looks more or like the following, plus some obvious mips.h and doc stuff. Ian Index: mips.c =================================================================== RCS file: /cvsroot/gnu/gcc/config/mips/mips.c,v retrieving revision 1.3.4.2 retrieving revision 1.3.4.6 diff -u -r1.3.4.2 -r1.3.4.6 --- mips.c 21 Sep 2004 05:10:50 -0000 1.3.4.2 +++ mips.c 11 Nov 2004 23:44:38 -0000 1.3.4.6 @@ -145,7 +145,11 @@ SYMBOL_GOTOFF_LOADGP An UNSPEC wrapper around a function's address. It represents the - offset of _gp from the start of the function. */ + offset of _gp from the start of the function. + + SYMBOL_GP + An UNSPEC wrapper around the _gp symbol. This is the absolute + value of _gp. */ enum mips_symbol_type { SYMBOL_GENERAL, SYMBOL_SMALL_DATA, @@ -155,9 +159,10 @@ SYMBOL_GOTOFF_PAGE, SYMBOL_GOTOFF_GLOBAL, SYMBOL_GOTOFF_CALL, - SYMBOL_GOTOFF_LOADGP + SYMBOL_GOTOFF_LOADGP, + SYMBOL_GP }; -#define NUM_SYMBOL_TYPES (SYMBOL_GOTOFF_LOADGP + 1) +#define NUM_SYMBOL_TYPES (SYMBOL_GP + 1) /* Classifies an address. @@ -970,6 +975,7 @@ case SYMBOL_GOTOFF_GLOBAL: case SYMBOL_GOTOFF_CALL: case SYMBOL_GOTOFF_LOADGP: + case SYMBOL_GP: return false; } abort (); @@ -1060,6 +1066,7 @@ case SYMBOL_GOTOFF_GLOBAL: case SYMBOL_GOTOFF_CALL: case SYMBOL_GOTOFF_LOADGP: + case SYMBOL_GP: return true; } abort (); @@ -1185,6 +1192,11 @@ case SYMBOL_GOTOFF_LOADGP: /* Check whether the offset is a 16- or 32-bit value. */ return mips_split_p[type] ? 2 : 1; + + case SYMBOL_GP: + if (ABI_HAS_64BIT_SYMBOLS) + abort (); + return 2; } abort (); } @@ -5145,6 +5163,13 @@ mips_split_p[SYMBOL_GOTOFF_LOADGP] = true; mips_hi_relocs[SYMBOL_GOTOFF_LOADGP] = "%hi(%neg(%gp_rel("; mips_lo_relocs[SYMBOL_GOTOFF_LOADGP] = "%lo(%neg(%gp_rel("; + + if (! ABI_HAS_64BIT_SYMBOLS) + { + mips_split_p[SYMBOL_GP] = true; + mips_hi_relocs[SYMBOL_GP] = "%hi("; + mips_lo_relocs[SYMBOL_GP] = "%lo("; + } } } @@ -6643,12 +6686,24 @@ { if (TARGET_ABICALLS && TARGET_NEWABI && cfun->machine->global_pointer > 0) { - rtx addr, offset, incoming_address; + if (TARGET_SHARED || ABI_HAS_64BIT_SYMBOLS || TARGET_MIPS16) + { + rtx addr, offset, incoming_address; - addr = XEXP (DECL_RTL (current_function_decl), 0); - offset = mips_unspec_address (addr, SYMBOL_GOTOFF_LOADGP); - incoming_address = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM); - emit_insn (gen_loadgp (offset, incoming_address)); + addr = XEXP (DECL_RTL (current_function_decl), 0); + offset = mips_unspec_address (addr, SYMBOL_GOTOFF_LOADGP); + incoming_address = gen_rtx_REG (Pmode, PIC_FUNCTION_ADDR_REGNUM); + emit_insn (gen_loadgp (offset, incoming_address)); + } + else + { + rtx addr; + + addr = mips_unspec_address (gen_rtx_SYMBOL_REF (Pmode, "_gp"), + SYMBOL_GP); + emit_move_insn (pic_offset_table_rtx, + mips_split_symbol (pic_offset_table_rtx, addr)); + } if (!TARGET_EXPLICIT_RELOCS) emit_insn (gen_loadgp_blockage ()); }