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 : 1821 : ix86_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait,
341 : : const char *name)
342 : : {
343 : 1821 : switch (trait)
344 : : {
345 : 363 : case omp_device_kind:
346 : 363 : return strcmp (name, "cpu") == 0;
347 : 642 : case omp_device_arch:
348 : 642 : if (strcmp (name, "x86") == 0)
349 : : return 1;
350 : 638 : if (TARGET_64BIT)
351 : : {
352 : 638 : if (TARGET_X32)
353 : 0 : return strcmp (name, "x32") == 0;
354 : : else
355 : 638 : 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 : 74949305 : ix86_function_specific_save (struct cl_target_option *ptr,
695 : : struct gcc_options *opts,
696 : : struct gcc_options */* opts_set */)
697 : : {
698 : 74949305 : ptr->arch = ix86_arch;
699 : 74949305 : ptr->schedule = ix86_schedule;
700 : 74949305 : ptr->prefetch_sse = ix86_prefetch_sse;
701 : 74949305 : ptr->tune = ix86_tune;
702 : 74949305 : ptr->branch_cost = ix86_branch_cost;
703 : 74949305 : ptr->tune_defaulted = ix86_tune_defaulted;
704 : 74949305 : ptr->arch_specified = ix86_arch_specified;
705 : 74949305 : ptr->x_ix86_apx_features = opts->x_ix86_apx_features;
706 : 74949305 : ptr->x_ix86_isa_flags_explicit = opts->x_ix86_isa_flags_explicit;
707 : 74949305 : ptr->x_ix86_isa_flags2_explicit = opts->x_ix86_isa_flags2_explicit;
708 : 74949305 : ptr->x_recip_mask_explicit = opts->x_recip_mask_explicit;
709 : 74949305 : ptr->x_ix86_arch_string = opts->x_ix86_arch_string;
710 : 74949305 : ptr->x_ix86_tune_string = opts->x_ix86_tune_string;
711 : 74949305 : ptr->x_ix86_asm_dialect = opts->x_ix86_asm_dialect;
712 : 74949305 : ptr->x_ix86_branch_cost = opts->x_ix86_branch_cost;
713 : 74949305 : ptr->x_ix86_dump_tunes = opts->x_ix86_dump_tunes;
714 : 74949305 : ptr->x_ix86_force_align_arg_pointer = opts->x_ix86_force_align_arg_pointer;
715 : 74949305 : ptr->x_ix86_force_drap = opts->x_ix86_force_drap;
716 : 74949305 : ptr->x_ix86_recip_name = opts->x_ix86_recip_name;
717 : 74949305 : ptr->x_ix86_section_threshold = opts->x_ix86_section_threshold;
718 : 74949305 : ptr->x_ix86_sse2avx = opts->x_ix86_sse2avx;
719 : 74949305 : ptr->x_ix86_stack_protector_guard = opts->x_ix86_stack_protector_guard;
720 : 74949305 : ptr->x_ix86_stringop_alg = opts->x_ix86_stringop_alg;
721 : 74949305 : ptr->x_ix86_tls_dialect = opts->x_ix86_tls_dialect;
722 : 74949305 : ptr->x_ix86_tune_ctrl_string = opts->x_ix86_tune_ctrl_string;
723 : 74949305 : ptr->x_ix86_tune_memcpy_strategy = opts->x_ix86_tune_memcpy_strategy;
724 : 74949305 : ptr->x_ix86_tune_memset_strategy = opts->x_ix86_tune_memset_strategy;
725 : 74949305 : 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 : 74949305 : gcc_assert (ptr->arch == ix86_arch);
730 : 74949305 : gcc_assert (ptr->schedule == ix86_schedule);
731 : 74949305 : gcc_assert (ptr->tune == ix86_tune);
732 : 74949305 : gcc_assert (ptr->branch_cost == ix86_branch_cost);
733 : 74949305 : }
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 : 52436379 : ix86_function_specific_restore (struct gcc_options *opts,
832 : : struct gcc_options */* opts_set */,
833 : : struct cl_target_option *ptr)
834 : : {
835 : 52436379 : enum processor_type old_tune = ix86_tune;
836 : 52436379 : enum processor_type old_arch = ix86_arch;
837 : 52436379 : unsigned HOST_WIDE_INT ix86_arch_mask;
838 : 52436379 : int i;
839 : :
840 : : /* We don't change -fPIC. */
841 : 52436379 : opts->x_flag_pic = flag_pic;
842 : :
843 : 52436379 : ix86_arch = (enum processor_type) ptr->arch;
844 : 52436379 : ix86_schedule = (enum attr_cpu) ptr->schedule;
845 : 52436379 : ix86_tune = (enum processor_type) ptr->tune;
846 : 52436379 : ix86_prefetch_sse = ptr->prefetch_sse;
847 : 52436379 : ix86_tune_defaulted = ptr->tune_defaulted;
848 : 52436379 : ix86_arch_specified = ptr->arch_specified;
849 : 52436379 : opts->x_ix86_apx_features = ptr->x_ix86_apx_features;
850 : 52436379 : opts->x_ix86_isa_flags_explicit = ptr->x_ix86_isa_flags_explicit;
851 : 52436379 : opts->x_ix86_isa_flags2_explicit = ptr->x_ix86_isa_flags2_explicit;
852 : 52436379 : opts->x_recip_mask_explicit = ptr->x_recip_mask_explicit;
853 : 52436379 : opts->x_ix86_arch_string = ptr->x_ix86_arch_string;
854 : 52436379 : opts->x_ix86_tune_string = ptr->x_ix86_tune_string;
855 : 52436379 : opts->x_ix86_asm_dialect = ptr->x_ix86_asm_dialect;
856 : 52436379 : opts->x_ix86_branch_cost = ptr->x_ix86_branch_cost;
857 : 52436379 : opts->x_ix86_dump_tunes = ptr->x_ix86_dump_tunes;
858 : 52436379 : opts->x_ix86_force_align_arg_pointer = ptr->x_ix86_force_align_arg_pointer;
859 : 52436379 : opts->x_ix86_force_drap = ptr->x_ix86_force_drap;
860 : 52436379 : opts->x_ix86_recip_name = ptr->x_ix86_recip_name;
861 : 52436379 : opts->x_ix86_section_threshold = ptr->x_ix86_section_threshold;
862 : 52436379 : opts->x_ix86_sse2avx = ptr->x_ix86_sse2avx;
863 : 52436379 : opts->x_ix86_stack_protector_guard = ptr->x_ix86_stack_protector_guard;
864 : 52436379 : opts->x_ix86_stringop_alg = ptr->x_ix86_stringop_alg;
865 : 52436379 : opts->x_ix86_tls_dialect = ptr->x_ix86_tls_dialect;
866 : 52436379 : opts->x_ix86_tune_ctrl_string = ptr->x_ix86_tune_ctrl_string;
867 : 52436379 : opts->x_ix86_tune_memcpy_strategy = ptr->x_ix86_tune_memcpy_strategy;
868 : 52436379 : opts->x_ix86_tune_memset_strategy = ptr->x_ix86_tune_memset_strategy;
869 : 52436379 : opts->x_ix86_tune_no_default = ptr->x_ix86_tune_no_default;
870 : 52436379 : 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 : 52436379 : if (opts->x_optimize_size)
874 : 699820 : ix86_cost = &ix86_size_cost;
875 : : else
876 : 51736559 : ix86_cost = ix86_tune_cost;
877 : :
878 : : /* Recreate the arch feature tests if the arch changed */
879 : 52436379 : 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 : 52436379 : if (old_tune != ix86_tune)
889 : 33215 : set_ix86_tune_features (opts, ix86_tune, false);
890 : 52436379 : }
891 : :
892 : : /* Adjust target options after streaming them in. This is mainly about
893 : : reconciling them with global options. */
894 : :
895 : : void
896 : 23134 : 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 : 23134 : 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 : 22796 : 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 : 23134 : }
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 : 48362366 : parse_mtune_ctrl_str (struct gcc_options *opts, bool dump)
1746 : : {
1747 : 48362366 : if (!opts->x_ix86_tune_ctrl_string)
1748 : : return;
1749 : :
1750 : 58121 : char *next_feature_string = NULL;
1751 : 58121 : char *curr_feature_string = xstrdup (opts->x_ix86_tune_ctrl_string);
1752 : 58121 : char *orig = curr_feature_string;
1753 : 58187 : int i;
1754 : 58187 : do
1755 : : {
1756 : 58187 : bool clear = false;
1757 : :
1758 : 58187 : next_feature_string = strchr (curr_feature_string, ',');
1759 : 58187 : if (next_feature_string)
1760 : 66 : *next_feature_string++ = '\0';
1761 : 58187 : if (*curr_feature_string == '^')
1762 : : {
1763 : 87 : curr_feature_string++;
1764 : 87 : clear = true;
1765 : : }
1766 : :
1767 : 58187 : if (!strcmp (curr_feature_string, "use_gather"))
1768 : : {
1769 : 4 : ix86_tune_features[X86_TUNE_USE_GATHER_2PARTS] = !clear;
1770 : 4 : ix86_tune_features[X86_TUNE_USE_GATHER_4PARTS] = !clear;
1771 : 4 : ix86_tune_features[X86_TUNE_USE_GATHER_8PARTS] = !clear;
1772 : 4 : 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 : 58187 : curr_feature_string = next_feature_string;
1807 : : }
1808 : 58187 : while (curr_feature_string);
1809 : 58121 : free (orig);
1810 : : }
1811 : :
1812 : : /* Helper function to set ix86_tune_features. IX86_TUNE is the
1813 : : processor type. */
1814 : :
1815 : : static void
1816 : 48362366 : set_ix86_tune_features (struct gcc_options *opts,
1817 : : enum processor_type ix86_tune, bool dump)
1818 : : {
1819 : 48362366 : unsigned HOST_WIDE_INT ix86_tune_mask = HOST_WIDE_INT_1U << ix86_tune;
1820 : 48362366 : int i;
1821 : :
1822 : 5900208652 : for (i = 0; i < X86_TUNE_LAST; ++i)
1823 : : {
1824 : 5851846286 : if (ix86_tune_no_default)
1825 : 0 : ix86_tune_features[i] = 0;
1826 : : else
1827 : 5851846286 : ix86_tune_features[i]
1828 : 5851846286 : = !!(initial_ix86_tune_features[i] & ix86_tune_mask);
1829 : : }
1830 : :
1831 : 48362366 : 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 : 48362366 : parse_mtune_ctrl_str (opts, dump);
1840 : :
1841 : : /* mgather/mscatter option would overwrite -mtune-crtl option. */
1842 : 48362366 : if (OPTION_SET_P (ix86_use_gather))
1843 : : {
1844 : 97891 : ix86_tune_features[X86_TUNE_USE_GATHER_2PARTS] = ix86_use_gather;
1845 : 97891 : ix86_tune_features[X86_TUNE_USE_GATHER_4PARTS] = ix86_use_gather;
1846 : 97891 : ix86_tune_features[X86_TUNE_USE_GATHER_8PARTS] = ix86_use_gather;
1847 : : }
1848 : :
1849 : 48362366 : if (OPTION_SET_P (ix86_use_scatter))
1850 : : {
1851 : 0 : ix86_tune_features[X86_TUNE_USE_SCATTER_2PARTS] = ix86_use_scatter;
1852 : 0 : ix86_tune_features[X86_TUNE_USE_SCATTER_4PARTS] = ix86_use_scatter;
1853 : 0 : ix86_tune_features[X86_TUNE_USE_SCATTER_8PARTS] = ix86_use_scatter;
1854 : : }
1855 : 48362366 : }
1856 : :
1857 : :
1858 : : /* Default align_* from the processor table. */
1859 : :
1860 : : static void
1861 : 100393756 : ix86_default_align (struct gcc_options *opts)
1862 : : {
1863 : : /* -falign-foo without argument: supply one. */
1864 : 100393756 : if (opts->x_flag_align_loops && !opts->x_str_align_loops)
1865 : 131888 : opts->x_str_align_loops = processor_cost_table[ix86_tune]->align_loop;
1866 : 100393756 : if (opts->x_flag_align_jumps && !opts->x_str_align_jumps)
1867 : 131889 : opts->x_str_align_jumps = processor_cost_table[ix86_tune]->align_jump;
1868 : 100393756 : if (opts->x_flag_align_labels && !opts->x_str_align_labels)
1869 : 131889 : opts->x_str_align_labels = processor_cost_table[ix86_tune]->align_label;
1870 : 100393756 : if (opts->x_flag_align_functions && !opts->x_str_align_functions)
1871 : 131884 : opts->x_str_align_functions = processor_cost_table[ix86_tune]->align_func;
1872 : 100393756 : }
1873 : :
1874 : : #ifndef USE_IX86_FRAME_POINTER
1875 : : #define USE_IX86_FRAME_POINTER 0
1876 : : #endif
1877 : :
1878 : : /* (Re)compute option overrides affected by optimization levels in
1879 : : target-specific ways. */
1880 : :
1881 : : static void
1882 : 100393756 : ix86_recompute_optlev_based_flags (struct gcc_options *opts,
1883 : : struct gcc_options *opts_set)
1884 : : {
1885 : : /* Set the default values for switches whose default depends on TARGET_64BIT
1886 : : in case they weren't overwritten by command line options. */
1887 : 100393756 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
1888 : : {
1889 : 98461246 : if (opts->x_optimize >= 1)
1890 : 94522204 : SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer,
1891 : : !USE_IX86_FRAME_POINTER);
1892 : 98461246 : if (opts->x_flag_asynchronous_unwind_tables
1893 : 98461246 : && TARGET_64BIT_MS_ABI)
1894 : 272696 : SET_OPTION_IF_UNSET (opts, opts_set, flag_unwind_tables, 1);
1895 : 98461246 : if (opts->x_flag_asynchronous_unwind_tables == 2)
1896 : 283245 : opts->x_flag_unwind_tables
1897 : 283245 : = opts->x_flag_asynchronous_unwind_tables = 1;
1898 : 98461246 : if (opts->x_flag_pcc_struct_return == 2)
1899 : 283275 : opts->x_flag_pcc_struct_return = 0;
1900 : : }
1901 : : else
1902 : : {
1903 : 1932510 : if (opts->x_optimize >= 1)
1904 : 1932007 : SET_OPTION_IF_UNSET (opts, opts_set, flag_omit_frame_pointer,
1905 : : !(USE_IX86_FRAME_POINTER || opts->x_optimize_size));
1906 : 1932510 : if (opts->x_flag_asynchronous_unwind_tables == 2)
1907 : 7120 : opts->x_flag_asynchronous_unwind_tables = !USE_IX86_FRAME_POINTER;
1908 : 1932510 : if (opts->x_flag_pcc_struct_return == 2)
1909 : : {
1910 : : /* Intel MCU psABI specifies that -freg-struct-return should
1911 : : be on. Instead of setting DEFAULT_PCC_STRUCT_RETURN to 0,
1912 : : we check -miamcu so that -freg-struct-return is always
1913 : : turned on if -miamcu is used. */
1914 : 7126 : if (TARGET_IAMCU_P (opts->x_target_flags))
1915 : 0 : opts->x_flag_pcc_struct_return = 0;
1916 : : else
1917 : 7126 : opts->x_flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
1918 : : }
1919 : : }
1920 : :
1921 : : /* Keep nonleaf frame pointers. */
1922 : 100393756 : if (opts->x_flag_omit_frame_pointer)
1923 : 95965447 : opts->x_target_flags &= ~MASK_OMIT_LEAF_FRAME_POINTER;
1924 : 4428309 : else if (TARGET_OMIT_LEAF_FRAME_POINTER_P (opts->x_target_flags))
1925 : 0 : opts->x_flag_omit_frame_pointer = 1;
1926 : 100393756 : }
1927 : :
1928 : : /* Implement part of TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */
1929 : :
1930 : : static void
1931 : 100393756 : ix86_override_options_after_change_1 (struct gcc_options *opts,
1932 : : struct gcc_options *opts_set)
1933 : : {
1934 : : #define OPTS_SET_P(OPTION) opts_set->x_ ## OPTION
1935 : : #define OPTS(OPTION) opts->x_ ## OPTION
1936 : :
1937 : : /* Disable unrolling small loops when there's explicit
1938 : : -f{,no}unroll-loop. */
1939 : 100393756 : if ((OPTS_SET_P (flag_unroll_loops))
1940 : 99674866 : || (OPTS_SET_P (flag_unroll_all_loops)
1941 : 126 : && OPTS (flag_unroll_all_loops)))
1942 : : {
1943 : 719016 : if (!OPTS_SET_P (ix86_unroll_only_small_loops))
1944 : 719016 : OPTS (ix86_unroll_only_small_loops) = 0;
1945 : : /* Re-enable -frename-registers and -fweb if funroll-loops
1946 : : enabled. */
1947 : 719016 : if (!OPTS_SET_P (flag_web))
1948 : 719008 : OPTS (flag_web) = OPTS (flag_unroll_loops);
1949 : 719016 : if (!OPTS_SET_P (flag_rename_registers))
1950 : 719014 : OPTS (flag_rename_registers) = OPTS (flag_unroll_loops);
1951 : : /* -fcunroll-grow-size default follws -f[no]-unroll-loops. */
1952 : 719016 : if (!OPTS_SET_P (flag_cunroll_grow_size))
1953 : 719016 : OPTS (flag_cunroll_grow_size)
1954 : 1438032 : = (OPTS (flag_unroll_loops)
1955 : 44 : || OPTS (flag_peel_loops)
1956 : 1438032 : || OPTS (optimize) >= 3);
1957 : : }
1958 : : else
1959 : : {
1960 : 99674740 : if (!OPTS_SET_P (flag_cunroll_grow_size))
1961 : 99674740 : OPTS (flag_cunroll_grow_size)
1962 : 199349480 : = (OPTS (flag_peel_loops)
1963 : 103730263 : || OPTS (optimize) >= 3);
1964 : : }
1965 : :
1966 : : #undef OPTS
1967 : : #undef OPTS_SET_P
1968 : 100393756 : }
1969 : :
1970 : : /* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */
1971 : :
1972 : : void
1973 : 52064605 : ix86_override_options_after_change (void)
1974 : : {
1975 : 52064605 : ix86_default_align (&global_options);
1976 : :
1977 : 52064605 : ix86_recompute_optlev_based_flags (&global_options, &global_options_set);
1978 : :
1979 : 52064605 : ix86_override_options_after_change_1 (&global_options, &global_options_set);
1980 : 52064605 : }
1981 : :
1982 : : /* Clear stack slot assignments remembered from previous functions.
1983 : : This is called from INIT_EXPANDERS once before RTL is emitted for each
1984 : : function. */
1985 : :
1986 : : static struct machine_function *
1987 : 185637505 : ix86_init_machine_status (void)
1988 : : {
1989 : 185637505 : struct machine_function *f;
1990 : :
1991 : 185637505 : f = ggc_cleared_alloc<machine_function> ();
1992 : 185637505 : f->call_abi = ix86_abi;
1993 : 185637505 : f->stack_frame_required = true;
1994 : 185637505 : f->silent_p = true;
1995 : :
1996 : 185637505 : return f;
1997 : : }
1998 : :
1999 : : /* Override various settings based on options. If MAIN_ARGS_P, the
2000 : : options are from the command line, otherwise they are from
2001 : : attributes. Return true if there's an error related to march
2002 : : option. */
2003 : :
2004 : : static bool
2005 : 48329155 : ix86_option_override_internal (bool main_args_p,
2006 : : struct gcc_options *opts,
2007 : : struct gcc_options *opts_set)
2008 : : {
2009 : 48329155 : unsigned int i;
2010 : 48329155 : unsigned HOST_WIDE_INT ix86_arch_mask;
2011 : 48329155 : const bool ix86_tune_specified = (opts->x_ix86_tune_string != NULL);
2012 : :
2013 : : /* -mrecip options. */
2014 : 48329155 : static struct
2015 : : {
2016 : : const char *string; /* option name */
2017 : : unsigned int mask; /* mask bits to set */
2018 : : }
2019 : : const recip_options[] =
2020 : : {
2021 : : { "all", RECIP_MASK_ALL },
2022 : : { "none", RECIP_MASK_NONE },
2023 : : { "div", RECIP_MASK_DIV },
2024 : : { "sqrt", RECIP_MASK_SQRT },
2025 : : { "vec-div", RECIP_MASK_VEC_DIV },
2026 : : { "vec-sqrt", RECIP_MASK_VEC_SQRT },
2027 : : };
2028 : :
2029 : : /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
2030 : : TARGET_64BIT_DEFAULT is true and TARGET_64BIT is false. */
2031 : 48329155 : if (TARGET_64BIT_DEFAULT && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2032 : 610985 : opts->x_ix86_isa_flags &= ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
2033 : : #ifdef TARGET_BI_ARCH
2034 : : else
2035 : : {
2036 : : #if TARGET_BI_ARCH == 1
2037 : : /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ABI_64
2038 : : is on and OPTION_MASK_ABI_X32 is off. We turn off
2039 : : OPTION_MASK_ABI_64 if OPTION_MASK_ABI_X32 is turned on by
2040 : : -mx32. */
2041 : 47718170 : if (TARGET_X32_P (opts->x_ix86_isa_flags))
2042 : 107 : opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
2043 : : #else
2044 : : /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
2045 : : on and OPTION_MASK_ABI_64 is off. We turn off
2046 : : OPTION_MASK_ABI_X32 if OPTION_MASK_ABI_64 is turned on by
2047 : : -m64 or OPTION_MASK_CODE16 is turned on by -m16. */
2048 : : if (TARGET_LP64_P (opts->x_ix86_isa_flags)
2049 : : || TARGET_16BIT_P (opts->x_ix86_isa_flags))
2050 : : opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
2051 : : #endif
2052 : 47718170 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2053 : 47718170 : && TARGET_IAMCU_P (opts->x_target_flags))
2054 : 0 : sorry ("Intel MCU psABI isn%'t supported in %s mode",
2055 : : TARGET_X32_P (opts->x_ix86_isa_flags) ? "x32" : "64-bit");
2056 : : }
2057 : : #endif
2058 : :
2059 : 48329155 : if (TARGET_X32_P (opts->x_ix86_isa_flags))
2060 : : {
2061 : : /* Always turn on OPTION_MASK_ISA_64BIT and turn off
2062 : : OPTION_MASK_ABI_64 for TARGET_X32. */
2063 : 107 : opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
2064 : 107 : opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
2065 : : }
2066 : 48329048 : else if (TARGET_16BIT_P (opts->x_ix86_isa_flags))
2067 : 6 : opts->x_ix86_isa_flags &= ~(OPTION_MASK_ISA_64BIT
2068 : : | OPTION_MASK_ABI_X32
2069 : : | OPTION_MASK_ABI_64);
2070 : 48329042 : else if (TARGET_LP64_P (opts->x_ix86_isa_flags))
2071 : : {
2072 : : /* Always turn on OPTION_MASK_ISA_64BIT and turn off
2073 : : OPTION_MASK_ABI_X32 for TARGET_LP64. */
2074 : 47718057 : opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
2075 : 47718057 : opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
2076 : : }
2077 : :
2078 : : #ifdef SUBTARGET_OVERRIDE_OPTIONS
2079 : : SUBTARGET_OVERRIDE_OPTIONS;
2080 : : #endif
2081 : :
2082 : : #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
2083 : : SUBSUBTARGET_OVERRIDE_OPTIONS;
2084 : : #endif
2085 : :
2086 : : #ifdef HAVE_LD_BROKEN_PE_DWARF5
2087 : : /* If the PE linker has broken DWARF 5 support, make
2088 : : DWARF 4 the default. */
2089 : : if (TARGET_PECOFF)
2090 : : SET_OPTION_IF_UNSET (opts, opts_set, dwarf_version, 4);
2091 : : #endif
2092 : :
2093 : : /* -fPIC is the default for x86_64. */
2094 : 48329155 : if (TARGET_MACHO && TARGET_64BIT_P (opts->x_ix86_isa_flags))
2095 : : opts->x_flag_pic = 2;
2096 : :
2097 : : /* Need to check -mtune=generic first. */
2098 : 48329155 : if (opts->x_ix86_tune_string)
2099 : : {
2100 : : /* As special support for cross compilers we read -mtune=native
2101 : : as -mtune=generic. With native compilers we won't see the
2102 : : -mtune=native, as it was changed by the driver. */
2103 : 48307916 : if (!strcmp (opts->x_ix86_tune_string, "native"))
2104 : 0 : opts->x_ix86_tune_string = "generic";
2105 : 48307916 : else if (!strcmp (opts->x_ix86_tune_string, "x86-64"))
2106 : 0 : warning (OPT_Wdeprecated,
2107 : : main_args_p
2108 : : ? G_("%<-mtune=x86-64%> is deprecated; use %<-mtune=k8%> "
2109 : : "or %<-mtune=generic%> instead as appropriate")
2110 : : : G_("%<target(\"tune=x86-64\")%> is deprecated; use "
2111 : : "%<target(\"tune=k8\")%> or %<target(\"tune=generic\")%>"
2112 : : " instead as appropriate"));
2113 : : }
2114 : : else
2115 : : {
2116 : 21239 : if (opts->x_ix86_arch_string)
2117 : 21239 : opts->x_ix86_tune_string = opts->x_ix86_arch_string;
2118 : 21239 : if (!opts->x_ix86_tune_string)
2119 : : {
2120 : 0 : opts->x_ix86_tune_string = processor_names[TARGET_CPU_DEFAULT];
2121 : 0 : ix86_tune_defaulted = 1;
2122 : : }
2123 : :
2124 : : /* opts->x_ix86_tune_string is set to opts->x_ix86_arch_string
2125 : : or defaulted. We need to use a sensible tune option. */
2126 : 21239 : if (startswith (opts->x_ix86_tune_string, "x86-64")
2127 : 21239 : && (opts->x_ix86_tune_string[6] == '\0'
2128 : 378 : || (!strcmp (opts->x_ix86_tune_string + 6, "-v2")
2129 : 338 : || !strcmp (opts->x_ix86_tune_string + 6, "-v3")
2130 : 132 : || !strcmp (opts->x_ix86_tune_string + 6, "-v4"))))
2131 : 570 : opts->x_ix86_tune_string = "generic";
2132 : : }
2133 : :
2134 : 48329155 : if (opts->x_ix86_stringop_alg == rep_prefix_8_byte
2135 : 10 : && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2136 : : {
2137 : : /* rep; movq isn't available in 32-bit code. */
2138 : 0 : error ("%<-mstringop-strategy=rep_8byte%> not supported for 32-bit code");
2139 : 0 : opts->x_ix86_stringop_alg = no_stringop;
2140 : : }
2141 : :
2142 : 48329155 : if (TARGET_APX_F_P (opts->x_ix86_isa_flags2)
2143 : 32203 : && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2144 : 0 : error ("%<-mapxf%> is not supported for 32-bit code");
2145 : 48329155 : else if (opts->x_ix86_apx_features != apx_none
2146 : 32217 : && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2147 : 0 : error ("%<-mapx-features=%> option is not supported for 32-bit code");
2148 : :
2149 : 48329155 : if (TARGET_UINTR_P (opts->x_ix86_isa_flags2)
2150 : 81523 : && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
2151 : 0 : error ("%<-muintr%> not supported for 32-bit code");
2152 : :
2153 : 48329155 : if (ix86_lam_type && !TARGET_LP64_P (opts->x_ix86_isa_flags))
2154 : 0 : error ("%<-mlam=%> option: [u48|u57] not supported for 32-bit code");
2155 : :
2156 : 48329155 : if (!opts->x_ix86_arch_string)
2157 : 0 : opts->x_ix86_arch_string
2158 : 0 : = TARGET_64BIT_P (opts->x_ix86_isa_flags)
2159 : 0 : ? "x86-64" : SUBTARGET32_DEFAULT_CPU;
2160 : : else
2161 : 48329155 : ix86_arch_specified = 1;
2162 : :
2163 : 48329155 : if (opts_set->x_ix86_pmode)
2164 : : {
2165 : 67 : if ((TARGET_LP64_P (opts->x_ix86_isa_flags)
2166 : 0 : && opts->x_ix86_pmode == PMODE_SI)
2167 : 67 : || (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
2168 : 0 : && opts->x_ix86_pmode == PMODE_DI))
2169 : 0 : error ("address mode %qs not supported in the %s bit mode",
2170 : : TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "short" : "long",
2171 : : TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "64" : "32");
2172 : : }
2173 : : else
2174 : 48329088 : opts->x_ix86_pmode = TARGET_LP64_P (opts->x_ix86_isa_flags)
2175 : 48329088 : ? PMODE_DI : PMODE_SI;
2176 : :
2177 : 48329155 : SET_OPTION_IF_UNSET (opts, opts_set, ix86_abi, DEFAULT_ABI);
2178 : :
2179 : 48329155 : if (opts->x_ix86_abi == MS_ABI && TARGET_X32_P (opts->x_ix86_isa_flags))
2180 : 1 : error ("%<-mabi=ms%> not supported with X32 ABI");
2181 : 48329155 : gcc_assert (opts->x_ix86_abi == SYSV_ABI || opts->x_ix86_abi == MS_ABI);
2182 : :
2183 : 48329155 : const char *abi_name = opts->x_ix86_abi == MS_ABI ? "ms" : "sysv";
2184 : 48329155 : if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS)
2185 : 2994 : && opts->x_ix86_abi != DEFAULT_ABI)
2186 : 7 : error ("%<-mabi=%s%> not supported with %<-fsanitize=address%>", abi_name);
2187 : 48329155 : if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS)
2188 : 141 : && opts->x_ix86_abi != DEFAULT_ABI)
2189 : 0 : error ("%<-mabi=%s%> not supported with %<-fsanitize=kernel-address%>",
2190 : : abi_name);
2191 : 48329155 : if ((opts->x_flag_sanitize & SANITIZE_THREAD)
2192 : 365 : && opts->x_ix86_abi != DEFAULT_ABI)
2193 : 2 : error ("%<-mabi=%s%> not supported with %<-fsanitize=thread%>", abi_name);
2194 : :
2195 : : /* Hwasan is supported with lam_u57 only. */
2196 : 48329155 : if (opts->x_flag_sanitize & SANITIZE_HWADDRESS)
2197 : : {
2198 : 540 : if (ix86_lam_type == lam_u48)
2199 : 0 : warning (0, "%<-mlam=u48%> is not compatible with Hardware-assisted "
2200 : : "AddressSanitizer, override to %<-mlam=u57%>");
2201 : 540 : ix86_lam_type = lam_u57;
2202 : : }
2203 : :
2204 : : /* For targets using ms ABI enable ms-extensions, if not
2205 : : explicit turned off. For non-ms ABI we turn off this
2206 : : option. */
2207 : 48329155 : SET_OPTION_IF_UNSET (opts, opts_set, flag_ms_extensions,
2208 : : (MS_ABI == DEFAULT_ABI));
2209 : :
2210 : 48329155 : if (opts_set->x_ix86_cmodel)
2211 : : {
2212 : 35471 : switch (opts->x_ix86_cmodel)
2213 : : {
2214 : 1 : case CM_SMALL:
2215 : 1 : case CM_SMALL_PIC:
2216 : 1 : if (opts->x_flag_pic)
2217 : 0 : opts->x_ix86_cmodel = CM_SMALL_PIC;
2218 : 1 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2219 : 0 : error ("code model %qs not supported in the %s bit mode",
2220 : : "small", "32");
2221 : : break;
2222 : :
2223 : 22387 : case CM_MEDIUM:
2224 : 22387 : case CM_MEDIUM_PIC:
2225 : 22387 : if (opts->x_flag_pic)
2226 : 22375 : opts->x_ix86_cmodel = CM_MEDIUM_PIC;
2227 : 22387 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2228 : 0 : error ("code model %qs not supported in the %s bit mode",
2229 : : "medium", "32");
2230 : 22387 : else if (TARGET_X32_P (opts->x_ix86_isa_flags))
2231 : 0 : error ("code model %qs not supported in x32 mode",
2232 : : "medium");
2233 : : break;
2234 : :
2235 : 13082 : case CM_LARGE:
2236 : 13082 : case CM_LARGE_PIC:
2237 : 13082 : if (opts->x_flag_pic)
2238 : 28 : opts->x_ix86_cmodel = CM_LARGE_PIC;
2239 : 13082 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2240 : 0 : error ("code model %qs not supported in the %s bit mode",
2241 : : "large", "32");
2242 : 13082 : else if (TARGET_X32_P (opts->x_ix86_isa_flags))
2243 : 0 : error ("code model %qs not supported in x32 mode",
2244 : : "large");
2245 : : break;
2246 : :
2247 : 0 : case CM_32:
2248 : 0 : if (opts->x_flag_pic)
2249 : 0 : error ("code model %s does not support PIC mode", "32");
2250 : 0 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2251 : 0 : error ("code model %qs not supported in the %s bit mode",
2252 : : "32", "64");
2253 : : break;
2254 : :
2255 : 1 : case CM_KERNEL:
2256 : 1 : if (opts->x_flag_pic)
2257 : : {
2258 : 0 : error ("code model %s does not support PIC mode", "kernel");
2259 : 0 : opts->x_ix86_cmodel = CM_32;
2260 : : }
2261 : 1 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2262 : 0 : error ("code model %qs not supported in the %s bit mode",
2263 : : "kernel", "32");
2264 : : break;
2265 : :
2266 : 0 : default:
2267 : 0 : gcc_unreachable ();
2268 : : }
2269 : : }
2270 : : else
2271 : : {
2272 : : /* For TARGET_64BIT and MS_ABI, force pic on, in order to enable the
2273 : : use of rip-relative addressing. This eliminates fixups that
2274 : : would otherwise be needed if this object is to be placed in a
2275 : : DLL, and is essentially just as efficient as direct addressing. */
2276 : 48293684 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2277 : : && (TARGET_RDOS || TARGET_PECOFF))
2278 : : opts->x_ix86_cmodel = CM_MEDIUM_PIC, opts->x_flag_pic = 1;
2279 : 48293684 : else if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2280 : 95023574 : opts->x_ix86_cmodel = opts->x_flag_pic ? CM_SMALL_PIC : CM_SMALL;
2281 : : else
2282 : 610991 : opts->x_ix86_cmodel = CM_32;
2283 : : }
2284 : 48329155 : if (TARGET_MACHO && opts->x_ix86_asm_dialect == ASM_INTEL)
2285 : : {
2286 : : error ("%<-masm=intel%> not supported in this configuration");
2287 : : opts->x_ix86_asm_dialect = ASM_ATT;
2288 : : }
2289 : 48329155 : if ((TARGET_64BIT_P (opts->x_ix86_isa_flags) != 0)
2290 : : != ((opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) != 0))
2291 : : sorry ("%i-bit mode not compiled in",
2292 : : (opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) ? 64 : 32);
2293 : :
2294 : : /* Last processor_alias_table must point to "generic" entry. */
2295 : 48329155 : gcc_checking_assert (strcmp (processor_alias_table[pta_size - 1].name,
2296 : : "generic") == 0);
2297 : 3853927633 : for (i = 0; i < pta_size; i++)
2298 : 3853927592 : if (! strcmp (opts->x_ix86_arch_string, processor_alias_table[i].name))
2299 : : {
2300 : 48329114 : if (!strcmp (opts->x_ix86_arch_string, "generic"))
2301 : : {
2302 : 2 : error (main_args_p
2303 : : ? G_("%<generic%> CPU can be used only for %<-mtune=%> "
2304 : : "switch")
2305 : : : G_("%<generic%> CPU can be used only for "
2306 : : "%<target(\"tune=\")%> attribute"));
2307 : 2 : return false;
2308 : : }
2309 : 48329112 : else if (!strcmp (opts->x_ix86_arch_string, "intel"))
2310 : : {
2311 : 1 : error (main_args_p
2312 : : ? G_("%<intel%> CPU can be used only for %<-mtune=%> "
2313 : : "switch")
2314 : : : G_("%<intel%> CPU can be used only for "
2315 : : "%<target(\"tune=\")%> attribute"));
2316 : 1 : return false;
2317 : : }
2318 : :
2319 : 48329111 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2320 : 48329111 : && !((processor_alias_table[i].flags & PTA_64BIT) != 0))
2321 : : {
2322 : 1 : error ("CPU you selected does not support x86-64 "
2323 : : "instruction set");
2324 : 1 : return false;
2325 : : }
2326 : :
2327 : 48329110 : ix86_schedule = processor_alias_table[i].schedule;
2328 : 48329110 : ix86_arch = processor_alias_table[i].processor;
2329 : :
2330 : : /* Default cpu tuning to the architecture, unless the table
2331 : : entry requests not to do this. Used by the x86-64 psABI
2332 : : micro-architecture levels. */
2333 : 48329110 : if ((processor_alias_table[i].flags & PTA_NO_TUNE) == 0)
2334 : 48001319 : ix86_tune = ix86_arch;
2335 : : else
2336 : 327791 : ix86_tune = PROCESSOR_GENERIC;
2337 : :
2338 : : /* Enable PTA flags that are enabled by default by a -march option. */
2339 : : #define TARGET_EXPLICIT_NO_SAHF_P(opts) (false)
2340 : : #define SET_TARGET_NO_SAHF(opts) {}
2341 : : #define TARGET_EXPLICIT_PREFETCH_SSE_P(opts) (false)
2342 : : #define SET_TARGET_PREFETCH_SSE(opts) {}
2343 : : #define TARGET_EXPLICIT_NO_TUNE_P(opts) (false)
2344 : : #define SET_TARGET_NO_TUNE(opts) {}
2345 : : #define TARGET_EXPLICIT_NO_80387_P(opts) (false)
2346 : : #define SET_TARGET_NO_80387(opts) {}
2347 : :
2348 : : #define DEF_PTA(NAME) \
2349 : : if (((processor_alias_table[i].flags & PTA_ ## NAME) != 0) \
2350 : : && PTA_ ## NAME != PTA_64BIT \
2351 : : && (TARGET_64BIT || (PTA_ ## NAME != PTA_UINTR \
2352 : : && PTA_ ## NAME != PTA_APX_F))\
2353 : : && !TARGET_EXPLICIT_ ## NAME ## _P (opts)) \
2354 : : SET_TARGET_ ## NAME (opts);
2355 : : #include "i386-isa.def"
2356 : : #undef DEF_PTA
2357 : :
2358 : :
2359 : 48329110 : if (!(TARGET_64BIT_P (opts->x_ix86_isa_flags)
2360 : 47718119 : && ((processor_alias_table[i].flags & PTA_NO_SAHF) != 0))
2361 : 49018289 : && !TARGET_EXPLICIT_SAHF_P (opts))
2362 : 1300159 : SET_TARGET_SAHF (opts);
2363 : :
2364 : 48329110 : if (((processor_alias_table[i].flags & PTA_ABM) != 0)
2365 : 5548 : && !TARGET_EXPLICIT_ABM_P (opts))
2366 : : {
2367 : 5537 : if (!TARGET_EXPLICIT_LZCNT_P (opts))
2368 : 5536 : SET_TARGET_LZCNT (opts);
2369 : 5537 : if (!TARGET_EXPLICIT_POPCNT_P (opts))
2370 : 5104 : SET_TARGET_POPCNT (opts);
2371 : : }
2372 : :
2373 : : /* Enable apx if apxf or apx_features are not
2374 : : explicitly set for -march. */
2375 : 48329110 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2376 : 47718119 : && ((processor_alias_table[i].flags & PTA_APX_F) != 0)
2377 : 173 : && !TARGET_EXPLICIT_APX_F_P (opts)
2378 : 48329283 : && !OPTION_SET_P (ix86_apx_features))
2379 : 173 : opts->x_ix86_apx_features = apx_all;
2380 : :
2381 : 48329110 : if ((processor_alias_table[i].flags
2382 : 48329110 : & (PTA_PREFETCH_SSE | PTA_SSE)) != 0)
2383 : 48329110 : ix86_prefetch_sse = true;
2384 : :
2385 : : /* Don't enable x87 instructions if only general registers are
2386 : : allowed by target("general-regs-only") function attribute or
2387 : : -mgeneral-regs-only. */
2388 : 48329110 : if (!(opts->x_ix86_target_flags & OPTION_MASK_GENERAL_REGS_ONLY)
2389 : 46089990 : && !(opts_set->x_target_flags & MASK_80387))
2390 : : {
2391 : 46089960 : if (((processor_alias_table[i].flags & PTA_NO_80387) != 0))
2392 : 0 : opts->x_target_flags &= ~MASK_80387;
2393 : : else
2394 : 46089960 : opts->x_target_flags |= MASK_80387;
2395 : : }
2396 : : break;
2397 : : }
2398 : :
2399 : 48329151 : if (i == pta_size)
2400 : : {
2401 : 43 : error (main_args_p
2402 : : ? G_("bad value %qs for %<-march=%> switch")
2403 : : : G_("bad value %qs for %<target(\"arch=\")%> attribute"),
2404 : : opts->x_ix86_arch_string);
2405 : :
2406 : 41 : auto_vec <const char *> candidates;
2407 : 4756 : for (i = 0; i < pta_size; i++)
2408 : 4715 : if (strcmp (processor_alias_table[i].name, "generic")
2409 : 4674 : && strcmp (processor_alias_table[i].name, "intel")
2410 : 9348 : && (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
2411 : 8036 : || ((processor_alias_table[i].flags & PTA_64BIT) != 0)))
2412 : 3321 : candidates.safe_push (processor_alias_table[i].name);
2413 : :
2414 : : #ifdef HAVE_LOCAL_CPU_DETECT
2415 : : /* Add also "native" as possible value. */
2416 : 41 : candidates.safe_push ("native");
2417 : : #endif
2418 : :
2419 : 41 : char *s;
2420 : 41 : const char *hint
2421 : 41 : = candidates_list_and_hint (opts->x_ix86_arch_string, s, candidates);
2422 : 41 : if (hint)
2423 : 3 : inform (input_location,
2424 : : main_args_p
2425 : : ? G_("valid arguments to %<-march=%> switch are: "
2426 : : "%s; did you mean %qs?")
2427 : : : G_("valid arguments to %<target(\"arch=\")%> attribute are: "
2428 : : "%s; did you mean %qs?"), s, hint);
2429 : : else
2430 : 40 : inform (input_location,
2431 : : main_args_p
2432 : : ? G_("valid arguments to %<-march=%> switch are: %s")
2433 : : : G_("valid arguments to %<target(\"arch=\")%> attribute "
2434 : : "are: %s"), s);
2435 : 41 : XDELETEVEC (s);
2436 : 41 : }
2437 : :
2438 : 48329151 : ix86_arch_mask = HOST_WIDE_INT_1U << ix86_arch;
2439 : 289974906 : for (i = 0; i < X86_ARCH_LAST; ++i)
2440 : 241645755 : ix86_arch_features[i] = !!(initial_ix86_arch_features[i] & ix86_arch_mask);
2441 : :
2442 : 5506733607 : for (i = 0; i < pta_size; i++)
2443 : 5506733562 : if (! strcmp (opts->x_ix86_tune_string, processor_alias_table[i].name)
2444 : 5506733562 : && (processor_alias_table[i].flags & PTA_NO_TUNE) == 0)
2445 : : {
2446 : 48329106 : ix86_schedule = processor_alias_table[i].schedule;
2447 : 48329106 : ix86_tune = processor_alias_table[i].processor;
2448 : 48329106 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2449 : : {
2450 : 47718115 : if (!((processor_alias_table[i].flags & PTA_64BIT) != 0))
2451 : : {
2452 : 0 : if (ix86_tune_defaulted)
2453 : : {
2454 : 0 : opts->x_ix86_tune_string = "x86-64";
2455 : 0 : for (i = 0; i < pta_size; i++)
2456 : 0 : if (! strcmp (opts->x_ix86_tune_string,
2457 : 0 : processor_alias_table[i].name))
2458 : : break;
2459 : 0 : ix86_schedule = processor_alias_table[i].schedule;
2460 : 0 : ix86_tune = processor_alias_table[i].processor;
2461 : : }
2462 : : else
2463 : 0 : error ("CPU you selected does not support x86-64 "
2464 : : "instruction set");
2465 : : }
2466 : : }
2467 : : /* Intel CPUs have always interpreted SSE prefetch instructions as
2468 : : NOPs; so, we can enable SSE prefetch instructions even when
2469 : : -mtune (rather than -march) points us to a processor that has them.
2470 : : However, the VIA C3 gives a SIGILL, so we only do that for i686 and
2471 : : higher processors. */
2472 : 48329106 : if (TARGET_CMOV
2473 : 48329106 : && ((processor_alias_table[i].flags
2474 : 48329106 : & (PTA_PREFETCH_SSE | PTA_SSE)) != 0))
2475 : 779789 : ix86_prefetch_sse = true;
2476 : : break;
2477 : : }
2478 : :
2479 : 48329151 : if (ix86_tune_specified && i == pta_size)
2480 : : {
2481 : 42 : error (main_args_p
2482 : : ? G_("bad value %qs for %<-mtune=%> switch")
2483 : : : G_("bad value %qs for %<target(\"tune=\")%> attribute"),
2484 : : opts->x_ix86_tune_string);
2485 : :
2486 : 40 : auto_vec <const char *> candidates;
2487 : 4640 : for (i = 0; i < pta_size; i++)
2488 : 4600 : if ((!TARGET_64BIT_P (opts->x_ix86_isa_flags)
2489 : 4600 : || ((processor_alias_table[i].flags & PTA_64BIT) != 0))
2490 : 12400 : && (processor_alias_table[i].flags & PTA_NO_TUNE) == 0)
2491 : 3200 : candidates.safe_push (processor_alias_table[i].name);
2492 : :
2493 : : #ifdef HAVE_LOCAL_CPU_DETECT
2494 : : /* Add also "native" as possible value. */
2495 : 40 : candidates.safe_push ("native");
2496 : : #endif
2497 : :
2498 : 40 : char *s;
2499 : 40 : const char *hint
2500 : 40 : = candidates_list_and_hint (opts->x_ix86_tune_string, s, candidates);
2501 : 40 : if (hint)
2502 : 1 : inform (input_location,
2503 : : main_args_p
2504 : : ? G_("valid arguments to %<-mtune=%> switch are: "
2505 : : "%s; did you mean %qs?")
2506 : : : G_("valid arguments to %<target(\"tune=\")%> attribute are: "
2507 : : "%s; did you mean %qs?"), s, hint);
2508 : : else
2509 : 41 : inform (input_location,
2510 : : main_args_p
2511 : : ? G_("valid arguments to %<-mtune=%> switch are: %s")
2512 : : : G_("valid arguments to %<target(\"tune=\")%> attribute "
2513 : : "are: %s"), s);
2514 : 40 : XDELETEVEC (s);
2515 : 40 : }
2516 : :
2517 : 48329151 : set_ix86_tune_features (opts, ix86_tune, opts->x_ix86_dump_tunes);
2518 : :
2519 : 48329151 : ix86_recompute_optlev_based_flags (opts, opts_set);
2520 : :
2521 : 48329151 : ix86_override_options_after_change_1 (opts, opts_set);
2522 : :
2523 : 48329151 : ix86_tune_cost = processor_cost_table[ix86_tune];
2524 : : /* TODO: ix86_cost should be chosen at instruction or function granuality
2525 : : so for cold code we use size_cost even in !optimize_size compilation. */
2526 : 48329151 : if (opts->x_optimize_size)
2527 : 692745 : ix86_cost = &ix86_size_cost;
2528 : : else
2529 : 47636406 : ix86_cost = ix86_tune_cost;
2530 : :
2531 : : /* Arrange to set up i386_stack_locals for all functions. */
2532 : 48329151 : init_machine_status = ix86_init_machine_status;
2533 : :
2534 : : /* Override APX flag here if ISA bit is set. */
2535 : 48329151 : if (TARGET_APX_F_P (opts->x_ix86_isa_flags2)
2536 : 32376 : && !OPTION_SET_P (ix86_apx_features))
2537 : 32376 : opts->x_ix86_apx_features = apx_all;
2538 : :
2539 : : /* Validate -mregparm= value. */
2540 : 48329151 : if (opts_set->x_ix86_regparm)
2541 : : {
2542 : 0 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2543 : 0 : warning (0, "%<-mregparm%> is ignored in 64-bit mode");
2544 : 0 : else if (TARGET_IAMCU_P (opts->x_target_flags))
2545 : 0 : warning (0, "%<-mregparm%> is ignored for Intel MCU psABI");
2546 : 0 : if (opts->x_ix86_regparm > REGPARM_MAX)
2547 : : {
2548 : 0 : error ("%<-mregparm=%d%> is not between 0 and %d",
2549 : 0 : opts->x_ix86_regparm, REGPARM_MAX);
2550 : 0 : opts->x_ix86_regparm = 0;
2551 : : }
2552 : : }
2553 : 48329151 : if (TARGET_IAMCU_P (opts->x_target_flags)
2554 : 48329151 : || TARGET_64BIT_P (opts->x_ix86_isa_flags))
2555 : 95367796 : opts->x_ix86_regparm = REGPARM_MAX;
2556 : :
2557 : : /* Default align_* from the processor table. */
2558 : 48329151 : ix86_default_align (&global_options);
2559 : :
2560 : : /* Provide default for -mbranch-cost= value. */
2561 : 48329151 : SET_OPTION_IF_UNSET (opts, opts_set, ix86_branch_cost,
2562 : : ix86_tune_cost->branch_cost);
2563 : :
2564 : 48329151 : if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2565 : : {
2566 : 47718160 : opts->x_target_flags
2567 : 47718160 : |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
2568 : :
2569 : 47718160 : if (!ix86_arch_specified)
2570 : 0 : opts->x_ix86_isa_flags
2571 : 0 : |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
2572 : :
2573 : 47718160 : if (!TARGET_128BIT_LONG_DOUBLE_P (opts->x_target_flags))
2574 : 1 : error ("%<-m96bit-long-double%> is not compatible with this target");
2575 : :
2576 : 47718160 : if (TARGET_RTD_P (opts->x_target_flags))
2577 : 0 : warning (0,
2578 : : main_args_p
2579 : : ? G_("%<-mrtd%> is ignored in 64bit mode")
2580 : : : G_("%<target(\"rtd\")%> is ignored in 64bit mode"));
2581 : : }
2582 : : else
2583 : : {
2584 : 610991 : opts->x_target_flags
2585 : : |= TARGET_SUBTARGET32_DEFAULT & ~opts_set->x_target_flags;
2586 : :
2587 : 610991 : if (!ix86_arch_specified)
2588 : 610991 : opts->x_ix86_isa_flags
2589 : : |= TARGET_SUBTARGET32_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
2590 : :
2591 : : /* i386 ABI does not specify red zone. It still makes sense to use it
2592 : : when programmer takes care to stack from being destroyed. */
2593 : 610991 : if (!(opts_set->x_target_flags & MASK_NO_RED_ZONE))
2594 : 610991 : opts->x_target_flags |= MASK_NO_RED_ZONE;
2595 : : }
2596 : :
2597 : : /* If we're doing fast math, we don't care about comparison order
2598 : : wrt NaNs. This lets us use a shorter comparison sequence. */
2599 : 48329151 : if (opts->x_flag_finite_math_only)
2600 : 974794 : opts->x_target_flags &= ~MASK_IEEE_FP;
2601 : :
2602 : : /* If the architecture always has an FPU, turn off NO_FANCY_MATH_387,
2603 : : since the insns won't need emulation. */
2604 : 48329151 : if (ix86_tune_features [X86_TUNE_ALWAYS_FANCY_MATH_387])
2605 : 48329151 : opts->x_target_flags &= ~MASK_NO_FANCY_MATH_387;
2606 : :
2607 : : /* Likewise, if the target doesn't have a 387, or we've specified
2608 : : software floating point, don't use 387 inline intrinsics. */
2609 : 48329151 : if (!TARGET_80387_P (opts->x_target_flags))
2610 : 2239142 : opts->x_target_flags |= MASK_NO_FANCY_MATH_387;
2611 : :
2612 : : /* Turn on MMX builtins for -msse. */
2613 : 48329151 : if (TARGET_SSE_P (opts->x_ix86_isa_flags))
2614 : 46148185 : opts->x_ix86_isa_flags
2615 : 46148185 : |= OPTION_MASK_ISA_MMX & ~opts->x_ix86_isa_flags_explicit;
2616 : :
2617 : : /* Enable SSE prefetch. */
2618 : 48329151 : if (TARGET_SSE_P (opts->x_ix86_isa_flags)
2619 : 2180966 : || (TARGET_PRFCHW_P (opts->x_ix86_isa_flags)
2620 : 18326 : && !TARGET_3DNOW_P (opts->x_ix86_isa_flags)))
2621 : 46166511 : ix86_prefetch_sse = true;
2622 : :
2623 : : /* Enable mwait/monitor instructions for -msse3. */
2624 : 48329151 : if (TARGET_SSE3_P (opts->x_ix86_isa_flags))
2625 : 45798895 : opts->x_ix86_isa_flags2
2626 : 45798895 : |= OPTION_MASK_ISA2_MWAIT & ~opts->x_ix86_isa_flags2_explicit;
2627 : :
2628 : : /* Enable popcnt instruction for -msse4.2 or -mabm. */
2629 : 48329151 : if (TARGET_SSE4_2_P (opts->x_ix86_isa_flags)
2630 : 2634515 : || TARGET_ABM_P (opts->x_ix86_isa_flags))
2631 : 45700713 : opts->x_ix86_isa_flags
2632 : 45700713 : |= OPTION_MASK_ISA_POPCNT & ~opts->x_ix86_isa_flags_explicit;
2633 : :
2634 : : /* Enable crc32 instruction for -msse4.2. */
2635 : 48329151 : if (TARGET_SSE4_2_P (opts->x_ix86_isa_flags))
2636 : 45694636 : opts->x_ix86_isa_flags
2637 : 45694636 : |= OPTION_MASK_ISA_CRC32 & ~opts->x_ix86_isa_flags_explicit;
2638 : :
2639 : : /* Enable lzcnt instruction for -mabm. */
2640 : 48329151 : if (TARGET_ABM_P(opts->x_ix86_isa_flags))
2641 : 67858 : opts->x_ix86_isa_flags
2642 : 67858 : |= OPTION_MASK_ISA_LZCNT & ~opts->x_ix86_isa_flags_explicit;
2643 : :
2644 : : /* Disable BMI, BMI2 and TBM instructions for -m16. */
2645 : 48329151 : if (TARGET_16BIT_P(opts->x_ix86_isa_flags))
2646 : 6 : opts->x_ix86_isa_flags
2647 : 6 : &= ~((OPTION_MASK_ISA_BMI | OPTION_MASK_ISA_BMI2 | OPTION_MASK_ISA_TBM)
2648 : 6 : & ~opts->x_ix86_isa_flags_explicit);
2649 : :
2650 : : /* Validate -mpreferred-stack-boundary= value or default it to
2651 : : PREFERRED_STACK_BOUNDARY_DEFAULT. */
2652 : 48329151 : ix86_preferred_stack_boundary = PREFERRED_STACK_BOUNDARY_DEFAULT;
2653 : 48329151 : if (opts_set->x_ix86_preferred_stack_boundary_arg)
2654 : : {
2655 : 1616 : int min = TARGET_64BIT_P (opts->x_ix86_isa_flags)? 3 : 2;
2656 : 1616 : int max = TARGET_SEH ? 4 : 12;
2657 : :
2658 : 1616 : if (opts->x_ix86_preferred_stack_boundary_arg < min
2659 : 1616 : || opts->x_ix86_preferred_stack_boundary_arg > max)
2660 : : {
2661 : 0 : if (min == max)
2662 : : error ("%<-mpreferred-stack-boundary%> is not supported "
2663 : : "for this target");
2664 : : else
2665 : 0 : error ("%<-mpreferred-stack-boundary=%d%> is not between %d and %d",
2666 : : opts->x_ix86_preferred_stack_boundary_arg, min, max);
2667 : : }
2668 : : else
2669 : 1616 : ix86_preferred_stack_boundary
2670 : 1616 : = (1 << opts->x_ix86_preferred_stack_boundary_arg) * BITS_PER_UNIT;
2671 : : }
2672 : :
2673 : : /* Set the default value for -mstackrealign. */
2674 : 48329151 : SET_OPTION_IF_UNSET (opts, opts_set, ix86_force_align_arg_pointer,
2675 : : STACK_REALIGN_DEFAULT);
2676 : :
2677 : 48329151 : ix86_default_incoming_stack_boundary = PREFERRED_STACK_BOUNDARY;
2678 : :
2679 : : /* Validate -mincoming-stack-boundary= value or default it to
2680 : : MIN_STACK_BOUNDARY/PREFERRED_STACK_BOUNDARY. */
2681 : 48329151 : ix86_incoming_stack_boundary = ix86_default_incoming_stack_boundary;
2682 : 48329151 : if (opts_set->x_ix86_incoming_stack_boundary_arg)
2683 : : {
2684 : 15 : int min = TARGET_64BIT_P (opts->x_ix86_isa_flags) ? 3 : 2;
2685 : :
2686 : 15 : if (opts->x_ix86_incoming_stack_boundary_arg < min
2687 : 15 : || opts->x_ix86_incoming_stack_boundary_arg > 12)
2688 : 0 : error ("%<-mincoming-stack-boundary=%d%> is not between %d and 12",
2689 : : opts->x_ix86_incoming_stack_boundary_arg, min);
2690 : : else
2691 : : {
2692 : 15 : ix86_user_incoming_stack_boundary
2693 : 15 : = (1 << opts->x_ix86_incoming_stack_boundary_arg) * BITS_PER_UNIT;
2694 : 15 : ix86_incoming_stack_boundary
2695 : 15 : = ix86_user_incoming_stack_boundary;
2696 : : }
2697 : : }
2698 : :
2699 : : #ifndef NO_PROFILE_COUNTERS
2700 : : if (flag_nop_mcount)
2701 : : error ("%<-mnop-mcount%> is not compatible with this target");
2702 : : #endif
2703 : 48329151 : if (flag_nop_mcount && flag_pic && !flag_plt)
2704 : 0 : error ("%<-mnop-mcount%> is not implemented for %<-fno-plt%>");
2705 : :
2706 : : /* Accept -msseregparm only if at least SSE support is enabled. */
2707 : 48329151 : if (TARGET_SSEREGPARM_P (opts->x_target_flags)
2708 : 0 : && ! TARGET_SSE_P (opts->x_ix86_isa_flags))
2709 : 0 : error (main_args_p
2710 : : ? G_("%<-msseregparm%> used without SSE enabled")
2711 : : : G_("%<target(\"sseregparm\")%> used without SSE enabled"));
2712 : :
2713 : 48329151 : if (opts_set->x_ix86_fpmath)
2714 : : {
2715 : 1300898 : if (opts->x_ix86_fpmath & FPMATH_SSE)
2716 : : {
2717 : 1258380 : if (!TARGET_SSE_P (opts->x_ix86_isa_flags))
2718 : : {
2719 : 45559 : if (TARGET_80387_P (opts->x_target_flags))
2720 : : {
2721 : 0 : warning (0, "SSE instruction set disabled, using 387 arithmetics");
2722 : 0 : opts->x_ix86_fpmath = FPMATH_387;
2723 : : }
2724 : : }
2725 : 1212821 : else if ((opts->x_ix86_fpmath & FPMATH_387)
2726 : 89 : && !TARGET_80387_P (opts->x_target_flags))
2727 : : {
2728 : 0 : warning (0, "387 instruction set disabled, using SSE arithmetics");
2729 : 0 : opts->x_ix86_fpmath = FPMATH_SSE;
2730 : : }
2731 : : }
2732 : : }
2733 : : /* For all chips supporting SSE2, -mfpmath=sse performs better than
2734 : : fpmath=387. The second is however default at many targets since the
2735 : : extra 80bit precision of temporaries is considered to be part of ABI.
2736 : : Overwrite the default at least for -ffast-math.
2737 : : TODO: -mfpmath=both seems to produce same performing code with bit
2738 : : smaller binaries. It is however not clear if register allocation is
2739 : : ready for this setting.
2740 : : Also -mfpmath=387 is overall a lot more compact (bout 4-5%) than SSE
2741 : : codegen. We may switch to 387 with -ffast-math for size optimized
2742 : : functions. */
2743 : 47028253 : else if (fast_math_flags_set_p (&global_options)
2744 : 47028253 : && TARGET_SSE2_P (opts->x_ix86_isa_flags))
2745 : 898766 : opts->x_ix86_fpmath = FPMATH_SSE;
2746 : : else
2747 : 48860440 : opts->x_ix86_fpmath = TARGET_FPMATH_DEFAULT_P (opts->x_ix86_isa_flags);
2748 : :
2749 : : /* Use external vectorized library in vectorizing intrinsics. */
2750 : 48329151 : if (opts_set->x_ix86_veclibabi_type)
2751 : 6 : switch (opts->x_ix86_veclibabi_type)
2752 : : {
2753 : 3 : case ix86_veclibabi_type_svml:
2754 : 3 : ix86_veclib_handler = &ix86_veclibabi_svml;
2755 : 3 : break;
2756 : :
2757 : 2 : case ix86_veclibabi_type_acml:
2758 : 2 : ix86_veclib_handler = &ix86_veclibabi_acml;
2759 : 2 : break;
2760 : :
2761 : 1 : case ix86_veclibabi_type_aocl:
2762 : 1 : ix86_veclib_handler = &ix86_veclibabi_aocl;
2763 : 1 : break;
2764 : :
2765 : 0 : default:
2766 : 0 : gcc_unreachable ();
2767 : : }
2768 : :
2769 : 48329151 : if (ix86_tune_features [X86_TUNE_ACCUMULATE_OUTGOING_ARGS]
2770 : 228536 : && !(opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
2771 : 228536 : opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
2772 : :
2773 : : /* If stack probes are required, the space used for large function
2774 : : arguments on the stack must also be probed, so enable
2775 : : -maccumulate-outgoing-args so this happens in the prologue. */
2776 : 48329151 : if (TARGET_STACK_PROBE_P (opts->x_target_flags)
2777 : 22 : && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
2778 : : {
2779 : 22 : if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
2780 : 0 : warning (0,
2781 : : main_args_p
2782 : : ? G_("stack probing requires %<-maccumulate-outgoing-args%> "
2783 : : "for correctness")
2784 : : : G_("stack probing requires "
2785 : : "%<target(\"accumulate-outgoing-args\")%> for "
2786 : : "correctness"));
2787 : 22 : opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
2788 : : }
2789 : :
2790 : : /* Stack realignment without -maccumulate-outgoing-args requires %ebp,
2791 : : so enable -maccumulate-outgoing-args when %ebp is fixed. */
2792 : 48329151 : if (fixed_regs[BP_REG]
2793 : 3 : && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
2794 : : {
2795 : 3 : if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
2796 : 2 : warning (0,
2797 : : main_args_p
2798 : : ? G_("fixed ebp register requires "
2799 : : "%<-maccumulate-outgoing-args%>")
2800 : : : G_("fixed ebp register requires "
2801 : : "%<target(\"accumulate-outgoing-args\")%>"));
2802 : 3 : opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
2803 : : }
2804 : :
2805 : : /* Figure out what ASM_GENERATE_INTERNAL_LABEL builds as a prefix. */
2806 : 48329151 : {
2807 : 48329151 : char *p;
2808 : 48329151 : ASM_GENERATE_INTERNAL_LABEL (internal_label_prefix, "LX", 0);
2809 : 48329151 : p = strchr (internal_label_prefix, 'X');
2810 : 48329151 : internal_label_prefix_len = p - internal_label_prefix;
2811 : 48329151 : *p = '\0';
2812 : : }
2813 : :
2814 : : /* When scheduling description is not available, disable scheduler pass
2815 : : so it won't slow down the compilation and make x87 code slower. */
2816 : 48329151 : if (!TARGET_SCHEDULE)
2817 : 12 : opts->x_flag_schedule_insns_after_reload = opts->x_flag_schedule_insns = 0;
2818 : :
2819 : 48329151 : SET_OPTION_IF_UNSET (opts, opts_set, param_simultaneous_prefetches,
2820 : : ix86_tune_cost->simultaneous_prefetches);
2821 : 48329151 : SET_OPTION_IF_UNSET (opts, opts_set, param_l1_cache_line_size,
2822 : : ix86_tune_cost->prefetch_block);
2823 : 48329151 : SET_OPTION_IF_UNSET (opts, opts_set, param_l1_cache_size,
2824 : : ix86_tune_cost->l1_cache_size);
2825 : 48329151 : SET_OPTION_IF_UNSET (opts, opts_set, param_l2_cache_size,
2826 : : ix86_tune_cost->l2_cache_size);
2827 : :
2828 : : /* 64B is the accepted value for these for all x86. */
2829 : 48329151 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
2830 : : param_destruct_interfere_size, 64);
2831 : 48329151 : SET_OPTION_IF_UNSET (&global_options, &global_options_set,
2832 : : param_construct_interfere_size, 64);
2833 : :
2834 : : /* Enable sw prefetching at -O3 for CPUS that prefetching is helpful. */
2835 : 48329151 : if (opts->x_flag_prefetch_loop_arrays < 0
2836 : 48329092 : && HAVE_prefetch
2837 : 48329053 : && (opts->x_optimize >= 3 || opts->x_flag_profile_use)
2838 : 2382626 : && !opts->x_optimize_size
2839 : 2382622 : && TARGET_SOFTWARE_PREFETCHING_BENEFICIAL)
2840 : 50 : opts->x_flag_prefetch_loop_arrays = 1;
2841 : :
2842 : : /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
2843 : : can be opts->x_optimized to ap = __builtin_next_arg (0). */
2844 : 48329151 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && !opts->x_flag_split_stack)
2845 : 15245 : targetm.expand_builtin_va_start = NULL;
2846 : :
2847 : : #ifdef USE_IX86_CLD
2848 : : /* Use -mcld by default for 32-bit code if configured with --enable-cld. */
2849 : : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2850 : : opts->x_target_flags |= MASK_CLD & ~opts_set->x_target_flags;
2851 : : #endif
2852 : :
2853 : : /* Set the default value for -mfentry. */
2854 : 48329151 : if (!opts_set->x_flag_fentry)
2855 : 48329100 : opts->x_flag_fentry = (TARGET_SEH
2856 : 48329100 : || (TARGET_64BIT_P (opts->x_ix86_isa_flags)
2857 : : && ENABLE_X86_64_MFENTRY));
2858 : : else
2859 : : {
2860 : 51 : if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && opts->x_flag_pic
2861 : 0 : && opts->x_flag_fentry)
2862 : 0 : sorry ("%<-mfentry%> isn%'t supported for 32-bit in combination "
2863 : : "with %<-fpic%>");
2864 : : else if (TARGET_SEH && !opts->x_flag_fentry)
2865 : : sorry ("%<-mno-fentry%> isn%'t compatible with SEH");
2866 : : }
2867 : :
2868 : : #ifdef OPTION_GLIBC_P
2869 : : /* -mfentry is supported only on glibc targets. */
2870 : 48329151 : if (!opts->x_flag_fentry
2871 : 611004 : && OPTION_GLIBC_P (opts)
2872 : 611004 : && (TARGET_64BIT_P (opts->x_ix86_isa_flags) || !opts->x_flag_pic)
2873 : 306176 : && opts->x_flag_shrink_wrap
2874 : 305664 : && opts->x_profile_flag)
2875 : 2 : warning (0, "%<-pg%> without %<-mfentry%> may be unreliable with "
2876 : : "shrink wrapping");
2877 : : #endif
2878 : :
2879 : 48329151 : if (TARGET_SEH && TARGET_CALL_MS2SYSV_XLOGUES)
2880 : : sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH");
2881 : :
2882 : 48329151 : if (!(opts_set->x_target_flags & MASK_VZEROUPPER)
2883 : 48127253 : && flag_expensive_optimizations
2884 : 44558423 : && !optimize_size)
2885 : 43865681 : opts->x_target_flags |= MASK_VZEROUPPER;
2886 : 48329151 : if (!(opts_set->x_target_flags & MASK_STV))
2887 : 48324223 : opts->x_target_flags |= MASK_STV;
2888 : : /* Disable STV if -mpreferred-stack-boundary={2,3} or
2889 : : -mincoming-stack-boundary={2,3} or -mstackrealign - the needed
2890 : : stack realignment will be extra cost the pass doesn't take into
2891 : : account and the pass can't realign the stack. */
2892 : 48329151 : if (ix86_preferred_stack_boundary < 128
2893 : 48329143 : || ix86_incoming_stack_boundary < 128
2894 : 48329142 : || opts->x_ix86_force_align_arg_pointer)
2895 : 1617 : opts->x_target_flags &= ~MASK_STV;
2896 : 48329151 : if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL]
2897 : 14497 : && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_LOAD))
2898 : 14497 : opts->x_target_flags |= MASK_AVX256_SPLIT_UNALIGNED_LOAD;
2899 : 48314654 : else if (!main_args_p
2900 : 48024284 : && ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL])
2901 : 48024284 : opts->x_target_flags &= ~MASK_AVX256_SPLIT_UNALIGNED_LOAD;
2902 : :
2903 : 48329151 : if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL]
2904 : 15239 : && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_STORE))
2905 : 15239 : opts->x_target_flags |= MASK_AVX256_SPLIT_UNALIGNED_STORE;
2906 : 48313912 : else if (!main_args_p
2907 : 48023589 : && ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL])
2908 : 48023589 : opts->x_target_flags &= ~MASK_AVX256_SPLIT_UNALIGNED_STORE;
2909 : :
2910 : : /* Enable 128-bit AVX instruction generation
2911 : : for the auto-vectorizer. */
2912 : 48329151 : if (ix86_tune_features[X86_TUNE_AVX128_OPTIMAL]
2913 : 836 : && (opts_set->x_prefer_vector_width_type == PVW_NONE))
2914 : 825 : opts->x_prefer_vector_width_type = PVW_AVX128;
2915 : :
2916 : : /* Use 256-bit AVX instruction generation
2917 : : in the auto-vectorizer. */
2918 : 48329151 : if (ix86_tune_features[X86_TUNE_AVX256_OPTIMAL]
2919 : 214732 : && (opts_set->x_prefer_vector_width_type == PVW_NONE))
2920 : 88221 : opts->x_prefer_vector_width_type = PVW_AVX256;
2921 : :
2922 : 48329151 : if (opts_set->x_ix86_move_max == PVW_NONE)
2923 : : {
2924 : : /* Set the maximum number of bits can be moved from memory to
2925 : : memory efficiently. */
2926 : 48329138 : if (opts_set->x_prefer_vector_width_type != PVW_NONE)
2927 : 944694 : opts->x_ix86_move_max = opts->x_prefer_vector_width_type;
2928 : 47384444 : else if (ix86_tune_features[X86_TUNE_AVX512_MOVE_BY_PIECES])
2929 : 4161 : opts->x_ix86_move_max = PVW_AVX512;
2930 : 47380283 : else if (ix86_tune_features[X86_TUNE_AVX256_MOVE_BY_PIECES])
2931 : 404143 : opts->x_ix86_move_max = PVW_AVX256;
2932 : : else
2933 : : {
2934 : 46976140 : opts->x_ix86_move_max = opts->x_prefer_vector_width_type;
2935 : 46976140 : if (opts->x_ix86_move_max == PVW_NONE)
2936 : : {
2937 : 46975376 : if (TARGET_AVX512F_P (opts->x_ix86_isa_flags))
2938 : 43049841 : opts->x_ix86_move_max = PVW_AVX512;
2939 : : /* Align with vectorizer to avoid potential STLF issue. */
2940 : 3925535 : else if (TARGET_AVX_P (opts->x_ix86_isa_flags))
2941 : 1339754 : opts->x_ix86_move_max = PVW_AVX256;
2942 : : else
2943 : 2585781 : opts->x_ix86_move_max = PVW_AVX128;
2944 : : }
2945 : : }
2946 : : }
2947 : :
2948 : 48329151 : if (opts->x_ix86_recip_name)
2949 : : {
2950 : 0 : char *p = ASTRDUP (opts->x_ix86_recip_name);
2951 : 0 : char *q;
2952 : 0 : unsigned int mask;
2953 : 0 : bool invert;
2954 : :
2955 : 0 : while ((q = strtok (p, ",")) != NULL)
2956 : : {
2957 : 0 : p = NULL;
2958 : 0 : if (*q == '!')
2959 : : {
2960 : 0 : invert = true;
2961 : 0 : q++;
2962 : : }
2963 : : else
2964 : : invert = false;
2965 : :
2966 : 0 : if (!strcmp (q, "default"))
2967 : : mask = RECIP_MASK_ALL;
2968 : : else
2969 : : {
2970 : 0 : for (i = 0; i < ARRAY_SIZE (recip_options); i++)
2971 : 0 : if (!strcmp (q, recip_options[i].string))
2972 : : {
2973 : 0 : mask = recip_options[i].mask;
2974 : 0 : break;
2975 : : }
2976 : :
2977 : 0 : if (i == ARRAY_SIZE (recip_options))
2978 : : {
2979 : 0 : error ("unknown option for %<-mrecip=%s%>", q);
2980 : 0 : invert = false;
2981 : 0 : mask = RECIP_MASK_NONE;
2982 : : }
2983 : : }
2984 : :
2985 : 0 : opts->x_recip_mask_explicit |= mask;
2986 : 0 : if (invert)
2987 : 0 : opts->x_recip_mask &= ~mask;
2988 : : else
2989 : 0 : opts->x_recip_mask |= mask;
2990 : : }
2991 : : }
2992 : :
2993 : 48329151 : if (TARGET_RECIP_P (opts->x_target_flags))
2994 : 13046 : opts->x_recip_mask |= RECIP_MASK_ALL & ~opts->x_recip_mask_explicit;
2995 : 48316105 : else if (opts_set->x_target_flags & MASK_RECIP)
2996 : 2 : opts->x_recip_mask &= ~(RECIP_MASK_ALL & ~opts->x_recip_mask_explicit);
2997 : :
2998 : : /* Default long double to 64-bit for 32-bit Bionic and to __float128
2999 : : for 64-bit Bionic. Also default long double to 64-bit for Intel
3000 : : MCU psABI. */
3001 : 48329151 : if ((TARGET_HAS_BIONIC || TARGET_IAMCU)
3002 : 8 : && !(opts_set->x_target_flags
3003 : : & (MASK_LONG_DOUBLE_64 | MASK_LONG_DOUBLE_128)))
3004 : 2 : opts->x_target_flags |= (TARGET_64BIT
3005 : 2 : ? MASK_LONG_DOUBLE_128
3006 : : : MASK_LONG_DOUBLE_64);
3007 : :
3008 : : /* Only one of them can be active. */
3009 : 48329151 : gcc_assert ((opts->x_target_flags & MASK_LONG_DOUBLE_64) == 0
3010 : : || (opts->x_target_flags & MASK_LONG_DOUBLE_128) == 0);
3011 : :
3012 : : /* Handle stack protector */
3013 : 48329151 : if (!opts_set->x_ix86_stack_protector_guard)
3014 : : {
3015 : : #ifdef TARGET_THREAD_SSP_OFFSET
3016 : 48329148 : if (!TARGET_HAS_BIONIC)
3017 : 48329140 : opts->x_ix86_stack_protector_guard = SSP_TLS;
3018 : : else
3019 : : #endif
3020 : 8 : opts->x_ix86_stack_protector_guard = SSP_GLOBAL;
3021 : : }
3022 : :
3023 : 48329151 : if (opts_set->x_ix86_stack_protector_guard_offset_str)
3024 : : {
3025 : 1 : char *endp;
3026 : 1 : const char *str = opts->x_ix86_stack_protector_guard_offset_str;
3027 : :
3028 : 1 : errno = 0;
3029 : 1 : int64_t offset;
3030 : :
3031 : : #if defined(INT64_T_IS_LONG)
3032 : 1 : offset = strtol (str, &endp, 0);
3033 : : #else
3034 : : offset = strtoll (str, &endp, 0);
3035 : : #endif
3036 : :
3037 : 1 : if (!*str || *endp || errno)
3038 : 0 : error ("%qs is not a valid number "
3039 : : "in %<-mstack-protector-guard-offset=%>", str);
3040 : :
3041 : 1 : if (!IN_RANGE (offset, HOST_WIDE_INT_C (-0x80000000),
3042 : : HOST_WIDE_INT_C (0x7fffffff)))
3043 : 0 : error ("%qs is not a valid offset "
3044 : : "in %<-mstack-protector-guard-offset=%>", str);
3045 : :
3046 : 1 : opts->x_ix86_stack_protector_guard_offset = offset;
3047 : : }
3048 : : #ifdef TARGET_THREAD_SSP_OFFSET
3049 : : else
3050 : 96047202 : opts->x_ix86_stack_protector_guard_offset = TARGET_THREAD_SSP_OFFSET;
3051 : : #endif
3052 : :
3053 : 48329151 : if (opts_set->x_ix86_stack_protector_guard_reg_str)
3054 : : {
3055 : 2 : const char *str = opts->x_ix86_stack_protector_guard_reg_str;
3056 : 2 : addr_space_t seg = ADDR_SPACE_GENERIC;
3057 : :
3058 : : /* Discard optional register prefix. */
3059 : 2 : if (str[0] == '%')
3060 : 0 : str++;
3061 : :
3062 : 2 : if (strlen (str) == 2 && str[1] == 's')
3063 : : {
3064 : 2 : if (str[0] == 'f')
3065 : : seg = ADDR_SPACE_SEG_FS;
3066 : 2 : else if (str[0] == 'g')
3067 : : seg = ADDR_SPACE_SEG_GS;
3068 : : }
3069 : :
3070 : : if (seg == ADDR_SPACE_GENERIC)
3071 : 0 : error ("%qs is not a valid base register "
3072 : : "in %<-mstack-protector-guard-reg=%>",
3073 : : opts->x_ix86_stack_protector_guard_reg_str);
3074 : :
3075 : 2 : opts->x_ix86_stack_protector_guard_reg = seg;
3076 : : }
3077 : : else
3078 : : {
3079 : 48329149 : opts->x_ix86_stack_protector_guard_reg = DEFAULT_TLS_SEG_REG;
3080 : :
3081 : : /* The kernel uses a different segment register for performance
3082 : : reasons; a system call would not have to trash the userspace
3083 : : segment register, which would be expensive. */
3084 : 48329149 : if (opts->x_ix86_cmodel == CM_KERNEL)
3085 : 1 : opts->x_ix86_stack_protector_guard_reg = ADDR_SPACE_SEG_GS;
3086 : : }
3087 : :
3088 : : /* Handle -mmemcpy-strategy= and -mmemset-strategy= */
3089 : 48329151 : if (opts->x_ix86_tune_memcpy_strategy)
3090 : : {
3091 : 18 : char *str = xstrdup (opts->x_ix86_tune_memcpy_strategy);
3092 : 18 : ix86_parse_stringop_strategy_string (str, false);
3093 : 18 : free (str);
3094 : : }
3095 : :
3096 : 48329151 : if (opts->x_ix86_tune_memset_strategy)
3097 : : {
3098 : 34 : char *str = xstrdup (opts->x_ix86_tune_memset_strategy);
3099 : 34 : ix86_parse_stringop_strategy_string (str, true);
3100 : 34 : free (str);
3101 : : }
3102 : :
3103 : : /* Save the initial options in case the user does function specific
3104 : : options. */
3105 : 48329151 : if (main_args_p)
3106 : : {
3107 : 290411 : opts->x_ix86_excess_precision
3108 : 290411 : = opts->x_flag_excess_precision;
3109 : 290411 : opts->x_ix86_unsafe_math_optimizations
3110 : 290411 : = opts->x_flag_unsafe_math_optimizations;
3111 : 580822 : target_option_default_node = target_option_current_node
3112 : 290411 : = build_target_option_node (opts, opts_set);
3113 : : }
3114 : :
3115 : 48329151 : const bool cf_okay_p = (TARGET_64BIT || TARGET_CMOV);
3116 : : /* When -fhardened, enable -fcf-protection=full, but only when it's
3117 : : compatible with this target, and when it wasn't already specified
3118 : : on the command line. */
3119 : 48329151 : if (opts->x_flag_hardened && cf_okay_p)
3120 : : {
3121 : 91 : if (!opts_set->x_flag_cf_protection)
3122 : 90 : opts->x_flag_cf_protection = CF_FULL;
3123 : 1 : else if (opts->x_flag_cf_protection != CF_FULL)
3124 : 1 : warning_at (UNKNOWN_LOCATION, OPT_Whardened,
3125 : : "%<-fcf-protection=full%> is not enabled by "
3126 : : "%<-fhardened%> because it was specified on the command "
3127 : : "line");
3128 : : }
3129 : :
3130 : 48329151 : if (opts->x_flag_cf_protection != CF_NONE)
3131 : : {
3132 : 42123 : if ((opts->x_flag_cf_protection & CF_BRANCH) == CF_BRANCH
3133 : 41994 : && !cf_okay_p)
3134 : 0 : error ("%<-fcf-protection%> is not compatible with this target");
3135 : :
3136 : 42123 : opts->x_flag_cf_protection
3137 : 42123 : = (cf_protection_level) (opts->x_flag_cf_protection | CF_SET);
3138 : : }
3139 : :
3140 : 48329151 : if (ix86_tune_features [X86_TUNE_AVOID_512FMA_CHAINS])
3141 : 65 : SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits, 512);
3142 : 48329086 : else if (ix86_tune_features [X86_TUNE_AVOID_256FMA_CHAINS])
3143 : 47587515 : SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits, 256);
3144 : 741571 : else if (ix86_tune_features [X86_TUNE_AVOID_128FMA_CHAINS])
3145 : 110 : SET_OPTION_IF_UNSET (opts, opts_set, param_avoid_fma_max_bits, 128);
3146 : :
3147 : : /* PR86952: jump table usage with retpolines is slow.
3148 : : The PR provides some numbers about the slowness. */
3149 : 48329151 : if (ix86_indirect_branch != indirect_branch_keep)
3150 : 49 : SET_OPTION_IF_UNSET (opts, opts_set, flag_jump_tables, 0);
3151 : :
3152 : 48329151 : SET_OPTION_IF_UNSET (opts, opts_set, param_ira_consider_dup_in_all_alts, 0);
3153 : :
3154 : : /* Fully masking the main or the epilogue vectorized loop is not
3155 : : profitable generally so leave it disabled until we get more
3156 : : fine grained control & costing. */
3157 : 48329151 : SET_OPTION_IF_UNSET (opts, opts_set, param_vect_partial_vector_usage, 0);
3158 : :
3159 : : return true;
3160 : : }
3161 : :
3162 : : /* Implement the TARGET_OPTION_OVERRIDE hook. */
3163 : :
3164 : : void
3165 : 290412 : ix86_option_override (void)
3166 : : {
3167 : 290412 : ix86_option_override_internal (true, &global_options, &global_options_set);
3168 : 290412 : }
3169 : :
3170 : : /* Remember the last target of ix86_set_current_function. */
3171 : : static GTY(()) tree ix86_previous_fndecl;
3172 : :
3173 : : /* Set targets globals to the default (or current #pragma GCC target
3174 : : if active). Invalidate ix86_previous_fndecl cache. */
3175 : :
3176 : : void
3177 : 2301675 : ix86_reset_previous_fndecl (void)
3178 : : {
3179 : 2301675 : tree new_tree = target_option_current_node;
3180 : 2301675 : cl_target_option_restore (&global_options, &global_options_set,
3181 : 2301675 : TREE_TARGET_OPTION (new_tree));
3182 : 2301675 : if (TREE_TARGET_GLOBALS (new_tree))
3183 : 577501 : restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
3184 : 1724174 : else if (new_tree == target_option_default_node)
3185 : 1252258 : restore_target_globals (&default_target_globals);
3186 : : else
3187 : 471916 : TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
3188 : 2301675 : ix86_previous_fndecl = NULL_TREE;
3189 : 2301675 : }
3190 : :
3191 : : /* Add target attribute to SIMD clone NODE if needed. */
3192 : :
3193 : : void
3194 : 7164 : ix86_simd_clone_adjust (struct cgraph_node *node)
3195 : : {
3196 : 7164 : const char *str = NULL;
3197 : :
3198 : : /* Attributes need to be adjusted for definitions, not declarations. */
3199 : 7164 : if (!node->definition)
3200 : : return;
3201 : :
3202 : 4472 : gcc_assert (node->decl == cfun->decl);
3203 : 4472 : switch (node->simdclone->vecsize_mangle)
3204 : : {
3205 : 1115 : case 'b':
3206 : 1115 : if (!TARGET_SSE2)
3207 : : str = "sse2";
3208 : : break;
3209 : 1176 : case 'c':
3210 : 1176 : if (TARGET_PREFER_AVX128)
3211 : : {
3212 : 1 : if (!TARGET_AVX)
3213 : : str = "avx,prefer-vector-width=256";
3214 : : else
3215 : : str = "prefer-vector-width=256";
3216 : : }
3217 : 1175 : else if (!TARGET_AVX)
3218 : : str = "avx";
3219 : : break;
3220 : 1091 : case 'd':
3221 : 1091 : if (TARGET_PREFER_AVX128)
3222 : : {
3223 : 1 : if (!TARGET_AVX2)
3224 : : str = "avx2,prefer-vector-width=256";
3225 : : else
3226 : : str = "prefer-vector-width=256";
3227 : : }
3228 : 1090 : else if (!TARGET_AVX2)
3229 : : str = "avx2";
3230 : : break;
3231 : 1090 : case 'e':
3232 : 1090 : if (TARGET_PREFER_AVX256)
3233 : : {
3234 : 4 : if (!TARGET_AVX512F)
3235 : : str = "avx512f,prefer-vector-width=512";
3236 : : else
3237 : 2 : str = "prefer-vector-width=512";
3238 : : }
3239 : 1086 : else if (!TARGET_AVX512F)
3240 : : str = "avx512f";
3241 : : break;
3242 : 0 : default:
3243 : 0 : gcc_unreachable ();
3244 : : }
3245 : 2 : if (str == NULL)
3246 : : return;
3247 : 2862 : push_cfun (NULL);
3248 : 2862 : tree args = build_tree_list (NULL_TREE, build_string (strlen (str), str));
3249 : 2862 : bool ok = ix86_valid_target_attribute_p (node->decl, NULL, args, 0);
3250 : 2862 : gcc_assert (ok);
3251 : 2862 : pop_cfun ();
3252 : 2862 : ix86_reset_previous_fndecl ();
3253 : 2862 : ix86_set_current_function (node->decl);
3254 : : }
3255 : :
3256 : :
3257 : :
3258 : : /* Set the func_type field from the function FNDECL. */
3259 : :
3260 : : static void
3261 : 372974178 : ix86_set_func_type (tree fndecl)
3262 : : {
3263 : : /* No need to save and restore callee-saved registers for a noreturn
3264 : : function with nothrow or compiled with -fno-exceptions unless when
3265 : : compiling with -O0 or -Og, except that it interferes with debugging
3266 : : of callers. So that backtrace works for those at least
3267 : : in most cases, save the bp register if it is used, because it often
3268 : : is used in callers to compute CFA.
3269 : :
3270 : : NB: Can't use just TREE_THIS_VOLATILE to check if this is a noreturn
3271 : : function. The local-pure-const pass turns an interrupt function
3272 : : into a noreturn function by setting TREE_THIS_VOLATILE. Normally
3273 : : the local-pure-const pass is run after ix86_set_func_type is called.
3274 : : When the local-pure-const pass is enabled for LTO, the interrupt
3275 : : function is marked with TREE_THIS_VOLATILE in the IR output, which
3276 : : leads to the incompatible attribute error in LTO1. Ignore the
3277 : : interrupt function in this case. */
3278 : 372974178 : enum call_saved_registers_type no_callee_saved_registers
3279 : : = TYPE_DEFAULT_CALL_SAVED_REGISTERS;
3280 : 372974178 : if (lookup_attribute ("preserve_none",
3281 : 372974178 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
3282 : : no_callee_saved_registers = TYPE_PRESERVE_NONE;
3283 : 372973269 : else if ((lookup_attribute ("no_callee_saved_registers",
3284 : 372973269 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
3285 : 372973269 : || (ix86_noreturn_no_callee_saved_registers
3286 : 565 : && TREE_THIS_VOLATILE (fndecl)
3287 : 565 : && optimize
3288 : 529 : && !optimize_debug
3289 : 477 : && (TREE_NOTHROW (fndecl) || !flag_exceptions)
3290 : 477 : && !lookup_attribute ("interrupt",
3291 : 477 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))
3292 : 477 : && !lookup_attribute ("no_caller_saved_registers",
3293 : 477 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl)))))
3294 : : no_callee_saved_registers = TYPE_NO_CALLEE_SAVED_REGISTERS;
3295 : :
3296 : 372974178 : if (cfun->machine->func_type == TYPE_UNKNOWN)
3297 : : {
3298 : 185035837 : if (lookup_attribute ("interrupt",
3299 : 185035837 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
3300 : : {
3301 : 154 : if (ix86_function_naked (fndecl))
3302 : 1 : error_at (DECL_SOURCE_LOCATION (fndecl),
3303 : : "interrupt and naked attributes are not compatible");
3304 : :
3305 : 154 : if (no_callee_saved_registers)
3306 : : {
3307 : 2 : const char *attr;
3308 : 2 : if (no_callee_saved_registers == TYPE_PRESERVE_NONE)
3309 : : attr = "preserve_none";
3310 : : else
3311 : 1 : attr = "no_callee_saved_registers";
3312 : 2 : error_at (DECL_SOURCE_LOCATION (fndecl),
3313 : : "%qs and %qs attributes are not compatible",
3314 : : "interrupt", attr);
3315 : : }
3316 : :
3317 : 154 : int nargs = 0;
3318 : 154 : for (tree arg = DECL_ARGUMENTS (fndecl);
3319 : 389 : arg;
3320 : 235 : arg = TREE_CHAIN (arg))
3321 : 235 : nargs++;
3322 : 154 : cfun->machine->call_saved_registers
3323 : 154 : = TYPE_NO_CALLER_SAVED_REGISTERS;
3324 : 154 : cfun->machine->func_type
3325 : 154 : = nargs == 2 ? TYPE_EXCEPTION : TYPE_INTERRUPT;
3326 : :
3327 : 154 : ix86_optimize_mode_switching[X86_DIRFLAG] = 1;
3328 : :
3329 : : /* Only dwarf2out.cc can handle -WORD(AP) as a pointer argument. */
3330 : 154 : if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
3331 : 0 : sorry ("only DWARF debug format is supported for interrupt "
3332 : : "service routine");
3333 : : }
3334 : : else
3335 : : {
3336 : 185035683 : cfun->machine->func_type = TYPE_NORMAL;
3337 : 185035683 : if (no_callee_saved_registers)
3338 : 82 : cfun->machine->call_saved_registers
3339 : 82 : = no_callee_saved_registers;
3340 : 185035601 : else if (lookup_attribute ("no_caller_saved_registers",
3341 : 185035601 : TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
3342 : 35 : cfun->machine->call_saved_registers
3343 : 35 : = TYPE_NO_CALLER_SAVED_REGISTERS;
3344 : : }
3345 : : }
3346 : 372974178 : }
3347 : :
3348 : : /* Set the indirect_branch_type field from the function FNDECL. */
3349 : :
3350 : : static void
3351 : 372974178 : ix86_set_indirect_branch_type (tree fndecl)
3352 : : {
3353 : 372974178 : if (cfun->machine->indirect_branch_type == indirect_branch_unset)
3354 : : {
3355 : 185035837 : tree attr = lookup_attribute ("indirect_branch",
3356 : 185035837 : DECL_ATTRIBUTES (fndecl));
3357 : 185035837 : if (attr != NULL)
3358 : : {
3359 : 17 : tree args = TREE_VALUE (attr);
3360 : 17 : if (args == NULL)
3361 : 0 : gcc_unreachable ();
3362 : 17 : tree cst = TREE_VALUE (args);
3363 : 17 : if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
3364 : 2 : cfun->machine->indirect_branch_type = indirect_branch_keep;
3365 : 15 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
3366 : 5 : cfun->machine->indirect_branch_type = indirect_branch_thunk;
3367 : 10 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
3368 : 3 : cfun->machine->indirect_branch_type = indirect_branch_thunk_inline;
3369 : 7 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
3370 : 7 : cfun->machine->indirect_branch_type = indirect_branch_thunk_extern;
3371 : : else
3372 : 0 : gcc_unreachable ();
3373 : : }
3374 : : else
3375 : 185035820 : cfun->machine->indirect_branch_type = ix86_indirect_branch;
3376 : :
3377 : : /* -mcmodel=large is not compatible with -mindirect-branch=thunk
3378 : : nor -mindirect-branch=thunk-extern. */
3379 : 185035837 : if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
3380 : 7451 : && ((cfun->machine->indirect_branch_type
3381 : 7451 : == indirect_branch_thunk_extern)
3382 : 7449 : || (cfun->machine->indirect_branch_type
3383 : : == indirect_branch_thunk)))
3384 : 6 : error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
3385 : : "compatible",
3386 : : ((cfun->machine->indirect_branch_type
3387 : : == indirect_branch_thunk_extern)
3388 : : ? "thunk-extern" : "thunk"));
3389 : :
3390 : 185035837 : if (cfun->machine->indirect_branch_type != indirect_branch_keep
3391 : 78 : && (cfun->machine->indirect_branch_type
3392 : : != indirect_branch_thunk_extern)
3393 : 52 : && (flag_cf_protection & CF_RETURN))
3394 : 3 : error ("%<-mindirect-branch%> and %<-fcf-protection%> are not "
3395 : : "compatible");
3396 : : }
3397 : :
3398 : 372974178 : if (cfun->machine->function_return_type == indirect_branch_unset)
3399 : : {
3400 : 185035837 : tree attr = lookup_attribute ("function_return",
3401 : 185035837 : DECL_ATTRIBUTES (fndecl));
3402 : 185035837 : if (attr != NULL)
3403 : : {
3404 : 12 : tree args = TREE_VALUE (attr);
3405 : 12 : if (args == NULL)
3406 : 0 : gcc_unreachable ();
3407 : 12 : tree cst = TREE_VALUE (args);
3408 : 12 : if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
3409 : 2 : cfun->machine->function_return_type = indirect_branch_keep;
3410 : 10 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
3411 : 4 : cfun->machine->function_return_type = indirect_branch_thunk;
3412 : 6 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
3413 : 3 : cfun->machine->function_return_type = indirect_branch_thunk_inline;
3414 : 3 : else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
3415 : 3 : cfun->machine->function_return_type = indirect_branch_thunk_extern;
3416 : : else
3417 : 0 : gcc_unreachable ();
3418 : : }
3419 : : else
3420 : 185035825 : cfun->machine->function_return_type = ix86_function_return;
3421 : :
3422 : : /* -mcmodel=large is not compatible with -mfunction-return=thunk
3423 : : nor -mfunction-return=thunk-extern. */
3424 : 185035837 : if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
3425 : 7451 : && ((cfun->machine->function_return_type
3426 : 7451 : == indirect_branch_thunk_extern)
3427 : 7449 : || (cfun->machine->function_return_type
3428 : : == indirect_branch_thunk)))
3429 : 6 : error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
3430 : : "compatible",
3431 : : ((cfun->machine->function_return_type
3432 : : == indirect_branch_thunk_extern)
3433 : : ? "thunk-extern" : "thunk"));
3434 : :
3435 : 185035837 : if (cfun->machine->function_return_type != indirect_branch_keep
3436 : 32 : && (cfun->machine->function_return_type
3437 : : != indirect_branch_thunk_extern)
3438 : 24 : && (flag_cf_protection & CF_RETURN))
3439 : 3 : error ("%<-mfunction-return%> and %<-fcf-protection%> are not "
3440 : : "compatible");
3441 : : }
3442 : 372974178 : }
3443 : :
3444 : : /* Establish appropriate back-end context for processing the function
3445 : : FNDECL. The argument might be NULL to indicate processing at top
3446 : : level, outside of any function scope. */
3447 : : void
3448 : 741824965 : ix86_set_current_function (tree fndecl)
3449 : : {
3450 : : /* Only change the context if the function changes. This hook is called
3451 : : several times in the course of compiling a function, and we don't want to
3452 : : slow things down too much or call target_reinit when it isn't safe. */
3453 : 741824965 : if (fndecl == ix86_previous_fndecl)
3454 : : {
3455 : : /* There may be 2 function bodies for the same function FNDECL,
3456 : : one is extern inline and one isn't. Call ix86_set_func_type
3457 : : to set the func_type field. */
3458 : 83176966 : if (fndecl != NULL_TREE)
3459 : : {
3460 : 83176939 : ix86_set_func_type (fndecl);
3461 : 83176939 : ix86_set_indirect_branch_type (fndecl);
3462 : : }
3463 : 83176966 : return;
3464 : : }
3465 : :
3466 : 658647999 : tree old_tree;
3467 : 658647999 : if (ix86_previous_fndecl == NULL_TREE)
3468 : 1991797 : old_tree = target_option_current_node;
3469 : 656656202 : else if (DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl))
3470 : : old_tree = DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl);
3471 : : else
3472 : 598257657 : old_tree = target_option_default_node;
3473 : :
3474 : 658647999 : if (fndecl == NULL_TREE)
3475 : : {
3476 : 368850760 : if (old_tree != target_option_current_node)
3477 : 1208479 : ix86_reset_previous_fndecl ();
3478 : 368850760 : return;
3479 : : }
3480 : :
3481 : 289797239 : ix86_set_func_type (fndecl);
3482 : 289797239 : ix86_set_indirect_branch_type (fndecl);
3483 : :
3484 : 289797239 : tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
3485 : 289797239 : if (new_tree == NULL_TREE)
3486 : 259991683 : new_tree = target_option_default_node;
3487 : :
3488 : 289797239 : bool fp_flag_change
3489 : 289797239 : = (flag_unsafe_math_optimizations
3490 : 289797239 : != TREE_TARGET_OPTION (new_tree)->x_ix86_unsafe_math_optimizations
3491 : 289797239 : || (flag_excess_precision
3492 : 289797126 : != TREE_TARGET_OPTION (new_tree)->x_ix86_excess_precision));
3493 : 289797239 : if (old_tree != new_tree || fp_flag_change)
3494 : : {
3495 : 1208554 : cl_target_option_restore (&global_options, &global_options_set,
3496 : 1208554 : TREE_TARGET_OPTION (new_tree));
3497 : 1208554 : if (fp_flag_change)
3498 : : {
3499 : 113 : ix86_excess_precision = flag_excess_precision;
3500 : 113 : ix86_unsafe_math_optimizations = flag_unsafe_math_optimizations;
3501 : 113 : DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = new_tree
3502 : 113 : = build_target_option_node (&global_options, &global_options_set);
3503 : : }
3504 : 1208554 : if (TREE_TARGET_GLOBALS (new_tree))
3505 : 1170871 : restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
3506 : 37683 : else if (new_tree == target_option_default_node)
3507 : 20542 : restore_target_globals (&default_target_globals);
3508 : : else
3509 : 17141 : TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
3510 : : }
3511 : 289797239 : ix86_previous_fndecl = fndecl;
3512 : :
3513 : 289797239 : static call_saved_registers_type prev_call_saved_registers;
3514 : :
3515 : : /* 64-bit MS and SYSV ABI have different set of call used registers.
3516 : : Avoid expensive re-initialization of init_regs each time we switch
3517 : : function context. */
3518 : 289797239 : if (TARGET_64BIT
3519 : 289797239 : && (call_used_or_fixed_reg_p (SI_REG)
3520 : 281351825 : == (cfun->machine->call_abi == MS_ABI)))
3521 : 36927 : reinit_regs ();
3522 : : /* Need to re-initialize init_regs if caller-saved registers are
3523 : : changed. */
3524 : 289760312 : else if (prev_call_saved_registers
3525 : 289760312 : != cfun->machine->call_saved_registers)
3526 : 10814 : reinit_regs ();
3527 : :
3528 : 289797239 : if (cfun->machine->func_type != TYPE_NORMAL
3529 : 289793099 : || (cfun->machine->call_saved_registers
3530 : 289793099 : == TYPE_NO_CALLER_SAVED_REGISTERS))
3531 : : {
3532 : : /* Don't allow AVX, AVX512, MMX nor x87 instructions since they
3533 : : may change processor state. Don't allow SSE instructions in
3534 : : exception/interrupt service routines. */
3535 : 4953 : const char *isa;
3536 : 4953 : if (TARGET_SSE)
3537 : : {
3538 : 205 : if (TARGET_AVX512F)
3539 : : isa = "AVX512";
3540 : 205 : else if (TARGET_AVX)
3541 : : isa = "AVX";
3542 : 205 : else if (cfun->machine->func_type != TYPE_NORMAL)
3543 : : isa = "SSE";
3544 : 204 : else if (TARGET_MMX)
3545 : : isa = "MMX/3Dnow";
3546 : 203 : else if (TARGET_80387)
3547 : : isa = "80387";
3548 : : else
3549 : : isa = NULL;
3550 : : }
3551 : 4748 : else if (TARGET_MMX)
3552 : : isa = "MMX/3Dnow";
3553 : 4745 : else if (TARGET_80387)
3554 : : isa = "80387";
3555 : : else
3556 : : isa = NULL;
3557 : : if (isa != NULL)
3558 : : {
3559 : 9 : if (cfun->machine->func_type != TYPE_NORMAL)
3560 : 7 : sorry (cfun->machine->func_type == TYPE_EXCEPTION
3561 : : ? G_("%s instructions aren%'t allowed in an"
3562 : : " exception service routine")
3563 : : : G_("%s instructions aren%'t allowed in an"
3564 : : " interrupt service routine"),
3565 : : isa);
3566 : : else
3567 : 4 : sorry ("%s instructions aren%'t allowed in a function with "
3568 : : "the %<no_caller_saved_registers%> attribute", isa);
3569 : : /* Don't issue the same error twice. */
3570 : 9 : cfun->machine->func_type = TYPE_NORMAL;
3571 : 9 : cfun->machine->call_saved_registers
3572 : 9 : = TYPE_DEFAULT_CALL_SAVED_REGISTERS;
3573 : : }
3574 : : }
3575 : :
3576 : 289797239 : prev_call_saved_registers = cfun->machine->call_saved_registers;
3577 : : }
3578 : :
3579 : : /* Implement the TARGET_OFFLOAD_OPTIONS hook. */
3580 : : char *
3581 : 0 : ix86_offload_options (void)
3582 : : {
3583 : 0 : if (TARGET_LP64)
3584 : 0 : return xstrdup ("-foffload-abi=lp64 -foffload-abi-host-opts=-m64");
3585 : 0 : return xstrdup ("-foffload-abi=ilp32 -foffload-abi-host-opts=-m32");
3586 : : }
3587 : :
3588 : : /* Handle "cdecl", "stdcall", "fastcall", "regparm", "thiscall",
3589 : : and "sseregparm" calling convention attributes;
3590 : : arguments as in struct attribute_spec.handler. */
3591 : :
3592 : : static tree
3593 : 11721 : ix86_handle_cconv_attribute (tree *node, tree name, tree args, int,
3594 : : bool *no_add_attrs)
3595 : : {
3596 : 11721 : if (TREE_CODE (*node) != FUNCTION_TYPE
3597 : 11721 : && TREE_CODE (*node) != METHOD_TYPE
3598 : : && TREE_CODE (*node) != FIELD_DECL
3599 : : && TREE_CODE (*node) != TYPE_DECL)
3600 : : {
3601 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3602 : : name);
3603 : 0 : *no_add_attrs = true;
3604 : 0 : return NULL_TREE;
3605 : : }
3606 : :
3607 : 11721 : if (TARGET_64BIT)
3608 : : {
3609 : : /* Do not warn when emulating the MS ABI. */
3610 : 791 : if ((TREE_CODE (*node) != FUNCTION_TYPE
3611 : : && TREE_CODE (*node) != METHOD_TYPE)
3612 : 791 : || ix86_function_type_abi (*node) != MS_ABI)
3613 : 788 : warning (OPT_Wattributes, "%qE attribute ignored",
3614 : : name);
3615 : 791 : *no_add_attrs = true;
3616 : 791 : return NULL_TREE;
3617 : : }
3618 : :
3619 : : /* Can combine regparm with all attributes but fastcall, and thiscall. */
3620 : 10930 : if (is_attribute_p ("regparm", name))
3621 : : {
3622 : 10928 : tree cst;
3623 : :
3624 : 10928 : if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3625 : : {
3626 : 0 : error ("fastcall and regparm attributes are not compatible");
3627 : : }
3628 : :
3629 : 10928 : if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3630 : : {
3631 : 0 : error ("regparm and thiscall attributes are not compatible");
3632 : : }
3633 : :
3634 : 10928 : cst = TREE_VALUE (args);
3635 : 10928 : if (TREE_CODE (cst) != INTEGER_CST)
3636 : : {
3637 : 0 : warning (OPT_Wattributes,
3638 : : "%qE attribute requires an integer constant argument",
3639 : : name);
3640 : 0 : *no_add_attrs = true;
3641 : : }
3642 : 10928 : else if (compare_tree_int (cst, REGPARM_MAX) > 0)
3643 : : {
3644 : 0 : warning (OPT_Wattributes, "argument to %qE attribute larger than %d",
3645 : 0 : name, REGPARM_MAX);
3646 : 0 : *no_add_attrs = true;
3647 : : }
3648 : :
3649 : 10928 : return NULL_TREE;
3650 : : }
3651 : :
3652 : : /* Can combine fastcall with sseregparm. */
3653 : 2 : if (is_attribute_p ("fastcall", name))
3654 : : {
3655 : 2 : if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
3656 : : {
3657 : 0 : error ("fastcall and cdecl attributes are not compatible");
3658 : : }
3659 : 2 : if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
3660 : : {
3661 : 0 : error ("fastcall and stdcall attributes are not compatible");
3662 : : }
3663 : 2 : if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node)))
3664 : : {
3665 : 0 : error ("fastcall and regparm attributes are not compatible");
3666 : : }
3667 : 2 : if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3668 : : {
3669 : 0 : error ("fastcall and thiscall attributes are not compatible");
3670 : : }
3671 : : }
3672 : :
3673 : : /* Can combine stdcall with regparm and sseregparm. */
3674 : 0 : else if (is_attribute_p ("stdcall", name))
3675 : : {
3676 : 0 : if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
3677 : : {
3678 : 0 : error ("stdcall and cdecl attributes are not compatible");
3679 : : }
3680 : 0 : if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3681 : : {
3682 : 0 : error ("stdcall and fastcall attributes are not compatible");
3683 : : }
3684 : 0 : if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3685 : : {
3686 : 0 : error ("stdcall and thiscall attributes are not compatible");
3687 : : }
3688 : : }
3689 : :
3690 : : /* Can combine cdecl with regparm and sseregparm. */
3691 : 0 : else if (is_attribute_p ("cdecl", name))
3692 : : {
3693 : 0 : if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
3694 : : {
3695 : 0 : error ("stdcall and cdecl attributes are not compatible");
3696 : : }
3697 : 0 : if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3698 : : {
3699 : 0 : error ("fastcall and cdecl attributes are not compatible");
3700 : : }
3701 : 0 : if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3702 : : {
3703 : 0 : error ("cdecl and thiscall attributes are not compatible");
3704 : : }
3705 : : }
3706 : 0 : else if (is_attribute_p ("thiscall", name))
3707 : : {
3708 : 0 : if (TREE_CODE (*node) != METHOD_TYPE && pedantic)
3709 : 0 : warning (OPT_Wattributes, "%qE attribute is used for non-class method",
3710 : : name);
3711 : 0 : if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
3712 : : {
3713 : 0 : error ("stdcall and thiscall attributes are not compatible");
3714 : : }
3715 : 0 : if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3716 : : {
3717 : 0 : error ("fastcall and thiscall attributes are not compatible");
3718 : : }
3719 : 0 : if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
3720 : : {
3721 : 0 : error ("cdecl and thiscall attributes are not compatible");
3722 : : }
3723 : 0 : if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node)))
3724 : : {
3725 : 0 : error ("regparm and thiscall attributes are not compatible");
3726 : : }
3727 : : }
3728 : :
3729 : : /* Can combine sseregparm with all attributes. */
3730 : :
3731 : : return NULL_TREE;
3732 : : }
3733 : :
3734 : : #ifndef CHECK_STACK_LIMIT
3735 : : #define CHECK_STACK_LIMIT (-1)
3736 : : #endif
3737 : :
3738 : : /* The transactional memory builtins are implicitly regparm or fastcall
3739 : : depending on the ABI. Override the generic do-nothing attribute that
3740 : : these builtins were declared with, and replace it with one of the two
3741 : : attributes that we expect elsewhere. */
3742 : :
3743 : : static tree
3744 : 35052 : ix86_handle_tm_regparm_attribute (tree *node, tree, tree,
3745 : : int flags, bool *no_add_attrs)
3746 : : {
3747 : 35052 : tree alt;
3748 : :
3749 : : /* In no case do we want to add the placeholder attribute. */
3750 : 35052 : *no_add_attrs = true;
3751 : :
3752 : : /* The 64-bit ABI is unchanged for transactional memory. */
3753 : 35052 : if (TARGET_64BIT)
3754 : : return NULL_TREE;
3755 : :
3756 : : /* ??? Is there a better way to validate 32-bit windows? We have
3757 : : cfun->machine->call_abi, but that seems to be set only for 64-bit. */
3758 : 0 : if (CHECK_STACK_LIMIT > 0)
3759 : : alt = tree_cons (get_identifier ("fastcall"), NULL, NULL);
3760 : : else
3761 : : {
3762 : 0 : alt = tree_cons (NULL, build_int_cst (NULL, 2), NULL);
3763 : 0 : alt = tree_cons (get_identifier ("regparm"), alt, NULL);
3764 : : }
3765 : 0 : decl_attributes (node, alt, flags);
3766 : :
3767 : 0 : return NULL_TREE;
3768 : : }
3769 : :
3770 : : /* Handle a "force_align_arg_pointer" attribute. */
3771 : :
3772 : : static tree
3773 : 5131 : ix86_handle_force_align_arg_pointer_attribute (tree *node, tree name,
3774 : : tree, int, bool *no_add_attrs)
3775 : : {
3776 : 5131 : if (TREE_CODE (*node) != FUNCTION_TYPE
3777 : 5131 : && TREE_CODE (*node) != METHOD_TYPE
3778 : : && TREE_CODE (*node) != FIELD_DECL
3779 : : && TREE_CODE (*node) != TYPE_DECL)
3780 : : {
3781 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3782 : : name);
3783 : 0 : *no_add_attrs = true;
3784 : : }
3785 : :
3786 : 5131 : return NULL_TREE;
3787 : : }
3788 : :
3789 : : /* Handle a "ms_struct" or "gcc_struct" attribute; arguments as in
3790 : : struct attribute_spec.handler. */
3791 : :
3792 : : static tree
3793 : 74 : ix86_handle_struct_attribute (tree *node, tree name, tree, int,
3794 : : bool *no_add_attrs)
3795 : : {
3796 : 74 : tree *type = NULL;
3797 : 74 : if (DECL_P (*node))
3798 : : {
3799 : 0 : if (TREE_CODE (*node) == TYPE_DECL)
3800 : 0 : type = &TREE_TYPE (*node);
3801 : : }
3802 : : else
3803 : : type = node;
3804 : :
3805 : 74 : if (!(type && RECORD_OR_UNION_TYPE_P (*type)))
3806 : : {
3807 : 0 : warning (OPT_Wattributes, "%qE attribute ignored",
3808 : : name);
3809 : 0 : *no_add_attrs = true;
3810 : : }
3811 : :
3812 : 74 : else if ((is_attribute_p ("ms_struct", name)
3813 : 62 : && lookup_attribute ("gcc_struct", TYPE_ATTRIBUTES (*type)))
3814 : 136 : || ((is_attribute_p ("gcc_struct", name)
3815 : 12 : && lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (*type)))))
3816 : : {
3817 : 0 : warning (OPT_Wattributes, "%qE incompatible attribute ignored",
3818 : : name);
3819 : 0 : *no_add_attrs = true;
3820 : : }
3821 : :
3822 : 74 : return NULL_TREE;
3823 : : }
3824 : :
3825 : : /* Handle a "callee_pop_aggregate_return" attribute; arguments as
3826 : : in struct attribute_spec handler. */
3827 : :
3828 : : static tree
3829 : 0 : ix86_handle_callee_pop_aggregate_return (tree *node, tree name, tree args, int,
3830 : : bool *no_add_attrs)
3831 : : {
3832 : 0 : if (TREE_CODE (*node) != FUNCTION_TYPE
3833 : 0 : && TREE_CODE (*node) != METHOD_TYPE
3834 : : && TREE_CODE (*node) != FIELD_DECL
3835 : : && TREE_CODE (*node) != TYPE_DECL)
3836 : : {
3837 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3838 : : name);
3839 : 0 : *no_add_attrs = true;
3840 : 0 : return NULL_TREE;
3841 : : }
3842 : 0 : if (TARGET_64BIT)
3843 : : {
3844 : 0 : warning (OPT_Wattributes, "%qE attribute only available for 32-bit",
3845 : : name);
3846 : 0 : *no_add_attrs = true;
3847 : 0 : return NULL_TREE;
3848 : : }
3849 : 0 : if (is_attribute_p ("callee_pop_aggregate_return", name))
3850 : : {
3851 : 0 : tree cst;
3852 : :
3853 : 0 : cst = TREE_VALUE (args);
3854 : 0 : if (TREE_CODE (cst) != INTEGER_CST)
3855 : : {
3856 : 0 : warning (OPT_Wattributes,
3857 : : "%qE attribute requires an integer constant argument",
3858 : : name);
3859 : 0 : *no_add_attrs = true;
3860 : : }
3861 : 0 : else if (compare_tree_int (cst, 0) != 0
3862 : 0 : && compare_tree_int (cst, 1) != 0)
3863 : : {
3864 : 0 : warning (OPT_Wattributes,
3865 : : "argument to %qE attribute is neither zero, nor one",
3866 : : name);
3867 : 0 : *no_add_attrs = true;
3868 : : }
3869 : :
3870 : 0 : return NULL_TREE;
3871 : : }
3872 : :
3873 : : return NULL_TREE;
3874 : : }
3875 : :
3876 : : /* Handle a "ms_abi" or "sysv" attribute; arguments as in
3877 : : struct attribute_spec.handler. */
3878 : :
3879 : : static tree
3880 : 1599122 : ix86_handle_abi_attribute (tree *node, tree name, tree, int,
3881 : : bool *no_add_attrs)
3882 : : {
3883 : 1599122 : if (TREE_CODE (*node) != FUNCTION_TYPE
3884 : 1599122 : && TREE_CODE (*node) != METHOD_TYPE
3885 : : && TREE_CODE (*node) != FIELD_DECL
3886 : : && TREE_CODE (*node) != TYPE_DECL)
3887 : : {
3888 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3889 : : name);
3890 : 0 : *no_add_attrs = true;
3891 : 0 : return NULL_TREE;
3892 : : }
3893 : :
3894 : : /* Can combine regparm with all attributes but fastcall. */
3895 : 1599122 : if (is_attribute_p ("ms_abi", name))
3896 : : {
3897 : 819794 : if (lookup_attribute ("sysv_abi", TYPE_ATTRIBUTES (*node)))
3898 : : {
3899 : 0 : error ("%qs and %qs attributes are not compatible",
3900 : : "ms_abi", "sysv_abi");
3901 : : }
3902 : :
3903 : 819794 : return NULL_TREE;
3904 : : }
3905 : 779328 : else if (is_attribute_p ("sysv_abi", name))
3906 : : {
3907 : 779328 : if (lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (*node)))
3908 : : {
3909 : 0 : error ("%qs and %qs attributes are not compatible",
3910 : : "ms_abi", "sysv_abi");
3911 : : }
3912 : :
3913 : 779328 : return NULL_TREE;
3914 : : }
3915 : :
3916 : : return NULL_TREE;
3917 : : }
3918 : :
3919 : : static tree
3920 : 122 : ix86_handle_fndecl_attribute (tree *node, tree name, tree args, int,
3921 : : bool *no_add_attrs)
3922 : : {
3923 : 122 : if (TREE_CODE (*node) != FUNCTION_DECL)
3924 : : {
3925 : 0 : warning (OPT_Wattributes, "%qE attribute only applies to functions",
3926 : : name);
3927 : 0 : *no_add_attrs = true;
3928 : : }
3929 : :
3930 : 122 : if (is_attribute_p ("indirect_branch", name))
3931 : : {
3932 : 17 : tree cst = TREE_VALUE (args);
3933 : 17 : if (TREE_CODE (cst) != STRING_CST)
3934 : : {
3935 : 0 : warning (OPT_Wattributes,
3936 : : "%qE attribute requires a string constant argument",
3937 : : name);
3938 : 0 : *no_add_attrs = true;
3939 : : }
3940 : 17 : else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
3941 : 15 : && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
3942 : 10 : && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
3943 : 24 : && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
3944 : : {
3945 : 0 : warning (OPT_Wattributes,
3946 : : "argument to %qE attribute is not "
3947 : : "(keep|thunk|thunk-inline|thunk-extern)", name);
3948 : 0 : *no_add_attrs = true;
3949 : : }
3950 : : }
3951 : :
3952 : 122 : if (is_attribute_p ("function_return", name))
3953 : : {
3954 : 12 : tree cst = TREE_VALUE (args);
3955 : 12 : if (TREE_CODE (cst) != STRING_CST)
3956 : : {
3957 : 0 : warning (OPT_Wattributes,
3958 : : "%qE attribute requires a string constant argument",
3959 : : name);
3960 : 0 : *no_add_attrs = true;
3961 : : }
3962 : 12 : else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
3963 : 10 : && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
3964 : 6 : && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
3965 : 15 : && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
3966 : : {
3967 : 0 : warning (OPT_Wattributes,
3968 : : "argument to %qE attribute is not "
3969 : : "(keep|thunk|thunk-inline|thunk-extern)", name);
3970 : 0 : *no_add_attrs = true;
3971 : : }
3972 : : }
3973 : :
3974 : 122 : return NULL_TREE;
3975 : : }
3976 : :
3977 : : static tree
3978 : 169 : ix86_handle_call_saved_registers_attribute (tree *node, tree name, tree,
3979 : : int, bool *)
3980 : : {
3981 : 169 : const char *attr1 = nullptr;
3982 : 169 : const char *attr2 = nullptr;
3983 : :
3984 : 169 : if (is_attribute_p ("no_callee_saved_registers", name))
3985 : : {
3986 : : /* Disallow preserve_none and no_caller_saved_registers
3987 : : attributes. */
3988 : 78 : attr1 = "no_callee_saved_registers";
3989 : 78 : if (lookup_attribute ("preserve_none", TYPE_ATTRIBUTES (*node)))
3990 : : attr2 = "preserve_none";
3991 : 77 : else if (lookup_attribute ("no_caller_saved_registers",
3992 : 77 : TYPE_ATTRIBUTES (*node)))
3993 : : attr2 = "no_caller_saved_registers";
3994 : : }
3995 : 91 : else if (is_attribute_p ("no_caller_saved_registers", name))
3996 : : {
3997 : : /* Disallow preserve_none and no_callee_saved_registers
3998 : : attributes. */
3999 : 52 : attr1 = "no_caller_saved_registers";
4000 : 52 : if (lookup_attribute ("preserve_none", TYPE_ATTRIBUTES (*node)))
4001 : : attr2 = "preserve_none";
4002 : 51 : else if (lookup_attribute ("no_callee_saved_registers",
4003 : 51 : TYPE_ATTRIBUTES (*node)))
4004 : : attr2 = "no_callee_saved_registers";
4005 : : }
4006 : 39 : else if (is_attribute_p ("preserve_none", name))
4007 : : {
4008 : : /* Disallow no_callee_saved_registers and no_caller_saved_registers
4009 : : attributes. */
4010 : 39 : attr1 = "preserve_none";
4011 : 39 : if (lookup_attribute ("no_callee_saved_registers",
4012 : 39 : TYPE_ATTRIBUTES (*node)))
4013 : : attr2 = "no_caller_saved_registers";
4014 : 39 : else if (lookup_attribute ("no_callee_saved_registers",
4015 : 39 : TYPE_ATTRIBUTES (*node)))
4016 : : attr2 = "no_callee_saved_registers";
4017 : : }
4018 : :
4019 : : if (attr2)
4020 : 3 : error ("%qs and %qs attributes are not compatible", attr1, attr2);
4021 : :
4022 : 169 : return NULL_TREE;
4023 : : }
4024 : :
4025 : : static tree
4026 : 129 : ix86_handle_interrupt_attribute (tree *node, tree, tree, int, bool *)
4027 : : {
4028 : : /* DECL_RESULT and DECL_ARGUMENTS do not exist there yet,
4029 : : but the function type contains args and return type data. */
4030 : 129 : tree func_type = *node;
4031 : 129 : tree return_type = TREE_TYPE (func_type);
4032 : :
4033 : 129 : int nargs = 0;
4034 : 129 : tree current_arg_type = TYPE_ARG_TYPES (func_type);
4035 : 129 : while (current_arg_type
4036 : 642 : && ! VOID_TYPE_P (TREE_VALUE (current_arg_type)))
4037 : : {
4038 : 192 : if (nargs == 0)
4039 : : {
4040 : 128 : if (! POINTER_TYPE_P (TREE_VALUE (current_arg_type)))
4041 : 2 : error ("interrupt service routine should have a pointer "
4042 : : "as the first argument");
4043 : : }
4044 : 64 : else if (nargs == 1)
4045 : : {
4046 : 64 : if (TREE_CODE (TREE_VALUE (current_arg_type)) != INTEGER_TYPE
4047 : 64 : || TYPE_MODE (TREE_VALUE (current_arg_type)) != word_mode)
4048 : 2 : error ("interrupt service routine should have %qs "
4049 : : "as the second argument",
4050 : 2 : TARGET_64BIT
4051 : 2 : ? (TARGET_X32 ? "unsigned long long int"
4052 : : : "unsigned long int")
4053 : : : "unsigned int");
4054 : : }
4055 : 192 : nargs++;
4056 : 192 : current_arg_type = TREE_CHAIN (current_arg_type);
4057 : : }
4058 : 129 : if (!nargs || nargs > 2)
4059 : 1 : error ("interrupt service routine can only have a pointer argument "
4060 : : "and an optional integer argument");
4061 : 129 : if (! VOID_TYPE_P (return_type))
4062 : 1 : error ("interrupt service routine must return %<void%>");
4063 : :
4064 : 129 : return NULL_TREE;
4065 : : }
4066 : :
4067 : : /* Handle fentry_name / fentry_section attribute. */
4068 : :
4069 : : static tree
4070 : 4 : ix86_handle_fentry_name (tree *node, tree name, tree args,
4071 : : int, bool *no_add_attrs)
4072 : : {
4073 : 4 : if (TREE_CODE (*node) == FUNCTION_DECL
4074 : 8 : && TREE_CODE (TREE_VALUE (args)) == STRING_CST)
4075 : : /* Do nothing else, just set the attribute. We'll get at
4076 : : it later with lookup_attribute. */
4077 : : ;
4078 : : else
4079 : : {
4080 : 0 : warning (OPT_Wattributes, "%qE attribute ignored", name);
4081 : 0 : *no_add_attrs = true;
4082 : : }
4083 : :
4084 : 4 : return NULL_TREE;
4085 : : }
4086 : :
4087 : : /* Handle a "nodirect_extern_access" attribute; arguments as in
4088 : : struct attribute_spec.handler. */
4089 : :
4090 : : static tree
4091 : 11 : handle_nodirect_extern_access_attribute (tree *pnode, tree name,
4092 : : tree ARG_UNUSED (args),
4093 : : int ARG_UNUSED (flags),
4094 : : bool *no_add_attrs)
4095 : : {
4096 : 11 : tree node = *pnode;
4097 : :
4098 : 11 : if (VAR_OR_FUNCTION_DECL_P (node))
4099 : : {
4100 : 7 : if ((!TREE_STATIC (node) && TREE_CODE (node) != FUNCTION_DECL
4101 : 18 : && !DECL_EXTERNAL (node)) || !TREE_PUBLIC (node))
4102 : : {
4103 : 0 : warning (OPT_Wattributes,
4104 : : "%qE attribute have effect only on public objects", name);
4105 : 0 : *no_add_attrs = true;
4106 : : }
4107 : : }
4108 : : else
4109 : : {
4110 : 0 : warning (OPT_Wattributes, "%qE attribute ignored", name);
4111 : 0 : *no_add_attrs = true;
4112 : : }
4113 : :
4114 : 11 : return NULL_TREE;
4115 : : }
4116 : :
4117 : : /* Table of valid machine attributes. */
4118 : : static const attribute_spec ix86_gnu_attributes[] =
4119 : : {
4120 : : /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
4121 : : affects_type_identity, handler, exclude } */
4122 : : /* Stdcall attribute says callee is responsible for popping arguments
4123 : : if they are not variable. */
4124 : : { "stdcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4125 : : NULL },
4126 : : /* Fastcall attribute says callee is responsible for popping arguments
4127 : : if they are not variable. */
4128 : : { "fastcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4129 : : NULL },
4130 : : /* Thiscall attribute says callee is responsible for popping arguments
4131 : : if they are not variable. */
4132 : : { "thiscall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4133 : : NULL },
4134 : : /* Cdecl attribute says the callee is a normal C declaration */
4135 : : { "cdecl", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4136 : : NULL },
4137 : : /* Regparm attribute specifies how many integer arguments are to be
4138 : : passed in registers. */
4139 : : { "regparm", 1, 1, false, true, true, true, ix86_handle_cconv_attribute,
4140 : : NULL },
4141 : : /* Sseregparm attribute says we are using x86_64 calling conventions
4142 : : for FP arguments. */
4143 : : { "sseregparm", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
4144 : : NULL },
4145 : : /* The transactional memory builtins are implicitly regparm or fastcall
4146 : : depending on the ABI. Override the generic do-nothing attribute that
4147 : : these builtins were declared with. */
4148 : : { "*tm regparm", 0, 0, false, true, true, true,
4149 : : ix86_handle_tm_regparm_attribute, NULL },
4150 : : /* force_align_arg_pointer says this function realigns the stack at entry. */
4151 : : { "force_align_arg_pointer", 0, 0,
4152 : : false, true, true, false, ix86_handle_force_align_arg_pointer_attribute,
4153 : : NULL },
4154 : : #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
4155 : : { "dllimport", 0, 0, false, false, false, false, handle_dll_attribute,
4156 : : NULL },
4157 : : { "dllexport", 0, 0, false, false, false, false, handle_dll_attribute,
4158 : : NULL },
4159 : : { "shared", 0, 0, true, false, false, false,
4160 : : ix86_handle_shared_attribute, NULL },
4161 : : #endif
4162 : : { "ms_struct", 0, 0, false, false, false, false,
4163 : : ix86_handle_struct_attribute, NULL },
4164 : : { "gcc_struct", 0, 0, false, false, false, false,
4165 : : ix86_handle_struct_attribute, NULL },
4166 : : #ifdef SUBTARGET_ATTRIBUTE_TABLE
4167 : : SUBTARGET_ATTRIBUTE_TABLE,
4168 : : #endif
4169 : : /* ms_abi and sysv_abi calling convention function attributes. */
4170 : : { "ms_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute, NULL },
4171 : : { "sysv_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute,
4172 : : NULL },
4173 : : { "ms_abi va_list", 0, 0, false, false, false, false, NULL, NULL },
4174 : : { "sysv_abi va_list", 0, 0, false, false, false, false, NULL, NULL },
4175 : : { "ms_hook_prologue", 0, 0, true, false, false, false,
4176 : : ix86_handle_fndecl_attribute, NULL },
4177 : : { "callee_pop_aggregate_return", 1, 1, false, true, true, true,
4178 : : ix86_handle_callee_pop_aggregate_return, NULL },
4179 : : { "interrupt", 0, 0, false, true, true, false,
4180 : : ix86_handle_interrupt_attribute, NULL },
4181 : : { "no_caller_saved_registers", 0, 0, false, true, true, false,
4182 : : ix86_handle_call_saved_registers_attribute, NULL },
4183 : : { "preserve_none", 0, 0, false, true, true, true,
4184 : : ix86_handle_call_saved_registers_attribute, NULL },
4185 : : { "no_callee_saved_registers", 0, 0, false, true, true, true,
4186 : : ix86_handle_call_saved_registers_attribute, NULL },
4187 : : { "naked", 0, 0, true, false, false, false,
4188 : : ix86_handle_fndecl_attribute, NULL },
4189 : : { "indirect_branch", 1, 1, true, false, false, false,
4190 : : ix86_handle_fndecl_attribute, NULL },
4191 : : { "function_return", 1, 1, true, false, false, false,
4192 : : ix86_handle_fndecl_attribute, NULL },
4193 : : { "indirect_return", 0, 0, false, true, true, false,
4194 : : NULL, NULL },
4195 : : { "fentry_name", 1, 1, true, false, false, false,
4196 : : ix86_handle_fentry_name, NULL },
4197 : : { "fentry_section", 1, 1, true, false, false, false,
4198 : : ix86_handle_fentry_name, NULL },
4199 : : { "cf_check", 0, 0, true, false, false, false,
4200 : : ix86_handle_fndecl_attribute, NULL },
4201 : : { "nodirect_extern_access", 0, 0, true, false, false, false,
4202 : : handle_nodirect_extern_access_attribute, NULL }
4203 : : };
4204 : :
4205 : : const scoped_attribute_specs ix86_gnu_attribute_table =
4206 : : {
4207 : : "gnu", { ix86_gnu_attributes }
4208 : : };
4209 : :
4210 : : #include "gt-i386-options.h"
|