1 /* Subroutines for the gcc driver.
2 Copyright (C) 2009-2025 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/>. */
21 #define IN_TARGET_CODE 1
25 #include "coretypes.h"
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 */
34 /* Bit defines for amask instruction. */
35 #define AMASK_BWX 0x1 /* byte/word extension. */
36 #define AMASK_FIX 0x2 /* sqrt and f <-> i conversions
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
44 /* This will be called by the spec parser in gcc.cc 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.
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.
55 ARGC and ARGV are set depending on the actual arguments given
58 host_detect_local_cpu (int argc
, const char **argv
)
60 static const struct cpu_types
{
63 const char *const cpu
;
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" },
82 if (strcmp (argv
[0], "cpu") && strcmp (argv
[0], "tune"))
85 implver
= __builtin_alpha_implver ();
86 amask
= __builtin_alpha_amask (~0L);
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
)
93 cpu
= cpu_types
[i
].cpu
;
100 return concat ("-m", argv
[0], "=", cpu
, NULL
);