0
|
1 /* Subroutines for the gcc driver.
|
145
|
2 Copyright (C) 2009-2020 Free Software Foundation, Inc.
|
0
|
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
|
131
|
21 #define IN_TARGET_CODE 1
|
|
22
|
0
|
23 #include "config.h"
|
|
24 #include "system.h"
|
|
25 #include "coretypes.h"
|
|
26 #include "tm.h"
|
|
27
|
111
|
28 /* Chip family type IDs, returned by implver instruction. */
|
|
29 #define IMPLVER_EV4_FAMILY 0 /* LCA/EV4/EV45 */
|
|
30 #define IMPLVER_EV5_FAMILY 1 /* EV5/EV56/PCA56 */
|
|
31 #define IMPLVER_EV6_FAMILY 2 /* EV6 */
|
|
32 #define IMPLVER_EV7_FAMILY 3 /* EV7 */
|
|
33
|
|
34 /* Bit defines for amask instruction. */
|
|
35 #define AMASK_BWX 0x1 /* byte/word extension. */
|
|
36 #define AMASK_FIX 0x2 /* sqrt and f <-> i conversions
|
|
37 extension. */
|
|
38 #define AMASK_CIX 0x4 /* count extension. */
|
|
39 #define AMASK_MVI 0x100 /* multimedia extension. */
|
|
40 #define AMASK_PRECISE 0x200 /* Precise arithmetic traps. */
|
|
41 #define AMASK_LOCKPFTCHOK 0x1000 /* Safe to prefetch lock cache
|
|
42 block. */
|
|
43
|
0
|
44 /* This will be called by the spec parser in gcc.c when it sees
|
|
45 a %:local_cpu_detect(args) construct. Currently it will be called
|
|
46 with either "cpu" or "tune" as argument depending on if -mcpu=native
|
|
47 or -mtune=native is to be substituted.
|
|
48
|
|
49 It returns a string containing new command line parameters to be
|
|
50 put at the place of the above two options, depending on what CPU
|
|
51 this is executed. E.g. "-mcpu=ev6" on an Alpha 21264 for
|
|
52 -mcpu=native. If the routine can't detect a known processor,
|
|
53 the -mcpu or -mtune option is discarded.
|
|
54
|
|
55 ARGC and ARGV are set depending on the actual arguments given
|
|
56 in the spec. */
|
|
57 const char *
|
|
58 host_detect_local_cpu (int argc, const char **argv)
|
|
59 {
|
111
|
60 static const struct cpu_types {
|
|
61 long implver;
|
|
62 long amask;
|
|
63 const char *const cpu;
|
|
64 } cpu_types[] = {
|
|
65 { IMPLVER_EV7_FAMILY, AMASK_BWX|AMASK_MVI|AMASK_FIX|AMASK_CIX, "ev67" },
|
|
66 { IMPLVER_EV6_FAMILY, AMASK_BWX|AMASK_MVI|AMASK_FIX|AMASK_CIX, "ev67" },
|
|
67 { IMPLVER_EV6_FAMILY, AMASK_BWX|AMASK_MVI|AMASK_FIX, "ev6" },
|
|
68 { IMPLVER_EV5_FAMILY, AMASK_BWX|AMASK_MVI, "pca56" },
|
|
69 { IMPLVER_EV5_FAMILY, AMASK_BWX, "ev56" },
|
|
70 { IMPLVER_EV5_FAMILY, 0, "ev5" },
|
|
71 { IMPLVER_EV4_FAMILY, 0, "ev4" },
|
|
72 { 0, 0, NULL }
|
0
|
73 };
|
111
|
74 long implver;
|
|
75 long amask;
|
|
76 const char *cpu;
|
0
|
77 int i;
|
|
78
|
|
79 if (argc < 1)
|
|
80 return NULL;
|
|
81
|
|
82 if (strcmp (argv[0], "cpu") && strcmp (argv[0], "tune"))
|
|
83 return NULL;
|
|
84
|
111
|
85 implver = __builtin_alpha_implver ();
|
|
86 amask = __builtin_alpha_amask (~0L);
|
|
87 cpu = NULL;
|
0
|
88
|
111
|
89 for (i = 0; cpu_types[i].cpu != NULL; i++)
|
|
90 if (implver == cpu_types[i].implver
|
|
91 && (~amask & cpu_types[i].amask) == cpu_types[i].amask)
|
0
|
92 {
|
111
|
93 cpu = cpu_types[i].cpu;
|
0
|
94 break;
|
|
95 }
|
|
96
|
|
97 if (cpu == NULL)
|
|
98 return NULL;
|
|
99
|
|
100 return concat ("-m", argv[0], "=", cpu, NULL);
|
|
101 }
|