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