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