Branch data Line data Source code
1 : : /* Copyright (C) 1988-2025 Free Software Foundation, Inc.
2 : :
3 : : This file is part of GCC.
4 : :
5 : : GCC is free software; you can redistribute it and/or modify
6 : : it under the terms of the GNU General Public License as published by
7 : : the Free Software Foundation; either version 3, or (at your option)
8 : : any later version.
9 : :
10 : : GCC is distributed in the hope that it will be useful,
11 : : but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 : : GNU General Public License for more details.
14 : :
15 : : You should have received a copy of the GNU General Public License
16 : : along with GCC; see the file COPYING3. If not see
17 : : <http://www.gnu.org/licenses/>. */
18 : :
19 : : #define IN_TARGET_CODE 1
20 : :
21 : : #include "config.h"
22 : : #include "system.h"
23 : : #include "coretypes.h"
24 : : #include "backend.h"
25 : : #include "rtl.h"
26 : : #include "tree.h"
27 : : #include "memmodel.h"
28 : : #include "gimple.h"
29 : : #include "cfghooks.h"
30 : : #include "cfgloop.h"
31 : : #include "df.h"
32 : : #include "tm_p.h"
33 : : #include "stringpool.h"
34 : : #include "expmed.h"
35 : : #include "optabs.h"
36 : : #include "regs.h"
37 : : #include "emit-rtl.h"
38 : : #include "recog.h"
39 : : #include "cgraph.h"
40 : : #include "diagnostic.h"
41 : : #include "cfgbuild.h"
42 : : #include "alias.h"
43 : : #include "fold-const.h"
44 : : #include "attribs.h"
45 : : #include "calls.h"
46 : : #include "stor-layout.h"
47 : : #include "varasm.h"
48 : : #include "output.h"
49 : : #include "insn-attr.h"
50 : : #include "flags.h"
51 : : #include "except.h"
52 : : #include "explow.h"
53 : : #include "expr.h"
54 : : #include "cfgrtl.h"
55 : : #include "common/common-target.h"
56 : : #include "langhooks.h"
57 : : #include "reload.h"
58 : : #include "gimplify.h"
59 : : #include "dwarf2.h"
60 : : #include "tm-constrs.h"
61 : : #include "cselib.h"
62 : : #include "sched-int.h"
63 : : #include "opts.h"
64 : : #include "tree-pass.h"
65 : : #include "context.h"
66 : : #include "pass_manager.h"
67 : : #include "target-globals.h"
68 : : #include "gimple-iterator.h"
69 : : #include "shrink-wrap.h"
70 : : #include "builtins.h"
71 : : #include "rtl-iter.h"
72 : : #include "tree-iterator.h"
73 : : #include "dbgcnt.h"
74 : : #include "case-cfn-macros.h"
75 : : #include "dojump.h"
76 : : #include "fold-const-call.h"
77 : : #include "tree-vrp.h"
78 : : #include "tree-ssanames.h"
79 : : #include "selftest.h"
80 : : #include "selftest-rtl.h"
81 : : #include "print-rtl.h"
82 : : #include "intl.h"
83 : : #include "ifcvt.h"
84 : : #include "symbol-summary.h"
85 : : #include "sreal.h"
86 : : #include "ipa-cp.h"
87 : : #include "ipa-prop.h"
88 : : #include "ipa-fnsummary.h"
89 : : #include "wide-int-bitmask.h"
90 : : #include "tree-vector-builder.h"
91 : : #include "debug.h"
92 : : #include "dwarf2out.h"
93 : : #include "i386-options.h"
94 : :
95 : : #include "x86-tune-costs.h"
96 : :
97 : : #ifndef SUBTARGET32_DEFAULT_CPU
98 : : #define SUBTARGET32_DEFAULT_CPU "i386"
99 : : #endif
100 : :
101 : : /* Processor feature/optimization bitmasks. */
102 : : #define m_NONE HOST_WIDE_INT_0U
103 : : #define m_ALL (~HOST_WIDE_INT_0U)
104 : : #define m_386 (HOST_WIDE_INT_1U<<PROCESSOR_I386)
105 : : #define m_486 (HOST_WIDE_INT_1U<<PROCESSOR_I486)
106 : : #define m_PENT (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM)
107 : : #define m_LAKEMONT (HOST_WIDE_INT_1U<<PROCESSOR_LAKEMONT)
108 : : #define m_PPRO (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUMPRO)
109 : : #define m_PENT4 (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM4)
110 : : #define m_NOCONA (HOST_WIDE_INT_1U<<PROCESSOR_NOCONA)
111 : : #define m_P4_NOCONA (m_PENT4 | m_NOCONA)
112 : : #define m_CORE2 (HOST_WIDE_INT_1U<<PROCESSOR_CORE2)
113 : : #define m_NEHALEM (HOST_WIDE_INT_1U<<PROCESSOR_NEHALEM)
114 : : #define m_SANDYBRIDGE (HOST_WIDE_INT_1U<<PROCESSOR_SANDYBRIDGE)
115 : : #define m_HASWELL (HOST_WIDE_INT_1U<<PROCESSOR_HASWELL)
116 : : #define m_BONNELL (HOST_WIDE_INT_1U<<PROCESSOR_BONNELL)
117 : : #define m_SILVERMONT (HOST_WIDE_INT_1U<<PROCESSOR_SILVERMONT)
118 : : #define m_SKYLAKE (HOST_WIDE_INT_1U<<PROCESSOR_SKYLAKE)
119 : : #define m_SKYLAKE_AVX512 (HOST_WIDE_INT_1U<<PROCESSOR_SKYLAKE_AVX512)
120 : : #define m_CANNONLAKE (HOST_WIDE_INT_1U<<PROCESSOR_CANNONLAKE)
121 : : #define m_ICELAKE_CLIENT (HOST_WIDE_INT_1U<<PROCESSOR_ICELAKE_CLIENT)
122 : : #define m_ICELAKE_SERVER (HOST_WIDE_INT_1U<<PROCESSOR_ICELAKE_SERVER)
123 : : #define m_CASCADELAKE (HOST_WIDE_INT_1U<<PROCESSOR_CASCADELAKE)
124 : : #define m_TIGERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_TIGERLAKE)
125 : : #define m_COOPERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_COOPERLAKE)
126 : : #define m_SAPPHIRERAPIDS (HOST_WIDE_INT_1U<<PROCESSOR_SAPPHIRERAPIDS)
127 : : #define m_ALDERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_ALDERLAKE)
128 : : #define m_ROCKETLAKE (HOST_WIDE_INT_1U<<PROCESSOR_ROCKETLAKE)
129 : : #define m_GRANITERAPIDS (HOST_WIDE_INT_1U<<PROCESSOR_GRANITERAPIDS)
130 : : #define m_GRANITERAPIDS_D (HOST_WIDE_INT_1U<<PROCESSOR_GRANITERAPIDS_D)
131 : : #define m_ARROWLAKE (HOST_WIDE_INT_1U<<PROCESSOR_ARROWLAKE)
132 : : #define m_ARROWLAKE_S (HOST_WIDE_INT_1U<<PROCESSOR_ARROWLAKE_S)
133 : : #define m_PANTHERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_PANTHERLAKE)
134 : : #define m_DIAMONDRAPIDS (HOST_WIDE_INT_1U<<PROCESSOR_DIAMONDRAPIDS)
135 : : #define m_NOVALAKE (HOST_WIDE_INT_1U<<PROCESSOR_NOVALAKE)
136 : : #define m_CORE_AVX512 (m_SKYLAKE_AVX512 | m_CANNONLAKE \
137 : : | m_ICELAKE_CLIENT | m_ICELAKE_SERVER | m_CASCADELAKE \
138 : : | m_TIGERLAKE | m_COOPERLAKE | m_SAPPHIRERAPIDS \
139 : : | m_ROCKETLAKE | m_GRANITERAPIDS | m_GRANITERAPIDS_D \
140 : : | m_DIAMONDRAPIDS)
141 : : #define m_CORE_AVX2 (m_HASWELL | m_SKYLAKE | m_CORE_AVX512)
142 : : #define m_CORE_ALL (m_CORE2 | m_NEHALEM | m_SANDYBRIDGE | m_CORE_AVX2)
143 : : #define m_CORE_HYBRID (m_ALDERLAKE | m_ARROWLAKE | m_ARROWLAKE_S \
144 : : | m_PANTHERLAKE | m_NOVALAKE)
145 : : #define m_GOLDMONT (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT)
146 : : #define m_GOLDMONT_PLUS (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT_PLUS)
147 : : #define m_TREMONT (HOST_WIDE_INT_1U<<PROCESSOR_TREMONT)
148 : : #define m_SIERRAFOREST (HOST_WIDE_INT_1U<<PROCESSOR_SIERRAFOREST)
149 : : #define m_GRANDRIDGE (HOST_WIDE_INT_1U<<PROCESSOR_GRANDRIDGE)
150 : : #define m_CLEARWATERFOREST (HOST_WIDE_INT_1U<<PROCESSOR_CLEARWATERFOREST)
151 : : #define m_CORE_ATOM (m_SIERRAFOREST | m_GRANDRIDGE | m_CLEARWATERFOREST)
152 : : #define m_INTEL (HOST_WIDE_INT_1U<<PROCESSOR_INTEL)
153 : : /* Gather Data Sampling / CVE-2022-40982 / INTEL-SA-00828.
154 : : Software mitigation. */
155 : : #define m_GDS (m_SKYLAKE | m_SKYLAKE_AVX512 | m_CANNONLAKE \
156 : : | m_ICELAKE_CLIENT | m_ICELAKE_SERVER | m_CASCADELAKE \
157 : : | m_TIGERLAKE | m_COOPERLAKE | m_ROCKETLAKE)
158 : :
159 : : #define m_LUJIAZUI (HOST_WIDE_INT_1U<<PROCESSOR_LUJIAZUI)
160 : : #define m_YONGFENG (HOST_WIDE_INT_1U<<PROCESSOR_YONGFENG)
161 : : #define m_SHIJIDADAO (HOST_WIDE_INT_1U<<PROCESSOR_SHIJIDADAO)
162 : : #define m_ZHAOXIN (m_LUJIAZUI | m_YONGFENG | m_SHIJIDADAO)
163 : :
164 : : #define m_GEODE (HOST_WIDE_INT_1U<<PROCESSOR_GEODE)
165 : : #define m_K6 (HOST_WIDE_INT_1U<<PROCESSOR_K6)
166 : : #define m_K6_GEODE (m_K6 | m_GEODE)
167 : : #define m_K8 (HOST_WIDE_INT_1U<<PROCESSOR_K8)
168 : : #define m_ATHLON (HOST_WIDE_INT_1U<<PROCESSOR_ATHLON)
169 : : #define m_ATHLON_K8 (m_K8 | m_ATHLON)
170 : : #define m_AMDFAM10 (HOST_WIDE_INT_1U<<PROCESSOR_AMDFAM10)
171 : : #define m_BDVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER1)
172 : : #define m_BDVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER2)
173 : : #define m_BDVER3 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER3)
174 : : #define m_BDVER4 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER4)
175 : : #define m_ZNVER1 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER1)
176 : : #define m_ZNVER2 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER2)
177 : : #define m_ZNVER3 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER3)
178 : : #define m_ZNVER4 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER4)
179 : : #define m_ZNVER5 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER5)
180 : : #define m_BTVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER1)
181 : : #define m_BTVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER2)
182 : : #define m_BDVER (m_BDVER1 | m_BDVER2 | m_BDVER3 | m_BDVER4)
183 : : #define m_BTVER (m_BTVER1 | m_BTVER2)
184 : : #define m_ZNVER (m_ZNVER1 | m_ZNVER2 | m_ZNVER3 | m_ZNVER4 | m_ZNVER5)
185 : : #define m_AMD_MULTIPLE (m_ATHLON_K8 | m_AMDFAM10 | m_BDVER | m_BTVER \
186 : : | m_ZNVER)
187 : :
188 : : #define m_GENERIC (HOST_WIDE_INT_1U<<PROCESSOR_GENERIC)
189 : :
190 : : const char* ix86_tune_feature_names[X86_TUNE_LAST] = {
191 : : #undef DEF_TUNE
192 : : #define DEF_TUNE(tune, name, selector) name,
193 : : #include "x86-tune.def"
194 : : #undef DEF_TUNE
195 : : };
196 : :
197 : : /* Feature tests against the various tunings. */
198 : : unsigned char ix86_tune_features[X86_TUNE_LAST];
199 : :
200 : : /* Feature tests against the various tunings used to create ix86_tune_features
201 : : based on the processor mask. */
202 : : static unsigned HOST_WIDE_INT initial_ix86_tune_features[X86_TUNE_LAST] = {
203 : : #undef DEF_TUNE
204 : : #define DEF_TUNE(tune, name, selector) selector,
205 : : #include "x86-tune.def"
206 : : #undef DEF_TUNE
207 : : };
208 : :
209 : : /* Feature tests against the various architecture variations. */
210 : : unsigned char ix86_arch_features[X86_ARCH_LAST];
211 : :
212 : : struct ix86_target_opts
213 : : {
214 : : const char *option; /* option string */
215 : : HOST_WIDE_INT mask; /* isa mask options */
216 : : };
217 : :
218 : : /* This table is ordered so that options like -msse4.2 that imply other
219 : : ISAs come first. Target string will be displayed in the same order. */
220 : : static struct ix86_target_opts isa2_opts[] =
221 : : {
222 : : { "-mcx16", OPTION_MASK_ISA2_CX16 },
223 : : { "-mvaes", OPTION_MASK_ISA2_VAES },
224 : : { "-mrdpid", OPTION_MASK_ISA2_RDPID },
225 : : { "-mpconfig", OPTION_MASK_ISA2_PCONFIG },
226 : : { "-mwbnoinvd", OPTION_MASK_ISA2_WBNOINVD },
227 : : { "-mavx512vp2intersect", OPTION_MASK_ISA2_AVX512VP2INTERSECT },
228 : : { "-msgx", OPTION_MASK_ISA2_SGX },
229 : : { "-mhle", OPTION_MASK_ISA2_HLE },
230 : : { "-mmovbe", OPTION_MASK_ISA2_MOVBE },
231 : : { "-mclzero", OPTION_MASK_ISA2_CLZERO },
232 : : { "-mmwaitx", OPTION_MASK_ISA2_MWAITX },
233 : : { "-mmwait", OPTION_MASK_ISA2_MWAIT },
234 : : { "-mmovdir64b", OPTION_MASK_ISA2_MOVDIR64B },
235 : : { "-mwaitpkg", OPTION_MASK_ISA2_WAITPKG },
236 : : { "-mcldemote", OPTION_MASK_ISA2_CLDEMOTE },
237 : : { "-mptwrite", OPTION_MASK_ISA2_PTWRITE },
238 : : { "-mavx512bf16", OPTION_MASK_ISA2_AVX512BF16 },
239 : : { "-menqcmd", OPTION_MASK_ISA2_ENQCMD },
240 : : { "-mserialize", OPTION_MASK_ISA2_SERIALIZE },
241 : : { "-mtsxldtrk", OPTION_MASK_ISA2_TSXLDTRK },
242 : : { "-mamx-tile", OPTION_MASK_ISA2_AMX_TILE },
243 : : { "-mamx-int8", OPTION_MASK_ISA2_AMX_INT8 },
244 : : { "-mamx-bf16", OPTION_MASK_ISA2_AMX_BF16 },
245 : : { "-muintr", OPTION_MASK_ISA2_UINTR },
246 : : { "-mhreset", OPTION_MASK_ISA2_HRESET },
247 : : { "-mkl", OPTION_MASK_ISA2_KL },
248 : : { "-mwidekl", OPTION_MASK_ISA2_WIDEKL },
249 : : { "-mavxvnni", OPTION_MASK_ISA2_AVXVNNI },
250 : : { "-mavx512fp16", OPTION_MASK_ISA2_AVX512FP16 },
251 : : { "-mavxifma", OPTION_MASK_ISA2_AVXIFMA },
252 : : { "-mavxvnniint8", OPTION_MASK_ISA2_AVXVNNIINT8 },
253 : : { "-mavxneconvert", OPTION_MASK_ISA2_AVXNECONVERT },
254 : : { "-mcmpccxadd", OPTION_MASK_ISA2_CMPCCXADD },
255 : : { "-mamx-fp16", OPTION_MASK_ISA2_AMX_FP16 },
256 : : { "-mprefetchi", OPTION_MASK_ISA2_PREFETCHI },
257 : : { "-mraoint", OPTION_MASK_ISA2_RAOINT },
258 : : { "-mamx-complex", OPTION_MASK_ISA2_AMX_COMPLEX },
259 : : { "-mavxvnniint16", OPTION_MASK_ISA2_AVXVNNIINT16 },
260 : : { "-msm3", OPTION_MASK_ISA2_SM3 },
261 : : { "-msha512", OPTION_MASK_ISA2_SHA512 },
262 : : { "-msm4", OPTION_MASK_ISA2_SM4 },
263 : : { "-musermsr", OPTION_MASK_ISA2_USER_MSR },
264 : : { "-mavx10.1", OPTION_MASK_ISA2_AVX10_1 },
265 : : { "-mavx10.2", OPTION_MASK_ISA2_AVX10_2 },
266 : : { "-mamx-avx512", OPTION_MASK_ISA2_AMX_AVX512 },
267 : : { "-mamx-tf32", OPTION_MASK_ISA2_AMX_TF32 },
268 : : { "-mamx-fp8", OPTION_MASK_ISA2_AMX_FP8 },
269 : : { "-mmovrs", OPTION_MASK_ISA2_MOVRS },
270 : : { "-mamx-movrs", OPTION_MASK_ISA2_AMX_MOVRS }
271 : : };
272 : : static struct ix86_target_opts isa_opts[] =
273 : : {
274 : : { "-mavx512vpopcntdq", OPTION_MASK_ISA_AVX512VPOPCNTDQ },
275 : : { "-mavx512bitalg", OPTION_MASK_ISA_AVX512BITALG },
276 : : { "-mvpclmulqdq", OPTION_MASK_ISA_VPCLMULQDQ },
277 : : { "-mgfni", OPTION_MASK_ISA_GFNI },
278 : : { "-mavx512vnni", OPTION_MASK_ISA_AVX512VNNI },
279 : : { "-mavx512vbmi2", OPTION_MASK_ISA_AVX512VBMI2 },
280 : : { "-mavx512vbmi", OPTION_MASK_ISA_AVX512VBMI },
281 : : { "-mavx512ifma", OPTION_MASK_ISA_AVX512IFMA },
282 : : { "-mavx512vl", OPTION_MASK_ISA_AVX512VL },
283 : : { "-mavx512bw", OPTION_MASK_ISA_AVX512BW },
284 : : { "-mavx512dq", OPTION_MASK_ISA_AVX512DQ },
285 : : { "-mavx512cd", OPTION_MASK_ISA_AVX512CD },
286 : : { "-mavx512f", OPTION_MASK_ISA_AVX512F },
287 : : { "-mavx2", OPTION_MASK_ISA_AVX2 },
288 : : { "-mfma", OPTION_MASK_ISA_FMA },
289 : : { "-mxop", OPTION_MASK_ISA_XOP },
290 : : { "-mfma4", OPTION_MASK_ISA_FMA4 },
291 : : { "-mf16c", OPTION_MASK_ISA_F16C },
292 : : { "-mavx", OPTION_MASK_ISA_AVX },
293 : : /*{ "-msse4" OPTION_MASK_ISA_SSE4 }, */
294 : : { "-msse4.2", OPTION_MASK_ISA_SSE4_2 },
295 : : { "-msse4.1", OPTION_MASK_ISA_SSE4_1 },
296 : : { "-msse4a", OPTION_MASK_ISA_SSE4A },
297 : : { "-mssse3", OPTION_MASK_ISA_SSSE3 },
298 : : { "-msse3", OPTION_MASK_ISA_SSE3 },
299 : : { "-maes", OPTION_MASK_ISA_AES },
300 : : { "-msha", OPTION_MASK_ISA_SHA },
301 : : { "-mpclmul", OPTION_MASK_ISA_PCLMUL },
302 : : { "-msse2", OPTION_MASK_ISA_SSE2 },
303 : : { "-msse", OPTION_MASK_ISA_SSE },
304 : : { "-m3dnowa", OPTION_MASK_ISA_3DNOW_A },
305 : : { "-m3dnow", OPTION_MASK_ISA_3DNOW },
306 : : { "-mmmx", OPTION_MASK_ISA_MMX },
307 : : { "-mrtm", OPTION_MASK_ISA_RTM },
308 : : { "-mprfchw", OPTION_MASK_ISA_PRFCHW },
309 : : { "-mrdseed", OPTION_MASK_ISA_RDSEED },
310 : : { "-madx", OPTION_MASK_ISA_ADX },
311 : : { "-mclflushopt", OPTION_MASK_ISA_CLFLUSHOPT },
312 : : { "-mxsaves", OPTION_MASK_ISA_XSAVES },
313 : : { "-mxsavec", OPTION_MASK_ISA_XSAVEC },
314 : : { "-mxsaveopt", OPTION_MASK_ISA_XSAVEOPT },
315 : : { "-mxsave", OPTION_MASK_ISA_XSAVE },
316 : : { "-mabm", OPTION_MASK_ISA_ABM },
317 : : { "-mbmi", OPTION_MASK_ISA_BMI },
318 : : { "-mbmi2", OPTION_MASK_ISA_BMI2 },
319 : : { "-mlzcnt", OPTION_MASK_ISA_LZCNT },
320 : : { "-mtbm", OPTION_MASK_ISA_TBM },
321 : : { "-mpopcnt", OPTION_MASK_ISA_POPCNT },
322 : : { "-msahf", OPTION_MASK_ISA_SAHF },
323 : : { "-mcrc32", OPTION_MASK_ISA_CRC32 },
324 : : { "-mfsgsbase", OPTION_MASK_ISA_FSGSBASE },
325 : : { "-mrdrnd", OPTION_MASK_ISA_RDRND },
326 : : { "-mpku", OPTION_MASK_ISA_PKU },
327 : : { "-mlwp", OPTION_MASK_ISA_LWP },
328 : : { "-mfxsr", OPTION_MASK_ISA_FXSR },
329 : : { "-mclwb", OPTION_MASK_ISA_CLWB },
330 : : { "-mshstk", OPTION_MASK_ISA_SHSTK },
331 : : { "-mmovdiri", OPTION_MASK_ISA_MOVDIRI }
332 : : };
333 : :
334 : : /* Return 1 if TRAIT NAME is present in the OpenMP context's
335 : : device trait set, return 0 if not present in any OpenMP context in the
336 : : whole translation unit, or -1 if not present in the current OpenMP context
337 : : but might be present in another OpenMP context in the same TU. */
338 : :
339 : : int
340 : 1771 : ix86_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
341 : : const char *name)
342 : : {
343 : 1771 : switch (trait)
344 : : {
345 : 359 : case omp_device_kind:
346 : 359 : return strcmp (name, "cpu") == 0;
347 : 596 : case omp_device_arch:
348 : 596 : if (strcmp (name, "x86") == 0)
349 : : return 1;
350 : 596 : if (TARGET_64BIT)
351 : : {
352 : 596 : if (TARGET_X32)
353 : 0 : return strcmp (name, "x32") == 0;
354 : : else
355 : 596 : return strcmp (name, "x86_64") == 0;
356 : : }
357 : 0 : if (strcmp (name, "ia32") == 0 || strcmp (name, "i386") == 0)
358 : : return 1;
359 : 0 : if (strcmp (name, "i486") == 0)
360 : 0 : return ix86_arch != PROCESSOR_I386 ? 1 : -1;
361 : 0 : if (strcmp (name, "i586") == 0)
362 : 0 : return (ix86_arch != PROCESSOR_I386
363 : 0 : && ix86_arch != PROCESSOR_I486) ? 1 : -1;
364 : 0 : if (strcmp (name, "i686") == 0)
365 : 0 : return (ix86_arch != PROCESSOR_I386
366 : 0 : && ix86_arch != PROCESSOR_I486
367 : 0 : && ix86_arch != PROCESSOR_LAKEMONT
368 : 0 : && ix86_arch != PROCESSOR_PENTIUM) ? 1 : -1;
369 : : return 0;
370 : : case omp_device_isa:
371 : 914 : for (int i = 0; i < 2; i++)
372 : : {
373 : 865 : struct ix86_target_opts *opts = i ? isa2_opts : isa_opts;
374 : 865 : size_t nopts = i ? ARRAY_SIZE (isa2_opts) : ARRAY_SIZE (isa_opts);
375 : 865 : HOST_WIDE_INT mask = i ? ix86_isa_flags2 : ix86_isa_flags;
376 : 16123 : for (size_t n = 0; n < nopts; n++)
377 : : {
378 : : /* Handle sse4 as an alias to sse4.2. */
379 : 16025 : if (opts[n].mask == OPTION_MASK_ISA_SSE4_2)
380 : : {
381 : 227 : if (strcmp (name, "sse4") == 0)
382 : 38 : return (mask & opts[n].mask) != 0 ? 1 : -1;
383 : : }
384 : 15996 : if (strcmp (name, opts[n].option + 2) == 0)
385 : 1014 : return (mask & opts[n].mask) != 0 ? 1 : -1;
386 : : }
387 : : }
388 : : return 0;
389 : 0 : default:
390 : 0 : gcc_unreachable ();
391 : : }
392 : : }
393 : :
394 : : /* Return a string that documents the current -m options. The caller is
395 : : responsible for freeing the string. */
396 : :
397 : : char *
398 : 23 : ix86_target_string (HOST_WIDE_INT isa, HOST_WIDE_INT isa2,
399 : : int flags, int flags2,
400 : : const char *arch, const char *tune,
401 : : enum fpmath_unit fpmath,
402 : : enum prefer_vector_width pvw,
403 : : enum prefer_vector_width move_max,
404 : : bool add_nl_p, bool add_abi_p)
405 : : {
406 : : /* Flag options. */
407 : 23 : static struct ix86_target_opts flag_opts[] =
408 : : {
409 : : { "-m128bit-long-double", MASK_128BIT_LONG_DOUBLE },
410 : : { "-mlong-double-128", MASK_LONG_DOUBLE_128 },
411 : : { "-mlong-double-64", MASK_LONG_DOUBLE_64 },
412 : : { "-m80387", MASK_80387 },
413 : : { "-maccumulate-outgoing-args", MASK_ACCUMULATE_OUTGOING_ARGS },
414 : : { "-malign-double", MASK_ALIGN_DOUBLE },
415 : : { "-mcld", MASK_CLD },
416 : : { "-mfp-ret-in-387", MASK_FLOAT_RETURNS },
417 : : { "-mieee-fp", MASK_IEEE_FP },
418 : : { "-minline-all-stringops", MASK_INLINE_ALL_STRINGOPS },
419 : : { "-minline-stringops-dynamically", MASK_INLINE_STRINGOPS_DYNAMICALLY },
420 : : { "-mms-bitfields", MASK_MS_BITFIELD_LAYOUT },
421 : : { "-mno-align-stringops", MASK_NO_ALIGN_STRINGOPS },
422 : : { "-mno-fancy-math-387", MASK_NO_FANCY_MATH_387 },
423 : : { "-mno-push-args", MASK_NO_PUSH_ARGS },
424 : : { "-mno-red-zone", MASK_NO_RED_ZONE },
425 : : { "-momit-leaf-frame-pointer", MASK_OMIT_LEAF_FRAME_POINTER },
426 : : { "-mrecip", MASK_RECIP },
427 : : { "-mrtd", MASK_RTD },
428 : : { "-msseregparm", MASK_SSEREGPARM },
429 : : { "-mstack-arg-probe", MASK_STACK_PROBE },
430 : : { "-mtls-direct-seg-refs", MASK_TLS_DIRECT_SEG_REFS },
431 : : { "-mvect8-ret-in-mem", MASK_VECT8_RETURNS },
432 : : { "-m8bit-idiv", MASK_USE_8BIT_IDIV },
433 : : { "-mvzeroupper", MASK_VZEROUPPER },
434 : : { "-mstv", MASK_STV },
435 : : { "-mavx256-split-unaligned-load", MASK_AVX256_SPLIT_UNALIGNED_LOAD },
436 : : { "-mavx256-split-unaligned-store", MASK_AVX256_SPLIT_UNALIGNED_STORE },
437 : : { "-mcall-ms2sysv-xlogues", MASK_CALL_MS2SYSV_XLOGUES },
438 : : { "-mrelax-cmpxchg-loop", MASK_RELAX_CMPXCHG_LOOP }
439 : : };
440 : :
441 : : /* Additional flag options. */
442 : 23 : static struct ix86_target_opts flag2_opts[] =
443 : : {
444 : : { "-mgeneral-regs-only", OPTION_MASK_GENERAL_REGS_ONLY }
445 : : };
446 : :
447 : 23 : const char *opts[ARRAY_SIZE (isa_opts) + ARRAY_SIZE (isa2_opts)
448 : : + ARRAY_SIZE (flag_opts) + ARRAY_SIZE (flag2_opts) + 6][2];
449 : :
450 : 23 : char isa_other[40];
451 : 23 : char isa2_other[40];
452 : 23 : char flags_other[40];
453 : 23 : char flags2_other[40];
454 : 23 : unsigned num = 0;
455 : 23 : unsigned i, j;
456 : 23 : char *ret;
457 : 23 : char *ptr;
458 : 23 : size_t len;
459 : 23 : size_t line_len;
460 : 23 : size_t sep_len;
461 : 23 : const char *abi;
462 : :
463 : 23 : memset (opts, '\0', sizeof (opts));
464 : :
465 : : /* Add -march= option. */
466 : 23 : if (arch)
467 : : {
468 : 0 : opts[num][0] = "-march=";
469 : 0 : opts[num++][1] = arch;
470 : : }
471 : :
472 : : /* Add -mtune= option. */
473 : 23 : if (tune)
474 : : {
475 : 0 : opts[num][0] = "-mtune=";
476 : 0 : opts[num++][1] = tune;
477 : : }
478 : :
479 : : /* Add -m32/-m64/-mx32. */
480 : 23 : if (add_abi_p)
481 : : {
482 : 2 : if ((isa & OPTION_MASK_ISA_64BIT) != 0)
483 : : {
484 : 2 : if ((isa & OPTION_MASK_ABI_64) != 0)
485 : : abi = "-m64";
486 : : else
487 : 0 : abi = "-mx32";
488 : : }
489 : : else
490 : : abi = "-m32";
491 : 2 : opts[num++][0] = abi;
492 : : }
493 : 23 : isa &= ~(OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
494 : :
495 : : /* Pick out the options in isa2 options. */
496 : 1150 : for (i = 0; i < ARRAY_SIZE (isa2_opts); i++)
497 : : {
498 : 1127 : if ((isa2 & isa2_opts[i].mask) != 0)
499 : : {
500 : 5 : opts[num++][0] = isa2_opts[i].option;
501 : 5 : isa2 &= ~ isa2_opts[i].mask;
502 : : }
503 : : }
504 : :
505 : 23 : if (isa2 && add_nl_p)
506 : : {
507 : 0 : opts[num++][0] = isa2_other;
508 : 0 : sprintf (isa2_other, "(other isa2: %#" HOST_WIDE_INT_PRINT "x)", isa2);
509 : : }
510 : :
511 : : /* Pick out the options in isa options. */
512 : 1334 : for (i = 0; i < ARRAY_SIZE (isa_opts); i++)
513 : : {
514 : 1311 : if ((isa & isa_opts[i].mask) != 0)
515 : : {
516 : 36 : opts[num++][0] = isa_opts[i].option;
517 : 36 : isa &= ~ isa_opts[i].mask;
518 : : }
519 : : }
520 : :
521 : 23 : if (isa && add_nl_p)
522 : : {
523 : 0 : opts[num++][0] = isa_other;
524 : 0 : sprintf (isa_other, "(other isa: %#" HOST_WIDE_INT_PRINT "x)", isa);
525 : : }
526 : :
527 : : /* Add flag options. */
528 : 713 : for (i = 0; i < ARRAY_SIZE (flag_opts); i++)
529 : : {
530 : 690 : if ((flags & flag_opts[i].mask) != 0)
531 : : {
532 : 0 : opts[num++][0] = flag_opts[i].option;
533 : 0 : flags &= ~ flag_opts[i].mask;
534 : : }
535 : : }
536 : :
537 : 23 : if (flags && add_nl_p)
538 : : {
539 : 0 : opts[num++][0] = flags_other;
540 : 0 : sprintf (flags_other, "(other flags: %#x)", flags);
541 : : }
542 : :
543 : : /* Add additional flag options. */
544 : 46 : for (i = 0; i < ARRAY_SIZE (flag2_opts); i++)
545 : : {
546 : 23 : if ((flags2 & flag2_opts[i].mask) != 0)
547 : : {
548 : 0 : opts[num++][0] = flag2_opts[i].option;
549 : 0 : flags2 &= ~ flag2_opts[i].mask;
550 : : }
551 : : }
552 : :
553 : 23 : if (flags2 && add_nl_p)
554 : : {
555 : 0 : opts[num++][0] = flags2_other;
556 : 0 : sprintf (flags2_other, "(other flags2: %#x)", flags2);
557 : : }
558 : :
559 : : /* Add -mfpmath= option. */
560 : 23 : if (fpmath)
561 : : {
562 : 0 : opts[num][0] = "-mfpmath=";
563 : 0 : switch ((int) fpmath)
564 : : {
565 : 0 : case FPMATH_387:
566 : 0 : opts[num++][1] = "387";
567 : 0 : break;
568 : :
569 : 0 : case FPMATH_SSE:
570 : 0 : opts[num++][1] = "sse";
571 : 0 : break;
572 : :
573 : 0 : case FPMATH_387 | FPMATH_SSE:
574 : 0 : opts[num++][1] = "sse+387";
575 : 0 : break;
576 : :
577 : 0 : default:
578 : 0 : gcc_unreachable ();
579 : : }
580 : : }
581 : :
582 : 23 : auto add_vector_width = [&opts, &num] (prefer_vector_width pvw,
583 : : const char *cmd)
584 : : {
585 : 0 : opts[num][0] = cmd;
586 : 0 : switch ((int) pvw)
587 : : {
588 : 0 : case PVW_AVX128:
589 : 0 : opts[num++][1] = "128";
590 : 0 : break;
591 : :
592 : 0 : case PVW_AVX256:
593 : 0 : opts[num++][1] = "256";
594 : 0 : break;
595 : :
596 : 0 : case PVW_AVX512:
597 : 0 : opts[num++][1] = "512";
598 : 0 : break;
599 : :
600 : 0 : default:
601 : 0 : gcc_unreachable ();
602 : : }
603 : 23 : };
604 : :
605 : : /* Add -mprefer-vector-width= option. */
606 : 23 : if (pvw)
607 : 0 : add_vector_width (pvw, "-mprefer-vector-width=");
608 : :
609 : : /* Add -mmove-max= option. */
610 : 23 : if (move_max)
611 : 0 : add_vector_width (move_max, "-mmove-max=");
612 : :
613 : : /* Any options? */
614 : 23 : if (num == 0)
615 : : return NULL;
616 : :
617 : 23 : gcc_assert (num < ARRAY_SIZE (opts));
618 : :
619 : : /* Size the string. */
620 : 23 : len = 0;
621 : 23 : sep_len = (add_nl_p) ? 3 : 1;
622 : 66 : for (i = 0; i < num; i++)
623 : : {
624 : 43 : len += sep_len;
625 : 129 : for (j = 0; j < 2; j++)
626 : 86 : if (opts[i][j])
627 : 43 : len += strlen (opts[i][j]);
628 : : }
629 : :
630 : : /* Build the string. */
631 : 23 : ret = ptr = (char *) xmalloc (len);
632 : 23 : line_len = 0;
633 : :
634 : 66 : for (i = 0; i < num; i++)
635 : : {
636 : : size_t len2[2];
637 : :
638 : 129 : for (j = 0; j < 2; j++)
639 : 86 : len2[j] = (opts[i][j]) ? strlen (opts[i][j]) : 0;
640 : :
641 : 43 : if (i != 0)
642 : : {
643 : 20 : *ptr++ = ' ';
644 : 20 : line_len++;
645 : :
646 : 20 : if (add_nl_p && line_len + len2[0] + len2[1] > 70)
647 : : {
648 : 0 : *ptr++ = '\\';
649 : 0 : *ptr++ = '\n';
650 : 0 : line_len = 0;
651 : : }
652 : : }
653 : :
654 : 129 : for (j = 0; j < 2; j++)
655 : 86 : if (opts[i][j])
656 : : {
657 : 43 : memcpy (ptr, opts[i][j], len2[j]);
658 : 43 : ptr += len2[j];
659 : 43 : line_len += len2[j];
660 : : }
661 : : }
662 : :
663 : 23 : *ptr = '\0';
664 : 23 : gcc_assert (ret + len >= ptr);
665 : :
666 : : return ret;
667 : : }
668 : :
669 : : /* Function that is callable from the debugger to print the current
670 : : options. */
671 : : void ATTRIBUTE_UNUSED
672 : 0 : ix86_debug_options (void)
673 : : {
674 : 0 : char *opts = ix86_target_string (ix86_isa_flags, ix86_isa_flags2,
675 : : target_flags, ix86_target_flags,
676 : : ix86_arch_string, ix86_tune_string,
677 : : ix86_fpmath, prefer_vector_width_type,
678 : : ix86_move_max, true, true);
679 : :
680 : 0 : if (opts)
681 : : {
682 : 0 : fprintf (stderr, "%s\n\n", opts);
683 : 0 : free (opts);
684 : : }
685 : : else
686 : 0 : fputs ("<no options>\n\n", stderr);
687 : :
688 : 0 : return;
689 : : }
690 : :
691 : : /* Save the current options */
692 : :
693 : : void
694 : 74948190 : ix86_function_specific_save (struct cl_target_option *ptr,
695 : : struct gcc_options *opts,
696 : : struct gcc_options */* opts_set */)
697 : : {
698 : 74948190 : ptr->arch = ix86_arch;
699 : 74948190 : ptr->schedule = ix86_schedule;
700 : 74948190 : ptr->prefetch_sse = ix86_prefetch_sse;
701 : 74948190 : ptr->tune = ix86_tune;
702 : 74948190 : ptr->branch_cost = ix86_branch_cost;
703 : 74948190 : ptr->tune_defaulted = ix86_tune_defaulted;
704 : 74948190 : ptr->arch_specified = ix86_arch_specified;
705 : 74948190 : ptr->x_ix86_apx_features = opts->x_ix86_apx_features;
706 : 74948190 : ptr->x_ix86_isa_flags_explicit = opts->x_ix86_isa_flags_explicit;
707 : 74948190 : ptr->x_ix86_isa_flags2_explicit = opts->x_ix86_isa_flags2_explicit;
708 : 74948190 : ptr->x_recip_mask_explicit = opts->x_recip_mask_explicit;
709 : 74948190 : ptr->x_ix86_arch_string = opts->x_ix86_arch_string;
710 : 74948190 : ptr->x_ix86_tune_string = opts->x_ix86_tune_string;
711 : 74948190 : ptr->x_ix86_asm_dialect = opts->x_ix86_asm_dialect;
712 : 74948190 : ptr->x_ix86_branch_cost = opts->x_ix86_branch_cost;
713 : 74948190 : ptr->x_ix86_dump_tunes = opts->x_ix86_dump_tunes;
714 : 74948190 : ptr->x_ix86_force_align_arg_pointer = opts->x_ix86_force_align_arg_pointer;
715 : 74948190 : ptr->x_ix86_force_drap = opts->x_ix86_force_drap;
716 : 74948190 : ptr->x_ix86_recip_name = opts->x_ix86_recip_name;
717 : 74948190 : ptr->x_ix86_section_threshold = opts->x_ix86_section_threshold;
718 : 74948190 : ptr->x_ix86_sse2avx = opts->x_ix86_sse2avx;
719 : 74948190 : ptr->x_ix86_stack_protector_guard = opts->x_ix86_stack_protector_guard;
720 : 74948190 : ptr->x_ix86_stringop_alg = opts->x_ix86_stringop_alg;
721 : 74948190 : ptr->x_ix86_tls_dialect = opts->x_ix86_tls_dialect;
722 : 74948190 : ptr->x_ix86_tune_ctrl_string = opts->x_ix86_tune_ctrl_string;
723 : 74948190 : ptr->x_ix86_tune_memcpy_strategy = opts->x_ix86_tune_memcpy_strategy;
724 : 74948190 : ptr->x_ix86_tune_memset_strategy = opts->x_ix86_tune_memset_strategy;
725 : 74948190 : ptr->x_ix86_tune_no_default = opts->x_ix86_tune_no_default;
726 : :
727 : : /* The fields are char but the variables are not; make sure the
728 : : values fit in the fields. */
729 : 74948190 : gcc_assert (ptr->arch == ix86_arch);
730 : 74948190 : gcc_assert (ptr->schedule == ix86_schedule);
731 : 74948190 : gcc_assert (ptr->tune == ix86_tune);
732 : 74948190 : gcc_assert (ptr->branch_cost == ix86_branch_cost);
733 : 74948190 : }
734 : :
735 : : /* Feature tests against the various architecture variations, used to create
736 : : ix86_arch_features based on the processor mask. */
737 : : static unsigned HOST_WIDE_INT initial_ix86_arch_features[X86_ARCH_LAST] = {
738 : : /* X86_ARCH_CMOV: Conditional move was added for pentiumpro. */
739 : : ~(m_386 | m_486 | m_PENT | m_LAKEMONT | m_K6),
740 : :
741 : : /* X86_ARCH_CMPXCHG: Compare and exchange was added for 80486. */
742 : : ~m_386,
743 : :
744 : : /* X86_ARCH_CMPXCHG8B: Compare and exchange 8 bytes was added for pentium. */
745 : : ~(m_386 | m_486),
746 : :
747 : : /* X86_ARCH_XADD: Exchange and add was added for 80486. */
748 : : ~m_386,
749 : :
750 : : /* X86_ARCH_BSWAP: Byteswap was added for 80486. */
751 : : ~m_386,
752 : : };
753 : :
754 : : /* This table must be in sync with enum processor_type in i386.h. */
755 : : static const struct processor_costs *processor_cost_table[] =
756 : : {
757 : : &generic_cost, /* PROCESSOR_GENERIC. */
758 : : &i386_cost, /* PROCESSOR_I386. */
759 : : &i486_cost, /* PROCESSOR_I486. */
760 : : &pentium_cost, /* PROCESSOR_PENTIUM. */
761 : : &lakemont_cost, /* PROCESSOR_LAKEMONT. */
762 : : &pentiumpro_cost, /* PROCESSOR_PENTIUMPRO. */
763 : : &pentium4_cost, /* PROCESSOR_PENTIUM4. */
764 : : &nocona_cost, /* PROCESSOR_NOCONA. */
765 : : &core_cost, /* PROCESSOR_CORE2. */
766 : : &core_cost, /* PROCESSOR_NEHALEM. */
767 : : &core_cost, /* PROCESSOR_SANDYBRIDGE. */
768 : : &core_cost, /* PROCESSOR_HASWELL. */
769 : : &atom_cost, /* PROCESSOR_BONNELL. */
770 : : &slm_cost, /* PROCESSOR_SILVERMONT. */
771 : : &slm_cost, /* PROCESSOR_GOLDMONT. */
772 : : &slm_cost, /* PROCESSOR_GOLDMONT_PLUS. */
773 : : &tremont_cost, /* PROCESSOR_TREMONT. */
774 : : &alderlake_cost, /* PROCESSOR_SIERRAFOREST. */
775 : : &alderlake_cost, /* PROCESSOR_GRANDRIDGE. */
776 : : &alderlake_cost, /* PROCESSOR_CLEARWATERFOREST. */
777 : : &skylake_cost, /* PROCESSOR_SKYLAKE. */
778 : : &skylake_cost, /* PROCESSOR_SKYLAKE_AVX512. */
779 : : &icelake_cost, /* PROCESSOR_CANNONLAKE. */
780 : : &icelake_cost, /* PROCESSOR_ICELAKE_CLIENT. */
781 : : &icelake_cost, /* PROCESSOR_ICELAKE_SERVER. */
782 : : &skylake_cost, /* PROCESSOR_CASCADELAKE. */
783 : : &icelake_cost, /* PROCESSOR_TIGERLAKE. */
784 : : &skylake_cost, /* PROCESSOR_COOPERLAKE. */
785 : : &icelake_cost, /* PROCESSOR_SAPPHIRERAPIDS. */
786 : : &alderlake_cost, /* PROCESSOR_ALDERLAKE. */
787 : : &icelake_cost, /* PROCESSOR_ROCKETLAKE. */
788 : : &icelake_cost, /* PROCESSOR_GRANITERAPIDS. */
789 : : &icelake_cost, /* PROCESSOR_GRANITERAPIDS_D. */
790 : : &alderlake_cost, /* PROCESSOR_ARROWLAKE. */
791 : : &alderlake_cost, /* PROCESSOR_ARROWLAKE_S. */
792 : : &alderlake_cost, /* PROCESSOR_PANTHERLAKE. */
793 : : &icelake_cost, /* PROCESSOR_DIAMONDRAPIDS. */
794 : : &alderlake_cost, /* PROCESSOR_NOVALAKE. */
795 : : &alderlake_cost, /* PROCESSOR_INTEL. */
796 : : &lujiazui_cost, /* PROCESSOR_LUJIAZUI. */
797 : : &yongfeng_cost, /* PROCESSOR_YONGFENG. */
798 : : &shijidadao_cost, /* PROCESSOR_SHIJIDADAO. */
799 : : &geode_cost, /* PROCESSOR_GEODE. */
800 : : &k6_cost, /* PROCESSOR_K6. */
801 : : &athlon_cost, /* PROCESSOR_ATHLON. */
802 : : &k8_cost, /* PROCESSOR_K8. */
803 : : &amdfam10_cost, /* PROCESSOR_AMDFAM10. */
804 : : &bdver_cost, /* PROCESSOR_BDVER1. */
805 : : &bdver_cost, /* PROCESSOR_BDVER2. */
806 : : &bdver_cost, /* PROCESSOR_BDVER3. */
807 : : &bdver_cost, /* PROCESSOR_BDVER4. */
808 : : &btver1_cost, /* PROCESSOR_BTVER1. */
809 : : &btver2_cost, /* PROCESSOR_BTVER2. */
810 : : &znver1_cost, /* PROCESSOR_ZNVER1. */
811 : : &znver2_cost, /* PROCESSOR_ZNVER2. */
812 : : &znver3_cost, /* PROCESSOR_ZNVER3. */
813 : : &znver4_cost, /* PROCESSOR_ZNVER4. */
814 : : &znver5_cost /* PROCESSOR_ZNVER5. */
815 : : };
816 : :
817 : : /* Guarantee that the array is aligned with enum processor_type. */
818 : : STATIC_ASSERT (ARRAY_SIZE (processor_cost_table) == PROCESSOR_max);
819 : :
820 : : static bool
821 : : ix86_option_override_internal (bool main_args_p,
822 : : struct gcc_options *opts,
823 : : struct gcc_options *opts_set);
824 : : static void
825 : : set_ix86_tune_features (struct gcc_options *opts,
826 : : enum processor_type ix86_tune, bool dump);
827 : :
828 : : /* Restore the current options */
829 : :
830 : : void
831 : 52437025 : ix86_function_specific_restore (struct gcc_options *opts,
832 : : struct gcc_options */* opts_set */,
833 : : struct cl_target_option *ptr)
834 : : {
835 : 52437025 : enum processor_type old_tune = ix86_tune;
836 : 52437025 : enum processor_type old_arch = ix86_arch;
837 : 52437025 : unsigned HOST_WIDE_INT ix86_arch_mask;
838 : 52437025 : int i;
839 : :
840 : : /* We don't change -fPIC. */
841 : 52437025 : opts->x_flag_pic = flag_pic;
842 : :
843 : 52437025 : ix86_arch = (enum processor_type) ptr->arch;
844 : 52437025 : ix86_schedule = (enum attr_cpu) ptr->schedule;
845 : 52437025 : ix86_tune = (enum processor_type) ptr->tune;
846 : 52437025 : ix86_prefetch_sse = ptr->prefetch_sse;
847 : 52437025 : ix86_tune_defaulted = ptr->tune_defaulted;
848 : 52437025 : ix86_arch_specified = ptr->arch_specified;
849 : 52437025 : opts->x_ix86_apx_features = ptr->x_ix86_apx_features;
850 : 52437025 : opts->x_ix86_isa_flags_explicit = ptr->x_ix86_isa_flags_explicit;
851 : 52437025 : opts->x_ix86_isa_flags2_explicit = ptr->x_ix86_isa_flags2_explicit;
852 : 52437025 : opts->x_recip_mask_explicit = ptr->x_recip_mask_explicit;
853 : 52437025 : opts->x_ix86_arch_string = ptr->x_ix86_arch_string;
854 : 52437025 : opts->x_ix86_tune_string = ptr->x_ix86_tune_string;
855 : 52437025 : opts->x_ix86_asm_dialect = ptr->x_ix86_asm_dialect;
856 : 52437025 : opts->x_ix86_branch_cost = ptr->x_ix86_branch_cost;
857 : 52437025 : opts->x_ix86_dump_tunes = ptr->x_ix86_dump_tunes;
858 : 52437025 : opts->x_ix86_force_align_arg_pointer = ptr->x_ix86_force_align_arg_pointer;
859 : 52437025 : opts->x_ix86_force_drap = ptr->x_ix86_force_drap;
860 : 52437025 : opts->x_ix86_recip_name = ptr->x_ix86_recip_name;
861 : 52437025 : opts->x_ix86_section_threshold = ptr->x_ix86_section_threshold;
862 : 52437025 : opts->x_ix86_sse2avx = ptr->x_ix86_sse2avx;
863 : 52437025 : opts->x_ix86_stack_protector_guard = ptr->x_ix86_stack_protector_guard;
864 : 52437025 : opts->x_ix86_stringop_alg = ptr->x_ix86_stringop_alg;
865 : 52437025 : opts->x_ix86_tls_dialect = ptr->x_ix86_tls_dialect;
866 : 52437025 : opts->x_ix86_tune_ctrl_string = ptr->x_ix86_tune_ctrl_string;
867 : 52437025 : opts->x_ix86_tune_memcpy_strategy = ptr->x_ix86_tune_memcpy_strategy;
868 : 52437025 : opts->x_ix86_tune_memset_strategy = ptr->x_ix86_tune_memset_strategy;
869 : 52437025 : opts->x_ix86_tune_no_default = ptr->x_ix86_tune_no_default;
870 : 52437025 : ix86_tune_cost = processor_cost_table[ix86_tune];
871 : : /* TODO: ix86_cost should be chosen at instruction or function granuality
872 : : so for cold code we use size_cost even in !optimize_size compilation. */
873 : 52437025 : if (opts->x_optimize_size)
874 : 699868 : ix86_cost = &ix86_size_cost;
875 : : else
876 : 51737157 : ix86_cost = ix86_tune_cost;
877 : :
878 : : /* Recreate the arch feature tests if the arch changed */
879 : 52437025 : if (old_arch != ix86_arch)
880 : : {
881 : 32973 : ix86_arch_mask = HOST_WIDE_INT_1U << ix86_arch;
882 : 197838 : for (i = 0; i < X86_ARCH_LAST; ++i)
883 : 164865 : ix86_arch_features[i]
884 : 164865 : = !!(initial_ix86_arch_features[i] & ix86_arch_mask);
885 : : }
886 : :
887 : : /* Recreate the tune optimization tests */
888 : 52437025 : if (old_tune != ix86_tune)
889 : 33215 : set_ix86_tune_features (opts, ix86_tune, false);
890 : 52437025 : }
891 : :
892 : : /* Adjust target options after streaming them in. This is mainly about
893 : : reconciling them with global options. */
894 : :
895 : : void
896 : 23190 : ix86_function_specific_post_stream_in (struct cl_target_option *ptr)
897 : : {
898 : : /* flag_pic is a global option, but ix86_cmodel is target saved option
899 : : partly computed from flag_pic. If flag_pic is on, adjust x_ix86_cmodel
900 : : for PIC, or error out. */
901 : 23190 : if (flag_pic)
902 : 338 : switch (ptr->x_ix86_cmodel)
903 : : {
904 : 90 : case CM_SMALL:
905 : 90 : ptr->x_ix86_cmodel = CM_SMALL_PIC;
906 : 90 : break;
907 : :
908 : 0 : case CM_MEDIUM:
909 : 0 : ptr->x_ix86_cmodel = CM_MEDIUM_PIC;
910 : 0 : break;
911 : :
912 : 0 : case CM_LARGE:
913 : 0 : ptr->x_ix86_cmodel = CM_LARGE_PIC;
914 : 0 : break;
915 : :
916 : 0 : case CM_KERNEL:
917 : 0 : error ("code model %s does not support PIC mode", "kernel");
918 : 0 : break;
919 : :
920 : : default:
921 : : break;
922 : : }
923 : : else
924 : 22852 : switch (ptr->x_ix86_cmodel)
925 : : {
926 : 99 : case CM_SMALL_PIC:
927 : 99 : ptr->x_ix86_cmodel = CM_SMALL;
928 : 99 : break;
929 : :
930 : 0 : case CM_MEDIUM_PIC:
931 : 0 : ptr->x_ix86_cmodel = CM_MEDIUM;
932 : 0 : break;
933 : :
934 : 0 : case CM_LARGE_PIC:
935 : 0 : ptr->x_ix86_cmodel = CM_LARGE;
936 : 0 : break;
937 : :
938 : : default:
939 : : break;
940 : : }
941 : 23190 : }
942 : :
943 : : /* Print the current options */
944 : :
945 : : void
946 : 0 : ix86_function_specific_print (FILE *file, int indent,
947 : : struct cl_target_option *ptr)
948 : : {
949 : 0 : char *target_string
950 : 0 : = ix86_target_string (ptr->x_ix86_isa_flags, ptr->x_ix86_isa_flags2,
951 : : ptr->x_target_flags, ptr->x_ix86_target_flags,
952 : : NULL, NULL, ptr->x_ix86_fpmath,
953 : : ptr->x_prefer_vector_width_type,
954 : : ptr->x_ix86_move_max, false, true);
955 : :
956 : 0 : gcc_assert (ptr->arch < PROCESSOR_max);
957 : 0 : fprintf (file, "%*sarch = %d (%s)\n",
958 : : indent, "",
959 : 0 : ptr->arch, processor_names[ptr->arch]);
960 : :
961 : 0 : gcc_assert (ptr->tune < PROCESSOR_max);
962 : 0 : fprintf (file, "%*stune = %d (%s)\n",
963 : : indent, "",
964 : 0 : ptr->tune, processor_names[ptr->tune]);
965 : :
966 : 0 : fprintf (file, "%*sbranch_cost = %d\n", indent, "", ptr->branch_cost);
967 : :
968 : 0 : if (target_string)
969 : : {
970 : 0 : fprintf (file, "%*s%s\n", indent, "", target_string);
971 : 0 : free (target_string);
972 : : }
973 : 0 : }
974 : :
975 : :
976 : : /* Inner function to process the attribute((target(...))), take an argument and
977 : : set the current options from the argument. If we have a list, recursively go
978 : : over the list. */
979 : :
980 : : static bool
981 : 97658552 : ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
982 : : struct gcc_options *opts,
983 : : struct gcc_options *opts_set,
984 : : struct gcc_options *enum_opts_set,
985 : : bool target_clone_attr)
986 : : {
987 : 97658552 : char *next_optstr;
988 : 97658552 : bool ret = true;
989 : :
990 : : #define IX86_ATTR_ISA(S,O) { S, sizeof (S)-1, ix86_opt_isa, O, 0 }
991 : : #define IX86_ATTR_STR(S,O) { S, sizeof (S)-1, ix86_opt_str, O, 0 }
992 : : #define IX86_ATTR_ENUM(S,O) { S, sizeof (S)-1, ix86_opt_enum, O, 0 }
993 : : #define IX86_ATTR_YES(S,O,M) { S, sizeof (S)-1, ix86_opt_yes, O, M }
994 : : #define IX86_ATTR_NO(S,O,M) { S, sizeof (S)-1, ix86_opt_no, O, M }
995 : : #define IX86_ATTR_IX86_YES(S,O,M) \
996 : : { S, sizeof (S)-1, ix86_opt_ix86_yes, O, M }
997 : : #define IX86_ATTR_IX86_NO(S,O,M) \
998 : : { S, sizeof (S)-1, ix86_opt_ix86_no, O, M }
999 : :
1000 : 97658552 : enum ix86_opt_type
1001 : : {
1002 : : ix86_opt_unknown,
1003 : : ix86_opt_yes,
1004 : : ix86_opt_no,
1005 : : ix86_opt_ix86_yes,
1006 : : ix86_opt_ix86_no,
1007 : : ix86_opt_str,
1008 : : ix86_opt_enum,
1009 : : ix86_opt_isa
1010 : : };
1011 : :
1012 : 97658552 : static const struct
1013 : : {
1014 : : const char *string;
1015 : : size_t len;
1016 : : enum ix86_opt_type type;
1017 : : int opt;
1018 : : int mask;
1019 : : } attrs[] = {
1020 : : /* isa options */
1021 : : IX86_ATTR_ISA ("pconfig", OPT_mpconfig),
1022 : : IX86_ATTR_ISA ("wbnoinvd", OPT_mwbnoinvd),
1023 : : IX86_ATTR_ISA ("sgx", OPT_msgx),
1024 : : IX86_ATTR_ISA ("avx512vpopcntdq", OPT_mavx512vpopcntdq),
1025 : : IX86_ATTR_ISA ("avx512vbmi2", OPT_mavx512vbmi2),
1026 : : IX86_ATTR_ISA ("avx512vnni", OPT_mavx512vnni),
1027 : : IX86_ATTR_ISA ("avx512bitalg", OPT_mavx512bitalg),
1028 : : IX86_ATTR_ISA ("avx512vp2intersect", OPT_mavx512vp2intersect),
1029 : :
1030 : : IX86_ATTR_ISA ("avx512vbmi", OPT_mavx512vbmi),
1031 : : IX86_ATTR_ISA ("avx512ifma", OPT_mavx512ifma),
1032 : : IX86_ATTR_ISA ("avx512vl", OPT_mavx512vl),
1033 : : IX86_ATTR_ISA ("avx512bw", OPT_mavx512bw),
1034 : : IX86_ATTR_ISA ("avx512dq", OPT_mavx512dq),
1035 : : IX86_ATTR_ISA ("avx512cd", OPT_mavx512cd),
1036 : : IX86_ATTR_ISA ("avx512f", OPT_mavx512f),
1037 : : IX86_ATTR_ISA ("avx2", OPT_mavx2),
1038 : : IX86_ATTR_ISA ("fma", OPT_mfma),
1039 : : IX86_ATTR_ISA ("xop", OPT_mxop),
1040 : : IX86_ATTR_ISA ("fma4", OPT_mfma4),
1041 : : IX86_ATTR_ISA ("f16c", OPT_mf16c),
1042 : : IX86_ATTR_ISA ("avx", OPT_mavx),
1043 : : IX86_ATTR_ISA ("sse4", OPT_msse4),
1044 : : IX86_ATTR_ISA ("sse4.2", OPT_msse4_2),
1045 : : IX86_ATTR_ISA ("sse4.1", OPT_msse4_1),
1046 : : IX86_ATTR_ISA ("sse4a", OPT_msse4a),
1047 : : IX86_ATTR_ISA ("ssse3", OPT_mssse3),
1048 : : IX86_ATTR_ISA ("sse3", OPT_msse3),
1049 : : IX86_ATTR_ISA ("aes", OPT_maes),
1050 : : IX86_ATTR_ISA ("sha", OPT_msha),
1051 : : IX86_ATTR_ISA ("pclmul", OPT_mpclmul),
1052 : : IX86_ATTR_ISA ("sse2", OPT_msse2),
1053 : : IX86_ATTR_ISA ("sse", OPT_msse),
1054 : : IX86_ATTR_ISA ("3dnowa", OPT_m3dnowa),
1055 : : IX86_ATTR_ISA ("3dnow", OPT_m3dnow),
1056 : : IX86_ATTR_ISA ("mmx", OPT_mmmx),
1057 : : IX86_ATTR_ISA ("rtm", OPT_mrtm),
1058 : : IX86_ATTR_ISA ("prfchw", OPT_mprfchw),
1059 : : IX86_ATTR_ISA ("rdseed", OPT_mrdseed),
1060 : : IX86_ATTR_ISA ("adx", OPT_madx),
1061 : : IX86_ATTR_ISA ("clflushopt", OPT_mclflushopt),
1062 : : IX86_ATTR_ISA ("xsaves", OPT_mxsaves),
1063 : : IX86_ATTR_ISA ("xsavec", OPT_mxsavec),
1064 : : IX86_ATTR_ISA ("xsaveopt", OPT_mxsaveopt),
1065 : : IX86_ATTR_ISA ("xsave", OPT_mxsave),
1066 : : IX86_ATTR_ISA ("abm", OPT_mabm),
1067 : : IX86_ATTR_ISA ("bmi", OPT_mbmi),
1068 : : IX86_ATTR_ISA ("bmi2", OPT_mbmi2),
1069 : : IX86_ATTR_ISA ("lzcnt", OPT_mlzcnt),
1070 : : IX86_ATTR_ISA ("tbm", OPT_mtbm),
1071 : : IX86_ATTR_ISA ("popcnt", OPT_mpopcnt),
1072 : : IX86_ATTR_ISA ("cx16", OPT_mcx16),
1073 : : IX86_ATTR_ISA ("sahf", OPT_msahf),
1074 : : IX86_ATTR_ISA ("movbe", OPT_mmovbe),
1075 : : IX86_ATTR_ISA ("crc32", OPT_mcrc32),
1076 : : IX86_ATTR_ISA ("fsgsbase", OPT_mfsgsbase),
1077 : : IX86_ATTR_ISA ("rdrnd", OPT_mrdrnd),
1078 : : IX86_ATTR_ISA ("mwaitx", OPT_mmwaitx),
1079 : : IX86_ATTR_ISA ("mwait", OPT_mmwait),
1080 : : IX86_ATTR_ISA ("clzero", OPT_mclzero),
1081 : : IX86_ATTR_ISA ("pku", OPT_mpku),
1082 : : IX86_ATTR_ISA ("lwp", OPT_mlwp),
1083 : : IX86_ATTR_ISA ("hle", OPT_mhle),
1084 : : IX86_ATTR_ISA ("fxsr", OPT_mfxsr),
1085 : : IX86_ATTR_ISA ("clwb", OPT_mclwb),
1086 : : IX86_ATTR_ISA ("rdpid", OPT_mrdpid),
1087 : : IX86_ATTR_ISA ("gfni", OPT_mgfni),
1088 : : IX86_ATTR_ISA ("shstk", OPT_mshstk),
1089 : : IX86_ATTR_ISA ("vaes", OPT_mvaes),
1090 : : IX86_ATTR_ISA ("vpclmulqdq", OPT_mvpclmulqdq),
1091 : : IX86_ATTR_ISA ("movdiri", OPT_mmovdiri),
1092 : : IX86_ATTR_ISA ("movdir64b", OPT_mmovdir64b),
1093 : : IX86_ATTR_ISA ("waitpkg", OPT_mwaitpkg),
1094 : : IX86_ATTR_ISA ("cldemote", OPT_mcldemote),
1095 : : IX86_ATTR_ISA ("uintr", OPT_muintr),
1096 : : IX86_ATTR_ISA ("ptwrite", OPT_mptwrite),
1097 : : IX86_ATTR_ISA ("kl", OPT_mkl),
1098 : : IX86_ATTR_ISA ("widekl", OPT_mwidekl),
1099 : : IX86_ATTR_ISA ("avx512bf16", OPT_mavx512bf16),
1100 : : IX86_ATTR_ISA ("enqcmd", OPT_menqcmd),
1101 : : IX86_ATTR_ISA ("serialize", OPT_mserialize),
1102 : : IX86_ATTR_ISA ("tsxldtrk", OPT_mtsxldtrk),
1103 : : IX86_ATTR_ISA ("amx-tile", OPT_mamx_tile),
1104 : : IX86_ATTR_ISA ("amx-int8", OPT_mamx_int8),
1105 : : IX86_ATTR_ISA ("amx-bf16", OPT_mamx_bf16),
1106 : : IX86_ATTR_ISA ("hreset", OPT_mhreset),
1107 : : IX86_ATTR_ISA ("avxvnni", OPT_mavxvnni),
1108 : : IX86_ATTR_ISA ("avx512fp16", OPT_mavx512fp16),
1109 : : IX86_ATTR_ISA ("avxifma", OPT_mavxifma),
1110 : : IX86_ATTR_ISA ("avxvnniint8", OPT_mavxvnniint8),
1111 : : IX86_ATTR_ISA ("avxneconvert", OPT_mavxneconvert),
1112 : : IX86_ATTR_ISA ("cmpccxadd", OPT_mcmpccxadd),
1113 : : IX86_ATTR_ISA ("amx-fp16", OPT_mamx_fp16),
1114 : : IX86_ATTR_ISA ("prefetchi", OPT_mprefetchi),
1115 : : IX86_ATTR_ISA ("raoint", OPT_mraoint),
1116 : : IX86_ATTR_ISA ("amx-complex", OPT_mamx_complex),
1117 : : IX86_ATTR_ISA ("avxvnniint16", OPT_mavxvnniint16),
1118 : : IX86_ATTR_ISA ("sm3", OPT_msm3),
1119 : : IX86_ATTR_ISA ("sha512", OPT_msha512),
1120 : : IX86_ATTR_ISA ("sm4", OPT_msm4),
1121 : : IX86_ATTR_ISA ("apxf", OPT_mapxf),
1122 : : IX86_ATTR_ISA ("usermsr", OPT_musermsr),
1123 : : IX86_ATTR_ISA ("avx10.1", OPT_mavx10_1),
1124 : : IX86_ATTR_ISA ("avx10.2", OPT_mavx10_2),
1125 : : IX86_ATTR_ISA ("amx-avx512", OPT_mamx_avx512),
1126 : : IX86_ATTR_ISA ("amx-tf32", OPT_mamx_tf32),
1127 : : IX86_ATTR_ISA ("amx-fp8", OPT_mamx_fp8),
1128 : : IX86_ATTR_ISA ("movrs", OPT_mmovrs),
1129 : : IX86_ATTR_ISA ("amx-movrs", OPT_mamx_movrs),
1130 : :
1131 : : /* enum options */
1132 : : IX86_ATTR_ENUM ("fpmath=", OPT_mfpmath_),
1133 : : IX86_ATTR_ENUM ("prefer-vector-width=", OPT_mprefer_vector_width_),
1134 : :
1135 : : /* string options */
1136 : : IX86_ATTR_STR ("arch=", IX86_FUNCTION_SPECIFIC_ARCH),
1137 : : IX86_ATTR_STR ("tune=", IX86_FUNCTION_SPECIFIC_TUNE),
1138 : :
1139 : : /* flag options */
1140 : : IX86_ATTR_YES ("cld",
1141 : : OPT_mcld,
1142 : : MASK_CLD),
1143 : :
1144 : : IX86_ATTR_NO ("fancy-math-387",
1145 : : OPT_mfancy_math_387,
1146 : : MASK_NO_FANCY_MATH_387),
1147 : :
1148 : : IX86_ATTR_YES ("ieee-fp",
1149 : : OPT_mieee_fp,
1150 : : MASK_IEEE_FP),
1151 : :
1152 : : IX86_ATTR_YES ("inline-all-stringops",
1153 : : OPT_minline_all_stringops,
1154 : : MASK_INLINE_ALL_STRINGOPS),
1155 : :
1156 : : IX86_ATTR_YES ("inline-stringops-dynamically",
1157 : : OPT_minline_stringops_dynamically,
1158 : : MASK_INLINE_STRINGOPS_DYNAMICALLY),
1159 : :
1160 : : IX86_ATTR_NO ("align-stringops",
1161 : : OPT_mno_align_stringops,
1162 : : MASK_NO_ALIGN_STRINGOPS),
1163 : :
1164 : : IX86_ATTR_YES ("recip",
1165 : : OPT_mrecip,
1166 : : MASK_RECIP),
1167 : :
1168 : : IX86_ATTR_YES ("80387",
1169 : : OPT_m80387,
1170 : : MASK_80387),
1171 : :
1172 : : IX86_ATTR_IX86_YES ("general-regs-only",
1173 : : OPT_mgeneral_regs_only,
1174 : : OPTION_MASK_GENERAL_REGS_ONLY),
1175 : :
1176 : : IX86_ATTR_YES ("relax-cmpxchg-loop",
1177 : : OPT_mrelax_cmpxchg_loop,
1178 : : MASK_RELAX_CMPXCHG_LOOP),
1179 : : };
1180 : :
1181 : 97658552 : location_t loc
1182 : 97658552 : = fndecl == NULL ? UNKNOWN_LOCATION : DECL_SOURCE_LOCATION (fndecl);
1183 : 97658552 : const char *attr_name = target_clone_attr ? "target_clone" : "target";
1184 : :
1185 : : /* If this is a list, recurse to get the options. */
1186 : 97658552 : if (TREE_CODE (args) == TREE_LIST)
1187 : : {
1188 : 97653791 : for (; args; args = TREE_CHAIN (args))
1189 : 49619173 : if (TREE_VALUE (args)
1190 : 49619173 : && !ix86_valid_target_attribute_inner_p (fndecl, TREE_VALUE (args),
1191 : : p_strings, opts, opts_set,
1192 : : enum_opts_set,
1193 : : target_clone_attr))
1194 : : ret = false;
1195 : :
1196 : : return ret;
1197 : : }
1198 : :
1199 : 49623934 : else if (TREE_CODE (args) != STRING_CST)
1200 : : {
1201 : 9 : error_at (loc, "attribute %qs argument is not a string", attr_name);
1202 : 9 : return false;
1203 : : }
1204 : :
1205 : : /* Handle multiple arguments separated by commas. */
1206 : 49623925 : next_optstr = ASTRDUP (TREE_STRING_POINTER (args));
1207 : :
1208 : 115645839 : while (next_optstr && *next_optstr != '\0')
1209 : : {
1210 : 66021916 : char *p = next_optstr;
1211 : 66021916 : char *orig_p = p;
1212 : 66021916 : char *comma = strchr (next_optstr, ',');
1213 : 66021916 : size_t len, opt_len;
1214 : 66021916 : int opt;
1215 : 66021916 : bool opt_set_p;
1216 : 66021916 : char ch;
1217 : 66021916 : unsigned i;
1218 : 66021916 : enum ix86_opt_type type = ix86_opt_unknown;
1219 : 66021916 : int mask = 0;
1220 : :
1221 : 66021916 : if (comma)
1222 : : {
1223 : 16398002 : *comma = '\0';
1224 : 16398002 : len = comma - next_optstr;
1225 : 16398002 : next_optstr = comma + 1;
1226 : : }
1227 : : else
1228 : : {
1229 : 49623914 : len = strlen (p);
1230 : 49623914 : next_optstr = NULL;
1231 : : }
1232 : :
1233 : : /* Recognize no-xxx. */
1234 : 66021916 : if (len > 3 && p[0] == 'n' && p[1] == 'o' && p[2] == '-')
1235 : : {
1236 : 1584 : opt_set_p = false;
1237 : 1584 : p += 3;
1238 : 1584 : len -= 3;
1239 : : }
1240 : : else
1241 : : opt_set_p = true;
1242 : :
1243 : : /* Find the option. */
1244 : 66021916 : ch = *p;
1245 : 66021916 : opt = N_OPTS;
1246 : 2724116589 : for (i = 0; i < ARRAY_SIZE (attrs); i++)
1247 : : {
1248 : 2724116473 : type = attrs[i].type;
1249 : 2724116473 : opt_len = attrs[i].len;
1250 : 2724116473 : if (ch == attrs[i].string[0]
1251 : 852880402 : && ((type != ix86_opt_str && type != ix86_opt_enum)
1252 : 852880402 : ? len == opt_len
1253 : : : len > opt_len)
1254 : 153597436 : && memcmp (p, attrs[i].string, opt_len) == 0)
1255 : : {
1256 : 66021800 : opt = attrs[i].opt;
1257 : 66021800 : mask = attrs[i].mask;
1258 : 66021800 : break;
1259 : : }
1260 : : }
1261 : :
1262 : : /* Process the option. */
1263 : 66021916 : if (opt == N_OPTS)
1264 : : {
1265 : 116 : error_at (loc, "attribute %qs argument %qs is unknown",
1266 : : attr_name, orig_p);
1267 : 116 : ret = false;
1268 : : }
1269 : :
1270 : 66021800 : else if (type == ix86_opt_isa)
1271 : : {
1272 : 64036579 : struct cl_decoded_option decoded;
1273 : :
1274 : 64036579 : generate_option (opt, NULL, opt_set_p, CL_TARGET, &decoded);
1275 : 64036579 : ix86_handle_option (opts, opts_set,
1276 : : &decoded, input_location);
1277 : : }
1278 : :
1279 : : else if (type == ix86_opt_yes || type == ix86_opt_no)
1280 : : {
1281 : 51 : opts_set->x_target_flags |= mask;
1282 : :
1283 : 51 : if (type == ix86_opt_no)
1284 : 12 : opt_set_p = !opt_set_p;
1285 : :
1286 : 51 : if (opt_set_p)
1287 : 42 : opts->x_target_flags |= mask;
1288 : : else
1289 : 9 : opts->x_target_flags &= ~mask;
1290 : : }
1291 : :
1292 : : else if (type == ix86_opt_ix86_yes || type == ix86_opt_ix86_no)
1293 : : {
1294 : 1964793 : if (mask == OPTION_MASK_GENERAL_REGS_ONLY)
1295 : : {
1296 : 1964793 : if (!opt_set_p)
1297 : : {
1298 : 2 : error_at (loc, "pragma or attribute %<target(\"%s\")%> "
1299 : : "does not allow a negated form", p);
1300 : 2 : return false;
1301 : : }
1302 : :
1303 : 1964791 : if (type != ix86_opt_ix86_yes)
1304 : 0 : gcc_unreachable ();
1305 : :
1306 : 1964791 : opts->x_ix86_target_flags |= mask;
1307 : :
1308 : 1964791 : struct cl_decoded_option decoded;
1309 : 1964791 : generate_option (opt, NULL, opt_set_p, CL_TARGET,
1310 : : &decoded);
1311 : 1964791 : ix86_handle_option (opts, opts_set, &decoded,
1312 : : input_location);
1313 : : }
1314 : : else
1315 : : {
1316 : 0 : if (type == ix86_opt_ix86_no)
1317 : 0 : opt_set_p = !opt_set_p;
1318 : :
1319 : 0 : if (opt_set_p)
1320 : 0 : opts->x_ix86_target_flags |= mask;
1321 : : else
1322 : 0 : opts->x_ix86_target_flags &= ~mask;
1323 : : }
1324 : : }
1325 : :
1326 : : else if (type == ix86_opt_str)
1327 : : {
1328 : 20190 : if (p_strings[opt])
1329 : : {
1330 : 1 : error_at (loc, "attribute value %qs was already specified "
1331 : : "in %qs attribute", orig_p, attr_name);
1332 : 1 : ret = false;
1333 : : }
1334 : : else
1335 : : {
1336 : 20189 : p_strings[opt] = xstrdup (p + opt_len);
1337 : 20189 : if (opt == IX86_FUNCTION_SPECIFIC_ARCH)
1338 : : {
1339 : : /* If arch= is set, clear all bits in x_ix86_isa_flags,
1340 : : except for ISA_64BIT, ABI_64, ABI_X32, and CODE16
1341 : : and all bits in x_ix86_isa_flags2. */
1342 : 20160 : opts->x_ix86_isa_flags &= (OPTION_MASK_ISA_64BIT
1343 : : | OPTION_MASK_ABI_64
1344 : : | OPTION_MASK_ABI_X32
1345 : : | OPTION_MASK_CODE16);
1346 : 20160 : opts->x_ix86_isa_flags_explicit &= (OPTION_MASK_ISA_64BIT
1347 : : | OPTION_MASK_ABI_64
1348 : : | OPTION_MASK_ABI_X32
1349 : : | OPTION_MASK_CODE16);
1350 : 20160 : opts->x_ix86_isa_flags2 = 0;
1351 : 20160 : opts->x_ix86_isa_flags2_explicit = 0;
1352 : : }
1353 : : }
1354 : : }
1355 : :
1356 : : else if (type == ix86_opt_enum)
1357 : : {
1358 : 187 : bool arg_ok;
1359 : 187 : int value;
1360 : :
1361 : 187 : arg_ok = opt_enum_arg_to_value (opt, p + opt_len, &value, CL_TARGET);
1362 : 187 : if (arg_ok)
1363 : 187 : set_option (opts, enum_opts_set, opt, value,
1364 : : p + opt_len,
1365 : : static_cast<int> (diagnostics::kind::unspecified),
1366 : : input_location,
1367 : : global_dc);
1368 : : else
1369 : : {
1370 : 0 : error_at (loc, "attribute value %qs is unknown in %qs attribute",
1371 : : orig_p, attr_name);
1372 : 0 : ret = false;
1373 : : }
1374 : : }
1375 : :
1376 : : else
1377 : 0 : gcc_unreachable ();
1378 : : }
1379 : :
1380 : : return ret;
1381 : : }
1382 : :
1383 : : /* Release allocated strings. */
1384 : : static void
1385 : 48038743 : release_options_strings (char **option_strings)
1386 : : {
1387 : : /* Free up memory allocated to hold the strings */
1388 : 144116229 : for (unsigned i = 0; i < IX86_FUNCTION_SPECIFIC_MAX; i++)
1389 : 96077486 : free (option_strings[i]);
1390 : 48038743 : }
1391 : :
1392 : : /* Return a TARGET_OPTION_NODE tree of the target options listed or NULL. */
1393 : :
1394 : : tree
1395 : 48039379 : ix86_valid_target_attribute_tree (tree fndecl, tree args,
1396 : : struct gcc_options *opts,
1397 : : struct gcc_options *opts_set,
1398 : : bool target_clone_attr)
1399 : : {
1400 : 48039379 : const char *orig_arch_string = opts->x_ix86_arch_string;
1401 : 48039379 : const char *orig_tune_string = opts->x_ix86_tune_string;
1402 : 48039379 : enum fpmath_unit orig_fpmath_set = opts_set->x_ix86_fpmath;
1403 : 48039379 : enum prefer_vector_width orig_pvw_set = opts_set->x_prefer_vector_width_type;
1404 : 48039379 : enum prefer_vector_width orig_ix86_move_max_set
1405 : : = opts_set->x_ix86_move_max;
1406 : 48039379 : int orig_tune_defaulted = ix86_tune_defaulted;
1407 : 48039379 : int orig_arch_specified = ix86_arch_specified;
1408 : 48039379 : char *option_strings[IX86_FUNCTION_SPECIFIC_MAX] = { NULL, NULL };
1409 : 48039379 : tree t = NULL_TREE;
1410 : 48039379 : struct cl_target_option *def
1411 : 48039379 : = TREE_TARGET_OPTION (target_option_default_node);
1412 : 48039379 : struct gcc_options enum_opts_set;
1413 : :
1414 : 48039379 : memset (&enum_opts_set, 0, sizeof (enum_opts_set));
1415 : :
1416 : : /* Process each of the options on the chain. */
1417 : 48039379 : if (!ix86_valid_target_attribute_inner_p (fndecl, args, option_strings, opts,
1418 : : opts_set, &enum_opts_set,
1419 : : target_clone_attr))
1420 : 125 : return error_mark_node;
1421 : :
1422 : : /* If the changed options are different from the default, rerun
1423 : : ix86_option_override_internal, and then save the options away.
1424 : : The string options are attribute options, and will be undone
1425 : : when we copy the save structure. */
1426 : 48039254 : if (opts->x_ix86_isa_flags != def->x_ix86_isa_flags
1427 : 1856552 : || opts->x_ix86_isa_flags2 != def->x_ix86_isa_flags2
1428 : 1878 : || opts->x_target_flags != def->x_target_flags
1429 : 722 : || option_strings[IX86_FUNCTION_SPECIFIC_ARCH]
1430 : 722 : || option_strings[IX86_FUNCTION_SPECIFIC_TUNE]
1431 : 693 : || enum_opts_set.x_ix86_fpmath
1432 : 524 : || enum_opts_set.x_prefer_vector_width_type)
1433 : : {
1434 : : /* If we are using the default tune= or arch=, undo the string assigned,
1435 : : and use the default. */
1436 : 48038743 : if (option_strings[IX86_FUNCTION_SPECIFIC_ARCH])
1437 : 20159 : opts->x_ix86_arch_string
1438 : 20159 : = ggc_strdup (option_strings[IX86_FUNCTION_SPECIFIC_ARCH]);
1439 : 48018584 : else if (!orig_arch_specified)
1440 : 0 : opts->x_ix86_arch_string = NULL;
1441 : :
1442 : 48038743 : if (option_strings[IX86_FUNCTION_SPECIFIC_TUNE])
1443 : 29 : opts->x_ix86_tune_string
1444 : 29 : = ggc_strdup (option_strings[IX86_FUNCTION_SPECIFIC_TUNE]);
1445 : : /* If we have explicit arch string and no tune string specified, set
1446 : : tune_string to NULL and later it will be overriden by arch_string
1447 : : so target clones can get proper optimization. */
1448 : 48038714 : else if (option_strings[IX86_FUNCTION_SPECIFIC_ARCH]
1449 : 48018555 : || orig_tune_defaulted)
1450 : 20159 : opts->x_ix86_tune_string = NULL;
1451 : :
1452 : : /* If fpmath= is not set, and we now have sse2 on 32-bit, use it. */
1453 : 48038743 : if (enum_opts_set.x_ix86_fpmath)
1454 : 169 : opts_set->x_ix86_fpmath = (enum fpmath_unit) 1;
1455 : 48038743 : if (enum_opts_set.x_prefer_vector_width_type)
1456 : 17 : opts_set->x_prefer_vector_width_type = (enum prefer_vector_width) 1;
1457 : :
1458 : : /* Do any overrides, such as arch=xxx, or tune=xxx support. */
1459 : 48038743 : bool r = ix86_option_override_internal (false, opts, opts_set);
1460 : 48038743 : if (!r)
1461 : : {
1462 : 3 : release_options_strings (option_strings);
1463 : 3 : return error_mark_node;
1464 : : }
1465 : :
1466 : : /* Add any builtin functions with the new isa if any. */
1467 : 48038740 : ix86_add_new_builtins (opts->x_ix86_isa_flags, opts->x_ix86_isa_flags2);
1468 : :
1469 : 48038740 : enum excess_precision orig_ix86_excess_precision
1470 : : = opts->x_ix86_excess_precision;
1471 : 48038740 : bool orig_ix86_unsafe_math_optimizations
1472 : : = opts->x_ix86_unsafe_math_optimizations;
1473 : 48038740 : opts->x_ix86_excess_precision = opts->x_flag_excess_precision;
1474 : 48038740 : opts->x_ix86_unsafe_math_optimizations
1475 : 48038740 : = opts->x_flag_unsafe_math_optimizations;
1476 : :
1477 : : /* Save the current options unless we are validating options for
1478 : : #pragma. */
1479 : 48038740 : t = build_target_option_node (opts, opts_set);
1480 : :
1481 : 48038740 : opts->x_ix86_arch_string = orig_arch_string;
1482 : 48038740 : opts->x_ix86_tune_string = orig_tune_string;
1483 : 48038740 : opts_set->x_ix86_fpmath = orig_fpmath_set;
1484 : 48038740 : opts_set->x_prefer_vector_width_type = orig_pvw_set;
1485 : 48038740 : opts_set->x_ix86_move_max = orig_ix86_move_max_set;
1486 : 48038740 : opts->x_ix86_excess_precision = orig_ix86_excess_precision;
1487 : 48038740 : opts->x_ix86_unsafe_math_optimizations
1488 : 48038740 : = orig_ix86_unsafe_math_optimizations;
1489 : :
1490 : 48038740 : release_options_strings (option_strings);
1491 : : }
1492 : :
1493 : : return t;
1494 : : }
1495 : :
1496 : : static GTY(()) tree target_attribute_cache[3];
1497 : :
1498 : : /* Hook to validate attribute((target("string"))). */
1499 : :
1500 : : bool
1501 : 47488371 : ix86_valid_target_attribute_p (tree fndecl,
1502 : : tree ARG_UNUSED (name),
1503 : : tree args,
1504 : : int flags)
1505 : : {
1506 : 47488371 : struct gcc_options func_options, func_options_set;
1507 : 47488371 : tree new_target, new_optimize;
1508 : 47488371 : bool ret = true;
1509 : :
1510 : : /* attribute((target("default"))) does nothing, beyond
1511 : : affecting multi-versioning. */
1512 : 47488371 : if (TREE_VALUE (args)
1513 : 47488371 : && TREE_CODE (TREE_VALUE (args)) == STRING_CST
1514 : 47488365 : && TREE_CHAIN (args) == NULL_TREE
1515 : 93433263 : && strcmp (TREE_STRING_POINTER (TREE_VALUE (args)), "default") == 0)
1516 : : return true;
1517 : :
1518 : 47488161 : if ((DECL_FUNCTION_SPECIFIC_TARGET (fndecl) == target_attribute_cache[1]
1519 : 47485841 : || DECL_FUNCTION_SPECIFIC_TARGET (fndecl) == NULL_TREE)
1520 : 6479 : && (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl)
1521 : 6479 : == target_attribute_cache[2]
1522 : 435 : || DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) == NULL_TREE)
1523 : 47494606 : && simple_cst_list_equal (args, target_attribute_cache[0]))
1524 : : {
1525 : 1306 : DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = target_attribute_cache[1];
1526 : 1306 : DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl)
1527 : 1306 : = target_attribute_cache[2];
1528 : 1306 : return true;
1529 : : }
1530 : :
1531 : 47486855 : tree old_optimize = build_optimization_node (&global_options,
1532 : : &global_options_set);
1533 : :
1534 : : /* Get the optimization options of the current function. */
1535 : 47486855 : tree func_optimize = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
1536 : :
1537 : 47486855 : if (!func_optimize)
1538 : 5139 : func_optimize = old_optimize;
1539 : :
1540 : : /* Init func_options. */
1541 : 47486855 : memset (&func_options, 0, sizeof (func_options));
1542 : 47486855 : init_options_struct (&func_options, NULL);
1543 : 47486855 : lang_hooks.init_options_struct (&func_options);
1544 : 47486855 : memset (&func_options_set, 0, sizeof (func_options_set));
1545 : :
1546 : 47486855 : cl_optimization_restore (&func_options, &func_options_set,
1547 : 47486855 : TREE_OPTIMIZATION (func_optimize));
1548 : :
1549 : : /* Initialize func_options to the default before its target options can
1550 : : be set. */
1551 : 47486855 : tree old_target = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
1552 : 47486855 : if (old_target == NULL_TREE)
1553 : 5169 : old_target = target_option_default_node;
1554 : 47486855 : cl_target_option_restore (&func_options, &func_options_set,
1555 : 47486855 : TREE_TARGET_OPTION (old_target));
1556 : :
1557 : : /* FLAGS == 1 is used for target_clones attribute. */
1558 : 47486855 : new_target
1559 : 47486855 : = ix86_valid_target_attribute_tree (fndecl, args, &func_options,
1560 : : &func_options_set, flags == 1);
1561 : :
1562 : 47486855 : new_optimize = build_optimization_node (&func_options, &func_options_set);
1563 : :
1564 : 47486855 : if (new_target == error_mark_node)
1565 : : ret = false;
1566 : :
1567 : 47486731 : else if (new_target)
1568 : : {
1569 : 47486485 : if (DECL_FUNCTION_SPECIFIC_TARGET (fndecl) == NULL_TREE
1570 : 47486485 : && DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) == NULL_TREE)
1571 : : {
1572 : 4786 : target_attribute_cache[0] = copy_list (args);
1573 : 4786 : target_attribute_cache[1] = new_target;
1574 : 4786 : target_attribute_cache[2]
1575 : 9119 : = old_optimize != new_optimize ? new_optimize : NULL_TREE;
1576 : : }
1577 : :
1578 : 47486485 : DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = new_target;
1579 : :
1580 : 47486485 : if (old_optimize != new_optimize)
1581 : 15215 : DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) = new_optimize;
1582 : : }
1583 : :
1584 : : return ret;
1585 : : }
1586 : :
1587 : : const char *stringop_alg_names[] = {
1588 : : #define DEF_ALG(alg, name) #name,
1589 : : #include "stringop.def"
1590 : : #undef DEF_ALG
1591 : : };
1592 : :
1593 : : /* Parse parameter string passed to -mmemcpy-strategy= or -mmemset-strategy=.
1594 : : The string is of the following form (or comma separated list of it):
1595 : :
1596 : : strategy_alg:max_size:[align|noalign]
1597 : :
1598 : : where the full size range for the strategy is either [0, max_size] or
1599 : : [min_size, max_size], in which min_size is the max_size + 1 of the
1600 : : preceding range. The last size range must have max_size == -1.
1601 : :
1602 : : Examples:
1603 : :
1604 : : 1.
1605 : : -mmemcpy-strategy=libcall:-1:noalign
1606 : :
1607 : : this is equivalent to (for known size memcpy) -mstringop-strategy=libcall
1608 : :
1609 : :
1610 : : 2.
1611 : : -mmemset-strategy=rep_8byte:16:noalign,vector_loop:2048:align,libcall:-1:noalign
1612 : :
1613 : : This is to tell the compiler to use the following strategy for memset
1614 : : 1) when the expected size is between [1, 16], use rep_8byte strategy;
1615 : : 2) when the size is between [17, 2048], use vector_loop;
1616 : : 3) when the size is > 2048, use libcall. */
1617 : :
1618 : : struct stringop_size_range
1619 : : {
1620 : : int max;
1621 : : stringop_alg alg;
1622 : : bool noalign;
1623 : : };
1624 : :
1625 : : static void
1626 : 52 : ix86_parse_stringop_strategy_string (char *strategy_str, bool is_memset)
1627 : : {
1628 : 52 : const struct stringop_algs *default_algs;
1629 : 52 : stringop_size_range input_ranges[MAX_STRINGOP_ALGS];
1630 : 52 : char *curr_range_str, *next_range_str;
1631 : 52 : const char *opt = is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy=";
1632 : 52 : int i = 0, n = 0;
1633 : :
1634 : 52 : if (is_memset)
1635 : 34 : default_algs = &ix86_cost->memset[TARGET_64BIT != 0];
1636 : : else
1637 : 18 : default_algs = &ix86_cost->memcpy[TARGET_64BIT != 0];
1638 : :
1639 : 52 : curr_range_str = strategy_str;
1640 : :
1641 : 94 : do
1642 : : {
1643 : 94 : int maxs;
1644 : 94 : char alg_name[128];
1645 : 94 : char align[16];
1646 : 94 : next_range_str = strchr (curr_range_str, ',');
1647 : 94 : if (next_range_str)
1648 : 42 : *next_range_str++ = '\0';
1649 : :
1650 : 94 : if (sscanf (curr_range_str, "%20[^:]:%d:%10s", alg_name, &maxs,
1651 : : align) != 3)
1652 : : {
1653 : 0 : error ("wrong argument %qs to option %qs", curr_range_str, opt);
1654 : 1 : return;
1655 : : }
1656 : :
1657 : 94 : if (n > 0 && (maxs < (input_ranges[n - 1].max + 1) && maxs != -1))
1658 : : {
1659 : 0 : error ("size ranges of option %qs should be increasing", opt);
1660 : 0 : return;
1661 : : }
1662 : :
1663 : 471 : for (i = 0; i < last_alg; i++)
1664 : 470 : if (!strcmp (alg_name, stringop_alg_names[i]))
1665 : : break;
1666 : :
1667 : 93 : if (i == last_alg)
1668 : : {
1669 : 1 : error ("wrong strategy name %qs specified for option %qs",
1670 : : alg_name, opt);
1671 : :
1672 : 1 : auto_vec <const char *> candidates;
1673 : 10 : for (i = 0; i < last_alg; i++)
1674 : 9 : if ((stringop_alg) i != rep_prefix_8_byte || TARGET_64BIT)
1675 : 9 : candidates.safe_push (stringop_alg_names[i]);
1676 : :
1677 : 1 : char *s;
1678 : 1 : const char *hint
1679 : 1 : = candidates_list_and_hint (alg_name, s, candidates);
1680 : 1 : if (hint)
1681 : 1 : inform (input_location,
1682 : : "valid arguments to %qs are: %s; did you mean %qs?",
1683 : : opt, s, hint);
1684 : : else
1685 : 0 : inform (input_location, "valid arguments to %qs are: %s",
1686 : : opt, s);
1687 : 1 : XDELETEVEC (s);
1688 : 1 : return;
1689 : 1 : }
1690 : :
1691 : 93 : if ((stringop_alg) i == rep_prefix_8_byte
1692 : 3 : && !TARGET_64BIT)
1693 : : {
1694 : : /* rep; movq isn't available in 32-bit code. */
1695 : 0 : error ("strategy name %qs specified for option %qs "
1696 : : "not supported for 32-bit code", alg_name, opt);
1697 : 0 : return;
1698 : : }
1699 : :
1700 : 93 : input_ranges[n].max = maxs;
1701 : 93 : input_ranges[n].alg = (stringop_alg) i;
1702 : 93 : if (!strcmp (align, "align"))
1703 : 18 : input_ranges[n].noalign = false;
1704 : 75 : else if (!strcmp (align, "noalign"))
1705 : 75 : input_ranges[n].noalign = true;
1706 : : else
1707 : : {
1708 : 0 : error ("unknown alignment %qs specified for option %qs", align, opt);
1709 : 0 : return;
1710 : : }
1711 : 93 : n++;
1712 : 93 : curr_range_str = next_range_str;
1713 : : }
1714 : 93 : while (curr_range_str);
1715 : :
1716 : 51 : if (input_ranges[n - 1].max != -1)
1717 : : {
1718 : 0 : error ("the max value for the last size range should be -1"
1719 : : " for option %qs", opt);
1720 : 0 : return;
1721 : : }
1722 : :
1723 : 51 : if (n > MAX_STRINGOP_ALGS)
1724 : : {
1725 : 0 : error ("too many size ranges specified in option %qs", opt);
1726 : 0 : return;
1727 : : }
1728 : :
1729 : : /* Now override the default algs array. */
1730 : 144 : for (i = 0; i < n; i++)
1731 : : {
1732 : 93 : *const_cast<int *>(&default_algs->size[i].max) = input_ranges[i].max;
1733 : 93 : *const_cast<stringop_alg *>(&default_algs->size[i].alg)
1734 : 93 : = input_ranges[i].alg;
1735 : 93 : *const_cast<int *>(&default_algs->size[i].noalign)
1736 : 93 : = input_ranges[i].noalign;
1737 : : }
1738 : : }
1739 : :
1740 : :
1741 : : /* parse -mtune-ctrl= option. When DUMP is true,
1742 : : print the features that are explicitly set. */
1743 : :
1744 : : static void
1745 : 48361251 : parse_mtune_ctrl_str (struct gcc_options *opts, bool dump)
1746 : : {
1747 : 48361251 : if (!opts->x_ix86_tune_ctrl_string)
1748 : : return;
1749 : :
1750 : 156012 : char *next_feature_string = NULL;
1751 : 156012 : char *curr_feature_string = xstrdup (opts->x_ix86_tune_ctrl_string);
1752 : 156012 : char *orig = curr_feature_string;
1753 : 156078 : int i;
1754 : 156078 : do
1755 : : {
1756 : 156078 : bool clear = false;
1757 : :
1758 : 156078 : next_feature_string = strchr (curr_feature_string, ',');
1759 : 156078 : if (next_feature_string)
1760 : 66 : *next_feature_string++ = '\0';
1761 : 156078 : if (*curr_feature_string == '^')
1762 : : {
1763 : 87 : curr_feature_string++;
1764 : 87 : clear = true;
1765 : : }
1766 : :
1767 : 156078 : if (!strcmp (curr_feature_string, "use_gather"))
1768 : : {
1769 : 97895 : ix86_tune_features[X86_TUNE_USE_GATHER_2PARTS] = !clear;
1770 : 97895 : ix86_tune_features[X86_TUNE_USE_GATHER_4PARTS] = !clear;
1771 : 97895 : ix86_tune_features[X86_TUNE_USE_GATHER_8PARTS] = !clear;
1772 : 97895 : if (dump)
1773 : 0 : fprintf (stderr, "Explicitly %s features use_gather_2parts,"
1774 : : " use_gather_4parts, use_gather_8parts\n",
1775 : : clear ? "clear" : "set");
1776 : :
1777 : : }
1778 : 58183 : else if (!strcmp (curr_feature_string, "use_scatter"))
1779 : : {
1780 : 0 : ix86_tune_features[X86_TUNE_USE_SCATTER_2PARTS] = !clear;
1781 : 0 : ix86_tune_features[X86_TUNE_USE_SCATTER_4PARTS] = !clear;
1782 : 0 : ix86_tune_features[X86_TUNE_USE_SCATTER_8PARTS] = !clear;
1783 : 0 : if (dump)
1784 : 0 : fprintf (stderr, "Explicitly %s features use_scatter_2parts,"
1785 : : " use_scatter_4parts, use_scatter_8parts\n",
1786 : : clear ? "clear" : "set");
1787 : : }
1788 : : else
1789 : : {
1790 : 1416959 : for (i = 0; i < X86_TUNE_LAST; i++)
1791 : : {
1792 : 1416959 : if (!strcmp (curr_feature_string, ix86_tune_feature_names[i]))
1793 : : {
1794 : 58183 : ix86_tune_features[i] = !clear;
1795 : 58183 : if (dump)
1796 : 0 : fprintf (stderr, "Explicitly %s feature %s\n",
1797 : : clear ? "clear" : "set", ix86_tune_feature_names[i]);
1798 : : break;
1799 : : }
1800 : : }
1801 : :
1802 : 58183 : if (i == X86_TUNE_LAST)
1803 : 0 : error ("unknown parameter to option %<-mtune-ctrl%>: %s",
1804 : : clear ? curr_feature_string - 1 : curr_feature_string);
1805 : : }
1806 : 156078 : curr_feature_string = next_feature_string;
1807 : : }
1808 : 156078 : while (curr_feature_string);
1809 : 156012 : free (orig);
1810 : : }
1811 : :
1812 : : /* Helper function to set ix86_tune_features. IX86_TUNE is the
1813 : : processor type. */
1814 : :
1815 : : static void
1816 : 48361251 : set_ix86_tune_features (struct gcc_options *opts,
1817 : : enum processor_type ix86_tune, bool dump)
1818 : : {
1819 : 48361251 : unsigned HOST_WIDE_INT ix86_tune_mask = HOST_WIDE_INT_1U << ix86_tune;
1820 : 48361251 : int i;
1821 : :
1822 : 5900072622 : for (i = 0; i < X86_TUNE_LAST; ++i)
1823 : : {
1824 : 5851711371 : if (ix86_tune_no_default)
1825 : 0 : ix86_tune_features[i] = 0;
1826 : : else
1827 : 5851711371 : ix86_tune_features[i]
1828 : 5851711371 : = !!(initial_ix86_tune_features[i] & ix86_tune_mask);
1829 : : }
1830 : :
1831 : 48361251 : if (dump)
1832 : : {
1833 : 0 : fprintf (stderr, "List of x86 specific tuning parameter names:\n");
1834 : 0 : for (i = 0; i < X86_TUNE_LAST; i++)
1835 : 0 : fprintf (stderr, "%s : %s\n", ix86_tune_feature_names[i],
1836 : 0 : ix86_tune_features[i] ? "on" : "off");
1837 : : }
1838 : :
1839 : 48361251 : parse_mtune_ctrl_str (opts, dump);
1840 : 48361251 : }
1841 : :
1842 : :
1843 : : /* Default align_* from the processor table. */
1844 : :
1845 : : static void
1846 : 100393337 : ix86_default_align (struct gcc_options *opts)
1847 : : {
1848 : : /* -falign-foo without argument: supply one. */
1849 : 100393337 : if (opts->x_flag_align_loops && !opts->x_str_align_loops)
1850 : 131466 : opts->x_str_align_loops = processor_cost_table[ix86_tune]->align_loop;
1851 : 100393337 : if (opts->x_flag_align_jumps && !opts->x_str_align_jumps)
1852 : 131467 : opts->x_str_align_jumps = processor_cost_table[ix86_tune]->align_jump;
1853 : 100393337 : if (opts->x_flag_align_labels && !opts->x_str_align_labels)
1854 : 131467 : opts->x_str_align_labels = processor_cost_table[ix86_tune]->align_label;
1855 : 100393337 : if (opts->x_flag_align_functions && !opts->x_str_align_functions)
1856 : 131462 : opts->x_str_align_functions = processor_cost_table[ix86_tune]->align_func;
1857 : 100393337 : }
1858 : :
1859 : : #ifndef USE_IX86_FRAME_POINTER
1860 : : #define USE_IX86_FRAME_POINTER 0
1861 : : #endif
1862 : :
1863 : : /* (Re)compute option overrides affected by optimization levels in
1864 : : target-specific ways. */
1865 : :
1866 : : static void
1867 : 100393337 : ix86_recompute_optlev_based_flags (struct gcc_options *opts,
1868 : : struct gcc_options *opts_set)
1869 : : {
1870 : : /* Set the default values for switches whose default depends on TARGET_64BIT
1871 : : in case they weren't overwritten by command line options. */
1872 : 100393337 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
1873 : : {
1874 : 98460831 : if (opts->x_optimize >= 1)
1875 : 94521613 : SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer,
1876 : : !USE_IX86_FRAME_POINTER);
1877 : 98460831 : if (opts->x_flag_asynchronous_unwind_tables
1878 : 98460831 : && TARGET_64BIT_MS_ABI)
1879 : 272696 : SET_OPTION_IF_UNSET (opts, opts_set, flag_unwind_tables, 1);
1880 : 98460831 : if (opts->x_flag_asynchronous_unwind_tables == 2)
1881 : 282085 : opts->x_flag_unwind_tables
1882 : 282085 : = opts->x_flag_asynchronous_unwind_tables = 1;
1883 : 98460831 : if (opts->x_flag_pcc_struct_return == 2)
1884 : 282164 : opts->x_flag_pcc_struct_return = 0;
1885 : : }
1886 : : else
1887 : : {
1888 : 1932506 : if (opts->x_optimize >= 1)
1889 : 1932004 : SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer,
1890 : : !(USE_IX86_FRAME_POINTER || opts->x_optimize_size));
1891 : 1932506 : if (opts->x_flag_asynchronous_unwind_tables == 2)
1892 : 7116 : opts->x_flag_asynchronous_unwind_tables = !USE_IX86_FRAME_POINTER;
1893 : 1932506 : if (opts->x_flag_pcc_struct_return == 2)
1894 : : {
1895 : : /* Intel MCU psABI specifies that -freg-struct-return should
1896 : : be on. Instead of setting DEFAULT_PCC_STRUCT_RETURN to 0,
1897 : : we check -miamcu so that -freg-struct-return is always
1898 : : turned on if -miamcu is used. */
1899 : 7122 : if (TARGET_IAMCU_P (opts->x_target_flags))
1900 : 0 : opts->x_flag_pcc_struct_return = 0;
1901 : : else
1902 : 7122 : opts->x_flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
1903 : : }
1904 : : }
1905 : :
1906 : : /* Keep nonleaf frame pointers. */
1907 : 100393337 : if (opts->x_flag_omit_frame_pointer)
1908 : 95964853 : opts->x_target_flags &= ~MASK_OMIT_LEAF_FRAME_POINTER;
1909 : 4428484 : else if (TARGET_OMIT_LEAF_FRAME_POINTER_P (opts->x_target_flags))
1910 : 0 : opts->x_flag_omit_frame_pointer = 1;
1911 : 100393337 : }
1912 : :
1913 : : /* Implement part of TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */
1914 : :
1915 : : static void
1916 : 100393337 : ix86_override_options_after_change_1 (struct gcc_options *opts,
1917 : : struct gcc_options *opts_set)
1918 : : {
1919 : : #define OPTS_SET_P(OPTION) opts_set->x_ ## OPTION
1920 : : #define OPTS(OPTION) opts->x_ ## OPTION
1921 : :
1922 : : /* Disable unrolling small loops when there's explicit
1923 : : -f{,no}unroll-loop. */
1924 : 100393337 : if ((OPTS_SET_P (flag_unroll_loops))
1925 : 99674456 : || (OPTS_SET_P (flag_unroll_all_loops)
1926 : 126 : && OPTS (flag_unroll_all_loops)))
1927 : : {
1928 : 719007 : if (!OPTS_SET_P (ix86_unroll_only_small_loops))
1929 : 719007 : OPTS (ix86_unroll_only_small_loops) = 0;
1930 : : /* Re-enable -frename-registers and -fweb if funroll-loops
1931 : : enabled. */
1932 : 719007 : if (!OPTS_SET_P (flag_web))
1933 : 718999 : OPTS (flag_web) = OPTS (flag_unroll_loops);
1934 : 719007 : if (!OPTS_SET_P (flag_rename_registers))
1935 : 719005 : OPTS (flag_rename_registers) = OPTS (flag_unroll_loops);
1936 : : /* -fcunroll-grow-size default follws -f[no]-unroll-loops. */
1937 : 719007 : if (!OPTS_SET_P (flag_cunroll_grow_size))
1938 : 719007 : OPTS (flag_cunroll_grow_size)
1939 : 1438014 : = (OPTS (flag_unroll_loops)
1940 : 44 : || OPTS (flag_peel_loops)
1941 : 1438014 : || OPTS (optimize) >= 3);
1942 : : }
1943 : : else
1944 : : {
1945 : 99674330 : if (!OPTS_SET_P (flag_cunroll_grow_size))
1946 : 99674330 : OPTS (flag_cunroll_grow_size)
1947 : 199348660 : = (OPTS (flag_peel_loops)
1948 : 103729799 : || OPTS (optimize) >= 3);
1949 : : }
1950 : :
1951 : : #undef OPTS
1952 : : #undef OPTS_SET_P
1953 : 100393337 : }
1954 : :
1955 : : /* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */
1956 : :
1957 : : void
1958 : 52065301 : ix86_override_options_after_change (void)
1959 : : {
1960 : 52065301 : ix86_default_align (&global_options);
1961 : :
1962 : 52065301 : ix86_recompute_optlev_based_flags (&global_options, &global_options_set);
1963 : :
1964 : 52065301 : ix86_override_options_after_change_1 (&global_options, &global_options_set);
1965 : 52065301 : }
1966 : :
1967 : : /* Clear stack slot assignments remembered from previous functions.
1968 : : This is called from INIT_EXPANDERS once before RTL is emitted for each
1969 : : function. */
1970 : :
1971 : : static struct machine_function *
1972 : 181627631 : ix86_init_machine_status (void)
1973 : : {
1974 : 181627631 : struct machine_function *f;
1975 : :
1976 : 181627631 : f = ggc_cleared_alloc<machine_function> ();
1977 : 181627631 : f->call_abi = ix86_abi;
1978 : 181627631 : f->stack_frame_required = true;
1979 : 181627631 : f->silent_p = true;
1980 : :
1981 : 181627631 : return f;
1982 : : }
1983 : :
1984 : : /* Override various settings based on options. If MAIN_ARGS_P, the
1985 : : options are from the command line, otherwise they are from
1986 : : attributes. Return true if there's an error related to march
1987 : : option. */
1988 : :
1989 : : static bool
1990 : 48328040 : ix86_option_override_internal (bool main_args_p,
1991 : : struct gcc_options *opts,
1992 : : struct gcc_options *opts_set)
1993 : : {
1994 : 48328040 : unsigned int i;
1995 : 48328040 : unsigned HOST_WIDE_INT ix86_arch_mask;
1996 : 48328040 : const bool ix86_tune_specified = (opts->x_ix86_tune_string != NULL);
1997 : :
1998 : : /* -mrecip options. */
1999 : 48328040 : static struct
2000 : : {
2001 : : const char *string; /* option name */
2002 : : unsigned int mask; /* mask bits to set */
2003 : : }
2004 : : const recip_options[] =
2005 : : {
2006 : : { "all", RECIP_MASK_ALL },
2007 : : { "none", RECIP_MASK_NONE },
2008 : : { "div", RECIP_MASK_DIV },
2009 : : { "sqrt", RECIP_MASK_SQRT },
2010 : : { "vec-div", RECIP_MASK_VEC_DIV },
2011 : : { "vec-sqrt", RECIP_MASK_VEC_SQRT },
2012 : : };
2013 : :
2014 : : /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
2015 : : TARGET_64BIT_DEFAULT is true and TARGET_64BIT is false. */
2016 : 48328040 : if (TARGET_64BIT_DEFAULT && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2017 : 610982 : opts->x_ix86_isa_flags &= ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
2018 : : #ifdef TARGET_BI_ARCH
2019 : : else
2020 : : {
2021 : : #if TARGET_BI_ARCH == 1
2022 : : /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ABI_64
2023 : : is on and OPTION_MASK_ABI_X32 is off. We turn off
2024 : : OPTION_MASK_ABI_64 if OPTION_MASK_ABI_X32 is turned on by
2025 : : -mx32. */
2026 : 47717058 : if (TARGET_X32_P (opts->x_ix86_isa_flags))
2027 : 107 : opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
2028 : : #else
2029 : : /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
2030 : : on and OPTION_MASK_ABI_64 is off. We turn off
2031 : : OPTION_MASK_ABI_X32 if OPTION_MASK_ABI_64 is turned on by
2032 : : -m64 or OPTION_MASK_CODE16 is turned on by -m16. */
2033 : : if (TARGET_LP64_P (opts->x_ix86_isa_flags)
2034 : : || TARGET_16BIT_P (opts->x_ix86_isa_flags))
2035 : : opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
2036 : : #endif
2037 : 47717058 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2038 : 47717058 : && TARGET_IAMCU_P (opts->x_target_flags))
2039 : 0 : sorry ("Intel MCU psABI isn%'t supported in %s mode",
2040 : : TARGET_X32_P (opts->x_ix86_isa_flags) ? "x32" : "64-bit");
2041 : : }
2042 : : #endif
2043 : :
2044 : 48328040 : if (TARGET_X32_P (opts->x_ix86_isa_flags))
2045 : : {
2046 : : /* Always turn on OPTION_MASK_ISA_64BIT and turn off
2047 : : OPTION_MASK_ABI_64 for TARGET_X32. */
2048 : 107 : opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
2049 : 107 : opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
2050 : : }
2051 : 48327933 : else if (TARGET_16BIT_P (opts->x_ix86_isa_flags))
2052 : 5 : opts->x_ix86_isa_flags &= ~(OPTION_MASK_ISA_64BIT
2053 : : | OPTION_MASK_ABI_X32
2054 : : | OPTION_MASK_ABI_64);
2055 : 48327928 : else if (TARGET_LP64_P (opts->x_ix86_isa_flags))
2056 : : {
2057 : : /* Always turn on OPTION_MASK_ISA_64BIT and turn off
2058 : : OPTION_MASK_ABI_X32 for TARGET_LP64. */
2059 : 47716946 : opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
2060 : 47716946 : opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
2061 : : }
2062 : :
2063 : : #ifdef SUBTARGET_OVERRIDE_OPTIONS
2064 : : SUBTARGET_OVERRIDE_OPTIONS;
2065 : : #endif
2066 : :
2067 : : #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
2068 : : SUBSUBTARGET_OVERRIDE_OPTIONS;
2069 : : #endif
2070 : :
2071 : : #ifdef HAVE_LD_BROKEN_PE_DWARF5
2072 : : /* If the PE linker has broken DWARF 5 support, make
2073 : : DWARF 4 the default. */
2074 : : if (TARGET_PECOFF)
2075 : : SET_OPTION_IF_UNSET (opts, opts_set, dwarf_version, 4);
2076 : : #endif
2077 : :
2078 : : /* -fPIC is the default for x86_64. */
2079 : 48328040 : if (TARGET_MACHO && TARGET_64BIT_P (opts->x_ix86_isa_flags))
2080 : : opts->x_flag_pic = 2;
2081 : :
2082 : : /* Need to check -mtune=generic first. */
2083 : 48328040 : if (opts->x_ix86_tune_string)
2084 : : {
2085 : : /* As special support for cross compilers we read -mtune=native
2086 : : as -mtune=generic. With native compilers we won't see the
2087 : : -mtune=native, as it was changed by the driver. */
2088 : 48306812 : if (!strcmp (opts->x_ix86_tune_string, "native"))
2089 : 0 : opts->x_ix86_tune_string = "generic";
2090 : 48306812 : else if (!strcmp (opts->x_ix86_tune_string, "x86-64"))
2091 : 0 : warning (OPT_Wdeprecated,
2092 : : main_args_p
2093 : : ? G_("%<-mtune=x86-64%> is deprecated; use %<-mtune=k8%> "
2094 : : "or %<-mtune=generic%> instead as appropriate")
2095 : : : G_("%<target(\"tune=x86-64\")%> is deprecated; use "
2096 : : "%<target(\"tune=k8\")%> or %<target(\"tune=generic\")%>"
2097 : : " instead as appropriate"));
2098 : : }
2099 : : else
2100 : : {
2101 : 21228 : if (opts->x_ix86_arch_string)
2102 : 21228 : opts->x_ix86_tune_string = opts->x_ix86_arch_string;
2103 : 21228 : if (!opts->x_ix86_tune_string)
2104 : : {
2105 : 0 : opts->x_ix86_tune_string = processor_names[TARGET_CPU_DEFAULT];
2106 : 0 : ix86_tune_defaulted = 1;
2107 : : }
2108 : :
2109 : : /* opts->x_ix86_tune_string is set to opts->x_ix86_arch_string
2110 : : or defaulted. We need to use a sensible tune option. */
2111 : 21228 : if (startswith (opts->x_ix86_tune_string, "x86-64")
2112 : 21228 : && (opts->x_ix86_tune_string[6] == '\0'
2113 : 371 : || (!strcmp (opts->x_ix86_tune_string + 6, "-v2")
2114 : 331 : || !strcmp (opts->x_ix86_tune_string + 6, "-v3")
2115 : 129 : || !strcmp (opts->x_ix86_tune_string + 6, "-v4"))))
2116 : 563 : opts->x_ix86_tune_string = "generic";
2117 : : }
2118 : :
2119 : 48328040 : if (opts->x_ix86_stringop_alg == rep_prefix_8_byte
2120 : 10 : && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2121 : : {
2122 : : /* rep; movq isn't available in 32-bit code. */
2123 : 0 : error ("%<-mstringop-strategy=rep_8byte%> not supported for 32-bit code");
2124 : 0 : opts->x_ix86_stringop_alg = no_stringop;
2125 : : }
2126 : :
2127 : 48328040 : if (TARGET_APX_F_P (opts->x_ix86_isa_flags2)
2128 : 32194 : && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2129 : 0 : error ("%<-mapxf%> is not supported for 32-bit code");
2130 : 48328040 : else if (opts->x_ix86_apx_features != apx_none
2131 : 32208 : && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2132 : 0 : error ("%<-mapx-features=%> option is not supported for 32-bit code");
2133 : :
2134 : 48328040 : if (TARGET_UINTR_P (opts->x_ix86_isa_flags2)
2135 : 81523 : && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2136 : 0 : error ("%<-muintr%> not supported for 32-bit code");
2137 : :
2138 : 48328040 : if (ix86_lam_type && !TARGET_LP64_P (opts->x_ix86_isa_flags))
2139 : 0 : error ("%<-mlam=%> option: [u48|u57] not supported for 32-bit code");
2140 : :
2141 : 48328040 : if (!opts->x_ix86_arch_string)
2142 : 0 : opts->x_ix86_arch_string
2143 : 0 : = TARGET_64BIT_P (opts->x_ix86_isa_flags)
2144 : 0 : ? "x86-64" : SUBTARGET32_DEFAULT_CPU;
2145 : : else
2146 : 48328040 : ix86_arch_specified = 1;
2147 : :
2148 : 48328040 : if (opts_set->x_ix86_pmode)
2149 : : {
2150 : 67 : if ((TARGET_LP64_P (opts->x_ix86_isa_flags)
2151 : 0 : && opts->x_ix86_pmode == PMODE_SI)
2152 : 67 : || (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
2153 : 0 : && opts->x_ix86_pmode == PMODE_DI))
2154 : 0 : error ("address mode %qs not supported in the %s bit mode",
2155 : : TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "short" : "long",
2156 : : TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "64" : "32");
2157 : : }
2158 : : else
2159 : 48327973 : opts->x_ix86_pmode = TARGET_LP64_P (opts->x_ix86_isa_flags)
2160 : 48327973 : ? PMODE_DI : PMODE_SI;
2161 : :
2162 : 48328040 : SET_OPTION_IF_UNSET (opts, opts_set, ix86_abi, DEFAULT_ABI);
2163 : :
2164 : 48328040 : if (opts->x_ix86_abi == MS_ABI && TARGET_X32_P (opts->x_ix86_isa_flags))
2165 : 1 : error ("%<-mabi=ms%> not supported with X32 ABI");
2166 : 48328040 : gcc_assert (opts->x_ix86_abi == SYSV_ABI || opts->x_ix86_abi == MS_ABI);
2167 : :
2168 : 48328040 : const char *abi_name = opts->x_ix86_abi == MS_ABI ? "ms" : "sysv";
2169 : 48328040 : if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS)
2170 : 2996 : && opts->x_ix86_abi != DEFAULT_ABI)
2171 : 7 : error ("%<-mabi=%s%> not supported with %<-fsanitize=address%>", abi_name);
2172 : 48328040 : if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS)
2173 : 141 : && opts->x_ix86_abi != DEFAULT_ABI)
2174 : 0 : error ("%<-mabi=%s%> not supported with %<-fsanitize=kernel-address%>",
2175 : : abi_name);
2176 : 48328040 : if ((opts->x_flag_sanitize & SANITIZE_THREAD)
2177 : 355 : && opts->x_ix86_abi != DEFAULT_ABI)
2178 : 2 : error ("%<-mabi=%s%> not supported with %<-fsanitize=thread%>", abi_name);
2179 : :
2180 : : /* Hwasan is supported with lam_u57 only. */
2181 : 48328040 : if (opts->x_flag_sanitize & SANITIZE_HWADDRESS)
2182 : : {
2183 : 523 : if (ix86_lam_type == lam_u48)
2184 : 0 : warning (0, "%<-mlam=u48%> is not compatible with Hardware-assisted "
2185 : : "AddressSanitizer, override to %<-mlam=u57%>");
2186 : 523 : ix86_lam_type = lam_u57;
2187 : : }
2188 : :
2189 : : /* For targets using ms ABI enable ms-extensions, if not
2190 : : explicit turned off. For non-ms ABI we turn off this
2191 : : option. */
2192 : 48328040 : SET_OPTION_IF_UNSET (opts, opts_set, flag_ms_extensions,
2193 : : (MS_ABI == DEFAULT_ABI));
2194 : :
2195 : 48328040 : if (opts_set->x_ix86_cmodel)
2196 : : {
2197 : 35471 : switch (opts->x_ix86_cmodel)
2198 : : {
2199 : 1 : case CM_SMALL:
2200 : 1 : case CM_SMALL_PIC:
2201 : 1 : if (opts->x_flag_pic)
2202 : 0 : opts->x_ix86_cmodel = CM_SMALL_PIC;
2203 : 1 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2204 : 0 : error ("code model %qs not supported in the %s bit mode",
2205 : : "small", "32");
2206 : : break;
2207 : :
2208 : 22387 : case CM_MEDIUM:
2209 : 22387 : case CM_MEDIUM_PIC:
2210 : 22387 : if (opts->x_flag_pic)
2211 : 22375 : opts->x_ix86_cmodel = CM_MEDIUM_PIC;
2212 : 22387 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2213 : 0 : error ("code model %qs not supported in the %s bit mode",
2214 : : "medium", "32");
2215 : 22387 : else if (TARGET_X32_P (opts->x_ix86_isa_flags))
2216 : 0 : error ("code model %qs not supported in x32 mode",
2217 : : "medium");
2218 : : break;
2219 : :
2220 : 13082 : case CM_LARGE:
2221 : 13082 : case CM_LARGE_PIC:
2222 : 13082 : if (opts->x_flag_pic)
2223 : 28 : opts->x_ix86_cmodel = CM_LARGE_PIC;
2224 : 13082 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2225 : 0 : error ("code model %qs not supported in the %s bit mode",
2226 : : "large", "32");
2227 : 13082 : else if (TARGET_X32_P (opts->x_ix86_isa_flags))
2228 : 0 : error ("code model %qs not supported in x32 mode",
2229 : : "large");
2230 : : break;
2231 : :
2232 : 0 : case CM_32:
2233 : 0 : if (opts->x_flag_pic)
2234 : 0 : error ("code model %s does not support PIC mode", "32");
2235 : 0 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2236 : 0 : error ("code model %qs not supported in the %s bit mode",
2237 : : "32", "64");
2238 : : break;
2239 : :
2240 : 1 : case CM_KERNEL:
2241 : 1 : if (opts->x_flag_pic)
2242 : : {
2243 : 0 : error ("code model %s does not support PIC mode", "kernel");
2244 : 0 : opts->x_ix86_cmodel = CM_32;
2245 : : }
2246 : 1 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2247 : 0 : error ("code model %qs not supported in the %s bit mode",
2248 : : "kernel", "32");
2249 : : break;
2250 : :
2251 : 0 : default:
2252 : 0 : gcc_unreachable ();
2253 : : }
2254 : : }
2255 : : else
2256 : : {
2257 : : /* For TARGET_64BIT and MS_ABI, force pic on, in order to enable the
2258 : : use of rip-relative addressing. This eliminates fixups that
2259 : : would otherwise be needed if this object is to be placed in a
2260 : : DLL, and is essentially just as efficient as direct addressing. */
2261 : 48292569 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2262 : : && (TARGET_RDOS || TARGET_PECOFF))
2263 : : opts->x_ix86_cmodel = CM_MEDIUM_PIC, opts->x_flag_pic = 1;
2264 : 48292569 : else if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2265 : 95021367 : opts->x_ix86_cmodel = opts->x_flag_pic ? CM_SMALL_PIC : CM_SMALL;
2266 : : else
2267 : 610987 : opts->x_ix86_cmodel = CM_32;
2268 : : }
2269 : 48328040 : if (TARGET_MACHO && opts->x_ix86_asm_dialect == ASM_INTEL)
2270 : : {
2271 : : error ("%<-masm=intel%> not supported in this configuration");
2272 : : opts->x_ix86_asm_dialect = ASM_ATT;
2273 : : }
2274 : 48328040 : if ((TARGET_64BIT_P (opts->x_ix86_isa_flags) != 0)
2275 : : != ((opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) != 0))
2276 : : sorry ("%i-bit mode not compiled in",
2277 : : (opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) ? 64 : 32);
2278 : :
2279 : : /* Last processor_alias_table must point to "generic" entry. */
2280 : 48328040 : gcc_checking_assert (strcmp (processor_alias_table[pta_size - 1].name,
2281 : : "generic") == 0);
2282 : 3853838244 : for (i = 0; i < pta_size; i++)
2283 : 3853838213 : if (! strcmp (opts->x_ix86_arch_string, processor_alias_table[i].name))
2284 : : {
2285 : 48328009 : if (!strcmp (opts->x_ix86_arch_string, "generic"))
2286 : : {
2287 : 2 : error (main_args_p
2288 : : ? G_("%<generic%> CPU can be used only for %<-mtune=%> "
2289 : : "switch")
2290 : : : G_("%<generic%> CPU can be used only for "
2291 : : "%<target(\"tune=\")%> attribute"));
2292 : 2 : return false;
2293 : : }
2294 : 48328007 : else if (!strcmp (opts->x_ix86_arch_string, "intel"))
2295 : : {
2296 : 1 : error (main_args_p
2297 : : ? G_("%<intel%> CPU can be used only for %<-mtune=%> "
2298 : : "switch")
2299 : : : G_("%<intel%> CPU can be used only for "
2300 : : "%<target(\"tune=\")%> attribute"));
2301 : 1 : return false;
2302 : : }
2303 : :
2304 : 48328006 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2305 : 48328006 : && !((processor_alias_table[i].flags & PTA_64BIT) != 0))
2306 : : {
2307 : 1 : error ("CPU you selected does not support x86-64 "
2308 : : "instruction set");
2309 : 1 : return false;
2310 : : }
2311 : :
2312 : 48328005 : ix86_schedule = processor_alias_table[i].schedule;
2313 : 48328005 : ix86_arch = processor_alias_table[i].processor;
2314 : :
2315 : : /* Default cpu tuning to the architecture, unless the table
2316 : : entry requests not to do this. Used by the x86-64 psABI
2317 : : micro-architecture levels. */
2318 : 48328005 : if ((processor_alias_table[i].flags & PTA_NO_TUNE) == 0)
2319 : 48000221 : ix86_tune = ix86_arch;
2320 : : else
2321 : 327784 : ix86_tune = PROCESSOR_GENERIC;
2322 : :
2323 : : /* Enable PTA flags that are enabled by default by a -march option. */
2324 : : #define TARGET_EXPLICIT_NO_SAHF_P(opts) (false)
2325 : : #define SET_TARGET_NO_SAHF(opts) {}
2326 : : #define TARGET_EXPLICIT_PREFETCH_SSE_P(opts) (false)
2327 : : #define SET_TARGET_PREFETCH_SSE(opts) {}
2328 : : #define TARGET_EXPLICIT_NO_TUNE_P(opts) (false)
2329 : : #define SET_TARGET_NO_TUNE(opts) {}
2330 : : #define TARGET_EXPLICIT_NO_80387_P(opts) (false)
2331 : : #define SET_TARGET_NO_80387(opts) {}
2332 : :
2333 : : #define DEF_PTA(NAME) \
2334 : : if (((processor_alias_table[i].flags & PTA_ ## NAME) != 0) \
2335 : : && PTA_ ## NAME != PTA_64BIT \
2336 : : && (TARGET_64BIT || (PTA_ ## NAME != PTA_UINTR \
2337 : : && PTA_ ## NAME != PTA_APX_F))\
2338 : : && !TARGET_EXPLICIT_ ## NAME ## _P (opts)) \
2339 : : SET_TARGET_ ## NAME (opts);
2340 : : #include "i386-isa.def"
2341 : : #undef DEF_PTA
2342 : :
2343 : :
2344 : 48328005 : if (!(TARGET_64BIT_P (opts->x_ix86_isa_flags)
2345 : 47717018 : && ((processor_alias_table[i].flags & PTA_NO_SAHF) != 0))
2346 : 49017175 : && !TARGET_EXPLICIT_SAHF_P (opts))
2347 : 1300146 : SET_TARGET_SAHF (opts);
2348 : :
2349 : 48328005 : if (((processor_alias_table[i].flags & PTA_ABM) != 0)
2350 : 5548 : && !TARGET_EXPLICIT_ABM_P (opts))
2351 : : {
2352 : 5537 : if (!TARGET_EXPLICIT_LZCNT_P (opts))
2353 : 5536 : SET_TARGET_LZCNT (opts);
2354 : 5537 : if (!TARGET_EXPLICIT_POPCNT_P (opts))
2355 : 5104 : SET_TARGET_POPCNT (opts);
2356 : : }
2357 : :
2358 : : /* Enable apx if apxf or apx_features are not
2359 : : explicitly set for -march. */
2360 : 48328005 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2361 : 47717018 : && ((processor_alias_table[i].flags & PTA_APX_F) != 0)
2362 : 173 : && !TARGET_EXPLICIT_APX_F_P (opts)
2363 : 48328178 : && !OPTION_SET_P (ix86_apx_features))
2364 : 173 : opts->x_ix86_apx_features = apx_all;
2365 : :
2366 : 48328005 : if ((processor_alias_table[i].flags
2367 : 48328005 : & (PTA_PREFETCH_SSE | PTA_SSE)) != 0)
2368 : 48328005 : ix86_prefetch_sse = true;
2369 : :
2370 : : /* Don't enable x87 instructions if only general registers are
2371 : : allowed by target("general-regs-only") function attribute or
2372 : : -mgeneral-regs-only. */
2373 : 48328005 : if (!(opts->x_ix86_target_flags & OPTION_MASK_GENERAL_REGS_ONLY)
2374 : 46088886 : && !(opts_set->x_target_flags & MASK_80387))
2375 : : {
2376 : 46088856 : if (((processor_alias_table[i].flags & PTA_NO_80387) != 0))
2377 : 0 : opts->x_target_flags &= ~MASK_80387;
2378 : : else
2379 : 46088856 : opts->x_target_flags |= MASK_80387;
2380 : : }
2381 : : break;
2382 : : }
2383 : :
2384 : 48328036 : if (i == pta_size)
2385 : : {
2386 : 33 : error (main_args_p
2387 : : ? G_("bad value %qs for %<-march=%> switch")
2388 : : : G_("bad value %qs for %<target(\"arch=\")%> attribute"),
2389 : : opts->x_ix86_arch_string);
2390 : :
2391 : 31 : auto_vec <const char *> candidates;
2392 : 3596 : for (i = 0; i < pta_size; i++)
2393 : 3565 : if (strcmp (processor_alias_table[i].name, "generic")
2394 : 3534 : && strcmp (processor_alias_table[i].name, "intel")
2395 : 7068 : && (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
2396 : 6076 : || ((processor_alias_table[i].flags & PTA_64BIT) != 0)))
2397 : 2511 : candidates.safe_push (processor_alias_table[i].name);
2398 : :
2399 : : #ifdef HAVE_LOCAL_CPU_DETECT
2400 : : /* Add also "native" as possible value. */
2401 : 31 : candidates.safe_push ("native");
2402 : : #endif
2403 : :
2404 : 31 : char *s;
2405 : 31 : const char *hint
2406 : 31 : = candidates_list_and_hint (opts->x_ix86_arch_string, s, candidates);
2407 : 31 : if (hint)
2408 : 3 : inform (input_location,
2409 : : main_args_p
2410 : : ? G_("valid arguments to %<-march=%> switch are: "
2411 : : "%s; did you mean %qs?")
2412 : : : G_("valid arguments to %<target(\"arch=\")%> attribute are: "
2413 : : "%s; did you mean %qs?"), s, hint);
2414 : : else
2415 : 30 : inform (input_location,
2416 : : main_args_p
2417 : : ? G_("valid arguments to %<-march=%> switch are: %s")
2418 : : : G_("valid arguments to %<target(\"arch=\")%> attribute "
2419 : : "are: %s"), s);
2420 : 31 : XDELETEVEC (s);
2421 : 31 : }
2422 : :
2423 : 48328036 : ix86_arch_mask = HOST_WIDE_INT_1U << ix86_arch;
2424 : 289968216 : for (i = 0; i < X86_ARCH_LAST; ++i)
2425 : 241640180 : ix86_arch_features[i] = !!(initial_ix86_arch_features[i] & ix86_arch_mask);
2426 : :
2427 : 5506605700 : for (i = 0; i < pta_size; i++)
2428 : 5506605665 : if (! strcmp (opts->x_ix86_tune_string, processor_alias_table[i].name)
2429 : 5506605665 : && (processor_alias_table[i].flags & PTA_NO_TUNE) == 0)
2430 : : {
2431 : 48328001 : ix86_schedule = processor_alias_table[i].schedule;
2432 : 48328001 : ix86_tune = processor_alias_table[i].processor;
2433 : 48328001 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2434 : : {
2435 : 47717014 : if (!((processor_alias_table[i].flags & PTA_64BIT) != 0))
2436 : : {
2437 : 0 : if (ix86_tune_defaulted)
2438 : : {
2439 : 0 : opts->x_ix86_tune_string = "x86-64";
2440 : 0 : for (i = 0; i < pta_size; i++)
2441 : 0 : if (! strcmp (opts->x_ix86_tune_string,
2442 : 0 : processor_alias_table[i].name))
2443 : : break;
2444 : 0 : ix86_schedule = processor_alias_table[i].schedule;
2445 : 0 : ix86_tune = processor_alias_table[i].processor;
2446 : : }
2447 : : else
2448 : 0 : error ("CPU you selected does not support x86-64 "
2449 : : "instruction set");
2450 : : }
2451 : : }
2452 : : /* Intel CPUs have always interpreted SSE prefetch instructions as
2453 : : NOPs; so, we can enable SSE prefetch instructions even when
2454 : : -mtune (rather than -march) points us to a processor that has them.
2455 : : However, the VIA C3 gives a SIGILL, so we only do that for i686 and
2456 : : higher processors. */
2457 : 48328001 : if (TARGET_CMOV
2458 : 48328001 : && ((processor_alias_table[i].flags
2459 : 48328001 : & (PTA_PREFETCH_SSE | PTA_SSE)) != 0))
2460 : 779785 : ix86_prefetch_sse = true;
2461 : : break;
2462 : : }
2463 : :
2464 : 48328036 : if (ix86_tune_specified && i == pta_size)
2465 : : {
2466 : 32 : error (main_args_p
2467 : : ? G_("bad value %qs for %<-mtune=%> switch")
2468 : : : G_("bad value %qs for %<target(\"tune=\")%> attribute"),
2469 : : opts->x_ix86_tune_string);
2470 : :
2471 : 30 : auto_vec <const char *> candidates;
2472 : 3480 : for (i = 0; i < pta_size; i++)
2473 : 3450 : if ((!TARGET_64BIT_P (opts->x_ix86_isa_flags)
2474 : 3450 : || ((processor_alias_table[i].flags & PTA_64BIT) != 0))
2475 : 9300 : && (processor_alias_table[i].flags & PTA_NO_TUNE) == 0)
2476 : 2400 : candidates.safe_push (processor_alias_table[i].name);
2477 : :
2478 : : #ifdef HAVE_LOCAL_CPU_DETECT
2479 : : /* Add also "native" as possible value. */
2480 : 30 : candidates.safe_push ("native");
2481 : : #endif
2482 : :
2483 : 30 : char *s;
2484 : 30 : const char *hint
2485 : 30 : = candidates_list_and_hint (opts->x_ix86_tune_string, s, candidates);
2486 : 30 : if (hint)
2487 : 1 : inform (input_location,
2488 : : main_args_p
2489 : : ? G_("valid arguments to %<-mtune=%> switch are: "
2490 : : "%s; did you mean %qs?")
2491 : : : G_("valid arguments to %<target(\"tune=\")%> attribute are: "
2492 : : "%s; did you mean %qs?"), s, hint);
2493 : : else
2494 : 31 : inform (input_location,
2495 : : main_args_p
2496 : : ? G_("valid arguments to %<-mtune=%> switch are: %s")
2497 : : : G_("valid arguments to %<target(\"tune=\")%> attribute "
2498 : : "are: %s"), s);
2499 : 30 : XDELETEVEC (s);
2500 : 30 : }
2501 : :
2502 : 48328036 : set_ix86_tune_features (opts, ix86_tune, opts->x_ix86_dump_tunes);
2503 : :
2504 : 48328036 : ix86_recompute_optlev_based_flags (opts, opts_set);
2505 : :
2506 : 48328036 : ix86_override_options_after_change_1 (opts, opts_set);
2507 : :
2508 : 48328036 : ix86_tune_cost = processor_cost_table[ix86_tune];
2509 : : /* TODO: ix86_cost should be chosen at instruction or function granuality
2510 : : so for cold code we use size_cost even in !optimize_size compilation. */
2511 : 48328036 : if (opts->x_optimize_size)
2512 : 692724 : ix86_cost = &ix86_size_cost;
2513 : : else
2514 : 47635312 : ix86_cost = ix86_tune_cost;
2515 : :
2516 : : /* Arrange to set up i386_stack_locals for all functions. */
2517 : 48328036 : init_machine_status = ix86_init_machine_status;
2518 : :
2519 : : /* Override APX flag here if ISA bit is set. */
2520 : 48328036 : if (TARGET_APX_F_P (opts->x_ix86_isa_flags2)
2521 : 32367 : && !OPTION_SET_P (ix86_apx_features))
2522 : 32367 : opts->x_ix86_apx_features = apx_all;
2523 : :
2524 : : /* Validate -mregparm= value. */
2525 : 48328036 : if (opts_set->x_ix86_regparm)
2526 : : {
2527 : 0 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2528 : 0 : warning (0, "%<-mregparm%> is ignored in 64-bit mode");
2529 : 0 : else if (TARGET_IAMCU_P (opts->x_target_flags))
2530 : 0 : warning (0, "%<-mregparm%> is ignored for Intel MCU psABI");
2531 : 0 : if (opts->x_ix86_regparm > REGPARM_MAX)
2532 : : {
2533 : 0 : error ("%<-mregparm=%d%> is not between 0 and %d",
2534 : 0 : opts->x_ix86_regparm, REGPARM_MAX);
2535 : 0 : opts->x_ix86_regparm = 0;
2536 : : }
2537 : : }
2538 : 48328036 : if (TARGET_IAMCU_P (opts->x_target_flags)
2539 : 48328036 : || TARGET_64BIT_P (opts->x_ix86_isa_flags))
2540 : 95365574 : opts->x_ix86_regparm = REGPARM_MAX;
2541 : :
2542 : : /* Default align_* from the processor table. */
2543 : 48328036 : ix86_default_align (&global_options);
2544 : :
2545 : : /* Provide default for -mbranch-cost= value. */
2546 : 48328036 : SET_OPTION_IF_UNSET (opts, opts_set, ix86_branch_cost,
2547 : : ix86_tune_cost->branch_cost);
2548 : :
2549 : 48328036 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2550 : : {
2551 : 47717049 : opts->x_target_flags
2552 : 47717049 : |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
2553 : :
2554 : 47717049 : if (!ix86_arch_specified)
2555 : 0 : opts->x_ix86_isa_flags
2556 : 0 : |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
2557 : :
2558 : 47717049 : if (!TARGET_128BIT_LONG_DOUBLE_P (opts->x_target_flags))
2559 : 1 : error ("%<-m96bit-long-double%> is not compatible with this target");
2560 : :
2561 : 47717049 : if (TARGET_RTD_P (opts->x_target_flags))
2562 : 0 : warning (0,
2563 : : main_args_p
2564 : : ? G_("%<-mrtd%> is ignored in 64bit mode")
2565 : : : G_("%<target(\"rtd\")%> is ignored in 64bit mode"));
2566 : : }
2567 : : else
2568 : : {
2569 : 610987 : opts->x_target_flags
2570 : : |= TARGET_SUBTARGET32_DEFAULT & ~opts_set->x_target_flags;
2571 : :
2572 : 610987 : if (!ix86_arch_specified)
2573 : 610987 : opts->x_ix86_isa_flags
2574 : : |= TARGET_SUBTARGET32_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
2575 : :
2576 : : /* i386 ABI does not specify red zone. It still makes sense to use it
2577 : : when programmer takes care to stack from being destroyed. */
2578 : 610987 : if (!(opts_set->x_target_flags & MASK_NO_RED_ZONE))
2579 : 610987 : opts->x_target_flags |= MASK_NO_RED_ZONE;
2580 : : }
2581 : :
2582 : : /* If we're doing fast math, we don't care about comparison order
2583 : : wrt NaNs. This lets us use a shorter comparison sequence. */
2584 : 48328036 : if (opts->x_flag_finite_math_only)
2585 : 974783 : opts->x_target_flags &= ~MASK_IEEE_FP;
2586 : :
2587 : : /* If the architecture always has an FPU, turn off NO_FANCY_MATH_387,
2588 : : since the insns won't need emulation. */
2589 : 48328036 : if (ix86_tune_features [X86_TUNE_ALWAYS_FANCY_MATH_387])
2590 : 48328036 : opts->x_target_flags &= ~MASK_NO_FANCY_MATH_387;
2591 : :
2592 : : /* Likewise, if the target doesn't have a 387, or we've specified
2593 : : software floating point, don't use 387 inline intrinsics. */
2594 : 48328036 : if (!TARGET_80387_P (opts->x_target_flags))
2595 : 2239141 : opts->x_target_flags |= MASK_NO_FANCY_MATH_387;
2596 : :
2597 : : /* Turn on MMX builtins for -msse. */
2598 : 48328036 : if (TARGET_SSE_P (opts->x_ix86_isa_flags))
2599 : 46147081 : opts->x_ix86_isa_flags
2600 : 46147081 : |= OPTION_MASK_ISA_MMX & ~opts->x_ix86_isa_flags_explicit;
2601 : :
2602 : : /* Enable SSE prefetch. */
2603 : 48328036 : if (TARGET_SSE_P (opts->x_ix86_isa_flags)
2604 : 2180955 : || (TARGET_PRFCHW_P (opts->x_ix86_isa_flags)
2605 : 18326 : && !TARGET_3DNOW_P (opts->x_ix86_isa_flags)))
2606 : 46165407 : ix86_prefetch_sse = true;
2607 : :
2608 : : /* Enable mwait/monitor instructions for -msse3. */
2609 : 48328036 : if (TARGET_SSE3_P (opts->x_ix86_isa_flags))
2610 : 45798786 : opts->x_ix86_isa_flags2
2611 : 45798786 : |= OPTION_MASK_ISA2_MWAIT & ~opts->x_ix86_isa_flags2_explicit;
2612 : :
2613 : : /* Enable popcnt instruction for -msse4.2 or -mabm. */
2614 : 48328036 : if (TARGET_SSE4_2_P (opts->x_ix86_isa_flags)
2615 : 2633481 : || TARGET_ABM_P (opts->x_ix86_isa_flags))
2616 : 45700632 : opts->x_ix86_isa_flags
2617 : 45700632 : |= OPTION_MASK_ISA_POPCNT & ~opts->x_ix86_isa_flags_explicit;
2618 : :
2619 : : /* Enable crc32 instruction for -msse4.2. */
2620 : 48328036 : if (TARGET_SSE4_2_P (opts->x_ix86_isa_flags))
2621 : 45694555 : opts->x_ix86_isa_flags
2622 : 45694555 : |= OPTION_MASK_ISA_CRC32 & ~opts->x_ix86_isa_flags_explicit;
2623 : :
2624 : : /* Enable lzcnt instruction for -mabm. */
2625 : 48328036 : if (TARGET_ABM_P(opts->x_ix86_isa_flags))
2626 : 67858 : opts->x_ix86_isa_flags
2627 : 67858 : |= OPTION_MASK_ISA_LZCNT & ~opts->x_ix86_isa_flags_explicit;
2628 : :
2629 : : /* Disable BMI, BMI2 and TBM instructions for -m16. */
2630 : 48328036 : if (TARGET_16BIT_P(opts->x_ix86_isa_flags))
2631 : 5 : opts->x_ix86_isa_flags
2632 : 5 : &= ~((OPTION_MASK_ISA_BMI | OPTION_MASK_ISA_BMI2 | OPTION_MASK_ISA_TBM)
2633 : 5 : & ~opts->x_ix86_isa_flags_explicit);
2634 : :
2635 : : /* Validate -mpreferred-stack-boundary= value or default it to
2636 : : PREFERRED_STACK_BOUNDARY_DEFAULT. */
2637 : 48328036 : ix86_preferred_stack_boundary = PREFERRED_STACK_BOUNDARY_DEFAULT;
2638 : 48328036 : if (opts_set->x_ix86_preferred_stack_boundary_arg)
2639 : : {
2640 : 1616 : int min = TARGET_64BIT_P (opts->x_ix86_isa_flags)? 3 : 2;
2641 : 1616 : int max = TARGET_SEH ? 4 : 12;
2642 : :
2643 : 1616 : if (opts->x_ix86_preferred_stack_boundary_arg < min
2644 : 1616 : || opts->x_ix86_preferred_stack_boundary_arg > max)
2645 : : {
2646 : 0 : if (min == max)
2647 : : error ("%<-mpreferred-stack-boundary%> is not supported "
2648 : : "for this target");
2649 : : else
2650 : 0 : error ("%<-mpreferred-stack-boundary=%d%> is not between %d and %d",
2651 : : opts->x_ix86_preferred_stack_boundary_arg, min, max);
2652 : : }
2653 : : else
2654 : 1616 : ix86_preferred_stack_boundary
2655 : 1616 : = (1 << opts->x_ix86_preferred_stack_boundary_arg) * BITS_PER_UNIT;
2656 : : }
2657 : :
2658 : : /* Set the default value for -mstackrealign. */
2659 : 48328036 : SET_OPTION_IF_UNSET (opts, opts_set, ix86_force_align_arg_pointer,
2660 : : STACK_REALIGN_DEFAULT);
2661 : :
2662 : 48328036 : ix86_default_incoming_stack_boundary = PREFERRED_STACK_BOUNDARY;
2663 : :
2664 : : /* Validate -mincoming-stack-boundary= value or default it to
2665 : : MIN_STACK_BOUNDARY/PREFERRED_STACK_BOUNDARY. */
2666 : 48328036 : ix86_incoming_stack_boundary = ix86_default_incoming_stack_boundary;
2667 : 48328036 : if (opts_set->x_ix86_incoming_stack_boundary_arg)
2668 : : {
2669 : 15 : int min = TARGET_64BIT_P (opts->x_ix86_isa_flags) ? 3 : 2;
2670 : :
2671 : 15 : if (opts->x_ix86_incoming_stack_boundary_arg < min
2672 : 15 : || opts->x_ix86_incoming_stack_boundary_arg > 12)
2673 : 0 : error ("%<-mincoming-stack-boundary=%d%> is not between %d and 12",
2674 : : opts->x_ix86_incoming_stack_boundary_arg, min);
2675 : : else
2676 : : {
2677 : 15 : ix86_user_incoming_stack_boundary
2678 : 15 : = (1 << opts->x_ix86_incoming_stack_boundary_arg) * BITS_PER_UNIT;
2679 : 15 : ix86_incoming_stack_boundary
2680 : 15 : = ix86_user_incoming_stack_boundary;
2681 : : }
2682 : : }
2683 : :
2684 : : #ifndef NO_PROFILE_COUNTERS
2685 : : if (flag_nop_mcount)
2686 : : error ("%<-mnop-mcount%> is not compatible with this target");
2687 : : #endif
2688 : 48328036 : if (flag_nop_mcount && flag_pic && !flag_plt)
2689 : 0 : error ("%<-mnop-mcount%> is not implemented for %<-fno-plt%>");
2690 : :
2691 : : /* Accept -msseregparm only if at least SSE support is enabled. */
2692 : 48328036 : if (TARGET_SSEREGPARM_P (opts->x_target_flags)
2693 : 0 : && ! TARGET_SSE_P (opts->x_ix86_isa_flags))
2694 : 0 : error (main_args_p
2695 : : ? G_("%<-msseregparm%> used without SSE enabled")
2696 : : : G_("%<target(\"sseregparm\")%> used without SSE enabled"));
2697 : :
2698 : 48328036 : if (opts_set->x_ix86_fpmath)
2699 : : {
2700 : 1300897 : if (opts->x_ix86_fpmath & FPMATH_SSE)
2701 : : {
2702 : 1258379 : if (!TARGET_SSE_P (opts->x_ix86_isa_flags))
2703 : : {
2704 : 45559 : if (TARGET_80387_P (opts->x_target_flags))
2705 : : {
2706 : 0 : warning (0, "SSE instruction set disabled, using 387 arithmetics");
2707 : 0 : opts->x_ix86_fpmath = FPMATH_387;
2708 : : }
2709 : : }
2710 : 1212820 : else if ((opts->x_ix86_fpmath & FPMATH_387)
2711 : 89 : && !TARGET_80387_P (opts->x_target_flags))
2712 : : {
2713 : 0 : warning (0, "387 instruction set disabled, using SSE arithmetics");
2714 : 0 : opts->x_ix86_fpmath = FPMATH_SSE;
2715 : : }
2716 : : }
2717 : : }
2718 : : /* For all chips supporting SSE2, -mfpmath=sse performs better than
2719 : : fpmath=387. The second is however default at many targets since the
2720 : : extra 80bit precision of temporaries is considered to be part of ABI.
2721 : : Overwrite the default at least for -ffast-math.
2722 : : TODO: -mfpmath=both seems to produce same performing code with bit
2723 : : smaller binaries. It is however not clear if register allocation is
2724 : : ready for this setting.
2725 : : Also -mfpmath=387 is overall a lot more compact (bout 4-5%) than SSE
2726 : : codegen. We may switch to 387 with -ffast-math for size optimized
2727 : : functions. */
2728 : 47027139 : else if (fast_math_flags_set_p (&global_options)
2729 : 47027139 : && TARGET_SSE2_P (opts->x_ix86_isa_flags))
2730 : 898766 : opts->x_ix86_fpmath = FPMATH_SSE;
2731 : : else
2732 : 48859311 : opts->x_ix86_fpmath = TARGET_FPMATH_DEFAULT_P (opts->x_ix86_isa_flags);
2733 : :
2734 : : /* Use external vectorized library in vectorizing intrinsics. */
2735 : 48328036 : if (opts_set->x_ix86_veclibabi_type)
2736 : 6 : switch (opts->x_ix86_veclibabi_type)
2737 : : {
2738 : 3 : case ix86_veclibabi_type_svml:
2739 : 3 : ix86_veclib_handler = &ix86_veclibabi_svml;
2740 : 3 : break;
2741 : :
2742 : 2 : case ix86_veclibabi_type_acml:
2743 : 2 : ix86_veclib_handler = &ix86_veclibabi_acml;
2744 : 2 : break;
2745 : :
2746 : 1 : case ix86_veclibabi_type_aocl:
2747 : 1 : ix86_veclib_handler = &ix86_veclibabi_aocl;
2748 : 1 : break;
2749 : :
2750 : 0 : default:
2751 : 0 : gcc_unreachable ();
2752 : : }
2753 : :
2754 : 48328036 : if (ix86_tune_features [X86_TUNE_ACCUMULATE_OUTGOING_ARGS]
2755 : 228536 : && !(opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
2756 : 228536 : opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
2757 : :
2758 : : /* If stack probes are required, the space used for large function
2759 : : arguments on the stack must also be probed, so enable
2760 : : -maccumulate-outgoing-args so this happens in the prologue. */
2761 : 48328036 : if (TARGET_STACK_PROBE_P (opts->x_target_flags)
2762 : 22 : && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
2763 : : {
2764 : 22 : if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
2765 : 0 : warning (0,
2766 : : main_args_p
2767 : : ? G_("stack probing requires %<-maccumulate-outgoing-args%> "
2768 : : "for correctness")
2769 : : : G_("stack probing requires "
2770 : : "%<target(\"accumulate-outgoing-args\")%> for "
2771 : : "correctness"));
2772 : 22 : opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
2773 : : }
2774 : :
2775 : : /* Stack realignment without -maccumulate-outgoing-args requires %ebp,
2776 : : so enable -maccumulate-outgoing-args when %ebp is fixed. */
2777 : 48328036 : if (fixed_regs[BP_REG]
2778 : 3 : && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
2779 : : {
2780 : 3 : if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
2781 : 2 : warning (0,
2782 : : main_args_p
2783 : : ? G_("fixed ebp register requires "
2784 : : "%<-maccumulate-outgoing-args%>")
2785 : : : G_("fixed ebp register requires "
2786 : : "%<target(\"accumulate-outgoing-args\")%>"));
2787 : 3 : opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
2788 : : }
2789 : :
2790 : : /* Figure out what ASM_GENERATE_INTERNAL_LABEL builds as a prefix. */
2791 : 48328036 : {
2792 : 48328036 : char *p;
2793 : 48328036 : ASM_GENERATE_INTERNAL_LABEL (internal_label_prefix, "LX", 0);
2794 : 48328036 : p = strchr (internal_label_prefix, 'X');
2795 : 48328036 : internal_label_prefix_len = p - internal_label_prefix;
2796 : 48328036 : *p = '\0';
2797 : : }
2798 : :
2799 : : /* When scheduling description is not available, disable scheduler pass
2800 : : so it won't slow down the compilation and make x87 code slower. */
2801 : 48328036 : if (!TARGET_SCHEDULE)
2802 : 12 : opts->x_flag_schedule_insns_after_reload = opts->x_flag_schedule_insns = 0;
2803 : :
2804 : 48328036 : SET_OPTION_IF_UNSET (opts, opts_set, param_simultaneous_prefetches,
2805 : : ix86_tune_cost->simultaneous_prefetches);
2806 : 48328036 : SET_OPTION_IF_UNSET (opts, opts_set, param_l1_cache_line_size,
2807 : : ix86_tune_cost->prefetch_block);
2808 : 48328036 : SET_OPTION_IF_UNSET (opts, opts_set, param_l1_cache_size,
2809 : : ix86_tune_cost->l1_cache_size);
2810 : 48328036 : SET_OPTION_IF_UNSET (opts, opts_set, param_l2_cache_size,
2811 : : ix86_tune_cost->l2_cache_size);
2812 : :
2813 : : /* 64B is the accepted value for these for all x86. */
2814 : 48328036 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
2815 : : param_destruct_interfere_size, 64);
2816 : 48328036 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
2817 : : param_construct_interfere_size, 64);
2818 : :
2819 : : /* Enable sw prefetching at -O3 for CPUS that prefetching is helpful. */
2820 : 48328036 : if (opts->x_flag_prefetch_loop_arrays < 0
2821 : 48327977 : && HAVE_prefetch
2822 : 48327948 : && (opts->x_optimize >= 3 || opts->x_flag_profile_use)
2823 : 2382575 : && !opts->x_optimize_size
2824 : 2382571 : && TARGET_SOFTWARE_PREFETCHING_BENEFICIAL)
2825 : 50 : opts->x_flag_prefetch_loop_arrays = 1;
2826 : :
2827 : : /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
2828 : : can be opts->x_optimized to ap = __builtin_next_arg (0). */
2829 : 48328036 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && !opts->x_flag_split_stack)
2830 : 15241 : targetm.expand_builtin_va_start = NULL;
2831 : :
2832 : : #ifdef USE_IX86_CLD
2833 : : /* Use -mcld by default for 32-bit code if configured with --enable-cld. */
2834 : : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2835 : : opts->x_target_flags |= MASK_CLD & ~opts_set->x_target_flags;
2836 : : #endif
2837 : :
2838 : : /* Set the default value for -mfentry. */
2839 : 48328036 : if (!opts_set->x_flag_fentry)
2840 : 48327985 : opts->x_flag_fentry = (TARGET_SEH
2841 : 48327985 : || (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2842 : : && ENABLE_X86_64_MFENTRY));
2843 : : else
2844 : : {
2845 : 51 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && opts->x_flag_pic
2846 : 0 : && opts->x_flag_fentry)
2847 : 0 : sorry ("%<-mfentry%> isn%'t supported for 32-bit in combination "
2848 : : "with %<-fpic%>");
2849 : : else if (TARGET_SEH && !opts->x_flag_fentry)
2850 : : sorry ("%<-mno-fentry%> isn%'t compatible with SEH");
2851 : : }
2852 : :
2853 : : #ifdef OPTION_GLIBC_P
2854 : : /* -mfentry is supported only on glibc targets. */
2855 : 48328036 : if (!opts->x_flag_fentry
2856 : 611001 : && OPTION_GLIBC_P (opts)
2857 : 611001 : && (TARGET_64BIT_P (opts->x_ix86_isa_flags) || !opts->x_flag_pic)
2858 : 306173 : && opts->x_flag_shrink_wrap
2859 : 305661 : && opts->x_profile_flag)
2860 : 2 : warning (0, "%<-pg%> without %<-mfentry%> may be unreliable with "
2861 : : "shrink wrapping");
2862 : : #endif
2863 : :
2864 : 48328036 : if (TARGET_SEH && TARGET_CALL_MS2SYSV_XLOGUES)
2865 : : sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH");
2866 : :
2867 : 48328036 : if (!(opts_set->x_target_flags & MASK_VZEROUPPER)
2868 : 48126138 : && flag_expensive_optimizations
2869 : 44557980 : && !optimize_size)
2870 : 43865259 : opts->x_target_flags |= MASK_VZEROUPPER;
2871 : 48328036 : if (!(opts_set->x_target_flags & MASK_STV))
2872 : 48323108 : opts->x_target_flags |= MASK_STV;
2873 : : /* Disable STV if -mpreferred-stack-boundary={2,3} or
2874 : : -mincoming-stack-boundary={2,3} or -mstackrealign - the needed
2875 : : stack realignment will be extra cost the pass doesn't take into
2876 : : account and the pass can't realign the stack. */
2877 : 48328036 : if (ix86_preferred_stack_boundary < 128
2878 : 48328028 : || ix86_incoming_stack_boundary < 128
2879 : 48328027 : || opts->x_ix86_force_align_arg_pointer)
2880 : 1617 : opts->x_target_flags &= ~MASK_STV;
2881 : 48328036 : if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL]
2882 : 14497 : && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_LOAD))
2883 : 14497 : opts->x_target_flags |= MASK_AVX256_SPLIT_UNALIGNED_LOAD;
2884 : 48313539 : else if (!main_args_p
2885 : 48024284 : && ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL])
2886 : 48024284 : opts->x_target_flags &= ~MASK_AVX256_SPLIT_UNALIGNED_LOAD;
2887 : :
2888 : 48328036 : if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL]
2889 : 15239 : && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_STORE))
2890 : 15239 : opts->x_target_flags |= MASK_AVX256_SPLIT_UNALIGNED_STORE;
2891 : 48312797 : else if (!main_args_p
2892 : 48023589 : && ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL])
2893 : 48023589 : opts->x_target_flags &= ~MASK_AVX256_SPLIT_UNALIGNED_STORE;
2894 : :
2895 : : /* Enable 128-bit AVX instruction generation
2896 : : for the auto-vectorizer. */
2897 : 48328036 : if (ix86_tune_features[X86_TUNE_AVX128_OPTIMAL]
2898 : 836 : && (opts_set->x_prefer_vector_width_type == PVW_NONE))
2899 : 825 : opts->x_prefer_vector_width_type = PVW_AVX128;
2900 : :
2901 : : /* Use 256-bit AVX instruction generation
2902 : : in the auto-vectorizer. */
2903 : 48328036 : if (ix86_tune_features[X86_TUNE_AVX256_OPTIMAL]
2904 : 214732 : && (opts_set->x_prefer_vector_width_type == PVW_NONE))
2905 : 88221 : opts->x_prefer_vector_width_type = PVW_AVX256;
2906 : :
2907 : 48328036 : if (opts_set->x_ix86_move_max == PVW_NONE)
2908 : : {
2909 : : /* Set the maximum number of bits can be moved from memory to
2910 : : memory efficiently. */
2911 : 48328023 : if (opts_set->x_prefer_vector_width_type != PVW_NONE)
2912 : 944693 : opts->x_ix86_move_max = opts->x_prefer_vector_width_type;
2913 : 47383330 : else if (ix86_tune_features[X86_TUNE_AVX512_MOVE_BY_PIECES])
2914 : 4161 : opts->x_ix86_move_max = PVW_AVX512;
2915 : 47379169 : else if (ix86_tune_features[X86_TUNE_AVX256_MOVE_BY_PIECES])
2916 : 404139 : opts->x_ix86_move_max = PVW_AVX256;
2917 : : else
2918 : : {
2919 : 46975030 : opts->x_ix86_move_max = opts->x_prefer_vector_width_type;
2920 : 46975030 : if (opts->x_ix86_move_max == PVW_NONE)
2921 : : {
2922 : 46974266 : if (TARGET_AVX512F_P (opts->x_ix86_isa_flags))
2923 : 43049791 : opts->x_ix86_move_max = PVW_AVX512;
2924 : : /* Align with vectorizer to avoid potential STLF issue. */
2925 : 3924475 : else if (TARGET_AVX_P (opts->x_ix86_isa_flags))
2926 : 1339729 : opts->x_ix86_move_max = PVW_AVX256;
2927 : : else
2928 : 2584746 : opts->x_ix86_move_max = PVW_AVX128;
2929 : : }
2930 : : }
2931 : : }
2932 : :
2933 : 48328036 : if (opts->x_ix86_recip_name)
2934 : : {
2935 : 0 : char *p = ASTRDUP (opts->x_ix86_recip_name);
2936 : 0 : char *q;
2937 : 0 : unsigned int mask;
2938 : 0 : bool invert;
2939 : :
2940 : 0 : while ((q = strtok (p, ",")) != NULL)
2941 : : {
2942 : 0 : p = NULL;
2943 : 0 : if (*q == '!')
2944 : : {
2945 : 0 : invert = true;
2946 : 0 : q++;
2947 : : }
2948 : : else
2949 : : invert = false;
2950 : :
2951 : 0 : if (!strcmp (q, "default"))
2952 : : mask = RECIP_MASK_ALL;
2953 : : else
2954 : : {
2955 : 0 : for (i = 0; i < ARRAY_SIZE (recip_options); i++)
2956 : 0 : if (!strcmp (q, recip_options[i].string))
2957 : : {
2958 : 0 : mask = recip_options[i].mask;
2959 : 0 : break;
2960 : : }
2961 : :
2962 : 0 : if (i == ARRAY_SIZE (recip_options))
2963 : : {
2964 : 0 : error ("unknown option for %<-mrecip=%s%>", q);
2965 : 0 : invert = false;
2966 : 0 : mask = RECIP_MASK_NONE;
2967 : : }
2968 : : }
2969 : :
2970 : 0 : opts->x_recip_mask_explicit |= mask;
2971 : 0 : if (invert)
2972 : 0 : opts->x_recip_mask &= ~mask;
2973 : : else
2974 : 0 : opts->x_recip_mask |= mask;
2975 : : }
2976 : : }
2977 : :
2978 : 48328036 : if (TARGET_RECIP_P (opts->x_target_flags))
2979 : 13046 : opts->x_recip_mask |= RECIP_MASK_ALL & ~opts->x_recip_mask_explicit;
2980 : 48314990 : else if (opts_set->x_target_flags & MASK_RECIP)
2981 : 2 : opts->x_recip_mask &= ~(RECIP_MASK_ALL & ~opts->x_recip_mask_explicit);
2982 : :
2983 : : /* Default long double to 64-bit for 32-bit Bionic and to __float128
2984 : : for 64-bit Bionic. Also default long double to 64-bit for Intel
2985 : : MCU psABI. */
2986 : 48328036 : if ((TARGET_HAS_BIONIC || TARGET_IAMCU)
2987 : 8 : && !(opts_set->x_target_flags
2988 : : & (MASK_LONG_DOUBLE_64 | MASK_LONG_DOUBLE_128)))
2989 : 2 : opts->x_target_flags |= (TARGET_64BIT
2990 : 2 : ? MASK_LONG_DOUBLE_128
2991 : : : MASK_LONG_DOUBLE_64);
2992 : :
2993 : : /* Only one of them can be active. */
2994 : 48328036 : gcc_assert ((opts->x_target_flags & MASK_LONG_DOUBLE_64) == 0
2995 : : || (opts->x_target_flags & MASK_LONG_DOUBLE_128) == 0);
2996 : :
2997 : : /* Handle stack protector */
2998 : 48328036 : if (!opts_set->x_ix86_stack_protector_guard)
2999 : : {
3000 : : #ifdef TARGET_THREAD_SSP_OFFSET
3001 : 48328033 : if (!TARGET_HAS_BIONIC)
3002 : 48328025 : opts->x_ix86_stack_protector_guard = SSP_TLS;
3003 : : else
3004 : : #endif
3005 : 8 : opts->x_ix86_stack_protector_guard = SSP_GLOBAL;
3006 : : }
3007 : :
3008 : 48328036 : if (opts_set->x_ix86_stack_protector_guard_offset_str)
3009 : : {
3010 : 1 : char *endp;
3011 : 1 : const char *str = opts->x_ix86_stack_protector_guard_offset_str;
3012 : :
3013 : 1 : errno = 0;
3014 : 1 : int64_t offset;
3015 : :
3016 : : #if defined(INT64_T_IS_LONG)
3017 : 1 : offset = strtol (str, &endp, 0);
3018 : : #else
3019 : : offset = strtoll (str, &endp, 0);
3020 : : #endif
3021 : :
3022 : 1 : if (!*str || *endp || errno)
3023 : 0 : error ("%qs is not a valid number "
3024 : : "in %<-mstack-protector-guard-offset=%>", str);
3025 : :
3026 : 1 : if (!IN_RANGE (offset, HOST_WIDE_INT_C (-0x80000000),
3027 : : HOST_WIDE_INT_C (0x7fffffff)))
3028 : 0 : error ("%qs is not a valid offset "
3029 : : "in %<-mstack-protector-guard-offset=%>", str);
3030 : :
3031 : 1 : opts->x_ix86_stack_protector_guard_offset = offset;
3032 : : }
3033 : : #ifdef TARGET_THREAD_SSP_OFFSET
3034 : : else
3035 : 96044976 : opts->x_ix86_stack_protector_guard_offset = TARGET_THREAD_SSP_OFFSET;
3036 : : #endif
3037 : :
3038 : 48328036 : if (opts_set->x_ix86_stack_protector_guard_reg_str)
3039 : : {
3040 : 2 : const char *str = opts->x_ix86_stack_protector_guard_reg_str;
3041 : 2 : addr_space_t seg = ADDR_SPACE_GENERIC;
3042 : :
3043 : : /* Discard optional register prefix. */
3044 : 2 : if (str[0] == '%')
3045 : 0 : str++;
3046 : :
3047 : 2 : if (strlen (str) == 2 && str[1] == 's')
3048 : : {
3049 : 2 : if (str[0] == 'f')
3050 : : seg = ADDR_SPACE_SEG_FS;
3051 : 2 : else if (str[0] == 'g')
3052 : : seg = ADDR_SPACE_SEG_GS;
3053 : : }
3054 : :
3055 : : if (seg == ADDR_SPACE_GENERIC)
3056 : 0 : error ("%qs is not a valid base register "
3057 : : "in %<-mstack-protector-guard-reg=%>",
3058 : : opts->x_ix86_stack_protector_guard_reg_str);
3059 : :
3060 : 2 : opts->x_ix86_stack_protector_guard_reg = seg;
3061 : : }
3062 : : else
3063 : : {
3064 : 48328034 : opts->x_ix86_stack_protector_guard_reg = DEFAULT_TLS_SEG_REG;
3065 : :
3066 : : /* The kernel uses a different segment register for performance
3067 : : reasons; a system call would not have to trash the userspace
3068 : : segment register, which would be expensive. */
3069 : 48328034 : if (opts->x_ix86_cmodel == CM_KERNEL)
3070 : 1 : opts->x_ix86_stack_protector_guard_reg = ADDR_SPACE_SEG_GS;
3071 : : }
3072 : :
3073 : : /* Handle -mmemcpy-strategy= and -mmemset-strategy= */
3074 : 48328036 : if (opts->x_ix86_tune_memcpy_strategy)
3075 : : {
3076 : 18 : char *str = xstrdup (opts->x_ix86_tune_memcpy_strategy);
3077 : 18 : ix86_parse_stringop_strategy_string (str, false);
3078 : 18 : free (str);
3079 : : }
3080 : :
3081 : 48328036 : if (opts->x_ix86_tune_memset_strategy)
3082 : : {
3083 : 34 : char *str = xstrdup (opts->x_ix86_tune_memset_strategy);
3084 : 34 : ix86_parse_stringop_strategy_string (str, true);
3085 : 34 : free (str);
3086 : : }
3087 : :
3088 : : /* Save the initial options in case the user does function specific
3089 : : options. */
3090 : 48328036 : if (main_args_p)
3091 : : {
3092 : 289296 : opts->x_ix86_excess_precision
3093 : 289296 : = opts->x_flag_excess_precision;
3094 : 289296 : opts->x_ix86_unsafe_math_optimizations
3095 : 289296 : = opts->x_flag_unsafe_math_optimizations;
3096 : 578592 : target_option_default_node = target_option_current_node
3097 : 289296 : = build_target_option_node (opts, opts_set);
3098 : : }
3099 : :
3100 : 48328036 : const bool cf_okay_p = (TARGET_64BIT || TARGET_CMOV);
3101 : : /* When -fhardened, enable -fcf-protection=full, but only when it's
3102 : : compatible with this target, and when it wasn't already specified
3103 : : on the command line. */
3104 : 48328036 : if (opts->x_flag_hardened && cf_okay_p)
3105 : : {
3106 : 91 : if (!opts_set->x_flag_cf_protection)
3107 : 90 : opts->x_flag_cf_protection = CF_FULL;
3108 : 1 : else if (opts->x_flag_cf_protection != CF_FULL)
3109 : 1 : warning_at (UNKNOWN_LOCATION, OPT_Whardened,
3110 : : "%<-fcf-protection=full%> is not enabled by "
3111 : : "%<-fhardened%> because it was specified on the command "
3112 : : "line");
3113 : : }
3114 : :
3115 : 48328036 : if (opts->x_flag_cf_protection != CF_NONE)
3116 : : {
3117 : 41984 : if ((opts->x_flag_cf_protection & CF_BRANCH) == CF_BRANCH
3118 : 41855 : && !cf_okay_p)
3119 : 0 : error ("%<-fcf-protection%> is not compatible with this target");
3120 : :
3121 : 41984 : opts->x_flag_cf_protection
3122 : 41984 : = (cf_protection_level) (opts->x_flag_cf_protection | CF_SET);
3123 : : }
3124 : :
3125 : 48328036 : if (ix86_tune_features [X86_TUNE_AVOID_512FMA_CHAINS])
3126 : 65 : SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits, 512);
3127 : 48327971 : else if (ix86_tune_features [X86_TUNE_AVOID_256FMA_CHAINS])
3128 : 47586404 : SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits, 256);
3129 : 741567 : else if (ix86_tune_features [X86_TUNE_AVOID_128FMA_CHAINS])
3130 : 110 : SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits, 128);
3131 : :
3132 : : /* PR86952: jump table usage with retpolines is slow.
3133 : : The PR provides some numbers about the slowness. */
3134 : 48328036 : if (ix86_indirect_branch != indirect_branch_keep)
3135 : 49 : SET_OPTION_IF_UNSET (opts, opts_set, flag_jump_tables, 0);
3136 : :
3137 : 48328036 : SET_OPTION_IF_UNSET (opts, opts_set, param_ira_consider_dup_in_all_alts, 0);
3138 : :
3139 : : /* Fully masking the main or the epilogue vectorized loop is not
3140 : : profitable generally so leave it disabled until we get more
3141 : : fine grained control & costing. */
3142 : 48328036 : SET_OPTION_IF_UNSET (opts, opts_set, param_vect_partial_vector_usage, 0);
3143 : :
3144 : : return true;
3145 : : }
3146 : :
3147 : : /* Implement the TARGET_OPTION_OVERRIDE hook. */
3148 : :
3149 : : void
3150 : 289297 : ix86_option_override (void)
3151 : : {
3152 : 289297 : ix86_option_override_internal (true, &global_options, &global_options_set);
3153 : 289297 : }
3154 : :
3155 : : /* Remember the last target of ix86_set_current_function. */
3156 : : static GTY(()) tree ix86_previous_fndecl;
3157 : :
3158 : : /* Set targets globals to the default (or current #pragma GCC target
3159 : : if active). Invalidate ix86_previous_fndecl cache. */
3160 : :
3161 : : void
3162 : 2301998 : ix86_reset_previous_fndecl (void)
3163 : : {
3164 : 2301998 : tree new_tree = target_option_current_node;
3165 : 2301998 : cl_target_option_restore (&global_options, &global_options_set,
3166 : 2301998 : TREE_TARGET_OPTION (new_tree));
3167 : 2301998 : if (TREE_TARGET_GLOBALS (new_tree))
3168 : 577501 : restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
3169 : 1724497 : else if (new_tree == target_option_default_node)
3170 : 1252581 : restore_target_globals (&default_target_globals);
3171 : : else
3172 : 471916 : TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
3173 : 2301998 : ix86_previous_fndecl = NULL_TREE;
3174 : 2301998 : }
3175 : :
3176 : : /* Add target attribute to SIMD clone NODE if needed. */
3177 : :
3178 : : void
3179 : 7156 : ix86_simd_clone_adjust (struct cgraph_node *node)
3180 : : {
3181 : 7156 : const char *str = NULL;
3182 : :
3183 : : /* Attributes need to be adjusted for definitions, not declarations. */
3184 : 7156 : if (!node->definition)
3185 : : return;
3186 : :
3187 : 4472 : gcc_assert (node->decl == cfun->decl);
3188 : 4472 : switch (node->simdclone->vecsize_mangle)
3189 : : {
3190 : 1115 : case 'b':
3191 : 1115 : if (!TARGET_SSE2)
3192 : : str = "sse2";
3193 : : break;
3194 : 1176 : case 'c':
3195 : 1176 : if (TARGET_PREFER_AVX128)
3196 : : {
3197 : 1 : if (!TARGET_AVX)
3198 : : str = "avx,prefer-vector-width=256";
3199 : : else
3200 : : str = "prefer-vector-width=256";
3201 : : }
3202 : 1175 : else if (!TARGET_AVX)
3203 : : str = "avx";
3204 : : break;
3205 : 1091 : case 'd':
3206 : 1091 : if (TARGET_PREFER_AVX128)
3207 : : {
3208 : 1 : if (!TARGET_AVX2)
3209 : : str = "avx2,prefer-vector-width=256";
3210 : : else
3211 : : str = "prefer-vector-width=256";
3212 : : }
3213 : 1090 : else if (!TARGET_AVX2)
3214 : : str = "avx2";
3215 : : break;
3216 : 1090 : case 'e':
3217 : 1090 : if (TARGET_PREFER_AVX256)
3218 : : {
3219 : 4 : if (!TARGET_AVX512F)
3220 : : str = "avx512f,prefer-vector-width=512";
3221 : : else
3222 : 2 : str = "prefer-vector-width=512";
3223 : : }
3224 : 1086 : else if (!TARGET_AVX512F)
3225 : : str = "avx512f";
3226 : : break;
3227 : 0 : default:
3228 : 0 : gcc_unreachable ();
3229 : : }
3230 : 2 : if (str == NULL)
3231 : : return;
3232 : 2862 : push_cfun (NULL);
3233 : 2862 : tree args = build_tree_list (NULL_TREE, build_string (strlen (str), str));
3234 : 2862 : bool ok = ix86_valid_target_attribute_p (node->decl, NULL, args, 0);
3235 : 2862 : gcc_assert (ok);
3236 : 2862 : pop_cfun ();
3237 : 2862 : ix86_reset_previous_fndecl ();
3238 : 2862 : ix86_set_current_function (node->decl);
3239 : : }
3240 : :
3241 : :
3242 : :
3243 : : /* Set the func_type field from the function FNDECL. */
3244 : :
3245 : : static void
3246 : 362686214 : ix86_set_func_type (tree fndecl)
3247 : : {
3248 : : /* No need to save and restore callee-saved registers for a noreturn
3249 : : function with nothrow or compiled with -fno-exceptions unless when
3250 : : compiling with -O0 or -Og, except that it interferes with debugging
3251 : : of callers. So that backtrace works for those at least
3252 : : in most cases, save the bp register if it is used, because it often
3253 : : is used in callers to compute CFA.
3254 : :
3255 : : NB: Can't use just TREE_THIS_VOLATILE to check if this is a noreturn
3256 : : function. The local-pure-const pass turns an interrupt function
3257 : : into a noreturn function by setting TREE_THIS_VOLATILE. Normally
3258 : : the local-pure-const pass is run after ix86_set_func_type is called.
3259 : : When the local-pure-const pass is enabled for LTO, the interrupt
3260 : : function is marked with TREE_THIS_VOLATILE in the IR output, which
3261 : : leads to the incompatible attribute error in LTO1. Ignore the
3262 : : interrupt function in this case. */
3263 : 362686214 : enum call_saved_registers_type no_callee_saved_registers
3264 : : = TYPE_DEFAULT_CALL_SAVED_REGISTERS;
3265 : 362686214 : if (lookup_attribute ("preserve_none",
3266 : 362686214 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
3267 : : no_callee_saved_registers = TYPE_PRESERVE_NONE;
3268 : 362685305 : else if ((lookup_attribute ("no_callee_saved_registers",
3269 : 362685305 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
3270 : 362685305 : || (ix86_noreturn_no_callee_saved_registers
3271 : 565 : && TREE_THIS_VOLATILE (fndecl)
3272 : 565 : && optimize
3273 : 529 : && !optimize_debug
3274 : 477 : && (TREE_NOTHROW (fndecl) || !flag_exceptions)
3275 : 477 : && !lookup_attribute ("interrupt",
3276 : 477 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))
3277 : 477 : && !lookup_attribute ("no_caller_saved_registers",
3278 : 477 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))))
3279 : : no_callee_saved_registers = TYPE_NO_CALLEE_SAVED_REGISTERS;
3280 : :
3281 : 362686214 : if (cfun->machine->func_type == TYPE_UNKNOWN)
3282 : : {
3283 : 181039976 : if (lookup_attribute ("interrupt",
3284 : 181039976 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
3285 : : {
3286 : 154 : if (ix86_function_naked (fndecl))
3287 : 1 : error_at (DECL_SOURCE_LOCATION (fndecl),
3288 : : "interrupt and naked attributes are not compatible");
3289 : :
3290 : 154 : if (no_callee_saved_registers)
3291 : : {
3292 : 2 : const char *attr;
3293 : 2 : if (no_callee_saved_registers == TYPE_PRESERVE_NONE)
3294 : : attr = "preserve_none";
3295 : : else
3296 : 1 : attr = "no_callee_saved_registers";
3297 : 2 : error_at (DECL_SOURCE_LOCATION (fndecl),
3298 : : "%qs and %qs attributes are not compatible",
3299 : : "interrupt", attr);
3300 : : }
3301 : :
3302 : 154 : int nargs = 0;
3303 : 154 : for (tree arg = DECL_ARGUMENTS (fndecl);
3304 : 389 : arg;
3305 : 235 : arg = TREE_CHAIN (arg))
3306 : 235 : nargs++;
3307 : 154 : cfun->machine->call_saved_registers
3308 : 154 : = TYPE_NO_CALLER_SAVED_REGISTERS;
3309 : 154 : cfun->machine->func_type
3310 : 154 : = nargs == 2 ? TYPE_EXCEPTION : TYPE_INTERRUPT;
3311 : :
3312 : 154 : ix86_optimize_mode_switching[X86_DIRFLAG] = 1;
3313 : :
3314 : : /* Only dwarf2out.cc can handle -WORD(AP) as a pointer argument. */
3315 : 154 : if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
3316 : 0 : sorry ("only DWARF debug format is supported for interrupt "
3317 : : "service routine");
3318 : : }
3319 : : else
3320 : : {
3321 : 181039822 : cfun->machine->func_type = TYPE_NORMAL;
3322 : 181039822 : if (no_callee_saved_registers)
3323 : 82 : cfun->machine->call_saved_registers
3324 : 82 : = no_callee_saved_registers;
3325 : 181039740 : else if (lookup_attribute ("no_caller_saved_registers",
3326 : 181039740 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
3327 : 35 : cfun->machine->call_saved_registers
3328 : 35 : = TYPE_NO_CALLER_SAVED_REGISTERS;
3329 : : }
3330 : : }
3331 : 362686214 : }
3332 : :
3333 : : /* Set the indirect_branch_type field from the function FNDECL. */
3334 : :
3335 : : static void
3336 : 362686214 : ix86_set_indirect_branch_type (tree fndecl)
3337 : : {
3338 : 362686214 : if (cfun->machine->indirect_branch_type == indirect_branch_unset)
3339 : : {
3340 : 181039976 : tree attr = lookup_attribute ("indirect_branch",
3341 : 181039976 : DECL_ATTRIBUTES (fndecl));
3342 : 181039976 : if (attr != NULL)
3343 : : {
3344 : 17 : tree args = TREE_VALUE (attr);
3345 : 17 : if (args == NULL)
3346 : 0 : gcc_unreachable ();
3347 : 17 : tree cst = TREE_VALUE (args);
3348 : 17 : if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
3349 : 2 : cfun->machine->indirect_branch_type = indirect_branch_keep;
3350 : 15 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
3351 : 5 : cfun->machine->indirect_branch_type = indirect_branch_thunk;
3352 : 10 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
3353 : 3 : cfun->machine->indirect_branch_type = indirect_branch_thunk_inline;
3354 : 7 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
3355 : 7 : cfun->machine->indirect_branch_type = indirect_branch_thunk_extern;
3356 : : else
3357 : 0 : gcc_unreachable ();
3358 : : }
3359 : : else
3360 : 181039959 : cfun->machine->indirect_branch_type = ix86_indirect_branch;
3361 : :
3362 : : /* -mcmodel=large is not compatible with -mindirect-branch=thunk
3363 : : nor -mindirect-branch=thunk-extern. */
3364 : 181039976 : if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
3365 : 7451 : && ((cfun->machine->indirect_branch_type
3366 : 7451 : == indirect_branch_thunk_extern)
3367 : 7449 : || (cfun->machine->indirect_branch_type
3368 : : == indirect_branch_thunk)))
3369 : 6 : error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
3370 : : "compatible",
3371 : : ((cfun->machine->indirect_branch_type
3372 : : == indirect_branch_thunk_extern)
3373 : : ? "thunk-extern" : "thunk"));
3374 : :
3375 : 181039976 : if (cfun->machine->indirect_branch_type != indirect_branch_keep
3376 : 78 : && (cfun->machine->indirect_branch_type
3377 : : != indirect_branch_thunk_extern)
3378 : 52 : && (flag_cf_protection & CF_RETURN))
3379 : 3 : error ("%<-mindirect-branch%> and %<-fcf-protection%> are not "
3380 : : "compatible");
3381 : : }
3382 : :
3383 : 362686214 : if (cfun->machine->function_return_type == indirect_branch_unset)
3384 : : {
3385 : 181039976 : tree attr = lookup_attribute ("function_return",
3386 : 181039976 : DECL_ATTRIBUTES (fndecl));
3387 : 181039976 : if (attr != NULL)
3388 : : {
3389 : 12 : tree args = TREE_VALUE (attr);
3390 : 12 : if (args == NULL)
3391 : 0 : gcc_unreachable ();
3392 : 12 : tree cst = TREE_VALUE (args);
3393 : 12 : if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
3394 : 2 : cfun->machine->function_return_type = indirect_branch_keep;
3395 : 10 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
3396 : 4 : cfun->machine->function_return_type = indirect_branch_thunk;
3397 : 6 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
3398 : 3 : cfun->machine->function_return_type = indirect_branch_thunk_inline;
3399 : 3 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
3400 : 3 : cfun->machine->function_return_type = indirect_branch_thunk_extern;
3401 : : else
3402 : 0 : gcc_unreachable ();
3403 : : }
3404 : : else
3405 : 181039964 : cfun->machine->function_return_type = ix86_function_return;
3406 : :
3407 : : /* -mcmodel=large is not compatible with -mfunction-return=thunk
3408 : : nor -mfunction-return=thunk-extern. */
3409 : 181039976 : if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
3410 : 7451 : && ((cfun->machine->function_return_type
3411 : 7451 : == indirect_branch_thunk_extern)
3412 : 7449 : || (cfun->machine->function_return_type
3413 : : == indirect_branch_thunk)))
3414 : 6 : error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
3415 : : "compatible",
3416 : : ((cfun->machine->function_return_type
3417 : : == indirect_branch_thunk_extern)
3418 : : ? "thunk-extern" : "thunk"));
3419 : :
3420 : 181039976 : if (cfun->machine->function_return_type != indirect_branch_keep
3421 : 32 : && (cfun->machine->function_return_type
3422 : : != indirect_branch_thunk_extern)
3423 : 24 : && (flag_cf_protection & CF_RETURN))
3424 : 3 : error ("%<-mfunction-return%> and %<-fcf-protection%> are not "
3425 : : "compatible");
3426 : : }
3427 : 362686214 : }
3428 : :
3429 : : /* Establish appropriate back-end context for processing the function
3430 : : FNDECL. The argument might be NULL to indicate processing at top
3431 : : level, outside of any function scope. */
3432 : : void
3433 : 721289371 : ix86_set_current_function (tree fndecl)
3434 : : {
3435 : : /* Only change the context if the function changes. This hook is called
3436 : : several times in the course of compiling a function, and we don't want to
3437 : : slow things down too much or call target_reinit when it isn't safe. */
3438 : 721289371 : if (fndecl == ix86_previous_fndecl)
3439 : : {
3440 : : /* There may be 2 function bodies for the same function FNDECL,
3441 : : one is extern inline and one isn't. Call ix86_set_func_type
3442 : : to set the func_type field. */
3443 : 78134304 : if (fndecl != NULL_TREE)
3444 : : {
3445 : 78134277 : ix86_set_func_type (fndecl);
3446 : 78134277 : ix86_set_indirect_branch_type (fndecl);
3447 : : }
3448 : 78134304 : return;
3449 : : }
3450 : :
3451 : 643155067 : tree old_tree;
3452 : 643155067 : if (ix86_previous_fndecl == NULL_TREE)
3453 : 1991193 : old_tree = target_option_current_node;
3454 : 641163874 : else if (DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl))
3455 : : old_tree = DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl);
3456 : : else
3457 : 582771552 : old_tree = target_option_default_node;
3458 : :
3459 : 643155067 : if (fndecl == NULL_TREE)
3460 : : {
3461 : 358603130 : if (old_tree != target_option_current_node)
3462 : 1208802 : ix86_reset_previous_fndecl ();
3463 : 358603130 : return;
3464 : : }
3465 : :
3466 : 284551937 : ix86_set_func_type (fndecl);
3467 : 284551937 : ix86_set_indirect_branch_type (fndecl);
3468 : :
3469 : 284551937 : tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
3470 : 284551937 : if (new_tree == NULL_TREE)
3471 : 254749339 : new_tree = target_option_default_node;
3472 : :
3473 : 284551937 : bool fp_flag_change
3474 : 284551937 : = (flag_unsafe_math_optimizations
3475 : 284551937 : != TREE_TARGET_OPTION (new_tree)->x_ix86_unsafe_math_optimizations
3476 : 284551937 : || (flag_excess_precision
3477 : 284551824 : != TREE_TARGET_OPTION (new_tree)->x_ix86_excess_precision));
3478 : 284551937 : if (old_tree != new_tree || fp_flag_change)
3479 : : {
3480 : 1208877 : cl_target_option_restore (&global_options, &global_options_set,
3481 : 1208877 : TREE_TARGET_OPTION (new_tree));
3482 : 1208877 : if (fp_flag_change)
3483 : : {
3484 : 113 : ix86_excess_precision = flag_excess_precision;
3485 : 113 : ix86_unsafe_math_optimizations = flag_unsafe_math_optimizations;
3486 : 113 : DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = new_tree
3487 : 113 : = build_target_option_node (&global_options, &global_options_set);
3488 : : }
3489 : 1208877 : if (TREE_TARGET_GLOBALS (new_tree))
3490 : 1171169 : restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
3491 : 37708 : else if (new_tree == target_option_default_node)
3492 : 20542 : restore_target_globals (&default_target_globals);
3493 : : else
3494 : 17166 : TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
3495 : : }
3496 : 284551937 : ix86_previous_fndecl = fndecl;
3497 : :
3498 : 284551937 : static call_saved_registers_type prev_call_saved_registers;
3499 : :
3500 : : /* 64-bit MS and SYSV ABI have different set of call used registers.
3501 : : Avoid expensive re-initialization of init_regs each time we switch
3502 : : function context. */
3503 : 284551937 : if (TARGET_64BIT
3504 : 284551937 : && (call_used_or_fixed_reg_p (SI_REG)
3505 : 276131273 : == (cfun->machine->call_abi == MS_ABI)))
3506 : 36927 : reinit_regs ();
3507 : : /* Need to re-initialize init_regs if caller-saved registers are
3508 : : changed. */
3509 : 284515010 : else if (prev_call_saved_registers
3510 : 284515010 : != cfun->machine->call_saved_registers)
3511 : 10814 : reinit_regs ();
3512 : :
3513 : 284551937 : if (cfun->machine->func_type != TYPE_NORMAL
3514 : 284547797 : || (cfun->machine->call_saved_registers
3515 : 284547797 : == TYPE_NO_CALLER_SAVED_REGISTERS))
3516 : : {
3517 : : /* Don't allow AVX, AVX512, MMX nor x87 instructions since they
3518 : : may change processor state. Don't allow SSE instructions in
3519 : : exception/interrupt service routines. */
3520 : 4953 : const char *isa;
3521 : 4953 : if (TARGET_SSE)
3522 : : {
3523 : 205 : if (TARGET_AVX512F)
3524 : : isa = "AVX512";
3525 : 205 : else if (TARGET_AVX)
3526 : : isa = "AVX";
3527 : 205 : else if (cfun->machine->func_type != TYPE_NORMAL)
3528 : : isa = "SSE";
3529 : 204 : else if (TARGET_MMX)
3530 : : isa = "MMX/3Dnow";
3531 : 203 : else if (TARGET_80387)
3532 : : isa = "80387";
3533 : : else
3534 : : isa = NULL;
3535 : : }
3536 : 4748 : else if (TARGET_MMX)
3537 : : isa = "MMX/3Dnow";
3538 : 4745 : else if (TARGET_80387)
3539 : : isa = "80387";
3540 : : else
3541 : : isa = NULL;
3542 : : if (isa != NULL)
3543 : : {
3544 : 9 : if (cfun->machine->func_type != TYPE_NORMAL)
3545 : 7 : sorry (cfun->machine->func_type == TYPE_EXCEPTION
3546 : : ? G_("%s instructions aren%'t allowed in an"
3547 : : " exception service routine")
3548 : : : G_("%s instructions aren%'t allowed in an"
3549 : : " interrupt service routine"),
3550 : : isa);
3551 : : else
3552 : 4 : sorry ("%s instructions aren%'t allowed in a function with "
3553 : : "the %<no_caller_saved_registers%> attribute", isa);
3554 : : /* Don't issue the same error twice. */
3555 : 9 : cfun->machine->func_type = TYPE_NORMAL;
3556 : 9 : cfun->machine->call_saved_registers
3557 : 9 : = TYPE_DEFAULT_CALL_SAVED_REGISTERS;
3558 : : }
3559 : : }
3560 : :
3561 : 284551937 : prev_call_saved_registers = cfun->machine->call_saved_registers;
3562 : : }
3563 : :
3564 : : /* Implement the TARGET_OFFLOAD_OPTIONS hook. */
3565 : : char *
3566 : 0 : ix86_offload_options (void)
3567 : : {
3568 : 0 : if (TARGET_LP64)
3569 : 0 : return xstrdup ("-foffload-abi=lp64 -foffload-abi-host-opts=-m64");
3570 : 0 : return xstrdup ("-foffload-abi=ilp32 -foffload-abi-host-opts=-m32");
3571 : : }
3572 : :
3573 : : /* Handle "cdecl", "stdcall", "fastcall", "regparm", "thiscall",
3574 : : and "sseregparm" calling convention attributes;
3575 : : arguments as in struct attribute_spec.handler. */
3576 : :
3577 : : static tree
3578 : 11721 : ix86_handle_cconv_attribute (tree *node, tree name, tree args, int,
3579 : : bool *no_add_attrs)
3580 : : {
3581 : 11721 : if (TREE_CODE (*node) != FUNCTION_TYPE
3582 : 11721 : && TREE_CODE (*node) != METHOD_TYPE
3583 : : && TREE_CODE (*node) != FIELD_DECL
3584 : : && TREE_CODE (*node) != TYPE_DECL)
3585 : : {
3586 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3587 : : name);
3588 : 0 : *no_add_attrs = true;
3589 : 0 : return NULL_TREE;
3590 : : }
3591 : :
3592 : 11721 : if (TARGET_64BIT)
3593 : : {
3594 : : /* Do not warn when emulating the MS ABI. */
3595 : 791 : if ((TREE_CODE (*node) != FUNCTION_TYPE
3596 : : && TREE_CODE (*node) != METHOD_TYPE)
3597 : 791 : || ix86_function_type_abi (*node) != MS_ABI)
3598 : 788 : warning (OPT_Wattributes, "%qE attribute ignored",
3599 : : name);
3600 : 791 : *no_add_attrs = true;
3601 : 791 : return NULL_TREE;
3602 : : }
3603 : :
3604 : : /* Can combine regparm with all attributes but fastcall, and thiscall. */
3605 : 10930 : if (is_attribute_p ("regparm", name))
3606 : : {
3607 : 10928 : tree cst;
3608 : :
3609 : 10928 : if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3610 : : {
3611 : 0 : error ("fastcall and regparm attributes are not compatible");
3612 : : }
3613 : :
3614 : 10928 : if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3615 : : {
3616 : 0 : error ("regparm and thiscall attributes are not compatible");
3617 : : }
3618 : :
3619 : 10928 : cst = TREE_VALUE (args);
3620 : 10928 : if (TREE_CODE (cst) != INTEGER_CST)
3621 : : {
3622 : 0 : warning (OPT_Wattributes,
3623 : : "%qE attribute requires an integer constant argument",
3624 : : name);
3625 : 0 : *no_add_attrs = true;
3626 : : }
3627 : 10928 : else if (compare_tree_int (cst, REGPARM_MAX) > 0)
3628 : : {
3629 : 0 : warning (OPT_Wattributes, "argument to %qE attribute larger than %d",
3630 : 0 : name, REGPARM_MAX);
3631 : 0 : *no_add_attrs = true;
3632 : : }
3633 : :
3634 : 10928 : return NULL_TREE;
3635 : : }
3636 : :
3637 : : /* Can combine fastcall with sseregparm. */
3638 : 2 : if (is_attribute_p ("fastcall", name))
3639 : : {
3640 : 2 : if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
3641 : : {
3642 : 0 : error ("fastcall and cdecl attributes are not compatible");
3643 : : }
3644 : 2 : if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
3645 : : {
3646 : 0 : error ("fastcall and stdcall attributes are not compatible");
3647 : : }
3648 : 2 : if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node)))
3649 : : {
3650 : 0 : error ("fastcall and regparm attributes are not compatible");
3651 : : }
3652 : 2 : if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3653 : : {
3654 : 0 : error ("fastcall and thiscall attributes are not compatible");
3655 : : }
3656 : : }
3657 : :
3658 : : /* Can combine stdcall with regparm and sseregparm. */
3659 : 0 : else if (is_attribute_p ("stdcall", name))
3660 : : {
3661 : 0 : if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
3662 : : {
3663 : 0 : error ("stdcall and cdecl attributes are not compatible");
3664 : : }
3665 : 0 : if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3666 : : {
3667 : 0 : error ("stdcall and fastcall attributes are not compatible");
3668 : : }
3669 : 0 : if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3670 : : {
3671 : 0 : error ("stdcall and thiscall attributes are not compatible");
3672 : : }
3673 : : }
3674 : :
3675 : : /* Can combine cdecl with regparm and sseregparm. */
3676 : 0 : else if (is_attribute_p ("cdecl", name))
3677 : : {
3678 : 0 : if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
3679 : : {
3680 : 0 : error ("stdcall and cdecl attributes are not compatible");
3681 : : }
3682 : 0 : if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3683 : : {
3684 : 0 : error ("fastcall and cdecl attributes are not compatible");
3685 : : }
3686 : 0 : if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3687 : : {
3688 : 0 : error ("cdecl and thiscall attributes are not compatible");
3689 : : }
3690 : : }
3691 : 0 : else if (is_attribute_p ("thiscall", name))
3692 : : {
3693 : 0 : if (TREE_CODE (*node) != METHOD_TYPE && pedantic)
3694 : 0 : warning (OPT_Wattributes, "%qE attribute is used for non-class method",
3695 : : name);
3696 : 0 : if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
3697 : : {
3698 : 0 : error ("stdcall and thiscall attributes are not compatible");
3699 : : }
3700 : 0 : if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3701 : : {
3702 : 0 : error ("fastcall and thiscall attributes are not compatible");
3703 : : }
3704 : 0 : if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
3705 : : {
3706 : 0 : error ("cdecl and thiscall attributes are not compatible");
3707 : : }
3708 : 0 : if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node)))
3709 : : {
3710 : 0 : error ("regparm and thiscall attributes are not compatible");
3711 : : }
3712 : : }
3713 : :
3714 : : /* Can combine sseregparm with all attributes. */
3715 : :
3716 : : return NULL_TREE;
3717 : : }
3718 : :
3719 : : #ifndef CHECK_STACK_LIMIT
3720 : : #define CHECK_STACK_LIMIT (-1)
3721 : : #endif
3722 : :
3723 : : /* The transactional memory builtins are implicitly regparm or fastcall
3724 : : depending on the ABI. Override the generic do-nothing attribute that
3725 : : these builtins were declared with, and replace it with one of the two
3726 : : attributes that we expect elsewhere. */
3727 : :
3728 : : static tree
3729 : 34707 : ix86_handle_tm_regparm_attribute (tree *node, tree, tree,
3730 : : int flags, bool *no_add_attrs)
3731 : : {
3732 : 34707 : tree alt;
3733 : :
3734 : : /* In no case do we want to add the placeholder attribute. */
3735 : 34707 : *no_add_attrs = true;
3736 : :
3737 : : /* The 64-bit ABI is unchanged for transactional memory. */
3738 : 34707 : if (TARGET_64BIT)
3739 : : return NULL_TREE;
3740 : :
3741 : : /* ??? Is there a better way to validate 32-bit windows? We have
3742 : : cfun->machine->call_abi, but that seems to be set only for 64-bit. */
3743 : 0 : if (CHECK_STACK_LIMIT > 0)
3744 : : alt = tree_cons (get_identifier ("fastcall"), NULL, NULL);
3745 : : else
3746 : : {
3747 : 0 : alt = tree_cons (NULL, build_int_cst (NULL, 2), NULL);
3748 : 0 : alt = tree_cons (get_identifier ("regparm"), alt, NULL);
3749 : : }
3750 : 0 : decl_attributes (node, alt, flags);
3751 : :
3752 : 0 : return NULL_TREE;
3753 : : }
3754 : :
3755 : : /* Handle a "force_align_arg_pointer" attribute. */
3756 : :
3757 : : static tree
3758 : 5131 : ix86_handle_force_align_arg_pointer_attribute (tree *node, tree name,
3759 : : tree, int, bool *no_add_attrs)
3760 : : {
3761 : 5131 : if (TREE_CODE (*node) != FUNCTION_TYPE
3762 : 5131 : && TREE_CODE (*node) != METHOD_TYPE
3763 : : && TREE_CODE (*node) != FIELD_DECL
3764 : : && TREE_CODE (*node) != TYPE_DECL)
3765 : : {
3766 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3767 : : name);
3768 : 0 : *no_add_attrs = true;
3769 : : }
3770 : :
3771 : 5131 : return NULL_TREE;
3772 : : }
3773 : :
3774 : : /* Handle a "ms_struct" or "gcc_struct" attribute; arguments as in
3775 : : struct attribute_spec.handler. */
3776 : :
3777 : : static tree
3778 : 74 : ix86_handle_struct_attribute (tree *node, tree name, tree, int,
3779 : : bool *no_add_attrs)
3780 : : {
3781 : 74 : tree *type = NULL;
3782 : 74 : if (DECL_P (*node))
3783 : : {
3784 : 0 : if (TREE_CODE (*node) == TYPE_DECL)
3785 : 0 : type = &TREE_TYPE (*node);
3786 : : }
3787 : : else
3788 : : type = node;
3789 : :
3790 : 74 : if (!(type && RECORD_OR_UNION_TYPE_P (*type)))
3791 : : {
3792 : 0 : warning (OPT_Wattributes, "%qE attribute ignored",
3793 : : name);
3794 : 0 : *no_add_attrs = true;
3795 : : }
3796 : :
3797 : 74 : else if ((is_attribute_p ("ms_struct", name)
3798 : 62 : && lookup_attribute ("gcc_struct", TYPE_ATTRIBUTES (*type)))
3799 : 136 : || ((is_attribute_p ("gcc_struct", name)
3800 : 12 : && lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (*type)))))
3801 : : {
3802 : 0 : warning (OPT_Wattributes, "%qE incompatible attribute ignored",
3803 : : name);
3804 : 0 : *no_add_attrs = true;
3805 : : }
3806 : :
3807 : 74 : return NULL_TREE;
3808 : : }
3809 : :
3810 : : /* Handle a "callee_pop_aggregate_return" attribute; arguments as
3811 : : in struct attribute_spec handler. */
3812 : :
3813 : : static tree
3814 : 0 : ix86_handle_callee_pop_aggregate_return (tree *node, tree name, tree args, int,
3815 : : bool *no_add_attrs)
3816 : : {
3817 : 0 : if (TREE_CODE (*node) != FUNCTION_TYPE
3818 : 0 : && TREE_CODE (*node) != METHOD_TYPE
3819 : : && TREE_CODE (*node) != FIELD_DECL
3820 : : && TREE_CODE (*node) != TYPE_DECL)
3821 : : {
3822 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3823 : : name);
3824 : 0 : *no_add_attrs = true;
3825 : 0 : return NULL_TREE;
3826 : : }
3827 : 0 : if (TARGET_64BIT)
3828 : : {
3829 : 0 : warning (OPT_Wattributes, "%qE attribute only available for 32-bit",
3830 : : name);
3831 : 0 : *no_add_attrs = true;
3832 : 0 : return NULL_TREE;
3833 : : }
3834 : 0 : if (is_attribute_p ("callee_pop_aggregate_return", name))
3835 : : {
3836 : 0 : tree cst;
3837 : :
3838 : 0 : cst = TREE_VALUE (args);
3839 : 0 : if (TREE_CODE (cst) != INTEGER_CST)
3840 : : {
3841 : 0 : warning (OPT_Wattributes,
3842 : : "%qE attribute requires an integer constant argument",
3843 : : name);
3844 : 0 : *no_add_attrs = true;
3845 : : }
3846 : 0 : else if (compare_tree_int (cst, 0) != 0
3847 : 0 : && compare_tree_int (cst, 1) != 0)
3848 : : {
3849 : 0 : warning (OPT_Wattributes,
3850 : : "argument to %qE attribute is neither zero, nor one",
3851 : : name);
3852 : 0 : *no_add_attrs = true;
3853 : : }
3854 : :
3855 : 0 : return NULL_TREE;
3856 : : }
3857 : :
3858 : : return NULL_TREE;
3859 : : }
3860 : :
3861 : : /* Handle a "ms_abi" or "sysv" attribute; arguments as in
3862 : : struct attribute_spec.handler. */
3863 : :
3864 : : static tree
3865 : 1592642 : ix86_handle_abi_attribute (tree *node, tree name, tree, int,
3866 : : bool *no_add_attrs)
3867 : : {
3868 : 1592642 : if (TREE_CODE (*node) != FUNCTION_TYPE
3869 : 1592642 : && TREE_CODE (*node) != METHOD_TYPE
3870 : : && TREE_CODE (*node) != FIELD_DECL
3871 : : && TREE_CODE (*node) != TYPE_DECL)
3872 : : {
3873 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3874 : : name);
3875 : 0 : *no_add_attrs = true;
3876 : 0 : return NULL_TREE;
3877 : : }
3878 : :
3879 : : /* Can combine regparm with all attributes but fastcall. */
3880 : 1592642 : if (is_attribute_p ("ms_abi", name))
3881 : : {
3882 : 816554 : if (lookup_attribute ("sysv_abi", TYPE_ATTRIBUTES (*node)))
3883 : : {
3884 : 0 : error ("%qs and %qs attributes are not compatible",
3885 : : "ms_abi", "sysv_abi");
3886 : : }
3887 : :
3888 : 816554 : return NULL_TREE;
3889 : : }
3890 : 776088 : else if (is_attribute_p ("sysv_abi", name))
3891 : : {
3892 : 776088 : if (lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (*node)))
3893 : : {
3894 : 0 : error ("%qs and %qs attributes are not compatible",
3895 : : "ms_abi", "sysv_abi");
3896 : : }
3897 : :
3898 : 776088 : return NULL_TREE;
3899 : : }
3900 : :
3901 : : return NULL_TREE;
3902 : : }
3903 : :
3904 : : static tree
3905 : 121 : ix86_handle_fndecl_attribute (tree *node, tree name, tree args, int,
3906 : : bool *no_add_attrs)
3907 : : {
3908 : 121 : if (TREE_CODE (*node) != FUNCTION_DECL)
3909 : : {
3910 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3911 : : name);
3912 : 0 : *no_add_attrs = true;
3913 : : }
3914 : :
3915 : 121 : if (is_attribute_p ("indirect_branch", name))
3916 : : {
3917 : 17 : tree cst = TREE_VALUE (args);
3918 : 17 : if (TREE_CODE (cst) != STRING_CST)
3919 : : {
3920 : 0 : warning (OPT_Wattributes,
3921 : : "%qE attribute requires a string constant argument",
3922 : : name);
3923 : 0 : *no_add_attrs = true;
3924 : : }
3925 : 17 : else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
3926 : 15 : && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
3927 : 10 : && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
3928 : 24 : && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
3929 : : {
3930 : 0 : warning (OPT_Wattributes,
3931 : : "argument to %qE attribute is not "
3932 : : "(keep|thunk|thunk-inline|thunk-extern)", name);
3933 : 0 : *no_add_attrs = true;
3934 : : }
3935 : : }
3936 : :
3937 : 121 : if (is_attribute_p ("function_return", name))
3938 : : {
3939 : 12 : tree cst = TREE_VALUE (args);
3940 : 12 : if (TREE_CODE (cst) != STRING_CST)
3941 : : {
3942 : 0 : warning (OPT_Wattributes,
3943 : : "%qE attribute requires a string constant argument",
3944 : : name);
3945 : 0 : *no_add_attrs = true;
3946 : : }
3947 : 12 : else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
3948 : 10 : && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
3949 : 6 : && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
3950 : 15 : && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
3951 : : {
3952 : 0 : warning (OPT_Wattributes,
3953 : : "argument to %qE attribute is not "
3954 : : "(keep|thunk|thunk-inline|thunk-extern)", name);
3955 : 0 : *no_add_attrs = true;
3956 : : }
3957 : : }
3958 : :
3959 : 121 : return NULL_TREE;
3960 : : }
3961 : :
3962 : : static tree
3963 : 169 : ix86_handle_call_saved_registers_attribute (tree *node, tree name, tree,
3964 : : int, bool *)
3965 : : {
3966 : 169 : const char *attr1 = nullptr;
3967 : 169 : const char *attr2 = nullptr;
3968 : :
3969 : 169 : if (is_attribute_p ("no_callee_saved_registers", name))
3970 : : {
3971 : : /* Disallow preserve_none and no_caller_saved_registers
3972 : : attributes. */
3973 : 78 : attr1 = "no_callee_saved_registers";
3974 : 78 : if (lookup_attribute ("preserve_none", TYPE_ATTRIBUTES (*node)))
3975 : : attr2 = "preserve_none";
3976 : 77 : else if (lookup_attribute ("no_caller_saved_registers",
3977 : 77 : TYPE_ATTRIBUTES (*node)))
3978 : : attr2 = "no_caller_saved_registers";
3979 : : }
3980 : 91 : else if (is_attribute_p ("no_caller_saved_registers", name))
3981 : : {
3982 : : /* Disallow preserve_none and no_callee_saved_registers
3983 : : attributes. */
3984 : 52 : attr1 = "no_caller_saved_registers";
3985 : 52 : if (lookup_attribute ("preserve_none", TYPE_ATTRIBUTES (*node)))
3986 : : attr2 = "preserve_none";
3987 : 51 : else if (lookup_attribute ("no_callee_saved_registers",
3988 : 51 : TYPE_ATTRIBUTES (*node)))
3989 : : attr2 = "no_callee_saved_registers";
3990 : : }
3991 : 39 : else if (is_attribute_p ("preserve_none", name))
3992 : : {
3993 : : /* Disallow no_callee_saved_registers and no_caller_saved_registers
3994 : : attributes. */
3995 : 39 : attr1 = "preserve_none";
3996 : 39 : if (lookup_attribute ("no_callee_saved_registers",
3997 : 39 : TYPE_ATTRIBUTES (*node)))
3998 : : attr2 = "no_caller_saved_registers";
3999 : 39 : else if (lookup_attribute ("no_callee_saved_registers",
4000 : 39 : TYPE_ATTRIBUTES (*node)))
4001 : : attr2 = "no_callee_saved_registers";
4002 : : }
4003 : :
4004 : : if (attr2)
4005 : 3 : error ("%qs and %qs attributes are not compatible", attr1, attr2);
4006 : :
4007 : 169 : return NULL_TREE;
4008 : : }
4009 : :
4010 : : static tree
4011 : 129 : ix86_handle_interrupt_attribute (tree *node, tree, tree, int, bool *)
4012 : : {
4013 : : /* DECL_RESULT and DECL_ARGUMENTS do not exist there yet,
4014 : : but the function type contains args and return type data. */
4015 : 129 : tree func_type = *node;
4016 : 129 : tree return_type = TREE_TYPE (func_type);
4017 : :
4018 : 129 : int nargs = 0;
4019 : 129 : tree current_arg_type = TYPE_ARG_TYPES (func_type);
4020 : 129 : while (current_arg_type
4021 : 642 : && ! VOID_TYPE_P (TREE_VALUE (current_arg_type)))
4022 : : {
4023 : 192 : if (nargs == 0)
4024 : : {
4025 : 128 : if (! POINTER_TYPE_P (TREE_VALUE (current_arg_type)))
4026 : 2 : error ("interrupt service routine should have a pointer "
4027 : : "as the first argument");
4028 : : }
4029 : 64 : else if (nargs == 1)
4030 : : {
4031 : 64 : if (TREE_CODE (TREE_VALUE (current_arg_type)) != INTEGER_TYPE
4032 : 64 : || TYPE_MODE (TREE_VALUE (current_arg_type)) != word_mode)
4033 : 2 : error ("interrupt service routine should have %qs "
4034 : : "as the second argument",
4035 : 2 : TARGET_64BIT
4036 : 2 : ? (TARGET_X32 ? "unsigned long long int"
4037 : : : "unsigned long int")
4038 : : : "unsigned int");
4039 : : }
4040 : 192 : nargs++;
4041 : 192 : current_arg_type = TREE_CHAIN (current_arg_type);
4042 : : }
4043 : 129 : if (!nargs || nargs > 2)
4044 : 1 : error ("interrupt service routine can only have a pointer argument "
4045 : : "and an optional integer argument");
4046 : 129 : if (! VOID_TYPE_P (return_type))
4047 : 1 : error ("interrupt service routine must return %<void%>");
4048 : :
4049 : 129 : return NULL_TREE;
4050 : : }
4051 : :
4052 : : /* Handle fentry_name / fentry_section attribute. */
4053 : :
4054 : : static tree
4055 : 4 : ix86_handle_fentry_name (tree *node, tree name, tree args,
4056 : : int, bool *no_add_attrs)
4057 : : {
4058 : 4 : if (TREE_CODE (*node) == FUNCTION_DECL
4059 : 8 : && TREE_CODE (TREE_VALUE (args)) == STRING_CST)
4060 : : /* Do nothing else, just set the attribute. We'll get at
4061 : : it later with lookup_attribute. */
4062 : : ;
4063 : : else
4064 : : {
4065 : 0 : warning (OPT_Wattributes, "%qE attribute ignored", name);
4066 : 0 : *no_add_attrs = true;
4067 : : }
4068 : :
4069 : 4 : return NULL_TREE;
4070 : : }
4071 : :
4072 : : /* Handle a "nodirect_extern_access" attribute; arguments as in
4073 : : struct attribute_spec.handler. */
4074 : :
4075 : : static tree
4076 : 11 : handle_nodirect_extern_access_attribute (tree *pnode, tree name,
4077 : : tree ARG_UNUSED (args),
4078 : : int ARG_UNUSED (flags),
4079 : : bool *no_add_attrs)
4080 : : {
4081 : 11 : tree node = *pnode;
4082 : :
4083 : 11 : if (VAR_OR_FUNCTION_DECL_P (node))
4084 : : {
4085 : 7 : if ((!TREE_STATIC (node) && TREE_CODE (node) != FUNCTION_DECL
4086 : 18 : && !DECL_EXTERNAL (node)) || !TREE_PUBLIC (node))
4087 : : {
4088 : 0 : warning (OPT_Wattributes,
4089 : : "%qE attribute have effect only on public objects", name);
4090 : 0 : *no_add_attrs = true;
4091 : : }
4092 : : }
4093 : : else
4094 : : {
4095 : 0 : warning (OPT_Wattributes, "%qE attribute ignored", name);
4096 : 0 : *no_add_attrs = true;
4097 : : }
4098 : :
4099 : 11 : return NULL_TREE;
4100 : : }
4101 : :
4102 : : /* Table of valid machine attributes. */
4103 : : static const attribute_spec ix86_gnu_attributes[] =
4104 : : {
4105 : : /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
4106 : : affects_type_identity, handler, exclude } */
4107 : : /* Stdcall attribute says callee is responsible for popping arguments
4108 : : if they are not variable. */
4109 : : { "stdcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4110 : : NULL },
4111 : : /* Fastcall attribute says callee is responsible for popping arguments
4112 : : if they are not variable. */
4113 : : { "fastcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4114 : : NULL },
4115 : : /* Thiscall attribute says callee is responsible for popping arguments
4116 : : if they are not variable. */
4117 : : { "thiscall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4118 : : NULL },
4119 : : /* Cdecl attribute says the callee is a normal C declaration */
4120 : : { "cdecl", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4121 : : NULL },
4122 : : /* Regparm attribute specifies how many integer arguments are to be
4123 : : passed in registers. */
4124 : : { "regparm", 1, 1, false, true, true, true, ix86_handle_cconv_attribute,
4125 : : NULL },
4126 : : /* Sseregparm attribute says we are using x86_64 calling conventions
4127 : : for FP arguments. */
4128 : : { "sseregparm", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4129 : : NULL },
4130 : : /* The transactional memory builtins are implicitly regparm or fastcall
4131 : : depending on the ABI. Override the generic do-nothing attribute that
4132 : : these builtins were declared with. */
4133 : : { "*tm regparm", 0, 0, false, true, true, true,
4134 : : ix86_handle_tm_regparm_attribute, NULL },
4135 : : /* force_align_arg_pointer says this function realigns the stack at entry. */
4136 : : { "force_align_arg_pointer", 0, 0,
4137 : : false, true, true, false, ix86_handle_force_align_arg_pointer_attribute,
4138 : : NULL },
4139 : : #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
4140 : : { "dllimport", 0, 0, false, false, false, false, handle_dll_attribute,
4141 : : NULL },
4142 : : { "dllexport", 0, 0, false, false, false, false, handle_dll_attribute,
4143 : : NULL },
4144 : : { "shared", 0, 0, true, false, false, false,
4145 : : ix86_handle_shared_attribute, NULL },
4146 : : #endif
4147 : : { "ms_struct", 0, 0, false, false, false, false,
4148 : : ix86_handle_struct_attribute, NULL },
4149 : : { "gcc_struct", 0, 0, false, false, false, false,
4150 : : ix86_handle_struct_attribute, NULL },
4151 : : #ifdef SUBTARGET_ATTRIBUTE_TABLE
4152 : : SUBTARGET_ATTRIBUTE_TABLE,
4153 : : #endif
4154 : : /* ms_abi and sysv_abi calling convention function attributes. */
4155 : : { "ms_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute, NULL },
4156 : : { "sysv_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute,
4157 : : NULL },
4158 : : { "ms_abi va_list", 0, 0, false, false, false, false, NULL, NULL },
4159 : : { "sysv_abi va_list", 0, 0, false, false, false, false, NULL, NULL },
4160 : : { "ms_hook_prologue", 0, 0, true, false, false, false,
4161 : : ix86_handle_fndecl_attribute, NULL },
4162 : : { "callee_pop_aggregate_return", 1, 1, false, true, true, true,
4163 : : ix86_handle_callee_pop_aggregate_return, NULL },
4164 : : { "interrupt", 0, 0, false, true, true, false,
4165 : : ix86_handle_interrupt_attribute, NULL },
4166 : : { "no_caller_saved_registers", 0, 0, false, true, true, false,
4167 : : ix86_handle_call_saved_registers_attribute, NULL },
4168 : : { "preserve_none", 0, 0, false, true, true, true,
4169 : : ix86_handle_call_saved_registers_attribute, NULL },
4170 : : { "no_callee_saved_registers", 0, 0, false, true, true, true,
4171 : : ix86_handle_call_saved_registers_attribute, NULL },
4172 : : { "naked", 0, 0, true, false, false, false,
4173 : : ix86_handle_fndecl_attribute, NULL },
4174 : : { "indirect_branch", 1, 1, true, false, false, false,
4175 : : ix86_handle_fndecl_attribute, NULL },
4176 : : { "function_return", 1, 1, true, false, false, false,
4177 : : ix86_handle_fndecl_attribute, NULL },
4178 : : { "indirect_return", 0, 0, false, true, true, false,
4179 : : NULL, NULL },
4180 : : { "fentry_name", 1, 1, true, false, false, false,
4181 : : ix86_handle_fentry_name, NULL },
4182 : : { "fentry_section", 1, 1, true, false, false, false,
4183 : : ix86_handle_fentry_name, NULL },
4184 : : { "cf_check", 0, 0, true, false, false, false,
4185 : : ix86_handle_fndecl_attribute, NULL },
4186 : : { "nodirect_extern_access", 0, 0, true, false, false, false,
4187 : : handle_nodirect_extern_access_attribute, NULL }
4188 : : };
4189 : :
4190 : : const scoped_attribute_specs ix86_gnu_attribute_table =
4191 : : {
4192 : : "gnu", { ix86_gnu_attributes }
4193 : : };
4194 : :
4195 : : #include "gt-i386-options.h"
|