+2011-07-29 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
+
+ * config/mips/driver-native.c [__sgi__]: Include <invent.h>,
+ <sys/sbd.h>.
+ (cpu_types): New array.
+ (cputype): New function.
+ (host_detect_local_cpu): Only define buf, f if !__sgi__.
+ Use scaninvent instead of /proc/cpuinfo if __sgi__.
+ * config.host: Also use driver-native.o, mips/x-native on
+ mips-sgi-irix*.
+ * config/mips/iris6.h [__mips__] (host_detect_local_cpu):
+ Declare.
+ (EXTRA_SPEC_FUNCTIONS, MARCH_MTUNE_NATIVE_SPECS): Define.
+ (DRIVER_SELF_SPECS): Add MARCH_MTUNE_NATIVE_SPECS.
+
2011-07-29 Jakub Jelinek <jakub@redhat.com>
PR middle-end/49897
/* Subroutines for the gcc driver.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008, 2011 Free Software Foundation, Inc.
This file is part of GCC.
#include "coretypes.h"
#include "tm.h"
+#ifdef __sgi__
+#include <invent.h>
+#include <sys/sbd.h>
+
+/* Cf. MIPS R10000 Microprocessor User Guide, Version 2.0, 14.13 Processor
+ Revision Identifier (PRId) Register (15).
+
+ http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi/hdwr/bks/SGI_Developer/books/R10K_UM/sgi_html/t5.Ver.2.0.book_279.html */
+
+static const struct cpu_types {
+ int impl;
+ const char *cpu;
+} cpu_types[] = {
+ { C0_IMP_R2000, "r2000" },
+ { C0_IMP_R3000, "r3000" },
+ { C0_IMP_R6000, "r6000" },
+ { C0_IMP_R4000, "r4000" },
+ { C0_IMP_R6000A, "r6000" },
+ { C0_IMP_R10000, "r10000" },
+ { C0_IMP_R12000, "r12000" },
+ { C0_IMP_R14000, "r14000" },
+ { C0_IMP_R8000, "r8000" },
+ { C0_IMP_R4600, "r4600" },
+ { C0_IMP_R4700, "r4600" },
+ { C0_IMP_R4650, "r4650" },
+ { C0_IMP_R5000, "vr5000" },
+ { C0_IMP_RM7000, "rm7000" },
+ { C0_IMP_RM5271, "vr5000" },
+ { 0, 0 }
+};
+
+static int
+cputype (inventory_t *inv, void *arg)
+{
+ if (inv != NULL
+ && inv->inv_class == INV_PROCESSOR
+ && inv->inv_type == INV_CPUCHIP)
+ {
+ int i;
+ /* inv_state is the cpu revision number. */
+ int impl = (inv->inv_state & C0_IMPMASK) >> C0_IMPSHIFT;
+
+ for (i = 0; cpu_types[i].cpu != NULL; i++)
+ if (cpu_types[i].impl == impl)
+ {
+ *((const char **) arg) = cpu_types[i].cpu;
+ break;
+ }
+ }
+ return 0;
+}
+#endif
+
/* 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 "arch" or "tune" as argument depending on if -march=native
host_detect_local_cpu (int argc, const char **argv)
{
const char *cpu = NULL;
+#ifndef __sgi__
char buf[128];
FILE *f;
+#endif
bool arch;
if (argc < 1)
if (!arch && strcmp (argv[0], "tune"))
return NULL;
+#ifdef __sgi__
+ scaninvent (cputype, &cpu);
+#else
f = fopen ("/proc/cpuinfo", "r");
if (f == NULL)
return NULL;
}
fclose (f);
+#endif
if (cpu == NULL)
return NULL;
#undef MULTILIB_DEFAULTS
#define MULTILIB_DEFAULTS { "mabi=n32" }
+/* -march=native handling only makes sense with compiler running on
+ a MIPS chip. */
+#if defined(__mips__)
+extern const char *host_detect_local_cpu (int argc, const char **argv);
+# define EXTRA_SPEC_FUNCTIONS \
+ { "local_cpu_detect", host_detect_local_cpu },
+
+# define MARCH_MTUNE_NATIVE_SPECS \
+ " %{march=native:%<march=native %:local_cpu_detect(arch)}" \
+ " %{mtune=native:%<mtune=native %:local_cpu_detect(tune)}"
+#else
+# define MARCH_MTUNE_NATIVE_SPECS ""
+#endif
+
/* Force the default ABI onto the command line in order to make the specs
easier to write. */
#undef DRIVER_SELF_SPECS
#define DRIVER_SELF_SPECS \
"%{!mabi=*: -mabi=n32}", \
/* Configuration-independent MIPS rules. */ \
- BASE_DRIVER_SELF_SPECS
+ BASE_DRIVER_SELF_SPECS, \
+ MARCH_MTUNE_NATIVE_SPECS
/* IRIX 6.5 has the float and long double forms of math functions. */
#define TARGET_C99_FUNCTIONS 1