This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [mips] generate PIC jump tables for n32 and n64


On Oct 13, 2002, Eric Christopher <echristo@redhat.com> wrote:

>> IRIX6.  It's not like we were able to use the GNU assembler and linker
>> on IRIX 6 before, though, so perhaps this fix is acceptable for 3.3.
>> Ok to install?
>> 

> OK for b-i-b if it bootstraps. I'd offer, but I'm in the same position
> you are :)

It's back, at last!  I've run into the same problems that Kaveh had
and, try as I might, I couldn't find any way to get the SGI assembler
to generate a 64-bit GPREL relocation, so I ended up writing this
patch, that I've bootstrapped on mips-sgi-irix6.5 without GNU as (that
won't build for mips-sgi-irix6.5 and, if I force it, things don't
quite work, but for other reasons; I'm working on that).  I also
bootstrapped it on another mips64 port I'm working on.  Are the
mips-specific parts ok for b-i-b?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* config.gcc (tm_defines): Define HAVE_GNU_AS and HAVE_GNU_LD.
	* config/mips/mips.h (ASM_OUTPUT_ADDR_DIFF_ELT): Output
	.gpword/.gpdword for ABI_N32 and ABI_64 too.
	* config/mips/mips.md (tablejump_internal3): Output .cpadd
	before jump on ABI_N32 too.
	(tablejump_internal4): Ditto on ABI_64.  Increase maximum
	length to match.

Index: gcc/config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.240.2.7
diff -u -p -r1.240.2.7 config.gcc
--- gcc/config.gcc 21 Oct 2002 17:51:54 -0000 1.240.2.7
+++ gcc/config.gcc 25 Oct 2002 00:05:28 -0000
@@ -2938,6 +2938,18 @@ then
 	fi
 fi
 
+if test x$gas = xyes; then
+	tm_defines="$tm_defines HAVE_GNU_AS=1"
+else
+	tm_defines="$tm_defines HAVE_GNU_AS=0"
+fi
+
+if test x$gnu_ld = xyes; then
+	tm_defines="$tm_defines HAVE_GNU_LD=1"
+else
+	tm_defines="$tm_defines HAVE_GNU_LD=0"
+fi	
+
 # Save data on machine being used to compile GCC in build_xm_file.
 # Save data on host machine in vars host_xm_file and host_xmake_file.
 if test x$pass1done = x
Index: gcc/config/mips/mips.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.215.2.8
diff -u -p -r1.215.2.8 mips.h
--- gcc/config/mips/mips.h 15 Oct 2002 01:33:14 -0000 1.215.2.8
+++ gcc/config/mips/mips.h 25 Oct 2002 00:05:32 -0000
@@ -4408,7 +4408,9 @@ do {									\
     fprintf (STREAM, "\t%s\t%sL%d-%sLS%d\n",				\
 	     Pmode == DImode ? ".dword" : ".word",			\
 	     LOCAL_LABEL_PREFIX, VALUE, LOCAL_LABEL_PREFIX, REL);	\
-  else if (mips_abi == ABI_32 || mips_abi == ABI_O64)			\
+  else if (mips_abi == ABI_32 || mips_abi == ABI_O64			\
+	   || mips_abi == ABI_N32					\
+	   || (HAVE_GNU_AS && mips_abi == ABI_64))			\
     fprintf (STREAM, "\t%s\t%sL%d\n",					\
 	     Pmode == DImode ? ".gpdword" : ".gpword",			\
 	     LOCAL_LABEL_PREFIX, VALUE);				\
Index: gcc/config/mips/mips.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.md,v
retrieving revision 1.141.2.3
diff -u -p -r1.141.2.3 mips.md
--- gcc/config/mips/mips.md 15 Oct 2002 01:33:14 -0000 1.141.2.3
+++ gcc/config/mips/mips.md 25 Oct 2002 00:05:35 -0000
@@ -1,6 +1,6 @@
 ;;  Mips.md	     Machine Description for MIPS based processors
 ;;  Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-;;  1999, 2000, 2001 Free Software Foundation, Inc.
+;;  1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 ;;  Contributed by   A. Lichnewsky, lich@inria.inria.fr
 ;;  Changes by       Michael Meissner, meissner@osf.org
 ;;  64 bit r4000 support by Ian Lance Taylor, ian@cygnus.com, and
@@ -9780,7 +9780,7 @@ move\\t%0,%z4\\n\\
   "*
 {
   /* .cpadd expands to add REG,REG,$gp when pic, and nothing when not pic.  */
-  if (mips_abi == ABI_32 || mips_abi == ABI_O64)
+  if (mips_abi == ABI_32 || mips_abi == ABI_O64 || mips_abi == ABI_N32)
     output_asm_insn (\".cpadd\\t%0\", operands);
   return \"%*j\\t%0\";
 }"
@@ -9808,9 +9808,16 @@ move\\t%0,%z4\\n\\
   "Pmode == DImode && next_active_insn (insn) != 0
    && GET_CODE (PATTERN (next_active_insn (insn))) == ADDR_DIFF_VEC
    && PREV_INSN (next_active_insn (insn)) == operands[1]"
-  "%*j\\t%0"
+  "*
+{
+  /* .cpadd expands to add REG,REG,$gp when pic, and nothing when not pic.  */
+  if (HAVE_GNU_AS && mips_abi == ABI_64)
+    output_asm_insn (\".cpadd\\t%0\", operands);
+  return \"%*j\\t%0\";
+}"
   [(set_attr "type"	"jump")
-   (set_attr "mode"	"none")])
+   (set_attr "mode"	"none")
+   (set_attr "length"	"8")])
 
 ;; Implement a switch statement when generating embedded PIC code.
 ;; Switches are implemented by `tablejump' when not using -membedded-pic.
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]