diff options
author | mkuvyrkov <mkuvyrkov@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-06-18 08:28:07 +0000 |
---|---|---|
committer | mkuvyrkov <mkuvyrkov@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-06-18 08:28:07 +0000 |
commit | 69f36814fe0634a6334bbc45db2feef3235d07c9 (patch) | |
tree | 08ad1899ff895eecff141825004ddfce771bcfae /gcc/config/mips/driver-native.c | |
parent | d598f4ffeb953d381371f9741fb94220ed8cee5a (diff) | |
download | gcc-69f36814fe0634a6334bbc45db2feef3235d07c9.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@136888 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/mips/driver-native.c')
-rw-r--r-- | gcc/config/mips/driver-native.c | 73 |
1 files changed, 73 insertions, 0 deletions
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 +<http://www.gnu.org/licenses/>. */ + +#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); +} |