diff mbox

Use Enum for MIPS -march=, -mtune=, -mips options

Message ID 87pqna4eft.fsf@firetop.home
State New
Headers show

Commit Message

Richard Sandiford May 22, 2011, 9:23 p.m. UTC
"Joseph S. Myers" <joseph@codesourcery.com> writes:
> The processing of MIPS_CPU_STRING_DEFAULT is replaced by much simpler
> use of strcmp to find a matching entry; the "from-abi" default
> definition of that macro is replaced by code in mips_default_arch if
> that macro is not defined.  (Previously it would always have been
> defined, so the previous fallback for it being undefined was dead
> code.)

For the record, the fallback really was needed.  The "from-abi" default
came from:

> -/* 'from-abi' makes a good default: you get whatever the ABI requires.  */
> -#ifndef MIPS_ISA_DEFAULT
> -#ifndef MIPS_CPU_STRING_DEFAULT
> -#define MIPS_CPU_STRING_DEFAULT "from-abi"
> -#endif
> -#endif

so it was only used if both MIPS_CPU_STRING_DEFAULT and
MIPS_ISA_DEFAULT were undefined.  The default was tested here:

> -#ifdef MIPS_CPU_STRING_DEFAULT
> -      mips_set_architecture (mips_parse_cpu (MIPS_CPU_STRING_DEFAULT));
> -#else
> -      mips_set_architecture (mips_cpu_info_from_isa (MIPS_ISA_DEFAULT));
> -#endif

So the patch had the effect of ignoring MIPS_ISA_DEFAULT.  This showed
up on mipsisa64-elf, where crt0.S was assembled as MIPS I rather than
MIPS64.

I've applied the fix below.  Tested on mipsisa64-elf and mips-linux-gnu.

Richard


gcc/
	* config/mips/mips.c (mips_default_arch): Honor MIPS_ISA_DEFAULT.
diff mbox

Patch

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2011-05-22 22:19:08.000000000 +0100
+++ gcc/config/mips/mips.c	2011-05-22 22:20:47.000000000 +0100
@@ -15239,12 +15239,14 @@  mips_cpu_info_from_opt (int opt)
 static const struct mips_cpu_info *
 mips_default_arch (void)
 {
-#ifdef MIPS_CPU_STRING_DEFAULT
+#if defined (MIPS_CPU_STRING_DEFAULT)
   unsigned int i;
   for (i = 0; i < ARRAY_SIZE (mips_cpu_info_table); i++)
     if (strcmp (mips_cpu_info_table[i].name, MIPS_CPU_STRING_DEFAULT) == 0)
       return mips_cpu_info_table + i;
   gcc_unreachable ();
+#elif defined (MIPS_ISA_DEFAULT)
+  return mips_cpu_info_from_isa (MIPS_ISA_DEFAULT);
 #else
   /* 'from-abi' makes a good default: you get whatever the ABI
      requires.  */