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] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 282 jeremybenn
/* Subroutines for the gcc driver.
2
   Copyright (C) 2009 Free Software Foundation, Inc.
3
   Contributed by Arthur Loiret <aloiret@debian.org>
4
 
5
This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 3, or (at your option)
10
any later version.
11
 
12
GCC is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING3.  If not see
19
<http://www.gnu.org/licenses/>.  */
20
 
21
#include "config.h"
22
#include "system.h"
23
#include "coretypes.h"
24
#include "tm.h"
25
 
26
/* This will be called by the spec parser in gcc.c when it sees
27
   a %:local_cpu_detect(args) construct.  Currently it will be called
28
   with either "cpu" or "tune" as argument depending on if -mcpu=native
29
   or -mtune=native is to be substituted.
30
 
31
   It returns a string containing new command line parameters to be
32
   put at the place of the above two options, depending on what CPU
33
   this is executed.  E.g. "-mcpu=ev6" on an Alpha 21264 for
34
   -mcpu=native.  If the routine can't detect a known processor,
35
   the -mcpu or -mtune option is discarded.
36
 
37
   ARGC and ARGV are set depending on the actual arguments given
38
   in the spec.  */
39
const char *
40
host_detect_local_cpu (int argc, const char **argv)
41
{
42
  const char *cpu = NULL;
43
  char buf[128];
44
  FILE *f;
45
 
46
  static const struct cpu_names {
47
   const char *const name;
48
   const char *const cpu;
49
  } cpu_names[] = {
50
    { "EV79",   "ev67" },
51
    { "EV7",    "ev67" },
52
    { "EV69",   "ev67" },
53
    { "EV68CX", "ev67" },
54
    { "EV68CB", "ev67" },
55
    { "EV68AL", "ev67" },
56
    { "EV67",   "ev67" },
57
    { "EV6",    "ev6" },
58
    { "PCA57",  "pca56" },
59
    { "PCA56",  "pca56" },
60
    { "EV56",   "ev56" },
61
    { "EV5",    "ev5" },
62
    { "LCA45",  "ev45" },
63
    { "EV45",   "ev45" },
64
    { "LCA4",   "ev4" },
65
    { "EV4",    "ev4" },
66
/*  { "EV3",    "ev3" },  */
67
    { 0, 0 }
68
  };
69
 
70
  int i;
71
 
72
  if (argc < 1)
73
    return NULL;
74
 
75
  if (strcmp (argv[0], "cpu") && strcmp (argv[0], "tune"))
76
    return NULL;
77
 
78
  f = fopen ("/proc/cpuinfo", "r");
79
  if (f == NULL)
80
    return NULL;
81
 
82
  while (fgets (buf, sizeof (buf), f) != NULL)
83
    if (strncmp (buf, "cpu model", sizeof ("cpu model") - 1) == 0)
84
      {
85
        for (i = 0; cpu_names [i].name; i++)
86
          if (strstr (buf, cpu_names [i].name) != NULL)
87
            {
88
              cpu = cpu_names [i].cpu;
89
              break;
90
            }
91
        break;
92
      }
93
 
94
  fclose (f);
95
 
96
  if (cpu == NULL)
97
    return NULL;
98
 
99
  return concat ("-m", argv[0], "=", cpu, NULL);
100
}

powered by: WebSVN 2.1.0

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