]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/i386/i386-options.c
Add call_used_or_fixed_reg_p
[thirdparty/gcc.git] / gcc / config / i386 / i386-options.c
1 /* Copyright (C) 1988-2019 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 "params.h"
62 #include "cselib.h"
63 #include "sched-int.h"
64 #include "opts.h"
65 #include "tree-pass.h"
66 #include "context.h"
67 #include "pass_manager.h"
68 #include "target-globals.h"
69 #include "gimple-iterator.h"
70 #include "tree-vectorizer.h"
71 #include "shrink-wrap.h"
72 #include "builtins.h"
73 #include "rtl-iter.h"
74 #include "tree-iterator.h"
75 #include "dbgcnt.h"
76 #include "case-cfn-macros.h"
77 #include "dojump.h"
78 #include "fold-const-call.h"
79 #include "tree-vrp.h"
80 #include "tree-ssanames.h"
81 #include "selftest.h"
82 #include "selftest-rtl.h"
83 #include "print-rtl.h"
84 #include "intl.h"
85 #include "ifcvt.h"
86 #include "symbol-summary.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_386 (HOST_WIDE_INT_1U<<PROCESSOR_I386)
103 #define m_486 (HOST_WIDE_INT_1U<<PROCESSOR_I486)
104 #define m_PENT (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM)
105 #define m_LAKEMONT (HOST_WIDE_INT_1U<<PROCESSOR_LAKEMONT)
106 #define m_PPRO (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUMPRO)
107 #define m_PENT4 (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM4)
108 #define m_NOCONA (HOST_WIDE_INT_1U<<PROCESSOR_NOCONA)
109 #define m_P4_NOCONA (m_PENT4 | m_NOCONA)
110 #define m_CORE2 (HOST_WIDE_INT_1U<<PROCESSOR_CORE2)
111 #define m_NEHALEM (HOST_WIDE_INT_1U<<PROCESSOR_NEHALEM)
112 #define m_SANDYBRIDGE (HOST_WIDE_INT_1U<<PROCESSOR_SANDYBRIDGE)
113 #define m_HASWELL (HOST_WIDE_INT_1U<<PROCESSOR_HASWELL)
114 #define m_BONNELL (HOST_WIDE_INT_1U<<PROCESSOR_BONNELL)
115 #define m_SILVERMONT (HOST_WIDE_INT_1U<<PROCESSOR_SILVERMONT)
116 #define m_KNL (HOST_WIDE_INT_1U<<PROCESSOR_KNL)
117 #define m_KNM (HOST_WIDE_INT_1U<<PROCESSOR_KNM)
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_CORE_AVX512 (m_SKYLAKE_AVX512 | m_CANNONLAKE \
127 | m_ICELAKE_CLIENT | m_ICELAKE_SERVER | m_CASCADELAKE \
128 | m_TIGERLAKE | m_COOPERLAKE)
129 #define m_CORE_AVX2 (m_HASWELL | m_SKYLAKE | m_CORE_AVX512)
130 #define m_CORE_ALL (m_CORE2 | m_NEHALEM | m_SANDYBRIDGE | m_CORE_AVX2)
131 #define m_GOLDMONT (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT)
132 #define m_GOLDMONT_PLUS (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT_PLUS)
133 #define m_TREMONT (HOST_WIDE_INT_1U<<PROCESSOR_TREMONT)
134 #define m_INTEL (HOST_WIDE_INT_1U<<PROCESSOR_INTEL)
135
136 #define m_GEODE (HOST_WIDE_INT_1U<<PROCESSOR_GEODE)
137 #define m_K6 (HOST_WIDE_INT_1U<<PROCESSOR_K6)
138 #define m_K6_GEODE (m_K6 | m_GEODE)
139 #define m_K8 (HOST_WIDE_INT_1U<<PROCESSOR_K8)
140 #define m_ATHLON (HOST_WIDE_INT_1U<<PROCESSOR_ATHLON)
141 #define m_ATHLON_K8 (m_K8 | m_ATHLON)
142 #define m_AMDFAM10 (HOST_WIDE_INT_1U<<PROCESSOR_AMDFAM10)
143 #define m_BDVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER1)
144 #define m_BDVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER2)
145 #define m_BDVER3 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER3)
146 #define m_BDVER4 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER4)
147 #define m_ZNVER1 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER1)
148 #define m_ZNVER2 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER2)
149 #define m_BTVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER1)
150 #define m_BTVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER2)
151 #define m_BDVER (m_BDVER1 | m_BDVER2 | m_BDVER3 | m_BDVER4)
152 #define m_BTVER (m_BTVER1 | m_BTVER2)
153 #define m_ZNVER (m_ZNVER1 | m_ZNVER2)
154 #define m_AMD_MULTIPLE (m_ATHLON_K8 | m_AMDFAM10 | m_BDVER | m_BTVER \
155 | m_ZNVER)
156
157 #define m_GENERIC (HOST_WIDE_INT_1U<<PROCESSOR_GENERIC)
158
159 const char* ix86_tune_feature_names[X86_TUNE_LAST] = {
160 #undef DEF_TUNE
161 #define DEF_TUNE(tune, name, selector) name,
162 #include "x86-tune.def"
163 #undef DEF_TUNE
164 };
165
166 /* Feature tests against the various tunings. */
167 unsigned char ix86_tune_features[X86_TUNE_LAST];
168
169 /* Feature tests against the various tunings used to create ix86_tune_features
170 based on the processor mask. */
171 static unsigned HOST_WIDE_INT initial_ix86_tune_features[X86_TUNE_LAST] = {
172 #undef DEF_TUNE
173 #define DEF_TUNE(tune, name, selector) selector,
174 #include "x86-tune.def"
175 #undef DEF_TUNE
176 };
177
178 /* Feature tests against the various architecture variations. */
179 unsigned char ix86_arch_features[X86_ARCH_LAST];
180
181 /* Return a string that documents the current -m options. The caller is
182 responsible for freeing the string. */
183
184 char *
185 ix86_target_string (HOST_WIDE_INT isa, HOST_WIDE_INT isa2,
186 int flags, int flags2,
187 const char *arch, const char *tune,
188 enum fpmath_unit fpmath, bool add_nl_p, bool add_abi_p)
189 {
190 struct ix86_target_opts
191 {
192 const char *option; /* option string */
193 HOST_WIDE_INT mask; /* isa mask options */
194 };
195
196 /* This table is ordered so that options like -msse4.2 that imply other
197 ISAs come first. Target string will be displayed in the same order. */
198 static struct ix86_target_opts isa2_opts[] =
199 {
200 { "-mcx16", OPTION_MASK_ISA_CX16 },
201 { "-mvaes", OPTION_MASK_ISA_VAES },
202 { "-mrdpid", OPTION_MASK_ISA_RDPID },
203 { "-mpconfig", OPTION_MASK_ISA_PCONFIG },
204 { "-mwbnoinvd", OPTION_MASK_ISA_WBNOINVD },
205 { "-mavx512vp2intersect", OPTION_MASK_ISA_AVX512VP2INTERSECT },
206 { "-msgx", OPTION_MASK_ISA_SGX },
207 { "-mavx5124vnniw", OPTION_MASK_ISA_AVX5124VNNIW },
208 { "-mavx5124fmaps", OPTION_MASK_ISA_AVX5124FMAPS },
209 { "-mhle", OPTION_MASK_ISA_HLE },
210 { "-mmovbe", OPTION_MASK_ISA_MOVBE },
211 { "-mclzero", OPTION_MASK_ISA_CLZERO },
212 { "-mmwaitx", OPTION_MASK_ISA_MWAITX },
213 { "-mmovdir64b", OPTION_MASK_ISA_MOVDIR64B },
214 { "-mwaitpkg", OPTION_MASK_ISA_WAITPKG },
215 { "-mcldemote", OPTION_MASK_ISA_CLDEMOTE },
216 { "-mptwrite", OPTION_MASK_ISA_PTWRITE },
217 { "-mavx512bf16", OPTION_MASK_ISA_AVX512BF16 },
218 { "-menqcmd", OPTION_MASK_ISA_ENQCMD }
219 };
220 static struct ix86_target_opts isa_opts[] =
221 {
222 { "-mavx512vpopcntdq", OPTION_MASK_ISA_AVX512VPOPCNTDQ },
223 { "-mavx512bitalg", OPTION_MASK_ISA_AVX512BITALG },
224 { "-mvpclmulqdq", OPTION_MASK_ISA_VPCLMULQDQ },
225 { "-mgfni", OPTION_MASK_ISA_GFNI },
226 { "-mavx512vnni", OPTION_MASK_ISA_AVX512VNNI },
227 { "-mavx512vbmi2", OPTION_MASK_ISA_AVX512VBMI2 },
228 { "-mavx512vbmi", OPTION_MASK_ISA_AVX512VBMI },
229 { "-mavx512ifma", OPTION_MASK_ISA_AVX512IFMA },
230 { "-mavx512vl", OPTION_MASK_ISA_AVX512VL },
231 { "-mavx512bw", OPTION_MASK_ISA_AVX512BW },
232 { "-mavx512dq", OPTION_MASK_ISA_AVX512DQ },
233 { "-mavx512er", OPTION_MASK_ISA_AVX512ER },
234 { "-mavx512pf", OPTION_MASK_ISA_AVX512PF },
235 { "-mavx512cd", OPTION_MASK_ISA_AVX512CD },
236 { "-mavx512f", OPTION_MASK_ISA_AVX512F },
237 { "-mavx2", OPTION_MASK_ISA_AVX2 },
238 { "-mfma", OPTION_MASK_ISA_FMA },
239 { "-mxop", OPTION_MASK_ISA_XOP },
240 { "-mfma4", OPTION_MASK_ISA_FMA4 },
241 { "-mf16c", OPTION_MASK_ISA_F16C },
242 { "-mavx", OPTION_MASK_ISA_AVX },
243 /* { "-msse4" OPTION_MASK_ISA_SSE4 }, */
244 { "-msse4.2", OPTION_MASK_ISA_SSE4_2 },
245 { "-msse4.1", OPTION_MASK_ISA_SSE4_1 },
246 { "-msse4a", OPTION_MASK_ISA_SSE4A },
247 { "-mssse3", OPTION_MASK_ISA_SSSE3 },
248 { "-msse3", OPTION_MASK_ISA_SSE3 },
249 { "-maes", OPTION_MASK_ISA_AES },
250 { "-msha", OPTION_MASK_ISA_SHA },
251 { "-mpclmul", OPTION_MASK_ISA_PCLMUL },
252 { "-msse2", OPTION_MASK_ISA_SSE2 },
253 { "-msse", OPTION_MASK_ISA_SSE },
254 { "-m3dnowa", OPTION_MASK_ISA_3DNOW_A },
255 { "-m3dnow", OPTION_MASK_ISA_3DNOW },
256 { "-mmmx", OPTION_MASK_ISA_MMX },
257 { "-mrtm", OPTION_MASK_ISA_RTM },
258 { "-mprfchw", OPTION_MASK_ISA_PRFCHW },
259 { "-mrdseed", OPTION_MASK_ISA_RDSEED },
260 { "-madx", OPTION_MASK_ISA_ADX },
261 { "-mprefetchwt1", OPTION_MASK_ISA_PREFETCHWT1 },
262 { "-mclflushopt", OPTION_MASK_ISA_CLFLUSHOPT },
263 { "-mxsaves", OPTION_MASK_ISA_XSAVES },
264 { "-mxsavec", OPTION_MASK_ISA_XSAVEC },
265 { "-mxsaveopt", OPTION_MASK_ISA_XSAVEOPT },
266 { "-mxsave", OPTION_MASK_ISA_XSAVE },
267 { "-mabm", OPTION_MASK_ISA_ABM },
268 { "-mbmi", OPTION_MASK_ISA_BMI },
269 { "-mbmi2", OPTION_MASK_ISA_BMI2 },
270 { "-mlzcnt", OPTION_MASK_ISA_LZCNT },
271 { "-mtbm", OPTION_MASK_ISA_TBM },
272 { "-mpopcnt", OPTION_MASK_ISA_POPCNT },
273 { "-msahf", OPTION_MASK_ISA_SAHF },
274 { "-mcrc32", OPTION_MASK_ISA_CRC32 },
275 { "-mfsgsbase", OPTION_MASK_ISA_FSGSBASE },
276 { "-mrdrnd", OPTION_MASK_ISA_RDRND },
277 { "-mpku", OPTION_MASK_ISA_PKU },
278 { "-mlwp", OPTION_MASK_ISA_LWP },
279 { "-mfxsr", OPTION_MASK_ISA_FXSR },
280 { "-mclwb", OPTION_MASK_ISA_CLWB },
281 { "-mshstk", OPTION_MASK_ISA_SHSTK },
282 { "-mmovdiri", OPTION_MASK_ISA_MOVDIRI }
283 };
284
285 /* Flag options. */
286 static struct ix86_target_opts flag_opts[] =
287 {
288 { "-m128bit-long-double", MASK_128BIT_LONG_DOUBLE },
289 { "-mlong-double-128", MASK_LONG_DOUBLE_128 },
290 { "-mlong-double-64", MASK_LONG_DOUBLE_64 },
291 { "-m80387", MASK_80387 },
292 { "-maccumulate-outgoing-args", MASK_ACCUMULATE_OUTGOING_ARGS },
293 { "-malign-double", MASK_ALIGN_DOUBLE },
294 { "-mcld", MASK_CLD },
295 { "-mfp-ret-in-387", MASK_FLOAT_RETURNS },
296 { "-mieee-fp", MASK_IEEE_FP },
297 { "-minline-all-stringops", MASK_INLINE_ALL_STRINGOPS },
298 { "-minline-stringops-dynamically", MASK_INLINE_STRINGOPS_DYNAMICALLY },
299 { "-mms-bitfields", MASK_MS_BITFIELD_LAYOUT },
300 { "-mno-align-stringops", MASK_NO_ALIGN_STRINGOPS },
301 { "-mno-fancy-math-387", MASK_NO_FANCY_MATH_387 },
302 { "-mno-push-args", MASK_NO_PUSH_ARGS },
303 { "-mno-red-zone", MASK_NO_RED_ZONE },
304 { "-momit-leaf-frame-pointer", MASK_OMIT_LEAF_FRAME_POINTER },
305 { "-mrecip", MASK_RECIP },
306 { "-mrtd", MASK_RTD },
307 { "-msseregparm", MASK_SSEREGPARM },
308 { "-mstack-arg-probe", MASK_STACK_PROBE },
309 { "-mtls-direct-seg-refs", MASK_TLS_DIRECT_SEG_REFS },
310 { "-mvect8-ret-in-mem", MASK_VECT8_RETURNS },
311 { "-m8bit-idiv", MASK_USE_8BIT_IDIV },
312 { "-mvzeroupper", MASK_VZEROUPPER },
313 { "-mstv", MASK_STV },
314 { "-mavx256-split-unaligned-load", MASK_AVX256_SPLIT_UNALIGNED_LOAD },
315 { "-mavx256-split-unaligned-store", MASK_AVX256_SPLIT_UNALIGNED_STORE },
316 { "-mcall-ms2sysv-xlogues", MASK_CALL_MS2SYSV_XLOGUES }
317 };
318
319 /* Additional flag options. */
320 static struct ix86_target_opts flag2_opts[] =
321 {
322 { "-mgeneral-regs-only", OPTION_MASK_GENERAL_REGS_ONLY }
323 };
324
325 const char *opts[ARRAY_SIZE (isa_opts) + ARRAY_SIZE (isa2_opts)
326 + ARRAY_SIZE (flag_opts) + ARRAY_SIZE (flag2_opts) + 6][2];
327
328 char isa_other[40];
329 char isa2_other[40];
330 char flags_other[40];
331 char flags2_other[40];
332 unsigned num = 0;
333 unsigned i, j;
334 char *ret;
335 char *ptr;
336 size_t len;
337 size_t line_len;
338 size_t sep_len;
339 const char *abi;
340
341 memset (opts, '\0', sizeof (opts));
342
343 /* Add -march= option. */
344 if (arch)
345 {
346 opts[num][0] = "-march=";
347 opts[num++][1] = arch;
348 }
349
350 /* Add -mtune= option. */
351 if (tune)
352 {
353 opts[num][0] = "-mtune=";
354 opts[num++][1] = tune;
355 }
356
357 /* Add -m32/-m64/-mx32. */
358 if (add_abi_p)
359 {
360 if ((isa & OPTION_MASK_ISA_64BIT) != 0)
361 {
362 if ((isa & OPTION_MASK_ABI_64) != 0)
363 abi = "-m64";
364 else
365 abi = "-mx32";
366 }
367 else
368 abi = "-m32";
369 opts[num++][0] = abi;
370 }
371 isa &= ~(OPTION_MASK_ISA_64BIT | OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
372
373 /* Pick out the options in isa2 options. */
374 for (i = 0; i < ARRAY_SIZE (isa2_opts); i++)
375 {
376 if ((isa2 & isa2_opts[i].mask) != 0)
377 {
378 opts[num++][0] = isa2_opts[i].option;
379 isa2 &= ~ isa2_opts[i].mask;
380 }
381 }
382
383 if (isa2 && add_nl_p)
384 {
385 opts[num++][0] = isa2_other;
386 sprintf (isa2_other, "(other isa2: %#" HOST_WIDE_INT_PRINT "x)", isa2);
387 }
388
389 /* Pick out the options in isa options. */
390 for (i = 0; i < ARRAY_SIZE (isa_opts); i++)
391 {
392 if ((isa & isa_opts[i].mask) != 0)
393 {
394 opts[num++][0] = isa_opts[i].option;
395 isa &= ~ isa_opts[i].mask;
396 }
397 }
398
399 if (isa && add_nl_p)
400 {
401 opts[num++][0] = isa_other;
402 sprintf (isa_other, "(other isa: %#" HOST_WIDE_INT_PRINT "x)", isa);
403 }
404
405 /* Add flag options. */
406 for (i = 0; i < ARRAY_SIZE (flag_opts); i++)
407 {
408 if ((flags & flag_opts[i].mask) != 0)
409 {
410 opts[num++][0] = flag_opts[i].option;
411 flags &= ~ flag_opts[i].mask;
412 }
413 }
414
415 if (flags && add_nl_p)
416 {
417 opts[num++][0] = flags_other;
418 sprintf (flags_other, "(other flags: %#x)", flags);
419 }
420
421 /* Add additional flag options. */
422 for (i = 0; i < ARRAY_SIZE (flag2_opts); i++)
423 {
424 if ((flags2 & flag2_opts[i].mask) != 0)
425 {
426 opts[num++][0] = flag2_opts[i].option;
427 flags2 &= ~ flag2_opts[i].mask;
428 }
429 }
430
431 if (flags2 && add_nl_p)
432 {
433 opts[num++][0] = flags2_other;
434 sprintf (flags2_other, "(other flags2: %#x)", flags2);
435 }
436
437 /* Add -fpmath= option. */
438 if (fpmath)
439 {
440 opts[num][0] = "-mfpmath=";
441 switch ((int) fpmath)
442 {
443 case FPMATH_387:
444 opts[num++][1] = "387";
445 break;
446
447 case FPMATH_SSE:
448 opts[num++][1] = "sse";
449 break;
450
451 case FPMATH_387 | FPMATH_SSE:
452 opts[num++][1] = "sse+387";
453 break;
454
455 default:
456 gcc_unreachable ();
457 }
458 }
459
460 /* Any options? */
461 if (num == 0)
462 return NULL;
463
464 gcc_assert (num < ARRAY_SIZE (opts));
465
466 /* Size the string. */
467 len = 0;
468 sep_len = (add_nl_p) ? 3 : 1;
469 for (i = 0; i < num; i++)
470 {
471 len += sep_len;
472 for (j = 0; j < 2; j++)
473 if (opts[i][j])
474 len += strlen (opts[i][j]);
475 }
476
477 /* Build the string. */
478 ret = ptr = (char *) xmalloc (len);
479 line_len = 0;
480
481 for (i = 0; i < num; i++)
482 {
483 size_t len2[2];
484
485 for (j = 0; j < 2; j++)
486 len2[j] = (opts[i][j]) ? strlen (opts[i][j]) : 0;
487
488 if (i != 0)
489 {
490 *ptr++ = ' ';
491 line_len++;
492
493 if (add_nl_p && line_len + len2[0] + len2[1] > 70)
494 {
495 *ptr++ = '\\';
496 *ptr++ = '\n';
497 line_len = 0;
498 }
499 }
500
501 for (j = 0; j < 2; j++)
502 if (opts[i][j])
503 {
504 memcpy (ptr, opts[i][j], len2[j]);
505 ptr += len2[j];
506 line_len += len2[j];
507 }
508 }
509
510 *ptr = '\0';
511 gcc_assert (ret + len >= ptr);
512
513 return ret;
514 }
515
516 /* Function that is callable from the debugger to print the current
517 options. */
518 void ATTRIBUTE_UNUSED
519 ix86_debug_options (void)
520 {
521 char *opts = ix86_target_string (ix86_isa_flags, ix86_isa_flags2,
522 target_flags, ix86_target_flags,
523 ix86_arch_string,ix86_tune_string,
524 ix86_fpmath, true, true);
525
526 if (opts)
527 {
528 fprintf (stderr, "%s\n\n", opts);
529 free (opts);
530 }
531 else
532 fputs ("<no options>\n\n", stderr);
533
534 return;
535 }
536
537 /* Save the current options */
538
539 void
540 ix86_function_specific_save (struct cl_target_option *ptr,
541 struct gcc_options *opts)
542 {
543 ptr->arch = ix86_arch;
544 ptr->schedule = ix86_schedule;
545 ptr->prefetch_sse = x86_prefetch_sse;
546 ptr->tune = ix86_tune;
547 ptr->branch_cost = ix86_branch_cost;
548 ptr->tune_defaulted = ix86_tune_defaulted;
549 ptr->arch_specified = ix86_arch_specified;
550 ptr->x_ix86_isa_flags_explicit = opts->x_ix86_isa_flags_explicit;
551 ptr->x_ix86_isa_flags2_explicit = opts->x_ix86_isa_flags2_explicit;
552 ptr->x_recip_mask_explicit = opts->x_recip_mask_explicit;
553 ptr->x_ix86_arch_string = opts->x_ix86_arch_string;
554 ptr->x_ix86_tune_string = opts->x_ix86_tune_string;
555 ptr->x_ix86_cmodel = opts->x_ix86_cmodel;
556 ptr->x_ix86_abi = opts->x_ix86_abi;
557 ptr->x_ix86_asm_dialect = opts->x_ix86_asm_dialect;
558 ptr->x_ix86_branch_cost = opts->x_ix86_branch_cost;
559 ptr->x_ix86_dump_tunes = opts->x_ix86_dump_tunes;
560 ptr->x_ix86_force_align_arg_pointer = opts->x_ix86_force_align_arg_pointer;
561 ptr->x_ix86_force_drap = opts->x_ix86_force_drap;
562 ptr->x_ix86_incoming_stack_boundary_arg = opts->x_ix86_incoming_stack_boundary_arg;
563 ptr->x_ix86_pmode = opts->x_ix86_pmode;
564 ptr->x_ix86_preferred_stack_boundary_arg = opts->x_ix86_preferred_stack_boundary_arg;
565 ptr->x_ix86_recip_name = opts->x_ix86_recip_name;
566 ptr->x_ix86_regparm = opts->x_ix86_regparm;
567 ptr->x_ix86_section_threshold = opts->x_ix86_section_threshold;
568 ptr->x_ix86_sse2avx = opts->x_ix86_sse2avx;
569 ptr->x_ix86_stack_protector_guard = opts->x_ix86_stack_protector_guard;
570 ptr->x_ix86_stringop_alg = opts->x_ix86_stringop_alg;
571 ptr->x_ix86_tls_dialect = opts->x_ix86_tls_dialect;
572 ptr->x_ix86_tune_ctrl_string = opts->x_ix86_tune_ctrl_string;
573 ptr->x_ix86_tune_memcpy_strategy = opts->x_ix86_tune_memcpy_strategy;
574 ptr->x_ix86_tune_memset_strategy = opts->x_ix86_tune_memset_strategy;
575 ptr->x_ix86_tune_no_default = opts->x_ix86_tune_no_default;
576 ptr->x_ix86_veclibabi_type = opts->x_ix86_veclibabi_type;
577
578 /* The fields are char but the variables are not; make sure the
579 values fit in the fields. */
580 gcc_assert (ptr->arch == ix86_arch);
581 gcc_assert (ptr->schedule == ix86_schedule);
582 gcc_assert (ptr->tune == ix86_tune);
583 gcc_assert (ptr->branch_cost == ix86_branch_cost);
584 }
585
586 /* Feature tests against the various architecture variations, used to create
587 ix86_arch_features based on the processor mask. */
588 static unsigned HOST_WIDE_INT initial_ix86_arch_features[X86_ARCH_LAST] = {
589 /* X86_ARCH_CMOV: Conditional move was added for pentiumpro. */
590 ~(m_386 | m_486 | m_PENT | m_LAKEMONT | m_K6),
591
592 /* X86_ARCH_CMPXCHG: Compare and exchange was added for 80486. */
593 ~m_386,
594
595 /* X86_ARCH_CMPXCHG8B: Compare and exchange 8 bytes was added for pentium. */
596 ~(m_386 | m_486),
597
598 /* X86_ARCH_XADD: Exchange and add was added for 80486. */
599 ~m_386,
600
601 /* X86_ARCH_BSWAP: Byteswap was added for 80486. */
602 ~m_386,
603 };
604
605 /* This table must be in sync with enum processor_type in i386.h. */
606 static const struct processor_costs *processor_cost_table[] =
607 {
608 &generic_cost,
609 &i386_cost,
610 &i486_cost,
611 &pentium_cost,
612 &lakemont_cost,
613 &pentiumpro_cost,
614 &pentium4_cost,
615 &nocona_cost,
616 &core_cost,
617 &core_cost,
618 &core_cost,
619 &core_cost,
620 &atom_cost,
621 &slm_cost,
622 &slm_cost,
623 &slm_cost,
624 &slm_cost,
625 &slm_cost,
626 &slm_cost,
627 &skylake_cost,
628 &skylake_cost,
629 &skylake_cost,
630 &skylake_cost,
631 &skylake_cost,
632 &skylake_cost,
633 &skylake_cost,
634 &skylake_cost,
635 &intel_cost,
636 &geode_cost,
637 &k6_cost,
638 &athlon_cost,
639 &k8_cost,
640 &amdfam10_cost,
641 &bdver_cost,
642 &bdver_cost,
643 &bdver_cost,
644 &bdver_cost,
645 &btver1_cost,
646 &btver2_cost,
647 &znver1_cost,
648 &znver2_cost
649 };
650
651 /* Guarantee that the array is aligned with enum processor_type. */
652 STATIC_ASSERT (ARRAY_SIZE (processor_cost_table) == PROCESSOR_max);
653
654 static bool
655 ix86_option_override_internal (bool main_args_p,
656 struct gcc_options *opts,
657 struct gcc_options *opts_set);
658 static void
659 set_ix86_tune_features (enum processor_type ix86_tune, bool dump);
660
661 /* Restore the current options */
662
663 void
664 ix86_function_specific_restore (struct gcc_options *opts,
665 struct cl_target_option *ptr)
666 {
667 enum processor_type old_tune = ix86_tune;
668 enum processor_type old_arch = ix86_arch;
669 unsigned HOST_WIDE_INT ix86_arch_mask;
670 int i;
671
672 /* We don't change -fPIC. */
673 opts->x_flag_pic = flag_pic;
674
675 ix86_arch = (enum processor_type) ptr->arch;
676 ix86_schedule = (enum attr_cpu) ptr->schedule;
677 ix86_tune = (enum processor_type) ptr->tune;
678 x86_prefetch_sse = ptr->prefetch_sse;
679 opts->x_ix86_branch_cost = ptr->branch_cost;
680 ix86_tune_defaulted = ptr->tune_defaulted;
681 ix86_arch_specified = ptr->arch_specified;
682 opts->x_ix86_isa_flags_explicit = ptr->x_ix86_isa_flags_explicit;
683 opts->x_ix86_isa_flags2_explicit = ptr->x_ix86_isa_flags2_explicit;
684 opts->x_recip_mask_explicit = ptr->x_recip_mask_explicit;
685 opts->x_ix86_arch_string = ptr->x_ix86_arch_string;
686 opts->x_ix86_tune_string = ptr->x_ix86_tune_string;
687 opts->x_ix86_cmodel = ptr->x_ix86_cmodel;
688 opts->x_ix86_abi = ptr->x_ix86_abi;
689 opts->x_ix86_asm_dialect = ptr->x_ix86_asm_dialect;
690 opts->x_ix86_branch_cost = ptr->x_ix86_branch_cost;
691 opts->x_ix86_dump_tunes = ptr->x_ix86_dump_tunes;
692 opts->x_ix86_force_align_arg_pointer = ptr->x_ix86_force_align_arg_pointer;
693 opts->x_ix86_force_drap = ptr->x_ix86_force_drap;
694 opts->x_ix86_incoming_stack_boundary_arg = ptr->x_ix86_incoming_stack_boundary_arg;
695 opts->x_ix86_pmode = ptr->x_ix86_pmode;
696 opts->x_ix86_preferred_stack_boundary_arg = ptr->x_ix86_preferred_stack_boundary_arg;
697 opts->x_ix86_recip_name = ptr->x_ix86_recip_name;
698 opts->x_ix86_regparm = ptr->x_ix86_regparm;
699 opts->x_ix86_section_threshold = ptr->x_ix86_section_threshold;
700 opts->x_ix86_sse2avx = ptr->x_ix86_sse2avx;
701 opts->x_ix86_stack_protector_guard = ptr->x_ix86_stack_protector_guard;
702 opts->x_ix86_stringop_alg = ptr->x_ix86_stringop_alg;
703 opts->x_ix86_tls_dialect = ptr->x_ix86_tls_dialect;
704 opts->x_ix86_tune_ctrl_string = ptr->x_ix86_tune_ctrl_string;
705 opts->x_ix86_tune_memcpy_strategy = ptr->x_ix86_tune_memcpy_strategy;
706 opts->x_ix86_tune_memset_strategy = ptr->x_ix86_tune_memset_strategy;
707 opts->x_ix86_tune_no_default = ptr->x_ix86_tune_no_default;
708 opts->x_ix86_veclibabi_type = ptr->x_ix86_veclibabi_type;
709 ix86_tune_cost = processor_cost_table[ix86_tune];
710 /* TODO: ix86_cost should be chosen at instruction or function granuality
711 so for cold code we use size_cost even in !optimize_size compilation. */
712 if (opts->x_optimize_size)
713 ix86_cost = &ix86_size_cost;
714 else
715 ix86_cost = ix86_tune_cost;
716
717 /* Recreate the arch feature tests if the arch changed */
718 if (old_arch != ix86_arch)
719 {
720 ix86_arch_mask = HOST_WIDE_INT_1U << ix86_arch;
721 for (i = 0; i < X86_ARCH_LAST; ++i)
722 ix86_arch_features[i]
723 = !!(initial_ix86_arch_features[i] & ix86_arch_mask);
724 }
725
726 /* Recreate the tune optimization tests */
727 if (old_tune != ix86_tune)
728 set_ix86_tune_features (ix86_tune, false);
729 }
730
731 /* Adjust target options after streaming them in. This is mainly about
732 reconciling them with global options. */
733
734 void
735 ix86_function_specific_post_stream_in (struct cl_target_option *ptr)
736 {
737 /* flag_pic is a global option, but ix86_cmodel is target saved option
738 partly computed from flag_pic. If flag_pic is on, adjust x_ix86_cmodel
739 for PIC, or error out. */
740 if (flag_pic)
741 switch (ptr->x_ix86_cmodel)
742 {
743 case CM_SMALL:
744 ptr->x_ix86_cmodel = CM_SMALL_PIC;
745 break;
746
747 case CM_MEDIUM:
748 ptr->x_ix86_cmodel = CM_MEDIUM_PIC;
749 break;
750
751 case CM_LARGE:
752 ptr->x_ix86_cmodel = CM_LARGE_PIC;
753 break;
754
755 case CM_KERNEL:
756 error ("code model %s does not support PIC mode", "kernel");
757 break;
758
759 default:
760 break;
761 }
762 else
763 switch (ptr->x_ix86_cmodel)
764 {
765 case CM_SMALL_PIC:
766 ptr->x_ix86_cmodel = CM_SMALL;
767 break;
768
769 case CM_MEDIUM_PIC:
770 ptr->x_ix86_cmodel = CM_MEDIUM;
771 break;
772
773 case CM_LARGE_PIC:
774 ptr->x_ix86_cmodel = CM_LARGE;
775 break;
776
777 default:
778 break;
779 }
780 }
781
782 /* Print the current options */
783
784 void
785 ix86_function_specific_print (FILE *file, int indent,
786 struct cl_target_option *ptr)
787 {
788 char *target_string
789 = ix86_target_string (ptr->x_ix86_isa_flags, ptr->x_ix86_isa_flags2,
790 ptr->x_target_flags, ptr->x_ix86_target_flags,
791 NULL, NULL, ptr->x_ix86_fpmath, false, true);
792
793 gcc_assert (ptr->arch < PROCESSOR_max);
794 fprintf (file, "%*sarch = %d (%s)\n",
795 indent, "",
796 ptr->arch, processor_names[ptr->arch]);
797
798 gcc_assert (ptr->tune < PROCESSOR_max);
799 fprintf (file, "%*stune = %d (%s)\n",
800 indent, "",
801 ptr->tune, processor_names[ptr->tune]);
802
803 fprintf (file, "%*sbranch_cost = %d\n", indent, "", ptr->branch_cost);
804
805 if (target_string)
806 {
807 fprintf (file, "%*s%s\n", indent, "", target_string);
808 free (target_string);
809 }
810 }
811
812 \f
813 /* Inner function to process the attribute((target(...))), take an argument and
814 set the current options from the argument. If we have a list, recursively go
815 over the list. */
816
817 static bool
818 ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[],
819 struct gcc_options *opts,
820 struct gcc_options *opts_set,
821 struct gcc_options *enum_opts_set,
822 bool target_clone_attr)
823 {
824 char *next_optstr;
825 bool ret = true;
826
827 #define IX86_ATTR_ISA(S,O) { S, sizeof (S)-1, ix86_opt_isa, O, 0 }
828 #define IX86_ATTR_STR(S,O) { S, sizeof (S)-1, ix86_opt_str, O, 0 }
829 #define IX86_ATTR_ENUM(S,O) { S, sizeof (S)-1, ix86_opt_enum, O, 0 }
830 #define IX86_ATTR_YES(S,O,M) { S, sizeof (S)-1, ix86_opt_yes, O, M }
831 #define IX86_ATTR_NO(S,O,M) { S, sizeof (S)-1, ix86_opt_no, O, M }
832
833 enum ix86_opt_type
834 {
835 ix86_opt_unknown,
836 ix86_opt_yes,
837 ix86_opt_no,
838 ix86_opt_str,
839 ix86_opt_enum,
840 ix86_opt_isa
841 };
842
843 static const struct
844 {
845 const char *string;
846 size_t len;
847 enum ix86_opt_type type;
848 int opt;
849 int mask;
850 } attrs[] = {
851 /* isa options */
852 IX86_ATTR_ISA ("pconfig", OPT_mpconfig),
853 IX86_ATTR_ISA ("wbnoinvd", OPT_mwbnoinvd),
854 IX86_ATTR_ISA ("sgx", OPT_msgx),
855 IX86_ATTR_ISA ("avx5124fmaps", OPT_mavx5124fmaps),
856 IX86_ATTR_ISA ("avx5124vnniw", OPT_mavx5124vnniw),
857 IX86_ATTR_ISA ("avx512vpopcntdq", OPT_mavx512vpopcntdq),
858 IX86_ATTR_ISA ("avx512vbmi2", OPT_mavx512vbmi2),
859 IX86_ATTR_ISA ("avx512vnni", OPT_mavx512vnni),
860 IX86_ATTR_ISA ("avx512bitalg", OPT_mavx512bitalg),
861 IX86_ATTR_ISA ("avx512vp2intersect", OPT_mavx512vp2intersect),
862
863 IX86_ATTR_ISA ("avx512vbmi", OPT_mavx512vbmi),
864 IX86_ATTR_ISA ("avx512ifma", OPT_mavx512ifma),
865 IX86_ATTR_ISA ("avx512vl", OPT_mavx512vl),
866 IX86_ATTR_ISA ("avx512bw", OPT_mavx512bw),
867 IX86_ATTR_ISA ("avx512dq", OPT_mavx512dq),
868 IX86_ATTR_ISA ("avx512er", OPT_mavx512er),
869 IX86_ATTR_ISA ("avx512pf", OPT_mavx512pf),
870 IX86_ATTR_ISA ("avx512cd", OPT_mavx512cd),
871 IX86_ATTR_ISA ("avx512f", OPT_mavx512f),
872 IX86_ATTR_ISA ("avx2", OPT_mavx2),
873 IX86_ATTR_ISA ("fma", OPT_mfma),
874 IX86_ATTR_ISA ("xop", OPT_mxop),
875 IX86_ATTR_ISA ("fma4", OPT_mfma4),
876 IX86_ATTR_ISA ("f16c", OPT_mf16c),
877 IX86_ATTR_ISA ("avx", OPT_mavx),
878 IX86_ATTR_ISA ("sse4", OPT_msse4),
879 IX86_ATTR_ISA ("sse4.2", OPT_msse4_2),
880 IX86_ATTR_ISA ("sse4.1", OPT_msse4_1),
881 IX86_ATTR_ISA ("sse4a", OPT_msse4a),
882 IX86_ATTR_ISA ("ssse3", OPT_mssse3),
883 IX86_ATTR_ISA ("sse3", OPT_msse3),
884 IX86_ATTR_ISA ("aes", OPT_maes),
885 IX86_ATTR_ISA ("sha", OPT_msha),
886 IX86_ATTR_ISA ("pclmul", OPT_mpclmul),
887 IX86_ATTR_ISA ("sse2", OPT_msse2),
888 IX86_ATTR_ISA ("sse", OPT_msse),
889 IX86_ATTR_ISA ("3dnowa", OPT_m3dnowa),
890 IX86_ATTR_ISA ("3dnow", OPT_m3dnow),
891 IX86_ATTR_ISA ("mmx", OPT_mmmx),
892 IX86_ATTR_ISA ("rtm", OPT_mrtm),
893 IX86_ATTR_ISA ("prfchw", OPT_mprfchw),
894 IX86_ATTR_ISA ("rdseed", OPT_mrdseed),
895 IX86_ATTR_ISA ("adx", OPT_madx),
896 IX86_ATTR_ISA ("prefetchwt1", OPT_mprefetchwt1),
897 IX86_ATTR_ISA ("clflushopt", OPT_mclflushopt),
898 IX86_ATTR_ISA ("xsaves", OPT_mxsaves),
899 IX86_ATTR_ISA ("xsavec", OPT_mxsavec),
900 IX86_ATTR_ISA ("xsaveopt", OPT_mxsaveopt),
901 IX86_ATTR_ISA ("xsave", OPT_mxsave),
902 IX86_ATTR_ISA ("abm", OPT_mabm),
903 IX86_ATTR_ISA ("bmi", OPT_mbmi),
904 IX86_ATTR_ISA ("bmi2", OPT_mbmi2),
905 IX86_ATTR_ISA ("lzcnt", OPT_mlzcnt),
906 IX86_ATTR_ISA ("tbm", OPT_mtbm),
907 IX86_ATTR_ISA ("popcnt", OPT_mpopcnt),
908 IX86_ATTR_ISA ("cx16", OPT_mcx16),
909 IX86_ATTR_ISA ("sahf", OPT_msahf),
910 IX86_ATTR_ISA ("movbe", OPT_mmovbe),
911 IX86_ATTR_ISA ("crc32", OPT_mcrc32),
912 IX86_ATTR_ISA ("fsgsbase", OPT_mfsgsbase),
913 IX86_ATTR_ISA ("rdrnd", OPT_mrdrnd),
914 IX86_ATTR_ISA ("mwaitx", OPT_mmwaitx),
915 IX86_ATTR_ISA ("clzero", OPT_mclzero),
916 IX86_ATTR_ISA ("pku", OPT_mpku),
917 IX86_ATTR_ISA ("lwp", OPT_mlwp),
918 IX86_ATTR_ISA ("hle", OPT_mhle),
919 IX86_ATTR_ISA ("fxsr", OPT_mfxsr),
920 IX86_ATTR_ISA ("clwb", OPT_mclwb),
921 IX86_ATTR_ISA ("rdpid", OPT_mrdpid),
922 IX86_ATTR_ISA ("gfni", OPT_mgfni),
923 IX86_ATTR_ISA ("shstk", OPT_mshstk),
924 IX86_ATTR_ISA ("vaes", OPT_mvaes),
925 IX86_ATTR_ISA ("vpclmulqdq", OPT_mvpclmulqdq),
926 IX86_ATTR_ISA ("movdiri", OPT_mmovdiri),
927 IX86_ATTR_ISA ("movdir64b", OPT_mmovdir64b),
928 IX86_ATTR_ISA ("waitpkg", OPT_mwaitpkg),
929 IX86_ATTR_ISA ("cldemote", OPT_mcldemote),
930 IX86_ATTR_ISA ("ptwrite", OPT_mptwrite),
931 IX86_ATTR_ISA ("avx512bf16", OPT_mavx512bf16),
932 IX86_ATTR_ISA ("enqcmd", OPT_menqcmd),
933
934 /* enum options */
935 IX86_ATTR_ENUM ("fpmath=", OPT_mfpmath_),
936
937 /* string options */
938 IX86_ATTR_STR ("arch=", IX86_FUNCTION_SPECIFIC_ARCH),
939 IX86_ATTR_STR ("tune=", IX86_FUNCTION_SPECIFIC_TUNE),
940
941 /* flag options */
942 IX86_ATTR_YES ("cld",
943 OPT_mcld,
944 MASK_CLD),
945
946 IX86_ATTR_NO ("fancy-math-387",
947 OPT_mfancy_math_387,
948 MASK_NO_FANCY_MATH_387),
949
950 IX86_ATTR_YES ("ieee-fp",
951 OPT_mieee_fp,
952 MASK_IEEE_FP),
953
954 IX86_ATTR_YES ("inline-all-stringops",
955 OPT_minline_all_stringops,
956 MASK_INLINE_ALL_STRINGOPS),
957
958 IX86_ATTR_YES ("inline-stringops-dynamically",
959 OPT_minline_stringops_dynamically,
960 MASK_INLINE_STRINGOPS_DYNAMICALLY),
961
962 IX86_ATTR_NO ("align-stringops",
963 OPT_mno_align_stringops,
964 MASK_NO_ALIGN_STRINGOPS),
965
966 IX86_ATTR_YES ("recip",
967 OPT_mrecip,
968 MASK_RECIP),
969 };
970
971 location_t loc
972 = fndecl == NULL ? UNKNOWN_LOCATION : DECL_SOURCE_LOCATION (fndecl);
973 const char *attr_name = target_clone_attr ? "target_clone" : "target";
974
975 /* If this is a list, recurse to get the options. */
976 if (TREE_CODE (args) == TREE_LIST)
977 {
978 bool ret = true;
979
980 for (; args; args = TREE_CHAIN (args))
981 if (TREE_VALUE (args)
982 && !ix86_valid_target_attribute_inner_p (fndecl, TREE_VALUE (args),
983 p_strings, opts, opts_set,
984 enum_opts_set,
985 target_clone_attr))
986 ret = false;
987
988 return ret;
989 }
990
991 else if (TREE_CODE (args) != STRING_CST)
992 {
993 error_at (loc, "attribute %qs argument is not a string", attr_name);
994 return false;
995 }
996
997 /* Handle multiple arguments separated by commas. */
998 next_optstr = ASTRDUP (TREE_STRING_POINTER (args));
999
1000 while (next_optstr && *next_optstr != '\0')
1001 {
1002 char *p = next_optstr;
1003 char *orig_p = p;
1004 char *comma = strchr (next_optstr, ',');
1005 size_t len, opt_len;
1006 int opt;
1007 bool opt_set_p;
1008 char ch;
1009 unsigned i;
1010 enum ix86_opt_type type = ix86_opt_unknown;
1011 int mask = 0;
1012
1013 if (comma)
1014 {
1015 *comma = '\0';
1016 len = comma - next_optstr;
1017 next_optstr = comma + 1;
1018 }
1019 else
1020 {
1021 len = strlen (p);
1022 next_optstr = NULL;
1023 }
1024
1025 /* Recognize no-xxx. */
1026 if (len > 3 && p[0] == 'n' && p[1] == 'o' && p[2] == '-')
1027 {
1028 opt_set_p = false;
1029 p += 3;
1030 len -= 3;
1031 }
1032 else
1033 opt_set_p = true;
1034
1035 /* Find the option. */
1036 ch = *p;
1037 opt = N_OPTS;
1038 for (i = 0; i < ARRAY_SIZE (attrs); i++)
1039 {
1040 type = attrs[i].type;
1041 opt_len = attrs[i].len;
1042 if (ch == attrs[i].string[0]
1043 && ((type != ix86_opt_str && type != ix86_opt_enum)
1044 ? len == opt_len
1045 : len > opt_len)
1046 && memcmp (p, attrs[i].string, opt_len) == 0)
1047 {
1048 opt = attrs[i].opt;
1049 mask = attrs[i].mask;
1050 break;
1051 }
1052 }
1053
1054 /* Process the option. */
1055 if (opt == N_OPTS)
1056 {
1057 error_at (loc, "attribute %qs argument %qs is unknown",
1058 orig_p, attr_name);
1059 ret = false;
1060 }
1061
1062 else if (type == ix86_opt_isa)
1063 {
1064 struct cl_decoded_option decoded;
1065
1066 generate_option (opt, NULL, opt_set_p, CL_TARGET, &decoded);
1067 ix86_handle_option (opts, opts_set,
1068 &decoded, input_location);
1069 }
1070
1071 else if (type == ix86_opt_yes || type == ix86_opt_no)
1072 {
1073 if (type == ix86_opt_no)
1074 opt_set_p = !opt_set_p;
1075
1076 if (opt_set_p)
1077 opts->x_target_flags |= mask;
1078 else
1079 opts->x_target_flags &= ~mask;
1080 }
1081
1082 else if (type == ix86_opt_str)
1083 {
1084 if (p_strings[opt])
1085 {
1086 error_at (loc, "attribute value %qs was already specified "
1087 "in %qs attribute", orig_p, attr_name);
1088 ret = false;
1089 }
1090 else
1091 p_strings[opt] = xstrdup (p + opt_len);
1092 }
1093
1094 else if (type == ix86_opt_enum)
1095 {
1096 bool arg_ok;
1097 int value;
1098
1099 arg_ok = opt_enum_arg_to_value (opt, p + opt_len, &value, CL_TARGET);
1100 if (arg_ok)
1101 set_option (opts, enum_opts_set, opt, value,
1102 p + opt_len, DK_UNSPECIFIED, input_location,
1103 global_dc);
1104 else
1105 {
1106 error_at (loc, "attribute value %qs is unknown in %qs attribute",
1107 orig_p, attr_name);
1108 ret = false;
1109 }
1110 }
1111
1112 else
1113 gcc_unreachable ();
1114 }
1115
1116 return ret;
1117 }
1118
1119 /* Release allocated strings. */
1120 static void
1121 release_options_strings (char **option_strings)
1122 {
1123 /* Free up memory allocated to hold the strings */
1124 for (unsigned i = 0; i < IX86_FUNCTION_SPECIFIC_MAX; i++)
1125 free (option_strings[i]);
1126 }
1127
1128 /* Return a TARGET_OPTION_NODE tree of the target options listed or NULL. */
1129
1130 tree
1131 ix86_valid_target_attribute_tree (tree fndecl, tree args,
1132 struct gcc_options *opts,
1133 struct gcc_options *opts_set,
1134 bool target_clone_attr)
1135 {
1136 const char *orig_arch_string = opts->x_ix86_arch_string;
1137 const char *orig_tune_string = opts->x_ix86_tune_string;
1138 enum fpmath_unit orig_fpmath_set = opts_set->x_ix86_fpmath;
1139 int orig_tune_defaulted = ix86_tune_defaulted;
1140 int orig_arch_specified = ix86_arch_specified;
1141 char *option_strings[IX86_FUNCTION_SPECIFIC_MAX] = { NULL, NULL };
1142 tree t = NULL_TREE;
1143 struct cl_target_option *def
1144 = TREE_TARGET_OPTION (target_option_default_node);
1145 struct gcc_options enum_opts_set;
1146
1147 memset (&enum_opts_set, 0, sizeof (enum_opts_set));
1148
1149 /* Process each of the options on the chain. */
1150 if (!ix86_valid_target_attribute_inner_p (fndecl, args, option_strings, opts,
1151 opts_set, &enum_opts_set,
1152 target_clone_attr))
1153 return error_mark_node;
1154
1155 /* If the changed options are different from the default, rerun
1156 ix86_option_override_internal, and then save the options away.
1157 The string options are attribute options, and will be undone
1158 when we copy the save structure. */
1159 if (opts->x_ix86_isa_flags != def->x_ix86_isa_flags
1160 || opts->x_ix86_isa_flags2 != def->x_ix86_isa_flags2
1161 || opts->x_target_flags != def->x_target_flags
1162 || option_strings[IX86_FUNCTION_SPECIFIC_ARCH]
1163 || option_strings[IX86_FUNCTION_SPECIFIC_TUNE]
1164 || enum_opts_set.x_ix86_fpmath)
1165 {
1166 /* If we are using the default tune= or arch=, undo the string assigned,
1167 and use the default. */
1168 if (option_strings[IX86_FUNCTION_SPECIFIC_ARCH])
1169 {
1170 opts->x_ix86_arch_string
1171 = ggc_strdup (option_strings[IX86_FUNCTION_SPECIFIC_ARCH]);
1172
1173 /* If arch= is set, clear all bits in x_ix86_isa_flags,
1174 except for ISA_64BIT, ABI_64, ABI_X32, and CODE16. */
1175 opts->x_ix86_isa_flags &= (OPTION_MASK_ISA_64BIT
1176 | OPTION_MASK_ABI_64
1177 | OPTION_MASK_ABI_X32
1178 | OPTION_MASK_CODE16);
1179 opts->x_ix86_isa_flags2 = 0;
1180 }
1181 else if (!orig_arch_specified)
1182 opts->x_ix86_arch_string = NULL;
1183
1184 if (option_strings[IX86_FUNCTION_SPECIFIC_TUNE])
1185 opts->x_ix86_tune_string
1186 = ggc_strdup (option_strings[IX86_FUNCTION_SPECIFIC_TUNE]);
1187 else if (orig_tune_defaulted)
1188 opts->x_ix86_tune_string = NULL;
1189
1190 /* If fpmath= is not set, and we now have sse2 on 32-bit, use it. */
1191 if (enum_opts_set.x_ix86_fpmath)
1192 opts_set->x_ix86_fpmath = (enum fpmath_unit) 1;
1193
1194 /* Do any overrides, such as arch=xxx, or tune=xxx support. */
1195 bool r = ix86_option_override_internal (false, opts, opts_set);
1196 if (!r)
1197 {
1198 release_options_strings (option_strings);
1199 return error_mark_node;
1200 }
1201
1202 /* Add any builtin functions with the new isa if any. */
1203 ix86_add_new_builtins (opts->x_ix86_isa_flags, opts->x_ix86_isa_flags2);
1204
1205 /* Save the current options unless we are validating options for
1206 #pragma. */
1207 t = build_target_option_node (opts);
1208
1209 opts->x_ix86_arch_string = orig_arch_string;
1210 opts->x_ix86_tune_string = orig_tune_string;
1211 opts_set->x_ix86_fpmath = orig_fpmath_set;
1212
1213 release_options_strings (option_strings);
1214 }
1215
1216 return t;
1217 }
1218
1219 /* Hook to validate attribute((target("string"))). */
1220
1221 bool
1222 ix86_valid_target_attribute_p (tree fndecl,
1223 tree ARG_UNUSED (name),
1224 tree args,
1225 int flags)
1226 {
1227 struct gcc_options func_options;
1228 tree new_target, new_optimize;
1229 bool ret = true;
1230
1231 /* attribute((target("default"))) does nothing, beyond
1232 affecting multi-versioning. */
1233 if (TREE_VALUE (args)
1234 && TREE_CODE (TREE_VALUE (args)) == STRING_CST
1235 && TREE_CHAIN (args) == NULL_TREE
1236 && strcmp (TREE_STRING_POINTER (TREE_VALUE (args)), "default") == 0)
1237 return true;
1238
1239 tree old_optimize = build_optimization_node (&global_options);
1240
1241 /* Get the optimization options of the current function. */
1242 tree func_optimize = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
1243
1244 if (!func_optimize)
1245 func_optimize = old_optimize;
1246
1247 /* Init func_options. */
1248 memset (&func_options, 0, sizeof (func_options));
1249 init_options_struct (&func_options, NULL);
1250 lang_hooks.init_options_struct (&func_options);
1251
1252 cl_optimization_restore (&func_options,
1253 TREE_OPTIMIZATION (func_optimize));
1254
1255 /* Initialize func_options to the default before its target options can
1256 be set. */
1257 cl_target_option_restore (&func_options,
1258 TREE_TARGET_OPTION (target_option_default_node));
1259
1260 /* FLAGS == 1 is used for target_clones attribute. */
1261 new_target
1262 = ix86_valid_target_attribute_tree (fndecl, args, &func_options,
1263 &global_options_set, flags == 1);
1264
1265 new_optimize = build_optimization_node (&func_options);
1266
1267 if (new_target == error_mark_node)
1268 ret = false;
1269
1270 else if (fndecl && new_target)
1271 {
1272 DECL_FUNCTION_SPECIFIC_TARGET (fndecl) = new_target;
1273
1274 if (old_optimize != new_optimize)
1275 DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl) = new_optimize;
1276 }
1277
1278 finalize_options_struct (&func_options);
1279
1280 return ret;
1281 }
1282
1283 const char *stringop_alg_names[] = {
1284 #define DEF_ENUM
1285 #define DEF_ALG(alg, name) #name,
1286 #include "stringop.def"
1287 #undef DEF_ENUM
1288 #undef DEF_ALG
1289 };
1290
1291 /* Parse parameter string passed to -mmemcpy-strategy= or -mmemset-strategy=.
1292 The string is of the following form (or comma separated list of it):
1293
1294 strategy_alg:max_size:[align|noalign]
1295
1296 where the full size range for the strategy is either [0, max_size] or
1297 [min_size, max_size], in which min_size is the max_size + 1 of the
1298 preceding range. The last size range must have max_size == -1.
1299
1300 Examples:
1301
1302 1.
1303 -mmemcpy-strategy=libcall:-1:noalign
1304
1305 this is equivalent to (for known size memcpy) -mstringop-strategy=libcall
1306
1307
1308 2.
1309 -mmemset-strategy=rep_8byte:16:noalign,vector_loop:2048:align,libcall:-1:noalign
1310
1311 This is to tell the compiler to use the following strategy for memset
1312 1) when the expected size is between [1, 16], use rep_8byte strategy;
1313 2) when the size is between [17, 2048], use vector_loop;
1314 3) when the size is > 2048, use libcall. */
1315
1316 struct stringop_size_range
1317 {
1318 int max;
1319 stringop_alg alg;
1320 bool noalign;
1321 };
1322
1323 static void
1324 ix86_parse_stringop_strategy_string (char *strategy_str, bool is_memset)
1325 {
1326 const struct stringop_algs *default_algs;
1327 stringop_size_range input_ranges[MAX_STRINGOP_ALGS];
1328 char *curr_range_str, *next_range_str;
1329 const char *opt = is_memset ? "-mmemset_strategy=" : "-mmemcpy_strategy=";
1330 int i = 0, n = 0;
1331
1332 if (is_memset)
1333 default_algs = &ix86_cost->memset[TARGET_64BIT != 0];
1334 else
1335 default_algs = &ix86_cost->memcpy[TARGET_64BIT != 0];
1336
1337 curr_range_str = strategy_str;
1338
1339 do
1340 {
1341 int maxs;
1342 char alg_name[128];
1343 char align[16];
1344 next_range_str = strchr (curr_range_str, ',');
1345 if (next_range_str)
1346 *next_range_str++ = '\0';
1347
1348 if (sscanf (curr_range_str, "%20[^:]:%d:%10s", alg_name, &maxs,
1349 align) != 3)
1350 {
1351 error ("wrong argument %qs to option %qs", curr_range_str, opt);
1352 return;
1353 }
1354
1355 if (n > 0 && (maxs < (input_ranges[n - 1].max + 1) && maxs != -1))
1356 {
1357 error ("size ranges of option %qs should be increasing", opt);
1358 return;
1359 }
1360
1361 for (i = 0; i < last_alg; i++)
1362 if (!strcmp (alg_name, stringop_alg_names[i]))
1363 break;
1364
1365 if (i == last_alg)
1366 {
1367 error ("wrong strategy name %qs specified for option %qs",
1368 alg_name, opt);
1369
1370 auto_vec <const char *> candidates;
1371 for (i = 0; i < last_alg; i++)
1372 if ((stringop_alg) i != rep_prefix_8_byte || TARGET_64BIT)
1373 candidates.safe_push (stringop_alg_names[i]);
1374
1375 char *s;
1376 const char *hint
1377 = candidates_list_and_hint (alg_name, s, candidates);
1378 if (hint)
1379 inform (input_location,
1380 "valid arguments to %qs are: %s; did you mean %qs?",
1381 opt, s, hint);
1382 else
1383 inform (input_location, "valid arguments to %qs are: %s",
1384 opt, s);
1385 XDELETEVEC (s);
1386 return;
1387 }
1388
1389 if ((stringop_alg) i == rep_prefix_8_byte
1390 && !TARGET_64BIT)
1391 {
1392 /* rep; movq isn't available in 32-bit code. */
1393 error ("strategy name %qs specified for option %qs "
1394 "not supported for 32-bit code", alg_name, opt);
1395 return;
1396 }
1397
1398 input_ranges[n].max = maxs;
1399 input_ranges[n].alg = (stringop_alg) i;
1400 if (!strcmp (align, "align"))
1401 input_ranges[n].noalign = false;
1402 else if (!strcmp (align, "noalign"))
1403 input_ranges[n].noalign = true;
1404 else
1405 {
1406 error ("unknown alignment %qs specified for option %qs", align, opt);
1407 return;
1408 }
1409 n++;
1410 curr_range_str = next_range_str;
1411 }
1412 while (curr_range_str);
1413
1414 if (input_ranges[n - 1].max != -1)
1415 {
1416 error ("the max value for the last size range should be -1"
1417 " for option %qs", opt);
1418 return;
1419 }
1420
1421 if (n > MAX_STRINGOP_ALGS)
1422 {
1423 error ("too many size ranges specified in option %qs", opt);
1424 return;
1425 }
1426
1427 /* Now override the default algs array. */
1428 for (i = 0; i < n; i++)
1429 {
1430 *const_cast<int *>(&default_algs->size[i].max) = input_ranges[i].max;
1431 *const_cast<stringop_alg *>(&default_algs->size[i].alg)
1432 = input_ranges[i].alg;
1433 *const_cast<int *>(&default_algs->size[i].noalign)
1434 = input_ranges[i].noalign;
1435 }
1436 }
1437
1438 \f
1439 /* parse -mtune-ctrl= option. When DUMP is true,
1440 print the features that are explicitly set. */
1441
1442 static void
1443 parse_mtune_ctrl_str (bool dump)
1444 {
1445 if (!ix86_tune_ctrl_string)
1446 return;
1447
1448 char *next_feature_string = NULL;
1449 char *curr_feature_string = xstrdup (ix86_tune_ctrl_string);
1450 char *orig = curr_feature_string;
1451 int i;
1452 do
1453 {
1454 bool clear = false;
1455
1456 next_feature_string = strchr (curr_feature_string, ',');
1457 if (next_feature_string)
1458 *next_feature_string++ = '\0';
1459 if (*curr_feature_string == '^')
1460 {
1461 curr_feature_string++;
1462 clear = true;
1463 }
1464 for (i = 0; i < X86_TUNE_LAST; i++)
1465 {
1466 if (!strcmp (curr_feature_string, ix86_tune_feature_names[i]))
1467 {
1468 ix86_tune_features[i] = !clear;
1469 if (dump)
1470 fprintf (stderr, "Explicitly %s feature %s\n",
1471 clear ? "clear" : "set", ix86_tune_feature_names[i]);
1472 break;
1473 }
1474 }
1475 if (i == X86_TUNE_LAST)
1476 error ("unknown parameter to option %<-mtune-ctrl%>: %s",
1477 clear ? curr_feature_string - 1 : curr_feature_string);
1478 curr_feature_string = next_feature_string;
1479 }
1480 while (curr_feature_string);
1481 free (orig);
1482 }
1483
1484 /* Helper function to set ix86_tune_features. IX86_TUNE is the
1485 processor type. */
1486
1487 static void
1488 set_ix86_tune_features (enum processor_type ix86_tune, bool dump)
1489 {
1490 unsigned HOST_WIDE_INT ix86_tune_mask = HOST_WIDE_INT_1U << ix86_tune;
1491 int i;
1492
1493 for (i = 0; i < X86_TUNE_LAST; ++i)
1494 {
1495 if (ix86_tune_no_default)
1496 ix86_tune_features[i] = 0;
1497 else
1498 ix86_tune_features[i]
1499 = !!(initial_ix86_tune_features[i] & ix86_tune_mask);
1500 }
1501
1502 if (dump)
1503 {
1504 fprintf (stderr, "List of x86 specific tuning parameter names:\n");
1505 for (i = 0; i < X86_TUNE_LAST; i++)
1506 fprintf (stderr, "%s : %s\n", ix86_tune_feature_names[i],
1507 ix86_tune_features[i] ? "on" : "off");
1508 }
1509
1510 parse_mtune_ctrl_str (dump);
1511 }
1512
1513
1514 /* Default align_* from the processor table. */
1515
1516 static void
1517 ix86_default_align (struct gcc_options *opts)
1518 {
1519 /* -falign-foo without argument: supply one. */
1520 if (opts->x_flag_align_loops && !opts->x_str_align_loops)
1521 opts->x_str_align_loops = processor_cost_table[ix86_tune]->align_loop;
1522 if (opts->x_flag_align_jumps && !opts->x_str_align_jumps)
1523 opts->x_str_align_jumps = processor_cost_table[ix86_tune]->align_jump;
1524 if (opts->x_flag_align_labels && !opts->x_str_align_labels)
1525 opts->x_str_align_labels = processor_cost_table[ix86_tune]->align_label;
1526 if (opts->x_flag_align_functions && !opts->x_str_align_functions)
1527 opts->x_str_align_functions = processor_cost_table[ix86_tune]->align_func;
1528 }
1529
1530 /* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */
1531
1532 void
1533 ix86_override_options_after_change (void)
1534 {
1535 ix86_default_align (&global_options);
1536 }
1537
1538 /* Clear stack slot assignments remembered from previous functions.
1539 This is called from INIT_EXPANDERS once before RTL is emitted for each
1540 function. */
1541
1542 static struct machine_function *
1543 ix86_init_machine_status (void)
1544 {
1545 struct machine_function *f;
1546
1547 f = ggc_cleared_alloc<machine_function> ();
1548 f->call_abi = ix86_abi;
1549 f->stack_frame_required = true;
1550
1551 return f;
1552 }
1553
1554 /* Override various settings based on options. If MAIN_ARGS_P, the
1555 options are from the command line, otherwise they are from
1556 attributes. Return true if there's an error related to march
1557 option. */
1558
1559 static bool
1560 ix86_option_override_internal (bool main_args_p,
1561 struct gcc_options *opts,
1562 struct gcc_options *opts_set)
1563 {
1564 int i;
1565 unsigned HOST_WIDE_INT ix86_arch_mask;
1566 const bool ix86_tune_specified = (opts->x_ix86_tune_string != NULL);
1567
1568 /* -mrecip options. */
1569 static struct
1570 {
1571 const char *string; /* option name */
1572 unsigned int mask; /* mask bits to set */
1573 }
1574 const recip_options[] =
1575 {
1576 { "all", RECIP_MASK_ALL },
1577 { "none", RECIP_MASK_NONE },
1578 { "div", RECIP_MASK_DIV },
1579 { "sqrt", RECIP_MASK_SQRT },
1580 { "vec-div", RECIP_MASK_VEC_DIV },
1581 { "vec-sqrt", RECIP_MASK_VEC_SQRT },
1582 };
1583
1584
1585 /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
1586 TARGET_64BIT_DEFAULT is true and TARGET_64BIT is false. */
1587 if (TARGET_64BIT_DEFAULT && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
1588 opts->x_ix86_isa_flags &= ~(OPTION_MASK_ABI_64 | OPTION_MASK_ABI_X32);
1589 #ifdef TARGET_BI_ARCH
1590 else
1591 {
1592 #if TARGET_BI_ARCH == 1
1593 /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ABI_64
1594 is on and OPTION_MASK_ABI_X32 is off. We turn off
1595 OPTION_MASK_ABI_64 if OPTION_MASK_ABI_X32 is turned on by
1596 -mx32. */
1597 if (TARGET_X32_P (opts->x_ix86_isa_flags))
1598 opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
1599 #else
1600 /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
1601 on and OPTION_MASK_ABI_64 is off. We turn off
1602 OPTION_MASK_ABI_X32 if OPTION_MASK_ABI_64 is turned on by
1603 -m64 or OPTION_MASK_CODE16 is turned on by -m16. */
1604 if (TARGET_LP64_P (opts->x_ix86_isa_flags)
1605 || TARGET_16BIT_P (opts->x_ix86_isa_flags))
1606 opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
1607 #endif
1608 if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
1609 && TARGET_IAMCU_P (opts->x_target_flags))
1610 sorry ("Intel MCU psABI isn%'t supported in %s mode",
1611 TARGET_X32_P (opts->x_ix86_isa_flags) ? "x32" : "64-bit");
1612 }
1613 #endif
1614
1615 if (TARGET_X32_P (opts->x_ix86_isa_flags))
1616 {
1617 /* Always turn on OPTION_MASK_ISA_64BIT and turn off
1618 OPTION_MASK_ABI_64 for TARGET_X32. */
1619 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
1620 opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_64;
1621 }
1622 else if (TARGET_16BIT_P (opts->x_ix86_isa_flags))
1623 opts->x_ix86_isa_flags &= ~(OPTION_MASK_ISA_64BIT
1624 | OPTION_MASK_ABI_X32
1625 | OPTION_MASK_ABI_64);
1626 else if (TARGET_LP64_P (opts->x_ix86_isa_flags))
1627 {
1628 /* Always turn on OPTION_MASK_ISA_64BIT and turn off
1629 OPTION_MASK_ABI_X32 for TARGET_LP64. */
1630 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_64BIT;
1631 opts->x_ix86_isa_flags &= ~OPTION_MASK_ABI_X32;
1632 }
1633
1634 #ifdef SUBTARGET_OVERRIDE_OPTIONS
1635 SUBTARGET_OVERRIDE_OPTIONS;
1636 #endif
1637
1638 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
1639 SUBSUBTARGET_OVERRIDE_OPTIONS;
1640 #endif
1641
1642 /* -fPIC is the default for x86_64. */
1643 if (TARGET_MACHO && TARGET_64BIT_P (opts->x_ix86_isa_flags))
1644 opts->x_flag_pic = 2;
1645
1646 /* Need to check -mtune=generic first. */
1647 if (opts->x_ix86_tune_string)
1648 {
1649 /* As special support for cross compilers we read -mtune=native
1650 as -mtune=generic. With native compilers we won't see the
1651 -mtune=native, as it was changed by the driver. */
1652 if (!strcmp (opts->x_ix86_tune_string, "native"))
1653 {
1654 opts->x_ix86_tune_string = "generic";
1655 }
1656 else if (!strcmp (opts->x_ix86_tune_string, "x86-64"))
1657 warning (OPT_Wdeprecated,
1658 main_args_p
1659 ? G_("%<-mtune=x86-64%> is deprecated; use %<-mtune=k8%> "
1660 "or %<-mtune=generic%> instead as appropriate")
1661 : G_("%<target(\"tune=x86-64\")%> is deprecated; use "
1662 "%<target(\"tune=k8\")%> or %<target(\"tune=generic\")%>"
1663 " instead as appropriate"));
1664 }
1665 else
1666 {
1667 if (opts->x_ix86_arch_string)
1668 opts->x_ix86_tune_string = opts->x_ix86_arch_string;
1669 if (!opts->x_ix86_tune_string)
1670 {
1671 opts->x_ix86_tune_string = processor_names[TARGET_CPU_DEFAULT];
1672 ix86_tune_defaulted = 1;
1673 }
1674
1675 /* opts->x_ix86_tune_string is set to opts->x_ix86_arch_string
1676 or defaulted. We need to use a sensible tune option. */
1677 if (!strcmp (opts->x_ix86_tune_string, "x86-64"))
1678 {
1679 opts->x_ix86_tune_string = "generic";
1680 }
1681 }
1682
1683 if (opts->x_ix86_stringop_alg == rep_prefix_8_byte
1684 && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
1685 {
1686 /* rep; movq isn't available in 32-bit code. */
1687 error ("%<-mstringop-strategy=rep_8byte%> not supported for 32-bit code");
1688 opts->x_ix86_stringop_alg = no_stringop;
1689 }
1690
1691 if (!opts->x_ix86_arch_string)
1692 opts->x_ix86_arch_string
1693 = TARGET_64BIT_P (opts->x_ix86_isa_flags)
1694 ? "x86-64" : SUBTARGET32_DEFAULT_CPU;
1695 else
1696 ix86_arch_specified = 1;
1697
1698 if (opts_set->x_ix86_pmode)
1699 {
1700 if ((TARGET_LP64_P (opts->x_ix86_isa_flags)
1701 && opts->x_ix86_pmode == PMODE_SI)
1702 || (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
1703 && opts->x_ix86_pmode == PMODE_DI))
1704 error ("address mode %qs not supported in the %s bit mode",
1705 TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "short" : "long",
1706 TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "64" : "32");
1707 }
1708 else
1709 opts->x_ix86_pmode = TARGET_LP64_P (opts->x_ix86_isa_flags)
1710 ? PMODE_DI : PMODE_SI;
1711
1712 if (!opts_set->x_ix86_abi)
1713 opts->x_ix86_abi = DEFAULT_ABI;
1714
1715 if (opts->x_ix86_abi == MS_ABI && TARGET_X32_P (opts->x_ix86_isa_flags))
1716 error ("%<-mabi=ms%> not supported with X32 ABI");
1717 gcc_assert (opts->x_ix86_abi == SYSV_ABI || opts->x_ix86_abi == MS_ABI);
1718
1719 const char *abi_name = opts->x_ix86_abi == MS_ABI ? "ms" : "sysv";
1720 if ((opts->x_flag_sanitize & SANITIZE_USER_ADDRESS)
1721 && opts->x_ix86_abi != DEFAULT_ABI)
1722 error ("%<-mabi=%s%> not supported with %<-fsanitize=address%>", abi_name);
1723 if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS)
1724 && opts->x_ix86_abi != DEFAULT_ABI)
1725 error ("%<-mabi=%s%> not supported with %<-fsanitize=kernel-address%>",
1726 abi_name);
1727 if ((opts->x_flag_sanitize & SANITIZE_THREAD)
1728 && opts->x_ix86_abi != DEFAULT_ABI)
1729 error ("%<-mabi=%s%> not supported with %<-fsanitize=thread%>", abi_name);
1730
1731 /* For targets using ms ABI enable ms-extensions, if not
1732 explicit turned off. For non-ms ABI we turn off this
1733 option. */
1734 if (!opts_set->x_flag_ms_extensions)
1735 opts->x_flag_ms_extensions = (MS_ABI == DEFAULT_ABI);
1736
1737 if (opts_set->x_ix86_cmodel)
1738 {
1739 switch (opts->x_ix86_cmodel)
1740 {
1741 case CM_SMALL:
1742 case CM_SMALL_PIC:
1743 if (opts->x_flag_pic)
1744 opts->x_ix86_cmodel = CM_SMALL_PIC;
1745 if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
1746 error ("code model %qs not supported in the %s bit mode",
1747 "small", "32");
1748 break;
1749
1750 case CM_MEDIUM:
1751 case CM_MEDIUM_PIC:
1752 if (opts->x_flag_pic)
1753 opts->x_ix86_cmodel = CM_MEDIUM_PIC;
1754 if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
1755 error ("code model %qs not supported in the %s bit mode",
1756 "medium", "32");
1757 else if (TARGET_X32_P (opts->x_ix86_isa_flags))
1758 error ("code model %qs not supported in x32 mode",
1759 "medium");
1760 break;
1761
1762 case CM_LARGE:
1763 case CM_LARGE_PIC:
1764 if (opts->x_flag_pic)
1765 opts->x_ix86_cmodel = CM_LARGE_PIC;
1766 if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
1767 error ("code model %qs not supported in the %s bit mode",
1768 "large", "32");
1769 else if (TARGET_X32_P (opts->x_ix86_isa_flags))
1770 error ("code model %qs not supported in x32 mode",
1771 "large");
1772 break;
1773
1774 case CM_32:
1775 if (opts->x_flag_pic)
1776 error ("code model %s does not support PIC mode", "32");
1777 if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
1778 error ("code model %qs not supported in the %s bit mode",
1779 "32", "64");
1780 break;
1781
1782 case CM_KERNEL:
1783 if (opts->x_flag_pic)
1784 {
1785 error ("code model %s does not support PIC mode", "kernel");
1786 opts->x_ix86_cmodel = CM_32;
1787 }
1788 if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
1789 error ("code model %qs not supported in the %s bit mode",
1790 "kernel", "32");
1791 break;
1792
1793 default:
1794 gcc_unreachable ();
1795 }
1796 }
1797 else
1798 {
1799 /* For TARGET_64BIT and MS_ABI, force pic on, in order to enable the
1800 use of rip-relative addressing. This eliminates fixups that
1801 would otherwise be needed if this object is to be placed in a
1802 DLL, and is essentially just as efficient as direct addressing. */
1803 if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
1804 && (TARGET_RDOS || TARGET_PECOFF))
1805 opts->x_ix86_cmodel = CM_MEDIUM_PIC, opts->x_flag_pic = 1;
1806 else if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
1807 opts->x_ix86_cmodel = opts->x_flag_pic ? CM_SMALL_PIC : CM_SMALL;
1808 else
1809 opts->x_ix86_cmodel = CM_32;
1810 }
1811 if (TARGET_MACHO && opts->x_ix86_asm_dialect == ASM_INTEL)
1812 {
1813 error ("%<-masm=intel%> not supported in this configuration");
1814 opts->x_ix86_asm_dialect = ASM_ATT;
1815 }
1816 if ((TARGET_64BIT_P (opts->x_ix86_isa_flags) != 0)
1817 != ((opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) != 0))
1818 sorry ("%i-bit mode not compiled in",
1819 (opts->x_ix86_isa_flags & OPTION_MASK_ISA_64BIT) ? 64 : 32);
1820
1821 for (i = 0; i < pta_size; i++)
1822 if (! strcmp (opts->x_ix86_arch_string, processor_alias_table[i].name))
1823 {
1824 if (!strcmp (opts->x_ix86_arch_string, "generic"))
1825 {
1826 error (main_args_p
1827 ? G_("%<generic%> CPU can be used only for %<-mtune=%> "
1828 "switch")
1829 : G_("%<generic%> CPU can be used only for "
1830 "%<target(\"tune=\")%> attribute"));
1831 return false;
1832 }
1833 else if (!strcmp (opts->x_ix86_arch_string, "intel"))
1834 {
1835 error (main_args_p
1836 ? G_("%<intel%> CPU can be used only for %<-mtune=%> "
1837 "switch")
1838 : G_("%<intel%> CPU can be used only for "
1839 "%<target(\"tune=\")%> attribute"));
1840 return false;
1841 }
1842
1843 if (TARGET_64BIT_P (opts->x_ix86_isa_flags)
1844 && !((processor_alias_table[i].flags & PTA_64BIT) != 0))
1845 {
1846 error ("CPU you selected does not support x86-64 "
1847 "instruction set");
1848 return false;
1849 }
1850
1851 ix86_schedule = processor_alias_table[i].schedule;
1852 ix86_arch = processor_alias_table[i].processor;
1853 /* Default cpu tuning to the architecture. */
1854 ix86_tune = ix86_arch;
1855
1856 if (((processor_alias_table[i].flags & PTA_MMX) != 0)
1857 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_MMX))
1858 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_MMX;
1859 if (((processor_alias_table[i].flags & PTA_3DNOW) != 0)
1860 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_3DNOW))
1861 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_3DNOW;
1862 if (((processor_alias_table[i].flags & PTA_3DNOW_A) != 0)
1863 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_3DNOW_A))
1864 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_3DNOW_A;
1865 if (((processor_alias_table[i].flags & PTA_SSE) != 0)
1866 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SSE))
1867 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE;
1868 if (((processor_alias_table[i].flags & PTA_SSE2) != 0)
1869 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SSE2))
1870 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE2;
1871 if (((processor_alias_table[i].flags & PTA_SSE3) != 0)
1872 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SSE3))
1873 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE3;
1874 if (((processor_alias_table[i].flags & PTA_SSSE3) != 0)
1875 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SSSE3))
1876 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSSE3;
1877 if (((processor_alias_table[i].flags & PTA_SSE4_1) != 0)
1878 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SSE4_1))
1879 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE4_1;
1880 if (((processor_alias_table[i].flags & PTA_SSE4_2) != 0)
1881 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SSE4_2))
1882 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE4_2;
1883 if (((processor_alias_table[i].flags & PTA_AVX) != 0)
1884 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX))
1885 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX;
1886 if (((processor_alias_table[i].flags & PTA_AVX2) != 0)
1887 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX2))
1888 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX2;
1889 if (((processor_alias_table[i].flags & PTA_FMA) != 0)
1890 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_FMA))
1891 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_FMA;
1892 if (((processor_alias_table[i].flags & PTA_SSE4A) != 0)
1893 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SSE4A))
1894 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE4A;
1895 if (((processor_alias_table[i].flags & PTA_FMA4) != 0)
1896 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_FMA4))
1897 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_FMA4;
1898 if (((processor_alias_table[i].flags & PTA_XOP) != 0)
1899 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_XOP))
1900 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_XOP;
1901 if (((processor_alias_table[i].flags & PTA_LWP) != 0)
1902 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_LWP))
1903 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_LWP;
1904 if (((processor_alias_table[i].flags & PTA_ABM) != 0)
1905 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_ABM))
1906 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_ABM;
1907 if (((processor_alias_table[i].flags & PTA_BMI) != 0)
1908 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_BMI))
1909 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_BMI;
1910 if (((processor_alias_table[i].flags & (PTA_LZCNT | PTA_ABM)) != 0)
1911 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_LZCNT))
1912 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_LZCNT;
1913 if (((processor_alias_table[i].flags & PTA_TBM) != 0)
1914 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_TBM))
1915 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_TBM;
1916 if (((processor_alias_table[i].flags & PTA_BMI2) != 0)
1917 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_BMI2))
1918 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_BMI2;
1919 if (((processor_alias_table[i].flags & PTA_CX16) != 0)
1920 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_CX16))
1921 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_CX16;
1922 if (((processor_alias_table[i].flags & (PTA_POPCNT | PTA_ABM)) != 0)
1923 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_POPCNT))
1924 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_POPCNT;
1925 if (!(TARGET_64BIT_P (opts->x_ix86_isa_flags)
1926 && ((processor_alias_table[i].flags & PTA_NO_SAHF) != 0))
1927 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SAHF))
1928 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SAHF;
1929 if (((processor_alias_table[i].flags & PTA_MOVBE) != 0)
1930 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_MOVBE))
1931 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_MOVBE;
1932 if (((processor_alias_table[i].flags & PTA_AES) != 0)
1933 && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_AES))
1934 ix86_isa_flags |= OPTION_MASK_ISA_AES;
1935 if (((processor_alias_table[i].flags & PTA_SHA) != 0)
1936 && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_SHA))
1937 ix86_isa_flags |= OPTION_MASK_ISA_SHA;
1938 if (((processor_alias_table[i].flags & PTA_PCLMUL) != 0)
1939 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_PCLMUL))
1940 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_PCLMUL;
1941 if (((processor_alias_table[i].flags & PTA_FSGSBASE) != 0)
1942 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_FSGSBASE))
1943 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_FSGSBASE;
1944 if (((processor_alias_table[i].flags & PTA_RDRND) != 0)
1945 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_RDRND))
1946 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_RDRND;
1947 if (((processor_alias_table[i].flags & PTA_F16C) != 0)
1948 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_F16C))
1949 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_F16C;
1950 if (((processor_alias_table[i].flags & PTA_RTM) != 0)
1951 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_RTM))
1952 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_RTM;
1953 if (((processor_alias_table[i].flags & PTA_HLE) != 0)
1954 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_HLE))
1955 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_HLE;
1956 if (((processor_alias_table[i].flags & PTA_PRFCHW) != 0)
1957 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_PRFCHW))
1958 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_PRFCHW;
1959 if (((processor_alias_table[i].flags & PTA_RDSEED) != 0)
1960 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_RDSEED))
1961 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_RDSEED;
1962 if (((processor_alias_table[i].flags & PTA_ADX) != 0)
1963 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_ADX))
1964 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_ADX;
1965 if (((processor_alias_table[i].flags & PTA_FXSR) != 0)
1966 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_FXSR))
1967 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_FXSR;
1968 if (((processor_alias_table[i].flags & PTA_XSAVE) != 0)
1969 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_XSAVE))
1970 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_XSAVE;
1971 if (((processor_alias_table[i].flags & PTA_XSAVEOPT) != 0)
1972 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_XSAVEOPT))
1973 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_XSAVEOPT;
1974 if (((processor_alias_table[i].flags & PTA_AVX512F) != 0)
1975 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512F))
1976 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512F;
1977 if (((processor_alias_table[i].flags & PTA_AVX512ER) != 0)
1978 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512ER))
1979 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512ER;
1980 if (((processor_alias_table[i].flags & PTA_AVX512PF) != 0)
1981 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512PF))
1982 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512PF;
1983 if (((processor_alias_table[i].flags & PTA_AVX512CD) != 0)
1984 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512CD))
1985 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512CD;
1986 if (((processor_alias_table[i].flags & PTA_PREFETCHWT1) != 0)
1987 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_PREFETCHWT1))
1988 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_PREFETCHWT1;
1989 if (((processor_alias_table[i].flags & PTA_CLWB) != 0)
1990 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_CLWB))
1991 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_CLWB;
1992 if (((processor_alias_table[i].flags & PTA_CLFLUSHOPT) != 0)
1993 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_CLFLUSHOPT))
1994 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_CLFLUSHOPT;
1995 if (((processor_alias_table[i].flags & PTA_CLZERO) != 0)
1996 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_CLZERO))
1997 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_CLZERO;
1998 if (((processor_alias_table[i].flags & PTA_XSAVEC) != 0)
1999 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_XSAVEC))
2000 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_XSAVEC;
2001 if (((processor_alias_table[i].flags & PTA_XSAVES) != 0)
2002 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_XSAVES))
2003 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_XSAVES;
2004 if (((processor_alias_table[i].flags & PTA_AVX512DQ) != 0)
2005 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512DQ))
2006 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512DQ;
2007 if (((processor_alias_table[i].flags & PTA_AVX512BW) != 0)
2008 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512BW))
2009 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512BW;
2010 if (((processor_alias_table[i].flags & PTA_AVX512VL) != 0)
2011 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512VL))
2012 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VL;
2013 if (((processor_alias_table[i].flags & PTA_AVX512VBMI) != 0)
2014 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512VBMI))
2015 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VBMI;
2016 if (((processor_alias_table[i].flags & PTA_AVX512IFMA) != 0)
2017 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512IFMA))
2018 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512IFMA;
2019 if (((processor_alias_table[i].flags & PTA_AVX512VNNI) != 0)
2020 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AVX512VNNI))
2021 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VNNI;
2022 if (((processor_alias_table[i].flags & PTA_GFNI) != 0)
2023 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_GFNI))
2024 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_GFNI;
2025 if (((processor_alias_table[i].flags & PTA_AVX512VBMI2) != 0)
2026 && !(opts->x_ix86_isa_flags_explicit
2027 & OPTION_MASK_ISA_AVX512VBMI2))
2028 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VBMI2;
2029 if (((processor_alias_table[i].flags & PTA_VPCLMULQDQ) != 0)
2030 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_VPCLMULQDQ))
2031 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_VPCLMULQDQ;
2032 if (((processor_alias_table[i].flags & PTA_AVX512BITALG) != 0)
2033 && !(opts->x_ix86_isa_flags_explicit
2034 & OPTION_MASK_ISA_AVX512BITALG))
2035 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512BITALG;
2036
2037 if (((processor_alias_table[i].flags & PTA_AVX512VP2INTERSECT) != 0)
2038 && !(opts->x_ix86_isa_flags2_explicit
2039 & OPTION_MASK_ISA_AVX512VP2INTERSECT))
2040 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_AVX512VP2INTERSECT;
2041 if (((processor_alias_table[i].flags & PTA_AVX5124VNNIW) != 0)
2042 && !(opts->x_ix86_isa_flags2_explicit
2043 & OPTION_MASK_ISA_AVX5124VNNIW))
2044 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_AVX5124VNNIW;
2045 if (((processor_alias_table[i].flags & PTA_AVX5124FMAPS) != 0)
2046 && !(opts->x_ix86_isa_flags2_explicit
2047 & OPTION_MASK_ISA_AVX5124FMAPS))
2048 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_AVX5124FMAPS;
2049 if (((processor_alias_table[i].flags & PTA_AVX512VPOPCNTDQ) != 0)
2050 && !(opts->x_ix86_isa_flags_explicit
2051 & OPTION_MASK_ISA_AVX512VPOPCNTDQ))
2052 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VPOPCNTDQ;
2053 if (((processor_alias_table[i].flags & PTA_AVX512BF16) != 0)
2054 && !(opts->x_ix86_isa_flags2_explicit
2055 & OPTION_MASK_ISA_AVX512BF16))
2056 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_AVX512BF16;
2057 if (((processor_alias_table[i].flags & PTA_MOVDIRI) != 0)
2058 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_MOVDIRI))
2059 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_MOVDIRI;
2060 if (((processor_alias_table[i].flags & PTA_MOVDIR64B) != 0)
2061 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_MOVDIR64B))
2062 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_MOVDIR64B;
2063 if (((processor_alias_table[i].flags & PTA_SGX) != 0)
2064 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_SGX))
2065 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_SGX;
2066 if (((processor_alias_table[i].flags & PTA_VAES) != 0)
2067 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_VAES))
2068 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_VAES;
2069 if (((processor_alias_table[i].flags & PTA_RDPID) != 0)
2070 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_RDPID))
2071 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_RDPID;
2072 if (((processor_alias_table[i].flags & PTA_PCONFIG) != 0)
2073 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_PCONFIG))
2074 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_PCONFIG;
2075 if (((processor_alias_table[i].flags & PTA_WBNOINVD) != 0)
2076 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_WBNOINVD))
2077 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_WBNOINVD;
2078 if (((processor_alias_table[i].flags & PTA_PTWRITE) != 0)
2079 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_PTWRITE))
2080 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_PTWRITE;
2081
2082 if ((processor_alias_table[i].flags
2083 & (PTA_PREFETCH_SSE | PTA_SSE)) != 0)
2084 x86_prefetch_sse = true;
2085 if (((processor_alias_table[i].flags & PTA_MWAITX) != 0)
2086 && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA_MWAITX))
2087 opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA_MWAITX;
2088 if (((processor_alias_table[i].flags & PTA_PKU) != 0)
2089 && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_PKU))
2090 opts->x_ix86_isa_flags |= OPTION_MASK_ISA_PKU;
2091
2092 /* Don't enable x87 instructions if only
2093 general registers are allowed. */
2094 if (!(opts_set->x_ix86_target_flags & OPTION_MASK_GENERAL_REGS_ONLY)
2095 && !(opts_set->x_target_flags & MASK_80387))
2096 {
2097 if (((processor_alias_table[i].flags & PTA_NO_80387) != 0))
2098 opts->x_target_flags &= ~MASK_80387;
2099 else
2100 opts->x_target_flags |= MASK_80387;
2101 }
2102 break;
2103 }
2104
2105 if (i == pta_size)
2106 {
2107 error (main_args_p
2108 ? G_("bad value (%qs) for %<-march=%> switch")
2109 : G_("bad value (%qs) for %<target(\"arch=\")%> attribute"),
2110 opts->x_ix86_arch_string);
2111
2112 auto_vec <const char *> candidates;
2113 for (i = 0; i < pta_size; i++)
2114 if (strcmp (processor_alias_table[i].name, "generic")
2115 && strcmp (processor_alias_table[i].name, "intel")
2116 && (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
2117 || ((processor_alias_table[i].flags & PTA_64BIT) != 0)))
2118 candidates.safe_push (processor_alias_table[i].name);
2119
2120 #ifdef HAVE_LOCAL_CPU_DETECT
2121 /* Add also "native" as possible value. */
2122 candidates.safe_push ("native");
2123 #endif
2124
2125 char *s;
2126 const char *hint
2127 = candidates_list_and_hint (opts->x_ix86_arch_string, s, candidates);
2128 if (hint)
2129 inform (input_location,
2130 main_args_p
2131 ? G_("valid arguments to %<-march=%> switch are: "
2132 "%s; did you mean %qs?")
2133 : G_("valid arguments to %<target(\"arch=\")%> attribute are: "
2134 "%s; did you mean %qs?"), s, hint);
2135 else
2136 inform (input_location,
2137 main_args_p
2138 ? G_("valid arguments to %<-march=%> switch are: %s")
2139 : G_("valid arguments to %<target(\"arch=\")%> attribute "
2140 "are: %s"), s);
2141 XDELETEVEC (s);
2142 }
2143
2144 ix86_arch_mask = HOST_WIDE_INT_1U << ix86_arch;
2145 for (i = 0; i < X86_ARCH_LAST; ++i)
2146 ix86_arch_features[i] = !!(initial_ix86_arch_features[i] & ix86_arch_mask);
2147
2148 for (i = 0; i < pta_size; i++)
2149 if (! strcmp (opts->x_ix86_tune_string, processor_alias_table[i].name))
2150 {
2151 ix86_schedule = processor_alias_table[i].schedule;
2152 ix86_tune = processor_alias_table[i].processor;
2153 if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2154 {
2155 if (!((processor_alias_table[i].flags & PTA_64BIT) != 0))
2156 {
2157 if (ix86_tune_defaulted)
2158 {
2159 opts->x_ix86_tune_string = "x86-64";
2160 for (i = 0; i < pta_size; i++)
2161 if (! strcmp (opts->x_ix86_tune_string,
2162 processor_alias_table[i].name))
2163 break;
2164 ix86_schedule = processor_alias_table[i].schedule;
2165 ix86_tune = processor_alias_table[i].processor;
2166 }
2167 else
2168 error ("CPU you selected does not support x86-64 "
2169 "instruction set");
2170 }
2171 }
2172 /* Intel CPUs have always interpreted SSE prefetch instructions as
2173 NOPs; so, we can enable SSE prefetch instructions even when
2174 -mtune (rather than -march) points us to a processor that has them.
2175 However, the VIA C3 gives a SIGILL, so we only do that for i686 and
2176 higher processors. */
2177 if (TARGET_CMOV
2178 && ((processor_alias_table[i].flags
2179 & (PTA_PREFETCH_SSE | PTA_SSE)) != 0))
2180 x86_prefetch_sse = true;
2181 break;
2182 }
2183
2184 if (ix86_tune_specified && i == pta_size)
2185 {
2186 error (main_args_p
2187 ? G_("bad value (%qs) for %<-mtune=%> switch")
2188 : G_("bad value (%qs) for %<target(\"tune=\")%> attribute"),
2189 opts->x_ix86_tune_string);
2190
2191 auto_vec <const char *> candidates;
2192 for (i = 0; i < pta_size; i++)
2193 if (!TARGET_64BIT_P (opts->x_ix86_isa_flags)
2194 || ((processor_alias_table[i].flags & PTA_64BIT) != 0))
2195 candidates.safe_push (processor_alias_table[i].name);
2196
2197 #ifdef HAVE_LOCAL_CPU_DETECT
2198 /* Add also "native" as possible value. */
2199 candidates.safe_push ("native");
2200 #endif
2201
2202 char *s;
2203 const char *hint
2204 = candidates_list_and_hint (opts->x_ix86_tune_string, s, candidates);
2205 if (hint)
2206 inform (input_location,
2207 main_args_p
2208 ? G_("valid arguments to %<-mtune=%> switch are: "
2209 "%s; did you mean %qs?")
2210 : G_("valid arguments to %<target(\"tune=\")%> attribute are: "
2211 "%s; did you mean %qs?"), s, hint);
2212 else
2213 inform (input_location,
2214 main_args_p
2215 ? G_("valid arguments to %<-mtune=%> switch are: %s")
2216 : G_("valid arguments to %<target(\"tune=\")%> attribute "
2217 "are: %s"), s);
2218 XDELETEVEC (s);
2219 }
2220
2221 set_ix86_tune_features (ix86_tune, opts->x_ix86_dump_tunes);
2222
2223 #ifndef USE_IX86_FRAME_POINTER
2224 #define USE_IX86_FRAME_POINTER 0
2225 #endif
2226
2227 /* Set the default values for switches whose default depends on TARGET_64BIT
2228 in case they weren't overwritten by command line options. */
2229 if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2230 {
2231 if (opts->x_optimize >= 1 && !opts_set->x_flag_omit_frame_pointer)
2232 opts->x_flag_omit_frame_pointer = !USE_IX86_FRAME_POINTER;
2233 if (opts->x_flag_asynchronous_unwind_tables
2234 && !opts_set->x_flag_unwind_tables
2235 && TARGET_64BIT_MS_ABI)
2236 opts->x_flag_unwind_tables = 1;
2237 if (opts->x_flag_asynchronous_unwind_tables == 2)
2238 opts->x_flag_unwind_tables
2239 = opts->x_flag_asynchronous_unwind_tables = 1;
2240 if (opts->x_flag_pcc_struct_return == 2)
2241 opts->x_flag_pcc_struct_return = 0;
2242 }
2243 else
2244 {
2245 if (opts->x_optimize >= 1 && !opts_set->x_flag_omit_frame_pointer)
2246 opts->x_flag_omit_frame_pointer
2247 = !(USE_IX86_FRAME_POINTER || opts->x_optimize_size);
2248 if (opts->x_flag_asynchronous_unwind_tables == 2)
2249 opts->x_flag_asynchronous_unwind_tables = !USE_IX86_FRAME_POINTER;
2250 if (opts->x_flag_pcc_struct_return == 2)
2251 {
2252 /* Intel MCU psABI specifies that -freg-struct-return should
2253 be on. Instead of setting DEFAULT_PCC_STRUCT_RETURN to 1,
2254 we check -miamcu so that -freg-struct-return is always
2255 turned on if -miamcu is used. */
2256 if (TARGET_IAMCU_P (opts->x_target_flags))
2257 opts->x_flag_pcc_struct_return = 0;
2258 else
2259 opts->x_flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
2260 }
2261 }
2262
2263 ix86_tune_cost = processor_cost_table[ix86_tune];
2264 /* TODO: ix86_cost should be chosen at instruction or function granuality
2265 so for cold code we use size_cost even in !optimize_size compilation. */
2266 if (opts->x_optimize_size)
2267 ix86_cost = &ix86_size_cost;
2268 else
2269 ix86_cost = ix86_tune_cost;
2270
2271 /* Arrange to set up i386_stack_locals for all functions. */
2272 init_machine_status = ix86_init_machine_status;
2273
2274 /* Validate -mregparm= value. */
2275 if (opts_set->x_ix86_regparm)
2276 {
2277 if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2278 warning (0, "%<-mregparm%> is ignored in 64-bit mode");
2279 else if (TARGET_IAMCU_P (opts->x_target_flags))
2280 warning (0, "%<-mregparm%> is ignored for Intel MCU psABI");
2281 if (opts->x_ix86_regparm > REGPARM_MAX)
2282 {
2283 error ("%<-mregparm=%d%> is not between 0 and %d",
2284 opts->x_ix86_regparm, REGPARM_MAX);
2285 opts->x_ix86_regparm = 0;
2286 }
2287 }
2288 if (TARGET_IAMCU_P (opts->x_target_flags)
2289 || TARGET_64BIT_P (opts->x_ix86_isa_flags))
2290 opts->x_ix86_regparm = REGPARM_MAX;
2291
2292 /* Default align_* from the processor table. */
2293 ix86_default_align (opts);
2294
2295 /* Provide default for -mbranch-cost= value. */
2296 if (!opts_set->x_ix86_branch_cost)
2297 opts->x_ix86_branch_cost = ix86_tune_cost->branch_cost;
2298
2299 if (TARGET_64BIT_P (opts->x_ix86_isa_flags))
2300 {
2301 opts->x_target_flags
2302 |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
2303
2304 if (!ix86_arch_specified)
2305 opts->x_ix86_isa_flags
2306 |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
2307
2308 if (TARGET_RTD_P (opts->x_target_flags))
2309 warning (0,
2310 main_args_p
2311 ? G_("%<-mrtd%> is ignored in 64bit mode")
2312 : G_("%<target(\"rtd\")%> is ignored in 64bit mode"));
2313 }
2314 else
2315 {
2316 opts->x_target_flags
2317 |= TARGET_SUBTARGET32_DEFAULT & ~opts_set->x_target_flags;
2318
2319 if (!ix86_arch_specified)
2320 opts->x_ix86_isa_flags
2321 |= TARGET_SUBTARGET32_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit;
2322
2323 /* i386 ABI does not specify red zone. It still makes sense to use it
2324 when programmer takes care to stack from being destroyed. */
2325 if (!(opts_set->x_target_flags & MASK_NO_RED_ZONE))
2326 opts->x_target_flags |= MASK_NO_RED_ZONE;
2327 }
2328
2329 /* Keep nonleaf frame pointers. */
2330 if (opts->x_flag_omit_frame_pointer)
2331 opts->x_target_flags &= ~MASK_OMIT_LEAF_FRAME_POINTER;
2332 else if (TARGET_OMIT_LEAF_FRAME_POINTER_P (opts->x_target_flags))
2333 opts->x_flag_omit_frame_pointer = 1;
2334
2335 /* If we're doing fast math, we don't care about comparison order
2336 wrt NaNs. This lets us use a shorter comparison sequence. */
2337 if (opts->x_flag_finite_math_only)
2338 opts->x_target_flags &= ~MASK_IEEE_FP;
2339
2340 /* If the architecture always has an FPU, turn off NO_FANCY_MATH_387,
2341 since the insns won't need emulation. */
2342 if (ix86_tune_features [X86_TUNE_ALWAYS_FANCY_MATH_387])
2343 opts->x_target_flags &= ~MASK_NO_FANCY_MATH_387;
2344
2345 /* Likewise, if the target doesn't have a 387, or we've specified
2346 software floating point, don't use 387 inline intrinsics. */
2347 if (!TARGET_80387_P (opts->x_target_flags))
2348 opts->x_target_flags |= MASK_NO_FANCY_MATH_387;
2349
2350 /* Turn on MMX builtins for -msse. */
2351 if (TARGET_SSE_P (opts->x_ix86_isa_flags))
2352 opts->x_ix86_isa_flags
2353 |= OPTION_MASK_ISA_MMX & ~opts->x_ix86_isa_flags_explicit;
2354
2355 /* Enable SSE prefetch. */
2356 if (TARGET_SSE_P (opts->x_ix86_isa_flags)
2357 || (TARGET_PRFCHW_P (opts->x_ix86_isa_flags)
2358 && !TARGET_3DNOW_P (opts->x_ix86_isa_flags))
2359 || TARGET_PREFETCHWT1_P (opts->x_ix86_isa_flags))
2360 x86_prefetch_sse = true;
2361
2362 /* Enable popcnt instruction for -msse4.2 or -mabm. */
2363 if (TARGET_SSE4_2_P (opts->x_ix86_isa_flags)
2364 || TARGET_ABM_P (opts->x_ix86_isa_flags))
2365 opts->x_ix86_isa_flags
2366 |= OPTION_MASK_ISA_POPCNT & ~opts->x_ix86_isa_flags_explicit;
2367
2368 /* Enable lzcnt instruction for -mabm. */
2369 if (TARGET_ABM_P(opts->x_ix86_isa_flags))
2370 opts->x_ix86_isa_flags
2371 |= OPTION_MASK_ISA_LZCNT & ~opts->x_ix86_isa_flags_explicit;
2372
2373 /* Disable BMI, BMI2 and TBM instructions for -m16. */
2374 if (TARGET_16BIT_P(opts->x_ix86_isa_flags))
2375 opts->x_ix86_isa_flags
2376 &= ~((OPTION_MASK_ISA_BMI | OPTION_MASK_ISA_BMI2 | OPTION_MASK_ISA_TBM)
2377 & ~opts->x_ix86_isa_flags_explicit);
2378
2379 /* Validate -mpreferred-stack-boundary= value or default it to
2380 PREFERRED_STACK_BOUNDARY_DEFAULT. */
2381 ix86_preferred_stack_boundary = PREFERRED_STACK_BOUNDARY_DEFAULT;
2382 if (opts_set->x_ix86_preferred_stack_boundary_arg)
2383 {
2384 int min = TARGET_64BIT_P (opts->x_ix86_isa_flags)? 3 : 2;
2385 int max = TARGET_SEH ? 4 : 12;
2386
2387 if (opts->x_ix86_preferred_stack_boundary_arg < min
2388 || opts->x_ix86_preferred_stack_boundary_arg > max)
2389 {
2390 if (min == max)
2391 error ("%<-mpreferred-stack-boundary%> is not supported "
2392 "for this target");
2393 else
2394 error ("%<-mpreferred-stack-boundary=%d%> is not between %d and %d",
2395 opts->x_ix86_preferred_stack_boundary_arg, min, max);
2396 }
2397 else
2398 ix86_preferred_stack_boundary
2399 = (1 << opts->x_ix86_preferred_stack_boundary_arg) * BITS_PER_UNIT;
2400 }
2401
2402 /* Set the default value for -mstackrealign. */
2403 if (!opts_set->x_ix86_force_align_arg_pointer)
2404 opts->x_ix86_force_align_arg_pointer = STACK_REALIGN_DEFAULT;
2405
2406 ix86_default_incoming_stack_boundary = PREFERRED_STACK_BOUNDARY;
2407
2408 /* Validate -mincoming-stack-boundary= value or default it to
2409 MIN_STACK_BOUNDARY/PREFERRED_STACK_BOUNDARY. */
2410 ix86_incoming_stack_boundary = ix86_default_incoming_stack_boundary;
2411 if (opts_set->x_ix86_incoming_stack_boundary_arg)
2412 {
2413 int min = TARGET_64BIT_P (opts->x_ix86_isa_flags) ? 3 : 2;
2414
2415 if (opts->x_ix86_incoming_stack_boundary_arg < min
2416 || opts->x_ix86_incoming_stack_boundary_arg > 12)
2417 error ("%<-mincoming-stack-boundary=%d%> is not between %d and 12",
2418 opts->x_ix86_incoming_stack_boundary_arg, min);
2419 else
2420 {
2421 ix86_user_incoming_stack_boundary
2422 = (1 << opts->x_ix86_incoming_stack_boundary_arg) * BITS_PER_UNIT;
2423 ix86_incoming_stack_boundary
2424 = ix86_user_incoming_stack_boundary;
2425 }
2426 }
2427
2428 #ifndef NO_PROFILE_COUNTERS
2429 if (flag_nop_mcount)
2430 error ("%<-mnop-mcount%> is not compatible with this target");
2431 #endif
2432 if (flag_nop_mcount && flag_pic)
2433 error ("%<-mnop-mcount%> is not implemented for %<-fPIC%>");
2434
2435 /* Accept -msseregparm only if at least SSE support is enabled. */
2436 if (TARGET_SSEREGPARM_P (opts->x_target_flags)
2437 && ! TARGET_SSE_P (opts->x_ix86_isa_flags))
2438 error (main_args_p
2439 ? G_("%<-msseregparm%> used without SSE enabled")
2440 : G_("%<target(\"sseregparm\")%> used without SSE enabled"));
2441
2442 if (opts_set->x_ix86_fpmath)
2443 {
2444 if (opts->x_ix86_fpmath & FPMATH_SSE)
2445 {
2446 if (!TARGET_SSE_P (opts->x_ix86_isa_flags))
2447 {
2448 if (TARGET_80387_P (opts->x_target_flags))
2449 {
2450 warning (0, "SSE instruction set disabled, using 387 arithmetics");
2451 opts->x_ix86_fpmath = FPMATH_387;
2452 }
2453 }
2454 else if ((opts->x_ix86_fpmath & FPMATH_387)
2455 && !TARGET_80387_P (opts->x_target_flags))
2456 {
2457 warning (0, "387 instruction set disabled, using SSE arithmetics");
2458 opts->x_ix86_fpmath = FPMATH_SSE;
2459 }
2460 }
2461 }
2462 /* For all chips supporting SSE2, -mfpmath=sse performs better than
2463 fpmath=387. The second is however default at many targets since the
2464 extra 80bit precision of temporaries is considered to be part of ABI.
2465 Overwrite the default at least for -ffast-math.
2466 TODO: -mfpmath=both seems to produce same performing code with bit
2467 smaller binaries. It is however not clear if register allocation is
2468 ready for this setting.
2469 Also -mfpmath=387 is overall a lot more compact (bout 4-5%) than SSE
2470 codegen. We may switch to 387 with -ffast-math for size optimized
2471 functions. */
2472 else if (fast_math_flags_set_p (&global_options)
2473 && TARGET_SSE2_P (opts->x_ix86_isa_flags))
2474 opts->x_ix86_fpmath = FPMATH_SSE;
2475 else
2476 opts->x_ix86_fpmath = TARGET_FPMATH_DEFAULT_P (opts->x_ix86_isa_flags);
2477
2478 /* Use external vectorized library in vectorizing intrinsics. */
2479 if (opts_set->x_ix86_veclibabi_type)
2480 switch (opts->x_ix86_veclibabi_type)
2481 {
2482 case ix86_veclibabi_type_svml:
2483 ix86_veclib_handler = &ix86_veclibabi_svml;
2484 break;
2485
2486 case ix86_veclibabi_type_acml:
2487 ix86_veclib_handler = &ix86_veclibabi_acml;
2488 break;
2489
2490 default:
2491 gcc_unreachable ();
2492 }
2493
2494 if (ix86_tune_features [X86_TUNE_ACCUMULATE_OUTGOING_ARGS]
2495 && !(opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
2496 opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
2497
2498 /* If stack probes are required, the space used for large function
2499 arguments on the stack must also be probed, so enable
2500 -maccumulate-outgoing-args so this happens in the prologue. */
2501 if (TARGET_STACK_PROBE_P (opts->x_target_flags)
2502 && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
2503 {
2504 if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
2505 warning (0,
2506 main_args_p
2507 ? G_("stack probing requires %<-maccumulate-outgoing-args%> "
2508 "for correctness")
2509 : G_("stack probing requires "
2510 "%<target(\"accumulate-outgoing-args\")%> for "
2511 "correctness"));
2512 opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
2513 }
2514
2515 /* Stack realignment without -maccumulate-outgoing-args requires %ebp,
2516 so enable -maccumulate-outgoing-args when %ebp is fixed. */
2517 if (fixed_regs[BP_REG]
2518 && !(opts->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
2519 {
2520 if (opts_set->x_target_flags & MASK_ACCUMULATE_OUTGOING_ARGS)
2521 warning (0,
2522 main_args_p
2523 ? G_("fixed ebp register requires "
2524 "%<-maccumulate-outgoing-args%>")
2525 : G_("fixed ebp register requires "
2526 "%<target(\"accumulate-outgoing-args\")%>"));
2527 opts->x_target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
2528 }
2529
2530 /* Figure out what ASM_GENERATE_INTERNAL_LABEL builds as a prefix. */
2531 {
2532 char *p;
2533 ASM_GENERATE_INTERNAL_LABEL (internal_label_prefix, "LX", 0);
2534 p = strchr (internal_label_prefix, 'X');
2535 internal_label_prefix_len = p - internal_label_prefix;
2536 *p = '\0';
2537 }
2538
2539 /* When scheduling description is not available, disable scheduler pass
2540 so it won't slow down the compilation and make x87 code slower. */
2541 if (!TARGET_SCHEDULE)
2542 opts->x_flag_schedule_insns_after_reload = opts->x_flag_schedule_insns = 0;
2543
2544 maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES,
2545 ix86_tune_cost->simultaneous_prefetches,
2546 opts->x_param_values,
2547 opts_set->x_param_values);
2548 maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE,
2549 ix86_tune_cost->prefetch_block,
2550 opts->x_param_values,
2551 opts_set->x_param_values);
2552 maybe_set_param_value (PARAM_L1_CACHE_SIZE,
2553 ix86_tune_cost->l1_cache_size,
2554 opts->x_param_values,
2555 opts_set->x_param_values);
2556 maybe_set_param_value (PARAM_L2_CACHE_SIZE,
2557 ix86_tune_cost->l2_cache_size,
2558 opts->x_param_values,
2559 opts_set->x_param_values);
2560
2561 /* Enable sw prefetching at -O3 for CPUS that prefetching is helpful. */
2562 if (opts->x_flag_prefetch_loop_arrays < 0
2563 && HAVE_prefetch
2564 && (opts->x_optimize >= 3 || opts->x_flag_profile_use)
2565 && !opts->x_optimize_size
2566 && TARGET_SOFTWARE_PREFETCHING_BENEFICIAL)
2567 opts->x_flag_prefetch_loop_arrays = 1;
2568
2569 /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
2570 can be opts->x_optimized to ap = __builtin_next_arg (0). */
2571 if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && !opts->x_flag_split_stack)
2572 targetm.expand_builtin_va_start = NULL;
2573
2574 #ifdef USE_IX86_CLD
2575 /* Use -mcld by default for 32-bit code if configured with --enable-cld. */
2576 if (!TARGET_64BIT_P (opts->x_ix86_isa_flags))
2577 opts->x_target_flags |= MASK_CLD & ~opts_set->x_target_flags;
2578 #endif
2579
2580 /* Set the default value for -mfentry. */
2581 if (!opts_set->x_flag_fentry)
2582 opts->x_flag_fentry = TARGET_SEH;
2583 else
2584 {
2585 if (!TARGET_64BIT_P (opts->x_ix86_isa_flags) && opts->x_flag_pic
2586 && opts->x_flag_fentry)
2587 sorry ("%<-mfentry%> isn%'t supported for 32-bit in combination "
2588 "with %<-fpic%>");
2589 else if (TARGET_SEH && !opts->x_flag_fentry)
2590 sorry ("%<-mno-fentry%> isn%'t compatible with SEH");
2591 }
2592
2593 if (TARGET_SEH && TARGET_CALL_MS2SYSV_XLOGUES)
2594 sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH");
2595
2596 if (!(opts_set->x_target_flags & MASK_VZEROUPPER)
2597 && TARGET_EMIT_VZEROUPPER)
2598 opts->x_target_flags |= MASK_VZEROUPPER;
2599 if (!(opts_set->x_target_flags & MASK_STV))
2600 opts->x_target_flags |= MASK_STV;
2601 /* Disable STV if -mpreferred-stack-boundary={2,3} or
2602 -mincoming-stack-boundary={2,3} or -mstackrealign - the needed
2603 stack realignment will be extra cost the pass doesn't take into
2604 account and the pass can't realign the stack. */
2605 if (ix86_preferred_stack_boundary < 128
2606 || ix86_incoming_stack_boundary < 128
2607 || opts->x_ix86_force_align_arg_pointer)
2608 opts->x_target_flags &= ~MASK_STV;
2609 if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL]
2610 && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_LOAD))
2611 opts->x_target_flags |= MASK_AVX256_SPLIT_UNALIGNED_LOAD;
2612 if (!ix86_tune_features[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL]
2613 && !(opts_set->x_target_flags & MASK_AVX256_SPLIT_UNALIGNED_STORE))
2614 opts->x_target_flags |= MASK_AVX256_SPLIT_UNALIGNED_STORE;
2615
2616 /* Enable 128-bit AVX instruction generation
2617 for the auto-vectorizer. */
2618 if (TARGET_AVX128_OPTIMAL
2619 && (opts_set->x_prefer_vector_width_type == PVW_NONE))
2620 opts->x_prefer_vector_width_type = PVW_AVX128;
2621
2622 /* Use 256-bit AVX instruction generation
2623 in the auto-vectorizer. */
2624 if (ix86_tune_features[X86_TUNE_AVX256_OPTIMAL]
2625 && (opts_set->x_prefer_vector_width_type == PVW_NONE))
2626 opts->x_prefer_vector_width_type = PVW_AVX256;
2627
2628 if (opts->x_ix86_recip_name)
2629 {
2630 char *p = ASTRDUP (opts->x_ix86_recip_name);
2631 char *q;
2632 unsigned int mask, i;
2633 bool invert;
2634
2635 while ((q = strtok (p, ",")) != NULL)
2636 {
2637 p = NULL;
2638 if (*q == '!')
2639 {
2640 invert = true;
2641 q++;
2642 }
2643 else
2644 invert = false;
2645
2646 if (!strcmp (q, "default"))
2647 mask = RECIP_MASK_ALL;
2648 else
2649 {
2650 for (i = 0; i < ARRAY_SIZE (recip_options); i++)
2651 if (!strcmp (q, recip_options[i].string))
2652 {
2653 mask = recip_options[i].mask;
2654 break;
2655 }
2656
2657 if (i == ARRAY_SIZE (recip_options))
2658 {
2659 error ("unknown option for %<-mrecip=%s%>", q);
2660 invert = false;
2661 mask = RECIP_MASK_NONE;
2662 }
2663 }
2664
2665 opts->x_recip_mask_explicit |= mask;
2666 if (invert)
2667 opts->x_recip_mask &= ~mask;
2668 else
2669 opts->x_recip_mask |= mask;
2670 }
2671 }
2672
2673 if (TARGET_RECIP_P (opts->x_target_flags))
2674 opts->x_recip_mask |= RECIP_MASK_ALL & ~opts->x_recip_mask_explicit;
2675 else if (opts_set->x_target_flags & MASK_RECIP)
2676 opts->x_recip_mask &= ~(RECIP_MASK_ALL & ~opts->x_recip_mask_explicit);
2677
2678 /* Default long double to 64-bit for 32-bit Bionic and to __float128
2679 for 64-bit Bionic. Also default long double to 64-bit for Intel
2680 MCU psABI. */
2681 if ((TARGET_HAS_BIONIC || TARGET_IAMCU)
2682 && !(opts_set->x_target_flags
2683 & (MASK_LONG_DOUBLE_64 | MASK_LONG_DOUBLE_128)))
2684 opts->x_target_flags |= (TARGET_64BIT
2685 ? MASK_LONG_DOUBLE_128
2686 : MASK_LONG_DOUBLE_64);
2687
2688 /* Only one of them can be active. */
2689 gcc_assert ((opts->x_target_flags & MASK_LONG_DOUBLE_64) == 0
2690 || (opts->x_target_flags & MASK_LONG_DOUBLE_128) == 0);
2691
2692 /* Handle stack protector */
2693 if (!opts_set->x_ix86_stack_protector_guard)
2694 {
2695 #ifdef TARGET_THREAD_SSP_OFFSET
2696 if (!TARGET_HAS_BIONIC)
2697 opts->x_ix86_stack_protector_guard = SSP_TLS;
2698 else
2699 #endif
2700 opts->x_ix86_stack_protector_guard = SSP_GLOBAL;
2701 }
2702
2703 if (opts_set->x_ix86_stack_protector_guard_offset_str)
2704 {
2705 char *endp;
2706 const char *str = opts->x_ix86_stack_protector_guard_offset_str;
2707
2708 errno = 0;
2709 int64_t offset;
2710
2711 #if defined(INT64_T_IS_LONG)
2712 offset = strtol (str, &endp, 0);
2713 #else
2714 offset = strtoll (str, &endp, 0);
2715 #endif
2716
2717 if (!*str || *endp || errno)
2718 error ("%qs is not a valid number "
2719 "in %<-mstack-protector-guard-offset=%>", str);
2720
2721 if (!IN_RANGE (offset, HOST_WIDE_INT_C (-0x80000000),
2722 HOST_WIDE_INT_C (0x7fffffff)))
2723 error ("%qs is not a valid offset "
2724 "in %<-mstack-protector-guard-offset=%>", str);
2725
2726 opts->x_ix86_stack_protector_guard_offset = offset;
2727 }
2728 #ifdef TARGET_THREAD_SSP_OFFSET
2729 else
2730 opts->x_ix86_stack_protector_guard_offset = TARGET_THREAD_SSP_OFFSET;
2731 #endif
2732
2733 if (opts_set->x_ix86_stack_protector_guard_reg_str)
2734 {
2735 const char *str = opts->x_ix86_stack_protector_guard_reg_str;
2736 addr_space_t seg = ADDR_SPACE_GENERIC;
2737
2738 /* Discard optional register prefix. */
2739 if (str[0] == '%')
2740 str++;
2741
2742 if (strlen (str) == 2 && str[1] == 's')
2743 {
2744 if (str[0] == 'f')
2745 seg = ADDR_SPACE_SEG_FS;
2746 else if (str[0] == 'g')
2747 seg = ADDR_SPACE_SEG_GS;
2748 }
2749
2750 if (seg == ADDR_SPACE_GENERIC)
2751 error ("%qs is not a valid base register "
2752 "in %<-mstack-protector-guard-reg=%>",
2753 opts->x_ix86_stack_protector_guard_reg_str);
2754
2755 opts->x_ix86_stack_protector_guard_reg = seg;
2756 }
2757 else
2758 {
2759 opts->x_ix86_stack_protector_guard_reg = DEFAULT_TLS_SEG_REG;
2760
2761 /* The kernel uses a different segment register for performance
2762 reasons; a system call would not have to trash the userspace
2763 segment register, which would be expensive. */
2764 if (opts->x_ix86_cmodel == CM_KERNEL)
2765 opts->x_ix86_stack_protector_guard_reg = ADDR_SPACE_SEG_GS;
2766 }
2767
2768 /* Handle -mmemcpy-strategy= and -mmemset-strategy= */
2769 if (opts->x_ix86_tune_memcpy_strategy)
2770 {
2771 char *str = xstrdup (opts->x_ix86_tune_memcpy_strategy);
2772 ix86_parse_stringop_strategy_string (str, false);
2773 free (str);
2774 }
2775
2776 if (opts->x_ix86_tune_memset_strategy)
2777 {
2778 char *str = xstrdup (opts->x_ix86_tune_memset_strategy);
2779 ix86_parse_stringop_strategy_string (str, true);
2780 free (str);
2781 }
2782
2783 /* Save the initial options in case the user does function specific
2784 options. */
2785 if (main_args_p)
2786 target_option_default_node = target_option_current_node
2787 = build_target_option_node (opts);
2788
2789 if (opts->x_flag_cf_protection != CF_NONE)
2790 opts->x_flag_cf_protection
2791 = (cf_protection_level) (opts->x_flag_cf_protection | CF_SET);
2792
2793 if (ix86_tune_features [X86_TUNE_AVOID_256FMA_CHAINS])
2794 maybe_set_param_value (PARAM_AVOID_FMA_MAX_BITS, 256,
2795 opts->x_param_values,
2796 opts_set->x_param_values);
2797 else if (ix86_tune_features [X86_TUNE_AVOID_128FMA_CHAINS])
2798 maybe_set_param_value (PARAM_AVOID_FMA_MAX_BITS, 128,
2799 opts->x_param_values,
2800 opts_set->x_param_values);
2801
2802 /* PR86952: jump table usage with retpolines is slow.
2803 The PR provides some numbers about the slowness. */
2804 if (ix86_indirect_branch != indirect_branch_keep
2805 && !opts_set->x_flag_jump_tables)
2806 opts->x_flag_jump_tables = 0;
2807
2808 return true;
2809 }
2810
2811 /* Implement the TARGET_OPTION_OVERRIDE hook. */
2812
2813 void
2814 ix86_option_override (void)
2815 {
2816 ix86_option_override_internal (true, &global_options, &global_options_set);
2817 }
2818
2819 /* Remember the last target of ix86_set_current_function. */
2820 static GTY(()) tree ix86_previous_fndecl;
2821
2822 /* Set targets globals to the default (or current #pragma GCC target
2823 if active). Invalidate ix86_previous_fndecl cache. */
2824
2825 void
2826 ix86_reset_previous_fndecl (void)
2827 {
2828 tree new_tree = target_option_current_node;
2829 cl_target_option_restore (&global_options, TREE_TARGET_OPTION (new_tree));
2830 if (TREE_TARGET_GLOBALS (new_tree))
2831 restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
2832 else if (new_tree == target_option_default_node)
2833 restore_target_globals (&default_target_globals);
2834 else
2835 TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
2836 ix86_previous_fndecl = NULL_TREE;
2837 }
2838
2839 /* Add target attribute to SIMD clone NODE if needed. */
2840
2841 void
2842 ix86_simd_clone_adjust (struct cgraph_node *node)
2843 {
2844 const char *str = NULL;
2845
2846 /* Attributes need to be adjusted for definitions, not declarations. */
2847 if (!node->definition)
2848 return;
2849
2850 gcc_assert (node->decl == cfun->decl);
2851 switch (node->simdclone->vecsize_mangle)
2852 {
2853 case 'b':
2854 if (!TARGET_SSE2)
2855 str = "sse2";
2856 break;
2857 case 'c':
2858 if (!TARGET_AVX)
2859 str = "avx";
2860 break;
2861 case 'd':
2862 if (!TARGET_AVX2)
2863 str = "avx2";
2864 break;
2865 case 'e':
2866 if (!TARGET_AVX512F)
2867 str = "avx512f";
2868 break;
2869 default:
2870 gcc_unreachable ();
2871 }
2872 if (str == NULL)
2873 return;
2874 push_cfun (NULL);
2875 tree args = build_tree_list (NULL_TREE, build_string (strlen (str), str));
2876 bool ok = ix86_valid_target_attribute_p (node->decl, NULL, args, 0);
2877 gcc_assert (ok);
2878 pop_cfun ();
2879 ix86_reset_previous_fndecl ();
2880 ix86_set_current_function (node->decl);
2881 }
2882
2883
2884
2885 /* Set the func_type field from the function FNDECL. */
2886
2887 static void
2888 ix86_set_func_type (tree fndecl)
2889 {
2890 if (cfun->machine->func_type == TYPE_UNKNOWN)
2891 {
2892 if (lookup_attribute ("interrupt",
2893 TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
2894 {
2895 if (ix86_function_naked (fndecl))
2896 error_at (DECL_SOURCE_LOCATION (fndecl),
2897 "interrupt and naked attributes are not compatible");
2898
2899 int nargs = 0;
2900 for (tree arg = DECL_ARGUMENTS (fndecl);
2901 arg;
2902 arg = TREE_CHAIN (arg))
2903 nargs++;
2904 cfun->machine->no_caller_saved_registers = true;
2905 cfun->machine->func_type
2906 = nargs == 2 ? TYPE_EXCEPTION : TYPE_INTERRUPT;
2907
2908 ix86_optimize_mode_switching[X86_DIRFLAG] = 1;
2909
2910 /* Only dwarf2out.c can handle -WORD(AP) as a pointer argument. */
2911 if (write_symbols != NO_DEBUG && write_symbols != DWARF2_DEBUG)
2912 sorry ("only DWARF debug format is supported for interrupt "
2913 "service routine");
2914 }
2915 else
2916 {
2917 cfun->machine->func_type = TYPE_NORMAL;
2918 if (lookup_attribute ("no_caller_saved_registers",
2919 TYPE_ATTRIBUTES (TREE_TYPE (fndecl))))
2920 cfun->machine->no_caller_saved_registers = true;
2921 }
2922 }
2923 }
2924
2925 /* Set the indirect_branch_type field from the function FNDECL. */
2926
2927 static void
2928 ix86_set_indirect_branch_type (tree fndecl)
2929 {
2930 if (cfun->machine->indirect_branch_type == indirect_branch_unset)
2931 {
2932 tree attr = lookup_attribute ("indirect_branch",
2933 DECL_ATTRIBUTES (fndecl));
2934 if (attr != NULL)
2935 {
2936 tree args = TREE_VALUE (attr);
2937 if (args == NULL)
2938 gcc_unreachable ();
2939 tree cst = TREE_VALUE (args);
2940 if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
2941 cfun->machine->indirect_branch_type = indirect_branch_keep;
2942 else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
2943 cfun->machine->indirect_branch_type = indirect_branch_thunk;
2944 else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
2945 cfun->machine->indirect_branch_type = indirect_branch_thunk_inline;
2946 else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
2947 cfun->machine->indirect_branch_type = indirect_branch_thunk_extern;
2948 else
2949 gcc_unreachable ();
2950 }
2951 else
2952 cfun->machine->indirect_branch_type = ix86_indirect_branch;
2953
2954 /* -mcmodel=large is not compatible with -mindirect-branch=thunk
2955 nor -mindirect-branch=thunk-extern. */
2956 if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
2957 && ((cfun->machine->indirect_branch_type
2958 == indirect_branch_thunk_extern)
2959 || (cfun->machine->indirect_branch_type
2960 == indirect_branch_thunk)))
2961 error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
2962 "compatible",
2963 ((cfun->machine->indirect_branch_type
2964 == indirect_branch_thunk_extern)
2965 ? "thunk-extern" : "thunk"));
2966
2967 if (cfun->machine->indirect_branch_type != indirect_branch_keep
2968 && (flag_cf_protection & CF_RETURN))
2969 error ("%<-mindirect-branch%> and %<-fcf-protection%> are not "
2970 "compatible");
2971 }
2972
2973 if (cfun->machine->function_return_type == indirect_branch_unset)
2974 {
2975 tree attr = lookup_attribute ("function_return",
2976 DECL_ATTRIBUTES (fndecl));
2977 if (attr != NULL)
2978 {
2979 tree args = TREE_VALUE (attr);
2980 if (args == NULL)
2981 gcc_unreachable ();
2982 tree cst = TREE_VALUE (args);
2983 if (strcmp (TREE_STRING_POINTER (cst), "keep") == 0)
2984 cfun->machine->function_return_type = indirect_branch_keep;
2985 else if (strcmp (TREE_STRING_POINTER (cst), "thunk") == 0)
2986 cfun->machine->function_return_type = indirect_branch_thunk;
2987 else if (strcmp (TREE_STRING_POINTER (cst), "thunk-inline") == 0)
2988 cfun->machine->function_return_type = indirect_branch_thunk_inline;
2989 else if (strcmp (TREE_STRING_POINTER (cst), "thunk-extern") == 0)
2990 cfun->machine->function_return_type = indirect_branch_thunk_extern;
2991 else
2992 gcc_unreachable ();
2993 }
2994 else
2995 cfun->machine->function_return_type = ix86_function_return;
2996
2997 /* -mcmodel=large is not compatible with -mfunction-return=thunk
2998 nor -mfunction-return=thunk-extern. */
2999 if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC)
3000 && ((cfun->machine->function_return_type
3001 == indirect_branch_thunk_extern)
3002 || (cfun->machine->function_return_type
3003 == indirect_branch_thunk)))
3004 error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
3005 "compatible",
3006 ((cfun->machine->function_return_type
3007 == indirect_branch_thunk_extern)
3008 ? "thunk-extern" : "thunk"));
3009
3010 if (cfun->machine->function_return_type != indirect_branch_keep
3011 && (flag_cf_protection & CF_RETURN))
3012 error ("%<-mfunction-return%> and %<-fcf-protection%> are not "
3013 "compatible");
3014 }
3015 }
3016
3017 /* Establish appropriate back-end context for processing the function
3018 FNDECL. The argument might be NULL to indicate processing at top
3019 level, outside of any function scope. */
3020 void
3021 ix86_set_current_function (tree fndecl)
3022 {
3023 /* Only change the context if the function changes. This hook is called
3024 several times in the course of compiling a function, and we don't want to
3025 slow things down too much or call target_reinit when it isn't safe. */
3026 if (fndecl == ix86_previous_fndecl)
3027 {
3028 /* There may be 2 function bodies for the same function FNDECL,
3029 one is extern inline and one isn't. Call ix86_set_func_type
3030 to set the func_type field. */
3031 if (fndecl != NULL_TREE)
3032 {
3033 ix86_set_func_type (fndecl);
3034 ix86_set_indirect_branch_type (fndecl);
3035 }
3036 return;
3037 }
3038
3039 tree old_tree;
3040 if (ix86_previous_fndecl == NULL_TREE)
3041 old_tree = target_option_current_node;
3042 else if (DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl))
3043 old_tree = DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl);
3044 else
3045 old_tree = target_option_default_node;
3046
3047 if (fndecl == NULL_TREE)
3048 {
3049 if (old_tree != target_option_current_node)
3050 ix86_reset_previous_fndecl ();
3051 return;
3052 }
3053
3054 ix86_set_func_type (fndecl);
3055 ix86_set_indirect_branch_type (fndecl);
3056
3057 tree new_tree = DECL_FUNCTION_SPECIFIC_TARGET (fndecl);
3058 if (new_tree == NULL_TREE)
3059 new_tree = target_option_default_node;
3060
3061 if (old_tree != new_tree)
3062 {
3063 cl_target_option_restore (&global_options, TREE_TARGET_OPTION (new_tree));
3064 if (TREE_TARGET_GLOBALS (new_tree))
3065 restore_target_globals (TREE_TARGET_GLOBALS (new_tree));
3066 else if (new_tree == target_option_default_node)
3067 restore_target_globals (&default_target_globals);
3068 else
3069 TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
3070 }
3071 ix86_previous_fndecl = fndecl;
3072
3073 static bool prev_no_caller_saved_registers;
3074
3075 /* 64-bit MS and SYSV ABI have different set of call used registers.
3076 Avoid expensive re-initialization of init_regs each time we switch
3077 function context. */
3078 if (TARGET_64BIT
3079 && (call_used_or_fixed_reg_p (SI_REG)
3080 == (cfun->machine->call_abi == MS_ABI)))
3081 reinit_regs ();
3082 /* Need to re-initialize init_regs if caller-saved registers are
3083 changed. */
3084 else if (prev_no_caller_saved_registers
3085 != cfun->machine->no_caller_saved_registers)
3086 reinit_regs ();
3087
3088 if (cfun->machine->func_type != TYPE_NORMAL
3089 || cfun->machine->no_caller_saved_registers)
3090 {
3091 /* Don't allow SSE, MMX nor x87 instructions since they
3092 may change processor state. */
3093 const char *isa;
3094 if (TARGET_SSE)
3095 isa = "SSE";
3096 else if (TARGET_MMX)
3097 isa = "MMX/3Dnow";
3098 else if (TARGET_80387)
3099 isa = "80387";
3100 else
3101 isa = NULL;
3102 if (isa != NULL)
3103 {
3104 if (cfun->machine->func_type != TYPE_NORMAL)
3105 sorry (cfun->machine->func_type == TYPE_EXCEPTION
3106 ? G_("%s instructions aren%'t allowed in an"
3107 " exception service routine")
3108 : G_("%s instructions aren%'t allowed in an"
3109 " interrupt service routine"),
3110 isa);
3111 else
3112 sorry ("%s instructions aren%'t allowed in a function with "
3113 "the %<no_caller_saved_registers%> attribute", isa);
3114 /* Don't issue the same error twice. */
3115 cfun->machine->func_type = TYPE_NORMAL;
3116 cfun->machine->no_caller_saved_registers = false;
3117 }
3118 }
3119
3120 prev_no_caller_saved_registers
3121 = cfun->machine->no_caller_saved_registers;
3122 }
3123
3124 /* Implement the TARGET_OFFLOAD_OPTIONS hook. */
3125 char *
3126 ix86_offload_options (void)
3127 {
3128 if (TARGET_LP64)
3129 return xstrdup ("-foffload-abi=lp64");
3130 return xstrdup ("-foffload-abi=ilp32");
3131 }
3132
3133 /* Handle "cdecl", "stdcall", "fastcall", "regparm", "thiscall",
3134 and "sseregparm" calling convention attributes;
3135 arguments as in struct attribute_spec.handler. */
3136
3137 static tree
3138 ix86_handle_cconv_attribute (tree *node, tree name, tree args, int,
3139 bool *no_add_attrs)
3140 {
3141 if (TREE_CODE (*node) != FUNCTION_TYPE
3142 && TREE_CODE (*node) != METHOD_TYPE
3143 && TREE_CODE (*node) != FIELD_DECL
3144 && TREE_CODE (*node) != TYPE_DECL)
3145 {
3146 warning (OPT_Wattributes, "%qE attribute only applies to functions",
3147 name);
3148 *no_add_attrs = true;
3149 return NULL_TREE;
3150 }
3151
3152 /* Can combine regparm with all attributes but fastcall, and thiscall. */
3153 if (is_attribute_p ("regparm", name))
3154 {
3155 tree cst;
3156
3157 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3158 {
3159 error ("fastcall and regparm attributes are not compatible");
3160 }
3161
3162 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3163 {
3164 error ("regparam and thiscall attributes are not compatible");
3165 }
3166
3167 cst = TREE_VALUE (args);
3168 if (TREE_CODE (cst) != INTEGER_CST)
3169 {
3170 warning (OPT_Wattributes,
3171 "%qE attribute requires an integer constant argument",
3172 name);
3173 *no_add_attrs = true;
3174 }
3175 else if (compare_tree_int (cst, REGPARM_MAX) > 0)
3176 {
3177 warning (OPT_Wattributes, "argument to %qE attribute larger than %d",
3178 name, REGPARM_MAX);
3179 *no_add_attrs = true;
3180 }
3181
3182 return NULL_TREE;
3183 }
3184
3185 if (TARGET_64BIT)
3186 {
3187 /* Do not warn when emulating the MS ABI. */
3188 if ((TREE_CODE (*node) != FUNCTION_TYPE
3189 && TREE_CODE (*node) != METHOD_TYPE)
3190 || ix86_function_type_abi (*node) != MS_ABI)
3191 warning (OPT_Wattributes, "%qE attribute ignored",
3192 name);
3193 *no_add_attrs = true;
3194 return NULL_TREE;
3195 }
3196
3197 /* Can combine fastcall with stdcall (redundant) and sseregparm. */
3198 if (is_attribute_p ("fastcall", name))
3199 {
3200 if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
3201 {
3202 error ("fastcall and cdecl attributes are not compatible");
3203 }
3204 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
3205 {
3206 error ("fastcall and stdcall attributes are not compatible");
3207 }
3208 if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node)))
3209 {
3210 error ("fastcall and regparm attributes are not compatible");
3211 }
3212 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3213 {
3214 error ("fastcall and thiscall attributes are not compatible");
3215 }
3216 }
3217
3218 /* Can combine stdcall with fastcall (redundant), regparm and
3219 sseregparm. */
3220 else if (is_attribute_p ("stdcall", name))
3221 {
3222 if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
3223 {
3224 error ("stdcall and cdecl attributes are not compatible");
3225 }
3226 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3227 {
3228 error ("stdcall and fastcall attributes are not compatible");
3229 }
3230 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3231 {
3232 error ("stdcall and thiscall attributes are not compatible");
3233 }
3234 }
3235
3236 /* Can combine cdecl with regparm and sseregparm. */
3237 else if (is_attribute_p ("cdecl", name))
3238 {
3239 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
3240 {
3241 error ("stdcall and cdecl attributes are not compatible");
3242 }
3243 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3244 {
3245 error ("fastcall and cdecl attributes are not compatible");
3246 }
3247 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node)))
3248 {
3249 error ("cdecl and thiscall attributes are not compatible");
3250 }
3251 }
3252 else if (is_attribute_p ("thiscall", name))
3253 {
3254 if (TREE_CODE (*node) != METHOD_TYPE && pedantic)
3255 warning (OPT_Wattributes, "%qE attribute is used for non-class method",
3256 name);
3257 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node)))
3258 {
3259 error ("stdcall and thiscall attributes are not compatible");
3260 }
3261 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node)))
3262 {
3263 error ("fastcall and thiscall attributes are not compatible");
3264 }
3265 if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node)))
3266 {
3267 error ("cdecl and thiscall attributes are not compatible");
3268 }
3269 }
3270
3271 /* Can combine sseregparm with all attributes. */
3272
3273 return NULL_TREE;
3274 }
3275
3276 #ifndef CHECK_STACK_LIMIT
3277 #define CHECK_STACK_LIMIT (-1)
3278 #endif
3279
3280 /* The transactional memory builtins are implicitly regparm or fastcall
3281 depending on the ABI. Override the generic do-nothing attribute that
3282 these builtins were declared with, and replace it with one of the two
3283 attributes that we expect elsewhere. */
3284
3285 static tree
3286 ix86_handle_tm_regparm_attribute (tree *node, tree, tree,
3287 int flags, bool *no_add_attrs)
3288 {
3289 tree alt;
3290
3291 /* In no case do we want to add the placeholder attribute. */
3292 *no_add_attrs = true;
3293
3294 /* The 64-bit ABI is unchanged for transactional memory. */
3295 if (TARGET_64BIT)
3296 return NULL_TREE;
3297
3298 /* ??? Is there a better way to validate 32-bit windows? We have
3299 cfun->machine->call_abi, but that seems to be set only for 64-bit. */
3300 if (CHECK_STACK_LIMIT > 0)
3301 alt = tree_cons (get_identifier ("fastcall"), NULL, NULL);
3302 else
3303 {
3304 alt = tree_cons (NULL, build_int_cst (NULL, 2), NULL);
3305 alt = tree_cons (get_identifier ("regparm"), alt, NULL);
3306 }
3307 decl_attributes (node, alt, flags);
3308
3309 return NULL_TREE;
3310 }
3311
3312 /* Handle a "force_align_arg_pointer" attribute. */
3313
3314 static tree
3315 ix86_handle_force_align_arg_pointer_attribute (tree *node, tree name,
3316 tree, int, bool *no_add_attrs)
3317 {
3318 if (TREE_CODE (*node) != FUNCTION_TYPE
3319 && TREE_CODE (*node) != METHOD_TYPE
3320 && TREE_CODE (*node) != FIELD_DECL
3321 && TREE_CODE (*node) != TYPE_DECL)
3322 {
3323 warning (OPT_Wattributes, "%qE attribute only applies to functions",
3324 name);
3325 *no_add_attrs = true;
3326 }
3327
3328 return NULL_TREE;
3329 }
3330
3331 /* Handle a "ms_struct" or "gcc_struct" attribute; arguments as in
3332 struct attribute_spec.handler. */
3333
3334 static tree
3335 ix86_handle_struct_attribute (tree *node, tree name, tree, int,
3336 bool *no_add_attrs)
3337 {
3338 tree *type = NULL;
3339 if (DECL_P (*node))
3340 {
3341 if (TREE_CODE (*node) == TYPE_DECL)
3342 type = &TREE_TYPE (*node);
3343 }
3344 else
3345 type = node;
3346
3347 if (!(type && RECORD_OR_UNION_TYPE_P (*type)))
3348 {
3349 warning (OPT_Wattributes, "%qE attribute ignored",
3350 name);
3351 *no_add_attrs = true;
3352 }
3353
3354 else if ((is_attribute_p ("ms_struct", name)
3355 && lookup_attribute ("gcc_struct", TYPE_ATTRIBUTES (*type)))
3356 || ((is_attribute_p ("gcc_struct", name)
3357 && lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (*type)))))
3358 {
3359 warning (OPT_Wattributes, "%qE incompatible attribute ignored",
3360 name);
3361 *no_add_attrs = true;
3362 }
3363
3364 return NULL_TREE;
3365 }
3366
3367 /* Handle a "callee_pop_aggregate_return" attribute; arguments as
3368 in struct attribute_spec handler. */
3369
3370 static tree
3371 ix86_handle_callee_pop_aggregate_return (tree *node, tree name, tree args, int,
3372 bool *no_add_attrs)
3373 {
3374 if (TREE_CODE (*node) != FUNCTION_TYPE
3375 && TREE_CODE (*node) != METHOD_TYPE
3376 && TREE_CODE (*node) != FIELD_DECL
3377 && TREE_CODE (*node) != TYPE_DECL)
3378 {
3379 warning (OPT_Wattributes, "%qE attribute only applies to functions",
3380 name);
3381 *no_add_attrs = true;
3382 return NULL_TREE;
3383 }
3384 if (TARGET_64BIT)
3385 {
3386 warning (OPT_Wattributes, "%qE attribute only available for 32-bit",
3387 name);
3388 *no_add_attrs = true;
3389 return NULL_TREE;
3390 }
3391 if (is_attribute_p ("callee_pop_aggregate_return", name))
3392 {
3393 tree cst;
3394
3395 cst = TREE_VALUE (args);
3396 if (TREE_CODE (cst) != INTEGER_CST)
3397 {
3398 warning (OPT_Wattributes,
3399 "%qE attribute requires an integer constant argument",
3400 name);
3401 *no_add_attrs = true;
3402 }
3403 else if (compare_tree_int (cst, 0) != 0
3404 && compare_tree_int (cst, 1) != 0)
3405 {
3406 warning (OPT_Wattributes,
3407 "argument to %qE attribute is neither zero, nor one",
3408 name);
3409 *no_add_attrs = true;
3410 }
3411
3412 return NULL_TREE;
3413 }
3414
3415 return NULL_TREE;
3416 }
3417
3418 /* Handle a "ms_abi" or "sysv" attribute; arguments as in
3419 struct attribute_spec.handler. */
3420
3421 static tree
3422 ix86_handle_abi_attribute (tree *node, tree name, tree, int,
3423 bool *no_add_attrs)
3424 {
3425 if (TREE_CODE (*node) != FUNCTION_TYPE
3426 && TREE_CODE (*node) != METHOD_TYPE
3427 && TREE_CODE (*node) != FIELD_DECL
3428 && TREE_CODE (*node) != TYPE_DECL)
3429 {
3430 warning (OPT_Wattributes, "%qE attribute only applies to functions",
3431 name);
3432 *no_add_attrs = true;
3433 return NULL_TREE;
3434 }
3435
3436 /* Can combine regparm with all attributes but fastcall. */
3437 if (is_attribute_p ("ms_abi", name))
3438 {
3439 if (lookup_attribute ("sysv_abi", TYPE_ATTRIBUTES (*node)))
3440 {
3441 error ("%qs and %qs attributes are not compatible",
3442 "ms_abi", "sysv_abi");
3443 }
3444
3445 return NULL_TREE;
3446 }
3447 else if (is_attribute_p ("sysv_abi", name))
3448 {
3449 if (lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (*node)))
3450 {
3451 error ("%qs and %qs attributes are not compatible",
3452 "ms_abi", "sysv_abi");
3453 }
3454
3455 return NULL_TREE;
3456 }
3457
3458 return NULL_TREE;
3459 }
3460
3461 static tree
3462 ix86_handle_fndecl_attribute (tree *node, tree name, tree args, int,
3463 bool *no_add_attrs)
3464 {
3465 if (TREE_CODE (*node) != FUNCTION_DECL)
3466 {
3467 warning (OPT_Wattributes, "%qE attribute only applies to functions",
3468 name);
3469 *no_add_attrs = true;
3470 }
3471
3472 if (is_attribute_p ("indirect_branch", name))
3473 {
3474 tree cst = TREE_VALUE (args);
3475 if (TREE_CODE (cst) != STRING_CST)
3476 {
3477 warning (OPT_Wattributes,
3478 "%qE attribute requires a string constant argument",
3479 name);
3480 *no_add_attrs = true;
3481 }
3482 else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
3483 && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
3484 && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
3485 && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
3486 {
3487 warning (OPT_Wattributes,
3488 "argument to %qE attribute is not "
3489 "(keep|thunk|thunk-inline|thunk-extern)", name);
3490 *no_add_attrs = true;
3491 }
3492 }
3493
3494 if (is_attribute_p ("function_return", name))
3495 {
3496 tree cst = TREE_VALUE (args);
3497 if (TREE_CODE (cst) != STRING_CST)
3498 {
3499 warning (OPT_Wattributes,
3500 "%qE attribute requires a string constant argument",
3501 name);
3502 *no_add_attrs = true;
3503 }
3504 else if (strcmp (TREE_STRING_POINTER (cst), "keep") != 0
3505 && strcmp (TREE_STRING_POINTER (cst), "thunk") != 0
3506 && strcmp (TREE_STRING_POINTER (cst), "thunk-inline") != 0
3507 && strcmp (TREE_STRING_POINTER (cst), "thunk-extern") != 0)
3508 {
3509 warning (OPT_Wattributes,
3510 "argument to %qE attribute is not "
3511 "(keep|thunk|thunk-inline|thunk-extern)", name);
3512 *no_add_attrs = true;
3513 }
3514 }
3515
3516 return NULL_TREE;
3517 }
3518
3519 static tree
3520 ix86_handle_no_caller_saved_registers_attribute (tree *, tree, tree,
3521 int, bool *)
3522 {
3523 return NULL_TREE;
3524 }
3525
3526 static tree
3527 ix86_handle_interrupt_attribute (tree *node, tree, tree, int, bool *)
3528 {
3529 /* DECL_RESULT and DECL_ARGUMENTS do not exist there yet,
3530 but the function type contains args and return type data. */
3531 tree func_type = *node;
3532 tree return_type = TREE_TYPE (func_type);
3533
3534 int nargs = 0;
3535 tree current_arg_type = TYPE_ARG_TYPES (func_type);
3536 while (current_arg_type
3537 && ! VOID_TYPE_P (TREE_VALUE (current_arg_type)))
3538 {
3539 if (nargs == 0)
3540 {
3541 if (! POINTER_TYPE_P (TREE_VALUE (current_arg_type)))
3542 error ("interrupt service routine should have a pointer "
3543 "as the first argument");
3544 }
3545 else if (nargs == 1)
3546 {
3547 if (TREE_CODE (TREE_VALUE (current_arg_type)) != INTEGER_TYPE
3548 || TYPE_MODE (TREE_VALUE (current_arg_type)) != word_mode)
3549 error ("interrupt service routine should have %qs "
3550 "as the second argument",
3551 TARGET_64BIT
3552 ? (TARGET_X32 ? "unsigned long long int"
3553 : "unsigned long int")
3554 : "unsigned int");
3555 }
3556 nargs++;
3557 current_arg_type = TREE_CHAIN (current_arg_type);
3558 }
3559 if (!nargs || nargs > 2)
3560 error ("interrupt service routine can only have a pointer argument "
3561 "and an optional integer argument");
3562 if (! VOID_TYPE_P (return_type))
3563 error ("interrupt service routine must return %<void%>");
3564
3565 return NULL_TREE;
3566 }
3567
3568 /* Handle fentry_name / fentry_section attribute. */
3569
3570 static tree
3571 ix86_handle_fentry_name (tree *node, tree name, tree args,
3572 int, bool *no_add_attrs)
3573 {
3574 if (TREE_CODE (*node) == FUNCTION_DECL
3575 && TREE_CODE (TREE_VALUE (args)) == STRING_CST)
3576 /* Do nothing else, just set the attribute. We'll get at
3577 it later with lookup_attribute. */
3578 ;
3579 else
3580 {
3581 warning (OPT_Wattributes, "%qE attribute ignored", name);
3582 *no_add_attrs = true;
3583 }
3584
3585 return NULL_TREE;
3586 }
3587
3588 /* Table of valid machine attributes. */
3589 const struct attribute_spec ix86_attribute_table[] =
3590 {
3591 /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
3592 affects_type_identity, handler, exclude } */
3593 /* Stdcall attribute says callee is responsible for popping arguments
3594 if they are not variable. */
3595 { "stdcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
3596 NULL },
3597 /* Fastcall attribute says callee is responsible for popping arguments
3598 if they are not variable. */
3599 { "fastcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
3600 NULL },
3601 /* Thiscall attribute says callee is responsible for popping arguments
3602 if they are not variable. */
3603 { "thiscall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
3604 NULL },
3605 /* Cdecl attribute says the callee is a normal C declaration */
3606 { "cdecl", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
3607 NULL },
3608 /* Regparm attribute specifies how many integer arguments are to be
3609 passed in registers. */
3610 { "regparm", 1, 1, false, true, true, true, ix86_handle_cconv_attribute,
3611 NULL },
3612 /* Sseregparm attribute says we are using x86_64 calling conventions
3613 for FP arguments. */
3614 { "sseregparm", 0, 0, false, true, true, true, ix86_handle_cconv_attribute,
3615 NULL },
3616 /* The transactional memory builtins are implicitly regparm or fastcall
3617 depending on the ABI. Override the generic do-nothing attribute that
3618 these builtins were declared with. */
3619 { "*tm regparm", 0, 0, false, true, true, true,
3620 ix86_handle_tm_regparm_attribute, NULL },
3621 /* force_align_arg_pointer says this function realigns the stack at entry. */
3622 { "force_align_arg_pointer", 0, 0,
3623 false, true, true, false, ix86_handle_force_align_arg_pointer_attribute,
3624 NULL },
3625 #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
3626 { "dllimport", 0, 0, false, false, false, false, handle_dll_attribute,
3627 NULL },
3628 { "dllexport", 0, 0, false, false, false, false, handle_dll_attribute,
3629 NULL },
3630 { "shared", 0, 0, true, false, false, false,
3631 ix86_handle_shared_attribute, NULL },
3632 #endif
3633 { "ms_struct", 0, 0, false, false, false, false,
3634 ix86_handle_struct_attribute, NULL },
3635 { "gcc_struct", 0, 0, false, false, false, false,
3636 ix86_handle_struct_attribute, NULL },
3637 #ifdef SUBTARGET_ATTRIBUTE_TABLE
3638 SUBTARGET_ATTRIBUTE_TABLE,
3639 #endif
3640 /* ms_abi and sysv_abi calling convention function attributes. */
3641 { "ms_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute, NULL },
3642 { "sysv_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute,
3643 NULL },
3644 { "ms_abi va_list", 0, 0, false, false, false, false, NULL, NULL },
3645 { "sysv_abi va_list", 0, 0, false, false, false, false, NULL, NULL },
3646 { "ms_hook_prologue", 0, 0, true, false, false, false,
3647 ix86_handle_fndecl_attribute, NULL },
3648 { "callee_pop_aggregate_return", 1, 1, false, true, true, true,
3649 ix86_handle_callee_pop_aggregate_return, NULL },
3650 { "interrupt", 0, 0, false, true, true, false,
3651 ix86_handle_interrupt_attribute, NULL },
3652 { "no_caller_saved_registers", 0, 0, false, true, true, false,
3653 ix86_handle_no_caller_saved_registers_attribute, NULL },
3654 { "naked", 0, 0, true, false, false, false,
3655 ix86_handle_fndecl_attribute, NULL },
3656 { "indirect_branch", 1, 1, true, false, false, false,
3657 ix86_handle_fndecl_attribute, NULL },
3658 { "function_return", 1, 1, true, false, false, false,
3659 ix86_handle_fndecl_attribute, NULL },
3660 { "indirect_return", 0, 0, false, true, true, false,
3661 NULL, NULL },
3662 { "fentry_name", 1, 1, true, false, false, false,
3663 ix86_handle_fentry_name, NULL },
3664 { "fentry_section", 1, 1, true, false, false, false,
3665 ix86_handle_fentry_name, NULL },
3666 { "cf_check", 0, 0, true, false, false, false,
3667 ix86_handle_fndecl_attribute, NULL },
3668
3669 /* End element. */
3670 { NULL, 0, 0, false, false, false, false, NULL, NULL }
3671 };
3672
3673 #include "gt-i386-options.h"