1 /* Copyright (C) 1988-2021 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"
62 #include "sched-int.h"
64 #include "tree-pass.h"
66 #include "pass_manager.h"
67 #include "target-globals.h"
68 #include "gimple-iterator.h"
69 #include "tree-vectorizer.h"
70 #include "shrink-wrap.h"
73 #include "tree-iterator.h"
75 #include "case-cfn-macros.h"
77 #include "fold-const-call.h"
79 #include "tree-ssanames.h"
81 #include "selftest-rtl.h"
82 #include "print-rtl.h"
85 #include "symbol-summary.h"
87 #include "ipa-fnsummary.h"
88 #include "wide-int-bitmask.h"
89 #include "tree-vector-builder.h"
91 #include "dwarf2out.h"
92 #include "i386-options.h"
94 #include "x86-tune-costs.h"
96 #ifndef SUBTARGET32_DEFAULT_CPU
97 #define SUBTARGET32_DEFAULT_CPU "i386"
100 /* Processor feature/optimization bitmasks. */
101 #define m_NONE HOST_WIDE_INT_0U
102 #define m_ALL (~HOST_WIDE_INT_0U)
103 #define m_386 (HOST_WIDE_INT_1U<<PROCESSOR_I386)
104 #define m_486 (HOST_WIDE_INT_1U<<PROCESSOR_I486)
105 #define m_PENT (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM)
106 #define m_LAKEMONT (HOST_WIDE_INT_1U<<PROCESSOR_LAKEMONT)
107 #define m_PPRO (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUMPRO)
108 #define m_PENT4 (HOST_WIDE_INT_1U<<PROCESSOR_PENTIUM4)
109 #define m_NOCONA (HOST_WIDE_INT_1U<<PROCESSOR_NOCONA)
110 #define m_P4_NOCONA (m_PENT4 | m_NOCONA)
111 #define m_CORE2 (HOST_WIDE_INT_1U<<PROCESSOR_CORE2)
112 #define m_NEHALEM (HOST_WIDE_INT_1U<<PROCESSOR_NEHALEM)
113 #define m_SANDYBRIDGE (HOST_WIDE_INT_1U<<PROCESSOR_SANDYBRIDGE)
114 #define m_HASWELL (HOST_WIDE_INT_1U<<PROCESSOR_HASWELL)
115 #define m_BONNELL (HOST_WIDE_INT_1U<<PROCESSOR_BONNELL)
116 #define m_SILVERMONT (HOST_WIDE_INT_1U<<PROCESSOR_SILVERMONT)
117 #define m_KNL (HOST_WIDE_INT_1U<<PROCESSOR_KNL)
118 #define m_KNM (HOST_WIDE_INT_1U<<PROCESSOR_KNM)
119 #define m_SKYLAKE (HOST_WIDE_INT_1U<<PROCESSOR_SKYLAKE)
120 #define m_SKYLAKE_AVX512 (HOST_WIDE_INT_1U<<PROCESSOR_SKYLAKE_AVX512)
121 #define m_CANNONLAKE (HOST_WIDE_INT_1U<<PROCESSOR_CANNONLAKE)
122 #define m_ICELAKE_CLIENT (HOST_WIDE_INT_1U<<PROCESSOR_ICELAKE_CLIENT)
123 #define m_ICELAKE_SERVER (HOST_WIDE_INT_1U<<PROCESSOR_ICELAKE_SERVER)
124 #define m_CASCADELAKE (HOST_WIDE_INT_1U<<PROCESSOR_CASCADELAKE)
125 #define m_TIGERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_TIGERLAKE)
126 #define m_COOPERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_COOPERLAKE)
127 #define m_SAPPHIRERAPIDS (HOST_WIDE_INT_1U<<PROCESSOR_SAPPHIRERAPIDS)
128 #define m_ALDERLAKE (HOST_WIDE_INT_1U<<PROCESSOR_ALDERLAKE)
129 #define m_ROCKETLAKE (HOST_WIDE_INT_1U<<PROCESSOR_ROCKETLAKE)
130 #define m_CORE_AVX512 (m_SKYLAKE_AVX512 | m_CANNONLAKE \
131 | m_ICELAKE_CLIENT | m_ICELAKE_SERVER | m_CASCADELAKE \
132 | m_TIGERLAKE | m_COOPERLAKE | m_SAPPHIRERAPIDS \
134 #define m_CORE_AVX2 (m_HASWELL | m_SKYLAKE | m_CORE_AVX512)
135 #define m_CORE_ALL (m_CORE2 | m_NEHALEM | m_SANDYBRIDGE | m_CORE_AVX2)
136 #define m_GOLDMONT (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT)
137 #define m_GOLDMONT_PLUS (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT_PLUS)
138 #define m_TREMONT (HOST_WIDE_INT_1U<<PROCESSOR_TREMONT)
139 #define m_INTEL (HOST_WIDE_INT_1U<<PROCESSOR_INTEL)
141 #define m_GEODE (HOST_WIDE_INT_1U<<PROCESSOR_GEODE)
142 #define m_K6 (HOST_WIDE_INT_1U<<PROCESSOR_K6)
143 #define m_K6_GEODE (m_K6 | m_GEODE)
144 #define m_K8 (HOST_WIDE_INT_1U<<PROCESSOR_K8)
145 #define m_ATHLON (HOST_WIDE_INT_1U<<PROCESSOR_ATHLON)
146 #define m_ATHLON_K8 (m_K8 | m_ATHLON)
147 #define m_AMDFAM10 (HOST_WIDE_INT_1U<<PROCESSOR_AMDFAM10)
148 #define m_BDVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER1)
149 #define m_BDVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER2)
150 #define m_BDVER3 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER3)
151 #define m_BDVER4 (HOST_WIDE_INT_1U<<PROCESSOR_BDVER4)
152 #define m_ZNVER1 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER1)
153 #define m_ZNVER2 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER2)
154 #define m_ZNVER3 (HOST_WIDE_INT_1U<<PROCESSOR_ZNVER3)
155 #define m_BTVER1 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER1)
156 #define m_BTVER2 (HOST_WIDE_INT_1U<<PROCESSOR_BTVER2)
157 #define m_BDVER (m_BDVER1 | m_BDVER2 | m_BDVER3 | m_BDVER4)
158 #define m_BTVER (m_BTVER1 | m_BTVER2)
159 #define m_ZNVER (m_ZNVER1 | m_ZNVER2 | m_ZNVER3)
160 #define m_AMD_MULTIPLE (m_ATHLON_K8 | m_AMDFAM10 | m_BDVER | m_BTVER \
163 #define m_GENERIC (HOST_WIDE_INT_1U<<PROCESSOR_GENERIC)
165 const char* ix86_tune_feature_names
[X86_TUNE_LAST
] = {
167 #define DEF_TUNE(tune, name, selector) name,
168 #include "x86-tune.def"
172 /* Feature tests against the various tunings. */
173 unsigned char ix86_tune_features
[X86_TUNE_LAST
];
175 /* Feature tests against the various tunings used to create ix86_tune_features
176 based on the processor mask. */
177 static unsigned HOST_WIDE_INT initial_ix86_tune_features
[X86_TUNE_LAST
] = {
179 #define DEF_TUNE(tune, name, selector) selector,
180 #include "x86-tune.def"
184 /* Feature tests against the various architecture variations. */
185 unsigned char ix86_arch_features
[X86_ARCH_LAST
];
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_ISA2_CX16
},
198 { "-mvaes", OPTION_MASK_ISA2_VAES
},
199 { "-mrdpid", OPTION_MASK_ISA2_RDPID
},
200 { "-mpconfig", OPTION_MASK_ISA2_PCONFIG
},
201 { "-mwbnoinvd", OPTION_MASK_ISA2_WBNOINVD
},
202 { "-mavx512vp2intersect", OPTION_MASK_ISA2_AVX512VP2INTERSECT
},
203 { "-msgx", OPTION_MASK_ISA2_SGX
},
204 { "-mavx5124vnniw", OPTION_MASK_ISA2_AVX5124VNNIW
},
205 { "-mavx5124fmaps", OPTION_MASK_ISA2_AVX5124FMAPS
},
206 { "-mhle", OPTION_MASK_ISA2_HLE
},
207 { "-mmovbe", OPTION_MASK_ISA2_MOVBE
},
208 { "-mclzero", OPTION_MASK_ISA2_CLZERO
},
209 { "-mmwaitx", OPTION_MASK_ISA2_MWAITX
},
210 { "-mmwait", OPTION_MASK_ISA2_MWAIT
},
211 { "-mmovdir64b", OPTION_MASK_ISA2_MOVDIR64B
},
212 { "-mwaitpkg", OPTION_MASK_ISA2_WAITPKG
},
213 { "-mcldemote", OPTION_MASK_ISA2_CLDEMOTE
},
214 { "-mptwrite", OPTION_MASK_ISA2_PTWRITE
},
215 { "-mavx512bf16", OPTION_MASK_ISA2_AVX512BF16
},
216 { "-menqcmd", OPTION_MASK_ISA2_ENQCMD
},
217 { "-mserialize", OPTION_MASK_ISA2_SERIALIZE
},
218 { "-mtsxldtrk", OPTION_MASK_ISA2_TSXLDTRK
},
219 { "-mamx-tile", OPTION_MASK_ISA2_AMX_TILE
},
220 { "-mamx-int8", OPTION_MASK_ISA2_AMX_INT8
},
221 { "-mamx-bf16", OPTION_MASK_ISA2_AMX_BF16
},
222 { "-muintr", OPTION_MASK_ISA2_UINTR
},
223 { "-mhreset", OPTION_MASK_ISA2_HRESET
},
224 { "-mkl", OPTION_MASK_ISA2_KL
},
225 { "-mwidekl", OPTION_MASK_ISA2_WIDEKL
},
226 { "-mavxvnni", OPTION_MASK_ISA2_AVXVNNI
},
227 { "-mavx512fp16", OPTION_MASK_ISA2_AVX512FP16
}
229 static struct ix86_target_opts isa_opts
[] =
231 { "-mavx512vpopcntdq", OPTION_MASK_ISA_AVX512VPOPCNTDQ
},
232 { "-mavx512bitalg", OPTION_MASK_ISA_AVX512BITALG
},
233 { "-mvpclmulqdq", OPTION_MASK_ISA_VPCLMULQDQ
},
234 { "-mgfni", OPTION_MASK_ISA_GFNI
},
235 { "-mavx512vnni", OPTION_MASK_ISA_AVX512VNNI
},
236 { "-mavx512vbmi2", OPTION_MASK_ISA_AVX512VBMI2
},
237 { "-mavx512vbmi", OPTION_MASK_ISA_AVX512VBMI
},
238 { "-mavx512ifma", OPTION_MASK_ISA_AVX512IFMA
},
239 { "-mavx512vl", OPTION_MASK_ISA_AVX512VL
},
240 { "-mavx512bw", OPTION_MASK_ISA_AVX512BW
},
241 { "-mavx512dq", OPTION_MASK_ISA_AVX512DQ
},
242 { "-mavx512er", OPTION_MASK_ISA_AVX512ER
},
243 { "-mavx512pf", OPTION_MASK_ISA_AVX512PF
},
244 { "-mavx512cd", OPTION_MASK_ISA_AVX512CD
},
245 { "-mavx512f", OPTION_MASK_ISA_AVX512F
},
246 { "-mavx2", OPTION_MASK_ISA_AVX2
},
247 { "-mfma", OPTION_MASK_ISA_FMA
},
248 { "-mxop", OPTION_MASK_ISA_XOP
},
249 { "-mfma4", OPTION_MASK_ISA_FMA4
},
250 { "-mf16c", OPTION_MASK_ISA_F16C
},
251 { "-mavx", OPTION_MASK_ISA_AVX
},
252 /*{ "-msse4" OPTION_MASK_ISA_SSE4 }, */
253 { "-msse4.2", OPTION_MASK_ISA_SSE4_2
},
254 { "-msse4.1", OPTION_MASK_ISA_SSE4_1
},
255 { "-msse4a", OPTION_MASK_ISA_SSE4A
},
256 { "-mssse3", OPTION_MASK_ISA_SSSE3
},
257 { "-msse3", OPTION_MASK_ISA_SSE3
},
258 { "-maes", OPTION_MASK_ISA_AES
},
259 { "-msha", OPTION_MASK_ISA_SHA
},
260 { "-mpclmul", OPTION_MASK_ISA_PCLMUL
},
261 { "-msse2", OPTION_MASK_ISA_SSE2
},
262 { "-msse", OPTION_MASK_ISA_SSE
},
263 { "-m3dnowa", OPTION_MASK_ISA_3DNOW_A
},
264 { "-m3dnow", OPTION_MASK_ISA_3DNOW
},
265 { "-mmmx", OPTION_MASK_ISA_MMX
},
266 { "-mrtm", OPTION_MASK_ISA_RTM
},
267 { "-mprfchw", OPTION_MASK_ISA_PRFCHW
},
268 { "-mrdseed", OPTION_MASK_ISA_RDSEED
},
269 { "-madx", OPTION_MASK_ISA_ADX
},
270 { "-mprefetchwt1", OPTION_MASK_ISA_PREFETCHWT1
},
271 { "-mclflushopt", OPTION_MASK_ISA_CLFLUSHOPT
},
272 { "-mxsaves", OPTION_MASK_ISA_XSAVES
},
273 { "-mxsavec", OPTION_MASK_ISA_XSAVEC
},
274 { "-mxsaveopt", OPTION_MASK_ISA_XSAVEOPT
},
275 { "-mxsave", OPTION_MASK_ISA_XSAVE
},
276 { "-mabm", OPTION_MASK_ISA_ABM
},
277 { "-mbmi", OPTION_MASK_ISA_BMI
},
278 { "-mbmi2", OPTION_MASK_ISA_BMI2
},
279 { "-mlzcnt", OPTION_MASK_ISA_LZCNT
},
280 { "-mtbm", OPTION_MASK_ISA_TBM
},
281 { "-mpopcnt", OPTION_MASK_ISA_POPCNT
},
282 { "-msahf", OPTION_MASK_ISA_SAHF
},
283 { "-mcrc32", OPTION_MASK_ISA_CRC32
},
284 { "-mfsgsbase", OPTION_MASK_ISA_FSGSBASE
},
285 { "-mrdrnd", OPTION_MASK_ISA_RDRND
},
286 { "-mpku", OPTION_MASK_ISA_PKU
},
287 { "-mlwp", OPTION_MASK_ISA_LWP
},
288 { "-mfxsr", OPTION_MASK_ISA_FXSR
},
289 { "-mclwb", OPTION_MASK_ISA_CLWB
},
290 { "-mshstk", OPTION_MASK_ISA_SHSTK
},
291 { "-mmovdiri", OPTION_MASK_ISA_MOVDIRI
}
294 /* Return 1 if TRAIT NAME is present in the OpenMP context's
295 device trait set, return 0 if not present in any OpenMP context in the
296 whole translation unit, or -1 if not present in the current OpenMP context
297 but might be present in another OpenMP context in the same TU. */
300 ix86_omp_device_kind_arch_isa (enum omp_device_kind_arch_isa trait
,
305 case omp_device_kind
:
306 return strcmp (name
, "cpu") == 0;
307 case omp_device_arch
:
308 #ifdef ACCEL_COMPILER
309 if (strcmp (name
, "intel_mic") == 0)
312 if (strcmp (name
, "x86") == 0)
317 return strcmp (name
, "x32") == 0;
319 return strcmp (name
, "x86_64") == 0;
321 if (strcmp (name
, "ia32") == 0 || strcmp (name
, "i386") == 0)
323 if (strcmp (name
, "i486") == 0)
324 return ix86_arch
!= PROCESSOR_I386
? 1 : -1;
325 if (strcmp (name
, "i586") == 0)
326 return (ix86_arch
!= PROCESSOR_I386
327 && ix86_arch
!= PROCESSOR_I486
) ? 1 : -1;
328 if (strcmp (name
, "i686") == 0)
329 return (ix86_arch
!= PROCESSOR_I386
330 && ix86_arch
!= PROCESSOR_I486
331 && ix86_arch
!= PROCESSOR_LAKEMONT
332 && ix86_arch
!= PROCESSOR_PENTIUM
) ? 1 : -1;
335 for (int i
= 0; i
< 2; i
++)
337 struct ix86_target_opts
*opts
= i
? isa2_opts
: isa_opts
;
338 size_t nopts
= i
? ARRAY_SIZE (isa2_opts
) : ARRAY_SIZE (isa_opts
);
339 HOST_WIDE_INT mask
= i
? ix86_isa_flags2
: ix86_isa_flags
;
340 for (size_t n
= 0; n
< nopts
; n
++)
342 /* Handle sse4 as an alias to sse4.2. */
343 if (opts
[n
].mask
== OPTION_MASK_ISA_SSE4_2
)
345 if (strcmp (name
, "sse4") == 0)
346 return (mask
& opts
[n
].mask
) != 0 ? 1 : -1;
348 if (strcmp (name
, opts
[n
].option
+ 2) == 0)
349 return (mask
& opts
[n
].mask
) != 0 ? 1 : -1;
358 /* Return a string that documents the current -m options. The caller is
359 responsible for freeing the string. */
362 ix86_target_string (HOST_WIDE_INT isa
, HOST_WIDE_INT isa2
,
363 int flags
, int flags2
,
364 const char *arch
, const char *tune
,
365 enum fpmath_unit fpmath
,
366 enum prefer_vector_width pvw
,
367 bool add_nl_p
, bool add_abi_p
)
370 static struct ix86_target_opts flag_opts
[] =
372 { "-m128bit-long-double", MASK_128BIT_LONG_DOUBLE
},
373 { "-mlong-double-128", MASK_LONG_DOUBLE_128
},
374 { "-mlong-double-64", MASK_LONG_DOUBLE_64
},
375 { "-m80387", MASK_80387
},
376 { "-maccumulate-outgoing-args", MASK_ACCUMULATE_OUTGOING_ARGS
},
377 { "-malign-double", MASK_ALIGN_DOUBLE
},
378 { "-mcld", MASK_CLD
},
379 { "-mfp-ret-in-387", MASK_FLOAT_RETURNS
},
380 { "-mieee-fp", MASK_IEEE_FP
},
381 { "-minline-all-stringops", MASK_INLINE_ALL_STRINGOPS
},
382 { "-minline-stringops-dynamically", MASK_INLINE_STRINGOPS_DYNAMICALLY
},
383 { "-mms-bitfields", MASK_MS_BITFIELD_LAYOUT
},
384 { "-mno-align-stringops", MASK_NO_ALIGN_STRINGOPS
},
385 { "-mno-fancy-math-387", MASK_NO_FANCY_MATH_387
},
386 { "-mno-push-args", MASK_NO_PUSH_ARGS
},
387 { "-mno-red-zone", MASK_NO_RED_ZONE
},
388 { "-momit-leaf-frame-pointer", MASK_OMIT_LEAF_FRAME_POINTER
},
389 { "-mrecip", MASK_RECIP
},
390 { "-mrtd", MASK_RTD
},
391 { "-msseregparm", MASK_SSEREGPARM
},
392 { "-mstack-arg-probe", MASK_STACK_PROBE
},
393 { "-mtls-direct-seg-refs", MASK_TLS_DIRECT_SEG_REFS
},
394 { "-mvect8-ret-in-mem", MASK_VECT8_RETURNS
},
395 { "-m8bit-idiv", MASK_USE_8BIT_IDIV
},
396 { "-mvzeroupper", MASK_VZEROUPPER
},
397 { "-mstv", MASK_STV
},
398 { "-mavx256-split-unaligned-load", MASK_AVX256_SPLIT_UNALIGNED_LOAD
},
399 { "-mavx256-split-unaligned-store", MASK_AVX256_SPLIT_UNALIGNED_STORE
},
400 { "-mcall-ms2sysv-xlogues", MASK_CALL_MS2SYSV_XLOGUES
},
401 { "-mrelax-cmpxchg-loop", MASK_RELAX_CMPXCHG_LOOP
}
404 /* Additional flag options. */
405 static struct ix86_target_opts flag2_opts
[] =
407 { "-mgeneral-regs-only", OPTION_MASK_GENERAL_REGS_ONLY
}
410 const char *opts
[ARRAY_SIZE (isa_opts
) + ARRAY_SIZE (isa2_opts
)
411 + ARRAY_SIZE (flag_opts
) + ARRAY_SIZE (flag2_opts
) + 6][2];
415 char flags_other
[40];
416 char flags2_other
[40];
426 memset (opts
, '\0', sizeof (opts
));
428 /* Add -march= option. */
431 opts
[num
][0] = "-march=";
432 opts
[num
++][1] = arch
;
435 /* Add -mtune= option. */
438 opts
[num
][0] = "-mtune=";
439 opts
[num
++][1] = tune
;
442 /* Add -m32/-m64/-mx32. */
445 if ((isa
& OPTION_MASK_ISA_64BIT
) != 0)
447 if ((isa
& OPTION_MASK_ABI_64
) != 0)
454 opts
[num
++][0] = abi
;
456 isa
&= ~(OPTION_MASK_ISA_64BIT
| OPTION_MASK_ABI_64
| OPTION_MASK_ABI_X32
);
458 /* Pick out the options in isa2 options. */
459 for (i
= 0; i
< ARRAY_SIZE (isa2_opts
); i
++)
461 if ((isa2
& isa2_opts
[i
].mask
) != 0)
463 opts
[num
++][0] = isa2_opts
[i
].option
;
464 isa2
&= ~ isa2_opts
[i
].mask
;
468 if (isa2
&& add_nl_p
)
470 opts
[num
++][0] = isa2_other
;
471 sprintf (isa2_other
, "(other isa2: %#" HOST_WIDE_INT_PRINT
"x)", isa2
);
474 /* Pick out the options in isa options. */
475 for (i
= 0; i
< ARRAY_SIZE (isa_opts
); i
++)
477 if ((isa
& isa_opts
[i
].mask
) != 0)
479 opts
[num
++][0] = isa_opts
[i
].option
;
480 isa
&= ~ isa_opts
[i
].mask
;
486 opts
[num
++][0] = isa_other
;
487 sprintf (isa_other
, "(other isa: %#" HOST_WIDE_INT_PRINT
"x)", isa
);
490 /* Add flag options. */
491 for (i
= 0; i
< ARRAY_SIZE (flag_opts
); i
++)
493 if ((flags
& flag_opts
[i
].mask
) != 0)
495 opts
[num
++][0] = flag_opts
[i
].option
;
496 flags
&= ~ flag_opts
[i
].mask
;
500 if (flags
&& add_nl_p
)
502 opts
[num
++][0] = flags_other
;
503 sprintf (flags_other
, "(other flags: %#x)", flags
);
506 /* Add additional flag options. */
507 for (i
= 0; i
< ARRAY_SIZE (flag2_opts
); i
++)
509 if ((flags2
& flag2_opts
[i
].mask
) != 0)
511 opts
[num
++][0] = flag2_opts
[i
].option
;
512 flags2
&= ~ flag2_opts
[i
].mask
;
516 if (flags2
&& add_nl_p
)
518 opts
[num
++][0] = flags2_other
;
519 sprintf (flags2_other
, "(other flags2: %#x)", flags2
);
522 /* Add -mfpmath= option. */
525 opts
[num
][0] = "-mfpmath=";
526 switch ((int) fpmath
)
529 opts
[num
++][1] = "387";
533 opts
[num
++][1] = "sse";
536 case FPMATH_387
| FPMATH_SSE
:
537 opts
[num
++][1] = "sse+387";
545 /* Add -mprefer-vector-width= option. */
548 opts
[num
][0] = "-mprefer-vector-width=";
552 opts
[num
++][1] = "128";
556 opts
[num
++][1] = "256";
560 opts
[num
++][1] = "512";
572 gcc_assert (num
< ARRAY_SIZE (opts
));
574 /* Size the string. */
576 sep_len
= (add_nl_p
) ? 3 : 1;
577 for (i
= 0; i
< num
; i
++)
580 for (j
= 0; j
< 2; j
++)
582 len
+= strlen (opts
[i
][j
]);
585 /* Build the string. */
586 ret
= ptr
= (char *) xmalloc (len
);
589 for (i
= 0; i
< num
; i
++)
593 for (j
= 0; j
< 2; j
++)
594 len2
[j
] = (opts
[i
][j
]) ? strlen (opts
[i
][j
]) : 0;
601 if (add_nl_p
&& line_len
+ len2
[0] + len2
[1] > 70)
609 for (j
= 0; j
< 2; j
++)
612 memcpy (ptr
, opts
[i
][j
], len2
[j
]);
619 gcc_assert (ret
+ len
>= ptr
);
624 /* Function that is callable from the debugger to print the current
626 void ATTRIBUTE_UNUSED
627 ix86_debug_options (void)
629 char *opts
= ix86_target_string (ix86_isa_flags
, ix86_isa_flags2
,
630 target_flags
, ix86_target_flags
,
631 ix86_arch_string
, ix86_tune_string
,
632 ix86_fpmath
, prefer_vector_width_type
,
637 fprintf (stderr
, "%s\n\n", opts
);
641 fputs ("<no options>\n\n", stderr
);
646 /* Save the current options */
649 ix86_function_specific_save (struct cl_target_option
*ptr
,
650 struct gcc_options
*opts
,
651 struct gcc_options */
* opts_set */
)
653 ptr
->arch
= ix86_arch
;
654 ptr
->schedule
= ix86_schedule
;
655 ptr
->prefetch_sse
= ix86_prefetch_sse
;
656 ptr
->tune
= ix86_tune
;
657 ptr
->branch_cost
= ix86_branch_cost
;
658 ptr
->tune_defaulted
= ix86_tune_defaulted
;
659 ptr
->arch_specified
= ix86_arch_specified
;
660 ptr
->x_ix86_isa_flags_explicit
= opts
->x_ix86_isa_flags_explicit
;
661 ptr
->x_ix86_isa_flags2_explicit
= opts
->x_ix86_isa_flags2_explicit
;
662 ptr
->x_recip_mask_explicit
= opts
->x_recip_mask_explicit
;
663 ptr
->x_ix86_arch_string
= opts
->x_ix86_arch_string
;
664 ptr
->x_ix86_tune_string
= opts
->x_ix86_tune_string
;
665 ptr
->x_ix86_abi
= opts
->x_ix86_abi
;
666 ptr
->x_ix86_asm_dialect
= opts
->x_ix86_asm_dialect
;
667 ptr
->x_ix86_branch_cost
= opts
->x_ix86_branch_cost
;
668 ptr
->x_ix86_dump_tunes
= opts
->x_ix86_dump_tunes
;
669 ptr
->x_ix86_force_align_arg_pointer
= opts
->x_ix86_force_align_arg_pointer
;
670 ptr
->x_ix86_force_drap
= opts
->x_ix86_force_drap
;
671 ptr
->x_ix86_recip_name
= opts
->x_ix86_recip_name
;
672 ptr
->x_ix86_section_threshold
= opts
->x_ix86_section_threshold
;
673 ptr
->x_ix86_sse2avx
= opts
->x_ix86_sse2avx
;
674 ptr
->x_ix86_stack_protector_guard
= opts
->x_ix86_stack_protector_guard
;
675 ptr
->x_ix86_stringop_alg
= opts
->x_ix86_stringop_alg
;
676 ptr
->x_ix86_tls_dialect
= opts
->x_ix86_tls_dialect
;
677 ptr
->x_ix86_tune_ctrl_string
= opts
->x_ix86_tune_ctrl_string
;
678 ptr
->x_ix86_tune_memcpy_strategy
= opts
->x_ix86_tune_memcpy_strategy
;
679 ptr
->x_ix86_tune_memset_strategy
= opts
->x_ix86_tune_memset_strategy
;
680 ptr
->x_ix86_tune_no_default
= opts
->x_ix86_tune_no_default
;
682 /* The fields are char but the variables are not; make sure the
683 values fit in the fields. */
684 gcc_assert (ptr
->arch
== ix86_arch
);
685 gcc_assert (ptr
->schedule
== ix86_schedule
);
686 gcc_assert (ptr
->tune
== ix86_tune
);
687 gcc_assert (ptr
->branch_cost
== ix86_branch_cost
);
690 /* Feature tests against the various architecture variations, used to create
691 ix86_arch_features based on the processor mask. */
692 static unsigned HOST_WIDE_INT initial_ix86_arch_features
[X86_ARCH_LAST
] = {
693 /* X86_ARCH_CMOV: Conditional move was added for pentiumpro. */
694 ~(m_386
| m_486
| m_PENT
| m_LAKEMONT
| m_K6
),
696 /* X86_ARCH_CMPXCHG: Compare and exchange was added for 80486. */
699 /* X86_ARCH_CMPXCHG8B: Compare and exchange 8 bytes was added for pentium. */
702 /* X86_ARCH_XADD: Exchange and add was added for 80486. */
705 /* X86_ARCH_BSWAP: Byteswap was added for 80486. */
709 /* This table must be in sync with enum processor_type in i386.h. */
710 static const struct processor_costs
*processor_cost_table
[] =
759 /* Guarantee that the array is aligned with enum processor_type. */
760 STATIC_ASSERT (ARRAY_SIZE (processor_cost_table
) == PROCESSOR_max
);
763 ix86_option_override_internal (bool main_args_p
,
764 struct gcc_options
*opts
,
765 struct gcc_options
*opts_set
);
767 set_ix86_tune_features (struct gcc_options
*opts
,
768 enum processor_type ix86_tune
, bool dump
);
770 /* Restore the current options */
773 ix86_function_specific_restore (struct gcc_options
*opts
,
774 struct gcc_options */
* opts_set */
,
775 struct cl_target_option
*ptr
)
777 enum processor_type old_tune
= ix86_tune
;
778 enum processor_type old_arch
= ix86_arch
;
779 unsigned HOST_WIDE_INT ix86_arch_mask
;
782 /* We don't change -fPIC. */
783 opts
->x_flag_pic
= flag_pic
;
785 ix86_arch
= (enum processor_type
) ptr
->arch
;
786 ix86_schedule
= (enum attr_cpu
) ptr
->schedule
;
787 ix86_tune
= (enum processor_type
) ptr
->tune
;
788 ix86_prefetch_sse
= ptr
->prefetch_sse
;
789 ix86_tune_defaulted
= ptr
->tune_defaulted
;
790 ix86_arch_specified
= ptr
->arch_specified
;
791 opts
->x_ix86_isa_flags_explicit
= ptr
->x_ix86_isa_flags_explicit
;
792 opts
->x_ix86_isa_flags2_explicit
= ptr
->x_ix86_isa_flags2_explicit
;
793 opts
->x_recip_mask_explicit
= ptr
->x_recip_mask_explicit
;
794 opts
->x_ix86_arch_string
= ptr
->x_ix86_arch_string
;
795 opts
->x_ix86_tune_string
= ptr
->x_ix86_tune_string
;
796 opts
->x_ix86_abi
= ptr
->x_ix86_abi
;
797 opts
->x_ix86_asm_dialect
= ptr
->x_ix86_asm_dialect
;
798 opts
->x_ix86_branch_cost
= ptr
->x_ix86_branch_cost
;
799 opts
->x_ix86_dump_tunes
= ptr
->x_ix86_dump_tunes
;
800 opts
->x_ix86_force_align_arg_pointer
= ptr
->x_ix86_force_align_arg_pointer
;
801 opts
->x_ix86_force_drap
= ptr
->x_ix86_force_drap
;
802 opts
->x_ix86_recip_name
= ptr
->x_ix86_recip_name
;
803 opts
->x_ix86_section_threshold
= ptr
->x_ix86_section_threshold
;
804 opts
->x_ix86_sse2avx
= ptr
->x_ix86_sse2avx
;
805 opts
->x_ix86_stack_protector_guard
= ptr
->x_ix86_stack_protector_guard
;
806 opts
->x_ix86_stringop_alg
= ptr
->x_ix86_stringop_alg
;
807 opts
->x_ix86_tls_dialect
= ptr
->x_ix86_tls_dialect
;
808 opts
->x_ix86_tune_ctrl_string
= ptr
->x_ix86_tune_ctrl_string
;
809 opts
->x_ix86_tune_memcpy_strategy
= ptr
->x_ix86_tune_memcpy_strategy
;
810 opts
->x_ix86_tune_memset_strategy
= ptr
->x_ix86_tune_memset_strategy
;
811 opts
->x_ix86_tune_no_default
= ptr
->x_ix86_tune_no_default
;
812 ix86_tune_cost
= processor_cost_table
[ix86_tune
];
813 /* TODO: ix86_cost should be chosen at instruction or function granuality
814 so for cold code we use size_cost even in !optimize_size compilation. */
815 if (opts
->x_optimize_size
)
816 ix86_cost
= &ix86_size_cost
;
818 ix86_cost
= ix86_tune_cost
;
820 /* Recreate the arch feature tests if the arch changed */
821 if (old_arch
!= ix86_arch
)
823 ix86_arch_mask
= HOST_WIDE_INT_1U
<< ix86_arch
;
824 for (i
= 0; i
< X86_ARCH_LAST
; ++i
)
825 ix86_arch_features
[i
]
826 = !!(initial_ix86_arch_features
[i
] & ix86_arch_mask
);
829 /* Recreate the tune optimization tests */
830 if (old_tune
!= ix86_tune
)
831 set_ix86_tune_features (opts
, ix86_tune
, false);
834 /* Adjust target options after streaming them in. This is mainly about
835 reconciling them with global options. */
838 ix86_function_specific_post_stream_in (struct cl_target_option
*ptr
)
840 /* flag_pic is a global option, but ix86_cmodel is target saved option
841 partly computed from flag_pic. If flag_pic is on, adjust x_ix86_cmodel
842 for PIC, or error out. */
844 switch (ptr
->x_ix86_cmodel
)
847 ptr
->x_ix86_cmodel
= CM_SMALL_PIC
;
851 ptr
->x_ix86_cmodel
= CM_MEDIUM_PIC
;
855 ptr
->x_ix86_cmodel
= CM_LARGE_PIC
;
859 error ("code model %s does not support PIC mode", "kernel");
866 switch (ptr
->x_ix86_cmodel
)
869 ptr
->x_ix86_cmodel
= CM_SMALL
;
873 ptr
->x_ix86_cmodel
= CM_MEDIUM
;
877 ptr
->x_ix86_cmodel
= CM_LARGE
;
885 /* Print the current options */
888 ix86_function_specific_print (FILE *file
, int indent
,
889 struct cl_target_option
*ptr
)
892 = ix86_target_string (ptr
->x_ix86_isa_flags
, ptr
->x_ix86_isa_flags2
,
893 ptr
->x_target_flags
, ptr
->x_ix86_target_flags
,
894 NULL
, NULL
, ptr
->x_ix86_fpmath
,
895 ptr
->x_prefer_vector_width_type
, false, true);
897 gcc_assert (ptr
->arch
< PROCESSOR_max
);
898 fprintf (file
, "%*sarch = %d (%s)\n",
900 ptr
->arch
, processor_names
[ptr
->arch
]);
902 gcc_assert (ptr
->tune
< PROCESSOR_max
);
903 fprintf (file
, "%*stune = %d (%s)\n",
905 ptr
->tune
, processor_names
[ptr
->tune
]);
907 fprintf (file
, "%*sbranch_cost = %d\n", indent
, "", ptr
->branch_cost
);
911 fprintf (file
, "%*s%s\n", indent
, "", target_string
);
912 free (target_string
);
917 /* Inner function to process the attribute((target(...))), take an argument and
918 set the current options from the argument. If we have a list, recursively go
922 ix86_valid_target_attribute_inner_p (tree fndecl
, tree args
, char *p_strings
[],
923 struct gcc_options
*opts
,
924 struct gcc_options
*opts_set
,
925 struct gcc_options
*enum_opts_set
,
926 bool target_clone_attr
)
931 #define IX86_ATTR_ISA(S,O) { S, sizeof (S)-1, ix86_opt_isa, O, 0 }
932 #define IX86_ATTR_STR(S,O) { S, sizeof (S)-1, ix86_opt_str, O, 0 }
933 #define IX86_ATTR_ENUM(S,O) { S, sizeof (S)-1, ix86_opt_enum, O, 0 }
934 #define IX86_ATTR_YES(S,O,M) { S, sizeof (S)-1, ix86_opt_yes, O, M }
935 #define IX86_ATTR_NO(S,O,M) { S, sizeof (S)-1, ix86_opt_no, O, M }
936 #define IX86_ATTR_IX86_YES(S,O,M) \
937 { S, sizeof (S)-1, ix86_opt_ix86_yes, O, M }
938 #define IX86_ATTR_IX86_NO(S,O,M) \
939 { S, sizeof (S)-1, ix86_opt_ix86_no, O, M }
957 enum ix86_opt_type type
;
962 IX86_ATTR_ISA ("pconfig", OPT_mpconfig
),
963 IX86_ATTR_ISA ("wbnoinvd", OPT_mwbnoinvd
),
964 IX86_ATTR_ISA ("sgx", OPT_msgx
),
965 IX86_ATTR_ISA ("avx5124fmaps", OPT_mavx5124fmaps
),
966 IX86_ATTR_ISA ("avx5124vnniw", OPT_mavx5124vnniw
),
967 IX86_ATTR_ISA ("avx512vpopcntdq", OPT_mavx512vpopcntdq
),
968 IX86_ATTR_ISA ("avx512vbmi2", OPT_mavx512vbmi2
),
969 IX86_ATTR_ISA ("avx512vnni", OPT_mavx512vnni
),
970 IX86_ATTR_ISA ("avx512bitalg", OPT_mavx512bitalg
),
971 IX86_ATTR_ISA ("avx512vp2intersect", OPT_mavx512vp2intersect
),
973 IX86_ATTR_ISA ("avx512vbmi", OPT_mavx512vbmi
),
974 IX86_ATTR_ISA ("avx512ifma", OPT_mavx512ifma
),
975 IX86_ATTR_ISA ("avx512vl", OPT_mavx512vl
),
976 IX86_ATTR_ISA ("avx512bw", OPT_mavx512bw
),
977 IX86_ATTR_ISA ("avx512dq", OPT_mavx512dq
),
978 IX86_ATTR_ISA ("avx512er", OPT_mavx512er
),
979 IX86_ATTR_ISA ("avx512pf", OPT_mavx512pf
),
980 IX86_ATTR_ISA ("avx512cd", OPT_mavx512cd
),
981 IX86_ATTR_ISA ("avx512f", OPT_mavx512f
),
982 IX86_ATTR_ISA ("avx2", OPT_mavx2
),
983 IX86_ATTR_ISA ("fma", OPT_mfma
),
984 IX86_ATTR_ISA ("xop", OPT_mxop
),
985 IX86_ATTR_ISA ("fma4", OPT_mfma4
),
986 IX86_ATTR_ISA ("f16c", OPT_mf16c
),
987 IX86_ATTR_ISA ("avx", OPT_mavx
),
988 IX86_ATTR_ISA ("sse4", OPT_msse4
),
989 IX86_ATTR_ISA ("sse4.2", OPT_msse4_2
),
990 IX86_ATTR_ISA ("sse4.1", OPT_msse4_1
),
991 IX86_ATTR_ISA ("sse4a", OPT_msse4a
),
992 IX86_ATTR_ISA ("ssse3", OPT_mssse3
),
993 IX86_ATTR_ISA ("sse3", OPT_msse3
),
994 IX86_ATTR_ISA ("aes", OPT_maes
),
995 IX86_ATTR_ISA ("sha", OPT_msha
),
996 IX86_ATTR_ISA ("pclmul", OPT_mpclmul
),
997 IX86_ATTR_ISA ("sse2", OPT_msse2
),
998 IX86_ATTR_ISA ("sse", OPT_msse
),
999 IX86_ATTR_ISA ("3dnowa", OPT_m3dnowa
),
1000 IX86_ATTR_ISA ("3dnow", OPT_m3dnow
),
1001 IX86_ATTR_ISA ("mmx", OPT_mmmx
),
1002 IX86_ATTR_ISA ("rtm", OPT_mrtm
),
1003 IX86_ATTR_ISA ("prfchw", OPT_mprfchw
),
1004 IX86_ATTR_ISA ("rdseed", OPT_mrdseed
),
1005 IX86_ATTR_ISA ("adx", OPT_madx
),
1006 IX86_ATTR_ISA ("prefetchwt1", OPT_mprefetchwt1
),
1007 IX86_ATTR_ISA ("clflushopt", OPT_mclflushopt
),
1008 IX86_ATTR_ISA ("xsaves", OPT_mxsaves
),
1009 IX86_ATTR_ISA ("xsavec", OPT_mxsavec
),
1010 IX86_ATTR_ISA ("xsaveopt", OPT_mxsaveopt
),
1011 IX86_ATTR_ISA ("xsave", OPT_mxsave
),
1012 IX86_ATTR_ISA ("abm", OPT_mabm
),
1013 IX86_ATTR_ISA ("bmi", OPT_mbmi
),
1014 IX86_ATTR_ISA ("bmi2", OPT_mbmi2
),
1015 IX86_ATTR_ISA ("lzcnt", OPT_mlzcnt
),
1016 IX86_ATTR_ISA ("tbm", OPT_mtbm
),
1017 IX86_ATTR_ISA ("popcnt", OPT_mpopcnt
),
1018 IX86_ATTR_ISA ("cx16", OPT_mcx16
),
1019 IX86_ATTR_ISA ("sahf", OPT_msahf
),
1020 IX86_ATTR_ISA ("movbe", OPT_mmovbe
),
1021 IX86_ATTR_ISA ("crc32", OPT_mcrc32
),
1022 IX86_ATTR_ISA ("fsgsbase", OPT_mfsgsbase
),
1023 IX86_ATTR_ISA ("rdrnd", OPT_mrdrnd
),
1024 IX86_ATTR_ISA ("mwaitx", OPT_mmwaitx
),
1025 IX86_ATTR_ISA ("mwait", OPT_mmwait
),
1026 IX86_ATTR_ISA ("clzero", OPT_mclzero
),
1027 IX86_ATTR_ISA ("pku", OPT_mpku
),
1028 IX86_ATTR_ISA ("lwp", OPT_mlwp
),
1029 IX86_ATTR_ISA ("hle", OPT_mhle
),
1030 IX86_ATTR_ISA ("fxsr", OPT_mfxsr
),
1031 IX86_ATTR_ISA ("clwb", OPT_mclwb
),
1032 IX86_ATTR_ISA ("rdpid", OPT_mrdpid
),
1033 IX86_ATTR_ISA ("gfni", OPT_mgfni
),
1034 IX86_ATTR_ISA ("shstk", OPT_mshstk
),
1035 IX86_ATTR_ISA ("vaes", OPT_mvaes
),
1036 IX86_ATTR_ISA ("vpclmulqdq", OPT_mvpclmulqdq
),
1037 IX86_ATTR_ISA ("movdiri", OPT_mmovdiri
),
1038 IX86_ATTR_ISA ("movdir64b", OPT_mmovdir64b
),
1039 IX86_ATTR_ISA ("waitpkg", OPT_mwaitpkg
),
1040 IX86_ATTR_ISA ("cldemote", OPT_mcldemote
),
1041 IX86_ATTR_ISA ("uintr", OPT_muintr
),
1042 IX86_ATTR_ISA ("ptwrite", OPT_mptwrite
),
1043 IX86_ATTR_ISA ("kl", OPT_mkl
),
1044 IX86_ATTR_ISA ("widekl", OPT_mwidekl
),
1045 IX86_ATTR_ISA ("avx512bf16", OPT_mavx512bf16
),
1046 IX86_ATTR_ISA ("enqcmd", OPT_menqcmd
),
1047 IX86_ATTR_ISA ("serialize", OPT_mserialize
),
1048 IX86_ATTR_ISA ("tsxldtrk", OPT_mtsxldtrk
),
1049 IX86_ATTR_ISA ("amx-tile", OPT_mamx_tile
),
1050 IX86_ATTR_ISA ("amx-int8", OPT_mamx_int8
),
1051 IX86_ATTR_ISA ("amx-bf16", OPT_mamx_bf16
),
1052 IX86_ATTR_ISA ("hreset", OPT_mhreset
),
1053 IX86_ATTR_ISA ("avxvnni", OPT_mavxvnni
),
1054 IX86_ATTR_ISA ("avx512fp16", OPT_mavx512fp16
),
1057 IX86_ATTR_ENUM ("fpmath=", OPT_mfpmath_
),
1058 IX86_ATTR_ENUM ("prefer-vector-width=", OPT_mprefer_vector_width_
),
1060 /* string options */
1061 IX86_ATTR_STR ("arch=", IX86_FUNCTION_SPECIFIC_ARCH
),
1062 IX86_ATTR_STR ("tune=", IX86_FUNCTION_SPECIFIC_TUNE
),
1065 IX86_ATTR_YES ("cld",
1069 IX86_ATTR_NO ("fancy-math-387",
1070 OPT_mfancy_math_387
,
1071 MASK_NO_FANCY_MATH_387
),
1073 IX86_ATTR_YES ("ieee-fp",
1077 IX86_ATTR_YES ("inline-all-stringops",
1078 OPT_minline_all_stringops
,
1079 MASK_INLINE_ALL_STRINGOPS
),
1081 IX86_ATTR_YES ("inline-stringops-dynamically",
1082 OPT_minline_stringops_dynamically
,
1083 MASK_INLINE_STRINGOPS_DYNAMICALLY
),
1085 IX86_ATTR_NO ("align-stringops",
1086 OPT_mno_align_stringops
,
1087 MASK_NO_ALIGN_STRINGOPS
),
1089 IX86_ATTR_YES ("recip",
1093 IX86_ATTR_IX86_YES ("general-regs-only",
1094 OPT_mgeneral_regs_only
,
1095 OPTION_MASK_GENERAL_REGS_ONLY
),
1097 IX86_ATTR_YES ("relax-cmpxchg-loop",
1098 OPT_mrelax_cmpxchg_loop
,
1099 MASK_RELAX_CMPXCHG_LOOP
),
1103 = fndecl
== NULL
? UNKNOWN_LOCATION
: DECL_SOURCE_LOCATION (fndecl
);
1104 const char *attr_name
= target_clone_attr
? "target_clone" : "target";
1106 /* If this is a list, recurse to get the options. */
1107 if (TREE_CODE (args
) == TREE_LIST
)
1109 for (; args
; args
= TREE_CHAIN (args
))
1110 if (TREE_VALUE (args
)
1111 && !ix86_valid_target_attribute_inner_p (fndecl
, TREE_VALUE (args
),
1112 p_strings
, opts
, opts_set
,
1120 else if (TREE_CODE (args
) != STRING_CST
)
1122 error_at (loc
, "attribute %qs argument is not a string", attr_name
);
1126 /* Handle multiple arguments separated by commas. */
1127 next_optstr
= ASTRDUP (TREE_STRING_POINTER (args
));
1129 while (next_optstr
&& *next_optstr
!= '\0')
1131 char *p
= next_optstr
;
1133 char *comma
= strchr (next_optstr
, ',');
1134 size_t len
, opt_len
;
1139 enum ix86_opt_type type
= ix86_opt_unknown
;
1145 len
= comma
- next_optstr
;
1146 next_optstr
= comma
+ 1;
1154 /* Recognize no-xxx. */
1155 if (len
> 3 && p
[0] == 'n' && p
[1] == 'o' && p
[2] == '-')
1164 /* Find the option. */
1167 for (i
= 0; i
< ARRAY_SIZE (attrs
); i
++)
1169 type
= attrs
[i
].type
;
1170 opt_len
= attrs
[i
].len
;
1171 if (ch
== attrs
[i
].string
[0]
1172 && ((type
!= ix86_opt_str
&& type
!= ix86_opt_enum
)
1175 && memcmp (p
, attrs
[i
].string
, opt_len
) == 0)
1178 mask
= attrs
[i
].mask
;
1183 /* Process the option. */
1186 error_at (loc
, "attribute %qs argument %qs is unknown",
1191 else if (type
== ix86_opt_isa
)
1193 struct cl_decoded_option decoded
;
1195 generate_option (opt
, NULL
, opt_set_p
, CL_TARGET
, &decoded
);
1196 ix86_handle_option (opts
, opts_set
,
1197 &decoded
, input_location
);
1200 else if (type
== ix86_opt_yes
|| type
== ix86_opt_no
)
1202 if (type
== ix86_opt_no
)
1203 opt_set_p
= !opt_set_p
;
1206 opts
->x_target_flags
|= mask
;
1208 opts
->x_target_flags
&= ~mask
;
1211 else if (type
== ix86_opt_ix86_yes
|| type
== ix86_opt_ix86_no
)
1213 if (mask
== OPTION_MASK_GENERAL_REGS_ONLY
)
1217 error_at (loc
, "pragma or attribute %<target(\"%s\")%> "
1218 "does not allow a negated form", p
);
1222 if (type
!= ix86_opt_ix86_yes
)
1225 opts
->x_ix86_target_flags
|= mask
;
1227 struct cl_decoded_option decoded
;
1228 generate_option (opt
, NULL
, opt_set_p
, CL_TARGET
,
1230 ix86_handle_option (opts
, opts_set
, &decoded
,
1235 if (type
== ix86_opt_ix86_no
)
1236 opt_set_p
= !opt_set_p
;
1239 opts
->x_ix86_target_flags
|= mask
;
1241 opts
->x_ix86_target_flags
&= ~mask
;
1245 else if (type
== ix86_opt_str
)
1249 error_at (loc
, "attribute value %qs was already specified "
1250 "in %qs attribute", orig_p
, attr_name
);
1255 p_strings
[opt
] = xstrdup (p
+ opt_len
);
1256 if (opt
== IX86_FUNCTION_SPECIFIC_ARCH
)
1258 /* If arch= is set, clear all bits in x_ix86_isa_flags,
1259 except for ISA_64BIT, ABI_64, ABI_X32, and CODE16
1260 and all bits in x_ix86_isa_flags2. */
1261 opts
->x_ix86_isa_flags
&= (OPTION_MASK_ISA_64BIT
1262 | OPTION_MASK_ABI_64
1263 | OPTION_MASK_ABI_X32
1264 | OPTION_MASK_CODE16
);
1265 opts
->x_ix86_isa_flags_explicit
&= (OPTION_MASK_ISA_64BIT
1266 | OPTION_MASK_ABI_64
1267 | OPTION_MASK_ABI_X32
1268 | OPTION_MASK_CODE16
);
1269 opts
->x_ix86_isa_flags2
= 0;
1270 opts
->x_ix86_isa_flags2_explicit
= 0;
1275 else if (type
== ix86_opt_enum
)
1280 arg_ok
= opt_enum_arg_to_value (opt
, p
+ opt_len
, &value
, CL_TARGET
);
1282 set_option (opts
, enum_opts_set
, opt
, value
,
1283 p
+ opt_len
, DK_UNSPECIFIED
, input_location
,
1287 error_at (loc
, "attribute value %qs is unknown in %qs attribute",
1300 /* Release allocated strings. */
1302 release_options_strings (char **option_strings
)
1304 /* Free up memory allocated to hold the strings */
1305 for (unsigned i
= 0; i
< IX86_FUNCTION_SPECIFIC_MAX
; i
++)
1306 free (option_strings
[i
]);
1309 /* Return a TARGET_OPTION_NODE tree of the target options listed or NULL. */
1312 ix86_valid_target_attribute_tree (tree fndecl
, tree args
,
1313 struct gcc_options
*opts
,
1314 struct gcc_options
*opts_set
,
1315 bool target_clone_attr
)
1317 const char *orig_arch_string
= opts
->x_ix86_arch_string
;
1318 const char *orig_tune_string
= opts
->x_ix86_tune_string
;
1319 enum fpmath_unit orig_fpmath_set
= opts_set
->x_ix86_fpmath
;
1320 enum prefer_vector_width orig_pvw_set
= opts_set
->x_prefer_vector_width_type
;
1321 int orig_tune_defaulted
= ix86_tune_defaulted
;
1322 int orig_arch_specified
= ix86_arch_specified
;
1323 char *option_strings
[IX86_FUNCTION_SPECIFIC_MAX
] = { NULL
, NULL
};
1325 struct cl_target_option
*def
1326 = TREE_TARGET_OPTION (target_option_default_node
);
1327 struct gcc_options enum_opts_set
;
1329 memset (&enum_opts_set
, 0, sizeof (enum_opts_set
));
1331 /* Process each of the options on the chain. */
1332 if (!ix86_valid_target_attribute_inner_p (fndecl
, args
, option_strings
, opts
,
1333 opts_set
, &enum_opts_set
,
1335 return error_mark_node
;
1337 /* If the changed options are different from the default, rerun
1338 ix86_option_override_internal, and then save the options away.
1339 The string options are attribute options, and will be undone
1340 when we copy the save structure. */
1341 if (opts
->x_ix86_isa_flags
!= def
->x_ix86_isa_flags
1342 || opts
->x_ix86_isa_flags2
!= def
->x_ix86_isa_flags2
1343 || opts
->x_target_flags
!= def
->x_target_flags
1344 || option_strings
[IX86_FUNCTION_SPECIFIC_ARCH
]
1345 || option_strings
[IX86_FUNCTION_SPECIFIC_TUNE
]
1346 || enum_opts_set
.x_ix86_fpmath
1347 || enum_opts_set
.x_prefer_vector_width_type
)
1349 /* If we are using the default tune= or arch=, undo the string assigned,
1350 and use the default. */
1351 if (option_strings
[IX86_FUNCTION_SPECIFIC_ARCH
])
1352 opts
->x_ix86_arch_string
1353 = ggc_strdup (option_strings
[IX86_FUNCTION_SPECIFIC_ARCH
]);
1354 else if (!orig_arch_specified
)
1355 opts
->x_ix86_arch_string
= NULL
;
1357 if (option_strings
[IX86_FUNCTION_SPECIFIC_TUNE
])
1358 opts
->x_ix86_tune_string
1359 = ggc_strdup (option_strings
[IX86_FUNCTION_SPECIFIC_TUNE
]);
1360 else if (orig_tune_defaulted
)
1361 opts
->x_ix86_tune_string
= NULL
;
1363 /* If fpmath= is not set, and we now have sse2 on 32-bit, use it. */
1364 if (enum_opts_set
.x_ix86_fpmath
)
1365 opts_set
->x_ix86_fpmath
= (enum fpmath_unit
) 1;
1366 if (enum_opts_set
.x_prefer_vector_width_type
)
1367 opts_set
->x_prefer_vector_width_type
= (enum prefer_vector_width
) 1;
1369 /* Do any overrides, such as arch=xxx, or tune=xxx support. */
1370 bool r
= ix86_option_override_internal (false, opts
, opts_set
);
1373 release_options_strings (option_strings
);
1374 return error_mark_node
;
1377 /* Add any builtin functions with the new isa if any. */
1378 ix86_add_new_builtins (opts
->x_ix86_isa_flags
, opts
->x_ix86_isa_flags2
);
1380 enum excess_precision orig_ix86_excess_precision
1381 = opts
->x_ix86_excess_precision
;
1382 bool orig_ix86_unsafe_math_optimizations
1383 = opts
->x_ix86_unsafe_math_optimizations
;
1384 opts
->x_ix86_excess_precision
= opts
->x_flag_excess_precision
;
1385 opts
->x_ix86_unsafe_math_optimizations
1386 = opts
->x_flag_unsafe_math_optimizations
;
1388 /* Save the current options unless we are validating options for
1390 t
= build_target_option_node (opts
, opts_set
);
1392 opts
->x_ix86_arch_string
= orig_arch_string
;
1393 opts
->x_ix86_tune_string
= orig_tune_string
;
1394 opts_set
->x_ix86_fpmath
= orig_fpmath_set
;
1395 opts_set
->x_prefer_vector_width_type
= orig_pvw_set
;
1396 opts
->x_ix86_excess_precision
= orig_ix86_excess_precision
;
1397 opts
->x_ix86_unsafe_math_optimizations
1398 = orig_ix86_unsafe_math_optimizations
;
1400 release_options_strings (option_strings
);
1406 /* Hook to validate attribute((target("string"))). */
1409 ix86_valid_target_attribute_p (tree fndecl
,
1410 tree
ARG_UNUSED (name
),
1414 struct gcc_options func_options
, func_options_set
;
1415 tree new_target
, new_optimize
;
1418 /* attribute((target("default"))) does nothing, beyond
1419 affecting multi-versioning. */
1420 if (TREE_VALUE (args
)
1421 && TREE_CODE (TREE_VALUE (args
)) == STRING_CST
1422 && TREE_CHAIN (args
) == NULL_TREE
1423 && strcmp (TREE_STRING_POINTER (TREE_VALUE (args
)), "default") == 0)
1426 tree old_optimize
= build_optimization_node (&global_options
,
1427 &global_options_set
);
1429 /* Get the optimization options of the current function. */
1430 tree func_optimize
= DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl
);
1433 func_optimize
= old_optimize
;
1435 /* Init func_options. */
1436 memset (&func_options
, 0, sizeof (func_options
));
1437 init_options_struct (&func_options
, NULL
);
1438 lang_hooks
.init_options_struct (&func_options
);
1439 memset (&func_options_set
, 0, sizeof (func_options_set
));
1441 cl_optimization_restore (&func_options
, &func_options_set
,
1442 TREE_OPTIMIZATION (func_optimize
));
1444 /* Initialize func_options to the default before its target options can
1446 cl_target_option_restore (&func_options
, &func_options_set
,
1447 TREE_TARGET_OPTION (target_option_default_node
));
1449 /* FLAGS == 1 is used for target_clones attribute. */
1451 = ix86_valid_target_attribute_tree (fndecl
, args
, &func_options
,
1452 &func_options_set
, flags
== 1);
1454 new_optimize
= build_optimization_node (&func_options
, &func_options_set
);
1456 if (new_target
== error_mark_node
)
1459 else if (fndecl
&& new_target
)
1461 DECL_FUNCTION_SPECIFIC_TARGET (fndecl
) = new_target
;
1463 if (old_optimize
!= new_optimize
)
1464 DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl
) = new_optimize
;
1470 const char *stringop_alg_names
[] = {
1471 #define DEF_ALG(alg, name) #name,
1472 #include "stringop.def"
1476 /* Parse parameter string passed to -mmemcpy-strategy= or -mmemset-strategy=.
1477 The string is of the following form (or comma separated list of it):
1479 strategy_alg:max_size:[align|noalign]
1481 where the full size range for the strategy is either [0, max_size] or
1482 [min_size, max_size], in which min_size is the max_size + 1 of the
1483 preceding range. The last size range must have max_size == -1.
1488 -mmemcpy-strategy=libcall:-1:noalign
1490 this is equivalent to (for known size memcpy) -mstringop-strategy=libcall
1494 -mmemset-strategy=rep_8byte:16:noalign,vector_loop:2048:align,libcall:-1:noalign
1496 This is to tell the compiler to use the following strategy for memset
1497 1) when the expected size is between [1, 16], use rep_8byte strategy;
1498 2) when the size is between [17, 2048], use vector_loop;
1499 3) when the size is > 2048, use libcall. */
1501 struct stringop_size_range
1509 ix86_parse_stringop_strategy_string (char *strategy_str
, bool is_memset
)
1511 const struct stringop_algs
*default_algs
;
1512 stringop_size_range input_ranges
[MAX_STRINGOP_ALGS
];
1513 char *curr_range_str
, *next_range_str
;
1514 const char *opt
= is_memset
? "-mmemset_strategy=" : "-mmemcpy_strategy=";
1518 default_algs
= &ix86_cost
->memset
[TARGET_64BIT
!= 0];
1520 default_algs
= &ix86_cost
->memcpy
[TARGET_64BIT
!= 0];
1522 curr_range_str
= strategy_str
;
1529 next_range_str
= strchr (curr_range_str
, ',');
1531 *next_range_str
++ = '\0';
1533 if (sscanf (curr_range_str
, "%20[^:]:%d:%10s", alg_name
, &maxs
,
1536 error ("wrong argument %qs to option %qs", curr_range_str
, opt
);
1540 if (n
> 0 && (maxs
< (input_ranges
[n
- 1].max
+ 1) && maxs
!= -1))
1542 error ("size ranges of option %qs should be increasing", opt
);
1546 for (i
= 0; i
< last_alg
; i
++)
1547 if (!strcmp (alg_name
, stringop_alg_names
[i
]))
1552 error ("wrong strategy name %qs specified for option %qs",
1555 auto_vec
<const char *> candidates
;
1556 for (i
= 0; i
< last_alg
; i
++)
1557 if ((stringop_alg
) i
!= rep_prefix_8_byte
|| TARGET_64BIT
)
1558 candidates
.safe_push (stringop_alg_names
[i
]);
1562 = candidates_list_and_hint (alg_name
, s
, candidates
);
1564 inform (input_location
,
1565 "valid arguments to %qs are: %s; did you mean %qs?",
1568 inform (input_location
, "valid arguments to %qs are: %s",
1574 if ((stringop_alg
) i
== rep_prefix_8_byte
1577 /* rep; movq isn't available in 32-bit code. */
1578 error ("strategy name %qs specified for option %qs "
1579 "not supported for 32-bit code", alg_name
, opt
);
1583 input_ranges
[n
].max
= maxs
;
1584 input_ranges
[n
].alg
= (stringop_alg
) i
;
1585 if (!strcmp (align
, "align"))
1586 input_ranges
[n
].noalign
= false;
1587 else if (!strcmp (align
, "noalign"))
1588 input_ranges
[n
].noalign
= true;
1591 error ("unknown alignment %qs specified for option %qs", align
, opt
);
1595 curr_range_str
= next_range_str
;
1597 while (curr_range_str
);
1599 if (input_ranges
[n
- 1].max
!= -1)
1601 error ("the max value for the last size range should be -1"
1602 " for option %qs", opt
);
1606 if (n
> MAX_STRINGOP_ALGS
)
1608 error ("too many size ranges specified in option %qs", opt
);
1612 /* Now override the default algs array. */
1613 for (i
= 0; i
< n
; i
++)
1615 *const_cast<int *>(&default_algs
->size
[i
].max
) = input_ranges
[i
].max
;
1616 *const_cast<stringop_alg
*>(&default_algs
->size
[i
].alg
)
1617 = input_ranges
[i
].alg
;
1618 *const_cast<int *>(&default_algs
->size
[i
].noalign
)
1619 = input_ranges
[i
].noalign
;
1624 /* parse -mtune-ctrl= option. When DUMP is true,
1625 print the features that are explicitly set. */
1628 parse_mtune_ctrl_str (struct gcc_options
*opts
, bool dump
)
1630 if (!opts
->x_ix86_tune_ctrl_string
)
1633 char *next_feature_string
= NULL
;
1634 char *curr_feature_string
= xstrdup (opts
->x_ix86_tune_ctrl_string
);
1635 char *orig
= curr_feature_string
;
1641 next_feature_string
= strchr (curr_feature_string
, ',');
1642 if (next_feature_string
)
1643 *next_feature_string
++ = '\0';
1644 if (*curr_feature_string
== '^')
1646 curr_feature_string
++;
1649 for (i
= 0; i
< X86_TUNE_LAST
; i
++)
1651 if (!strcmp (curr_feature_string
, ix86_tune_feature_names
[i
]))
1653 ix86_tune_features
[i
] = !clear
;
1655 fprintf (stderr
, "Explicitly %s feature %s\n",
1656 clear
? "clear" : "set", ix86_tune_feature_names
[i
]);
1660 if (i
== X86_TUNE_LAST
)
1661 error ("unknown parameter to option %<-mtune-ctrl%>: %s",
1662 clear
? curr_feature_string
- 1 : curr_feature_string
);
1663 curr_feature_string
= next_feature_string
;
1665 while (curr_feature_string
);
1669 /* Helper function to set ix86_tune_features. IX86_TUNE is the
1673 set_ix86_tune_features (struct gcc_options
*opts
,
1674 enum processor_type ix86_tune
, bool dump
)
1676 unsigned HOST_WIDE_INT ix86_tune_mask
= HOST_WIDE_INT_1U
<< ix86_tune
;
1679 for (i
= 0; i
< X86_TUNE_LAST
; ++i
)
1681 if (ix86_tune_no_default
)
1682 ix86_tune_features
[i
] = 0;
1684 ix86_tune_features
[i
]
1685 = !!(initial_ix86_tune_features
[i
] & ix86_tune_mask
);
1690 fprintf (stderr
, "List of x86 specific tuning parameter names:\n");
1691 for (i
= 0; i
< X86_TUNE_LAST
; i
++)
1692 fprintf (stderr
, "%s : %s\n", ix86_tune_feature_names
[i
],
1693 ix86_tune_features
[i
] ? "on" : "off");
1696 parse_mtune_ctrl_str (opts
, dump
);
1700 /* Default align_* from the processor table. */
1703 ix86_default_align (struct gcc_options
*opts
)
1705 /* -falign-foo without argument: supply one. */
1706 if (opts
->x_flag_align_loops
&& !opts
->x_str_align_loops
)
1707 opts
->x_str_align_loops
= processor_cost_table
[ix86_tune
]->align_loop
;
1708 if (opts
->x_flag_align_jumps
&& !opts
->x_str_align_jumps
)
1709 opts
->x_str_align_jumps
= processor_cost_table
[ix86_tune
]->align_jump
;
1710 if (opts
->x_flag_align_labels
&& !opts
->x_str_align_labels
)
1711 opts
->x_str_align_labels
= processor_cost_table
[ix86_tune
]->align_label
;
1712 if (opts
->x_flag_align_functions
&& !opts
->x_str_align_functions
)
1713 opts
->x_str_align_functions
= processor_cost_table
[ix86_tune
]->align_func
;
1716 #ifndef USE_IX86_FRAME_POINTER
1717 #define USE_IX86_FRAME_POINTER 0
1720 /* (Re)compute option overrides affected by optimization levels in
1721 target-specific ways. */
1724 ix86_recompute_optlev_based_flags (struct gcc_options
*opts
,
1725 struct gcc_options
*opts_set
)
1727 /* Set the default values for switches whose default depends on TARGET_64BIT
1728 in case they weren't overwritten by command line options. */
1729 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1731 if (opts
->x_optimize
>= 1)
1732 SET_OPTION_IF_UNSET (opts
, opts_set
, flag_omit_frame_pointer
,
1733 !USE_IX86_FRAME_POINTER
);
1734 if (opts
->x_flag_asynchronous_unwind_tables
1735 && TARGET_64BIT_MS_ABI
)
1736 SET_OPTION_IF_UNSET (opts
, opts_set
, flag_unwind_tables
, 1);
1737 if (opts
->x_flag_asynchronous_unwind_tables
== 2)
1738 opts
->x_flag_unwind_tables
1739 = opts
->x_flag_asynchronous_unwind_tables
= 1;
1740 if (opts
->x_flag_pcc_struct_return
== 2)
1741 opts
->x_flag_pcc_struct_return
= 0;
1745 if (opts
->x_optimize
>= 1)
1746 SET_OPTION_IF_UNSET (opts
, opts_set
, flag_omit_frame_pointer
,
1747 !(USE_IX86_FRAME_POINTER
|| opts
->x_optimize_size
));
1748 if (opts
->x_flag_asynchronous_unwind_tables
== 2)
1749 opts
->x_flag_asynchronous_unwind_tables
= !USE_IX86_FRAME_POINTER
;
1750 if (opts
->x_flag_pcc_struct_return
== 2)
1752 /* Intel MCU psABI specifies that -freg-struct-return should
1753 be on. Instead of setting DEFAULT_PCC_STRUCT_RETURN to 0,
1754 we check -miamcu so that -freg-struct-return is always
1755 turned on if -miamcu is used. */
1756 if (TARGET_IAMCU_P (opts
->x_target_flags
))
1757 opts
->x_flag_pcc_struct_return
= 0;
1759 opts
->x_flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
1764 /* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */
1767 ix86_override_options_after_change (void)
1769 ix86_default_align (&global_options
);
1770 ix86_recompute_optlev_based_flags (&global_options
, &global_options_set
);
1773 /* Clear stack slot assignments remembered from previous functions.
1774 This is called from INIT_EXPANDERS once before RTL is emitted for each
1777 static struct machine_function
*
1778 ix86_init_machine_status (void)
1780 struct machine_function
*f
;
1782 f
= ggc_cleared_alloc
<machine_function
> ();
1783 f
->call_abi
= ix86_abi
;
1784 f
->stack_frame_required
= true;
1790 /* Override various settings based on options. If MAIN_ARGS_P, the
1791 options are from the command line, otherwise they are from
1792 attributes. Return true if there's an error related to march
1796 ix86_option_override_internal (bool main_args_p
,
1797 struct gcc_options
*opts
,
1798 struct gcc_options
*opts_set
)
1801 unsigned HOST_WIDE_INT ix86_arch_mask
;
1802 const bool ix86_tune_specified
= (opts
->x_ix86_tune_string
!= NULL
);
1804 /* -mrecip options. */
1807 const char *string
; /* option name */
1808 unsigned int mask
; /* mask bits to set */
1810 const recip_options
[] =
1812 { "all", RECIP_MASK_ALL
},
1813 { "none", RECIP_MASK_NONE
},
1814 { "div", RECIP_MASK_DIV
},
1815 { "sqrt", RECIP_MASK_SQRT
},
1816 { "vec-div", RECIP_MASK_VEC_DIV
},
1817 { "vec-sqrt", RECIP_MASK_VEC_SQRT
},
1821 /* Turn off both OPTION_MASK_ABI_64 and OPTION_MASK_ABI_X32 if
1822 TARGET_64BIT_DEFAULT is true and TARGET_64BIT is false. */
1823 if (TARGET_64BIT_DEFAULT
&& !TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1824 opts
->x_ix86_isa_flags
&= ~(OPTION_MASK_ABI_64
| OPTION_MASK_ABI_X32
);
1825 #ifdef TARGET_BI_ARCH
1828 #if TARGET_BI_ARCH == 1
1829 /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ABI_64
1830 is on and OPTION_MASK_ABI_X32 is off. We turn off
1831 OPTION_MASK_ABI_64 if OPTION_MASK_ABI_X32 is turned on by
1833 if (TARGET_X32_P (opts
->x_ix86_isa_flags
))
1834 opts
->x_ix86_isa_flags
&= ~OPTION_MASK_ABI_64
;
1836 /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ABI_X32 is
1837 on and OPTION_MASK_ABI_64 is off. We turn off
1838 OPTION_MASK_ABI_X32 if OPTION_MASK_ABI_64 is turned on by
1839 -m64 or OPTION_MASK_CODE16 is turned on by -m16. */
1840 if (TARGET_LP64_P (opts
->x_ix86_isa_flags
)
1841 || TARGET_16BIT_P (opts
->x_ix86_isa_flags
))
1842 opts
->x_ix86_isa_flags
&= ~OPTION_MASK_ABI_X32
;
1844 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
1845 && TARGET_IAMCU_P (opts
->x_target_flags
))
1846 sorry ("Intel MCU psABI isn%'t supported in %s mode",
1847 TARGET_X32_P (opts
->x_ix86_isa_flags
) ? "x32" : "64-bit");
1851 if (TARGET_X32_P (opts
->x_ix86_isa_flags
))
1853 /* Always turn on OPTION_MASK_ISA_64BIT and turn off
1854 OPTION_MASK_ABI_64 for TARGET_X32. */
1855 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_64BIT
;
1856 opts
->x_ix86_isa_flags
&= ~OPTION_MASK_ABI_64
;
1858 else if (TARGET_16BIT_P (opts
->x_ix86_isa_flags
))
1859 opts
->x_ix86_isa_flags
&= ~(OPTION_MASK_ISA_64BIT
1860 | OPTION_MASK_ABI_X32
1861 | OPTION_MASK_ABI_64
);
1862 else if (TARGET_LP64_P (opts
->x_ix86_isa_flags
))
1864 /* Always turn on OPTION_MASK_ISA_64BIT and turn off
1865 OPTION_MASK_ABI_X32 for TARGET_LP64. */
1866 opts
->x_ix86_isa_flags
|= OPTION_MASK_ISA_64BIT
;
1867 opts
->x_ix86_isa_flags
&= ~OPTION_MASK_ABI_X32
;
1870 #ifdef SUBTARGET_OVERRIDE_OPTIONS
1871 SUBTARGET_OVERRIDE_OPTIONS
;
1874 #ifdef SUBSUBTARGET_OVERRIDE_OPTIONS
1875 SUBSUBTARGET_OVERRIDE_OPTIONS
;
1878 #ifdef HAVE_LD_BROKEN_PE_DWARF5
1879 /* If the PE linker has broken DWARF 5 support, make
1880 DWARF 4 the default. */
1882 SET_OPTION_IF_UNSET (opts
, opts_set
, dwarf_version
, 4);
1885 /* -fPIC is the default for x86_64. */
1886 if (TARGET_MACHO
&& TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1887 opts
->x_flag_pic
= 2;
1889 /* Need to check -mtune=generic first. */
1890 if (opts
->x_ix86_tune_string
)
1892 /* As special support for cross compilers we read -mtune=native
1893 as -mtune=generic. With native compilers we won't see the
1894 -mtune=native, as it was changed by the driver. */
1895 if (!strcmp (opts
->x_ix86_tune_string
, "native"))
1896 opts
->x_ix86_tune_string
= "generic";
1897 else if (!strcmp (opts
->x_ix86_tune_string
, "x86-64"))
1898 warning (OPT_Wdeprecated
,
1900 ? G_("%<-mtune=x86-64%> is deprecated; use %<-mtune=k8%> "
1901 "or %<-mtune=generic%> instead as appropriate")
1902 : G_("%<target(\"tune=x86-64\")%> is deprecated; use "
1903 "%<target(\"tune=k8\")%> or %<target(\"tune=generic\")%>"
1904 " instead as appropriate"));
1908 if (opts
->x_ix86_arch_string
)
1909 opts
->x_ix86_tune_string
= opts
->x_ix86_arch_string
;
1910 if (!opts
->x_ix86_tune_string
)
1912 opts
->x_ix86_tune_string
= processor_names
[TARGET_CPU_DEFAULT
];
1913 ix86_tune_defaulted
= 1;
1916 /* opts->x_ix86_tune_string is set to opts->x_ix86_arch_string
1917 or defaulted. We need to use a sensible tune option. */
1918 if (startswith (opts
->x_ix86_tune_string
, "x86-64")
1919 && (opts
->x_ix86_tune_string
[6] == '\0'
1920 || (!strcmp (opts
->x_ix86_tune_string
+ 6, "-v2")
1921 || !strcmp (opts
->x_ix86_tune_string
+ 6, "-v3")
1922 || !strcmp (opts
->x_ix86_tune_string
+ 6, "-v4"))))
1923 opts
->x_ix86_tune_string
= "generic";
1926 if (opts
->x_ix86_stringop_alg
== rep_prefix_8_byte
1927 && !TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1929 /* rep; movq isn't available in 32-bit code. */
1930 error ("%<-mstringop-strategy=rep_8byte%> not supported for 32-bit code");
1931 opts
->x_ix86_stringop_alg
= no_stringop
;
1934 if (TARGET_UINTR
&& !TARGET_64BIT
)
1935 error ("%<-muintr%> not supported for 32-bit code");
1937 if (!opts
->x_ix86_arch_string
)
1938 opts
->x_ix86_arch_string
1939 = TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
1940 ? "x86-64" : SUBTARGET32_DEFAULT_CPU
;
1942 ix86_arch_specified
= 1;
1944 if (opts_set
->x_ix86_pmode
)
1946 if ((TARGET_LP64_P (opts
->x_ix86_isa_flags
)
1947 && opts
->x_ix86_pmode
== PMODE_SI
)
1948 || (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
1949 && opts
->x_ix86_pmode
== PMODE_DI
))
1950 error ("address mode %qs not supported in the %s bit mode",
1951 TARGET_64BIT_P (opts
->x_ix86_isa_flags
) ? "short" : "long",
1952 TARGET_64BIT_P (opts
->x_ix86_isa_flags
) ? "64" : "32");
1955 opts
->x_ix86_pmode
= TARGET_LP64_P (opts
->x_ix86_isa_flags
)
1956 ? PMODE_DI
: PMODE_SI
;
1958 SET_OPTION_IF_UNSET (opts
, opts_set
, ix86_abi
, DEFAULT_ABI
);
1960 if (opts
->x_ix86_abi
== MS_ABI
&& TARGET_X32_P (opts
->x_ix86_isa_flags
))
1961 error ("%<-mabi=ms%> not supported with X32 ABI");
1962 gcc_assert (opts
->x_ix86_abi
== SYSV_ABI
|| opts
->x_ix86_abi
== MS_ABI
);
1964 const char *abi_name
= opts
->x_ix86_abi
== MS_ABI
? "ms" : "sysv";
1965 if ((opts
->x_flag_sanitize
& SANITIZE_USER_ADDRESS
)
1966 && opts
->x_ix86_abi
!= DEFAULT_ABI
)
1967 error ("%<-mabi=%s%> not supported with %<-fsanitize=address%>", abi_name
);
1968 if ((opts
->x_flag_sanitize
& SANITIZE_KERNEL_ADDRESS
)
1969 && opts
->x_ix86_abi
!= DEFAULT_ABI
)
1970 error ("%<-mabi=%s%> not supported with %<-fsanitize=kernel-address%>",
1972 if ((opts
->x_flag_sanitize
& SANITIZE_THREAD
)
1973 && opts
->x_ix86_abi
!= DEFAULT_ABI
)
1974 error ("%<-mabi=%s%> not supported with %<-fsanitize=thread%>", abi_name
);
1976 /* For targets using ms ABI enable ms-extensions, if not
1977 explicit turned off. For non-ms ABI we turn off this
1979 SET_OPTION_IF_UNSET (opts
, opts_set
, flag_ms_extensions
,
1980 (MS_ABI
== DEFAULT_ABI
));
1982 if (opts_set
->x_ix86_cmodel
)
1984 switch (opts
->x_ix86_cmodel
)
1988 if (opts
->x_flag_pic
)
1989 opts
->x_ix86_cmodel
= CM_SMALL_PIC
;
1990 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
1991 error ("code model %qs not supported in the %s bit mode",
1997 if (opts
->x_flag_pic
)
1998 opts
->x_ix86_cmodel
= CM_MEDIUM_PIC
;
1999 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2000 error ("code model %qs not supported in the %s bit mode",
2002 else if (TARGET_X32_P (opts
->x_ix86_isa_flags
))
2003 error ("code model %qs not supported in x32 mode",
2009 if (opts
->x_flag_pic
)
2010 opts
->x_ix86_cmodel
= CM_LARGE_PIC
;
2011 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2012 error ("code model %qs not supported in the %s bit mode",
2014 else if (TARGET_X32_P (opts
->x_ix86_isa_flags
))
2015 error ("code model %qs not supported in x32 mode",
2020 if (opts
->x_flag_pic
)
2021 error ("code model %s does not support PIC mode", "32");
2022 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2023 error ("code model %qs not supported in the %s bit mode",
2028 if (opts
->x_flag_pic
)
2030 error ("code model %s does not support PIC mode", "kernel");
2031 opts
->x_ix86_cmodel
= CM_32
;
2033 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2034 error ("code model %qs not supported in the %s bit mode",
2044 /* For TARGET_64BIT and MS_ABI, force pic on, in order to enable the
2045 use of rip-relative addressing. This eliminates fixups that
2046 would otherwise be needed if this object is to be placed in a
2047 DLL, and is essentially just as efficient as direct addressing. */
2048 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
2049 && (TARGET_RDOS
|| TARGET_PECOFF
))
2050 opts
->x_ix86_cmodel
= CM_MEDIUM_PIC
, opts
->x_flag_pic
= 1;
2051 else if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2052 opts
->x_ix86_cmodel
= opts
->x_flag_pic
? CM_SMALL_PIC
: CM_SMALL
;
2054 opts
->x_ix86_cmodel
= CM_32
;
2056 if (TARGET_MACHO
&& opts
->x_ix86_asm_dialect
== ASM_INTEL
)
2058 error ("%<-masm=intel%> not supported in this configuration");
2059 opts
->x_ix86_asm_dialect
= ASM_ATT
;
2061 if ((TARGET_64BIT_P (opts
->x_ix86_isa_flags
) != 0)
2062 != ((opts
->x_ix86_isa_flags
& OPTION_MASK_ISA_64BIT
) != 0))
2063 sorry ("%i-bit mode not compiled in",
2064 (opts
->x_ix86_isa_flags
& OPTION_MASK_ISA_64BIT
) ? 64 : 32);
2066 /* Last processor_alias_table must point to "generic" entry. */
2067 gcc_checking_assert (strcmp (processor_alias_table
[pta_size
- 1].name
,
2069 for (i
= 0; i
< pta_size
; i
++)
2070 if (! strcmp (opts
->x_ix86_arch_string
, processor_alias_table
[i
].name
))
2072 if (!strcmp (opts
->x_ix86_arch_string
, "generic"))
2075 ? G_("%<generic%> CPU can be used only for %<-mtune=%> "
2077 : G_("%<generic%> CPU can be used only for "
2078 "%<target(\"tune=\")%> attribute"));
2081 else if (!strcmp (opts
->x_ix86_arch_string
, "intel"))
2084 ? G_("%<intel%> CPU can be used only for %<-mtune=%> "
2086 : G_("%<intel%> CPU can be used only for "
2087 "%<target(\"tune=\")%> attribute"));
2091 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
2092 && !((processor_alias_table
[i
].flags
& PTA_64BIT
) != 0))
2094 error ("CPU you selected does not support x86-64 "
2099 ix86_schedule
= processor_alias_table
[i
].schedule
;
2100 ix86_arch
= processor_alias_table
[i
].processor
;
2102 /* Default cpu tuning to the architecture, unless the table
2103 entry requests not to do this. Used by the x86-64 psABI
2104 micro-architecture levels. */
2105 if ((processor_alias_table
[i
].flags
& PTA_NO_TUNE
) == 0)
2106 ix86_tune
= ix86_arch
;
2108 ix86_tune
= PROCESSOR_GENERIC
;
2110 /* Enable PTA flags that are enabled by default by a -march option. */
2111 #define TARGET_EXPLICIT_NO_SAHF_P(opts) (false)
2112 #define SET_TARGET_NO_SAHF(opts) {}
2113 #define TARGET_EXPLICIT_PREFETCH_SSE_P(opts) (false)
2114 #define SET_TARGET_PREFETCH_SSE(opts) {}
2115 #define TARGET_EXPLICIT_NO_TUNE_P(opts) (false)
2116 #define SET_TARGET_NO_TUNE(opts) {}
2117 #define TARGET_EXPLICIT_NO_80387_P(opts) (false)
2118 #define SET_TARGET_NO_80387(opts) {}
2120 #define DEF_PTA(NAME) \
2121 if (((processor_alias_table[i].flags & PTA_ ## NAME) != 0) \
2122 && PTA_ ## NAME != PTA_64BIT \
2123 && (TARGET_64BIT || PTA_ ## NAME != PTA_UINTR) \
2124 && !TARGET_EXPLICIT_ ## NAME ## _P (opts)) \
2125 SET_TARGET_ ## NAME (opts);
2126 #include "i386-isa.def"
2130 if (!(TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
2131 && ((processor_alias_table
[i
].flags
& PTA_NO_SAHF
) != 0))
2132 && !TARGET_EXPLICIT_SAHF_P (opts
))
2133 SET_TARGET_SAHF (opts
);
2135 if (((processor_alias_table
[i
].flags
& PTA_ABM
) != 0)
2136 && !TARGET_EXPLICIT_ABM_P (opts
))
2138 if (!TARGET_EXPLICIT_LZCNT_P (opts
))
2139 SET_TARGET_LZCNT (opts
);
2140 if (!TARGET_EXPLICIT_POPCNT_P (opts
))
2141 SET_TARGET_POPCNT (opts
);
2144 if ((processor_alias_table
[i
].flags
2145 & (PTA_PREFETCH_SSE
| PTA_SSE
)) != 0)
2146 ix86_prefetch_sse
= true;
2148 /* Don't enable x87 instructions if only general registers are
2149 allowed by target("general-regs-only") function attribute or
2150 -mgeneral-regs-only. */
2151 if (!(opts
->x_ix86_target_flags
& OPTION_MASK_GENERAL_REGS_ONLY
)
2152 && !(opts_set
->x_target_flags
& MASK_80387
))
2154 if (((processor_alias_table
[i
].flags
& PTA_NO_80387
) != 0))
2155 opts
->x_target_flags
&= ~MASK_80387
;
2157 opts
->x_target_flags
|= MASK_80387
;
2165 ? G_("bad value (%qs) for %<-march=%> switch")
2166 : G_("bad value (%qs) for %<target(\"arch=\")%> attribute"),
2167 opts
->x_ix86_arch_string
);
2169 auto_vec
<const char *> candidates
;
2170 for (i
= 0; i
< pta_size
; i
++)
2171 if (strcmp (processor_alias_table
[i
].name
, "generic")
2172 && strcmp (processor_alias_table
[i
].name
, "intel")
2173 && (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
2174 || ((processor_alias_table
[i
].flags
& PTA_64BIT
) != 0)))
2175 candidates
.safe_push (processor_alias_table
[i
].name
);
2177 #ifdef HAVE_LOCAL_CPU_DETECT
2178 /* Add also "native" as possible value. */
2179 candidates
.safe_push ("native");
2184 = candidates_list_and_hint (opts
->x_ix86_arch_string
, s
, candidates
);
2186 inform (input_location
,
2188 ? G_("valid arguments to %<-march=%> switch are: "
2189 "%s; did you mean %qs?")
2190 : G_("valid arguments to %<target(\"arch=\")%> attribute are: "
2191 "%s; did you mean %qs?"), s
, hint
);
2193 inform (input_location
,
2195 ? G_("valid arguments to %<-march=%> switch are: %s")
2196 : G_("valid arguments to %<target(\"arch=\")%> attribute "
2201 ix86_arch_mask
= HOST_WIDE_INT_1U
<< ix86_arch
;
2202 for (i
= 0; i
< X86_ARCH_LAST
; ++i
)
2203 ix86_arch_features
[i
] = !!(initial_ix86_arch_features
[i
] & ix86_arch_mask
);
2205 for (i
= 0; i
< pta_size
; i
++)
2206 if (! strcmp (opts
->x_ix86_tune_string
, processor_alias_table
[i
].name
)
2207 && (processor_alias_table
[i
].flags
& PTA_NO_TUNE
) == 0)
2209 ix86_schedule
= processor_alias_table
[i
].schedule
;
2210 ix86_tune
= processor_alias_table
[i
].processor
;
2211 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2213 if (!((processor_alias_table
[i
].flags
& PTA_64BIT
) != 0))
2215 if (ix86_tune_defaulted
)
2217 opts
->x_ix86_tune_string
= "x86-64";
2218 for (i
= 0; i
< pta_size
; i
++)
2219 if (! strcmp (opts
->x_ix86_tune_string
,
2220 processor_alias_table
[i
].name
))
2222 ix86_schedule
= processor_alias_table
[i
].schedule
;
2223 ix86_tune
= processor_alias_table
[i
].processor
;
2226 error ("CPU you selected does not support x86-64 "
2230 /* Intel CPUs have always interpreted SSE prefetch instructions as
2231 NOPs; so, we can enable SSE prefetch instructions even when
2232 -mtune (rather than -march) points us to a processor that has them.
2233 However, the VIA C3 gives a SIGILL, so we only do that for i686 and
2234 higher processors. */
2236 && ((processor_alias_table
[i
].flags
2237 & (PTA_PREFETCH_SSE
| PTA_SSE
)) != 0))
2238 ix86_prefetch_sse
= true;
2242 if (ix86_tune_specified
&& i
== pta_size
)
2245 ? G_("bad value (%qs) for %<-mtune=%> switch")
2246 : G_("bad value (%qs) for %<target(\"tune=\")%> attribute"),
2247 opts
->x_ix86_tune_string
);
2249 auto_vec
<const char *> candidates
;
2250 for (i
= 0; i
< pta_size
; i
++)
2251 if ((!TARGET_64BIT_P (opts
->x_ix86_isa_flags
)
2252 || ((processor_alias_table
[i
].flags
& PTA_64BIT
) != 0))
2253 && (processor_alias_table
[i
].flags
& PTA_NO_TUNE
) == 0)
2254 candidates
.safe_push (processor_alias_table
[i
].name
);
2256 #ifdef HAVE_LOCAL_CPU_DETECT
2257 /* Add also "native" as possible value. */
2258 candidates
.safe_push ("native");
2263 = candidates_list_and_hint (opts
->x_ix86_tune_string
, s
, candidates
);
2265 inform (input_location
,
2267 ? G_("valid arguments to %<-mtune=%> switch are: "
2268 "%s; did you mean %qs?")
2269 : G_("valid arguments to %<target(\"tune=\")%> attribute are: "
2270 "%s; did you mean %qs?"), s
, hint
);
2272 inform (input_location
,
2274 ? G_("valid arguments to %<-mtune=%> switch are: %s")
2275 : G_("valid arguments to %<target(\"tune=\")%> attribute "
2280 set_ix86_tune_features (opts
, ix86_tune
, opts
->x_ix86_dump_tunes
);
2282 ix86_recompute_optlev_based_flags (opts
, opts_set
);
2284 ix86_tune_cost
= processor_cost_table
[ix86_tune
];
2285 /* TODO: ix86_cost should be chosen at instruction or function granuality
2286 so for cold code we use size_cost even in !optimize_size compilation. */
2287 if (opts
->x_optimize_size
)
2288 ix86_cost
= &ix86_size_cost
;
2290 ix86_cost
= ix86_tune_cost
;
2292 /* Arrange to set up i386_stack_locals for all functions. */
2293 init_machine_status
= ix86_init_machine_status
;
2295 /* Validate -mregparm= value. */
2296 if (opts_set
->x_ix86_regparm
)
2298 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2299 warning (0, "%<-mregparm%> is ignored in 64-bit mode");
2300 else if (TARGET_IAMCU_P (opts
->x_target_flags
))
2301 warning (0, "%<-mregparm%> is ignored for Intel MCU psABI");
2302 if (opts
->x_ix86_regparm
> REGPARM_MAX
)
2304 error ("%<-mregparm=%d%> is not between 0 and %d",
2305 opts
->x_ix86_regparm
, REGPARM_MAX
);
2306 opts
->x_ix86_regparm
= 0;
2309 if (TARGET_IAMCU_P (opts
->x_target_flags
)
2310 || TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2311 opts
->x_ix86_regparm
= REGPARM_MAX
;
2313 /* Default align_* from the processor table. */
2314 ix86_default_align (opts
);
2316 /* Provide default for -mbranch-cost= value. */
2317 SET_OPTION_IF_UNSET (opts
, opts_set
, ix86_branch_cost
,
2318 ix86_tune_cost
->branch_cost
);
2320 if (TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2322 opts
->x_target_flags
2323 |= TARGET_SUBTARGET64_DEFAULT
& ~opts_set
->x_target_flags
;
2325 if (!ix86_arch_specified
)
2326 opts
->x_ix86_isa_flags
2327 |= TARGET_SUBTARGET64_ISA_DEFAULT
& ~opts
->x_ix86_isa_flags_explicit
;
2329 if (!TARGET_128BIT_LONG_DOUBLE_P (opts
->x_target_flags
))
2330 error ("%<-m96bit-long-double%> is not compatible with this target");
2332 if (TARGET_RTD_P (opts
->x_target_flags
))
2335 ? G_("%<-mrtd%> is ignored in 64bit mode")
2336 : G_("%<target(\"rtd\")%> is ignored in 64bit mode"));
2340 opts
->x_target_flags
2341 |= TARGET_SUBTARGET32_DEFAULT
& ~opts_set
->x_target_flags
;
2343 if (!ix86_arch_specified
)
2344 opts
->x_ix86_isa_flags
2345 |= TARGET_SUBTARGET32_ISA_DEFAULT
& ~opts
->x_ix86_isa_flags_explicit
;
2347 /* i386 ABI does not specify red zone. It still makes sense to use it
2348 when programmer takes care to stack from being destroyed. */
2349 if (!(opts_set
->x_target_flags
& MASK_NO_RED_ZONE
))
2350 opts
->x_target_flags
|= MASK_NO_RED_ZONE
;
2353 /* Keep nonleaf frame pointers. */
2354 if (opts
->x_flag_omit_frame_pointer
)
2355 opts
->x_target_flags
&= ~MASK_OMIT_LEAF_FRAME_POINTER
;
2356 else if (TARGET_OMIT_LEAF_FRAME_POINTER_P (opts
->x_target_flags
))
2357 opts
->x_flag_omit_frame_pointer
= 1;
2359 /* If we're doing fast math, we don't care about comparison order
2360 wrt NaNs. This lets us use a shorter comparison sequence. */
2361 if (opts
->x_flag_finite_math_only
)
2362 opts
->x_target_flags
&= ~MASK_IEEE_FP
;
2364 /* If the architecture always has an FPU, turn off NO_FANCY_MATH_387,
2365 since the insns won't need emulation. */
2366 if (ix86_tune_features
[X86_TUNE_ALWAYS_FANCY_MATH_387
])
2367 opts
->x_target_flags
&= ~MASK_NO_FANCY_MATH_387
;
2369 /* Likewise, if the target doesn't have a 387, or we've specified
2370 software floating point, don't use 387 inline intrinsics. */
2371 if (!TARGET_80387_P (opts
->x_target_flags
))
2372 opts
->x_target_flags
|= MASK_NO_FANCY_MATH_387
;
2374 /* Turn on MMX builtins for -msse. */
2375 if (TARGET_SSE_P (opts
->x_ix86_isa_flags
))
2376 opts
->x_ix86_isa_flags
2377 |= OPTION_MASK_ISA_MMX
& ~opts
->x_ix86_isa_flags_explicit
;
2379 /* Enable SSE prefetch. */
2380 if (TARGET_SSE_P (opts
->x_ix86_isa_flags
)
2381 || (TARGET_PRFCHW_P (opts
->x_ix86_isa_flags
)
2382 && !TARGET_3DNOW_P (opts
->x_ix86_isa_flags
))
2383 || TARGET_PREFETCHWT1_P (opts
->x_ix86_isa_flags
))
2384 ix86_prefetch_sse
= true;
2386 /* Enable mwait/monitor instructions for -msse3. */
2387 if (TARGET_SSE3_P (opts
->x_ix86_isa_flags
))
2388 opts
->x_ix86_isa_flags2
2389 |= OPTION_MASK_ISA2_MWAIT
& ~opts
->x_ix86_isa_flags2_explicit
;
2391 /* Enable popcnt instruction for -msse4.2 or -mabm. */
2392 if (TARGET_SSE4_2_P (opts
->x_ix86_isa_flags
)
2393 || TARGET_ABM_P (opts
->x_ix86_isa_flags
))
2394 opts
->x_ix86_isa_flags
2395 |= OPTION_MASK_ISA_POPCNT
& ~opts
->x_ix86_isa_flags_explicit
;
2397 /* Enable crc32 instruction for -msse4.2. */
2398 if (TARGET_SSE4_2_P (opts
->x_ix86_isa_flags
))
2399 opts
->x_ix86_isa_flags
2400 |= OPTION_MASK_ISA_CRC32
& ~opts
->x_ix86_isa_flags_explicit
;
2402 /* Enable lzcnt instruction for -mabm. */
2403 if (TARGET_ABM_P(opts
->x_ix86_isa_flags
))
2404 opts
->x_ix86_isa_flags
2405 |= OPTION_MASK_ISA_LZCNT
& ~opts
->x_ix86_isa_flags_explicit
;
2407 /* Disable BMI, BMI2 and TBM instructions for -m16. */
2408 if (TARGET_16BIT_P(opts
->x_ix86_isa_flags
))
2409 opts
->x_ix86_isa_flags
2410 &= ~((OPTION_MASK_ISA_BMI
| OPTION_MASK_ISA_BMI2
| OPTION_MASK_ISA_TBM
)
2411 & ~opts
->x_ix86_isa_flags_explicit
);
2413 /* Validate -mpreferred-stack-boundary= value or default it to
2414 PREFERRED_STACK_BOUNDARY_DEFAULT. */
2415 ix86_preferred_stack_boundary
= PREFERRED_STACK_BOUNDARY_DEFAULT
;
2416 if (opts_set
->x_ix86_preferred_stack_boundary_arg
)
2418 int min
= TARGET_64BIT_P (opts
->x_ix86_isa_flags
)? 3 : 2;
2419 int max
= TARGET_SEH
? 4 : 12;
2421 if (opts
->x_ix86_preferred_stack_boundary_arg
< min
2422 || opts
->x_ix86_preferred_stack_boundary_arg
> max
)
2425 error ("%<-mpreferred-stack-boundary%> is not supported "
2428 error ("%<-mpreferred-stack-boundary=%d%> is not between %d and %d",
2429 opts
->x_ix86_preferred_stack_boundary_arg
, min
, max
);
2432 ix86_preferred_stack_boundary
2433 = (1 << opts
->x_ix86_preferred_stack_boundary_arg
) * BITS_PER_UNIT
;
2436 /* Set the default value for -mstackrealign. */
2437 SET_OPTION_IF_UNSET (opts
, opts_set
, ix86_force_align_arg_pointer
,
2438 STACK_REALIGN_DEFAULT
);
2440 ix86_default_incoming_stack_boundary
= PREFERRED_STACK_BOUNDARY
;
2442 /* Validate -mincoming-stack-boundary= value or default it to
2443 MIN_STACK_BOUNDARY/PREFERRED_STACK_BOUNDARY. */
2444 ix86_incoming_stack_boundary
= ix86_default_incoming_stack_boundary
;
2445 if (opts_set
->x_ix86_incoming_stack_boundary_arg
)
2447 int min
= TARGET_64BIT_P (opts
->x_ix86_isa_flags
) ? 3 : 2;
2449 if (opts
->x_ix86_incoming_stack_boundary_arg
< min
2450 || opts
->x_ix86_incoming_stack_boundary_arg
> 12)
2451 error ("%<-mincoming-stack-boundary=%d%> is not between %d and 12",
2452 opts
->x_ix86_incoming_stack_boundary_arg
, min
);
2455 ix86_user_incoming_stack_boundary
2456 = (1 << opts
->x_ix86_incoming_stack_boundary_arg
) * BITS_PER_UNIT
;
2457 ix86_incoming_stack_boundary
2458 = ix86_user_incoming_stack_boundary
;
2462 #ifndef NO_PROFILE_COUNTERS
2463 if (flag_nop_mcount
)
2464 error ("%<-mnop-mcount%> is not compatible with this target");
2466 if (flag_nop_mcount
&& flag_pic
)
2467 error ("%<-mnop-mcount%> is not implemented for %<-fPIC%>");
2469 /* Accept -msseregparm only if at least SSE support is enabled. */
2470 if (TARGET_SSEREGPARM_P (opts
->x_target_flags
)
2471 && ! TARGET_SSE_P (opts
->x_ix86_isa_flags
))
2473 ? G_("%<-msseregparm%> used without SSE enabled")
2474 : G_("%<target(\"sseregparm\")%> used without SSE enabled"));
2476 if (opts_set
->x_ix86_fpmath
)
2478 if (opts
->x_ix86_fpmath
& FPMATH_SSE
)
2480 if (!TARGET_SSE_P (opts
->x_ix86_isa_flags
))
2482 if (TARGET_80387_P (opts
->x_target_flags
))
2484 warning (0, "SSE instruction set disabled, using 387 arithmetics");
2485 opts
->x_ix86_fpmath
= FPMATH_387
;
2488 else if ((opts
->x_ix86_fpmath
& FPMATH_387
)
2489 && !TARGET_80387_P (opts
->x_target_flags
))
2491 warning (0, "387 instruction set disabled, using SSE arithmetics");
2492 opts
->x_ix86_fpmath
= FPMATH_SSE
;
2496 /* For all chips supporting SSE2, -mfpmath=sse performs better than
2497 fpmath=387. The second is however default at many targets since the
2498 extra 80bit precision of temporaries is considered to be part of ABI.
2499 Overwrite the default at least for -ffast-math.
2500 TODO: -mfpmath=both seems to produce same performing code with bit
2501 smaller binaries. It is however not clear if register allocation is
2502 ready for this setting.
2503 Also -mfpmath=387 is overall a lot more compact (bout 4-5%) than SSE
2504 codegen. We may switch to 387 with -ffast-math for size optimized
2506 else if (fast_math_flags_set_p (&global_options
)
2507 && TARGET_SSE2_P (opts
->x_ix86_isa_flags
))
2508 opts
->x_ix86_fpmath
= FPMATH_SSE
;
2510 opts
->x_ix86_fpmath
= TARGET_FPMATH_DEFAULT_P (opts
->x_ix86_isa_flags
);
2512 /* Use external vectorized library in vectorizing intrinsics. */
2513 if (opts_set
->x_ix86_veclibabi_type
)
2514 switch (opts
->x_ix86_veclibabi_type
)
2516 case ix86_veclibabi_type_svml
:
2517 ix86_veclib_handler
= &ix86_veclibabi_svml
;
2520 case ix86_veclibabi_type_acml
:
2521 ix86_veclib_handler
= &ix86_veclibabi_acml
;
2528 if (ix86_tune_features
[X86_TUNE_ACCUMULATE_OUTGOING_ARGS
]
2529 && !(opts_set
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
))
2530 opts
->x_target_flags
|= MASK_ACCUMULATE_OUTGOING_ARGS
;
2532 /* If stack probes are required, the space used for large function
2533 arguments on the stack must also be probed, so enable
2534 -maccumulate-outgoing-args so this happens in the prologue. */
2535 if (TARGET_STACK_PROBE_P (opts
->x_target_flags
)
2536 && !(opts
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
))
2538 if (opts_set
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
)
2541 ? G_("stack probing requires %<-maccumulate-outgoing-args%> "
2543 : G_("stack probing requires "
2544 "%<target(\"accumulate-outgoing-args\")%> for "
2546 opts
->x_target_flags
|= MASK_ACCUMULATE_OUTGOING_ARGS
;
2549 /* Stack realignment without -maccumulate-outgoing-args requires %ebp,
2550 so enable -maccumulate-outgoing-args when %ebp is fixed. */
2551 if (fixed_regs
[BP_REG
]
2552 && !(opts
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
))
2554 if (opts_set
->x_target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS
)
2557 ? G_("fixed ebp register requires "
2558 "%<-maccumulate-outgoing-args%>")
2559 : G_("fixed ebp register requires "
2560 "%<target(\"accumulate-outgoing-args\")%>"));
2561 opts
->x_target_flags
|= MASK_ACCUMULATE_OUTGOING_ARGS
;
2564 /* Figure out what ASM_GENERATE_INTERNAL_LABEL builds as a prefix. */
2567 ASM_GENERATE_INTERNAL_LABEL (internal_label_prefix
, "LX", 0);
2568 p
= strchr (internal_label_prefix
, 'X');
2569 internal_label_prefix_len
= p
- internal_label_prefix
;
2573 /* When scheduling description is not available, disable scheduler pass
2574 so it won't slow down the compilation and make x87 code slower. */
2575 if (!TARGET_SCHEDULE
)
2576 opts
->x_flag_schedule_insns_after_reload
= opts
->x_flag_schedule_insns
= 0;
2578 SET_OPTION_IF_UNSET (opts
, opts_set
, param_simultaneous_prefetches
,
2579 ix86_tune_cost
->simultaneous_prefetches
);
2580 SET_OPTION_IF_UNSET (opts
, opts_set
, param_l1_cache_line_size
,
2581 ix86_tune_cost
->prefetch_block
);
2582 SET_OPTION_IF_UNSET (opts
, opts_set
, param_l1_cache_size
,
2583 ix86_tune_cost
->l1_cache_size
);
2584 SET_OPTION_IF_UNSET (opts
, opts_set
, param_l2_cache_size
,
2585 ix86_tune_cost
->l2_cache_size
);
2587 /* 64B is the accepted value for these for all x86. */
2588 SET_OPTION_IF_UNSET (&global_options
, &global_options_set
,
2589 param_destruct_interfere_size
, 64);
2590 SET_OPTION_IF_UNSET (&global_options
, &global_options_set
,
2591 param_construct_interfere_size
, 64);
2593 /* Enable sw prefetching at -O3 for CPUS that prefetching is helpful. */
2594 if (opts
->x_flag_prefetch_loop_arrays
< 0
2596 && (opts
->x_optimize
>= 3 || opts
->x_flag_profile_use
)
2597 && !opts
->x_optimize_size
2598 && TARGET_SOFTWARE_PREFETCHING_BENEFICIAL
)
2599 opts
->x_flag_prefetch_loop_arrays
= 1;
2601 /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)
2602 can be opts->x_optimized to ap = __builtin_next_arg (0). */
2603 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
) && !opts
->x_flag_split_stack
)
2604 targetm
.expand_builtin_va_start
= NULL
;
2607 /* Use -mcld by default for 32-bit code if configured with --enable-cld. */
2608 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
))
2609 opts
->x_target_flags
|= MASK_CLD
& ~opts_set
->x_target_flags
;
2612 /* Set the default value for -mfentry. */
2613 if (!opts_set
->x_flag_fentry
)
2614 opts
->x_flag_fentry
= TARGET_SEH
;
2617 if (!TARGET_64BIT_P (opts
->x_ix86_isa_flags
) && opts
->x_flag_pic
2618 && opts
->x_flag_fentry
)
2619 sorry ("%<-mfentry%> isn%'t supported for 32-bit in combination "
2621 else if (TARGET_SEH
&& !opts
->x_flag_fentry
)
2622 sorry ("%<-mno-fentry%> isn%'t compatible with SEH");
2625 if (TARGET_SEH
&& TARGET_CALL_MS2SYSV_XLOGUES
)
2626 sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH");
2628 if (!(opts_set
->x_target_flags
& MASK_VZEROUPPER
)
2629 && TARGET_EMIT_VZEROUPPER
)
2630 opts
->x_target_flags
|= MASK_VZEROUPPER
;
2631 if (!(opts_set
->x_target_flags
& MASK_STV
))
2632 opts
->x_target_flags
|= MASK_STV
;
2633 /* Disable STV if -mpreferred-stack-boundary={2,3} or
2634 -mincoming-stack-boundary={2,3} or -mstackrealign - the needed
2635 stack realignment will be extra cost the pass doesn't take into
2636 account and the pass can't realign the stack. */
2637 if (ix86_preferred_stack_boundary
< 128
2638 || ix86_incoming_stack_boundary
< 128
2639 || opts
->x_ix86_force_align_arg_pointer
)
2640 opts
->x_target_flags
&= ~MASK_STV
;
2641 if (!ix86_tune_features
[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL
]
2642 && !(opts_set
->x_target_flags
& MASK_AVX256_SPLIT_UNALIGNED_LOAD
))
2643 opts
->x_target_flags
|= MASK_AVX256_SPLIT_UNALIGNED_LOAD
;
2644 else if (!main_args_p
2645 && ix86_tune_features
[X86_TUNE_AVX256_UNALIGNED_LOAD_OPTIMAL
])
2646 opts
->x_target_flags
&= ~MASK_AVX256_SPLIT_UNALIGNED_LOAD
;
2648 if (!ix86_tune_features
[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL
]
2649 && !(opts_set
->x_target_flags
& MASK_AVX256_SPLIT_UNALIGNED_STORE
))
2650 opts
->x_target_flags
|= MASK_AVX256_SPLIT_UNALIGNED_STORE
;
2651 else if (!main_args_p
2652 && ix86_tune_features
[X86_TUNE_AVX256_UNALIGNED_STORE_OPTIMAL
])
2653 opts
->x_target_flags
&= ~MASK_AVX256_SPLIT_UNALIGNED_STORE
;
2655 /* Enable 128-bit AVX instruction generation
2656 for the auto-vectorizer. */
2657 if (ix86_tune_features
[X86_TUNE_AVX128_OPTIMAL
]
2658 && (opts_set
->x_prefer_vector_width_type
== PVW_NONE
))
2659 opts
->x_prefer_vector_width_type
= PVW_AVX128
;
2661 /* Use 256-bit AVX instruction generation
2662 in the auto-vectorizer. */
2663 if (ix86_tune_features
[X86_TUNE_AVX256_OPTIMAL
]
2664 && (opts_set
->x_prefer_vector_width_type
== PVW_NONE
))
2665 opts
->x_prefer_vector_width_type
= PVW_AVX256
;
2667 if (opts
->x_ix86_recip_name
)
2669 char *p
= ASTRDUP (opts
->x_ix86_recip_name
);
2674 while ((q
= strtok (p
, ",")) != NULL
)
2685 if (!strcmp (q
, "default"))
2686 mask
= RECIP_MASK_ALL
;
2689 for (i
= 0; i
< ARRAY_SIZE (recip_options
); i
++)
2690 if (!strcmp (q
, recip_options
[i
].string
))
2692 mask
= recip_options
[i
].mask
;
2696 if (i
== ARRAY_SIZE (recip_options
))
2698 error ("unknown option for %<-mrecip=%s%>", q
);
2700 mask
= RECIP_MASK_NONE
;
2704 opts
->x_recip_mask_explicit
|= mask
;
2706 opts
->x_recip_mask
&= ~mask
;
2708 opts
->x_recip_mask
|= mask
;
2712 if (TARGET_RECIP_P (opts
->x_target_flags
))
2713 opts
->x_recip_mask
|= RECIP_MASK_ALL
& ~opts
->x_recip_mask_explicit
;
2714 else if (opts_set
->x_target_flags
& MASK_RECIP
)
2715 opts
->x_recip_mask
&= ~(RECIP_MASK_ALL
& ~opts
->x_recip_mask_explicit
);
2717 /* Default long double to 64-bit for 32-bit Bionic and to __float128
2718 for 64-bit Bionic. Also default long double to 64-bit for Intel
2720 if ((TARGET_HAS_BIONIC
|| TARGET_IAMCU
)
2721 && !(opts_set
->x_target_flags
2722 & (MASK_LONG_DOUBLE_64
| MASK_LONG_DOUBLE_128
)))
2723 opts
->x_target_flags
|= (TARGET_64BIT
2724 ? MASK_LONG_DOUBLE_128
2725 : MASK_LONG_DOUBLE_64
);
2727 /* Only one of them can be active. */
2728 gcc_assert ((opts
->x_target_flags
& MASK_LONG_DOUBLE_64
) == 0
2729 || (opts
->x_target_flags
& MASK_LONG_DOUBLE_128
) == 0);
2731 /* Handle stack protector */
2732 if (!opts_set
->x_ix86_stack_protector_guard
)
2734 #ifdef TARGET_THREAD_SSP_OFFSET
2735 if (!TARGET_HAS_BIONIC
)
2736 opts
->x_ix86_stack_protector_guard
= SSP_TLS
;
2739 opts
->x_ix86_stack_protector_guard
= SSP_GLOBAL
;
2742 if (opts_set
->x_ix86_stack_protector_guard_offset_str
)
2745 const char *str
= opts
->x_ix86_stack_protector_guard_offset_str
;
2750 #if defined(INT64_T_IS_LONG)
2751 offset
= strtol (str
, &endp
, 0);
2753 offset
= strtoll (str
, &endp
, 0);
2756 if (!*str
|| *endp
|| errno
)
2757 error ("%qs is not a valid number "
2758 "in %<-mstack-protector-guard-offset=%>", str
);
2760 if (!IN_RANGE (offset
, HOST_WIDE_INT_C (-0x80000000),
2761 HOST_WIDE_INT_C (0x7fffffff)))
2762 error ("%qs is not a valid offset "
2763 "in %<-mstack-protector-guard-offset=%>", str
);
2765 opts
->x_ix86_stack_protector_guard_offset
= offset
;
2767 #ifdef TARGET_THREAD_SSP_OFFSET
2769 opts
->x_ix86_stack_protector_guard_offset
= TARGET_THREAD_SSP_OFFSET
;
2772 if (opts_set
->x_ix86_stack_protector_guard_reg_str
)
2774 const char *str
= opts
->x_ix86_stack_protector_guard_reg_str
;
2775 addr_space_t seg
= ADDR_SPACE_GENERIC
;
2777 /* Discard optional register prefix. */
2781 if (strlen (str
) == 2 && str
[1] == 's')
2784 seg
= ADDR_SPACE_SEG_FS
;
2785 else if (str
[0] == 'g')
2786 seg
= ADDR_SPACE_SEG_GS
;
2789 if (seg
== ADDR_SPACE_GENERIC
)
2790 error ("%qs is not a valid base register "
2791 "in %<-mstack-protector-guard-reg=%>",
2792 opts
->x_ix86_stack_protector_guard_reg_str
);
2794 opts
->x_ix86_stack_protector_guard_reg
= seg
;
2798 opts
->x_ix86_stack_protector_guard_reg
= DEFAULT_TLS_SEG_REG
;
2800 /* The kernel uses a different segment register for performance
2801 reasons; a system call would not have to trash the userspace
2802 segment register, which would be expensive. */
2803 if (opts
->x_ix86_cmodel
== CM_KERNEL
)
2804 opts
->x_ix86_stack_protector_guard_reg
= ADDR_SPACE_SEG_GS
;
2807 /* Handle -mmemcpy-strategy= and -mmemset-strategy= */
2808 if (opts
->x_ix86_tune_memcpy_strategy
)
2810 char *str
= xstrdup (opts
->x_ix86_tune_memcpy_strategy
);
2811 ix86_parse_stringop_strategy_string (str
, false);
2815 if (opts
->x_ix86_tune_memset_strategy
)
2817 char *str
= xstrdup (opts
->x_ix86_tune_memset_strategy
);
2818 ix86_parse_stringop_strategy_string (str
, true);
2822 /* Save the initial options in case the user does function specific
2826 opts
->x_ix86_excess_precision
2827 = opts
->x_flag_excess_precision
;
2828 opts
->x_ix86_unsafe_math_optimizations
2829 = opts
->x_flag_unsafe_math_optimizations
;
2830 target_option_default_node
= target_option_current_node
2831 = build_target_option_node (opts
, opts_set
);
2834 if (opts
->x_flag_cf_protection
!= CF_NONE
)
2836 if ((opts
->x_flag_cf_protection
& CF_BRANCH
) == CF_BRANCH
2837 && !TARGET_64BIT
&& !TARGET_CMOV
)
2838 error ("%<-fcf-protection%> is not compatible with this target");
2840 opts
->x_flag_cf_protection
2841 = (cf_protection_level
) (opts
->x_flag_cf_protection
| CF_SET
);
2844 if (ix86_tune_features
[X86_TUNE_AVOID_256FMA_CHAINS
])
2845 SET_OPTION_IF_UNSET (opts
, opts_set
, param_avoid_fma_max_bits
, 256);
2846 else if (ix86_tune_features
[X86_TUNE_AVOID_128FMA_CHAINS
])
2847 SET_OPTION_IF_UNSET (opts
, opts_set
, param_avoid_fma_max_bits
, 128);
2849 /* PR86952: jump table usage with retpolines is slow.
2850 The PR provides some numbers about the slowness. */
2851 if (ix86_indirect_branch
!= indirect_branch_keep
)
2852 SET_OPTION_IF_UNSET (opts
, opts_set
, flag_jump_tables
, 0);
2854 SET_OPTION_IF_UNSET (opts
, opts_set
, param_ira_consider_dup_in_all_alts
, 0);
2856 /* Fully masking the main or the epilogue vectorized loop is not
2857 profitable generally so leave it disabled until we get more
2858 fine grained control & costing. */
2859 SET_OPTION_IF_UNSET (opts
, opts_set
, param_vect_partial_vector_usage
, 0);
2864 /* Implement the TARGET_OPTION_OVERRIDE hook. */
2867 ix86_option_override (void)
2869 ix86_option_override_internal (true, &global_options
, &global_options_set
);
2872 /* Remember the last target of ix86_set_current_function. */
2873 static GTY(()) tree ix86_previous_fndecl
;
2875 /* Set targets globals to the default (or current #pragma GCC target
2876 if active). Invalidate ix86_previous_fndecl cache. */
2879 ix86_reset_previous_fndecl (void)
2881 tree new_tree
= target_option_current_node
;
2882 cl_target_option_restore (&global_options
, &global_options_set
,
2883 TREE_TARGET_OPTION (new_tree
));
2884 if (TREE_TARGET_GLOBALS (new_tree
))
2885 restore_target_globals (TREE_TARGET_GLOBALS (new_tree
));
2886 else if (new_tree
== target_option_default_node
)
2887 restore_target_globals (&default_target_globals
);
2889 TREE_TARGET_GLOBALS (new_tree
) = save_target_globals_default_opts ();
2890 ix86_previous_fndecl
= NULL_TREE
;
2893 /* Add target attribute to SIMD clone NODE if needed. */
2896 ix86_simd_clone_adjust (struct cgraph_node
*node
)
2898 const char *str
= NULL
;
2900 /* Attributes need to be adjusted for definitions, not declarations. */
2901 if (!node
->definition
)
2904 gcc_assert (node
->decl
== cfun
->decl
);
2905 switch (node
->simdclone
->vecsize_mangle
)
2912 if (TARGET_PREFER_AVX128
)
2915 str
= "avx,prefer-vector-width=256";
2917 str
= "prefer-vector-width=256";
2919 else if (!TARGET_AVX
)
2923 if (TARGET_PREFER_AVX128
)
2926 str
= "avx2,prefer-vector-width=256";
2928 str
= "prefer-vector-width=256";
2930 else if (!TARGET_AVX2
)
2934 if (TARGET_PREFER_AVX256
)
2936 if (!TARGET_AVX512F
)
2937 str
= "avx512f,prefer-vector-width=512";
2939 str
= "prefer-vector-width=512";
2941 else if (!TARGET_AVX512F
)
2950 tree args
= build_tree_list (NULL_TREE
, build_string (strlen (str
), str
));
2951 bool ok
= ix86_valid_target_attribute_p (node
->decl
, NULL
, args
, 0);
2954 ix86_reset_previous_fndecl ();
2955 ix86_set_current_function (node
->decl
);
2960 /* Set the func_type field from the function FNDECL. */
2963 ix86_set_func_type (tree fndecl
)
2965 if (cfun
->machine
->func_type
== TYPE_UNKNOWN
)
2967 if (lookup_attribute ("interrupt",
2968 TYPE_ATTRIBUTES (TREE_TYPE (fndecl
))))
2970 if (ix86_function_naked (fndecl
))
2971 error_at (DECL_SOURCE_LOCATION (fndecl
),
2972 "interrupt and naked attributes are not compatible");
2975 for (tree arg
= DECL_ARGUMENTS (fndecl
);
2977 arg
= TREE_CHAIN (arg
))
2979 cfun
->machine
->no_caller_saved_registers
= true;
2980 cfun
->machine
->func_type
2981 = nargs
== 2 ? TYPE_EXCEPTION
: TYPE_INTERRUPT
;
2983 ix86_optimize_mode_switching
[X86_DIRFLAG
] = 1;
2985 /* Only dwarf2out.c can handle -WORD(AP) as a pointer argument. */
2986 if (write_symbols
!= NO_DEBUG
&& write_symbols
!= DWARF2_DEBUG
)
2987 sorry ("only DWARF debug format is supported for interrupt "
2992 cfun
->machine
->func_type
= TYPE_NORMAL
;
2993 if (lookup_attribute ("no_caller_saved_registers",
2994 TYPE_ATTRIBUTES (TREE_TYPE (fndecl
))))
2995 cfun
->machine
->no_caller_saved_registers
= true;
3000 /* Set the indirect_branch_type field from the function FNDECL. */
3003 ix86_set_indirect_branch_type (tree fndecl
)
3005 if (cfun
->machine
->indirect_branch_type
== indirect_branch_unset
)
3007 tree attr
= lookup_attribute ("indirect_branch",
3008 DECL_ATTRIBUTES (fndecl
));
3011 tree args
= TREE_VALUE (attr
);
3014 tree cst
= TREE_VALUE (args
);
3015 if (strcmp (TREE_STRING_POINTER (cst
), "keep") == 0)
3016 cfun
->machine
->indirect_branch_type
= indirect_branch_keep
;
3017 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk") == 0)
3018 cfun
->machine
->indirect_branch_type
= indirect_branch_thunk
;
3019 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk-inline") == 0)
3020 cfun
->machine
->indirect_branch_type
= indirect_branch_thunk_inline
;
3021 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk-extern") == 0)
3022 cfun
->machine
->indirect_branch_type
= indirect_branch_thunk_extern
;
3027 cfun
->machine
->indirect_branch_type
= ix86_indirect_branch
;
3029 /* -mcmodel=large is not compatible with -mindirect-branch=thunk
3030 nor -mindirect-branch=thunk-extern. */
3031 if ((ix86_cmodel
== CM_LARGE
|| ix86_cmodel
== CM_LARGE_PIC
)
3032 && ((cfun
->machine
->indirect_branch_type
3033 == indirect_branch_thunk_extern
)
3034 || (cfun
->machine
->indirect_branch_type
3035 == indirect_branch_thunk
)))
3036 error ("%<-mindirect-branch=%s%> and %<-mcmodel=large%> are not "
3038 ((cfun
->machine
->indirect_branch_type
3039 == indirect_branch_thunk_extern
)
3040 ? "thunk-extern" : "thunk"));
3042 if (cfun
->machine
->indirect_branch_type
!= indirect_branch_keep
3043 && (cfun
->machine
->indirect_branch_type
3044 != indirect_branch_thunk_extern
)
3045 && (flag_cf_protection
& CF_RETURN
))
3046 error ("%<-mindirect-branch%> and %<-fcf-protection%> are not "
3050 if (cfun
->machine
->function_return_type
== indirect_branch_unset
)
3052 tree attr
= lookup_attribute ("function_return",
3053 DECL_ATTRIBUTES (fndecl
));
3056 tree args
= TREE_VALUE (attr
);
3059 tree cst
= TREE_VALUE (args
);
3060 if (strcmp (TREE_STRING_POINTER (cst
), "keep") == 0)
3061 cfun
->machine
->function_return_type
= indirect_branch_keep
;
3062 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk") == 0)
3063 cfun
->machine
->function_return_type
= indirect_branch_thunk
;
3064 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk-inline") == 0)
3065 cfun
->machine
->function_return_type
= indirect_branch_thunk_inline
;
3066 else if (strcmp (TREE_STRING_POINTER (cst
), "thunk-extern") == 0)
3067 cfun
->machine
->function_return_type
= indirect_branch_thunk_extern
;
3072 cfun
->machine
->function_return_type
= ix86_function_return
;
3074 /* -mcmodel=large is not compatible with -mfunction-return=thunk
3075 nor -mfunction-return=thunk-extern. */
3076 if ((ix86_cmodel
== CM_LARGE
|| ix86_cmodel
== CM_LARGE_PIC
)
3077 && ((cfun
->machine
->function_return_type
3078 == indirect_branch_thunk_extern
)
3079 || (cfun
->machine
->function_return_type
3080 == indirect_branch_thunk
)))
3081 error ("%<-mfunction-return=%s%> and %<-mcmodel=large%> are not "
3083 ((cfun
->machine
->function_return_type
3084 == indirect_branch_thunk_extern
)
3085 ? "thunk-extern" : "thunk"));
3087 if (cfun
->machine
->function_return_type
!= indirect_branch_keep
3088 && (cfun
->machine
->function_return_type
3089 != indirect_branch_thunk_extern
)
3090 && (flag_cf_protection
& CF_RETURN
))
3091 error ("%<-mfunction-return%> and %<-fcf-protection%> are not "
3096 /* Establish appropriate back-end context for processing the function
3097 FNDECL. The argument might be NULL to indicate processing at top
3098 level, outside of any function scope. */
3100 ix86_set_current_function (tree fndecl
)
3102 /* Only change the context if the function changes. This hook is called
3103 several times in the course of compiling a function, and we don't want to
3104 slow things down too much or call target_reinit when it isn't safe. */
3105 if (fndecl
== ix86_previous_fndecl
)
3107 /* There may be 2 function bodies for the same function FNDECL,
3108 one is extern inline and one isn't. Call ix86_set_func_type
3109 to set the func_type field. */
3110 if (fndecl
!= NULL_TREE
)
3112 ix86_set_func_type (fndecl
);
3113 ix86_set_indirect_branch_type (fndecl
);
3119 if (ix86_previous_fndecl
== NULL_TREE
)
3120 old_tree
= target_option_current_node
;
3121 else if (DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl
))
3122 old_tree
= DECL_FUNCTION_SPECIFIC_TARGET (ix86_previous_fndecl
);
3124 old_tree
= target_option_default_node
;
3126 if (fndecl
== NULL_TREE
)
3128 if (old_tree
!= target_option_current_node
)
3129 ix86_reset_previous_fndecl ();
3133 ix86_set_func_type (fndecl
);
3134 ix86_set_indirect_branch_type (fndecl
);
3136 tree new_tree
= DECL_FUNCTION_SPECIFIC_TARGET (fndecl
);
3137 if (new_tree
== NULL_TREE
)
3138 new_tree
= target_option_default_node
;
3140 if (old_tree
!= new_tree
)
3142 cl_target_option_restore (&global_options
, &global_options_set
,
3143 TREE_TARGET_OPTION (new_tree
));
3144 if (TREE_TARGET_GLOBALS (new_tree
))
3145 restore_target_globals (TREE_TARGET_GLOBALS (new_tree
));
3146 else if (new_tree
== target_option_default_node
)
3147 restore_target_globals (&default_target_globals
);
3149 TREE_TARGET_GLOBALS (new_tree
) = save_target_globals_default_opts ();
3151 else if (flag_unsafe_math_optimizations
3152 != TREE_TARGET_OPTION (new_tree
)->x_ix86_unsafe_math_optimizations
3153 || (flag_excess_precision
3154 != TREE_TARGET_OPTION (new_tree
)->x_ix86_excess_precision
))
3156 cl_target_option_restore (&global_options
, &global_options_set
,
3157 TREE_TARGET_OPTION (new_tree
));
3158 ix86_excess_precision
= flag_excess_precision
;
3159 ix86_unsafe_math_optimizations
= flag_unsafe_math_optimizations
;
3160 DECL_FUNCTION_SPECIFIC_TARGET (fndecl
) = new_tree
3161 = build_target_option_node (&global_options
, &global_options_set
);
3162 if (TREE_TARGET_GLOBALS (new_tree
))
3163 restore_target_globals (TREE_TARGET_GLOBALS (new_tree
));
3164 else if (new_tree
== target_option_default_node
)
3165 restore_target_globals (&default_target_globals
);
3167 TREE_TARGET_GLOBALS (new_tree
) = save_target_globals_default_opts ();
3169 ix86_previous_fndecl
= fndecl
;
3171 static bool prev_no_caller_saved_registers
;
3173 /* 64-bit MS and SYSV ABI have different set of call used registers.
3174 Avoid expensive re-initialization of init_regs each time we switch
3175 function context. */
3177 && (call_used_or_fixed_reg_p (SI_REG
)
3178 == (cfun
->machine
->call_abi
== MS_ABI
)))
3180 /* Need to re-initialize init_regs if caller-saved registers are
3182 else if (prev_no_caller_saved_registers
3183 != cfun
->machine
->no_caller_saved_registers
)
3186 if (cfun
->machine
->func_type
!= TYPE_NORMAL
3187 || cfun
->machine
->no_caller_saved_registers
)
3189 /* Don't allow SSE, MMX nor x87 instructions since they
3190 may change processor state. */
3194 else if (TARGET_MMX
)
3196 else if (TARGET_80387
)
3202 if (cfun
->machine
->func_type
!= TYPE_NORMAL
)
3203 sorry (cfun
->machine
->func_type
== TYPE_EXCEPTION
3204 ? G_("%s instructions aren%'t allowed in an"
3205 " exception service routine")
3206 : G_("%s instructions aren%'t allowed in an"
3207 " interrupt service routine"),
3210 sorry ("%s instructions aren%'t allowed in a function with "
3211 "the %<no_caller_saved_registers%> attribute", isa
);
3212 /* Don't issue the same error twice. */
3213 cfun
->machine
->func_type
= TYPE_NORMAL
;
3214 cfun
->machine
->no_caller_saved_registers
= false;
3218 prev_no_caller_saved_registers
3219 = cfun
->machine
->no_caller_saved_registers
;
3222 /* Implement the TARGET_OFFLOAD_OPTIONS hook. */
3224 ix86_offload_options (void)
3227 return xstrdup ("-foffload-abi=lp64");
3228 return xstrdup ("-foffload-abi=ilp32");
3231 /* Handle "cdecl", "stdcall", "fastcall", "regparm", "thiscall",
3232 and "sseregparm" calling convention attributes;
3233 arguments as in struct attribute_spec.handler. */
3236 ix86_handle_cconv_attribute (tree
*node
, tree name
, tree args
, int,
3239 if (TREE_CODE (*node
) != FUNCTION_TYPE
3240 && TREE_CODE (*node
) != METHOD_TYPE
3241 && TREE_CODE (*node
) != FIELD_DECL
3242 && TREE_CODE (*node
) != TYPE_DECL
)
3244 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3246 *no_add_attrs
= true;
3250 /* Can combine regparm with all attributes but fastcall, and thiscall. */
3251 if (is_attribute_p ("regparm", name
))
3255 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node
)))
3257 error ("fastcall and regparm attributes are not compatible");
3260 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node
)))
3262 error ("regparam and thiscall attributes are not compatible");
3265 cst
= TREE_VALUE (args
);
3266 if (TREE_CODE (cst
) != INTEGER_CST
)
3268 warning (OPT_Wattributes
,
3269 "%qE attribute requires an integer constant argument",
3271 *no_add_attrs
= true;
3273 else if (compare_tree_int (cst
, REGPARM_MAX
) > 0)
3275 warning (OPT_Wattributes
, "argument to %qE attribute larger than %d",
3277 *no_add_attrs
= true;
3285 /* Do not warn when emulating the MS ABI. */
3286 if ((TREE_CODE (*node
) != FUNCTION_TYPE
3287 && TREE_CODE (*node
) != METHOD_TYPE
)
3288 || ix86_function_type_abi (*node
) != MS_ABI
)
3289 warning (OPT_Wattributes
, "%qE attribute ignored",
3291 *no_add_attrs
= true;
3295 /* Can combine fastcall with stdcall (redundant) and sseregparm. */
3296 if (is_attribute_p ("fastcall", name
))
3298 if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node
)))
3300 error ("fastcall and cdecl attributes are not compatible");
3302 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node
)))
3304 error ("fastcall and stdcall attributes are not compatible");
3306 if (lookup_attribute ("regparm", TYPE_ATTRIBUTES (*node
)))
3308 error ("fastcall and regparm attributes are not compatible");
3310 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node
)))
3312 error ("fastcall and thiscall attributes are not compatible");
3316 /* Can combine stdcall with fastcall (redundant), regparm and
3318 else if (is_attribute_p ("stdcall", name
))
3320 if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node
)))
3322 error ("stdcall and cdecl attributes are not compatible");
3324 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node
)))
3326 error ("stdcall and fastcall attributes are not compatible");
3328 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node
)))
3330 error ("stdcall and thiscall attributes are not compatible");
3334 /* Can combine cdecl with regparm and sseregparm. */
3335 else if (is_attribute_p ("cdecl", name
))
3337 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node
)))
3339 error ("stdcall and cdecl attributes are not compatible");
3341 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node
)))
3343 error ("fastcall and cdecl attributes are not compatible");
3345 if (lookup_attribute ("thiscall", TYPE_ATTRIBUTES (*node
)))
3347 error ("cdecl and thiscall attributes are not compatible");
3350 else if (is_attribute_p ("thiscall", name
))
3352 if (TREE_CODE (*node
) != METHOD_TYPE
&& pedantic
)
3353 warning (OPT_Wattributes
, "%qE attribute is used for non-class method",
3355 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (*node
)))
3357 error ("stdcall and thiscall attributes are not compatible");
3359 if (lookup_attribute ("fastcall", TYPE_ATTRIBUTES (*node
)))
3361 error ("fastcall and thiscall attributes are not compatible");
3363 if (lookup_attribute ("cdecl", TYPE_ATTRIBUTES (*node
)))
3365 error ("cdecl and thiscall attributes are not compatible");
3369 /* Can combine sseregparm with all attributes. */
3374 #ifndef CHECK_STACK_LIMIT
3375 #define CHECK_STACK_LIMIT (-1)
3378 /* The transactional memory builtins are implicitly regparm or fastcall
3379 depending on the ABI. Override the generic do-nothing attribute that
3380 these builtins were declared with, and replace it with one of the two
3381 attributes that we expect elsewhere. */
3384 ix86_handle_tm_regparm_attribute (tree
*node
, tree
, tree
,
3385 int flags
, bool *no_add_attrs
)
3389 /* In no case do we want to add the placeholder attribute. */
3390 *no_add_attrs
= true;
3392 /* The 64-bit ABI is unchanged for transactional memory. */
3396 /* ??? Is there a better way to validate 32-bit windows? We have
3397 cfun->machine->call_abi, but that seems to be set only for 64-bit. */
3398 if (CHECK_STACK_LIMIT
> 0)
3399 alt
= tree_cons (get_identifier ("fastcall"), NULL
, NULL
);
3402 alt
= tree_cons (NULL
, build_int_cst (NULL
, 2), NULL
);
3403 alt
= tree_cons (get_identifier ("regparm"), alt
, NULL
);
3405 decl_attributes (node
, alt
, flags
);
3410 /* Handle a "force_align_arg_pointer" attribute. */
3413 ix86_handle_force_align_arg_pointer_attribute (tree
*node
, tree name
,
3414 tree
, int, bool *no_add_attrs
)
3416 if (TREE_CODE (*node
) != FUNCTION_TYPE
3417 && TREE_CODE (*node
) != METHOD_TYPE
3418 && TREE_CODE (*node
) != FIELD_DECL
3419 && TREE_CODE (*node
) != TYPE_DECL
)
3421 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3423 *no_add_attrs
= true;
3429 /* Handle a "ms_struct" or "gcc_struct" attribute; arguments as in
3430 struct attribute_spec.handler. */
3433 ix86_handle_struct_attribute (tree
*node
, tree name
, tree
, int,
3439 if (TREE_CODE (*node
) == TYPE_DECL
)
3440 type
= &TREE_TYPE (*node
);
3445 if (!(type
&& RECORD_OR_UNION_TYPE_P (*type
)))
3447 warning (OPT_Wattributes
, "%qE attribute ignored",
3449 *no_add_attrs
= true;
3452 else if ((is_attribute_p ("ms_struct", name
)
3453 && lookup_attribute ("gcc_struct", TYPE_ATTRIBUTES (*type
)))
3454 || ((is_attribute_p ("gcc_struct", name
)
3455 && lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (*type
)))))
3457 warning (OPT_Wattributes
, "%qE incompatible attribute ignored",
3459 *no_add_attrs
= true;
3465 /* Handle a "callee_pop_aggregate_return" attribute; arguments as
3466 in struct attribute_spec handler. */
3469 ix86_handle_callee_pop_aggregate_return (tree
*node
, tree name
, tree args
, int,
3472 if (TREE_CODE (*node
) != FUNCTION_TYPE
3473 && TREE_CODE (*node
) != METHOD_TYPE
3474 && TREE_CODE (*node
) != FIELD_DECL
3475 && TREE_CODE (*node
) != TYPE_DECL
)
3477 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3479 *no_add_attrs
= true;
3484 warning (OPT_Wattributes
, "%qE attribute only available for 32-bit",
3486 *no_add_attrs
= true;
3489 if (is_attribute_p ("callee_pop_aggregate_return", name
))
3493 cst
= TREE_VALUE (args
);
3494 if (TREE_CODE (cst
) != INTEGER_CST
)
3496 warning (OPT_Wattributes
,
3497 "%qE attribute requires an integer constant argument",
3499 *no_add_attrs
= true;
3501 else if (compare_tree_int (cst
, 0) != 0
3502 && compare_tree_int (cst
, 1) != 0)
3504 warning (OPT_Wattributes
,
3505 "argument to %qE attribute is neither zero, nor one",
3507 *no_add_attrs
= true;
3516 /* Handle a "ms_abi" or "sysv" attribute; arguments as in
3517 struct attribute_spec.handler. */
3520 ix86_handle_abi_attribute (tree
*node
, tree name
, tree
, int,
3523 if (TREE_CODE (*node
) != FUNCTION_TYPE
3524 && TREE_CODE (*node
) != METHOD_TYPE
3525 && TREE_CODE (*node
) != FIELD_DECL
3526 && TREE_CODE (*node
) != TYPE_DECL
)
3528 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3530 *no_add_attrs
= true;
3534 /* Can combine regparm with all attributes but fastcall. */
3535 if (is_attribute_p ("ms_abi", name
))
3537 if (lookup_attribute ("sysv_abi", TYPE_ATTRIBUTES (*node
)))
3539 error ("%qs and %qs attributes are not compatible",
3540 "ms_abi", "sysv_abi");
3545 else if (is_attribute_p ("sysv_abi", name
))
3547 if (lookup_attribute ("ms_abi", TYPE_ATTRIBUTES (*node
)))
3549 error ("%qs and %qs attributes are not compatible",
3550 "ms_abi", "sysv_abi");
3560 ix86_handle_fndecl_attribute (tree
*node
, tree name
, tree args
, int,
3563 if (TREE_CODE (*node
) != FUNCTION_DECL
)
3565 warning (OPT_Wattributes
, "%qE attribute only applies to functions",
3567 *no_add_attrs
= true;
3570 if (is_attribute_p ("indirect_branch", name
))
3572 tree cst
= TREE_VALUE (args
);
3573 if (TREE_CODE (cst
) != STRING_CST
)
3575 warning (OPT_Wattributes
,
3576 "%qE attribute requires a string constant argument",
3578 *no_add_attrs
= true;
3580 else if (strcmp (TREE_STRING_POINTER (cst
), "keep") != 0
3581 && strcmp (TREE_STRING_POINTER (cst
), "thunk") != 0
3582 && strcmp (TREE_STRING_POINTER (cst
), "thunk-inline") != 0
3583 && strcmp (TREE_STRING_POINTER (cst
), "thunk-extern") != 0)
3585 warning (OPT_Wattributes
,
3586 "argument to %qE attribute is not "
3587 "(keep|thunk|thunk-inline|thunk-extern)", name
);
3588 *no_add_attrs
= true;
3592 if (is_attribute_p ("function_return", name
))
3594 tree cst
= TREE_VALUE (args
);
3595 if (TREE_CODE (cst
) != STRING_CST
)
3597 warning (OPT_Wattributes
,
3598 "%qE attribute requires a string constant argument",
3600 *no_add_attrs
= true;
3602 else if (strcmp (TREE_STRING_POINTER (cst
), "keep") != 0
3603 && strcmp (TREE_STRING_POINTER (cst
), "thunk") != 0
3604 && strcmp (TREE_STRING_POINTER (cst
), "thunk-inline") != 0
3605 && strcmp (TREE_STRING_POINTER (cst
), "thunk-extern") != 0)
3607 warning (OPT_Wattributes
,
3608 "argument to %qE attribute is not "
3609 "(keep|thunk|thunk-inline|thunk-extern)", name
);
3610 *no_add_attrs
= true;
3618 ix86_handle_no_caller_saved_registers_attribute (tree
*, tree
, tree
,
3625 ix86_handle_interrupt_attribute (tree
*node
, tree
, tree
, int, bool *)
3627 /* DECL_RESULT and DECL_ARGUMENTS do not exist there yet,
3628 but the function type contains args and return type data. */
3629 tree func_type
= *node
;
3630 tree return_type
= TREE_TYPE (func_type
);
3633 tree current_arg_type
= TYPE_ARG_TYPES (func_type
);
3634 while (current_arg_type
3635 && ! VOID_TYPE_P (TREE_VALUE (current_arg_type
)))
3639 if (! POINTER_TYPE_P (TREE_VALUE (current_arg_type
)))
3640 error ("interrupt service routine should have a pointer "
3641 "as the first argument");
3643 else if (nargs
== 1)
3645 if (TREE_CODE (TREE_VALUE (current_arg_type
)) != INTEGER_TYPE
3646 || TYPE_MODE (TREE_VALUE (current_arg_type
)) != word_mode
)
3647 error ("interrupt service routine should have %qs "
3648 "as the second argument",
3650 ? (TARGET_X32
? "unsigned long long int"
3651 : "unsigned long int")
3655 current_arg_type
= TREE_CHAIN (current_arg_type
);
3657 if (!nargs
|| nargs
> 2)
3658 error ("interrupt service routine can only have a pointer argument "
3659 "and an optional integer argument");
3660 if (! VOID_TYPE_P (return_type
))
3661 error ("interrupt service routine must return %<void%>");
3666 /* Handle fentry_name / fentry_section attribute. */
3669 ix86_handle_fentry_name (tree
*node
, tree name
, tree args
,
3670 int, bool *no_add_attrs
)
3672 if (TREE_CODE (*node
) == FUNCTION_DECL
3673 && TREE_CODE (TREE_VALUE (args
)) == STRING_CST
)
3674 /* Do nothing else, just set the attribute. We'll get at
3675 it later with lookup_attribute. */
3679 warning (OPT_Wattributes
, "%qE attribute ignored", name
);
3680 *no_add_attrs
= true;
3686 /* Table of valid machine attributes. */
3687 const struct attribute_spec ix86_attribute_table
[] =
3689 /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
3690 affects_type_identity, handler, exclude } */
3691 /* Stdcall attribute says callee is responsible for popping arguments
3692 if they are not variable. */
3693 { "stdcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3695 /* Fastcall attribute says callee is responsible for popping arguments
3696 if they are not variable. */
3697 { "fastcall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3699 /* Thiscall attribute says callee is responsible for popping arguments
3700 if they are not variable. */
3701 { "thiscall", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3703 /* Cdecl attribute says the callee is a normal C declaration */
3704 { "cdecl", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3706 /* Regparm attribute specifies how many integer arguments are to be
3707 passed in registers. */
3708 { "regparm", 1, 1, false, true, true, true, ix86_handle_cconv_attribute
,
3710 /* Sseregparm attribute says we are using x86_64 calling conventions
3711 for FP arguments. */
3712 { "sseregparm", 0, 0, false, true, true, true, ix86_handle_cconv_attribute
,
3714 /* The transactional memory builtins are implicitly regparm or fastcall
3715 depending on the ABI. Override the generic do-nothing attribute that
3716 these builtins were declared with. */
3717 { "*tm regparm", 0, 0, false, true, true, true,
3718 ix86_handle_tm_regparm_attribute
, NULL
},
3719 /* force_align_arg_pointer says this function realigns the stack at entry. */
3720 { "force_align_arg_pointer", 0, 0,
3721 false, true, true, false, ix86_handle_force_align_arg_pointer_attribute
,
3723 #if TARGET_DLLIMPORT_DECL_ATTRIBUTES
3724 { "dllimport", 0, 0, false, false, false, false, handle_dll_attribute
,
3726 { "dllexport", 0, 0, false, false, false, false, handle_dll_attribute
,
3728 { "shared", 0, 0, true, false, false, false,
3729 ix86_handle_shared_attribute
, NULL
},
3731 { "ms_struct", 0, 0, false, false, false, false,
3732 ix86_handle_struct_attribute
, NULL
},
3733 { "gcc_struct", 0, 0, false, false, false, false,
3734 ix86_handle_struct_attribute
, NULL
},
3735 #ifdef SUBTARGET_ATTRIBUTE_TABLE
3736 SUBTARGET_ATTRIBUTE_TABLE
,
3738 /* ms_abi and sysv_abi calling convention function attributes. */
3739 { "ms_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute
, NULL
},
3740 { "sysv_abi", 0, 0, false, true, true, true, ix86_handle_abi_attribute
,
3742 { "ms_abi va_list", 0, 0, false, false, false, false, NULL
, NULL
},
3743 { "sysv_abi va_list", 0, 0, false, false, false, false, NULL
, NULL
},
3744 { "ms_hook_prologue", 0, 0, true, false, false, false,
3745 ix86_handle_fndecl_attribute
, NULL
},
3746 { "callee_pop_aggregate_return", 1, 1, false, true, true, true,
3747 ix86_handle_callee_pop_aggregate_return
, NULL
},
3748 { "interrupt", 0, 0, false, true, true, false,
3749 ix86_handle_interrupt_attribute
, NULL
},
3750 { "no_caller_saved_registers", 0, 0, false, true, true, false,
3751 ix86_handle_no_caller_saved_registers_attribute
, NULL
},
3752 { "naked", 0, 0, true, false, false, false,
3753 ix86_handle_fndecl_attribute
, NULL
},
3754 { "indirect_branch", 1, 1, true, false, false, false,
3755 ix86_handle_fndecl_attribute
, NULL
},
3756 { "function_return", 1, 1, true, false, false, false,
3757 ix86_handle_fndecl_attribute
, NULL
},
3758 { "indirect_return", 0, 0, false, true, true, false,
3760 { "fentry_name", 1, 1, true, false, false, false,
3761 ix86_handle_fentry_name
, NULL
},
3762 { "fentry_section", 1, 1, true, false, false, false,
3763 ix86_handle_fentry_name
, NULL
},
3764 { "cf_check", 0, 0, true, false, false, false,
3765 ix86_handle_fndecl_attribute
, NULL
},
3768 { NULL
, 0, 0, false, false, false, false, NULL
, NULL
}
3771 #include "gt-i386-options.h"