]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/alpha/driver-alpha.c
Update copyright years.
[thirdparty/gcc.git] / gcc / config / alpha / driver-alpha.c
CommitLineData
d94a427e 1/* Subroutines for the gcc driver.
8d9254fc 2 Copyright (C) 2009-2020 Free Software Foundation, Inc.
d94a427e
AL
3 Contributed by Arthur Loiret <aloiret@debian.org>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
8fcc61f8
RS
21#define IN_TARGET_CODE 1
22
d94a427e
AL
23#include "config.h"
24#include "system.h"
25#include "coretypes.h"
26#include "tm.h"
27
d2da41f5
RO
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
d94a427e
AL
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. */
57const char *
58host_detect_local_cpu (int argc, const char **argv)
59{
d2da41f5
RO
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 }
d94a427e 73 };
d2da41f5
RO
74 long implver;
75 long amask;
76 const char *cpu;
d94a427e
AL
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
d2da41f5
RO
85 implver = __builtin_alpha_implver ();
86 amask = __builtin_alpha_amask (~0L);
87 cpu = NULL;
d94a427e 88
d2da41f5
RO
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)
d94a427e 92 {
d2da41f5 93 cpu = cpu_types[i].cpu;
d94a427e
AL
94 break;
95 }
96
d94a427e
AL
97 if (cpu == NULL)
98 return NULL;
99
100 return concat ("-m", argv[0], "=", cpu, NULL);
101}