[PR c++/84426] ICE after conflicting member decl
[official-gcc.git] / gcc / config / mips / genopt.sh
blobfcd71469eeab78c8e8658df6fa9b8df72ba28d59
1 #!/bin/sh
2 # Generate mips-tables.opt from the list of CPUs in mips-cpus.def.
3 # Copyright (C) 2011-2018 Free Software Foundation, Inc.
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)
10 # any later version.
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 cat <<EOF
22 ; -*- buffer-read-only: t -*-
23 ; Generated automatically by genopt.sh from mips-cpus.def.
25 ; Copyright (C) 2011-2018 Free Software Foundation, Inc.
27 ; This file is part of GCC.
29 ; GCC is free software; you can redistribute it and/or modify it under
30 ; the terms of the GNU General Public License as published by the Free
31 ; Software Foundation; either version 3, or (at your option) any later
32 ; version.
34 ; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
35 ; WARRANTY; without even the implied warranty of MERCHANTABILITY or
36 ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
37 ; for more details.
39 ; You should have received a copy of the GNU General Public License
40 ; along with GCC; see the file COPYING3. If not see
41 ; <http://www.gnu.org/licenses/>.
43 Enum
44 Name(mips_arch_opt_value) Type(int)
45 Known MIPS CPUs (for use with the -march= and -mtune= options):
47 Enum
48 Name(mips_mips_opt_value) Type(int)
49 Known MIPS ISA levels (for use with the -mips option):
51 EnumValue
52 Enum(mips_arch_opt_value) String(from-abi) Value(MIPS_ARCH_OPTION_FROM_ABI)
54 EnumValue
55 Enum(mips_arch_opt_value) String(native) Value(MIPS_ARCH_OPTION_NATIVE) DriverOnly
57 EOF
59 awk -F'[(, ]+' '
60 BEGIN {
61 value = 0
64 # Write an entry for a single string accepted as a -march= argument.
66 function write_one_arch_value(name, value, flags)
68 print "EnumValue"
69 print "Enum(mips_arch_opt_value) String(" name ") Value(" value ")" flags
70 print ""
71 if (name ~ "^mips") {
72 sub("^mips", "", name)
73 print "EnumValue"
74 print "Enum(mips_mips_opt_value) String(" name ") Value(" value ")"
75 print ""
79 # The logic for matching CPU name variants should be the same as in GAS.
81 # Write an entry for a single string accepted as a -march= argument,
82 # plus any variant with a final "000" replaced by "k".
84 function write_arch_value_maybe_k(name, value, flags)
86 write_one_arch_value(name, value, flags)
87 if (name ~ "000$") {
88 sub("000$", "k", name)
89 write_one_arch_value(name, value, "")
93 # Write all the entries for a -march= argument. In addition to
94 # replacement of a final "000" with "k", an argument starting with
95 # "vr", "rm" or "r" followed by a number, or just a plain number,
96 # matches a plain number or "r" followed by a plain number.
98 function write_all_arch_values(name, value)
100 write_arch_value_maybe_k(name, value, " Canonical")
101 cname = name
102 if (cname ~ "^vr") {
103 sub("^vr", "", cname)
104 } else if (cname ~ "^rm") {
105 sub("^rm", "", cname)
106 } else if (cname ~ "^r") {
107 sub("^r", "", cname)
109 if (cname ~ "^[0-9]") {
110 if (cname != name)
111 write_arch_value_maybe_k(cname, value, "")
112 rname = "r" cname
113 if (rname != name)
114 write_arch_value_maybe_k(rname, value, "")
118 /^MIPS_CPU/ {
119 name = $2
120 gsub("\"", "", name)
121 write_all_arch_values(name, value)
122 value++
123 }' $1/mips-cpus.def