comparison gcc/config/i386/i386-c.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* Subroutines used for macro/preprocessor support on the ia-32. 1 /* Subroutines used for macro/preprocessor support on the ia-32.
2 Copyright (C) 2008, 2009, 2010 2 Copyright (C) 2008-2017 Free Software Foundation, Inc.
3 Free Software Foundation, Inc.
4 3
5 This file is part of GCC. 4 This file is part of GCC.
6 5
7 GCC is free software; you can redistribute it and/or modify 6 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
19 <http://www.gnu.org/licenses/>. */ 18 <http://www.gnu.org/licenses/>. */
20 19
21 #include "config.h" 20 #include "config.h"
22 #include "system.h" 21 #include "system.h"
23 #include "coretypes.h" 22 #include "coretypes.h"
24 #include "tm.h" 23 #include "target.h"
25 #include "tree.h" 24 #include "c-family/c-common.h"
25 #include "memmodel.h"
26 #include "tm_p.h" 26 #include "tm_p.h"
27 #include "flags.h"
28 #include "c-family/c-common.h"
29 #include "ggc.h"
30 #include "target.h"
31 #include "target-def.h"
32 #include "cpplib.h"
33 #include "c-family/c-pragma.h" 27 #include "c-family/c-pragma.h"
34 28
35 static bool ix86_pragma_target_parse (tree, tree); 29 static bool ix86_pragma_target_parse (tree, tree);
36 static void ix86_target_macros_internal 30 static void ix86_target_macros_internal
37 (int, enum processor_type, enum processor_type, enum fpmath_unit, 31 (HOST_WIDE_INT, HOST_WIDE_INT, enum processor_type, enum processor_type, enum fpmath_unit,
38 void (*def_or_undef) (cpp_reader *, const char *)); 32 void (*def_or_undef) (cpp_reader *, const char *));
39 33
40
41 /* Internal function to either define or undef the appropriate system 34 /* Internal function to either define or undef the appropriate system
42 macros. */ 35 macros. */
43 static void 36 static void
44 ix86_target_macros_internal (int isa_flag, 37 ix86_target_macros_internal (HOST_WIDE_INT isa_flag,
38 HOST_WIDE_INT isa_flag2,
45 enum processor_type arch, 39 enum processor_type arch,
46 enum processor_type tune, 40 enum processor_type tune,
47 enum fpmath_unit fpmath, 41 enum fpmath_unit fpmath,
48 void (*def_or_undef) (cpp_reader *, 42 void (*def_or_undef) (cpp_reader *,
49 const char *)) 43 const char *))
50 { 44 {
51 /* For some of the k6/pentium varients there weren't seperate ISA bits to 45 /* For some of the k6/pentium varients there weren't separate ISA bits to
52 identify which tune/arch flag was passed, so figure it out here. */ 46 identify which tune/arch flag was passed, so figure it out here. */
53 size_t arch_len = strlen (ix86_arch_string); 47 size_t arch_len = strlen (ix86_arch_string);
54 size_t tune_len = strlen (ix86_tune_string); 48 size_t tune_len = strlen (ix86_tune_string);
55 int last_arch_char = ix86_arch_string[arch_len - 1]; 49 int last_arch_char = ix86_arch_string[arch_len - 1];
56 int last_tune_char = ix86_tune_string[tune_len - 1]; 50 int last_tune_char = ix86_tune_string[tune_len - 1];
62 break; 56 break;
63 case PROCESSOR_I486: 57 case PROCESSOR_I486:
64 def_or_undef (parse_in, "__i486"); 58 def_or_undef (parse_in, "__i486");
65 def_or_undef (parse_in, "__i486__"); 59 def_or_undef (parse_in, "__i486__");
66 break; 60 break;
61 case PROCESSOR_LAKEMONT:
62 /* Intel MCU is based on Intel Pentium CPU. */
67 case PROCESSOR_PENTIUM: 63 case PROCESSOR_PENTIUM:
68 def_or_undef (parse_in, "__i586"); 64 def_or_undef (parse_in, "__i586");
69 def_or_undef (parse_in, "__i586__"); 65 def_or_undef (parse_in, "__i586__");
70 def_or_undef (parse_in, "__pentium"); 66 def_or_undef (parse_in, "__pentium");
71 def_or_undef (parse_in, "__pentium__"); 67 def_or_undef (parse_in, "__pentium__");
108 break; 104 break;
109 case PROCESSOR_BDVER1: 105 case PROCESSOR_BDVER1:
110 def_or_undef (parse_in, "__bdver1"); 106 def_or_undef (parse_in, "__bdver1");
111 def_or_undef (parse_in, "__bdver1__"); 107 def_or_undef (parse_in, "__bdver1__");
112 break; 108 break;
109 case PROCESSOR_BDVER2:
110 def_or_undef (parse_in, "__bdver2");
111 def_or_undef (parse_in, "__bdver2__");
112 break;
113 case PROCESSOR_BDVER3:
114 def_or_undef (parse_in, "__bdver3");
115 def_or_undef (parse_in, "__bdver3__");
116 break;
117 case PROCESSOR_BDVER4:
118 def_or_undef (parse_in, "__bdver4");
119 def_or_undef (parse_in, "__bdver4__");
120 break;
121 case PROCESSOR_ZNVER1:
122 def_or_undef (parse_in, "__znver1");
123 def_or_undef (parse_in, "__znver1__");
124 break;
113 case PROCESSOR_BTVER1: 125 case PROCESSOR_BTVER1:
114 def_or_undef (parse_in, "__btver1"); 126 def_or_undef (parse_in, "__btver1");
115 def_or_undef (parse_in, "__btver1__"); 127 def_or_undef (parse_in, "__btver1__");
116 break; 128 break;
129 case PROCESSOR_BTVER2:
130 def_or_undef (parse_in, "__btver2");
131 def_or_undef (parse_in, "__btver2__");
132 break;
117 case PROCESSOR_PENTIUM4: 133 case PROCESSOR_PENTIUM4:
118 def_or_undef (parse_in, "__pentium4"); 134 def_or_undef (parse_in, "__pentium4");
119 def_or_undef (parse_in, "__pentium4__"); 135 def_or_undef (parse_in, "__pentium4__");
120 break; 136 break;
121 case PROCESSOR_NOCONA: 137 case PROCESSOR_NOCONA:
122 def_or_undef (parse_in, "__nocona"); 138 def_or_undef (parse_in, "__nocona");
123 def_or_undef (parse_in, "__nocona__"); 139 def_or_undef (parse_in, "__nocona__");
124 break; 140 break;
125 case PROCESSOR_CORE2_32: 141 case PROCESSOR_CORE2:
126 case PROCESSOR_CORE2_64:
127 def_or_undef (parse_in, "__core2"); 142 def_or_undef (parse_in, "__core2");
128 def_or_undef (parse_in, "__core2__"); 143 def_or_undef (parse_in, "__core2__");
129 break; 144 break;
130 case PROCESSOR_COREI7_32: 145 case PROCESSOR_NEHALEM:
131 case PROCESSOR_COREI7_64:
132 def_or_undef (parse_in, "__corei7"); 146 def_or_undef (parse_in, "__corei7");
133 def_or_undef (parse_in, "__corei7__"); 147 def_or_undef (parse_in, "__corei7__");
134 break; 148 def_or_undef (parse_in, "__nehalem");
135 case PROCESSOR_ATOM: 149 def_or_undef (parse_in, "__nehalem__");
150 break;
151 case PROCESSOR_SANDYBRIDGE:
152 def_or_undef (parse_in, "__corei7_avx");
153 def_or_undef (parse_in, "__corei7_avx__");
154 def_or_undef (parse_in, "__sandybridge");
155 def_or_undef (parse_in, "__sandybridge__");
156 break;
157 case PROCESSOR_HASWELL:
158 def_or_undef (parse_in, "__core_avx2");
159 def_or_undef (parse_in, "__core_avx2__");
160 def_or_undef (parse_in, "__haswell");
161 def_or_undef (parse_in, "__haswell__");
162 break;
163 case PROCESSOR_BONNELL:
136 def_or_undef (parse_in, "__atom"); 164 def_or_undef (parse_in, "__atom");
137 def_or_undef (parse_in, "__atom__"); 165 def_or_undef (parse_in, "__atom__");
166 def_or_undef (parse_in, "__bonnell");
167 def_or_undef (parse_in, "__bonnell__");
168 break;
169 case PROCESSOR_SILVERMONT:
170 def_or_undef (parse_in, "__slm");
171 def_or_undef (parse_in, "__slm__");
172 def_or_undef (parse_in, "__silvermont");
173 def_or_undef (parse_in, "__silvermont__");
174 break;
175 case PROCESSOR_KNL:
176 def_or_undef (parse_in, "__knl");
177 def_or_undef (parse_in, "__knl__");
178 break;
179 case PROCESSOR_KNM:
180 def_or_undef (parse_in, "__knm");
181 def_or_undef (parse_in, "__knm__");
182 break;
183 case PROCESSOR_SKYLAKE_AVX512:
184 def_or_undef (parse_in, "__skylake_avx512");
185 def_or_undef (parse_in, "__skylake_avx512__");
138 break; 186 break;
139 /* use PROCESSOR_max to not set/unset the arch macro. */ 187 /* use PROCESSOR_max to not set/unset the arch macro. */
140 case PROCESSOR_max: 188 case PROCESSOR_max:
141 break; 189 break;
142 case PROCESSOR_GENERIC32: 190 case PROCESSOR_INTEL:
143 case PROCESSOR_GENERIC64: 191 case PROCESSOR_GENERIC:
144 gcc_unreachable (); 192 gcc_unreachable ();
145 } 193 }
146 194
147 /* Built-ins based on -mtune=. */ 195 /* Built-ins based on -mtune=. */
148 switch (tune) 196 switch (tune)
196 def_or_undef (parse_in, "__tune_amdfam10__"); 244 def_or_undef (parse_in, "__tune_amdfam10__");
197 break; 245 break;
198 case PROCESSOR_BDVER1: 246 case PROCESSOR_BDVER1:
199 def_or_undef (parse_in, "__tune_bdver1__"); 247 def_or_undef (parse_in, "__tune_bdver1__");
200 break; 248 break;
201 case PROCESSOR_BTVER1: 249 case PROCESSOR_BDVER2:
250 def_or_undef (parse_in, "__tune_bdver2__");
251 break;
252 case PROCESSOR_BDVER3:
253 def_or_undef (parse_in, "__tune_bdver3__");
254 break;
255 case PROCESSOR_BDVER4:
256 def_or_undef (parse_in, "__tune_bdver4__");
257 break;
258 case PROCESSOR_ZNVER1:
259 def_or_undef (parse_in, "__tune_znver1__");
260 break;
261 case PROCESSOR_BTVER1:
202 def_or_undef (parse_in, "__tune_btver1__"); 262 def_or_undef (parse_in, "__tune_btver1__");
203 break; 263 break;
264 case PROCESSOR_BTVER2:
265 def_or_undef (parse_in, "__tune_btver2__");
266 break;
204 case PROCESSOR_PENTIUM4: 267 case PROCESSOR_PENTIUM4:
205 def_or_undef (parse_in, "__tune_pentium4__"); 268 def_or_undef (parse_in, "__tune_pentium4__");
206 break; 269 break;
207 case PROCESSOR_NOCONA: 270 case PROCESSOR_NOCONA:
208 def_or_undef (parse_in, "__tune_nocona__"); 271 def_or_undef (parse_in, "__tune_nocona__");
209 break; 272 break;
210 case PROCESSOR_CORE2_32: 273 case PROCESSOR_CORE2:
211 case PROCESSOR_CORE2_64:
212 def_or_undef (parse_in, "__tune_core2__"); 274 def_or_undef (parse_in, "__tune_core2__");
213 break; 275 break;
214 case PROCESSOR_COREI7_32: 276 case PROCESSOR_NEHALEM:
215 case PROCESSOR_COREI7_64:
216 def_or_undef (parse_in, "__tune_corei7__"); 277 def_or_undef (parse_in, "__tune_corei7__");
217 break; 278 def_or_undef (parse_in, "__tune_nehalem__");
218 case PROCESSOR_ATOM: 279 break;
280 case PROCESSOR_SANDYBRIDGE:
281 def_or_undef (parse_in, "__tune_corei7_avx__");
282 def_or_undef (parse_in, "__tune_sandybridge__");
283 break;
284 case PROCESSOR_HASWELL:
285 def_or_undef (parse_in, "__tune_core_avx2__");
286 def_or_undef (parse_in, "__tune_haswell__");
287 break;
288 case PROCESSOR_BONNELL:
219 def_or_undef (parse_in, "__tune_atom__"); 289 def_or_undef (parse_in, "__tune_atom__");
220 break; 290 def_or_undef (parse_in, "__tune_bonnell__");
221 case PROCESSOR_GENERIC32: 291 break;
222 case PROCESSOR_GENERIC64: 292 case PROCESSOR_SILVERMONT:
293 def_or_undef (parse_in, "__tune_slm__");
294 def_or_undef (parse_in, "__tune_silvermont__");
295 break;
296 case PROCESSOR_KNL:
297 def_or_undef (parse_in, "__tune_knl__");
298 break;
299 case PROCESSOR_KNM:
300 def_or_undef (parse_in, "__tune_knm__");
301 break;
302 case PROCESSOR_SKYLAKE_AVX512:
303 def_or_undef (parse_in, "__tune_skylake_avx512__");
304 break;
305 case PROCESSOR_LAKEMONT:
306 def_or_undef (parse_in, "__tune_lakemont__");
307 break;
308 case PROCESSOR_INTEL:
309 case PROCESSOR_GENERIC:
223 break; 310 break;
224 /* use PROCESSOR_max to not set/unset the tune macro. */ 311 /* use PROCESSOR_max to not set/unset the tune macro. */
225 case PROCESSOR_max: 312 case PROCESSOR_max:
226 break; 313 break;
314 }
315
316 switch (ix86_cmodel)
317 {
318 case CM_SMALL:
319 case CM_SMALL_PIC:
320 def_or_undef (parse_in, "__code_model_small__");
321 break;
322 case CM_MEDIUM:
323 case CM_MEDIUM_PIC:
324 def_or_undef (parse_in, "__code_model_medium__");
325 break;
326 case CM_LARGE:
327 case CM_LARGE_PIC:
328 def_or_undef (parse_in, "__code_model_large__");
329 break;
330 case CM_32:
331 def_or_undef (parse_in, "__code_model_32__");
332 break;
333 case CM_KERNEL:
334 def_or_undef (parse_in, "__code_model_kernel__");
335 break;
336 default:
337 ;
227 } 338 }
228 339
229 if (isa_flag & OPTION_MASK_ISA_MMX) 340 if (isa_flag & OPTION_MASK_ISA_MMX)
230 def_or_undef (parse_in, "__MMX__"); 341 def_or_undef (parse_in, "__MMX__");
231 if (isa_flag & OPTION_MASK_ISA_3DNOW) 342 if (isa_flag & OPTION_MASK_ISA_3DNOW)
244 def_or_undef (parse_in, "__SSE4_1__"); 355 def_or_undef (parse_in, "__SSE4_1__");
245 if (isa_flag & OPTION_MASK_ISA_SSE4_2) 356 if (isa_flag & OPTION_MASK_ISA_SSE4_2)
246 def_or_undef (parse_in, "__SSE4_2__"); 357 def_or_undef (parse_in, "__SSE4_2__");
247 if (isa_flag & OPTION_MASK_ISA_AES) 358 if (isa_flag & OPTION_MASK_ISA_AES)
248 def_or_undef (parse_in, "__AES__"); 359 def_or_undef (parse_in, "__AES__");
360 if (isa_flag & OPTION_MASK_ISA_SHA)
361 def_or_undef (parse_in, "__SHA__");
249 if (isa_flag & OPTION_MASK_ISA_PCLMUL) 362 if (isa_flag & OPTION_MASK_ISA_PCLMUL)
250 def_or_undef (parse_in, "__PCLMUL__"); 363 def_or_undef (parse_in, "__PCLMUL__");
251 if (isa_flag & OPTION_MASK_ISA_AVX) 364 if (isa_flag & OPTION_MASK_ISA_AVX)
252 def_or_undef (parse_in, "__AVX__"); 365 def_or_undef (parse_in, "__AVX__");
366 if (isa_flag & OPTION_MASK_ISA_AVX2)
367 def_or_undef (parse_in, "__AVX2__");
368 if (isa_flag & OPTION_MASK_ISA_AVX512F)
369 def_or_undef (parse_in, "__AVX512F__");
370 if (isa_flag & OPTION_MASK_ISA_AVX512ER)
371 def_or_undef (parse_in, "__AVX512ER__");
372 if (isa_flag & OPTION_MASK_ISA_AVX512CD)
373 def_or_undef (parse_in, "__AVX512CD__");
374 if (isa_flag & OPTION_MASK_ISA_AVX512PF)
375 def_or_undef (parse_in, "__AVX512PF__");
376 if (isa_flag & OPTION_MASK_ISA_AVX512DQ)
377 def_or_undef (parse_in, "__AVX512DQ__");
378 if (isa_flag & OPTION_MASK_ISA_AVX512BW)
379 def_or_undef (parse_in, "__AVX512BW__");
380 if (isa_flag & OPTION_MASK_ISA_AVX512VL)
381 def_or_undef (parse_in, "__AVX512VL__");
382 if (isa_flag & OPTION_MASK_ISA_AVX512VBMI)
383 def_or_undef (parse_in, "__AVX512VBMI__");
384 if (isa_flag & OPTION_MASK_ISA_AVX512IFMA)
385 def_or_undef (parse_in, "__AVX512IFMA__");
386 if (isa_flag2 & OPTION_MASK_ISA_AVX5124VNNIW)
387 def_or_undef (parse_in, "__AVX5124VNNIW__");
388 if (isa_flag2 & OPTION_MASK_ISA_SGX)
389 def_or_undef (parse_in, "__SGX__");
390 if (isa_flag2 & OPTION_MASK_ISA_AVX5124FMAPS)
391 def_or_undef (parse_in, "__AVX5124FMAPS__");
392 if (isa_flag2 & OPTION_MASK_ISA_AVX512VPOPCNTDQ)
393 def_or_undef (parse_in, "__AVX512VPOPCNTDQ__");
253 if (isa_flag & OPTION_MASK_ISA_FMA) 394 if (isa_flag & OPTION_MASK_ISA_FMA)
254 def_or_undef (parse_in, "__FMA__"); 395 def_or_undef (parse_in, "__FMA__");
396 if (isa_flag & OPTION_MASK_ISA_RTM)
397 def_or_undef (parse_in, "__RTM__");
255 if (isa_flag & OPTION_MASK_ISA_SSE4A) 398 if (isa_flag & OPTION_MASK_ISA_SSE4A)
256 def_or_undef (parse_in, "__SSE4A__"); 399 def_or_undef (parse_in, "__SSE4A__");
257 if (isa_flag & OPTION_MASK_ISA_FMA4) 400 if (isa_flag & OPTION_MASK_ISA_FMA4)
258 def_or_undef (parse_in, "__FMA4__"); 401 def_or_undef (parse_in, "__FMA4__");
259 if (isa_flag & OPTION_MASK_ISA_XOP) 402 if (isa_flag & OPTION_MASK_ISA_XOP)
262 def_or_undef (parse_in, "__LWP__"); 405 def_or_undef (parse_in, "__LWP__");
263 if (isa_flag & OPTION_MASK_ISA_ABM) 406 if (isa_flag & OPTION_MASK_ISA_ABM)
264 def_or_undef (parse_in, "__ABM__"); 407 def_or_undef (parse_in, "__ABM__");
265 if (isa_flag & OPTION_MASK_ISA_BMI) 408 if (isa_flag & OPTION_MASK_ISA_BMI)
266 def_or_undef (parse_in, "__BMI__"); 409 def_or_undef (parse_in, "__BMI__");
410 if (isa_flag & OPTION_MASK_ISA_BMI2)
411 def_or_undef (parse_in, "__BMI2__");
412 if (isa_flag & OPTION_MASK_ISA_LZCNT)
413 def_or_undef (parse_in, "__LZCNT__");
267 if (isa_flag & OPTION_MASK_ISA_TBM) 414 if (isa_flag & OPTION_MASK_ISA_TBM)
268 def_or_undef (parse_in, "__TBM__"); 415 def_or_undef (parse_in, "__TBM__");
269 if (isa_flag & OPTION_MASK_ISA_POPCNT) 416 if (isa_flag & OPTION_MASK_ISA_POPCNT)
270 def_or_undef (parse_in, "__POPCNT__"); 417 def_or_undef (parse_in, "__POPCNT__");
271 if (isa_flag & OPTION_MASK_ISA_FSGSBASE) 418 if (isa_flag & OPTION_MASK_ISA_FSGSBASE)
272 def_or_undef (parse_in, "__FSGSBASE__"); 419 def_or_undef (parse_in, "__FSGSBASE__");
273 if (isa_flag & OPTION_MASK_ISA_RDRND) 420 if (isa_flag & OPTION_MASK_ISA_RDRND)
274 def_or_undef (parse_in, "__RDRND__"); 421 def_or_undef (parse_in, "__RDRND__");
275 if (isa_flag & OPTION_MASK_ISA_F16C) 422 if (isa_flag & OPTION_MASK_ISA_F16C)
276 def_or_undef (parse_in, "__F16C__"); 423 def_or_undef (parse_in, "__F16C__");
424 if (isa_flag & OPTION_MASK_ISA_RDSEED)
425 def_or_undef (parse_in, "__RDSEED__");
426 if (isa_flag & OPTION_MASK_ISA_PRFCHW)
427 def_or_undef (parse_in, "__PRFCHW__");
428 if (isa_flag & OPTION_MASK_ISA_ADX)
429 def_or_undef (parse_in, "__ADX__");
430 if (isa_flag & OPTION_MASK_ISA_FXSR)
431 def_or_undef (parse_in, "__FXSR__");
432 if (isa_flag & OPTION_MASK_ISA_XSAVE)
433 def_or_undef (parse_in, "__XSAVE__");
434 if (isa_flag & OPTION_MASK_ISA_XSAVEOPT)
435 def_or_undef (parse_in, "__XSAVEOPT__");
436 if (isa_flag & OPTION_MASK_ISA_PREFETCHWT1)
437 def_or_undef (parse_in, "__PREFETCHWT1__");
277 if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE)) 438 if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE))
278 def_or_undef (parse_in, "__SSE_MATH__"); 439 def_or_undef (parse_in, "__SSE_MATH__");
279 if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE2)) 440 if ((fpmath & FPMATH_SSE) && (isa_flag & OPTION_MASK_ISA_SSE2))
280 def_or_undef (parse_in, "__SSE2_MATH__"); 441 def_or_undef (parse_in, "__SSE2_MATH__");
442 if (isa_flag & OPTION_MASK_ISA_CLFLUSHOPT)
443 def_or_undef (parse_in, "__CLFLUSHOPT__");
444 if (isa_flag & OPTION_MASK_ISA_CLZERO)
445 def_or_undef (parse_in, "__CLZERO__");
446 if (isa_flag & OPTION_MASK_ISA_XSAVEC)
447 def_or_undef (parse_in, "__XSAVEC__");
448 if (isa_flag & OPTION_MASK_ISA_XSAVES)
449 def_or_undef (parse_in, "__XSAVES__");
450 if (isa_flag & OPTION_MASK_ISA_MPX)
451 def_or_undef (parse_in, "__MPX__");
452 if (isa_flag & OPTION_MASK_ISA_CLWB)
453 def_or_undef (parse_in, "__CLWB__");
454 if (isa_flag & OPTION_MASK_ISA_MWAITX)
455 def_or_undef (parse_in, "__MWAITX__");
456 if (isa_flag & OPTION_MASK_ISA_PKU)
457 def_or_undef (parse_in, "__PKU__");
458 if (isa_flag2 & OPTION_MASK_ISA_RDPID)
459 def_or_undef (parse_in, "__RDPID__");
460 if (isa_flag2 & OPTION_MASK_ISA_GFNI)
461 def_or_undef (parse_in, "__GFNI__");
462 if (isa_flag2 & OPTION_MASK_ISA_IBT)
463 {
464 def_or_undef (parse_in, "__IBT__");
465 if (flag_cf_protection != CF_NONE)
466 def_or_undef (parse_in, "__CET__");
467 }
468 if (isa_flag2 & OPTION_MASK_ISA_SHSTK)
469 {
470 def_or_undef (parse_in, "__SHSTK__");
471 if (flag_cf_protection != CF_NONE)
472 def_or_undef (parse_in, "__CET__");
473 }
474 if (TARGET_IAMCU)
475 {
476 def_or_undef (parse_in, "__iamcu");
477 def_or_undef (parse_in, "__iamcu__");
478 }
281 } 479 }
282 480
283 481
284 /* Hook to validate the current #pragma GCC target and set the state, and 482 /* Hook to validate the current #pragma GCC target and set the state, and
285 update the macros based on what was changed. If ARGS is NULL, then 483 update the macros based on what was changed. If ARGS is NULL, then
286 POP_TARGET is used to reset the options. */ 484 POP_TARGET is used to reset the options. */
287 485
288 static bool 486 static bool
289 ix86_pragma_target_parse (tree args, tree pop_target) 487 ix86_pragma_target_parse (tree args, tree pop_target)
290 { 488 {
291 tree prev_tree = build_target_option_node (); 489 tree prev_tree = build_target_option_node (&global_options);
292 tree cur_tree; 490 tree cur_tree;
293 struct cl_target_option *prev_opt; 491 struct cl_target_option *prev_opt;
294 struct cl_target_option *cur_opt; 492 struct cl_target_option *cur_opt;
295 int prev_isa; 493 HOST_WIDE_INT prev_isa;
296 int cur_isa; 494 HOST_WIDE_INT cur_isa;
297 int diff_isa; 495 HOST_WIDE_INT diff_isa;
496 HOST_WIDE_INT prev_isa2;
497 HOST_WIDE_INT cur_isa2;
498 HOST_WIDE_INT diff_isa2;
298 enum processor_type prev_arch; 499 enum processor_type prev_arch;
299 enum processor_type prev_tune; 500 enum processor_type prev_tune;
300 enum processor_type cur_arch; 501 enum processor_type cur_arch;
301 enum processor_type cur_tune; 502 enum processor_type cur_tune;
302 503
303 if (! args) 504 if (! args)
304 { 505 {
305 cur_tree = ((pop_target) 506 cur_tree = (pop_target ? pop_target : target_option_default_node);
306 ? pop_target
307 : target_option_default_node);
308 cl_target_option_restore (&global_options, 507 cl_target_option_restore (&global_options,
309 TREE_TARGET_OPTION (cur_tree)); 508 TREE_TARGET_OPTION (cur_tree));
310 } 509 }
311 else 510 else
312 { 511 {
313 cur_tree = ix86_valid_target_attribute_tree (args); 512 cur_tree = ix86_valid_target_attribute_tree (args, &global_options,
314 if (!cur_tree) 513 &global_options_set);
315 return false; 514 if (!cur_tree || cur_tree == error_mark_node)
515 {
516 cl_target_option_restore (&global_options,
517 TREE_TARGET_OPTION (prev_tree));
518 return false;
519 }
316 } 520 }
317 521
318 target_option_current_node = cur_tree; 522 target_option_current_node = cur_tree;
523 ix86_reset_previous_fndecl ();
319 524
320 /* Figure out the previous/current isa, arch, tune and the differences. */ 525 /* Figure out the previous/current isa, arch, tune and the differences. */
321 prev_opt = TREE_TARGET_OPTION (prev_tree); 526 prev_opt = TREE_TARGET_OPTION (prev_tree);
322 cur_opt = TREE_TARGET_OPTION (cur_tree); 527 cur_opt = TREE_TARGET_OPTION (cur_tree);
323 prev_isa = prev_opt->x_ix86_isa_flags; 528 prev_isa = prev_opt->x_ix86_isa_flags;
324 cur_isa = cur_opt->x_ix86_isa_flags; 529 cur_isa = cur_opt->x_ix86_isa_flags;
325 diff_isa = (prev_isa ^ cur_isa); 530 diff_isa = (prev_isa ^ cur_isa);
531 prev_isa2 = prev_opt->x_ix86_isa_flags2;
532 cur_isa2 = cur_opt->x_ix86_isa_flags2;
533 diff_isa2 = (prev_isa2 ^ cur_isa2);
326 prev_arch = (enum processor_type) prev_opt->arch; 534 prev_arch = (enum processor_type) prev_opt->arch;
327 prev_tune = (enum processor_type) prev_opt->tune; 535 prev_tune = (enum processor_type) prev_opt->tune;
328 cur_arch = (enum processor_type) cur_opt->arch; 536 cur_arch = (enum processor_type) cur_opt->arch;
329 cur_tune = (enum processor_type) cur_opt->tune; 537 cur_tune = (enum processor_type) cur_opt->tune;
330 538
336 if (cur_tune == prev_tune) 544 if (cur_tune == prev_tune)
337 cur_tune = prev_tune = PROCESSOR_max; 545 cur_tune = prev_tune = PROCESSOR_max;
338 546
339 /* Undef all of the macros for that are no longer current. */ 547 /* Undef all of the macros for that are no longer current. */
340 ix86_target_macros_internal (prev_isa & diff_isa, 548 ix86_target_macros_internal (prev_isa & diff_isa,
549 prev_isa2 & diff_isa2,
341 prev_arch, 550 prev_arch,
342 prev_tune, 551 prev_tune,
343 (enum fpmath_unit) prev_opt->fpmath, 552 (enum fpmath_unit) prev_opt->x_ix86_fpmath,
344 cpp_undef); 553 cpp_undef);
554
555 /* For the definitions, ensure all newly defined macros are considered
556 as used for -Wunused-macros. There is no point warning about the
557 compiler predefined macros. */
558 cpp_options *cpp_opts = cpp_get_options (parse_in);
559 unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros;
560 cpp_opts->warn_unused_macros = 0;
345 561
346 /* Define all of the macros for new options that were just turned on. */ 562 /* Define all of the macros for new options that were just turned on. */
347 ix86_target_macros_internal (cur_isa & diff_isa, 563 ix86_target_macros_internal (cur_isa & diff_isa,
564 cur_isa2 & diff_isa2,
348 cur_arch, 565 cur_arch,
349 cur_tune, 566 cur_tune,
350 (enum fpmath_unit) cur_opt->fpmath, 567 (enum fpmath_unit) cur_opt->x_ix86_fpmath,
351 cpp_define); 568 cpp_define);
569
570 cpp_opts->warn_unused_macros = saved_warn_unused_macros;
352 571
353 return true; 572 return true;
354 } 573 }
355 574
356 /* Function to tell the preprocessor about the defines for the current target. */ 575 /* Function to tell the preprocessor about the defines for the current target. */
366 cpp_assert (parse_in, "machine=x86_64"); 585 cpp_assert (parse_in, "machine=x86_64");
367 cpp_define (parse_in, "__amd64"); 586 cpp_define (parse_in, "__amd64");
368 cpp_define (parse_in, "__amd64__"); 587 cpp_define (parse_in, "__amd64__");
369 cpp_define (parse_in, "__x86_64"); 588 cpp_define (parse_in, "__x86_64");
370 cpp_define (parse_in, "__x86_64__"); 589 cpp_define (parse_in, "__x86_64__");
590 if (TARGET_X32)
591 {
592 cpp_define (parse_in, "_ILP32");
593 cpp_define (parse_in, "__ILP32__");
594 }
371 } 595 }
372 else 596 else
373 { 597 {
374 cpp_assert (parse_in, "cpu=i386"); 598 cpp_assert (parse_in, "cpu=i386");
375 cpp_assert (parse_in, "machine=i386"); 599 cpp_assert (parse_in, "machine=i386");
376 builtin_define_std ("i386"); 600 builtin_define_std ("i386");
377 } 601 }
378 602
603 if (!TARGET_80387)
604 cpp_define (parse_in, "_SOFT_FLOAT");
605
606 if (TARGET_LONG_DOUBLE_64)
607 cpp_define (parse_in, "__LONG_DOUBLE_64__");
608
609 if (TARGET_LONG_DOUBLE_128)
610 cpp_define (parse_in, "__LONG_DOUBLE_128__");
611
612 if (TARGET_128BIT_LONG_DOUBLE)
613 cpp_define (parse_in, "__SIZEOF_FLOAT80__=16");
614 else
615 cpp_define (parse_in, "__SIZEOF_FLOAT80__=12");
616
617 cpp_define (parse_in, "__SIZEOF_FLOAT128__=16");
618
619 cpp_define_formatted (parse_in, "__ATOMIC_HLE_ACQUIRE=%d", IX86_HLE_ACQUIRE);
620 cpp_define_formatted (parse_in, "__ATOMIC_HLE_RELEASE=%d", IX86_HLE_RELEASE);
621
622 cpp_define (parse_in, "__GCC_ASM_FLAG_OUTPUTS__");
623
379 ix86_target_macros_internal (ix86_isa_flags, 624 ix86_target_macros_internal (ix86_isa_flags,
625 ix86_isa_flags2,
380 ix86_arch, 626 ix86_arch,
381 ix86_tune, 627 ix86_tune,
382 ix86_fpmath, 628 ix86_fpmath,
383 cpp_define); 629 cpp_define);
630
631 cpp_define (parse_in, "__SEG_FS");
632 cpp_define (parse_in, "__SEG_GS");
384 } 633 }
385 634
386 635
387 /* Register target pragmas. We need to add the hook for parsing #pragma GCC 636 /* Register target pragmas. We need to add the hook for parsing #pragma GCC
388 option here rather than in i386.c since it will pull in various preprocessor 637 option here rather than in i386.c since it will pull in various preprocessor
393 ix86_register_pragmas (void) 642 ix86_register_pragmas (void)
394 { 643 {
395 /* Update pragma hook to allow parsing #pragma GCC target. */ 644 /* Update pragma hook to allow parsing #pragma GCC target. */
396 targetm.target_option.pragma_parse = ix86_pragma_target_parse; 645 targetm.target_option.pragma_parse = ix86_pragma_target_parse;
397 646
647 c_register_addr_space ("__seg_fs", ADDR_SPACE_SEG_FS);
648 c_register_addr_space ("__seg_gs", ADDR_SPACE_SEG_GS);
649
398 #ifdef REGISTER_SUBTARGET_PRAGMAS 650 #ifdef REGISTER_SUBTARGET_PRAGMAS
399 REGISTER_SUBTARGET_PRAGMAS (); 651 REGISTER_SUBTARGET_PRAGMAS ();
400 #endif 652 #endif
401 } 653 }