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