This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


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

FYI: -march/-mcpu patch for mips


Here is a patch I have been using to add -march/-mcpu for mips. But it
only works with my -march/-mcpu patch for binutils. I didn't submit
them since they have to be installed together. My Linux mips toolchain
has the -march/-mcpu gcc/binutils patches.


H.J.
------
2001-04-11  H.J. Lu  (hjl@gnu.org)

	* config/mips/mips.c (mips_parse_cpu): New function to parse
	-march=*/-mcpu=*.
	(mips_arch_string): New for -march=*.
	(override_options): Handle mips_arch_string. Set mips_isa if
	mips_arch_string is set and mips_isa is not set. Set
	mips_cpu_string to mips_arch_string if mips_cpu_string is not
	set.

	* config/mips/mips.h (processor_type): Add PROCESSOR_R10000.
	(mips_arch_string): Declared.
	(SUBTARGET_TARGET_OPTIONS): Add "arch=".
	(GAS_ASM_SPEC): Add %{march=*}.

--- gcc/config/mips/mips.c.march	Tue Apr 10 15:43:03 2001
+++ gcc/config/mips/mips.c	Tue Apr 10 20:43:45 2001
@@ -113,6 +113,7 @@ static void abort_with_insn			PARAMS ((r
   ATTRIBUTE_NORETURN;
 static int symbolic_expression_p                PARAMS ((rtx));
 static void mips_add_gc_roots                   PARAMS ((void));
+static enum processor_type mips_parse_cpu	PARAMS ((const char *));
 
 /* Global variables for machine-dependent things.  */
 
@@ -212,6 +213,7 @@ int mips_abi;
 #endif
 
 /* Strings to hold which cpu and instruction set architecture to use.  */
+const char *mips_arch_string;	/* for -march=<xxx> */
 const char *mips_cpu_string;	/* for -mcpu=<xxx> */
 const char *mips_isa_string;	/* for -mips{1,2,3,4} */
 const char *mips_abi_string;	/* for -mabi={32,n32,64,eabi} */
@@ -4623,6 +4625,99 @@ abort_with_insn (insn, reason)
   abort ();
 }
 
+static enum processor_type
+mips_parse_cpu (cpu_string)
+     const char *cpu_string;
+{
+  const char *p = cpu_string;
+  int seen_v = 0;
+  enum processor_type cpu;
+
+  /* We need to cope with the various "vr" prefixes for the NEC 4300
+     and 4100 processors.  */
+  if (*p == 'v' || *p == 'V')
+    seen_v = 1, p++;
+
+  if (*p == 'r' || *p == 'R')
+    p++;
+
+  /* Since there is no difference between a R2000 and R3000 in
+     terms of the scheduler, we collapse them into just an R3000. */
+
+  cpu = PROCESSOR_DEFAULT;
+  switch (*p)
+    {
+    case '1':
+      if (!strcmp (p, "10000") || !strcmp (p, "10k") || !strcmp (p, "10K"))
+	cpu = PROCESSOR_R10000;
+      break;
+
+    case '2':
+      if (!strcmp (p, "2000") || !strcmp (p, "2k") || !strcmp (p, "2K"))
+	cpu = PROCESSOR_R3000;
+      break;
+
+    case '3':
+      if (!strcmp (p, "3000") || !strcmp (p, "3k") || !strcmp (p, "3K"))
+	cpu = PROCESSOR_R3000;
+      else if (!strcmp (p, "3900"))
+	cpu = PROCESSOR_R3900;
+     break;
+
+    case '4':
+      if (!strcmp (p, "4000") || !strcmp (p, "4k") || !strcmp (p, "4K"))
+	cpu = PROCESSOR_R4000;
+      /* The vr4100 is a non-FP ISA III processor with some extra
+	instructions.  */
+      else if (!strcmp (p, "4100"))
+	cpu = PROCESSOR_R4100;
+      /* The vr4300 is a standard ISA III processor, but with a
+	 different pipeline.  */
+      else if (!strcmp (p, "4300"))
+	cpu = PROCESSOR_R4300;
+      /* The r4400 is exactly the same as the r4000 from the compiler's
+	 viewpoint.  */
+      else if (!strcmp (p, "4400"))
+	cpu = PROCESSOR_R4000;
+      else if (!strcmp (p, "4600"))
+	cpu = PROCESSOR_R4600;
+      else if (!strcmp (p, "4650"))
+	cpu = PROCESSOR_R4650;
+      break;
+
+    case '5':
+      if (!strcmp (p, "5000") || !strcmp (p, "5k") || !strcmp (p, "5K"))
+	cpu = PROCESSOR_R5000;
+      break;
+
+    case '6':
+      if (!strcmp (p, "6000") || !strcmp (p, "6k") || !strcmp (p, "6K"))
+	cpu = PROCESSOR_R6000;
+      break;
+
+    case '8':
+      if (!strcmp (p, "8000") || !strcmp (p, "8k") || !strcmp (p, "8K"))
+	cpu = PROCESSOR_R8000;
+      break;
+
+    case 'o':
+      if (!strcmp (p, "orion"))
+	cpu = PROCESSOR_R4600;
+      break;
+    }
+
+  if (seen_v
+      && cpu != PROCESSOR_R4300
+      && cpu != PROCESSOR_R4100
+      && cpu != PROCESSOR_R5000)
+    cpu = PROCESSOR_DEFAULT;
+
+  if (cpu == PROCESSOR_DEFAULT)
+    error ("bad value (%s) for -mcpu= switch", cpu_string);
+
+  return cpu;
+}
+
 /* Set up the threshold for data to go into the small data area, instead
    of the normal data area, and detect any conflicts in the switches.  */
 
@@ -4759,124 +4854,81 @@ override_options ()
      greater than that supported by the default processor, then the user gets
      an error.  Normally, the compiler will just default to the base level cpu
      for the indicated isa.  */
+  if (mips_arch_string == 0)
+    mips_arch_string = MIPS_CPU_STRING_DEFAULT;
   if (mips_cpu_string == 0)
     mips_cpu_string = MIPS_CPU_STRING_DEFAULT;
 #endif
 
-  /* Identify the processor type */
-  if (mips_cpu_string == 0
-      || !strcmp (mips_cpu_string, "default")
-      || !strcmp (mips_cpu_string, "DEFAULT"))
+  /* Identify the architecture type */
+  if (mips_arch_string == 0
+      || !strcmp (mips_arch_string, "default")
+      || !strcmp (mips_arch_string, "DEFAULT"))
     {
       switch (mips_isa)
 	{
 	default:
-	  mips_cpu_string = "3000";
+	  mips_arch_string = "3000";
 	  mips_cpu = PROCESSOR_R3000;
 	  break;
 	case 2:
-	  mips_cpu_string = "6000";
+	  mips_arch_string = "6000";
 	  mips_cpu = PROCESSOR_R6000;
 	  break;
 	case 3:
-	  mips_cpu_string = "4000";
+	  mips_arch_string = "4000";
 	  mips_cpu = PROCESSOR_R4000;
 	  break;
 	case 4:
-	  mips_cpu_string = "8000";
+	  mips_arch_string = "8000";
 	  mips_cpu = PROCESSOR_R8000;
 	  break;
 	}
     }
-
   else
     {
-      const char *p = mips_cpu_string;
-      int seen_v = 0;
-
-      /* We need to cope with the various "vr" prefixes for the NEC 4300
-	 and 4100 processors.  */
-      if (*p == 'v' || *p == 'V')
-	seen_v = 1, p++;
-
-      if (*p == 'r' || *p == 'R')
-	p++;
-
-      /* Since there is no difference between a R2000 and R3000 in
-	 terms of the scheduler, we collapse them into just an R3000. */
-
-      mips_cpu = PROCESSOR_DEFAULT;
-      switch (*p)
-	{
-	case '2':
-	  if (!strcmp (p, "2000") || !strcmp (p, "2k") || !strcmp (p, "2K"))
-	    mips_cpu = PROCESSOR_R3000;
-	  break;
-
-	case '3':
-	  if (!strcmp (p, "3000") || !strcmp (p, "3k") || !strcmp (p, "3K"))
-	    mips_cpu = PROCESSOR_R3000;
-	  else if (!strcmp (p, "3900"))
-	    mips_cpu = PROCESSOR_R3900;
-	  break;
-
-	case '4':
-	  if (!strcmp (p, "4000") || !strcmp (p, "4k") || !strcmp (p, "4K"))
-	    mips_cpu = PROCESSOR_R4000;
-          /* The vr4100 is a non-FP ISA III processor with some extra
-             instructions.  */
-	  else if (!strcmp (p, "4100"))
-	    {
-              mips_cpu = PROCESSOR_R4100;
-              target_flags |= MASK_SOFT_FLOAT ;
-	    }
-	  /* The vr4300 is a standard ISA III processor, but with a different
-	     pipeline.  */
-	  else if (!strcmp (p, "4300"))
-            mips_cpu = PROCESSOR_R4300;
-	  /* The r4400 is exactly the same as the r4000 from the compiler's
-	     viewpoint.  */
-	  else if (!strcmp (p, "4400"))
-	    mips_cpu = PROCESSOR_R4000;
-	  else if (!strcmp (p, "4600"))
-	    mips_cpu = PROCESSOR_R4600;
-	  else if (!strcmp (p, "4650"))
-	    mips_cpu = PROCESSOR_R4650;
-	  break;
-
-	case '5':
-	  if (!strcmp (p, "5000") || !strcmp (p, "5k") || !strcmp (p, "5K"))
-	    mips_cpu = PROCESSOR_R5000;
-	  break;
-
-	case '6':
-	  if (!strcmp (p, "6000") || !strcmp (p, "6k") || !strcmp (p, "6K"))
-	    mips_cpu = PROCESSOR_R6000;
-	  break;
-
-	case '8':
-	  if (!strcmp (p, "8000"))
-	    mips_cpu = PROCESSOR_R8000;
-	  break;
-
-	case 'o':
-	  if (!strcmp (p, "orion"))
-	    mips_cpu = PROCESSOR_R4600;
-	  break;
-	}
-
-      if (seen_v
-	  && mips_cpu != PROCESSOR_R4300
-	  && mips_cpu != PROCESSOR_R4100
-	  && mips_cpu != PROCESSOR_R5000)
-	mips_cpu = PROCESSOR_DEFAULT;
+      mips_cpu = mips_parse_cpu (mips_arch_string);
+      if (mips_cpu == PROCESSOR_DEFAULT)
+	mips_arch_string = "default";
+      else if (mips_isa_string == 0)
+	switch (mips_cpu)
+	  {
+	  case PROCESSOR_R3000:
+	  case PROCESSOR_R3900:
+	    mips_isa = 1;
+	    break;
+	  case PROCESSOR_R6000:
+	    mips_isa = 2;
+	    break;
+	  case PROCESSOR_R4000:
+	  case PROCESSOR_R4100:
+	  case PROCESSOR_R4300:
+	  case PROCESSOR_R4600:
+	  case PROCESSOR_R4650:
+	    mips_isa = 3;
+	    break;
+	  case PROCESSOR_R5000:
+	  case PROCESSOR_R8000:
+	  case PROCESSOR_R10000:
+	    mips_isa = 4;
+	    break;
+	  }
+    }
 
+  /* Identify the processor type */
+  if (mips_cpu_string == 0
+      || !strcmp (mips_cpu_string, "default")
+      || !strcmp (mips_cpu_string, "DEFAULT"))
+    mips_cpu_string = mips_arch_string;
+  else
+    {
+      mips_cpu = mips_parse_cpu (mips_cpu_string);
       if (mips_cpu == PROCESSOR_DEFAULT)
-	{
-	  error ("bad value (%s) for -mcpu= switch", mips_cpu_string);
-	  mips_cpu_string = "default";
-	}
+	mips_cpu_string = "default";
     }
+
+  if (mips_cpu == PROCESSOR_R4100)
+    target_flags |= MASK_SOFT_FLOAT ;
 
   if ((mips_cpu == PROCESSOR_R3000 && (mips_isa != 1))
       || (mips_cpu == PROCESSOR_R6000 && mips_isa != 1 && mips_isa != 2)
--- gcc/config/mips/mips.h.march	Tue Apr 10 15:40:06 2001
+++ gcc/config/mips/mips.h	Tue Apr 10 16:27:55 2001
@@ -67,7 +67,8 @@ enum processor_type {
   PROCESSOR_R4600,
   PROCESSOR_R4650,
   PROCESSOR_R5000,
-  PROCESSOR_R8000
+  PROCESSOR_R8000,
+  PROCESSOR_R10000
 };
 
 /* Recast the cpu class to be the cpu attribute.  */
@@ -139,6 +140,7 @@ extern int mips_isa;			/* architectural 
 extern int mips16;			/* whether generating mips16 code */
 extern int mips16_hard_float;		/* mips16 without -msoft-float */
 extern int mips_entry;			/* generate entry/exit for mips16 */
+extern const char *mips_arch_string;	/* for -march=<xxx> */
 extern const char *mips_cpu_string;	/* for -mcpu=<xxx> */
 extern const char *mips_isa_string;	/* for -mips{1,2,3,4} */
 extern const char *mips_abi_string;	/* for -mabi={32,n32,64} */
@@ -552,6 +554,8 @@ extern void		sbss_section PARAMS ((void)
   SUBTARGET_TARGET_OPTIONS						\
   { "cpu=",	&mips_cpu_string,					\
       N_("Specify CPU for scheduling purposes")},			\
+  { "arch=",	&mips_arch_string,					\
+      N_("Specify CPU for code generation purposes")},			\
   { "ips",	&mips_isa_string,					\
       N_("Specify MIPS ISA")},						\
   { "entry",	&mips_entry_string,					\
@@ -774,7 +778,7 @@ while (0)
 /* GAS_ASM_SPEC is passed when using gas, rather than the MIPS
    assembler.  */
 
-#define GAS_ASM_SPEC "%{mcpu=*} %{m4650} %{mmad:-m4650} %{m3900} %{v} %{mgp32} %{mgp64}"
+#define GAS_ASM_SPEC "%{march=*} %{mcpu=*} %{m4650} %{mmad:-m4650} %{m3900} %{v} %{mgp32} %{mgp64}"
 
 /* TARGET_ASM_SPEC is used to select either MIPS_AS_ASM_SPEC or
    GAS_ASM_SPEC as the default, depending upon the value of


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