1 /* Subroutines used for code generation on IA-32.
2 Copyright (C) 1988, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
3 2002 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
28 #include "hard-reg-set.h"
30 #include "insn-config.h"
31 #include "conditions.h"
33 #include "insn-attr.h"
41 #include "basic-block.h"
44 #include "target-def.h"
45 #include "langhooks.h"
47 #ifndef CHECK_STACK_LIMIT
48 #define CHECK_STACK_LIMIT (-1)
51 /* Processor costs (relative to an add) */
53 struct processor_costs size_cost
= { /* costs for tunning for size */
54 2, /* cost of an add instruction */
55 3, /* cost of a lea instruction */
56 2, /* variable shift costs */
57 3, /* constant shift costs */
58 3, /* cost of starting a multiply */
59 0, /* cost of multiply per each bit set */
60 3, /* cost of a divide/mod */
61 3, /* cost of movsx */
62 3, /* cost of movzx */
65 2, /* cost for loading QImode using movzbl */
66 {2, 2, 2}, /* cost of loading integer registers
67 in QImode, HImode and SImode.
68 Relative to reg-reg move (2). */
69 {2, 2, 2}, /* cost of storing integer registers */
70 2, /* cost of reg,reg fld/fst */
71 {2, 2, 2}, /* cost of loading fp registers
72 in SFmode, DFmode and XFmode */
73 {2, 2, 2}, /* cost of loading integer registers */
74 3, /* cost of moving MMX register */
75 {3, 3}, /* cost of loading MMX registers
76 in SImode and DImode */
77 {3, 3}, /* cost of storing MMX registers
78 in SImode and DImode */
79 3, /* cost of moving SSE register */
80 {3, 3, 3}, /* cost of loading SSE registers
81 in SImode, DImode and TImode */
82 {3, 3, 3}, /* cost of storing SSE registers
83 in SImode, DImode and TImode */
84 3, /* MMX or SSE register to integer */
85 0, /* size of prefetch block */
86 0, /* number of parallel prefetches */
88 /* Processor costs (relative to an add) */
90 struct processor_costs i386_cost
= { /* 386 specific costs */
91 1, /* cost of an add instruction */
92 1, /* cost of a lea instruction */
93 3, /* variable shift costs */
94 2, /* constant shift costs */
95 6, /* cost of starting a multiply */
96 1, /* cost of multiply per each bit set */
97 23, /* cost of a divide/mod */
98 3, /* cost of movsx */
99 2, /* cost of movzx */
100 15, /* "large" insn */
102 4, /* cost for loading QImode using movzbl */
103 {2, 4, 2}, /* cost of loading integer registers
104 in QImode, HImode and SImode.
105 Relative to reg-reg move (2). */
106 {2, 4, 2}, /* cost of storing integer registers */
107 2, /* cost of reg,reg fld/fst */
108 {8, 8, 8}, /* cost of loading fp registers
109 in SFmode, DFmode and XFmode */
110 {8, 8, 8}, /* cost of loading integer registers */
111 2, /* cost of moving MMX register */
112 {4, 8}, /* cost of loading MMX registers
113 in SImode and DImode */
114 {4, 8}, /* cost of storing MMX registers
115 in SImode and DImode */
116 2, /* cost of moving SSE register */
117 {4, 8, 16}, /* cost of loading SSE registers
118 in SImode, DImode and TImode */
119 {4, 8, 16}, /* cost of storing SSE registers
120 in SImode, DImode and TImode */
121 3, /* MMX or SSE register to integer */
122 0, /* size of prefetch block */
123 0, /* number of parallel prefetches */
127 struct processor_costs i486_cost
= { /* 486 specific costs */
128 1, /* cost of an add instruction */
129 1, /* cost of a lea instruction */
130 3, /* variable shift costs */
131 2, /* constant shift costs */
132 12, /* cost of starting a multiply */
133 1, /* cost of multiply per each bit set */
134 40, /* cost of a divide/mod */
135 3, /* cost of movsx */
136 2, /* cost of movzx */
137 15, /* "large" insn */
139 4, /* cost for loading QImode using movzbl */
140 {2, 4, 2}, /* cost of loading integer registers
141 in QImode, HImode and SImode.
142 Relative to reg-reg move (2). */
143 {2, 4, 2}, /* cost of storing integer registers */
144 2, /* cost of reg,reg fld/fst */
145 {8, 8, 8}, /* cost of loading fp registers
146 in SFmode, DFmode and XFmode */
147 {8, 8, 8}, /* cost of loading integer registers */
148 2, /* cost of moving MMX register */
149 {4, 8}, /* cost of loading MMX registers
150 in SImode and DImode */
151 {4, 8}, /* cost of storing MMX registers
152 in SImode and DImode */
153 2, /* cost of moving SSE register */
154 {4, 8, 16}, /* cost of loading SSE registers
155 in SImode, DImode and TImode */
156 {4, 8, 16}, /* cost of storing SSE registers
157 in SImode, DImode and TImode */
158 3, /* MMX or SSE register to integer */
159 0, /* size of prefetch block */
160 0, /* number of parallel prefetches */
164 struct processor_costs pentium_cost
= {
165 1, /* cost of an add instruction */
166 1, /* cost of a lea instruction */
167 4, /* variable shift costs */
168 1, /* constant shift costs */
169 11, /* cost of starting a multiply */
170 0, /* cost of multiply per each bit set */
171 25, /* cost of a divide/mod */
172 3, /* cost of movsx */
173 2, /* cost of movzx */
174 8, /* "large" insn */
176 6, /* cost for loading QImode using movzbl */
177 {2, 4, 2}, /* cost of loading integer registers
178 in QImode, HImode and SImode.
179 Relative to reg-reg move (2). */
180 {2, 4, 2}, /* cost of storing integer registers */
181 2, /* cost of reg,reg fld/fst */
182 {2, 2, 6}, /* cost of loading fp registers
183 in SFmode, DFmode and XFmode */
184 {4, 4, 6}, /* cost of loading integer registers */
185 8, /* cost of moving MMX register */
186 {8, 8}, /* cost of loading MMX registers
187 in SImode and DImode */
188 {8, 8}, /* cost of storing MMX registers
189 in SImode and DImode */
190 2, /* cost of moving SSE register */
191 {4, 8, 16}, /* cost of loading SSE registers
192 in SImode, DImode and TImode */
193 {4, 8, 16}, /* cost of storing SSE registers
194 in SImode, DImode and TImode */
195 3, /* MMX or SSE register to integer */
196 0, /* size of prefetch block */
197 0, /* number of parallel prefetches */
201 struct processor_costs pentiumpro_cost
= {
202 1, /* cost of an add instruction */
203 1, /* cost of a lea instruction */
204 1, /* variable shift costs */
205 1, /* constant shift costs */
206 4, /* cost of starting a multiply */
207 0, /* cost of multiply per each bit set */
208 17, /* cost of a divide/mod */
209 1, /* cost of movsx */
210 1, /* cost of movzx */
211 8, /* "large" insn */
213 2, /* cost for loading QImode using movzbl */
214 {4, 4, 4}, /* cost of loading integer registers
215 in QImode, HImode and SImode.
216 Relative to reg-reg move (2). */
217 {2, 2, 2}, /* cost of storing integer registers */
218 2, /* cost of reg,reg fld/fst */
219 {2, 2, 6}, /* cost of loading fp registers
220 in SFmode, DFmode and XFmode */
221 {4, 4, 6}, /* cost of loading integer registers */
222 2, /* cost of moving MMX register */
223 {2, 2}, /* cost of loading MMX registers
224 in SImode and DImode */
225 {2, 2}, /* cost of storing MMX registers
226 in SImode and DImode */
227 2, /* cost of moving SSE register */
228 {2, 2, 8}, /* cost of loading SSE registers
229 in SImode, DImode and TImode */
230 {2, 2, 8}, /* cost of storing SSE registers
231 in SImode, DImode and TImode */
232 3, /* MMX or SSE register to integer */
233 32, /* size of prefetch block */
234 6, /* number of parallel prefetches */
238 struct processor_costs k6_cost
= {
239 1, /* cost of an add instruction */
240 2, /* cost of a lea instruction */
241 1, /* variable shift costs */
242 1, /* constant shift costs */
243 3, /* cost of starting a multiply */
244 0, /* cost of multiply per each bit set */
245 18, /* cost of a divide/mod */
246 2, /* cost of movsx */
247 2, /* cost of movzx */
248 8, /* "large" insn */
250 3, /* cost for loading QImode using movzbl */
251 {4, 5, 4}, /* cost of loading integer registers
252 in QImode, HImode and SImode.
253 Relative to reg-reg move (2). */
254 {2, 3, 2}, /* cost of storing integer registers */
255 4, /* cost of reg,reg fld/fst */
256 {6, 6, 6}, /* cost of loading fp registers
257 in SFmode, DFmode and XFmode */
258 {4, 4, 4}, /* cost of loading integer registers */
259 2, /* cost of moving MMX register */
260 {2, 2}, /* cost of loading MMX registers
261 in SImode and DImode */
262 {2, 2}, /* cost of storing MMX registers
263 in SImode and DImode */
264 2, /* cost of moving SSE register */
265 {2, 2, 8}, /* cost of loading SSE registers
266 in SImode, DImode and TImode */
267 {2, 2, 8}, /* cost of storing SSE registers
268 in SImode, DImode and TImode */
269 6, /* MMX or SSE register to integer */
270 32, /* size of prefetch block */
271 1, /* number of parallel prefetches */
275 struct processor_costs athlon_cost
= {
276 1, /* cost of an add instruction */
277 2, /* cost of a lea instruction */
278 1, /* variable shift costs */
279 1, /* constant shift costs */
280 5, /* cost of starting a multiply */
281 0, /* cost of multiply per each bit set */
282 42, /* cost of a divide/mod */
283 1, /* cost of movsx */
284 1, /* cost of movzx */
285 8, /* "large" insn */
287 4, /* cost for loading QImode using movzbl */
288 {4, 5, 4}, /* cost of loading integer registers
289 in QImode, HImode and SImode.
290 Relative to reg-reg move (2). */
291 {2, 3, 2}, /* cost of storing integer registers */
292 4, /* cost of reg,reg fld/fst */
293 {6, 6, 20}, /* cost of loading fp registers
294 in SFmode, DFmode and XFmode */
295 {4, 4, 16}, /* cost of loading integer registers */
296 2, /* cost of moving MMX register */
297 {2, 2}, /* cost of loading MMX registers
298 in SImode and DImode */
299 {2, 2}, /* cost of storing MMX registers
300 in SImode and DImode */
301 2, /* cost of moving SSE register */
302 {2, 2, 8}, /* cost of loading SSE registers
303 in SImode, DImode and TImode */
304 {2, 2, 8}, /* cost of storing SSE registers
305 in SImode, DImode and TImode */
306 6, /* MMX or SSE register to integer */
307 64, /* size of prefetch block */
308 6, /* number of parallel prefetches */
312 struct processor_costs pentium4_cost
= {
313 1, /* cost of an add instruction */
314 1, /* cost of a lea instruction */
315 8, /* variable shift costs */
316 8, /* constant shift costs */
317 30, /* cost of starting a multiply */
318 0, /* cost of multiply per each bit set */
319 112, /* cost of a divide/mod */
320 1, /* cost of movsx */
321 1, /* cost of movzx */
322 16, /* "large" insn */
324 2, /* cost for loading QImode using movzbl */
325 {4, 5, 4}, /* cost of loading integer registers
326 in QImode, HImode and SImode.
327 Relative to reg-reg move (2). */
328 {2, 3, 2}, /* cost of storing integer registers */
329 2, /* cost of reg,reg fld/fst */
330 {2, 2, 6}, /* cost of loading fp registers
331 in SFmode, DFmode and XFmode */
332 {4, 4, 6}, /* cost of loading integer registers */
333 2, /* cost of moving MMX register */
334 {2, 2}, /* cost of loading MMX registers
335 in SImode and DImode */
336 {2, 2}, /* cost of storing MMX registers
337 in SImode and DImode */
338 12, /* cost of moving SSE register */
339 {12, 12, 12}, /* cost of loading SSE registers
340 in SImode, DImode and TImode */
341 {2, 2, 8}, /* cost of storing SSE registers
342 in SImode, DImode and TImode */
343 10, /* MMX or SSE register to integer */
344 64, /* size of prefetch block */
345 6, /* number of parallel prefetches */
348 const struct processor_costs
*ix86_cost
= &pentium_cost
;
350 /* Processor feature/optimization bitmasks. */
351 #define m_386 (1<<PROCESSOR_I386)
352 #define m_486 (1<<PROCESSOR_I486)
353 #define m_PENT (1<<PROCESSOR_PENTIUM)
354 #define m_PPRO (1<<PROCESSOR_PENTIUMPRO)
355 #define m_K6 (1<<PROCESSOR_K6)
356 #define m_ATHLON (1<<PROCESSOR_ATHLON)
357 #define m_PENT4 (1<<PROCESSOR_PENTIUM4)
359 const int x86_use_leave
= m_386
| m_K6
| m_ATHLON
;
360 const int x86_push_memory
= m_386
| m_K6
| m_ATHLON
| m_PENT4
;
361 const int x86_zero_extend_with_and
= m_486
| m_PENT
;
362 const int x86_movx
= m_ATHLON
| m_PPRO
| m_PENT4
/* m_386 | m_K6 */;
363 const int x86_double_with_add
= ~m_386
;
364 const int x86_use_bit_test
= m_386
;
365 const int x86_unroll_strlen
= m_486
| m_PENT
| m_PPRO
| m_ATHLON
| m_K6
;
366 const int x86_cmove
= m_PPRO
| m_ATHLON
| m_PENT4
;
367 const int x86_3dnow_a
= m_ATHLON
;
368 const int x86_deep_branch
= m_PPRO
| m_K6
| m_ATHLON
| m_PENT4
;
369 const int x86_branch_hints
= m_PENT4
;
370 const int x86_use_sahf
= m_PPRO
| m_K6
| m_PENT4
;
371 const int x86_partial_reg_stall
= m_PPRO
;
372 const int x86_use_loop
= m_K6
;
373 const int x86_use_fiop
= ~(m_PPRO
| m_ATHLON
| m_PENT
);
374 const int x86_use_mov0
= m_K6
;
375 const int x86_use_cltd
= ~(m_PENT
| m_K6
);
376 const int x86_read_modify_write
= ~m_PENT
;
377 const int x86_read_modify
= ~(m_PENT
| m_PPRO
);
378 const int x86_split_long_moves
= m_PPRO
;
379 const int x86_promote_QImode
= m_K6
| m_PENT
| m_386
| m_486
| m_ATHLON
;
380 const int x86_fast_prefix
= ~(m_PENT
| m_486
| m_386
);
381 const int x86_single_stringop
= m_386
| m_PENT4
;
382 const int x86_qimode_math
= ~(0);
383 const int x86_promote_qi_regs
= 0;
384 const int x86_himode_math
= ~(m_PPRO
);
385 const int x86_promote_hi_regs
= m_PPRO
;
386 const int x86_sub_esp_4
= m_ATHLON
| m_PPRO
| m_PENT4
;
387 const int x86_sub_esp_8
= m_ATHLON
| m_PPRO
| m_386
| m_486
| m_PENT4
;
388 const int x86_add_esp_4
= m_ATHLON
| m_K6
| m_PENT4
;
389 const int x86_add_esp_8
= m_ATHLON
| m_PPRO
| m_K6
| m_386
| m_486
| m_PENT4
;
390 const int x86_integer_DFmode_moves
= ~(m_ATHLON
| m_PENT4
| m_PPRO
);
391 const int x86_partial_reg_dependency
= m_ATHLON
| m_PENT4
;
392 const int x86_memory_mismatch_stall
= m_ATHLON
| m_PENT4
;
393 const int x86_accumulate_outgoing_args
= m_ATHLON
| m_PENT4
| m_PPRO
;
394 const int x86_prologue_using_move
= m_ATHLON
| m_PENT4
| m_PPRO
;
395 const int x86_epilogue_using_move
= m_ATHLON
| m_PENT4
| m_PPRO
;
396 const int x86_decompose_lea
= m_PENT4
;
397 const int x86_shift1
= ~m_486
;
398 const int x86_arch_always_fancy_math_387
= m_PENT
| m_PPRO
| m_ATHLON
| m_PENT4
;
400 /* In case the avreage insn count for single function invocation is
401 lower than this constant, emit fast (but longer) prologue and
403 #define FAST_PROLOGUE_INSN_COUNT 30
405 /* Set by prologue expander and used by epilogue expander to determine
407 static int use_fast_prologue_epilogue
;
409 /* Names for 8 (low), 8 (high), and 16-bit registers, respectively. */
410 static const char *const qi_reg_name
[] = QI_REGISTER_NAMES
;
411 static const char *const qi_high_reg_name
[] = QI_HIGH_REGISTER_NAMES
;
412 static const char *const hi_reg_name
[] = HI_REGISTER_NAMES
;
414 /* Array of the smallest class containing reg number REGNO, indexed by
415 REGNO. Used by REGNO_REG_CLASS in i386.h. */
417 enum reg_class
const regclass_map
[FIRST_PSEUDO_REGISTER
] =
420 AREG
, DREG
, CREG
, BREG
,
422 SIREG
, DIREG
, NON_Q_REGS
, NON_Q_REGS
,
424 FP_TOP_REG
, FP_SECOND_REG
, FLOAT_REGS
, FLOAT_REGS
,
425 FLOAT_REGS
, FLOAT_REGS
, FLOAT_REGS
, FLOAT_REGS
,
428 /* flags, fpsr, dirflag, frame */
429 NO_REGS
, NO_REGS
, NO_REGS
, NON_Q_REGS
,
430 SSE_REGS
, SSE_REGS
, SSE_REGS
, SSE_REGS
, SSE_REGS
, SSE_REGS
,
432 MMX_REGS
, MMX_REGS
, MMX_REGS
, MMX_REGS
, MMX_REGS
, MMX_REGS
,
434 NON_Q_REGS
, NON_Q_REGS
, NON_Q_REGS
, NON_Q_REGS
,
435 NON_Q_REGS
, NON_Q_REGS
, NON_Q_REGS
, NON_Q_REGS
,
436 SSE_REGS
, SSE_REGS
, SSE_REGS
, SSE_REGS
, SSE_REGS
, SSE_REGS
,
440 /* The "default" register map used in 32bit mode. */
442 int const dbx_register_map
[FIRST_PSEUDO_REGISTER
] =
444 0, 2, 1, 3, 6, 7, 4, 5, /* general regs */
445 12, 13, 14, 15, 16, 17, 18, 19, /* fp regs */
446 -1, -1, -1, -1, -1, /* arg, flags, fpsr, dir, frame */
447 21, 22, 23, 24, 25, 26, 27, 28, /* SSE */
448 29, 30, 31, 32, 33, 34, 35, 36, /* MMX */
449 -1, -1, -1, -1, -1, -1, -1, -1, /* extended integer registers */
450 -1, -1, -1, -1, -1, -1, -1, -1, /* extended SSE registers */
453 static int const x86_64_int_parameter_registers
[6] =
455 5 /*RDI*/, 4 /*RSI*/, 1 /*RDX*/, 2 /*RCX*/,
456 FIRST_REX_INT_REG
/*R8 */, FIRST_REX_INT_REG
+ 1 /*R9 */
459 static int const x86_64_int_return_registers
[4] =
461 0 /*RAX*/, 1 /*RDI*/, 5 /*RDI*/, 4 /*RSI*/
464 /* The "default" register map used in 64bit mode. */
465 int const dbx64_register_map
[FIRST_PSEUDO_REGISTER
] =
467 0, 1, 2, 3, 4, 5, 6, 7, /* general regs */
468 33, 34, 35, 36, 37, 38, 39, 40, /* fp regs */
469 -1, -1, -1, -1, -1, /* arg, flags, fpsr, dir, frame */
470 17, 18, 19, 20, 21, 22, 23, 24, /* SSE */
471 41, 42, 43, 44, 45, 46, 47, 48, /* MMX */
472 8,9,10,11,12,13,14,15, /* extended integer registers */
473 25, 26, 27, 28, 29, 30, 31, 32, /* extended SSE registers */
476 /* Define the register numbers to be used in Dwarf debugging information.
477 The SVR4 reference port C compiler uses the following register numbers
478 in its Dwarf output code:
479 0 for %eax (gcc regno = 0)
480 1 for %ecx (gcc regno = 2)
481 2 for %edx (gcc regno = 1)
482 3 for %ebx (gcc regno = 3)
483 4 for %esp (gcc regno = 7)
484 5 for %ebp (gcc regno = 6)
485 6 for %esi (gcc regno = 4)
486 7 for %edi (gcc regno = 5)
487 The following three DWARF register numbers are never generated by
488 the SVR4 C compiler or by the GNU compilers, but SDB on x86/svr4
489 believes these numbers have these meanings.
490 8 for %eip (no gcc equivalent)
491 9 for %eflags (gcc regno = 17)
492 10 for %trapno (no gcc equivalent)
493 It is not at all clear how we should number the FP stack registers
494 for the x86 architecture. If the version of SDB on x86/svr4 were
495 a bit less brain dead with respect to floating-point then we would
496 have a precedent to follow with respect to DWARF register numbers
497 for x86 FP registers, but the SDB on x86/svr4 is so completely
498 broken with respect to FP registers that it is hardly worth thinking
499 of it as something to strive for compatibility with.
500 The version of x86/svr4 SDB I have at the moment does (partially)
501 seem to believe that DWARF register number 11 is associated with
502 the x86 register %st(0), but that's about all. Higher DWARF
503 register numbers don't seem to be associated with anything in
504 particular, and even for DWARF regno 11, SDB only seems to under-
505 stand that it should say that a variable lives in %st(0) (when
506 asked via an `=' command) if we said it was in DWARF regno 11,
507 but SDB still prints garbage when asked for the value of the
508 variable in question (via a `/' command).
509 (Also note that the labels SDB prints for various FP stack regs
510 when doing an `x' command are all wrong.)
511 Note that these problems generally don't affect the native SVR4
512 C compiler because it doesn't allow the use of -O with -g and
513 because when it is *not* optimizing, it allocates a memory
514 location for each floating-point variable, and the memory
515 location is what gets described in the DWARF AT_location
516 attribute for the variable in question.
517 Regardless of the severe mental illness of the x86/svr4 SDB, we
518 do something sensible here and we use the following DWARF
519 register numbers. Note that these are all stack-top-relative
521 11 for %st(0) (gcc regno = 8)
522 12 for %st(1) (gcc regno = 9)
523 13 for %st(2) (gcc regno = 10)
524 14 for %st(3) (gcc regno = 11)
525 15 for %st(4) (gcc regno = 12)
526 16 for %st(5) (gcc regno = 13)
527 17 for %st(6) (gcc regno = 14)
528 18 for %st(7) (gcc regno = 15)
530 int const svr4_dbx_register_map
[FIRST_PSEUDO_REGISTER
] =
532 0, 2, 1, 3, 6, 7, 5, 4, /* general regs */
533 11, 12, 13, 14, 15, 16, 17, 18, /* fp regs */
534 -1, 9, -1, -1, -1, /* arg, flags, fpsr, dir, frame */
535 21, 22, 23, 24, 25, 26, 27, 28, /* SSE registers */
536 29, 30, 31, 32, 33, 34, 35, 36, /* MMX registers */
537 -1, -1, -1, -1, -1, -1, -1, -1, /* extemded integer registers */
538 -1, -1, -1, -1, -1, -1, -1, -1, /* extemded SSE registers */
541 /* Test and compare insns in i386.md store the information needed to
542 generate branch and scc insns here. */
544 rtx ix86_compare_op0
= NULL_RTX
;
545 rtx ix86_compare_op1
= NULL_RTX
;
547 /* The encoding characters for the four TLS models present in ELF. */
549 static char const tls_model_chars
[] = " GLil";
551 #define MAX_386_STACK_LOCALS 3
552 /* Size of the register save area. */
553 #define X86_64_VARARGS_SIZE (REGPARM_MAX * UNITS_PER_WORD + SSE_REGPARM_MAX * 16)
555 /* Define the structure for the machine field in struct function. */
556 struct machine_function
GTY(())
558 rtx stack_locals
[(int) MAX_MACHINE_MODE
][MAX_386_STACK_LOCALS
];
559 const char *some_ld_name
;
560 int save_varrargs_registers
;
561 int accesses_prev_frame
;
564 #define ix86_stack_locals (cfun->machine->stack_locals)
565 #define ix86_save_varrargs_registers (cfun->machine->save_varrargs_registers)
567 /* Structure describing stack frame layout.
568 Stack grows downward:
574 saved frame pointer if frame_pointer_needed
575 <- HARD_FRAME_POINTER
581 > to_allocate <- FRAME_POINTER
593 int outgoing_arguments_size
;
596 HOST_WIDE_INT to_allocate
;
597 /* The offsets relative to ARG_POINTER. */
598 HOST_WIDE_INT frame_pointer_offset
;
599 HOST_WIDE_INT hard_frame_pointer_offset
;
600 HOST_WIDE_INT stack_pointer_offset
;
603 /* Used to enable/disable debugging features. */
604 const char *ix86_debug_arg_string
, *ix86_debug_addr_string
;
605 /* Code model option as passed by user. */
606 const char *ix86_cmodel_string
;
608 enum cmodel ix86_cmodel
;
610 const char *ix86_asm_string
;
611 enum asm_dialect ix86_asm_dialect
= ASM_ATT
;
613 const char *ix86_tls_dialect_string
;
614 enum tls_dialect ix86_tls_dialect
= TLS_DIALECT_GNU
;
616 /* Which unit we are generating floating point math for. */
617 enum fpmath_unit ix86_fpmath
;
619 /* Which cpu are we scheduling for. */
620 enum processor_type ix86_cpu
;
621 /* Which instruction set architecture to use. */
622 enum processor_type ix86_arch
;
624 /* Strings to hold which cpu and instruction set architecture to use. */
625 const char *ix86_cpu_string
; /* for -mcpu=<xxx> */
626 const char *ix86_arch_string
; /* for -march=<xxx> */
627 const char *ix86_fpmath_string
; /* for -mfpmath=<xxx> */
629 /* # of registers to use to pass arguments. */
630 const char *ix86_regparm_string
;
632 /* true if sse prefetch instruction is not NOOP. */
633 int x86_prefetch_sse
;
635 /* ix86_regparm_string as a number */
638 /* Alignment to use for loops and jumps: */
640 /* Power of two alignment for loops. */
641 const char *ix86_align_loops_string
;
643 /* Power of two alignment for non-loop jumps. */
644 const char *ix86_align_jumps_string
;
646 /* Power of two alignment for stack boundary in bytes. */
647 const char *ix86_preferred_stack_boundary_string
;
649 /* Preferred alignment for stack boundary in bits. */
650 int ix86_preferred_stack_boundary
;
652 /* Values 1-5: see jump.c */
653 int ix86_branch_cost
;
654 const char *ix86_branch_cost_string
;
656 /* Power of two alignment for functions. */
657 const char *ix86_align_funcs_string
;
659 /* Prefix built by ASM_GENERATE_INTERNAL_LABEL. */
660 static char internal_label_prefix
[16];
661 static int internal_label_prefix_len
;
663 static int local_symbolic_operand
PARAMS ((rtx
, enum machine_mode
));
664 static int tls_symbolic_operand_1
PARAMS ((rtx
, enum tls_model
));
665 static void output_pic_addr_const
PARAMS ((FILE *, rtx
, int));
666 static void put_condition_code
PARAMS ((enum rtx_code
, enum machine_mode
,
668 static const char *get_some_local_dynamic_name
PARAMS ((void));
669 static int get_some_local_dynamic_name_1
PARAMS ((rtx
*, void *));
670 static rtx maybe_get_pool_constant
PARAMS ((rtx
));
671 static rtx ix86_expand_int_compare
PARAMS ((enum rtx_code
, rtx
, rtx
));
672 static enum rtx_code ix86_prepare_fp_compare_args
PARAMS ((enum rtx_code
,
674 static rtx get_thread_pointer
PARAMS ((void));
675 static void get_pc_thunk_name
PARAMS ((char [32], unsigned int));
676 static rtx gen_push
PARAMS ((rtx
));
677 static int memory_address_length
PARAMS ((rtx addr
));
678 static int ix86_flags_dependant
PARAMS ((rtx
, rtx
, enum attr_type
));
679 static int ix86_agi_dependant
PARAMS ((rtx
, rtx
, enum attr_type
));
680 static enum attr_ppro_uops ix86_safe_ppro_uops
PARAMS ((rtx
));
681 static void ix86_dump_ppro_packet
PARAMS ((FILE *));
682 static void ix86_reorder_insn
PARAMS ((rtx
*, rtx
*));
683 static struct machine_function
* ix86_init_machine_status
PARAMS ((void));
684 static int ix86_split_to_parts
PARAMS ((rtx
, rtx
*, enum machine_mode
));
685 static int ix86_nsaved_regs
PARAMS ((void));
686 static void ix86_emit_save_regs
PARAMS ((void));
687 static void ix86_emit_save_regs_using_mov
PARAMS ((rtx
, HOST_WIDE_INT
));
688 static void ix86_emit_restore_regs_using_mov
PARAMS ((rtx
, int, int));
689 static void ix86_output_function_epilogue
PARAMS ((FILE *, HOST_WIDE_INT
));
690 static void ix86_set_move_mem_attrs_1
PARAMS ((rtx
, rtx
, rtx
, rtx
, rtx
));
691 static void ix86_sched_reorder_ppro
PARAMS ((rtx
*, rtx
*));
692 static HOST_WIDE_INT ix86_GOT_alias_set
PARAMS ((void));
693 static void ix86_adjust_counter
PARAMS ((rtx
, HOST_WIDE_INT
));
694 static rtx ix86_expand_aligntest
PARAMS ((rtx
, int));
695 static void ix86_expand_strlensi_unroll_1
PARAMS ((rtx
, rtx
));
696 static int ix86_issue_rate
PARAMS ((void));
697 static int ix86_adjust_cost
PARAMS ((rtx
, rtx
, rtx
, int));
698 static void ix86_sched_init
PARAMS ((FILE *, int, int));
699 static int ix86_sched_reorder
PARAMS ((FILE *, int, rtx
*, int *, int));
700 static int ix86_variable_issue
PARAMS ((FILE *, int, rtx
, int));
701 static int ia32_use_dfa_pipeline_interface
PARAMS ((void));
702 static int ia32_multipass_dfa_lookahead
PARAMS ((void));
703 static void ix86_init_mmx_sse_builtins
PARAMS ((void));
707 rtx base
, index
, disp
;
711 static int ix86_decompose_address
PARAMS ((rtx
, struct ix86_address
*));
713 static void ix86_encode_section_info
PARAMS ((tree
, int)) ATTRIBUTE_UNUSED
;
714 static const char *ix86_strip_name_encoding
PARAMS ((const char *))
717 struct builtin_description
;
718 static rtx ix86_expand_sse_comi
PARAMS ((const struct builtin_description
*,
720 static rtx ix86_expand_sse_compare
PARAMS ((const struct builtin_description
*,
722 static rtx ix86_expand_unop1_builtin
PARAMS ((enum insn_code
, tree
, rtx
));
723 static rtx ix86_expand_unop_builtin
PARAMS ((enum insn_code
, tree
, rtx
, int));
724 static rtx ix86_expand_binop_builtin
PARAMS ((enum insn_code
, tree
, rtx
));
725 static rtx ix86_expand_timode_binop_builtin
PARAMS ((enum insn_code
,
727 static rtx ix86_expand_store_builtin
PARAMS ((enum insn_code
, tree
));
728 static rtx safe_vector_operand
PARAMS ((rtx
, enum machine_mode
));
729 static enum rtx_code ix86_fp_compare_code_to_integer
PARAMS ((enum rtx_code
));
730 static void ix86_fp_comparison_codes
PARAMS ((enum rtx_code code
,
734 static rtx ix86_expand_fp_compare
PARAMS ((enum rtx_code
, rtx
, rtx
, rtx
,
736 static int ix86_fp_comparison_arithmetics_cost
PARAMS ((enum rtx_code code
));
737 static int ix86_fp_comparison_fcomi_cost
PARAMS ((enum rtx_code code
));
738 static int ix86_fp_comparison_sahf_cost
PARAMS ((enum rtx_code code
));
739 static int ix86_fp_comparison_cost
PARAMS ((enum rtx_code code
));
740 static unsigned int ix86_select_alt_pic_regnum
PARAMS ((void));
741 static int ix86_save_reg
PARAMS ((unsigned int, int));
742 static void ix86_compute_frame_layout
PARAMS ((struct ix86_frame
*));
743 static int ix86_comp_type_attributes
PARAMS ((tree
, tree
));
744 const struct attribute_spec ix86_attribute_table
[];
745 static tree ix86_handle_cdecl_attribute
PARAMS ((tree
*, tree
, tree
, int, bool *));
746 static tree ix86_handle_regparm_attribute
PARAMS ((tree
*, tree
, tree
, int, bool *));
747 static int ix86_value_regno
PARAMS ((enum machine_mode
));
749 #if defined (DO_GLOBAL_CTORS_BODY) && defined (HAS_INIT_SECTION)
750 static void ix86_svr3_asm_out_constructor
PARAMS ((rtx
, int));
753 /* Register class used for passing given 64bit part of the argument.
754 These represent classes as documented by the PS ABI, with the exception
755 of SSESF, SSEDF classes, that are basically SSE class, just gcc will
756 use SF or DFmode move instead of DImode to avoid reformating penalties.
758 Similary we play games with INTEGERSI_CLASS to use cheaper SImode moves
759 whenever possible (upper half does contain padding).
761 enum x86_64_reg_class
764 X86_64_INTEGER_CLASS
,
765 X86_64_INTEGERSI_CLASS
,
774 static const char * const x86_64_reg_class_name
[] =
775 {"no", "integer", "integerSI", "sse", "sseSF", "sseDF", "sseup", "x87", "x87up", "no"};
777 #define MAX_CLASSES 4
778 static int classify_argument
PARAMS ((enum machine_mode
, tree
,
779 enum x86_64_reg_class
[MAX_CLASSES
],
781 static int examine_argument
PARAMS ((enum machine_mode
, tree
, int, int *,
783 static rtx construct_container
PARAMS ((enum machine_mode
, tree
, int, int, int,
785 static enum x86_64_reg_class merge_classes
PARAMS ((enum x86_64_reg_class
,
786 enum x86_64_reg_class
));
788 /* Initialize the GCC target structure. */
789 #undef TARGET_ATTRIBUTE_TABLE
790 #define TARGET_ATTRIBUTE_TABLE ix86_attribute_table
791 #ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
792 # undef TARGET_MERGE_DECL_ATTRIBUTES
793 # define TARGET_MERGE_DECL_ATTRIBUTES merge_dllimport_decl_attributes
796 #undef TARGET_COMP_TYPE_ATTRIBUTES
797 #define TARGET_COMP_TYPE_ATTRIBUTES ix86_comp_type_attributes
799 #undef TARGET_INIT_BUILTINS
800 #define TARGET_INIT_BUILTINS ix86_init_builtins
802 #undef TARGET_EXPAND_BUILTIN
803 #define TARGET_EXPAND_BUILTIN ix86_expand_builtin
805 #undef TARGET_ASM_FUNCTION_EPILOGUE
806 #define TARGET_ASM_FUNCTION_EPILOGUE ix86_output_function_epilogue
808 #undef TARGET_ASM_OPEN_PAREN
809 #define TARGET_ASM_OPEN_PAREN ""
810 #undef TARGET_ASM_CLOSE_PAREN
811 #define TARGET_ASM_CLOSE_PAREN ""
813 #undef TARGET_ASM_ALIGNED_HI_OP
814 #define TARGET_ASM_ALIGNED_HI_OP ASM_SHORT
815 #undef TARGET_ASM_ALIGNED_SI_OP
816 #define TARGET_ASM_ALIGNED_SI_OP ASM_LONG
818 #undef TARGET_ASM_ALIGNED_DI_OP
819 #define TARGET_ASM_ALIGNED_DI_OP ASM_QUAD
822 #undef TARGET_ASM_UNALIGNED_HI_OP
823 #define TARGET_ASM_UNALIGNED_HI_OP TARGET_ASM_ALIGNED_HI_OP
824 #undef TARGET_ASM_UNALIGNED_SI_OP
825 #define TARGET_ASM_UNALIGNED_SI_OP TARGET_ASM_ALIGNED_SI_OP
826 #undef TARGET_ASM_UNALIGNED_DI_OP
827 #define TARGET_ASM_UNALIGNED_DI_OP TARGET_ASM_ALIGNED_DI_OP
829 #undef TARGET_SCHED_ADJUST_COST
830 #define TARGET_SCHED_ADJUST_COST ix86_adjust_cost
831 #undef TARGET_SCHED_ISSUE_RATE
832 #define TARGET_SCHED_ISSUE_RATE ix86_issue_rate
833 #undef TARGET_SCHED_VARIABLE_ISSUE
834 #define TARGET_SCHED_VARIABLE_ISSUE ix86_variable_issue
835 #undef TARGET_SCHED_INIT
836 #define TARGET_SCHED_INIT ix86_sched_init
837 #undef TARGET_SCHED_REORDER
838 #define TARGET_SCHED_REORDER ix86_sched_reorder
839 #undef TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE
840 #define TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE \
841 ia32_use_dfa_pipeline_interface
842 #undef TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD
843 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD \
844 ia32_multipass_dfa_lookahead
847 #undef TARGET_HAVE_TLS
848 #define TARGET_HAVE_TLS true
851 struct gcc_target targetm
= TARGET_INITIALIZER
;
853 /* Sometimes certain combinations of command options do not make
854 sense on a particular target machine. You can define a macro
855 `OVERRIDE_OPTIONS' to take account of this. This macro, if
856 defined, is executed once just after all the command options have
859 Don't use this macro to turn on various extra optimizations for
860 `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */
866 /* Comes from final.c -- no real reason to change it. */
867 #define MAX_CODE_ALIGN 16
871 const struct processor_costs
*cost
; /* Processor costs */
872 const int target_enable
; /* Target flags to enable. */
873 const int target_disable
; /* Target flags to disable. */
874 const int align_loop
; /* Default alignments. */
875 const int align_loop_max_skip
;
876 const int align_jump
;
877 const int align_jump_max_skip
;
878 const int align_func
;
879 const int branch_cost
;
881 const processor_target_table
[PROCESSOR_max
] =
883 {&i386_cost
, 0, 0, 4, 3, 4, 3, 4, 1},
884 {&i486_cost
, 0, 0, 16, 15, 16, 15, 16, 1},
885 {&pentium_cost
, 0, 0, 16, 7, 16, 7, 16, 1},
886 {&pentiumpro_cost
, 0, 0, 16, 15, 16, 7, 16, 1},
887 {&k6_cost
, 0, 0, 32, 7, 32, 7, 32, 1},
888 {&athlon_cost
, 0, 0, 16, 7, 64, 7, 16, 1},
889 {&pentium4_cost
, 0, 0, 0, 0, 0, 0, 0, 1}
892 static const char * const cpu_names
[] = TARGET_CPU_DEFAULT_NAMES
;
895 const char *const name
; /* processor name or nickname. */
896 const enum processor_type processor
;
902 PTA_PREFETCH_SSE
= 8,
907 const processor_alias_table
[] =
909 {"i386", PROCESSOR_I386
, 0},
910 {"i486", PROCESSOR_I486
, 0},
911 {"i586", PROCESSOR_PENTIUM
, 0},
912 {"pentium", PROCESSOR_PENTIUM
, 0},
913 {"pentium-mmx", PROCESSOR_PENTIUM
, PTA_MMX
},
914 {"winchip-c6", PROCESSOR_I486
, PTA_MMX
},
915 {"winchip2", PROCESSOR_I486
, PTA_MMX
| PTA_3DNOW
},
916 {"c3", PROCESSOR_I486
, PTA_MMX
| PTA_3DNOW
},
917 {"i686", PROCESSOR_PENTIUMPRO
, 0},
918 {"pentiumpro", PROCESSOR_PENTIUMPRO
, 0},
919 {"pentium2", PROCESSOR_PENTIUMPRO
, PTA_MMX
},
920 {"pentium3", PROCESSOR_PENTIUMPRO
, PTA_MMX
| PTA_SSE
| PTA_PREFETCH_SSE
},
921 {"pentium4", PROCESSOR_PENTIUM4
, PTA_SSE
| PTA_SSE2
|
922 PTA_MMX
| PTA_PREFETCH_SSE
},
923 {"k6", PROCESSOR_K6
, PTA_MMX
},
924 {"k6-2", PROCESSOR_K6
, PTA_MMX
| PTA_3DNOW
},
925 {"k6-3", PROCESSOR_K6
, PTA_MMX
| PTA_3DNOW
},
926 {"athlon", PROCESSOR_ATHLON
, PTA_MMX
| PTA_PREFETCH_SSE
| PTA_3DNOW
928 {"athlon-tbird", PROCESSOR_ATHLON
, PTA_MMX
| PTA_PREFETCH_SSE
929 | PTA_3DNOW
| PTA_3DNOW_A
},
930 {"athlon-4", PROCESSOR_ATHLON
, PTA_MMX
| PTA_PREFETCH_SSE
| PTA_3DNOW
931 | PTA_3DNOW_A
| PTA_SSE
},
932 {"athlon-xp", PROCESSOR_ATHLON
, PTA_MMX
| PTA_PREFETCH_SSE
| PTA_3DNOW
933 | PTA_3DNOW_A
| PTA_SSE
},
934 {"athlon-mp", PROCESSOR_ATHLON
, PTA_MMX
| PTA_PREFETCH_SSE
| PTA_3DNOW
935 | PTA_3DNOW_A
| PTA_SSE
},
938 int const pta_size
= ARRAY_SIZE (processor_alias_table
);
940 /* By default our XFmode is the 80-bit extended format. If we have
941 use TFmode instead, it's also the 80-bit format, but with padding. */
942 real_format_for_mode
[XFmode
- QFmode
] = &ieee_extended_intel_96_format
;
943 real_format_for_mode
[TFmode
- QFmode
] = &ieee_extended_intel_128_format
;
945 #ifdef SUBTARGET_OVERRIDE_OPTIONS
946 SUBTARGET_OVERRIDE_OPTIONS
;
949 if (!ix86_cpu_string
&& ix86_arch_string
)
950 ix86_cpu_string
= ix86_arch_string
;
951 if (!ix86_cpu_string
)
952 ix86_cpu_string
= cpu_names
[TARGET_CPU_DEFAULT
];
953 if (!ix86_arch_string
)
954 ix86_arch_string
= TARGET_64BIT
? "athlon-4" : "i386";
956 if (ix86_cmodel_string
!= 0)
958 if (!strcmp (ix86_cmodel_string
, "small"))
959 ix86_cmodel
= flag_pic
? CM_SMALL_PIC
: CM_SMALL
;
961 sorry ("code model %s not supported in PIC mode", ix86_cmodel_string
);
962 else if (!strcmp (ix86_cmodel_string
, "32"))
964 else if (!strcmp (ix86_cmodel_string
, "kernel") && !flag_pic
)
965 ix86_cmodel
= CM_KERNEL
;
966 else if (!strcmp (ix86_cmodel_string
, "medium") && !flag_pic
)
967 ix86_cmodel
= CM_MEDIUM
;
968 else if (!strcmp (ix86_cmodel_string
, "large") && !flag_pic
)
969 ix86_cmodel
= CM_LARGE
;
971 error ("bad value (%s) for -mcmodel= switch", ix86_cmodel_string
);
977 ix86_cmodel
= flag_pic
? CM_SMALL_PIC
: CM_SMALL
;
979 if (ix86_asm_string
!= 0)
981 if (!strcmp (ix86_asm_string
, "intel"))
982 ix86_asm_dialect
= ASM_INTEL
;
983 else if (!strcmp (ix86_asm_string
, "att"))
984 ix86_asm_dialect
= ASM_ATT
;
986 error ("bad value (%s) for -masm= switch", ix86_asm_string
);
988 if ((TARGET_64BIT
== 0) != (ix86_cmodel
== CM_32
))
989 error ("code model `%s' not supported in the %s bit mode",
990 ix86_cmodel_string
, TARGET_64BIT
? "64" : "32");
991 if (ix86_cmodel
== CM_LARGE
)
992 sorry ("code model `large' not supported yet");
993 if ((TARGET_64BIT
!= 0) != ((target_flags
& MASK_64BIT
) != 0))
994 sorry ("%i-bit mode not compiled in",
995 (target_flags
& MASK_64BIT
) ? 64 : 32);
997 for (i
= 0; i
< pta_size
; i
++)
998 if (! strcmp (ix86_arch_string
, processor_alias_table
[i
].name
))
1000 ix86_arch
= processor_alias_table
[i
].processor
;
1001 /* Default cpu tuning to the architecture. */
1002 ix86_cpu
= ix86_arch
;
1003 if (processor_alias_table
[i
].flags
& PTA_MMX
1004 && !(target_flags
& MASK_MMX_SET
))
1005 target_flags
|= MASK_MMX
;
1006 if (processor_alias_table
[i
].flags
& PTA_3DNOW
1007 && !(target_flags
& MASK_3DNOW_SET
))
1008 target_flags
|= MASK_3DNOW
;
1009 if (processor_alias_table
[i
].flags
& PTA_3DNOW_A
1010 && !(target_flags
& MASK_3DNOW_A_SET
))
1011 target_flags
|= MASK_3DNOW_A
;
1012 if (processor_alias_table
[i
].flags
& PTA_SSE
1013 && !(target_flags
& MASK_SSE_SET
))
1014 target_flags
|= MASK_SSE
;
1015 if (processor_alias_table
[i
].flags
& PTA_SSE2
1016 && !(target_flags
& MASK_SSE2_SET
))
1017 target_flags
|= MASK_SSE2
;
1018 if (processor_alias_table
[i
].flags
& PTA_PREFETCH_SSE
)
1019 x86_prefetch_sse
= true;
1024 error ("bad value (%s) for -march= switch", ix86_arch_string
);
1026 for (i
= 0; i
< pta_size
; i
++)
1027 if (! strcmp (ix86_cpu_string
, processor_alias_table
[i
].name
))
1029 ix86_cpu
= processor_alias_table
[i
].processor
;
1032 if (processor_alias_table
[i
].flags
& PTA_PREFETCH_SSE
)
1033 x86_prefetch_sse
= true;
1035 error ("bad value (%s) for -mcpu= switch", ix86_cpu_string
);
1038 ix86_cost
= &size_cost
;
1040 ix86_cost
= processor_target_table
[ix86_cpu
].cost
;
1041 target_flags
|= processor_target_table
[ix86_cpu
].target_enable
;
1042 target_flags
&= ~processor_target_table
[ix86_cpu
].target_disable
;
1044 /* Arrange to set up i386_stack_locals for all functions. */
1045 init_machine_status
= ix86_init_machine_status
;
1047 /* Validate -mregparm= value. */
1048 if (ix86_regparm_string
)
1050 i
= atoi (ix86_regparm_string
);
1051 if (i
< 0 || i
> REGPARM_MAX
)
1052 error ("-mregparm=%d is not between 0 and %d", i
, REGPARM_MAX
);
1058 ix86_regparm
= REGPARM_MAX
;
1060 /* If the user has provided any of the -malign-* options,
1061 warn and use that value only if -falign-* is not set.
1062 Remove this code in GCC 3.2 or later. */
1063 if (ix86_align_loops_string
)
1065 warning ("-malign-loops is obsolete, use -falign-loops");
1066 if (align_loops
== 0)
1068 i
= atoi (ix86_align_loops_string
);
1069 if (i
< 0 || i
> MAX_CODE_ALIGN
)
1070 error ("-malign-loops=%d is not between 0 and %d", i
, MAX_CODE_ALIGN
);
1072 align_loops
= 1 << i
;
1076 if (ix86_align_jumps_string
)
1078 warning ("-malign-jumps is obsolete, use -falign-jumps");
1079 if (align_jumps
== 0)
1081 i
= atoi (ix86_align_jumps_string
);
1082 if (i
< 0 || i
> MAX_CODE_ALIGN
)
1083 error ("-malign-loops=%d is not between 0 and %d", i
, MAX_CODE_ALIGN
);
1085 align_jumps
= 1 << i
;
1089 if (ix86_align_funcs_string
)
1091 warning ("-malign-functions is obsolete, use -falign-functions");
1092 if (align_functions
== 0)
1094 i
= atoi (ix86_align_funcs_string
);
1095 if (i
< 0 || i
> MAX_CODE_ALIGN
)
1096 error ("-malign-loops=%d is not between 0 and %d", i
, MAX_CODE_ALIGN
);
1098 align_functions
= 1 << i
;
1102 /* Default align_* from the processor table. */
1103 if (align_loops
== 0)
1105 align_loops
= processor_target_table
[ix86_cpu
].align_loop
;
1106 align_loops_max_skip
= processor_target_table
[ix86_cpu
].align_loop_max_skip
;
1108 if (align_jumps
== 0)
1110 align_jumps
= processor_target_table
[ix86_cpu
].align_jump
;
1111 align_jumps_max_skip
= processor_target_table
[ix86_cpu
].align_jump_max_skip
;
1113 if (align_functions
== 0)
1115 align_functions
= processor_target_table
[ix86_cpu
].align_func
;
1118 /* Validate -mpreferred-stack-boundary= value, or provide default.
1119 The default of 128 bits is for Pentium III's SSE __m128, but we
1120 don't want additional code to keep the stack aligned when
1121 optimizing for code size. */
1122 ix86_preferred_stack_boundary
= (optimize_size
1123 ? TARGET_64BIT
? 128 : 32
1125 if (ix86_preferred_stack_boundary_string
)
1127 i
= atoi (ix86_preferred_stack_boundary_string
);
1128 if (i
< (TARGET_64BIT
? 4 : 2) || i
> 12)
1129 error ("-mpreferred-stack-boundary=%d is not between %d and 12", i
,
1130 TARGET_64BIT
? 4 : 2);
1132 ix86_preferred_stack_boundary
= (1 << i
) * BITS_PER_UNIT
;
1135 /* Validate -mbranch-cost= value, or provide default. */
1136 ix86_branch_cost
= processor_target_table
[ix86_cpu
].branch_cost
;
1137 if (ix86_branch_cost_string
)
1139 i
= atoi (ix86_branch_cost_string
);
1141 error ("-mbranch-cost=%d is not between 0 and 5", i
);
1143 ix86_branch_cost
= i
;
1146 if (ix86_tls_dialect_string
)
1148 if (strcmp (ix86_tls_dialect_string
, "gnu") == 0)
1149 ix86_tls_dialect
= TLS_DIALECT_GNU
;
1150 else if (strcmp (ix86_tls_dialect_string
, "sun") == 0)
1151 ix86_tls_dialect
= TLS_DIALECT_SUN
;
1153 error ("bad value (%s) for -mtls-dialect= switch",
1154 ix86_tls_dialect_string
);
1158 target_flags
&= ~MASK_OMIT_LEAF_FRAME_POINTER
;
1160 /* Keep nonleaf frame pointers. */
1161 if (TARGET_OMIT_LEAF_FRAME_POINTER
)
1162 flag_omit_frame_pointer
= 1;
1164 /* If we're doing fast math, we don't care about comparison order
1165 wrt NaNs. This lets us use a shorter comparison sequence. */
1166 if (flag_unsafe_math_optimizations
)
1167 target_flags
&= ~MASK_IEEE_FP
;
1169 /* If the architecture always has an FPU, turn off NO_FANCY_MATH_387,
1170 since the insns won't need emulation. */
1171 if (x86_arch_always_fancy_math_387
& (1 << ix86_arch
))
1172 target_flags
&= ~MASK_NO_FANCY_MATH_387
;
1176 if (TARGET_ALIGN_DOUBLE
)
1177 error ("-malign-double makes no sense in the 64bit mode");
1179 error ("-mrtd calling convention not supported in the 64bit mode");
1180 /* Enable by default the SSE and MMX builtins. */
1181 target_flags
|= (MASK_SSE2
| MASK_SSE
| MASK_MMX
| MASK_128BIT_LONG_DOUBLE
);
1182 ix86_fpmath
= FPMATH_SSE
;
1185 ix86_fpmath
= FPMATH_387
;
1187 if (ix86_fpmath_string
!= 0)
1189 if (! strcmp (ix86_fpmath_string
, "387"))
1190 ix86_fpmath
= FPMATH_387
;
1191 else if (! strcmp (ix86_fpmath_string
, "sse"))
1195 warning ("SSE instruction set disabled, using 387 arithmetics");
1196 ix86_fpmath
= FPMATH_387
;
1199 ix86_fpmath
= FPMATH_SSE
;
1201 else if (! strcmp (ix86_fpmath_string
, "387,sse")
1202 || ! strcmp (ix86_fpmath_string
, "sse,387"))
1206 warning ("SSE instruction set disabled, using 387 arithmetics");
1207 ix86_fpmath
= FPMATH_387
;
1209 else if (!TARGET_80387
)
1211 warning ("387 instruction set disabled, using SSE arithmetics");
1212 ix86_fpmath
= FPMATH_SSE
;
1215 ix86_fpmath
= FPMATH_SSE
| FPMATH_387
;
1218 error ("bad value (%s) for -mfpmath= switch", ix86_fpmath_string
);
1221 /* It makes no sense to ask for just SSE builtins, so MMX is also turned
1225 target_flags
|= MASK_MMX
;
1226 x86_prefetch_sse
= true;
1229 /* If it has 3DNow! it also has MMX so MMX is also turned on by -m3dnow */
1232 target_flags
|= MASK_MMX
;
1233 /* If we are targetting the Athlon architecture, enable the 3Dnow/MMX
1234 extensions it adds. */
1235 if (x86_3dnow_a
& (1 << ix86_arch
))
1236 target_flags
|= MASK_3DNOW_A
;
1238 if ((x86_accumulate_outgoing_args
& CPUMASK
)
1239 && !(target_flags
& MASK_ACCUMULATE_OUTGOING_ARGS_SET
)
1241 target_flags
|= MASK_ACCUMULATE_OUTGOING_ARGS
;
1243 /* Figure out what ASM_GENERATE_INTERNAL_LABEL builds as a prefix. */
1246 ASM_GENERATE_INTERNAL_LABEL (internal_label_prefix
, "LX", 0);
1247 p
= strchr (internal_label_prefix
, 'X');
1248 internal_label_prefix_len
= p
- internal_label_prefix
;
1254 optimization_options (level
, size
)
1256 int size ATTRIBUTE_UNUSED
;
1258 /* For -O2 and beyond, turn off -fschedule-insns by default. It tends to
1259 make the problem with not enough registers even worse. */
1260 #ifdef INSN_SCHEDULING
1262 flag_schedule_insns
= 0;
1264 if (TARGET_64BIT
&& optimize
>= 1)
1265 flag_omit_frame_pointer
= 1;
1268 flag_pcc_struct_return
= 0;
1269 flag_asynchronous_unwind_tables
= 1;
1272 flag_omit_frame_pointer
= 0;
1275 /* Table of valid machine attributes. */
1276 const struct attribute_spec ix86_attribute_table
[] =
1278 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
1279 /* Stdcall attribute says callee is responsible for popping arguments
1280 if they are not variable. */
1281 { "stdcall", 0, 0, false, true, true, ix86_handle_cdecl_attribute
},
1282 /* Cdecl attribute says the callee is a normal C declaration */
1283 { "cdecl", 0, 0, false, true, true, ix86_handle_cdecl_attribute
},
1284 /* Regparm attribute specifies how many integer arguments are to be
1285 passed in registers. */
1286 { "regparm", 1, 1, false, true, true, ix86_handle_regparm_attribute
},
1287 #ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
1288 { "dllimport", 0, 0, false, false, false, ix86_handle_dll_attribute
},
1289 { "dllexport", 0, 0, false, false, false, ix86_handle_dll_attribute
},
1290 { "shared", 0, 0, true, false, false, ix86_handle_shared_attribute
},
1292 { NULL
, 0, 0, false, false, false, NULL
}
1295 /* Handle a "cdecl" or "stdcall" attribute;
1296 arguments as in struct attribute_spec.handler. */
1298 ix86_handle_cdecl_attribute (node
, name
, args
, flags
, no_add_attrs
)
1301 tree args ATTRIBUTE_UNUSED
;
1302 int flags ATTRIBUTE_UNUSED
;
1305 if (TREE_CODE (*node
) != FUNCTION_TYPE
1306 && TREE_CODE (*node
) != METHOD_TYPE
1307 && TREE_CODE (*node
) != FIELD_DECL
1308 && TREE_CODE (*node
) != TYPE_DECL
)
1310 warning ("`%s' attribute only applies to functions",
1311 IDENTIFIER_POINTER (name
));
1312 *no_add_attrs
= true;
1317 warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name
));
1318 *no_add_attrs
= true;
1324 /* Handle a "regparm" attribute;
1325 arguments as in struct attribute_spec.handler. */
1327 ix86_handle_regparm_attribute (node
, name
, args
, flags
, no_add_attrs
)
1331 int flags ATTRIBUTE_UNUSED
;
1334 if (TREE_CODE (*node
) != FUNCTION_TYPE
1335 && TREE_CODE (*node
) != METHOD_TYPE
1336 && TREE_CODE (*node
) != FIELD_DECL
1337 && TREE_CODE (*node
) != TYPE_DECL
)
1339 warning ("`%s' attribute only applies to functions",
1340 IDENTIFIER_POINTER (name
));
1341 *no_add_attrs
= true;
1347 cst
= TREE_VALUE (args
);
1348 if (TREE_CODE (cst
) != INTEGER_CST
)
1350 warning ("`%s' attribute requires an integer constant argument",
1351 IDENTIFIER_POINTER (name
));
1352 *no_add_attrs
= true;
1354 else if (compare_tree_int (cst
, REGPARM_MAX
) > 0)
1356 warning ("argument to `%s' attribute larger than %d",
1357 IDENTIFIER_POINTER (name
), REGPARM_MAX
);
1358 *no_add_attrs
= true;
1365 /* Return 0 if the attributes for two types are incompatible, 1 if they
1366 are compatible, and 2 if they are nearly compatible (which causes a
1367 warning to be generated). */
1370 ix86_comp_type_attributes (type1
, type2
)
1374 /* Check for mismatch of non-default calling convention. */
1375 const char *const rtdstr
= TARGET_RTD
? "cdecl" : "stdcall";
1377 if (TREE_CODE (type1
) != FUNCTION_TYPE
)
1380 /* Check for mismatched return types (cdecl vs stdcall). */
1381 if (!lookup_attribute (rtdstr
, TYPE_ATTRIBUTES (type1
))
1382 != !lookup_attribute (rtdstr
, TYPE_ATTRIBUTES (type2
)))
1387 /* Value is the number of bytes of arguments automatically
1388 popped when returning from a subroutine call.
1389 FUNDECL is the declaration node of the function (as a tree),
1390 FUNTYPE is the data type of the function (as a tree),
1391 or for a library call it is an identifier node for the subroutine name.
1392 SIZE is the number of bytes of arguments passed on the stack.
1394 On the 80386, the RTD insn may be used to pop them if the number
1395 of args is fixed, but if the number is variable then the caller
1396 must pop them all. RTD can't be used for library calls now
1397 because the library is compiled with the Unix compiler.
1398 Use of RTD is a selectable option, since it is incompatible with
1399 standard Unix calling sequences. If the option is not selected,
1400 the caller must always pop the args.
1402 The attribute stdcall is equivalent to RTD on a per module basis. */
1405 ix86_return_pops_args (fundecl
, funtype
, size
)
1410 int rtd
= TARGET_RTD
&& (!fundecl
|| TREE_CODE (fundecl
) != IDENTIFIER_NODE
);
1412 /* Cdecl functions override -mrtd, and never pop the stack. */
1413 if (! lookup_attribute ("cdecl", TYPE_ATTRIBUTES (funtype
))) {
1415 /* Stdcall functions will pop the stack if not variable args. */
1416 if (lookup_attribute ("stdcall", TYPE_ATTRIBUTES (funtype
)))
1420 && (TYPE_ARG_TYPES (funtype
) == NULL_TREE
1421 || (TREE_VALUE (tree_last (TYPE_ARG_TYPES (funtype
)))
1422 == void_type_node
)))
1426 /* Lose any fake structure return argument if it is passed on the stack. */
1427 if (aggregate_value_p (TREE_TYPE (funtype
))
1430 int nregs
= ix86_regparm
;
1434 tree attr
= lookup_attribute ("regparm", TYPE_ATTRIBUTES (funtype
));
1437 nregs
= TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (attr
)));
1441 return GET_MODE_SIZE (Pmode
);
1447 /* Argument support functions. */
1449 /* Return true when register may be used to pass function parameters. */
1451 ix86_function_arg_regno_p (regno
)
1456 return (regno
< REGPARM_MAX
1457 || (TARGET_SSE
&& SSE_REGNO_P (regno
) && !fixed_regs
[regno
]));
1458 if (SSE_REGNO_P (regno
) && TARGET_SSE
)
1460 /* RAX is used as hidden argument to va_arg functions. */
1463 for (i
= 0; i
< REGPARM_MAX
; i
++)
1464 if (regno
== x86_64_int_parameter_registers
[i
])
1469 /* Initialize a variable CUM of type CUMULATIVE_ARGS
1470 for a call to a function whose data type is FNTYPE.
1471 For a library call, FNTYPE is 0. */
1474 init_cumulative_args (cum
, fntype
, libname
)
1475 CUMULATIVE_ARGS
*cum
; /* Argument info to initialize */
1476 tree fntype
; /* tree ptr for function decl */
1477 rtx libname
; /* SYMBOL_REF of library name or 0 */
1479 static CUMULATIVE_ARGS zero_cum
;
1480 tree param
, next_param
;
1482 if (TARGET_DEBUG_ARG
)
1484 fprintf (stderr
, "\ninit_cumulative_args (");
1486 fprintf (stderr
, "fntype code = %s, ret code = %s",
1487 tree_code_name
[(int) TREE_CODE (fntype
)],
1488 tree_code_name
[(int) TREE_CODE (TREE_TYPE (fntype
))]);
1490 fprintf (stderr
, "no fntype");
1493 fprintf (stderr
, ", libname = %s", XSTR (libname
, 0));
1498 /* Set up the number of registers to use for passing arguments. */
1499 cum
->nregs
= ix86_regparm
;
1500 cum
->sse_nregs
= SSE_REGPARM_MAX
;
1501 if (fntype
&& !TARGET_64BIT
)
1503 tree attr
= lookup_attribute ("regparm", TYPE_ATTRIBUTES (fntype
));
1506 cum
->nregs
= TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (attr
)));
1508 cum
->maybe_vaarg
= false;
1510 /* Determine if this function has variable arguments. This is
1511 indicated by the last argument being 'void_type_mode' if there
1512 are no variable arguments. If there are variable arguments, then
1513 we won't pass anything in registers */
1517 for (param
= (fntype
) ? TYPE_ARG_TYPES (fntype
) : 0;
1518 param
!= 0; param
= next_param
)
1520 next_param
= TREE_CHAIN (param
);
1521 if (next_param
== 0 && TREE_VALUE (param
) != void_type_node
)
1525 cum
->maybe_vaarg
= true;
1529 if ((!fntype
&& !libname
)
1530 || (fntype
&& !TYPE_ARG_TYPES (fntype
)))
1531 cum
->maybe_vaarg
= 1;
1533 if (TARGET_DEBUG_ARG
)
1534 fprintf (stderr
, ", nregs=%d )\n", cum
->nregs
);
1539 /* x86-64 register passing impleemntation. See x86-64 ABI for details. Goal
1540 of this code is to classify each 8bytes of incoming argument by the register
1541 class and assign registers accordingly. */
1543 /* Return the union class of CLASS1 and CLASS2.
1544 See the x86-64 PS ABI for details. */
1546 static enum x86_64_reg_class
1547 merge_classes (class1
, class2
)
1548 enum x86_64_reg_class class1
, class2
;
1550 /* Rule #1: If both classes are equal, this is the resulting class. */
1551 if (class1
== class2
)
1554 /* Rule #2: If one of the classes is NO_CLASS, the resulting class is
1556 if (class1
== X86_64_NO_CLASS
)
1558 if (class2
== X86_64_NO_CLASS
)
1561 /* Rule #3: If one of the classes is MEMORY, the result is MEMORY. */
1562 if (class1
== X86_64_MEMORY_CLASS
|| class2
== X86_64_MEMORY_CLASS
)
1563 return X86_64_MEMORY_CLASS
;
1565 /* Rule #4: If one of the classes is INTEGER, the result is INTEGER. */
1566 if ((class1
== X86_64_INTEGERSI_CLASS
&& class2
== X86_64_SSESF_CLASS
)
1567 || (class2
== X86_64_INTEGERSI_CLASS
&& class1
== X86_64_SSESF_CLASS
))
1568 return X86_64_INTEGERSI_CLASS
;
1569 if (class1
== X86_64_INTEGER_CLASS
|| class1
== X86_64_INTEGERSI_CLASS
1570 || class2
== X86_64_INTEGER_CLASS
|| class2
== X86_64_INTEGERSI_CLASS
)
1571 return X86_64_INTEGER_CLASS
;
1573 /* Rule #5: If one of the classes is X87 or X87UP class, MEMORY is used. */
1574 if (class1
== X86_64_X87_CLASS
|| class1
== X86_64_X87UP_CLASS
1575 || class2
== X86_64_X87_CLASS
|| class2
== X86_64_X87UP_CLASS
)
1576 return X86_64_MEMORY_CLASS
;
1578 /* Rule #6: Otherwise class SSE is used. */
1579 return X86_64_SSE_CLASS
;
1582 /* Classify the argument of type TYPE and mode MODE.
1583 CLASSES will be filled by the register class used to pass each word
1584 of the operand. The number of words is returned. In case the parameter
1585 should be passed in memory, 0 is returned. As a special case for zero
1586 sized containers, classes[0] will be NO_CLASS and 1 is returned.
1588 BIT_OFFSET is used internally for handling records and specifies offset
1589 of the offset in bits modulo 256 to avoid overflow cases.
1591 See the x86-64 PS ABI for details.
1595 classify_argument (mode
, type
, classes
, bit_offset
)
1596 enum machine_mode mode
;
1598 enum x86_64_reg_class classes
[MAX_CLASSES
];
1602 (mode
== BLKmode
) ? int_size_in_bytes (type
) : (int) GET_MODE_SIZE (mode
);
1603 int words
= (bytes
+ (bit_offset
% 64) / 8 + UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
1605 /* Variable sized entities are always passed/returned in memory. */
1609 if (type
&& AGGREGATE_TYPE_P (type
))
1613 enum x86_64_reg_class subclasses
[MAX_CLASSES
];
1615 /* On x86-64 we pass structures larger than 16 bytes on the stack. */
1619 for (i
= 0; i
< words
; i
++)
1620 classes
[i
] = X86_64_NO_CLASS
;
1622 /* Zero sized arrays or structures are NO_CLASS. We return 0 to
1623 signalize memory class, so handle it as special case. */
1626 classes
[0] = X86_64_NO_CLASS
;
1630 /* Classify each field of record and merge classes. */
1631 if (TREE_CODE (type
) == RECORD_TYPE
)
1633 /* For classes first merge in the field of the subclasses. */
1634 if (TYPE_BINFO (type
) != NULL
&& TYPE_BINFO_BASETYPES (type
) != NULL
)
1636 tree bases
= TYPE_BINFO_BASETYPES (type
);
1637 int n_bases
= TREE_VEC_LENGTH (bases
);
1640 for (i
= 0; i
< n_bases
; ++i
)
1642 tree binfo
= TREE_VEC_ELT (bases
, i
);
1644 int offset
= tree_low_cst (BINFO_OFFSET (binfo
), 0) * 8;
1645 tree type
= BINFO_TYPE (binfo
);
1647 num
= classify_argument (TYPE_MODE (type
),
1649 (offset
+ bit_offset
) % 256);
1652 for (i
= 0; i
< num
; i
++)
1654 int pos
= (offset
+ (bit_offset
% 64)) / 8 / 8;
1656 merge_classes (subclasses
[i
], classes
[i
+ pos
]);
1660 /* And now merge the fields of structure. */
1661 for (field
= TYPE_FIELDS (type
); field
; field
= TREE_CHAIN (field
))
1663 if (TREE_CODE (field
) == FIELD_DECL
)
1667 /* Bitfields are always classified as integer. Handle them
1668 early, since later code would consider them to be
1669 misaligned integers. */
1670 if (DECL_BIT_FIELD (field
))
1672 for (i
= int_bit_position (field
) / 8 / 8;
1673 i
< (int_bit_position (field
)
1674 + tree_low_cst (DECL_SIZE (field
), 0)
1677 merge_classes (X86_64_INTEGER_CLASS
,
1682 num
= classify_argument (TYPE_MODE (TREE_TYPE (field
)),
1683 TREE_TYPE (field
), subclasses
,
1684 (int_bit_position (field
)
1685 + bit_offset
) % 256);
1688 for (i
= 0; i
< num
; i
++)
1691 (int_bit_position (field
) + (bit_offset
% 64)) / 8 / 8;
1693 merge_classes (subclasses
[i
], classes
[i
+ pos
]);
1699 /* Arrays are handled as small records. */
1700 else if (TREE_CODE (type
) == ARRAY_TYPE
)
1703 num
= classify_argument (TYPE_MODE (TREE_TYPE (type
)),
1704 TREE_TYPE (type
), subclasses
, bit_offset
);
1708 /* The partial classes are now full classes. */
1709 if (subclasses
[0] == X86_64_SSESF_CLASS
&& bytes
!= 4)
1710 subclasses
[0] = X86_64_SSE_CLASS
;
1711 if (subclasses
[0] == X86_64_INTEGERSI_CLASS
&& bytes
!= 4)
1712 subclasses
[0] = X86_64_INTEGER_CLASS
;
1714 for (i
= 0; i
< words
; i
++)
1715 classes
[i
] = subclasses
[i
% num
];
1717 /* Unions are similar to RECORD_TYPE but offset is always 0. */
1718 else if (TREE_CODE (type
) == UNION_TYPE
1719 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1721 /* For classes first merge in the field of the subclasses. */
1722 if (TYPE_BINFO (type
) != NULL
&& TYPE_BINFO_BASETYPES (type
) != NULL
)
1724 tree bases
= TYPE_BINFO_BASETYPES (type
);
1725 int n_bases
= TREE_VEC_LENGTH (bases
);
1728 for (i
= 0; i
< n_bases
; ++i
)
1730 tree binfo
= TREE_VEC_ELT (bases
, i
);
1732 int offset
= tree_low_cst (BINFO_OFFSET (binfo
), 0) * 8;
1733 tree type
= BINFO_TYPE (binfo
);
1735 num
= classify_argument (TYPE_MODE (type
),
1737 (offset
+ (bit_offset
% 64)) % 256);
1740 for (i
= 0; i
< num
; i
++)
1742 int pos
= (offset
+ (bit_offset
% 64)) / 8 / 8;
1744 merge_classes (subclasses
[i
], classes
[i
+ pos
]);
1748 for (field
= TYPE_FIELDS (type
); field
; field
= TREE_CHAIN (field
))
1750 if (TREE_CODE (field
) == FIELD_DECL
)
1753 num
= classify_argument (TYPE_MODE (TREE_TYPE (field
)),
1754 TREE_TYPE (field
), subclasses
,
1758 for (i
= 0; i
< num
; i
++)
1759 classes
[i
] = merge_classes (subclasses
[i
], classes
[i
]);
1766 /* Final merger cleanup. */
1767 for (i
= 0; i
< words
; i
++)
1769 /* If one class is MEMORY, everything should be passed in
1771 if (classes
[i
] == X86_64_MEMORY_CLASS
)
1774 /* The X86_64_SSEUP_CLASS should be always preceded by
1775 X86_64_SSE_CLASS. */
1776 if (classes
[i
] == X86_64_SSEUP_CLASS
1777 && (i
== 0 || classes
[i
- 1] != X86_64_SSE_CLASS
))
1778 classes
[i
] = X86_64_SSE_CLASS
;
1780 /* X86_64_X87UP_CLASS should be preceded by X86_64_X87_CLASS. */
1781 if (classes
[i
] == X86_64_X87UP_CLASS
1782 && (i
== 0 || classes
[i
- 1] != X86_64_X87_CLASS
))
1783 classes
[i
] = X86_64_SSE_CLASS
;
1788 /* Compute alignment needed. We align all types to natural boundaries with
1789 exception of XFmode that is aligned to 64bits. */
1790 if (mode
!= VOIDmode
&& mode
!= BLKmode
)
1792 int mode_alignment
= GET_MODE_BITSIZE (mode
);
1795 mode_alignment
= 128;
1796 else if (mode
== XCmode
)
1797 mode_alignment
= 256;
1798 /* Misaligned fields are always returned in memory. */
1799 if (bit_offset
% mode_alignment
)
1803 /* Classification of atomic types. */
1813 if (bit_offset
+ GET_MODE_BITSIZE (mode
) <= 32)
1814 classes
[0] = X86_64_INTEGERSI_CLASS
;
1816 classes
[0] = X86_64_INTEGER_CLASS
;
1820 classes
[0] = classes
[1] = X86_64_INTEGER_CLASS
;
1823 classes
[0] = classes
[1] = X86_64_INTEGER_CLASS
;
1824 classes
[2] = classes
[3] = X86_64_INTEGER_CLASS
;
1827 if (!(bit_offset
% 64))
1828 classes
[0] = X86_64_SSESF_CLASS
;
1830 classes
[0] = X86_64_SSE_CLASS
;
1833 classes
[0] = X86_64_SSEDF_CLASS
;
1836 classes
[0] = X86_64_X87_CLASS
;
1837 classes
[1] = X86_64_X87UP_CLASS
;
1840 classes
[0] = X86_64_X87_CLASS
;
1841 classes
[1] = X86_64_X87UP_CLASS
;
1842 classes
[2] = X86_64_X87_CLASS
;
1843 classes
[3] = X86_64_X87UP_CLASS
;
1846 classes
[0] = X86_64_SSEDF_CLASS
;
1847 classes
[1] = X86_64_SSEDF_CLASS
;
1850 classes
[0] = X86_64_SSE_CLASS
;
1858 classes
[0] = X86_64_SSE_CLASS
;
1859 classes
[1] = X86_64_SSEUP_CLASS
;
1865 classes
[0] = X86_64_SSE_CLASS
;
1875 /* Examine the argument and return set number of register required in each
1876 class. Return 0 iff parameter should be passed in memory. */
1878 examine_argument (mode
, type
, in_return
, int_nregs
, sse_nregs
)
1879 enum machine_mode mode
;
1881 int *int_nregs
, *sse_nregs
;
1884 enum x86_64_reg_class
class[MAX_CLASSES
];
1885 int n
= classify_argument (mode
, type
, class, 0);
1891 for (n
--; n
>= 0; n
--)
1894 case X86_64_INTEGER_CLASS
:
1895 case X86_64_INTEGERSI_CLASS
:
1898 case X86_64_SSE_CLASS
:
1899 case X86_64_SSESF_CLASS
:
1900 case X86_64_SSEDF_CLASS
:
1903 case X86_64_NO_CLASS
:
1904 case X86_64_SSEUP_CLASS
:
1906 case X86_64_X87_CLASS
:
1907 case X86_64_X87UP_CLASS
:
1911 case X86_64_MEMORY_CLASS
:
1916 /* Construct container for the argument used by GCC interface. See
1917 FUNCTION_ARG for the detailed description. */
1919 construct_container (mode
, type
, in_return
, nintregs
, nsseregs
, intreg
, sse_regno
)
1920 enum machine_mode mode
;
1923 int nintregs
, nsseregs
;
1927 enum machine_mode tmpmode
;
1929 (mode
== BLKmode
) ? int_size_in_bytes (type
) : (int) GET_MODE_SIZE (mode
);
1930 enum x86_64_reg_class
class[MAX_CLASSES
];
1934 int needed_sseregs
, needed_intregs
;
1935 rtx exp
[MAX_CLASSES
];
1938 n
= classify_argument (mode
, type
, class, 0);
1939 if (TARGET_DEBUG_ARG
)
1942 fprintf (stderr
, "Memory class\n");
1945 fprintf (stderr
, "Classes:");
1946 for (i
= 0; i
< n
; i
++)
1948 fprintf (stderr
, " %s", x86_64_reg_class_name
[class[i
]]);
1950 fprintf (stderr
, "\n");
1955 if (!examine_argument (mode
, type
, in_return
, &needed_intregs
, &needed_sseregs
))
1957 if (needed_intregs
> nintregs
|| needed_sseregs
> nsseregs
)
1960 /* First construct simple cases. Avoid SCmode, since we want to use
1961 single register to pass this type. */
1962 if (n
== 1 && mode
!= SCmode
)
1965 case X86_64_INTEGER_CLASS
:
1966 case X86_64_INTEGERSI_CLASS
:
1967 return gen_rtx_REG (mode
, intreg
[0]);
1968 case X86_64_SSE_CLASS
:
1969 case X86_64_SSESF_CLASS
:
1970 case X86_64_SSEDF_CLASS
:
1971 return gen_rtx_REG (mode
, SSE_REGNO (sse_regno
));
1972 case X86_64_X87_CLASS
:
1973 return gen_rtx_REG (mode
, FIRST_STACK_REG
);
1974 case X86_64_NO_CLASS
:
1975 /* Zero sized array, struct or class. */
1980 if (n
== 2 && class[0] == X86_64_SSE_CLASS
&& class[1] == X86_64_SSEUP_CLASS
)
1981 return gen_rtx_REG (mode
, SSE_REGNO (sse_regno
));
1983 && class[0] == X86_64_X87_CLASS
&& class[1] == X86_64_X87UP_CLASS
)
1984 return gen_rtx_REG (TFmode
, FIRST_STACK_REG
);
1985 if (n
== 2 && class[0] == X86_64_INTEGER_CLASS
1986 && class[1] == X86_64_INTEGER_CLASS
1987 && (mode
== CDImode
|| mode
== TImode
)
1988 && intreg
[0] + 1 == intreg
[1])
1989 return gen_rtx_REG (mode
, intreg
[0]);
1991 && class[0] == X86_64_X87_CLASS
&& class[1] == X86_64_X87UP_CLASS
1992 && class[2] == X86_64_X87_CLASS
&& class[3] == X86_64_X87UP_CLASS
)
1993 return gen_rtx_REG (TCmode
, FIRST_STACK_REG
);
1995 /* Otherwise figure out the entries of the PARALLEL. */
1996 for (i
= 0; i
< n
; i
++)
2000 case X86_64_NO_CLASS
:
2002 case X86_64_INTEGER_CLASS
:
2003 case X86_64_INTEGERSI_CLASS
:
2004 /* Merge TImodes on aligned occassions here too. */
2005 if (i
* 8 + 8 > bytes
)
2006 tmpmode
= mode_for_size ((bytes
- i
* 8) * BITS_PER_UNIT
, MODE_INT
, 0);
2007 else if (class[i
] == X86_64_INTEGERSI_CLASS
)
2011 /* We've requested 24 bytes we don't have mode for. Use DImode. */
2012 if (tmpmode
== BLKmode
)
2014 exp
[nexps
++] = gen_rtx_EXPR_LIST (VOIDmode
,
2015 gen_rtx_REG (tmpmode
, *intreg
),
2019 case X86_64_SSESF_CLASS
:
2020 exp
[nexps
++] = gen_rtx_EXPR_LIST (VOIDmode
,
2021 gen_rtx_REG (SFmode
,
2022 SSE_REGNO (sse_regno
)),
2026 case X86_64_SSEDF_CLASS
:
2027 exp
[nexps
++] = gen_rtx_EXPR_LIST (VOIDmode
,
2028 gen_rtx_REG (DFmode
,
2029 SSE_REGNO (sse_regno
)),
2033 case X86_64_SSE_CLASS
:
2034 if (i
< n
&& class[i
+ 1] == X86_64_SSEUP_CLASS
)
2035 tmpmode
= TImode
, i
++;
2038 exp
[nexps
++] = gen_rtx_EXPR_LIST (VOIDmode
,
2039 gen_rtx_REG (tmpmode
,
2040 SSE_REGNO (sse_regno
)),
2048 ret
= gen_rtx_PARALLEL (mode
, rtvec_alloc (nexps
));
2049 for (i
= 0; i
< nexps
; i
++)
2050 XVECEXP (ret
, 0, i
) = exp
[i
];
2054 /* Update the data in CUM to advance over an argument
2055 of mode MODE and data type TYPE.
2056 (TYPE is null for libcalls where that information may not be available.) */
2059 function_arg_advance (cum
, mode
, type
, named
)
2060 CUMULATIVE_ARGS
*cum
; /* current arg information */
2061 enum machine_mode mode
; /* current arg mode */
2062 tree type
; /* type of the argument or 0 if lib support */
2063 int named
; /* whether or not the argument was named */
2066 (mode
== BLKmode
) ? int_size_in_bytes (type
) : (int) GET_MODE_SIZE (mode
);
2067 int words
= (bytes
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
2069 if (TARGET_DEBUG_ARG
)
2071 "function_adv (sz=%d, wds=%2d, nregs=%d, mode=%s, named=%d)\n\n",
2072 words
, cum
->words
, cum
->nregs
, GET_MODE_NAME (mode
), named
);
2075 int int_nregs
, sse_nregs
;
2076 if (!examine_argument (mode
, type
, 0, &int_nregs
, &sse_nregs
))
2077 cum
->words
+= words
;
2078 else if (sse_nregs
<= cum
->sse_nregs
&& int_nregs
<= cum
->nregs
)
2080 cum
->nregs
-= int_nregs
;
2081 cum
->sse_nregs
-= sse_nregs
;
2082 cum
->regno
+= int_nregs
;
2083 cum
->sse_regno
+= sse_nregs
;
2086 cum
->words
+= words
;
2090 if (TARGET_SSE
&& mode
== TImode
)
2092 cum
->sse_words
+= words
;
2093 cum
->sse_nregs
-= 1;
2094 cum
->sse_regno
+= 1;
2095 if (cum
->sse_nregs
<= 0)
2103 cum
->words
+= words
;
2104 cum
->nregs
-= words
;
2105 cum
->regno
+= words
;
2107 if (cum
->nregs
<= 0)
2117 /* Define where to put the arguments to a function.
2118 Value is zero to push the argument on the stack,
2119 or a hard register in which to store the argument.
2121 MODE is the argument's machine mode.
2122 TYPE is the data type of the argument (as a tree).
2123 This is null for libcalls where that information may
2125 CUM is a variable of type CUMULATIVE_ARGS which gives info about
2126 the preceding args and about the function being called.
2127 NAMED is nonzero if this argument is a named parameter
2128 (otherwise it is an extra parameter matching an ellipsis). */
2131 function_arg (cum
, mode
, type
, named
)
2132 CUMULATIVE_ARGS
*cum
; /* current arg information */
2133 enum machine_mode mode
; /* current arg mode */
2134 tree type
; /* type of the argument or 0 if lib support */
2135 int named
; /* != 0 for normal args, == 0 for ... args */
2139 (mode
== BLKmode
) ? int_size_in_bytes (type
) : (int) GET_MODE_SIZE (mode
);
2140 int words
= (bytes
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
2142 /* Handle an hidden AL argument containing number of registers for varargs
2143 x86-64 functions. For i386 ABI just return constm1_rtx to avoid
2145 if (mode
== VOIDmode
)
2148 return GEN_INT (cum
->maybe_vaarg
2149 ? (cum
->sse_nregs
< 0
2157 ret
= construct_container (mode
, type
, 0, cum
->nregs
, cum
->sse_nregs
,
2158 &x86_64_int_parameter_registers
[cum
->regno
],
2163 /* For now, pass fp/complex values on the stack. */
2172 if (words
<= cum
->nregs
)
2173 ret
= gen_rtx_REG (mode
, cum
->regno
);
2177 ret
= gen_rtx_REG (mode
, cum
->sse_regno
);
2181 if (TARGET_DEBUG_ARG
)
2184 "function_arg (size=%d, wds=%2d, nregs=%d, mode=%4s, named=%d, ",
2185 words
, cum
->words
, cum
->nregs
, GET_MODE_NAME (mode
), named
);
2188 print_simple_rtl (stderr
, ret
);
2190 fprintf (stderr
, ", stack");
2192 fprintf (stderr
, " )\n");
2198 /* Gives the alignment boundary, in bits, of an argument with the specified mode
2202 ix86_function_arg_boundary (mode
, type
)
2203 enum machine_mode mode
;
2208 return PARM_BOUNDARY
;
2210 align
= TYPE_ALIGN (type
);
2212 align
= GET_MODE_ALIGNMENT (mode
);
2213 if (align
< PARM_BOUNDARY
)
2214 align
= PARM_BOUNDARY
;
2220 /* Return true if N is a possible register number of function value. */
2222 ix86_function_value_regno_p (regno
)
2227 return ((regno
) == 0
2228 || ((regno
) == FIRST_FLOAT_REG
&& TARGET_FLOAT_RETURNS_IN_80387
)
2229 || ((regno
) == FIRST_SSE_REG
&& TARGET_SSE
));
2231 return ((regno
) == 0 || (regno
) == FIRST_FLOAT_REG
2232 || ((regno
) == FIRST_SSE_REG
&& TARGET_SSE
)
2233 || ((regno
) == FIRST_FLOAT_REG
&& TARGET_FLOAT_RETURNS_IN_80387
));
2236 /* Define how to find the value returned by a function.
2237 VALTYPE is the data type of the value (as a tree).
2238 If the precise function being called is known, FUNC is its FUNCTION_DECL;
2239 otherwise, FUNC is 0. */
2241 ix86_function_value (valtype
)
2246 rtx ret
= construct_container (TYPE_MODE (valtype
), valtype
, 1,
2247 REGPARM_MAX
, SSE_REGPARM_MAX
,
2248 x86_64_int_return_registers
, 0);
2249 /* For zero sized structures, construct_continer return NULL, but we need
2250 to keep rest of compiler happy by returning meaningfull value. */
2252 ret
= gen_rtx_REG (TYPE_MODE (valtype
), 0);
2256 return gen_rtx_REG (TYPE_MODE (valtype
),
2257 ix86_value_regno (TYPE_MODE (valtype
)));
2260 /* Return false iff type is returned in memory. */
2262 ix86_return_in_memory (type
)
2265 int needed_intregs
, needed_sseregs
;
2268 return !examine_argument (TYPE_MODE (type
), type
, 1,
2269 &needed_intregs
, &needed_sseregs
);
2273 if (TYPE_MODE (type
) == BLKmode
2274 || (VECTOR_MODE_P (TYPE_MODE (type
))
2275 && int_size_in_bytes (type
) == 8)
2276 || (int_size_in_bytes (type
) > 12 && TYPE_MODE (type
) != TImode
2277 && TYPE_MODE (type
) != TFmode
2278 && !VECTOR_MODE_P (TYPE_MODE (type
))))
2284 /* Define how to find the value returned by a library function
2285 assuming the value has mode MODE. */
2287 ix86_libcall_value (mode
)
2288 enum machine_mode mode
;
2298 return gen_rtx_REG (mode
, FIRST_SSE_REG
);
2301 return gen_rtx_REG (mode
, FIRST_FLOAT_REG
);
2303 return gen_rtx_REG (mode
, 0);
2307 return gen_rtx_REG (mode
, ix86_value_regno (mode
));
2310 /* Given a mode, return the register to use for a return value. */
2313 ix86_value_regno (mode
)
2314 enum machine_mode mode
;
2316 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
&& TARGET_FLOAT_RETURNS_IN_80387
)
2317 return FIRST_FLOAT_REG
;
2318 if (mode
== TImode
|| VECTOR_MODE_P (mode
))
2319 return FIRST_SSE_REG
;
2323 /* Create the va_list data type. */
2326 ix86_build_va_list ()
2328 tree f_gpr
, f_fpr
, f_ovf
, f_sav
, record
, type_decl
;
2330 /* For i386 we use plain pointer to argument area. */
2332 return build_pointer_type (char_type_node
);
2334 record
= (*lang_hooks
.types
.make_type
) (RECORD_TYPE
);
2335 type_decl
= build_decl (TYPE_DECL
, get_identifier ("__va_list_tag"), record
);
2337 f_gpr
= build_decl (FIELD_DECL
, get_identifier ("gp_offset"),
2338 unsigned_type_node
);
2339 f_fpr
= build_decl (FIELD_DECL
, get_identifier ("fp_offset"),
2340 unsigned_type_node
);
2341 f_ovf
= build_decl (FIELD_DECL
, get_identifier ("overflow_arg_area"),
2343 f_sav
= build_decl (FIELD_DECL
, get_identifier ("reg_save_area"),
2346 DECL_FIELD_CONTEXT (f_gpr
) = record
;
2347 DECL_FIELD_CONTEXT (f_fpr
) = record
;
2348 DECL_FIELD_CONTEXT (f_ovf
) = record
;
2349 DECL_FIELD_CONTEXT (f_sav
) = record
;
2351 TREE_CHAIN (record
) = type_decl
;
2352 TYPE_NAME (record
) = type_decl
;
2353 TYPE_FIELDS (record
) = f_gpr
;
2354 TREE_CHAIN (f_gpr
) = f_fpr
;
2355 TREE_CHAIN (f_fpr
) = f_ovf
;
2356 TREE_CHAIN (f_ovf
) = f_sav
;
2358 layout_type (record
);
2360 /* The correct type is an array type of one element. */
2361 return build_array_type (record
, build_index_type (size_zero_node
));
2364 /* Perform any needed actions needed for a function that is receiving a
2365 variable number of arguments.
2369 MODE and TYPE are the mode and type of the current parameter.
2371 PRETEND_SIZE is a variable that should be set to the amount of stack
2372 that must be pushed by the prolog to pretend that our caller pushed
2375 Normally, this macro will push all remaining incoming registers on the
2376 stack and set PRETEND_SIZE to the length of the registers pushed. */
2379 ix86_setup_incoming_varargs (cum
, mode
, type
, pretend_size
, no_rtl
)
2380 CUMULATIVE_ARGS
*cum
;
2381 enum machine_mode mode
;
2383 int *pretend_size ATTRIBUTE_UNUSED
;
2387 CUMULATIVE_ARGS next_cum
;
2388 rtx save_area
= NULL_RTX
, mem
;
2401 /* Indicate to allocate space on the stack for varargs save area. */
2402 ix86_save_varrargs_registers
= 1;
2404 fntype
= TREE_TYPE (current_function_decl
);
2405 stdarg_p
= (TYPE_ARG_TYPES (fntype
) != 0
2406 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (fntype
)))
2407 != void_type_node
));
2409 /* For varargs, we do not want to skip the dummy va_dcl argument.
2410 For stdargs, we do want to skip the last named argument. */
2413 function_arg_advance (&next_cum
, mode
, type
, 1);
2416 save_area
= frame_pointer_rtx
;
2418 set
= get_varargs_alias_set ();
2420 for (i
= next_cum
.regno
; i
< ix86_regparm
; i
++)
2422 mem
= gen_rtx_MEM (Pmode
,
2423 plus_constant (save_area
, i
* UNITS_PER_WORD
));
2424 set_mem_alias_set (mem
, set
);
2425 emit_move_insn (mem
, gen_rtx_REG (Pmode
,
2426 x86_64_int_parameter_registers
[i
]));
2429 if (next_cum
.sse_nregs
)
2431 /* Now emit code to save SSE registers. The AX parameter contains number
2432 of SSE parameter regsiters used to call this function. We use
2433 sse_prologue_save insn template that produces computed jump across
2434 SSE saves. We need some preparation work to get this working. */
2436 label
= gen_label_rtx ();
2437 label_ref
= gen_rtx_LABEL_REF (Pmode
, label
);
2439 /* Compute address to jump to :
2440 label - 5*eax + nnamed_sse_arguments*5 */
2441 tmp_reg
= gen_reg_rtx (Pmode
);
2442 nsse_reg
= gen_reg_rtx (Pmode
);
2443 emit_insn (gen_zero_extendqidi2 (nsse_reg
, gen_rtx_REG (QImode
, 0)));
2444 emit_insn (gen_rtx_SET (VOIDmode
, tmp_reg
,
2445 gen_rtx_MULT (Pmode
, nsse_reg
,
2447 if (next_cum
.sse_regno
)
2450 gen_rtx_CONST (DImode
,
2451 gen_rtx_PLUS (DImode
,
2453 GEN_INT (next_cum
.sse_regno
* 4))));
2455 emit_move_insn (nsse_reg
, label_ref
);
2456 emit_insn (gen_subdi3 (nsse_reg
, nsse_reg
, tmp_reg
));
2458 /* Compute address of memory block we save into. We always use pointer
2459 pointing 127 bytes after first byte to store - this is needed to keep
2460 instruction size limited by 4 bytes. */
2461 tmp_reg
= gen_reg_rtx (Pmode
);
2462 emit_insn (gen_rtx_SET (VOIDmode
, tmp_reg
,
2463 plus_constant (save_area
,
2464 8 * REGPARM_MAX
+ 127)));
2465 mem
= gen_rtx_MEM (BLKmode
, plus_constant (tmp_reg
, -127));
2466 set_mem_alias_set (mem
, set
);
2467 set_mem_align (mem
, BITS_PER_WORD
);
2469 /* And finally do the dirty job! */
2470 emit_insn (gen_sse_prologue_save (mem
, nsse_reg
,
2471 GEN_INT (next_cum
.sse_regno
), label
));
2476 /* Implement va_start. */
2479 ix86_va_start (valist
, nextarg
)
2483 HOST_WIDE_INT words
, n_gpr
, n_fpr
;
2484 tree f_gpr
, f_fpr
, f_ovf
, f_sav
;
2485 tree gpr
, fpr
, ovf
, sav
, t
;
2487 /* Only 64bit target needs something special. */
2490 std_expand_builtin_va_start (valist
, nextarg
);
2494 f_gpr
= TYPE_FIELDS (TREE_TYPE (va_list_type_node
));
2495 f_fpr
= TREE_CHAIN (f_gpr
);
2496 f_ovf
= TREE_CHAIN (f_fpr
);
2497 f_sav
= TREE_CHAIN (f_ovf
);
2499 valist
= build1 (INDIRECT_REF
, TREE_TYPE (TREE_TYPE (valist
)), valist
);
2500 gpr
= build (COMPONENT_REF
, TREE_TYPE (f_gpr
), valist
, f_gpr
);
2501 fpr
= build (COMPONENT_REF
, TREE_TYPE (f_fpr
), valist
, f_fpr
);
2502 ovf
= build (COMPONENT_REF
, TREE_TYPE (f_ovf
), valist
, f_ovf
);
2503 sav
= build (COMPONENT_REF
, TREE_TYPE (f_sav
), valist
, f_sav
);
2505 /* Count number of gp and fp argument registers used. */
2506 words
= current_function_args_info
.words
;
2507 n_gpr
= current_function_args_info
.regno
;
2508 n_fpr
= current_function_args_info
.sse_regno
;
2510 if (TARGET_DEBUG_ARG
)
2511 fprintf (stderr
, "va_start: words = %d, n_gpr = %d, n_fpr = %d\n",
2512 (int) words
, (int) n_gpr
, (int) n_fpr
);
2514 t
= build (MODIFY_EXPR
, TREE_TYPE (gpr
), gpr
,
2515 build_int_2 (n_gpr
* 8, 0));
2516 TREE_SIDE_EFFECTS (t
) = 1;
2517 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2519 t
= build (MODIFY_EXPR
, TREE_TYPE (fpr
), fpr
,
2520 build_int_2 (n_fpr
* 16 + 8*REGPARM_MAX
, 0));
2521 TREE_SIDE_EFFECTS (t
) = 1;
2522 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2524 /* Find the overflow area. */
2525 t
= make_tree (TREE_TYPE (ovf
), virtual_incoming_args_rtx
);
2527 t
= build (PLUS_EXPR
, TREE_TYPE (ovf
), t
,
2528 build_int_2 (words
* UNITS_PER_WORD
, 0));
2529 t
= build (MODIFY_EXPR
, TREE_TYPE (ovf
), ovf
, t
);
2530 TREE_SIDE_EFFECTS (t
) = 1;
2531 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2533 /* Find the register save area.
2534 Prologue of the function save it right above stack frame. */
2535 t
= make_tree (TREE_TYPE (sav
), frame_pointer_rtx
);
2536 t
= build (MODIFY_EXPR
, TREE_TYPE (sav
), sav
, t
);
2537 TREE_SIDE_EFFECTS (t
) = 1;
2538 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2541 /* Implement va_arg. */
2543 ix86_va_arg (valist
, type
)
2546 static const int intreg
[6] = { 0, 1, 2, 3, 4, 5 };
2547 tree f_gpr
, f_fpr
, f_ovf
, f_sav
;
2548 tree gpr
, fpr
, ovf
, sav
, t
;
2550 rtx lab_false
, lab_over
= NULL_RTX
;
2554 /* Only 64bit target needs something special. */
2557 return std_expand_builtin_va_arg (valist
, type
);
2560 f_gpr
= TYPE_FIELDS (TREE_TYPE (va_list_type_node
));
2561 f_fpr
= TREE_CHAIN (f_gpr
);
2562 f_ovf
= TREE_CHAIN (f_fpr
);
2563 f_sav
= TREE_CHAIN (f_ovf
);
2565 valist
= build1 (INDIRECT_REF
, TREE_TYPE (TREE_TYPE (valist
)), valist
);
2566 gpr
= build (COMPONENT_REF
, TREE_TYPE (f_gpr
), valist
, f_gpr
);
2567 fpr
= build (COMPONENT_REF
, TREE_TYPE (f_fpr
), valist
, f_fpr
);
2568 ovf
= build (COMPONENT_REF
, TREE_TYPE (f_ovf
), valist
, f_ovf
);
2569 sav
= build (COMPONENT_REF
, TREE_TYPE (f_sav
), valist
, f_sav
);
2571 size
= int_size_in_bytes (type
);
2572 rsize
= (size
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
2574 container
= construct_container (TYPE_MODE (type
), type
, 0,
2575 REGPARM_MAX
, SSE_REGPARM_MAX
, intreg
, 0);
2577 * Pull the value out of the saved registers ...
2580 addr_rtx
= gen_reg_rtx (Pmode
);
2584 rtx int_addr_rtx
, sse_addr_rtx
;
2585 int needed_intregs
, needed_sseregs
;
2588 lab_over
= gen_label_rtx ();
2589 lab_false
= gen_label_rtx ();
2591 examine_argument (TYPE_MODE (type
), type
, 0,
2592 &needed_intregs
, &needed_sseregs
);
2595 need_temp
= ((needed_intregs
&& TYPE_ALIGN (type
) > 64)
2596 || TYPE_ALIGN (type
) > 128);
2598 /* In case we are passing structure, verify that it is consetuctive block
2599 on the register save area. If not we need to do moves. */
2600 if (!need_temp
&& !REG_P (container
))
2602 /* Verify that all registers are strictly consetuctive */
2603 if (SSE_REGNO_P (REGNO (XEXP (XVECEXP (container
, 0, 0), 0))))
2607 for (i
= 0; i
< XVECLEN (container
, 0) && !need_temp
; i
++)
2609 rtx slot
= XVECEXP (container
, 0, i
);
2610 if (REGNO (XEXP (slot
, 0)) != FIRST_SSE_REG
+ (unsigned int) i
2611 || INTVAL (XEXP (slot
, 1)) != i
* 16)
2619 for (i
= 0; i
< XVECLEN (container
, 0) && !need_temp
; i
++)
2621 rtx slot
= XVECEXP (container
, 0, i
);
2622 if (REGNO (XEXP (slot
, 0)) != (unsigned int) i
2623 || INTVAL (XEXP (slot
, 1)) != i
* 8)
2630 int_addr_rtx
= addr_rtx
;
2631 sse_addr_rtx
= addr_rtx
;
2635 int_addr_rtx
= gen_reg_rtx (Pmode
);
2636 sse_addr_rtx
= gen_reg_rtx (Pmode
);
2638 /* First ensure that we fit completely in registers. */
2641 emit_cmp_and_jump_insns (expand_expr
2642 (gpr
, NULL_RTX
, SImode
, EXPAND_NORMAL
),
2643 GEN_INT ((REGPARM_MAX
- needed_intregs
+
2644 1) * 8), GE
, const1_rtx
, SImode
,
2649 emit_cmp_and_jump_insns (expand_expr
2650 (fpr
, NULL_RTX
, SImode
, EXPAND_NORMAL
),
2651 GEN_INT ((SSE_REGPARM_MAX
-
2652 needed_sseregs
+ 1) * 16 +
2653 REGPARM_MAX
* 8), GE
, const1_rtx
,
2654 SImode
, 1, lab_false
);
2657 /* Compute index to start of area used for integer regs. */
2660 t
= build (PLUS_EXPR
, ptr_type_node
, sav
, gpr
);
2661 r
= expand_expr (t
, int_addr_rtx
, Pmode
, EXPAND_NORMAL
);
2662 if (r
!= int_addr_rtx
)
2663 emit_move_insn (int_addr_rtx
, r
);
2667 t
= build (PLUS_EXPR
, ptr_type_node
, sav
, fpr
);
2668 r
= expand_expr (t
, sse_addr_rtx
, Pmode
, EXPAND_NORMAL
);
2669 if (r
!= sse_addr_rtx
)
2670 emit_move_insn (sse_addr_rtx
, r
);
2677 /* Never use the memory itself, as it has the alias set. */
2678 addr_rtx
= XEXP (assign_temp (type
, 0, 1, 0), 0);
2679 mem
= gen_rtx_MEM (BLKmode
, addr_rtx
);
2680 set_mem_alias_set (mem
, get_varargs_alias_set ());
2681 set_mem_align (mem
, BITS_PER_UNIT
);
2683 for (i
= 0; i
< XVECLEN (container
, 0); i
++)
2685 rtx slot
= XVECEXP (container
, 0, i
);
2686 rtx reg
= XEXP (slot
, 0);
2687 enum machine_mode mode
= GET_MODE (reg
);
2693 if (SSE_REGNO_P (REGNO (reg
)))
2695 src_addr
= sse_addr_rtx
;
2696 src_offset
= (REGNO (reg
) - FIRST_SSE_REG
) * 16;
2700 src_addr
= int_addr_rtx
;
2701 src_offset
= REGNO (reg
) * 8;
2703 src_mem
= gen_rtx_MEM (mode
, src_addr
);
2704 set_mem_alias_set (src_mem
, get_varargs_alias_set ());
2705 src_mem
= adjust_address (src_mem
, mode
, src_offset
);
2706 dest_mem
= adjust_address (mem
, mode
, INTVAL (XEXP (slot
, 1)));
2707 emit_move_insn (dest_mem
, src_mem
);
2714 build (PLUS_EXPR
, TREE_TYPE (gpr
), gpr
,
2715 build_int_2 (needed_intregs
* 8, 0));
2716 t
= build (MODIFY_EXPR
, TREE_TYPE (gpr
), gpr
, t
);
2717 TREE_SIDE_EFFECTS (t
) = 1;
2718 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2723 build (PLUS_EXPR
, TREE_TYPE (fpr
), fpr
,
2724 build_int_2 (needed_sseregs
* 16, 0));
2725 t
= build (MODIFY_EXPR
, TREE_TYPE (fpr
), fpr
, t
);
2726 TREE_SIDE_EFFECTS (t
) = 1;
2727 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2730 emit_jump_insn (gen_jump (lab_over
));
2732 emit_label (lab_false
);
2735 /* ... otherwise out of the overflow area. */
2737 /* Care for on-stack alignment if needed. */
2738 if (FUNCTION_ARG_BOUNDARY (VOIDmode
, type
) <= 64)
2742 HOST_WIDE_INT align
= FUNCTION_ARG_BOUNDARY (VOIDmode
, type
) / 8;
2743 t
= build (PLUS_EXPR
, TREE_TYPE (ovf
), ovf
, build_int_2 (align
- 1, 0));
2744 t
= build (BIT_AND_EXPR
, TREE_TYPE (t
), t
, build_int_2 (-align
, -1));
2748 r
= expand_expr (t
, addr_rtx
, Pmode
, EXPAND_NORMAL
);
2750 emit_move_insn (addr_rtx
, r
);
2753 build (PLUS_EXPR
, TREE_TYPE (t
), t
,
2754 build_int_2 (rsize
* UNITS_PER_WORD
, 0));
2755 t
= build (MODIFY_EXPR
, TREE_TYPE (ovf
), ovf
, t
);
2756 TREE_SIDE_EFFECTS (t
) = 1;
2757 expand_expr (t
, const0_rtx
, VOIDmode
, EXPAND_NORMAL
);
2760 emit_label (lab_over
);
2765 /* Return nonzero if OP is either a i387 or SSE fp register. */
2767 any_fp_register_operand (op
, mode
)
2769 enum machine_mode mode ATTRIBUTE_UNUSED
;
2771 return ANY_FP_REG_P (op
);
2774 /* Return nonzero if OP is an i387 fp register. */
2776 fp_register_operand (op
, mode
)
2778 enum machine_mode mode ATTRIBUTE_UNUSED
;
2780 return FP_REG_P (op
);
2783 /* Return nonzero if OP is a non-fp register_operand. */
2785 register_and_not_any_fp_reg_operand (op
, mode
)
2787 enum machine_mode mode
;
2789 return register_operand (op
, mode
) && !ANY_FP_REG_P (op
);
2792 /* Return nonzero of OP is a register operand other than an
2793 i387 fp register. */
2795 register_and_not_fp_reg_operand (op
, mode
)
2797 enum machine_mode mode
;
2799 return register_operand (op
, mode
) && !FP_REG_P (op
);
2802 /* Return nonzero if OP is general operand representable on x86_64. */
2805 x86_64_general_operand (op
, mode
)
2807 enum machine_mode mode
;
2810 return general_operand (op
, mode
);
2811 if (nonimmediate_operand (op
, mode
))
2813 return x86_64_sign_extended_value (op
);
2816 /* Return nonzero if OP is general operand representable on x86_64
2817 as either sign extended or zero extended constant. */
2820 x86_64_szext_general_operand (op
, mode
)
2822 enum machine_mode mode
;
2825 return general_operand (op
, mode
);
2826 if (nonimmediate_operand (op
, mode
))
2828 return x86_64_sign_extended_value (op
) || x86_64_zero_extended_value (op
);
2831 /* Return nonzero if OP is nonmemory operand representable on x86_64. */
2834 x86_64_nonmemory_operand (op
, mode
)
2836 enum machine_mode mode
;
2839 return nonmemory_operand (op
, mode
);
2840 if (register_operand (op
, mode
))
2842 return x86_64_sign_extended_value (op
);
2845 /* Return nonzero if OP is nonmemory operand acceptable by movabs patterns. */
2848 x86_64_movabs_operand (op
, mode
)
2850 enum machine_mode mode
;
2852 if (!TARGET_64BIT
|| !flag_pic
)
2853 return nonmemory_operand (op
, mode
);
2854 if (register_operand (op
, mode
) || x86_64_sign_extended_value (op
))
2856 if (CONSTANT_P (op
) && !symbolic_reference_mentioned_p (op
))
2861 /* Return nonzero if OP is nonmemory operand representable on x86_64. */
2864 x86_64_szext_nonmemory_operand (op
, mode
)
2866 enum machine_mode mode
;
2869 return nonmemory_operand (op
, mode
);
2870 if (register_operand (op
, mode
))
2872 return x86_64_sign_extended_value (op
) || x86_64_zero_extended_value (op
);
2875 /* Return nonzero if OP is immediate operand representable on x86_64. */
2878 x86_64_immediate_operand (op
, mode
)
2880 enum machine_mode mode
;
2883 return immediate_operand (op
, mode
);
2884 return x86_64_sign_extended_value (op
);
2887 /* Return nonzero if OP is immediate operand representable on x86_64. */
2890 x86_64_zext_immediate_operand (op
, mode
)
2892 enum machine_mode mode ATTRIBUTE_UNUSED
;
2894 return x86_64_zero_extended_value (op
);
2897 /* Return nonzero if OP is (const_int 1), else return zero. */
2900 const_int_1_operand (op
, mode
)
2902 enum machine_mode mode ATTRIBUTE_UNUSED
;
2904 return (GET_CODE (op
) == CONST_INT
&& INTVAL (op
) == 1);
2907 /* Return nonzero if OP is CONST_INT >= 1 and <= 31 (a valid operand
2908 for shift & compare patterns, as shifting by 0 does not change flags),
2909 else return zero. */
2912 const_int_1_31_operand (op
, mode
)
2914 enum machine_mode mode ATTRIBUTE_UNUSED
;
2916 return (GET_CODE (op
) == CONST_INT
&& INTVAL (op
) >= 1 && INTVAL (op
) <= 31);
2919 /* Returns 1 if OP is either a symbol reference or a sum of a symbol
2920 reference and a constant. */
2923 symbolic_operand (op
, mode
)
2925 enum machine_mode mode ATTRIBUTE_UNUSED
;
2927 switch (GET_CODE (op
))
2935 if (GET_CODE (op
) == SYMBOL_REF
2936 || GET_CODE (op
) == LABEL_REF
2937 || (GET_CODE (op
) == UNSPEC
2938 && (XINT (op
, 1) == UNSPEC_GOT
2939 || XINT (op
, 1) == UNSPEC_GOTOFF
2940 || XINT (op
, 1) == UNSPEC_GOTPCREL
)))
2942 if (GET_CODE (op
) != PLUS
2943 || GET_CODE (XEXP (op
, 1)) != CONST_INT
)
2947 if (GET_CODE (op
) == SYMBOL_REF
2948 || GET_CODE (op
) == LABEL_REF
)
2950 /* Only @GOTOFF gets offsets. */
2951 if (GET_CODE (op
) != UNSPEC
2952 || XINT (op
, 1) != UNSPEC_GOTOFF
)
2955 op
= XVECEXP (op
, 0, 0);
2956 if (GET_CODE (op
) == SYMBOL_REF
2957 || GET_CODE (op
) == LABEL_REF
)
2966 /* Return true if the operand contains a @GOT or @GOTOFF reference. */
2969 pic_symbolic_operand (op
, mode
)
2971 enum machine_mode mode ATTRIBUTE_UNUSED
;
2973 if (GET_CODE (op
) != CONST
)
2978 if (GET_CODE (XEXP (op
, 0)) == UNSPEC
)
2983 if (GET_CODE (op
) == UNSPEC
)
2985 if (GET_CODE (op
) != PLUS
2986 || GET_CODE (XEXP (op
, 1)) != CONST_INT
)
2989 if (GET_CODE (op
) == UNSPEC
)
2995 /* Return true if OP is a symbolic operand that resolves locally. */
2998 local_symbolic_operand (op
, mode
)
3000 enum machine_mode mode ATTRIBUTE_UNUSED
;
3002 if (GET_CODE (op
) == LABEL_REF
)
3005 if (GET_CODE (op
) == CONST
3006 && GET_CODE (XEXP (op
, 0)) == PLUS
3007 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
)
3008 op
= XEXP (XEXP (op
, 0), 0);
3010 if (GET_CODE (op
) != SYMBOL_REF
)
3013 /* These we've been told are local by varasm and encode_section_info
3015 if (CONSTANT_POOL_ADDRESS_P (op
) || SYMBOL_REF_FLAG (op
))
3018 /* There is, however, a not insubstantial body of code in the rest of
3019 the compiler that assumes it can just stick the results of
3020 ASM_GENERATE_INTERNAL_LABEL in a symbol_ref and have done. */
3021 /* ??? This is a hack. Should update the body of the compiler to
3022 always create a DECL an invoke targetm.encode_section_info. */
3023 if (strncmp (XSTR (op
, 0), internal_label_prefix
,
3024 internal_label_prefix_len
) == 0)
3030 /* Test for various thread-local symbols. See ix86_encode_section_info. */
3033 tls_symbolic_operand (op
, mode
)
3035 enum machine_mode mode ATTRIBUTE_UNUSED
;
3037 const char *symbol_str
;
3039 if (GET_CODE (op
) != SYMBOL_REF
)
3041 symbol_str
= XSTR (op
, 0);
3043 if (symbol_str
[0] != '%')
3045 return strchr (tls_model_chars
, symbol_str
[1]) - tls_model_chars
;
3049 tls_symbolic_operand_1 (op
, kind
)
3051 enum tls_model kind
;
3053 const char *symbol_str
;
3055 if (GET_CODE (op
) != SYMBOL_REF
)
3057 symbol_str
= XSTR (op
, 0);
3059 return symbol_str
[0] == '%' && symbol_str
[1] == tls_model_chars
[kind
];
3063 global_dynamic_symbolic_operand (op
, mode
)
3065 enum machine_mode mode ATTRIBUTE_UNUSED
;
3067 return tls_symbolic_operand_1 (op
, TLS_MODEL_GLOBAL_DYNAMIC
);
3071 local_dynamic_symbolic_operand (op
, mode
)
3073 enum machine_mode mode ATTRIBUTE_UNUSED
;
3075 return tls_symbolic_operand_1 (op
, TLS_MODEL_LOCAL_DYNAMIC
);
3079 initial_exec_symbolic_operand (op
, mode
)
3081 enum machine_mode mode ATTRIBUTE_UNUSED
;
3083 return tls_symbolic_operand_1 (op
, TLS_MODEL_INITIAL_EXEC
);
3087 local_exec_symbolic_operand (op
, mode
)
3089 enum machine_mode mode ATTRIBUTE_UNUSED
;
3091 return tls_symbolic_operand_1 (op
, TLS_MODEL_LOCAL_EXEC
);
3094 /* Test for a valid operand for a call instruction. Don't allow the
3095 arg pointer register or virtual regs since they may decay into
3096 reg + const, which the patterns can't handle. */
3099 call_insn_operand (op
, mode
)
3101 enum machine_mode mode ATTRIBUTE_UNUSED
;
3103 /* Disallow indirect through a virtual register. This leads to
3104 compiler aborts when trying to eliminate them. */
3105 if (GET_CODE (op
) == REG
3106 && (op
== arg_pointer_rtx
3107 || op
== frame_pointer_rtx
3108 || (REGNO (op
) >= FIRST_PSEUDO_REGISTER
3109 && REGNO (op
) <= LAST_VIRTUAL_REGISTER
)))
3112 /* Disallow `call 1234'. Due to varying assembler lameness this
3113 gets either rejected or translated to `call .+1234'. */
3114 if (GET_CODE (op
) == CONST_INT
)
3117 /* Explicitly allow SYMBOL_REF even if pic. */
3118 if (GET_CODE (op
) == SYMBOL_REF
)
3121 /* Otherwise we can allow any general_operand in the address. */
3122 return general_operand (op
, Pmode
);
3126 constant_call_address_operand (op
, mode
)
3128 enum machine_mode mode ATTRIBUTE_UNUSED
;
3130 if (GET_CODE (op
) == CONST
3131 && GET_CODE (XEXP (op
, 0)) == PLUS
3132 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
)
3133 op
= XEXP (XEXP (op
, 0), 0);
3134 return GET_CODE (op
) == SYMBOL_REF
;
3137 /* Match exactly zero and one. */
3140 const0_operand (op
, mode
)
3142 enum machine_mode mode
;
3144 return op
== CONST0_RTX (mode
);
3148 const1_operand (op
, mode
)
3150 enum machine_mode mode ATTRIBUTE_UNUSED
;
3152 return op
== const1_rtx
;
3155 /* Match 2, 4, or 8. Used for leal multiplicands. */
3158 const248_operand (op
, mode
)
3160 enum machine_mode mode ATTRIBUTE_UNUSED
;
3162 return (GET_CODE (op
) == CONST_INT
3163 && (INTVAL (op
) == 2 || INTVAL (op
) == 4 || INTVAL (op
) == 8));
3166 /* True if this is a constant appropriate for an increment or decremenmt. */
3169 incdec_operand (op
, mode
)
3171 enum machine_mode mode ATTRIBUTE_UNUSED
;
3173 /* On Pentium4, the inc and dec operations causes extra dependency on flag
3174 registers, since carry flag is not set. */
3175 if (TARGET_PENTIUM4
&& !optimize_size
)
3177 return op
== const1_rtx
|| op
== constm1_rtx
;
3180 /* Return nonzero if OP is acceptable as operand of DImode shift
3184 shiftdi_operand (op
, mode
)
3186 enum machine_mode mode ATTRIBUTE_UNUSED
;
3189 return nonimmediate_operand (op
, mode
);
3191 return register_operand (op
, mode
);
3194 /* Return false if this is the stack pointer, or any other fake
3195 register eliminable to the stack pointer. Otherwise, this is
3198 This is used to prevent esp from being used as an index reg.
3199 Which would only happen in pathological cases. */
3202 reg_no_sp_operand (op
, mode
)
3204 enum machine_mode mode
;
3207 if (GET_CODE (t
) == SUBREG
)
3209 if (t
== stack_pointer_rtx
|| t
== arg_pointer_rtx
|| t
== frame_pointer_rtx
)
3212 return register_operand (op
, mode
);
3216 mmx_reg_operand (op
, mode
)
3218 enum machine_mode mode ATTRIBUTE_UNUSED
;
3220 return MMX_REG_P (op
);
3223 /* Return false if this is any eliminable register. Otherwise
3227 general_no_elim_operand (op
, mode
)
3229 enum machine_mode mode
;
3232 if (GET_CODE (t
) == SUBREG
)
3234 if (t
== arg_pointer_rtx
|| t
== frame_pointer_rtx
3235 || t
== virtual_incoming_args_rtx
|| t
== virtual_stack_vars_rtx
3236 || t
== virtual_stack_dynamic_rtx
)
3239 && REGNO (t
) >= FIRST_VIRTUAL_REGISTER
3240 && REGNO (t
) <= LAST_VIRTUAL_REGISTER
)
3243 return general_operand (op
, mode
);
3246 /* Return false if this is any eliminable register. Otherwise
3247 register_operand or const_int. */
3250 nonmemory_no_elim_operand (op
, mode
)
3252 enum machine_mode mode
;
3255 if (GET_CODE (t
) == SUBREG
)
3257 if (t
== arg_pointer_rtx
|| t
== frame_pointer_rtx
3258 || t
== virtual_incoming_args_rtx
|| t
== virtual_stack_vars_rtx
3259 || t
== virtual_stack_dynamic_rtx
)
3262 return GET_CODE (op
) == CONST_INT
|| register_operand (op
, mode
);
3265 /* Return false if this is any eliminable register or stack register,
3266 otherwise work like register_operand. */
3269 index_register_operand (op
, mode
)
3271 enum machine_mode mode
;
3274 if (GET_CODE (t
) == SUBREG
)
3278 if (t
== arg_pointer_rtx
3279 || t
== frame_pointer_rtx
3280 || t
== virtual_incoming_args_rtx
3281 || t
== virtual_stack_vars_rtx
3282 || t
== virtual_stack_dynamic_rtx
3283 || REGNO (t
) == STACK_POINTER_REGNUM
)
3286 return general_operand (op
, mode
);
3289 /* Return true if op is a Q_REGS class register. */
3292 q_regs_operand (op
, mode
)
3294 enum machine_mode mode
;
3296 if (mode
!= VOIDmode
&& GET_MODE (op
) != mode
)
3298 if (GET_CODE (op
) == SUBREG
)
3299 op
= SUBREG_REG (op
);
3300 return ANY_QI_REG_P (op
);
3303 /* Return true if op is a NON_Q_REGS class register. */
3306 non_q_regs_operand (op
, mode
)
3308 enum machine_mode mode
;
3310 if (mode
!= VOIDmode
&& GET_MODE (op
) != mode
)
3312 if (GET_CODE (op
) == SUBREG
)
3313 op
= SUBREG_REG (op
);
3314 return NON_QI_REG_P (op
);
3317 /* Return 1 if OP is a comparison that can be used in the CMPSS/CMPPS
3320 sse_comparison_operator (op
, mode
)
3322 enum machine_mode mode ATTRIBUTE_UNUSED
;
3324 enum rtx_code code
= GET_CODE (op
);
3327 /* Operations supported directly. */
3337 /* These are equivalent to ones above in non-IEEE comparisons. */
3344 return !TARGET_IEEE_FP
;
3349 /* Return 1 if OP is a valid comparison operator in valid mode. */
3351 ix86_comparison_operator (op
, mode
)
3353 enum machine_mode mode
;
3355 enum machine_mode inmode
;
3356 enum rtx_code code
= GET_CODE (op
);
3357 if (mode
!= VOIDmode
&& GET_MODE (op
) != mode
)
3359 if (GET_RTX_CLASS (code
) != '<')
3361 inmode
= GET_MODE (XEXP (op
, 0));
3363 if (inmode
== CCFPmode
|| inmode
== CCFPUmode
)
3365 enum rtx_code second_code
, bypass_code
;
3366 ix86_fp_comparison_codes (code
, &bypass_code
, &code
, &second_code
);
3367 return (bypass_code
== NIL
&& second_code
== NIL
);
3374 if (inmode
== CCmode
|| inmode
== CCGCmode
3375 || inmode
== CCGOCmode
|| inmode
== CCNOmode
)
3378 case LTU
: case GTU
: case LEU
: case ORDERED
: case UNORDERED
: case GEU
:
3379 if (inmode
== CCmode
)
3383 if (inmode
== CCmode
|| inmode
== CCGCmode
|| inmode
== CCNOmode
)
3391 /* Return 1 if OP is a comparison operator that can be issued by fcmov. */
3394 fcmov_comparison_operator (op
, mode
)
3396 enum machine_mode mode
;
3398 enum machine_mode inmode
;
3399 enum rtx_code code
= GET_CODE (op
);
3400 if (mode
!= VOIDmode
&& GET_MODE (op
) != mode
)
3402 if (GET_RTX_CLASS (code
) != '<')
3404 inmode
= GET_MODE (XEXP (op
, 0));
3405 if (inmode
== CCFPmode
|| inmode
== CCFPUmode
)
3407 enum rtx_code second_code
, bypass_code
;
3408 ix86_fp_comparison_codes (code
, &bypass_code
, &code
, &second_code
);
3409 if (bypass_code
!= NIL
|| second_code
!= NIL
)
3411 code
= ix86_fp_compare_code_to_integer (code
);
3413 /* i387 supports just limited amount of conditional codes. */
3416 case LTU
: case GTU
: case LEU
: case GEU
:
3417 if (inmode
== CCmode
|| inmode
== CCFPmode
|| inmode
== CCFPUmode
)
3420 case ORDERED
: case UNORDERED
:
3428 /* Return 1 if OP is a binary operator that can be promoted to wider mode. */
3431 promotable_binary_operator (op
, mode
)
3433 enum machine_mode mode ATTRIBUTE_UNUSED
;
3435 switch (GET_CODE (op
))
3438 /* Modern CPUs have same latency for HImode and SImode multiply,
3439 but 386 and 486 do HImode multiply faster. */
3440 return ix86_cpu
> PROCESSOR_I486
;
3452 /* Nearly general operand, but accept any const_double, since we wish
3453 to be able to drop them into memory rather than have them get pulled
3457 cmp_fp_expander_operand (op
, mode
)
3459 enum machine_mode mode
;
3461 if (mode
!= VOIDmode
&& mode
!= GET_MODE (op
))
3463 if (GET_CODE (op
) == CONST_DOUBLE
)
3465 return general_operand (op
, mode
);
3468 /* Match an SI or HImode register for a zero_extract. */
3471 ext_register_operand (op
, mode
)
3473 enum machine_mode mode ATTRIBUTE_UNUSED
;
3476 if ((!TARGET_64BIT
|| GET_MODE (op
) != DImode
)
3477 && GET_MODE (op
) != SImode
&& GET_MODE (op
) != HImode
)
3480 if (!register_operand (op
, VOIDmode
))
3483 /* Be curefull to accept only registers having upper parts. */
3484 regno
= REG_P (op
) ? REGNO (op
) : REGNO (SUBREG_REG (op
));
3485 return (regno
> LAST_VIRTUAL_REGISTER
|| regno
< 4);
3488 /* Return 1 if this is a valid binary floating-point operation.
3489 OP is the expression matched, and MODE is its mode. */
3492 binary_fp_operator (op
, mode
)
3494 enum machine_mode mode
;
3496 if (mode
!= VOIDmode
&& mode
!= GET_MODE (op
))
3499 switch (GET_CODE (op
))
3505 return GET_MODE_CLASS (GET_MODE (op
)) == MODE_FLOAT
;
3513 mult_operator (op
, mode
)
3515 enum machine_mode mode ATTRIBUTE_UNUSED
;
3517 return GET_CODE (op
) == MULT
;
3521 div_operator (op
, mode
)
3523 enum machine_mode mode ATTRIBUTE_UNUSED
;
3525 return GET_CODE (op
) == DIV
;
3529 arith_or_logical_operator (op
, mode
)
3531 enum machine_mode mode
;
3533 return ((mode
== VOIDmode
|| GET_MODE (op
) == mode
)
3534 && (GET_RTX_CLASS (GET_CODE (op
)) == 'c'
3535 || GET_RTX_CLASS (GET_CODE (op
)) == '2'));
3538 /* Returns 1 if OP is memory operand with a displacement. */
3541 memory_displacement_operand (op
, mode
)
3543 enum machine_mode mode
;
3545 struct ix86_address parts
;
3547 if (! memory_operand (op
, mode
))
3550 if (! ix86_decompose_address (XEXP (op
, 0), &parts
))
3553 return parts
.disp
!= NULL_RTX
;
3556 /* To avoid problems when jump re-emits comparisons like testqi_ext_ccno_0,
3557 re-recognize the operand to avoid a copy_to_mode_reg that will fail.
3559 ??? It seems likely that this will only work because cmpsi is an
3560 expander, and no actual insns use this. */
3563 cmpsi_operand (op
, mode
)
3565 enum machine_mode mode
;
3567 if (nonimmediate_operand (op
, mode
))
3570 if (GET_CODE (op
) == AND
3571 && GET_MODE (op
) == SImode
3572 && GET_CODE (XEXP (op
, 0)) == ZERO_EXTRACT
3573 && GET_CODE (XEXP (XEXP (op
, 0), 1)) == CONST_INT
3574 && GET_CODE (XEXP (XEXP (op
, 0), 2)) == CONST_INT
3575 && INTVAL (XEXP (XEXP (op
, 0), 1)) == 8
3576 && INTVAL (XEXP (XEXP (op
, 0), 2)) == 8
3577 && GET_CODE (XEXP (op
, 1)) == CONST_INT
)
3583 /* Returns 1 if OP is memory operand that can not be represented by the
3587 long_memory_operand (op
, mode
)
3589 enum machine_mode mode
;
3591 if (! memory_operand (op
, mode
))
3594 return memory_address_length (op
) != 0;
3597 /* Return nonzero if the rtx is known aligned. */
3600 aligned_operand (op
, mode
)
3602 enum machine_mode mode
;
3604 struct ix86_address parts
;
3606 if (!general_operand (op
, mode
))
3609 /* Registers and immediate operands are always "aligned". */
3610 if (GET_CODE (op
) != MEM
)
3613 /* Don't even try to do any aligned optimizations with volatiles. */
3614 if (MEM_VOLATILE_P (op
))
3619 /* Pushes and pops are only valid on the stack pointer. */
3620 if (GET_CODE (op
) == PRE_DEC
3621 || GET_CODE (op
) == POST_INC
)
3624 /* Decode the address. */
3625 if (! ix86_decompose_address (op
, &parts
))
3628 if (parts
.base
&& GET_CODE (parts
.base
) == SUBREG
)
3629 parts
.base
= SUBREG_REG (parts
.base
);
3630 if (parts
.index
&& GET_CODE (parts
.index
) == SUBREG
)
3631 parts
.index
= SUBREG_REG (parts
.index
);
3633 /* Look for some component that isn't known to be aligned. */
3637 && REGNO_POINTER_ALIGN (REGNO (parts
.index
)) < 32)
3642 if (REGNO_POINTER_ALIGN (REGNO (parts
.base
)) < 32)
3647 if (GET_CODE (parts
.disp
) != CONST_INT
3648 || (INTVAL (parts
.disp
) & 3) != 0)
3652 /* Didn't find one -- this must be an aligned address. */
3656 /* Return true if the constant is something that can be loaded with
3657 a special instruction. Only handle 0.0 and 1.0; others are less
3661 standard_80387_constant_p (x
)
3664 if (GET_CODE (x
) != CONST_DOUBLE
|| !FLOAT_MODE_P (GET_MODE (x
)))
3666 /* Note that on the 80387, other constants, such as pi, that we should support
3667 too. On some machines, these are much slower to load as standard constant,
3668 than to load from doubles in memory. */
3669 if (x
== CONST0_RTX (GET_MODE (x
)))
3671 if (x
== CONST1_RTX (GET_MODE (x
)))
3676 /* Return 1 if X is FP constant we can load to SSE register w/o using memory.
3679 standard_sse_constant_p (x
)
3682 if (GET_CODE (x
) != CONST_DOUBLE
)
3684 return (x
== CONST0_RTX (GET_MODE (x
)));
3687 /* Returns 1 if OP contains a symbol reference */
3690 symbolic_reference_mentioned_p (op
)
3693 register const char *fmt
;
3696 if (GET_CODE (op
) == SYMBOL_REF
|| GET_CODE (op
) == LABEL_REF
)
3699 fmt
= GET_RTX_FORMAT (GET_CODE (op
));
3700 for (i
= GET_RTX_LENGTH (GET_CODE (op
)) - 1; i
>= 0; i
--)
3706 for (j
= XVECLEN (op
, i
) - 1; j
>= 0; j
--)
3707 if (symbolic_reference_mentioned_p (XVECEXP (op
, i
, j
)))
3711 else if (fmt
[i
] == 'e' && symbolic_reference_mentioned_p (XEXP (op
, i
)))
3718 /* Return 1 if it is appropriate to emit `ret' instructions in the
3719 body of a function. Do this only if the epilogue is simple, needing a
3720 couple of insns. Prior to reloading, we can't tell how many registers
3721 must be saved, so return 0 then. Return 0 if there is no frame
3722 marker to de-allocate.
3724 If NON_SAVING_SETJMP is defined and true, then it is not possible
3725 for the epilogue to be simple, so return 0. This is a special case
3726 since NON_SAVING_SETJMP will not cause regs_ever_live to change
3727 until final, but jump_optimize may need to know sooner if a
3731 ix86_can_use_return_insn_p ()
3733 struct ix86_frame frame
;
3735 #ifdef NON_SAVING_SETJMP
3736 if (NON_SAVING_SETJMP
&& current_function_calls_setjmp
)
3740 if (! reload_completed
|| frame_pointer_needed
)
3743 /* Don't allow more than 32 pop, since that's all we can do
3744 with one instruction. */
3745 if (current_function_pops_args
3746 && current_function_args_size
>= 32768)
3749 ix86_compute_frame_layout (&frame
);
3750 return frame
.to_allocate
== 0 && frame
.nregs
== 0;
3753 /* Return 1 if VALUE can be stored in the sign extended immediate field. */
3755 x86_64_sign_extended_value (value
)
3758 switch (GET_CODE (value
))
3760 /* CONST_DOUBLES never match, since HOST_BITS_PER_WIDE_INT is known
3761 to be at least 32 and this all acceptable constants are
3762 represented as CONST_INT. */
3764 if (HOST_BITS_PER_WIDE_INT
== 32)
3768 HOST_WIDE_INT val
= trunc_int_for_mode (INTVAL (value
), DImode
);
3769 return trunc_int_for_mode (val
, SImode
) == val
;
3773 /* For certain code models, the symbolic references are known to fit. */
3775 return ix86_cmodel
== CM_SMALL
|| ix86_cmodel
== CM_KERNEL
;
3777 /* For certain code models, the code is near as well. */
3779 return ix86_cmodel
!= CM_LARGE
&& ix86_cmodel
!= CM_SMALL_PIC
;
3781 /* We also may accept the offsetted memory references in certain special
3784 if (GET_CODE (XEXP (value
, 0)) == UNSPEC
3785 && XINT (XEXP (value
, 0), 1) == UNSPEC_GOTPCREL
)
3787 else if (GET_CODE (XEXP (value
, 0)) == PLUS
)
3789 rtx op1
= XEXP (XEXP (value
, 0), 0);
3790 rtx op2
= XEXP (XEXP (value
, 0), 1);
3791 HOST_WIDE_INT offset
;
3793 if (ix86_cmodel
== CM_LARGE
)
3795 if (GET_CODE (op2
) != CONST_INT
)
3797 offset
= trunc_int_for_mode (INTVAL (op2
), DImode
);
3798 switch (GET_CODE (op1
))
3801 /* For CM_SMALL assume that latest object is 1MB before
3802 end of 31bits boundary. We may also accept pretty
3803 large negative constants knowing that all objects are
3804 in the positive half of address space. */
3805 if (ix86_cmodel
== CM_SMALL
3806 && offset
< 1024*1024*1024
3807 && trunc_int_for_mode (offset
, SImode
) == offset
)
3809 /* For CM_KERNEL we know that all object resist in the
3810 negative half of 32bits address space. We may not
3811 accept negative offsets, since they may be just off
3812 and we may accept pretty large positive ones. */
3813 if (ix86_cmodel
== CM_KERNEL
3815 && trunc_int_for_mode (offset
, SImode
) == offset
)
3819 /* These conditions are similar to SYMBOL_REF ones, just the
3820 constraints for code models differ. */
3821 if ((ix86_cmodel
== CM_SMALL
|| ix86_cmodel
== CM_MEDIUM
)
3822 && offset
< 1024*1024*1024
3823 && trunc_int_for_mode (offset
, SImode
) == offset
)
3825 if (ix86_cmodel
== CM_KERNEL
3827 && trunc_int_for_mode (offset
, SImode
) == offset
)
3840 /* Return 1 if VALUE can be stored in the zero extended immediate field. */
3842 x86_64_zero_extended_value (value
)
3845 switch (GET_CODE (value
))
3848 if (HOST_BITS_PER_WIDE_INT
== 32)
3849 return (GET_MODE (value
) == VOIDmode
3850 && !CONST_DOUBLE_HIGH (value
));
3854 if (HOST_BITS_PER_WIDE_INT
== 32)
3855 return INTVAL (value
) >= 0;
3857 return !(INTVAL (value
) & ~(HOST_WIDE_INT
) 0xffffffff);
3860 /* For certain code models, the symbolic references are known to fit. */
3862 return ix86_cmodel
== CM_SMALL
;
3864 /* For certain code models, the code is near as well. */
3866 return ix86_cmodel
== CM_SMALL
|| ix86_cmodel
== CM_MEDIUM
;
3868 /* We also may accept the offsetted memory references in certain special
3871 if (GET_CODE (XEXP (value
, 0)) == PLUS
)
3873 rtx op1
= XEXP (XEXP (value
, 0), 0);
3874 rtx op2
= XEXP (XEXP (value
, 0), 1);
3876 if (ix86_cmodel
== CM_LARGE
)
3878 switch (GET_CODE (op1
))
3882 /* For small code model we may accept pretty large positive
3883 offsets, since one bit is available for free. Negative
3884 offsets are limited by the size of NULL pointer area
3885 specified by the ABI. */
3886 if (ix86_cmodel
== CM_SMALL
3887 && GET_CODE (op2
) == CONST_INT
3888 && trunc_int_for_mode (INTVAL (op2
), DImode
) > -0x10000
3889 && (trunc_int_for_mode (INTVAL (op2
), SImode
)
3892 /* ??? For the kernel, we may accept adjustment of
3893 -0x10000000, since we know that it will just convert
3894 negative address space to positive, but perhaps this
3895 is not worthwhile. */
3898 /* These conditions are similar to SYMBOL_REF ones, just the
3899 constraints for code models differ. */
3900 if ((ix86_cmodel
== CM_SMALL
|| ix86_cmodel
== CM_MEDIUM
)
3901 && GET_CODE (op2
) == CONST_INT
3902 && trunc_int_for_mode (INTVAL (op2
), DImode
) > -0x10000
3903 && (trunc_int_for_mode (INTVAL (op2
), SImode
)
3917 /* Value should be nonzero if functions must have frame pointers.
3918 Zero means the frame pointer need not be set up (and parms may
3919 be accessed via the stack pointer) in functions that seem suitable. */
3922 ix86_frame_pointer_required ()
3924 /* If we accessed previous frames, then the generated code expects
3925 to be able to access the saved ebp value in our frame. */
3926 if (cfun
->machine
->accesses_prev_frame
)
3929 /* Several x86 os'es need a frame pointer for other reasons,
3930 usually pertaining to setjmp. */
3931 if (SUBTARGET_FRAME_POINTER_REQUIRED
)
3934 /* In override_options, TARGET_OMIT_LEAF_FRAME_POINTER turns off
3935 the frame pointer by default. Turn it back on now if we've not
3936 got a leaf function. */
3937 if (TARGET_OMIT_LEAF_FRAME_POINTER
3938 && (!current_function_is_leaf
|| current_function_profile
))
3944 /* Record that the current function accesses previous call frames. */
3947 ix86_setup_frame_addresses ()
3949 cfun
->machine
->accesses_prev_frame
= 1;
3952 #if defined(HAVE_GAS_HIDDEN) && defined(SUPPORTS_ONE_ONLY)
3953 # define USE_HIDDEN_LINKONCE 1
3955 # define USE_HIDDEN_LINKONCE 0
3958 static int pic_labels_used
;
3960 /* Fills in the label name that should be used for a pc thunk for
3961 the given register. */
3964 get_pc_thunk_name (name
, regno
)
3968 if (USE_HIDDEN_LINKONCE
)
3969 sprintf (name
, "__i686.get_pc_thunk.%s", reg_names
[regno
]);
3971 ASM_GENERATE_INTERNAL_LABEL (name
, "LPR", regno
);
3975 /* This function generates code for -fpic that loads %ebx with
3976 the return address of the caller and then returns. */
3979 ix86_asm_file_end (file
)
3985 for (regno
= 0; regno
< 8; ++regno
)
3989 if (! ((pic_labels_used
>> regno
) & 1))
3992 get_pc_thunk_name (name
, regno
);
3994 if (USE_HIDDEN_LINKONCE
)
3998 decl
= build_decl (FUNCTION_DECL
, get_identifier (name
),
4000 TREE_PUBLIC (decl
) = 1;
4001 TREE_STATIC (decl
) = 1;
4002 DECL_ONE_ONLY (decl
) = 1;
4004 (*targetm
.asm_out
.unique_section
) (decl
, 0);
4005 named_section (decl
, NULL
, 0);
4007 (*targetm
.asm_out
.globalize_label
) (file
, name
);
4008 fputs ("\t.hidden\t", file
);
4009 assemble_name (file
, name
);
4011 ASM_DECLARE_FUNCTION_NAME (file
, name
, decl
);
4016 ASM_OUTPUT_LABEL (file
, name
);
4019 xops
[0] = gen_rtx_REG (SImode
, regno
);
4020 xops
[1] = gen_rtx_MEM (SImode
, stack_pointer_rtx
);
4021 output_asm_insn ("mov{l}\t{%1, %0|%0, %1}", xops
);
4022 output_asm_insn ("ret", xops
);
4026 /* Emit code for the SET_GOT patterns. */
4029 output_set_got (dest
)
4035 xops
[1] = gen_rtx_SYMBOL_REF (Pmode
, GOT_SYMBOL_NAME
);
4037 if (! TARGET_DEEP_BRANCH_PREDICTION
|| !flag_pic
)
4039 xops
[2] = gen_rtx_LABEL_REF (Pmode
, gen_label_rtx ());
4042 output_asm_insn ("mov{l}\t{%2, %0|%0, %2}", xops
);
4044 output_asm_insn ("call\t%a2", xops
);
4047 /* Output the "canonical" label name ("Lxx$pb") here too. This
4048 is what will be referred to by the Mach-O PIC subsystem. */
4049 ASM_OUTPUT_LABEL (asm_out_file
, machopic_function_base_name ());
4051 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, "L",
4052 CODE_LABEL_NUMBER (XEXP (xops
[2], 0)));
4055 output_asm_insn ("pop{l}\t%0", xops
);
4060 get_pc_thunk_name (name
, REGNO (dest
));
4061 pic_labels_used
|= 1 << REGNO (dest
);
4063 xops
[2] = gen_rtx_SYMBOL_REF (Pmode
, ggc_strdup (name
));
4064 xops
[2] = gen_rtx_MEM (QImode
, xops
[2]);
4065 output_asm_insn ("call\t%X2", xops
);
4068 if (!flag_pic
|| TARGET_DEEP_BRANCH_PREDICTION
)
4069 output_asm_insn ("add{l}\t{%1, %0|%0, %1}", xops
);
4070 else if (!TARGET_MACHO
)
4071 output_asm_insn ("add{l}\t{%1+[.-%a2], %0|%0, %a1+(.-%a2)}", xops
);
4076 /* Generate an "push" pattern for input ARG. */
4082 return gen_rtx_SET (VOIDmode
,
4084 gen_rtx_PRE_DEC (Pmode
,
4085 stack_pointer_rtx
)),
4089 /* Return >= 0 if there is an unused call-clobbered register available
4090 for the entire function. */
4093 ix86_select_alt_pic_regnum ()
4095 if (current_function_is_leaf
&& !current_function_profile
)
4098 for (i
= 2; i
>= 0; --i
)
4099 if (!regs_ever_live
[i
])
4103 return INVALID_REGNUM
;
4106 /* Return 1 if we need to save REGNO. */
4108 ix86_save_reg (regno
, maybe_eh_return
)
4110 int maybe_eh_return
;
4112 if (pic_offset_table_rtx
4113 && regno
== REAL_PIC_OFFSET_TABLE_REGNUM
4114 && (regs_ever_live
[REAL_PIC_OFFSET_TABLE_REGNUM
]
4115 || current_function_profile
4116 || current_function_calls_eh_return
))
4118 if (ix86_select_alt_pic_regnum () != INVALID_REGNUM
)
4123 if (current_function_calls_eh_return
&& maybe_eh_return
)
4128 unsigned test
= EH_RETURN_DATA_REGNO (i
);
4129 if (test
== INVALID_REGNUM
)
4136 return (regs_ever_live
[regno
]
4137 && !call_used_regs
[regno
]
4138 && !fixed_regs
[regno
]
4139 && (regno
!= HARD_FRAME_POINTER_REGNUM
|| !frame_pointer_needed
));
4142 /* Return number of registers to be saved on the stack. */
4150 for (regno
= FIRST_PSEUDO_REGISTER
- 1; regno
>= 0; regno
--)
4151 if (ix86_save_reg (regno
, true))
4156 /* Return the offset between two registers, one to be eliminated, and the other
4157 its replacement, at the start of a routine. */
4160 ix86_initial_elimination_offset (from
, to
)
4164 struct ix86_frame frame
;
4165 ix86_compute_frame_layout (&frame
);
4167 if (from
== ARG_POINTER_REGNUM
&& to
== HARD_FRAME_POINTER_REGNUM
)
4168 return frame
.hard_frame_pointer_offset
;
4169 else if (from
== FRAME_POINTER_REGNUM
4170 && to
== HARD_FRAME_POINTER_REGNUM
)
4171 return frame
.hard_frame_pointer_offset
- frame
.frame_pointer_offset
;
4174 if (to
!= STACK_POINTER_REGNUM
)
4176 else if (from
== ARG_POINTER_REGNUM
)
4177 return frame
.stack_pointer_offset
;
4178 else if (from
!= FRAME_POINTER_REGNUM
)
4181 return frame
.stack_pointer_offset
- frame
.frame_pointer_offset
;
4185 /* Fill structure ix86_frame about frame of currently computed function. */
4188 ix86_compute_frame_layout (frame
)
4189 struct ix86_frame
*frame
;
4191 HOST_WIDE_INT total_size
;
4192 int stack_alignment_needed
= cfun
->stack_alignment_needed
/ BITS_PER_UNIT
;
4194 int preferred_alignment
= cfun
->preferred_stack_boundary
/ BITS_PER_UNIT
;
4195 HOST_WIDE_INT size
= get_frame_size ();
4197 frame
->nregs
= ix86_nsaved_regs ();
4200 /* Skip return address and saved base pointer. */
4201 offset
= frame_pointer_needed
? UNITS_PER_WORD
* 2 : UNITS_PER_WORD
;
4203 frame
->hard_frame_pointer_offset
= offset
;
4205 /* Do some sanity checking of stack_alignment_needed and
4206 preferred_alignment, since i386 port is the only using those features
4207 that may break easily. */
4209 if (size
&& !stack_alignment_needed
)
4211 if (preferred_alignment
< STACK_BOUNDARY
/ BITS_PER_UNIT
)
4213 if (preferred_alignment
> PREFERRED_STACK_BOUNDARY
/ BITS_PER_UNIT
)
4215 if (stack_alignment_needed
> PREFERRED_STACK_BOUNDARY
/ BITS_PER_UNIT
)
4218 if (stack_alignment_needed
< STACK_BOUNDARY
/ BITS_PER_UNIT
)
4219 stack_alignment_needed
= STACK_BOUNDARY
/ BITS_PER_UNIT
;
4221 /* Register save area */
4222 offset
+= frame
->nregs
* UNITS_PER_WORD
;
4225 if (ix86_save_varrargs_registers
)
4227 offset
+= X86_64_VARARGS_SIZE
;
4228 frame
->va_arg_size
= X86_64_VARARGS_SIZE
;
4231 frame
->va_arg_size
= 0;
4233 /* Align start of frame for local function. */
4234 frame
->padding1
= ((offset
+ stack_alignment_needed
- 1)
4235 & -stack_alignment_needed
) - offset
;
4237 offset
+= frame
->padding1
;
4239 /* Frame pointer points here. */
4240 frame
->frame_pointer_offset
= offset
;
4244 /* Add outgoing arguments area. Can be skipped if we eliminated
4245 all the function calls as dead code. */
4246 if (ACCUMULATE_OUTGOING_ARGS
&& !current_function_is_leaf
)
4248 offset
+= current_function_outgoing_args_size
;
4249 frame
->outgoing_arguments_size
= current_function_outgoing_args_size
;
4252 frame
->outgoing_arguments_size
= 0;
4254 /* Align stack boundary. Only needed if we're calling another function
4256 if (!current_function_is_leaf
|| current_function_calls_alloca
)
4257 frame
->padding2
= ((offset
+ preferred_alignment
- 1)
4258 & -preferred_alignment
) - offset
;
4260 frame
->padding2
= 0;
4262 offset
+= frame
->padding2
;
4264 /* We've reached end of stack frame. */
4265 frame
->stack_pointer_offset
= offset
;
4267 /* Size prologue needs to allocate. */
4268 frame
->to_allocate
=
4269 (size
+ frame
->padding1
+ frame
->padding2
4270 + frame
->outgoing_arguments_size
+ frame
->va_arg_size
);
4272 if (TARGET_64BIT
&& TARGET_RED_ZONE
&& current_function_sp_is_unchanging
4273 && current_function_is_leaf
)
4275 frame
->red_zone_size
= frame
->to_allocate
;
4276 if (frame
->red_zone_size
> RED_ZONE_SIZE
- RED_ZONE_RESERVE
)
4277 frame
->red_zone_size
= RED_ZONE_SIZE
- RED_ZONE_RESERVE
;
4280 frame
->red_zone_size
= 0;
4281 frame
->to_allocate
-= frame
->red_zone_size
;
4282 frame
->stack_pointer_offset
-= frame
->red_zone_size
;
4284 fprintf (stderr
, "nregs: %i\n", frame
->nregs
);
4285 fprintf (stderr
, "size: %i\n", size
);
4286 fprintf (stderr
, "alignment1: %i\n", stack_alignment_needed
);
4287 fprintf (stderr
, "padding1: %i\n", frame
->padding1
);
4288 fprintf (stderr
, "va_arg: %i\n", frame
->va_arg_size
);
4289 fprintf (stderr
, "padding2: %i\n", frame
->padding2
);
4290 fprintf (stderr
, "to_allocate: %i\n", frame
->to_allocate
);
4291 fprintf (stderr
, "red_zone_size: %i\n", frame
->red_zone_size
);
4292 fprintf (stderr
, "frame_pointer_offset: %i\n", frame
->frame_pointer_offset
);
4293 fprintf (stderr
, "hard_frame_pointer_offset: %i\n",
4294 frame
->hard_frame_pointer_offset
);
4295 fprintf (stderr
, "stack_pointer_offset: %i\n", frame
->stack_pointer_offset
);
4299 /* Emit code to save registers in the prologue. */
4302 ix86_emit_save_regs ()
4307 for (regno
= FIRST_PSEUDO_REGISTER
- 1; regno
>= 0; regno
--)
4308 if (ix86_save_reg (regno
, true))
4310 insn
= emit_insn (gen_push (gen_rtx_REG (Pmode
, regno
)));
4311 RTX_FRAME_RELATED_P (insn
) = 1;
4315 /* Emit code to save registers using MOV insns. First register
4316 is restored from POINTER + OFFSET. */
4318 ix86_emit_save_regs_using_mov (pointer
, offset
)
4320 HOST_WIDE_INT offset
;
4325 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
4326 if (ix86_save_reg (regno
, true))
4328 insn
= emit_move_insn (adjust_address (gen_rtx_MEM (Pmode
, pointer
),
4330 gen_rtx_REG (Pmode
, regno
));
4331 RTX_FRAME_RELATED_P (insn
) = 1;
4332 offset
+= UNITS_PER_WORD
;
4336 /* Expand the prologue into a bunch of separate insns. */
4339 ix86_expand_prologue ()
4343 struct ix86_frame frame
;
4345 HOST_WIDE_INT allocate
;
4349 use_fast_prologue_epilogue
4350 = !expensive_function_p (FAST_PROLOGUE_INSN_COUNT
);
4351 if (TARGET_PROLOGUE_USING_MOVE
)
4352 use_mov
= use_fast_prologue_epilogue
;
4354 ix86_compute_frame_layout (&frame
);
4356 /* Note: AT&T enter does NOT have reversed args. Enter is probably
4357 slower on all targets. Also sdb doesn't like it. */
4359 if (frame_pointer_needed
)
4361 insn
= emit_insn (gen_push (hard_frame_pointer_rtx
));
4362 RTX_FRAME_RELATED_P (insn
) = 1;
4364 insn
= emit_move_insn (hard_frame_pointer_rtx
, stack_pointer_rtx
);
4365 RTX_FRAME_RELATED_P (insn
) = 1;
4368 allocate
= frame
.to_allocate
;
4369 /* In case we are dealing only with single register and empty frame,
4370 push is equivalent of the mov+add sequence. */
4371 if (allocate
== 0 && frame
.nregs
<= 1)
4375 ix86_emit_save_regs ();
4377 allocate
+= frame
.nregs
* UNITS_PER_WORD
;
4381 else if (! TARGET_STACK_PROBE
|| allocate
< CHECK_STACK_LIMIT
)
4383 insn
= emit_insn (gen_pro_epilogue_adjust_stack
4384 (stack_pointer_rtx
, stack_pointer_rtx
,
4385 GEN_INT (-allocate
)));
4386 RTX_FRAME_RELATED_P (insn
) = 1;
4390 /* ??? Is this only valid for Win32? */
4397 arg0
= gen_rtx_REG (SImode
, 0);
4398 emit_move_insn (arg0
, GEN_INT (allocate
));
4400 sym
= gen_rtx_MEM (FUNCTION_MODE
,
4401 gen_rtx_SYMBOL_REF (Pmode
, "_alloca"));
4402 insn
= emit_call_insn (gen_call (sym
, const0_rtx
, constm1_rtx
));
4404 CALL_INSN_FUNCTION_USAGE (insn
)
4405 = gen_rtx_EXPR_LIST (VOIDmode
, gen_rtx_USE (VOIDmode
, arg0
),
4406 CALL_INSN_FUNCTION_USAGE (insn
));
4410 if (!frame_pointer_needed
|| !frame
.to_allocate
)
4411 ix86_emit_save_regs_using_mov (stack_pointer_rtx
, frame
.to_allocate
);
4413 ix86_emit_save_regs_using_mov (hard_frame_pointer_rtx
,
4414 -frame
.nregs
* UNITS_PER_WORD
);
4417 #ifdef SUBTARGET_PROLOGUE
4421 pic_reg_used
= false;
4422 if (pic_offset_table_rtx
4423 && (regs_ever_live
[REAL_PIC_OFFSET_TABLE_REGNUM
]
4424 || current_function_profile
))
4426 unsigned int alt_pic_reg_used
= ix86_select_alt_pic_regnum ();
4428 if (alt_pic_reg_used
!= INVALID_REGNUM
)
4429 REGNO (pic_offset_table_rtx
) = alt_pic_reg_used
;
4431 pic_reg_used
= true;
4436 insn
= emit_insn (gen_set_got (pic_offset_table_rtx
));
4438 /* Even with accurate pre-reload life analysis, we can wind up
4439 deleting all references to the pic register after reload.
4440 Consider if cross-jumping unifies two sides of a branch
4441 controled by a comparison vs the only read from a global.
4442 In which case, allow the set_got to be deleted, though we're
4443 too late to do anything about the ebx save in the prologue. */
4444 REG_NOTES (insn
) = gen_rtx_EXPR_LIST (REG_MAYBE_DEAD
, const0_rtx
, NULL
);
4447 /* Prevent function calls from be scheduled before the call to mcount.
4448 In the pic_reg_used case, make sure that the got load isn't deleted. */
4449 if (current_function_profile
)
4450 emit_insn (gen_blockage (pic_reg_used
? pic_offset_table_rtx
: const0_rtx
));
4453 /* Emit code to restore saved registers using MOV insns. First register
4454 is restored from POINTER + OFFSET. */
4456 ix86_emit_restore_regs_using_mov (pointer
, offset
, maybe_eh_return
)
4459 int maybe_eh_return
;
4463 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
4464 if (ix86_save_reg (regno
, maybe_eh_return
))
4466 emit_move_insn (gen_rtx_REG (Pmode
, regno
),
4467 adjust_address (gen_rtx_MEM (Pmode
, pointer
),
4469 offset
+= UNITS_PER_WORD
;
4473 /* Restore function stack, frame, and registers. */
4476 ix86_expand_epilogue (style
)
4480 int sp_valid
= !frame_pointer_needed
|| current_function_sp_is_unchanging
;
4481 struct ix86_frame frame
;
4482 HOST_WIDE_INT offset
;
4484 ix86_compute_frame_layout (&frame
);
4486 /* Calculate start of saved registers relative to ebp. Special care
4487 must be taken for the normal return case of a function using
4488 eh_return: the eax and edx registers are marked as saved, but not
4489 restored along this path. */
4490 offset
= frame
.nregs
;
4491 if (current_function_calls_eh_return
&& style
!= 2)
4493 offset
*= -UNITS_PER_WORD
;
4495 /* If we're only restoring one register and sp is not valid then
4496 using a move instruction to restore the register since it's
4497 less work than reloading sp and popping the register.
4499 The default code result in stack adjustment using add/lea instruction,
4500 while this code results in LEAVE instruction (or discrete equivalent),
4501 so it is profitable in some other cases as well. Especially when there
4502 are no registers to restore. We also use this code when TARGET_USE_LEAVE
4503 and there is exactly one register to pop. This heruistic may need some
4504 tuning in future. */
4505 if ((!sp_valid
&& frame
.nregs
<= 1)
4506 || (TARGET_EPILOGUE_USING_MOVE
4507 && use_fast_prologue_epilogue
4508 && (frame
.nregs
> 1 || frame
.to_allocate
))
4509 || (frame_pointer_needed
&& !frame
.nregs
&& frame
.to_allocate
)
4510 || (frame_pointer_needed
&& TARGET_USE_LEAVE
4511 && use_fast_prologue_epilogue
&& frame
.nregs
== 1)
4512 || current_function_calls_eh_return
)
4514 /* Restore registers. We can use ebp or esp to address the memory
4515 locations. If both are available, default to ebp, since offsets
4516 are known to be small. Only exception is esp pointing directly to the
4517 end of block of saved registers, where we may simplify addressing
4520 if (!frame_pointer_needed
|| (sp_valid
&& !frame
.to_allocate
))
4521 ix86_emit_restore_regs_using_mov (stack_pointer_rtx
,
4522 frame
.to_allocate
, style
== 2);
4524 ix86_emit_restore_regs_using_mov (hard_frame_pointer_rtx
,
4525 offset
, style
== 2);
4527 /* eh_return epilogues need %ecx added to the stack pointer. */
4530 rtx tmp
, sa
= EH_RETURN_STACKADJ_RTX
;
4532 if (frame_pointer_needed
)
4534 tmp
= gen_rtx_PLUS (Pmode
, hard_frame_pointer_rtx
, sa
);
4535 tmp
= plus_constant (tmp
, UNITS_PER_WORD
);
4536 emit_insn (gen_rtx_SET (VOIDmode
, sa
, tmp
));
4538 tmp
= gen_rtx_MEM (Pmode
, hard_frame_pointer_rtx
);
4539 emit_move_insn (hard_frame_pointer_rtx
, tmp
);
4541 emit_insn (gen_pro_epilogue_adjust_stack
4542 (stack_pointer_rtx
, sa
, const0_rtx
));
4546 tmp
= gen_rtx_PLUS (Pmode
, stack_pointer_rtx
, sa
);
4547 tmp
= plus_constant (tmp
, (frame
.to_allocate
4548 + frame
.nregs
* UNITS_PER_WORD
));
4549 emit_insn (gen_rtx_SET (VOIDmode
, stack_pointer_rtx
, tmp
));
4552 else if (!frame_pointer_needed
)
4553 emit_insn (gen_pro_epilogue_adjust_stack
4554 (stack_pointer_rtx
, stack_pointer_rtx
,
4555 GEN_INT (frame
.to_allocate
4556 + frame
.nregs
* UNITS_PER_WORD
)));
4557 /* If not an i386, mov & pop is faster than "leave". */
4558 else if (TARGET_USE_LEAVE
|| optimize_size
|| !use_fast_prologue_epilogue
)
4559 emit_insn (TARGET_64BIT
? gen_leave_rex64 () : gen_leave ());
4562 emit_insn (gen_pro_epilogue_adjust_stack (stack_pointer_rtx
,
4563 hard_frame_pointer_rtx
,
4566 emit_insn (gen_popdi1 (hard_frame_pointer_rtx
));
4568 emit_insn (gen_popsi1 (hard_frame_pointer_rtx
));
4573 /* First step is to deallocate the stack frame so that we can
4574 pop the registers. */
4577 if (!frame_pointer_needed
)
4579 emit_insn (gen_pro_epilogue_adjust_stack (stack_pointer_rtx
,
4580 hard_frame_pointer_rtx
,
4583 else if (frame
.to_allocate
)
4584 emit_insn (gen_pro_epilogue_adjust_stack
4585 (stack_pointer_rtx
, stack_pointer_rtx
,
4586 GEN_INT (frame
.to_allocate
)));
4588 for (regno
= 0; regno
< FIRST_PSEUDO_REGISTER
; regno
++)
4589 if (ix86_save_reg (regno
, false))
4592 emit_insn (gen_popdi1 (gen_rtx_REG (Pmode
, regno
)));
4594 emit_insn (gen_popsi1 (gen_rtx_REG (Pmode
, regno
)));
4596 if (frame_pointer_needed
)
4598 /* Leave results in shorter dependency chains on CPUs that are
4599 able to grok it fast. */
4600 if (TARGET_USE_LEAVE
)
4601 emit_insn (TARGET_64BIT
? gen_leave_rex64 () : gen_leave ());
4602 else if (TARGET_64BIT
)
4603 emit_insn (gen_popdi1 (hard_frame_pointer_rtx
));
4605 emit_insn (gen_popsi1 (hard_frame_pointer_rtx
));
4609 /* Sibcall epilogues don't want a return instruction. */
4613 if (current_function_pops_args
&& current_function_args_size
)
4615 rtx popc
= GEN_INT (current_function_pops_args
);
4617 /* i386 can only pop 64K bytes. If asked to pop more, pop
4618 return address, do explicit add, and jump indirectly to the
4621 if (current_function_pops_args
>= 65536)
4623 rtx ecx
= gen_rtx_REG (SImode
, 2);
4625 /* There are is no "pascal" calling convention in 64bit ABI. */
4629 emit_insn (gen_popsi1 (ecx
));
4630 emit_insn (gen_addsi3 (stack_pointer_rtx
, stack_pointer_rtx
, popc
));
4631 emit_jump_insn (gen_return_indirect_internal (ecx
));
4634 emit_jump_insn (gen_return_pop_internal (popc
));
4637 emit_jump_insn (gen_return_internal ());
4640 /* Reset from the function's potential modifications. */
4643 ix86_output_function_epilogue (file
, size
)
4644 FILE *file ATTRIBUTE_UNUSED
;
4645 HOST_WIDE_INT size ATTRIBUTE_UNUSED
;
4647 if (pic_offset_table_rtx
)
4648 REGNO (pic_offset_table_rtx
) = REAL_PIC_OFFSET_TABLE_REGNUM
;
4651 /* Extract the parts of an RTL expression that is a valid memory address
4652 for an instruction. Return 0 if the structure of the address is
4653 grossly off. Return -1 if the address contains ASHIFT, so it is not
4654 strictly valid, but still used for computing length of lea instruction.
4658 ix86_decompose_address (addr
, out
)
4660 struct ix86_address
*out
;
4662 rtx base
= NULL_RTX
;
4663 rtx index
= NULL_RTX
;
4664 rtx disp
= NULL_RTX
;
4665 HOST_WIDE_INT scale
= 1;
4666 rtx scale_rtx
= NULL_RTX
;
4669 if (REG_P (addr
) || GET_CODE (addr
) == SUBREG
)
4671 else if (GET_CODE (addr
) == PLUS
)
4673 rtx op0
= XEXP (addr
, 0);
4674 rtx op1
= XEXP (addr
, 1);
4675 enum rtx_code code0
= GET_CODE (op0
);
4676 enum rtx_code code1
= GET_CODE (op1
);
4678 if (code0
== REG
|| code0
== SUBREG
)
4680 if (code1
== REG
|| code1
== SUBREG
)
4681 index
= op0
, base
= op1
; /* index + base */
4683 base
= op0
, disp
= op1
; /* base + displacement */
4685 else if (code0
== MULT
)
4687 index
= XEXP (op0
, 0);
4688 scale_rtx
= XEXP (op0
, 1);
4689 if (code1
== REG
|| code1
== SUBREG
)
4690 base
= op1
; /* index*scale + base */
4692 disp
= op1
; /* index*scale + disp */
4694 else if (code0
== PLUS
&& GET_CODE (XEXP (op0
, 0)) == MULT
)
4696 index
= XEXP (XEXP (op0
, 0), 0); /* index*scale + base + disp */
4697 scale_rtx
= XEXP (XEXP (op0
, 0), 1);
4698 base
= XEXP (op0
, 1);
4701 else if (code0
== PLUS
)
4703 index
= XEXP (op0
, 0); /* index + base + disp */
4704 base
= XEXP (op0
, 1);
4710 else if (GET_CODE (addr
) == MULT
)
4712 index
= XEXP (addr
, 0); /* index*scale */
4713 scale_rtx
= XEXP (addr
, 1);
4715 else if (GET_CODE (addr
) == ASHIFT
)
4719 /* We're called for lea too, which implements ashift on occasion. */
4720 index
= XEXP (addr
, 0);
4721 tmp
= XEXP (addr
, 1);
4722 if (GET_CODE (tmp
) != CONST_INT
)
4724 scale
= INTVAL (tmp
);
4725 if ((unsigned HOST_WIDE_INT
) scale
> 3)
4731 disp
= addr
; /* displacement */
4733 /* Extract the integral value of scale. */
4736 if (GET_CODE (scale_rtx
) != CONST_INT
)
4738 scale
= INTVAL (scale_rtx
);
4741 /* Allow arg pointer and stack pointer as index if there is not scaling */
4742 if (base
&& index
&& scale
== 1
4743 && (index
== arg_pointer_rtx
|| index
== frame_pointer_rtx
4744 || index
== stack_pointer_rtx
))
4751 /* Special case: %ebp cannot be encoded as a base without a displacement. */
4752 if ((base
== hard_frame_pointer_rtx
4753 || base
== frame_pointer_rtx
4754 || base
== arg_pointer_rtx
) && !disp
)
4757 /* Special case: on K6, [%esi] makes the instruction vector decoded.
4758 Avoid this by transforming to [%esi+0]. */
4759 if (ix86_cpu
== PROCESSOR_K6
&& !optimize_size
4760 && base
&& !index
&& !disp
4762 && REGNO_REG_CLASS (REGNO (base
)) == SIREG
)
4765 /* Special case: encode reg+reg instead of reg*2. */
4766 if (!base
&& index
&& scale
&& scale
== 2)
4767 base
= index
, scale
= 1;
4769 /* Special case: scaling cannot be encoded without base or displacement. */
4770 if (!base
&& !disp
&& index
&& scale
!= 1)
4781 /* Return cost of the memory address x.
4782 For i386, it is better to use a complex address than let gcc copy
4783 the address into a reg and make a new pseudo. But not if the address
4784 requires to two regs - that would mean more pseudos with longer
4787 ix86_address_cost (x
)
4790 struct ix86_address parts
;
4793 if (!ix86_decompose_address (x
, &parts
))
4796 if (parts
.base
&& GET_CODE (parts
.base
) == SUBREG
)
4797 parts
.base
= SUBREG_REG (parts
.base
);
4798 if (parts
.index
&& GET_CODE (parts
.index
) == SUBREG
)
4799 parts
.index
= SUBREG_REG (parts
.index
);
4801 /* More complex memory references are better. */
4802 if (parts
.disp
&& parts
.disp
!= const0_rtx
)
4805 /* Attempt to minimize number of registers in the address. */
4807 && (!REG_P (parts
.base
) || REGNO (parts
.base
) >= FIRST_PSEUDO_REGISTER
))
4809 && (!REG_P (parts
.index
)
4810 || REGNO (parts
.index
) >= FIRST_PSEUDO_REGISTER
)))
4814 && (!REG_P (parts
.base
) || REGNO (parts
.base
) >= FIRST_PSEUDO_REGISTER
)
4816 && (!REG_P (parts
.index
) || REGNO (parts
.index
) >= FIRST_PSEUDO_REGISTER
)
4817 && parts
.base
!= parts
.index
)
4820 /* AMD-K6 don't like addresses with ModR/M set to 00_xxx_100b,
4821 since it's predecode logic can't detect the length of instructions
4822 and it degenerates to vector decoded. Increase cost of such
4823 addresses here. The penalty is minimally 2 cycles. It may be worthwhile
4824 to split such addresses or even refuse such addresses at all.
4826 Following addressing modes are affected:
4831 The first and last case may be avoidable by explicitly coding the zero in
4832 memory address, but I don't have AMD-K6 machine handy to check this
4836 && ((!parts
.disp
&& parts
.base
&& parts
.index
&& parts
.scale
!= 1)
4837 || (parts
.disp
&& !parts
.base
&& parts
.index
&& parts
.scale
!= 1)
4838 || (!parts
.disp
&& parts
.base
&& parts
.index
&& parts
.scale
== 1)))
4844 /* If X is a machine specific address (i.e. a symbol or label being
4845 referenced as a displacement from the GOT implemented using an
4846 UNSPEC), then return the base term. Otherwise return X. */
4849 ix86_find_base_term (x
)
4856 if (GET_CODE (x
) != CONST
)
4859 if (GET_CODE (term
) == PLUS
4860 && (GET_CODE (XEXP (term
, 1)) == CONST_INT
4861 || GET_CODE (XEXP (term
, 1)) == CONST_DOUBLE
))
4862 term
= XEXP (term
, 0);
4863 if (GET_CODE (term
) != UNSPEC
4864 || XINT (term
, 1) != UNSPEC_GOTPCREL
)
4867 term
= XVECEXP (term
, 0, 0);
4869 if (GET_CODE (term
) != SYMBOL_REF
4870 && GET_CODE (term
) != LABEL_REF
)
4876 if (GET_CODE (x
) != PLUS
4877 || XEXP (x
, 0) != pic_offset_table_rtx
4878 || GET_CODE (XEXP (x
, 1)) != CONST
)
4881 term
= XEXP (XEXP (x
, 1), 0);
4883 if (GET_CODE (term
) == PLUS
&& GET_CODE (XEXP (term
, 1)) == CONST_INT
)
4884 term
= XEXP (term
, 0);
4886 if (GET_CODE (term
) != UNSPEC
4887 || XINT (term
, 1) != UNSPEC_GOTOFF
)
4890 term
= XVECEXP (term
, 0, 0);
4892 if (GET_CODE (term
) != SYMBOL_REF
4893 && GET_CODE (term
) != LABEL_REF
)
4899 /* Determine if a given RTX is a valid constant. We already know this
4900 satisfies CONSTANT_P. */
4903 legitimate_constant_p (x
)
4908 switch (GET_CODE (x
))
4911 /* TLS symbols are not constant. */
4912 if (tls_symbolic_operand (x
, Pmode
))
4917 inner
= XEXP (x
, 0);
4919 /* Offsets of TLS symbols are never valid.
4920 Discourage CSE from creating them. */
4921 if (GET_CODE (inner
) == PLUS
4922 && tls_symbolic_operand (XEXP (inner
, 0), Pmode
))
4925 /* Only some unspecs are valid as "constants". */
4926 if (GET_CODE (inner
) == UNSPEC
)
4927 switch (XINT (inner
, 1))
4930 return local_exec_symbolic_operand (XVECEXP (inner
, 0, 0), Pmode
);
4940 /* Otherwise we handle everything else in the move patterns. */
4944 /* Determine if a given RTX is a valid constant address. */
4947 constant_address_p (x
)
4950 switch (GET_CODE (x
))
4957 return TARGET_64BIT
;
4960 /* For Mach-O, really believe the CONST. */
4963 /* Otherwise fall through. */
4965 return !flag_pic
&& legitimate_constant_p (x
);
4972 /* Nonzero if the constant value X is a legitimate general operand
4973 when generating PIC code. It is given that flag_pic is on and
4974 that X satisfies CONSTANT_P or is a CONST_DOUBLE. */
4977 legitimate_pic_operand_p (x
)
4982 switch (GET_CODE (x
))
4985 inner
= XEXP (x
, 0);
4987 /* Only some unspecs are valid as "constants". */
4988 if (GET_CODE (inner
) == UNSPEC
)
4989 switch (XINT (inner
, 1))
4992 return local_exec_symbolic_operand (XVECEXP (inner
, 0, 0), Pmode
);
5000 return legitimate_pic_address_disp_p (x
);
5007 /* Determine if a given CONST RTX is a valid memory displacement
5011 legitimate_pic_address_disp_p (disp
)
5016 /* In 64bit mode we can allow direct addresses of symbols and labels
5017 when they are not dynamic symbols. */
5021 if (GET_CODE (disp
) == CONST
)
5023 /* ??? Handle PIC code models */
5024 if (GET_CODE (x
) == PLUS
5025 && (GET_CODE (XEXP (x
, 1)) == CONST_INT
5026 && ix86_cmodel
== CM_SMALL_PIC
5027 && INTVAL (XEXP (x
, 1)) < 1024*1024*1024
5028 && INTVAL (XEXP (x
, 1)) > -1024*1024*1024))
5030 if (local_symbolic_operand (x
, Pmode
))
5033 if (GET_CODE (disp
) != CONST
)
5035 disp
= XEXP (disp
, 0);
5039 /* We are unsafe to allow PLUS expressions. This limit allowed distance
5040 of GOT tables. We should not need these anyway. */
5041 if (GET_CODE (disp
) != UNSPEC
5042 || XINT (disp
, 1) != UNSPEC_GOTPCREL
)
5045 if (GET_CODE (XVECEXP (disp
, 0, 0)) != SYMBOL_REF
5046 && GET_CODE (XVECEXP (disp
, 0, 0)) != LABEL_REF
)
5052 if (GET_CODE (disp
) == PLUS
)
5054 if (GET_CODE (XEXP (disp
, 1)) != CONST_INT
)
5056 disp
= XEXP (disp
, 0);
5060 /* Allow {LABEL | SYMBOL}_REF - SYMBOL_REF-FOR-PICBASE for Mach-O. */
5061 if (TARGET_MACHO
&& GET_CODE (disp
) == MINUS
)
5063 if (GET_CODE (XEXP (disp
, 0)) == LABEL_REF
5064 || GET_CODE (XEXP (disp
, 0)) == SYMBOL_REF
)
5065 if (GET_CODE (XEXP (disp
, 1)) == SYMBOL_REF
)
5067 const char *sym_name
= XSTR (XEXP (disp
, 1), 0);
5068 if (strstr (sym_name
, "$pb") != 0)
5073 if (GET_CODE (disp
) != UNSPEC
)
5076 switch (XINT (disp
, 1))
5081 return GET_CODE (XVECEXP (disp
, 0, 0)) == SYMBOL_REF
;
5083 return local_symbolic_operand (XVECEXP (disp
, 0, 0), Pmode
);
5084 case UNSPEC_GOTTPOFF
:
5085 case UNSPEC_GOTNTPOFF
:
5086 case UNSPEC_INDNTPOFF
:
5089 return initial_exec_symbolic_operand (XVECEXP (disp
, 0, 0), Pmode
);
5091 return local_exec_symbolic_operand (XVECEXP (disp
, 0, 0), Pmode
);
5093 return local_dynamic_symbolic_operand (XVECEXP (disp
, 0, 0), Pmode
);
5099 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression that is a valid
5100 memory address for an instruction. The MODE argument is the machine mode
5101 for the MEM expression that wants to use this address.
5103 It only recognizes address in canonical form. LEGITIMIZE_ADDRESS should
5104 convert common non-canonical forms to canonical form so that they will
5108 legitimate_address_p (mode
, addr
, strict
)
5109 enum machine_mode mode
;
5113 struct ix86_address parts
;
5114 rtx base
, index
, disp
;
5115 HOST_WIDE_INT scale
;
5116 const char *reason
= NULL
;
5117 rtx reason_rtx
= NULL_RTX
;
5119 if (TARGET_DEBUG_ADDR
)
5122 "\n======\nGO_IF_LEGITIMATE_ADDRESS, mode = %s, strict = %d\n",
5123 GET_MODE_NAME (mode
), strict
);
5127 if (GET_CODE (addr
) == UNSPEC
&& XINT (addr
, 1) == UNSPEC_TP
)
5129 if (TARGET_DEBUG_ADDR
)
5130 fprintf (stderr
, "Success.\n");
5134 if (ix86_decompose_address (addr
, &parts
) <= 0)
5136 reason
= "decomposition failed";
5141 index
= parts
.index
;
5143 scale
= parts
.scale
;
5145 /* Validate base register.
5147 Don't allow SUBREG's here, it can lead to spill failures when the base
5148 is one word out of a two word structure, which is represented internally
5156 if (GET_CODE (base
) == SUBREG
)
5157 reg
= SUBREG_REG (base
);
5161 if (GET_CODE (reg
) != REG
)
5163 reason
= "base is not a register";
5167 if (GET_MODE (base
) != Pmode
)
5169 reason
= "base is not in Pmode";
5173 if ((strict
&& ! REG_OK_FOR_BASE_STRICT_P (reg
))
5174 || (! strict
&& ! REG_OK_FOR_BASE_NONSTRICT_P (reg
)))
5176 reason
= "base is not valid";
5181 /* Validate index register.
5183 Don't allow SUBREG's here, it can lead to spill failures when the index
5184 is one word out of a two word structure, which is represented internally
5192 if (GET_CODE (index
) == SUBREG
)
5193 reg
= SUBREG_REG (index
);
5197 if (GET_CODE (reg
) != REG
)
5199 reason
= "index is not a register";
5203 if (GET_MODE (index
) != Pmode
)
5205 reason
= "index is not in Pmode";
5209 if ((strict
&& ! REG_OK_FOR_INDEX_STRICT_P (reg
))
5210 || (! strict
&& ! REG_OK_FOR_INDEX_NONSTRICT_P (reg
)))
5212 reason
= "index is not valid";
5217 /* Validate scale factor. */
5220 reason_rtx
= GEN_INT (scale
);
5223 reason
= "scale without index";
5227 if (scale
!= 2 && scale
!= 4 && scale
!= 8)
5229 reason
= "scale is not a valid multiplier";
5234 /* Validate displacement. */
5241 if (!x86_64_sign_extended_value (disp
))
5243 reason
= "displacement is out of range";
5249 if (GET_CODE (disp
) == CONST_DOUBLE
)
5251 reason
= "displacement is a const_double";
5256 if (GET_CODE (disp
) == CONST
5257 && GET_CODE (XEXP (disp
, 0)) == UNSPEC
)
5258 switch (XINT (XEXP (disp
, 0), 1))
5262 case UNSPEC_GOTPCREL
:
5265 goto is_legitimate_pic
;
5267 case UNSPEC_GOTTPOFF
:
5268 case UNSPEC_GOTNTPOFF
:
5269 case UNSPEC_INDNTPOFF
:
5275 reason
= "invalid address unspec";
5279 else if (flag_pic
&& (SYMBOLIC_CONST (disp
)
5281 && !machopic_operand_p (disp
)
5286 if (TARGET_64BIT
&& (index
|| base
))
5288 reason
= "non-constant pic memory reference";
5291 if (! legitimate_pic_address_disp_p (disp
))
5293 reason
= "displacement is an invalid pic construct";
5297 /* This code used to verify that a symbolic pic displacement
5298 includes the pic_offset_table_rtx register.
5300 While this is good idea, unfortunately these constructs may
5301 be created by "adds using lea" optimization for incorrect
5310 This code is nonsensical, but results in addressing
5311 GOT table with pic_offset_table_rtx base. We can't
5312 just refuse it easily, since it gets matched by
5313 "addsi3" pattern, that later gets split to lea in the
5314 case output register differs from input. While this
5315 can be handled by separate addsi pattern for this case
5316 that never results in lea, this seems to be easier and
5317 correct fix for crash to disable this test. */
5319 else if (!CONSTANT_ADDRESS_P (disp
))
5321 reason
= "displacement is not constant";
5326 /* Everything looks valid. */
5327 if (TARGET_DEBUG_ADDR
)
5328 fprintf (stderr
, "Success.\n");
5332 if (TARGET_DEBUG_ADDR
)
5334 fprintf (stderr
, "Error: %s\n", reason
);
5335 debug_rtx (reason_rtx
);
5340 /* Return an unique alias set for the GOT. */
5342 static HOST_WIDE_INT
5343 ix86_GOT_alias_set ()
5345 static HOST_WIDE_INT set
= -1;
5347 set
= new_alias_set ();
5351 /* Return a legitimate reference for ORIG (an address) using the
5352 register REG. If REG is 0, a new pseudo is generated.
5354 There are two types of references that must be handled:
5356 1. Global data references must load the address from the GOT, via
5357 the PIC reg. An insn is emitted to do this load, and the reg is
5360 2. Static data references, constant pool addresses, and code labels
5361 compute the address as an offset from the GOT, whose base is in
5362 the PIC reg. Static data objects have SYMBOL_REF_FLAG set to
5363 differentiate them from global data objects. The returned
5364 address is the PIC reg + an unspec constant.
5366 GO_IF_LEGITIMATE_ADDRESS rejects symbolic references unless the PIC
5367 reg also appears in the address. */
5370 legitimize_pic_address (orig
, reg
)
5380 reg
= gen_reg_rtx (Pmode
);
5381 /* Use the generic Mach-O PIC machinery. */
5382 return machopic_legitimize_pic_address (orig
, GET_MODE (orig
), reg
);
5385 if (local_symbolic_operand (addr
, Pmode
))
5387 /* In 64bit mode we can address such objects directly. */
5392 /* This symbol may be referenced via a displacement from the PIC
5393 base address (@GOTOFF). */
5395 if (reload_in_progress
)
5396 regs_ever_live
[PIC_OFFSET_TABLE_REGNUM
] = 1;
5397 new = gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, addr
), UNSPEC_GOTOFF
);
5398 new = gen_rtx_CONST (Pmode
, new);
5399 new = gen_rtx_PLUS (Pmode
, pic_offset_table_rtx
, new);
5403 emit_move_insn (reg
, new);
5408 else if (GET_CODE (addr
) == SYMBOL_REF
)
5412 new = gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, addr
), UNSPEC_GOTPCREL
);
5413 new = gen_rtx_CONST (Pmode
, new);
5414 new = gen_rtx_MEM (Pmode
, new);
5415 RTX_UNCHANGING_P (new) = 1;
5416 set_mem_alias_set (new, ix86_GOT_alias_set ());
5419 reg
= gen_reg_rtx (Pmode
);
5420 /* Use directly gen_movsi, otherwise the address is loaded
5421 into register for CSE. We don't want to CSE this addresses,
5422 instead we CSE addresses from the GOT table, so skip this. */
5423 emit_insn (gen_movsi (reg
, new));
5428 /* This symbol must be referenced via a load from the
5429 Global Offset Table (@GOT). */
5431 if (reload_in_progress
)
5432 regs_ever_live
[PIC_OFFSET_TABLE_REGNUM
] = 1;
5433 new = gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, addr
), UNSPEC_GOT
);
5434 new = gen_rtx_CONST (Pmode
, new);
5435 new = gen_rtx_PLUS (Pmode
, pic_offset_table_rtx
, new);
5436 new = gen_rtx_MEM (Pmode
, new);
5437 RTX_UNCHANGING_P (new) = 1;
5438 set_mem_alias_set (new, ix86_GOT_alias_set ());
5441 reg
= gen_reg_rtx (Pmode
);
5442 emit_move_insn (reg
, new);
5448 if (GET_CODE (addr
) == CONST
)
5450 addr
= XEXP (addr
, 0);
5452 /* We must match stuff we generate before. Assume the only
5453 unspecs that can get here are ours. Not that we could do
5454 anything with them anyway... */
5455 if (GET_CODE (addr
) == UNSPEC
5456 || (GET_CODE (addr
) == PLUS
5457 && GET_CODE (XEXP (addr
, 0)) == UNSPEC
))
5459 if (GET_CODE (addr
) != PLUS
)
5462 if (GET_CODE (addr
) == PLUS
)
5464 rtx op0
= XEXP (addr
, 0), op1
= XEXP (addr
, 1);
5466 /* Check first to see if this is a constant offset from a @GOTOFF
5467 symbol reference. */
5468 if (local_symbolic_operand (op0
, Pmode
)
5469 && GET_CODE (op1
) == CONST_INT
)
5473 if (reload_in_progress
)
5474 regs_ever_live
[PIC_OFFSET_TABLE_REGNUM
] = 1;
5475 new = gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, op0
),
5477 new = gen_rtx_PLUS (Pmode
, new, op1
);
5478 new = gen_rtx_CONST (Pmode
, new);
5479 new = gen_rtx_PLUS (Pmode
, pic_offset_table_rtx
, new);
5483 emit_move_insn (reg
, new);
5489 /* ??? We need to limit offsets here. */
5494 base
= legitimize_pic_address (XEXP (addr
, 0), reg
);
5495 new = legitimize_pic_address (XEXP (addr
, 1),
5496 base
== reg
? NULL_RTX
: reg
);
5498 if (GET_CODE (new) == CONST_INT
)
5499 new = plus_constant (base
, INTVAL (new));
5502 if (GET_CODE (new) == PLUS
&& CONSTANT_P (XEXP (new, 1)))
5504 base
= gen_rtx_PLUS (Pmode
, base
, XEXP (new, 0));
5505 new = XEXP (new, 1);
5507 new = gen_rtx_PLUS (Pmode
, base
, new);
5516 ix86_encode_section_info (decl
, first
)
5518 int first ATTRIBUTE_UNUSED
;
5520 bool local_p
= (*targetm
.binds_local_p
) (decl
);
5523 rtl
= DECL_P (decl
) ? DECL_RTL (decl
) : TREE_CST_RTL (decl
);
5524 if (GET_CODE (rtl
) != MEM
)
5526 symbol
= XEXP (rtl
, 0);
5527 if (GET_CODE (symbol
) != SYMBOL_REF
)
5530 /* For basic x86, if using PIC, mark a SYMBOL_REF for a non-global
5531 symbol so that we may access it directly in the GOT. */
5534 SYMBOL_REF_FLAG (symbol
) = local_p
;
5536 /* For ELF, encode thread-local data with %[GLil] for "global dynamic",
5537 "local dynamic", "initial exec" or "local exec" TLS models
5540 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_THREAD_LOCAL (decl
))
5542 const char *symbol_str
;
5545 enum tls_model kind
;
5550 kind
= TLS_MODEL_LOCAL_EXEC
;
5552 kind
= TLS_MODEL_INITIAL_EXEC
;
5554 /* Local dynamic is inefficient when we're not combining the
5555 parts of the address. */
5556 else if (optimize
&& local_p
)
5557 kind
= TLS_MODEL_LOCAL_DYNAMIC
;
5559 kind
= TLS_MODEL_GLOBAL_DYNAMIC
;
5560 if (kind
< flag_tls_default
)
5561 kind
= flag_tls_default
;
5563 symbol_str
= XSTR (symbol
, 0);
5565 if (symbol_str
[0] == '%')
5567 if (symbol_str
[1] == tls_model_chars
[kind
])
5571 len
= strlen (symbol_str
) + 1;
5572 newstr
= alloca (len
+ 2);
5575 newstr
[1] = tls_model_chars
[kind
];
5576 memcpy (newstr
+ 2, symbol_str
, len
);
5578 XSTR (symbol
, 0) = ggc_alloc_string (newstr
, len
+ 2 - 1);
5582 /* Undo the above when printing symbol names. */
5585 ix86_strip_name_encoding (str
)
5595 /* Load the thread pointer into a register. */
5598 get_thread_pointer ()
5602 tp
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, const0_rtx
), UNSPEC_TP
);
5603 tp
= gen_rtx_MEM (Pmode
, tp
);
5604 RTX_UNCHANGING_P (tp
) = 1;
5605 set_mem_alias_set (tp
, ix86_GOT_alias_set ());
5606 tp
= force_reg (Pmode
, tp
);
5611 /* Try machine-dependent ways of modifying an illegitimate address
5612 to be legitimate. If we find one, return the new, valid address.
5613 This macro is used in only one place: `memory_address' in explow.c.
5615 OLDX is the address as it was before break_out_memory_refs was called.
5616 In some cases it is useful to look at this to decide what needs to be done.
5618 MODE and WIN are passed so that this macro can use
5619 GO_IF_LEGITIMATE_ADDRESS.
5621 It is always safe for this macro to do nothing. It exists to recognize
5622 opportunities to optimize the output.
5624 For the 80386, we handle X+REG by loading X into a register R and
5625 using R+REG. R will go in a general reg and indexing will be used.
5626 However, if REG is a broken-out memory address or multiplication,
5627 nothing needs to be done because REG can certainly go in a general reg.
5629 When -fpic is used, special handling is needed for symbolic references.
5630 See comments by legitimize_pic_address in i386.c for details. */
5633 legitimize_address (x
, oldx
, mode
)
5635 register rtx oldx ATTRIBUTE_UNUSED
;
5636 enum machine_mode mode
;
5641 if (TARGET_DEBUG_ADDR
)
5643 fprintf (stderr
, "\n==========\nLEGITIMIZE_ADDRESS, mode = %s\n",
5644 GET_MODE_NAME (mode
));
5648 log
= tls_symbolic_operand (x
, mode
);
5651 rtx dest
, base
, off
, pic
;
5655 case TLS_MODEL_GLOBAL_DYNAMIC
:
5656 dest
= gen_reg_rtx (Pmode
);
5657 emit_insn (gen_tls_global_dynamic (dest
, x
));
5660 case TLS_MODEL_LOCAL_DYNAMIC
:
5661 base
= gen_reg_rtx (Pmode
);
5662 emit_insn (gen_tls_local_dynamic_base (base
));
5664 off
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, x
), UNSPEC_DTPOFF
);
5665 off
= gen_rtx_CONST (Pmode
, off
);
5667 return gen_rtx_PLUS (Pmode
, base
, off
);
5669 case TLS_MODEL_INITIAL_EXEC
:
5672 if (reload_in_progress
)
5673 regs_ever_live
[PIC_OFFSET_TABLE_REGNUM
] = 1;
5674 pic
= pic_offset_table_rtx
;
5676 else if (!TARGET_GNU_TLS
)
5678 pic
= gen_reg_rtx (Pmode
);
5679 emit_insn (gen_set_got (pic
));
5684 base
= get_thread_pointer ();
5686 off
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, x
),
5689 : flag_pic
? UNSPEC_GOTNTPOFF
5690 : UNSPEC_INDNTPOFF
);
5691 off
= gen_rtx_CONST (Pmode
, off
);
5692 if (flag_pic
|| !TARGET_GNU_TLS
)
5693 off
= gen_rtx_PLUS (Pmode
, pic
, off
);
5694 off
= gen_rtx_MEM (Pmode
, off
);
5695 RTX_UNCHANGING_P (off
) = 1;
5696 set_mem_alias_set (off
, ix86_GOT_alias_set ());
5697 dest
= gen_reg_rtx (Pmode
);
5701 emit_move_insn (dest
, off
);
5702 return gen_rtx_PLUS (Pmode
, base
, dest
);
5705 emit_insn (gen_subsi3 (dest
, base
, off
));
5708 case TLS_MODEL_LOCAL_EXEC
:
5709 base
= get_thread_pointer ();
5711 off
= gen_rtx_UNSPEC (Pmode
, gen_rtvec (1, x
),
5712 TARGET_GNU_TLS
? UNSPEC_NTPOFF
: UNSPEC_TPOFF
);
5713 off
= gen_rtx_CONST (Pmode
, off
);
5716 return gen_rtx_PLUS (Pmode
, base
, off
);
5719 dest
= gen_reg_rtx (Pmode
);
5720 emit_insn (gen_subsi3 (dest
, base
, off
));
5731 if (flag_pic
&& SYMBOLIC_CONST (x
))
5732 return legitimize_pic_address (x
, 0);
5734 /* Canonicalize shifts by 0, 1, 2, 3 into multiply */
5735 if (GET_CODE (x
) == ASHIFT
5736 && GET_CODE (XEXP (x
, 1)) == CONST_INT
5737 && (log
= (unsigned) exact_log2 (INTVAL (XEXP (x
, 1)))) < 4)
5740 x
= gen_rtx_MULT (Pmode
, force_reg (Pmode
, XEXP (x
, 0)),
5741 GEN_INT (1 << log
));
5744 if (GET_CODE (x
) == PLUS
)
5746 /* Canonicalize shifts by 0, 1, 2, 3 into multiply. */
5748 if (GET_CODE (XEXP (x
, 0)) == ASHIFT
5749 && GET_CODE (XEXP (XEXP (x
, 0), 1)) == CONST_INT
5750 && (log
= (unsigned) exact_log2 (INTVAL (XEXP (XEXP (x
, 0), 1)))) < 4)
5753 XEXP (x
, 0) = gen_rtx_MULT (Pmode
,
5754 force_reg (Pmode
, XEXP (XEXP (x
, 0), 0)),
5755 GEN_INT (1 << log
));
5758 if (GET_CODE (XEXP (x
, 1)) == ASHIFT
5759 && GET_CODE (XEXP (XEXP (x
, 1), 1)) == CONST_INT
5760 && (log
= (unsigned) exact_log2 (INTVAL (XEXP (XEXP (x
, 1), 1)))) < 4)
5763 XEXP (x
, 1) = gen_rtx_MULT (Pmode
,
5764 force_reg (Pmode
, XEXP (XEXP (x
, 1), 0)),
5765 GEN_INT (1 << log
));
5768 /* Put multiply first if it isn't already. */
5769 if (GET_CODE (XEXP (x
, 1)) == MULT
)
5771 rtx tmp
= XEXP (x
, 0);
5772 XEXP (x
, 0) = XEXP (x
, 1);
5777 /* Canonicalize (plus (mult (reg) (const)) (plus (reg) (const)))
5778 into (plus (plus (mult (reg) (const)) (reg)) (const)). This can be
5779 created by virtual register instantiation, register elimination, and
5780 similar optimizations. */
5781 if (GET_CODE (XEXP (x
, 0)) == MULT
&& GET_CODE (XEXP (x
, 1)) == PLUS
)
5784 x
= gen_rtx_PLUS (Pmode
,
5785 gen_rtx_PLUS (Pmode
, XEXP (x
, 0),
5786 XEXP (XEXP (x
, 1), 0)),
5787 XEXP (XEXP (x
, 1), 1));
5791 (plus (plus (mult (reg) (const)) (plus (reg) (const))) const)
5792 into (plus (plus (mult (reg) (const)) (reg)) (const)). */
5793 else if (GET_CODE (x
) == PLUS
&& GET_CODE (XEXP (x
, 0)) == PLUS
5794 && GET_CODE (XEXP (XEXP (x
, 0), 0)) == MULT
5795 && GET_CODE (XEXP (XEXP (x
, 0), 1)) == PLUS
5796 && CONSTANT_P (XEXP (x
, 1)))
5799 rtx other
= NULL_RTX
;
5801 if (GET_CODE (XEXP (x
, 1)) == CONST_INT
)
5803 constant
= XEXP (x
, 1);
5804 other
= XEXP (XEXP (XEXP (x
, 0), 1), 1);
5806 else if (GET_CODE (XEXP (XEXP (XEXP (x
, 0), 1), 1)) == CONST_INT
)
5808 constant
= XEXP (XEXP (XEXP (x
, 0), 1), 1);
5809 other
= XEXP (x
, 1);
5817 x
= gen_rtx_PLUS (Pmode
,
5818 gen_rtx_PLUS (Pmode
, XEXP (XEXP (x
, 0), 0),
5819 XEXP (XEXP (XEXP (x
, 0), 1), 0)),
5820 plus_constant (other
, INTVAL (constant
)));
5824 if (changed
&& legitimate_address_p (mode
, x
, FALSE
))
5827 if (GET_CODE (XEXP (x
, 0)) == MULT
)
5830 XEXP (x
, 0) = force_operand (XEXP (x
, 0), 0);
5833 if (GET_CODE (XEXP (x
, 1)) == MULT
)
5836 XEXP (x
, 1) = force_operand (XEXP (x
, 1), 0);
5840 && GET_CODE (XEXP (x
, 1)) == REG
5841 && GET_CODE (XEXP (x
, 0)) == REG
)
5844 if (flag_pic
&& SYMBOLIC_CONST (XEXP (x
, 1)))
5847 x
= legitimize_pic_address (x
, 0);
5850 if (changed
&& legitimate_address_p (mode
, x
, FALSE
))
5853 if (GET_CODE (XEXP (x
, 0)) == REG
)
5855 register rtx temp
= gen_reg_rtx (Pmode
);
5856 register rtx val
= force_operand (XEXP (x
, 1), temp
);
5858 emit_move_insn (temp
, val
);
5864 else if (GET_CODE (XEXP (x
, 1)) == REG
)
5866 register rtx temp
= gen_reg_rtx (Pmode
);
5867 register rtx val
= force_operand (XEXP (x
, 0), temp
);
5869 emit_move_insn (temp
, val
);
5879 /* Print an integer constant expression in assembler syntax. Addition
5880 and subtraction are the only arithmetic that may appear in these
5881 expressions. FILE is the stdio stream to write to, X is the rtx, and
5882 CODE is the operand print code from the output string. */
5885 output_pic_addr_const (file
, x
, code
)
5892 switch (GET_CODE (x
))
5902 assemble_name (file
, XSTR (x
, 0));
5903 if (!TARGET_MACHO
&& code
== 'P' && ! SYMBOL_REF_FLAG (x
))
5904 fputs ("@PLT", file
);
5911 ASM_GENERATE_INTERNAL_LABEL (buf
, "L", CODE_LABEL_NUMBER (x
));
5912 assemble_name (asm_out_file
, buf
);
5916 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
));
5920 /* This used to output parentheses around the expression,
5921 but that does not work on the 386 (either ATT or BSD assembler). */
5922 output_pic_addr_const (file
, XEXP (x
, 0), code
);
5926 if (GET_MODE (x
) == VOIDmode
)
5928 /* We can use %d if the number is <32 bits and positive. */
5929 if (CONST_DOUBLE_HIGH (x
) || CONST_DOUBLE_LOW (x
) < 0)
5930 fprintf (file
, "0x%lx%08lx",
5931 (unsigned long) CONST_DOUBLE_HIGH (x
),
5932 (unsigned long) CONST_DOUBLE_LOW (x
));
5934 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, CONST_DOUBLE_LOW (x
));
5937 /* We can't handle floating point constants;
5938 PRINT_OPERAND must handle them. */
5939 output_operand_lossage ("floating constant misused");
5943 /* Some assemblers need integer constants to appear first. */
5944 if (GET_CODE (XEXP (x
, 0)) == CONST_INT
)
5946 output_pic_addr_const (file
, XEXP (x
, 0), code
);
5948 output_pic_addr_const (file
, XEXP (x
, 1), code
);
5950 else if (GET_CODE (XEXP (x
, 1)) == CONST_INT
)
5952 output_pic_addr_const (file
, XEXP (x
, 1), code
);
5954 output_pic_addr_const (file
, XEXP (x
, 0), code
);
5962 putc (ASSEMBLER_DIALECT
== ASM_INTEL
? '(' : '[', file
);
5963 output_pic_addr_const (file
, XEXP (x
, 0), code
);
5965 output_pic_addr_const (file
, XEXP (x
, 1), code
);
5967 putc (ASSEMBLER_DIALECT
== ASM_INTEL
? ')' : ']', file
);
5971 if (XVECLEN (x
, 0) != 1)
5973 output_pic_addr_const (file
, XVECEXP (x
, 0, 0), code
);
5974 switch (XINT (x
, 1))
5977 fputs ("@GOT", file
);
5980 fputs ("@GOTOFF", file
);
5982 case UNSPEC_GOTPCREL
:
5983 fputs ("@GOTPCREL(%rip)", file
);
5985 case UNSPEC_GOTTPOFF
:
5986 /* FIXME: This might be @TPOFF in Sun ld too. */
5987 fputs ("@GOTTPOFF", file
);
5990 fputs ("@TPOFF", file
);
5993 fputs ("@NTPOFF", file
);
5996 fputs ("@DTPOFF", file
);
5998 case UNSPEC_GOTNTPOFF
:
5999 fputs ("@GOTNTPOFF", file
);
6001 case UNSPEC_INDNTPOFF
:
6002 fputs ("@INDNTPOFF", file
);
6005 output_operand_lossage ("invalid UNSPEC as operand");
6011 output_operand_lossage ("invalid expression as operand");
6015 /* This is called from dwarfout.c via ASM_OUTPUT_DWARF_ADDR_CONST.
6016 We need to handle our special PIC relocations. */
6019 i386_dwarf_output_addr_const (file
, x
)
6024 fprintf (file
, "%s", TARGET_64BIT
? ASM_QUAD
: ASM_LONG
);
6028 fprintf (file
, "%s", ASM_LONG
);
6031 output_pic_addr_const (file
, x
, '\0');
6033 output_addr_const (file
, x
);
6037 /* This is called from dwarf2out.c via ASM_OUTPUT_DWARF_DTPREL.
6038 We need to emit DTP-relative relocations. */
6041 i386_output_dwarf_dtprel (file
, size
, x
)
6049 fputs (ASM_LONG
, file
);
6053 fputs (ASM_QUAD
, file
);
6060 output_addr_const (file
, x
);
6061 fputs ("@DTPOFF", file
);
6064 /* In the name of slightly smaller debug output, and to cater to
6065 general assembler losage, recognize PIC+GOTOFF and turn it back
6066 into a direct symbol reference. */
6069 i386_simplify_dwarf_addr (orig_x
)
6074 if (GET_CODE (x
) == MEM
)
6079 if (GET_CODE (x
) != CONST
6080 || GET_CODE (XEXP (x
, 0)) != UNSPEC
6081 || XINT (XEXP (x
, 0), 1) != UNSPEC_GOTPCREL
6082 || GET_CODE (orig_x
) != MEM
)
6084 return XVECEXP (XEXP (x
, 0), 0, 0);
6087 if (GET_CODE (x
) != PLUS
6088 || GET_CODE (XEXP (x
, 1)) != CONST
)
6091 if (GET_CODE (XEXP (x
, 0)) == REG
6092 && REGNO (XEXP (x
, 0)) == PIC_OFFSET_TABLE_REGNUM
)
6093 /* %ebx + GOT/GOTOFF */
6095 else if (GET_CODE (XEXP (x
, 0)) == PLUS
)
6097 /* %ebx + %reg * scale + GOT/GOTOFF */
6099 if (GET_CODE (XEXP (y
, 0)) == REG
6100 && REGNO (XEXP (y
, 0)) == PIC_OFFSET_TABLE_REGNUM
)
6102 else if (GET_CODE (XEXP (y
, 1)) == REG
6103 && REGNO (XEXP (y
, 1)) == PIC_OFFSET_TABLE_REGNUM
)
6107 if (GET_CODE (y
) != REG
6108 && GET_CODE (y
) != MULT
6109 && GET_CODE (y
) != ASHIFT
)
6115 x
= XEXP (XEXP (x
, 1), 0);
6116 if (GET_CODE (x
) == UNSPEC
6117 && ((XINT (x
, 1) == UNSPEC_GOT
&& GET_CODE (orig_x
) == MEM
)
6118 || (XINT (x
, 1) == UNSPEC_GOTOFF
&& GET_CODE (orig_x
) != MEM
)))
6121 return gen_rtx_PLUS (Pmode
, y
, XVECEXP (x
, 0, 0));
6122 return XVECEXP (x
, 0, 0);
6125 if (GET_CODE (x
) == PLUS
6126 && GET_CODE (XEXP (x
, 0)) == UNSPEC
6127 && GET_CODE (XEXP (x
, 1)) == CONST_INT
6128 && ((XINT (XEXP (x
, 0), 1) == UNSPEC_GOT
&& GET_CODE (orig_x
) == MEM
)
6129 || (XINT (XEXP (x
, 0), 1) == UNSPEC_GOTOFF
6130 && GET_CODE (orig_x
) != MEM
)))
6132 x
= gen_rtx_PLUS (VOIDmode
, XVECEXP (XEXP (x
, 0), 0, 0), XEXP (x
, 1));
6134 return gen_rtx_PLUS (Pmode
, y
, x
);
6142 put_condition_code (code
, mode
, reverse
, fp
, file
)
6144 enum machine_mode mode
;
6150 if (mode
== CCFPmode
|| mode
== CCFPUmode
)
6152 enum rtx_code second_code
, bypass_code
;
6153 ix86_fp_comparison_codes (code
, &bypass_code
, &code
, &second_code
);
6154 if (bypass_code
!= NIL
|| second_code
!= NIL
)
6156 code
= ix86_fp_compare_code_to_integer (code
);
6160 code
= reverse_condition (code
);
6171 if (mode
!= CCmode
&& mode
!= CCNOmode
&& mode
!= CCGCmode
)
6176 /* ??? Use "nbe" instead of "a" for fcmov losage on some assemblers.
6177 Those same assemblers have the same but opposite losage on cmov. */
6180 suffix
= fp
? "nbe" : "a";
6183 if (mode
== CCNOmode
|| mode
== CCGOCmode
)
6185 else if (mode
== CCmode
|| mode
== CCGCmode
)
6196 if (mode
== CCNOmode
|| mode
== CCGOCmode
)
6198 else if (mode
== CCmode
|| mode
== CCGCmode
)
6207 suffix
= fp
? "nb" : "ae";
6210 if (mode
!= CCmode
&& mode
!= CCGCmode
&& mode
!= CCNOmode
)
6220 suffix
= fp
? "u" : "p";
6223 suffix
= fp
? "nu" : "np";
6228 fputs (suffix
, file
);
6232 print_reg (x
, code
, file
)
6237 if (REGNO (x
) == ARG_POINTER_REGNUM
6238 || REGNO (x
) == FRAME_POINTER_REGNUM
6239 || REGNO (x
) == FLAGS_REG
6240 || REGNO (x
) == FPSR_REG
)
6243 if (ASSEMBLER_DIALECT
== ASM_ATT
|| USER_LABEL_PREFIX
[0] == 0)
6246 if (code
== 'w' || MMX_REG_P (x
))
6248 else if (code
== 'b')
6250 else if (code
== 'k')
6252 else if (code
== 'q')
6254 else if (code
== 'y')
6256 else if (code
== 'h')
6259 code
= GET_MODE_SIZE (GET_MODE (x
));
6261 /* Irritatingly, AMD extended registers use different naming convention
6262 from the normal registers. */
6263 if (REX_INT_REG_P (x
))
6270 error ("extended registers have no high halves");
6273 fprintf (file
, "r%ib", REGNO (x
) - FIRST_REX_INT_REG
+ 8);
6276 fprintf (file
, "r%iw", REGNO (x
) - FIRST_REX_INT_REG
+ 8);
6279 fprintf (file
, "r%id", REGNO (x
) - FIRST_REX_INT_REG
+ 8);
6282 fprintf (file
, "r%i", REGNO (x
) - FIRST_REX_INT_REG
+ 8);
6285 error ("unsupported operand size for extended register");
6293 if (STACK_TOP_P (x
))
6295 fputs ("st(0)", file
);
6302 if (! ANY_FP_REG_P (x
))
6303 putc (code
== 8 && TARGET_64BIT
? 'r' : 'e', file
);
6307 fputs (hi_reg_name
[REGNO (x
)], file
);
6310 fputs (qi_reg_name
[REGNO (x
)], file
);
6313 fputs (qi_high_reg_name
[REGNO (x
)], file
);
6320 /* Locate some local-dynamic symbol still in use by this function
6321 so that we can print its name in some tls_local_dynamic_base
6325 get_some_local_dynamic_name ()
6329 if (cfun
->machine
->some_ld_name
)
6330 return cfun
->machine
->some_ld_name
;
6332 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
6334 && for_each_rtx (&PATTERN (insn
), get_some_local_dynamic_name_1
, 0))
6335 return cfun
->machine
->some_ld_name
;
6341 get_some_local_dynamic_name_1 (px
, data
)
6343 void *data ATTRIBUTE_UNUSED
;
6347 if (GET_CODE (x
) == SYMBOL_REF
6348 && local_dynamic_symbolic_operand (x
, Pmode
))
6350 cfun
->machine
->some_ld_name
= XSTR (x
, 0);
6358 L,W,B,Q,S,T -- print the opcode suffix for specified size of operand.
6359 C -- print opcode suffix for set/cmov insn.
6360 c -- like C, but print reversed condition
6361 F,f -- likewise, but for floating-point.
6362 O -- if CMOV_SUN_AS_SYNTAX, expand to "w.", "l." or "q.", otherwise
6364 R -- print the prefix for register names.
6365 z -- print the opcode suffix for the size of the current operand.
6366 * -- print a star (in certain assembler syntax)
6367 A -- print an absolute memory reference.
6368 w -- print the operand as if it's a "word" (HImode) even if it isn't.
6369 s -- print a shift double count, followed by the assemblers argument
6371 b -- print the QImode name of the register for the indicated operand.
6372 %b0 would print %al if operands[0] is reg 0.
6373 w -- likewise, print the HImode name of the register.
6374 k -- likewise, print the SImode name of the register.
6375 q -- likewise, print the DImode name of the register.
6376 h -- print the QImode name for a "high" register, either ah, bh, ch or dh.
6377 y -- print "st(0)" instead of "st" as a register.
6378 D -- print condition for SSE cmp instruction.
6379 P -- if PIC, print an @PLT suffix.
6380 X -- don't print any sort of PIC '@' suffix for a symbol.
6381 & -- print some in-use local-dynamic symbol name.
6385 print_operand (file
, x
, code
)
6395 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6400 assemble_name (file
, get_some_local_dynamic_name ());
6404 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6406 else if (ASSEMBLER_DIALECT
== ASM_INTEL
)
6408 /* Intel syntax. For absolute addresses, registers should not
6409 be surrounded by braces. */
6410 if (GET_CODE (x
) != REG
)
6413 PRINT_OPERAND (file
, x
, 0);
6421 PRINT_OPERAND (file
, x
, 0);
6426 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6431 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6436 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6441 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6446 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6451 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6456 /* 387 opcodes don't get size suffixes if the operands are
6458 if (STACK_REG_P (x
))
6461 /* Likewise if using Intel opcodes. */
6462 if (ASSEMBLER_DIALECT
== ASM_INTEL
)
6465 /* This is the size of op from size of operand. */
6466 switch (GET_MODE_SIZE (GET_MODE (x
)))
6469 #ifdef HAVE_GAS_FILDS_FISTS
6475 if (GET_MODE (x
) == SFmode
)
6490 if (GET_MODE_CLASS (GET_MODE (x
)) == MODE_INT
)
6492 #ifdef GAS_MNEMONICS
6518 if (GET_CODE (x
) == CONST_INT
|| ! SHIFT_DOUBLE_OMITS_COUNT
)
6520 PRINT_OPERAND (file
, x
, 0);
6526 /* Little bit of braindamage here. The SSE compare instructions
6527 does use completely different names for the comparisons that the
6528 fp conditional moves. */
6529 switch (GET_CODE (x
))
6544 fputs ("unord", file
);
6548 fputs ("neq", file
);
6552 fputs ("nlt", file
);
6556 fputs ("nle", file
);
6559 fputs ("ord", file
);
6567 #ifdef CMOV_SUN_AS_SYNTAX
6568 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6570 switch (GET_MODE (x
))
6572 case HImode
: putc ('w', file
); break;
6574 case SFmode
: putc ('l', file
); break;
6576 case DFmode
: putc ('q', file
); break;
6584 put_condition_code (GET_CODE (x
), GET_MODE (XEXP (x
, 0)), 0, 0, file
);
6587 #ifdef CMOV_SUN_AS_SYNTAX
6588 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6591 put_condition_code (GET_CODE (x
), GET_MODE (XEXP (x
, 0)), 0, 1, file
);
6594 /* Like above, but reverse condition */
6596 /* Check to see if argument to %c is really a constant
6597 and not a condition code which needs to be reversed. */
6598 if (GET_RTX_CLASS (GET_CODE (x
)) != '<')
6600 output_operand_lossage ("operand is neither a constant nor a condition code, invalid operand code 'c'");
6603 put_condition_code (GET_CODE (x
), GET_MODE (XEXP (x
, 0)), 1, 0, file
);
6606 #ifdef CMOV_SUN_AS_SYNTAX
6607 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6610 put_condition_code (GET_CODE (x
), GET_MODE (XEXP (x
, 0)), 1, 1, file
);
6616 if (!optimize
|| optimize_size
|| !TARGET_BRANCH_PREDICTION_HINTS
)
6619 x
= find_reg_note (current_output_insn
, REG_BR_PROB
, 0);
6622 int pred_val
= INTVAL (XEXP (x
, 0));
6624 if (pred_val
< REG_BR_PROB_BASE
* 45 / 100
6625 || pred_val
> REG_BR_PROB_BASE
* 55 / 100)
6627 int taken
= pred_val
> REG_BR_PROB_BASE
/ 2;
6628 int cputaken
= final_forward_branch_p (current_output_insn
) == 0;
6630 /* Emit hints only in the case default branch prediction
6631 heruistics would fail. */
6632 if (taken
!= cputaken
)
6634 /* We use 3e (DS) prefix for taken branches and
6635 2e (CS) prefix for not taken branches. */
6637 fputs ("ds ; ", file
);
6639 fputs ("cs ; ", file
);
6646 output_operand_lossage ("invalid operand code `%c'", code
);
6650 if (GET_CODE (x
) == REG
)
6652 PRINT_REG (x
, code
, file
);
6655 else if (GET_CODE (x
) == MEM
)
6657 /* No `byte ptr' prefix for call instructions. */
6658 if (ASSEMBLER_DIALECT
== ASM_INTEL
&& code
!= 'X' && code
!= 'P')
6661 switch (GET_MODE_SIZE (GET_MODE (x
)))
6663 case 1: size
= "BYTE"; break;
6664 case 2: size
= "WORD"; break;
6665 case 4: size
= "DWORD"; break;
6666 case 8: size
= "QWORD"; break;
6667 case 12: size
= "XWORD"; break;
6668 case 16: size
= "XMMWORD"; break;
6673 /* Check for explicit size override (codes 'b', 'w' and 'k') */
6676 else if (code
== 'w')
6678 else if (code
== 'k')
6682 fputs (" PTR ", file
);
6686 if (flag_pic
&& CONSTANT_ADDRESS_P (x
))
6687 output_pic_addr_const (file
, x
, code
);
6688 /* Avoid (%rip) for call operands. */
6689 else if (CONSTANT_ADDRESS_P (x
) && code
== 'P'
6690 && GET_CODE (x
) != CONST_INT
)
6691 output_addr_const (file
, x
);
6692 else if (this_is_asm_operands
&& ! address_operand (x
, VOIDmode
))
6693 output_operand_lossage ("invalid constraints for operand");
6698 else if (GET_CODE (x
) == CONST_DOUBLE
&& GET_MODE (x
) == SFmode
)
6703 REAL_VALUE_FROM_CONST_DOUBLE (r
, x
);
6704 REAL_VALUE_TO_TARGET_SINGLE (r
, l
);
6706 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6708 fprintf (file
, "0x%lx", l
);
6711 /* These float cases don't actually occur as immediate operands. */
6712 else if (GET_CODE (x
) == CONST_DOUBLE
&& GET_MODE (x
) == DFmode
)
6717 REAL_VALUE_FROM_CONST_DOUBLE (r
, x
);
6718 REAL_VALUE_TO_DECIMAL (r
, dstr
, -1);
6719 fprintf (file
, "%s", dstr
);
6722 else if (GET_CODE (x
) == CONST_DOUBLE
6723 && (GET_MODE (x
) == XFmode
|| GET_MODE (x
) == TFmode
))
6728 REAL_VALUE_FROM_CONST_DOUBLE (r
, x
);
6729 REAL_VALUE_TO_DECIMAL (r
, dstr
, -1);
6730 fprintf (file
, "%s", dstr
);
6737 if (GET_CODE (x
) == CONST_INT
|| GET_CODE (x
) == CONST_DOUBLE
)
6739 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6742 else if (GET_CODE (x
) == CONST
|| GET_CODE (x
) == SYMBOL_REF
6743 || GET_CODE (x
) == LABEL_REF
)
6745 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6748 fputs ("OFFSET FLAT:", file
);
6751 if (GET_CODE (x
) == CONST_INT
)
6752 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
));
6754 output_pic_addr_const (file
, x
, code
);
6756 output_addr_const (file
, x
);
6760 /* Print a memory operand whose address is ADDR. */
6763 print_operand_address (file
, addr
)
6767 struct ix86_address parts
;
6768 rtx base
, index
, disp
;
6771 if (GET_CODE (addr
) == UNSPEC
&& XINT (addr
, 1) == UNSPEC_TP
)
6773 if (ASSEMBLER_DIALECT
== ASM_INTEL
)
6774 fputs ("DWORD PTR ", file
);
6775 if (ASSEMBLER_DIALECT
== ASM_ATT
|| USER_LABEL_PREFIX
[0] == 0)
6777 fputs ("gs:0", file
);
6781 if (! ix86_decompose_address (addr
, &parts
))
6785 index
= parts
.index
;
6787 scale
= parts
.scale
;
6789 if (!base
&& !index
)
6791 /* Displacement only requires special attention. */
6793 if (GET_CODE (disp
) == CONST_INT
)
6795 if (ASSEMBLER_DIALECT
== ASM_INTEL
)
6797 if (USER_LABEL_PREFIX
[0] == 0)
6799 fputs ("ds:", file
);
6801 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (addr
));
6804 output_pic_addr_const (file
, addr
, 0);
6806 output_addr_const (file
, addr
);
6808 /* Use one byte shorter RIP relative addressing for 64bit mode. */
6810 && (GET_CODE (addr
) == SYMBOL_REF
6811 || GET_CODE (addr
) == LABEL_REF
6812 || (GET_CODE (addr
) == CONST
6813 && GET_CODE (XEXP (addr
, 0)) == PLUS
6814 && GET_CODE (XEXP (XEXP (addr
, 0), 0)) == SYMBOL_REF
6815 && GET_CODE (XEXP (XEXP (addr
, 0), 1)) == CONST_INT
)))
6816 fputs ("(%rip)", file
);
6820 if (ASSEMBLER_DIALECT
== ASM_ATT
)
6825 output_pic_addr_const (file
, disp
, 0);
6826 else if (GET_CODE (disp
) == LABEL_REF
)
6827 output_asm_label (disp
);
6829 output_addr_const (file
, disp
);
6834 PRINT_REG (base
, 0, file
);
6838 PRINT_REG (index
, 0, file
);
6840 fprintf (file
, ",%d", scale
);
6846 rtx offset
= NULL_RTX
;
6850 /* Pull out the offset of a symbol; print any symbol itself. */
6851 if (GET_CODE (disp
) == CONST
6852 && GET_CODE (XEXP (disp
, 0)) == PLUS
6853 && GET_CODE (XEXP (XEXP (disp
, 0), 1)) == CONST_INT
)
6855 offset
= XEXP (XEXP (disp
, 0), 1);
6856 disp
= gen_rtx_CONST (VOIDmode
,
6857 XEXP (XEXP (disp
, 0), 0));
6861 output_pic_addr_const (file
, disp
, 0);
6862 else if (GET_CODE (disp
) == LABEL_REF
)
6863 output_asm_label (disp
);
6864 else if (GET_CODE (disp
) == CONST_INT
)
6867 output_addr_const (file
, disp
);
6873 PRINT_REG (base
, 0, file
);
6876 if (INTVAL (offset
) >= 0)
6878 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (offset
));
6882 fprintf (file
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (offset
));
6889 PRINT_REG (index
, 0, file
);
6891 fprintf (file
, "*%d", scale
);
6899 output_addr_const_extra (file
, x
)
6905 if (GET_CODE (x
) != UNSPEC
)
6908 op
= XVECEXP (x
, 0, 0);
6909 switch (XINT (x
, 1))
6911 case UNSPEC_GOTTPOFF
:
6912 output_addr_const (file
, op
);
6913 /* FIXME: This might be @TPOFF in Sun ld. */
6914 fputs ("@GOTTPOFF", file
);
6917 output_addr_const (file
, op
);
6918 fputs ("@TPOFF", file
);
6921 output_addr_const (file
, op
);
6922 fputs ("@NTPOFF", file
);
6925 output_addr_const (file
, op
);
6926 fputs ("@DTPOFF", file
);
6928 case UNSPEC_GOTNTPOFF
:
6929 output_addr_const (file
, op
);
6930 fputs ("@GOTNTPOFF", file
);
6932 case UNSPEC_INDNTPOFF
:
6933 output_addr_const (file
, op
);
6934 fputs ("@INDNTPOFF", file
);
6944 /* Split one or more DImode RTL references into pairs of SImode
6945 references. The RTL can be REG, offsettable MEM, integer constant, or
6946 CONST_DOUBLE. "operands" is a pointer to an array of DImode RTL to
6947 split and "num" is its length. lo_half and hi_half are output arrays
6948 that parallel "operands". */
6951 split_di (operands
, num
, lo_half
, hi_half
)
6954 rtx lo_half
[], hi_half
[];
6958 rtx op
= operands
[num
];
6960 /* simplify_subreg refuse to split volatile memory addresses,
6961 but we still have to handle it. */
6962 if (GET_CODE (op
) == MEM
)
6964 lo_half
[num
] = adjust_address (op
, SImode
, 0);
6965 hi_half
[num
] = adjust_address (op
, SImode
, 4);
6969 lo_half
[num
] = simplify_gen_subreg (SImode
, op
,
6970 GET_MODE (op
) == VOIDmode
6971 ? DImode
: GET_MODE (op
), 0);
6972 hi_half
[num
] = simplify_gen_subreg (SImode
, op
,
6973 GET_MODE (op
) == VOIDmode
6974 ? DImode
: GET_MODE (op
), 4);
6978 /* Split one or more TImode RTL references into pairs of SImode
6979 references. The RTL can be REG, offsettable MEM, integer constant, or
6980 CONST_DOUBLE. "operands" is a pointer to an array of DImode RTL to
6981 split and "num" is its length. lo_half and hi_half are output arrays
6982 that parallel "operands". */
6985 split_ti (operands
, num
, lo_half
, hi_half
)
6988 rtx lo_half
[], hi_half
[];
6992 rtx op
= operands
[num
];
6994 /* simplify_subreg refuse to split volatile memory addresses, but we
6995 still have to handle it. */
6996 if (GET_CODE (op
) == MEM
)
6998 lo_half
[num
] = adjust_address (op
, DImode
, 0);
6999 hi_half
[num
] = adjust_address (op
, DImode
, 8);
7003 lo_half
[num
] = simplify_gen_subreg (DImode
, op
, TImode
, 0);
7004 hi_half
[num
] = simplify_gen_subreg (DImode
, op
, TImode
, 8);
7009 /* Output code to perform a 387 binary operation in INSN, one of PLUS,
7010 MINUS, MULT or DIV. OPERANDS are the insn operands, where operands[3]
7011 is the expression of the binary operation. The output may either be
7012 emitted here, or returned to the caller, like all output_* functions.
7014 There is no guarantee that the operands are the same mode, as they
7015 might be within FLOAT or FLOAT_EXTEND expressions. */
7017 #ifndef SYSV386_COMPAT
7018 /* Set to 1 for compatibility with brain-damaged assemblers. No-one
7019 wants to fix the assemblers because that causes incompatibility
7020 with gcc. No-one wants to fix gcc because that causes
7021 incompatibility with assemblers... You can use the option of
7022 -DSYSV386_COMPAT=0 if you recompile both gcc and gas this way. */
7023 #define SYSV386_COMPAT 1
7027 output_387_binary_op (insn
, operands
)
7031 static char buf
[30];
7034 int is_sse
= SSE_REG_P (operands
[0]) | SSE_REG_P (operands
[1]) | SSE_REG_P (operands
[2]);
7036 #ifdef ENABLE_CHECKING
7037 /* Even if we do not want to check the inputs, this documents input
7038 constraints. Which helps in understanding the following code. */
7039 if (STACK_REG_P (operands
[0])
7040 && ((REG_P (operands
[1])
7041 && REGNO (operands
[0]) == REGNO (operands
[1])
7042 && (STACK_REG_P (operands
[2]) || GET_CODE (operands
[2]) == MEM
))
7043 || (REG_P (operands
[2])
7044 && REGNO (operands
[0]) == REGNO (operands
[2])
7045 && (STACK_REG_P (operands
[1]) || GET_CODE (operands
[1]) == MEM
)))
7046 && (STACK_TOP_P (operands
[1]) || STACK_TOP_P (operands
[2])))
7052 switch (GET_CODE (operands
[3]))
7055 if (GET_MODE_CLASS (GET_MODE (operands
[1])) == MODE_INT
7056 || GET_MODE_CLASS (GET_MODE (operands
[2])) == MODE_INT
)
7064 if (GET_MODE_CLASS (GET_MODE (operands
[1])) == MODE_INT
7065 || GET_MODE_CLASS (GET_MODE (operands
[2])) == MODE_INT
)
7073 if (GET_MODE_CLASS (GET_MODE (operands
[1])) == MODE_INT
7074 || GET_MODE_CLASS (GET_MODE (operands
[2])) == MODE_INT
)
7082 if (GET_MODE_CLASS (GET_MODE (operands
[1])) == MODE_INT
7083 || GET_MODE_CLASS (GET_MODE (operands
[2])) == MODE_INT
)
7097 if (GET_MODE (operands
[0]) == SFmode
)
7098 strcat (buf
, "ss\t{%2, %0|%0, %2}");
7100 strcat (buf
, "sd\t{%2, %0|%0, %2}");
7105 switch (GET_CODE (operands
[3]))
7109 if (REG_P (operands
[2]) && REGNO (operands
[0]) == REGNO (operands
[2]))
7111 rtx temp
= operands
[2];
7112 operands
[2] = operands
[1];
7116 /* know operands[0] == operands[1]. */
7118 if (GET_CODE (operands
[2]) == MEM
)
7124 if (find_regno_note (insn
, REG_DEAD
, REGNO (operands
[2])))
7126 if (STACK_TOP_P (operands
[0]))
7127 /* How is it that we are storing to a dead operand[2]?
7128 Well, presumably operands[1] is dead too. We can't
7129 store the result to st(0) as st(0) gets popped on this
7130 instruction. Instead store to operands[2] (which I
7131 think has to be st(1)). st(1) will be popped later.
7132 gcc <= 2.8.1 didn't have this check and generated
7133 assembly code that the Unixware assembler rejected. */
7134 p
= "p\t{%0, %2|%2, %0}"; /* st(1) = st(0) op st(1); pop */
7136 p
= "p\t{%2, %0|%0, %2}"; /* st(r1) = st(r1) op st(0); pop */
7140 if (STACK_TOP_P (operands
[0]))
7141 p
= "\t{%y2, %0|%0, %y2}"; /* st(0) = st(0) op st(r2) */
7143 p
= "\t{%2, %0|%0, %2}"; /* st(r1) = st(r1) op st(0) */
7148 if (GET_CODE (operands
[1]) == MEM
)
7154 if (GET_CODE (operands
[2]) == MEM
)
7160 if (find_regno_note (insn
, REG_DEAD
, REGNO (operands
[2])))
7163 /* The SystemV/386 SVR3.2 assembler, and probably all AT&T
7164 derived assemblers, confusingly reverse the direction of
7165 the operation for fsub{r} and fdiv{r} when the
7166 destination register is not st(0). The Intel assembler
7167 doesn't have this brain damage. Read !SYSV386_COMPAT to
7168 figure out what the hardware really does. */
7169 if (STACK_TOP_P (operands
[0]))
7170 p
= "{p\t%0, %2|rp\t%2, %0}";
7172 p
= "{rp\t%2, %0|p\t%0, %2}";
7174 if (STACK_TOP_P (operands
[0]))
7175 /* As above for fmul/fadd, we can't store to st(0). */
7176 p
= "rp\t{%0, %2|%2, %0}"; /* st(1) = st(0) op st(1); pop */
7178 p
= "p\t{%2, %0|%0, %2}"; /* st(r1) = st(r1) op st(0); pop */
7183 if (find_regno_note (insn
, REG_DEAD
, REGNO (operands
[1])))
7186 if (STACK_TOP_P (operands
[0]))
7187 p
= "{rp\t%0, %1|p\t%1, %0}";
7189 p
= "{p\t%1, %0|rp\t%0, %1}";
7191 if (STACK_TOP_P (operands
[0]))
7192 p
= "p\t{%0, %1|%1, %0}"; /* st(1) = st(1) op st(0); pop */
7194 p
= "rp\t{%1, %0|%0, %1}"; /* st(r2) = st(0) op st(r2); pop */
7199 if (STACK_TOP_P (operands
[0]))
7201 if (STACK_TOP_P (operands
[1]))
7202 p
= "\t{%y2, %0|%0, %y2}"; /* st(0) = st(0) op st(r2) */
7204 p
= "r\t{%y1, %0|%0, %y1}"; /* st(0) = st(r1) op st(0) */
7207 else if (STACK_TOP_P (operands
[1]))
7210 p
= "{\t%1, %0|r\t%0, %1}";
7212 p
= "r\t{%1, %0|%0, %1}"; /* st(r2) = st(0) op st(r2) */
7218 p
= "{r\t%2, %0|\t%0, %2}";
7220 p
= "\t{%2, %0|%0, %2}"; /* st(r1) = st(r1) op st(0) */
7233 /* Output code to initialize control word copies used by
7234 trunc?f?i patterns. NORMAL is set to current control word, while ROUND_DOWN
7235 is set to control word rounding downwards. */
7237 emit_i387_cw_initialization (normal
, round_down
)
7238 rtx normal
, round_down
;
7240 rtx reg
= gen_reg_rtx (HImode
);
7242 emit_insn (gen_x86_fnstcw_1 (normal
));
7243 emit_move_insn (reg
, normal
);
7244 if (!TARGET_PARTIAL_REG_STALL
&& !optimize_size
7246 emit_insn (gen_movsi_insv_1 (reg
, GEN_INT (0xc)));
7248 emit_insn (gen_iorhi3 (reg
, reg
, GEN_INT (0xc00)));
7249 emit_move_insn (round_down
, reg
);
7252 /* Output code for INSN to convert a float to a signed int. OPERANDS
7253 are the insn operands. The output may be [HSD]Imode and the input
7254 operand may be [SDX]Fmode. */
7257 output_fix_trunc (insn
, operands
)
7261 int stack_top_dies
= find_regno_note (insn
, REG_DEAD
, FIRST_STACK_REG
) != 0;
7262 int dimode_p
= GET_MODE (operands
[0]) == DImode
;
7264 /* Jump through a hoop or two for DImode, since the hardware has no
7265 non-popping instruction. We used to do this a different way, but
7266 that was somewhat fragile and broke with post-reload splitters. */
7267 if (dimode_p
&& !stack_top_dies
)
7268 output_asm_insn ("fld\t%y1", operands
);
7270 if (!STACK_TOP_P (operands
[1]))
7273 if (GET_CODE (operands
[0]) != MEM
)
7276 output_asm_insn ("fldcw\t%3", operands
);
7277 if (stack_top_dies
|| dimode_p
)
7278 output_asm_insn ("fistp%z0\t%0", operands
);
7280 output_asm_insn ("fist%z0\t%0", operands
);
7281 output_asm_insn ("fldcw\t%2", operands
);
7286 /* Output code for INSN to compare OPERANDS. EFLAGS_P is 1 when fcomi
7287 should be used and 2 when fnstsw should be used. UNORDERED_P is true
7288 when fucom should be used. */
7291 output_fp_compare (insn
, operands
, eflags_p
, unordered_p
)
7294 int eflags_p
, unordered_p
;
7297 rtx cmp_op0
= operands
[0];
7298 rtx cmp_op1
= operands
[1];
7299 int is_sse
= SSE_REG_P (operands
[0]) | SSE_REG_P (operands
[1]);
7304 cmp_op1
= operands
[2];
7308 if (GET_MODE (operands
[0]) == SFmode
)
7310 return "ucomiss\t{%1, %0|%0, %1}";
7312 return "comiss\t{%1, %0|%0, %y}";
7315 return "ucomisd\t{%1, %0|%0, %1}";
7317 return "comisd\t{%1, %0|%0, %y}";
7320 if (! STACK_TOP_P (cmp_op0
))
7323 stack_top_dies
= find_regno_note (insn
, REG_DEAD
, FIRST_STACK_REG
) != 0;
7325 if (STACK_REG_P (cmp_op1
)
7327 && find_regno_note (insn
, REG_DEAD
, REGNO (cmp_op1
))
7328 && REGNO (cmp_op1
) != FIRST_STACK_REG
)
7330 /* If both the top of the 387 stack dies, and the other operand
7331 is also a stack register that dies, then this must be a
7332 `fcompp' float compare */
7336 /* There is no double popping fcomi variant. Fortunately,
7337 eflags is immune from the fstp's cc clobbering. */
7339 output_asm_insn ("fucomip\t{%y1, %0|%0, %y1}", operands
);
7341 output_asm_insn ("fcomip\t{%y1, %0|%0, %y1}", operands
);
7349 return "fucompp\n\tfnstsw\t%0";
7351 return "fcompp\n\tfnstsw\t%0";
7364 /* Encoded here as eflags_p | intmode | unordered_p | stack_top_dies. */
7366 static const char * const alt
[24] =
7378 "fcomi\t{%y1, %0|%0, %y1}",
7379 "fcomip\t{%y1, %0|%0, %y1}",
7380 "fucomi\t{%y1, %0|%0, %y1}",
7381 "fucomip\t{%y1, %0|%0, %y1}",
7388 "fcom%z2\t%y2\n\tfnstsw\t%0",
7389 "fcomp%z2\t%y2\n\tfnstsw\t%0",
7390 "fucom%z2\t%y2\n\tfnstsw\t%0",
7391 "fucomp%z2\t%y2\n\tfnstsw\t%0",
7393 "ficom%z2\t%y2\n\tfnstsw\t%0",
7394 "ficomp%z2\t%y2\n\tfnstsw\t%0",
7402 mask
= eflags_p
<< 3;
7403 mask
|= (GET_MODE_CLASS (GET_MODE (operands
[1])) == MODE_INT
) << 2;
7404 mask
|= unordered_p
<< 1;
7405 mask
|= stack_top_dies
;
7418 ix86_output_addr_vec_elt (file
, value
)
7422 const char *directive
= ASM_LONG
;
7427 directive
= ASM_QUAD
;
7433 fprintf (file
, "%s%s%d\n", directive
, LPREFIX
, value
);
7437 ix86_output_addr_diff_elt (file
, value
, rel
)
7442 fprintf (file
, "%s%s%d-%s%d\n",
7443 ASM_LONG
, LPREFIX
, value
, LPREFIX
, rel
);
7444 else if (HAVE_AS_GOTOFF_IN_DATA
)
7445 fprintf (file
, "%s%s%d@GOTOFF\n", ASM_LONG
, LPREFIX
, value
);
7447 else if (TARGET_MACHO
)
7448 fprintf (file
, "%s%s%d-%s\n", ASM_LONG
, LPREFIX
, value
,
7449 machopic_function_base_name () + 1);
7452 asm_fprintf (file
, "%s%U%s+[.-%s%d]\n",
7453 ASM_LONG
, GOT_SYMBOL_NAME
, LPREFIX
, value
);
7456 /* Generate either "mov $0, reg" or "xor reg, reg", as appropriate
7460 ix86_expand_clear (dest
)
7465 /* We play register width games, which are only valid after reload. */
7466 if (!reload_completed
)
7469 /* Avoid HImode and its attendant prefix byte. */
7470 if (GET_MODE_SIZE (GET_MODE (dest
)) < 4)
7471 dest
= gen_rtx_REG (SImode
, REGNO (dest
));
7473 tmp
= gen_rtx_SET (VOIDmode
, dest
, const0_rtx
);
7475 /* This predicate should match that for movsi_xor and movdi_xor_rex64. */
7476 if (reload_completed
&& (!TARGET_USE_MOV0
|| optimize_size
))
7478 rtx clob
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (CCmode
, 17));
7479 tmp
= gen_rtx_PARALLEL (VOIDmode
, gen_rtvec (2, tmp
, clob
));
7485 /* X is an unchanging MEM. If it is a constant pool reference, return
7486 the constant pool rtx, else NULL. */
7489 maybe_get_pool_constant (x
)
7496 if (GET_CODE (x
) != PLUS
)
7498 if (XEXP (x
, 0) != pic_offset_table_rtx
)
7501 if (GET_CODE (x
) != CONST
)
7504 if (GET_CODE (x
) != UNSPEC
)
7506 if (XINT (x
, 1) != UNSPEC_GOTOFF
)
7508 x
= XVECEXP (x
, 0, 0);
7511 if (GET_CODE (x
) == SYMBOL_REF
&& CONSTANT_POOL_ADDRESS_P (x
))
7512 return get_pool_constant (x
);
7518 ix86_expand_move (mode
, operands
)
7519 enum machine_mode mode
;
7522 int strict
= (reload_in_progress
|| reload_completed
);
7523 rtx insn
, op0
, op1
, tmp
;
7528 /* ??? We have a slight problem. We need to say that tls symbols are
7529 not legitimate constants so that reload does not helpfully reload
7530 these constants from a REG_EQUIV, which we cannot handle. (Recall
7531 that general- and local-dynamic address resolution requires a
7534 However, if we say that tls symbols are not legitimate constants,
7535 then emit_move_insn helpfully drop them into the constant pool.
7537 It is far easier to work around emit_move_insn than reload. Recognize
7538 the MEM that we would have created and extract the symbol_ref. */
7541 && GET_CODE (op1
) == MEM
7542 && RTX_UNCHANGING_P (op1
))
7544 tmp
= maybe_get_pool_constant (op1
);
7545 /* Note that we only care about symbolic constants here, which
7546 unlike CONST_INT will always have a proper mode. */
7547 if (tmp
&& GET_MODE (tmp
) == Pmode
)
7551 if (tls_symbolic_operand (op1
, Pmode
))
7553 op1
= legitimize_address (op1
, op1
, VOIDmode
);
7554 if (GET_CODE (op0
) == MEM
)
7556 tmp
= gen_reg_rtx (mode
);
7557 emit_insn (gen_rtx_SET (VOIDmode
, tmp
, op1
));
7561 else if (flag_pic
&& mode
== Pmode
&& symbolic_operand (op1
, Pmode
))
7566 rtx temp
= ((reload_in_progress
7567 || ((op0
&& GET_CODE (op0
) == REG
)
7569 ? op0
: gen_reg_rtx (Pmode
));
7570 op1
= machopic_indirect_data_reference (op1
, temp
);
7571 op1
= machopic_legitimize_pic_address (op1
, mode
,
7572 temp
== op1
? 0 : temp
);
7576 if (MACHOPIC_INDIRECT
)
7577 op1
= machopic_indirect_data_reference (op1
, 0);
7581 insn
= gen_rtx_SET (VOIDmode
, op0
, op1
);
7585 #endif /* TARGET_MACHO */
7586 if (GET_CODE (op0
) == MEM
)
7587 op1
= force_reg (Pmode
, op1
);
7591 if (GET_CODE (temp
) != REG
)
7592 temp
= gen_reg_rtx (Pmode
);
7593 temp
= legitimize_pic_address (op1
, temp
);
7601 if (GET_CODE (op0
) == MEM
7602 && (PUSH_ROUNDING (GET_MODE_SIZE (mode
)) != GET_MODE_SIZE (mode
)
7603 || !push_operand (op0
, mode
))
7604 && GET_CODE (op1
) == MEM
)
7605 op1
= force_reg (mode
, op1
);
7607 if (push_operand (op0
, mode
)
7608 && ! general_no_elim_operand (op1
, mode
))
7609 op1
= copy_to_mode_reg (mode
, op1
);
7611 /* Force large constants in 64bit compilation into register
7612 to get them CSEed. */
7613 if (TARGET_64BIT
&& mode
== DImode
7614 && immediate_operand (op1
, mode
)
7615 && !x86_64_zero_extended_value (op1
)
7616 && !register_operand (op0
, mode
)
7617 && optimize
&& !reload_completed
&& !reload_in_progress
)
7618 op1
= copy_to_mode_reg (mode
, op1
);
7620 if (FLOAT_MODE_P (mode
))
7622 /* If we are loading a floating point constant to a register,
7623 force the value to memory now, since we'll get better code
7624 out the back end. */
7628 else if (GET_CODE (op1
) == CONST_DOUBLE
7629 && register_operand (op0
, mode
))
7630 op1
= validize_mem (force_const_mem (mode
, op1
));
7634 insn
= gen_rtx_SET (VOIDmode
, op0
, op1
);
7640 ix86_expand_vector_move (mode
, operands
)
7641 enum machine_mode mode
;
7644 /* Force constants other than zero into memory. We do not know how
7645 the instructions used to build constants modify the upper 64 bits
7646 of the register, once we have that information we may be able
7647 to handle some of them more efficiently. */
7648 if ((reload_in_progress
| reload_completed
) == 0
7649 && register_operand (operands
[0], mode
)
7650 && CONSTANT_P (operands
[1]))
7652 rtx addr
= gen_reg_rtx (Pmode
);
7653 emit_move_insn (addr
, XEXP (force_const_mem (mode
, operands
[1]), 0));
7654 operands
[1] = gen_rtx_MEM (mode
, addr
);
7657 /* Make operand1 a register if it isn't already. */
7658 if ((reload_in_progress
| reload_completed
) == 0
7659 && !register_operand (operands
[0], mode
)
7660 && !register_operand (operands
[1], mode
)
7661 && operands
[1] != CONST0_RTX (mode
))
7663 rtx temp
= force_reg (GET_MODE (operands
[1]), operands
[1]);
7664 emit_move_insn (operands
[0], temp
);
7668 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0], operands
[1]));
7671 /* Attempt to expand a binary operator. Make the expansion closer to the
7672 actual machine, then just general_operand, which will allow 3 separate
7673 memory references (one output, two input) in a single insn. */
7676 ix86_expand_binary_operator (code
, mode
, operands
)
7678 enum machine_mode mode
;
7681 int matching_memory
;
7682 rtx src1
, src2
, dst
, op
, clob
;
7688 /* Recognize <var1> = <value> <op> <var1> for commutative operators */
7689 if (GET_RTX_CLASS (code
) == 'c'
7690 && (rtx_equal_p (dst
, src2
)
7691 || immediate_operand (src1
, mode
)))
7698 /* If the destination is memory, and we do not have matching source
7699 operands, do things in registers. */
7700 matching_memory
= 0;
7701 if (GET_CODE (dst
) == MEM
)
7703 if (rtx_equal_p (dst
, src1
))
7704 matching_memory
= 1;
7705 else if (GET_RTX_CLASS (code
) == 'c'
7706 && rtx_equal_p (dst
, src2
))
7707 matching_memory
= 2;
7709 dst
= gen_reg_rtx (mode
);
7712 /* Both source operands cannot be in memory. */
7713 if (GET_CODE (src1
) == MEM
&& GET_CODE (src2
) == MEM
)
7715 if (matching_memory
!= 2)
7716 src2
= force_reg (mode
, src2
);
7718 src1
= force_reg (mode
, src1
);
7721 /* If the operation is not commutable, source 1 cannot be a constant
7722 or non-matching memory. */
7723 if ((CONSTANT_P (src1
)
7724 || (!matching_memory
&& GET_CODE (src1
) == MEM
))
7725 && GET_RTX_CLASS (code
) != 'c')
7726 src1
= force_reg (mode
, src1
);
7728 /* If optimizing, copy to regs to improve CSE */
7729 if (optimize
&& ! no_new_pseudos
)
7731 if (GET_CODE (dst
) == MEM
)
7732 dst
= gen_reg_rtx (mode
);
7733 if (GET_CODE (src1
) == MEM
)
7734 src1
= force_reg (mode
, src1
);
7735 if (GET_CODE (src2
) == MEM
)
7736 src2
= force_reg (mode
, src2
);
7739 /* Emit the instruction. */
7741 op
= gen_rtx_SET (VOIDmode
, dst
, gen_rtx_fmt_ee (code
, mode
, src1
, src2
));
7742 if (reload_in_progress
)
7744 /* Reload doesn't know about the flags register, and doesn't know that
7745 it doesn't want to clobber it. We can only do this with PLUS. */
7752 clob
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (CCmode
, FLAGS_REG
));
7753 emit_insn (gen_rtx_PARALLEL (VOIDmode
, gen_rtvec (2, op
, clob
)));
7756 /* Fix up the destination if needed. */
7757 if (dst
!= operands
[0])
7758 emit_move_insn (operands
[0], dst
);
7761 /* Return TRUE or FALSE depending on whether the binary operator meets the
7762 appropriate constraints. */
7765 ix86_binary_operator_ok (code
, mode
, operands
)
7767 enum machine_mode mode ATTRIBUTE_UNUSED
;
7770 /* Both source operands cannot be in memory. */
7771 if (GET_CODE (operands
[1]) == MEM
&& GET_CODE (operands
[2]) == MEM
)
7773 /* If the operation is not commutable, source 1 cannot be a constant. */
7774 if (CONSTANT_P (operands
[1]) && GET_RTX_CLASS (code
) != 'c')
7776 /* If the destination is memory, we must have a matching source operand. */
7777 if (GET_CODE (operands
[0]) == MEM
7778 && ! (rtx_equal_p (operands
[0], operands
[1])
7779 || (GET_RTX_CLASS (code
) == 'c'
7780 && rtx_equal_p (operands
[0], operands
[2]))))
7782 /* If the operation is not commutable and the source 1 is memory, we must
7783 have a matching destination. */
7784 if (GET_CODE (operands
[1]) == MEM
7785 && GET_RTX_CLASS (code
) != 'c'
7786 && ! rtx_equal_p (operands
[0], operands
[1]))
7791 /* Attempt to expand a unary operator. Make the expansion closer to the
7792 actual machine, then just general_operand, which will allow 2 separate
7793 memory references (one output, one input) in a single insn. */
7796 ix86_expand_unary_operator (code
, mode
, operands
)
7798 enum machine_mode mode
;
7801 int matching_memory
;
7802 rtx src
, dst
, op
, clob
;
7807 /* If the destination is memory, and we do not have matching source
7808 operands, do things in registers. */
7809 matching_memory
= 0;
7810 if (GET_CODE (dst
) == MEM
)
7812 if (rtx_equal_p (dst
, src
))
7813 matching_memory
= 1;
7815 dst
= gen_reg_rtx (mode
);
7818 /* When source operand is memory, destination must match. */
7819 if (!matching_memory
&& GET_CODE (src
) == MEM
)
7820 src
= force_reg (mode
, src
);
7822 /* If optimizing, copy to regs to improve CSE */
7823 if (optimize
&& ! no_new_pseudos
)
7825 if (GET_CODE (dst
) == MEM
)
7826 dst
= gen_reg_rtx (mode
);
7827 if (GET_CODE (src
) == MEM
)
7828 src
= force_reg (mode
, src
);
7831 /* Emit the instruction. */
7833 op
= gen_rtx_SET (VOIDmode
, dst
, gen_rtx_fmt_e (code
, mode
, src
));
7834 if (reload_in_progress
|| code
== NOT
)
7836 /* Reload doesn't know about the flags register, and doesn't know that
7837 it doesn't want to clobber it. */
7844 clob
= gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (CCmode
, FLAGS_REG
));
7845 emit_insn (gen_rtx_PARALLEL (VOIDmode
, gen_rtvec (2, op
, clob
)));
7848 /* Fix up the destination if needed. */
7849 if (dst
!= operands
[0])
7850 emit_move_insn (operands
[0], dst
);
7853 /* Return TRUE or FALSE depending on whether the unary operator meets the
7854 appropriate constraints. */
7857 ix86_unary_operator_ok (code
, mode
, operands
)
7858 enum rtx_code code ATTRIBUTE_UNUSED
;
7859 enum machine_mode mode ATTRIBUTE_UNUSED
;
7860 rtx operands
[2] ATTRIBUTE_UNUSED
;
7862 /* If one of operands is memory, source and destination must match. */
7863 if ((GET_CODE (operands
[0]) == MEM
7864 || GET_CODE (operands
[1]) == MEM
)
7865 && ! rtx_equal_p (operands
[0], operands
[1]))
7870 /* Return TRUE or FALSE depending on whether the first SET in INSN
7871 has source and destination with matching CC modes, and that the
7872 CC mode is at least as constrained as REQ_MODE. */
7875 ix86_match_ccmode (insn
, req_mode
)
7877 enum machine_mode req_mode
;
7880 enum machine_mode set_mode
;
7882 set
= PATTERN (insn
);
7883 if (GET_CODE (set
) == PARALLEL
)
7884 set
= XVECEXP (set
, 0, 0);
7885 if (GET_CODE (set
) != SET
)
7887 if (GET_CODE (SET_SRC (set
)) != COMPARE
)
7890 set_mode
= GET_MODE (SET_DEST (set
));
7894 if (req_mode
!= CCNOmode
7895 && (req_mode
!= CCmode
7896 || XEXP (SET_SRC (set
), 1) != const0_rtx
))
7900 if (req_mode
== CCGCmode
)
7904 if (req_mode
== CCGOCmode
|| req_mode
== CCNOmode
)
7908 if (req_mode
== CCZmode
)
7918 return (GET_MODE (SET_SRC (set
)) == set_mode
);
7921 /* Generate insn patterns to do an integer compare of OPERANDS. */
7924 ix86_expand_int_compare (code
, op0
, op1
)
7928 enum machine_mode cmpmode
;
7931 cmpmode
= SELECT_CC_MODE (code
, op0
, op1
);
7932 flags
= gen_rtx_REG (cmpmode
, FLAGS_REG
);
7934 /* This is very simple, but making the interface the same as in the
7935 FP case makes the rest of the code easier. */
7936 tmp
= gen_rtx_COMPARE (cmpmode
, op0
, op1
);
7937 emit_insn (gen_rtx_SET (VOIDmode
, flags
, tmp
));
7939 /* Return the test that should be put into the flags user, i.e.
7940 the bcc, scc, or cmov instruction. */
7941 return gen_rtx_fmt_ee (code
, VOIDmode
, flags
, const0_rtx
);
7944 /* Figure out whether to use ordered or unordered fp comparisons.
7945 Return the appropriate mode to use. */
7948 ix86_fp_compare_mode (code
)
7949 enum rtx_code code ATTRIBUTE_UNUSED
;
7951 /* ??? In order to make all comparisons reversible, we do all comparisons
7952 non-trapping when compiling for IEEE. Once gcc is able to distinguish
7953 all forms trapping and nontrapping comparisons, we can make inequality
7954 comparisons trapping again, since it results in better code when using
7955 FCOM based compares. */
7956 return TARGET_IEEE_FP
? CCFPUmode
: CCFPmode
;
7960 ix86_cc_mode (code
, op0
, op1
)
7964 if (GET_MODE_CLASS (GET_MODE (op0
)) == MODE_FLOAT
)
7965 return ix86_fp_compare_mode (code
);
7968 /* Only zero flag is needed. */
7970 case NE
: /* ZF!=0 */
7972 /* Codes needing carry flag. */
7973 case GEU
: /* CF=0 */
7974 case GTU
: /* CF=0 & ZF=0 */
7975 case LTU
: /* CF=1 */
7976 case LEU
: /* CF=1 | ZF=1 */
7978 /* Codes possibly doable only with sign flag when
7979 comparing against zero. */
7980 case GE
: /* SF=OF or SF=0 */
7981 case LT
: /* SF<>OF or SF=1 */
7982 if (op1
== const0_rtx
)
7985 /* For other cases Carry flag is not required. */
7987 /* Codes doable only with sign flag when comparing
7988 against zero, but we miss jump instruction for it
7989 so we need to use relational tests agains overflow
7990 that thus needs to be zero. */
7991 case GT
: /* ZF=0 & SF=OF */
7992 case LE
: /* ZF=1 | SF<>OF */
7993 if (op1
== const0_rtx
)
7997 /* strcmp pattern do (use flags) and combine may ask us for proper
8006 /* Return true if we should use an FCOMI instruction for this fp comparison. */
8009 ix86_use_fcomi_compare (code
)
8010 enum rtx_code code ATTRIBUTE_UNUSED
;
8012 enum rtx_code swapped_code
= swap_condition (code
);
8013 return ((ix86_fp_comparison_cost (code
) == ix86_fp_comparison_fcomi_cost (code
))
8014 || (ix86_fp_comparison_cost (swapped_code
)
8015 == ix86_fp_comparison_fcomi_cost (swapped_code
)));
8018 /* Swap, force into registers, or otherwise massage the two operands
8019 to a fp comparison. The operands are updated in place; the new
8020 comparsion code is returned. */
8022 static enum rtx_code
8023 ix86_prepare_fp_compare_args (code
, pop0
, pop1
)
8027 enum machine_mode fpcmp_mode
= ix86_fp_compare_mode (code
);
8028 rtx op0
= *pop0
, op1
= *pop1
;
8029 enum machine_mode op_mode
= GET_MODE (op0
);
8030 int is_sse
= SSE_REG_P (op0
) | SSE_REG_P (op1
);
8032 /* All of the unordered compare instructions only work on registers.
8033 The same is true of the XFmode compare instructions. The same is
8034 true of the fcomi compare instructions. */
8037 && (fpcmp_mode
== CCFPUmode
8038 || op_mode
== XFmode
8039 || op_mode
== TFmode
8040 || ix86_use_fcomi_compare (code
)))
8042 op0
= force_reg (op_mode
, op0
);
8043 op1
= force_reg (op_mode
, op1
);
8047 /* %%% We only allow op1 in memory; op0 must be st(0). So swap
8048 things around if they appear profitable, otherwise force op0
8051 if (standard_80387_constant_p (op0
) == 0
8052 || (GET_CODE (op0
) == MEM
8053 && ! (standard_80387_constant_p (op1
) == 0
8054 || GET_CODE (op1
) == MEM
)))
8057 tmp
= op0
, op0
= op1
, op1
= tmp
;
8058 code
= swap_condition (code
);
8061 if (GET_CODE (op0
) != REG
)
8062 op0
= force_reg (op_mode
, op0
);
8064 if (CONSTANT_P (op1
))
8066 if (standard_80387_constant_p (op1
))
8067 op1
= force_reg (op_mode
, op1
);
8069 op1
= validize_mem (force_const_mem (op_mode
, op1
));
8073 /* Try to rearrange the comparison to make it cheaper. */
8074 if (ix86_fp_comparison_cost (code
)
8075 > ix86_fp_comparison_cost (swap_condition (code
))
8076 && (GET_CODE (op1
) == REG
|| !no_new_pseudos
))
8079 tmp
= op0
, op0
= op1
, op1
= tmp
;
8080 code
= swap_condition (code
);
8081 if (GET_CODE (op0
) != REG
)
8082 op0
= force_reg (op_mode
, op0
);
8090 /* Convert comparison codes we use to represent FP comparison to integer
8091 code that will result in proper branch. Return UNKNOWN if no such code
8093 static enum rtx_code
8094 ix86_fp_compare_code_to_integer (code
)
8124 /* Split comparison code CODE into comparisons we can do using branch
8125 instructions. BYPASS_CODE is comparison code for branch that will
8126 branch around FIRST_CODE and SECOND_CODE. If some of branches
8127 is not required, set value to NIL.
8128 We never require more than two branches. */
8130 ix86_fp_comparison_codes (code
, bypass_code
, first_code
, second_code
)
8131 enum rtx_code code
, *bypass_code
, *first_code
, *second_code
;
8137 /* The fcomi comparison sets flags as follows:
8147 case GT
: /* GTU - CF=0 & ZF=0 */
8148 case GE
: /* GEU - CF=0 */
8149 case ORDERED
: /* PF=0 */
8150 case UNORDERED
: /* PF=1 */
8151 case UNEQ
: /* EQ - ZF=1 */
8152 case UNLT
: /* LTU - CF=1 */
8153 case UNLE
: /* LEU - CF=1 | ZF=1 */
8154 case LTGT
: /* EQ - ZF=0 */
8156 case LT
: /* LTU - CF=1 - fails on unordered */
8158 *bypass_code
= UNORDERED
;
8160 case LE
: /* LEU - CF=1 | ZF=1 - fails on unordered */
8162 *bypass_code
= UNORDERED
;
8164 case EQ
: /* EQ - ZF=1 - fails on unordered */
8166 *bypass_code
= UNORDERED
;
8168 case NE
: /* NE - ZF=0 - fails on unordered */
8170 *second_code
= UNORDERED
;
8172 case UNGE
: /* GEU - CF=0 - fails on unordered */
8174 *second_code
= UNORDERED
;
8176 case UNGT
: /* GTU - CF=0 & ZF=0 - fails on unordered */
8178 *second_code
= UNORDERED
;
8183 if (!TARGET_IEEE_FP
)
8190 /* Return cost of comparison done fcom + arithmetics operations on AX.
8191 All following functions do use number of instructions as an cost metrics.
8192 In future this should be tweaked to compute bytes for optimize_size and
8193 take into account performance of various instructions on various CPUs. */
8195 ix86_fp_comparison_arithmetics_cost (code
)
8198 if (!TARGET_IEEE_FP
)
8200 /* The cost of code output by ix86_expand_fp_compare. */
8228 /* Return cost of comparison done using fcomi operation.
8229 See ix86_fp_comparison_arithmetics_cost for the metrics. */
8231 ix86_fp_comparison_fcomi_cost (code
)
8234 enum rtx_code bypass_code
, first_code
, second_code
;
8235 /* Return arbitarily high cost when instruction is not supported - this
8236 prevents gcc from using it. */
8239 ix86_fp_comparison_codes (code
, &bypass_code
, &first_code
, &second_code
);
8240 return (bypass_code
!= NIL
|| second_code
!= NIL
) + 2;
8243 /* Return cost of comparison done using sahf operation.
8244 See ix86_fp_comparison_arithmetics_cost for the metrics. */
8246 ix86_fp_comparison_sahf_cost (code
)
8249 enum rtx_code bypass_code
, first_code
, second_code
;
8250 /* Return arbitarily high cost when instruction is not preferred - this
8251 avoids gcc from using it. */
8252 if (!TARGET_USE_SAHF
&& !optimize_size
)
8254 ix86_fp_comparison_codes (code
, &bypass_code
, &first_code
, &second_code
);
8255 return (bypass_code
!= NIL
|| second_code
!= NIL
) + 3;
8258 /* Compute cost of the comparison done using any method.
8259 See ix86_fp_comparison_arithmetics_cost for the metrics. */
8261 ix86_fp_comparison_cost (code
)
8264 int fcomi_cost
, sahf_cost
, arithmetics_cost
= 1024;
8267 fcomi_cost
= ix86_fp_comparison_fcomi_cost (code
);
8268 sahf_cost
= ix86_fp_comparison_sahf_cost (code
);
8270 min
= arithmetics_cost
= ix86_fp_comparison_arithmetics_cost (code
);
8271 if (min
> sahf_cost
)
8273 if (min
> fcomi_cost
)
8278 /* Generate insn patterns to do a floating point compare of OPERANDS. */
8281 ix86_expand_fp_compare (code
, op0
, op1
, scratch
, second_test
, bypass_test
)
8283 rtx op0
, op1
, scratch
;
8287 enum machine_mode fpcmp_mode
, intcmp_mode
;
8289 int cost
= ix86_fp_comparison_cost (code
);
8290 enum rtx_code bypass_code
, first_code
, second_code
;
8292 fpcmp_mode
= ix86_fp_compare_mode (code
);
8293 code
= ix86_prepare_fp_compare_args (code
, &op0
, &op1
);
8296 *second_test
= NULL_RTX
;
8298 *bypass_test
= NULL_RTX
;
8300 ix86_fp_comparison_codes (code
, &bypass_code
, &first_code
, &second_code
);
8302 /* Do fcomi/sahf based test when profitable. */
8303 if ((bypass_code
== NIL
|| bypass_test
)
8304 && (second_code
== NIL
|| second_test
)
8305 && ix86_fp_comparison_arithmetics_cost (code
) > cost
)
8309 tmp
= gen_rtx_COMPARE (fpcmp_mode
, op0
, op1
);
8310 tmp
= gen_rtx_SET (VOIDmode
, gen_rtx_REG (fpcmp_mode
, FLAGS_REG
),
8316 tmp
= gen_rtx_COMPARE (fpcmp_mode
, op0
, op1
);
8317 tmp2
= gen_rtx_UNSPEC (HImode
, gen_rtvec (1, tmp
), UNSPEC_FNSTSW
);
8319 scratch
= gen_reg_rtx (HImode
);
8320 emit_insn (gen_rtx_SET (VOIDmode
, scratch
, tmp2
));
8321 emit_insn (gen_x86_sahf_1 (scratch
));
8324 /* The FP codes work out to act like unsigned. */
8325 intcmp_mode
= fpcmp_mode
;
8327 if (bypass_code
!= NIL
)
8328 *bypass_test
= gen_rtx_fmt_ee (bypass_code
, VOIDmode
,
8329 gen_rtx_REG (intcmp_mode
, FLAGS_REG
),
8331 if (second_code
!= NIL
)
8332 *second_test
= gen_rtx_fmt_ee (second_code
, VOIDmode
,
8333 gen_rtx_REG (intcmp_mode
, FLAGS_REG
),
8338 /* Sadness wrt reg-stack pops killing fpsr -- gotta get fnstsw first. */
8339 tmp
= gen_rtx_COMPARE (fpcmp_mode
, op0
, op1
);
8340 tmp2
= gen_rtx_UNSPEC (HImode
, gen_rtvec (1, tmp
), UNSPEC_FNSTSW
);
8342 scratch
= gen_reg_rtx (HImode
);
8343 emit_insn (gen_rtx_SET (VOIDmode
, scratch
, tmp2
));
8345 /* In the unordered case, we have to check C2 for NaN's, which
8346 doesn't happen to work out to anything nice combination-wise.
8347 So do some bit twiddling on the value we've got in AH to come
8348 up with an appropriate set of condition codes. */
8350 intcmp_mode
= CCNOmode
;
8355 if (code
== GT
|| !TARGET_IEEE_FP
)
8357 emit_insn (gen_testqi_ext_ccno_0 (scratch
, GEN_INT (0x45)));
8362 emit_insn (gen_andqi_ext_0 (scratch
, scratch
, GEN_INT (0x45)));
8363 emit_insn (gen_addqi_ext_1 (scratch
, scratch
, constm1_rtx
));
8364 emit_insn (gen_cmpqi_ext_3 (scratch
, GEN_INT (0x44)));
8365 intcmp_mode
= CCmode
;
8371 if (code
== LT
&& TARGET_IEEE_FP
)
8373 emit_insn (gen_andqi_ext_0 (scratch
, scratch
, GEN_INT (0x45)));
8374 emit_insn (gen_cmpqi_ext_3 (scratch
, GEN_INT (0x01)));
8375 intcmp_mode
= CCmode
;
8380 emit_insn (gen_testqi_ext_ccno_0 (scratch
, GEN_INT (0x01)));
8386 if (code
== GE
|| !TARGET_IEEE_FP
)
8388 emit_insn (gen_testqi_ext_ccno_0 (scratch
, GEN_INT (0x05)));
8393 emit_insn (gen_andqi_ext_0 (scratch
, scratch
, GEN_INT (0x45)));
8394 emit_insn (gen_xorqi_cc_ext_1 (scratch
, scratch
,
8401 if (code
== LE
&& TARGET_IEEE_FP
)
8403 emit_insn (gen_andqi_ext_0 (scratch
, scratch
, GEN_INT (0x45)));
8404 emit_insn (gen_addqi_ext_1 (scratch
, scratch
, constm1_rtx
));
8405 emit_insn (gen_cmpqi_ext_3 (scratch
, GEN_INT (0x40)));
8406 intcmp_mode
= CCmode
;
8411 emit_insn (gen_testqi_ext_ccno_0 (scratch
, GEN_INT (0x45)));
8417 if (code
== EQ
&& TARGET_IEEE_FP
)
8419 emit_insn (gen_andqi_ext_0 (scratch
, scratch
, GEN_INT (0x45)));
8420 emit_insn (gen_cmpqi_ext_3 (scratch
, GEN_INT (0x40)));
8421 intcmp_mode
= CCmode
;
8426 emit_insn (gen_testqi_ext_ccno_0 (scratch
, GEN_INT (0x40)));
8433 if (code
== NE
&& TARGET_IEEE_FP
)
8435 emit_insn (gen_andqi_ext_0 (scratch
, scratch
, GEN_INT (0x45)));
8436 emit_insn (gen_xorqi_cc_ext_1 (scratch
, scratch
,
8442 emit_insn (gen_testqi_ext_ccno_0 (scratch
, GEN_INT (0x40)));
8448 emit_insn (gen_testqi_ext_ccno_0 (scratch
, GEN_INT (0x04)));
8452 emit_insn (gen_testqi_ext_ccno_0 (scratch
, GEN_INT (0x04)));
8461 /* Return the test that should be put into the flags user, i.e.
8462 the bcc, scc, or cmov instruction. */
8463 return gen_rtx_fmt_ee (code
, VOIDmode
,
8464 gen_rtx_REG (intcmp_mode
, FLAGS_REG
),
8469 ix86_expand_compare (code
, second_test
, bypass_test
)
8471 rtx
*second_test
, *bypass_test
;
8474 op0
= ix86_compare_op0
;
8475 op1
= ix86_compare_op1
;
8478 *second_test
= NULL_RTX
;
8480 *bypass_test
= NULL_RTX
;
8482 if (GET_MODE_CLASS (GET_MODE (op0
)) == MODE_FLOAT
)
8483 ret
= ix86_expand_fp_compare (code
, op0
, op1
, NULL_RTX
,
8484 second_test
, bypass_test
);
8486 ret
= ix86_expand_int_compare (code
, op0
, op1
);
8491 /* Return true if the CODE will result in nontrivial jump sequence. */
8493 ix86_fp_jump_nontrivial_p (code
)
8496 enum rtx_code bypass_code
, first_code
, second_code
;
8499 ix86_fp_comparison_codes (code
, &bypass_code
, &first_code
, &second_code
);
8500 return bypass_code
!= NIL
|| second_code
!= NIL
;
8504 ix86_expand_branch (code
, label
)
8510 switch (GET_MODE (ix86_compare_op0
))
8516 tmp
= ix86_expand_compare (code
, NULL
, NULL
);
8517 tmp
= gen_rtx_IF_THEN_ELSE (VOIDmode
, tmp
,
8518 gen_rtx_LABEL_REF (VOIDmode
, label
),
8520 emit_jump_insn (gen_rtx_SET (VOIDmode
, pc_rtx
, tmp
));
8530 enum rtx_code bypass_code
, first_code
, second_code
;
8532 code
= ix86_prepare_fp_compare_args (code
, &ix86_compare_op0
,
8535 ix86_fp_comparison_codes (code
, &bypass_code
, &first_code
, &second_code
);
8537 /* Check whether we will use the natural sequence with one jump. If
8538 so, we can expand jump early. Otherwise delay expansion by
8539 creating compound insn to not confuse optimizers. */
8540 if (bypass_code
== NIL
&& second_code
== NIL
8543 ix86_split_fp_branch (code
, ix86_compare_op0
, ix86_compare_op1
,
8544 gen_rtx_LABEL_REF (VOIDmode
, label
),
8549 tmp
= gen_rtx_fmt_ee (code
, VOIDmode
,
8550 ix86_compare_op0
, ix86_compare_op1
);
8551 tmp
= gen_rtx_IF_THEN_ELSE (VOIDmode
, tmp
,
8552 gen_rtx_LABEL_REF (VOIDmode
, label
),
8554 tmp
= gen_rtx_SET (VOIDmode
, pc_rtx
, tmp
);
8556 use_fcomi
= ix86_use_fcomi_compare (code
);
8557 vec
= rtvec_alloc (3 + !use_fcomi
);
8558 RTVEC_ELT (vec
, 0) = tmp
;
8560 = gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (CCFPmode
, 18));
8562 = gen_rtx_CLOBBER (VOIDmode
, gen_rtx_REG (CCFPmode
, 17));
8565 = gen_rtx_CLOBBER (VOIDmode
, gen_rtx_SCRATCH (HImode
));
8567 emit_jump_insn (gen_rtx_PARALLEL (VOIDmode
, vec
));
8575 /* Expand DImode branch into multiple compare+branch. */
8577 rtx lo
[2], hi
[2], label2
;
8578 enum rtx_code code1
, code2
, code3
;
8580 if (CONSTANT_P (ix86_compare_op0
) && ! CONSTANT_P (ix86_compare_op1
))
8582 tmp
= ix86_compare_op0
;
8583 ix86_compare_op0
= ix86_compare_op1
;
8584 ix86_compare_op1
= tmp
;
8585 code
= swap_condition (code
);
8587 split_di (&ix86_compare_op0
, 1, lo
+0, hi
+0);
8588 split_di (&ix86_compare_op1
, 1, lo
+1, hi
+1);
8590 /* When comparing for equality, we can use (hi0^hi1)|(lo0^lo1) to
8591 avoid two branches. This costs one extra insn, so disable when
8592 optimizing for size. */
8594 if ((code
== EQ
|| code
== NE
)
8596 || hi
[1] == const0_rtx
|| lo
[1] == const0_rtx
))
8601 if (hi
[1] != const0_rtx
)
8602 xor1
= expand_binop (SImode
, xor_optab
, xor1
, hi
[1],
8603 NULL_RTX
, 0, OPTAB_WIDEN
);
8606 if (lo
[1] != const0_rtx
)
8607 xor0
= expand_binop (SImode
, xor_optab
, xor0
, lo
[1],
8608 NULL_RTX
, 0, OPTAB_WIDEN
);
8610 tmp
= expand_binop (SImode
, ior_optab
, xor1
, xor0
,
8611 NULL_RTX
, 0, OPTAB_WIDEN
);
8613 ix86_compare_op0
= tmp
;
8614 ix86_compare_op1
= const0_rtx
;
8615 ix86_expand_branch (code
, label
);
8619 /* Otherwise, if we are doing less-than or greater-or-equal-than,
8620 op1 is a constant and the low word is zero, then we can just
8621 examine the high word. */
8623 if (GET_CODE (hi
[1]) == CONST_INT
&& lo
[1] == const0_rtx
)
8626 case LT
: case LTU
: case GE
: case GEU
:
8627 ix86_compare_op0
= hi
[0];
8628 ix86_compare_op1
= hi
[1];
8629 ix86_expand_branch (code
, label
);
8635 /* Otherwise, we need two or three jumps. */
8637 label2
= gen_label_rtx ();
8640 code2
= swap_condition (code
);
8641 code3
= unsigned_condition (code
);
8645 case LT
: case GT
: case LTU
: case GTU
:
8648 case LE
: code1
= LT
; code2
= GT
; break;
8649 case GE
: code1
= GT
; code2
= LT
; break;
8650 case LEU
: code1
= LTU
; code2
= GTU
; break;
8651 case GEU
: code1
= GTU
; code2
= LTU
; break;
8653 case EQ
: code1
= NIL
; code2
= NE
; break;
8654 case NE
: code2
= NIL
; break;
8662 * if (hi(a) < hi(b)) goto true;
8663 * if (hi(a) > hi(b)) goto false;
8664 * if (lo(a) < lo(b)) goto true;
8668 ix86_compare_op0
= hi
[0];
8669 ix86_compare_op1
= hi
[1];
8672 ix86_expand_branch (code1
, label
);
8674 ix86_expand_branch (code2
, label2
);
8676 ix86_compare_op0
= lo
[0];
8677 ix86_compare_op1
= lo
[1];
8678 ix86_expand_branch (code3
, label
);
8681 emit_label (label2
);
8690 /* Split branch based on floating point condition. */
8692 ix86_split_fp_branch (code
, op1
, op2
, target1
, target2
, tmp
)
8694 rtx op1
, op2
, target1
, target2
, tmp
;
8697 rtx label
= NULL_RTX
;
8699 int bypass_probability
= -1, second_probability
= -1, probability
= -1;
8702 if (target2
!= pc_rtx
)
8705 code
= reverse_condition_maybe_unordered (code
);
8710 condition
= ix86_expand_fp_compare (code
, op1
, op2
,
8711 tmp
, &second
, &bypass
);
8713 if (split_branch_probability
>= 0)
8715 /* Distribute the probabilities across the jumps.
8716 Assume the BYPASS and SECOND to be always test
8718 probability
= split_branch_probability
;
8720 /* Value of 1 is low enough to make no need for probability
8721 to be updated. Later we may run some experiments and see
8722 if unordered values are more frequent in practice. */
8724 bypass_probability
= 1;
8726 second_probability
= 1;
8728 if (bypass
!= NULL_RTX
)
8730 label
= gen_label_rtx ();
8731 i
= emit_jump_insn (gen_rtx_SET
8733 gen_rtx_IF_THEN_ELSE (VOIDmode
,
8735 gen_rtx_LABEL_REF (VOIDmode
,
8738 if (bypass_probability
>= 0)
8740 = gen_rtx_EXPR_LIST (REG_BR_PROB
,
8741 GEN_INT (bypass_probability
),
8744 i
= emit_jump_insn (gen_rtx_SET
8746 gen_rtx_IF_THEN_ELSE (VOIDmode
,
8747 condition
, target1
, target2
)));
8748 if (probability
>= 0)
8750 = gen_rtx_EXPR_LIST (REG_BR_PROB
,
8751 GEN_INT (probability
),
8753 if (second
!= NULL_RTX
)
8755 i
= emit_jump_insn (gen_rtx_SET
8757 gen_rtx_IF_THEN_ELSE (VOIDmode
, second
, target1
,
8759 if (second_probability
>= 0)
8761 = gen_rtx_EXPR_LIST (REG_BR_PROB
,
8762 GEN_INT (second_probability
),
8765 if (label
!= NULL_RTX
)
8770 ix86_expand_setcc (code
, dest
)
8774 rtx ret
, tmp
, tmpreg
;
8775 rtx second_test
, bypass_test
;
8777 if (GET_MODE (ix86_compare_op0
) == DImode
8779 return 0; /* FAIL */
8781 if (GET_MODE (dest
) != QImode
)
8784 ret
= ix86_expand_compare (code
, &second_test
, &bypass_test
);
8785 PUT_MODE (ret
, QImode
);
8790 emit_insn (gen_rtx_SET (VOIDmode
, tmp
, ret
));
8791 if (bypass_test
|| second_test
)
8793 rtx test
= second_test
;
8795 rtx tmp2
= gen_reg_rtx (QImode
);
8802 PUT_CODE (test
, reverse_condition_maybe_unordered (GET_CODE (test
)));
8804 PUT_MODE (test
, QImode
);
8805 emit_insn (gen_rtx_SET (VOIDmode
, tmp2
, test
));
8808 emit_insn (gen_andqi3 (tmp
, tmpreg
, tmp2
));
8810 emit_insn (gen_iorqi3 (tmp
, tmpreg
, tmp2
));
8813 return 1; /* DONE */
8817 ix86_expand_int_movcc (operands
)
8820 enum rtx_code code
= GET_CODE (operands
[1]), compare_code
;
8821 rtx compare_seq
, compare_op
;
8822 rtx second_test
, bypass_test
;
8823 enum machine_mode mode
= GET_MODE (operands
[0]);
8825 /* When the compare code is not LTU or GEU, we can not use sbbl case.
8826 In case comparsion is done with immediate, we can convert it to LTU or
8827 GEU by altering the integer. */
8829 if ((code
== LEU
|| code
== GTU
)
8830 && GET_CODE (ix86_compare_op1
) == CONST_INT
8832 && INTVAL (ix86_compare_op1
) != -1
8833 /* For x86-64, the immediate field in the instruction is 32-bit
8834 signed, so we can't increment a DImode value above 0x7fffffff. */
8836 || GET_MODE (ix86_compare_op0
) != DImode
8837 || INTVAL (ix86_compare_op1
) != 0x7fffffff)
8838 && GET_CODE (operands
[2]) == CONST_INT
8839 && GET_CODE (operands
[3]) == CONST_INT
)
8845 ix86_compare_op1
= gen_int_mode (INTVAL (ix86_compare_op1
) + 1,
8846 GET_MODE (ix86_compare_op0
));
8850 compare_op
= ix86_expand_compare (code
, &second_test
, &bypass_test
);
8851 compare_seq
= get_insns ();
8854 compare_code
= GET_CODE (compare_op
);
8856 /* Don't attempt mode expansion here -- if we had to expand 5 or 6
8857 HImode insns, we'd be swallowed in word prefix ops. */
8860 && (mode
!= DImode
|| TARGET_64BIT
)
8861 && GET_CODE (operands
[2]) == CONST_INT
8862 && GET_CODE (operands
[3]) == CONST_INT
)
8864 rtx out
= operands
[0];
8865 HOST_WIDE_INT ct
= INTVAL (operands
[2]);
8866 HOST_WIDE_INT cf
= INTVAL (operands
[3]);
8869 if ((compare_code
== LTU
|| compare_code
== GEU
)
8870 && !second_test
&& !bypass_test
)
8872 /* Detect overlap between destination and compare sources. */
8875 /* To simplify rest of code, restrict to the GEU case. */
8876 if (compare_code
== LTU
)
8881 compare_code
= reverse_condition (compare_code
);
8882 code
= reverse_condition (code
);
8886 if (reg_overlap_mentioned_p (out
, ix86_compare_op0
)
8887 || reg_overlap_mentioned_p (out
, ix86_compare_op1
))
8888 tmp
= gen_reg_rtx (mode
);
8890 emit_insn (compare_seq
);
8892 emit_insn (gen_x86_movdicc_0_m1_rex64 (tmp
));
8894 emit_insn (gen_x86_movsicc_0_m1 (tmp
));
8906 tmp
= expand_simple_binop (mode
, PLUS
,
8908 tmp
, 1, OPTAB_DIRECT
);
8919 tmp
= expand_simple_binop (mode
, IOR
,
8921 tmp
, 1, OPTAB_DIRECT
);
8923 else if (diff
== -1 && ct
)
8933 tmp
= expand_simple_unop (mode
, NOT
, tmp
, tmp
, 1);
8935 tmp
= expand_simple_binop (mode
, PLUS
,
8937 tmp
, 1, OPTAB_DIRECT
);
8945 * andl cf - ct, dest
8955 tmp
= expand_simple_unop (mode
, NOT
, tmp
, tmp
, 1);
8958 tmp
= expand_simple_binop (mode
, AND
,
8960 gen_int_mode (cf
- ct
, mode
),
8961 tmp
, 1, OPTAB_DIRECT
);
8963 tmp
= expand_simple_binop (mode
, PLUS
,
8965 tmp
, 1, OPTAB_DIRECT
);
8969 emit_move_insn (out
, tmp
);
8971 return 1; /* DONE */
8978 tmp
= ct
, ct
= cf
, cf
= tmp
;
8980 if (FLOAT_MODE_P (GET_MODE (ix86_compare_op0
)))
8982 /* We may be reversing unordered compare to normal compare, that
8983 is not valid in general (we may convert non-trapping condition
8984 to trapping one), however on i386 we currently emit all
8985 comparisons unordered. */
8986 compare_code
= reverse_condition_maybe_unordered (compare_code
);
8987 code
= reverse_condition_maybe_unordered (code
);
8991 compare_code
= reverse_condition (compare_code
);
8992 code
= reverse_condition (code
);
8997 if (GET_MODE_CLASS (GET_MODE (ix86_compare_op0
)) == MODE_INT
8998 && GET_CODE (ix86_compare_op1
) == CONST_INT
)
9000 if (ix86_compare_op1
== const0_rtx
9001 && (code
== LT
|| code
== GE
))
9002 compare_code
= code
;
9003 else if (ix86_compare_op1
== constm1_rtx
)
9007 else if (code
== GT
)
9012 /* Optimize dest = (op0 < 0) ? -1 : cf. */
9013 if (compare_code
!= NIL
9014 && GET_MODE (ix86_compare_op0
) == GET_MODE (out
)
9015 && (cf
== -1 || ct
== -1))
9017 /* If lea code below could be used, only optimize
9018 if it results in a 2 insn sequence. */
9020 if (! (diff
== 1 || diff
== 2 || diff
== 4 || diff
== 8
9021 || diff
== 3 || diff
== 5 || diff
== 9)
9022 || (compare_code
== LT
&& ct
== -1)
9023 || (compare_code
== GE
&& cf
== -1))
9026 * notl op1 (if necessary)
9034 code
= reverse_condition (code
);
9037 out
= emit_store_flag (out
, code
, ix86_compare_op0
,
9038 ix86_compare_op1
, VOIDmode
, 0, -1);
9040 out
= expand_simple_binop (mode
, IOR
,
9042 out
, 1, OPTAB_DIRECT
);
9043 if (out
!= operands
[0])
9044 emit_move_insn (operands
[0], out
);
9046 return 1; /* DONE */
9050 if ((diff
== 1 || diff
== 2 || diff
== 4 || diff
== 8
9051 || diff
== 3 || diff
== 5 || diff
== 9)
9052 && (mode
!= DImode
|| x86_64_sign_extended_value (GEN_INT (cf
))))
9058 * lea cf(dest*(ct-cf)),dest
9062 * This also catches the degenerate setcc-only case.
9068 out
= emit_store_flag (out
, code
, ix86_compare_op0
,
9069 ix86_compare_op1
, VOIDmode
, 0, 1);
9072 /* On x86_64 the lea instruction operates on Pmode, so we need
9073 to get arithmetics done in proper mode to match. */
9080 tmp
= gen_rtx_MULT (mode
, out1
, GEN_INT (diff
& ~1));
9084 tmp
= gen_rtx_PLUS (mode
, tmp
, out1
);
9090 tmp
= gen_rtx_PLUS (mode
, tmp
, GEN_INT (cf
));
9094 && (GET_CODE (tmp
) != SUBREG
|| SUBREG_REG (tmp
) != out
))
9100 clob
= gen_rtx_REG (CCmode
, FLAGS_REG
);
9101 clob
= gen_rtx_CLOBBER (VOIDmode
, clob
);
9103 tmp
= gen_rtx_SET (VOIDmode
, out
, tmp
);
9104 tmp
= gen_rtx_PARALLEL (VOIDmode
, gen_rtvec (2, tmp
, clob
));
9108 emit_insn (gen_rtx_SET (VOIDmode
, out
, tmp
));
9110 if (out
!= operands
[0])
9111 emit_move_insn (operands
[0], copy_rtx (out
));
9113 return 1; /* DONE */
9117 * General case: Jumpful:
9118 * xorl dest,dest cmpl op1, op2
9119 * cmpl op1, op2 movl ct, dest
9121 * decl dest movl cf, dest
9122 * andl (cf-ct),dest 1:
9127 * This is reasonably steep, but branch mispredict costs are
9128 * high on modern cpus, so consider failing only if optimizing
9131 * %%% Parameterize branch_cost on the tuning architecture, then
9132 * use that. The 80386 couldn't care less about mispredicts.
9135 if (!optimize_size
&& !TARGET_CMOVE
)
9141 if (FLOAT_MODE_P (GET_MODE (ix86_compare_op0
)))
9142 /* We may be reversing unordered compare to normal compare,
9143 that is not valid in general (we may convert non-trapping
9144 condition to trapping one), however on i386 we currently
9145 emit all comparisons unordered. */
9146 code
= reverse_condition_maybe_unordered (code
);
9149 code
= reverse_condition (code
);
9150 if (compare_code
!= NIL
)
9151 compare_code
= reverse_condition (compare_code
);
9155 if (compare_code
!= NIL
)
9157 /* notl op1 (if needed)
9162 For x < 0 (resp. x <= -1) there will be no notl,
9163 so if possible swap the constants to get rid of the
9165 True/false will be -1/0 while code below (store flag
9166 followed by decrement) is 0/-1, so the constants need
9167 to be exchanged once more. */
9169 if (compare_code
== GE
|| !cf
)
9171 code
= reverse_condition (code
);
9176 HOST_WIDE_INT tmp
= cf
;
9181 out
= emit_store_flag (out
, code
, ix86_compare_op0
,
9182 ix86_compare_op1
, VOIDmode
, 0, -1);
9186 out
= emit_store_flag (out
, code
, ix86_compare_op0
,
9187 ix86_compare_op1
, VOIDmode
, 0, 1);
9189 out
= expand_simple_binop (mode
, PLUS
, out
, constm1_rtx
,
9190 out
, 1, OPTAB_DIRECT
);
9193 out
= expand_simple_binop (mode
, AND
, out
,
9194 gen_int_mode (cf
- ct
, mode
),
9195 out
, 1, OPTAB_DIRECT
);
9197 out
= expand_simple_binop (mode
, PLUS
, out
, GEN_INT (ct
),
9198 out
, 1, OPTAB_DIRECT
);
9199 if (out
!= operands
[0])
9200 emit_move_insn (operands
[0], out
);
9202 return 1; /* DONE */
9208 /* Try a few things more with specific constants and a variable. */
9211 rtx var
, orig_out
, out
, tmp
;
9214 return 0; /* FAIL */
9216 /* If one of the two operands is an interesting constant, load a
9217 constant with the above and mask it in with a logical operation. */
9219 if (GET_CODE (operands
[2]) == CONST_INT
)
9222 if (INTVAL (operands
[2]) == 0)
9223 operands
[3] = constm1_rtx
, op
= and_optab
;
9224 else if (INTVAL (operands
[2]) == -1)
9225 operands
[3] = const0_rtx
, op
= ior_optab
;
9227 return 0; /* FAIL */
9229 else if (GET_CODE (operands
[3]) == CONST_INT
)
9232 if (INTVAL (operands
[3]) == 0)
9233 operands
[2] = constm1_rtx
, op
= and_optab
;
9234 else if (INTVAL (operands
[3]) == -1)
9235 operands
[2] = const0_rtx
, op
= ior_optab
;
9237 return 0; /* FAIL */
9240 return 0; /* FAIL */
9242 orig_out
= operands
[0];
9243 tmp
= gen_reg_rtx (mode
);
9246 /* Recurse to get the constant loaded. */
9247 if (ix86_expand_int_movcc (operands
) == 0)
9248 return 0; /* FAIL */
9250 /* Mask in the interesting variable. */
9251 out
= expand_binop (mode
, op
, var
, tmp
, orig_out
, 0,
9253 if (out
!= orig_out
)
9254 emit_move_insn (orig_out
, out
);
9256 return 1; /* DONE */
9260 * For comparison with above,
9270 if (! nonimmediate_operand (operands
[2], mode
))
9271 operands
[2] = force_reg (mode
, operands
[2]);
9272 if (! nonimmediate_operand (operands
[3], mode
))
9273 operands
[3] = force_reg (mode
, operands
[3]);
9275 if (bypass_test
&& reg_overlap_mentioned_p (operands
[0], operands
[3]))
9277 rtx tmp
= gen_reg_rtx (mode
);
9278 emit_move_insn (tmp
, operands
[3]);
9281 if (second_test
&& reg_overlap_mentioned_p (operands
[0], operands
[2]))
9283 rtx tmp
= gen_reg_rtx (mode
);
9284 emit_move_insn (tmp
, operands
[2]);
9287 if (! register_operand (operands
[2], VOIDmode
)
9288 && ! register_operand (operands
[3], VOIDmode
))
9289 operands
[2] = force_reg (mode
, operands
[2]);
9291 emit_insn (compare_seq
);
9292 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0],
9293 gen_rtx_IF_THEN_ELSE (mode
,
9294 compare_op
, operands
[2],
9297 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0],
9298 gen_rtx_IF_THEN_ELSE (mode
,
9303 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0],
9304 gen_rtx_IF_THEN_ELSE (mode
,
9309 return 1; /* DONE */
9313 ix86_expand_fp_movcc (operands
)
9318 rtx compare_op
, second_test
, bypass_test
;
9320 /* For SF/DFmode conditional moves based on comparisons
9321 in same mode, we may want to use SSE min/max instructions. */
9322 if (((TARGET_SSE_MATH
&& GET_MODE (operands
[0]) == SFmode
)
9323 || (TARGET_SSE2
&& TARGET_SSE_MATH
&& GET_MODE (operands
[0]) == DFmode
))
9324 && GET_MODE (ix86_compare_op0
) == GET_MODE (operands
[0])
9325 /* The SSE comparisons does not support the LTGT/UNEQ pair. */
9327 || (GET_CODE (operands
[1]) != LTGT
&& GET_CODE (operands
[1]) != UNEQ
))
9328 /* We may be called from the post-reload splitter. */
9329 && (!REG_P (operands
[0])
9330 || SSE_REG_P (operands
[0])
9331 || REGNO (operands
[0]) >= FIRST_PSEUDO_REGISTER
))
9333 rtx op0
= ix86_compare_op0
, op1
= ix86_compare_op1
;
9334 code
= GET_CODE (operands
[1]);
9336 /* See if we have (cross) match between comparison operands and
9337 conditional move operands. */
9338 if (rtx_equal_p (operands
[2], op1
))
9343 code
= reverse_condition_maybe_unordered (code
);
9345 if (rtx_equal_p (operands
[2], op0
) && rtx_equal_p (operands
[3], op1
))
9347 /* Check for min operation. */
9350 operands
[0] = force_reg (GET_MODE (operands
[0]), operands
[0]);
9351 if (memory_operand (op0
, VOIDmode
))
9352 op0
= force_reg (GET_MODE (operands
[0]), op0
);
9353 if (GET_MODE (operands
[0]) == SFmode
)
9354 emit_insn (gen_minsf3 (operands
[0], op0
, op1
));
9356 emit_insn (gen_mindf3 (operands
[0], op0
, op1
));
9359 /* Check for max operation. */
9362 operands
[0] = force_reg (GET_MODE (operands
[0]), operands
[0]);
9363 if (memory_operand (op0
, VOIDmode
))
9364 op0
= force_reg (GET_MODE (operands
[0]), op0
);
9365 if (GET_MODE (operands
[0]) == SFmode
)
9366 emit_insn (gen_maxsf3 (operands
[0], op0
, op1
));
9368 emit_insn (gen_maxdf3 (operands
[0], op0
, op1
));
9372 /* Manage condition to be sse_comparison_operator. In case we are
9373 in non-ieee mode, try to canonicalize the destination operand
9374 to be first in the comparison - this helps reload to avoid extra
9376 if (!sse_comparison_operator (operands
[1], VOIDmode
)
9377 || (rtx_equal_p (operands
[0], ix86_compare_op1
) && !TARGET_IEEE_FP
))
9379 rtx tmp
= ix86_compare_op0
;
9380 ix86_compare_op0
= ix86_compare_op1
;
9381 ix86_compare_op1
= tmp
;
9382 operands
[1] = gen_rtx_fmt_ee (swap_condition (GET_CODE (operands
[1])),
9383 VOIDmode
, ix86_compare_op0
,
9386 /* Similary try to manage result to be first operand of conditional
9387 move. We also don't support the NE comparison on SSE, so try to
9389 if ((rtx_equal_p (operands
[0], operands
[3])
9390 && (!TARGET_IEEE_FP
|| GET_CODE (operands
[1]) != EQ
))
9391 || (GET_CODE (operands
[1]) == NE
&& TARGET_IEEE_FP
))
9393 rtx tmp
= operands
[2];
9394 operands
[2] = operands
[3];
9396 operands
[1] = gen_rtx_fmt_ee (reverse_condition_maybe_unordered
9397 (GET_CODE (operands
[1])),
9398 VOIDmode
, ix86_compare_op0
,
9401 if (GET_MODE (operands
[0]) == SFmode
)
9402 emit_insn (gen_sse_movsfcc (operands
[0], operands
[1],
9403 operands
[2], operands
[3],
9404 ix86_compare_op0
, ix86_compare_op1
));
9406 emit_insn (gen_sse_movdfcc (operands
[0], operands
[1],
9407 operands
[2], operands
[3],
9408 ix86_compare_op0
, ix86_compare_op1
));
9412 /* The floating point conditional move instructions don't directly
9413 support conditions resulting from a signed integer comparison. */
9415 code
= GET_CODE (operands
[1]);
9416 compare_op
= ix86_expand_compare (code
, &second_test
, &bypass_test
);
9418 /* The floating point conditional move instructions don't directly
9419 support signed integer comparisons. */
9421 if (!fcmov_comparison_operator (compare_op
, VOIDmode
))
9423 if (second_test
!= NULL
|| bypass_test
!= NULL
)
9425 tmp
= gen_reg_rtx (QImode
);
9426 ix86_expand_setcc (code
, tmp
);
9428 ix86_compare_op0
= tmp
;
9429 ix86_compare_op1
= const0_rtx
;
9430 compare_op
= ix86_expand_compare (code
, &second_test
, &bypass_test
);
9432 if (bypass_test
&& reg_overlap_mentioned_p (operands
[0], operands
[3]))
9434 tmp
= gen_reg_rtx (GET_MODE (operands
[0]));
9435 emit_move_insn (tmp
, operands
[3]);
9438 if (second_test
&& reg_overlap_mentioned_p (operands
[0], operands
[2]))
9440 tmp
= gen_reg_rtx (GET_MODE (operands
[0]));
9441 emit_move_insn (tmp
, operands
[2]);
9445 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0],
9446 gen_rtx_IF_THEN_ELSE (GET_MODE (operands
[0]),
9451 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0],
9452 gen_rtx_IF_THEN_ELSE (GET_MODE (operands
[0]),
9457 emit_insn (gen_rtx_SET (VOIDmode
, operands
[0],
9458 gen_rtx_IF_THEN_ELSE (GET_MODE (operands
[0]),
9466 /* Split operands 0 and 1 into SImode parts. Similar to split_di, but
9467 works for floating pointer parameters and nonoffsetable memories.
9468 For pushes, it returns just stack offsets; the values will be saved
9469 in the right order. Maximally three parts are generated. */
9472 ix86_split_to_parts (operand
, parts
, mode
)
9475 enum machine_mode mode
;
9480 size
= mode
== TFmode
? 3 : (GET_MODE_SIZE (mode
) / 4);
9482 size
= (GET_MODE_SIZE (mode
) + 4) / 8;
9484 if (GET_CODE (operand
) == REG
&& MMX_REGNO_P (REGNO (operand
)))
9486 if (size
< 2 || size
> 3)
9489 /* Optimize constant pool reference to immediates. This is used by fp
9490 moves, that force all constants to memory to allow combining. */
9491 if (GET_CODE (operand
) == MEM
&& RTX_UNCHANGING_P (operand
))
9493 rtx tmp
= maybe_get_pool_constant (operand
);
9498 if (GET_CODE (operand
) == MEM
&& !offsettable_memref_p (operand
))
9500 /* The only non-offsetable memories we handle are pushes. */
9501 if (! push_operand (operand
, VOIDmode
))
9504 operand
= copy_rtx (operand
);
9505 PUT_MODE (operand
, Pmode
);
9506 parts
[0] = parts
[1] = parts
[2] = operand
;
9508 else if (!TARGET_64BIT
)
9511 split_di (&operand
, 1, &parts
[0], &parts
[1]);
9514 if (REG_P (operand
))
9516 if (!reload_completed
)
9518 parts
[0] = gen_rtx_REG (SImode
, REGNO (operand
) + 0);
9519 parts
[1] = gen_rtx_REG (SImode
, REGNO (operand
) + 1);
9521 parts
[2] = gen_rtx_REG (SImode
, REGNO (operand
) + 2);
9523 else if (offsettable_memref_p (operand
))
9525 operand
= adjust_address (operand
, SImode
, 0);
9527 parts
[1] = adjust_address (operand
, SImode
, 4);
9529 parts
[2] = adjust_address (operand
, SImode
, 8);
9531 else if (GET_CODE (operand
) == CONST_DOUBLE
)
9536 REAL_VALUE_FROM_CONST_DOUBLE (r
, operand
);
9541 REAL_VALUE_TO_TARGET_LONG_DOUBLE (r
, l
);
9542 parts
[2] = gen_int_mode (l
[2], SImode
);
9545 REAL_VALUE_TO_TARGET_DOUBLE (r
, l
);
9550 parts
[1] = gen_int_mode (l
[1], SImode
);
9551 parts
[0] = gen_int_mode (l
[0], SImode
);
9560 split_ti (&operand
, 1, &parts
[0], &parts
[1]);
9561 if (mode
== XFmode
|| mode
== TFmode
)
9563 if (REG_P (operand
))
9565 if (!reload_completed
)
9567 parts
[0] = gen_rtx_REG (DImode
, REGNO (operand
) + 0);
9568 parts
[1] = gen_rtx_REG (SImode
, REGNO (operand
) + 1);
9570 else if (offsettable_memref_p (operand
))
9572 operand
= adjust_address (operand
, DImode
, 0);
9574 parts
[1] = adjust_address (operand
, SImode
, 8);
9576 else if (GET_CODE (operand
) == CONST_DOUBLE
)
9581 REAL_VALUE_FROM_CONST_DOUBLE (r
, operand
);
9582 REAL_VALUE_TO_TARGET_LONG_DOUBLE (r
, l
);
9583 /* Do not use shift by 32 to avoid warning on 32bit systems. */
9584 if (HOST_BITS_PER_WIDE_INT
>= 64)
9587 ((l
[0] & (((HOST_WIDE_INT
) 2 << 31) - 1))
9588 + ((((HOST_WIDE_INT
) l
[1]) << 31) << 1),
9591 parts
[0] = immed_double_const (l
[0], l
[1], DImode
);
9592 parts
[1] = gen_int_mode (l
[2], SImode
);
9602 /* Emit insns to perform a move or push of DI, DF, and XF values.
9603 Return false when normal moves are needed; true when all required
9604 insns have been emitted. Operands 2-4 contain the input values
9605 int the correct order; operands 5-7 contain the output values. */
9608 ix86_split_long_move (operands
)
9615 enum machine_mode mode
= GET_MODE (operands
[0]);
9617 /* The DFmode expanders may ask us to move double.
9618 For 64bit target this is single move. By hiding the fact
9619 here we simplify i386.md splitters. */
9620 if (GET_MODE_SIZE (GET_MODE (operands
[0])) == 8 && TARGET_64BIT
)
9622 /* Optimize constant pool reference to immediates. This is used by
9623 fp moves, that force all constants to memory to allow combining. */
9625 if (GET_CODE (operands
[1]) == MEM
9626 && GET_CODE (XEXP (operands
[1], 0)) == SYMBOL_REF
9627 && CONSTANT_POOL_ADDRESS_P (XEXP (operands
[1], 0)))
9628 operands
[1] = get_pool_constant (XEXP (operands
[1], 0));
9629 if (push_operand (operands
[0], VOIDmode
))
9631 operands
[0] = copy_rtx (operands
[0]);
9632 PUT_MODE (operands
[0], Pmode
);
9635 operands
[0] = gen_lowpart (DImode
, operands
[0]);
9636 operands
[1] = gen_lowpart (DImode
, operands
[1]);
9637 emit_move_insn (operands
[0], operands
[1]);
9641 /* The only non-offsettable memory we handle is push. */
9642 if (push_operand (operands
[0], VOIDmode
))
9644 else if (GET_CODE (operands
[0]) == MEM
9645 && ! offsettable_memref_p (operands
[0]))
9648 nparts
= ix86_split_to_parts (operands
[1], part
[1], GET_MODE (operands
[0]));
9649 ix86_split_to_parts (operands
[0], part
[0], GET_MODE (operands
[0]));
9651 /* When emitting push, take care for source operands on the stack. */
9652 if (push
&& GET_CODE (operands
[1]) == MEM
9653 && reg_overlap_mentioned_p (stack_pointer_rtx
, operands
[1]))
9656 part
[1][1] = change_address (part
[1][1], GET_MODE (part
[1][1]),
9657 XEXP (part
[1][2], 0));
9658 part
[1][0] = change_address (part
[1][0], GET_MODE (part
[1][0]),
9659 XEXP (part
[1][1], 0));
9662 /* We need to do copy in the right order in case an address register
9663 of the source overlaps the destination. */
9664 if (REG_P (part
[0][0]) && GET_CODE (part
[1][0]) == MEM
)
9666 if (reg_overlap_mentioned_p (part
[0][0], XEXP (part
[1][0], 0)))
9668 if (reg_overlap_mentioned_p (part
[0][1], XEXP (part
[1][0], 0)))
9671 && reg_overlap_mentioned_p (part
[0][2], XEXP (part
[1][0], 0)))
9674 /* Collision in the middle part can be handled by reordering. */
9675 if (collisions
== 1 && nparts
== 3
9676 && reg_overlap_mentioned_p (part
[0][1], XEXP (part
[1][0], 0)))
9679 tmp
= part
[0][1]; part
[0][1] = part
[0][2]; part
[0][2] = tmp
;
9680 tmp
= part
[1][1]; part
[1][1] = part
[1][2]; part
[1][2] = tmp
;
9683 /* If there are more collisions, we can't handle it by reordering.
9684 Do an lea to the last part and use only one colliding move. */
9685 else if (collisions
> 1)
9688 emit_insn (gen_rtx_SET (VOIDmode
, part
[0][nparts
- 1],
9689 XEXP (part
[1][0], 0)));
9690 part
[1][0] = change_address (part
[1][0],
9691 TARGET_64BIT
? DImode
: SImode
,
9692 part
[0][nparts
- 1]);
9693 part
[1][1] = adjust_address (part
[1][0], VOIDmode
, UNITS_PER_WORD
);
9695 part
[1][2] = adjust_address (part
[1][0], VOIDmode
, 8);
9705 /* We use only first 12 bytes of TFmode value, but for pushing we
9706 are required to adjust stack as if we were pushing real 16byte
9708 if (mode
== TFmode
&& !TARGET_64BIT
)
9709 emit_insn (gen_addsi3 (stack_pointer_rtx
, stack_pointer_rtx
,
9711 emit_move_insn (part
[0][2], part
[1][2]);
9716 /* In 64bit mode we don't have 32bit push available. In case this is
9717 register, it is OK - we will just use larger counterpart. We also
9718 retype memory - these comes from attempt to avoid REX prefix on
9719 moving of second half of TFmode value. */
9720 if (GET_MODE (part
[1][1]) == SImode
)
9722 if (GET_CODE (part
[1][1]) == MEM
)
9723 part
[1][1] = adjust_address (part
[1][1], DImode
, 0);
9724 else if (REG_P (part
[1][1]))
9725 part
[1][1] = gen_rtx_REG (DImode
, REGNO (part
[1][1]));
9728 if (GET_MODE (part
[1][0]) == SImode
)
9729 part
[1][0] = part
[1][1];
9732 emit_move_insn (part
[0][1], part
[1][1]);
9733 emit_move_insn (part
[0][0], part
[1][0]);
9737 /* Choose correct order to not overwrite the source before it is copied. */
9738 if ((REG_P (part
[0][0])
9739 && REG_P (part
[1][1])
9740 && (REGNO (part
[0][0]) == REGNO (part
[1][1])
9742 && REGNO (part
[0][0]) == REGNO (part
[1][2]))))
9744 && reg_overlap_mentioned_p (part
[0][0], XEXP (part
[1][0], 0))))
9748 operands
[2] = part
[0][2];
9749 operands
[3] = part
[0][1];
9750 operands
[4] = part
[0][0];
9751 operands
[5] = part
[1][2];
9752 operands
[6] = part
[1][1];
9753 operands
[7] = part
[1][0];
9757 operands
[2] = part
[0][1];
9758 operands
[3] = part
[0][0];
9759 operands
[5] = part
[1][1];
9760 operands
[6] = part
[1][0];
9767 operands
[2] = part
[0][0];
9768 operands
[3] = part
[0][1];
9769 operands
[4] = part
[0][2];
9770 operands
[5] = part
[1][0];
9771 operands
[6] = part
[1][1];
9772 operands
[7] = part
[1][2];
9776 operands
[2] = part
[0][0];
9777 operands
[3] = part
[0][1];
9778 operands
[5] = part
[1][0];
9779 operands
[6] = part
[1][1];
9782 emit_move_insn (operands
[2], operands
[5]);
9783 emit_move_insn (operands
[3], operands
[6]);
9785 emit_move_insn (operands
[4], operands
[7]);
9791 ix86_split_ashldi (operands
, scratch
)
9792 rtx
*operands
, scratch
;
9794 rtx low
[2], high
[2];
9797 if (GET_CODE (operands
[2]) == CONST_INT
)
9799 split_di (operands
, 2, low
, high
);
9800 count
= INTVAL (operands
[2]) & 63;
9804 emit_move_insn (high
[0], low
[1]);
9805 emit_move_insn (low
[0], const0_rtx
);
9808 emit_insn (gen_ashlsi3 (high
[0], high
[0], GEN_INT (count
- 32)));
9812 if (!rtx_equal_p (operands
[0], operands
[1]))
9813 emit_move_insn (operands
[0], operands
[1]);
9814 emit_insn (gen_x86_shld_1 (high
[0], low
[0], GEN_INT (count
)));
9815 emit_insn (gen_ashlsi3 (low
[0], low
[0], GEN_INT (count
)));
9820 if (!rtx_equal_p (operands
[0], operands
[1]))
9821 emit_move_insn (operands
[0], operands
[1]);
9823 split_di (operands
, 1, low
, high
);
9825 emit_insn (gen_x86_shld_1 (high
[0], low
[0], operands
[2]));
9826 emit_insn (gen_ashlsi3 (low
[0], low
[0], operands
[2]));
9828 if (TARGET_CMOVE
&& (! no_new_pseudos
|| scratch
))
9830 if (! no_new_pseudos
)
9831 scratch
= force_reg (SImode
, const0_rtx
);
9833 emit_move_insn (scratch
, const0_rtx
);
9835 emit_insn (gen_x86_shift_adj_1 (high
[0], low
[0], operands
[2],
9839 emit_insn (gen_x86_shift_adj_2 (high
[0], low
[0], operands
[2]));
9844 ix86_split_ashrdi (operands
, scratch
)
9845 rtx
*operands
, scratch
;
9847 rtx low
[2], high
[2];
9850 if (GET_CODE (operands
[2]) == CONST_INT
)
9852 split_di (operands
, 2, low
, high
);
9853 count
= INTVAL (operands
[2]) & 63;
9857 emit_move_insn (low
[0], high
[1]);
9859 if (! reload_completed
)
9860 emit_insn (gen_ashrsi3 (high
[0], low
[0], GEN_INT (31)));
9863 emit_move_insn (high
[0], low
[0]);
9864 emit_insn (gen_ashrsi3 (high
[0], high
[0], GEN_INT (31)));
9868 emit_insn (gen_ashrsi3 (low
[0], low
[0], GEN_INT (count
- 32)));
9872 if (!rtx_equal_p (operands
[0], operands
[1]))
9873 emit_move_insn (operands
[0], operands
[1]);
9874 emit_insn (gen_x86_shrd_1 (low
[0], high
[0], GEN_INT (count
)));
9875 emit_insn (gen_ashrsi3 (high
[0], high
[0], GEN_INT (count
)));
9880 if (!rtx_equal_p (operands
[0], operands
[1]))
9881 emit_move_insn (operands
[0], operands
[1]);
9883 split_di (operands
, 1, low
, high
);
9885 emit_insn (gen_x86_shrd_1 (low
[0], high
[0], operands
[2]));
9886 emit_insn (gen_ashrsi3 (high
[0], high
[0], operands
[2]));
9888 if (TARGET_CMOVE
&& (! no_new_pseudos
|| scratch
))
9890 if (! no_new_pseudos
)
9891 scratch
= gen_reg_rtx (SImode
);
9892 emit_move_insn (scratch
, high
[0]);
9893 emit_insn (gen_ashrsi3 (scratch
, scratch
, GEN_INT (31)));
9894 emit_insn (gen_x86_shift_adj_1 (low
[0], high
[0], operands
[2],
9898 emit_insn (gen_x86_shift_adj_3 (low
[0], high
[0], operands
[2]));
9903 ix86_split_lshrdi (operands
, scratch
)
9904 rtx
*operands
, scratch
;
9906 rtx low
[2], high
[2];
9909 if (GET_CODE (operands
[2]) == CONST_INT
)
9911 split_di (operands
, 2, low
, high
);
9912 count
= INTVAL (operands
[2]) & 63;
9916 emit_move_insn (low
[0], high
[1]);
9917 emit_move_insn (high
[0], const0_rtx
);
9920 emit_insn (gen_lshrsi3 (low
[0], low
[0], GEN_INT (count
- 32)));
9924 if (!rtx_equal_p (operands
[0], operands
[1]))
9925 emit_move_insn (operands
[0], operands
[1]);
9926 emit_insn (gen_x86_shrd_1 (low
[0], high
[0], GEN_INT (count
)));
9927 emit_insn (gen_lshrsi3 (high
[0], high
[0], GEN_INT (count
)));
9932 if (!rtx_equal_p (operands
[0], operands
[1]))
9933 emit_move_insn (operands
[0], operands
[1]);
9935 split_di (operands
, 1, low
, high
);
9937 emit_insn (gen_x86_shrd_1 (low
[0], high
[0], operands
[2]));
9938 emit_insn (gen_lshrsi3 (high
[0], high
[0], operands
[2]));
9940 /* Heh. By reversing the arguments, we can reuse this pattern. */
9941 if (TARGET_CMOVE
&& (! no_new_pseudos
|| scratch
))
9943 if (! no_new_pseudos
)
9944 scratch
= force_reg (SImode
, const0_rtx
);
9946 emit_move_insn (scratch
, const0_rtx
);
9948 emit_insn (gen_x86_shift_adj_1 (low
[0], high
[0], operands
[2],
9952 emit_insn (gen_x86_shift_adj_2 (low
[0], high
[0], operands
[2]));
9956 /* Helper function for the string operations below. Dest VARIABLE whether
9957 it is aligned to VALUE bytes. If true, jump to the label. */
9959 ix86_expand_aligntest (variable
, value
)
9963 rtx label
= gen_label_rtx ();
9964 rtx tmpcount
= gen_reg_rtx (GET_MODE (variable
));
9965 if (GET_MODE (variable
) == DImode
)
9966 emit_insn (gen_anddi3 (tmpcount
, variable
, GEN_INT (value
)));
9968 emit_insn (gen_andsi3 (tmpcount
, variable
, GEN_INT (value
)));
9969 emit_cmp_and_jump_insns (tmpcount
, const0_rtx
, EQ
, 0, GET_MODE (variable
),
9974 /* Adjust COUNTER by the VALUE. */
9976 ix86_adjust_counter (countreg
, value
)
9978 HOST_WIDE_INT value
;
9980 if (GET_MODE (countreg
) == DImode
)
9981 emit_insn (gen_adddi3 (countreg
, countreg
, GEN_INT (-value
)));
9983 emit_insn (gen_addsi3 (countreg
, countreg
, GEN_INT (-value
)));
9986 /* Zero extend possibly SImode EXP to Pmode register. */
9988 ix86_zero_extend_to_Pmode (exp
)
9992 if (GET_MODE (exp
) == VOIDmode
)
9993 return force_reg (Pmode
, exp
);
9994 if (GET_MODE (exp
) == Pmode
)
9995 return copy_to_mode_reg (Pmode
, exp
);
9996 r
= gen_reg_rtx (Pmode
);
9997 emit_insn (gen_zero_extendsidi2 (r
, exp
));
10001 /* Expand string move (memcpy) operation. Use i386 string operations when
10002 profitable. expand_clrstr contains similar code. */
10004 ix86_expand_movstr (dst
, src
, count_exp
, align_exp
)
10005 rtx dst
, src
, count_exp
, align_exp
;
10007 rtx srcreg
, destreg
, countreg
;
10008 enum machine_mode counter_mode
;
10009 HOST_WIDE_INT align
= 0;
10010 unsigned HOST_WIDE_INT count
= 0;
10015 if (GET_CODE (align_exp
) == CONST_INT
)
10016 align
= INTVAL (align_exp
);
10018 /* This simple hack avoids all inlining code and simplifies code below. */
10019 if (!TARGET_ALIGN_STRINGOPS
)
10022 if (GET_CODE (count_exp
) == CONST_INT
)
10023 count
= INTVAL (count_exp
);
10025 /* Figure out proper mode for counter. For 32bits it is always SImode,
10026 for 64bits use SImode when possible, otherwise DImode.
10027 Set count to number of bytes copied when known at compile time. */
10028 if (!TARGET_64BIT
|| GET_MODE (count_exp
) == SImode
10029 || x86_64_zero_extended_value (count_exp
))
10030 counter_mode
= SImode
;
10032 counter_mode
= DImode
;
10034 if (counter_mode
!= SImode
&& counter_mode
!= DImode
)
10037 destreg
= copy_to_mode_reg (Pmode
, XEXP (dst
, 0));
10038 srcreg
= copy_to_mode_reg (Pmode
, XEXP (src
, 0));
10040 emit_insn (gen_cld ());
10042 /* When optimizing for size emit simple rep ; movsb instruction for
10043 counts not divisible by 4. */
10045 if ((!optimize
|| optimize_size
) && (count
== 0 || (count
& 0x03)))
10047 countreg
= ix86_zero_extend_to_Pmode (count_exp
);
10049 emit_insn (gen_rep_movqi_rex64 (destreg
, srcreg
, countreg
,
10050 destreg
, srcreg
, countreg
));
10052 emit_insn (gen_rep_movqi (destreg
, srcreg
, countreg
,
10053 destreg
, srcreg
, countreg
));
10056 /* For constant aligned (or small unaligned) copies use rep movsl
10057 followed by code copying the rest. For PentiumPro ensure 8 byte
10058 alignment to allow rep movsl acceleration. */
10060 else if (count
!= 0
10062 || (!TARGET_PENTIUMPRO
&& !TARGET_64BIT
&& align
>= 4)
10063 || optimize_size
|| count
< (unsigned int) 64))
10065 int size
= TARGET_64BIT
&& !optimize_size
? 8 : 4;
10066 if (count
& ~(size
- 1))
10068 countreg
= copy_to_mode_reg (counter_mode
,
10069 GEN_INT ((count
>> (size
== 4 ? 2 : 3))
10070 & (TARGET_64BIT
? -1 : 0x3fffffff)));
10071 countreg
= ix86_zero_extend_to_Pmode (countreg
);
10075 emit_insn (gen_rep_movsi_rex64 (destreg
, srcreg
, countreg
,
10076 destreg
, srcreg
, countreg
));
10078 emit_insn (gen_rep_movsi (destreg
, srcreg
, countreg
,
10079 destreg
, srcreg
, countreg
));
10082 emit_insn (gen_rep_movdi_rex64 (destreg
, srcreg
, countreg
,
10083 destreg
, srcreg
, countreg
));
10085 if (size
== 8 && (count
& 0x04))
10086 emit_insn (gen_strmovsi (destreg
, srcreg
));
10088 emit_insn (gen_strmovhi (destreg
, srcreg
));
10090 emit_insn (gen_strmovqi (destreg
, srcreg
));
10092 /* The generic code based on the glibc implementation:
10093 - align destination to 4 bytes (8 byte alignment is used for PentiumPro
10094 allowing accelerated copying there)
10095 - copy the data using rep movsl
10096 - copy the rest. */
10101 int desired_alignment
= (TARGET_PENTIUMPRO
10102 && (count
== 0 || count
>= (unsigned int) 260)
10103 ? 8 : UNITS_PER_WORD
);
10105 /* In case we don't know anything about the alignment, default to
10106 library version, since it is usually equally fast and result in
10108 if (!TARGET_INLINE_ALL_STRINGOPS
&& align
< UNITS_PER_WORD
)
10114 if (TARGET_SINGLE_STRINGOP
)
10115 emit_insn (gen_cld ());
10117 countreg2
= gen_reg_rtx (Pmode
);
10118 countreg
= copy_to_mode_reg (counter_mode
, count_exp
);
10120 /* We don't use loops to align destination and to copy parts smaller
10121 than 4 bytes, because gcc is able to optimize such code better (in
10122 the case the destination or the count really is aligned, gcc is often
10123 able to predict the branches) and also it is friendlier to the
10124 hardware branch prediction.
10126 Using loops is benefical for generic case, because we can
10127 handle small counts using the loops. Many CPUs (such as Athlon)
10128 have large REP prefix setup costs.
10130 This is quite costy. Maybe we can revisit this decision later or
10131 add some customizability to this code. */
10133 if (count
== 0 && align
< desired_alignment
)
10135 label
= gen_label_rtx ();
10136 emit_cmp_and_jump_insns (countreg
, GEN_INT (desired_alignment
- 1),
10137 LEU
, 0, counter_mode
, 1, label
);
10141 rtx label
= ix86_expand_aligntest (destreg
, 1);
10142 emit_insn (gen_strmovqi (destreg
, srcreg
));
10143 ix86_adjust_counter (countreg
, 1);
10144 emit_label (label
);
10145 LABEL_NUSES (label
) = 1;
10149 rtx label
= ix86_expand_aligntest (destreg
, 2);
10150 emit_insn (gen_strmovhi (destreg
, srcreg
));
10151 ix86_adjust_counter (countreg
, 2);
10152 emit_label (label
);
10153 LABEL_NUSES (label
) = 1;
10155 if (align
<= 4 && desired_alignment
> 4)
10157 rtx label
= ix86_expand_aligntest (destreg
, 4);
10158 emit_insn (gen_strmovsi (destreg
, srcreg
));
10159 ix86_adjust_counter (countreg
, 4);
10160 emit_label (label
);
10161 LABEL_NUSES (label
) = 1;
10164 if (label
&& desired_alignment
> 4 && !TARGET_64BIT
)
10166 emit_label (label
);
10167 LABEL_NUSES (label
) = 1;
10170 if (!TARGET_SINGLE_STRINGOP
)
10171 emit_insn (gen_cld ());
10174 emit_insn (gen_lshrdi3 (countreg2
, ix86_zero_extend_to_Pmode (countreg
),
10176 emit_insn (gen_rep_movdi_rex64 (destreg
, srcreg
, countreg2
,
10177 destreg
, srcreg
, countreg2
));
10181 emit_insn (gen_lshrsi3 (countreg2
, countreg
, GEN_INT (2)));
10182 emit_insn (gen_rep_movsi (destreg
, srcreg
, countreg2
,
10183 destreg
, srcreg
, countreg2
));
10188 emit_label (label
);
10189 LABEL_NUSES (label
) = 1;
10191 if (TARGET_64BIT
&& align
> 4 && count
!= 0 && (count
& 4))
10192 emit_insn (gen_strmovsi (destreg
, srcreg
));
10193 if ((align
<= 4 || count
== 0) && TARGET_64BIT
)
10195 rtx label
= ix86_expand_aligntest (countreg
, 4);
10196 emit_insn (gen_strmovsi (destreg
, srcreg
));
10197 emit_label (label
);
10198 LABEL_NUSES (label
) = 1;
10200 if (align
> 2 && count
!= 0 && (count
& 2))
10201 emit_insn (gen_strmovhi (destreg
, srcreg
));
10202 if (align
<= 2 || count
== 0)
10204 rtx label
= ix86_expand_aligntest (countreg
, 2);
10205 emit_insn (gen_strmovhi (destreg
, srcreg
));
10206 emit_label (label
);
10207 LABEL_NUSES (label
) = 1;
10209 if (align
> 1 && count
!= 0 && (count
& 1))
10210 emit_insn (gen_strmovqi (destreg
, srcreg
));
10211 if (align
<= 1 || count
== 0)
10213 rtx label
= ix86_expand_aligntest (countreg
, 1);
10214 emit_insn (gen_strmovqi (destreg
, srcreg
));
10215 emit_label (label
);
10216 LABEL_NUSES (label
) = 1;
10220 insns
= get_insns ();
10223 ix86_set_move_mem_attrs (insns
, dst
, src
, destreg
, srcreg
);
10228 /* Expand string clear operation (bzero). Use i386 string operations when
10229 profitable. expand_movstr contains similar code. */
10231 ix86_expand_clrstr (src
, count_exp
, align_exp
)
10232 rtx src
, count_exp
, align_exp
;
10234 rtx destreg
, zeroreg
, countreg
;
10235 enum machine_mode counter_mode
;
10236 HOST_WIDE_INT align
= 0;
10237 unsigned HOST_WIDE_INT count
= 0;
10239 if (GET_CODE (align_exp
) == CONST_INT
)
10240 align
= INTVAL (align_exp
);
10242 /* This simple hack avoids all inlining code and simplifies code below. */
10243 if (!TARGET_ALIGN_STRINGOPS
)
10246 if (GET_CODE (count_exp
) == CONST_INT
)
10247 count
= INTVAL (count_exp
);
10248 /* Figure out proper mode for counter. For 32bits it is always SImode,
10249 for 64bits use SImode when possible, otherwise DImode.
10250 Set count to number of bytes copied when known at compile time. */
10251 if (!TARGET_64BIT
|| GET_MODE (count_exp
) == SImode
10252 || x86_64_zero_extended_value (count_exp
))
10253 counter_mode
= SImode
;
10255 counter_mode
= DImode
;
10257 destreg
= copy_to_mode_reg (Pmode
, XEXP (src
, 0));
10259 emit_insn (gen_cld ());
10261 /* When optimizing for size emit simple rep ; movsb instruction for
10262 counts not divisible by 4. */
10264 if ((!optimize
|| optimize_size
) && (count
== 0 || (count
& 0x03)))
10266 countreg
= ix86_zero_extend_to_Pmode (count_exp
);
10267 zeroreg
= copy_to_mode_reg (QImode
, const0_rtx
);
10269 emit_insn (gen_rep_stosqi_rex64 (destreg
, countreg
, zeroreg
,
10270 destreg
, countreg
));
10272 emit_insn (gen_rep_stosqi (destreg
, countreg
, zeroreg
,
10273 destreg
, countreg
));
10275 else if (count
!= 0
10277 || (!TARGET_PENTIUMPRO
&& !TARGET_64BIT
&& align
>= 4)
10278 || optimize_size
|| count
< (unsigned int) 64))
10280 int size
= TARGET_64BIT
&& !optimize_size
? 8 : 4;
10281 zeroreg
= copy_to_mode_reg (size
== 4 ? SImode
: DImode
, const0_rtx
);
10282 if (count
& ~(size
- 1))
10284 countreg
= copy_to_mode_reg (counter_mode
,
10285 GEN_INT ((count
>> (size
== 4 ? 2 : 3))
10286 & (TARGET_64BIT
? -1 : 0x3fffffff)));
10287 countreg
= ix86_zero_extend_to_Pmode (countreg
);
10291 emit_insn (gen_rep_stossi_rex64 (destreg
, countreg
, zeroreg
,
10292 destreg
, countreg
));
10294 emit_insn (gen_rep_stossi (destreg
, countreg
, zeroreg
,
10295 destreg
, countreg
));
10298 emit_insn (gen_rep_stosdi_rex64 (destreg
, countreg
, zeroreg
,
10299 destreg
, countreg
));
10301 if (size
== 8 && (count
& 0x04))
10302 emit_insn (gen_strsetsi (destreg
,
10303 gen_rtx_SUBREG (SImode
, zeroreg
, 0)));
10305 emit_insn (gen_strsethi (destreg
,
10306 gen_rtx_SUBREG (HImode
, zeroreg
, 0)));
10308 emit_insn (gen_strsetqi (destreg
,
10309 gen_rtx_SUBREG (QImode
, zeroreg
, 0)));
10315 /* Compute desired alignment of the string operation. */
10316 int desired_alignment
= (TARGET_PENTIUMPRO
10317 && (count
== 0 || count
>= (unsigned int) 260)
10318 ? 8 : UNITS_PER_WORD
);
10320 /* In case we don't know anything about the alignment, default to
10321 library version, since it is usually equally fast and result in
10323 if (!TARGET_INLINE_ALL_STRINGOPS
&& align
< UNITS_PER_WORD
)
10326 if (TARGET_SINGLE_STRINGOP
)
10327 emit_insn (gen_cld ());
10329 countreg2
= gen_reg_rtx (Pmode
);
10330 countreg
= copy_to_mode_reg (counter_mode
, count_exp
);
10331 zeroreg
= copy_to_mode_reg (Pmode
, const0_rtx
);
10333 if (count
== 0 && align
< desired_alignment
)
10335 label
= gen_label_rtx ();
10336 emit_cmp_and_jump_insns (countreg
, GEN_INT (desired_alignment
- 1),
10337 LEU
, 0, counter_mode
, 1, label
);
10341 rtx label
= ix86_expand_aligntest (destreg
, 1);
10342 emit_insn (gen_strsetqi (destreg
,
10343 gen_rtx_SUBREG (QImode
, zeroreg
, 0)));
10344 ix86_adjust_counter (countreg
, 1);
10345 emit_label (label
);
10346 LABEL_NUSES (label
) = 1;
10350 rtx label
= ix86_expand_aligntest (destreg
, 2);
10351 emit_insn (gen_strsethi (destreg
,
10352 gen_rtx_SUBREG (HImode
, zeroreg
, 0)));
10353 ix86_adjust_counter (countreg
, 2);
10354 emit_label (label
);
10355 LABEL_NUSES (label
) = 1;
10357 if (align
<= 4 && desired_alignment
> 4)
10359 rtx label
= ix86_expand_aligntest (destreg
, 4);
10360 emit_insn (gen_strsetsi (destreg
, (TARGET_64BIT
10361 ? gen_rtx_SUBREG (SImode
, zeroreg
, 0)
10363 ix86_adjust_counter (countreg
, 4);
10364 emit_label (label
);
10365 LABEL_NUSES (label
) = 1;
10368 if (label
&& desired_alignment
> 4 && !TARGET_64BIT
)
10370 emit_label (label
);
10371 LABEL_NUSES (label
) = 1;
10375 if (!TARGET_SINGLE_STRINGOP
)
10376 emit_insn (gen_cld ());
10379 emit_insn (gen_lshrdi3 (countreg2
, ix86_zero_extend_to_Pmode (countreg
),
10381 emit_insn (gen_rep_stosdi_rex64 (destreg
, countreg2
, zeroreg
,
10382 destreg
, countreg2
));
10386 emit_insn (gen_lshrsi3 (countreg2
, countreg
, GEN_INT (2)));
10387 emit_insn (gen_rep_stossi (destreg
, countreg2
, zeroreg
,
10388 destreg
, countreg2
));
10392 emit_label (label
);
10393 LABEL_NUSES (label
) = 1;
10396 if (TARGET_64BIT
&& align
> 4 && count
!= 0 && (count
& 4))
10397 emit_insn (gen_strsetsi (destreg
,
10398 gen_rtx_SUBREG (SImode
, zeroreg
, 0)));
10399 if (TARGET_64BIT
&& (align
<= 4 || count
== 0))
10401 rtx label
= ix86_expand_aligntest (countreg
, 4);
10402 emit_insn (gen_strsetsi (destreg
,
10403 gen_rtx_SUBREG (SImode
, zeroreg
, 0)));
10404 emit_label (label
);
10405 LABEL_NUSES (label
) = 1;
10407 if (align
> 2 && count
!= 0 && (count
& 2))
10408 emit_insn (gen_strsethi (destreg
,
10409 gen_rtx_SUBREG (HImode
, zeroreg
, 0)));
10410 if (align
<= 2 || count
== 0)
10412 rtx label
= ix86_expand_aligntest (countreg
, 2);
10413 emit_insn (gen_strsethi (destreg
,
10414 gen_rtx_SUBREG (HImode
, zeroreg
, 0)));
10415 emit_label (label
);
10416 LABEL_NUSES (label
) = 1;
10418 if (align
> 1 && count
!= 0 && (count
& 1))
10419 emit_insn (gen_strsetqi (destreg
,
10420 gen_rtx_SUBREG (QImode
, zeroreg
, 0)));
10421 if (align
<= 1 || count
== 0)
10423 rtx label
= ix86_expand_aligntest (countreg
, 1);
10424 emit_insn (gen_strsetqi (destreg
,
10425 gen_rtx_SUBREG (QImode
, zeroreg
, 0)));
10426 emit_label (label
);
10427 LABEL_NUSES (label
) = 1;
10432 /* Expand strlen. */
10434 ix86_expand_strlen (out
, src
, eoschar
, align
)
10435 rtx out
, src
, eoschar
, align
;
10437 rtx addr
, scratch1
, scratch2
, scratch3
, scratch4
;
10439 /* The generic case of strlen expander is long. Avoid it's
10440 expanding unless TARGET_INLINE_ALL_STRINGOPS. */
10442 if (TARGET_UNROLL_STRLEN
&& eoschar
== const0_rtx
&& optimize
> 1
10443 && !TARGET_INLINE_ALL_STRINGOPS
10445 && (GET_CODE (align
) != CONST_INT
|| INTVAL (align
) < 4))
10448 addr
= force_reg (Pmode
, XEXP (src
, 0));
10449 scratch1
= gen_reg_rtx (Pmode
);
10451 if (TARGET_UNROLL_STRLEN
&& eoschar
== const0_rtx
&& optimize
> 1
10454 /* Well it seems that some optimizer does not combine a call like
10455 foo(strlen(bar), strlen(bar));
10456 when the move and the subtraction is done here. It does calculate
10457 the length just once when these instructions are done inside of
10458 output_strlen_unroll(). But I think since &bar[strlen(bar)] is
10459 often used and I use one fewer register for the lifetime of
10460 output_strlen_unroll() this is better. */
10462 emit_move_insn (out
, addr
);
10464 ix86_expand_strlensi_unroll_1 (out
, align
);
10466 /* strlensi_unroll_1 returns the address of the zero at the end of
10467 the string, like memchr(), so compute the length by subtracting
10468 the start address. */
10470 emit_insn (gen_subdi3 (out
, out
, addr
));
10472 emit_insn (gen_subsi3 (out
, out
, addr
));
10476 scratch2
= gen_reg_rtx (Pmode
);
10477 scratch3
= gen_reg_rtx (Pmode
);
10478 scratch4
= force_reg (Pmode
, constm1_rtx
);
10480 emit_move_insn (scratch3
, addr
);
10481 eoschar
= force_reg (QImode
, eoschar
);
10483 emit_insn (gen_cld ());
10486 emit_insn (gen_strlenqi_rex_1 (scratch1
, scratch3
, eoschar
,
10487 align
, scratch4
, scratch3
));
10488 emit_insn (gen_one_cmpldi2 (scratch2
, scratch1
));
10489 emit_insn (gen_adddi3 (out
, scratch2
, constm1_rtx
));
10493 emit_insn (gen_strlenqi_1 (scratch1
, scratch3
, eoschar
,
10494 align
, scratch4
, scratch3
));
10495 emit_insn (gen_one_cmplsi2 (scratch2
, scratch1
));
10496 emit_insn (gen_addsi3 (out
, scratch2
, constm1_rtx
));
10502 /* Expand the appropriate insns for doing strlen if not just doing
10505 out = result, initialized with the start address
10506 align_rtx = alignment of the address.
10507 scratch = scratch register, initialized with the startaddress when
10508 not aligned, otherwise undefined
10510 This is just the body. It needs the initialisations mentioned above and
10511 some address computing at the end. These things are done in i386.md. */
10514 ix86_expand_strlensi_unroll_1 (out
, align_rtx
)
10515 rtx out
, align_rtx
;
10519 rtx align_2_label
= NULL_RTX
;
10520 rtx align_3_label
= NULL_RTX
;
10521 rtx align_4_label
= gen_label_rtx ();
10522 rtx end_0_label
= gen_label_rtx ();
10524 rtx tmpreg
= gen_reg_rtx (SImode
);
10525 rtx scratch
= gen_reg_rtx (SImode
);
10528 if (GET_CODE (align_rtx
) == CONST_INT
)
10529 align
= INTVAL (align_rtx
);
10531 /* Loop to check 1..3 bytes for null to get an aligned pointer. */
10533 /* Is there a known alignment and is it less than 4? */
10536 rtx scratch1
= gen_reg_rtx (Pmode
);
10537 emit_move_insn (scratch1
, out
);
10538 /* Is there a known alignment and is it not 2? */
10541 align_3_label
= gen_label_rtx (); /* Label when aligned to 3-byte */
10542 align_2_label
= gen_label_rtx (); /* Label when aligned to 2-byte */
10544 /* Leave just the 3 lower bits. */
10545 align_rtx
= expand_binop (Pmode
, and_optab
, scratch1
, GEN_INT (3),
10546 NULL_RTX
, 0, OPTAB_WIDEN
);
10548 emit_cmp_and_jump_insns (align_rtx
, const0_rtx
, EQ
, NULL
,
10549 Pmode
, 1, align_4_label
);
10550 emit_cmp_and_jump_insns (align_rtx
, GEN_INT (2), EQ
, NULL
,
10551 Pmode
, 1, align_2_label
);
10552 emit_cmp_and_jump_insns (align_rtx
, GEN_INT (2), GTU
, NULL
,
10553 Pmode
, 1, align_3_label
);
10557 /* Since the alignment is 2, we have to check 2 or 0 bytes;
10558 check if is aligned to 4 - byte. */
10560 align_rtx
= expand_binop (Pmode
, and_optab
, scratch1
, GEN_INT (2),
10561 NULL_RTX
, 0, OPTAB_WIDEN
);
10563 emit_cmp_and_jump_insns (align_rtx
, const0_rtx
, EQ
, NULL
,
10564 Pmode
, 1, align_4_label
);
10567 mem
= gen_rtx_MEM (QImode
, out
);
10569 /* Now compare the bytes. */
10571 /* Compare the first n unaligned byte on a byte per byte basis. */
10572 emit_cmp_and_jump_insns (mem
, const0_rtx
, EQ
, NULL
,
10573 QImode
, 1, end_0_label
);
10575 /* Increment the address. */
10577 emit_insn (gen_adddi3 (out
, out
, const1_rtx
));
10579 emit_insn (gen_addsi3 (out
, out
, const1_rtx
));
10581 /* Not needed with an alignment of 2 */
10584 emit_label (align_2_label
);
10586 emit_cmp_and_jump_insns (mem
, const0_rtx
, EQ
, NULL
, QImode
, 1,
10590 emit_insn (gen_adddi3 (out
, out
, const1_rtx
));
10592 emit_insn (gen_addsi3 (out
, out
, const1_rtx
));
10594 emit_label (align_3_label
);
10597 emit_cmp_and_jump_insns (mem
, const0_rtx
, EQ
, NULL
, QImode
, 1,
10601 emit_insn (gen_adddi3 (out
, out
, const1_rtx
));
10603 emit_insn (gen_addsi3 (out
, out
, const1_rtx
));
10606 /* Generate loop to check 4 bytes at a time. It is not a good idea to
10607 align this loop. It gives only huge programs, but does not help to
10609 emit_label (align_4_label
);
10611 mem
= gen_rtx_MEM (SImode
, out
);
10612 emit_move_insn (scratch
, mem
);
10614 emit_insn (gen_adddi3 (out
, out
, GEN_INT (4)));
10616 emit_insn (gen_addsi3 (out
, out
, GEN_INT (4)));
10618 /* This formula yields a nonzero result iff one of the bytes is zero.
10619 This saves three branches inside loop and many cycles. */
10621 emit_insn (gen_addsi3 (tmpreg
, scratch
, GEN_INT (-0x01010101)));
10622 emit_insn (gen_one_cmplsi2 (scratch
, scratch
));
10623 emit_insn (gen_andsi3 (tmpreg
, tmpreg
, scratch
));
10624 emit_insn (gen_andsi3 (tmpreg
, tmpreg
,
10625 gen_int_mode (0x80808080, SImode
)));
10626 emit_cmp_and_jump_insns (tmpreg
, const0_rtx
, EQ
, 0, SImode
, 1,
10631 rtx reg
= gen_reg_rtx (SImode
);
10632 rtx reg2
= gen_reg_rtx (Pmode
);
10633 emit_move_insn (reg
, tmpreg
);
10634 emit_insn (gen_lshrsi3 (reg
, reg
, GEN_INT (16)));
10636 /* If zero is not in the first two bytes, move two bytes forward. */
10637 emit_insn (gen_testsi_ccno_1 (tmpreg
, GEN_INT (0x8080)));
10638 tmp
= gen_rtx_REG (CCNOmode
, FLAGS_REG
);
10639 tmp
= gen_rtx_EQ (VOIDmode
, tmp
, const0_rtx
);
10640 emit_insn (gen_rtx_SET (VOIDmode
, tmpreg
,
10641 gen_rtx_IF_THEN_ELSE (SImode
, tmp
,
10644 /* Emit lea manually to avoid clobbering of flags. */
10645 emit_insn (gen_rtx_SET (SImode
, reg2
,
10646 gen_rtx_PLUS (Pmode
, out
, GEN_INT (2))));
10648 tmp
= gen_rtx_REG (CCNOmode
, FLAGS_REG
);
10649 tmp
= gen_rtx_EQ (VOIDmode
, tmp
, const0_rtx
);
10650 emit_insn (gen_rtx_SET (VOIDmode
, out
,
10651 gen_rtx_IF_THEN_ELSE (Pmode
, tmp
,
10658 rtx end_2_label
= gen_label_rtx ();
10659 /* Is zero in the first two bytes? */
10661 emit_insn (gen_testsi_ccno_1 (tmpreg
, GEN_INT (0x8080)));
10662 tmp
= gen_rtx_REG (CCNOmode
, FLAGS_REG
);
10663 tmp
= gen_rtx_NE (VOIDmode
, tmp
, const0_rtx
);
10664 tmp
= gen_rtx_IF_THEN_ELSE (VOIDmode
, tmp
,
10665 gen_rtx_LABEL_REF (VOIDmode
, end_2_label
),
10667 tmp
= emit_jump_insn (gen_rtx_SET (VOIDmode
, pc_rtx
, tmp
));
10668 JUMP_LABEL (tmp
) = end_2_label
;
10670 /* Not in the first two. Move two bytes forward. */
10671 emit_insn (gen_lshrsi3 (tmpreg
, tmpreg
, GEN_INT (16)));
10673 emit_insn (gen_adddi3 (out
, out
, GEN_INT (2)));
10675 emit_insn (gen_addsi3 (out
, out
, GEN_INT (2)));
10677 emit_label (end_2_label
);
10681 /* Avoid branch in fixing the byte. */
10682 tmpreg
= gen_lowpart (QImode
, tmpreg
);
10683 emit_insn (gen_addqi3_cc (tmpreg
, tmpreg
, tmpreg
));
10685 emit_insn (gen_subdi3_carry_rex64 (out
, out
, GEN_INT (3)));
10687 emit_insn (gen_subsi3_carry (out
, out
, GEN_INT (3)));
10689 emit_label (end_0_label
);
10693 ix86_expand_call (retval
, fnaddr
, callarg1
, callarg2
, pop
)
10694 rtx retval
, fnaddr
, callarg1
, callarg2
, pop
;
10696 rtx use
= NULL
, call
;
10698 if (pop
== const0_rtx
)
10700 if (TARGET_64BIT
&& pop
)
10704 if (flag_pic
&& GET_CODE (XEXP (fnaddr
, 0)) == SYMBOL_REF
)
10705 fnaddr
= machopic_indirect_call_target (fnaddr
);
10707 /* Static functions and indirect calls don't need the pic register. */
10708 if (! TARGET_64BIT
&& flag_pic
10709 && GET_CODE (XEXP (fnaddr
, 0)) == SYMBOL_REF
10710 && ! SYMBOL_REF_FLAG (XEXP (fnaddr
, 0)))
10711 use_reg (&use
, pic_offset_table_rtx
);
10713 if (TARGET_64BIT
&& INTVAL (callarg2
) >= 0)
10715 rtx al
= gen_rtx_REG (QImode
, 0);
10716 emit_move_insn (al
, callarg2
);
10717 use_reg (&use
, al
);
10719 #endif /* TARGET_MACHO */
10721 if (! call_insn_operand (XEXP (fnaddr
, 0), Pmode
))
10723 fnaddr
= copy_to_mode_reg (Pmode
, XEXP (fnaddr
, 0));
10724 fnaddr
= gen_rtx_MEM (QImode
, fnaddr
);
10727 call
= gen_rtx_CALL (VOIDmode
, fnaddr
, callarg1
);
10729 call
= gen_rtx_SET (VOIDmode
, retval
, call
);
10732 pop
= gen_rtx_PLUS (Pmode
, stack_pointer_rtx
, pop
);
10733 pop
= gen_rtx_SET (VOIDmode
, stack_pointer_rtx
, pop
);
10734 call
= gen_rtx_PARALLEL (VOIDmode
, gen_rtvec (2, call
, pop
));
10737 call
= emit_call_insn (call
);
10739 CALL_INSN_FUNCTION_USAGE (call
) = use
;
10743 /* Clear stack slot assignments remembered from previous functions.
10744 This is called from INIT_EXPANDERS once before RTL is emitted for each
10747 static struct machine_function
*
10748 ix86_init_machine_status ()
10750 return ggc_alloc_cleared (sizeof (struct machine_function
));
10753 /* Return a MEM corresponding to a stack slot with mode MODE.
10754 Allocate a new slot if necessary.
10756 The RTL for a function can have several slots available: N is
10757 which slot to use. */
10760 assign_386_stack_local (mode
, n
)
10761 enum machine_mode mode
;
10764 if (n
< 0 || n
>= MAX_386_STACK_LOCALS
)
10767 if (ix86_stack_locals
[(int) mode
][n
] == NULL_RTX
)
10768 ix86_stack_locals
[(int) mode
][n
]
10769 = assign_stack_local (mode
, GET_MODE_SIZE (mode
), 0);
10771 return ix86_stack_locals
[(int) mode
][n
];
10774 /* Construct the SYMBOL_REF for the tls_get_addr function. */
10776 static GTY(()) rtx ix86_tls_symbol
;
10778 ix86_tls_get_addr ()
10781 if (!ix86_tls_symbol
)
10783 ix86_tls_symbol
= gen_rtx_SYMBOL_REF (Pmode
, (TARGET_GNU_TLS
10784 ? "___tls_get_addr"
10785 : "__tls_get_addr"));
10788 return ix86_tls_symbol
;
10791 /* Calculate the length of the memory address in the instruction
10792 encoding. Does not include the one-byte modrm, opcode, or prefix. */
10795 memory_address_length (addr
)
10798 struct ix86_address parts
;
10799 rtx base
, index
, disp
;
10802 if (GET_CODE (addr
) == PRE_DEC
10803 || GET_CODE (addr
) == POST_INC
10804 || GET_CODE (addr
) == PRE_MODIFY
10805 || GET_CODE (addr
) == POST_MODIFY
)
10808 if (! ix86_decompose_address (addr
, &parts
))
10812 index
= parts
.index
;
10816 /* Register Indirect. */
10817 if (base
&& !index
&& !disp
)
10819 /* Special cases: ebp and esp need the two-byte modrm form. */
10820 if (addr
== stack_pointer_rtx
10821 || addr
== arg_pointer_rtx
10822 || addr
== frame_pointer_rtx
10823 || addr
== hard_frame_pointer_rtx
)
10827 /* Direct Addressing. */
10828 else if (disp
&& !base
&& !index
)
10833 /* Find the length of the displacement constant. */
10836 if (GET_CODE (disp
) == CONST_INT
10837 && CONST_OK_FOR_LETTER_P (INTVAL (disp
), 'K'))
10843 /* An index requires the two-byte modrm form. */
10851 /* Compute default value for "length_immediate" attribute. When SHORTFORM
10852 is set, expect that insn have 8bit immediate alternative. */
10854 ix86_attr_length_immediate_default (insn
, shortform
)
10860 extract_insn_cached (insn
);
10861 for (i
= recog_data
.n_operands
- 1; i
>= 0; --i
)
10862 if (CONSTANT_P (recog_data
.operand
[i
]))
10867 && GET_CODE (recog_data
.operand
[i
]) == CONST_INT
10868 && CONST_OK_FOR_LETTER_P (INTVAL (recog_data
.operand
[i
]), 'K'))
10872 switch (get_attr_mode (insn
))
10883 /* Immediates for DImode instructions are encoded as 32bit sign extended values. */
10888 fatal_insn ("unknown insn mode", insn
);
10894 /* Compute default value for "length_address" attribute. */
10896 ix86_attr_length_address_default (insn
)
10900 extract_insn_cached (insn
);
10901 for (i
= recog_data
.n_operands
- 1; i
>= 0; --i
)
10902 if (GET_CODE (recog_data
.operand
[i
]) == MEM
)
10904 return memory_address_length (XEXP (recog_data
.operand
[i
], 0));
10910 /* Return the maximum number of instructions a cpu can issue. */
10917 case PROCESSOR_PENTIUM
:
10921 case PROCESSOR_PENTIUMPRO
:
10922 case PROCESSOR_PENTIUM4
:
10923 case PROCESSOR_ATHLON
:
10931 /* A subroutine of ix86_adjust_cost -- return true iff INSN reads flags set
10932 by DEP_INSN and nothing set by DEP_INSN. */
10935 ix86_flags_dependant (insn
, dep_insn
, insn_type
)
10936 rtx insn
, dep_insn
;
10937 enum attr_type insn_type
;
10941 /* Simplify the test for uninteresting insns. */
10942 if (insn_type
!= TYPE_SETCC
10943 && insn_type
!= TYPE_ICMOV
10944 && insn_type
!= TYPE_FCMOV
10945 && insn_type
!= TYPE_IBR
)
10948 if ((set
= single_set (dep_insn
)) != 0)
10950 set
= SET_DEST (set
);
10953 else if (GET_CODE (PATTERN (dep_insn
)) == PARALLEL
10954 && XVECLEN (PATTERN (dep_insn
), 0) == 2
10955 && GET_CODE (XVECEXP (PATTERN (dep_insn
), 0, 0)) == SET
10956 && GET_CODE (XVECEXP (PATTERN (dep_insn
), 0, 1)) == SET
)
10958 set
= SET_DEST (XVECEXP (PATTERN (dep_insn
), 0, 0));
10959 set2
= SET_DEST (XVECEXP (PATTERN (dep_insn
), 0, 0));
10964 if (GET_CODE (set
) != REG
|| REGNO (set
) != FLAGS_REG
)
10967 /* This test is true if the dependent insn reads the flags but
10968 not any other potentially set register. */
10969 if (!reg_overlap_mentioned_p (set
, PATTERN (insn
)))
10972 if (set2
&& reg_overlap_mentioned_p (set2
, PATTERN (insn
)))
10978 /* A subroutine of ix86_adjust_cost -- return true iff INSN has a memory
10979 address with operands set by DEP_INSN. */
10982 ix86_agi_dependant (insn
, dep_insn
, insn_type
)
10983 rtx insn
, dep_insn
;
10984 enum attr_type insn_type
;
10988 if (insn_type
== TYPE_LEA
10991 addr
= PATTERN (insn
);
10992 if (GET_CODE (addr
) == SET
)
10994 else if (GET_CODE (addr
) == PARALLEL
10995 && GET_CODE (XVECEXP (addr
, 0, 0)) == SET
)
10996 addr
= XVECEXP (addr
, 0, 0);
10999 addr
= SET_SRC (addr
);
11004 extract_insn_cached (insn
);
11005 for (i
= recog_data
.n_operands
- 1; i
>= 0; --i
)
11006 if (GET_CODE (recog_data
.operand
[i
]) == MEM
)
11008 addr
= XEXP (recog_data
.operand
[i
], 0);
11015 return modified_in_p (addr
, dep_insn
);
11019 ix86_adjust_cost (insn
, link
, dep_insn
, cost
)
11020 rtx insn
, link
, dep_insn
;
11023 enum attr_type insn_type
, dep_insn_type
;
11024 enum attr_memory memory
, dep_memory
;
11026 int dep_insn_code_number
;
11028 /* Anti and output depenancies have zero cost on all CPUs. */
11029 if (REG_NOTE_KIND (link
) != 0)
11032 dep_insn_code_number
= recog_memoized (dep_insn
);
11034 /* If we can't recognize the insns, we can't really do anything. */
11035 if (dep_insn_code_number
< 0 || recog_memoized (insn
) < 0)
11038 insn_type
= get_attr_type (insn
);
11039 dep_insn_type
= get_attr_type (dep_insn
);
11043 case PROCESSOR_PENTIUM
:
11044 /* Address Generation Interlock adds a cycle of latency. */
11045 if (ix86_agi_dependant (insn
, dep_insn
, insn_type
))
11048 /* ??? Compares pair with jump/setcc. */
11049 if (ix86_flags_dependant (insn
, dep_insn
, insn_type
))
11052 /* Floating point stores require value to be ready one cycle ealier. */
11053 if (insn_type
== TYPE_FMOV
11054 && get_attr_memory (insn
) == MEMORY_STORE
11055 && !ix86_agi_dependant (insn
, dep_insn
, insn_type
))
11059 case PROCESSOR_PENTIUMPRO
:
11060 memory
= get_attr_memory (insn
);
11061 dep_memory
= get_attr_memory (dep_insn
);
11063 /* Since we can't represent delayed latencies of load+operation,
11064 increase the cost here for non-imov insns. */
11065 if (dep_insn_type
!= TYPE_IMOV
11066 && dep_insn_type
!= TYPE_FMOV
11067 && (dep_memory
== MEMORY_LOAD
|| dep_memory
== MEMORY_BOTH
))
11070 /* INT->FP conversion is expensive. */
11071 if (get_attr_fp_int_src (dep_insn
))
11074 /* There is one cycle extra latency between an FP op and a store. */
11075 if (insn_type
== TYPE_FMOV
11076 && (set
= single_set (dep_insn
)) != NULL_RTX
11077 && (set2
= single_set (insn
)) != NULL_RTX
11078 && rtx_equal_p (SET_DEST (set
), SET_SRC (set2
))
11079 && GET_CODE (SET_DEST (set2
)) == MEM
)
11082 /* Show ability of reorder buffer to hide latency of load by executing
11083 in parallel with previous instruction in case
11084 previous instruction is not needed to compute the address. */
11085 if ((memory
== MEMORY_LOAD
|| memory
== MEMORY_BOTH
)
11086 && !ix86_agi_dependant (insn
, dep_insn
, insn_type
))
11088 /* Claim moves to take one cycle, as core can issue one load
11089 at time and the next load can start cycle later. */
11090 if (dep_insn_type
== TYPE_IMOV
11091 || dep_insn_type
== TYPE_FMOV
)
11099 memory
= get_attr_memory (insn
);
11100 dep_memory
= get_attr_memory (dep_insn
);
11101 /* The esp dependency is resolved before the instruction is really
11103 if ((insn_type
== TYPE_PUSH
|| insn_type
== TYPE_POP
)
11104 && (dep_insn_type
== TYPE_PUSH
|| dep_insn_type
== TYPE_POP
))
11107 /* Since we can't represent delayed latencies of load+operation,
11108 increase the cost here for non-imov insns. */
11109 if (dep_memory
== MEMORY_LOAD
|| dep_memory
== MEMORY_BOTH
)
11110 cost
+= (dep_insn_type
!= TYPE_IMOV
) ? 2 : 1;
11112 /* INT->FP conversion is expensive. */
11113 if (get_attr_fp_int_src (dep_insn
))
11116 /* Show ability of reorder buffer to hide latency of load by executing
11117 in parallel with previous instruction in case
11118 previous instruction is not needed to compute the address. */
11119 if ((memory
== MEMORY_LOAD
|| memory
== MEMORY_BOTH
)
11120 && !ix86_agi_dependant (insn
, dep_insn
, insn_type
))
11122 /* Claim moves to take one cycle, as core can issue one load
11123 at time and the next load can start cycle later. */
11124 if (dep_insn_type
== TYPE_IMOV
11125 || dep_insn_type
== TYPE_FMOV
)
11134 case PROCESSOR_ATHLON
:
11135 memory
= get_attr_memory (insn
);
11136 dep_memory
= get_attr_memory (dep_insn
);
11138 if (dep_memory
== MEMORY_LOAD
|| dep_memory
== MEMORY_BOTH
)
11140 if (dep_insn_type
== TYPE_IMOV
|| dep_insn_type
== TYPE_FMOV
)
11145 /* Show ability of reorder buffer to hide latency of load by executing
11146 in parallel with previous instruction in case
11147 previous instruction is not needed to compute the address. */
11148 if ((memory
== MEMORY_LOAD
|| memory
== MEMORY_BOTH
)
11149 && !ix86_agi_dependant (insn
, dep_insn
, insn_type
))
11151 /* Claim moves to take one cycle, as core can issue one load
11152 at time and the next load can start cycle later. */
11153 if (dep_insn_type
== TYPE_IMOV
11154 || dep_insn_type
== TYPE_FMOV
)
11156 else if (cost
>= 3)
11171 struct ppro_sched_data
11174 int issued_this_cycle
;
11178 static enum attr_ppro_uops
11179 ix86_safe_ppro_uops (insn
)
11182 if (recog_memoized (insn
) >= 0)
11183 return get_attr_ppro_uops (insn
);
11185 return PPRO_UOPS_MANY
;
11189 ix86_dump_ppro_packet (dump
)
11192 if (ix86_sched_data
.ppro
.decode
[0])
11194 fprintf (dump
, "PPRO packet: %d",
11195 INSN_UID (ix86_sched_data
.ppro
.decode
[0]));
11196 if (ix86_sched_data
.ppro
.decode
[1])
11197 fprintf (dump
, " %d", INSN_UID (ix86_sched_data
.ppro
.decode
[1]));
11198 if (ix86_sched_data
.ppro
.decode
[2])
11199 fprintf (dump
, " %d", INSN_UID (ix86_sched_data
.ppro
.decode
[2]));
11200 fputc ('\n', dump
);
11204 /* We're beginning a new block. Initialize data structures as necessary. */
11207 ix86_sched_init (dump
, sched_verbose
, veclen
)
11208 FILE *dump ATTRIBUTE_UNUSED
;
11209 int sched_verbose ATTRIBUTE_UNUSED
;
11210 int veclen ATTRIBUTE_UNUSED
;
11212 memset (&ix86_sched_data
, 0, sizeof (ix86_sched_data
));
11215 /* Shift INSN to SLOT, and shift everything else down. */
11218 ix86_reorder_insn (insnp
, slot
)
11225 insnp
[0] = insnp
[1];
11226 while (++insnp
!= slot
);
11232 ix86_sched_reorder_ppro (ready
, e_ready
)
11237 enum attr_ppro_uops cur_uops
;
11238 int issued_this_cycle
;
11242 /* At this point .ppro.decode contains the state of the three
11243 decoders from last "cycle". That is, those insns that were
11244 actually independent. But here we're scheduling for the
11245 decoder, and we may find things that are decodable in the
11248 memcpy (decode
, ix86_sched_data
.ppro
.decode
, sizeof (decode
));
11249 issued_this_cycle
= 0;
11252 cur_uops
= ix86_safe_ppro_uops (*insnp
);
11254 /* If the decoders are empty, and we've a complex insn at the
11255 head of the priority queue, let it issue without complaint. */
11256 if (decode
[0] == NULL
)
11258 if (cur_uops
== PPRO_UOPS_MANY
)
11260 decode
[0] = *insnp
;
11264 /* Otherwise, search for a 2-4 uop unsn to issue. */
11265 while (cur_uops
!= PPRO_UOPS_FEW
)
11267 if (insnp
== ready
)
11269 cur_uops
= ix86_safe_ppro_uops (*--insnp
);
11272 /* If so, move it to the head of the line. */
11273 if (cur_uops
== PPRO_UOPS_FEW
)
11274 ix86_reorder_insn (insnp
, e_ready
);
11276 /* Issue the head of the queue. */
11277 issued_this_cycle
= 1;
11278 decode
[0] = *e_ready
--;
11281 /* Look for simple insns to fill in the other two slots. */
11282 for (i
= 1; i
< 3; ++i
)
11283 if (decode
[i
] == NULL
)
11285 if (ready
> e_ready
)
11289 cur_uops
= ix86_safe_ppro_uops (*insnp
);
11290 while (cur_uops
!= PPRO_UOPS_ONE
)
11292 if (insnp
== ready
)
11294 cur_uops
= ix86_safe_ppro_uops (*--insnp
);
11297 /* Found one. Move it to the head of the queue and issue it. */
11298 if (cur_uops
== PPRO_UOPS_ONE
)
11300 ix86_reorder_insn (insnp
, e_ready
);
11301 decode
[i
] = *e_ready
--;
11302 issued_this_cycle
++;
11306 /* ??? Didn't find one. Ideally, here we would do a lazy split
11307 of 2-uop insns, issue one and queue the other. */
11311 if (issued_this_cycle
== 0)
11312 issued_this_cycle
= 1;
11313 ix86_sched_data
.ppro
.issued_this_cycle
= issued_this_cycle
;
11316 /* We are about to being issuing insns for this clock cycle.
11317 Override the default sort algorithm to better slot instructions. */
11319 ix86_sched_reorder (dump
, sched_verbose
, ready
, n_readyp
, clock_var
)
11320 FILE *dump ATTRIBUTE_UNUSED
;
11321 int sched_verbose ATTRIBUTE_UNUSED
;
11324 int clock_var ATTRIBUTE_UNUSED
;
11326 int n_ready
= *n_readyp
;
11327 rtx
*e_ready
= ready
+ n_ready
- 1;
11329 /* Make sure to go ahead and initialize key items in
11330 ix86_sched_data if we are not going to bother trying to
11331 reorder the ready queue. */
11334 ix86_sched_data
.ppro
.issued_this_cycle
= 1;
11343 case PROCESSOR_PENTIUMPRO
:
11344 ix86_sched_reorder_ppro (ready
, e_ready
);
11349 return ix86_issue_rate ();
11352 /* We are about to issue INSN. Return the number of insns left on the
11353 ready queue that can be issued this cycle. */
11356 ix86_variable_issue (dump
, sched_verbose
, insn
, can_issue_more
)
11360 int can_issue_more
;
11366 return can_issue_more
- 1;
11368 case PROCESSOR_PENTIUMPRO
:
11370 enum attr_ppro_uops uops
= ix86_safe_ppro_uops (insn
);
11372 if (uops
== PPRO_UOPS_MANY
)
11375 ix86_dump_ppro_packet (dump
);
11376 ix86_sched_data
.ppro
.decode
[0] = insn
;
11377 ix86_sched_data
.ppro
.decode
[1] = NULL
;
11378 ix86_sched_data
.ppro
.decode
[2] = NULL
;
11380 ix86_dump_ppro_packet (dump
);
11381 ix86_sched_data
.ppro
.decode
[0] = NULL
;
11383 else if (uops
== PPRO_UOPS_FEW
)
11386 ix86_dump_ppro_packet (dump
);
11387 ix86_sched_data
.ppro
.decode
[0] = insn
;
11388 ix86_sched_data
.ppro
.decode
[1] = NULL
;
11389 ix86_sched_data
.ppro
.decode
[2] = NULL
;
11393 for (i
= 0; i
< 3; ++i
)
11394 if (ix86_sched_data
.ppro
.decode
[i
] == NULL
)
11396 ix86_sched_data
.ppro
.decode
[i
] = insn
;
11404 ix86_dump_ppro_packet (dump
);
11405 ix86_sched_data
.ppro
.decode
[0] = NULL
;
11406 ix86_sched_data
.ppro
.decode
[1] = NULL
;
11407 ix86_sched_data
.ppro
.decode
[2] = NULL
;
11411 return --ix86_sched_data
.ppro
.issued_this_cycle
;
11416 ia32_use_dfa_pipeline_interface ()
11418 if (ix86_cpu
== PROCESSOR_PENTIUM
)
11423 /* How many alternative schedules to try. This should be as wide as the
11424 scheduling freedom in the DFA, but no wider. Making this value too
11425 large results extra work for the scheduler. */
11428 ia32_multipass_dfa_lookahead ()
11430 if (ix86_cpu
== PROCESSOR_PENTIUM
)
11437 /* Walk through INSNS and look for MEM references whose address is DSTREG or
11438 SRCREG and set the memory attribute to those of DSTREF and SRCREF, as
11442 ix86_set_move_mem_attrs (insns
, dstref
, srcref
, dstreg
, srcreg
)
11444 rtx dstref
, srcref
, dstreg
, srcreg
;
11448 for (insn
= insns
; insn
!= 0 ; insn
= NEXT_INSN (insn
))
11450 ix86_set_move_mem_attrs_1 (PATTERN (insn
), dstref
, srcref
,
11454 /* Subroutine of above to actually do the updating by recursively walking
11458 ix86_set_move_mem_attrs_1 (x
, dstref
, srcref
, dstreg
, srcreg
)
11460 rtx dstref
, srcref
, dstreg
, srcreg
;
11462 enum rtx_code code
= GET_CODE (x
);
11463 const char *format_ptr
= GET_RTX_FORMAT (code
);
11466 if (code
== MEM
&& XEXP (x
, 0) == dstreg
)
11467 MEM_COPY_ATTRIBUTES (x
, dstref
);
11468 else if (code
== MEM
&& XEXP (x
, 0) == srcreg
)
11469 MEM_COPY_ATTRIBUTES (x
, srcref
);
11471 for (i
= 0; i
< GET_RTX_LENGTH (code
); i
++, format_ptr
++)
11473 if (*format_ptr
== 'e')
11474 ix86_set_move_mem_attrs_1 (XEXP (x
, i
), dstref
, srcref
,
11476 else if (*format_ptr
== 'E')
11477 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
11478 ix86_set_move_mem_attrs_1 (XVECEXP (x
, i
, j
), dstref
, srcref
,
11483 /* Compute the alignment given to a constant that is being placed in memory.
11484 EXP is the constant and ALIGN is the alignment that the object would
11486 The value of this function is used instead of that alignment to align
11490 ix86_constant_alignment (exp
, align
)
11494 if (TREE_CODE (exp
) == REAL_CST
)
11496 if (TYPE_MODE (TREE_TYPE (exp
)) == DFmode
&& align
< 64)
11498 else if (ALIGN_MODE_128 (TYPE_MODE (TREE_TYPE (exp
))) && align
< 128)
11501 else if (TREE_CODE (exp
) == STRING_CST
&& TREE_STRING_LENGTH (exp
) >= 31
11508 /* Compute the alignment for a static variable.
11509 TYPE is the data type, and ALIGN is the alignment that
11510 the object would ordinarily have. The value of this function is used
11511 instead of that alignment to align the object. */
11514 ix86_data_alignment (type
, align
)
11518 if (AGGREGATE_TYPE_P (type
)
11519 && TYPE_SIZE (type
)
11520 && TREE_CODE (TYPE_SIZE (type
)) == INTEGER_CST
11521 && (TREE_INT_CST_LOW (TYPE_SIZE (type
)) >= 256
11522 || TREE_INT_CST_HIGH (TYPE_SIZE (type
))) && align
< 256)
11525 /* x86-64 ABI requires arrays greater than 16 bytes to be aligned
11526 to 16byte boundary. */
11529 if (AGGREGATE_TYPE_P (type
)
11530 && TYPE_SIZE (type
)
11531 && TREE_CODE (TYPE_SIZE (type
)) == INTEGER_CST
11532 && (TREE_INT_CST_LOW (TYPE_SIZE (type
)) >= 128
11533 || TREE_INT_CST_HIGH (TYPE_SIZE (type
))) && align
< 128)
11537 if (TREE_CODE (type
) == ARRAY_TYPE
)
11539 if (TYPE_MODE (TREE_TYPE (type
)) == DFmode
&& align
< 64)
11541 if (ALIGN_MODE_128 (TYPE_MODE (TREE_TYPE (type
))) && align
< 128)
11544 else if (TREE_CODE (type
) == COMPLEX_TYPE
)
11547 if (TYPE_MODE (type
) == DCmode
&& align
< 64)
11549 if (TYPE_MODE (type
) == XCmode
&& align
< 128)
11552 else if ((TREE_CODE (type
) == RECORD_TYPE
11553 || TREE_CODE (type
) == UNION_TYPE
11554 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
11555 && TYPE_FIELDS (type
))
11557 if (DECL_MODE (TYPE_FIELDS (type
)) == DFmode
&& align
< 64)
11559 if (ALIGN_MODE_128 (DECL_MODE (TYPE_FIELDS (type
))) && align
< 128)
11562 else if (TREE_CODE (type
) == REAL_TYPE
|| TREE_CODE (type
) == VECTOR_TYPE
11563 || TREE_CODE (type
) == INTEGER_TYPE
)
11565 if (TYPE_MODE (type
) == DFmode
&& align
< 64)
11567 if (ALIGN_MODE_128 (TYPE_MODE (type
)) && align
< 128)
11574 /* Compute the alignment for a local variable.
11575 TYPE is the data type, and ALIGN is the alignment that
11576 the object would ordinarily have. The value of this macro is used
11577 instead of that alignment to align the object. */
11580 ix86_local_alignment (type
, align
)
11584 /* x86-64 ABI requires arrays greater than 16 bytes to be aligned
11585 to 16byte boundary. */
11588 if (AGGREGATE_TYPE_P (type
)
11589 && TYPE_SIZE (type
)
11590 && TREE_CODE (TYPE_SIZE (type
)) == INTEGER_CST
11591 && (TREE_INT_CST_LOW (TYPE_SIZE (type
)) >= 16
11592 || TREE_INT_CST_HIGH (TYPE_SIZE (type
))) && align
< 128)
11595 if (TREE_CODE (type
) == ARRAY_TYPE
)
11597 if (TYPE_MODE (TREE_TYPE (type
)) == DFmode
&& align
< 64)
11599 if (ALIGN_MODE_128 (TYPE_MODE (TREE_TYPE (type
))) && align
< 128)
11602 else if (TREE_CODE (type
) == COMPLEX_TYPE
)
11604 if (TYPE_MODE (type
) == DCmode
&& align
< 64)
11606 if (TYPE_MODE (type
) == XCmode
&& align
< 128)
11609 else if ((TREE_CODE (type
) == RECORD_TYPE
11610 || TREE_CODE (type
) == UNION_TYPE
11611 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
11612 && TYPE_FIELDS (type
))
11614 if (DECL_MODE (TYPE_FIELDS (type
)) == DFmode
&& align
< 64)
11616 if (ALIGN_MODE_128 (DECL_MODE (TYPE_FIELDS (type
))) && align
< 128)
11619 else if (TREE_CODE (type
) == REAL_TYPE
|| TREE_CODE (type
) == VECTOR_TYPE
11620 || TREE_CODE (type
) == INTEGER_TYPE
)
11623 if (TYPE_MODE (type
) == DFmode
&& align
< 64)
11625 if (ALIGN_MODE_128 (TYPE_MODE (type
)) && align
< 128)
11631 /* Emit RTL insns to initialize the variable parts of a trampoline.
11632 FNADDR is an RTX for the address of the function's pure code.
11633 CXT is an RTX for the static chain value for the function. */
11635 x86_initialize_trampoline (tramp
, fnaddr
, cxt
)
11636 rtx tramp
, fnaddr
, cxt
;
11640 /* Compute offset from the end of the jmp to the target function. */
11641 rtx disp
= expand_binop (SImode
, sub_optab
, fnaddr
,
11642 plus_constant (tramp
, 10),
11643 NULL_RTX
, 1, OPTAB_DIRECT
);
11644 emit_move_insn (gen_rtx_MEM (QImode
, tramp
),
11645 gen_int_mode (0xb9, QImode
));
11646 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 1)), cxt
);
11647 emit_move_insn (gen_rtx_MEM (QImode
, plus_constant (tramp
, 5)),
11648 gen_int_mode (0xe9, QImode
));
11649 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, 6)), disp
);
11654 /* Try to load address using shorter movl instead of movabs.
11655 We may want to support movq for kernel mode, but kernel does not use
11656 trampolines at the moment. */
11657 if (x86_64_zero_extended_value (fnaddr
))
11659 fnaddr
= copy_to_mode_reg (DImode
, fnaddr
);
11660 emit_move_insn (gen_rtx_MEM (HImode
, plus_constant (tramp
, offset
)),
11661 gen_int_mode (0xbb41, HImode
));
11662 emit_move_insn (gen_rtx_MEM (SImode
, plus_constant (tramp
, offset
+ 2)),
11663 gen_lowpart (SImode
, fnaddr
));
11668 emit_move_insn (gen_rtx_MEM (HImode
, plus_constant (tramp
, offset
)),
11669 gen_int_mode (0xbb49, HImode
));
11670 emit_move_insn (gen_rtx_MEM (DImode
, plus_constant (tramp
, offset
+ 2)),
11674 /* Load static chain using movabs to r10. */
11675 emit_move_insn (gen_rtx_MEM (HImode
, plus_constant (tramp
, offset
)),
11676 gen_int_mode (0xba49, HImode
));
11677 emit_move_insn (gen_rtx_MEM (DImode
, plus_constant (tramp
, offset
+ 2)),
11680 /* Jump to the r11 */
11681 emit_move_insn (gen_rtx_MEM (HImode
, plus_constant (tramp
, offset
)),
11682 gen_int_mode (0xff49, HImode
));
11683 emit_move_insn (gen_rtx_MEM (QImode
, plus_constant (tramp
, offset
+2)),
11684 gen_int_mode (0xe3, QImode
));
11686 if (offset
> TRAMPOLINE_SIZE
)
11691 #define def_builtin(MASK, NAME, TYPE, CODE) \
11693 if ((MASK) & target_flags) \
11694 builtin_function ((NAME), (TYPE), (CODE), BUILT_IN_MD, \
11695 NULL, NULL_TREE); \
11698 struct builtin_description
11700 const unsigned int mask
;
11701 const enum insn_code icode
;
11702 const char *const name
;
11703 const enum ix86_builtins code
;
11704 const enum rtx_code comparison
;
11705 const unsigned int flag
;
11708 /* Used for builtins that are enabled both by -msse and -msse2. */
11709 #define MASK_SSE1 (MASK_SSE | MASK_SSE2)
11711 static const struct builtin_description bdesc_comi
[] =
11713 { MASK_SSE1
, CODE_FOR_sse_comi
, "__builtin_ia32_comieq", IX86_BUILTIN_COMIEQSS
, EQ
, 0 },
11714 { MASK_SSE1
, CODE_FOR_sse_comi
, "__builtin_ia32_comilt", IX86_BUILTIN_COMILTSS
, LT
, 0 },
11715 { MASK_SSE1
, CODE_FOR_sse_comi
, "__builtin_ia32_comile", IX86_BUILTIN_COMILESS
, LE
, 0 },
11716 { MASK_SSE1
, CODE_FOR_sse_comi
, "__builtin_ia32_comigt", IX86_BUILTIN_COMIGTSS
, LT
, 1 },
11717 { MASK_SSE1
, CODE_FOR_sse_comi
, "__builtin_ia32_comige", IX86_BUILTIN_COMIGESS
, LE
, 1 },
11718 { MASK_SSE1
, CODE_FOR_sse_comi
, "__builtin_ia32_comineq", IX86_BUILTIN_COMINEQSS
, NE
, 0 },
11719 { MASK_SSE1
, CODE_FOR_sse_ucomi
, "__builtin_ia32_ucomieq", IX86_BUILTIN_UCOMIEQSS
, EQ
, 0 },
11720 { MASK_SSE1
, CODE_FOR_sse_ucomi
, "__builtin_ia32_ucomilt", IX86_BUILTIN_UCOMILTSS
, LT
, 0 },
11721 { MASK_SSE1
, CODE_FOR_sse_ucomi
, "__builtin_ia32_ucomile", IX86_BUILTIN_UCOMILESS
, LE
, 0 },
11722 { MASK_SSE1
, CODE_FOR_sse_ucomi
, "__builtin_ia32_ucomigt", IX86_BUILTIN_UCOMIGTSS
, LT
, 1 },
11723 { MASK_SSE1
, CODE_FOR_sse_ucomi
, "__builtin_ia32_ucomige", IX86_BUILTIN_UCOMIGESS
, LE
, 1 },
11724 { MASK_SSE1
, CODE_FOR_sse_ucomi
, "__builtin_ia32_ucomineq", IX86_BUILTIN_UCOMINEQSS
, NE
, 0 },
11725 { MASK_SSE2
, CODE_FOR_sse2_comi
, "__builtin_ia32_comisdeq", IX86_BUILTIN_COMIEQSD
, EQ
, 0 },
11726 { MASK_SSE2
, CODE_FOR_sse2_comi
, "__builtin_ia32_comisdlt", IX86_BUILTIN_COMILTSD
, LT
, 0 },
11727 { MASK_SSE2
, CODE_FOR_sse2_comi
, "__builtin_ia32_comisdle", IX86_BUILTIN_COMILESD
, LE
, 0 },
11728 { MASK_SSE2
, CODE_FOR_sse2_comi
, "__builtin_ia32_comisdgt", IX86_BUILTIN_COMIGTSD
, LT
, 1 },
11729 { MASK_SSE2
, CODE_FOR_sse2_comi
, "__builtin_ia32_comisdge", IX86_BUILTIN_COMIGESD
, LE
, 1 },
11730 { MASK_SSE2
, CODE_FOR_sse2_comi
, "__builtin_ia32_comisdneq", IX86_BUILTIN_COMINEQSD
, NE
, 0 },
11731 { MASK_SSE2
, CODE_FOR_sse2_ucomi
, "__builtin_ia32_ucomisdeq", IX86_BUILTIN_UCOMIEQSD
, EQ
, 0 },
11732 { MASK_SSE2
, CODE_FOR_sse2_ucomi
, "__builtin_ia32_ucomisdlt", IX86_BUILTIN_UCOMILTSD
, LT
, 0 },
11733 { MASK_SSE2
, CODE_FOR_sse2_ucomi
, "__builtin_ia32_ucomisdle", IX86_BUILTIN_UCOMILESD
, LE
, 0 },
11734 { MASK_SSE2
, CODE_FOR_sse2_ucomi
, "__builtin_ia32_ucomisdgt", IX86_BUILTIN_UCOMIGTSD
, LT
, 1 },
11735 { MASK_SSE2
, CODE_FOR_sse2_ucomi
, "__builtin_ia32_ucomisdge", IX86_BUILTIN_UCOMIGESD
, LE
, 1 },
11736 { MASK_SSE2
, CODE_FOR_sse2_ucomi
, "__builtin_ia32_ucomisdneq", IX86_BUILTIN_UCOMINEQSD
, NE
, 0 },
11739 static const struct builtin_description bdesc_2arg
[] =
11742 { MASK_SSE1
, CODE_FOR_addv4sf3
, "__builtin_ia32_addps", IX86_BUILTIN_ADDPS
, 0, 0 },
11743 { MASK_SSE1
, CODE_FOR_subv4sf3
, "__builtin_ia32_subps", IX86_BUILTIN_SUBPS
, 0, 0 },
11744 { MASK_SSE1
, CODE_FOR_mulv4sf3
, "__builtin_ia32_mulps", IX86_BUILTIN_MULPS
, 0, 0 },
11745 { MASK_SSE1
, CODE_FOR_divv4sf3
, "__builtin_ia32_divps", IX86_BUILTIN_DIVPS
, 0, 0 },
11746 { MASK_SSE1
, CODE_FOR_vmaddv4sf3
, "__builtin_ia32_addss", IX86_BUILTIN_ADDSS
, 0, 0 },
11747 { MASK_SSE1
, CODE_FOR_vmsubv4sf3
, "__builtin_ia32_subss", IX86_BUILTIN_SUBSS
, 0, 0 },
11748 { MASK_SSE1
, CODE_FOR_vmmulv4sf3
, "__builtin_ia32_mulss", IX86_BUILTIN_MULSS
, 0, 0 },
11749 { MASK_SSE1
, CODE_FOR_vmdivv4sf3
, "__builtin_ia32_divss", IX86_BUILTIN_DIVSS
, 0, 0 },
11751 { MASK_SSE1
, CODE_FOR_maskcmpv4sf3
, "__builtin_ia32_cmpeqps", IX86_BUILTIN_CMPEQPS
, EQ
, 0 },
11752 { MASK_SSE1
, CODE_FOR_maskcmpv4sf3
, "__builtin_ia32_cmpltps", IX86_BUILTIN_CMPLTPS
, LT
, 0 },
11753 { MASK_SSE1
, CODE_FOR_maskcmpv4sf3
, "__builtin_ia32_cmpleps", IX86_BUILTIN_CMPLEPS
, LE
, 0 },
11754 { MASK_SSE1
, CODE_FOR_maskcmpv4sf3
, "__builtin_ia32_cmpgtps", IX86_BUILTIN_CMPGTPS
, LT
, 1 },
11755 { MASK_SSE1
, CODE_FOR_maskcmpv4sf3
, "__builtin_ia32_cmpgeps", IX86_BUILTIN_CMPGEPS
, LE
, 1 },
11756 { MASK_SSE1
, CODE_FOR_maskcmpv4sf3
, "__builtin_ia32_cmpunordps", IX86_BUILTIN_CMPUNORDPS
, UNORDERED
, 0 },
11757 { MASK_SSE1
, CODE_FOR_maskncmpv4sf3
, "__builtin_ia32_cmpneqps", IX86_BUILTIN_CMPNEQPS
, EQ
, 0 },
11758 { MASK_SSE1
, CODE_FOR_maskncmpv4sf3
, "__builtin_ia32_cmpnltps", IX86_BUILTIN_CMPNLTPS
, LT
, 0 },
11759 { MASK_SSE1
, CODE_FOR_maskncmpv4sf3
, "__builtin_ia32_cmpnleps", IX86_BUILTIN_CMPNLEPS
, LE
, 0 },
11760 { MASK_SSE1
, CODE_FOR_maskncmpv4sf3
, "__builtin_ia32_cmpngtps", IX86_BUILTIN_CMPNGTPS
, LT
, 1 },
11761 { MASK_SSE1
, CODE_FOR_maskncmpv4sf3
, "__builtin_ia32_cmpngeps", IX86_BUILTIN_CMPNGEPS
, LE
, 1 },
11762 { MASK_SSE1
, CODE_FOR_maskncmpv4sf3
, "__builtin_ia32_cmpordps", IX86_BUILTIN_CMPORDPS
, UNORDERED
, 0 },
11763 { MASK_SSE1
, CODE_FOR_vmmaskcmpv4sf3
, "__builtin_ia32_cmpeqss", IX86_BUILTIN_CMPEQSS
, EQ
, 0 },
11764 { MASK_SSE1
, CODE_FOR_vmmaskcmpv4sf3
, "__builtin_ia32_cmpltss", IX86_BUILTIN_CMPLTSS
, LT
, 0 },
11765 { MASK_SSE1
, CODE_FOR_vmmaskcmpv4sf3
, "__builtin_ia32_cmpless", IX86_BUILTIN_CMPLESS
, LE
, 0 },
11766 { MASK_SSE1
, CODE_FOR_vmmaskcmpv4sf3
, "__builtin_ia32_cmpgtss", IX86_BUILTIN_CMPGTSS
, LT
, 1 },
11767 { MASK_SSE1
, CODE_FOR_vmmaskcmpv4sf3
, "__builtin_ia32_cmpgess", IX86_BUILTIN_CMPGESS
, LE
, 1 },
11768 { MASK_SSE1
, CODE_FOR_vmmaskcmpv4sf3
, "__builtin_ia32_cmpunordss", IX86_BUILTIN_CMPUNORDSS
, UNORDERED
, 0 },
11769 { MASK_SSE1
, CODE_FOR_vmmaskncmpv4sf3
, "__builtin_ia32_cmpneqss", IX86_BUILTIN_CMPNEQSS
, EQ
, 0 },
11770 { MASK_SSE1
, CODE_FOR_vmmaskncmpv4sf3
, "__builtin_ia32_cmpnltss", IX86_BUILTIN_CMPNLTSS
, LT
, 0 },
11771 { MASK_SSE1
, CODE_FOR_vmmaskncmpv4sf3
, "__builtin_ia32_cmpnless", IX86_BUILTIN_CMPNLESS
, LE
, 0 },
11772 { MASK_SSE1
, CODE_FOR_vmmaskncmpv4sf3
, "__builtin_ia32_cmpngtss", IX86_BUILTIN_CMPNGTSS
, LT
, 1 },
11773 { MASK_SSE1
, CODE_FOR_vmmaskncmpv4sf3
, "__builtin_ia32_cmpngess", IX86_BUILTIN_CMPNGESS
, LE
, 1 },
11774 { MASK_SSE1
, CODE_FOR_vmmaskncmpv4sf3
, "__builtin_ia32_cmpordss", IX86_BUILTIN_CMPORDSS
, UNORDERED
, 0 },
11776 { MASK_SSE1
, CODE_FOR_sminv4sf3
, "__builtin_ia32_minps", IX86_BUILTIN_MINPS
, 0, 0 },
11777 { MASK_SSE1
, CODE_FOR_smaxv4sf3
, "__builtin_ia32_maxps", IX86_BUILTIN_MAXPS
, 0, 0 },
11778 { MASK_SSE1
, CODE_FOR_vmsminv4sf3
, "__builtin_ia32_minss", IX86_BUILTIN_MINSS
, 0, 0 },
11779 { MASK_SSE1
, CODE_FOR_vmsmaxv4sf3
, "__builtin_ia32_maxss", IX86_BUILTIN_MAXSS
, 0, 0 },
11781 { MASK_SSE1
, CODE_FOR_sse_movss
, "__builtin_ia32_movss", IX86_BUILTIN_MOVSS
, 0, 0 },
11782 { MASK_SSE1
, CODE_FOR_sse_movhlps
, "__builtin_ia32_movhlps", IX86_BUILTIN_MOVHLPS
, 0, 0 },
11783 { MASK_SSE1
, CODE_FOR_sse_movlhps
, "__builtin_ia32_movlhps", IX86_BUILTIN_MOVLHPS
, 0, 0 },
11784 { MASK_SSE1
, CODE_FOR_sse_unpckhps
, "__builtin_ia32_unpckhps", IX86_BUILTIN_UNPCKHPS
, 0, 0 },
11785 { MASK_SSE1
, CODE_FOR_sse_unpcklps
, "__builtin_ia32_unpcklps", IX86_BUILTIN_UNPCKLPS
, 0, 0 },
11788 { MASK_MMX
, CODE_FOR_addv8qi3
, "__builtin_ia32_paddb", IX86_BUILTIN_PADDB
, 0, 0 },
11789 { MASK_MMX
, CODE_FOR_addv4hi3
, "__builtin_ia32_paddw", IX86_BUILTIN_PADDW
, 0, 0 },
11790 { MASK_MMX
, CODE_FOR_addv2si3
, "__builtin_ia32_paddd", IX86_BUILTIN_PADDD
, 0, 0 },
11791 { MASK_MMX
, CODE_FOR_subv8qi3
, "__builtin_ia32_psubb", IX86_BUILTIN_PSUBB
, 0, 0 },
11792 { MASK_MMX
, CODE_FOR_subv4hi3
, "__builtin_ia32_psubw", IX86_BUILTIN_PSUBW
, 0, 0 },
11793 { MASK_MMX
, CODE_FOR_subv2si3
, "__builtin_ia32_psubd", IX86_BUILTIN_PSUBD
, 0, 0 },
11795 { MASK_MMX
, CODE_FOR_ssaddv8qi3
, "__builtin_ia32_paddsb", IX86_BUILTIN_PADDSB
, 0, 0 },
11796 { MASK_MMX
, CODE_FOR_ssaddv4hi3
, "__builtin_ia32_paddsw", IX86_BUILTIN_PADDSW
, 0, 0 },
11797 { MASK_MMX
, CODE_FOR_sssubv8qi3
, "__builtin_ia32_psubsb", IX86_BUILTIN_PSUBSB
, 0, 0 },
11798 { MASK_MMX
, CODE_FOR_sssubv4hi3
, "__builtin_ia32_psubsw", IX86_BUILTIN_PSUBSW
, 0, 0 },
11799 { MASK_MMX
, CODE_FOR_usaddv8qi3
, "__builtin_ia32_paddusb", IX86_BUILTIN_PADDUSB
, 0, 0 },
11800 { MASK_MMX
, CODE_FOR_usaddv4hi3
, "__builtin_ia32_paddusw", IX86_BUILTIN_PADDUSW
, 0, 0 },
11801 { MASK_MMX
, CODE_FOR_ussubv8qi3
, "__builtin_ia32_psubusb", IX86_BUILTIN_PSUBUSB
, 0, 0 },
11802 { MASK_MMX
, CODE_FOR_ussubv4hi3
, "__builtin_ia32_psubusw", IX86_BUILTIN_PSUBUSW
, 0, 0 },
11804 { MASK_MMX
, CODE_FOR_mulv4hi3
, "__builtin_ia32_pmullw", IX86_BUILTIN_PMULLW
, 0, 0 },
11805 { MASK_MMX
, CODE_FOR_smulv4hi3_highpart
, "__builtin_ia32_pmulhw", IX86_BUILTIN_PMULHW
, 0, 0 },
11806 { MASK_SSE1
| MASK_3DNOW_A
, CODE_FOR_umulv4hi3_highpart
, "__builtin_ia32_pmulhuw", IX86_BUILTIN_PMULHUW
, 0, 0 },
11808 { MASK_MMX
, CODE_FOR_mmx_anddi3
, "__builtin_ia32_pand", IX86_BUILTIN_PAND
, 0, 0 },
11809 { MASK_MMX
, CODE_FOR_mmx_nanddi3
, "__builtin_ia32_pandn", IX86_BUILTIN_PANDN
, 0, 0 },
11810 { MASK_MMX
, CODE_FOR_mmx_iordi3
, "__builtin_ia32_por", IX86_BUILTIN_POR
, 0, 0 },
11811 { MASK_MMX
, CODE_FOR_mmx_xordi3
, "__builtin_ia32_pxor", IX86_BUILTIN_PXOR
, 0, 0 },
11813 { MASK_SSE1
| MASK_3DNOW_A
, CODE_FOR_mmx_uavgv8qi3
, "__builtin_ia32_pavgb", IX86_BUILTIN_PAVGB
, 0, 0 },
11814 { MASK_SSE1
| MASK_3DNOW_A
, CODE_FOR_mmx_uavgv4hi3
, "__builtin_ia32_pavgw", IX86_BUILTIN_PAVGW
, 0, 0 },
11816 { MASK_MMX
, CODE_FOR_eqv8qi3
, "__builtin_ia32_pcmpeqb", IX86_BUILTIN_PCMPEQB
, 0, 0 },
11817 { MASK_MMX
, CODE_FOR_eqv4hi3
, "__builtin_ia32_pcmpeqw", IX86_BUILTIN_PCMPEQW
, 0, 0 },
11818 { MASK_MMX
, CODE_FOR_eqv2si3
, "__builtin_ia32_pcmpeqd", IX86_BUILTIN_PCMPEQD
, 0, 0 },
11819 { MASK_MMX
, CODE_FOR_gtv8qi3
, "__builtin_ia32_pcmpgtb", IX86_BUILTIN_PCMPGTB
, 0, 0 },
11820 { MASK_MMX
, CODE_FOR_gtv4hi3
, "__builtin_ia32_pcmpgtw", IX86_BUILTIN_PCMPGTW
, 0, 0 },
11821 { MASK_MMX
, CODE_FOR_gtv2si3
, "__builtin_ia32_pcmpgtd", IX86_BUILTIN_PCMPGTD
, 0, 0 },
11823 { MASK_SSE1
| MASK_3DNOW_A
, CODE_FOR_umaxv8qi3
, "__builtin_ia32_pmaxub", IX86_BUILTIN_PMAXUB
, 0, 0 },
11824 { MASK_SSE1
| MASK_3DNOW_A
, CODE_FOR_smaxv4hi3
, "__builtin_ia32_pmaxsw", IX86_BUILTIN_PMAXSW
, 0, 0 },
11825 { MASK_SSE1
| MASK_3DNOW_A
, CODE_FOR_uminv8qi3
, "__builtin_ia32_pminub", IX86_BUILTIN_PMINUB
, 0, 0 },
11826 { MASK_SSE1
| MASK_3DNOW_A
, CODE_FOR_sminv4hi3
, "__builtin_ia32_pminsw", IX86_BUILTIN_PMINSW
, 0, 0 },
11828 { MASK_MMX
, CODE_FOR_mmx_punpckhbw
, "__builtin_ia32_punpckhbw", IX86_BUILTIN_PUNPCKHBW
, 0, 0 },
11829 { MASK_MMX
, CODE_FOR_mmx_punpckhwd
, "__builtin_ia32_punpckhwd", IX86_BUILTIN_PUNPCKHWD
, 0, 0 },
11830 { MASK_MMX
, CODE_FOR_mmx_punpckhdq
, "__builtin_ia32_punpckhdq", IX86_BUILTIN_PUNPCKHDQ
, 0, 0 },
11831 { MASK_MMX
, CODE_FOR_mmx_punpcklbw
, "__builtin_ia32_punpcklbw", IX86_BUILTIN_PUNPCKLBW
, 0, 0 },
11832 { MASK_MMX
, CODE_FOR_mmx_punpcklwd
, "__builtin_ia32_punpcklwd", IX86_BUILTIN_PUNPCKLWD
, 0, 0 },
11833 { MASK_MMX
, CODE_FOR_mmx_punpckldq
, "__builtin_ia32_punpckldq", IX86_BUILTIN_PUNPCKLDQ
, 0, 0 },
11836 { MASK_MMX
, CODE_FOR_mmx_packsswb
, 0, IX86_BUILTIN_PACKSSWB
, 0, 0 },
11837 { MASK_MMX
, CODE_FOR_mmx_packssdw
, 0, IX86_BUILTIN_PACKSSDW
, 0, 0 },
11838 { MASK_MMX
, CODE_FOR_mmx_packuswb
, 0, IX86_BUILTIN_PACKUSWB
, 0, 0 },
11840 { MASK_SSE1
, CODE_FOR_cvtpi2ps
, 0, IX86_BUILTIN_CVTPI2PS
, 0, 0 },
11841 { MASK_SSE1
, CODE_FOR_cvtsi2ss
, 0, IX86_BUILTIN_CVTSI2SS
, 0, 0 },
11843 { MASK_MMX
, CODE_FOR_ashlv4hi3
, 0, IX86_BUILTIN_PSLLW
, 0, 0 },
11844 { MASK_MMX
, CODE_FOR_ashlv4hi3
, 0, IX86_BUILTIN_PSLLWI
, 0, 0 },
11845 { MASK_MMX
, CODE_FOR_ashlv2si3
, 0, IX86_BUILTIN_PSLLD
, 0, 0 },
11846 { MASK_MMX
, CODE_FOR_ashlv2si3
, 0, IX86_BUILTIN_PSLLDI
, 0, 0 },
11847 { MASK_MMX
, CODE_FOR_mmx_ashldi3
, 0, IX86_BUILTIN_PSLLQ
, 0, 0 },
11848 { MASK_MMX
, CODE_FOR_mmx_ashldi3
, 0, IX86_BUILTIN_PSLLQI
, 0, 0 },
11850 { MASK_MMX
, CODE_FOR_lshrv4hi3
, 0, IX86_BUILTIN_PSRLW
, 0, 0 },
11851 { MASK_MMX
, CODE_FOR_lshrv4hi3
, 0, IX86_BUILTIN_PSRLWI
, 0, 0 },
11852 { MASK_MMX
, CODE_FOR_lshrv2si3
, 0, IX86_BUILTIN_PSRLD
, 0, 0 },
11853 { MASK_MMX
, CODE_FOR_lshrv2si3
, 0, IX86_BUILTIN_PSRLDI
, 0, 0 },
11854 { MASK_MMX
, CODE_FOR_mmx_lshrdi3
, 0, IX86_BUILTIN_PSRLQ
, 0, 0 },
11855 { MASK_MMX
, CODE_FOR_mmx_lshrdi3
, 0, IX86_BUILTIN_PSRLQI
, 0, 0 },
11857 { MASK_MMX
, CODE_FOR_ashrv4hi3
, 0, IX86_BUILTIN_PSRAW
, 0, 0 },
11858 { MASK_MMX
, CODE_FOR_ashrv4hi3
, 0, IX86_BUILTIN_PSRAWI
, 0, 0 },
11859 { MASK_MMX
, CODE_FOR_ashrv2si3
, 0, IX86_BUILTIN_PSRAD
, 0, 0 },
11860 { MASK_MMX
, CODE_FOR_ashrv2si3
, 0, IX86_BUILTIN_PSRADI
, 0, 0 },
11862 { MASK_SSE1
| MASK_3DNOW_A
, CODE_FOR_mmx_psadbw
, 0, IX86_BUILTIN_PSADBW
, 0, 0 },
11863 { MASK_MMX
, CODE_FOR_mmx_pmaddwd
, 0, IX86_BUILTIN_PMADDWD
, 0, 0 },
11866 { MASK_SSE2
, CODE_FOR_addv2df3
, "__builtin_ia32_addpd", IX86_BUILTIN_ADDPD
, 0, 0 },
11867 { MASK_SSE2
, CODE_FOR_subv2df3
, "__builtin_ia32_subpd", IX86_BUILTIN_SUBPD
, 0, 0 },
11868 { MASK_SSE2
, CODE_FOR_mulv2df3
, "__builtin_ia32_mulpd", IX86_BUILTIN_MULPD
, 0, 0 },
11869 { MASK_SSE2
, CODE_FOR_divv2df3
, "__builtin_ia32_divpd", IX86_BUILTIN_DIVPD
, 0, 0 },
11870 { MASK_SSE2
, CODE_FOR_vmaddv2df3
, "__builtin_ia32_addsd", IX86_BUILTIN_ADDSD
, 0, 0 },
11871 { MASK_SSE2
, CODE_FOR_vmsubv2df3
, "__builtin_ia32_subsd", IX86_BUILTIN_SUBSD
, 0, 0 },
11872 { MASK_SSE2
, CODE_FOR_vmmulv2df3
, "__builtin_ia32_mulsd", IX86_BUILTIN_MULSD
, 0, 0 },
11873 { MASK_SSE2
, CODE_FOR_vmdivv2df3
, "__builtin_ia32_divsd", IX86_BUILTIN_DIVSD
, 0, 0 },
11875 { MASK_SSE2
, CODE_FOR_maskcmpv2df3
, "__builtin_ia32_cmpeqpd", IX86_BUILTIN_CMPEQPD
, EQ
, 0 },
11876 { MASK_SSE2
, CODE_FOR_maskcmpv2df3
, "__builtin_ia32_cmpltpd", IX86_BUILTIN_CMPLTPD
, LT
, 0 },
11877 { MASK_SSE2
, CODE_FOR_maskcmpv2df3
, "__builtin_ia32_cmplepd", IX86_BUILTIN_CMPLEPD
, LE
, 0 },
11878 { MASK_SSE2
, CODE_FOR_maskcmpv2df3
, "__builtin_ia32_cmpgtpd", IX86_BUILTIN_CMPGTPD
, LT
, 1 },
11879 { MASK_SSE2
, CODE_FOR_maskcmpv2df3
, "__builtin_ia32_cmpgepd", IX86_BUILTIN_CMPGEPD
, LE
, 1 },
11880 { MASK_SSE2
, CODE_FOR_maskcmpv2df3
, "__builtin_ia32_cmpunordpd", IX86_BUILTIN_CMPUNORDPD
, UNORDERED
, 0 },
11881 { MASK_SSE2
, CODE_FOR_maskncmpv2df3
, "__builtin_ia32_cmpneqpd", IX86_BUILTIN_CMPNEQPD
, EQ
, 0 },
11882 { MASK_SSE2
, CODE_FOR_maskncmpv2df3
, "__builtin_ia32_cmpnltpd", IX86_BUILTIN_CMPNLTPD
, LT
, 0 },
11883 { MASK_SSE2
, CODE_FOR_maskncmpv2df3
, "__builtin_ia32_cmpnlepd", IX86_BUILTIN_CMPNLEPD
, LE
, 0 },
11884 { MASK_SSE2
, CODE_FOR_maskncmpv2df3
, "__builtin_ia32_cmpngtpd", IX86_BUILTIN_CMPNGTPD
, LT
, 1 },
11885 { MASK_SSE2
, CODE_FOR_maskncmpv2df3
, "__builtin_ia32_cmpngepd", IX86_BUILTIN_CMPNGEPD
, LE
, 1 },
11886 { MASK_SSE2
, CODE_FOR_maskncmpv2df3
, "__builtin_ia32_cmpordpd", IX86_BUILTIN_CMPORDPD
, UNORDERED
, 0 },
11887 { MASK_SSE2
, CODE_FOR_vmmaskcmpv2df3
, "__builtin_ia32_cmpeqsd", IX86_BUILTIN_CMPEQSD
, EQ
, 0 },
11888 { MASK_SSE2
, CODE_FOR_vmmaskcmpv2df3
, "__builtin_ia32_cmpltsd", IX86_BUILTIN_CMPLTSD
, LT
, 0 },
11889 { MASK_SSE2
, CODE_FOR_vmmaskcmpv2df3
, "__builtin_ia32_cmplesd", IX86_BUILTIN_CMPLESD
, LE
, 0 },
11890 { MASK_SSE2
, CODE_FOR_vmmaskcmpv2df3
, "__builtin_ia32_cmpgtsd", IX86_BUILTIN_CMPGTSD
, LT
, 1 },
11891 { MASK_SSE2
, CODE_FOR_vmmaskcmpv2df3
, "__builtin_ia32_cmpgesd", IX86_BUILTIN_CMPGESD
, LE
, 1 },
11892 { MASK_SSE2
, CODE_FOR_vmmaskcmpv2df3
, "__builtin_ia32_cmpunordsd", IX86_BUILTIN_CMPUNORDSD
, UNORDERED
, 0 },
11893 { MASK_SSE2
, CODE_FOR_vmmaskncmpv2df3
, "__builtin_ia32_cmpneqsd", IX86_BUILTIN_CMPNEQSD
, EQ
, 0 },
11894 { MASK_SSE2
, CODE_FOR_vmmaskncmpv2df3
, "__builtin_ia32_cmpnltsd", IX86_BUILTIN_CMPNLTSD
, LT
, 0 },
11895 { MASK_SSE2
, CODE_FOR_vmmaskncmpv2df3
, "__builtin_ia32_cmpnlesd", IX86_BUILTIN_CMPNLESD
, LE
, 0 },
11896 { MASK_SSE2
, CODE_FOR_vmmaskncmpv2df3
, "__builtin_ia32_cmpngtsd", IX86_BUILTIN_CMPNGTSD
, LT
, 1 },
11897 { MASK_SSE2
, CODE_FOR_vmmaskncmpv2df3
, "__builtin_ia32_cmpngesd", IX86_BUILTIN_CMPNGESD
, LE
, 1 },
11898 { MASK_SSE2
, CODE_FOR_vmmaskncmpv2df3
, "__builtin_ia32_cmpordsd", IX86_BUILTIN_CMPORDSD
, UNORDERED
, 0 },
11900 { MASK_SSE2
, CODE_FOR_sminv2df3
, "__builtin_ia32_minpd", IX86_BUILTIN_MINPD
, 0, 0 },
11901 { MASK_SSE2
, CODE_FOR_smaxv2df3
, "__builtin_ia32_maxpd", IX86_BUILTIN_MAXPD
, 0, 0 },
11902 { MASK_SSE2
, CODE_FOR_vmsminv2df3
, "__builtin_ia32_minsd", IX86_BUILTIN_MINSD
, 0, 0 },
11903 { MASK_SSE2
, CODE_FOR_vmsmaxv2df3
, "__builtin_ia32_maxsd", IX86_BUILTIN_MAXSD
, 0, 0 },
11905 { MASK_SSE2
, CODE_FOR_sse2_anddf3
, "__builtin_ia32_andpd", IX86_BUILTIN_ANDPD
, 0, 0 },
11906 { MASK_SSE2
, CODE_FOR_sse2_nanddf3
, "__builtin_ia32_andnpd", IX86_BUILTIN_ANDNPD
, 0, 0 },
11907 { MASK_SSE2
, CODE_FOR_sse2_iordf3
, "__builtin_ia32_orpd", IX86_BUILTIN_ORPD
, 0, 0 },
11908 { MASK_SSE2
, CODE_FOR_sse2_xordf3
, "__builtin_ia32_xorpd", IX86_BUILTIN_XORPD
, 0, 0 },
11910 { MASK_SSE2
, CODE_FOR_sse2_movsd
, "__builtin_ia32_movsd", IX86_BUILTIN_MOVSD
, 0, 0 },
11911 { MASK_SSE2
, CODE_FOR_sse2_unpckhpd
, "__builtin_ia32_unpckhpd", IX86_BUILTIN_UNPCKHPD
, 0, 0 },
11912 { MASK_SSE2
, CODE_FOR_sse2_unpcklpd
, "__builtin_ia32_unpcklpd", IX86_BUILTIN_UNPCKLPD
, 0, 0 },
11915 { MASK_SSE2
, CODE_FOR_addv16qi3
, "__builtin_ia32_paddb128", IX86_BUILTIN_PADDB128
, 0, 0 },
11916 { MASK_SSE2
, CODE_FOR_addv8hi3
, "__builtin_ia32_paddw128", IX86_BUILTIN_PADDW128
, 0, 0 },
11917 { MASK_SSE2
, CODE_FOR_addv4si3
, "__builtin_ia32_paddd128", IX86_BUILTIN_PADDD128
, 0, 0 },
11918 { MASK_SSE2
, CODE_FOR_addv4si3
, "__builtin_ia32_paddq128", IX86_BUILTIN_PADDQ128
, 0, 0 },
11919 { MASK_SSE2
, CODE_FOR_subv16qi3
, "__builtin_ia32_psubb128", IX86_BUILTIN_PSUBB128
, 0, 0 },
11920 { MASK_SSE2
, CODE_FOR_subv8hi3
, "__builtin_ia32_psubw128", IX86_BUILTIN_PSUBW128
, 0, 0 },
11921 { MASK_SSE2
, CODE_FOR_subv4si3
, "__builtin_ia32_psubd128", IX86_BUILTIN_PSUBD128
, 0, 0 },
11922 { MASK_SSE2
, CODE_FOR_subv4si3
, "__builtin_ia32_psubq128", IX86_BUILTIN_PSUBQ128
, 0, 0 },
11924 { MASK_MMX
, CODE_FOR_ssaddv16qi3
, "__builtin_ia32_paddsb128", IX86_BUILTIN_PADDSB128
, 0, 0 },
11925 { MASK_MMX
, CODE_FOR_ssaddv8hi3
, "__builtin_ia32_paddsw128", IX86_BUILTIN_PADDSW128
, 0, 0 },
11926 { MASK_MMX
, CODE_FOR_sssubv16qi3
, "__builtin_ia32_psubsb128", IX86_BUILTIN_PSUBSB128
, 0, 0 },
11927 { MASK_MMX
, CODE_FOR_sssubv8hi3
, "__builtin_ia32_psubsw128", IX86_BUILTIN_PSUBSW128
, 0, 0 },
11928 { MASK_MMX
, CODE_FOR_usaddv16qi3
, "__builtin_ia32_paddusb128", IX86_BUILTIN_PADDUSB128
, 0, 0 },
11929 { MASK_MMX
, CODE_FOR_usaddv8hi3
, "__builtin_ia32_paddusw128", IX86_BUILTIN_PADDUSW128
, 0, 0 },
11930 { MASK_MMX
, CODE_FOR_ussubv16qi3
, "__builtin_ia32_psubusb128", IX86_BUILTIN_PSUBUSB128
, 0, 0 },
11931 { MASK_MMX
, CODE_FOR_ussubv8hi3
, "__builtin_ia32_psubusw128", IX86_BUILTIN_PSUBUSW128
, 0, 0 },
11933 { MASK_SSE2
, CODE_FOR_mulv8hi3
, "__builtin_ia32_pmullw128", IX86_BUILTIN_PMULLW128
, 0, 0 },
11934 { MASK_SSE2
, CODE_FOR_smulv8hi3_highpart
, "__builtin_ia32_pmulhw128", IX86_BUILTIN_PMULHW128
, 0, 0 },
11935 { MASK_SSE2
, CODE_FOR_sse2_umulsidi3
, "__builtin_ia32_pmuludq", IX86_BUILTIN_PMULUDQ
, 0, 0 },
11936 { MASK_SSE2
, CODE_FOR_sse2_umulv2siv2di3
, "__builtin_ia32_pmuludq128", IX86_BUILTIN_PMULUDQ128
, 0, 0 },
11938 { MASK_SSE2
, CODE_FOR_sse2_andv2di3
, "__builtin_ia32_pand128", IX86_BUILTIN_PAND128
, 0, 0 },
11939 { MASK_SSE2
, CODE_FOR_sse2_nandv2di3
, "__builtin_ia32_pandn128", IX86_BUILTIN_PANDN128
, 0, 0 },
11940 { MASK_SSE2
, CODE_FOR_sse2_iorv2di3
, "__builtin_ia32_por128", IX86_BUILTIN_POR128
, 0, 0 },
11941 { MASK_SSE2
, CODE_FOR_sse2_xorv2di3
, "__builtin_ia32_pxor128", IX86_BUILTIN_PXOR128
, 0, 0 },
11943 { MASK_SSE2
, CODE_FOR_sse2_uavgv16qi3
, "__builtin_ia32_pavgb128", IX86_BUILTIN_PAVGB128
, 0, 0 },
11944 { MASK_SSE2
, CODE_FOR_sse2_uavgv8hi3
, "__builtin_ia32_pavgw128", IX86_BUILTIN_PAVGW128
, 0, 0 },
11946 { MASK_SSE2
, CODE_FOR_eqv16qi3
, "__builtin_ia32_pcmpeqb128", IX86_BUILTIN_PCMPEQB128
, 0, 0 },
11947 { MASK_SSE2
, CODE_FOR_eqv8hi3
, "__builtin_ia32_pcmpeqw128", IX86_BUILTIN_PCMPEQW128
, 0, 0 },
11948 { MASK_SSE2
, CODE_FOR_eqv4si3
, "__builtin_ia32_pcmpeqd128", IX86_BUILTIN_PCMPEQD128
, 0, 0 },
11949 { MASK_SSE2
, CODE_FOR_gtv16qi3
, "__builtin_ia32_pcmpgtb128", IX86_BUILTIN_PCMPGTB128
, 0, 0 },
11950 { MASK_SSE2
, CODE_FOR_gtv8hi3
, "__builtin_ia32_pcmpgtw128", IX86_BUILTIN_PCMPGTW128
, 0, 0 },
11951 { MASK_SSE2
, CODE_FOR_gtv4si3
, "__builtin_ia32_pcmpgtd128", IX86_BUILTIN_PCMPGTD128
, 0, 0 },
11953 { MASK_SSE2
, CODE_FOR_umaxv16qi3
, "__builtin_ia32_pmaxub128", IX86_BUILTIN_PMAXUB128
, 0, 0 },
11954 { MASK_SSE2
, CODE_FOR_smaxv8hi3
, "__builtin_ia32_pmaxsw128", IX86_BUILTIN_PMAXSW128
, 0, 0 },
11955 { MASK_SSE2
, CODE_FOR_uminv16qi3
, "__builtin_ia32_pminub128", IX86_BUILTIN_PMINUB128
, 0, 0 },
11956 { MASK_SSE2
, CODE_FOR_sminv8hi3
, "__builtin_ia32_pminsw128", IX86_BUILTIN_PMINSW128
, 0, 0 },
11958 { MASK_SSE2
, CODE_FOR_sse2_punpckhbw
, "__builtin_ia32_punpckhbw128", IX86_BUILTIN_PUNPCKHBW128
, 0, 0 },
11959 { MASK_SSE2
, CODE_FOR_sse2_punpckhwd
, "__builtin_ia32_punpckhwd128", IX86_BUILTIN_PUNPCKHWD128
, 0, 0 },
11960 { MASK_SSE2
, CODE_FOR_sse2_punpckhdq
, "__builtin_ia32_punpckhdq128", IX86_BUILTIN_PUNPCKHDQ128
, 0, 0 },
11961 { MASK_SSE2
, CODE_FOR_sse2_punpcklbw
, "__builtin_ia32_punpcklbw128", IX86_BUILTIN_PUNPCKLBW128
, 0, 0 },
11962 { MASK_SSE2
, CODE_FOR_sse2_punpcklwd
, "__builtin_ia32_punpcklwd128", IX86_BUILTIN_PUNPCKLWD128
, 0, 0 },
11963 { MASK_SSE2
, CODE_FOR_sse2_punpckldq
, "__builtin_ia32_punpckldq128", IX86_BUILTIN_PUNPCKLDQ128
, 0, 0 },
11965 { MASK_SSE2
, CODE_FOR_sse2_packsswb
, "__builtin_ia32_packsswb128", IX86_BUILTIN_PACKSSWB128
, 0, 0 },
11966 { MASK_SSE2
, CODE_FOR_sse2_packssdw
, "__builtin_ia32_packssdw128", IX86_BUILTIN_PACKSSDW128
, 0, 0 },
11967 { MASK_SSE2
, CODE_FOR_sse2_packuswb
, "__builtin_ia32_packuswb128", IX86_BUILTIN_PACKUSWB128
, 0, 0 },
11969 { MASK_SSE2
, CODE_FOR_umulv8hi3_highpart
, "__builtin_ia32_pmulhuw128", IX86_BUILTIN_PMULHUW128
, 0, 0 },
11970 { MASK_SSE2
, CODE_FOR_sse2_psadbw
, 0, IX86_BUILTIN_PSADBW128
, 0, 0 },
11972 { MASK_SSE2
, CODE_FOR_ashlv8hi3_ti
, 0, IX86_BUILTIN_PSLLW128
, 0, 0 },
11973 { MASK_SSE2
, CODE_FOR_ashlv8hi3
, 0, IX86_BUILTIN_PSLLWI128
, 0, 0 },
11974 { MASK_SSE2
, CODE_FOR_ashlv4si3_ti
, 0, IX86_BUILTIN_PSLLD128
, 0, 0 },
11975 { MASK_SSE2
, CODE_FOR_ashlv4si3
, 0, IX86_BUILTIN_PSLLDI128
, 0, 0 },
11976 { MASK_SSE2
, CODE_FOR_ashlv2di3_ti
, 0, IX86_BUILTIN_PSLLQ128
, 0, 0 },
11977 { MASK_SSE2
, CODE_FOR_ashlv2di3
, 0, IX86_BUILTIN_PSLLQI128
, 0, 0 },
11979 { MASK_SSE2
, CODE_FOR_lshrv8hi3_ti
, 0, IX86_BUILTIN_PSRLW128
, 0, 0 },
11980 { MASK_SSE2
, CODE_FOR_lshrv8hi3
, 0, IX86_BUILTIN_PSRLWI128
, 0, 0 },
11981 { MASK_SSE2
, CODE_FOR_lshrv4si3_ti
, 0, IX86_BUILTIN_PSRLD128
, 0, 0 },
11982 { MASK_SSE2
, CODE_FOR_lshrv4si3
, 0, IX86_BUILTIN_PSRLDI128
, 0, 0 },
11983 { MASK_SSE2
, CODE_FOR_lshrv2di3_ti
, 0, IX86_BUILTIN_PSRLQ128
, 0, 0 },
11984 { MASK_SSE2
, CODE_FOR_lshrv2di3
, 0, IX86_BUILTIN_PSRLQI128
, 0, 0 },
11986 { MASK_SSE2
, CODE_FOR_ashrv8hi3_ti
, 0, IX86_BUILTIN_PSRAW128
, 0, 0 },
11987 { MASK_SSE2
, CODE_FOR_ashrv8hi3
, 0, IX86_BUILTIN_PSRAWI128
, 0, 0 },
11988 { MASK_SSE2
, CODE_FOR_ashrv4si3_ti
, 0, IX86_BUILTIN_PSRAD128
, 0, 0 },
11989 { MASK_SSE2
, CODE_FOR_ashrv4si3
, 0, IX86_BUILTIN_PSRADI128
, 0, 0 },
11991 { MASK_SSE2
, CODE_FOR_sse2_pmaddwd
, 0, IX86_BUILTIN_PMADDWD128
, 0, 0 },
11993 { MASK_SSE2
, CODE_FOR_cvtsi2sd
, 0, IX86_BUILTIN_CVTSI2SD
, 0, 0 },
11994 { MASK_SSE2
, CODE_FOR_cvtsd2ss
, 0, IX86_BUILTIN_CVTSD2SS
, 0, 0 },
11995 { MASK_SSE2
, CODE_FOR_cvtss2sd
, 0, IX86_BUILTIN_CVTSS2SD
, 0, 0 }
11998 static const struct builtin_description bdesc_1arg
[] =
12000 { MASK_SSE1
| MASK_3DNOW_A
, CODE_FOR_mmx_pmovmskb
, 0, IX86_BUILTIN_PMOVMSKB
, 0, 0 },
12001 { MASK_SSE1
, CODE_FOR_sse_movmskps
, 0, IX86_BUILTIN_MOVMSKPS
, 0, 0 },
12003 { MASK_SSE1
, CODE_FOR_sqrtv4sf2
, 0, IX86_BUILTIN_SQRTPS
, 0, 0 },
12004 { MASK_SSE1
, CODE_FOR_rsqrtv4sf2
, 0, IX86_BUILTIN_RSQRTPS
, 0, 0 },
12005 { MASK_SSE1
, CODE_FOR_rcpv4sf2
, 0, IX86_BUILTIN_RCPPS
, 0, 0 },
12007 { MASK_SSE1
, CODE_FOR_cvtps2pi
, 0, IX86_BUILTIN_CVTPS2PI
, 0, 0 },
12008 { MASK_SSE1
, CODE_FOR_cvtss2si
, 0, IX86_BUILTIN_CVTSS2SI
, 0, 0 },
12009 { MASK_SSE1
, CODE_FOR_cvttps2pi
, 0, IX86_BUILTIN_CVTTPS2PI
, 0, 0 },
12010 { MASK_SSE1
, CODE_FOR_cvttss2si
, 0, IX86_BUILTIN_CVTTSS2SI
, 0, 0 },
12012 { MASK_SSE2
, CODE_FOR_sse2_pmovmskb
, 0, IX86_BUILTIN_PMOVMSKB128
, 0, 0 },
12013 { MASK_SSE2
, CODE_FOR_sse2_movmskpd
, 0, IX86_BUILTIN_MOVMSKPD
, 0, 0 },
12014 { MASK_SSE2
, CODE_FOR_sse2_movq2dq
, 0, IX86_BUILTIN_MOVQ2DQ
, 0, 0 },
12016 { MASK_SSE2
, CODE_FOR_sqrtv2df2
, 0, IX86_BUILTIN_SQRTPD
, 0, 0 },
12018 { MASK_SSE2
, CODE_FOR_cvtdq2pd
, 0, IX86_BUILTIN_CVTDQ2PD
, 0, 0 },
12019 { MASK_SSE2
, CODE_FOR_cvtdq2ps
, 0, IX86_BUILTIN_CVTDQ2PS
, 0, 0 },
12021 { MASK_SSE2
, CODE_FOR_cvtpd2dq
, 0, IX86_BUILTIN_CVTPD2DQ
, 0, 0 },
12022 { MASK_SSE2
, CODE_FOR_cvtpd2pi
, 0, IX86_BUILTIN_CVTPD2PI
, 0, 0 },
12023 { MASK_SSE2
, CODE_FOR_cvtpd2ps
, 0, IX86_BUILTIN_CVTPD2PS
, 0, 0 },
12024 { MASK_SSE2
, CODE_FOR_cvttpd2dq
, 0, IX86_BUILTIN_CVTTPD2DQ
, 0, 0 },
12025 { MASK_SSE2
, CODE_FOR_cvttpd2pi
, 0, IX86_BUILTIN_CVTTPD2PI
, 0, 0 },
12027 { MASK_SSE2
, CODE_FOR_cvtpi2pd
, 0, IX86_BUILTIN_CVTPI2PD
, 0, 0 },
12029 { MASK_SSE2
, CODE_FOR_cvtsd2si
, 0, IX86_BUILTIN_CVTSD2SI
, 0, 0 },
12030 { MASK_SSE2
, CODE_FOR_cvttsd2si
, 0, IX86_BUILTIN_CVTTSD2SI
, 0, 0 },
12032 { MASK_SSE2
, CODE_FOR_cvtps2dq
, 0, IX86_BUILTIN_CVTPS2DQ
, 0, 0 },
12033 { MASK_SSE2
, CODE_FOR_cvtps2pd
, 0, IX86_BUILTIN_CVTPS2PD
, 0, 0 },
12034 { MASK_SSE2
, CODE_FOR_cvttps2dq
, 0, IX86_BUILTIN_CVTTPS2DQ
, 0, 0 }
12038 ix86_init_builtins ()
12041 ix86_init_mmx_sse_builtins ();
12044 /* Set up all the MMX/SSE builtins. This is not called if TARGET_MMX
12045 is zero. Otherwise, if TARGET_SSE is not set, only expand the MMX
12048 ix86_init_mmx_sse_builtins ()
12050 const struct builtin_description
* d
;
12053 tree pchar_type_node
= build_pointer_type (char_type_node
);
12054 tree pfloat_type_node
= build_pointer_type (float_type_node
);
12055 tree pv2si_type_node
= build_pointer_type (V2SI_type_node
);
12056 tree pv2di_type_node
= build_pointer_type (V2DI_type_node
);
12057 tree pdi_type_node
= build_pointer_type (long_long_unsigned_type_node
);
12060 tree int_ftype_v4sf_v4sf
12061 = build_function_type_list (integer_type_node
,
12062 V4SF_type_node
, V4SF_type_node
, NULL_TREE
);
12063 tree v4si_ftype_v4sf_v4sf
12064 = build_function_type_list (V4SI_type_node
,
12065 V4SF_type_node
, V4SF_type_node
, NULL_TREE
);
12066 /* MMX/SSE/integer conversions. */
12067 tree int_ftype_v4sf
12068 = build_function_type_list (integer_type_node
,
12069 V4SF_type_node
, NULL_TREE
);
12070 tree int_ftype_v8qi
12071 = build_function_type_list (integer_type_node
, V8QI_type_node
, NULL_TREE
);
12072 tree v4sf_ftype_v4sf_int
12073 = build_function_type_list (V4SF_type_node
,
12074 V4SF_type_node
, integer_type_node
, NULL_TREE
);
12075 tree v4sf_ftype_v4sf_v2si
12076 = build_function_type_list (V4SF_type_node
,
12077 V4SF_type_node
, V2SI_type_node
, NULL_TREE
);
12078 tree int_ftype_v4hi_int
12079 = build_function_type_list (integer_type_node
,
12080 V4HI_type_node
, integer_type_node
, NULL_TREE
);
12081 tree v4hi_ftype_v4hi_int_int
12082 = build_function_type_list (V4HI_type_node
, V4HI_type_node
,
12083 integer_type_node
, integer_type_node
,
12085 /* Miscellaneous. */
12086 tree v8qi_ftype_v4hi_v4hi
12087 = build_function_type_list (V8QI_type_node
,
12088 V4HI_type_node
, V4HI_type_node
, NULL_TREE
);
12089 tree v4hi_ftype_v2si_v2si
12090 = build_function_type_list (V4HI_type_node
,
12091 V2SI_type_node
, V2SI_type_node
, NULL_TREE
);
12092 tree v4sf_ftype_v4sf_v4sf_int
12093 = build_function_type_list (V4SF_type_node
,
12094 V4SF_type_node
, V4SF_type_node
,
12095 integer_type_node
, NULL_TREE
);
12096 tree v2si_ftype_v4hi_v4hi
12097 = build_function_type_list (V2SI_type_node
,
12098 V4HI_type_node
, V4HI_type_node
, NULL_TREE
);
12099 tree v4hi_ftype_v4hi_int
12100 = build_function_type_list (V4HI_type_node
,
12101 V4HI_type_node
, integer_type_node
, NULL_TREE
);
12102 tree v4hi_ftype_v4hi_di
12103 = build_function_type_list (V4HI_type_node
,
12104 V4HI_type_node
, long_long_unsigned_type_node
,
12106 tree v2si_ftype_v2si_di
12107 = build_function_type_list (V2SI_type_node
,
12108 V2SI_type_node
, long_long_unsigned_type_node
,
12110 tree void_ftype_void
12111 = build_function_type (void_type_node
, void_list_node
);
12112 tree void_ftype_unsigned
12113 = build_function_type_list (void_type_node
, unsigned_type_node
, NULL_TREE
);
12114 tree unsigned_ftype_void
12115 = build_function_type (unsigned_type_node
, void_list_node
);
12117 = build_function_type (long_long_unsigned_type_node
, void_list_node
);
12118 tree v4sf_ftype_void
12119 = build_function_type (V4SF_type_node
, void_list_node
);
12120 tree v2si_ftype_v4sf
12121 = build_function_type_list (V2SI_type_node
, V4SF_type_node
, NULL_TREE
);
12122 /* Loads/stores. */
12123 tree void_ftype_v8qi_v8qi_pchar
12124 = build_function_type_list (void_type_node
,
12125 V8QI_type_node
, V8QI_type_node
,
12126 pchar_type_node
, NULL_TREE
);
12127 tree v4sf_ftype_pfloat
12128 = build_function_type_list (V4SF_type_node
, pfloat_type_node
, NULL_TREE
);
12129 /* @@@ the type is bogus */
12130 tree v4sf_ftype_v4sf_pv2si
12131 = build_function_type_list (V4SF_type_node
,
12132 V4SF_type_node
, pv2di_type_node
, NULL_TREE
);
12133 tree void_ftype_pv2si_v4sf
12134 = build_function_type_list (void_type_node
,
12135 pv2di_type_node
, V4SF_type_node
, NULL_TREE
);
12136 tree void_ftype_pfloat_v4sf
12137 = build_function_type_list (void_type_node
,
12138 pfloat_type_node
, V4SF_type_node
, NULL_TREE
);
12139 tree void_ftype_pdi_di
12140 = build_function_type_list (void_type_node
,
12141 pdi_type_node
, long_long_unsigned_type_node
,
12143 tree void_ftype_pv2di_v2di
12144 = build_function_type_list (void_type_node
,
12145 pv2di_type_node
, V2DI_type_node
, NULL_TREE
);
12146 /* Normal vector unops. */
12147 tree v4sf_ftype_v4sf
12148 = build_function_type_list (V4SF_type_node
, V4SF_type_node
, NULL_TREE
);
12150 /* Normal vector binops. */
12151 tree v4sf_ftype_v4sf_v4sf
12152 = build_function_type_list (V4SF_type_node
,
12153 V4SF_type_node
, V4SF_type_node
, NULL_TREE
);
12154 tree v8qi_ftype_v8qi_v8qi
12155 = build_function_type_list (V8QI_type_node
,
12156 V8QI_type_node
, V8QI_type_node
, NULL_TREE
);
12157 tree v4hi_ftype_v4hi_v4hi
12158 = build_function_type_list (V4HI_type_node
,
12159 V4HI_type_node
, V4HI_type_node
, NULL_TREE
);
12160 tree v2si_ftype_v2si_v2si
12161 = build_function_type_list (V2SI_type_node
,
12162 V2SI_type_node
, V2SI_type_node
, NULL_TREE
);
12163 tree di_ftype_di_di
12164 = build_function_type_list (long_long_unsigned_type_node
,
12165 long_long_unsigned_type_node
,
12166 long_long_unsigned_type_node
, NULL_TREE
);
12168 tree v2si_ftype_v2sf
12169 = build_function_type_list (V2SI_type_node
, V2SF_type_node
, NULL_TREE
);
12170 tree v2sf_ftype_v2si
12171 = build_function_type_list (V2SF_type_node
, V2SI_type_node
, NULL_TREE
);
12172 tree v2si_ftype_v2si
12173 = build_function_type_list (V2SI_type_node
, V2SI_type_node
, NULL_TREE
);
12174 tree v2sf_ftype_v2sf
12175 = build_function_type_list (V2SF_type_node
, V2SF_type_node
, NULL_TREE
);
12176 tree v2sf_ftype_v2sf_v2sf
12177 = build_function_type_list (V2SF_type_node
,
12178 V2SF_type_node
, V2SF_type_node
, NULL_TREE
);
12179 tree v2si_ftype_v2sf_v2sf
12180 = build_function_type_list (V2SI_type_node
,
12181 V2SF_type_node
, V2SF_type_node
, NULL_TREE
);
12182 tree pint_type_node
= build_pointer_type (integer_type_node
);
12183 tree pdouble_type_node
= build_pointer_type (double_type_node
);
12184 tree int_ftype_v2df_v2df
12185 = build_function_type_list (integer_type_node
,
12186 V2DF_type_node
, V2DF_type_node
, NULL_TREE
);
12189 = build_function_type (intTI_type_node
, void_list_node
);
12190 tree ti_ftype_ti_ti
12191 = build_function_type_list (intTI_type_node
,
12192 intTI_type_node
, intTI_type_node
, NULL_TREE
);
12193 tree void_ftype_pvoid
12194 = build_function_type_list (void_type_node
, ptr_type_node
, NULL_TREE
);
12196 = build_function_type_list (V2DI_type_node
,
12197 long_long_unsigned_type_node
, NULL_TREE
);
12198 tree v4sf_ftype_v4si
12199 = build_function_type_list (V4SF_type_node
, V4SI_type_node
, NULL_TREE
);
12200 tree v4si_ftype_v4sf
12201 = build_function_type_list (V4SI_type_node
, V4SF_type_node
, NULL_TREE
);
12202 tree v2df_ftype_v4si
12203 = build_function_type_list (V2DF_type_node
, V4SI_type_node
, NULL_TREE
);
12204 tree v4si_ftype_v2df
12205 = build_function_type_list (V4SI_type_node
, V2DF_type_node
, NULL_TREE
);
12206 tree v2si_ftype_v2df
12207 = build_function_type_list (V2SI_type_node
, V2DF_type_node
, NULL_TREE
);
12208 tree v4sf_ftype_v2df
12209 = build_function_type_list (V4SF_type_node
, V2DF_type_node
, NULL_TREE
);
12210 tree v2df_ftype_v2si
12211 = build_function_type_list (V2DF_type_node
, V2SI_type_node
, NULL_TREE
);
12212 tree v2df_ftype_v4sf
12213 = build_function_type_list (V2DF_type_node
, V4SF_type_node
, NULL_TREE
);
12214 tree int_ftype_v2df
12215 = build_function_type_list (integer_type_node
, V2DF_type_node
, NULL_TREE
);
12216 tree v2df_ftype_v2df_int
12217 = build_function_type_list (V2DF_type_node
,
12218 V2DF_type_node
, integer_type_node
, NULL_TREE
);
12219 tree v4sf_ftype_v4sf_v2df
12220 = build_function_type_list (V4SF_type_node
,
12221 V4SF_type_node
, V2DF_type_node
, NULL_TREE
);
12222 tree v2df_ftype_v2df_v4sf
12223 = build_function_type_list (V2DF_type_node
,
12224 V2DF_type_node
, V4SF_type_node
, NULL_TREE
);
12225 tree v2df_ftype_v2df_v2df_int
12226 = build_function_type_list (V2DF_type_node
,
12227 V2DF_type_node
, V2DF_type_node
,
12230 tree v2df_ftype_v2df_pv2si
12231 = build_function_type_list (V2DF_type_node
,
12232 V2DF_type_node
, pv2si_type_node
, NULL_TREE
);
12233 tree void_ftype_pv2si_v2df
12234 = build_function_type_list (void_type_node
,
12235 pv2si_type_node
, V2DF_type_node
, NULL_TREE
);
12236 tree void_ftype_pdouble_v2df
12237 = build_function_type_list (void_type_node
,
12238 pdouble_type_node
, V2DF_type_node
, NULL_TREE
);
12239 tree void_ftype_pint_int
12240 = build_function_type_list (void_type_node
,
12241 pint_type_node
, integer_type_node
, NULL_TREE
);
12242 tree void_ftype_v16qi_v16qi_pchar
12243 = build_function_type_list (void_type_node
,
12244 V16QI_type_node
, V16QI_type_node
,
12245 pchar_type_node
, NULL_TREE
);
12246 tree v2df_ftype_pdouble
12247 = build_function_type_list (V2DF_type_node
, pdouble_type_node
, NULL_TREE
);
12248 tree v2df_ftype_v2df_v2df
12249 = build_function_type_list (V2DF_type_node
,
12250 V2DF_type_node
, V2DF_type_node
, NULL_TREE
);
12251 tree v16qi_ftype_v16qi_v16qi
12252 = build_function_type_list (V16QI_type_node
,
12253 V16QI_type_node
, V16QI_type_node
, NULL_TREE
);
12254 tree v8hi_ftype_v8hi_v8hi
12255 = build_function_type_list (V8HI_type_node
,
12256 V8HI_type_node
, V8HI_type_node
, NULL_TREE
);
12257 tree v4si_ftype_v4si_v4si
12258 = build_function_type_list (V4SI_type_node
,
12259 V4SI_type_node
, V4SI_type_node
, NULL_TREE
);
12260 tree v2di_ftype_v2di_v2di
12261 = build_function_type_list (V2DI_type_node
,
12262 V2DI_type_node
, V2DI_type_node
, NULL_TREE
);
12263 tree v2di_ftype_v2df_v2df
12264 = build_function_type_list (V2DI_type_node
,
12265 V2DF_type_node
, V2DF_type_node
, NULL_TREE
);
12266 tree v2df_ftype_v2df
12267 = build_function_type_list (V2DF_type_node
, V2DF_type_node
, NULL_TREE
);
12268 tree v2df_ftype_double
12269 = build_function_type_list (V2DF_type_node
, double_type_node
, NULL_TREE
);
12270 tree v2df_ftype_double_double
12271 = build_function_type_list (V2DF_type_node
,
12272 double_type_node
, double_type_node
, NULL_TREE
);
12273 tree int_ftype_v8hi_int
12274 = build_function_type_list (integer_type_node
,
12275 V8HI_type_node
, integer_type_node
, NULL_TREE
);
12276 tree v8hi_ftype_v8hi_int_int
12277 = build_function_type_list (V8HI_type_node
,
12278 V8HI_type_node
, integer_type_node
,
12279 integer_type_node
, NULL_TREE
);
12280 tree v2di_ftype_v2di_int
12281 = build_function_type_list (V2DI_type_node
,
12282 V2DI_type_node
, integer_type_node
, NULL_TREE
);
12283 tree v4si_ftype_v4si_int
12284 = build_function_type_list (V4SI_type_node
,
12285 V4SI_type_node
, integer_type_node
, NULL_TREE
);
12286 tree v8hi_ftype_v8hi_int
12287 = build_function_type_list (V8HI_type_node
,
12288 V8HI_type_node
, integer_type_node
, NULL_TREE
);
12289 tree v8hi_ftype_v8hi_v2di
12290 = build_function_type_list (V8HI_type_node
,
12291 V8HI_type_node
, V2DI_type_node
, NULL_TREE
);
12292 tree v4si_ftype_v4si_v2di
12293 = build_function_type_list (V4SI_type_node
,
12294 V4SI_type_node
, V2DI_type_node
, NULL_TREE
);
12295 tree v4si_ftype_v8hi_v8hi
12296 = build_function_type_list (V4SI_type_node
,
12297 V8HI_type_node
, V8HI_type_node
, NULL_TREE
);
12298 tree di_ftype_v8qi_v8qi
12299 = build_function_type_list (long_long_unsigned_type_node
,
12300 V8QI_type_node
, V8QI_type_node
, NULL_TREE
);
12301 tree v2di_ftype_v16qi_v16qi
12302 = build_function_type_list (V2DI_type_node
,
12303 V16QI_type_node
, V16QI_type_node
, NULL_TREE
);
12304 tree int_ftype_v16qi
12305 = build_function_type_list (integer_type_node
, V16QI_type_node
, NULL_TREE
);
12307 /* Add all builtins that are more or less simple operations on two
12309 for (i
= 0, d
= bdesc_2arg
; i
< ARRAY_SIZE (bdesc_2arg
); i
++, d
++)
12311 /* Use one of the operands; the target can have a different mode for
12312 mask-generating compares. */
12313 enum machine_mode mode
;
12318 mode
= insn_data
[d
->icode
].operand
[1].mode
;
12323 type
= v16qi_ftype_v16qi_v16qi
;
12326 type
= v8hi_ftype_v8hi_v8hi
;
12329 type
= v4si_ftype_v4si_v4si
;
12332 type
= v2di_ftype_v2di_v2di
;
12335 type
= v2df_ftype_v2df_v2df
;
12338 type
= ti_ftype_ti_ti
;
12341 type
= v4sf_ftype_v4sf_v4sf
;
12344 type
= v8qi_ftype_v8qi_v8qi
;
12347 type
= v4hi_ftype_v4hi_v4hi
;
12350 type
= v2si_ftype_v2si_v2si
;
12353 type
= di_ftype_di_di
;
12360 /* Override for comparisons. */
12361 if (d
->icode
== CODE_FOR_maskcmpv4sf3
12362 || d
->icode
== CODE_FOR_maskncmpv4sf3
12363 || d
->icode
== CODE_FOR_vmmaskcmpv4sf3
12364 || d
->icode
== CODE_FOR_vmmaskncmpv4sf3
)
12365 type
= v4si_ftype_v4sf_v4sf
;
12367 if (d
->icode
== CODE_FOR_maskcmpv2df3
12368 || d
->icode
== CODE_FOR_maskncmpv2df3
12369 || d
->icode
== CODE_FOR_vmmaskcmpv2df3
12370 || d
->icode
== CODE_FOR_vmmaskncmpv2df3
)
12371 type
= v2di_ftype_v2df_v2df
;
12373 def_builtin (d
->mask
, d
->name
, type
, d
->code
);
12376 /* Add the remaining MMX insns with somewhat more complicated types. */
12377 def_builtin (MASK_MMX
, "__builtin_ia32_mmx_zero", di_ftype_void
, IX86_BUILTIN_MMX_ZERO
);
12378 def_builtin (MASK_MMX
, "__builtin_ia32_emms", void_ftype_void
, IX86_BUILTIN_EMMS
);
12379 def_builtin (MASK_MMX
, "__builtin_ia32_ldmxcsr", void_ftype_unsigned
, IX86_BUILTIN_LDMXCSR
);
12380 def_builtin (MASK_MMX
, "__builtin_ia32_stmxcsr", unsigned_ftype_void
, IX86_BUILTIN_STMXCSR
);
12381 def_builtin (MASK_MMX
, "__builtin_ia32_psllw", v4hi_ftype_v4hi_di
, IX86_BUILTIN_PSLLW
);
12382 def_builtin (MASK_MMX
, "__builtin_ia32_pslld", v2si_ftype_v2si_di
, IX86_BUILTIN_PSLLD
);
12383 def_builtin (MASK_MMX
, "__builtin_ia32_psllq", di_ftype_di_di
, IX86_BUILTIN_PSLLQ
);
12385 def_builtin (MASK_MMX
, "__builtin_ia32_psrlw", v4hi_ftype_v4hi_di
, IX86_BUILTIN_PSRLW
);
12386 def_builtin (MASK_MMX
, "__builtin_ia32_psrld", v2si_ftype_v2si_di
, IX86_BUILTIN_PSRLD
);
12387 def_builtin (MASK_MMX
, "__builtin_ia32_psrlq", di_ftype_di_di
, IX86_BUILTIN_PSRLQ
);
12389 def_builtin (MASK_MMX
, "__builtin_ia32_psraw", v4hi_ftype_v4hi_di
, IX86_BUILTIN_PSRAW
);
12390 def_builtin (MASK_MMX
, "__builtin_ia32_psrad", v2si_ftype_v2si_di
, IX86_BUILTIN_PSRAD
);
12392 def_builtin (MASK_MMX
, "__builtin_ia32_pshufw", v4hi_ftype_v4hi_int
, IX86_BUILTIN_PSHUFW
);
12393 def_builtin (MASK_MMX
, "__builtin_ia32_pmaddwd", v2si_ftype_v4hi_v4hi
, IX86_BUILTIN_PMADDWD
);
12395 /* comi/ucomi insns. */
12396 for (i
= 0, d
= bdesc_comi
; i
< ARRAY_SIZE (bdesc_comi
); i
++, d
++)
12397 if (d
->mask
== MASK_SSE2
)
12398 def_builtin (d
->mask
, d
->name
, int_ftype_v2df_v2df
, d
->code
);
12400 def_builtin (d
->mask
, d
->name
, int_ftype_v4sf_v4sf
, d
->code
);
12402 def_builtin (MASK_MMX
, "__builtin_ia32_packsswb", v8qi_ftype_v4hi_v4hi
, IX86_BUILTIN_PACKSSWB
);
12403 def_builtin (MASK_MMX
, "__builtin_ia32_packssdw", v4hi_ftype_v2si_v2si
, IX86_BUILTIN_PACKSSDW
);
12404 def_builtin (MASK_MMX
, "__builtin_ia32_packuswb", v8qi_ftype_v4hi_v4hi
, IX86_BUILTIN_PACKUSWB
);
12406 def_builtin (MASK_SSE1
, "__builtin_ia32_cvtpi2ps", v4sf_ftype_v4sf_v2si
, IX86_BUILTIN_CVTPI2PS
);
12407 def_builtin (MASK_SSE1
, "__builtin_ia32_cvtps2pi", v2si_ftype_v4sf
, IX86_BUILTIN_CVTPS2PI
);
12408 def_builtin (MASK_SSE1
, "__builtin_ia32_cvtsi2ss", v4sf_ftype_v4sf_int
, IX86_BUILTIN_CVTSI2SS
);
12409 def_builtin (MASK_SSE1
, "__builtin_ia32_cvtss2si", int_ftype_v4sf
, IX86_BUILTIN_CVTSS2SI
);
12410 def_builtin (MASK_SSE1
, "__builtin_ia32_cvttps2pi", v2si_ftype_v4sf
, IX86_BUILTIN_CVTTPS2PI
);
12411 def_builtin (MASK_SSE1
, "__builtin_ia32_cvttss2si", int_ftype_v4sf
, IX86_BUILTIN_CVTTSS2SI
);
12413 def_builtin (MASK_SSE1
, "__builtin_ia32_andps", v4sf_ftype_v4sf_v4sf
, IX86_BUILTIN_ANDPS
);
12414 def_builtin (MASK_SSE1
, "__builtin_ia32_andnps", v4sf_ftype_v4sf_v4sf
, IX86_BUILTIN_ANDNPS
);
12415 def_builtin (MASK_SSE1
, "__builtin_ia32_orps", v4sf_ftype_v4sf_v4sf
, IX86_BUILTIN_ORPS
);
12416 def_builtin (MASK_SSE1
, "__builtin_ia32_xorps", v4sf_ftype_v4sf_v4sf
, IX86_BUILTIN_XORPS
);
12418 def_builtin (MASK_SSE1
| MASK_3DNOW_A
, "__builtin_ia32_pextrw", int_ftype_v4hi_int
, IX86_BUILTIN_PEXTRW
);
12419 def_builtin (MASK_SSE1
| MASK_3DNOW_A
, "__builtin_ia32_pinsrw", v4hi_ftype_v4hi_int_int
, IX86_BUILTIN_PINSRW
);
12421 def_builtin (MASK_SSE1
| MASK_3DNOW_A
, "__builtin_ia32_maskmovq", void_ftype_v8qi_v8qi_pchar
, IX86_BUILTIN_MASKMOVQ
);
12423 def_builtin (MASK_SSE1
, "__builtin_ia32_loadaps", v4sf_ftype_pfloat
, IX86_BUILTIN_LOADAPS
);
12424 def_builtin (MASK_SSE1
, "__builtin_ia32_loadups", v4sf_ftype_pfloat
, IX86_BUILTIN_LOADUPS
);
12425 def_builtin (MASK_SSE1
, "__builtin_ia32_loadss", v4sf_ftype_pfloat
, IX86_BUILTIN_LOADSS
);
12426 def_builtin (MASK_SSE1
, "__builtin_ia32_storeaps", void_ftype_pfloat_v4sf
, IX86_BUILTIN_STOREAPS
);
12427 def_builtin (MASK_SSE1
, "__builtin_ia32_storeups", void_ftype_pfloat_v4sf
, IX86_BUILTIN_STOREUPS
);
12428 def_builtin (MASK_SSE1
, "__builtin_ia32_storess", void_ftype_pfloat_v4sf
, IX86_BUILTIN_STORESS
);
12430 def_builtin (MASK_SSE1
, "__builtin_ia32_loadhps", v4sf_ftype_v4sf_pv2si
, IX86_BUILTIN_LOADHPS
);
12431 def_builtin (MASK_SSE1
, "__builtin_ia32_loadlps", v4sf_ftype_v4sf_pv2si
, IX86_BUILTIN_LOADLPS
);
12432 def_builtin (MASK_SSE1
, "__builtin_ia32_storehps", void_ftype_pv2si_v4sf
, IX86_BUILTIN_STOREHPS
);
12433 def_builtin (MASK_SSE1
, "__builtin_ia32_storelps", void_ftype_pv2si_v4sf
, IX86_BUILTIN_STORELPS
);
12435 def_builtin (MASK_SSE1
, "__builtin_ia32_movmskps", int_ftype_v4sf
, IX86_BUILTIN_MOVMSKPS
);
12436 def_builtin (MASK_SSE1
| MASK_3DNOW_A
, "__builtin_ia32_pmovmskb", int_ftype_v8qi
, IX86_BUILTIN_PMOVMSKB
);
12437 def_builtin (MASK_SSE1
, "__builtin_ia32_movntps", void_ftype_pfloat_v4sf
, IX86_BUILTIN_MOVNTPS
);
12438 def_builtin (MASK_SSE1
| MASK_3DNOW_A
, "__builtin_ia32_movntq", void_ftype_pdi_di
, IX86_BUILTIN_MOVNTQ
);
12440 def_builtin (MASK_SSE1
| MASK_3DNOW_A
, "__builtin_ia32_sfence", void_ftype_void
, IX86_BUILTIN_SFENCE
);
12442 def_builtin (MASK_SSE1
| MASK_3DNOW_A
, "__builtin_ia32_psadbw", di_ftype_v8qi_v8qi
, IX86_BUILTIN_PSADBW
);
12444 def_builtin (MASK_SSE1
, "__builtin_ia32_rcpps", v4sf_ftype_v4sf
, IX86_BUILTIN_RCPPS
);
12445 def_builtin (MASK_SSE1
, "__builtin_ia32_rcpss", v4sf_ftype_v4sf
, IX86_BUILTIN_RCPSS
);
12446 def_builtin (MASK_SSE1
, "__builtin_ia32_rsqrtps", v4sf_ftype_v4sf
, IX86_BUILTIN_RSQRTPS
);
12447 def_builtin (MASK_SSE1
, "__builtin_ia32_rsqrtss", v4sf_ftype_v4sf
, IX86_BUILTIN_RSQRTSS
);
12448 def_builtin (MASK_SSE1
, "__builtin_ia32_sqrtps", v4sf_ftype_v4sf
, IX86_BUILTIN_SQRTPS
);
12449 def_builtin (MASK_SSE1
, "__builtin_ia32_sqrtss", v4sf_ftype_v4sf
, IX86_BUILTIN_SQRTSS
);
12451 def_builtin (MASK_SSE1
, "__builtin_ia32_shufps", v4sf_ftype_v4sf_v4sf_int
, IX86_BUILTIN_SHUFPS
);
12453 /* Original 3DNow! */
12454 def_builtin (MASK_3DNOW
, "__builtin_ia32_femms", void_ftype_void
, IX86_BUILTIN_FEMMS
);
12455 def_builtin (MASK_3DNOW
, "__builtin_ia32_pavgusb", v8qi_ftype_v8qi_v8qi
, IX86_BUILTIN_PAVGUSB
);
12456 def_builtin (MASK_3DNOW
, "__builtin_ia32_pf2id", v2si_ftype_v2sf
, IX86_BUILTIN_PF2ID
);
12457 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfacc", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFACC
);
12458 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfadd", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFADD
);
12459 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfcmpeq", v2si_ftype_v2sf_v2sf
, IX86_BUILTIN_PFCMPEQ
);
12460 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfcmpge", v2si_ftype_v2sf_v2sf
, IX86_BUILTIN_PFCMPGE
);
12461 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfcmpgt", v2si_ftype_v2sf_v2sf
, IX86_BUILTIN_PFCMPGT
);
12462 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfmax", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFMAX
);
12463 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfmin", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFMIN
);
12464 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfmul", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFMUL
);
12465 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfrcp", v2sf_ftype_v2sf
, IX86_BUILTIN_PFRCP
);
12466 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfrcpit1", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFRCPIT1
);
12467 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfrcpit2", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFRCPIT2
);
12468 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfrsqrt", v2sf_ftype_v2sf
, IX86_BUILTIN_PFRSQRT
);
12469 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfrsqit1", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFRSQIT1
);
12470 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfsub", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFSUB
);
12471 def_builtin (MASK_3DNOW
, "__builtin_ia32_pfsubr", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFSUBR
);
12472 def_builtin (MASK_3DNOW
, "__builtin_ia32_pi2fd", v2sf_ftype_v2si
, IX86_BUILTIN_PI2FD
);
12473 def_builtin (MASK_3DNOW
, "__builtin_ia32_pmulhrw", v4hi_ftype_v4hi_v4hi
, IX86_BUILTIN_PMULHRW
);
12475 /* 3DNow! extension as used in the Athlon CPU. */
12476 def_builtin (MASK_3DNOW_A
, "__builtin_ia32_pf2iw", v2si_ftype_v2sf
, IX86_BUILTIN_PF2IW
);
12477 def_builtin (MASK_3DNOW_A
, "__builtin_ia32_pfnacc", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFNACC
);
12478 def_builtin (MASK_3DNOW_A
, "__builtin_ia32_pfpnacc", v2sf_ftype_v2sf_v2sf
, IX86_BUILTIN_PFPNACC
);
12479 def_builtin (MASK_3DNOW_A
, "__builtin_ia32_pi2fw", v2sf_ftype_v2si
, IX86_BUILTIN_PI2FW
);
12480 def_builtin (MASK_3DNOW_A
, "__builtin_ia32_pswapdsf", v2sf_ftype_v2sf
, IX86_BUILTIN_PSWAPDSF
);
12481 def_builtin (MASK_3DNOW_A
, "__builtin_ia32_pswapdsi", v2si_ftype_v2si
, IX86_BUILTIN_PSWAPDSI
);
12483 def_builtin (MASK_SSE1
, "__builtin_ia32_setzerops", v4sf_ftype_void
, IX86_BUILTIN_SSE_ZERO
);
12486 def_builtin (MASK_SSE2
, "__builtin_ia32_pextrw128", int_ftype_v8hi_int
, IX86_BUILTIN_PEXTRW128
);
12487 def_builtin (MASK_SSE2
, "__builtin_ia32_pinsrw128", v8hi_ftype_v8hi_int_int
, IX86_BUILTIN_PINSRW128
);
12489 def_builtin (MASK_SSE2
, "__builtin_ia32_maskmovdqu", void_ftype_v16qi_v16qi_pchar
, IX86_BUILTIN_MASKMOVDQU
);
12490 def_builtin (MASK_SSE2
, "__builtin_ia32_movq2dq", v2di_ftype_di
, IX86_BUILTIN_MOVQ2DQ
);
12492 def_builtin (MASK_SSE2
, "__builtin_ia32_loadapd", v2df_ftype_pdouble
, IX86_BUILTIN_LOADAPD
);
12493 def_builtin (MASK_SSE2
, "__builtin_ia32_loadupd", v2df_ftype_pdouble
, IX86_BUILTIN_LOADUPD
);
12494 def_builtin (MASK_SSE2
, "__builtin_ia32_loadsd", v2df_ftype_pdouble
, IX86_BUILTIN_LOADSD
);
12495 def_builtin (MASK_SSE2
, "__builtin_ia32_storeapd", void_ftype_pdouble_v2df
, IX86_BUILTIN_STOREAPD
);
12496 def_builtin (MASK_SSE2
, "__builtin_ia32_storeupd", void_ftype_pdouble_v2df
, IX86_BUILTIN_STOREUPD
);
12497 def_builtin (MASK_SSE2
, "__builtin_ia32_storesd", void_ftype_pdouble_v2df
, IX86_BUILTIN_STORESD
);
12499 def_builtin (MASK_SSE2
, "__builtin_ia32_loadhpd", v2df_ftype_v2df_pv2si
, IX86_BUILTIN_LOADHPD
);
12500 def_builtin (MASK_SSE2
, "__builtin_ia32_loadlpd", v2df_ftype_v2df_pv2si
, IX86_BUILTIN_LOADLPD
);
12501 def_builtin (MASK_SSE2
, "__builtin_ia32_storehpd", void_ftype_pv2si_v2df
, IX86_BUILTIN_STOREHPD
);
12502 def_builtin (MASK_SSE2
, "__builtin_ia32_storelpd", void_ftype_pv2si_v2df
, IX86_BUILTIN_STORELPD
);
12504 def_builtin (MASK_SSE2
, "__builtin_ia32_movmskpd", int_ftype_v2df
, IX86_BUILTIN_MOVMSKPD
);
12505 def_builtin (MASK_SSE2
, "__builtin_ia32_pmovmskb128", int_ftype_v16qi
, IX86_BUILTIN_PMOVMSKB128
);
12506 def_builtin (MASK_SSE2
, "__builtin_ia32_movnti", void_ftype_pint_int
, IX86_BUILTIN_MOVNTI
);
12507 def_builtin (MASK_SSE2
, "__builtin_ia32_movntpd", void_ftype_pdouble_v2df
, IX86_BUILTIN_MOVNTPD
);
12508 def_builtin (MASK_SSE2
, "__builtin_ia32_movntdq", void_ftype_pv2di_v2di
, IX86_BUILTIN_MOVNTDQ
);
12510 def_builtin (MASK_SSE2
, "__builtin_ia32_pshufd", v4si_ftype_v4si_int
, IX86_BUILTIN_PSHUFD
);
12511 def_builtin (MASK_SSE2
, "__builtin_ia32_pshuflw", v8hi_ftype_v8hi_int
, IX86_BUILTIN_PSHUFLW
);
12512 def_builtin (MASK_SSE2
, "__builtin_ia32_pshufhw", v8hi_ftype_v8hi_int
, IX86_BUILTIN_PSHUFHW
);
12513 def_builtin (MASK_SSE2
, "__builtin_ia32_psadbw128", v2di_ftype_v16qi_v16qi
, IX86_BUILTIN_PSADBW128
);
12515 def_builtin (MASK_SSE2
, "__builtin_ia32_sqrtpd", v2df_ftype_v2df
, IX86_BUILTIN_SQRTPD
);
12516 def_builtin (MASK_SSE2
, "__builtin_ia32_sqrtsd", v2df_ftype_v2df
, IX86_BUILTIN_SQRTSD
);
12518 def_builtin (MASK_SSE2
, "__builtin_ia32_shufpd", v2df_ftype_v2df_v2df_int
, IX86_BUILTIN_SHUFPD
);
12520 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtdq2pd", v2df_ftype_v4si
, IX86_BUILTIN_CVTDQ2PD
);
12521 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtdq2ps", v4sf_ftype_v4si
, IX86_BUILTIN_CVTDQ2PS
);
12523 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtpd2dq", v4si_ftype_v2df
, IX86_BUILTIN_CVTPD2DQ
);
12524 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtpd2pi", v2si_ftype_v2df
, IX86_BUILTIN_CVTPD2PI
);
12525 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtpd2ps", v4sf_ftype_v2df
, IX86_BUILTIN_CVTPD2PS
);
12526 def_builtin (MASK_SSE2
, "__builtin_ia32_cvttpd2dq", v4si_ftype_v2df
, IX86_BUILTIN_CVTTPD2DQ
);
12527 def_builtin (MASK_SSE2
, "__builtin_ia32_cvttpd2pi", v2si_ftype_v2df
, IX86_BUILTIN_CVTTPD2PI
);
12529 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtpi2pd", v2df_ftype_v2si
, IX86_BUILTIN_CVTPI2PD
);
12531 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtsd2si", int_ftype_v2df
, IX86_BUILTIN_CVTSD2SI
);
12532 def_builtin (MASK_SSE2
, "__builtin_ia32_cvttsd2si", int_ftype_v2df
, IX86_BUILTIN_CVTTSD2SI
);
12534 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtps2dq", v4si_ftype_v4sf
, IX86_BUILTIN_CVTPS2DQ
);
12535 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtps2pd", v2df_ftype_v4sf
, IX86_BUILTIN_CVTPS2PD
);
12536 def_builtin (MASK_SSE2
, "__builtin_ia32_cvttps2dq", v4si_ftype_v4sf
, IX86_BUILTIN_CVTTPS2DQ
);
12538 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtsi2sd", v2df_ftype_v2df_int
, IX86_BUILTIN_CVTSI2SD
);
12539 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtsd2ss", v4sf_ftype_v4sf_v2df
, IX86_BUILTIN_CVTSD2SS
);
12540 def_builtin (MASK_SSE2
, "__builtin_ia32_cvtss2sd", v2df_ftype_v2df_v4sf
, IX86_BUILTIN_CVTSS2SD
);
12542 def_builtin (MASK_SSE2
, "__builtin_ia32_setpd1", v2df_ftype_double
, IX86_BUILTIN_SETPD1
);
12543 def_builtin (MASK_SSE2
, "__builtin_ia32_setpd", v2df_ftype_double_double
, IX86_BUILTIN_SETPD
);
12544 def_builtin (MASK_SSE2
, "__builtin_ia32_setzeropd", ti_ftype_void
, IX86_BUILTIN_CLRPD
);
12545 def_builtin (MASK_SSE2
, "__builtin_ia32_loadpd1", v2df_ftype_pdouble
, IX86_BUILTIN_LOADPD1
);
12546 def_builtin (MASK_SSE2
, "__builtin_ia32_loadrpd", v2df_ftype_pdouble
, IX86_BUILTIN_LOADRPD
);
12547 def_builtin (MASK_SSE2
, "__builtin_ia32_storepd1", void_ftype_pdouble_v2df
, IX86_BUILTIN_STOREPD1
);
12548 def_builtin (MASK_SSE2
, "__builtin_ia32_storerpd", void_ftype_pdouble_v2df
, IX86_BUILTIN_STORERPD
);
12550 def_builtin (MASK_SSE2
, "__builtin_ia32_clflush", void_ftype_pvoid
, IX86_BUILTIN_CLFLUSH
);
12551 def_builtin (MASK_SSE2
, "__builtin_ia32_lfence", void_ftype_void
, IX86_BUILTIN_LFENCE
);
12552 def_builtin (MASK_SSE2
, "__builtin_ia32_mfence", void_ftype_void
, IX86_BUILTIN_MFENCE
);
12554 def_builtin (MASK_SSE2
, "__builtin_ia32_psllw128", v8hi_ftype_v8hi_v2di
, IX86_BUILTIN_PSLLW128
);
12555 def_builtin (MASK_SSE2
, "__builtin_ia32_pslld128", v4si_ftype_v4si_v2di
, IX86_BUILTIN_PSLLD128
);
12556 def_builtin (MASK_SSE2
, "__builtin_ia32_psllq128", v2di_ftype_v2di_v2di
, IX86_BUILTIN_PSLLQ128
);
12558 def_builtin (MASK_SSE2
, "__builtin_ia32_psrlw128", v8hi_ftype_v8hi_v2di
, IX86_BUILTIN_PSRLW128
);
12559 def_builtin (MASK_SSE2
, "__builtin_ia32_psrld128", v4si_ftype_v4si_v2di
, IX86_BUILTIN_PSRLD128
);
12560 def_builtin (MASK_SSE2
, "__builtin_ia32_psrlq128", v2di_ftype_v2di_v2di
, IX86_BUILTIN_PSRLQ128
);
12562 def_builtin (MASK_SSE2
, "__builtin_ia32_psraw128", v8hi_ftype_v8hi_v2di
, IX86_BUILTIN_PSRAW128
);
12563 def_builtin (MASK_SSE2
, "__builtin_ia32_psrad128", v4si_ftype_v4si_v2di
, IX86_BUILTIN_PSRAD128
);
12565 def_builtin (MASK_SSE2
, "__builtin_ia32_psllwi128", v8hi_ftype_v8hi_int
, IX86_BUILTIN_PSLLWI128
);
12566 def_builtin (MASK_SSE2
, "__builtin_ia32_pslldi128", v4si_ftype_v4si_int
, IX86_BUILTIN_PSLLDI128
);
12567 def_builtin (MASK_SSE2
, "__builtin_ia32_psllqi128", v2di_ftype_v2di_int
, IX86_BUILTIN_PSLLQI128
);
12569 def_builtin (MASK_SSE2
, "__builtin_ia32_psrlwi128", v8hi_ftype_v8hi_int
, IX86_BUILTIN_PSRLWI128
);
12570 def_builtin (MASK_SSE2
, "__builtin_ia32_psrldi128", v4si_ftype_v4si_int
, IX86_BUILTIN_PSRLDI128
);
12571 def_builtin (MASK_SSE2
, "__builtin_ia32_psrlqi128", v2di_ftype_v2di_int
, IX86_BUILTIN_PSRLQI128
);
12573 def_builtin (MASK_SSE2
, "__builtin_ia32_psrawi128", v8hi_ftype_v8hi_int
, IX86_BUILTIN_PSRAWI128
);
12574 def_builtin (MASK_SSE2
, "__builtin_ia32_psradi128", v4si_ftype_v4si_int
, IX86_BUILTIN_PSRADI128
);
12576 def_builtin (MASK_SSE2
, "__builtin_ia32_pmaddwd128", v4si_ftype_v8hi_v8hi
, IX86_BUILTIN_PMADDWD128
);
12579 /* Errors in the source file can cause expand_expr to return const0_rtx
12580 where we expect a vector. To avoid crashing, use one of the vector
12581 clear instructions. */
12583 safe_vector_operand (x
, mode
)
12585 enum machine_mode mode
;
12587 if (x
!= const0_rtx
)
12589 x
= gen_reg_rtx (mode
);
12591 if (VALID_MMX_REG_MODE (mode
) || VALID_MMX_REG_MODE_3DNOW (mode
))
12592 emit_insn (gen_mmx_clrdi (mode
== DImode
? x
12593 : gen_rtx_SUBREG (DImode
, x
, 0)));
12595 emit_insn (gen_sse_clrv4sf (mode
== V4SFmode
? x
12596 : gen_rtx_SUBREG (V4SFmode
, x
, 0)));
12600 /* Subroutine of ix86_expand_builtin to take care of binop insns. */
12603 ix86_expand_binop_builtin (icode
, arglist
, target
)
12604 enum insn_code icode
;
12609 tree arg0
= TREE_VALUE (arglist
);
12610 tree arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
12611 rtx op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
12612 rtx op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
12613 enum machine_mode tmode
= insn_data
[icode
].operand
[0].mode
;
12614 enum machine_mode mode0
= insn_data
[icode
].operand
[1].mode
;
12615 enum machine_mode mode1
= insn_data
[icode
].operand
[2].mode
;
12617 if (VECTOR_MODE_P (mode0
))
12618 op0
= safe_vector_operand (op0
, mode0
);
12619 if (VECTOR_MODE_P (mode1
))
12620 op1
= safe_vector_operand (op1
, mode1
);
12623 || GET_MODE (target
) != tmode
12624 || ! (*insn_data
[icode
].operand
[0].predicate
) (target
, tmode
))
12625 target
= gen_reg_rtx (tmode
);
12627 /* In case the insn wants input operands in modes different from
12628 the result, abort. */
12629 if (GET_MODE (op0
) != mode0
|| GET_MODE (op1
) != mode1
)
12632 if (! (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode0
))
12633 op0
= copy_to_mode_reg (mode0
, op0
);
12634 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode1
))
12635 op1
= copy_to_mode_reg (mode1
, op1
);
12637 /* In the commutative cases, both op0 and op1 are nonimmediate_operand,
12638 yet one of the two must not be a memory. This is normally enforced
12639 by expanders, but we didn't bother to create one here. */
12640 if (GET_CODE (op0
) == MEM
&& GET_CODE (op1
) == MEM
)
12641 op0
= copy_to_mode_reg (mode0
, op0
);
12643 pat
= GEN_FCN (icode
) (target
, op0
, op1
);
12650 /* In type_for_mode we restrict the ability to create TImode types
12651 to hosts with 64-bit H_W_I. So we've defined the SSE logicals
12652 to have a V4SFmode signature. Convert them in-place to TImode. */
12655 ix86_expand_timode_binop_builtin (icode
, arglist
, target
)
12656 enum insn_code icode
;
12661 tree arg0
= TREE_VALUE (arglist
);
12662 tree arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
12663 rtx op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
12664 rtx op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
12666 op0
= gen_lowpart (TImode
, op0
);
12667 op1
= gen_lowpart (TImode
, op1
);
12668 target
= gen_reg_rtx (TImode
);
12670 if (! (*insn_data
[icode
].operand
[1].predicate
) (op0
, TImode
))
12671 op0
= copy_to_mode_reg (TImode
, op0
);
12672 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, TImode
))
12673 op1
= copy_to_mode_reg (TImode
, op1
);
12675 /* In the commutative cases, both op0 and op1 are nonimmediate_operand,
12676 yet one of the two must not be a memory. This is normally enforced
12677 by expanders, but we didn't bother to create one here. */
12678 if (GET_CODE (op0
) == MEM
&& GET_CODE (op1
) == MEM
)
12679 op0
= copy_to_mode_reg (TImode
, op0
);
12681 pat
= GEN_FCN (icode
) (target
, op0
, op1
);
12686 return gen_lowpart (V4SFmode
, target
);
12689 /* Subroutine of ix86_expand_builtin to take care of stores. */
12692 ix86_expand_store_builtin (icode
, arglist
)
12693 enum insn_code icode
;
12697 tree arg0
= TREE_VALUE (arglist
);
12698 tree arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
12699 rtx op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
12700 rtx op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
12701 enum machine_mode mode0
= insn_data
[icode
].operand
[0].mode
;
12702 enum machine_mode mode1
= insn_data
[icode
].operand
[1].mode
;
12704 if (VECTOR_MODE_P (mode1
))
12705 op1
= safe_vector_operand (op1
, mode1
);
12707 op0
= gen_rtx_MEM (mode0
, copy_to_mode_reg (Pmode
, op0
));
12709 if (! (*insn_data
[icode
].operand
[1].predicate
) (op1
, mode1
))
12710 op1
= copy_to_mode_reg (mode1
, op1
);
12712 pat
= GEN_FCN (icode
) (op0
, op1
);
12718 /* Subroutine of ix86_expand_builtin to take care of unop insns. */
12721 ix86_expand_unop_builtin (icode
, arglist
, target
, do_load
)
12722 enum insn_code icode
;
12728 tree arg0
= TREE_VALUE (arglist
);
12729 rtx op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
12730 enum machine_mode tmode
= insn_data
[icode
].operand
[0].mode
;
12731 enum machine_mode mode0
= insn_data
[icode
].operand
[1].mode
;
12734 || GET_MODE (target
) != tmode
12735 || ! (*insn_data
[icode
].operand
[0].predicate
) (target
, tmode
))
12736 target
= gen_reg_rtx (tmode
);
12738 op0
= gen_rtx_MEM (mode0
, copy_to_mode_reg (Pmode
, op0
));
12741 if (VECTOR_MODE_P (mode0
))
12742 op0
= safe_vector_operand (op0
, mode0
);
12744 if (! (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode0
))
12745 op0
= copy_to_mode_reg (mode0
, op0
);
12748 pat
= GEN_FCN (icode
) (target
, op0
);
12755 /* Subroutine of ix86_expand_builtin to take care of three special unop insns:
12756 sqrtss, rsqrtss, rcpss. */
12759 ix86_expand_unop1_builtin (icode
, arglist
, target
)
12760 enum insn_code icode
;
12765 tree arg0
= TREE_VALUE (arglist
);
12766 rtx op1
, op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
12767 enum machine_mode tmode
= insn_data
[icode
].operand
[0].mode
;
12768 enum machine_mode mode0
= insn_data
[icode
].operand
[1].mode
;
12771 || GET_MODE (target
) != tmode
12772 || ! (*insn_data
[icode
].operand
[0].predicate
) (target
, tmode
))
12773 target
= gen_reg_rtx (tmode
);
12775 if (VECTOR_MODE_P (mode0
))
12776 op0
= safe_vector_operand (op0
, mode0
);
12778 if (! (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode0
))
12779 op0
= copy_to_mode_reg (mode0
, op0
);
12782 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode0
))
12783 op1
= copy_to_mode_reg (mode0
, op1
);
12785 pat
= GEN_FCN (icode
) (target
, op0
, op1
);
12792 /* Subroutine of ix86_expand_builtin to take care of comparison insns. */
12795 ix86_expand_sse_compare (d
, arglist
, target
)
12796 const struct builtin_description
*d
;
12801 tree arg0
= TREE_VALUE (arglist
);
12802 tree arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
12803 rtx op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
12804 rtx op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
12806 enum machine_mode tmode
= insn_data
[d
->icode
].operand
[0].mode
;
12807 enum machine_mode mode0
= insn_data
[d
->icode
].operand
[1].mode
;
12808 enum machine_mode mode1
= insn_data
[d
->icode
].operand
[2].mode
;
12809 enum rtx_code comparison
= d
->comparison
;
12811 if (VECTOR_MODE_P (mode0
))
12812 op0
= safe_vector_operand (op0
, mode0
);
12813 if (VECTOR_MODE_P (mode1
))
12814 op1
= safe_vector_operand (op1
, mode1
);
12816 /* Swap operands if we have a comparison that isn't available in
12820 rtx tmp
= gen_reg_rtx (mode1
);
12821 emit_move_insn (tmp
, op1
);
12827 || GET_MODE (target
) != tmode
12828 || ! (*insn_data
[d
->icode
].operand
[0].predicate
) (target
, tmode
))
12829 target
= gen_reg_rtx (tmode
);
12831 if (! (*insn_data
[d
->icode
].operand
[1].predicate
) (op0
, mode0
))
12832 op0
= copy_to_mode_reg (mode0
, op0
);
12833 if (! (*insn_data
[d
->icode
].operand
[2].predicate
) (op1
, mode1
))
12834 op1
= copy_to_mode_reg (mode1
, op1
);
12836 op2
= gen_rtx_fmt_ee (comparison
, mode0
, op0
, op1
);
12837 pat
= GEN_FCN (d
->icode
) (target
, op0
, op1
, op2
);
12844 /* Subroutine of ix86_expand_builtin to take care of comi insns. */
12847 ix86_expand_sse_comi (d
, arglist
, target
)
12848 const struct builtin_description
*d
;
12853 tree arg0
= TREE_VALUE (arglist
);
12854 tree arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
12855 rtx op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
12856 rtx op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
12858 enum machine_mode mode0
= insn_data
[d
->icode
].operand
[0].mode
;
12859 enum machine_mode mode1
= insn_data
[d
->icode
].operand
[1].mode
;
12860 enum rtx_code comparison
= d
->comparison
;
12862 if (VECTOR_MODE_P (mode0
))
12863 op0
= safe_vector_operand (op0
, mode0
);
12864 if (VECTOR_MODE_P (mode1
))
12865 op1
= safe_vector_operand (op1
, mode1
);
12867 /* Swap operands if we have a comparison that isn't available in
12876 target
= gen_reg_rtx (SImode
);
12877 emit_move_insn (target
, const0_rtx
);
12878 target
= gen_rtx_SUBREG (QImode
, target
, 0);
12880 if (! (*insn_data
[d
->icode
].operand
[0].predicate
) (op0
, mode0
))
12881 op0
= copy_to_mode_reg (mode0
, op0
);
12882 if (! (*insn_data
[d
->icode
].operand
[1].predicate
) (op1
, mode1
))
12883 op1
= copy_to_mode_reg (mode1
, op1
);
12885 op2
= gen_rtx_fmt_ee (comparison
, mode0
, op0
, op1
);
12886 pat
= GEN_FCN (d
->icode
) (op0
, op1
, op2
);
12890 emit_insn (gen_rtx_SET (VOIDmode
,
12891 gen_rtx_STRICT_LOW_PART (VOIDmode
, target
),
12892 gen_rtx_fmt_ee (comparison
, QImode
,
12893 gen_rtx_REG (CCmode
, FLAGS_REG
),
12896 return SUBREG_REG (target
);
12899 /* Expand an expression EXP that calls a built-in function,
12900 with result going to TARGET if that's convenient
12901 (and in mode MODE if that's convenient).
12902 SUBTARGET may be used as the target for computing one of EXP's operands.
12903 IGNORE is nonzero if the value is to be ignored. */
12906 ix86_expand_builtin (exp
, target
, subtarget
, mode
, ignore
)
12909 rtx subtarget ATTRIBUTE_UNUSED
;
12910 enum machine_mode mode ATTRIBUTE_UNUSED
;
12911 int ignore ATTRIBUTE_UNUSED
;
12913 const struct builtin_description
*d
;
12915 enum insn_code icode
;
12916 tree fndecl
= TREE_OPERAND (TREE_OPERAND (exp
, 0), 0);
12917 tree arglist
= TREE_OPERAND (exp
, 1);
12918 tree arg0
, arg1
, arg2
;
12919 rtx op0
, op1
, op2
, pat
;
12920 enum machine_mode tmode
, mode0
, mode1
, mode2
;
12921 unsigned int fcode
= DECL_FUNCTION_CODE (fndecl
);
12925 case IX86_BUILTIN_EMMS
:
12926 emit_insn (gen_emms ());
12929 case IX86_BUILTIN_SFENCE
:
12930 emit_insn (gen_sfence ());
12933 case IX86_BUILTIN_PEXTRW
:
12934 case IX86_BUILTIN_PEXTRW128
:
12935 icode
= (fcode
== IX86_BUILTIN_PEXTRW
12936 ? CODE_FOR_mmx_pextrw
12937 : CODE_FOR_sse2_pextrw
);
12938 arg0
= TREE_VALUE (arglist
);
12939 arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
12940 op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
12941 op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
12942 tmode
= insn_data
[icode
].operand
[0].mode
;
12943 mode0
= insn_data
[icode
].operand
[1].mode
;
12944 mode1
= insn_data
[icode
].operand
[2].mode
;
12946 if (! (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode0
))
12947 op0
= copy_to_mode_reg (mode0
, op0
);
12948 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode1
))
12950 /* @@@ better error message */
12951 error ("selector must be an immediate");
12952 return gen_reg_rtx (tmode
);
12955 || GET_MODE (target
) != tmode
12956 || ! (*insn_data
[icode
].operand
[0].predicate
) (target
, tmode
))
12957 target
= gen_reg_rtx (tmode
);
12958 pat
= GEN_FCN (icode
) (target
, op0
, op1
);
12964 case IX86_BUILTIN_PINSRW
:
12965 case IX86_BUILTIN_PINSRW128
:
12966 icode
= (fcode
== IX86_BUILTIN_PINSRW
12967 ? CODE_FOR_mmx_pinsrw
12968 : CODE_FOR_sse2_pinsrw
);
12969 arg0
= TREE_VALUE (arglist
);
12970 arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
12971 arg2
= TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist
)));
12972 op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
12973 op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
12974 op2
= expand_expr (arg2
, NULL_RTX
, VOIDmode
, 0);
12975 tmode
= insn_data
[icode
].operand
[0].mode
;
12976 mode0
= insn_data
[icode
].operand
[1].mode
;
12977 mode1
= insn_data
[icode
].operand
[2].mode
;
12978 mode2
= insn_data
[icode
].operand
[3].mode
;
12980 if (! (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode0
))
12981 op0
= copy_to_mode_reg (mode0
, op0
);
12982 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode1
))
12983 op1
= copy_to_mode_reg (mode1
, op1
);
12984 if (! (*insn_data
[icode
].operand
[3].predicate
) (op2
, mode2
))
12986 /* @@@ better error message */
12987 error ("selector must be an immediate");
12991 || GET_MODE (target
) != tmode
12992 || ! (*insn_data
[icode
].operand
[0].predicate
) (target
, tmode
))
12993 target
= gen_reg_rtx (tmode
);
12994 pat
= GEN_FCN (icode
) (target
, op0
, op1
, op2
);
13000 case IX86_BUILTIN_MASKMOVQ
:
13001 icode
= (fcode
== IX86_BUILTIN_MASKMOVQ
13002 ? (TARGET_64BIT
? CODE_FOR_mmx_maskmovq_rex
: CODE_FOR_mmx_maskmovq
)
13003 : CODE_FOR_sse2_maskmovdqu
);
13004 /* Note the arg order is different from the operand order. */
13005 arg1
= TREE_VALUE (arglist
);
13006 arg2
= TREE_VALUE (TREE_CHAIN (arglist
));
13007 arg0
= TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist
)));
13008 op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
13009 op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
13010 op2
= expand_expr (arg2
, NULL_RTX
, VOIDmode
, 0);
13011 mode0
= insn_data
[icode
].operand
[0].mode
;
13012 mode1
= insn_data
[icode
].operand
[1].mode
;
13013 mode2
= insn_data
[icode
].operand
[2].mode
;
13015 if (! (*insn_data
[icode
].operand
[0].predicate
) (op0
, mode0
))
13016 op0
= copy_to_mode_reg (mode0
, op0
);
13017 if (! (*insn_data
[icode
].operand
[1].predicate
) (op1
, mode1
))
13018 op1
= copy_to_mode_reg (mode1
, op1
);
13019 if (! (*insn_data
[icode
].operand
[2].predicate
) (op2
, mode2
))
13020 op2
= copy_to_mode_reg (mode2
, op2
);
13021 pat
= GEN_FCN (icode
) (op0
, op1
, op2
);
13027 case IX86_BUILTIN_SQRTSS
:
13028 return ix86_expand_unop1_builtin (CODE_FOR_vmsqrtv4sf2
, arglist
, target
);
13029 case IX86_BUILTIN_RSQRTSS
:
13030 return ix86_expand_unop1_builtin (CODE_FOR_vmrsqrtv4sf2
, arglist
, target
);
13031 case IX86_BUILTIN_RCPSS
:
13032 return ix86_expand_unop1_builtin (CODE_FOR_vmrcpv4sf2
, arglist
, target
);
13034 case IX86_BUILTIN_ANDPS
:
13035 return ix86_expand_timode_binop_builtin (CODE_FOR_sse_andti3
,
13037 case IX86_BUILTIN_ANDNPS
:
13038 return ix86_expand_timode_binop_builtin (CODE_FOR_sse_nandti3
,
13040 case IX86_BUILTIN_ORPS
:
13041 return ix86_expand_timode_binop_builtin (CODE_FOR_sse_iorti3
,
13043 case IX86_BUILTIN_XORPS
:
13044 return ix86_expand_timode_binop_builtin (CODE_FOR_sse_xorti3
,
13047 case IX86_BUILTIN_LOADAPS
:
13048 return ix86_expand_unop_builtin (CODE_FOR_sse_movaps
, arglist
, target
, 1);
13050 case IX86_BUILTIN_LOADUPS
:
13051 return ix86_expand_unop_builtin (CODE_FOR_sse_movups
, arglist
, target
, 1);
13053 case IX86_BUILTIN_STOREAPS
:
13054 return ix86_expand_store_builtin (CODE_FOR_sse_movaps
, arglist
);
13055 case IX86_BUILTIN_STOREUPS
:
13056 return ix86_expand_store_builtin (CODE_FOR_sse_movups
, arglist
);
13058 case IX86_BUILTIN_LOADSS
:
13059 return ix86_expand_unop_builtin (CODE_FOR_sse_loadss
, arglist
, target
, 1);
13061 case IX86_BUILTIN_STORESS
:
13062 return ix86_expand_store_builtin (CODE_FOR_sse_storess
, arglist
);
13064 case IX86_BUILTIN_LOADHPS
:
13065 case IX86_BUILTIN_LOADLPS
:
13066 case IX86_BUILTIN_LOADHPD
:
13067 case IX86_BUILTIN_LOADLPD
:
13068 icode
= (fcode
== IX86_BUILTIN_LOADHPS
? CODE_FOR_sse_movhps
13069 : fcode
== IX86_BUILTIN_LOADLPS
? CODE_FOR_sse_movlps
13070 : fcode
== IX86_BUILTIN_LOADHPD
? CODE_FOR_sse2_movhpd
13071 : CODE_FOR_sse2_movlpd
);
13072 arg0
= TREE_VALUE (arglist
);
13073 arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
13074 op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
13075 op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
13076 tmode
= insn_data
[icode
].operand
[0].mode
;
13077 mode0
= insn_data
[icode
].operand
[1].mode
;
13078 mode1
= insn_data
[icode
].operand
[2].mode
;
13080 if (! (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode0
))
13081 op0
= copy_to_mode_reg (mode0
, op0
);
13082 op1
= gen_rtx_MEM (mode1
, copy_to_mode_reg (Pmode
, op1
));
13084 || GET_MODE (target
) != tmode
13085 || ! (*insn_data
[icode
].operand
[0].predicate
) (target
, tmode
))
13086 target
= gen_reg_rtx (tmode
);
13087 pat
= GEN_FCN (icode
) (target
, op0
, op1
);
13093 case IX86_BUILTIN_STOREHPS
:
13094 case IX86_BUILTIN_STORELPS
:
13095 case IX86_BUILTIN_STOREHPD
:
13096 case IX86_BUILTIN_STORELPD
:
13097 icode
= (fcode
== IX86_BUILTIN_STOREHPS
? CODE_FOR_sse_movhps
13098 : fcode
== IX86_BUILTIN_STORELPS
? CODE_FOR_sse_movlps
13099 : fcode
== IX86_BUILTIN_STOREHPD
? CODE_FOR_sse2_movhpd
13100 : CODE_FOR_sse2_movlpd
);
13101 arg0
= TREE_VALUE (arglist
);
13102 arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
13103 op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
13104 op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
13105 mode0
= insn_data
[icode
].operand
[1].mode
;
13106 mode1
= insn_data
[icode
].operand
[2].mode
;
13108 op0
= gen_rtx_MEM (mode0
, copy_to_mode_reg (Pmode
, op0
));
13109 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode1
))
13110 op1
= copy_to_mode_reg (mode1
, op1
);
13112 pat
= GEN_FCN (icode
) (op0
, op0
, op1
);
13118 case IX86_BUILTIN_MOVNTPS
:
13119 return ix86_expand_store_builtin (CODE_FOR_sse_movntv4sf
, arglist
);
13120 case IX86_BUILTIN_MOVNTQ
:
13121 return ix86_expand_store_builtin (CODE_FOR_sse_movntdi
, arglist
);
13123 case IX86_BUILTIN_LDMXCSR
:
13124 op0
= expand_expr (TREE_VALUE (arglist
), NULL_RTX
, VOIDmode
, 0);
13125 target
= assign_386_stack_local (SImode
, 0);
13126 emit_move_insn (target
, op0
);
13127 emit_insn (gen_ldmxcsr (target
));
13130 case IX86_BUILTIN_STMXCSR
:
13131 target
= assign_386_stack_local (SImode
, 0);
13132 emit_insn (gen_stmxcsr (target
));
13133 return copy_to_mode_reg (SImode
, target
);
13135 case IX86_BUILTIN_SHUFPS
:
13136 case IX86_BUILTIN_SHUFPD
:
13137 icode
= (fcode
== IX86_BUILTIN_SHUFPS
13138 ? CODE_FOR_sse_shufps
13139 : CODE_FOR_sse2_shufpd
);
13140 arg0
= TREE_VALUE (arglist
);
13141 arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
13142 arg2
= TREE_VALUE (TREE_CHAIN (TREE_CHAIN (arglist
)));
13143 op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
13144 op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
13145 op2
= expand_expr (arg2
, NULL_RTX
, VOIDmode
, 0);
13146 tmode
= insn_data
[icode
].operand
[0].mode
;
13147 mode0
= insn_data
[icode
].operand
[1].mode
;
13148 mode1
= insn_data
[icode
].operand
[2].mode
;
13149 mode2
= insn_data
[icode
].operand
[3].mode
;
13151 if (! (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode0
))
13152 op0
= copy_to_mode_reg (mode0
, op0
);
13153 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode1
))
13154 op1
= copy_to_mode_reg (mode1
, op1
);
13155 if (! (*insn_data
[icode
].operand
[3].predicate
) (op2
, mode2
))
13157 /* @@@ better error message */
13158 error ("mask must be an immediate");
13159 return gen_reg_rtx (tmode
);
13162 || GET_MODE (target
) != tmode
13163 || ! (*insn_data
[icode
].operand
[0].predicate
) (target
, tmode
))
13164 target
= gen_reg_rtx (tmode
);
13165 pat
= GEN_FCN (icode
) (target
, op0
, op1
, op2
);
13171 case IX86_BUILTIN_PSHUFW
:
13172 case IX86_BUILTIN_PSHUFD
:
13173 case IX86_BUILTIN_PSHUFHW
:
13174 case IX86_BUILTIN_PSHUFLW
:
13175 icode
= ( fcode
== IX86_BUILTIN_PSHUFHW
? CODE_FOR_sse2_pshufhw
13176 : fcode
== IX86_BUILTIN_PSHUFLW
? CODE_FOR_sse2_pshuflw
13177 : fcode
== IX86_BUILTIN_PSHUFD
? CODE_FOR_sse2_pshufd
13178 : CODE_FOR_mmx_pshufw
);
13179 arg0
= TREE_VALUE (arglist
);
13180 arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
13181 op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
13182 op1
= expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0);
13183 tmode
= insn_data
[icode
].operand
[0].mode
;
13184 mode1
= insn_data
[icode
].operand
[1].mode
;
13185 mode2
= insn_data
[icode
].operand
[2].mode
;
13187 if (! (*insn_data
[icode
].operand
[1].predicate
) (op0
, mode1
))
13188 op0
= copy_to_mode_reg (mode1
, op0
);
13189 if (! (*insn_data
[icode
].operand
[2].predicate
) (op1
, mode2
))
13191 /* @@@ better error message */
13192 error ("mask must be an immediate");
13196 || GET_MODE (target
) != tmode
13197 || ! (*insn_data
[icode
].operand
[0].predicate
) (target
, tmode
))
13198 target
= gen_reg_rtx (tmode
);
13199 pat
= GEN_FCN (icode
) (target
, op0
, op1
);
13205 case IX86_BUILTIN_FEMMS
:
13206 emit_insn (gen_femms ());
13209 case IX86_BUILTIN_PAVGUSB
:
13210 return ix86_expand_binop_builtin (CODE_FOR_pavgusb
, arglist
, target
);
13212 case IX86_BUILTIN_PF2ID
:
13213 return ix86_expand_unop_builtin (CODE_FOR_pf2id
, arglist
, target
, 0);
13215 case IX86_BUILTIN_PFACC
:
13216 return ix86_expand_binop_builtin (CODE_FOR_pfacc
, arglist
, target
);
13218 case IX86_BUILTIN_PFADD
:
13219 return ix86_expand_binop_builtin (CODE_FOR_addv2sf3
, arglist
, target
);
13221 case IX86_BUILTIN_PFCMPEQ
:
13222 return ix86_expand_binop_builtin (CODE_FOR_eqv2sf3
, arglist
, target
);
13224 case IX86_BUILTIN_PFCMPGE
:
13225 return ix86_expand_binop_builtin (CODE_FOR_gev2sf3
, arglist
, target
);
13227 case IX86_BUILTIN_PFCMPGT
:
13228 return ix86_expand_binop_builtin (CODE_FOR_gtv2sf3
, arglist
, target
);
13230 case IX86_BUILTIN_PFMAX
:
13231 return ix86_expand_binop_builtin (CODE_FOR_pfmaxv2sf3
, arglist
, target
);
13233 case IX86_BUILTIN_PFMIN
:
13234 return ix86_expand_binop_builtin (CODE_FOR_pfminv2sf3
, arglist
, target
);
13236 case IX86_BUILTIN_PFMUL
:
13237 return ix86_expand_binop_builtin (CODE_FOR_mulv2sf3
, arglist
, target
);
13239 case IX86_BUILTIN_PFRCP
:
13240 return ix86_expand_unop_builtin (CODE_FOR_pfrcpv2sf2
, arglist
, target
, 0);
13242 case IX86_BUILTIN_PFRCPIT1
:
13243 return ix86_expand_binop_builtin (CODE_FOR_pfrcpit1v2sf3
, arglist
, target
);
13245 case IX86_BUILTIN_PFRCPIT2
:
13246 return ix86_expand_binop_builtin (CODE_FOR_pfrcpit2v2sf3
, arglist
, target
);
13248 case IX86_BUILTIN_PFRSQIT1
:
13249 return ix86_expand_binop_builtin (CODE_FOR_pfrsqit1v2sf3
, arglist
, target
);
13251 case IX86_BUILTIN_PFRSQRT
:
13252 return ix86_expand_unop_builtin (CODE_FOR_pfrsqrtv2sf2
, arglist
, target
, 0);
13254 case IX86_BUILTIN_PFSUB
:
13255 return ix86_expand_binop_builtin (CODE_FOR_subv2sf3
, arglist
, target
);
13257 case IX86_BUILTIN_PFSUBR
:
13258 return ix86_expand_binop_builtin (CODE_FOR_subrv2sf3
, arglist
, target
);
13260 case IX86_BUILTIN_PI2FD
:
13261 return ix86_expand_unop_builtin (CODE_FOR_floatv2si2
, arglist
, target
, 0);
13263 case IX86_BUILTIN_PMULHRW
:
13264 return ix86_expand_binop_builtin (CODE_FOR_pmulhrwv4hi3
, arglist
, target
);
13266 case IX86_BUILTIN_PF2IW
:
13267 return ix86_expand_unop_builtin (CODE_FOR_pf2iw
, arglist
, target
, 0);
13269 case IX86_BUILTIN_PFNACC
:
13270 return ix86_expand_binop_builtin (CODE_FOR_pfnacc
, arglist
, target
);
13272 case IX86_BUILTIN_PFPNACC
:
13273 return ix86_expand_binop_builtin (CODE_FOR_pfpnacc
, arglist
, target
);
13275 case IX86_BUILTIN_PI2FW
:
13276 return ix86_expand_unop_builtin (CODE_FOR_pi2fw
, arglist
, target
, 0);
13278 case IX86_BUILTIN_PSWAPDSI
:
13279 return ix86_expand_unop_builtin (CODE_FOR_pswapdv2si2
, arglist
, target
, 0);
13281 case IX86_BUILTIN_PSWAPDSF
:
13282 return ix86_expand_unop_builtin (CODE_FOR_pswapdv2sf2
, arglist
, target
, 0);
13284 case IX86_BUILTIN_SSE_ZERO
:
13285 target
= gen_reg_rtx (V4SFmode
);
13286 emit_insn (gen_sse_clrv4sf (target
));
13289 case IX86_BUILTIN_MMX_ZERO
:
13290 target
= gen_reg_rtx (DImode
);
13291 emit_insn (gen_mmx_clrdi (target
));
13294 case IX86_BUILTIN_SQRTSD
:
13295 return ix86_expand_unop1_builtin (CODE_FOR_vmsqrtv2df2
, arglist
, target
);
13296 case IX86_BUILTIN_LOADAPD
:
13297 return ix86_expand_unop_builtin (CODE_FOR_sse2_movapd
, arglist
, target
, 1);
13298 case IX86_BUILTIN_LOADUPD
:
13299 return ix86_expand_unop_builtin (CODE_FOR_sse2_movupd
, arglist
, target
, 1);
13301 case IX86_BUILTIN_STOREAPD
:
13302 return ix86_expand_store_builtin (CODE_FOR_sse2_movapd
, arglist
);
13303 case IX86_BUILTIN_STOREUPD
:
13304 return ix86_expand_store_builtin (CODE_FOR_sse2_movupd
, arglist
);
13306 case IX86_BUILTIN_LOADSD
:
13307 return ix86_expand_unop_builtin (CODE_FOR_sse2_loadsd
, arglist
, target
, 1);
13309 case IX86_BUILTIN_STORESD
:
13310 return ix86_expand_store_builtin (CODE_FOR_sse2_storesd
, arglist
);
13312 case IX86_BUILTIN_SETPD1
:
13313 target
= assign_386_stack_local (DFmode
, 0);
13314 arg0
= TREE_VALUE (arglist
);
13315 emit_move_insn (adjust_address (target
, DFmode
, 0),
13316 expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0));
13317 op0
= gen_reg_rtx (V2DFmode
);
13318 emit_insn (gen_sse2_loadsd (op0
, adjust_address (target
, V2DFmode
, 0)));
13319 emit_insn (gen_sse2_shufpd (op0
, op0
, op0
, GEN_INT (0)));
13322 case IX86_BUILTIN_SETPD
:
13323 target
= assign_386_stack_local (V2DFmode
, 0);
13324 arg0
= TREE_VALUE (arglist
);
13325 arg1
= TREE_VALUE (TREE_CHAIN (arglist
));
13326 emit_move_insn (adjust_address (target
, DFmode
, 0),
13327 expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0));
13328 emit_move_insn (adjust_address (target
, DFmode
, 8),
13329 expand_expr (arg1
, NULL_RTX
, VOIDmode
, 0));
13330 op0
= gen_reg_rtx (V2DFmode
);
13331 emit_insn (gen_sse2_movapd (op0
, target
));
13334 case IX86_BUILTIN_LOADRPD
:
13335 target
= ix86_expand_unop_builtin (CODE_FOR_sse2_movapd
, arglist
,
13336 gen_reg_rtx (V2DFmode
), 1);
13337 emit_insn (gen_sse2_shufpd (target
, target
, target
, GEN_INT (1)));
13340 case IX86_BUILTIN_LOADPD1
:
13341 target
= ix86_expand_unop_builtin (CODE_FOR_sse2_loadsd
, arglist
,
13342 gen_reg_rtx (V2DFmode
), 1);
13343 emit_insn (gen_sse2_shufpd (target
, target
, target
, const0_rtx
));
13346 case IX86_BUILTIN_STOREPD1
:
13347 return ix86_expand_store_builtin (CODE_FOR_sse2_movapd
, arglist
);
13348 case IX86_BUILTIN_STORERPD
:
13349 return ix86_expand_store_builtin (CODE_FOR_sse2_movapd
, arglist
);
13351 case IX86_BUILTIN_MFENCE
:
13352 emit_insn (gen_sse2_mfence ());
13354 case IX86_BUILTIN_LFENCE
:
13355 emit_insn (gen_sse2_lfence ());
13358 case IX86_BUILTIN_CLFLUSH
:
13359 arg0
= TREE_VALUE (arglist
);
13360 op0
= expand_expr (arg0
, NULL_RTX
, VOIDmode
, 0);
13361 icode
= CODE_FOR_sse2_clflush
;
13362 mode0
= insn_data
[icode
].operand
[0].mode
;
13363 if (! (*insn_data
[icode
].operand
[0].predicate
) (op0
, mode0
))
13364 op0
= copy_to_mode_reg (mode0
, op0
);
13366 emit_insn (gen_sse2_clflush (op0
));
13369 case IX86_BUILTIN_MOVNTPD
:
13370 return ix86_expand_store_builtin (CODE_FOR_sse2_movntv2df
, arglist
);
13371 case IX86_BUILTIN_MOVNTDQ
:
13372 return ix86_expand_store_builtin (CODE_FOR_sse2_movntv2di
, arglist
);
13373 case IX86_BUILTIN_MOVNTI
:
13374 return ix86_expand_store_builtin (CODE_FOR_sse2_movntsi
, arglist
);
13380 for (i
= 0, d
= bdesc_2arg
; i
< ARRAY_SIZE (bdesc_2arg
); i
++, d
++)
13381 if (d
->code
== fcode
)
13383 /* Compares are treated specially. */
13384 if (d
->icode
== CODE_FOR_maskcmpv4sf3
13385 || d
->icode
== CODE_FOR_vmmaskcmpv4sf3
13386 || d
->icode
== CODE_FOR_maskncmpv4sf3
13387 || d
->icode
== CODE_FOR_vmmaskncmpv4sf3
13388 || d
->icode
== CODE_FOR_maskcmpv2df3
13389 || d
->icode
== CODE_FOR_vmmaskcmpv2df3
13390 || d
->icode
== CODE_FOR_maskncmpv2df3
13391 || d
->icode
== CODE_FOR_vmmaskncmpv2df3
)
13392 return ix86_expand_sse_compare (d
, arglist
, target
);
13394 return ix86_expand_binop_builtin (d
->icode
, arglist
, target
);
13397 for (i
= 0, d
= bdesc_1arg
; i
< ARRAY_SIZE (bdesc_1arg
); i
++, d
++)
13398 if (d
->code
== fcode
)
13399 return ix86_expand_unop_builtin (d
->icode
, arglist
, target
, 0);
13401 for (i
= 0, d
= bdesc_comi
; i
< ARRAY_SIZE (bdesc_comi
); i
++, d
++)
13402 if (d
->code
== fcode
)
13403 return ix86_expand_sse_comi (d
, arglist
, target
);
13405 /* @@@ Should really do something sensible here. */
13409 /* Store OPERAND to the memory after reload is completed. This means
13410 that we can't easily use assign_stack_local. */
13412 ix86_force_to_memory (mode
, operand
)
13413 enum machine_mode mode
;
13417 if (!reload_completed
)
13419 if (TARGET_64BIT
&& TARGET_RED_ZONE
)
13421 result
= gen_rtx_MEM (mode
,
13422 gen_rtx_PLUS (Pmode
,
13424 GEN_INT (-RED_ZONE_SIZE
)));
13425 emit_move_insn (result
, operand
);
13427 else if (TARGET_64BIT
&& !TARGET_RED_ZONE
)
13433 operand
= gen_lowpart (DImode
, operand
);
13437 gen_rtx_SET (VOIDmode
,
13438 gen_rtx_MEM (DImode
,
13439 gen_rtx_PRE_DEC (DImode
,
13440 stack_pointer_rtx
)),
13446 result
= gen_rtx_MEM (mode
, stack_pointer_rtx
);
13455 split_di (&operand
, 1, operands
, operands
+ 1);
13457 gen_rtx_SET (VOIDmode
,
13458 gen_rtx_MEM (SImode
,
13459 gen_rtx_PRE_DEC (Pmode
,
13460 stack_pointer_rtx
)),
13463 gen_rtx_SET (VOIDmode
,
13464 gen_rtx_MEM (SImode
,
13465 gen_rtx_PRE_DEC (Pmode
,
13466 stack_pointer_rtx
)),
13471 /* It is better to store HImodes as SImodes. */
13472 if (!TARGET_PARTIAL_REG_STALL
)
13473 operand
= gen_lowpart (SImode
, operand
);
13477 gen_rtx_SET (VOIDmode
,
13478 gen_rtx_MEM (GET_MODE (operand
),
13479 gen_rtx_PRE_DEC (SImode
,
13480 stack_pointer_rtx
)),
13486 result
= gen_rtx_MEM (mode
, stack_pointer_rtx
);
13491 /* Free operand from the memory. */
13493 ix86_free_from_memory (mode
)
13494 enum machine_mode mode
;
13496 if (!TARGET_64BIT
|| !TARGET_RED_ZONE
)
13500 if (mode
== DImode
|| TARGET_64BIT
)
13502 else if (mode
== HImode
&& TARGET_PARTIAL_REG_STALL
)
13506 /* Use LEA to deallocate stack space. In peephole2 it will be converted
13507 to pop or add instruction if registers are available. */
13508 emit_insn (gen_rtx_SET (VOIDmode
, stack_pointer_rtx
,
13509 gen_rtx_PLUS (Pmode
, stack_pointer_rtx
,
13514 /* Put float CONST_DOUBLE in the constant pool instead of fp regs.
13515 QImode must go into class Q_REGS.
13516 Narrow ALL_REGS to GENERAL_REGS. This supports allowing movsf and
13517 movdf to do mem-to-mem moves through integer regs. */
13519 ix86_preferred_reload_class (x
, class)
13521 enum reg_class
class;
13523 if (GET_CODE (x
) == CONST_DOUBLE
&& GET_MODE (x
) != VOIDmode
)
13525 /* SSE can't load any constant directly yet. */
13526 if (SSE_CLASS_P (class))
13528 /* Floats can load 0 and 1. */
13529 if (MAYBE_FLOAT_CLASS_P (class) && standard_80387_constant_p (x
))
13531 /* Limit class to non-SSE. Use GENERAL_REGS if possible. */
13532 if (MAYBE_SSE_CLASS_P (class))
13533 return (reg_class_subset_p (class, GENERAL_REGS
)
13534 ? GENERAL_REGS
: FLOAT_REGS
);
13538 /* General regs can load everything. */
13539 if (reg_class_subset_p (class, GENERAL_REGS
))
13540 return GENERAL_REGS
;
13541 /* In case we haven't resolved FLOAT or SSE yet, give up. */
13542 if (MAYBE_FLOAT_CLASS_P (class) || MAYBE_SSE_CLASS_P (class))
13545 if (MAYBE_MMX_CLASS_P (class) && CONSTANT_P (x
))
13547 if (GET_MODE (x
) == QImode
&& ! reg_class_subset_p (class, Q_REGS
))
13552 /* If we are copying between general and FP registers, we need a memory
13553 location. The same is true for SSE and MMX registers.
13555 The macro can't work reliably when one of the CLASSES is class containing
13556 registers from multiple units (SSE, MMX, integer). We avoid this by never
13557 combining those units in single alternative in the machine description.
13558 Ensure that this constraint holds to avoid unexpected surprises.
13560 When STRICT is false, we are being called from REGISTER_MOVE_COST, so do not
13561 enforce these sanity checks. */
13563 ix86_secondary_memory_needed (class1
, class2
, mode
, strict
)
13564 enum reg_class class1
, class2
;
13565 enum machine_mode mode
;
13568 if (MAYBE_FLOAT_CLASS_P (class1
) != FLOAT_CLASS_P (class1
)
13569 || MAYBE_FLOAT_CLASS_P (class2
) != FLOAT_CLASS_P (class2
)
13570 || MAYBE_SSE_CLASS_P (class1
) != SSE_CLASS_P (class1
)
13571 || MAYBE_SSE_CLASS_P (class2
) != SSE_CLASS_P (class2
)
13572 || MAYBE_MMX_CLASS_P (class1
) != MMX_CLASS_P (class1
)
13573 || MAYBE_MMX_CLASS_P (class2
) != MMX_CLASS_P (class2
))
13580 return (FLOAT_CLASS_P (class1
) != FLOAT_CLASS_P (class2
)
13581 || (SSE_CLASS_P (class1
) != SSE_CLASS_P (class2
)
13582 && (mode
) != SImode
)
13583 || (MMX_CLASS_P (class1
) != MMX_CLASS_P (class2
)
13584 && (mode
) != SImode
));
13586 /* Return the cost of moving data from a register in class CLASS1 to
13587 one in class CLASS2.
13589 It is not required that the cost always equal 2 when FROM is the same as TO;
13590 on some machines it is expensive to move between registers if they are not
13591 general registers. */
13593 ix86_register_move_cost (mode
, class1
, class2
)
13594 enum machine_mode mode
;
13595 enum reg_class class1
, class2
;
13597 /* In case we require secondary memory, compute cost of the store followed
13598 by load. In case of copying from general_purpose_register we may emit
13599 multiple stores followed by single load causing memory size mismatch
13600 stall. Count this as arbitarily high cost of 20. */
13601 if (ix86_secondary_memory_needed (class1
, class2
, mode
, 0))
13604 if (CLASS_MAX_NREGS (class1
, mode
) > CLASS_MAX_NREGS (class2
, mode
))
13606 return (MEMORY_MOVE_COST (mode
, class1
, 0)
13607 + MEMORY_MOVE_COST (mode
, class2
, 1) + add_cost
);
13609 /* Moves between SSE/MMX and integer unit are expensive. */
13610 if (MMX_CLASS_P (class1
) != MMX_CLASS_P (class2
)
13611 || SSE_CLASS_P (class1
) != SSE_CLASS_P (class2
))
13612 return ix86_cost
->mmxsse_to_integer
;
13613 if (MAYBE_FLOAT_CLASS_P (class1
))
13614 return ix86_cost
->fp_move
;
13615 if (MAYBE_SSE_CLASS_P (class1
))
13616 return ix86_cost
->sse_move
;
13617 if (MAYBE_MMX_CLASS_P (class1
))
13618 return ix86_cost
->mmx_move
;
13622 /* Return 1 if hard register REGNO can hold a value of machine-mode MODE. */
13624 ix86_hard_regno_mode_ok (regno
, mode
)
13626 enum machine_mode mode
;
13628 /* Flags and only flags can only hold CCmode values. */
13629 if (CC_REGNO_P (regno
))
13630 return GET_MODE_CLASS (mode
) == MODE_CC
;
13631 if (GET_MODE_CLASS (mode
) == MODE_CC
13632 || GET_MODE_CLASS (mode
) == MODE_RANDOM
13633 || GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
13635 if (FP_REGNO_P (regno
))
13636 return VALID_FP_MODE_P (mode
);
13637 if (SSE_REGNO_P (regno
))
13638 return VALID_SSE_REG_MODE (mode
);
13639 if (MMX_REGNO_P (regno
))
13640 return VALID_MMX_REG_MODE (mode
) || VALID_MMX_REG_MODE_3DNOW (mode
);
13641 /* We handle both integer and floats in the general purpose registers.
13642 In future we should be able to handle vector modes as well. */
13643 if (!VALID_INT_MODE_P (mode
) && !VALID_FP_MODE_P (mode
))
13645 /* Take care for QImode values - they can be in non-QI regs, but then
13646 they do cause partial register stalls. */
13647 if (regno
< 4 || mode
!= QImode
|| TARGET_64BIT
)
13649 return reload_in_progress
|| reload_completed
|| !TARGET_PARTIAL_REG_STALL
;
13652 /* Return the cost of moving data of mode M between a
13653 register and memory. A value of 2 is the default; this cost is
13654 relative to those in `REGISTER_MOVE_COST'.
13656 If moving between registers and memory is more expensive than
13657 between two registers, you should define this macro to express the
13660 Model also increased moving costs of QImode registers in non
13664 ix86_memory_move_cost (mode
, class, in
)
13665 enum machine_mode mode
;
13666 enum reg_class
class;
13669 if (FLOAT_CLASS_P (class))
13687 return in
? ix86_cost
->fp_load
[index
] : ix86_cost
->fp_store
[index
];
13689 if (SSE_CLASS_P (class))
13692 switch (GET_MODE_SIZE (mode
))
13706 return in
? ix86_cost
->sse_load
[index
] : ix86_cost
->sse_store
[index
];
13708 if (MMX_CLASS_P (class))
13711 switch (GET_MODE_SIZE (mode
))
13722 return in
? ix86_cost
->mmx_load
[index
] : ix86_cost
->mmx_store
[index
];
13724 switch (GET_MODE_SIZE (mode
))
13728 return (Q_CLASS_P (class) ? ix86_cost
->int_load
[0]
13729 : ix86_cost
->movzbl_load
);
13731 return (Q_CLASS_P (class) ? ix86_cost
->int_store
[0]
13732 : ix86_cost
->int_store
[0] + 4);
13735 return in
? ix86_cost
->int_load
[1] : ix86_cost
->int_store
[1];
13737 /* Compute number of 32bit moves needed. TFmode is moved as XFmode. */
13738 if (mode
== TFmode
)
13740 return ((in
? ix86_cost
->int_load
[2] : ix86_cost
->int_store
[2])
13741 * (int) GET_MODE_SIZE (mode
) / 4);
13745 #if defined (DO_GLOBAL_CTORS_BODY) && defined (HAS_INIT_SECTION)
13747 ix86_svr3_asm_out_constructor (symbol
, priority
)
13749 int priority ATTRIBUTE_UNUSED
;
13752 fputs ("\tpushl $", asm_out_file
);
13753 assemble_name (asm_out_file
, XSTR (symbol
, 0));
13754 fputc ('\n', asm_out_file
);
13760 static int current_machopic_label_num
;
13762 /* Given a symbol name and its associated stub, write out the
13763 definition of the stub. */
13766 machopic_output_stub (file
, symb
, stub
)
13768 const char *symb
, *stub
;
13770 unsigned int length
;
13771 char *binder_name
, *symbol_name
, lazy_ptr_name
[32];
13772 int label
= ++current_machopic_label_num
;
13774 /* Lose our funky encoding stuff so it doesn't contaminate the stub. */
13775 symb
= (*targetm
.strip_name_encoding
) (symb
);
13777 length
= strlen (stub
);
13778 binder_name
= alloca (length
+ 32);
13779 GEN_BINDER_NAME_FOR_STUB (binder_name
, stub
, length
);
13781 length
= strlen (symb
);
13782 symbol_name
= alloca (length
+ 32);
13783 GEN_SYMBOL_NAME_FOR_SYMBOL (symbol_name
, symb
, length
);
13785 sprintf (lazy_ptr_name
, "L%d$lz", label
);
13788 machopic_picsymbol_stub_section ();
13790 machopic_symbol_stub_section ();
13792 fprintf (file
, "%s:\n", stub
);
13793 fprintf (file
, "\t.indirect_symbol %s\n", symbol_name
);
13797 fprintf (file
, "\tcall LPC$%d\nLPC$%d:\tpopl %%eax\n", label
, label
);
13798 fprintf (file
, "\tmovl %s-LPC$%d(%%eax),%%edx\n", lazy_ptr_name
, label
);
13799 fprintf (file
, "\tjmp %%edx\n");
13802 fprintf (file
, "\tjmp *%s\n", lazy_ptr_name
);
13804 fprintf (file
, "%s:\n", binder_name
);
13808 fprintf (file
, "\tlea %s-LPC$%d(%%eax),%%eax\n", lazy_ptr_name
, label
);
13809 fprintf (file
, "\tpushl %%eax\n");
13812 fprintf (file
, "\t pushl $%s\n", lazy_ptr_name
);
13814 fprintf (file
, "\tjmp dyld_stub_binding_helper\n");
13816 machopic_lazy_symbol_ptr_section ();
13817 fprintf (file
, "%s:\n", lazy_ptr_name
);
13818 fprintf (file
, "\t.indirect_symbol %s\n", symbol_name
);
13819 fprintf (file
, "\t.long %s\n", binder_name
);
13821 #endif /* TARGET_MACHO */
13823 /* Order the registers for register allocator. */
13826 x86_order_regs_for_local_alloc ()
13831 /* First allocate the local general purpose registers. */
13832 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
13833 if (GENERAL_REGNO_P (i
) && call_used_regs
[i
])
13834 reg_alloc_order
[pos
++] = i
;
13836 /* Global general purpose registers. */
13837 for (i
= 0; i
< FIRST_PSEUDO_REGISTER
; i
++)
13838 if (GENERAL_REGNO_P (i
) && !call_used_regs
[i
])
13839 reg_alloc_order
[pos
++] = i
;
13841 /* x87 registers come first in case we are doing FP math
13843 if (!TARGET_SSE_MATH
)
13844 for (i
= FIRST_STACK_REG
; i
<= LAST_STACK_REG
; i
++)
13845 reg_alloc_order
[pos
++] = i
;
13847 /* SSE registers. */
13848 for (i
= FIRST_SSE_REG
; i
<= LAST_SSE_REG
; i
++)
13849 reg_alloc_order
[pos
++] = i
;
13850 for (i
= FIRST_REX_SSE_REG
; i
<= LAST_REX_SSE_REG
; i
++)
13851 reg_alloc_order
[pos
++] = i
;
13853 /* x87 registerts. */
13854 if (TARGET_SSE_MATH
)
13855 for (i
= FIRST_STACK_REG
; i
<= LAST_STACK_REG
; i
++)
13856 reg_alloc_order
[pos
++] = i
;
13858 for (i
= FIRST_MMX_REG
; i
<= LAST_MMX_REG
; i
++)
13859 reg_alloc_order
[pos
++] = i
;
13861 /* Initialize the rest of array as we do not allocate some registers
13863 while (pos
< FIRST_PSEUDO_REGISTER
)
13864 reg_alloc_order
[pos
++] = 0;
13868 x86_output_mi_thunk (file
, delta
, function
)
13876 if (ix86_regparm
> 0)
13877 parm
= TYPE_ARG_TYPES (TREE_TYPE (function
));
13880 for (; parm
; parm
= TREE_CHAIN (parm
))
13881 if (TREE_VALUE (parm
) == void_type_node
)
13884 xops
[0] = GEN_INT (delta
);
13887 int n
= aggregate_value_p (TREE_TYPE (TREE_TYPE (function
))) != 0;
13888 xops
[1] = gen_rtx_REG (DImode
, x86_64_int_parameter_registers
[n
]);
13889 output_asm_insn ("add{q} {%0, %1|%1, %0}", xops
);
13892 fprintf (file
, "\tjmp *");
13893 assemble_name (file
, XSTR (XEXP (DECL_RTL (function
), 0), 0));
13894 fprintf (file
, "@GOTPCREL(%%rip)\n");
13898 fprintf (file
, "\tjmp ");
13899 assemble_name (file
, XSTR (XEXP (DECL_RTL (function
), 0), 0));
13900 fprintf (file
, "\n");
13906 xops
[1] = gen_rtx_REG (SImode
, 0);
13907 else if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function
))))
13908 xops
[1] = gen_rtx_MEM (SImode
, plus_constant (stack_pointer_rtx
, 8));
13910 xops
[1] = gen_rtx_MEM (SImode
, plus_constant (stack_pointer_rtx
, 4));
13911 output_asm_insn ("add{l} {%0, %1|%1, %0}", xops
);
13915 xops
[0] = pic_offset_table_rtx
;
13916 xops
[1] = gen_label_rtx ();
13917 xops
[2] = gen_rtx_SYMBOL_REF (Pmode
, GOT_SYMBOL_NAME
);
13919 if (ix86_regparm
> 2)
13921 output_asm_insn ("push{l}\t%0", xops
);
13922 output_asm_insn ("call\t%P1", xops
);
13923 ASM_OUTPUT_INTERNAL_LABEL (file
, "L", CODE_LABEL_NUMBER (xops
[1]));
13924 output_asm_insn ("pop{l}\t%0", xops
);
13926 ("add{l}\t{%2+[.-%P1], %0|%0, OFFSET FLAT: %2+[.-%P1]}", xops
);
13927 xops
[0] = gen_rtx_MEM (SImode
, XEXP (DECL_RTL (function
), 0));
13929 ("mov{l}\t{%0@GOT(%%ebx), %%ecx|%%ecx, %0@GOT[%%ebx]}", xops
);
13930 asm_fprintf (file
, "\tpop{l\t%%ebx|\t%%ebx}\n");
13931 asm_fprintf (file
, "\tjmp\t{*%%ecx|%%ecx}\n");
13935 fprintf (file
, "\tjmp ");
13936 assemble_name (file
, XSTR (XEXP (DECL_RTL (function
), 0), 0));
13937 fprintf (file
, "\n");
13943 x86_field_alignment (field
, computed
)
13947 enum machine_mode mode
;
13948 tree type
= TREE_TYPE (field
);
13950 if (TARGET_64BIT
|| TARGET_ALIGN_DOUBLE
)
13952 mode
= TYPE_MODE (TREE_CODE (type
) == ARRAY_TYPE
13953 ? get_inner_array_type (type
) : type
);
13954 if (mode
== DFmode
|| mode
== DCmode
13955 || GET_MODE_CLASS (mode
) == MODE_INT
13956 || GET_MODE_CLASS (mode
) == MODE_COMPLEX_INT
)
13957 return MIN (32, computed
);
13961 /* Implement machine specific optimizations.
13962 At the moment we implement single transformation: AMD Athlon works faster
13963 when RET is not destination of conditional jump or directly preceeded
13964 by other jump instruction. We avoid the penalty by inserting NOP just
13965 before the RET instructions in such cases. */
13967 x86_machine_dependent_reorg (first
)
13968 rtx first ATTRIBUTE_UNUSED
;
13972 if (!TARGET_ATHLON
|| !optimize
|| optimize_size
)
13974 for (e
= EXIT_BLOCK_PTR
->pred
; e
; e
= e
->pred_next
)
13976 basic_block bb
= e
->src
;
13979 bool insert
= false;
13981 if (!returnjump_p (ret
) || !maybe_hot_bb_p (bb
))
13983 prev
= prev_nonnote_insn (ret
);
13984 if (prev
&& GET_CODE (prev
) == CODE_LABEL
)
13987 for (e
= bb
->pred
; e
; e
= e
->pred_next
)
13988 if (EDGE_FREQUENCY (e
) && e
->src
->index
> 0
13989 && !(e
->flags
& EDGE_FALLTHRU
))
13994 prev
= prev_real_insn (ret
);
13995 if (prev
&& GET_CODE (prev
) == JUMP_INSN
13996 && any_condjump_p (prev
))
14000 emit_insn_before (gen_nop (), ret
);
14004 #include "gt-i386.h"