OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [config/] [alpha/] [driver-alpha.c] - Diff between revs 282 and 338

Only display areas with differences | Details | Blame | View Log

Rev 282 Rev 338
/* Subroutines for the gcc driver.
/* Subroutines for the gcc driver.
   Copyright (C) 2009 Free Software Foundation, Inc.
   Copyright (C) 2009 Free Software Foundation, Inc.
   Contributed by Arthur Loiret <aloiret@debian.org>
   Contributed by Arthur Loiret <aloiret@debian.org>
 
 
This file is part of GCC.
This file is part of GCC.
 
 
GCC is free software; you can redistribute it and/or modify
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
the Free Software Foundation; either version 3, or (at your option)
any later version.
any later version.
 
 
GCC is distributed in the hope that it will be useful,
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */
<http://www.gnu.org/licenses/>.  */
 
 
#include "config.h"
#include "config.h"
#include "system.h"
#include "system.h"
#include "coretypes.h"
#include "coretypes.h"
#include "tm.h"
#include "tm.h"
 
 
/* This will be called by the spec parser in gcc.c when it sees
/* 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
   a %:local_cpu_detect(args) construct.  Currently it will be called
   with either "cpu" or "tune" as argument depending on if -mcpu=native
   with either "cpu" or "tune" as argument depending on if -mcpu=native
   or -mtune=native is to be substituted.
   or -mtune=native is to be substituted.
 
 
   It returns a string containing new command line parameters to be
   It returns a string containing new command line parameters to be
   put at the place of the above two options, depending on what CPU
   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
   this is executed.  E.g. "-mcpu=ev6" on an Alpha 21264 for
   -mcpu=native.  If the routine can't detect a known processor,
   -mcpu=native.  If the routine can't detect a known processor,
   the -mcpu or -mtune option is discarded.
   the -mcpu or -mtune option is discarded.
 
 
   ARGC and ARGV are set depending on the actual arguments given
   ARGC and ARGV are set depending on the actual arguments given
   in the spec.  */
   in the spec.  */
const char *
const char *
host_detect_local_cpu (int argc, const char **argv)
host_detect_local_cpu (int argc, const char **argv)
{
{
  const char *cpu = NULL;
  const char *cpu = NULL;
  char buf[128];
  char buf[128];
  FILE *f;
  FILE *f;
 
 
  static const struct cpu_names {
  static const struct cpu_names {
   const char *const name;
   const char *const name;
   const char *const cpu;
   const char *const cpu;
  } cpu_names[] = {
  } cpu_names[] = {
    { "EV79",   "ev67" },
    { "EV79",   "ev67" },
    { "EV7",    "ev67" },
    { "EV7",    "ev67" },
    { "EV69",   "ev67" },
    { "EV69",   "ev67" },
    { "EV68CX", "ev67" },
    { "EV68CX", "ev67" },
    { "EV68CB", "ev67" },
    { "EV68CB", "ev67" },
    { "EV68AL", "ev67" },
    { "EV68AL", "ev67" },
    { "EV67",   "ev67" },
    { "EV67",   "ev67" },
    { "EV6",    "ev6" },
    { "EV6",    "ev6" },
    { "PCA57",  "pca56" },
    { "PCA57",  "pca56" },
    { "PCA56",  "pca56" },
    { "PCA56",  "pca56" },
    { "EV56",   "ev56" },
    { "EV56",   "ev56" },
    { "EV5",    "ev5" },
    { "EV5",    "ev5" },
    { "LCA45",  "ev45" },
    { "LCA45",  "ev45" },
    { "EV45",   "ev45" },
    { "EV45",   "ev45" },
    { "LCA4",   "ev4" },
    { "LCA4",   "ev4" },
    { "EV4",    "ev4" },
    { "EV4",    "ev4" },
/*  { "EV3",    "ev3" },  */
/*  { "EV3",    "ev3" },  */
    { 0, 0 }
    { 0, 0 }
  };
  };
 
 
  int i;
  int i;
 
 
  if (argc < 1)
  if (argc < 1)
    return NULL;
    return NULL;
 
 
  if (strcmp (argv[0], "cpu") && strcmp (argv[0], "tune"))
  if (strcmp (argv[0], "cpu") && strcmp (argv[0], "tune"))
    return NULL;
    return NULL;
 
 
  f = fopen ("/proc/cpuinfo", "r");
  f = fopen ("/proc/cpuinfo", "r");
  if (f == NULL)
  if (f == NULL)
    return NULL;
    return NULL;
 
 
  while (fgets (buf, sizeof (buf), f) != NULL)
  while (fgets (buf, sizeof (buf), f) != NULL)
    if (strncmp (buf, "cpu model", sizeof ("cpu model") - 1) == 0)
    if (strncmp (buf, "cpu model", sizeof ("cpu model") - 1) == 0)
      {
      {
        for (i = 0; cpu_names [i].name; i++)
        for (i = 0; cpu_names [i].name; i++)
          if (strstr (buf, cpu_names [i].name) != NULL)
          if (strstr (buf, cpu_names [i].name) != NULL)
            {
            {
              cpu = cpu_names [i].cpu;
              cpu = cpu_names [i].cpu;
              break;
              break;
            }
            }
        break;
        break;
      }
      }
 
 
  fclose (f);
  fclose (f);
 
 
  if (cpu == NULL)
  if (cpu == NULL)
    return NULL;
    return NULL;
 
 
  return concat ("-m", argv[0], "=", cpu, NULL);
  return concat ("-m", argv[0], "=", cpu, NULL);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.