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]

[PATCH] Support -mtune= on Alpha


Hi!

Current alpha gcc does not allow to choose instruction set extensions and
scheduling for a particular CPU independently, unless you want to schedule
for the default compiled-in CPU (the reason is that -mcpu= overwrites
settings of -mmax/-mbwx/-mcix/-mfix and their -mno- variants).
This patch adds a separate -mtune= option which can be used to specify a
particular CPU which gcc should schedule for, while -mcpu= decides both
which extensions to use and scheduling CPU (but -mtune= overrides the
scheduling CPU set from any -mcpu=). This matches the options on SPARC, on
ia32 similar options are -march= (instruction set and scheduling) and -mcpu=
(scheduling).
Ok to commit?

BTW: I came over
          { 3, 13, -1 },        /* ev6 -- Ho hum, doesn't exist yet */
in override_options, the comment looks pretty outdated, that's why I'm
wondering whether somebody measured E2$ and E3$ latencies on ev6....

2000-09-15  Jakub Jelinek  <jakub@redhat.com>

	* config/alpha/alpha.h (TARGET_CPU_EV5, TARGET_CPU_EV6): Define.
	(TARGET_OPTIONS): Add tune=.
	(alpha_tune_string): Declare.
	* config/alpha/alpha.c (override_options): Add cpu_table.
	Use alpha_cpu_string first to set both alpha_cpu and target_flags
	and then alpha_tune_string to set alpha_cpu only.
	Replace tests for PROCESSOR_EV* with TARGET_CPU_EV* tests.
	* config/alpha/elf.h (ASM_FILE_START): Likewise.
	* config/alpha/osf.h (ASM_FILE_START): Likewise.
	* config/alpha/openbsd.h (ASM_FILE_START): Likewise.

--- gcc/config/alpha/alpha.h.jj	Sun Jul  2 10:37:08 2000
+++ gcc/config/alpha/alpha.h	Fri Sep 15 15:59:46 2000
@@ -156,12 +156,14 @@ extern enum alpha_fp_trap_mode alpha_fpt
 #define MASK_CIX	(1 << 11)
 #define TARGET_CIX	(target_flags & MASK_CIX)
 
-/* This means that the processor is an EV5, EV56, or PCA56.  This is defined
-   only in TARGET_CPU_DEFAULT.  */
+/* This means that the processor is an EV5, EV56, or PCA56.
+   Unlike alpha_cpu this is not affected by -mtune= setting.  */
 #define MASK_CPU_EV5	(1 << 28)
+#define TARGET_CPU_EV5	(target_flags & MASK_CPU_EV5)
 
 /* Likewise for EV6.  */
 #define MASK_CPU_EV6	(1 << 29)
+#define TARGET_CPU_EV6	(target_flags & MASK_CPU_EV6)
 
 /* This means we support the .arch directive in the assembler.  Only
    defined in TARGET_CPU_DEFAULT.  */
@@ -249,6 +251,7 @@ extern enum alpha_fp_trap_mode alpha_fpt
 	#define TARGET_OPTIONS { { "short-data-", &m88k_short_data } }  */
 
 extern const char *alpha_cpu_string;	/* For -mcpu= */
+extern const char *alpha_tune_string;	/* For -mtune= */
 extern const char *alpha_fprm_string;	/* For -mfp-rounding-mode=[n|m|c|d] */
 extern const char *alpha_fptm_string;	/* For -mfp-trap-mode=[n|u|su|sui]  */
 extern const char *alpha_tp_string;	/* For -mtrap-precision=[p|f|i] */
@@ -257,7 +260,9 @@ extern const char *alpha_mlat_string;	/*
 #define TARGET_OPTIONS					\
 {							\
   {"cpu=",		&alpha_cpu_string,		\
-   N_("Generate code for a given CPU")},		\
+   N_("Use features of and schedule given CPU")},	\
+  {"tune=",		&alpha_tune_string,		\
+   N_("Schedule given CPU")},				\
   {"fp-rounding-mode=",	&alpha_fprm_string,		\
    N_("Control the generated fp rounding mode")},	\
   {"fp-trap-mode=",	&alpha_fptm_string,		\
--- gcc/config/alpha/alpha.c.jj	Wed Sep 13 16:08:44 2000
+++ gcc/config/alpha/alpha.c	Fri Sep 15 16:14:14 2000
@@ -70,6 +70,7 @@ enum alpha_fp_trap_mode alpha_fptm;
 /* Strings decoded into the above options.  */
 
 const char *alpha_cpu_string;	/* -mcpu= */
+const char *alpha_tune_string;	/* -mtune= */
 const char *alpha_tp_string;	/* -mtrap-precision=[p|s|i] */
 const char *alpha_fprm_string;	/* -mfp-rounding-mode=[n|m|c|d] */
 const char *alpha_fptm_string;	/* -mfp-trap-mode=[n|u|su|sui] */
@@ -146,6 +147,31 @@ static rtx alpha_emit_xfloating_compare
 void
 override_options ()
 {
+  int i;
+  static struct cpu_table {
+    const char *name;
+    enum processor_type processor;
+    int flags;
+  } cpu_table[] = {
+#define EV5_MASK (MASK_CPU_EV5)
+#define EV6_MASK (MASK_CPU_EV6|MASK_BWX|MASK_MAX|MASK_FIX)
+    { "ev4",	PROCESSOR_EV4, 0 },
+    { "ev45",	PROCESSOR_EV4, 0 },
+    { "21064",	PROCESSOR_EV4, 0 },
+    { "ev5",	PROCESSOR_EV5, EV5_MASK },
+    { "21164",	PROCESSOR_EV5, EV5_MASK },
+    { "ev56",	PROCESSOR_EV5, EV5_MASK|MASK_BWX },
+    { "21164a",	PROCESSOR_EV5, EV5_MASK|MASK_BWX },
+    { "pca56",	PROCESSOR_EV5, EV5_MASK|MASK_BWX|MASK_MAX },
+    { "21164PC",PROCESSOR_EV5, EV5_MASK|MASK_BWX|MASK_MAX },
+    { "21164pc",PROCESSOR_EV5, EV5_MASK|MASK_BWX|MASK_MAX },
+    { "ev6",	PROCESSOR_EV6, EV6_MASK },
+    { "21264",	PROCESSOR_EV6, EV6_MASK },
+    { "ev67",	PROCESSOR_EV6, EV6_MASK|MASK_CIX },
+    { "21264a",	PROCESSOR_EV6, EV6_MASK|MASK_CIX },
+    { 0, 0, 0 }
+  };
+                  
   alpha_tp = ALPHA_TP_PROG;
   alpha_fprm = ALPHA_FPRM_NORM;
   alpha_fptm = ALPHA_FPTM_N;
@@ -209,61 +235,41 @@ override_options ()
 
   if (alpha_cpu_string)
     {
-      if (! strcmp (alpha_cpu_string, "ev4")
-	  || ! strcmp (alpha_cpu_string, "ev45")
-	  || ! strcmp (alpha_cpu_string, "21064"))
-	{
-	  alpha_cpu = PROCESSOR_EV4;
-	  target_flags &= ~ (MASK_BWX | MASK_MAX | MASK_FIX | MASK_CIX);
-	}
-      else if (! strcmp (alpha_cpu_string, "ev5")
-	       || ! strcmp (alpha_cpu_string, "21164"))
-	{
-	  alpha_cpu = PROCESSOR_EV5;
-	  target_flags &= ~ (MASK_BWX | MASK_MAX | MASK_FIX | MASK_CIX);
-	}
-      else if (! strcmp (alpha_cpu_string, "ev56")
-	       || ! strcmp (alpha_cpu_string, "21164a"))
-	{
-	  alpha_cpu = PROCESSOR_EV5;
-	  target_flags |= MASK_BWX;
-	  target_flags &= ~ (MASK_MAX | MASK_FIX | MASK_CIX);
-	}
-      else if (! strcmp (alpha_cpu_string, "pca56")
-	       || ! strcmp (alpha_cpu_string, "21164PC")
-	       || ! strcmp (alpha_cpu_string, "21164pc"))
-	{
-	  alpha_cpu = PROCESSOR_EV5;
-	  target_flags |= MASK_BWX | MASK_MAX;
-	  target_flags &= ~ (MASK_FIX | MASK_CIX);
-	}
-      else if (! strcmp (alpha_cpu_string, "ev6")
-	       || ! strcmp (alpha_cpu_string, "21264"))
-	{
-	  alpha_cpu = PROCESSOR_EV6;
-	  target_flags |= MASK_BWX | MASK_MAX | MASK_FIX;
-	  target_flags &= ~ (MASK_CIX);
-	}
-      else if (! strcmp (alpha_cpu_string, "ev67")
-	       || ! strcmp (alpha_cpu_string, "21264a"))
-	{
-	  alpha_cpu = PROCESSOR_EV6;
-	  target_flags |= MASK_BWX | MASK_MAX | MASK_FIX | MASK_CIX;
-	}
-      else
+      for (i = 0; cpu_table [i].name; i++)
+	if (! strcmp (alpha_cpu_string, cpu_table [i].name))
+	  {
+	    alpha_cpu = cpu_table [i].processor;
+	    target_flags &= ~ (MASK_BWX | MASK_MAX | MASK_FIX | MASK_CIX
+			       | MASK_CPU_EV5 | MASK_CPU_EV6);
+	    target_flags |= cpu_table [i].flags;
+	    break;
+	  }
+      if (! cpu_table [i].name)
 	error ("bad value `%s' for -mcpu switch", alpha_cpu_string);
     }
 
+  if (alpha_tune_string)
+    {
+      for (i = 0; cpu_table [i].name; i++)
+	if (! strcmp (alpha_tune_string, cpu_table [i].name))
+	  {
+	    alpha_cpu = cpu_table [i].processor;
+	    break;
+	  }
+      if (! cpu_table [i].name)
+	error ("bad value `%s' for -mcpu switch", alpha_tune_string);
+    }
+
   /* Do some sanity checks on the above options. */
 
   if ((alpha_fptm == ALPHA_FPTM_SU || alpha_fptm == ALPHA_FPTM_SUI)
-      && alpha_tp != ALPHA_TP_INSN && alpha_cpu != PROCESSOR_EV6)
+      && alpha_tp != ALPHA_TP_INSN && ! TARGET_CPU_EV6)
     {
       warning ("fp software completion requires -mtrap-precision=i");
       alpha_tp = ALPHA_TP_INSN;
     }
 
-  if (alpha_cpu == PROCESSOR_EV6)
+  if (TARGET_CPU_EV6)
     {
       /* Except for EV6 pass 1 (not released), we always have precise
 	 arithmetic traps.  Which means we can do software completion
--- gcc/config/alpha/elf.h.jj	Thu Jun  1 11:56:45 2000
+++ gcc/config/alpha/elf.h	Fri Sep 15 16:06:34 2000
@@ -61,7 +61,7 @@ do {								\
   if (TARGET_BWX | TARGET_MAX | TARGET_FIX | TARGET_CIX)	\
     {								\
       fprintf (FILE, "\t.arch %s\n",				\
-               (alpha_cpu == PROCESSOR_EV6 ? "ev6"		\
+               (TARGET_CPU_EV6 ? "ev6"				\
                 : TARGET_MAX ? "pca56" : "ev56"));		\
     }								\
 } while (0)
--- gcc/config/alpha/osf.h.jj	Thu Jul 27 19:46:46 2000
+++ gcc/config/alpha/osf.h	Fri Sep 15 16:09:18 2000
@@ -70,8 +70,8 @@ Boston, MA 02111-1307, USA.  */
   fprintf (FILE, "\t.set noat\n");				\
   if (TARGET_SUPPORT_ARCH)					\
     fprintf (FILE, "\t.arch %s\n",				\
-             alpha_cpu == PROCESSOR_EV6 ? "ev6"			\
-	     : (alpha_cpu == PROCESSOR_EV5			\
+             TARGET_CPU_EV6 ? "ev6"				\
+	     : (TARGET_CPU_EV5					\
 		? (TARGET_MAX ? "pca56" : TARGET_BWX ? "ev56" : "ev5") \
 		: "ev4"));					\
 								\
--- gcc/config/alpha/openbsd.h.jj	Sat Sep  4 17:08:55 1999
+++ gcc/config/alpha/openbsd.h	Fri Sep 15 16:08:49 2000
@@ -100,8 +100,8 @@ Boston, MA 02111-1307, USA.  */
   fprintf (FILE, "\t.set noat\n");				\
   if (TARGET_SUPPORT_ARCH)					\
     fprintf (FILE, "\t.arch %s\n",				\
-             alpha_cpu == PROCESSOR_EV6 ? "ev6"			\
-	     : (alpha_cpu == PROCESSOR_EV5			\
+             TARGET_CPU_EV6 ? "ev6"				\
+	     : (TARGET_CPU_EV5					\
 		? (TARGET_MAX ? "pca56" : TARGET_BWX ? "ev56" : "ev5") \
 		: "ev4"));					\
 								\

	Jakub

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