1 /* Subroutines for the gcc driver.
2 Copyright (C) 2009-2015 Free Software Foundation, Inc.
3 Contributed by Arthur Loiret <aloiret@debian.org>
5 This file is part of GCC.
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)
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.
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/>. */
23 #include "coretypes.h"
26 /* Chip family type IDs, returned by implver instruction. */
27 #define IMPLVER_EV4_FAMILY 0 /* LCA/EV4/EV45 */
28 #define IMPLVER_EV5_FAMILY 1 /* EV5/EV56/PCA56 */
29 #define IMPLVER_EV6_FAMILY 2 /* EV6 */
30 #define IMPLVER_EV7_FAMILY 3 /* EV7 */
32 /* Bit defines for amask instruction. */
33 #define AMASK_BWX 0x1 /* byte/word extension. */
34 #define AMASK_FIX 0x2 /* sqrt and f <-> i conversions
36 #define AMASK_CIX 0x4 /* count extension. */
37 #define AMASK_MVI 0x100 /* multimedia extension. */
38 #define AMASK_PRECISE 0x200 /* Precise arithmetic traps. */
39 #define AMASK_LOCKPFTCHOK 0x1000 /* Safe to prefetch lock cache
42 /* This will be called by the spec parser in gcc.c when it sees
43 a %:local_cpu_detect(args) construct. Currently it will be called
44 with either "cpu" or "tune" as argument depending on if -mcpu=native
45 or -mtune=native is to be substituted.
47 It returns a string containing new command line parameters to be
48 put at the place of the above two options, depending on what CPU
49 this is executed. E.g. "-mcpu=ev6" on an Alpha 21264 for
50 -mcpu=native. If the routine can't detect a known processor,
51 the -mcpu or -mtune option is discarded.
53 ARGC and ARGV are set depending on the actual arguments given
56 host_detect_local_cpu (int argc
, const char **argv
)
58 static const struct cpu_types
{
61 const char *const cpu
;
63 { IMPLVER_EV7_FAMILY
, AMASK_BWX
|AMASK_MVI
|AMASK_FIX
|AMASK_CIX
, "ev67" },
64 { IMPLVER_EV6_FAMILY
, AMASK_BWX
|AMASK_MVI
|AMASK_FIX
|AMASK_CIX
, "ev67" },
65 { IMPLVER_EV6_FAMILY
, AMASK_BWX
|AMASK_MVI
|AMASK_FIX
, "ev6" },
66 { IMPLVER_EV5_FAMILY
, AMASK_BWX
|AMASK_MVI
, "pca56" },
67 { IMPLVER_EV5_FAMILY
, AMASK_BWX
, "ev56" },
68 { IMPLVER_EV5_FAMILY
, 0, "ev5" },
69 { IMPLVER_EV4_FAMILY
, 0, "ev4" },
80 if (strcmp (argv
[0], "cpu") && strcmp (argv
[0], "tune"))
83 implver
= __builtin_alpha_implver ();
84 amask
= __builtin_alpha_amask (~0L);
87 for (i
= 0; cpu_types
[i
].cpu
!= NULL
; i
++)
88 if (implver
== cpu_types
[i
].implver
89 && (~amask
& cpu_types
[i
].amask
) == cpu_types
[i
].amask
)
91 cpu
= cpu_types
[i
].cpu
;
98 return concat ("-m", argv
[0], "=", cpu
, NULL
);