annotate gcc/opt-functions.awk @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1 # Copyright (C) 2003-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 # Contributed by Kelley Cook, June 2004.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 # Original code from Neil Booth, May 2003.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 # under the terms of the GNU General Public License as published by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 # Free Software Foundation; either version 3, or (at your option) any
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 # later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 # GNU General Public License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 # along with this program; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 # <http://www.gnu.org/licenses/>.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 # Some common subroutines for use by opt[ch]-gen.awk.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
21 # Define some helpful character classes, for portability.
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
22 BEGIN {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
23 lower = "abcdefghijklmnopqrstuvwxyz"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
24 upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
25 digit = "0123456789"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
26 alnum = lower "" upper "" digit
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
27 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
28
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 # Return nonzero if FLAGS contains a flag matching REGEX.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 function flag_set_p(regex, flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 {
111
kono
parents: 67
diff changeset
32 # Ignore the arguments of flags with arguments.
kono
parents: 67
diff changeset
33 gsub ("\\([^)]+\\)", "", flags);
kono
parents: 67
diff changeset
34 return (" " flags " ") ~ (" " regex " ")
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 # Return STRING if FLAGS contains a flag matching regexp REGEX,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 # otherwise return the empty string.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 function test_flag(regex, flags, string)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 if (flag_set_p(regex, flags))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 return string
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 return ""
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45
111
kono
parents: 67
diff changeset
46 # Return a field initializer, with trailing comma, for a field that is
kono
parents: 67
diff changeset
47 # 1 if FLAGS contains a flag matching REGEX and 0 otherwise.
kono
parents: 67
diff changeset
48 function flag_init(regex, flags)
kono
parents: 67
diff changeset
49 {
kono
parents: 67
diff changeset
50 if (flag_set_p(regex, flags))
kono
parents: 67
diff changeset
51 return "1 /* " regex " */, "
kono
parents: 67
diff changeset
52 else
kono
parents: 67
diff changeset
53 return "0, "
kono
parents: 67
diff changeset
54 }
kono
parents: 67
diff changeset
55
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 # If FLAGS contains a "NAME(...argument...)" flag, return the value
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 # of the argument. Return the empty string otherwise.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 function opt_args(name, flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 flags = " " flags
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 if (flags !~ " " name "\\(")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 return ""
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 sub(".* " name "\\(", "", flags)
111
kono
parents: 67
diff changeset
64 if (flags ~ "^[{]")
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
65 {
111
kono
parents: 67
diff changeset
66 sub ("^[{]", "", flags)
kono
parents: 67
diff changeset
67 sub ("}\\).*", "", flags)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
68 }
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
69 else
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
70 sub("\\).*", "", flags)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 return flags
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 # Return the Nth comma-separated element of S. Return the empty string
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 # if S does not contain N elements.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 function nth_arg(n, s)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 while (n-- > 0) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 if (s !~ ",")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 return ""
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 sub("[^,]*, *", "", s)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 sub(",.*", "", s)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 return s
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 # Return a bitmask of CL_* values for option flags FLAGS.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 function switch_flags (flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 result = "0"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 for (j = 0; j < n_langs; j++) {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 regex = langs[j]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 gsub ( "\\+", "\\+", regex )
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 result = result test_flag(regex, flags, " | " macros[j])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 result = result \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 test_flag("Common", flags, " | CL_COMMON") \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 test_flag("Target", flags, " | CL_TARGET") \
111
kono
parents: 67
diff changeset
100 test_flag("PchIgnore", flags, " | CL_PCH_IGNORE") \
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
101 test_flag("Driver", flags, " | CL_DRIVER") \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 test_flag("Joined", flags, " | CL_JOINED") \
111
kono
parents: 67
diff changeset
103 test_flag("JoinedOrMissing", flags, " | CL_JOINED") \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 test_flag("Separate", flags, " | CL_SEPARATE") \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 test_flag("Undocumented", flags, " | CL_UNDOCUMENTED") \
111
kono
parents: 67
diff changeset
106 test_flag("NoDWARFRecord", flags, " | CL_NO_DWARF_RECORD") \
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 test_flag("Warning", flags, " | CL_WARNING") \
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
108 test_flag("(Optimization|PerFunction)", flags, " | CL_OPTIMIZATION") \
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
109 test_flag("Param", flags, " | CL_PARAMS")
111
kono
parents: 67
diff changeset
110 sub( "^0 \\| ", "", result )
kono
parents: 67
diff changeset
111 return result
kono
parents: 67
diff changeset
112 }
kono
parents: 67
diff changeset
113
kono
parents: 67
diff changeset
114 # Return bit-field initializers for option flags FLAGS.
kono
parents: 67
diff changeset
115 function switch_bit_fields (flags)
kono
parents: 67
diff changeset
116 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
117 uinteger_flag = ""
111
kono
parents: 67
diff changeset
118 vn = var_name(flags);
kono
parents: 67
diff changeset
119 if (host_wide_int[vn] == "yes")
kono
parents: 67
diff changeset
120 hwi = "Host_Wide_Int"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
121 else if (flag_set_p("Host_Wide_Int", flags)) {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
122 hwi = "Host_Wide_Int"
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
123 uinteger_flag = flag_init("UInteger", flags)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
124 }
111
kono
parents: 67
diff changeset
125 else
kono
parents: 67
diff changeset
126 hwi = ""
kono
parents: 67
diff changeset
127 result = ""
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
128 sep_args = opt_args("Args", flags)
111
kono
parents: 67
diff changeset
129 if (sep_args == "")
kono
parents: 67
diff changeset
130 sep_args = 0
kono
parents: 67
diff changeset
131 else
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
132 sep_args--
111
kono
parents: 67
diff changeset
133 result = result sep_args ", "
kono
parents: 67
diff changeset
134
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
135 if (uinteger_flag == "")
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
136 uinteger_flag = flag_init("UInteger", flags)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
137
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
138 hwi_flag = flag_init("Host_Wide_Int", hwi)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
139 byte_size_flag = flag_init("ByteSize", flags)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
140
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
141 if (substr(byte_size_flag, 1, 1) != "0" \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
142 && substr(uinteger_flag, 1, 1) == "0" \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
143 && substr(hwi_flag, 1, 1) == "0")
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
144 print "#error only UInteger amd Host_Wide_Int options can specify a ByteSize suffix"
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
145
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
146 # The following flags need to be in the same order as
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
147 # the corresponding members of struct cl_option defined
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
148 # in gcc/opts.h.
111
kono
parents: 67
diff changeset
149 result = result \
kono
parents: 67
diff changeset
150 flag_init("SeparateAlias", flags) \
kono
parents: 67
diff changeset
151 flag_init("NegativeAlias", flags) \
kono
parents: 67
diff changeset
152 flag_init("NoDriverArg", flags) \
kono
parents: 67
diff changeset
153 flag_init("RejectDriver", flags) \
kono
parents: 67
diff changeset
154 flag_init("RejectNegative", flags) \
kono
parents: 67
diff changeset
155 flag_init("JoinedOrMissing", flags) \
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
156 uinteger_flag \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
157 hwi_flag \
111
kono
parents: 67
diff changeset
158 flag_init("ToLower", flags) \
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
159 flag_init("Report", flags) \
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
160 byte_size_flag
111
kono
parents: 67
diff changeset
161
kono
parents: 67
diff changeset
162 sub(", $", "", result)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163 return result
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 # If FLAGS includes a Var flag, return the name of the variable it specifies.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 # Return the empty string otherwise.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 function var_name(flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 return nth_arg(0, opt_args("Var", flags))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
111
kono
parents: 67
diff changeset
173 # Return the name of the variable if FLAGS has a HOST_WIDE_INT variable.
kono
parents: 67
diff changeset
174 # Return the empty string otherwise.
kono
parents: 67
diff changeset
175 function host_wide_int_var_name(flags)
kono
parents: 67
diff changeset
176 {
kono
parents: 67
diff changeset
177 split (flags, array, "[ \t]+")
kono
parents: 67
diff changeset
178 if (array[1] == "HOST_WIDE_INT")
kono
parents: 67
diff changeset
179 return array[2]
kono
parents: 67
diff changeset
180 else
kono
parents: 67
diff changeset
181 return ""
kono
parents: 67
diff changeset
182 }
kono
parents: 67
diff changeset
183
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 # Return true if the option described by FLAGS has a globally-visible state.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 function global_state_p(flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 return (var_name(flags) != "" \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 || opt_args("Mask", flags) != "" \
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 || opt_args("InverseMask", flags) != "")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 # Return true if the option described by FLAGS must have some state
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
193 # associated with it.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194 function needs_state_p(flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
196 return (flag_set_p("Target", flags) \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
197 && !flag_set_p("Alias.*", flags) \
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
198 && !flag_set_p("Ignore", flags))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
201 # If FLAGS describes an option that needs state without a public
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
202 # variable name, return the name of that field, minus the initial
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
203 # "x_", otherwise return "". NAME is the name of the option.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 function static_var(name, flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 if (global_state_p(flags) || !needs_state_p(flags))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 return ""
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
208 gsub ("[^" alnum "]", "_", name)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 return "VAR_" name
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212 # Return the type of variable that should be associated with the given flags.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 function var_type(flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
215 if (flag_set_p("Defer", flags))
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
216 return "void *"
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
217 else if (flag_set_p("Enum.*", flags)) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
218 en = opt_args("Enum", flags);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
219 return enum_type[en] " "
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
220 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
221 else if (!flag_set_p("Joined.*", flags) && !flag_set_p("Separate", flags))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 return "int "
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
223 else if (flag_set_p("Host_Wide_Int", flags))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
224 return "HOST_WIDE_INT "
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 else if (flag_set_p("UInteger", flags))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 return "int "
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 return "const char *"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231 # Return the type of variable that should be associated with the given flags
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
232 # for use within a structure. Simple variables are changed to signed char
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 # type instead of int to save space.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 function var_type_struct(flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
236 if (flag_set_p("UInteger", flags)) {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
237 if (host_wide_int[var_name(flags)] == "yes")
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
238 return "HOST_WIDE_INT ";
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
239 if (flag_set_p("ByteSize", flags))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
240 return "HOST_WIDE_INT "
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
241 return "int "
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
242 }
111
kono
parents: 67
diff changeset
243 else if (flag_set_p("Enum.*", flags)) {
kono
parents: 67
diff changeset
244 en = opt_args("Enum", flags);
kono
parents: 67
diff changeset
245 return enum_type[en] " "
kono
parents: 67
diff changeset
246 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
247 else if (!flag_set_p("Joined.*", flags) && !flag_set_p("Separate", flags)) {
111
kono
parents: 67
diff changeset
248 if (flag_set_p(".*Mask.*", flags)) {
kono
parents: 67
diff changeset
249 if (host_wide_int[var_name(flags)] == "yes")
kono
parents: 67
diff changeset
250 return "HOST_WIDE_INT "
kono
parents: 67
diff changeset
251 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
252 return "/* - */ int "
111
kono
parents: 67
diff changeset
253 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 else
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
255 return "signed char "
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 return "const char *"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 # Given that an option has flags FLAGS, return an initializer for the
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
262 # "var_enum", "var_type" and "var_value" fields of its cl_options[] entry.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 function var_set(flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
265 if (flag_set_p("Defer", flags))
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
266 return "0, CLVC_DEFER, 0"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 s = nth_arg(1, opt_args("Var", flags))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 if (s != "")
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
269 return "0, CLVC_EQUAL, " s
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 s = opt_args("Mask", flags);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 if (s != "") {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 vn = var_name(flags);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 if (vn)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
274 return "0, CLVC_BIT_SET, OPTION_MASK_" s
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 else
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
276 return "0, CLVC_BIT_SET, MASK_" s
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 s = nth_arg(0, opt_args("InverseMask", flags));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 if (s != "") {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 vn = var_name(flags);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 if (vn)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
282 return "0, CLVC_BIT_CLEAR, OPTION_MASK_" s
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 else
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
284 return "0, CLVC_BIT_CLEAR, MASK_" s
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
285 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
286 if (flag_set_p("Enum.*", flags)) {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
287 en = opt_args("Enum", flags);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
288 return enum_index[en] ", CLVC_ENUM, 0"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 if (var_type(flags) == "const char *")
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
291 return "0, CLVC_STRING, 0"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
292 if (flag_set_p("ByteSize", flags))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
293 return "0, CLVC_SIZE, 0"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
294 return "0, CLVC_BOOLEAN, 0"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 # Given that an option called NAME has flags FLAGS, return an initializer
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 # for the "flag_var" field of its cl_options[] entry.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 function var_ref(name, flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 name = var_name(flags) static_var(name, flags)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 if (name != "")
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
303 return "offsetof (struct gcc_options, x_" name ")"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 if (opt_args("Mask", flags) != "")
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
305 return "offsetof (struct gcc_options, x_target_flags)"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 if (opt_args("InverseMask", flags) != "")
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
307 return "offsetof (struct gcc_options, x_target_flags)"
111
kono
parents: 67
diff changeset
308 return "(unsigned short) -1"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 }
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
310
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
311 # Given the option called NAME return a sanitized version of its name.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
312 function opt_sanitized_name(name)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
313 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
314 gsub ("[^" alnum "]", "_", name)
63
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
315 return name
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
316 }
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
317
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
318 # Given the option called NAME return the appropriate enum for it.
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
319 function opt_enum(name)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
320 {
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
321 return "OPT_" opt_sanitized_name(name)
b7f97abdc517 update gcc from gcc-4.5.0 to gcc-4.6
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
322 }
111
kono
parents: 67
diff changeset
323
kono
parents: 67
diff changeset
324 # Given the language called NAME return a sanitized version of its name.
kono
parents: 67
diff changeset
325 function lang_sanitized_name(name)
kono
parents: 67
diff changeset
326 {
kono
parents: 67
diff changeset
327 gsub( "[^" alnum "_]", "X", name )
kono
parents: 67
diff changeset
328 return name
kono
parents: 67
diff changeset
329 }
kono
parents: 67
diff changeset
330
kono
parents: 67
diff changeset
331 # Search for a valid var_name among all OPTS equal to option NAME.
kono
parents: 67
diff changeset
332 # If not found, return "".
kono
parents: 67
diff changeset
333 function search_var_name(name, opt_numbers, opts, flags, n_opts)
kono
parents: 67
diff changeset
334 {
kono
parents: 67
diff changeset
335 opt_var_name = var_name(flags[opt_numbers[name]]);
kono
parents: 67
diff changeset
336 if (opt_var_name != "") {
kono
parents: 67
diff changeset
337 return opt_var_name;
kono
parents: 67
diff changeset
338 }
kono
parents: 67
diff changeset
339 for (k = 0; k < n_opts; k++) {
kono
parents: 67
diff changeset
340 if (opts[k] == name && var_name(flags[k]) != "") {
kono
parents: 67
diff changeset
341 return var_name(flags[k]);
kono
parents: 67
diff changeset
342 }
kono
parents: 67
diff changeset
343 }
kono
parents: 67
diff changeset
344 return ""
kono
parents: 67
diff changeset
345 }
kono
parents: 67
diff changeset
346
kono
parents: 67
diff changeset
347 function integer_range_info(range_option, init, option)
kono
parents: 67
diff changeset
348 {
kono
parents: 67
diff changeset
349 if (range_option != "") {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
350 ival = init + 0;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
351 start = nth_arg(0, range_option) + 0;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
352 end = nth_arg(1, range_option) + 0;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
353 if (init != "" && init != "-1" && (ival < start || ival > end))
111
kono
parents: 67
diff changeset
354 print "#error initial value " init " of '" option "' must be in range [" start "," end "]"
kono
parents: 67
diff changeset
355 return start ", " end
kono
parents: 67
diff changeset
356 }
kono
parents: 67
diff changeset
357 else
kono
parents: 67
diff changeset
358 return "-1, -1"
kono
parents: 67
diff changeset
359 }
kono
parents: 67
diff changeset
360
kono
parents: 67
diff changeset
361 # Handle LangEnabledBy(ENABLED_BY_LANGS, ENABLEDBY_NAME, ENABLEDBY_POSARG,
kono
parents: 67
diff changeset
362 # ENABLEDBY_NEGARG). This function does not return anything.
kono
parents: 67
diff changeset
363 function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enabledby_negarg)
kono
parents: 67
diff changeset
364 {
kono
parents: 67
diff changeset
365 n_enabledby_arg_langs = split(enabledby_langs, enabledby_arg_langs, " ");
kono
parents: 67
diff changeset
366 if (enabledby_posarg != "" && enabledby_negarg != "") {
kono
parents: 67
diff changeset
367 with_args = "," enabledby_posarg "," enabledby_negarg
kono
parents: 67
diff changeset
368 } else if (enabledby_posarg == "" && enabledby_negarg == "") {
kono
parents: 67
diff changeset
369 with_args = ""
kono
parents: 67
diff changeset
370 } else {
kono
parents: 67
diff changeset
371 print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \
kono
parents: 67
diff changeset
372 enabledby_posarg", " enabledby_negargs \
kono
parents: 67
diff changeset
373 ") with three arguments, it should have either 2 or 4"
kono
parents: 67
diff changeset
374 }
kono
parents: 67
diff changeset
375
kono
parents: 67
diff changeset
376 n_enabledby_array = split(enabledby_name, enabledby_array, " \\|\\| ");
kono
parents: 67
diff changeset
377 for (k = 1; k <= n_enabledby_array; k++) {
kono
parents: 67
diff changeset
378 enabledby_index = opt_numbers[enabledby_array[k]];
kono
parents: 67
diff changeset
379 if (enabledby_index == "") {
kono
parents: 67
diff changeset
380 print "#error " opts[i] " LangEnabledBy("enabledby_langs","enabledby_name", " \
kono
parents: 67
diff changeset
381 enabledby_posarg", " enabledby_negargs"), unknown option '" enabledby_name "'"
kono
parents: 67
diff changeset
382 } else {
kono
parents: 67
diff changeset
383 for (j = 1; j <= n_enabledby_arg_langs; j++) {
kono
parents: 67
diff changeset
384 lang_name = lang_sanitized_name(enabledby_arg_langs[j]);
kono
parents: 67
diff changeset
385 lang_index = lang_numbers[enabledby_arg_langs[j]];
kono
parents: 67
diff changeset
386 if (enables[lang_name,enabledby_array[k]] == "") {
kono
parents: 67
diff changeset
387 enabledby[lang_name,n_enabledby_lang[lang_index]] = enabledby_array[k];
kono
parents: 67
diff changeset
388 n_enabledby_lang[lang_index]++;
kono
parents: 67
diff changeset
389 }
kono
parents: 67
diff changeset
390 enables[lang_name,enabledby_array[k]] \
kono
parents: 67
diff changeset
391 = enables[lang_name,enabledby_array[k]] opts[i] with_args ";";
kono
parents: 67
diff changeset
392 }
kono
parents: 67
diff changeset
393 }
kono
parents: 67
diff changeset
394 }
kono
parents: 67
diff changeset
395 }