1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
4 ;; Mostly by William Schelter.
5 ;; x86_64 support added by Jan Hubicka
7 ;; This file is part of GNU CC.
9 ;; GNU CC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU CC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU CC; see the file COPYING. If not, write to
21 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA. */
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
29 ;; Macro #define NOTICE_UPDATE_CC in file i386.h handles condition code
30 ;; updates for most instructions.
32 ;; Macro REG_CLASS_FROM_LETTER in file i386.h defines the register
33 ;; constraint letters.
35 ;; The special asm out single letter directives following a '%' are:
36 ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
38 ;; 'L' Print the opcode suffix for a 32-bit integer opcode.
39 ;; 'W' Print the opcode suffix for a 16-bit integer opcode.
40 ;; 'B' Print the opcode suffix for an 8-bit integer opcode.
41 ;; 'Q' Print the opcode suffix for a 64-bit float opcode.
42 ;; 'S' Print the opcode suffix for a 32-bit float opcode.
43 ;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
44 ;; 'J' Print the appropriate jump operand.
46 ;; 'b' Print the QImode name of the register for the indicated operand.
47 ;; %b0 would print %al if operands[0] is reg 0.
48 ;; 'w' Likewise, print the HImode name of the register.
49 ;; 'k' Likewise, print the SImode name of the register.
50 ;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh.
51 ;; 'y' Print "st(0)" instead of "st" as a register.
54 ;; 0 This is a `scas' operation. The mode of the UNSPEC is always SImode.
55 ;; operand 0 is the memory address to scan.
56 ;; operand 1 is a register containing the value to scan for. The mode
57 ;; of the scas opcode will be the same as the mode of this operand.
58 ;; operand 2 is the known alignment of operand 0.
59 ;; 1 This is a `sin' operation. The mode of the UNSPEC is MODE_FLOAT.
60 ;; operand 0 is the argument for `sin'.
61 ;; 2 This is a `cos' operation. The mode of the UNSPEC is MODE_FLOAT.
62 ;; operand 0 is the argument for `cos'.
63 ;; 3 This is part of a `stack probe' operation. The mode of the UNSPEC is
64 ;; always SImode. operand 0 is the size of the stack allocation.
65 ;; 4 This is the source of a fake SET of the frame pointer which is used to
66 ;; prevent insns referencing it being scheduled across the initial
67 ;; decrement of the stack pointer.
68 ;; 5 This is a `bsf' operation.
69 ;; 6 This is the @GOT offset of a PIC address.
70 ;; 7 This is the @GOTOFF offset of a PIC address.
71 ;; 8 This is a reference to a symbol's @PLT address.
72 ;; 9 This is an `fnstsw' operation.
73 ;; 10 This is a `sahf' operation.
74 ;; 11 This is a `fstcw' operation
75 ;; 12 This is behaviour of add when setting carry flag.
76 ;; 13 This is a `eh_return' placeholder.
78 ;; For SSE/MMX support:
79 ;; 30 This is `fix', guaranteed to be truncating.
80 ;; 31 This is a `emms' operation.
81 ;; 32 This is a `maskmov' operation.
82 ;; 33 This is a `movmsk' operation.
83 ;; 34 This is a `non-temporal' move.
84 ;; 35 This is a `prefetch' operation.
85 ;; 36 This is used to distinguish COMISS from UCOMISS.
86 ;; 37 This is a `ldmxcsr' operation.
87 ;; 38 This is a forced `movaps' instruction (rather than whatever movti does)
88 ;; 39 This is a forced `movups' instruction (rather than whatever movti does)
89 ;; 40 This is a `stmxcsr' operation.
90 ;; 41 This is a `shuffle' operation.
91 ;; 42 This is a `rcp' operation.
92 ;; 43 This is a `rsqsrt' operation.
93 ;; 44 This is a `sfence' operation.
94 ;; 45 This is a noop to prevent excessive combiner cleverness.
95 ;; 46 This is a `femms' operation.
96 ;; 47 This is a `prefetch' (3DNow) operation.
97 ;; 48 This is a `prefetchw' operation.
98 ;; 49 This is a 'pavgusb' operation.
99 ;; 50 This is a `pfrcp' operation.
100 ;; 51 This is a `pfrcpit1' operation.
101 ;; 52 This is a `pfrcpit2' operation.
102 ;; 53 This is a `pfrsqrt' operation.
103 ;; 54 This is a `pfrsqrit1' operation.
105 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
108 ;; In C guard expressions, put expressions which may be compile-time
109 ;; constants first. This allows for better optimization. For
110 ;; example, write "TARGET_64BIT && reload_completed", not
111 ;; "reload_completed && TARGET_64BIT".
114 ;; Processor type. This attribute must exactly match the processor_type
115 ;; enumeration in i386.h.
116 (define_attr "cpu" "i386,i486,pentium,pentiumpro,k6,athlon,pentium4"
117 (const (symbol_ref "ix86_cpu")))
119 ;; A basic instruction type. Refinements due to arguments to be
120 ;; provided in other attributes.
122 "other,multi,alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,imul,idiv,ibr,setcc,push,pop,call,callv,icmov,fmov,fop,fop1,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,str,cld,sse,mmx,fistp"
123 (const_string "other"))
125 ;; Main data type used by the insn
126 (define_attr "mode" "unknown,none,QI,HI,SI,DI,unknownfp,SF,DF,XF,TI"
127 (const_string "unknown"))
129 ;; Set for i387 operations.
130 (define_attr "i387" ""
131 (if_then_else (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp")
135 ;; The (bounding maximum) length of an instruction immediate.
136 (define_attr "length_immediate" ""
137 (cond [(eq_attr "type" "incdec,setcc,icmov,ibr,str,cld,lea,other,multi,idiv,sse,mmx")
141 (eq_attr "type" "alu1,negnot,alu,icmp,imovx,ishift,imul,push,pop")
142 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
143 (eq_attr "type" "imov,test")
144 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
145 (eq_attr "type" "call")
146 (if_then_else (match_operand 0 "constant_call_address_operand" "")
149 (eq_attr "type" "callv")
150 (if_then_else (match_operand 1 "constant_call_address_operand" "")
153 (eq_attr "type" "ibr")
154 (if_then_else (and (ge (minus (match_dup 0) (pc))
156 (lt (minus (match_dup 0) (pc))
161 (symbol_ref "/* Update immediate_length and other attributes! */ abort(),1")))
163 ;; The (bounding maximum) length of an instruction address.
164 (define_attr "length_address" ""
165 (cond [(eq_attr "type" "str,cld,other,multi,fxch")
167 (and (eq_attr "type" "call")
168 (match_operand 1 "constant_call_address_operand" ""))
170 (and (eq_attr "type" "callv")
171 (match_operand 1 "constant_call_address_operand" ""))
174 (symbol_ref "ix86_attr_length_address_default (insn)")))
176 ;; Set when length prefix is used.
177 (define_attr "prefix_data16" ""
178 (if_then_else (eq_attr "mode" "HI")
182 ;; Set when string REP prefix is used.
183 (define_attr "prefix_rep" "" (const_int 0))
185 ;; Set when 0f opcode prefix is used.
186 (define_attr "prefix_0f" ""
187 (if_then_else (eq_attr "type" "imovx,setcc,icmov,sse,mmx")
191 ;; Set when modrm byte is used.
192 (define_attr "modrm" ""
193 (cond [(eq_attr "type" "str,cld")
197 (and (eq_attr "type" "incdec")
198 (ior (match_operand:SI 1 "register_operand" "")
199 (match_operand:HI 1 "register_operand" "")))
201 (and (eq_attr "type" "push")
202 (not (match_operand 1 "memory_operand" "")))
204 (and (eq_attr "type" "pop")
205 (not (match_operand 0 "memory_operand" "")))
207 (and (eq_attr "type" "imov")
208 (and (match_operand 0 "register_operand" "")
209 (match_operand 1 "immediate_operand" "")))
214 ;; The (bounding maximum) length of an instruction in bytes.
215 ;; ??? fistp is in fact fldcw/fistp/fldcw sequence. Later we may want
216 ;; to split it and compute proper length as for other insns.
217 (define_attr "length" ""
218 (cond [(eq_attr "type" "other,multi,fistp")
221 (plus (plus (attr "modrm")
222 (plus (attr "prefix_0f")
225 (plus (attr "prefix_rep")
226 (plus (attr "prefix_data16")
227 (plus (attr "length_immediate")
228 (attr "length_address")))))))
230 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
231 ;; `store' if there is a simple memory reference therein, or `unknown'
232 ;; if the instruction is complex.
234 (define_attr "memory" "none,load,store,both,unknown"
235 (cond [(eq_attr "type" "other,multi,str")
236 (const_string "unknown")
237 (eq_attr "type" "lea,fcmov,fpspc,cld")
238 (const_string "none")
239 (eq_attr "type" "fistp")
240 (const_string "both")
241 (eq_attr "type" "push")
242 (if_then_else (match_operand 1 "memory_operand" "")
243 (const_string "both")
244 (const_string "store"))
245 (eq_attr "type" "pop,setcc")
246 (if_then_else (match_operand 0 "memory_operand" "")
247 (const_string "both")
248 (const_string "load"))
249 (eq_attr "type" "icmp,test")
250 (if_then_else (ior (match_operand 0 "memory_operand" "")
251 (match_operand 1 "memory_operand" ""))
252 (const_string "load")
253 (const_string "none"))
254 (eq_attr "type" "ibr")
255 (if_then_else (match_operand 0 "memory_operand" "")
256 (const_string "load")
257 (const_string "none"))
258 (eq_attr "type" "call")
259 (if_then_else (match_operand 0 "constant_call_address_operand" "")
260 (const_string "none")
261 (const_string "load"))
262 (eq_attr "type" "callv")
263 (if_then_else (match_operand 1 "constant_call_address_operand" "")
264 (const_string "none")
265 (const_string "load"))
266 (and (eq_attr "type" "alu1,negnot")
267 (match_operand 1 "memory_operand" ""))
268 (const_string "both")
269 (and (match_operand 0 "memory_operand" "")
270 (match_operand 1 "memory_operand" ""))
271 (const_string "both")
272 (match_operand 0 "memory_operand" "")
273 (const_string "store")
274 (match_operand 1 "memory_operand" "")
275 (const_string "load")
276 (and (eq_attr "type" "!icmp,test,alu1,negnot,fop1,fsgn,imov,imovx,fmov,fcmp,sse,mmx")
277 (match_operand 2 "memory_operand" ""))
278 (const_string "load")
279 (and (eq_attr "type" "icmov")
280 (match_operand 3 "memory_operand" ""))
281 (const_string "load")
283 (const_string "none")))
285 ;; Indicates if an instruction has both an immediate and a displacement.
287 (define_attr "imm_disp" "false,true,unknown"
288 (cond [(eq_attr "type" "other,multi")
289 (const_string "unknown")
290 (and (eq_attr "type" "icmp,test,imov")
291 (and (match_operand 0 "memory_displacement_operand" "")
292 (match_operand 1 "immediate_operand" "")))
293 (const_string "true")
294 (and (eq_attr "type" "alu,ishift,imul,idiv")
295 (and (match_operand 0 "memory_displacement_operand" "")
296 (match_operand 2 "immediate_operand" "")))
297 (const_string "true")
299 (const_string "false")))
301 ;; Indicates if an FP operation has an integer source.
303 (define_attr "fp_int_src" "false,true"
304 (const_string "false"))
306 ;; Describe a user's asm statement.
307 (define_asm_attributes
308 [(set_attr "length" "128")
309 (set_attr "type" "multi")])
311 ;; Pentium Scheduling
313 ;; The Pentium is an in-order core with two integer pipelines.
315 ;; True for insns that behave like prefixed insns on the Pentium.
316 (define_attr "pent_prefix" "false,true"
317 (if_then_else (ior (eq_attr "prefix_0f" "1")
318 (ior (eq_attr "prefix_data16" "1")
319 (eq_attr "prefix_rep" "1")))
320 (const_string "true")
321 (const_string "false")))
323 ;; Categorize how an instruction slots.
325 ;; The non-MMX Pentium slots an instruction with prefixes on U pipe only,
326 ;; while MMX Pentium can slot it on either U or V. Model non-MMX Pentium
327 ;; rules, because it results in noticeably better code on non-MMX Pentium
328 ;; and doesn't hurt much on MMX. (Prefixed instructions are not very
329 ;; common, so the scheduler usualy has a non-prefixed insn to pair).
331 (define_attr "pent_pair" "uv,pu,pv,np"
332 (cond [(eq_attr "imm_disp" "true")
334 (ior (eq_attr "type" "alu1,alu,imov,icmp,test,lea,incdec")
335 (and (eq_attr "type" "pop,push")
336 (eq_attr "memory" "!both")))
337 (if_then_else (eq_attr "pent_prefix" "true")
340 (eq_attr "type" "ibr")
342 (and (eq_attr "type" "ishift")
343 (match_operand 2 "const_int_operand" ""))
345 (and (eq_attr "type" "call")
346 (match_operand 0 "constant_call_address_operand" ""))
348 (and (eq_attr "type" "callv")
349 (match_operand 1 "constant_call_address_operand" ""))
352 (const_string "np")))
354 ;; Rough readiness numbers. Fine tuning happens in i386.c.
356 ;; u describes pipe U
357 ;; v describes pipe V
358 ;; uv describes either pipe U or V for those that can issue to either
359 ;; np describes not paring
361 ;; fpm describes fp insns of different types are not pipelined.
363 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
365 (define_function_unit "pent_np" 1 0
366 (and (eq_attr "cpu" "pentium")
367 (eq_attr "type" "imul"))
370 (define_function_unit "pent_mul" 1 1
371 (and (eq_attr "cpu" "pentium")
372 (eq_attr "type" "imul"))
375 ;; Rep movs takes minimally 12 cycles.
376 (define_function_unit "pent_np" 1 0
377 (and (eq_attr "cpu" "pentium")
378 (eq_attr "type" "str"))
381 ; ??? IDIV for SI takes 46 cycles, for HI 30, for QI 22
382 (define_function_unit "pent_np" 1 0
383 (and (eq_attr "cpu" "pentium")
384 (eq_attr "type" "idiv"))
387 ; Fp reg-reg moves takes 1 cycle. Loads takes 1 cycle for SF/DF mode,
388 ; 3 cycles for XFmode. Stores takes 2 cycles for SF/DF and 3 for XF.
389 ; fldz and fld1 takes 2 cycles. Only reg-reg moves are pairable.
390 ; The integer <-> fp conversion is not modeled correctly. Fild behaves
391 ; like normal fp operation and fist takes 6 cycles.
393 (define_function_unit "fpu" 1 0
394 (and (eq_attr "cpu" "pentium")
395 (and (eq_attr "type" "fmov")
396 (and (eq_attr "memory" "load,store")
397 (eq_attr "mode" "XF"))))
400 (define_function_unit "pent_np" 1 0
401 (and (eq_attr "cpu" "pentium")
402 (and (eq_attr "type" "fmov")
403 (and (eq_attr "memory" "load,store")
404 (eq_attr "mode" "XF"))))
407 (define_function_unit "fpu" 1 0
408 (and (eq_attr "cpu" "pentium")
409 (and (eq_attr "type" "fmov")
410 (ior (match_operand 1 "immediate_operand" "")
411 (eq_attr "memory" "store"))))
414 (define_function_unit "pent_np" 1 0
415 (and (eq_attr "cpu" "pentium")
416 (and (eq_attr "type" "fmov")
417 (ior (match_operand 1 "immediate_operand" "")
418 (eq_attr "memory" "store"))))
421 (define_function_unit "pent_np" 1 0
422 (and (eq_attr "cpu" "pentium")
423 (eq_attr "type" "cld"))
426 (define_function_unit "fpu" 1 0
427 (and (eq_attr "cpu" "pentium")
428 (and (eq_attr "type" "fmov")
429 (eq_attr "memory" "none,load")))
432 ; Read/Modify/Write instructions usually take 3 cycles.
433 (define_function_unit "pent_u" 1 0
434 (and (eq_attr "cpu" "pentium")
435 (and (eq_attr "type" "alu,alu1,ishift")
436 (and (eq_attr "pent_pair" "pu")
437 (eq_attr "memory" "both"))))
440 (define_function_unit "pent_uv" 2 0
441 (and (eq_attr "cpu" "pentium")
442 (and (eq_attr "type" "alu,alu1,ishift")
443 (and (eq_attr "pent_pair" "!np")
444 (eq_attr "memory" "both"))))
447 (define_function_unit "pent_np" 1 0
448 (and (eq_attr "cpu" "pentium")
449 (and (eq_attr "type" "alu,alu1,negnot,ishift")
450 (and (eq_attr "pent_pair" "np")
451 (eq_attr "memory" "both"))))
454 ; Read/Modify or Modify/Write instructions usually take 2 cycles.
455 (define_function_unit "pent_u" 1 0
456 (and (eq_attr "cpu" "pentium")
457 (and (eq_attr "type" "alu,ishift")
458 (and (eq_attr "pent_pair" "pu")
459 (eq_attr "memory" "load,store"))))
462 (define_function_unit "pent_uv" 2 0
463 (and (eq_attr "cpu" "pentium")
464 (and (eq_attr "type" "alu,ishift")
465 (and (eq_attr "pent_pair" "!np")
466 (eq_attr "memory" "load,store"))))
469 (define_function_unit "pent_np" 1 0
470 (and (eq_attr "cpu" "pentium")
471 (and (eq_attr "type" "alu,ishift")
472 (and (eq_attr "pent_pair" "np")
473 (eq_attr "memory" "load,store"))))
476 ; Insns w/o memory operands and move instructions usually take one cycle.
477 (define_function_unit "pent_u" 1 0
478 (and (eq_attr "cpu" "pentium")
479 (eq_attr "pent_pair" "pu"))
482 (define_function_unit "pent_v" 1 0
483 (and (eq_attr "cpu" "pentium")
484 (eq_attr "pent_pair" "pv"))
487 (define_function_unit "pent_uv" 2 0
488 (and (eq_attr "cpu" "pentium")
489 (eq_attr "pent_pair" "!np"))
492 (define_function_unit "pent_np" 1 0
493 (and (eq_attr "cpu" "pentium")
494 (eq_attr "pent_pair" "np"))
497 ; Pairable insns only conflict with other non-pairable insns.
498 (define_function_unit "pent_np" 1 0
499 (and (eq_attr "cpu" "pentium")
500 (and (eq_attr "type" "alu,alu1,ishift")
501 (and (eq_attr "pent_pair" "!np")
502 (eq_attr "memory" "both"))))
504 [(eq_attr "pent_pair" "np")])
506 (define_function_unit "pent_np" 1 0
507 (and (eq_attr "cpu" "pentium")
508 (and (eq_attr "type" "alu,alu1,ishift")
509 (and (eq_attr "pent_pair" "!np")
510 (eq_attr "memory" "load,store"))))
512 [(eq_attr "pent_pair" "np")])
514 (define_function_unit "pent_np" 1 0
515 (and (eq_attr "cpu" "pentium")
516 (eq_attr "pent_pair" "!np"))
518 [(eq_attr "pent_pair" "np")])
520 ; Floating point instructions usually blocks cycle longer when combined with
521 ; integer instructions, because of the inpaired fxch instruction.
522 (define_function_unit "pent_np" 1 0
523 (and (eq_attr "cpu" "pentium")
524 (eq_attr "type" "fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp,fistp"))
526 [(eq_attr "type" "!fmov,fop,fop1,fsgn,fmul,fpspc,fcmov,fcmp,fistp")])
528 (define_function_unit "fpu" 1 0
529 (and (eq_attr "cpu" "pentium")
530 (eq_attr "type" "fcmp,fxch,fsgn"))
533 ; Addition takes 3 cycles; assume other random cruft does as well.
534 ; ??? Trivial fp operations such as fabs or fchs takes only one cycle.
535 (define_function_unit "fpu" 1 0
536 (and (eq_attr "cpu" "pentium")
537 (eq_attr "type" "fop,fop1,fistp"))
540 ; Multiplication takes 3 cycles and is only half pipelined.
541 (define_function_unit "fpu" 1 0
542 (and (eq_attr "cpu" "pentium")
543 (eq_attr "type" "fmul"))
546 (define_function_unit "pent_mul" 1 1
547 (and (eq_attr "cpu" "pentium")
548 (eq_attr "type" "fmul"))
551 ; ??? This is correct only for fdiv and sqrt -- sin/cos take 65-100 cycles.
552 ; They can overlap with integer insns. Only the last two cycles can overlap
553 ; with other fp insns. Only fsin/fcos can overlap with multiplies.
554 ; Only last two cycles of fsin/fcos can overlap with other instructions.
555 (define_function_unit "fpu" 1 0
556 (and (eq_attr "cpu" "pentium")
557 (eq_attr "type" "fdiv"))
560 (define_function_unit "pent_mul" 1 1
561 (and (eq_attr "cpu" "pentium")
562 (eq_attr "type" "fdiv"))
565 (define_function_unit "fpu" 1 0
566 (and (eq_attr "cpu" "pentium")
567 (eq_attr "type" "fpspc"))
570 (define_function_unit "pent_mul" 1 1
571 (and (eq_attr "cpu" "pentium")
572 (eq_attr "type" "fpspc"))
575 ;; Pentium Pro/PII Scheduling
577 ;; The PPro has an out-of-order core, but the instruction decoders are
578 ;; naturally in-order and asymmetric. We get best performance by scheduling
579 ;; for the decoders, for in doing so we give the oo execution unit the
582 ;; Categorize how many uops an ia32 instruction evaluates to:
583 ;; one -- an instruction with 1 uop can be decoded by any of the
585 ;; few -- an instruction with 1 to 4 uops can be decoded only by
587 ;; many -- a complex instruction may take an unspecified number of
588 ;; cycles to decode in decoder 0.
590 (define_attr "ppro_uops" "one,few,many"
591 (cond [(eq_attr "type" "other,multi,call,callv,fpspc,str")
592 (const_string "many")
593 (eq_attr "type" "icmov,fcmov,str,cld")
595 (eq_attr "type" "imov")
596 (if_then_else (eq_attr "memory" "store,both")
598 (const_string "one"))
599 (eq_attr "memory" "!none")
602 (const_string "one")))
604 ;; Rough readiness numbers. Fine tuning happens in i386.c.
606 ;; p0 describes port 0.
607 ;; p01 describes ports 0 and 1 as a pair; alu insns can issue to either.
608 ;; p2 describes port 2 for loads.
609 ;; p34 describes ports 3 and 4 for stores.
610 ;; fpu describes the fpu accessed via port 0.
611 ;; ??? It is less than clear if there are separate fadd and fmul units
612 ;; that could operate in parallel.
614 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
616 (define_function_unit "ppro_p0" 1 0
617 (and (eq_attr "cpu" "pentiumpro")
618 (eq_attr "type" "ishift,lea,ibr,cld"))
621 (define_function_unit "ppro_p0" 1 0
622 (and (eq_attr "cpu" "pentiumpro")
623 (eq_attr "type" "imul"))
626 ;; ??? Does the divider lock out the pipe while it works,
627 ;; or is there a disconnected unit?
628 (define_function_unit "ppro_p0" 1 0
629 (and (eq_attr "cpu" "pentiumpro")
630 (eq_attr "type" "idiv"))
633 (define_function_unit "ppro_p0" 1 0
634 (and (eq_attr "cpu" "pentiumpro")
635 (eq_attr "type" "fop,fop1,fsgn,fistp"))
638 (define_function_unit "ppro_p0" 1 0
639 (and (eq_attr "cpu" "pentiumpro")
640 (eq_attr "type" "fcmov"))
643 (define_function_unit "ppro_p0" 1 0
644 (and (eq_attr "cpu" "pentiumpro")
645 (eq_attr "type" "fcmp"))
648 (define_function_unit "ppro_p0" 1 0
649 (and (eq_attr "cpu" "pentiumpro")
650 (eq_attr "type" "fmov"))
653 (define_function_unit "ppro_p0" 1 0
654 (and (eq_attr "cpu" "pentiumpro")
655 (eq_attr "type" "fmul"))
658 (define_function_unit "ppro_p0" 1 0
659 (and (eq_attr "cpu" "pentiumpro")
660 (eq_attr "type" "fdiv,fpspc"))
663 (define_function_unit "ppro_p01" 2 0
664 (and (eq_attr "cpu" "pentiumpro")
665 (eq_attr "type" "!imov,fmov"))
668 (define_function_unit "ppro_p01" 2 0
669 (and (and (eq_attr "cpu" "pentiumpro")
670 (eq_attr "type" "imov,fmov"))
671 (eq_attr "memory" "none"))
674 (define_function_unit "ppro_p2" 1 0
675 (and (eq_attr "cpu" "pentiumpro")
676 (ior (eq_attr "type" "pop")
677 (eq_attr "memory" "load,both")))
680 (define_function_unit "ppro_p34" 1 0
681 (and (eq_attr "cpu" "pentiumpro")
682 (ior (eq_attr "type" "push")
683 (eq_attr "memory" "store,both")))
686 (define_function_unit "fpu" 1 0
687 (and (eq_attr "cpu" "pentiumpro")
688 (eq_attr "type" "fop,fop1,fsgn,fmov,fcmp,fcmov,fistp"))
691 (define_function_unit "fpu" 1 0
692 (and (eq_attr "cpu" "pentiumpro")
693 (eq_attr "type" "fmul"))
696 (define_function_unit "fpu" 1 0
697 (and (eq_attr "cpu" "pentiumpro")
698 (eq_attr "type" "fdiv,fpspc"))
701 ;; imul uses the fpu. ??? does it have the same throughput as fmul?
702 (define_function_unit "fpu" 1 0
703 (and (eq_attr "cpu" "pentiumpro")
704 (eq_attr "type" "imul"))
707 ;; AMD K6/K6-2 Scheduling
709 ;; The K6 has similar architecture to PPro. Important difference is, that
710 ;; there are only two decoders and they seems to be much slower than execution
711 ;; units. So we have to pay much more attention to proper decoding for
712 ;; schedulers. We share most of scheduler code for PPro in i386.c
714 ;; The fp unit is not pipelined and do one operation per two cycles including
717 ;; alu describes both ALU units (ALU-X and ALU-Y).
718 ;; alux describes X alu unit
719 ;; fpu describes FPU unit
720 ;; load describes load unit.
721 ;; branch describes branch unit.
722 ;; store decsribes store unit. This unit is not modelled completely and only
723 ;; used to model lea operation. Otherwise it lie outside of the critical
726 ;; ??? fxch isn't handled; not an issue until sched3 after reg-stack is real.
728 ;; The decoder specification is in the PPro section above!
730 ;; Shift instructions and certain arithmetic are issued only to X pipe.
731 (define_function_unit "k6_alux" 1 0
732 (and (eq_attr "cpu" "k6")
733 (eq_attr "type" "ishift,alu1,negnot,cld"))
736 ;; The QI mode arithmetic is issued to X pipe only.
737 (define_function_unit "k6_alux" 1 0
738 (and (eq_attr "cpu" "k6")
739 (and (eq_attr "type" "alu,alu1,negnot,icmp,test,imovx,incdec")
740 (match_operand:QI 0 "general_operand" "")))
743 (define_function_unit "k6_alu" 2 0
744 (and (eq_attr "cpu" "k6")
745 (eq_attr "type" "ishift,alu1,negnot,alu,icmp,test,imovx,incdec,setcc,lea"))
748 (define_function_unit "k6_alu" 2 0
749 (and (eq_attr "cpu" "k6")
750 (and (eq_attr "type" "imov")
751 (eq_attr "memory" "none")))
754 (define_function_unit "k6_branch" 1 0
755 (and (eq_attr "cpu" "k6")
756 (eq_attr "type" "call,callv,ibr"))
759 ;; Load unit have two cycle latency, but we take care for it in adjust_cost
760 (define_function_unit "k6_load" 1 0
761 (and (eq_attr "cpu" "k6")
762 (ior (eq_attr "type" "pop")
763 (eq_attr "memory" "load,both")))
766 (define_function_unit "k6_load" 1 0
767 (and (eq_attr "cpu" "k6")
768 (and (eq_attr "type" "str")
769 (eq_attr "memory" "load,both")))
772 ;; Lea have two instructions, so latency is probably 2
773 (define_function_unit "k6_store" 1 0
774 (and (eq_attr "cpu" "k6")
775 (eq_attr "type" "lea"))
778 (define_function_unit "k6_store" 1 0
779 (and (eq_attr "cpu" "k6")
780 (eq_attr "type" "str"))
783 (define_function_unit "k6_store" 1 0
784 (and (eq_attr "cpu" "k6")
785 (ior (eq_attr "type" "push")
786 (eq_attr "memory" "store,both")))
789 (define_function_unit "k6_fpu" 1 1
790 (and (eq_attr "cpu" "k6")
791 (eq_attr "type" "fop,fop1,fmov,fcmp,fistp"))
794 (define_function_unit "k6_fpu" 1 1
795 (and (eq_attr "cpu" "k6")
796 (eq_attr "type" "fmul"))
800 (define_function_unit "k6_fpu" 1 1
801 (and (eq_attr "cpu" "k6")
802 (eq_attr "type" "fdiv,fpspc"))
805 (define_function_unit "k6_alu" 2 0
806 (and (eq_attr "cpu" "k6")
807 (eq_attr "type" "imul"))
810 (define_function_unit "k6_alux" 1 0
811 (and (eq_attr "cpu" "k6")
812 (eq_attr "type" "imul"))
816 (define_function_unit "k6_alu" 2 0
817 (and (eq_attr "cpu" "k6")
818 (eq_attr "type" "idiv"))
821 (define_function_unit "k6_alux" 1 0
822 (and (eq_attr "cpu" "k6")
823 (eq_attr "type" "idiv"))
826 ;; AMD Athlon Scheduling
828 ;; The Athlon does contain three pipelined FP units, three integer units and
829 ;; three address generation units.
831 ;; The predecode logic is determining boundaries of instructions in the 64
832 ;; byte cache line. So the cache line straddling problem of K6 might be issue
833 ;; here as well, but it is not noted in the documentation.
835 ;; Three DirectPath instructions decoders and only one VectorPath decoder
836 ;; is available. They can decode three DirectPath instructions or one VectorPath
837 ;; instruction per cycle.
838 ;; Decoded macro instructions are then passed to 72 entry instruction control
840 ;; it to the specialized integer (18 entry) and fp (36 entry) schedulers.
842 ;; The load/store queue unit is not attached to the schedulers but
843 ;; communicates with all the execution units separately instead.
845 (define_attr "athlon_decode" "direct,vector"
846 (cond [(eq_attr "type" "call,imul,idiv,other,multi,fcmov,fpspc,str,pop,cld,fcmov")
847 (const_string "vector")
848 (and (eq_attr "type" "push")
849 (match_operand 1 "memory_operand" ""))
850 (const_string "vector")
851 (and (eq_attr "type" "fmov")
852 (and (eq_attr "memory" "load,store")
853 (eq_attr "mode" "XF")))
854 (const_string "vector")]
855 (const_string "direct")))
857 (define_function_unit "athlon_vectordec" 1 0
858 (and (eq_attr "cpu" "athlon")
859 (eq_attr "athlon_decode" "vector"))
862 (define_function_unit "athlon_directdec" 3 0
863 (and (eq_attr "cpu" "athlon")
864 (eq_attr "athlon_decode" "direct"))
867 (define_function_unit "athlon_vectordec" 1 0
868 (and (eq_attr "cpu" "athlon")
869 (eq_attr "athlon_decode" "direct"))
870 1 1 [(eq_attr "athlon_decode" "vector")])
872 (define_function_unit "athlon_ieu" 3 0
873 (and (eq_attr "cpu" "athlon")
874 (eq_attr "type" "alu1,negnot,alu,icmp,test,imov,imovx,lea,incdec,ishift,ibr,call,callv,icmov,cld,pop,setcc,push,pop"))
877 (define_function_unit "athlon_ieu" 3 0
878 (and (eq_attr "cpu" "athlon")
879 (eq_attr "type" "str"))
882 (define_function_unit "athlon_ieu" 3 0
883 (and (eq_attr "cpu" "athlon")
884 (eq_attr "type" "imul"))
887 (define_function_unit "athlon_ieu" 3 0
888 (and (eq_attr "cpu" "athlon")
889 (eq_attr "type" "idiv"))
892 (define_function_unit "athlon_muldiv" 1 0
893 (and (eq_attr "cpu" "athlon")
894 (eq_attr "type" "imul"))
897 (define_function_unit "athlon_muldiv" 1 0
898 (and (eq_attr "cpu" "athlon")
899 (eq_attr "type" "idiv"))
902 (define_attr "athlon_fpunits" "none,store,mul,add,muladd,any"
903 (cond [(eq_attr "type" "fop,fop1,fcmp,fistp")
905 (eq_attr "type" "fmul,fdiv,fpspc,fsgn,fcmov")
907 (and (eq_attr "type" "fmov") (eq_attr "memory" "store,both"))
908 (const_string "store")
909 (and (eq_attr "type" "fmov") (eq_attr "memory" "load"))
911 (and (eq_attr "type" "fmov")
912 (ior (match_operand:SI 1 "register_operand" "")
913 (match_operand 1 "immediate_operand" "")))
914 (const_string "store")
915 (eq_attr "type" "fmov")
916 (const_string "muladd")]
917 (const_string "none")))
919 ;; We use latencies 1 for definitions. This is OK to model colisions
920 ;; in execution units. The real latencies are modeled in the "fp" pipeline.
922 ;; fsin, fcos: 96-192
924 ;; fsqrt: 19 for SFmode, 27 for DFmode, 35 for XFmode.
925 (define_function_unit "athlon_fp" 3 0
926 (and (eq_attr "cpu" "athlon")
927 (eq_attr "type" "fpspc"))
930 ;; 16 cycles for SFmode, 20 for DFmode and 24 for XFmode.
931 (define_function_unit "athlon_fp" 3 0
932 (and (eq_attr "cpu" "athlon")
933 (eq_attr "type" "fdiv"))
936 (define_function_unit "athlon_fp" 3 0
937 (and (eq_attr "cpu" "athlon")
938 (eq_attr "type" "fop,fop1,fmul,fistp"))
941 ;; XFmode loads are slow.
942 ;; XFmode store is slow too (8 cycles), but we don't need to model it, because
943 ;; there are no dependent instructions.
945 (define_function_unit "athlon_fp" 3 0
946 (and (eq_attr "cpu" "athlon")
947 (and (eq_attr "type" "fmov")
948 (and (eq_attr "memory" "load")
949 (eq_attr "mode" "XF"))))
952 (define_function_unit "athlon_fp" 3 0
953 (and (eq_attr "cpu" "athlon")
954 (eq_attr "type" "fmov,fsgn"))
957 ;; fcmp and ftst instructions
958 (define_function_unit "athlon_fp" 3 0
959 (and (eq_attr "cpu" "athlon")
960 (and (eq_attr "type" "fcmp")
961 (eq_attr "athlon_decode" "direct")))
964 ;; fcmpi instructions.
965 (define_function_unit "athlon_fp" 3 0
966 (and (eq_attr "cpu" "athlon")
967 (and (eq_attr "type" "fcmp")
968 (eq_attr "athlon_decode" "vector")))
971 (define_function_unit "athlon_fp" 3 0
972 (and (eq_attr "cpu" "athlon")
973 (eq_attr "type" "fcmov"))
976 (define_function_unit "athlon_fp_mul" 1 0
977 (and (eq_attr "cpu" "athlon")
978 (eq_attr "athlon_fpunits" "mul"))
981 (define_function_unit "athlon_fp_add" 1 0
982 (and (eq_attr "cpu" "athlon")
983 (eq_attr "athlon_fpunits" "add"))
986 (define_function_unit "athlon_fp_muladd" 2 0
987 (and (eq_attr "cpu" "athlon")
988 (eq_attr "athlon_fpunits" "muladd,mul,add"))
991 (define_function_unit "athlon_fp_store" 1 0
992 (and (eq_attr "cpu" "athlon")
993 (eq_attr "athlon_fpunits" "store"))
996 ;; We don't need to model the Address Generation Unit, since we don't model
997 ;; the re-order buffer yet and thus we never schedule more than three operations
998 ;; at time. Later we may want to experiment with MD_SCHED macros modeling the
999 ;; decoders independently on the functional units.
1001 ;(define_function_unit "athlon_agu" 3 0
1002 ; (and (eq_attr "cpu" "athlon")
1003 ; (and (eq_attr "memory" "!none")
1004 ; (eq_attr "athlon_fpunits" "none")))
1007 ;; Model load unit to avoid too long sequences of loads. We don't need to
1008 ;; model store queue, since it is hardly going to be bottleneck.
1010 (define_function_unit "athlon_load" 2 0
1011 (and (eq_attr "cpu" "athlon")
1012 (eq_attr "memory" "load,both"))
1016 ;; Compare instructions.
1018 ;; All compare insns have expanders that save the operands away without
1019 ;; actually generating RTL. The bCOND or sCOND (emitted immediately
1020 ;; after the cmp) will actually emit the cmpM.
1022 (define_expand "cmpdi"
1024 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
1025 (match_operand:DI 1 "x86_64_general_operand" "")))]
1028 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1029 operands[0] = force_reg (DImode, operands[0]);
1030 ix86_compare_op0 = operands[0];
1031 ix86_compare_op1 = operands[1];
1035 (define_expand "cmpsi"
1037 (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
1038 (match_operand:SI 1 "general_operand" "")))]
1041 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1042 operands[0] = force_reg (SImode, operands[0]);
1043 ix86_compare_op0 = operands[0];
1044 ix86_compare_op1 = operands[1];
1048 (define_expand "cmphi"
1050 (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
1051 (match_operand:HI 1 "general_operand" "")))]
1054 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1055 operands[0] = force_reg (HImode, operands[0]);
1056 ix86_compare_op0 = operands[0];
1057 ix86_compare_op1 = operands[1];
1061 (define_expand "cmpqi"
1063 (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
1064 (match_operand:QI 1 "general_operand" "")))]
1065 "TARGET_QIMODE_MATH"
1067 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1068 operands[0] = force_reg (QImode, operands[0]);
1069 ix86_compare_op0 = operands[0];
1070 ix86_compare_op1 = operands[1];
1074 (define_insn "cmpdi_ccno_1_rex64"
1076 (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
1077 (match_operand:DI 1 "const0_operand" "n,n")))]
1078 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
1080 test{q}\t{%0, %0|%0, %0}
1081 cmp{q}\t{%1, %0|%0, %1}"
1082 [(set_attr "type" "test,icmp")
1083 (set_attr "length_immediate" "0,1")
1084 (set_attr "mode" "DI")])
1086 (define_insn "*cmpdi_minus_1_rex64"
1088 (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
1089 (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
1091 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
1092 "cmp{q}\t{%1, %0|%0, %1}"
1093 [(set_attr "type" "icmp")
1094 (set_attr "mode" "DI")])
1096 (define_expand "cmpdi_1_rex64"
1098 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
1099 (match_operand:DI 1 "general_operand" "")))]
1103 (define_insn "cmpdi_1_insn_rex64"
1105 (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
1106 (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
1107 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1108 "cmp{q}\t{%1, %0|%0, %1}"
1109 [(set_attr "type" "icmp")
1110 (set_attr "mode" "DI")])
1113 (define_insn "*cmpsi_ccno_1"
1115 (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
1116 (match_operand:SI 1 "const0_operand" "n,n")))]
1117 "ix86_match_ccmode (insn, CCNOmode)"
1119 test{l}\t{%0, %0|%0, %0}
1120 cmp{l}\t{%1, %0|%0, %1}"
1121 [(set_attr "type" "test,icmp")
1122 (set_attr "length_immediate" "0,1")
1123 (set_attr "mode" "SI")])
1125 (define_insn "*cmpsi_minus_1"
1127 (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1128 (match_operand:SI 1 "general_operand" "ri,mr"))
1130 "ix86_match_ccmode (insn, CCGOCmode)"
1131 "cmp{l}\t{%1, %0|%0, %1}"
1132 [(set_attr "type" "icmp")
1133 (set_attr "mode" "SI")])
1135 (define_expand "cmpsi_1"
1137 (compare:CC (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1138 (match_operand:SI 1 "general_operand" "ri,mr")))]
1142 (define_insn "*cmpsi_1_insn"
1144 (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1145 (match_operand:SI 1 "general_operand" "ri,mr")))]
1146 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1147 && ix86_match_ccmode (insn, CCmode)"
1148 "cmp{l}\t{%1, %0|%0, %1}"
1149 [(set_attr "type" "icmp")
1150 (set_attr "mode" "SI")])
1152 (define_insn "*cmphi_ccno_1"
1154 (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
1155 (match_operand:HI 1 "const0_operand" "n,n")))]
1156 "ix86_match_ccmode (insn, CCNOmode)"
1158 test{w}\t{%0, %0|%0, %0}
1159 cmp{w}\t{%1, %0|%0, %1}"
1160 [(set_attr "type" "test,icmp")
1161 (set_attr "length_immediate" "0,1")
1162 (set_attr "mode" "HI")])
1164 (define_insn "*cmphi_minus_1"
1166 (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1167 (match_operand:HI 1 "general_operand" "ri,mr"))
1169 "ix86_match_ccmode (insn, CCGOCmode)"
1170 "cmp{w}\t{%1, %0|%0, %1}"
1171 [(set_attr "type" "icmp")
1172 (set_attr "mode" "HI")])
1174 (define_insn "*cmphi_1"
1176 (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1177 (match_operand:HI 1 "general_operand" "ri,mr")))]
1178 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1179 && ix86_match_ccmode (insn, CCmode)"
1180 "cmp{w}\t{%1, %0|%0, %1}"
1181 [(set_attr "type" "icmp")
1182 (set_attr "mode" "HI")])
1184 (define_insn "*cmpqi_ccno_1"
1186 (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
1187 (match_operand:QI 1 "const0_operand" "n,n")))]
1188 "ix86_match_ccmode (insn, CCNOmode)"
1190 test{b}\t{%0, %0|%0, %0}
1191 cmp{b}\t{$0, %0|%0, 0}"
1192 [(set_attr "type" "test,icmp")
1193 (set_attr "length_immediate" "0,1")
1194 (set_attr "mode" "QI")])
1196 (define_insn "*cmpqi_1"
1198 (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1199 (match_operand:QI 1 "general_operand" "qi,mq")))]
1200 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
1201 && ix86_match_ccmode (insn, CCmode)"
1202 "cmp{b}\t{%1, %0|%0, %1}"
1203 [(set_attr "type" "icmp")
1204 (set_attr "mode" "QI")])
1206 (define_insn "*cmpqi_minus_1"
1208 (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1209 (match_operand:QI 1 "general_operand" "qi,mq"))
1211 "ix86_match_ccmode (insn, CCGOCmode)"
1212 "cmp{b}\t{%1, %0|%0, %1}"
1213 [(set_attr "type" "icmp")
1214 (set_attr "mode" "QI")])
1216 (define_insn "*cmpqi_ext_1"
1219 (match_operand:QI 0 "general_operand" "Qm")
1222 (match_operand 1 "ext_register_operand" "Q")
1224 (const_int 8)) 0)))]
1225 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1226 "cmp{b}\t{%h1, %0|%0, %h1}"
1227 [(set_attr "type" "icmp")
1228 (set_attr "mode" "QI")])
1230 (define_insn "*cmpqi_ext_1_rex64"
1233 (match_operand:QI 0 "register_operand" "Q")
1236 (match_operand 1 "ext_register_operand" "Q")
1238 (const_int 8)) 0)))]
1239 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1240 "cmp{b}\t{%h1, %0|%0, %h1}"
1241 [(set_attr "type" "icmp")
1242 (set_attr "mode" "QI")])
1244 (define_insn "*cmpqi_ext_2"
1249 (match_operand 0 "ext_register_operand" "Q")
1252 (match_operand:QI 1 "const0_operand" "n")))]
1253 "ix86_match_ccmode (insn, CCNOmode)"
1255 [(set_attr "type" "test")
1256 (set_attr "length_immediate" "0")
1257 (set_attr "mode" "QI")])
1259 (define_expand "cmpqi_ext_3"
1264 (match_operand 0 "ext_register_operand" "")
1267 (match_operand:QI 1 "general_operand" "")))]
1271 (define_insn "cmpqi_ext_3_insn"
1276 (match_operand 0 "ext_register_operand" "Q")
1279 (match_operand:QI 1 "general_operand" "Qmn")))]
1280 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1281 "cmp{b}\t{%1, %h0|%h0, %1}"
1282 [(set_attr "type" "icmp")
1283 (set_attr "mode" "QI")])
1285 (define_insn "cmpqi_ext_3_insn_rex64"
1290 (match_operand 0 "ext_register_operand" "Q")
1293 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1294 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1295 "cmp{b}\t{%1, %h0|%h0, %1}"
1296 [(set_attr "type" "icmp")
1297 (set_attr "mode" "QI")])
1299 (define_insn "*cmpqi_ext_4"
1304 (match_operand 0 "ext_register_operand" "Q")
1309 (match_operand 1 "ext_register_operand" "Q")
1311 (const_int 8)) 0)))]
1312 "ix86_match_ccmode (insn, CCmode)"
1313 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1314 [(set_attr "type" "icmp")
1315 (set_attr "mode" "QI")])
1317 ;; These implement float point compares.
1318 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1319 ;; which would allow mix and match FP modes on the compares. Which is what
1320 ;; the old patterns did, but with many more of them.
1322 (define_expand "cmpxf"
1324 (compare:CC (match_operand:XF 0 "cmp_fp_expander_operand" "")
1325 (match_operand:XF 1 "cmp_fp_expander_operand" "")))]
1326 "!TARGET_64BIT && TARGET_80387"
1328 ix86_compare_op0 = operands[0];
1329 ix86_compare_op1 = operands[1];
1333 (define_expand "cmptf"
1335 (compare:CC (match_operand:TF 0 "cmp_fp_expander_operand" "")
1336 (match_operand:TF 1 "cmp_fp_expander_operand" "")))]
1339 ix86_compare_op0 = operands[0];
1340 ix86_compare_op1 = operands[1];
1344 (define_expand "cmpdf"
1346 (compare:CC (match_operand:DF 0 "cmp_fp_expander_operand" "")
1347 (match_operand:DF 1 "cmp_fp_expander_operand" "")))]
1348 "TARGET_80387 || TARGET_SSE2"
1350 ix86_compare_op0 = operands[0];
1351 ix86_compare_op1 = operands[1];
1355 (define_expand "cmpsf"
1357 (compare:CC (match_operand:SF 0 "cmp_fp_expander_operand" "")
1358 (match_operand:SF 1 "cmp_fp_expander_operand" "")))]
1359 "TARGET_80387 || TARGET_SSE"
1361 ix86_compare_op0 = operands[0];
1362 ix86_compare_op1 = operands[1];
1366 ;; FP compares, step 1:
1367 ;; Set the FP condition codes.
1369 ;; CCFPmode compare with exceptions
1370 ;; CCFPUmode compare with no exceptions
1372 ;; %%% It is an unfortunate fact that ftst has no non-popping variant,
1373 ;; and that fp moves clobber the condition codes, and that there is
1374 ;; currently no way to describe this fact to reg-stack. So there are
1375 ;; no splitters yet for this.
1377 ;; %%% YIKES! This scheme does not retain a strong connection between
1378 ;; the real compare and the ultimate cc0 user, so CC_REVERSE does not
1379 ;; work! Only allow tos/mem with tos in op 0.
1381 ;; Hmm, of course, this is what the actual _hardware_ does. Perhaps
1382 ;; things aren't as bad as they sound...
1384 (define_insn "*cmpfp_0"
1385 [(set (match_operand:HI 0 "register_operand" "=a")
1387 [(compare:CCFP (match_operand 1 "register_operand" "f")
1388 (match_operand 2 "const0_operand" "X"))] 9))]
1390 && FLOAT_MODE_P (GET_MODE (operands[1]))
1391 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1393 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
1394 return "ftst\;fnstsw\t%0\;fstp\t%y0";
1396 return "ftst\;fnstsw\t%0";
1398 [(set_attr "type" "multi")
1399 (set_attr "mode" "unknownfp")])
1401 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1402 ;; used to manage the reg stack popping would not be preserved.
1404 (define_insn "*cmpfp_2_sf"
1407 (match_operand:SF 0 "register_operand" "f")
1408 (match_operand:SF 1 "nonimmediate_operand" "fm")))]
1410 "* return output_fp_compare (insn, operands, 0, 0);"
1411 [(set_attr "type" "fcmp")
1412 (set_attr "mode" "SF")])
1414 (define_insn "*cmpfp_2_sf_1"
1415 [(set (match_operand:HI 0 "register_operand" "=a")
1418 (match_operand:SF 1 "register_operand" "f")
1419 (match_operand:SF 2 "nonimmediate_operand" "fm"))] 9))]
1421 "* return output_fp_compare (insn, operands, 2, 0);"
1422 [(set_attr "type" "fcmp")
1423 (set_attr "mode" "SF")])
1425 (define_insn "*cmpfp_2_df"
1428 (match_operand:DF 0 "register_operand" "f")
1429 (match_operand:DF 1 "nonimmediate_operand" "fm")))]
1431 "* return output_fp_compare (insn, operands, 0, 0);"
1432 [(set_attr "type" "fcmp")
1433 (set_attr "mode" "DF")])
1435 (define_insn "*cmpfp_2_df_1"
1436 [(set (match_operand:HI 0 "register_operand" "=a")
1439 (match_operand:DF 1 "register_operand" "f")
1440 (match_operand:DF 2 "nonimmediate_operand" "fm"))] 9))]
1442 "* return output_fp_compare (insn, operands, 2, 0);"
1443 [(set_attr "type" "multi")
1444 (set_attr "mode" "DF")])
1446 (define_insn "*cmpfp_2_xf"
1449 (match_operand:XF 0 "register_operand" "f")
1450 (match_operand:XF 1 "register_operand" "f")))]
1451 "!TARGET_64BIT && TARGET_80387"
1452 "* return output_fp_compare (insn, operands, 0, 0);"
1453 [(set_attr "type" "fcmp")
1454 (set_attr "mode" "XF")])
1456 (define_insn "*cmpfp_2_tf"
1459 (match_operand:TF 0 "register_operand" "f")
1460 (match_operand:TF 1 "register_operand" "f")))]
1462 "* return output_fp_compare (insn, operands, 0, 0);"
1463 [(set_attr "type" "fcmp")
1464 (set_attr "mode" "XF")])
1466 (define_insn "*cmpfp_2_xf_1"
1467 [(set (match_operand:HI 0 "register_operand" "=a")
1470 (match_operand:XF 1 "register_operand" "f")
1471 (match_operand:XF 2 "register_operand" "f"))] 9))]
1472 "!TARGET_64BIT && TARGET_80387"
1473 "* return output_fp_compare (insn, operands, 2, 0);"
1474 [(set_attr "type" "multi")
1475 (set_attr "mode" "XF")])
1477 (define_insn "*cmpfp_2_tf_1"
1478 [(set (match_operand:HI 0 "register_operand" "=a")
1481 (match_operand:TF 1 "register_operand" "f")
1482 (match_operand:TF 2 "register_operand" "f"))] 9))]
1484 "* return output_fp_compare (insn, operands, 2, 0);"
1485 [(set_attr "type" "multi")
1486 (set_attr "mode" "XF")])
1488 (define_insn "*cmpfp_2u"
1489 [(set (reg:CCFPU 18)
1491 (match_operand 0 "register_operand" "f")
1492 (match_operand 1 "register_operand" "f")))]
1494 && FLOAT_MODE_P (GET_MODE (operands[0]))
1495 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1496 "* return output_fp_compare (insn, operands, 0, 1);"
1497 [(set_attr "type" "fcmp")
1498 (set_attr "mode" "unknownfp")])
1500 (define_insn "*cmpfp_2u_1"
1501 [(set (match_operand:HI 0 "register_operand" "=a")
1504 (match_operand 1 "register_operand" "f")
1505 (match_operand 2 "register_operand" "f"))] 9))]
1507 && FLOAT_MODE_P (GET_MODE (operands[1]))
1508 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1509 "* return output_fp_compare (insn, operands, 2, 1);"
1510 [(set_attr "type" "multi")
1511 (set_attr "mode" "unknownfp")])
1513 ;; Patterns to match the SImode-in-memory ficom instructions.
1515 ;; %%% Play games with accepting gp registers, as otherwise we have to
1516 ;; force them to memory during rtl generation, which is no good. We
1517 ;; can get rid of this once we teach reload to do memory input reloads
1520 (define_insn "*ficom_1"
1523 (match_operand 0 "register_operand" "f,f")
1524 (float (match_operand:SI 1 "nonimmediate_operand" "m,?r"))))]
1525 "0 && TARGET_80387 && FLOAT_MODE_P (GET_MODE (operands[0]))
1526 && GET_MODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == GET_MODE (operands[0])"
1529 ;; Split the not-really-implemented gp register case into a
1530 ;; push-op-pop sequence.
1532 ;; %%% This is most efficient, but am I gonna get in trouble
1533 ;; for separating cc0_setter and cc0_user?
1538 (match_operand:SF 0 "register_operand" "")
1539 (float (match_operand:SI 1 "register_operand" ""))))]
1540 "0 && TARGET_80387 && reload_completed"
1541 [(set (mem:SI (pre_dec:SI (reg:SI 7))) (match_dup 1))
1542 (set (reg:CCFP 18) (compare:CCFP (match_dup 0) (match_dup 2)))
1543 (parallel [(set (match_dup 1) (mem:SI (reg:SI 7)))
1544 (set (reg:SI 7) (plus:SI (reg:SI 7) (const_int 4)))])]
1545 "operands[2] = gen_rtx_MEM (Pmode, stack_pointer_rtx);
1546 operands[2] = gen_rtx_FLOAT (GET_MODE (operands[0]), operands[2]);")
1548 ;; FP compares, step 2
1549 ;; Move the fpsw to ax.
1551 (define_insn "x86_fnstsw_1"
1552 [(set (match_operand:HI 0 "register_operand" "=a")
1553 (unspec:HI [(reg 18)] 9))]
1556 [(set_attr "length" "2")
1557 (set_attr "mode" "SI")
1558 (set_attr "i387" "1")
1559 (set_attr "ppro_uops" "few")])
1561 ;; FP compares, step 3
1562 ;; Get ax into flags, general case.
1564 (define_insn "x86_sahf_1"
1566 (unspec:CC [(match_operand:HI 0 "register_operand" "a")] 10))]
1569 [(set_attr "length" "1")
1570 (set_attr "athlon_decode" "vector")
1571 (set_attr "mode" "SI")
1572 (set_attr "ppro_uops" "one")])
1574 ;; Pentium Pro can do steps 1 through 3 in one go.
1576 (define_insn "*cmpfp_i"
1578 (compare:CCFP (match_operand 0 "register_operand" "f")
1579 (match_operand 1 "register_operand" "f")))]
1580 "TARGET_80387 && TARGET_CMOVE
1581 && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1582 && FLOAT_MODE_P (GET_MODE (operands[0]))
1583 && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1584 "* return output_fp_compare (insn, operands, 1, 0);"
1585 [(set_attr "type" "fcmp")
1586 (set_attr "mode" "unknownfp")
1587 (set_attr "athlon_decode" "vector")])
1589 (define_insn "*cmpfp_i_sse"
1591 (compare:CCFP (match_operand 0 "register_operand" "f#x,x#f")
1592 (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1594 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1595 && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1596 "* return output_fp_compare (insn, operands, 1, 0);"
1597 [(set_attr "type" "fcmp,sse")
1598 (set_attr "mode" "unknownfp")
1599 (set_attr "athlon_decode" "vector")])
1601 (define_insn "*cmpfp_i_sse_only"
1603 (compare:CCFP (match_operand 0 "register_operand" "x")
1604 (match_operand 1 "nonimmediate_operand" "xm")))]
1605 "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1606 && GET_MODE (operands[0]) == GET_MODE (operands[0])"
1607 "* return output_fp_compare (insn, operands, 1, 0);"
1608 [(set_attr "type" "sse")
1609 (set_attr "mode" "unknownfp")
1610 (set_attr "athlon_decode" "vector")])
1612 (define_insn "*cmpfp_iu"
1613 [(set (reg:CCFPU 17)
1614 (compare:CCFPU (match_operand 0 "register_operand" "f")
1615 (match_operand 1 "register_operand" "f")))]
1616 "TARGET_80387 && TARGET_CMOVE
1617 && !SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1618 && FLOAT_MODE_P (GET_MODE (operands[0]))
1619 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1620 "* return output_fp_compare (insn, operands, 1, 1);"
1621 [(set_attr "type" "fcmp")
1622 (set_attr "mode" "unknownfp")
1623 (set_attr "athlon_decode" "vector")])
1625 (define_insn "*cmpfp_iu_sse"
1626 [(set (reg:CCFPU 17)
1627 (compare:CCFPU (match_operand 0 "register_operand" "f#x,x#f")
1628 (match_operand 1 "nonimmediate_operand" "f#x,xm#f")))]
1630 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1631 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1632 "* return output_fp_compare (insn, operands, 1, 1);"
1633 [(set_attr "type" "fcmp,sse")
1634 (set_attr "mode" "unknownfp")
1635 (set_attr "athlon_decode" "vector")])
1637 (define_insn "*cmpfp_iu_sse_only"
1638 [(set (reg:CCFPU 17)
1639 (compare:CCFPU (match_operand 0 "register_operand" "x")
1640 (match_operand 1 "nonimmediate_operand" "xm")))]
1641 "SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1642 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1643 "* return output_fp_compare (insn, operands, 1, 1);"
1644 [(set_attr "type" "sse")
1645 (set_attr "mode" "unknownfp")
1646 (set_attr "athlon_decode" "vector")])
1648 ;; Move instructions.
1650 ;; General case of fullword move.
1652 (define_expand "movsi"
1653 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1654 (match_operand:SI 1 "general_operand" ""))]
1656 "ix86_expand_move (SImode, operands); DONE;")
1658 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1661 ;; %%% We don't use a post-inc memory reference because x86 is not a
1662 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1663 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1664 ;; targets without our curiosities, and it is just as easy to represent
1665 ;; this differently.
1667 (define_insn "*pushsi2"
1668 [(set (match_operand:SI 0 "push_operand" "=<")
1669 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1672 [(set_attr "type" "push")
1673 (set_attr "mode" "SI")])
1675 ;; For 64BIT abi we always round up to 8 bytes.
1676 (define_insn "*pushsi2_rex64"
1677 [(set (match_operand:SI 0 "push_operand" "=X")
1678 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1681 [(set_attr "type" "push")
1682 (set_attr "mode" "SI")])
1684 (define_insn "*pushsi2_prologue"
1685 [(set (match_operand:SI 0 "push_operand" "=<")
1686 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1687 (clobber (mem:BLK (scratch)))]
1690 [(set_attr "type" "push")
1691 (set_attr "mode" "SI")])
1693 (define_insn "*popsi1_epilogue"
1694 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1695 (mem:SI (reg:SI 7)))
1697 (plus:SI (reg:SI 7) (const_int 4)))
1698 (clobber (mem:BLK (scratch)))]
1701 [(set_attr "type" "pop")
1702 (set_attr "mode" "SI")])
1704 (define_insn "popsi1"
1705 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1706 (mem:SI (reg:SI 7)))
1708 (plus:SI (reg:SI 7) (const_int 4)))]
1711 [(set_attr "type" "pop")
1712 (set_attr "mode" "SI")])
1714 (define_insn "*movsi_xor"
1715 [(set (match_operand:SI 0 "register_operand" "=r")
1716 (match_operand:SI 1 "const0_operand" "i"))
1717 (clobber (reg:CC 17))]
1718 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1719 "xor{l}\t{%0, %0|%0, %0}"
1720 [(set_attr "type" "alu1")
1721 (set_attr "mode" "SI")
1722 (set_attr "length_immediate" "0")])
1724 (define_insn "*movsi_or"
1725 [(set (match_operand:SI 0 "register_operand" "=r")
1726 (match_operand:SI 1 "immediate_operand" "i"))
1727 (clobber (reg:CC 17))]
1728 "reload_completed && GET_CODE (operands[1]) == CONST_INT
1729 && INTVAL (operands[1]) == -1
1730 && (TARGET_PENTIUM || optimize_size)"
1732 operands[1] = constm1_rtx;
1733 return "or{l}\t{%1, %0|%0, %1}";
1735 [(set_attr "type" "alu1")
1736 (set_attr "mode" "SI")
1737 (set_attr "length_immediate" "1")])
1739 (define_insn "*movsi_1"
1740 [(set (match_operand:SI 0 "nonimmediate_operand" "=*a,r,*a,m,!*y,!rm,!*Y,!rm,!*Y")
1741 (match_operand:SI 1 "general_operand" "im,rinm,rinm,rin,rm,*y,rm,*Y,*Y"))]
1742 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1744 switch (get_attr_type (insn))
1747 if (get_attr_mode (insn) == TImode)
1748 return "movdqa\t{%1, %0|%0, %1}";
1749 return "movd\t{%1, %0|%0, %1}";
1752 return "movd\t{%1, %0|%0, %1}";
1755 return "lea{l}\t{%1, %0|%0, %1}";
1758 if (flag_pic && SYMBOLIC_CONST (operands[1]))
1760 return "mov{l}\t{%1, %0|%0, %1}";
1764 (cond [(eq_attr "alternative" "4,5")
1765 (const_string "mmx")
1766 (eq_attr "alternative" "6,7,8")
1767 (const_string "sse")
1768 (and (ne (symbol_ref "flag_pic") (const_int 0))
1769 (match_operand:SI 1 "symbolic_operand" ""))
1770 (const_string "lea")
1772 (const_string "imov")))
1773 (set_attr "modrm" "0,*,0,*,*,*,*,*,*")
1774 (set_attr "mode" "SI,SI,SI,SI,SI,SI,TI,SI,SI")])
1776 ;; Stores and loads of ax to arbitary constant address.
1777 ;; We fake an second form of instruction to force reload to load address
1778 ;; into register when rax is not available
1779 (define_insn "*movabssi_1_rex64"
1780 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1781 (match_operand:SI 1 "nonmemory_operand" "a,er,i"))]
1784 movabs{l}\t{%1, %P0|%P0, %1}
1785 mov{l}\t{%1, %a0|%a0, %1}
1786 movabs{l}\t{%1, %a0|%a0, %1}"
1787 [(set_attr "type" "imov")
1788 (set_attr "modrm" "0,*,*")
1789 (set_attr "length_address" "8,0,0")
1790 (set_attr "length_immediate" "0,*,*")
1791 (set_attr "memory" "store")
1792 (set_attr "mode" "SI")])
1794 (define_insn "*movabssi_2_rex64"
1795 [(set (match_operand:SI 0 "register_operand" "=a,r")
1796 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1799 movabs{l}\t{%P1, %0|%0, %P1}
1800 mov{l}\t{%a1, %0|%0, %a1}"
1801 [(set_attr "type" "imov")
1802 (set_attr "modrm" "0,*")
1803 (set_attr "length_address" "8,0")
1804 (set_attr "length_immediate" "0")
1805 (set_attr "memory" "load")
1806 (set_attr "mode" "SI")])
1808 (define_insn "*swapsi"
1809 [(set (match_operand:SI 0 "register_operand" "+r")
1810 (match_operand:SI 1 "register_operand" "+r"))
1815 [(set_attr "type" "imov")
1816 (set_attr "pent_pair" "np")
1817 (set_attr "athlon_decode" "vector")
1818 (set_attr "mode" "SI")
1819 (set_attr "modrm" "0")
1820 (set_attr "ppro_uops" "few")])
1822 (define_expand "movhi"
1823 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1824 (match_operand:HI 1 "general_operand" ""))]
1826 "ix86_expand_move (HImode, operands); DONE;")
1828 (define_insn "*pushhi2"
1829 [(set (match_operand:HI 0 "push_operand" "=<,<")
1830 (match_operand:HI 1 "general_no_elim_operand" "n,r*m"))]
1833 push{w}\t{|WORD PTR }%1
1835 [(set_attr "type" "push")
1836 (set_attr "mode" "HI")])
1838 ;; For 64BIT abi we always round up to 8 bytes.
1839 (define_insn "*pushhi2_rex64"
1840 [(set (match_operand:HI 0 "push_operand" "=X")
1841 (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1844 [(set_attr "type" "push")
1845 (set_attr "mode" "QI")])
1847 (define_insn "*movhi_1"
1848 [(set (match_operand:HI 0 "nonimmediate_operand" "=*a,r,r,*a,r,m")
1849 (match_operand:HI 1 "general_operand" "i,r,rn,rm,rm,rn"))]
1850 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1852 switch (get_attr_type (insn))
1855 /* movzwl is faster than movw on p2 due to partial word stalls,
1856 though not as fast as an aligned movl. */
1857 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1859 if (get_attr_mode (insn) == MODE_SI)
1860 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1862 return "mov{w}\t{%1, %0|%0, %1}";
1866 (cond [(and (eq_attr "alternative" "0,1")
1867 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1869 (eq (symbol_ref "TARGET_HIMODE_MATH")
1871 (const_string "imov")
1872 (and (eq_attr "alternative" "2,3,4")
1873 (match_operand:HI 1 "aligned_operand" ""))
1874 (const_string "imov")
1875 (and (ne (symbol_ref "TARGET_MOVX")
1877 (eq_attr "alternative" "0,1,3,4"))
1878 (const_string "imovx")
1880 (const_string "imov")))
1882 (cond [(eq_attr "type" "imovx")
1884 (and (eq_attr "alternative" "2,3,4")
1885 (match_operand:HI 1 "aligned_operand" ""))
1887 (and (eq_attr "alternative" "0,1")
1888 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1890 (eq (symbol_ref "TARGET_HIMODE_MATH")
1894 (const_string "HI")))
1895 (set_attr "modrm" "0,*,*,0,*,*")])
1897 ;; Stores and loads of ax to arbitary constant address.
1898 ;; We fake an second form of instruction to force reload to load address
1899 ;; into register when rax is not available
1900 (define_insn "*movabshi_1_rex64"
1901 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
1902 (match_operand:HI 1 "nonmemory_operand" "a,er,i"))]
1905 movabs{w}\t{%1, %P0|%P0, %1}
1906 mov{w}\t{%1, %a0|%a0, %1}
1907 movabs{w}\t{%1, %a0|%a0, %1}"
1908 [(set_attr "type" "imov")
1909 (set_attr "modrm" "0,*,*")
1910 (set_attr "length_address" "8,0,0")
1911 (set_attr "length_immediate" "0,*,*")
1912 (set_attr "memory" "store")
1913 (set_attr "mode" "HI")])
1915 (define_insn "*movabshi_2_rex64"
1916 [(set (match_operand:HI 0 "register_operand" "=a,r")
1917 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1920 movabs{w}\t{%P1, %0|%0, %P1}
1921 mov{w}\t{%a1, %0|%0, %a1}"
1922 [(set_attr "type" "imov")
1923 (set_attr "modrm" "0,*")
1924 (set_attr "length_address" "8,0")
1925 (set_attr "length_immediate" "0")
1926 (set_attr "memory" "load")
1927 (set_attr "mode" "HI")])
1929 (define_insn "*swaphi_1"
1930 [(set (match_operand:HI 0 "register_operand" "+r")
1931 (match_operand:HI 1 "register_operand" "+r"))
1934 "TARGET_PARTIAL_REG_STALL"
1936 [(set_attr "type" "imov")
1937 (set_attr "pent_pair" "np")
1938 (set_attr "mode" "HI")
1939 (set_attr "modrm" "0")
1940 (set_attr "ppro_uops" "few")])
1942 (define_insn "*swaphi_2"
1943 [(set (match_operand:HI 0 "register_operand" "+r")
1944 (match_operand:HI 1 "register_operand" "+r"))
1947 "! TARGET_PARTIAL_REG_STALL"
1949 [(set_attr "type" "imov")
1950 (set_attr "pent_pair" "np")
1951 (set_attr "mode" "SI")
1952 (set_attr "modrm" "0")
1953 (set_attr "ppro_uops" "few")])
1955 (define_expand "movstricthi"
1956 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1957 (match_operand:HI 1 "general_operand" ""))]
1958 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1960 /* Don't generate memory->memory moves, go through a register */
1961 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
1962 operands[1] = force_reg (HImode, operands[1]);
1965 (define_insn "*movstricthi_1"
1966 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1967 (match_operand:HI 1 "general_operand" "rn,m"))]
1968 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1969 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
1970 "mov{w}\t{%1, %0|%0, %1}"
1971 [(set_attr "type" "imov")
1972 (set_attr "mode" "HI")])
1974 (define_insn "*movstricthi_xor"
1975 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1976 (match_operand:HI 1 "const0_operand" "i"))
1977 (clobber (reg:CC 17))]
1979 && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
1980 "xor{w}\t{%0, %0|%0, %0}"
1981 [(set_attr "type" "alu1")
1982 (set_attr "mode" "HI")
1983 (set_attr "length_immediate" "0")])
1985 (define_expand "movqi"
1986 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1987 (match_operand:QI 1 "general_operand" ""))]
1989 "ix86_expand_move (QImode, operands); DONE;")
1991 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1992 ;; "push a byte". But actually we use pushw, which has the effect
1993 ;; of rounding the amount pushed up to a halfword.
1995 (define_insn "*pushqi2"
1996 [(set (match_operand:QI 0 "push_operand" "=X,X")
1997 (match_operand:QI 1 "nonmemory_no_elim_operand" "n,r"))]
2000 push{w}\t{|word ptr }%1
2002 [(set_attr "type" "push")
2003 (set_attr "mode" "HI")])
2005 ;; For 64BIT abi we always round up to 8 bytes.
2006 (define_insn "*pushqi2_rex64"
2007 [(set (match_operand:QI 0 "push_operand" "=X")
2008 (match_operand:QI 1 "nonmemory_no_elim_operand" "ri"))]
2011 [(set_attr "type" "push")
2012 (set_attr "mode" "QI")])
2014 ;; Situation is quite tricky about when to choose full sized (SImode) move
2015 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2016 ;; partial register dependency machines (such as AMD Athlon), where QImode
2017 ;; moves issue extra dependency and for partial register stalls machines
2018 ;; that don't use QImode patterns (and QImode move cause stall on the next
2021 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2022 ;; register stall machines with, where we use QImode instructions, since
2023 ;; partial register stall can be caused there. Then we use movzx.
2024 (define_insn "*movqi_1"
2025 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2026 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2027 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
2029 switch (get_attr_type (insn))
2032 if (!ANY_QI_REG_P (operands[1]) && GET_CODE (operands[1]) != MEM)
2034 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2036 if (get_attr_mode (insn) == MODE_SI)
2037 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2039 return "mov{b}\t{%1, %0|%0, %1}";
2043 (cond [(and (eq_attr "alternative" "3")
2044 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2046 (eq (symbol_ref "TARGET_QIMODE_MATH")
2048 (const_string "imov")
2049 (eq_attr "alternative" "3,5")
2050 (const_string "imovx")
2051 (and (ne (symbol_ref "TARGET_MOVX")
2053 (eq_attr "alternative" "2"))
2054 (const_string "imovx")
2056 (const_string "imov")))
2058 (cond [(eq_attr "alternative" "3,4,5")
2060 (eq_attr "alternative" "6")
2062 (eq_attr "type" "imovx")
2064 (and (eq_attr "type" "imov")
2065 (and (eq_attr "alternative" "0,1,2")
2066 (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2069 ;; Avoid partial register stalls when not using QImode arithmetic
2070 (and (eq_attr "type" "imov")
2071 (and (eq_attr "alternative" "0,1,2")
2072 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2074 (eq (symbol_ref "TARGET_QIMODE_MATH")
2078 (const_string "QI")))])
2080 (define_expand "reload_outqi"
2081 [(parallel [(match_operand:QI 0 "" "=m")
2082 (match_operand:QI 1 "register_operand" "r")
2083 (match_operand:QI 2 "register_operand" "=&q")])]
2087 op0 = operands[0]; op1 = operands[1]; op2 = operands[2];
2089 if (reg_overlap_mentioned_p (op2, op0))
2091 if (! q_regs_operand (op1, QImode))
2093 emit_insn (gen_movqi (op2, op1));
2096 emit_insn (gen_movqi (op0, op1));
2100 (define_insn "*swapqi"
2101 [(set (match_operand:QI 0 "register_operand" "+r")
2102 (match_operand:QI 1 "register_operand" "+r"))
2107 [(set_attr "type" "imov")
2108 (set_attr "pent_pair" "np")
2109 (set_attr "mode" "QI")
2110 (set_attr "modrm" "0")
2111 (set_attr "ppro_uops" "few")])
2113 (define_expand "movstrictqi"
2114 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
2115 (match_operand:QI 1 "general_operand" ""))]
2116 "! TARGET_PARTIAL_REG_STALL"
2118 /* Don't generate memory->memory moves, go through a register */
2119 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
2120 operands[1] = force_reg (QImode, operands[1]);
2123 (define_insn "*movstrictqi_1"
2124 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
2125 (match_operand:QI 1 "general_operand" "*qn,m"))]
2126 "! TARGET_PARTIAL_REG_STALL
2127 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2128 "mov{b}\t{%1, %0|%0, %1}"
2129 [(set_attr "type" "imov")
2130 (set_attr "mode" "QI")])
2132 (define_insn "*movstrictqi_xor"
2133 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
2134 (match_operand:QI 1 "const0_operand" "i"))
2135 (clobber (reg:CC 17))]
2136 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
2137 "xor{b}\t{%0, %0|%0, %0}"
2138 [(set_attr "type" "alu1")
2139 (set_attr "mode" "QI")
2140 (set_attr "length_immediate" "0")])
2142 (define_insn "*movsi_extv_1"
2143 [(set (match_operand:SI 0 "register_operand" "=R")
2144 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
2148 "movs{bl|x}\t{%h1, %0|%0, %h1}"
2149 [(set_attr "type" "imovx")
2150 (set_attr "mode" "SI")])
2152 (define_insn "*movhi_extv_1"
2153 [(set (match_operand:HI 0 "register_operand" "=R")
2154 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
2158 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2159 [(set_attr "type" "imovx")
2160 (set_attr "mode" "SI")])
2162 (define_insn "*movqi_extv_1"
2163 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2164 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2169 switch (get_attr_type (insn))
2172 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2174 return "mov{b}\t{%h1, %0|%0, %h1}";
2178 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2179 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2180 (ne (symbol_ref "TARGET_MOVX")
2182 (const_string "imovx")
2183 (const_string "imov")))
2185 (if_then_else (eq_attr "type" "imovx")
2187 (const_string "QI")))])
2189 (define_insn "*movqi_extv_1_rex64"
2190 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2191 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2196 switch (get_attr_type (insn))
2199 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2201 return "mov{b}\t{%h1, %0|%0, %h1}";
2205 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2206 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2207 (ne (symbol_ref "TARGET_MOVX")
2209 (const_string "imovx")
2210 (const_string "imov")))
2212 (if_then_else (eq_attr "type" "imovx")
2214 (const_string "QI")))])
2216 ;; Stores and loads of ax to arbitary constant address.
2217 ;; We fake an second form of instruction to force reload to load address
2218 ;; into register when rax is not available
2219 (define_insn "*movabsqi_1_rex64"
2220 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
2221 (match_operand:QI 1 "nonmemory_operand" "a,er,i"))]
2224 movabs{q}\t{%1, %P0|%P0, %1}
2225 mov{q}\t{%1, %a0|%a0, %1}
2226 movabs{q}\t{%1, %a0|%a0, %1}"
2227 [(set_attr "type" "imov")
2228 (set_attr "modrm" "0,*,*")
2229 (set_attr "length_address" "8,0,0")
2230 (set_attr "length_immediate" "0,*,*")
2231 (set_attr "memory" "store")
2232 (set_attr "mode" "QI")])
2234 (define_insn "*movabsqi_2_rex64"
2235 [(set (match_operand:QI 0 "register_operand" "=a,r")
2236 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2239 movabs{q}\t{%P1, %0|%0, %P1}
2240 mov{q}\t{%a1, %0|%0, %a1}"
2241 [(set_attr "type" "imov")
2242 (set_attr "modrm" "0,*")
2243 (set_attr "length_address" "8,0")
2244 (set_attr "length_immediate" "0")
2245 (set_attr "memory" "load")
2246 (set_attr "mode" "QI")])
2248 (define_insn "*movsi_extzv_1"
2249 [(set (match_operand:SI 0 "register_operand" "=R")
2250 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
2254 "movz{bl|x}\t{%h1, %0|%0, %h1}"
2255 [(set_attr "type" "imovx")
2256 (set_attr "mode" "SI")])
2258 (define_insn "*movqi_extzv_2"
2259 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2260 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2265 switch (get_attr_type (insn))
2268 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2270 return "mov{b}\t{%h1, %0|%0, %h1}";
2274 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2275 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2276 (ne (symbol_ref "TARGET_MOVX")
2278 (const_string "imovx")
2279 (const_string "imov")))
2281 (if_then_else (eq_attr "type" "imovx")
2283 (const_string "QI")))])
2285 (define_insn "*movqi_extzv_2_rex64"
2286 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2287 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2292 switch (get_attr_type (insn))
2295 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2297 return "mov{b}\t{%h1, %0|%0, %h1}";
2301 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2302 (ne (symbol_ref "TARGET_MOVX")
2304 (const_string "imovx")
2305 (const_string "imov")))
2307 (if_then_else (eq_attr "type" "imovx")
2309 (const_string "QI")))])
2311 (define_insn "movsi_insv_1"
2312 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2315 (match_operand:SI 1 "general_operand" "Qmn"))]
2317 "mov{b}\t{%b1, %h0|%h0, %b1}"
2318 [(set_attr "type" "imov")
2319 (set_attr "mode" "QI")])
2321 (define_insn "*movsi_insv_1_rex64"
2322 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2325 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2327 "mov{b}\t{%b1, %h0|%h0, %b1}"
2328 [(set_attr "type" "imov")
2329 (set_attr "mode" "QI")])
2331 (define_insn "*movqi_insv_2"
2332 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2335 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2339 "mov{b}\t{%h1, %h0|%h0, %h1}"
2340 [(set_attr "type" "imov")
2341 (set_attr "mode" "QI")])
2343 (define_expand "movdi"
2344 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2345 (match_operand:DI 1 "general_operand" ""))]
2347 "ix86_expand_move (DImode, operands); DONE;")
2349 (define_insn "*pushdi"
2350 [(set (match_operand:DI 0 "push_operand" "=<")
2351 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2355 (define_insn "pushdi2_rex64"
2356 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2357 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2362 [(set_attr "type" "push,multi")
2363 (set_attr "mode" "DI")])
2365 ;; Convert impossible pushes of immediate to existing instructions.
2366 ;; First try to get scratch register and go trought it. In case this
2367 ;; fails, push sign extended lower part first and then overwrite
2368 ;; upper part by 32bit move.
2370 [(match_scratch:DI 2 "r")
2371 (set (match_operand:DI 0 "push_operand" "")
2372 (match_operand:DI 1 "immediate_operand" ""))]
2373 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2374 && !x86_64_immediate_operand (operands[1], DImode)"
2375 [(set (match_dup 2) (match_dup 1))
2376 (set (match_dup 0) (match_dup 2))]
2379 ;; We need to define this as both peepholer and splitter for case
2380 ;; peephole2 pass is not run.
2382 [(set (match_operand:DI 0 "push_operand" "")
2383 (match_operand:DI 1 "immediate_operand" ""))]
2384 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2385 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2386 [(set (match_dup 0) (match_dup 1))
2387 (set (match_dup 2) (match_dup 3))]
2388 "split_di (operands + 1, 1, operands + 2, operands + 3);
2389 operands[1] = gen_lowpart (DImode, operands[2]);
2390 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2395 [(set (match_operand:DI 0 "push_operand" "")
2396 (match_operand:DI 1 "immediate_operand" ""))]
2397 "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
2398 && !symbolic_operand (operands[1], DImode)
2399 && !x86_64_immediate_operand (operands[1], DImode)"
2400 [(set (match_dup 0) (match_dup 1))
2401 (set (match_dup 2) (match_dup 3))]
2402 "split_di (operands + 1, 1, operands + 2, operands + 3);
2403 operands[1] = gen_lowpart (DImode, operands[2]);
2404 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2408 (define_insn "*pushdi2_prologue_rex64"
2409 [(set (match_operand:DI 0 "push_operand" "=<")
2410 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2411 (clobber (mem:BLK (scratch)))]
2414 [(set_attr "type" "push")
2415 (set_attr "mode" "DI")])
2417 (define_insn "*popdi1_epilogue_rex64"
2418 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2419 (mem:DI (reg:DI 7)))
2421 (plus:DI (reg:DI 7) (const_int 8)))
2422 (clobber (mem:BLK (scratch)))]
2425 [(set_attr "type" "pop")
2426 (set_attr "mode" "DI")])
2428 (define_insn "popdi1"
2429 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2430 (mem:DI (reg:DI 7)))
2432 (plus:DI (reg:DI 7) (const_int 8)))]
2435 [(set_attr "type" "pop")
2436 (set_attr "mode" "DI")])
2438 (define_insn "*movdi_xor_rex64"
2439 [(set (match_operand:DI 0 "register_operand" "=r")
2440 (match_operand:DI 1 "const0_operand" "i"))
2441 (clobber (reg:CC 17))]
2442 "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
2443 && reload_completed"
2444 "xor{l}\t{%k0, %k0|%k0, %k0}"
2445 [(set_attr "type" "alu1")
2446 (set_attr "mode" "SI")
2447 (set_attr "length_immediate" "0")])
2449 (define_insn "*movdi_or_rex64"
2450 [(set (match_operand:DI 0 "register_operand" "=r")
2451 (match_operand:DI 1 "const_int_operand" "i"))
2452 (clobber (reg:CC 17))]
2453 "TARGET_64BIT && (TARGET_PENTIUM || optimize_size)
2455 && GET_CODE (operands[1]) == CONST_INT
2456 && INTVAL (operands[1]) == -1"
2458 operands[1] = constm1_rtx;
2459 return "or{q}\t{%1, %0|%0, %1}";
2461 [(set_attr "type" "alu1")
2462 (set_attr "mode" "DI")
2463 (set_attr "length_immediate" "1")])
2465 (define_insn "*movdi_2"
2466 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o,!m*y,!*y,!m,*Y,!*Y")
2467 (match_operand:DI 1 "general_operand" "riFo,riF,*y,m,*Y,*Y,m"))]
2469 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2473 movq\t{%1, %0|%0, %1}
2474 movq\t{%1, %0|%0, %1}
2475 movq\t{%1, %0|%0, %1}
2476 movdqa\t{%1, %0|%0, %1}
2477 movq\t{%1, %0|%0, %1}"
2478 [(set_attr "type" "*,*,mmx,mmx,sse,sse,sse")
2479 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI")])
2482 [(set (match_operand:DI 0 "push_operand" "")
2483 (match_operand:DI 1 "general_operand" ""))]
2484 "!TARGET_64BIT && reload_completed
2485 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2487 "ix86_split_long_move (operands); DONE;")
2489 ;; %%% This multiword shite has got to go.
2491 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2492 (match_operand:DI 1 "general_operand" ""))]
2493 "!TARGET_64BIT && reload_completed
2494 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2495 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2497 "ix86_split_long_move (operands); DONE;")
2499 (define_insn "*movdi_1_rex64"
2500 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,mr,!mr,!m*y,!*y,!*Y,!m,!*Y")
2501 (match_operand:DI 1 "general_operand" "Z,rem,i,re,n,*y,m,*Y,*Y,*m"))]
2503 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)"
2505 switch (get_attr_type (insn))
2508 if (register_operand (operands[0], DImode)
2509 && register_operand (operands[1], DImode))
2510 return "movdqa\t{%1, %0|%0, %1}";
2513 return "movq\t{%1, %0|%0, %1}";
2517 return "lea{q}\t{%a1, %0|%0, %a1}";
2519 if (flag_pic && SYMBOLIC_CONST (operands[1]))
2521 if (get_attr_mode (insn) == MODE_SI)
2522 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2523 else if (which_alternative == 2)
2524 return "movabs{q}\t{%1, %0|%0, %1}";
2526 return "mov{q}\t{%1, %0|%0, %1}";
2530 (cond [(eq_attr "alternative" "5,6")
2531 (const_string "mmx")
2532 (eq_attr "alternative" "7,8")
2533 (const_string "sse")
2534 (eq_attr "alternative" "4")
2535 (const_string "multi")
2536 (and (ne (symbol_ref "flag_pic") (const_int 0))
2537 (match_operand:DI 1 "symbolic_operand" ""))
2538 (const_string "lea")
2540 (const_string "imov")))
2541 (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*")
2542 (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*")
2543 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,TI,DI")])
2545 ;; Stores and loads of ax to arbitary constant address.
2546 ;; We fake an second form of instruction to force reload to load address
2547 ;; into register when rax is not available
2548 (define_insn "*movabsdi_1_rex64"
2549 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r,r"))
2550 (match_operand:DI 1 "nonmemory_operand" "a,er,i"))]
2553 movabs{q}\t{%1, %P0|%P0, %1}
2554 mov{q}\t{%1, %a0|%a0, %1}
2555 movabs{q}\t{%1, %a0|%a0, %1}"
2556 [(set_attr "type" "imov")
2557 (set_attr "modrm" "0,*,*")
2558 (set_attr "length_address" "8,0,0")
2559 (set_attr "length_immediate" "0,*,*")
2560 (set_attr "memory" "store")
2561 (set_attr "mode" "DI")])
2563 (define_insn "*movabsdi_2_rex64"
2564 [(set (match_operand:DI 0 "register_operand" "=a,r")
2565 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2568 movabs{q}\t{%P1, %0|%0, %P1}
2569 mov{q}\t{%a1, %0|%0, %a1}"
2570 [(set_attr "type" "imov")
2571 (set_attr "modrm" "0,*")
2572 (set_attr "length_address" "8,0")
2573 (set_attr "length_immediate" "0")
2574 (set_attr "memory" "load")
2575 (set_attr "mode" "DI")])
2577 ;; Convert impossible stores of immediate to existing instructions.
2578 ;; First try to get scratch register and go trought it. In case this
2579 ;; fails, move by 32bit parts.
2581 [(match_scratch:DI 2 "r")
2582 (set (match_operand:DI 0 "memory_operand" "")
2583 (match_operand:DI 1 "immediate_operand" ""))]
2584 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2585 && !x86_64_immediate_operand (operands[1], DImode)"
2586 [(set (match_dup 2) (match_dup 1))
2587 (set (match_dup 0) (match_dup 2))]
2590 ;; We need to define this as both peepholer and splitter for case
2591 ;; peephole2 pass is not run.
2593 [(set (match_operand:DI 0 "memory_operand" "")
2594 (match_operand:DI 1 "immediate_operand" ""))]
2595 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2596 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2597 [(set (match_dup 2) (match_dup 3))
2598 (set (match_dup 4) (match_dup 5))]
2599 "split_di (operands, 2, operands + 2, operands + 4);")
2602 [(set (match_operand:DI 0 "memory_operand" "")
2603 (match_operand:DI 1 "immediate_operand" ""))]
2604 "TARGET_64BIT && (flow2_completed || (reload_completed && !flag_peephole2))
2605 && !symbolic_operand (operands[1], DImode)
2606 && !x86_64_immediate_operand (operands[1], DImode)"
2607 [(set (match_dup 2) (match_dup 3))
2608 (set (match_dup 4) (match_dup 5))]
2609 "split_di (operands, 2, operands + 2, operands + 4);")
2611 (define_insn "*swapdi_rex64"
2612 [(set (match_operand:DI 0 "register_operand" "+r")
2613 (match_operand:DI 1 "register_operand" "+r"))
2618 [(set_attr "type" "imov")
2619 (set_attr "pent_pair" "np")
2620 (set_attr "athlon_decode" "vector")
2621 (set_attr "mode" "DI")
2622 (set_attr "modrm" "0")
2623 (set_attr "ppro_uops" "few")])
2626 (define_expand "movsf"
2627 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2628 (match_operand:SF 1 "general_operand" ""))]
2630 "ix86_expand_move (SFmode, operands); DONE;")
2632 (define_insn "*pushsf"
2633 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2634 (match_operand:SF 1 "general_no_elim_operand" "f#rx,rFm#fx,x#rf"))]
2637 switch (which_alternative)
2640 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
2641 operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx);
2642 operands[2] = stack_pointer_rtx;
2643 operands[3] = GEN_INT (4);
2644 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2645 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2647 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2650 return "push{l}\t%1";
2658 [(set_attr "type" "multi,push,multi")
2659 (set_attr "mode" "SF,SI,SF")])
2661 (define_insn "*pushsf_rex64"
2662 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2663 (match_operand:SF 1 "nonmemory_no_elim_operand" "f#rx,rF#fx,x#rf"))]
2666 switch (which_alternative)
2669 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
2670 operands[0] = gen_rtx_MEM (SFmode, stack_pointer_rtx);
2671 operands[2] = stack_pointer_rtx;
2672 operands[3] = GEN_INT (8);
2673 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2674 return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2676 return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2679 return "push{q}\t%q1";
2688 [(set_attr "type" "multi,push,multi")
2689 (set_attr "mode" "SF,DI,SF")])
2692 [(set (match_operand:SF 0 "push_operand" "")
2693 (match_operand:SF 1 "memory_operand" ""))]
2695 && GET_CODE (operands[1]) == MEM
2696 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2697 && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))"
2700 "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
2703 ;; %%% Kill this when call knows how to work this out.
2705 [(set (match_operand:SF 0 "push_operand" "")
2706 (match_operand:SF 1 "register_operand" ""))]
2707 "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2708 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -4)))
2709 (set (mem:SF (reg:SI 7)) (match_dup 1))])
2712 [(set (match_operand:SF 0 "push_operand" "")
2713 (match_operand:SF 1 "register_operand" ""))]
2714 "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
2715 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2716 (set (mem:SF (reg:DI 7)) (match_dup 1))])
2718 (define_insn "*movsf_1"
2719 [(set (match_operand:SF 0 "nonimmediate_operand" "=f#xr,m,f#xr,r#xf,m,x#rf,x#rf,x#rf,m")
2720 (match_operand:SF 1 "general_operand" "fm#rx,f#rx,G,rmF#fx,Fr#fx,H,x,xm#rf,x#rf"))]
2721 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2722 && (reload_in_progress || reload_completed
2723 || GET_CODE (operands[1]) != CONST_DOUBLE
2724 || memory_operand (operands[0], SFmode))"
2726 switch (which_alternative)
2729 if (REG_P (operands[1])
2730 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2732 else if (STACK_TOP_P (operands[0]))
2733 return "fld%z1\t%y1";
2738 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2739 return "fstp%z0\t%y0";
2741 return "fst%z0\t%y0";
2744 switch (standard_80387_constant_p (operands[1]))
2755 return "mov{l}\t{%1, %0|%0, %1}";
2757 return "pxor\t%0, %0";
2759 if (TARGET_PARTIAL_REG_DEPENDENCY)
2760 return "movaps\t{%1, %0|%0, %1}";
2762 return "movss\t{%1, %0|%0, %1}";
2765 return "movss\t{%1, %0|%0, %1}";
2771 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sse,sse,sse,sse")
2772 (set_attr "mode" "SF,SF,SF,SI,SI,TI,SF,SF,SF")])
2774 (define_insn "*swapsf"
2775 [(set (match_operand:SF 0 "register_operand" "+f")
2776 (match_operand:SF 1 "register_operand" "+f"))
2779 "reload_completed || !TARGET_SSE2"
2781 if (STACK_TOP_P (operands[0]))
2786 [(set_attr "type" "fxch")
2787 (set_attr "mode" "SF")])
2789 (define_expand "movdf"
2790 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2791 (match_operand:DF 1 "general_operand" ""))]
2793 "ix86_expand_move (DFmode, operands); DONE;")
2795 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2796 ;; Size of pushdf using integer insturctions is 2+2*memory operand size
2797 ;; On the average, pushdf using integers can be still shorter. Allow this
2798 ;; pattern for optimize_size too.
2800 (define_insn "*pushdf_nointeger"
2801 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2802 (match_operand:DF 1 "general_no_elim_operand" "f#Y,Fo#fY,*r#fY,Y#f"))]
2803 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2805 switch (which_alternative)
2808 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
2809 operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2810 operands[2] = stack_pointer_rtx;
2811 operands[3] = GEN_INT (8);
2812 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2813 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2815 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2826 [(set_attr "type" "multi")
2827 (set_attr "mode" "DF,SI,SI,DF")])
2829 (define_insn "*pushdf_integer"
2830 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2831 (match_operand:DF 1 "general_no_elim_operand" "f#rY,rFo#fY,Y#rf"))]
2832 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2834 switch (which_alternative)
2837 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
2838 operands[0] = gen_rtx_MEM (DFmode, stack_pointer_rtx);
2839 operands[2] = stack_pointer_rtx;
2840 operands[3] = GEN_INT (8);
2842 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2843 return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2845 return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2847 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2848 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
2850 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
2861 [(set_attr "type" "multi")
2862 (set_attr "mode" "DF,SI,DF")])
2864 ;; %%% Kill this when call knows how to work this out.
2866 [(set (match_operand:DF 0 "push_operand" "")
2867 (match_operand:DF 1 "register_operand" ""))]
2868 "!TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))"
2869 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -8)))
2870 (set (mem:DF (reg:SI 7)) (match_dup 1))]
2874 [(set (match_operand:DF 0 "push_operand" "")
2875 (match_operand:DF 1 "register_operand" ""))]
2876 "TARGET_64BIT && reload_completed && ANY_FP_REGNO_P (REGNO (operands[1]))"
2877 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -8)))
2878 (set (mem:DF (reg:DI 7)) (match_dup 1))]
2882 [(set (match_operand:DF 0 "push_operand" "")
2883 (match_operand:DF 1 "general_operand" ""))]
2886 "ix86_split_long_move (operands); DONE;")
2888 ;; Moving is usually shorter when only FP registers are used. This separate
2889 ;; movdf pattern avoids the use of integer registers for FP operations
2890 ;; when optimizing for size.
2892 (define_insn "*movdf_nointeger"
2893 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Y,m,f#Y,*r,o,Y#f,Y#f,Y#f,m")
2894 (match_operand:DF 1 "general_operand" "fm#Y,f#Y,G,*roF,F*r,H,Y#f,YHm#f,Y#f"))]
2895 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2896 && (optimize_size || !TARGET_INTEGER_DFMODE_MOVES)
2897 && (reload_in_progress || reload_completed
2898 || GET_CODE (operands[1]) != CONST_DOUBLE
2899 || memory_operand (operands[0], DFmode))"
2901 switch (which_alternative)
2904 if (REG_P (operands[1])
2905 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2907 else if (STACK_TOP_P (operands[0]))
2908 return "fld%z1\t%y1";
2913 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2914 return "fstp%z0\t%y0";
2916 return "fst%z0\t%y0";
2919 switch (standard_80387_constant_p (operands[1]))
2932 return "pxor\t%0, %0";
2934 if (TARGET_PARTIAL_REG_DEPENDENCY)
2935 return "movapd\t{%1, %0|%0, %1}";
2937 return "movsd\t{%1, %0|%0, %1}";
2940 return "movsd\t{%1, %0|%0, %1}";
2946 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse")
2947 (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
2949 (define_insn "*movdf_integer"
2950 [(set (match_operand:DF 0 "nonimmediate_operand" "=f#Yr,m,f#Yr,r#Yf,o,Y#rf,Y#rf,Y#rf,m")
2951 (match_operand:DF 1 "general_operand" "fm#Yr,f#Yr,G,roF#Yf,Fr#Yf,H,Y#rf,Ym#rf,Y#rf"))]
2952 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
2953 && !optimize_size && TARGET_INTEGER_DFMODE_MOVES
2954 && (reload_in_progress || reload_completed
2955 || GET_CODE (operands[1]) != CONST_DOUBLE
2956 || memory_operand (operands[0], DFmode))"
2958 switch (which_alternative)
2961 if (REG_P (operands[1])
2962 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2964 else if (STACK_TOP_P (operands[0]))
2965 return "fld%z1\t%y1";
2970 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
2971 return "fstp%z0\t%y0";
2973 return "fst%z0\t%y0";
2976 switch (standard_80387_constant_p (operands[1]))
2990 return "pxor\t%0, %0";
2992 if (TARGET_PARTIAL_REG_DEPENDENCY)
2993 return "movapd\t{%1, %0|%0, %1}";
2995 return "movsd\t{%1, %0|%0, %1}";
2998 return "movsd\t{%1, %0|%0, %1}";
3004 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sse,sse,sse,sse")
3005 (set_attr "mode" "DF,DF,DF,SI,SI,TI,DF,DF,DF")])
3008 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3009 (match_operand:DF 1 "general_operand" ""))]
3011 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3012 && ! (ANY_FP_REG_P (operands[0]) ||
3013 (GET_CODE (operands[0]) == SUBREG
3014 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3015 && ! (ANY_FP_REG_P (operands[1]) ||
3016 (GET_CODE (operands[1]) == SUBREG
3017 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3019 "ix86_split_long_move (operands); DONE;")
3021 (define_insn "*swapdf"
3022 [(set (match_operand:DF 0 "register_operand" "+f")
3023 (match_operand:DF 1 "register_operand" "+f"))
3026 "reload_completed || !TARGET_SSE2"
3028 if (STACK_TOP_P (operands[0]))
3033 [(set_attr "type" "fxch")
3034 (set_attr "mode" "DF")])
3036 (define_expand "movxf"
3037 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3038 (match_operand:XF 1 "general_operand" ""))]
3040 "ix86_expand_move (XFmode, operands); DONE;")
3042 (define_expand "movtf"
3043 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3044 (match_operand:TF 1 "general_operand" ""))]
3046 "ix86_expand_move (TFmode, operands); DONE;")
3048 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3049 ;; Size of pushdf using integer insturctions is 3+3*memory operand size
3050 ;; Pushing using integer instructions is longer except for constants
3051 ;; and direct memory references.
3052 ;; (assuming that any given constant is pushed only once, but this ought to be
3053 ;; handled elsewhere).
3055 (define_insn "*pushxf_nointeger"
3056 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
3057 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
3058 "!TARGET_64BIT && optimize_size"
3060 switch (which_alternative)
3063 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
3064 operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3065 operands[2] = stack_pointer_rtx;
3066 operands[3] = GEN_INT (12);
3067 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3068 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3070 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3080 [(set_attr "type" "multi")
3081 (set_attr "mode" "XF,SI,SI")])
3083 (define_insn "*pushtf_nointeger"
3084 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
3085 (match_operand:TF 1 "general_no_elim_operand" "f,Fo,*r"))]
3088 switch (which_alternative)
3091 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
3092 operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3093 operands[2] = stack_pointer_rtx;
3094 operands[3] = GEN_INT (16);
3095 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3096 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3098 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3108 [(set_attr "type" "multi")
3109 (set_attr "mode" "XF,SI,SI")])
3111 (define_insn "*pushxf_integer"
3112 [(set (match_operand:XF 0 "push_operand" "=<,<")
3113 (match_operand:XF 1 "general_no_elim_operand" "f#r,ro#f"))]
3114 "!TARGET_64BIT && !optimize_size"
3116 switch (which_alternative)
3119 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
3120 operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3121 operands[2] = stack_pointer_rtx;
3122 operands[3] = GEN_INT (12);
3123 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3124 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3126 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3135 [(set_attr "type" "multi")
3136 (set_attr "mode" "XF,SI")])
3138 (define_insn "*pushtf_integer"
3139 [(set (match_operand:TF 0 "push_operand" "=<,<")
3140 (match_operand:TF 1 "general_no_elim_operand" "f#r,rFo#f"))]
3143 switch (which_alternative)
3146 /* %%% We loose REG_DEAD notes for controling pops if we split late. */
3147 operands[0] = gen_rtx_MEM (XFmode, stack_pointer_rtx);
3148 operands[2] = stack_pointer_rtx;
3149 operands[3] = GEN_INT (16);
3151 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3152 return "sub{q}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3154 return "sub{q}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3156 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3157 return "sub{l}\t{%3, %2|%2, %3}\;fstp%z0\t%y0";
3159 return "sub{l}\t{%3, %2|%2, %3}\;fst%z0\t%y0";
3168 [(set_attr "type" "multi")
3169 (set_attr "mode" "XF,SI")])
3172 [(set (match_operand 0 "push_operand" "")
3173 (match_operand 1 "general_operand" ""))]
3175 && (GET_MODE (operands[0]) == XFmode
3176 || GET_MODE (operands[0]) == TFmode
3177 || GET_MODE (operands[0]) == DFmode)
3178 && (!REG_P (operands[1]) || !ANY_FP_REGNO_P (REGNO (operands[1])))"
3180 "ix86_split_long_move (operands); DONE;")
3183 [(set (match_operand:XF 0 "push_operand" "")
3184 (match_operand:XF 1 "register_operand" ""))]
3185 "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
3186 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -12)))
3187 (set (mem:XF (reg:SI 7)) (match_dup 1))])
3190 [(set (match_operand:TF 0 "push_operand" "")
3191 (match_operand:TF 1 "register_operand" ""))]
3192 "!TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
3193 [(set (reg:SI 7) (plus:SI (reg:SI 7) (const_int -16)))
3194 (set (mem:TF (reg:SI 7)) (match_dup 1))])
3197 [(set (match_operand:TF 0 "push_operand" "")
3198 (match_operand:TF 1 "register_operand" ""))]
3199 "TARGET_64BIT && ANY_FP_REGNO_P (REGNO (operands[1]))"
3200 [(set (reg:DI 7) (plus:DI (reg:DI 7) (const_int -16)))
3201 (set (mem:TF (reg:DI 7)) (match_dup 1))])
3203 ;; Do not use integer registers when optimizing for size
3204 (define_insn "*movxf_nointeger"
3205 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3206 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3209 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3210 && (reload_in_progress || reload_completed
3211 || GET_CODE (operands[1]) != CONST_DOUBLE
3212 || memory_operand (operands[0], XFmode))"
3214 switch (which_alternative)
3217 if (REG_P (operands[1])
3218 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3220 else if (STACK_TOP_P (operands[0]))
3221 return "fld%z1\t%y1";
3226 /* There is no non-popping store to memory for XFmode. So if
3227 we need one, follow the store with a load. */
3228 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3229 return "fstp%z0\t%y0\;fld%z0\t%y0";
3231 return "fstp%z0\t%y0";
3234 switch (standard_80387_constant_p (operands[1]))
3248 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3249 (set_attr "mode" "XF,XF,XF,SI,SI")])
3251 (define_insn "*movtf_nointeger"
3252 [(set (match_operand:TF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3253 (match_operand:TF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3254 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3256 && (reload_in_progress || reload_completed
3257 || GET_CODE (operands[1]) != CONST_DOUBLE
3258 || memory_operand (operands[0], TFmode))"
3260 switch (which_alternative)
3263 if (REG_P (operands[1])
3264 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3266 else if (STACK_TOP_P (operands[0]))
3267 return "fld%z1\t%y1";
3272 /* There is no non-popping store to memory for XFmode. So if
3273 we need one, follow the store with a load. */
3274 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3275 return "fstp%z0\t%y0\;fld%z0\t%y0";
3277 return "fstp%z0\t%y0";
3280 switch (standard_80387_constant_p (operands[1]))
3294 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3295 (set_attr "mode" "XF,XF,XF,SI,SI")])
3297 (define_insn "*movxf_integer"
3298 [(set (match_operand:XF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
3299 (match_operand:XF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
3302 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3303 && (reload_in_progress || reload_completed
3304 || GET_CODE (operands[1]) != CONST_DOUBLE
3305 || memory_operand (operands[0], XFmode))"
3307 switch (which_alternative)
3310 if (REG_P (operands[1])
3311 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3313 else if (STACK_TOP_P (operands[0]))
3314 return "fld%z1\t%y1";
3319 /* There is no non-popping store to memory for XFmode. So if
3320 we need one, follow the store with a load. */
3321 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3322 return "fstp%z0\t%y0\;fld%z0\t%y0";
3324 return "fstp%z0\t%y0";
3327 switch (standard_80387_constant_p (operands[1]))
3341 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3342 (set_attr "mode" "XF,XF,XF,SI,SI")])
3344 (define_insn "*movtf_integer"
3345 [(set (match_operand:TF 0 "nonimmediate_operand" "=f#r,m,f#r,r#f,o")
3346 (match_operand:TF 1 "general_operand" "fm#r,f#r,G,roF#f,Fr#f"))]
3347 "(GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3349 && (reload_in_progress || reload_completed
3350 || GET_CODE (operands[1]) != CONST_DOUBLE
3351 || memory_operand (operands[0], TFmode))"
3353 switch (which_alternative)
3356 if (REG_P (operands[1])
3357 && find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3359 else if (STACK_TOP_P (operands[0]))
3360 return "fld%z1\t%y1";
3365 /* There is no non-popping store to memory for XFmode. So if
3366 we need one, follow the store with a load. */
3367 if (! find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
3368 return "fstp%z0\t%y0\;fld%z0\t%y0";
3370 return "fstp%z0\t%y0";
3373 switch (standard_80387_constant_p (operands[1]))
3387 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3388 (set_attr "mode" "XF,XF,XF,SI,SI")])
3391 [(set (match_operand 0 "nonimmediate_operand" "")
3392 (match_operand 1 "general_operand" ""))]
3394 && (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM)
3395 && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode)
3396 && ! (ANY_FP_REG_P (operands[0]) ||
3397 (GET_CODE (operands[0]) == SUBREG
3398 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3399 && ! (ANY_FP_REG_P (operands[1]) ||
3400 (GET_CODE (operands[1]) == SUBREG
3401 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3403 "ix86_split_long_move (operands); DONE;")
3406 [(set (match_operand 0 "register_operand" "")
3407 (match_operand 1 "memory_operand" ""))]
3409 && GET_CODE (operands[1]) == MEM
3410 && (GET_MODE (operands[0]) == XFmode || GET_MODE (operands[0]) == TFmode
3411 || GET_MODE (operands[0]) == SFmode || GET_MODE (operands[0]) == DFmode)
3412 && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
3413 && CONSTANT_POOL_ADDRESS_P (XEXP (operands[1], 0))
3414 && (!(SSE_REG_P (operands[0]) ||
3415 (GET_CODE (operands[0]) == SUBREG
3416 && SSE_REG_P (SUBREG_REG (operands[0]))))
3417 || standard_sse_constant_p (get_pool_constant (XEXP (operands[1], 0))))
3418 && (!(FP_REG_P (operands[0]) ||
3419 (GET_CODE (operands[0]) == SUBREG
3420 && FP_REG_P (SUBREG_REG (operands[0]))))
3421 || standard_80387_constant_p (get_pool_constant (XEXP (operands[1], 0))))"
3424 "operands[1] = get_pool_constant (XEXP (operands[1], 0));")
3426 (define_insn "swapxf"
3427 [(set (match_operand:XF 0 "register_operand" "+f")
3428 (match_operand:XF 1 "register_operand" "+f"))
3433 if (STACK_TOP_P (operands[0]))
3438 [(set_attr "type" "fxch")
3439 (set_attr "mode" "XF")])
3441 (define_insn "swaptf"
3442 [(set (match_operand:TF 0 "register_operand" "+f")
3443 (match_operand:TF 1 "register_operand" "+f"))