From: Daniel Jacobowitz Date: Wed, 18 Jun 2008 08:28:07 +0000 (+0000) Subject: config.gcc (mips64el-st-linux-gnu): Use mips/st.h and mips/t-st. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=900e3ae581fac0fa5fb79b790f4be57501fba319;p=gcc.git config.gcc (mips64el-st-linux-gnu): Use mips/st.h and mips/t-st. * config.gcc (mips64el-st-linux-gnu): Use mips/st.h and mips/t-st. * config.host: Use driver-native.o and mips/x-native for mips*-linux*. * config/mips/linux.h (host_detect_local_cpu): Declare, add to EXTRA_SPEC_FUNCTIONS. (MARCH_MTUNE_NATIVE_SPECS, BASE_DRIVER_SELF_SPECS): New macros. (DRIVER_SELF_SPECS): Adjust. * config/mips/linux64.h (DRIVER_SELF_SPECS): Update. * config/mips/st.h, config/mips/t-st: New. * config/mips/driver-native.c, config/mips/x-native: New. * doc/invoke.texi (MIPS): Document 'native' value for -march and -mtune options. Co-Authored-By: Kazu Hirata From-SVN: r136888 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 059fa77f058..3712af4fe22 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2008-06-16 Daniel Jacobowitz + Kazu Hirata + Maxim Kuvyrkov * config/mips/mips.h (ISA_HAS_CONDMOVE): Slice ISA_HAS_FP_CONDMOVE diff --git a/gcc/config.gcc b/gcc/config.gcc index 8c8a66a6772..5327abde7f8 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -1523,6 +1523,12 @@ mips64*-*-linux*) tm_file="dbxelf.h elfos.h svr4.h linux.h ${tm_file} mips/linux.h mips/linux64.h" tmake_file="${tmake_file} mips/t-linux64" tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_N32" + case ${target} in + mips64el-st-linux-gnu) + tm_file="${tm_file} mips/st.h" + tmake_file="${tmake_file} mips/t-st" + ;; + esac gnu_ld=yes gas=yes test x$with_llsc != x || with_llsc=yes diff --git a/gcc/config.host b/gcc/config.host index 965288a29f4..d6efc6d730b 100644 --- a/gcc/config.host +++ b/gcc/config.host @@ -104,6 +104,14 @@ case ${host} in ;; esac ;; + mips*-*-linux*) + case ${target} in + mips*-*-linux*) + host_extra_gcc_objs="driver-native.o" + host_xmake_file="${host_xmake_file} mips/x-native" + ;; + esac + ;; esac case ${host} in diff --git a/gcc/config/mips/driver-native.c b/gcc/config/mips/driver-native.c new file mode 100644 index 00000000000..22b08939e24 --- /dev/null +++ b/gcc/config/mips/driver-native.c @@ -0,0 +1,73 @@ +/* Subroutines for the gcc driver. + Copyright (C) 2008 Free Software Foundation, Inc. + +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 +. */ + +#include "config.h" +#include "system.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 "arch" or "tune" as argument depending on if -march=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. "-march=loongson2f" on a Loongson 2F for + -march=native. If the routine can't detect a known processor, + the -march 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; + bool arch; + + if (argc < 1) + return NULL; + + arch = strcmp (argv[0], "arch") == 0; + if (!arch && 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) + { + if (strstr (buf, "Godson2 V0.2") != NULL + || strstr (buf, "Loongson-2 V0.2") != NULL) + cpu = "loongson2e"; + else if (strstr (buf, "Godson2 V0.3") != NULL + || strstr (buf, "Loongson-2 V0.3") != NULL) + cpu = "loongson2f"; + break; + } + + fclose (f); + + if (cpu == NULL) + return NULL; + + return concat ("-m", argv[0], "=", cpu, NULL); +} diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h index 4ee046a5954..2e7b1028c6e 100644 --- a/gcc/config/mips/linux.h +++ b/gcc/config/mips/linux.h @@ -143,9 +143,27 @@ along with GCC; see the file COPYING3. If not see #ifdef HAVE_AS_NO_SHARED /* Default to -mno-shared for non-PIC. */ -#define NO_SHARED_SPECS \ +# define NO_SHARED_SPECS \ "%{mshared|mno-shared|fpic|fPIC|fpie|fPIE:;:-mno-shared}" -#define DRIVER_SELF_SPECS NO_SHARED_SPECS #else -#define NO_SHARED_SPECS +# define NO_SHARED_SPECS "" #endif + +/* -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:%. */ + +/* The various C libraries each have their own subdirectory. */ +#undef SYSROOT_SUFFIX_SPEC +#define SYSROOT_SUFFIX_SPEC \ + "%{march=loongson2e:/2e ; \ + march=loongson2f:/2f}" + +#undef STARTFILE_PREFIX_SPEC +#define STARTFILE_PREFIX_SPEC \ + "%{mabi=32: /usr/local/lib/ /lib/ /usr/lib/} \ + %{mabi=n32: /usr/local/lib32/ /lib32/ /usr/lib32/} \ + %{mabi=64: /usr/local/lib64/ /lib64/ /usr/lib64/}" diff --git a/gcc/config/mips/t-st b/gcc/config/mips/t-st new file mode 100644 index 00000000000..8fa679016df --- /dev/null +++ b/gcc/config/mips/t-st @@ -0,0 +1,14 @@ +MULTILIB_OPTIONS = march=loongson2e/march=loongson2f mabi=n32/mabi=32/mabi=64 +MULTILIB_DIRNAMES = 2e 2f lib32 lib lib64 + +MULTILIB_OSDIRNAMES = march.loongson2e/mabi.n32=../lib32/2e +MULTILIB_OSDIRNAMES += march.loongson2e/mabi.32=../lib/2e +MULTILIB_OSDIRNAMES += march.loongson2e/mabi.64=../lib64/2e +MULTILIB_OSDIRNAMES += march.loongson2f/mabi.n32=../lib32/2f +MULTILIB_OSDIRNAMES += march.loongson2f/mabi.32=../lib/2f +MULTILIB_OSDIRNAMES += march.loongson2f/mabi.64=../lib64/2f +MULTILIB_OSDIRNAMES += mabi.n32=../lib32 +MULTILIB_OSDIRNAMES += mabi.32=../lib +MULTILIB_OSDIRNAMES += mabi.64=../lib64 + +EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o diff --git a/gcc/config/mips/x-native b/gcc/config/mips/x-native new file mode 100644 index 00000000000..6820e73d94b --- /dev/null +++ b/gcc/config/mips/x-native @@ -0,0 +1,3 @@ +driver-native.o : $(srcdir)/config/mips/driver-native.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 f1bffe471ad..fd438122f5b 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -11972,6 +11972,11 @@ The special value @samp{from-abi} selects the most compatible architecture for the selected ABI (that is, @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@. +Native Linux/GNU toolchains also support the value @samp{native}, +which selects the best architecture option for the host processor. +@option{-march=native} has no effect if GCC does not recognize +the processor. + In processor names, a final @samp{000} can be abbreviated as @samp{k} (for example, @samp{-march=r2k}). Prefixes are optional, and @samp{vr} may be written @samp{r}.