aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Loiret <aloiret@debian.org>2009-03-24 10:33:57 +0000
committerLaurent GUERBY <laurent@guerby.net>2009-03-24 10:33:57 +0000
commitdeacb9c6ba376cd0ca1a04c6fff6611d8d7b4f1b (patch)
treef8641df89601617667b5eb32e4dd05c034244718
parent89e976d847338286931c2f723d36b4899afa48f5 (diff)
2009-03-24 Arthur Loiret <aloiret@debian.org>
* config.host (alpha*-*-linux*): Use driver-alpha.o and alpha/x-alpha. * config/alpha/linux.h (host_detect_local_cpu): Declare, add to EXTRA_SPEC_FUNCTIONS. (MCPU_MTUNE_NATIVE_SPECS, DRIVER_SELF_SPECS): New macros. * config/alpha/driver-alpha.c, config/alpha/x-alpha: New. * doc/invoke.texi (DEC Alpha Options): Document 'native' value for -march and -mtune options. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@145028 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/config.host11
-rw-r--r--gcc/config/alpha/driver-alpha.c100
-rw-r--r--gcc/config/alpha/linux.h16
-rw-r--r--gcc/config/alpha/x-alpha3
-rw-r--r--gcc/doc/invoke.texi10
6 files changed, 148 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 25c07ea3c5b..6974b1f802a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2009-03-24 Arthur Loiret <aloiret@debian.org>
+
+ * config.host (alpha*-*-linux*): Use driver-alpha.o and
+ alpha/x-alpha.
+ * config/alpha/linux.h (host_detect_local_cpu): Declare, add to
+ EXTRA_SPEC_FUNCTIONS.
+ (MCPU_MTUNE_NATIVE_SPECS, DRIVER_SELF_SPECS): New macros.
+ * config/alpha/driver-alpha.c, config/alpha/x-alpha: New.
+ * doc/invoke.texi (DEC Alpha Options): Document 'native' value for
+ -march and -mtune options.
+
2009-03-24 Ralf Corsépius <ralf.corsepius@rtems.org>
* config/m68k/t-rtems: Add m5329 multilib.
diff --git a/gcc/config.host b/gcc/config.host
index 0cd57ed87f9..b06d1648c73 100644
--- a/gcc/config.host
+++ b/gcc/config.host
@@ -94,6 +94,14 @@ case ${host} in
esac
case ${host} in
+ alpha*-*-linux*)
+ case ${target} in
+ alpha*-*-linux*)
+ host_extra_gcc_objs="driver-alpha.o"
+ host_xmake_file="${host_xmake_file} alpha/x-alpha"
+ ;;
+ esac
+ ;;
i[34567]86-*-* \
| x86_64-*-* )
case ${target} in
@@ -112,9 +120,6 @@ case ${host} in
;;
esac
;;
-esac
-
-case ${host} in
rs6000-*-* \
| powerpc*-*-* )
case ${target} in
diff --git a/gcc/config/alpha/driver-alpha.c b/gcc/config/alpha/driver-alpha.c
new file mode 100644
index 00000000000..d787886d172
--- /dev/null
+++ b/gcc/config/alpha/driver-alpha.c
@@ -0,0 +1,100 @@
+/* Subroutines for the gcc driver.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Arthur Loiret <aloiret@debian.org>
+
+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 3, 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 COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+
+/* This will be called by the spec parser in gcc.c when it sees
+ a %:local_cpu_detect(args) construct. Currently it will be called
+ with either "cpu" or "tune" as argument depending on if -mcpu=native
+ or -mtune=native is to be substituted.
+
+ It returns a string containing new command line parameters to be
+ put at the place of the above two options, depending on what CPU
+ this is executed. E.g. "-mcpu=ev6" on an Alpha 21264 for
+ -mcpu=native. If the routine can't detect a known processor,
+ the -mcpu or -mtune option is discarded.
+
+ ARGC and ARGV are set depending on the actual arguments given
+ in the spec. */
+const char *
+host_detect_local_cpu (int argc, const char **argv)
+{
+ const char *cpu = NULL;
+ char buf[128];
+ FILE *f;
+
+ static const struct cpu_names {
+ const char *const name;
+ const char *const cpu;
+ } cpu_names[] = {
+ { "EV79", "ev67" },
+ { "EV7", "ev67" },
+ { "EV69", "ev67" },
+ { "EV68CX", "ev67" },
+ { "EV68CB", "ev67" },
+ { "EV68AL", "ev67" },
+ { "EV67", "ev67" },
+ { "EV6", "ev6" },
+ { "PCA57", "pca56" },
+ { "PCA56", "pca56" },
+ { "EV56", "ev56" },
+ { "EV5", "ev5" },
+ { "LCA45", "ev45" },
+ { "EV45", "ev45" },
+ { "LCA4", "ev4" },
+ { "EV4", "ev4" },
+/* { "EV3", "ev3" }, */
+ { 0, 0 }
+ };
+
+ int i;
+
+ if (argc < 1)
+ return NULL;
+
+ if (strcmp (argv[0], "cpu") && strcmp (argv[0], "tune"))
+ return NULL;
+
+ f = fopen ("/proc/cpuinfo", "r");
+ if (f == NULL)
+ return NULL;
+
+ while (fgets (buf, sizeof (buf), f) != NULL)
+ if (strncmp (buf, "cpu model", sizeof ("cpu model") - 1) == 0)
+ {
+ for (i = 0; cpu_names [i].name; i++)
+ if (strstr (buf, cpu_names [i].name) != NULL)
+ {
+ cpu = cpu_names [i].cpu;
+ break;
+ }
+ break;
+ }
+
+ fclose (f);
+
+ if (cpu == NULL)
+ return NULL;
+
+ return concat ("-m", argv[0], "=", cpu, NULL);
+}
diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h
index 94876f646de..0a32479d5d7 100644
--- a/gcc/config/alpha/linux.h
+++ b/gcc/config/alpha/linux.h
@@ -85,3 +85,19 @@ along with GCC; see the file COPYING3. If not see
/* Define if long doubles should be mangled as 'g'. */
#define TARGET_ALTERNATE_LONG_DOUBLE_MANGLING
+
+/* -mcpu=native handling only makes sense with compiler running on
+ an Alpha chip. */
+#if defined(__alpha__) || defined(__alpha)
+extern const char *host_detect_local_cpu (int argc, const char **argv);
+# define EXTRA_SPEC_FUNCTIONS \
+ { "local_cpu_detect", host_detect_local_cpu },
+
+# define MCPU_MTUNE_NATIVE_SPECS \
+ " %{mcpu=native:%<mcpu=native %:local_cpu_detect(cpu)}" \
+ " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
+#else
+# define MCPU_MTUNE_NATIVE_SPECS ""
+#endif
+
+#define DRIVER_SELF_SPECS MCPU_MTUNE_NATIVE_SPECS
diff --git a/gcc/config/alpha/x-alpha b/gcc/config/alpha/x-alpha
new file mode 100644
index 00000000000..27b5f466903
--- /dev/null
+++ b/gcc/config/alpha/x-alpha
@@ -0,0 +1,3 @@
+driver-alpha.o: $(srcdir)/config/alpha/driver-alpha.c \
+ $(CONFIG_H) $(SYSTEM_H)
+ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index d1c86dc6ea9..40b72026ce2 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10212,11 +10212,21 @@ Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
@end table
+Native Linux/GNU toolchains also support the value @samp{native},
+which selects the best architecture option for the host processor.
+@option{-mcpu=native} has no effect if GCC does not recognize
+the processor.
+
@item -mtune=@var{cpu_type}
@opindex mtune
Set only the instruction scheduling parameters for machine type
@var{cpu_type}. The instruction set is not changed.
+Native Linux/GNU toolchains also support the value @samp{native},
+which selects the best architecture option for the host processor.
+@option{-mtune=native} has no effect if GCC does not recognize
+the processor.
+
@item -mmemory-latency=@var{time}
@opindex mmemory-latency
Sets the latency the scheduler should assume for typical memory