1 /* Copyright (C) 1988-2019 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
10 GCC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GCC; see the file COPYING3. If not see
17 <http://www.gnu.org/licenses/>. */
19 #define IN_TARGET_CODE 1
23 #include "coretypes.h"
33 #include "stringpool.h"
40 #include "diagnostic.h"
43 #include "fold-const.h"
46 #include "stor-layout.h"
49 #include "insn-attr.h"
55 #include "common/common-target.h"
56 #include "langhooks.h"
60 #include "tm-constrs.h"
63 #include "sched-int.h"
65 #include "tree-pass.h"
67 #include "pass_manager.h"
68 #include "target-globals.h"
69 #include "gimple-iterator.h"
70 #include "tree-vectorizer.h"
71 #include "shrink-wrap.h"
74 #include "tree-iterator.h"
76 #include "case-cfn-macros.h"
78 #include "fold-const-call.h"
80 #include "tree-ssanames.h"
82 #include "selftest-rtl.h"
83 #include "print-rtl.h"
86 #include "symbol-summary.h"
88 #include "ipa-fnsummary.h"
89 #include "wide-int-bitmask.h"
90 #include "tree-vector-builder.h"
92 #include "dwarf2out.h"
93 #include "i386-options.h"
95 #include "x86-tune-costs.h"
97 #ifndef SUBTARGET32_DEFAULT_CPU
98 #define SUBTARGET32_DEFAULT_CPU "i386"
101 /* Processor feature/optimization bitmasks. */
102 #define m_386 (HOST_WIDE_INT_1U<<PROCESSOR_I386)
103 #define m_486 (HOST_WIDE_INT_1U<<PROCESSOR_I486)
104 #define m_PENT (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM)
105 #define m_LAKEMONT (HOST_WIDE_INT_1U<<PROCESSOR_LAKEMONT)
106 #define m_PPRO (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUMPRO)
107 #define m_PENT4 (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM4)
108 #define m_NOCONA (HOST_WIDE_INT_1U<<PROCESSOR_NOCONA)
109 #define m_P4_NOCONA (m_PENT4 | m_NOCONA)
110 #define m_CORE2 (HOST_WIDE_INT_1U<<PROCESSOR_CORE2)
111 #define m_NEHALEM (HOST_WIDE_INT_1U<<PROCESSOR_NEHALEM)
112 #define m_SANDYBRIDGE (HOST_WIDE_INT_1U<<PROCESSOR_SANDYBRIDGE)
113 #define m_HASWELL (HOST_WIDE_INT_1U<<PROCESSOR_HASWELL)
114 #define m_BONNELL (HOST_WIDE_INT_1U<<PROCESSOR_BONNELL)
115 #define m_SILVERMONT (HOST_WIDE_INT_1U<<PROCESSOR_SILVERMONT)
116 #define m_KNL (HOST_WIDE_INT_1U<<PROCESSOR_KNL)
117 #define m_KNM (HOST_WIDE_INT_1U<<PROCESSOR_KNM)
118 #define m_SKYLAKE (HOST_WIDE_INT_1U<<PROCESSOR_SKYLAKE)
119 #define m_SKYLAKE_AVX512 (HOST_WIDE_INT_1U<<PROCESSOR_SKYLAKE_AVX512)
120 #define m_CANNONLAKE (HOST_WIDE_INT_1U<<PROCESSOR_CANNONLAKE)
121 #define m_ICELAKE_CLIENT (HOST_WIDE_INT_1U<<PROCESSOR_ICELAKE_CLIENT)
122 #define m_ICELAKE_SERVER (HOST_WIDE_INT_1U<<PROCESSOR_ICELAKE_SERVER)
123 #define m_CASCADELAKE (HOST_WIDE_INT_1U<<PROCESSOR_CASCADELAKE)
124 #define m_CORE_AVX512 (m_SKYLAKE_AVX512 | m_CANNONLAKE \
125 | m_ICELAKE_CLIENT | m_ICELAKE_SERVER | m_CASCADELAKE)
126 #define m_CORE_AVX2 (m_HASWELL | m_SKYLAKE | m_CORE_AVX512)
127 #define m_CORE_ALL (m_CORE2 | m_NEHALEM | m_SANDYBRIDGE | m_CORE_AVX2)
128 #define m_GOLDMONT (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT)
129 #define m_GOLDMONT_PLUS (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT_PLUS)
130 #define m_TREMONT (HOST_WIDE_INT_1U<<PROCESSOR_TREMONT)
131 #define m_INTEL (HOST_WIDE_INT_1U<<PROCESSOR_INTEL)
133 #define m_GEODE (HOST_WIDE_INT_1U<<PROCESSOR_GEODE)
134 #define m_K6 (HOST_WIDE_INT_1U<<PROCESSOR_K6)
135 #define m_K6_GEODE (m_K6 | m_GEODE)
136 #define m_K8 (HOST_WIDE_INT_1U<<PROCESSOR_K8)
137 #define m_ATHLON (HOST_WIDE_INT_1U<<PROCESSOR_ATHLON)
138 #define m_ATHLON_K8 (m_K8 | m_ATHLON)
139 #define m_AMDFAM10 (HOST_WIDE_INT_1U<<PROCESSOR_AMDFAM10)
140 #define m_BDVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER1)
141 #define m_BDVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER2)
142 #define m_BDVER3 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER3)
143 #define m_BDVER4 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER4)
144 #define m_ZNVER1 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER1)
145 #define m_ZNVER2 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER2)
146 #define m_BTVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER1)
147 #define m_BTVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER2)
148 #define m_BDVER (m_BDVER1 | m_BDVER2 | m_BDVER3 | m_BDVER4)
149 #define m_BTVER (m_BTVER1 | m_BTVER2)
150 #define m_ZNVER (m_ZNVER1 | m_ZNVER2)
151 #define m_AMD_MULTIPLE (m_ATHLON_K8 | m_AMDFAM10 | m_BDVER | m_BTVER \
154 #define m_GENERIC (HOST_WIDE_INT_1U<<PROCESSOR_GENERIC)
156 const char* ix86_tune_feature_names
[X86_TUNE_LAST
] = {
158 #define DEF_TUNE(tune, name, selector) name,
159 #include "x86-tune.def"
163 /* Feature tests against the various tunings. */
164 unsigned char ix86_tune_features
[X86_TUNE_LAST
];
166 /* Feature tests against the various tunings used to create ix86_tune_features
167 based on the processor mask. */
168 static unsigned HOST_WIDE_INT initial_ix86_tune_features
[X86_TUNE_LAST
] = {
170 #define DEF_TUNE(tune, name, selector) selector,
171 #include "x86-tune.def"
175 /* Feature tests against the various architecture variations. */
176 unsigned char ix86_arch_features
[X86_ARCH_LAST
];
178 /* Return a string that documents the current -m options. The caller is
179 responsible for freeing the string. */
182 ix86_target_string (HOST_WIDE_INT isa
, HOST_WIDE_INT isa2
,
183 int flags
, int flags2
,
184 const char *arch
, const char *tune
,
185 enum fpmath_unit fpmath
, bool add_nl_p
, bool add_abi_p
)
187 struct ix86_target_opts
189 const char *option
; /* option string */
190 HOST_WIDE_INT mask
; /* isa mask options */
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. */
195 static struct ix86_target_opts isa2_opts
[] =
197 { "-mcx16", OPTION_MASK_ISA_CX16
},
198 { "-mvaes", OPTION_MASK_ISA_VAES
},
199 { "-mrdpid", OPTION_MASK_ISA_RDPID
},
200 { "-mpconfig", OPTION_MASK_ISA_PCONFIG
},
201 { "-mwbnoinvd", OPTION_MASK_ISA_WBNOINVD
},
202 { "-msgx", OPTION_MASK_ISA_SGX
},
203 { "-mavx5124vnniw", OPTION_MASK_ISA_AVX5124VNNIW
},
204 { "-mavx5124fmaps", OPTION_MASK_ISA_AVX5124FMAPS
},
205 { "-mhle", OPTION_MASK_ISA_HLE
},
206 { "-mmovbe", OPTION_MASK_ISA_MOVBE
},
207 { "-mclzero", OPTION_MASK_ISA_CLZERO
},
208 { "-mmwaitx", OPTION_MASK_ISA_MWAITX
},
209 { "-mmovdir64b", OPTION_MASK_ISA_MOVDIR64B
},
210 { "-mwaitpkg", OPTION_MASK_ISA_WAITPKG
},
211 { "-mcldemote", OPTION_MASK_ISA_CLDEMOTE
},
212 { "-mptwrite", OPTION_MASK_ISA_PTWRITE
},
213 { "-mavx512bf16", OPTION_MASK_ISA_AVX512BF16
},
214 { "-menqcmd", OPTION_MASK_ISA_ENQCMD
}
216 static struct ix86_target_opts isa_opts
[] =
218 { "-mavx512vpopcntdq", OPTION_MASK_ISA_AVX512VPOPCNTDQ
},
219 { "-mavx512bitalg", OPTION_MASK_ISA_AVX512BITALG
},
220 { "-mvpclmulqdq", OPTION_MASK_ISA_VPCLMULQDQ
},
221 { "-mgfni", OPTION_MASK_ISA_GFNI
},
222 { "-mavx512vnni", OPTION_MASK_ISA_AVX512VNNI
},
223 { "-mavx512vbmi2", OPTION_MASK_ISA_AVX512VBMI2
},
224 { "-mavx512vbmi", OPTION_MASK_ISA_AVX512VBMI
},
225 { "-mavx512ifma", OPTION_MASK_ISA_AVX512IFMA
},
226 { "-mavx512vl", OPTION_MASK_ISA_AVX512VL
},
227 { "-mavx512bw", OPTION_MASK_ISA_AVX512BW
},
228 { "-mavx512dq", OPTION_MASK_ISA_AVX512DQ
},
229 { "-mavx512er", OPTION_MASK_ISA_AVX512ER
},
230 { "-mavx512pf", OPTION_MASK_ISA_AVX512PF
},
231 { "-mavx512cd", OPTION_MASK_ISA_AVX512CD
},
232 { "-mavx512f", OPTION_MASK_ISA_AVX512F
},
233 { "-mavx2", OPTION_MASK_ISA_AVX2
},
234 { "-mfma", OPTION_MASK_ISA_FMA
},
235 { "-mxop", OPTION_MASK_ISA_XOP
},
236 { "-mfma4", OPTION_MASK_ISA_FMA4
},
237 { "-mf16c", OPTION_MASK_ISA_F16C
},
238 { "-mavx", OPTION_MASK_ISA_AVX
},
239 /* { "-msse4" OPTION_MASK_ISA_SSE4 }, */
240 { "-msse4.2", OPTION_MASK_ISA_SSE4_2
},
241 { "-msse4.1", OPTION_MASK_ISA_SSE4_1
},
242 { "-msse4a", OPTION_MASK_ISA_SSE4A
},
243 { "-mssse3", OPTION_MASK_ISA_SSSE3
},
244 { "-msse3", OPTION_MASK_ISA_SSE3
},
245 { "-maes", OPTION_MASK_ISA_AES
},
246 { "-msha", OPTION_MASK_ISA_SHA
},
247 { "-mpclmul", OPTION_MASK_ISA_PCLMUL
},
248 { "-msse2", OPTION_MASK_ISA_SSE2
},
249 { "-msse", OPTION_MASK_ISA_SSE
},
250 { "-m3dnowa", OPTION_MASK_ISA_3DNOW_A
},
251 { "-m3dnow", OPTION_MASK_ISA_3DNOW
},
252 { "-mmmx", OPTION_MASK_ISA_MMX
},
253 { "-mrtm", OPTION_MASK_ISA_RTM
},
254 { "-mprfchw", OPTION_MASK_ISA_PRFCHW
},
255 { "-mrdseed", OPTION_MASK_ISA_RDSEED
},
256 { "-madx", OPTION_MASK_ISA_ADX
},
257 { "-mprefetchwt1", OPTION_MASK_ISA_PREFETCHWT1
},
258 { "-mclflushopt", OPTION_MASK_ISA_CLFLUSHOPT
},
259 { "-mxsaves", OPTION_MASK_ISA_XSAVES
},
260 { "-mxsavec", OPTION_MASK_ISA_XSAVEC
},
261 { "-mxsaveopt", OPTION_MASK_ISA_XSAVEOPT
},
262 { "-mxsave", OPTION_MASK_ISA_XSAVE
},
263 { "-mabm", OPTION_MASK_ISA_ABM
},
264 { "-mbmi", OPTION_MASK_ISA_BMI
},
265 { "-mbmi2", OPTION_MASK_ISA_BMI2
},
266 { "-mlzcnt", OPTION_MASK_ISA_LZCNT
},
267 { "-mtbm", OPTION_MASK_ISA_TBM
},
268 { "-mpopcnt", OPTION_MASK_ISA_POPCNT
},
269 { "-msahf", OPTION_MASK_ISA_SAHF
},
270 { "-mcrc32", OPTION_MASK_ISA_CRC32
},
271 { "-mfsgsbase", OPTION_MASK_ISA_FSGSBASE
},
272 { "-mrdrnd", OPTION_MASK_ISA_RDRND
},
273 { "-mpku", OPTION_MASK_ISA_PKU
},
274 { "-mlwp", OPTION_MASK_ISA_LWP
},
275 { "-mfxsr", OPTION_MASK_ISA_FXSR
},
276 { "-mclwb", OPTION_MASK_ISA_CLWB
},
277 { "-mshstk", OPTION_MASK_ISA_SHSTK
},
278 { "-mmovdiri", OPTION_MASK_ISA_MOVDIRI
}
282 static struct ix86_target_opts flag_opts
[] =
284 { "-m128bit-long-double", MASK_128BIT_LONG_DOUBLE
},
285 { "-mlong-double-128", MASK_LONG_DOUBLE_128
},
286 { "-mlong-double-64", MASK_LONG_DOUBLE_64
},
287 { "-m80387", MASK_80387
},
288 { "-maccumulate-outgoing-args", MASK_ACCUMULATE_OUTGOING_ARGS
},
289 { "-malign-double", MASK_ALIGN_DOUBLE
},
290 { "-mcld", MASK_CLD
},
291 { "-mfp-ret-in-387", MASK_FLOAT_RETURNS
},
292 { "-mieee-fp", MASK_IEEE_FP
},
293 { "-minline-all-stringops", MASK_INLINE_ALL_STRINGOPS
},
294 { "-minline-stringops-dynamically", MASK_INLINE_STRINGOPS_DYNAMICALLY
},
295 { "-mms-bitfields", MASK_MS_BITFIELD_LAYOUT
},
296 { "-mno-align-stringops", MASK_NO_ALIGN_STRINGOPS
},
297 { "-mno-fancy-math-387", MASK_NO_FANCY_MATH_387
},
298 { "-mno-push-args", MASK_NO_PUSH_ARGS
},
299 { "-mno-red-zone", MASK_NO_RED_ZONE
},
300 { "-momit-leaf-frame-pointer", MASK_OMIT_LEAF_FRAME_POINTER
},
301 { "-mrecip", MASK_RECIP
},
302 { "-mrtd", MASK_RTD
},
303 { "-msseregparm", MASK_SSEREGPARM
},
304 { "-mstack-arg-probe", MASK_STACK_PROBE
},
305 { "-mtls-direct-seg-refs", MASK_TLS_DIRECT_SEG_REFS
},
306 { "-mvect8-ret-in-mem", MASK_VECT8_RETURNS
},
307 { "-m8bit-idiv", MASK_USE_8BIT_IDIV
},
308 { "-mvzeroupper", MASK_VZEROUPPER
},
309 { "-mstv", MASK_STV
},
310 { "-mavx256-split-unaligned-load", MASK_AVX256_SPLIT_UNALIGNED_LOAD
},
311 { "-mavx256-split-unaligned-store", MASK_AVX256_SPLIT_UNALIGNED_STORE
},
312 { "-mcall-ms2sysv-xlogues", MASK_CALL_MS2SYSV_XLOGUES
}
315 /* Additional flag options. */
316 static struct ix86_target_opts flag2_opts
[] =
318 { "-mgeneral-regs-only", OPTION_MASK_GENERAL_REGS_ONLY
}
321 const char *opts
[ARRAY_SIZE (isa_opts
) + ARRAY_SIZE (isa2_opts
)
322 + ARRAY_SIZE (flag_opts
) + ARRAY_SIZE (flag2_opts
) + 6][2];
326 char flags_other
[40];
327 char flags2_other
[40];
337 memset (opts
, '\0', sizeof (opts
));
339 /* Add -march= option. */
342 opts
[num
][0] = "-march=";
343 opts
[num
++][1] = arch
;
346 /* Add -mtune= option. */
349 opts
[num
][0] = "-mtune=";
350 opts
[num
++][1] = tune
;
353 /* Add -m32/-m64/-mx32. */
356 if ((isa
& OPTION_MASK_ISA_64BIT
) != 0)
358 if ((isa
& OPTION_MASK_ABI_64
) != 0)
365 opts
[num
++][0] = abi
;
367 isa
&= ~(OPTION_MASK_ISA_64BIT
| OPTION_MASK_ABI_64
| OPTION_MASK_ABI_X32
);
369 /* Pick out the options in isa2 options. */
370 for (i
= 0; i
< ARRAY_SIZE (isa2_opts
); i
++)
372 if ((isa2
& isa2_opts
[i
].mask
) != 0)
374 opts
[num
++][0] = isa2_opts
[i
].option
;
375 isa2
&= ~ isa2_opts
[i
].mask
;
379 if (isa2
&& add_nl_p
)
381 opts
[num
++][0] = isa2_other
;
382 sprintf (isa2_other
, "(other isa2: %#" HOST_WIDE_INT_PRINT
"x)", isa2
);
385 /* Pick out the options in isa options. */
386 for (i
= 0; i
< ARRAY_SIZE (isa_opts
); i
++)
388 if ((isa
& isa_opts
[i
].mask
) != 0)
390 opts
[num
++][0] = isa_opts
[i
].option
;
391 isa
&= ~ isa_opts
[i
].mask
;
397 opts
[num
++][0] = isa_other
;
398 sprintf (isa_other
, "(other isa: %#" HOST_WIDE_INT_PRINT
"x)", isa
);
401 /* Add flag options. */
402 for (i
= 0; i
< ARRAY_SIZE (flag_opts
); i
++)
404 if ((flags
& flag_opts
[i
].mask
) != 0)
406 opts
[num
++][0] = flag_opts
[i
].option
;
407 flags
&= ~ flag_opts
[i
].mask
;
411 if (flags
&& add_nl_p
)
413 opts
[num
++][0] = flags_other
;
414 sprintf (flags_other
, "(other flags: %#x)", flags
);
417 /* Add additional flag options. */
418 for (i
= 0; i
< ARRAY_SIZE (flag2_opts
); i
++)
420 if ((flags2
& flag2_opts
[i
].mask
) != 0)
422 opts
[num
++][0] = flag2_opts
[i
].option
;
423 flags2
&= ~ flag2_opts
[i
].mask
;
427 if (flags2
&& add_nl_p
)
429 opts
[num
++][0] = flags2_other
;
430 sprintf (flags2_other
, "(other flags2: %#x)", flags2
);
433 /* Add -fpmath= option. */
436 opts
[num
][0] = "-mfpmath=";
437 switch ((int) fpmath
)
440 opts
[num
++][1] = "387";
444 opts
[num
++][1] = "sse";
447 case FPMATH_387
| FPMATH_SSE
:
448 opts
[num
++][1] = "sse+387";
460 gcc_assert (num
< ARRAY_SIZE (opts
));
462 /* Size the string. */
464 sep_len
= (add_nl_p
) ? 3 : 1;
465 for (i
= 0; i
< num
; i
++)
468 for (j
= 0; j
< 2; j
++)
470 len
+= strlen (opts
[i
][j
]);
473 /* Build the string. */
474 ret
= ptr
= (char *) xmalloc (len
);
477 for (i
= 0; i
< num
; i
++)
481 for (j
= 0; j
< 2; j
++)
482 len2
[j
] = (opts
[i
][j
]) ? strlen (opts
[i
][j
]) : 0;
489 if (add_nl_p
&& line_len
+ len2
[0] + len2
[1] > 70)
497 for (j
= 0; j
< 2; j
++)
500 memcpy (ptr
, opts
[i
][j
], len2
[j
]);
507 gcc_assert (ret
+ len
>= ptr
);
512 /* Function that is callable from the debugger to print the current
514 void ATTRIBUTE_UNUSED
515 ix86_debug_options (void)
517 char *opts
= ix86_target_string (ix86_isa_flags
, ix86_isa_flags2
,
518 target_flags
, ix86_target_flags
,
519 ix86_arch_string
,ix86_tune_string
,
520 ix86_fpmath
, true, true);
524 fprintf (stderr
, "%s\n\n", opts
);
528 fputs ("<no options>\n\n", stderr
);
533 /* Save the current options */
536 ix86_function_specific_save (struct cl_target_option
*ptr
,
537 struct gcc_options
*opts
)
539 ptr
->arch
= ix86_arch
;
540 ptr
->schedule
= ix86_schedule
;
541 ptr
->prefetch_sse
= x86_prefetch_sse
;
542 ptr
->tune
= ix86_tune
;
543 ptr
->branch_cost
= ix86_branch_cost
;
544 ptr
->tune_defaulted
= ix86_tune_defaulted
;
545 ptr
->arch_specified
= ix86_arch_specified
;
546 ptr
->x_ix86_isa_flags_explicit
= opts
->x_ix86_isa_flags_explicit
;
547 ptr
->x_ix86_isa_flags2_explicit
= opts
->x_ix86_isa_flags2_explicit
;
548 ptr
->x_recip_mask_explicit
= opts
->x_recip_mask_explicit
;
549 ptr
->x_ix86_arch_string
= opts
->x_ix86_arch_string
;
550 ptr
->x_ix86_tune_string
= opts
->x_ix86_tune_string
;
551 ptr
->x_ix86_cmodel
= opts
->x_ix86_cmodel
;
552 ptr
->x_ix86_abi
= opts
->x_ix86_abi
;
553 ptr
->x_ix86_asm_dialect
= opts
->x_ix86_asm_dialect
;
554 ptr
->x_ix86_branch_cost
= opts
->x_ix86_branch_cost
;
555 ptr
->x_ix86_dump_tunes
= opts
->x_ix86_dump_tunes
;
556 ptr
->x_ix86_force_align_arg_pointer
= opts
->x_ix86_force_align_arg_pointer
;
557 ptr
->x_ix86_force_drap
= opts
->x_ix86_force_drap
;
558 ptr
->x_ix86_incoming_stack_boundary_arg
= opts
->x_ix86_incoming_stack_boundary_arg
;
559 ptr
->x_ix86_pmode
= opts
->x_ix86_pmode
;
560 ptr
->x_ix86_preferred_stack_boundary_arg
= opts
->x_ix86_preferred_stack_boundary_arg
;
561 ptr
->x_ix86_recip_name
= opts
->x_ix86_recip_name
;
562 ptr
->x_ix86_regparm
= opts
->x_ix86_regparm
;
563 ptr
->x_ix86_section_threshold
= opts
->x_ix86_section_threshold
;
564 ptr
->x_ix86_sse2avx
= opts
->x_ix86_sse2avx
;
565 ptr
->x_ix86_stack_protector_guard
= opts
->x_ix86_stack_protector_guard
;
566 ptr
->x_ix86_stringop_alg
= opts
->x_ix86_stringop_alg
;
567 ptr
->x_ix86_tls_dialect
= opts
->x_ix86_tls_dialect
;
568 ptr
->x_ix86_tune_ctrl_string
= opts
->x_ix86_tune_ctrl_string
;
569 ptr
->x_ix86_tune_memcpy_strategy
= opts
->x_ix86_tune_memcpy_strategy
;
570 ptr
->x_ix86_tune_memset_strategy
= opts
->x_ix86_tune_memset_strategy
;
571 ptr
->x_ix86_tune_no_default
= opts
->x_ix86_tune_no_default
;
572 ptr
->x_ix86_veclibabi_type
= opts
->x_ix86_veclibabi_type
;
574 /* The fields are char but the variables are not; make sure the
575 values fit in the fields. */
576 gcc_assert (ptr
->arch
== ix86_arch
);
577 gcc_assert (ptr
->schedule
== ix86_schedule
);
578 gcc_assert (ptr
->tune
== ix86_tune
);
579 gcc_assert (ptr
->branch_cost
== ix86_branch_cost
);
582 /* Feature tests against the various architecture variations, used to create
583 ix86_arch_features based on the processor mask. */
584 static unsigned HOST_WIDE_INT initial_ix86_arch_features
[X86_ARCH_LAST
] = {
585 /* X86_ARCH_CMOV: Conditional move was added for pentiumpro. */
586 ~(m_386
| m_486
| m_PENT
| m_LAKEMONT
| m_K6
),
588 /* X86_ARCH_CMPXCHG: Compare and exchange was added for 80486. */
591 /* X86_ARCH_CMPXCHG8B: Compare and exchange 8 bytes was added for pentium. */
594 /* X86_ARCH_XADD: Exchange and add was added for 80486. */
597 /* X86_ARCH_BSWAP: Byteswap was added for 80486. */
601 /* This table must be in sync with enum processor_type in i386.h. */
602 static const struct processor_costs
*processor_cost_table
[] =
645 /* Guarantee that the array is aligned with enum processor_type. */
646 STATIC_ASSERT (ARRAY_SIZE (processor_cost_table
) == PROCESSOR_max
);
649 ix86_option_override_internal (bool main_args_p
,
650 struct gcc_options
*opts
,
651 struct gcc_options
*opts_set
);
653 set_ix86_tune_features (enum processor_type ix86_tune
, bool dump
);
655 /* Restore the current options */
658 ix86_function_specific_restore (struct gcc_options
*opts
,
659 struct cl_target_option
*ptr
)
661 enum processor_type old_tune
= ix86_tune
;
662 enum processor_type old_arch
= ix86_arch
;
663 unsigned HOST_WIDE_INT ix86_arch_mask
;
666 /* We don't change -fPIC. */
667 opts
->x_flag_pic
= flag_pic
;
669 ix86_arch
= (enum processor_type
) ptr
->arch
;
670 ix86_schedule
= (enum attr_cpu
) ptr
->schedule
;
671 ix86_tune
= (enum processor_type
) ptr
->tune
;
672 x86_prefetch_sse
= ptr
->prefetch_sse
;
673 opts
->x_ix86_branch_cost
= ptr
->branch_cost
;
674 ix86_tune_defaulted
= ptr
->tune_defaulted
;
675 ix86_arch_specified
= ptr
->arch_specified
;
676 opts
->x_ix86_isa_flags_explicit
= ptr
->x_ix86_isa_flags_explicit
;
677 opts
->x_ix86_isa_flags2_explicit
= ptr
->x_ix86_isa_flags2_explicit
;
678 opts
->x_recip_mask_explicit
= ptr
->x_recip_mask_explicit
;
679 opts
->x_ix86_arch_string
= ptr
->x_ix86_arch_string
;
680 opts
->x_ix86_tune_string
= ptr
->x_ix86_tune_string
;
681 opts
->x_ix86_cmodel
= ptr
->x_ix86_cmodel
;
682 opts
->x_ix86_abi
= ptr
->x_ix86_abi
;
683 opts
->x_ix86_asm_dialect
= ptr
->x_ix86_asm_dialect
;
684 opts
->x_ix86_branch_cost
= ptr
->x_ix86_branch_cost
;
685 opts
->x_ix86_dump_tunes
= ptr
->x_ix86_dump_tunes
;
686 opts
->x_ix86_force_align_arg_pointer
= ptr
->x_ix86_force_align_arg_pointer
;
687 opts
->x_ix86_force_drap
= ptr
->x_ix86_force_drap
;
688 opts
->x_ix86_incoming_stack_boundary_arg
= ptr
->x_ix86_incoming_stack_boundary_arg
;
689 opts
->x_ix86_pmode
= ptr
->x_ix86_pmode
;
690 opts
->x_ix86_preferred_stack_boundary_arg
= ptr
->x_ix86_preferred_stack_boundary_arg
;
691 opts
->x_ix86_recip_name
= ptr
->x_ix86_recip_name
;
692 opts
->x_ix86_regparm
= ptr
->x_ix86_regparm
;
693 opts
->x_ix86_section_threshold
= ptr
->x_ix86_section_threshold
;
694 opts
->x_ix86_sse2avx
= ptr
->x_ix86_sse2avx
;
695 opts
->x_ix86_stack_protector_guard
= ptr
->x_ix86_stack_protector_guard
;
696 opts
->x_ix86_stringop_alg
= ptr
->x_ix86_stringop_alg
;
697 opts
->x_ix86_tls_dialect
= ptr
->x_ix86_tls_dialect
;
698 opts
->x_ix86_tune_ctrl_string
= ptr
->x_ix86_tune_ctrl_string
;
699 opts
->x_ix86_tune_memcpy_strategy
= ptr
->x_ix86_tune_memcpy_strategy
;
700 opts
->x_ix86_tune_memset_strategy
= ptr
->x_ix86_tune_memset_strategy
;
701 opts
->x_ix86_tune_no_default
= ptr
->x_ix86_tune_no_default
;
702 opts
->x_ix86_veclibabi_type
= ptr
->x_ix86_veclibabi_type
;
703 ix86_tune_cost
= processor_cost_table
[ix86_tune
];
704 /* TODO: ix86_cost should be chosen at instruction or function granuality
705 so for cold code we use size_cost even in !optimize_size compilation. */
706 if (opts
->x_optimize_size
)
707 ix86_cost
= &ix86_size_cost
;
709 ix86_cost
= ix86_tune_cost
;
711 /* Recreate the arch feature tests if the arch changed */
712 if (old_arch
!= ix86_arch
)
714 ix86_arch_mask
= HOST_WIDE_INT_1U
<< ix86_arch
;
715 for (i
= 0; i
< X86_ARCH_LAST
; ++i
)
716 ix86_arch_features
[i
]
717 = !!(initial_ix86_arch_features
[i
] & ix86_arch_mask
);
720 /* Recreate the tune optimization tests */
721 if (old_tune
!= ix86_tune
)
722 set_ix86_tune_features (ix86_tune
, false);
725 /* Adjust target options after streaming them in. This is mainly about
726 reconciling them with global options. */
729 ix86_function_specific_post_stream_in (struct cl_target_option
*ptr
)
731 /* flag_pic is a global option, but ix86_cmodel is target saved option
732 partly computed from flag_pic. If flag_pic is on, adjust x_ix86_cmodel
733 for PIC, or error out. */
735 switch (ptr
->x_ix86_cmodel
)
738 ptr
->x_ix86_cmodel
= CM_SMALL_PIC
;
742 ptr
->x_ix86_cmodel
= CM_MEDIUM_PIC
;
746 ptr
->x_ix86_cmodel
= CM_LARGE_PIC
;
750 error ("code model %s does not support PIC mode", "kernel");
757 switch (ptr
->x_ix86_cmodel
)
760 ptr
->x_ix86_cmodel
= CM_SMALL
;
764 ptr
->x_ix86_cmodel
= CM_MEDIUM
;
768 ptr
->x_ix86_cmodel
= CM_LARGE
;
776 /* Print the current options */
779 ix86_function_specific_print (FILE *file
, int indent
,
780 struct cl_target_option
*ptr
)
783 = ix86_target_string (ptr
->x_ix86_isa_flags
, ptr
->x_ix86_isa_flags2
,
784 ptr
->x_target_flags
, ptr
->x_ix86_target_flags
,
785 NULL
, NULL
, ptr
->x_ix86_fpmath
, false, true);
787 gcc_assert (ptr
->arch
< PROCESSOR_max
);
788 fprintf (file
, "%*sarch = %d (%s)\n",
790 ptr
->arch
, processor_names
[ptr
->arch
]);
792 gcc_assert (ptr
->tune
< PROCESSOR_max
);
793 fprintf (file
, "%*stune = %d (%s)\n",
795 ptr
->tune
, processor_names
[ptr
->tune
]);
797 fprintf (file
, "%*sbranch_cost = %d\n", indent
, "", ptr
->branch_cost
);
801 fprintf (file
, "%*s%s\n", indent
, "", target_string
);
802 free (target_string
);
807 /* Inner function to process the attribute((target(...))), take an argument and
808 set the current options from the argument. If we have a list, recursively go
812 ix86_valid_target_attribute_inner_p (tree fndecl
, tree args
, char *p_strings
[],
813 struct gcc_options
*opts
,
814 struct gcc_options
*opts_set
,
815 struct gcc_options
*enum_opts_set
,
816 bool target_clone_attr
)
821 #define IX86_ATTR_ISA(S,O) { S, sizeof (S)-1, ix86_opt_isa, O, 0 }
822 #define IX86_ATTR_STR(S,O) { S, sizeof (S)-1, ix86_opt_str, O, 0 }
823 #define IX86_ATTR_ENUM(S,O) { S, sizeof (S)-1, ix86_opt_enum, O, 0 }
824 #define IX86_ATTR_YES(S,O,M) { S, sizeof (S)-1, ix86_opt_yes, O, M }
825 #define IX86_ATTR_NO(S,O,M) { S, sizeof (S)-1, ix86_opt_no, O, M }
841 enum ix86_opt_type type
;
846 IX86_ATTR_ISA ("pconfig", OPT_mpconfig
),
847 IX86_ATTR_ISA ("wbnoinvd", OPT_mwbnoinvd
),
848 IX86_ATTR_ISA ("sgx", OPT_msgx
),
849 IX86_ATTR_ISA ("avx5124fmaps", OPT_mavx5124fmaps
),
850 IX86_ATTR_ISA ("avx5124vnniw", OPT_mavx5124vnniw
),
851 IX86_ATTR_ISA ("avx512vpopcntdq", OPT_mavx512vpopcntdq
),
852 IX86_ATTR_ISA ("avx512vbmi2", OPT_mavx512vbmi2
),
853 IX86_ATTR_ISA ("avx512vnni", OPT_mavx512vnni
),
854 IX86_ATTR_ISA ("avx512bitalg", OPT_mavx512bitalg
),
856 IX86_ATTR_ISA ("avx512vbmi", OPT_mavx512vbmi
),
857 IX86_ATTR_ISA ("avx512ifma", OPT_mavx512ifma
),
858 IX86_ATTR_ISA ("avx512vl", OPT_mavx512vl
),
859 IX86_ATTR_ISA ("avx512bw", OPT_mavx512bw
),
860 IX86_ATTR_ISA ("avx512dq", OPT_mavx512dq
),
861 IX86_ATTR_ISA ("avx512er", OPT_mavx512er
),
862 IX86_ATTR_ISA ("avx512pf", OPT_mavx512pf
),
863 IX86_ATTR_ISA ("avx512cd", OPT_mavx512cd
),
864 IX86_ATTR_ISA ("avx512f", OPT_mavx512f
),
865 IX86_ATTR_ISA ("avx2", OPT_mavx2
),
866 IX86_ATTR_ISA ("fma", OPT_mfma
),
867 IX86_ATTR_ISA ("xop", OPT_mxop
),
868 IX86_ATTR_ISA ("fma4", OPT_mfma4
),
869 IX86_ATTR_ISA ("f16c", OPT_mf16c
),
870 IX86_ATTR_ISA ("avx", OPT_mavx
),
871 IX86_ATTR_ISA ("sse4", OPT_msse4
),
872 IX86_ATTR_ISA ("sse4.2", OPT_msse4_2
),
873 IX86_ATTR_ISA ("sse4.1", OPT_msse4_1
),
874 IX86_ATTR_ISA ("sse4a", OPT_msse4a
),
875 IX86_ATTR_ISA ("ssse3", OPT_mssse3
),
876 IX86_ATTR_ISA ("sse3", OPT_msse3
),
877 IX86_ATTR_ISA ("aes", OPT_maes
),
878 IX86_ATTR_ISA ("sha", OPT_msha
),
879 IX86_ATTR_ISA ("pclmul", OPT_mpclmul
),
880 IX86_ATTR_ISA ("sse2", OPT_msse2
),
881 IX86_ATTR_ISA ("sse", OPT_msse
),
882 IX86_ATTR_ISA ("3dnowa", OPT_m3dnowa
),
883 IX86_ATTR_ISA ("3dnow", OPT_m3dnow
),
884 IX86_ATTR_ISA ("mmx", OPT_mmmx
),
885 IX86_ATTR_ISA ("rtm", OPT_mrtm
),
886 IX86_ATTR_ISA ("prfchw", OPT_mprfchw
),
887 IX86_ATTR_ISA ("rdseed", OPT_mrdseed
),
888 IX86_ATTR_ISA ("adx", OPT_madx
),
889 IX86_ATTR_ISA ("prefetchwt1", OPT_mprefetchwt1
),
890 IX86_ATTR_ISA ("clflushopt", OPT_mclflushopt
),
891 IX86_ATTR_ISA ("xsaves", OPT_mxsaves
),
892 IX86_ATTR_ISA ("xsavec", OPT_mxsavec
),
893 IX86_ATTR_ISA ("xsaveopt", OPT_mxsaveopt
),
894 IX86_ATTR_ISA ("xsave", OPT_mxsave
),
895 IX86_ATTR_ISA ("abm", OPT_mabm
),
896 IX86_ATTR_ISA ("bmi", OPT_mbmi
),
897 IX86_ATTR_ISA ("bmi2", OPT_mbmi2
),
898 IX86_ATTR_ISA ("lzcnt", OPT_mlzcnt
),
899 IX86_ATTR_ISA ("tbm", OPT_mtbm
),
900 IX86_ATTR_ISA ("popcnt", OPT_mpopcnt
),
901 IX86_ATTR_ISA ("cx16", OPT_mcx16
),
902 IX86_ATTR_ISA ("sahf", OPT_msahf
),
903 IX86_ATTR_ISA ("movbe", OPT_mmovbe
),
904 IX86_ATTR_ISA ("crc32", OPT_mcrc32
),
905 IX86_ATTR_ISA ("fsgsbase", OPT_mfsgsbase
),
906 IX86_ATTR_ISA ("rdrnd", OPT_mrdrnd
),
907 IX86_ATTR_ISA ("mwaitx", OPT_mmwaitx
),
908 IX86_ATTR_ISA ("clzero", OPT_mclzero
),
909 IX86_ATTR_ISA ("pku", OPT_mpku
),
910 IX86_ATTR_ISA ("lwp", OPT_mlwp
),
911 IX86_ATTR_ISA ("hle", OPT_mhle
),
912 IX86_ATTR_ISA ("fxsr", OPT_mfxsr
),
913 IX86_ATTR_ISA ("clwb", OPT_mclwb
),
914 IX86_ATTR_ISA ("rdpid", OPT_mrdpid
),
915 IX86_ATTR_ISA ("gfni", OPT_mgfni
),
916 IX86_ATTR_ISA ("shstk", OPT_mshstk
),
917 IX86_ATTR_ISA ("vaes", OPT_mvaes
),
918 IX86_ATTR_ISA ("vpclmulqdq", OPT_mvpclmulqdq
),
919 IX86_ATTR_ISA ("movdiri", OPT_mmovdiri
),
920 IX86_ATTR_ISA ("movdir64b", OPT_mmovdir64b
),
921 IX86_ATTR_ISA ("waitpkg", OPT_mwaitpkg
),
922 IX86_ATTR_ISA ("cldemote", OPT_mcldemote
),
923 IX86_ATTR_ISA ("ptwrite", OPT_mptwrite
),
924 IX86_ATTR_ISA ("avx512bf16", OPT_mavx512bf16
),
925 IX86_ATTR_ISA ("enqcmd", OPT_menqcmd
),
928 IX86_ATTR_ENUM ("fpmath=", OPT_mfpmath_
),
931 IX86_ATTR_STR ("arch=", IX86_FUNCTION_SPECIFIC_ARCH
),
932 IX86_ATTR_STR ("tune=", IX86_FUNCTION_SPECIFIC_TUNE
),
935 IX86_ATTR_YES ("cld",
939 IX86_ATTR_NO ("fancy-math-387",
941 MASK_NO_FANCY_MATH_387
),
943 IX86_ATTR_YES ("ieee-fp",
947 IX86_ATTR_YES ("inline-all-stringops",
948 OPT_minline_all_stringops
,
949 MASK_INLINE_ALL_STRINGOPS
),
951 IX86_ATTR_YES ("inline-stringops-dynamically",
952 OPT_minline_stringops_dynamically
,
953 MASK_INLINE_STRINGOPS_DYNAMICALLY
),
955 IX86_ATTR_NO ("align-stringops",
956 OPT_mno_align_stringops
,
957 MASK_NO_ALIGN_STRINGOPS
),
959 IX86_ATTR_YES ("recip",
965 = fndecl
== NULL
? UNKNOWN_LOCATION
: DECL_SOURCE_LOCATION (fndecl
);
966 const char *attr_name
= target_clone_attr
? "target_clone" : "target";
968 /* If this is a list, recurse to get the options. */
969 if (TREE_CODE (args
) == TREE_LIST
)
973 for (; args
; args
= TREE_CHAIN (args
))
974 if (TREE_VALUE (args
)
975 && !ix86_valid_target_attribute_inner_p (fndecl
, TREE_VALUE (args
),
976 p_strings
, opts
, opts_set
,
984 else if (TREE_CODE (args
) != STRING_CST
)
986 error_at (loc
, "attribute %qs argument is not a string", attr_name
);
990 /* Handle multiple arguments separated by commas. */
991 next_optstr
= ASTRDUP (TREE_STRING_POINTER (args
));
993 while (next_optstr
&& *next_optstr
!= '\0')
995 char *p
= next_optstr
;
997 char *comma
= strchr (next_optstr
, ',');
1003 enum ix86_opt_type type
= ix86_opt_unknown
;
1009 len
= comma
- next_optstr
;
1010 next_optstr
= comma
+ 1;
1018 /* Recognize no-xxx. */
1019 if (len
> 3 && p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-')
1028 /* Find the option. */
1031 for (i
= 0; i
< ARRAY_SIZE (attrs
); i
++)
1033 type
= attrs
[i
].type
;
1034 opt_len
= attrs
[i
].len
;
1035 if (ch
== attrs
[i
].string
[0]
1036 && ((type
!= ix86_opt_str
&& type
!= ix86_opt_enum
)
1039 && memcmp (p
, attrs
[i
].string
, opt_len
) == 0)
1042 mask
= attrs
[i
].mask
;
1047 /* Process the option. */
1050 error_at (loc
, "attribute %qs argument %qs is unknown",
1055 else if (type
== ix86_opt_isa
)
1057 struct cl_decoded_option decoded
;
1059 generate_option (opt
, NULL
, opt_set_p
, CL_TARGET
, &decoded
);
1060 ix86_handle_option (opts
, opts_set
,
1061 &decoded
, input_location
);
1064 else if (type
== ix86_opt_yes
|| type
== ix86_opt_no
)
1066 if (type
== ix86_opt_no
)
1067 opt_set_p
= !opt_set_p
;
1070 opts
->x_target_flags
|= mask
;
1072 opts
->x_target_flags
&= ~mask
;
1075 else if (type
== ix86_opt_str
)
1079 error_at (loc
, "attribute value %qs was already specified "
1080 "in %qs attribute", orig_p
, attr_name
);
1084 p_strings
[opt
] = xstrdup (p
+ opt_len
);
1087 else if (type
== ix86_opt_enum
)
1092 arg_ok
= opt_enum_arg_to_value (opt
, p
+ opt_len
, &value
, CL_TARGET
);
1094 set_option (opts
, enum_opts_set
, opt
, value
,
1095 p
+ opt_len
, DK_UNSPECIFIED
, input_location
,
1099 error_at (loc
, "attribute value %qs is unknown in %qs attribute",
1112 /* Release allocated strings. */
1114 release_options_strings (char **option_strings
)
1116 /* Free up memory allocated to hold the strings */
1117 for (unsigned i
= 0; i
< IX86_FUNCTION_SPECIFIC_MAX
; i
++)
1118 free (option_strings
[i
]);
1121 /* Return a TARGET_OPTION_NODE tree of the target options listed or NULL. */
1124 ix86_valid_target_attribute_tree (tree fndecl
, tree args
,
1125 struct gcc_options
*opts
,
1126 struct gcc_options
*opts_set
,
1127 bool target_clone_attr
)
1129 const char *orig_arch_string
= opts
->x_ix86_arch_string
;
1130 const char *orig_tune_string
= opts
->x_ix86_tune_string
;
1131 enum fpmath_unit orig_fpmath_set
= opts_set
->x_ix86_fpmath
;
1132 int orig_tune_defaulted
= ix86_tune_defaulted
;
1133 int orig_arch_specified
= ix86_arch_specified
;
1134 char *option_strings
[IX86_FUNCTION_SPECIFIC_MAX
] = { NULL
, NULL
};
1136 struct cl_target_option
*def
1137 = TREE_TARGET_OPTION (target_option_default_node
);
1138 struct gcc_options enum_opts_set
;
1140 memset (&enum_opts_set
, 0, sizeof (enum_opts_set
));
1142 /* Process each of the options on the chain. */
1143 if (!ix86_valid_target_attribute_inner_p (fndecl
, args
, option_strings
, opts
,
1144 opts_set
, &enum_opts_set
,
1146 return error_mark_node
;
1148 /* If the changed options are different from the default, rerun
1149 ix86_option_override_internal, and then save the options away.
1150 The string options are attribute options, and will be undone
1151 when we copy the save structure. */
1152 if (opts
->x_ix86_isa_flags
!= def
->x_ix86_isa_flags
1153 || opts
->x_ix86_isa_flags2
!= def
->x_ix86_isa_flags2
1154 || opts
->x_target_flags
!= def
->x_target_flags
1155 || option_strings
[IX86_FUNCTION_SPECIFIC_ARCH
]
1156 || option_strings
[IX86_FUNCTION_SPECIFIC_TUNE
]
1157 || enum_opts_set
.x_ix86_fpmath
)
1159 /* If we are using the default tune= or arch=, undo the string assigned,
1160 and use the default. */
1161 if (option_strings
[IX86_FUNCTION_SPECIFIC_ARCH
])
1163 opts
->x_ix86_arch_string
1164 = ggc_strdup (option_strings
[IX86_FUNCTION_SPECIFIC_ARCH
]);
1166 /* If arch= is set, clear all bits in x_ix86_isa_flags,
1167 except for ISA_64BIT, ABI_64, ABI_X32, and CODE16. */
1168 opts
->x_ix86_isa_flags
&= (OPTION_MASK_ISA_64BIT
1169 | OPTION_MASK_ABI_64
1170 | OPTION_MASK_ABI_X32
1171 | OPTION_MASK_CODE16
);
1172 opts
->x_ix86_isa_flags2
= 0;
1174 else if (!orig_arch_specified
)
1175 opts
->x_ix86_arch_string
= NULL
;
1177 if (option_strings
[IX86_FUNCTION_SPECIFIC_TUNE
])
1178 opts
->x_ix86_tune_string
1179 = ggc_strdup (option_strings
[IX86_FUNCTION_SPECIFIC_TUNE
]);
1180 else if (orig_tune_defaulted
)
1181 opts
->x_ix86_tune_string
= NULL
;
1183 /* If fpmath= is not set, and we now have sse2 on 32-bit, use it. */
1184 if (enum_opts_set
.x_ix86_fpmath
)
1185 opts_set
->x_ix86_fpmath
= (enum fpmath_unit
) 1;
1187 /* Do any overrides, such as arch=xxx, or tune=xxx support. */
1188 bool r
= ix86_option_override_internal (false, opts
, opts_set
);
1191 release_options_strings (option_strings
);
1192 return error_mark_node
;
1195 /* Add any builtin functions with the new isa if any. */
1196 ix86_add_new_builtins (opts
->x_ix86_isa_flags
, opts
->x_ix86_isa_flags2
);
1198 /* Save the current options unless we are validating options for
1200 t
= build_target_option_node (opts
);
1202 opts
->x_ix86_arch_string
= orig_arch_string
;
1203 opts
->x_ix86_tune_string
= orig_tune_string
;
1204 opts_set
->x_ix86_fpmath
= orig_fpmath_set
;
1206 release_options_strings (option_strings
);
1212 /* Hook to validate attribute((target("string"))). */
1215 ix86_valid_target_attribute_p (tree fndecl
,
1216 tree
ARG_UNUSED (name
),
1220 struct gcc_options func_options
;
1221 tree new_target
, new_optimize
;
1224 /* attribute((target("default"))) does nothing, beyond
1225 affecting multi-versioning. */
1226 if (TREE_VALUE (args
)
1227 && TREE_CODE (TREE_VALUE (args
)) == STRING_CST
1228 && TREE_CHAIN (args
) == NULL_TREE
1229 && strcmp (TREE_STRING_POINTER (TREE_VALUE (args
)), "default") == 0)
1232 tree old_optimize
= build_optimization_node (&global_options
);
1234 /* Get the optimization options of the current function. */
1235 tree func_optimize
= DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl
);
1238 func_optimize
= old_optimize
;
1240 /* Init func_options. */
1241 memset (&func_options
, 0, sizeof (func_options
));
1242 init_options_struct (&func_options
, NULL
);
1243 lang_hooks
.init_options_struct (&func_options
);
1245 cl_optimization_restore (&func_options
,
1246 TREE_OPTIMIZATION (func_optimize
));
1248 /* Initialize func_options to the default before its target options can
1250 cl_target_option_restore (&func_options
,
1251 TREE_TARGET_OPTION (target_option_default_node
));
1253 /* FLAGS == 1 is used for target_clones attribute. */
1255 = ix86_valid_target_attribute_tree (fndecl
, args
, &func_options
,
1256 &global_options_set
, flags
== 1);
1258 new_optimize
= build_optimization_node (&func_options
);
1260 if (new_target
== error_mark_node
)
1263 else if (fndecl
&& new_target
)
1265 DECL_FUNCTION_SPECIFIC_TARGET (fndecl
) = new_target
;
1267 if (old_optimize
!= new_optimize
)
1268 DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl
) = new_optimize
;
1271 finalize_options_struct (&func_options
);
1276 const char *stringop_alg_names
[] = {
1278 #define DEF_ALG(alg, name) #name,
1279 #include "stringop.def"
1284 /* Parse parameter string passed to -mmemcpy-strategy= or -mmemset-strategy=.
1285 The string is of the following form (or comma separated list of it):
1287 strategy_alg:max_size:[align|noalign]
1289 where the full size range for the strategy is either [0, max_size] or
1290 [min_size, max_size], in which min_size is the max_size + 1 of the
1291 preceding range. The last size range must have max_size == -1.
1296 -mmemcpy-strategy=libcall:-1:noalign
1298 this is equivalent to (for known size memcpy) -mstringop-strategy=libcall
1302 -mmemset-strategy=rep_8byte:16:noalign,vector_loop:2048:align,libcall:-1:noalign
1304 This is to tell the compiler to use the following strategy for memset
1305 1) when the expected size is between [1, 16], use rep_8byte strategy;
1306 2) when the size is between [17, 2048], use vector_loop;
1307 3) when the size is > 2048, use libcall. */
1309 struct stringop_size_range
1317 ix86_parse_stringop_strategy_string (char *strategy_str
, bool is_memset
)
1319 const struct stringop_algs
*default_algs
;
1320 stringop_size_range input_ranges
[MAX_STRINGOP_ALGS
];
1321 char *curr_range_str
, *next_range_str
;
1322 const char *opt
= is_memset
? "-mmemset_strategy=" : "-mmemcpy_strategy=";
1326 default_algs
= &ix86_cost
->memset
[TARGET_64BIT
!= 0];
1328 default_algs
= &ix86_cost
->memcpy
[TARGET_64BIT
!= 0];
1330 curr_range_str
= strategy_str
;
1337 next_range_str
= strchr (curr_range_str
, ',');
1339 *next_range_str
++ = '\0';
1341 if (sscanf (curr_range_str
, "%20[^:]:%d:%10s", alg_name
, &maxs
,
1344 error ("wrong argument %qs to option %qs", curr_range_str
, opt
);
1348 if (n
> 0 && (maxs
< (input_ranges
[n
- 1].max
+ 1) && maxs
!= -1))
1350 error ("size ranges of option %qs should be increasing", opt
);
1354 for (i
= 0; i
< last_alg
; i
++)
1355 if (!strcmp (alg_name
, stringop_alg_names
[i
]))
1360 error ("wrong strategy name %qs specified for option %qs",
1363 auto_vec
<const char *> candidates
;
1364 for (i
= 0; i
< last_alg
; i
++)
1365 if ((stringop_alg
) i
!= rep_prefix_8_byte
|| TARGET_64BIT
)
1366 candidates
.safe_push (stringop_alg_names
[i
]);
1370 = candidates_list_and_hint (alg_name
, s
, candidates
);
1372 inform (input_location
,
1373 "valid arguments to %qs are: %s; did you mean %qs?",
1376 inform (input_location
, "valid arguments to %qs are: %s",
1382 if ((stringop_alg
) i
== rep_prefix_8_byte
1385 /* rep; movq isn't available in 32-bit code. */
1386 error ("strategy name %qs specified for option %qs "
1387 "not supported for 32-bit code", alg_name
, opt
);
1391 input_ranges
[n
].max
= maxs
;
1392 input_ranges
[n
].alg
= (stringop_alg
) i
;
1393 if (!strcmp (align
, "align"))
1394 input_ranges
[n
].noalign
= false;
1395 else if (!strcmp (align
, "noalign"))
1396 input_ranges
[n
].noalign
= true;
1399 error ("unknown alignment %qs specified for option %qs", align
, opt
);
1403 curr_range_str
= next_range_str
;
1405 while (curr_range_str
);
1407 if (input_ranges
[n
- 1].max
!= -1)
1409 error ("the max value for the last size range should be -1"
1410 " for option %qs", opt
);
1414 if (n
> MAX_STRINGOP_ALGS
)
1416 error ("too many size ranges specified in option %qs", opt
);
1420 /* Now override the default algs array. */
1421 for (i
= 0; i
< n
; i
++)
1423 *const_cast<int *>(&default_algs
->size
[i
].max
) = input_ranges
[i
].max
;
1424 *const_cast<stringop_alg
*>(&default_algs
->size
[i
].alg
)
1425 = input_ranges
[i
].alg
;
1426 *const_cast<int *>(&default_algs
->size
[i
].noalign
)
1427 = input_ranges
[i
].noalign
;
1432 /* parse -mtune-ctrl= option. When DUMP is true,
1433 print the features that are explicitly set. */
1436 parse_mtune_ctrl_str (bool dump
)
1438 if (!ix86_tune_ctrl_string
)
1441 char *next_feature_string
= NULL
;
1442 char *curr_feature_string
= xstrdup (ix86_tune_ctrl_string
);
1443 char *orig
= curr_feature_string
;
1449 next_feature_string
= strchr (curr_feature_string
, ',');
1450 if (next_feature_string
)
1451 *next_feature_string
++ = '\0';
1452 if (*curr_feature_string
== '^')
1454 curr_feature_string
++;
1457 for (i
= 0; i
< X86_TUNE_LAST
; i
++)
1459 if (!strcmp (curr_feature_string
, ix86_tune_feature_names
[i
]))
1461 ix86_tune_features
[i
] = !clear
;
1463 fprintf (stderr
, "Explicitly %s feature %s\n",
1464 clear
? "clear" : "set", ix86_tune_feature_names
[i
]);
1468 if (i
== X86_TUNE_LAST
)
1469 error ("unknown parameter to option %<-mtune-ctrl%>: %s",
1470 clear
? curr_feature_string
- 1 : curr_feature_string
);
1471 curr_feature_string
= next_feature_string
;
1473 while (curr_feature_string
);
1477 /* Helper function to set ix86_tune_features. IX86_TUNE is the
1481 set_ix86_tune_features (enum processor_type ix86_tune
, bool dump
)
1483 unsigned HOST_WIDE_INT ix86_tune_mask
= HOST_WIDE_INT_1U
<< ix86_tune
;
1486 for (i
= 0; i
< X86_TUNE_LAST
; ++i
)
1488 if (ix86_tune_no_default
)
1489 ix86_tune_features
[i
] = 0;
1491 ix86_tune_features
[i
]
1492 = !!(initial_ix86_tune_features
[i
] & ix86_tune_mask
);
1497 fprintf (stderr
, "List of x86 specific tuning parameter names:\n");
1498 for (i
= 0; i
< X86_TUNE_LAST
; i
++)
1499 fprintf (stderr
, "%s : %s\n", ix86_tune_feature_names
[i
],
1500 ix86_tune_features
[i
] ? "on" : "off");
1503 parse_mtune_ctrl_str (dump
);
1507 /* Default align_* from the processor table. */
1510 ix86_default_align (struct gcc_options
*opts
)
1512 /* -falign-foo without argument: supply one. */
1513 if (opts
->x_flag_align_loops
&& !opts
->x_str_align_loops
)
1514 opts
->x_str_align_loops
= processor_cost_table
[ix86_tune
]->align_loop
;
1515 if (opts
->x_flag_align_jumps
&& !opts
->x_str_align_jumps
)
1516 opts
->x_str_align_jumps
= processor_cost_table
[ix86_tune
]->align_jump
;
1517 if (opts
->x_flag_align_labels
&& !opts
->x_str_align_labels
)
1518 opts
->x_str_align_labels
= processor_cost_table
[ix86_tune
]->align_label
;
1519 if (opts
->x_flag_align_functions
&& !opts
->x_str_align_functions
)
1520 opts
->x_str_align_functions
= processor_cost_table
[ix86_tune
]->align_func
;
1523 /* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */
1526 ix86_override_options_after_change (void)
1528 ix86_default_align (&global_options
);
1531 /* Clear stack slot assignments remembered from previous functions.
1532 This is called from INIT_EXPANDERS once before RTL is emitted for each
1535 static struct machine_function
*
1536 ix86_init_machine_status (void)
1538 struct machine_function
*f
;
1540 f
= ggc_cleared_alloc
<machine_function
> ();
1541 f
->call_abi
= ix86_abi
;
1542 f
->stack_frame_required
= true;
1547 /* Override various settings based on options. If MAIN_ARGS_P, the
1548 options are from the command line, otherwise they are from
1549 attributes. Return true if there's an error related to march
1553 ix86_option_override_internal (bool main_args_p
,
1554 struct gcc_options
*opts
,
1555 struct gcc_options
*opts_set
)
1558 unsigned HOST_WIDE_INT ix86_arch_mask
;
1559 const bool ix86_tune_specified
= (opts
->x_ix86_tune_string
!= NULL
);
1561 /* -mrecip options. */
1564 const char *string
; /* option name */
1565 unsigned int mask
; /* mask bits to set */
1567 const recip_options
[] =
1569 { "all", RECIP_MASK_ALL
},
1570 { "none", RECIP_MASK_NONE
},
1571 { "div", RECIP_MASK_DIV
},
1572 { "sqrt", RECIP_MASK_SQRT
},
1573 { "vec-div", RECIP_MASK_VEC_DIV
},
1574 { "vec-sqrt", RECIP_MASK_VEC_SQRT
},
1578 /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
1579 TARGET_64BIT_DEFAULT is true and TARGET_64BIT is false. */
1580 if (TARGET_64BIT_DEFAULT
&& !TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1581 opts
->x_ix86_isa_flags
&= ~(OPTION_MASK_ABI_64
| OPTION_MASK_ABI_X32
);
1582 #ifdef TARGET_BI_ARCH
1585 #if TARGET_BI_ARCH == 1
1586 /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ABI_64
1587 is on and OPTION_MASK_ABI_X32 is off. We turn off
1588 OPTION_MASK_ABI_64 if OPTION_MASK_ABI_X32 is turned on by
1590 if (TARGET_X32_P (opts
->x_ix86_isa_flags
))
1591 opts
->x_ix86_isa_flags
&= ~OPTION_MASK_ABI_64
;
1593 /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
1594 on and OPTION_MASK_ABI_64 is off. We turn off
1595 OPTION_MASK_ABI_X32 if OPTION_MASK_ABI_64 is turned on by
1596 -m64 or OPTION_MASK_CODE16 is turned on by -m16. */
1597 if (TARGET_LP64_P (opts
->x_ix86_isa_flags
)
1598 || TARGET_16BIT_P (opts
->x_ix86_isa_flags
))
1599 opts
->x_ix86_isa_flags
&= ~OPTION_MASK_ABI_X32
;
1601 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
1602 && TARGET_IAMCU_P (opts
->x_target_flags
))
1603 sorry ("Intel MCU psABI isn%'t supported in %s mode",
1604 TARGET_X32_P (opts
->x_ix86_isa_flags
) ? "x32" : "64-bit");
1608 if (TARGET_X32_P (opts
->x_ix86_isa_flags
))
1610 /* Always turn on OPTION_MASK_ISA_64BIT and turn off
1611 OPTION_MASK_ABI_64 for TARGET_X32. */
1612 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_64BIT
;
1613 opts
->x_ix86_isa_flags
&= ~OPTION_MASK_ABI_64
;
1615 else if (TARGET_16BIT_P (opts
->x_ix86_isa_flags
))
1616 opts
->x_ix86_isa_flags
&= ~(OPTION_MASK_ISA_64BIT
1617 | OPTION_MASK_ABI_X32
1618 | OPTION_MASK_ABI_64
);
1619 else if (TARGET_LP64_P (opts
->x_ix86_isa_flags
))
1621 /* Always turn on OPTION_MASK_ISA_64BIT and turn off
1622 OPTION_MASK_ABI_X32 for TARGET_LP64. */
1623 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_64BIT
;
1624 opts
->x_ix86_isa_flags
&= ~OPTION_MASK_ABI_X32
;
1627 #ifdef SUBTARGET_OVERRIDE_OPTIONS
1628 SUBTARGET_OVERRIDE_OPTIONS
;
1631 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
1632 SUBSUBTARGET_OVERRIDE_OPTIONS
;
1635 /* -fPIC is the default for x86_64. */
1636 if (TARGET_MACHO
&& TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1637 opts
->x_flag_pic
= 2;
1639 /* Need to check -mtune=generic first. */
1640 if (opts
->x_ix86_tune_string
)
1642 /* As special support for cross compilers we read -mtune=native
1643 as -mtune=generic. With native compilers we won't see the
1644 -mtune=native, as it was changed by the driver. */
1645 if (!strcmp (opts
->x_ix86_tune_string
, "native"))
1647 opts
->x_ix86_tune_string
= "generic";
1649 else if (!strcmp (opts
->x_ix86_tune_string
, "x86-64"))
1650 warning (OPT_Wdeprecated
,
1652 ? G_("%<-mtune=x86-64%> is deprecated; use %<-mtune=k8%> "
1653 "or %<-mtune=generic%> instead as appropriate")
1654 : G_("%<target(\"tune=x86-64\")%> is deprecated; use "
1655 "%<target(\"tune=k8\")%> or %<target(\"tune=generic\")%>"
1656 " instead as appropriate"));
1660 if (opts
->x_ix86_arch_string
)
1661 opts
->x_ix86_tune_string
= opts
->x_ix86_arch_string
;
1662 if (!opts
->x_ix86_tune_string
)
1664 opts
->x_ix86_tune_string
= processor_names
[TARGET_CPU_DEFAULT
];
1665 ix86_tune_defaulted
= 1;
1668 /* opts->x_ix86_tune_string is set to opts->x_ix86_arch_string
1669 or defaulted. We need to use a sensible tune option. */
1670 if (!strcmp (opts
->x_ix86_tune_string
, "x86-64"))
1672 opts
->x_ix86_tune_string
= "generic";
1676 if (opts
->x_ix86_stringop_alg
== rep_prefix_8_byte
1677 && !TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1679 /* rep; movq isn't available in 32-bit code. */
1680 error ("%<-mstringop-strategy=rep_8byte%> not supported for 32-bit code");
1681 opts
->x_ix86_stringop_alg
= no_stringop
;
1684 if (!opts
->x_ix86_arch_string
)
1685 opts
->x_ix86_arch_string
1686 = TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
1687 ? "x86-64" : SUBTARGET32_DEFAULT_CPU
;
1689 ix86_arch_specified
= 1;
1691 if (opts_set
->x_ix86_pmode
)
1693 if ((TARGET_LP64_P (opts
->x_ix86_isa_flags
)
1694 && opts
->x_ix86_pmode
== PMODE_SI
)
1695 || (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
1696 && opts
->x_ix86_pmode
== PMODE_DI
))
1697 error ("address mode %qs not supported in the %s bit mode",
1698 TARGET_64BIT_P (opts
->x_ix86_isa_flags
) ? "short" : "long",
1699 TARGET_64BIT_P (opts
->x_ix86_isa_flags
) ? "64" : "32");
1702 opts
->x_ix86_pmode
= TARGET_LP64_P (opts
->x_ix86_isa_flags
)
1703 ? PMODE_DI
: PMODE_SI
;
1705 if (!opts_set
->x_ix86_abi
)
1706 opts
->x_ix86_abi
= DEFAULT_ABI
;
1708 if (opts
->x_ix86_abi
== MS_ABI
&& TARGET_X32_P (opts
->x_ix86_isa_flags
))
1709 error ("%<-mabi=ms%> not supported with X32 ABI");
1710 gcc_assert (opts
->x_ix86_abi
== SYSV_ABI
|| opts
->x_ix86_abi
== MS_ABI
);
1712 const char *abi_name
= opts
->x_ix86_abi
== MS_ABI
? "ms" : "sysv";
1713 if ((opts
->x_flag_sanitize
& SANITIZE_USER_ADDRESS
)
1714 && opts
->x_ix86_abi
!= DEFAULT_ABI
)
1715 error ("%<-mabi=%s%> not supported with %<-fsanitize=address%>", abi_name
);
1716 if ((opts
->x_flag_sanitize
& SANITIZE_KERNEL_ADDRESS
)
1717 && opts
->x_ix86_abi
!= DEFAULT_ABI
)
1718 error ("%<-mabi=%s%> not supported with %<-fsanitize=kernel-address%>",
1720 if ((opts
->x_flag_sanitize
& SANITIZE_THREAD
)
1721 && opts
->x_ix86_abi
!= DEFAULT_ABI
)
1722 error ("%<-mabi=%s%> not supported with %<-fsanitize=thread%>", abi_name
);
1724 /* For targets using ms ABI enable ms-extensions, if not
1725 explicit turned off. For non-ms ABI we turn off this
1727 if (!opts_set
->x_flag_ms_extensions
)
1728 opts
->x_flag_ms_extensions
= (MS_ABI
== DEFAULT_ABI
);
1730 if (opts_set
->x_ix86_cmodel
)
1732 switch (opts
->x_ix86_cmodel
)
1736 if (opts
->x_flag_pic
)
1737 opts
->x_ix86_cmodel
= CM_SMALL_PIC
;
1738 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1739 error ("code model %qs not supported in the %s bit mode",
1745 if (opts
->x_flag_pic
)
1746 opts
->x_ix86_cmodel
= CM_MEDIUM_PIC
;
1747 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1748 error ("code model %qs not supported in the %s bit mode",
1750 else if (TARGET_X32_P (opts
->x_ix86_isa_flags
))
1751 error ("code model %qs not supported in x32 mode",
1757 if (opts
->x_flag_pic
)
1758 opts
->x_ix86_cmodel
= CM_LARGE_PIC
;
1759 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1760 error ("code model %qs not supported in the %s bit mode",
1762 else if (TARGET_X32_P (opts
->x_ix86_isa_flags
))
1763 error ("code model %qs not supported in x32 mode",
1768 if (opts
->x_flag_pic
)
1769 error ("code model %s does not support PIC mode", "32");
1770 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1771 error ("code model %qs not supported in the %s bit mode",
1776 if (opts
->x_flag_pic
)
1778 error ("code model %s does not support PIC mode", "kernel");
1779 opts
->x_ix86_cmodel
= CM_32
;
1781 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1782 error ("code model %qs not supported in the %s bit mode",
1792 /* For TARGET_64BIT and MS_ABI, force pic on, in order to enable the
1793 use of rip-relative addressing. This eliminates fixups that
1794 would otherwise be needed if this object is to be placed in a
1795 DLL, and is essentially just as efficient as direct addressing. */
1796 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
1797 && (TARGET_RDOS
|| TARGET_PECOFF
))
1798 opts
->x_ix86_cmodel
= CM_MEDIUM_PIC
, opts
->x_flag_pic
= 1;
1799 else if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1800 opts
->x_ix86_cmodel
= opts
->x_flag_pic
? CM_SMALL_PIC
: CM_SMALL
;
1802 opts
->x_ix86_cmodel
= CM_32
;
1804 if (TARGET_MACHO
&& opts
->x_ix86_asm_dialect
== ASM_INTEL
)
1806 error ("%<-masm=intel%> not supported in this configuration");
1807 opts
->x_ix86_asm_dialect
= ASM_ATT
;
1809 if ((TARGET_64BIT_P (opts
->x_ix86_isa_flags
) != 0)
1810 != ((opts
->x_ix86_isa_flags
& OPTION_MASK_ISA_64BIT
) != 0))
1811 sorry ("%i-bit mode not compiled in",
1812 (opts
->x_ix86_isa_flags
& OPTION_MASK_ISA_64BIT
) ? 64 : 32);
1814 for (i
= 0; i
< pta_size
; i
++)
1815 if (! strcmp (opts
->x_ix86_arch_string
, processor_alias_table
[i
].name
))
1817 if (!strcmp (opts
->x_ix86_arch_string
, "generic"))
1820 ? G_("%<generic%> CPU can be used only for %<-mtune=%> "
1822 : G_("%<generic%> CPU can be used only for "
1823 "%<target(\"tune=\")%> attribute"));
1826 else if (!strcmp (opts
->x_ix86_arch_string
, "intel"))
1829 ? G_("%<intel%> CPU can be used only for %<-mtune=%> "
1831 : G_("%<intel%> CPU can be used only for "
1832 "%<target(\"tune=\")%> attribute"));
1836 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
1837 && !((processor_alias_table
[i
].flags
& PTA_64BIT
) != 0))
1839 error ("CPU you selected does not support x86-64 "
1844 ix86_schedule
= processor_alias_table
[i
].schedule
;
1845 ix86_arch
= processor_alias_table
[i
].processor
;
1846 /* Default cpu tuning to the architecture. */
1847 ix86_tune
= ix86_arch
;
1849 if (((processor_alias_table
[i
].flags
& PTA_MMX
) != 0)
1850 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_MMX
))
1851 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_MMX
;
1852 if (((processor_alias_table
[i
].flags
& PTA_3DNOW
) != 0)
1853 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_3DNOW
))
1854 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_3DNOW
;
1855 if (((processor_alias_table
[i
].flags
& PTA_3DNOW_A
) != 0)
1856 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_3DNOW_A
))
1857 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_3DNOW_A
;
1858 if (((processor_alias_table
[i
].flags
& PTA_SSE
) != 0)
1859 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_SSE
))
1860 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_SSE
;
1861 if (((processor_alias_table
[i
].flags
& PTA_SSE2
) != 0)
1862 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_SSE2
))
1863 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_SSE2
;
1864 if (((processor_alias_table
[i
].flags
& PTA_SSE3
) != 0)
1865 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_SSE3
))
1866 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_SSE3
;
1867 if (((processor_alias_table
[i
].flags
& PTA_SSSE3
) != 0)
1868 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_SSSE3
))
1869 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_SSSE3
;
1870 if (((processor_alias_table
[i
].flags
& PTA_SSE4_1
) != 0)
1871 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_SSE4_1
))
1872 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_SSE4_1
;
1873 if (((processor_alias_table
[i
].flags
& PTA_SSE4_2
) != 0)
1874 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_SSE4_2
))
1875 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_SSE4_2
;
1876 if (((processor_alias_table
[i
].flags
& PTA_AVX
) != 0)
1877 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX
))
1878 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX
;
1879 if (((processor_alias_table
[i
].flags
& PTA_AVX2
) != 0)
1880 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX2
))
1881 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX2
;
1882 if (((processor_alias_table
[i
].flags
& PTA_FMA
) != 0)
1883 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_FMA
))
1884 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_FMA
;
1885 if (((processor_alias_table
[i
].flags
& PTA_SSE4A
) != 0)
1886 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_SSE4A
))
1887 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_SSE4A
;
1888 if (((processor_alias_table
[i
].flags
& PTA_FMA4
) != 0)
1889 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_FMA4
))
1890 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_FMA4
;
1891 if (((processor_alias_table
[i
].flags
& PTA_XOP
) != 0)
1892 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_XOP
))
1893 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_XOP
;
1894 if (((processor_alias_table
[i
].flags
& PTA_LWP
) != 0)
1895 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_LWP
))
1896 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_LWP
;
1897 if (((processor_alias_table
[i
].flags
& PTA_ABM
) != 0)
1898 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_ABM
))
1899 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_ABM
;
1900 if (((processor_alias_table
[i
].flags
& PTA_BMI
) != 0)
1901 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_BMI
))
1902 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_BMI
;
1903 if (((processor_alias_table
[i
].flags
& (PTA_LZCNT
| PTA_ABM
)) != 0)
1904 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_LZCNT
))
1905 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_LZCNT
;
1906 if (((processor_alias_table
[i
].flags
& PTA_TBM
) != 0)
1907 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_TBM
))
1908 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_TBM
;
1909 if (((processor_alias_table
[i
].flags
& PTA_BMI2
) != 0)
1910 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_BMI2
))
1911 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_BMI2
;
1912 if (((processor_alias_table
[i
].flags
& PTA_CX16
) != 0)
1913 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_CX16
))
1914 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_CX16
;
1915 if (((processor_alias_table
[i
].flags
& (PTA_POPCNT
| PTA_ABM
)) != 0)
1916 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_POPCNT
))
1917 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_POPCNT
;
1918 if (!(TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
1919 && ((processor_alias_table
[i
].flags
& PTA_NO_SAHF
) != 0))
1920 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_SAHF
))
1921 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_SAHF
;
1922 if (((processor_alias_table
[i
].flags
& PTA_MOVBE
) != 0)
1923 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_MOVBE
))
1924 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_MOVBE
;
1925 if (((processor_alias_table
[i
].flags
& PTA_AES
) != 0)
1926 && !(ix86_isa_flags_explicit
& OPTION_MASK_ISA_AES
))
1927 ix86_isa_flags
|= OPTION_MASK_ISA_AES
;
1928 if (((processor_alias_table
[i
].flags
& PTA_SHA
) != 0)
1929 && !(ix86_isa_flags_explicit
& OPTION_MASK_ISA_SHA
))
1930 ix86_isa_flags
|= OPTION_MASK_ISA_SHA
;
1931 if (((processor_alias_table
[i
].flags
& PTA_PCLMUL
) != 0)
1932 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_PCLMUL
))
1933 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_PCLMUL
;
1934 if (((processor_alias_table
[i
].flags
& PTA_FSGSBASE
) != 0)
1935 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_FSGSBASE
))
1936 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_FSGSBASE
;
1937 if (((processor_alias_table
[i
].flags
& PTA_RDRND
) != 0)
1938 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_RDRND
))
1939 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_RDRND
;
1940 if (((processor_alias_table
[i
].flags
& PTA_F16C
) != 0)
1941 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_F16C
))
1942 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_F16C
;
1943 if (((processor_alias_table
[i
].flags
& PTA_RTM
) != 0)
1944 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_RTM
))
1945 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_RTM
;
1946 if (((processor_alias_table
[i
].flags
& PTA_HLE
) != 0)
1947 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_HLE
))
1948 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_HLE
;
1949 if (((processor_alias_table
[i
].flags
& PTA_PRFCHW
) != 0)
1950 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_PRFCHW
))
1951 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_PRFCHW
;
1952 if (((processor_alias_table
[i
].flags
& PTA_RDSEED
) != 0)
1953 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_RDSEED
))
1954 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_RDSEED
;
1955 if (((processor_alias_table
[i
].flags
& PTA_ADX
) != 0)
1956 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_ADX
))
1957 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_ADX
;
1958 if (((processor_alias_table
[i
].flags
& PTA_FXSR
) != 0)
1959 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_FXSR
))
1960 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_FXSR
;
1961 if (((processor_alias_table
[i
].flags
& PTA_XSAVE
) != 0)
1962 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_XSAVE
))
1963 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_XSAVE
;
1964 if (((processor_alias_table
[i
].flags
& PTA_XSAVEOPT
) != 0)
1965 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_XSAVEOPT
))
1966 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_XSAVEOPT
;
1967 if (((processor_alias_table
[i
].flags
& PTA_AVX512F
) != 0)
1968 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512F
))
1969 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512F
;
1970 if (((processor_alias_table
[i
].flags
& PTA_AVX512ER
) != 0)
1971 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512ER
))
1972 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512ER
;
1973 if (((processor_alias_table
[i
].flags
& PTA_AVX512PF
) != 0)
1974 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512PF
))
1975 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512PF
;
1976 if (((processor_alias_table
[i
].flags
& PTA_AVX512CD
) != 0)
1977 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512CD
))
1978 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512CD
;
1979 if (((processor_alias_table
[i
].flags
& PTA_PREFETCHWT1
) != 0)
1980 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_PREFETCHWT1
))
1981 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_PREFETCHWT1
;
1982 if (((processor_alias_table
[i
].flags
& PTA_CLWB
) != 0)
1983 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_CLWB
))
1984 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_CLWB
;
1985 if (((processor_alias_table
[i
].flags
& PTA_CLFLUSHOPT
) != 0)
1986 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_CLFLUSHOPT
))
1987 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_CLFLUSHOPT
;
1988 if (((processor_alias_table
[i
].flags
& PTA_CLZERO
) != 0)
1989 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_CLZERO
))
1990 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_CLZERO
;
1991 if (((processor_alias_table
[i
].flags
& PTA_XSAVEC
) != 0)
1992 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_XSAVEC
))
1993 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_XSAVEC
;
1994 if (((processor_alias_table
[i
].flags
& PTA_XSAVES
) != 0)
1995 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_XSAVES
))
1996 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_XSAVES
;
1997 if (((processor_alias_table
[i
].flags
& PTA_AVX512DQ
) != 0)
1998 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512DQ
))
1999 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512DQ
;
2000 if (((processor_alias_table
[i
].flags
& PTA_AVX512BW
) != 0)
2001 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512BW
))
2002 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512BW
;
2003 if (((processor_alias_table
[i
].flags
& PTA_AVX512VL
) != 0)
2004 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512VL
))
2005 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512VL
;
2006 if (((processor_alias_table
[i
].flags
& PTA_AVX512VBMI
) != 0)
2007 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512VBMI
))
2008 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512VBMI
;
2009 if (((processor_alias_table
[i
].flags
& PTA_AVX512IFMA
) != 0)
2010 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512IFMA
))
2011 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512IFMA
;
2012 if (((processor_alias_table
[i
].flags
& PTA_AVX512VNNI
) != 0)
2013 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_AVX512VNNI
))
2014 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512VNNI
;
2015 if (((processor_alias_table
[i
].flags
& PTA_GFNI
) != 0)
2016 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_GFNI
))
2017 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_GFNI
;
2018 if (((processor_alias_table
[i
].flags
& PTA_AVX512VBMI2
) != 0)
2019 && !(opts
->x_ix86_isa_flags_explicit
2020 & OPTION_MASK_ISA_AVX512VBMI2
))
2021 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512VBMI2
;
2022 if (((processor_alias_table
[i
].flags
& PTA_VPCLMULQDQ
) != 0)
2023 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_VPCLMULQDQ
))
2024 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_VPCLMULQDQ
;
2025 if (((processor_alias_table
[i
].flags
& PTA_AVX512BITALG
) != 0)
2026 && !(opts
->x_ix86_isa_flags_explicit
2027 & OPTION_MASK_ISA_AVX512BITALG
))
2028 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512BITALG
;
2030 if (((processor_alias_table
[i
].flags
& PTA_AVX5124VNNIW
) != 0)
2031 && !(opts
->x_ix86_isa_flags2_explicit
2032 & OPTION_MASK_ISA_AVX5124VNNIW
))
2033 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_AVX5124VNNIW
;
2034 if (((processor_alias_table
[i
].flags
& PTA_AVX5124FMAPS
) != 0)
2035 && !(opts
->x_ix86_isa_flags2_explicit
2036 & OPTION_MASK_ISA_AVX5124FMAPS
))
2037 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_AVX5124FMAPS
;
2038 if (((processor_alias_table
[i
].flags
& PTA_AVX512VPOPCNTDQ
) != 0)
2039 && !(opts
->x_ix86_isa_flags_explicit
2040 & OPTION_MASK_ISA_AVX512VPOPCNTDQ
))
2041 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_AVX512VPOPCNTDQ
;
2042 if (((processor_alias_table
[i
].flags
& PTA_AVX512BF16
) != 0)
2043 && !(opts
->x_ix86_isa_flags2_explicit
2044 & OPTION_MASK_ISA_AVX512BF16
))
2045 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_AVX512BF16
;
2046 if (((processor_alias_table
[i
].flags
& PTA_SGX
) != 0)
2047 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_SGX
))
2048 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_SGX
;
2049 if (((processor_alias_table
[i
].flags
& PTA_VAES
) != 0)
2050 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_VAES
))
2051 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_VAES
;
2052 if (((processor_alias_table
[i
].flags
& PTA_RDPID
) != 0)
2053 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_RDPID
))
2054 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_RDPID
;
2055 if (((processor_alias_table
[i
].flags
& PTA_PCONFIG
) != 0)
2056 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_PCONFIG
))
2057 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_PCONFIG
;
2058 if (((processor_alias_table
[i
].flags
& PTA_WBNOINVD
) != 0)
2059 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_WBNOINVD
))
2060 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_WBNOINVD
;
2061 if (((processor_alias_table
[i
].flags
& PTA_PTWRITE
) != 0)
2062 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_PTWRITE
))
2063 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_PTWRITE
;
2065 if ((processor_alias_table
[i
].flags
2066 & (PTA_PREFETCH_SSE
| PTA_SSE
)) != 0)
2067 x86_prefetch_sse
= true;
2068 if (((processor_alias_table
[i
].flags
& PTA_MWAITX
) != 0)
2069 && !(opts
->x_ix86_isa_flags2_explicit
& OPTION_MASK_ISA_MWAITX
))
2070 opts
->x_ix86_isa_flags2
|= OPTION_MASK_ISA_MWAITX
;
2071 if (((processor_alias_table
[i
].flags
& PTA_PKU
) != 0)
2072 && !(opts
->x_ix86_isa_flags_explicit
& OPTION_MASK_ISA_PKU
))
2073 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_PKU
;
2075 /* Don't enable x87 instructions if only
2076 general registers are allowed. */
2077 if (!(opts_set
->x_ix86_target_flags
& OPTION_MASK_GENERAL_REGS_ONLY
)
2078 && !(opts_set
->x_target_flags
& MASK_80387
))
2080 if (((processor_alias_table
[i
].flags
& PTA_NO_80387
) != 0))
2081 opts
->x_target_flags
&= ~MASK_80387
;
2083 opts
->x_target_flags
|= MASK_80387
;
2091 ? G_("bad value (%qs) for %<-march=%> switch")
2092 : G_("bad value (%qs) for %<target(\"arch=\")%> attribute"),
2093 opts
->x_ix86_arch_string
);
2095 auto_vec
<const char *> candidates
;
2096 for (i
= 0; i
< pta_size
; i
++)
2097 if (strcmp (processor_alias_table
[i
].name
, "generic")
2098 && strcmp (processor_alias_table
[i
].name
, "intel")
2099 && (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
2100 || ((processor_alias_table
[i
].flags
& PTA_64BIT
) != 0)))
2101 candidates
.safe_push (processor_alias_table
[i
].name
);
2103 #ifdef HAVE_LOCAL_CPU_DETECT
2104 /* Add also "native" as possible value. */
2105 candidates
.safe_push ("native");
2110 = candidates_list_and_hint (opts
->x_ix86_arch_string
, s
, candidates
);
2112 inform (input_location
,
2114 ? G_("valid arguments to %<-march=%> switch are: "
2115 "%s; did you mean %qs?")
2116 : G_("valid arguments to %<target(\"arch=\")%> attribute are: "
2117 "%s; did you mean %qs?"), s
, hint
);
2119 inform (input_location
,
2121 ? G_("valid arguments to %<-march=%> switch are: %s")
2122 : G_("valid arguments to %<target(\"arch=\")%> attribute "
2127 ix86_arch_mask
= HOST_WIDE_INT_1U
<< ix86_arch
;
2128 for (i
= 0; i
< X86_ARCH_LAST
; ++i
)
2129 ix86_arch_features
[i
] = !!(initial_ix86_arch_features
[i
] & ix86_arch_mask
);
2131 for (i
= 0; i
< pta_size
; i
++)
2132 if (! strcmp (opts
->x_ix86_tune_string
, processor_alias_table
[i
].name
))
2134 ix86_schedule
= processor_alias_table
[i
].schedule
;
2135 ix86_tune
= processor_alias_table
[i
].processor
;
2136 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2138 if (!((processor_alias_table
[i
].flags
& PTA_64BIT
) != 0))
2140 if (ix86_tune_defaulted
)
2142 opts
->x_ix86_tune_string
= "x86-64";
2143 for (i
= 0; i
< pta_size
; i
++)
2144 if (! strcmp (opts
->x_ix86_tune_string
,
2145 processor_alias_table
[i
].name
))
2147 ix86_schedule
= processor_alias_table
[i
].schedule
;
2148 ix86_tune
= processor_alias_table
[i
].processor
;
2151 error ("CPU you selected does not support x86-64 "
2155 /* Intel CPUs have always interpreted SSE prefetch instructions as
2156 NOPs; so, we can enable SSE prefetch instructions even when
2157 -mtune (rather than -march) points us to a processor that has them.
2158 However, the VIA C3 gives a SIGILL, so we only do that for i686 and
2159 higher processors. */
2161 && ((processor_alias_table
[i
].flags
2162 & (PTA_PREFETCH_SSE
| PTA_SSE
)) != 0))
2163 x86_prefetch_sse
= true;
2167 if (ix86_tune_specified
&& i
== pta_size
)
2170 ? G_("bad value (%qs) for %<-mtune=%> switch")
2171 : G_("bad value (%qs) for %<target(\"tune=\")%> attribute"),
2172 opts
->x_ix86_tune_string
);
2174 auto_vec
<const char *> candidates
;
2175 for (i
= 0; i
< pta_size
; i
++)
2176 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
2177 || ((processor_alias_table
[i
].flags
& PTA_64BIT
) != 0))
2178 candidates
.safe_push (processor_alias_table
[i
].name
);
2180 #ifdef HAVE_LOCAL_CPU_DETECT
2181 /* Add also "native" as possible value. */
2182 candidates
.safe_push ("native");
2187 = candidates_list_and_hint (opts
->x_ix86_tune_string
, s
, candidates
);
2189 inform (input_location
,
2191 ? G_("valid arguments to %<-mtune=%> switch are: "
2192 "%s; did you mean %qs?")
2193 : G_("valid arguments to %<target(\"tune=\")%> attribute are: "
2194 "%s; did you mean %qs?"), s
, hint
);
2196 inform (input_location
,
2198 ? G_("valid arguments to %<-mtune=%> switch are: %s")
2199 : G_("valid arguments to %<target(\"tune=\")%> attribute "
2204 set_ix86_tune_features (ix86_tune
, opts
->x_ix86_dump_tunes
);
2206 #ifndef USE_IX86_FRAME_POINTER
2207 #define USE_IX86_FRAME_POINTER 0
2210 /* Set the default values for switches whose default depends on TARGET_64BIT
2211 in case they weren't overwritten by command line options. */
2212 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2214 if (opts
->x_optimize
>= 1 && !opts_set
->x_flag_omit_frame_pointer
)
2215 opts
->x_flag_omit_frame_pointer
= !USE_IX86_FRAME_POINTER
;
2216 if (opts
->x_flag_asynchronous_unwind_tables
2217 && !opts_set
->x_flag_unwind_tables
2218 && TARGET_64BIT_MS_ABI
)
2219 opts
->x_flag_unwind_tables
= 1;
2220 if (opts
->x_flag_asynchronous_unwind_tables
== 2)
2221 opts
->x_flag_unwind_tables
2222 = opts
->x_flag_asynchronous_unwind_tables
= 1;
2223 if (opts
->x_flag_pcc_struct_return
== 2)
2224 opts
->x_flag_pcc_struct_return
= 0;
2228 if (opts
->x_optimize
>= 1 && !opts_set
->x_flag_omit_frame_pointer
)
2229 opts
->x_flag_omit_frame_pointer
2230 = !(USE_IX86_FRAME_POINTER
|| opts
->x_optimize_size
);
2231 if (opts
->x_flag_asynchronous_unwind_tables
== 2)
2232 opts
->x_flag_asynchronous_unwind_tables
= !USE_IX86_FRAME_POINTER
;
2233 if (opts
->x_flag_pcc_struct_return
== 2)
2235 /* Intel MCU psABI specifies that -freg-struct-return should
2236 be on. Instead of setting DEFAULT_PCC_STRUCT_RETURN to 1,
2237 we check -miamcu so that -freg-struct-return is always
2238 turned on if -miamcu is used. */
2239 if (TARGET_IAMCU_P (opts
->x_target_flags
))
2240 opts
->x_flag_pcc_struct_return
= 0;
2242 opts
->x_flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
2246 ix86_tune_cost
= processor_cost_table
[ix86_tune
];
2247 /* TODO: ix86_cost should be chosen at instruction or function granuality
2248 so for cold code we use size_cost even in !optimize_size compilation. */
2249 if (opts
->x_optimize_size
)
2250 ix86_cost
= &ix86_size_cost
;
2252 ix86_cost
= ix86_tune_cost
;
2254 /* Arrange to set up i386_stack_locals for all functions. */
2255 init_machine_status
= ix86_init_machine_status
;
2257 /* Validate -mregparm= value. */
2258 if (opts_set
->x_ix86_regparm
)
2260 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2261 warning (0, "%<-mregparm%> is ignored in 64-bit mode");
2262 else if (TARGET_IAMCU_P (opts
->x_target_flags
))
2263 warning (0, "%<-mregparm%> is ignored for Intel MCU psABI");
2264 if (opts
->x_ix86_regparm
> REGPARM_MAX
)
2266 error ("%<-mregparm=%d%> is not between 0 and %d",
2267 opts
->x_ix86_regparm
, REGPARM_MAX
);
2268 opts
->x_ix86_regparm
= 0;
2271 if (TARGET_IAMCU_P (opts
->x_target_flags
)
2272 || TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2273 opts
->x_ix86_regparm
= REGPARM_MAX
;
2275 /* Default align_* from the processor table. */
2276 ix86_default_align (opts
);
2278 /* Provide default for -mbranch-cost= value. */
2279 if (!opts_set
->x_ix86_branch_cost
)
2280 opts
->x_ix86_branch_cost
= ix86_tune_cost
->branch_cost
;
2282 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2284 opts
->x_target_flags
2285 |= TARGET_SUBTARGET64_DEFAULT
& ~opts_set
->x_target_flags
;
2287 if (!ix86_arch_specified
)
2288 opts
->x_ix86_isa_flags
2289 |= TARGET_SUBTARGET64_ISA_DEFAULT
& ~opts
->x_ix86_isa_flags_explicit
;
2291 if (TARGET_RTD_P (opts
->x_target_flags
))
2294 ? G_("%<-mrtd%> is ignored in 64bit mode")
2295 : G_("%<target(\"rtd\")%> is ignored in 64bit mode"));
2299 opts
->x_target_flags
2300 |= TARGET_SUBTARGET32_DEFAULT
& ~opts_set
->x_target_flags
;
2302 if (!ix86_arch_specified
)
2303 opts
->x_ix86_isa_flags
2304 |= TARGET_SUBTARGET32_ISA_DEFAULT
& ~opts
->x_ix86_isa_flags_explicit
;
2306 /* i386 ABI does not specify red zone. It still makes sense to use it
2307 when programmer takes care to stack from being destroyed. */
2308 if (!(opts_set
->x_target_flags
& MASK_NO_RED_ZONE
))
2309 opts
->x_target_flags
|= MASK_NO_RED_ZONE
;
2312 /* Keep nonleaf frame pointers. */
2313 if (opts
->x_flag_omit_frame_pointer
)
2314 opts
->x_target_flags
&= ~MASK_OMIT_LEAF_FRAME_POINTER
;
2315 else if (TARGET_OMIT_LEAF_FRAME_POINTER_P (opts
->x_target_flags
))
2316 opts
->x_flag_omit_frame_pointer
= 1;
2318 /* If we're doing fast math, we don't care about comparison order
2319 wrt NaNs. This lets us use a shorter comparison sequence. */
2320 if (opts
->x_flag_finite_math_only
)
2321 opts
->x_target_flags
&= ~MASK_IEEE_FP
;
2323 /* If the architecture always has an FPU, turn off NO_FANCY_MATH_387,
2324 since the insns won't need emulation. */
2325 if (ix86_tune_features
[X86_TUNE_ALWAYS_FANCY_MATH_387
])
2326 opts
->x_target_flags
&= ~MASK_NO_FANCY_MATH_387
;
2328 /* Likewise, if the target doesn't have a 387, or we've specified
2329 software floating point, don't use 387 inline intrinsics. */
2330 if (!TARGET_80387_P (opts
->x_target_flags
))
2331 opts
->x_target_flags
|= MASK_NO_FANCY_MATH_387
;
2333 /* Turn on MMX builtins for -msse. */
2334 if (TARGET_SSE_P (opts
->x_ix86_isa_flags
))
2335 opts
->x_ix86_isa_flags
2336 |= OPTION_MASK_ISA_MMX
& ~opts
->x_ix86_isa_flags_explicit
;
2338 /* Enable SSE prefetch. */
2339 if (TARGET_SSE_P (opts
->x_ix86_isa_flags
)
2340 || (TARGET_PRFCHW_P (opts
->x_ix86_isa_flags
)
2341 && !TARGET_3DNOW_P (opts
->x_ix86_isa_flags
))
2342 || TARGET_PREFETCHWT1_P (opts
->x_ix86_isa_flags
))
2343 x86_prefetch_sse
= true;
2345 /* Enable popcnt instruction for -msse4.2 or -mabm. */
2346 if (TARGET_SSE4_2_P (opts
->x_ix86_isa_flags
)
2347 || TARGET_ABM_P (opts
->x_ix86_isa_flags
))
2348 opts
->x_ix86_isa_flags
2349 |= OPTION_MASK_ISA_POPCNT
& ~opts
->x_ix86_isa_flags_explicit
;
2351 /* Enable lzcnt instruction for -mabm. */
2352 if (TARGET_ABM_P(opts
->x_ix86_isa_flags
))
2353 opts
->x_ix86_isa_flags
2354 |= OPTION_MASK_ISA_LZCNT
& ~opts
->x_ix86_isa_flags_explicit
;
2356 /* Disable BMI, BMI2 and TBM instructions for -m16. */
2357 if (TARGET_16BIT_P(opts
->x_ix86_isa_flags
))
2358 opts
->x_ix86_isa_flags
2359 &= ~((OPTION_MASK_ISA_BMI
| OPTION_MASK_ISA_BMI2
| OPTION_MASK_ISA_TBM
)
2360 & ~opts
->x_ix86_isa_flags_explicit
);
2362 /* Validate -mpreferred-stack-boundary= value or default it to
2363 PREFERRED_STACK_BOUNDARY_DEFAULT. */
2364 ix86_preferred_stack_boundary
= PREFERRED_STACK_BOUNDARY_DEFAULT
;
2365 if (opts_set
->x_ix86_preferred_stack_boundary_arg
)
2367 int min
= TARGET_64BIT_P (opts
->x_ix86_isa_flags
)? 3 : 2;
2368 int max
= TARGET_SEH
? 4 : 12;
2370 if (opts
->x_ix86_preferred_stack_boundary_arg
< min
2371 || opts
->x_ix86_preferred_stack_boundary_arg
> max
)
2374 error ("%<-mpreferred-stack-boundary%> is not supported "
2377 error ("%<-mpreferred-stack-boundary=%d%> is not between %d and %d",
2378 opts
->x_ix86_preferred_stack_boundary_arg
, min
, max
);
2381 ix86_preferred_stack_boundary
2382 = (1 << opts
->x_ix86_preferred_stack_boundary_arg
) * BITS_PER_UNIT
;
2385 /* Set the default value for -mstackrealign. */
2386 if (!opts_set
->x_ix86_force_align_arg_pointer
)
2387 opts
->x_ix86_force_align_arg_pointer
= STACK_REALIGN_DEFAULT
;
2389 ix86_default_incoming_stack_boundary
= PREFERRED_STACK_BOUNDARY
;
2391 /* Validate -mincoming-stack-boundary= value or default it to
2392 MIN_STACK_BOUNDARY/PREFERRED_STACK_BOUNDARY. */
2393 ix86_incoming_stack_boundary
= ix86_default_incoming_stack_boundary
;
2394 if (opts_set
->x_ix86_incoming_stack_boundary_arg
)
2396 int min
= TARGET_64BIT_P (opts
->x_ix86_isa_flags
) ? 3 : 2;
2398 if (opts
->x_ix86_incoming_stack_boundary_arg
< min
2399 || opts
->x_ix86_incoming_stack_boundary_arg
> 12)
2400 error ("%<-mincoming-stack-boundary=%d%> is not between %d and 12",
2401 opts
->x_ix86_incoming_stack_boundary_arg
, min
);
2404 ix86_user_incoming_stack_boundary
2405 = (1 << opts
->x_ix86_incoming_stack_boundary_arg
) * BITS_PER_UNIT
;
2406 ix86_incoming_stack_boundary
2407 = ix86_user_incoming_stack_boundary
;
2411 #ifndef NO_PROFILE_COUNTERS
2412 if (flag_nop_mcount
)
2413 error ("%<-mnop-mcount%> is not compatible with this target");
2415 if (flag_nop_mcount
&& flag_pic
)
2416 error ("%<-mnop-mcount%> is not implemented for %<-fPIC%>");
2418 /* Accept -msseregparm only if at least SSE support is enabled. */
2419 if (TARGET_SSEREGPARM_P (opts
->x_target_flags
)
2420 && ! TARGET_SSE_P (opts
->x_ix86_isa_flags
))
2422 ? G_("%<-msseregparm%> used without SSE enabled")
2423 : G_("%<target(\"sseregparm\")%> used without SSE enabled"));
2425 if (opts_set
->x_ix86_fpmath
)
2427 if (opts
->x_ix86_fpmath
& FPMATH_SSE
)
2429 if (!TARGET_SSE_P (opts
->x_ix86_isa_flags
))
2431 if (TARGET_80387_P (opts
->x_target_flags
))
2433 warning (0, "SSE instruction set disabled, using 387 arithmetics");
2434 opts
->x_ix86_fpmath
= FPMATH_387
;
2437 else if ((opts
->x_ix86_fpmath
& FPMATH_387
)
2438 && !TARGET_80387_P (opts
->x_target_flags
))
2440 warning (0, "387 instruction set disabled, using SSE arithmetics");
2441 opts
->x_ix86_fpmath
= FPMATH_SSE
;
2445 /* For all chips supporting SSE2, -mfpmath=sse performs better than
2446 fpmath=387. The second is however default at many targets since the
2447 extra 80bit precision of temporaries is considered to be part of ABI.
2448 Overwrite the default at least for -ffast-math.
2449 TODO: -mfpmath=both seems to produce same performing code with bit
2450 smaller binaries. It is however not clear if register allocation is
2451 ready for this setting.
2452 Also -mfpmath=387 is overall a lot more compact (bout 4-5%) than SSE
2453 codegen. We may switch to 387 with -ffast-math for size optimized
2455 else if (fast_math_flags_set_p (&global_options
)
2456 && TARGET_SSE2_P (opts
->x_ix86_isa_flags
))
2457 opts
->x_ix86_fpmath
= FPMATH_SSE
;
2459 opts
->x_ix86_fpmath
= TARGET_FPMATH_DEFAULT_P (opts
->x_ix86_isa_flags
);
2461 /* Use external vectorized library in vectorizing intrinsics. */
2462 if (opts_set
->x_ix86_veclibabi_type
)
2463 switch (opts
->x_ix86_veclibabi_type
)
2465 case ix86_veclibabi_type_svml
:
2466 ix86_veclib_handler
= &ix86_veclibabi_svml
;
2469 case ix86_veclibabi_type_acml
:
2470 ix86_veclib_handler
= &ix86_veclibabi_acml
;
2477 if (ix86_tune_features
[X86_TUNE_ACCUMULATE_OUTGOING_ARGS
]
2478 && !(opts_set
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
))
2479 opts
->x_target_flags
|= MASK_ACCUMULATE_OUTGOING_ARGS
;
2481 /* If stack probes are required, the space used for large function
2482 arguments on the stack must also be probed, so enable
2483 -maccumulate-outgoing-args so this happens in the prologue. */
2484 if (TARGET_STACK_PROBE_P (opts
->x_target_flags
)
2485 && !(opts
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
))
2487 if (opts_set
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
)
2490 ? G_("stack probing requires %<-maccumulate-outgoing-args%> "
2492 : G_("stack probing requires "
2493 "%<target(\"accumulate-outgoing-args\")%> for "
2495 opts
->x_target_flags
|= MASK_ACCUMULATE_OUTGOING_ARGS
;
2498 /* Stack realignment without -maccumulate-outgoing-args requires %ebp,
2499 so enable -maccumulate-outgoing-args when %ebp is fixed. */
2500 if (fixed_regs
[BP_REG
]
2501 && !(opts
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
))
2503 if (opts_set
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
)
2506 ? G_("fixed ebp register requires "
2507 "%<-maccumulate-outgoing-args%>")
2508 : G_("fixed ebp register requires "
2509 "%<target(\"accumulate-outgoing-args\")%>"));
2510 opts
->x_target_flags
|= MASK_ACCUMULATE_OUTGOING_ARGS
;
2513 /* Figure out what ASM_GENERATE_INTERNAL_LABEL builds as a prefix. */
2516 ASM_GENERATE_INTERNAL_LABEL (internal_label_prefix
, "LX", 0);
2517 p
= strchr (internal_label_prefix
, 'X');
2518 internal_label_prefix_len
= p
- internal_label_prefix
;
2522 /* When scheduling description is not available, disable scheduler pass
2523 so it won't slow down the compilation and make x87 code slower. */
2524 if (!TARGET_SCHEDULE
)
2525 opts
->x_flag_schedule_insns_after_reload
= opts
->x_flag_schedule_insns
= 0;
2527 maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES
,
2528 ix86_tune_cost
->simultaneous_prefetches
,
2529 opts
->x_param_values
,
2530 opts_set
->x_param_values
);
2531 maybe_set_param_value (PARAM_L1_CACHE_LINE_SIZE
,
2532 ix86_tune_cost
->prefetch_block
,
2533 opts
->x_param_values
,
2534 opts_set
->x_param_values
);
2535 maybe_set_param_value (PARAM_L1_CACHE_SIZE
,
2536 ix86_tune_cost
->l1_cache_size
,
2537 opts
->x_param_values
,
2538 opts_set
->x_param_values
);
2539 maybe_set_param_value (PARAM_L2_CACHE_SIZE
,
2540 ix86_tune_cost
->l2_cache_size
,
2541 opts
->x_param_values
,
2542 opts_set
->x_param_values
);
2544 /* Enable sw prefetching at -O3 for CPUS that prefetching is helpful. */
2545 if (opts
->x_flag_prefetch_loop_arrays
< 0
2547 && (opts
->x_optimize
>= 3 || opts
->x_flag_profile_use
)
2548 && !opts
->x_optimize_size
2549 && TARGET_SOFTWARE_PREFETCHING_BENEFICIAL
)
2550 opts
->x_flag_prefetch_loop_arrays
= 1;
2552 /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
2553 can be opts->x_optimized to ap = __builtin_next_arg (0). */
2554 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
) && !opts
->x_flag_split_stack
)
2555 targetm
.expand_builtin_va_start
= NULL
;
2558 /* Use -mcld by default for 32-bit code if configured with --enable-cld. */
2559 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2560 opts
->x_target_flags
|= MASK_CLD
& ~opts_set
->x_target_flags
;
2563 /* Set the default value for -mfentry. */
2564 if (!opts_set
->x_flag_fentry
)
2565 opts
->x_flag_fentry
= TARGET_SEH
;
2568 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
) && opts
->x_flag_pic
2569 && opts
->x_flag_fentry
)
2570 sorry ("%<-mfentry%> isn%'t supported for 32-bit in combination "
2572 else if (TARGET_SEH
&& !opts
->x_flag_fentry
)
2573 sorry ("%<-mno-fentry%> isn%'t compatible with SEH");
2576 if (TARGET_SEH
&& TARGET_CALL_MS2SYSV_XLOGUES
)
2577 sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH");
2579 if (!(opts_set
->x_target_flags
& MASK_VZEROUPPER
)
2580 && TARGET_EMIT_VZEROUPPER
)
2581 opts
->x_target_flags
|= MASK_VZEROUPPER
;
2582 if (!(opts_set
->x_target_flags
& MASK_STV
))
2583 opts
->x_target_flags
|= MASK_STV
;
2584 /* Disable STV if -mpreferred-stack-boundary={2,3} or
2585 -mincoming-stack-boundary={2,3} or -mstackrealign - the needed
2586 stack realignment will be extra cost the pass doesn't take into
2587 account and the pass can't realign the stack. */
2588 if (ix86_preferred_stack_boundary
< 128
2589 || ix86_incoming_stack_boundary
< 128
2590 || opts
->x_ix86_force_align_arg_pointer
)
2591 opts
->x_target_flags
&= ~MASK_STV
;
2592 if (!ix86_tune_features
[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL
]
2593 && !(opts_set
->x_target_flags
& MASK_AVX256_SPLIT_UNALIGNED_LOAD
))
2594 opts
->x_target_flags
|= MASK_AVX256_SPLIT_UNALIGNED_LOAD
;
2595 if (!ix86_tune_features
[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL
]
2596 && !(opts_set
->x_target_flags
& MASK_AVX256_SPLIT_UNALIGNED_STORE
))
2597 opts
->x_target_flags
|= MASK_AVX256_SPLIT_UNALIGNED_STORE
;
2599 /* Enable 128-bit AVX instruction generation
2600 for the auto-vectorizer. */
2601 if (TARGET_AVX128_OPTIMAL
2602 && (opts_set
->x_prefer_vector_width_type
== PVW_NONE
))
2603 opts
->x_prefer_vector_width_type
= PVW_AVX128
;
2605 /* Use 256-bit AVX instruction generation
2606 in the auto-vectorizer. */
2607 if (ix86_tune_features
[X86_TUNE_AVX256_OPTIMAL
]
2608 && (opts_set
->x_prefer_vector_width_type
== PVW_NONE
))
2609 opts
->x_prefer_vector_width_type
= PVW_AVX256
;
2611 if (opts
->x_ix86_recip_name
)
2613 char *p
= ASTRDUP (opts
->x_ix86_recip_name
);
2615 unsigned int mask
, i
;
2618 while ((q
= strtok (p
, ",")) != NULL
)
2629 if (!strcmp (q
, "default"))
2630 mask
= RECIP_MASK_ALL
;
2633 for (i
= 0; i
< ARRAY_SIZE (recip_options
); i
++)
2634 if (!strcmp (q
, recip_options
[i
].string
))
2636 mask
= recip_options
[i
].mask
;
2640 if (i
== ARRAY_SIZE (recip_options
))
2642 error ("unknown option for %<-mrecip=%s%>", q
);
2644 mask
= RECIP_MASK_NONE
;
2648 opts
->x_recip_mask_explicit
|= mask
;
2650 opts
->x_recip_mask
&= ~mask
;
2652 opts
->x_recip_mask
|= mask
;
2656 if (TARGET_RECIP_P (opts
->x_target_flags
))
2657 opts
->x_recip_mask
|= RECIP_MASK_ALL
& ~opts
->x_recip_mask_explicit
;
2658 else if (opts_set
->x_target_flags
& MASK_RECIP
)
2659 opts
->x_recip_mask
&= ~(RECIP_MASK_ALL
& ~opts
->x_recip_mask_explicit
);
2661 /* Default long double to 64-bit for 32-bit Bionic and to __float128
2662 for 64-bit Bionic. Also default long double to 64-bit for Intel
2664 if ((TARGET_HAS_BIONIC
|| TARGET_IAMCU
)
2665 && !(opts_set
->x_target_flags
2666 & (MASK_LONG_DOUBLE_64
| MASK_LONG_DOUBLE_128
)))
2667 opts
->x_target_flags
|= (TARGET_64BIT
2668 ? MASK_LONG_DOUBLE_128
2669 : MASK_LONG_DOUBLE_64
);
2671 /* Only one of them can be active. */
2672 gcc_assert ((opts
->x_target_flags
& MASK_LONG_DOUBLE_64
) == 0
2673 || (opts
->x_target_flags
& MASK_LONG_DOUBLE_128
) == 0);
2675 /* Handle stack protector */
2676 if (!opts_set
->x_ix86_stack_protector_guard
)
2678 #ifdef TARGET_THREAD_SSP_OFFSET
2679 if (!TARGET_HAS_BIONIC
)
2680 opts
->x_ix86_stack_protector_guard
= SSP_TLS
;
2683 opts
->x_ix86_stack_protector_guard
= SSP_GLOBAL
;
2686 if (opts_set
->x_ix86_stack_protector_guard_offset_str
)
2689 const char *str
= opts
->x_ix86_stack_protector_guard_offset_str
;
2694 #if defined(INT64_T_IS_LONG)
2695 offset
= strtol (str
, &endp
, 0);
2697 offset
= strtoll (str
, &endp
, 0);
2700 if (!*str
|| *endp
|| errno
)
2701 error ("%qs is not a valid number "
2702 "in %<-mstack-protector-guard-offset=%>", str
);
2704 if (!IN_RANGE (offset
, HOST_WIDE_INT_C (-0x80000000),
2705 HOST_WIDE_INT_C (0x7fffffff)))
2706 error ("%qs is not a valid offset "
2707 "in %<-mstack-protector-guard-offset=%>", str
);
2709 opts
->x_ix86_stack_protector_guard_offset
= offset
;
2711 #ifdef TARGET_THREAD_SSP_OFFSET
2713 opts
->x_ix86_stack_protector_guard_offset
= TARGET_THREAD_SSP_OFFSET
;
2716 if (opts_set
->x_ix86_stack_protector_guard_reg_str
)
2718 const char *str
= opts
->x_ix86_stack_protector_guard_reg_str
;
2719 addr_space_t seg
= ADDR_SPACE_GENERIC
;
2721 /* Discard optional register prefix. */
2725 if (strlen (str
) == 2 && str
[1] == 's')
2728 seg
= ADDR_SPACE_SEG_FS
;
2729 else if (str
[0] == 'g')
2730 seg
= ADDR_SPACE_SEG_GS
;
2733 if (seg
== ADDR_SPACE_GENERIC
)
2734 error ("%qs is not a valid base register "
2735 "in %<-mstack-protector-guard-reg=%>",
2736 opts
->x_ix86_stack_protector_guard_reg_str
);
2738 opts
->x_ix86_stack_protector_guard_reg
= seg
;
2742 opts
->x_ix86_stack_protector_guard_reg
= DEFAULT_TLS_SEG_REG
;
2744 /* The kernel uses a different segment register for performance
2745 reasons; a system call would not have to trash the userspace
2746 segment register, which would be expensive. */
2747 if (opts
->x_ix86_cmodel
== CM_KERNEL
)
2748 opts
->x_ix86_stack_protector_guard_reg
= ADDR_SPACE_SEG_GS
;
2751 /* Handle -mmemcpy-strategy= and -mmemset-strategy= */
2752 if (opts
->x_ix86_tune_memcpy_strategy
)
2754 char *str
= xstrdup (opts
->x_ix86_tune_memcpy_strategy
);
2755 ix86_parse_stringop_strategy_string (str
, false);
2759 if (opts
->x_ix86_tune_memset_strategy
)
2761 char *str
= xstrdup (opts
->x_ix86_tune_memset_strategy
);
2762 ix86_parse_stringop_strategy_string (str
, true);
2766 /* Save the initial options in case the user does function specific
2769 target_option_default_node
= target_option_current_node
2770 = build_target_option_node (opts
);
2772 if (opts
->x_flag_cf_protection
!= CF_NONE
)
2773 opts
->x_flag_cf_protection
2774 = (cf_protection_level
) (opts
->x_flag_cf_protection
| CF_SET
);
2776 if (ix86_tune_features
[X86_TUNE_AVOID_128FMA_CHAINS
])
2777 maybe_set_param_value (PARAM_AVOID_FMA_MAX_BITS
, 128,
2778 opts
->x_param_values
,
2779 opts_set
->x_param_values
);
2781 /* PR86952: jump table usage with retpolines is slow.
2782 The PR provides some numbers about the slowness. */
2783 if (ix86_indirect_branch
!= indirect_branch_keep
2784 && !opts_set
->x_flag_jump_tables
)
2785 opts
->x_flag_jump_tables
= 0;
2790 /* Implement the TARGET_OPTION_OVERRIDE hook. */
2793 ix86_option_override (void)
2795 ix86_option_override_internal (true, &global_options
, &global_options_set
);
2798 /* Remember the last target of ix86_set_current_function. */
2799 static GTY(()) tree ix86_previous_fndecl
;
2801 /* Set targets globals to the default (or current #pragma GCC target
2802 if active). Invalidate ix86_previous_fndecl cache. */
2805 ix86_reset_previous_fndecl (void)
2807 tree new_tree
= target_option_current_node
;
2808 cl_target_option_restore (&global_options
, TREE_TARGET_OPTION (new_tree
));
2809 if (TREE_TARGET_GLOBALS (new_tree
))
2810 restore_target_globals (TREE_TARGET_GLOBALS (new_tree
));
2811 else if (new_tree
== target_option_default_node
)
2812 restore_target_globals (&default_target_globals
);
2814 TREE_TARGET_GLOBALS (new_tree
) = save_target_globals_default_opts ();
2815 ix86_previous_fndecl
= NULL_TREE
;
2818 /* Add target attribute to SIMD clone NODE if needed. */
2821 ix86_simd_clone_adjust (struct cgraph_node
*node
)
2823 const char *str
= NULL
;
2825 /* Attributes need to be adjusted for definitions, not declarations. */
2826 if (!node
->definition
)
2829 gcc_assert (node
->decl
== cfun
->decl
);
2830 switch (node
->simdclone
->vecsize_mangle
)
2845 if (!TARGET_AVX512F
)
2854 tree args
= build_tree_list (NULL_TREE
, build_string (strlen (str
), str
));
2855 bool ok
= ix86_valid_target_attribute_p (node
->decl
, NULL
, args
, 0);
2858 ix86_reset_previous_fndecl ();
2859 ix86_set_current_function (node
->decl
);
2864 /* Set the func_type field from the function FNDECL. */
2867 ix86_set_func_type (tree fndecl
)
2869 if (cfun
->machine
->func_type
== TYPE_UNKNOWN
)
2871 if (lookup_attribute ("interrupt",
2872 TYPE_ATTRIBUTES (TREE_TYPE (fndecl
))))
2874 if (ix86_function_naked (fndecl
))
2875 error_at (DECL_SOURCE_LOCATION (fndecl
),
2876 "interrupt and naked attributes are not compatible");
2879 for (tree arg
= DECL_ARGUMENTS (fndecl
);
2881 arg
= TREE_CHAIN (arg
))
2883 cfun
->machine
->no_caller_saved_registers
= true;
2884 cfun
->machine
->func_type
2885 = nargs
== 2 ? TYPE_EXCEPTION
: TYPE_INTERRUPT
;
2887 ix86_optimize_mode_switching
[X86_DIRFLAG
] = 1;
2889 /* Only dwarf2out.c can handle -WORD(AP) as a pointer argument. */
2890 if (write_symbols
!= NO_DEBUG
&& write_symbols
!= DWARF2_DEBUG
)
2891 sorry ("only DWARF debug format is supported for interrupt "
2896 cfun
->machine
->func_type
= TYPE_NORMAL
;
2897 if (lookup_attribute ("no_caller_saved_registers",
2898 TYPE_ATTRIBUTES (TREE_TYPE (fndecl
))))
2899 cfun
->machine
->no_caller_saved_registers
= true;
2904 /* Set the indirect_branch_type field from the function FNDECL. */
2907 ix86_set_indirect_branch_type (tree fndecl
)
2909 if (cfun
->machine
->indirect_branch_type
== indirect_branch_unset
)
2911 tree attr
= lookup_attribute ("indirect_branch",
2912 DECL_ATTRIBUTES (fndecl
));
2915 tree args
= TREE_VALUE (attr
);
2918 tree cst
= TREE_VALUE (args
);
2919 if (strcmp (TREE_STRING_POINTER (cst
), "keep") == 0)
2920 cfun
->machine
->indirect_branch_type
= indirect_branch_keep
;
2921 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk") == 0)
2922 cfun
->machine
->indirect_branch_type
= indirect_branch_thunk
;
2923 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk-inline") == 0)
2924 cfun
->machine
->indirect_branch_type
= indirect_branch_thunk_inline
;
2925 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk-extern") == 0)
2926 cfun
->machine
->indirect_branch_type
= indirect_branch_thunk_extern
;
2931 cfun
->machine
->indirect_branch_type
= ix86_indirect_branch
;
2933 /* -mcmodel=large is not compatible with -mindirect-branch=thunk
2934 nor -mindirect-branch=thunk-extern. */
2935 if ((ix86_cmodel
== CM_LARGE
|| ix86_cmodel
== CM_LARGE_PIC
)
2936 && ((cfun
->machine
->indirect_branch_type
2937 == indirect_branch_thunk_extern
)
2938 || (cfun
->machine
->indirect_branch_type
2939 == indirect_branch_thunk
)))
2940 error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
2942 ((cfun
->machine
->indirect_branch_type
2943 == indirect_branch_thunk_extern
)
2944 ? "thunk-extern" : "thunk"));
2946 if (cfun
->machine
->indirect_branch_type
!= indirect_branch_keep
2947 && (flag_cf_protection
& CF_RETURN
))
2948 error ("%<-mindirect-branch%> and %<-fcf-protection%> are not "
2952 if (cfun
->machine
->function_return_type
== indirect_branch_unset
)
2954 tree attr
= lookup_attribute ("function_return",
2955 DECL_ATTRIBUTES (fndecl
));
2958 tree args
= TREE_VALUE (attr
);
2961 tree cst
= TREE_VALUE (args
);
2962 if (strcmp (TREE_STRING_POINTER (cst
), "keep") == 0)
2963 cfun
->machine
->function_return_type
= indirect_branch_keep
;
2964 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk") == 0)
2965 cfun
->machine
->function_return_type
= indirect_branch_thunk
;
2966 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk-inline") == 0)
2967 cfun
->machine
->function_return_type
= indirect_branch_thunk_inline
;
2968 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk-extern") == 0)
2969 cfun
->machine
->function_return_type
= indirect_branch_thunk_extern
;
2974 cfun
->machine
->function_return_type
= ix86_function_return
;
2976 /* -mcmodel=large is not compatible with -mfunction-return=thunk
2977 nor -mfunction-return=thunk-extern. */
2978 if ((ix86_cmodel
== CM_LARGE
|| ix86_cmodel
== CM_LARGE_PIC
)
2979 && ((cfun
->machine
->function_return_type
2980 == indirect_branch_thunk_extern
)
2981 || (cfun
->machine
->function_return_type
2982 == indirect_branch_thunk
)))
2983 error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
2985 ((cfun
->machine
->function_return_type
2986 == indirect_branch_thunk_extern
)
2987 ? "thunk-extern" : "thunk"));
2989 if (cfun
->machine
->function_return_type
!= indirect_branch_keep
2990 && (flag_cf_protection
& CF_RETURN
))
2991 error ("%<-mfunction-return%> and %<-fcf-protection%> are not "
2996 /* Establish appropriate back-end context for processing the function
2997 FNDECL. The argument might be NULL to indicate processing at top
2998 level, outside of any function scope. */
3000 ix86_set_current_function (tree fndecl
)
3002 /* Only change the context if the function changes. This hook is called
3003 several times in the course of compiling a function, and we don't want to
3004 slow things down too much or call target_reinit when it isn't safe. */
3005 if (fndecl
== ix86_previous_fndecl
)
3007 /* There may be 2 function bodies for the same function FNDECL,
3008 one is extern inline and one isn't. Call ix86_set_func_type
3009 to set the func_type field. */
3010 if (fndecl
!= NULL_TREE
)
3012 ix86_set_func_type (fndecl
);
3013 ix86_set_indirect_branch_type (fndecl
);
3019 if (ix86_previous_fndecl
== NULL_TREE
)
3020 old_tree
= target_option_current_node
;
3021 else if (DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl
))
3022 old_tree
= DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl
);
3024 old_tree
= target_option_default_node
;
3026 if (fndecl
== NULL_TREE
)
3028 if (old_tree
!= target_option_current_node
)
3029 ix86_reset_previous_fndecl ();
3033 ix86_set_func_type (fndecl
);
3034 ix86_set_indirect_branch_type (fndecl
);
3036 tree new_tree
= DECL_FUNCTION_SPECIFIC_TARGET (fndecl
);
3037 if (new_tree
== NULL_TREE
)
3038 new_tree
= target_option_default_node
;
3040 if (old_tree
!= new_tree
)
3042 cl_target_option_restore (&global_options
, TREE_TARGET_OPTION (new_tree
));
3043 if (TREE_TARGET_GLOBALS (new_tree
))
3044 restore_target_globals (TREE_TARGET_GLOBALS (new_tree
));
3045 else if (new_tree
== target_option_default_node
)
3046 restore_target_globals (&default_target_globals
);
3048 TREE_TARGET_GLOBALS (new_tree
) = save_target_globals_default_opts ();
3050 ix86_previous_fndecl
= fndecl
;
3052 static bool prev_no_caller_saved_registers
;
3054 /* 64-bit MS and SYSV ABI have different set of call used registers.
3055 Avoid expensive re-initialization of init_regs each time we switch
3056 function context. */
3058 && (call_used_regs
[SI_REG
]
3059 == (cfun
->machine
->call_abi
== MS_ABI
)))
3061 /* Need to re-initialize init_regs if caller-saved registers are
3063 else if (prev_no_caller_saved_registers
3064 != cfun
->machine
->no_caller_saved_registers
)
3067 if (cfun
->machine
->func_type
!= TYPE_NORMAL
3068 || cfun
->machine
->no_caller_saved_registers
)
3070 /* Don't allow SSE, MMX nor x87 instructions since they
3071 may change processor state. */
3075 else if (TARGET_MMX
)
3077 else if (TARGET_80387
)
3083 if (cfun
->machine
->func_type
!= TYPE_NORMAL
)
3084 sorry (cfun
->machine
->func_type
== TYPE_EXCEPTION
3085 ? G_("%s instructions aren%'t allowed in an"
3086 " exception service routine")
3087 : G_("%s instructions aren%'t allowed in an"
3088 " interrupt service routine"),
3091 sorry ("%s instructions aren%'t allowed in a function with "
3092 "the %<no_caller_saved_registers%> attribute", isa
);
3093 /* Don't issue the same error twice. */
3094 cfun
->machine
->func_type
= TYPE_NORMAL
;
3095 cfun
->machine
->no_caller_saved_registers
= false;
3099 prev_no_caller_saved_registers
3100 = cfun
->machine
->no_caller_saved_registers
;
3103 /* Implement the TARGET_OFFLOAD_OPTIONS hook. */
3105 ix86_offload_options (void)
3108 return xstrdup ("-foffload-abi=lp64");
3109 return xstrdup ("-foffload-abi=ilp32");
3112 /* Handle "cdecl", "stdcall", "fastcall", "regparm", "thiscall",
3113 and "sseregparm" calling convention attributes;
3114 arguments as in struct attribute_spec.handler. */
3117 ix86_handle_cconv_attribute (tree
*node
, tree name
, tree args
, int,
3120 if (TREE_CODE (*node
) != FUNCTION_TYPE
3121 && TREE_CODE (*node
) != METHOD_TYPE
3122 && TREE_CODE (*node
) != FIELD_DECL
3123 && TREE_CODE (*node
) != TYPE_DECL
)
3125 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3127 *no_add_attrs
= true;
3131 /* Can combine regparm with all attributes but fastcall, and thiscall. */
3132 if (is_attribute_p ("regparm", name
))
3136 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node
)))
3138 error ("fastcall and regparm attributes are not compatible");
3141 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node
)))
3143 error ("regparam and thiscall attributes are not compatible");
3146 cst
= TREE_VALUE (args
);
3147 if (TREE_CODE (cst
) != INTEGER_CST
)
3149 warning (OPT_Wattributes
,
3150 "%qE attribute requires an integer constant argument",
3152 *no_add_attrs
= true;
3154 else if (compare_tree_int (cst
, REGPARM_MAX
) > 0)
3156 warning (OPT_Wattributes
, "argument to %qE attribute larger than %d",
3158 *no_add_attrs
= true;
3166 /* Do not warn when emulating the MS ABI. */
3167 if ((TREE_CODE (*node
) != FUNCTION_TYPE
3168 && TREE_CODE (*node
) != METHOD_TYPE
)
3169 || ix86_function_type_abi (*node
) != MS_ABI
)
3170 warning (OPT_Wattributes
, "%qE attribute ignored",
3172 *no_add_attrs
= true;
3176 /* Can combine fastcall with stdcall (redundant) and sseregparm. */
3177 if (is_attribute_p ("fastcall", name
))
3179 if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node
)))
3181 error ("fastcall and cdecl attributes are not compatible");
3183 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node
)))
3185 error ("fastcall and stdcall attributes are not compatible");
3187 if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node
)))
3189 error ("fastcall and regparm attributes are not compatible");
3191 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node
)))
3193 error ("fastcall and thiscall attributes are not compatible");
3197 /* Can combine stdcall with fastcall (redundant), regparm and
3199 else if (is_attribute_p ("stdcall", name
))
3201 if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node
)))
3203 error ("stdcall and cdecl attributes are not compatible");
3205 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node
)))
3207 error ("stdcall and fastcall attributes are not compatible");
3209 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node
)))
3211 error ("stdcall and thiscall attributes are not compatible");
3215 /* Can combine cdecl with regparm and sseregparm. */
3216 else if (is_attribute_p ("cdecl", name
))
3218 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node
)))
3220 error ("stdcall and cdecl attributes are not compatible");
3222 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node
)))
3224 error ("fastcall and cdecl attributes are not compatible");
3226 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node
)))
3228 error ("cdecl and thiscall attributes are not compatible");
3231 else if (is_attribute_p ("thiscall", name
))
3233 if (TREE_CODE (*node
) != METHOD_TYPE
&& pedantic
)
3234 warning (OPT_Wattributes
, "%qE attribute is used for non-class method",
3236 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node
)))
3238 error ("stdcall and thiscall attributes are not compatible");
3240 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node
)))
3242 error ("fastcall and thiscall attributes are not compatible");
3244 if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node
)))
3246 error ("cdecl and thiscall attributes are not compatible");
3250 /* Can combine sseregparm with all attributes. */
3255 #ifndef CHECK_STACK_LIMIT
3256 #define CHECK_STACK_LIMIT (-1)
3259 /* The transactional memory builtins are implicitly regparm or fastcall
3260 depending on the ABI. Override the generic do-nothing attribute that
3261 these builtins were declared with, and replace it with one of the two
3262 attributes that we expect elsewhere. */
3265 ix86_handle_tm_regparm_attribute (tree
*node
, tree
, tree
,
3266 int flags
, bool *no_add_attrs
)
3270 /* In no case do we want to add the placeholder attribute. */
3271 *no_add_attrs
= true;
3273 /* The 64-bit ABI is unchanged for transactional memory. */
3277 /* ??? Is there a better way to validate 32-bit windows? We have
3278 cfun->machine->call_abi, but that seems to be set only for 64-bit. */
3279 if (CHECK_STACK_LIMIT
> 0)
3280 alt
= tree_cons (get_identifier ("fastcall"), NULL
, NULL
);
3283 alt
= tree_cons (NULL
, build_int_cst (NULL
, 2), NULL
);
3284 alt
= tree_cons (get_identifier ("regparm"), alt
, NULL
);
3286 decl_attributes (node
, alt
, flags
);
3291 /* Handle a "force_align_arg_pointer" attribute. */
3294 ix86_handle_force_align_arg_pointer_attribute (tree
*node
, tree name
,
3295 tree
, int, bool *no_add_attrs
)
3297 if (TREE_CODE (*node
) != FUNCTION_TYPE
3298 && TREE_CODE (*node
) != METHOD_TYPE
3299 && TREE_CODE (*node
) != FIELD_DECL
3300 && TREE_CODE (*node
) != TYPE_DECL
)
3302 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3304 *no_add_attrs
= true;
3310 /* Handle a "ms_struct" or "gcc_struct" attribute; arguments as in
3311 struct attribute_spec.handler. */
3314 ix86_handle_struct_attribute (tree
*node
, tree name
, tree
, int,
3320 if (TREE_CODE (*node
) == TYPE_DECL
)
3321 type
= &TREE_TYPE (*node
);
3326 if (!(type
&& RECORD_OR_UNION_TYPE_P (*type
)))
3328 warning (OPT_Wattributes
, "%qE attribute ignored",
3330 *no_add_attrs
= true;
3333 else if ((is_attribute_p ("ms_struct", name
)
3334 && lookup_attribute ("gcc_struct", TYPE_ATTRIBUTES (*type
)))
3335 || ((is_attribute_p ("gcc_struct", name
)
3336 && lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (*type
)))))
3338 warning (OPT_Wattributes
, "%qE incompatible attribute ignored",
3340 *no_add_attrs
= true;
3346 /* Handle a "callee_pop_aggregate_return" attribute; arguments as
3347 in struct attribute_spec handler. */
3350 ix86_handle_callee_pop_aggregate_return (tree
*node
, tree name
, tree args
, int,
3353 if (TREE_CODE (*node
) != FUNCTION_TYPE
3354 && TREE_CODE (*node
) != METHOD_TYPE
3355 && TREE_CODE (*node
) != FIELD_DECL
3356 && TREE_CODE (*node
) != TYPE_DECL
)
3358 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3360 *no_add_attrs
= true;
3365 warning (OPT_Wattributes
, "%qE attribute only available for 32-bit",
3367 *no_add_attrs
= true;
3370 if (is_attribute_p ("callee_pop_aggregate_return", name
))
3374 cst
= TREE_VALUE (args
);
3375 if (TREE_CODE (cst
) != INTEGER_CST
)
3377 warning (OPT_Wattributes
,
3378 "%qE attribute requires an integer constant argument",
3380 *no_add_attrs
= true;
3382 else if (compare_tree_int (cst
, 0) != 0
3383 && compare_tree_int (cst
, 1) != 0)
3385 warning (OPT_Wattributes
,
3386 "argument to %qE attribute is neither zero, nor one",
3388 *no_add_attrs
= true;
3397 /* Handle a "ms_abi" or "sysv" attribute; arguments as in
3398 struct attribute_spec.handler. */
3401 ix86_handle_abi_attribute (tree
*node
, tree name
, tree
, int,
3404 if (TREE_CODE (*node
) != FUNCTION_TYPE
3405 && TREE_CODE (*node
) != METHOD_TYPE
3406 && TREE_CODE (*node
) != FIELD_DECL
3407 && TREE_CODE (*node
) != TYPE_DECL
)
3409 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3411 *no_add_attrs
= true;
3415 /* Can combine regparm with all attributes but fastcall. */
3416 if (is_attribute_p ("ms_abi", name
))
3418 if (lookup_attribute ("sysv_abi", TYPE_ATTRIBUTES (*node
)))
3420 error ("%qs and %qs attributes are not compatible",
3421 "ms_abi", "sysv_abi");
3426 else if (is_attribute_p ("sysv_abi", name
))
3428 if (lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (*node
)))
3430 error ("%qs and %qs attributes are not compatible",
3431 "ms_abi", "sysv_abi");
3441 ix86_handle_fndecl_attribute (tree
*node
, tree name
, tree args
, int,
3444 if (TREE_CODE (*node
) != FUNCTION_DECL
)
3446 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3448 *no_add_attrs
= true;
3451 if (is_attribute_p ("indirect_branch", name
))
3453 tree cst
= TREE_VALUE (args
);
3454 if (TREE_CODE (cst
) != STRING_CST
)
3456 warning (OPT_Wattributes
,
3457 "%qE attribute requires a string constant argument",
3459 *no_add_attrs
= true;
3461 else if (strcmp (TREE_STRING_POINTER (cst
), "keep") != 0
3462 && strcmp (TREE_STRING_POINTER (cst
), "thunk") != 0
3463 && strcmp (TREE_STRING_POINTER (cst
), "thunk-inline") != 0
3464 && strcmp (TREE_STRING_POINTER (cst
), "thunk-extern") != 0)
3466 warning (OPT_Wattributes
,
3467 "argument to %qE attribute is not "
3468 "(keep|thunk|thunk-inline|thunk-extern)", name
);
3469 *no_add_attrs
= true;
3473 if (is_attribute_p ("function_return", name
))
3475 tree cst
= TREE_VALUE (args
);
3476 if (TREE_CODE (cst
) != STRING_CST
)
3478 warning (OPT_Wattributes
,
3479 "%qE attribute requires a string constant argument",
3481 *no_add_attrs
= true;
3483 else if (strcmp (TREE_STRING_POINTER (cst
), "keep") != 0
3484 && strcmp (TREE_STRING_POINTER (cst
), "thunk") != 0
3485 && strcmp (TREE_STRING_POINTER (cst
), "thunk-inline") != 0
3486 && strcmp (TREE_STRING_POINTER (cst
), "thunk-extern") != 0)
3488 warning (OPT_Wattributes
,
3489 "argument to %qE attribute is not "
3490 "(keep|thunk|thunk-inline|thunk-extern)", name
);
3491 *no_add_attrs
= true;
3499 ix86_handle_no_caller_saved_registers_attribute (tree
*, tree
, tree
,
3506 ix86_handle_interrupt_attribute (tree
*node
, tree
, tree
, int, bool *)
3508 /* DECL_RESULT and DECL_ARGUMENTS do not exist there yet,
3509 but the function type contains args and return type data. */
3510 tree func_type
= *node
;
3511 tree return_type
= TREE_TYPE (func_type
);
3514 tree current_arg_type
= TYPE_ARG_TYPES (func_type
);
3515 while (current_arg_type
3516 && ! VOID_TYPE_P (TREE_VALUE (current_arg_type
)))
3520 if (! POINTER_TYPE_P (TREE_VALUE (current_arg_type
)))
3521 error ("interrupt service routine should have a pointer "
3522 "as the first argument");
3524 else if (nargs
== 1)
3526 if (TREE_CODE (TREE_VALUE (current_arg_type
)) != INTEGER_TYPE
3527 || TYPE_MODE (TREE_VALUE (current_arg_type
)) != word_mode
)
3528 error ("interrupt service routine should have %qs "
3529 "as the second argument",
3531 ? (TARGET_X32
? "unsigned long long int"
3532 : "unsigned long int")
3536 current_arg_type
= TREE_CHAIN (current_arg_type
);
3538 if (!nargs
|| nargs
> 2)
3539 error ("interrupt service routine can only have a pointer argument "
3540 "and an optional integer argument");
3541 if (! VOID_TYPE_P (return_type
))
3542 error ("interrupt service routine must return %<void%>");
3547 /* Handle fentry_name / fentry_section attribute. */
3550 ix86_handle_fentry_name (tree
*node
, tree name
, tree args
,
3551 int, bool *no_add_attrs
)
3553 if (TREE_CODE (*node
) == FUNCTION_DECL
3554 && TREE_CODE (TREE_VALUE (args
)) == STRING_CST
)
3555 /* Do nothing else, just set the attribute. We'll get at
3556 it later with lookup_attribute. */
3560 warning (OPT_Wattributes
, "%qE attribute ignored", name
);
3561 *no_add_attrs
= true;
3567 /* Table of valid machine attributes. */
3568 const struct attribute_spec ix86_attribute_table
[] =
3570 /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
3571 affects_type_identity, handler, exclude } */
3572 /* Stdcall attribute says callee is responsible for popping arguments
3573 if they are not variable. */
3574 { "stdcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3576 /* Fastcall attribute says callee is responsible for popping arguments
3577 if they are not variable. */
3578 { "fastcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3580 /* Thiscall attribute says callee is responsible for popping arguments
3581 if they are not variable. */
3582 { "thiscall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3584 /* Cdecl attribute says the callee is a normal C declaration */
3585 { "cdecl", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3587 /* Regparm attribute specifies how many integer arguments are to be
3588 passed in registers. */
3589 { "regparm", 1, 1, false, true, true, true, ix86_handle_cconv_attribute
,
3591 /* Sseregparm attribute says we are using x86_64 calling conventions
3592 for FP arguments. */
3593 { "sseregparm", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3595 /* The transactional memory builtins are implicitly regparm or fastcall
3596 depending on the ABI. Override the generic do-nothing attribute that
3597 these builtins were declared with. */
3598 { "*tm regparm", 0, 0, false, true, true, true,
3599 ix86_handle_tm_regparm_attribute
, NULL
},
3600 /* force_align_arg_pointer says this function realigns the stack at entry. */
3601 { "force_align_arg_pointer", 0, 0,
3602 false, true, true, false, ix86_handle_force_align_arg_pointer_attribute
,
3604 #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
3605 { "dllimport", 0, 0, false, false, false, false, handle_dll_attribute
,
3607 { "dllexport", 0, 0, false, false, false, false, handle_dll_attribute
,
3609 { "shared", 0, 0, true, false, false, false,
3610 ix86_handle_shared_attribute
, NULL
},
3612 { "ms_struct", 0, 0, false, false, false, false,
3613 ix86_handle_struct_attribute
, NULL
},
3614 { "gcc_struct", 0, 0, false, false, false, false,
3615 ix86_handle_struct_attribute
, NULL
},
3616 #ifdef SUBTARGET_ATTRIBUTE_TABLE
3617 SUBTARGET_ATTRIBUTE_TABLE
,
3619 /* ms_abi and sysv_abi calling convention function attributes. */
3620 { "ms_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute
, NULL
},
3621 { "sysv_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute
,
3623 { "ms_abi va_list", 0, 0, false, false, false, false, NULL
, NULL
},
3624 { "sysv_abi va_list", 0, 0, false, false, false, false, NULL
, NULL
},
3625 { "ms_hook_prologue", 0, 0, true, false, false, false,
3626 ix86_handle_fndecl_attribute
, NULL
},
3627 { "callee_pop_aggregate_return", 1, 1, false, true, true, true,
3628 ix86_handle_callee_pop_aggregate_return
, NULL
},
3629 { "interrupt", 0, 0, false, true, true, false,
3630 ix86_handle_interrupt_attribute
, NULL
},
3631 { "no_caller_saved_registers", 0, 0, false, true, true, false,
3632 ix86_handle_no_caller_saved_registers_attribute
, NULL
},
3633 { "naked", 0, 0, true, false, false, false,
3634 ix86_handle_fndecl_attribute
, NULL
},
3635 { "indirect_branch", 1, 1, true, false, false, false,
3636 ix86_handle_fndecl_attribute
, NULL
},
3637 { "function_return", 1, 1, true, false, false, false,
3638 ix86_handle_fndecl_attribute
, NULL
},
3639 { "indirect_return", 0, 0, false, true, true, false,
3641 { "fentry_name", 1, 1, true, false, false, false,
3642 ix86_handle_fentry_name
, NULL
},
3643 { "fentry_section", 1, 1, true, false, false, false,
3644 ix86_handle_fentry_name
, NULL
},
3645 { "cf_check", 0, 0, true, false, false, false,
3646 ix86_handle_fndecl_attribute
, NULL
},
3649 { NULL
, 0, 0, false, false, false, false, NULL
, NULL
}
3652 #include "gt-i386-options.h"