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]

[committed] Add mipsisa*-elfoabi configurations


mips-elf and mips64-elf use o32 and o64 for 32-bit and 64-bit targets
respectively, but mipsisa32*-elf and mipsisa64*-elf use EABI instead.
The reasons for the difference are historical.  mipsisa*-elf originally
used an EABI defined by MTI (known to gcc as "meabi"), but the spec for
that ABI was (as far as I know) never released.  MEABI support was
therefore removed from gcc, and mipsisa*-elf switched to the older
Cygnus EABI.

Although EABI32 is in many ways better than o32, and although
EABI64 -mlong32 (not the default) is in many ways better than o64,
this choice makes some testing rather difficult:

  - The MIPS16e save instruction is designed specifically for o32;
    it can save registers in the caller-allocated stack area.

  - The MIPS32r2 -mgp32 -mfp64 combination is currently only supported
    for o32.

  - The MIPS16 hard-float support is currently specific to o32 and o64.

It'd therefore be useful to have configurations that use o32 and o64
together with the MIPS32 and MIPS64 ISAs.  This patch adds associated
mipsisa*-elfoabi triplets.  We've been using it locally to test some
recent patches.

The configuration tries to infer the ABI from the architecture, in such
a way that the option can be passed down to the assembler too.  It also
tries to choose the right -mips32, -mips32r2 or -mips64 multilibs for a
given -march=* option.  The associated specs should be useful for other
configurations too.

AFAIK we don't have a list of all supported targets (just those
that need special installation instructions), so there's no
corresponding documentation patch.  I'm not sure whether the
configuration would be useful for users anyway.

Tested with mipsisa32r2-elfoabi and mipsisa64-elfoabi.
Applied to mainline.

Richard


gcc/
	* config.gcc (mipsisa32-*-elf*, mipsisa32el-*-elf*)
	(mipsisa32r2-*-elf*, mipsisa32r2el-*-elf*)
	(mipsisa64-*-elf*, mipsisa64el-*-elf*): Combine top-level
	stanzas.  Use the first part of the triplet to set MIPS_ISA_DEFAULT.
	Remove redundant setting of MASK_FLOAT64 and MASK_64BIT for the
	64-bit targets.  Add support for *-elfoabi*.
	* config/mips/t-isa3264 (MULTILIB_OPTIONS, MULTILIB_DIRNAMES): Use
	different settings if $(tm_defines) does not select the EABI.
	(MULTILIB_EXCLUSIONS): Define in those circumstances.
	* config/mips/mips.h (MIPS_ISA_LEVEL_OPTION_SPEC): New macro.
	(MIPS_ARCH_OPTION_SPEC): Likewise.
	(MIPS_ISA_LEVEL_SPEC): Likewise.
	(OPTION_DEFAULT_SPECS): Use MIPS_ARCH_OPTION_SPEC.
	* config/mips/elfoabi.h: New file.

Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 125997)
+++ gcc/config.gcc	(working copy)
@@ -1673,24 +1673,35 @@ mips*-*-openbsd*)
 	*)  tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=MASK_BIG_ENDIAN";;
         esac
 	;;
-mipsisa32-*-elf* | mipsisa32el-*-elf*)
-	tm_file="elfos.h ${tm_file} mips/elf.h"
-	tmake_file=mips/t-isa3264
-	tm_defines="${tm_defines} MIPS_ISA_DEFAULT=32 MIPS_ABI_DEFAULT=ABI_EABI"
-	use_fixproto=yes
-	;;
-mipsisa32r2-*-elf* | mipsisa32r2el-*-elf*)
-	tm_file="elfos.h ${tm_file} mips/elf.h"
-	tmake_file=mips/t-isa3264
-	tm_defines="${tm_defines} MIPS_ISA_DEFAULT=33 MIPS_ABI_DEFAULT=ABI_EABI"
-	use_fixproto=yes
-	;;
+mipsisa32-*-elf* | mipsisa32el-*-elf* | \
+mipsisa32r2-*-elf* | mipsisa32r2el-*-elf* | \
 mipsisa64-*-elf* | mipsisa64el-*-elf*)
 	tm_file="elfos.h ${tm_file} mips/elf.h"
 	tmake_file=mips/t-isa3264
-	target_cpu_default="MASK_64BIT|MASK_FLOAT64"
-	tm_defines="${tm_defines} MIPS_ISA_DEFAULT=64 MIPS_ABI_DEFAULT=ABI_EABI"
-	use_fixproto=yes
+	case ${target} in
+	  mipsisa32r2*)
+	    tm_defines="${tm_defines} MIPS_ISA_DEFAULT=33"
+	    ;;
+	  mipsisa32*)
+	    tm_defines="${tm_defines} MIPS_ISA_DEFAULT=32"
+	    ;;
+	  mipsisa64*)
+	    tm_defines="${tm_defines} MIPS_ISA_DEFAULT=64"
+	    ;;
+	esac
+	case ${target} in
+	  mipsisa32*-*-elfoabi*)
+	    tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_32"
+	    tm_file="${tm_file} mips/elfoabi.h"
+	    ;;
+	  mipsisa64*-*-elfoabi*)
+	    tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_O64"
+	    tm_file="${tm_file} mips/elfoabi.h"
+	    ;;
+	  *-*-elf*)
+	    tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_EABI"
+	    ;;
+	esac
 	;;
 mipsisa64sr71k-*-elf*)
         tm_file="elfos.h ${tm_file} mips/elf.h"
Index: gcc/config/mips/t-isa3264
===================================================================
--- gcc/config/mips/t-isa3264	(revision 125997)
+++ gcc/config/mips/t-isa3264	(working copy)
@@ -36,8 +36,18 @@ TARGET_LIBGCC2_CFLAGS = -G 0
 
 # Build the libraries for both hard and soft floating point
 
+ifneq ($(filter MIPS_ABI_DEFAULT=ABI_EABI,$(tm_defines)),)
 MULTILIB_OPTIONS = msoft-float EL/EB mips32/mips32r2/mips64
 MULTILIB_DIRNAMES = soft-float el eb mips32 mips32r2 mips64
+else
+MULTILIB_OPTIONS = msoft-float/mfp64 EL/EB mips32/mips32r2/mips64
+MULTILIB_DIRNAMES = soft-float fp64 el eb mips32 mips32r2 mips64
+ifneq ($(filter MIPS_ISA_DEFAULT=33,$(tm_defines)),)
+MULTILIB_EXCLUSIONS = mips32/mfp64 mips64/mfp64
+else
+MULTILIB_EXCLUSIONS = !mips32r2/mfp64
+endif
+endif
 MULTILIB_MATCHES = EL=mel EB=meb
 EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crti.o crtn.o
 
Index: gcc/config/mips/mips.h
===================================================================
--- gcc/config/mips/mips.h	(revision 125997)
+++ gcc/config/mips/mips.h	(working copy)
@@ -561,6 +561,29 @@ #define ENDIAN_SPEC "%{!EL:%{!mel:-EB}} 
 #endif
 #endif
 
+/* A spec condition that matches all non-mips16 -mips arguments.  */
+
+#define MIPS_ISA_LEVEL_OPTION_SPEC \
+  "mips1|mips2|mips3|mips4|mips32*|mips64*"
+
+/* A spec condition that matches all non-mips16 architecture arguments.  */
+
+#define MIPS_ARCH_OPTION_SPEC \
+  MIPS_ISA_LEVEL_OPTION_SPEC "|march=*"
+
+/* A spec that infers a -mips argument from an -march argument.  */
+
+#define MIPS_ISA_LEVEL_SPEC \
+  "%{" MIPS_ISA_LEVEL_OPTION_SPEC ":;: \
+     %{march=mips1|march=r2000|march=r3000|march=r3900:-mips1} \
+     %{march=mips2|march=r6000:-mips2} \
+     %{march=mips3|march=r4*|march=vr4*|march=orion:-mips3} \
+     %{march=mips4|march=r8000|march=vr5*|march=rm7000|march=rm9000:-mips4} \
+     %{march=mips32|march=4kc|march=4km|march=4kp:-mips32} \
+     %{march=mips32r2|march=m4k|march=4ke*|march=24k* \
+       |march=34k*|march=74k*: -mips32r2} \
+     %{march=mips64|march=5k*|march=20k*|march=sb1*|march=sr71000: -mips64}}"
+
 /* Support for a compile-time default CPU, et cetera.  The rules are:
    --with-arch is ignored if -march is specified or a -mips is specified
      (other than -mips16).
@@ -571,7 +594,7 @@ #define ENDIAN_SPEC "%{!EL:%{!mel:-EB}} 
    --with-divide is ignored if -mdivide-traps or -mdivide-breaks are
      specified. */
 #define OPTION_DEFAULT_SPECS \
-  {"arch", "%{!march=*:%{mips16:-march=%(VALUE)}%{!mips*:-march=%(VALUE)}}" }, \
+  {"arch", "%{" MIPS_ARCH_OPTION_SPEC ":;: -march=%(VALUE)}" }, \
   {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \
   {"abi", "%{!mabi=*:-mabi=%(VALUE)}" }, \
   {"float", "%{!msoft-float:%{!mhard-float:-m%(VALUE)-float}}" }, \
Index: gcc/config/mips/elfoabi.h
===================================================================
--- gcc/config/mips/elfoabi.h	(revision 0)
+++ gcc/config/mips/elfoabi.h	(revision 0)
@@ -0,0 +1,41 @@
+/* Target macros for mips*-elf targets that selected between o32 and o64
+   based on the target architecture.
+   Copyright (C) 1994, 1997, 1999, 2000, 2002, 2003, 2004
+   Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
+
+#define DRIVER_SELF_SPECS						\
+  /* Infer a -mips option from a -march option.  This makes		\
+     -march pick the right multilib, and also makes the later		\
+     specs easier to write.  */						\
+  MIPS_ISA_LEVEL_SPEC,							\
+									\
+  /* If no architecture option is specified, force the default to	\
+     be listed explicitly.  This too makes later specs easier to	\
+     write.  */							       	\
+  "%{" MIPS_ISA_LEVEL_OPTION_SPEC ":;: -" MULTILIB_ISA_DEFAULT "}",	\
+									\
+  /* If no ABI option is specified, infer one from the ISA level	\
+     or -mgp setting.  */						\
+  "%{!mabi=*: %{mips1|mips2|mips32*|mgp32: -mabi=32;: -mabi=o64}}",	\
+									\
+  /* Remove a redundant -mfp64 for -mabi=o64; we want the !mfp64	\
+     multilibs.  There's no need to check whether the architecture	\
+     is 64-bit; cc1 will complain if it isn't.  */			\
+  "%{mabi=o64: %<mfp64}"


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