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