1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 ;; Free Software Foundation, Inc.
5 ;; Mostly by William Schelter.
6 ;; x86_64 support added by Jan Hubicka
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>. */
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 ;; The special asm out single letter directives following a '%' are:
30 ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
32 ;; 'L' Print the opcode suffix for a 32-bit integer opcode.
33 ;; 'W' Print the opcode suffix for a 16-bit integer opcode.
34 ;; 'B' Print the opcode suffix for an 8-bit integer opcode.
35 ;; 'Q' Print the opcode suffix for a 64-bit float opcode.
36 ;; 'S' Print the opcode suffix for a 32-bit float opcode.
37 ;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
38 ;; 'J' Print the appropriate jump operand.
40 ;; 'b' Print the QImode name of the register for the indicated operand.
41 ;; %b0 would print %al if operands[0] is reg 0.
42 ;; 'w' Likewise, print the HImode name of the register.
43 ;; 'k' Likewise, print the SImode name of the register.
44 ;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh.
45 ;; 'y' Print "st(0)" instead of "st" as a register.
50 [; Relocation specifiers
63 (UNSPEC_STACK_ALLOC 11)
65 (UNSPEC_SSE_PROLOGUE_SAVE 13)
69 (UNSPEC_SET_GOT_OFFSET 17)
74 (UNSPEC_TLS_LD_BASE 20)
77 ; Other random patterns
86 (UNSPEC_LD_MPIC 38) ; load_macho_picbase
87 (UNSPEC_TRUNC_NOOP 39)
89 ; For SSE/MMX support:
90 (UNSPEC_FIX_NOTRUNC 40)
108 ; Generic math support
110 (UNSPEC_IEEE_MIN 51) ; not commutative
111 (UNSPEC_IEEE_MAX 52) ; not commutative
126 (UNSPEC_FRNDINT_FLOOR 70)
127 (UNSPEC_FRNDINT_CEIL 71)
128 (UNSPEC_FRNDINT_TRUNC 72)
129 (UNSPEC_FRNDINT_MASK_PM 73)
130 (UNSPEC_FIST_FLOOR 74)
131 (UNSPEC_FIST_CEIL 75)
133 ; x87 Double output FP
134 (UNSPEC_SINCOS_COS 80)
135 (UNSPEC_SINCOS_SIN 81)
136 (UNSPEC_XTRACT_FRACT 84)
137 (UNSPEC_XTRACT_EXP 85)
138 (UNSPEC_FSCALE_FRACT 86)
139 (UNSPEC_FSCALE_EXP 87)
150 (UNSPEC_SP_TLS_SET 102)
151 (UNSPEC_SP_TLS_TEST 103)
161 (UNSPEC_INSERTQI 132)
166 (UNSPEC_INSERTPS 135)
168 (UNSPEC_MOVNTDQA 137)
170 (UNSPEC_PHMINPOSUW 139)
176 (UNSPEC_PCMPESTR 144)
177 (UNSPEC_PCMPISTR 145)
180 (UNSPEC_SSE5_INTRINSIC 150)
181 (UNSPEC_SSE5_UNSIGNED_CMP 151)
182 (UNSPEC_SSE5_TRUEFALSE 152)
183 (UNSPEC_SSE5_PERMUTE 153)
184 (UNSPEC_SSE5_ASHIFT 154)
185 (UNSPEC_SSE5_LSHIFT 155)
187 (UNSPEC_CVTPH2PS 157)
188 (UNSPEC_CVTPS2PH 158)
192 [(UNSPECV_BLOCKAGE 0)
193 (UNSPECV_STACK_PROBE 1)
202 (UNSPECV_CMPXCHG_1 10)
203 (UNSPECV_CMPXCHG_2 11)
206 (UNSPECV_PROLOGUE_USE 14)
209 ;; Constants to represent pcomtrue/pcomfalse variants
219 ;; Registers by name.
235 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
238 ;; In C guard expressions, put expressions which may be compile-time
239 ;; constants first. This allows for better optimization. For
240 ;; example, write "TARGET_64BIT && reload_completed", not
241 ;; "reload_completed && TARGET_64BIT".
244 ;; Processor type. This attribute must exactly match the processor_type
245 ;; enumeration in i386.h.
246 (define_attr "cpu" "i386,i486,pentium,pentiumpro,geode,k6,athlon,pentium4,k8,
247 nocona,core2,generic32,generic64,amdfam10"
248 (const (symbol_ref "ix86_tune")))
250 ;; A basic instruction type. Refinements due to arguments to be
251 ;; provided in other attributes.
254 alu,alu1,negnot,imov,imovx,lea,
255 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
256 icmp,test,ibr,setcc,icmov,
257 push,pop,call,callv,leave,
259 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
260 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
261 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
263 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
264 (const_string "other"))
266 ;; Main data type used by the insn
268 "unknown,none,QI,HI,SI,DI,SF,DF,XF,TI,V4SF,V2DF,V2SF,V1DF"
269 (const_string "unknown"))
271 ;; The CPU unit operations uses.
272 (define_attr "unit" "integer,i387,sse,mmx,unknown"
273 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
274 (const_string "i387")
275 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
276 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
277 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
279 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
281 (eq_attr "type" "other")
282 (const_string "unknown")]
283 (const_string "integer")))
285 ;; The (bounding maximum) length of an instruction immediate.
286 (define_attr "length_immediate" ""
287 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
290 (eq_attr "unit" "i387,sse,mmx")
292 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
294 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
295 (eq_attr "type" "imov,test")
296 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
297 (eq_attr "type" "call")
298 (if_then_else (match_operand 0 "constant_call_address_operand" "")
301 (eq_attr "type" "callv")
302 (if_then_else (match_operand 1 "constant_call_address_operand" "")
305 ;; We don't know the size before shorten_branches. Expect
306 ;; the instruction to fit for better scheduling.
307 (eq_attr "type" "ibr")
310 (symbol_ref "/* Update immediate_length and other attributes! */
311 gcc_unreachable (),1")))
313 ;; The (bounding maximum) length of an instruction address.
314 (define_attr "length_address" ""
315 (cond [(eq_attr "type" "str,other,multi,fxch")
317 (and (eq_attr "type" "call")
318 (match_operand 0 "constant_call_address_operand" ""))
320 (and (eq_attr "type" "callv")
321 (match_operand 1 "constant_call_address_operand" ""))
324 (symbol_ref "ix86_attr_length_address_default (insn)")))
326 ;; Set when length prefix is used.
327 (define_attr "prefix_data16" ""
328 (if_then_else (ior (eq_attr "mode" "HI")
329 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF")))
333 ;; Set when string REP prefix is used.
334 (define_attr "prefix_rep" ""
335 (if_then_else (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
339 ;; Set when 0f opcode prefix is used.
340 (define_attr "prefix_0f" ""
342 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
343 (eq_attr "unit" "sse,mmx"))
347 ;; Set when REX opcode prefix is used.
348 (define_attr "prefix_rex" ""
349 (cond [(and (eq_attr "mode" "DI")
350 (eq_attr "type" "!push,pop,call,callv,leave,ibr"))
352 (and (eq_attr "mode" "QI")
353 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
356 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
362 ;; There are also additional prefixes in SSSE3.
363 (define_attr "prefix_extra" "" (const_int 0))
365 ;; Set when modrm byte is used.
366 (define_attr "modrm" ""
367 (cond [(eq_attr "type" "str,leave")
369 (eq_attr "unit" "i387")
371 (and (eq_attr "type" "incdec")
372 (ior (match_operand:SI 1 "register_operand" "")
373 (match_operand:HI 1 "register_operand" "")))
375 (and (eq_attr "type" "push")
376 (not (match_operand 1 "memory_operand" "")))
378 (and (eq_attr "type" "pop")
379 (not (match_operand 0 "memory_operand" "")))
381 (and (eq_attr "type" "imov")
382 (ior (and (match_operand 0 "register_operand" "")
383 (match_operand 1 "immediate_operand" ""))
384 (ior (and (match_operand 0 "ax_reg_operand" "")
385 (match_operand 1 "memory_displacement_only_operand" ""))
386 (and (match_operand 0 "memory_displacement_only_operand" "")
387 (match_operand 1 "ax_reg_operand" "")))))
389 (and (eq_attr "type" "call")
390 (match_operand 0 "constant_call_address_operand" ""))
392 (and (eq_attr "type" "callv")
393 (match_operand 1 "constant_call_address_operand" ""))
398 ;; The (bounding maximum) length of an instruction in bytes.
399 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
400 ;; Later we may want to split them and compute proper length as for
402 (define_attr "length" ""
403 (cond [(eq_attr "type" "other,multi,fistp,frndint")
405 (eq_attr "type" "fcmp")
407 (eq_attr "unit" "i387")
409 (plus (attr "prefix_data16")
410 (attr "length_address")))]
411 (plus (plus (attr "modrm")
412 (plus (attr "prefix_0f")
413 (plus (attr "prefix_rex")
414 (plus (attr "prefix_extra")
416 (plus (attr "prefix_rep")
417 (plus (attr "prefix_data16")
418 (plus (attr "length_immediate")
419 (attr "length_address")))))))
421 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
422 ;; `store' if there is a simple memory reference therein, or `unknown'
423 ;; if the instruction is complex.
425 (define_attr "memory" "none,load,store,both,unknown"
426 (cond [(eq_attr "type" "other,multi,str")
427 (const_string "unknown")
428 (eq_attr "type" "lea,fcmov,fpspc")
429 (const_string "none")
430 (eq_attr "type" "fistp,leave")
431 (const_string "both")
432 (eq_attr "type" "frndint")
433 (const_string "load")
434 (eq_attr "type" "push")
435 (if_then_else (match_operand 1 "memory_operand" "")
436 (const_string "both")
437 (const_string "store"))
438 (eq_attr "type" "pop")
439 (if_then_else (match_operand 0 "memory_operand" "")
440 (const_string "both")
441 (const_string "load"))
442 (eq_attr "type" "setcc")
443 (if_then_else (match_operand 0 "memory_operand" "")
444 (const_string "store")
445 (const_string "none"))
446 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
447 (if_then_else (ior (match_operand 0 "memory_operand" "")
448 (match_operand 1 "memory_operand" ""))
449 (const_string "load")
450 (const_string "none"))
451 (eq_attr "type" "ibr")
452 (if_then_else (match_operand 0 "memory_operand" "")
453 (const_string "load")
454 (const_string "none"))
455 (eq_attr "type" "call")
456 (if_then_else (match_operand 0 "constant_call_address_operand" "")
457 (const_string "none")
458 (const_string "load"))
459 (eq_attr "type" "callv")
460 (if_then_else (match_operand 1 "constant_call_address_operand" "")
461 (const_string "none")
462 (const_string "load"))
463 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
464 (match_operand 1 "memory_operand" ""))
465 (const_string "both")
466 (and (match_operand 0 "memory_operand" "")
467 (match_operand 1 "memory_operand" ""))
468 (const_string "both")
469 (match_operand 0 "memory_operand" "")
470 (const_string "store")
471 (match_operand 1 "memory_operand" "")
472 (const_string "load")
474 "!alu1,negnot,ishift1,
475 imov,imovx,icmp,test,bitmanip,
477 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
478 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
479 (match_operand 2 "memory_operand" ""))
480 (const_string "load")
481 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
482 (match_operand 3 "memory_operand" ""))
483 (const_string "load")
485 (const_string "none")))
487 ;; Indicates if an instruction has both an immediate and a displacement.
489 (define_attr "imm_disp" "false,true,unknown"
490 (cond [(eq_attr "type" "other,multi")
491 (const_string "unknown")
492 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
493 (and (match_operand 0 "memory_displacement_operand" "")
494 (match_operand 1 "immediate_operand" "")))
495 (const_string "true")
496 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
497 (and (match_operand 0 "memory_displacement_operand" "")
498 (match_operand 2 "immediate_operand" "")))
499 (const_string "true")
501 (const_string "false")))
503 ;; Indicates if an FP operation has an integer source.
505 (define_attr "fp_int_src" "false,true"
506 (const_string "false"))
508 ;; Defines rounding mode of an FP operation.
510 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
511 (const_string "any"))
513 ;; Describe a user's asm statement.
514 (define_asm_attributes
515 [(set_attr "length" "128")
516 (set_attr "type" "multi")])
518 ;; All integer comparison codes.
519 (define_code_iterator int_cond [ne eq ge gt le lt geu gtu leu ltu ])
521 ;; All floating-point comparison codes.
522 (define_code_iterator fp_cond [unordered ordered
523 uneq unge ungt unle unlt ltgt ])
525 (define_code_iterator plusminus [plus minus])
527 ;; Base name for define_insn and insn mnemonic.
528 (define_code_attr addsub [(plus "add") (minus "sub")])
530 ;; Mark commutative operators as such in constraints.
531 (define_code_attr comm [(plus "%") (minus "")])
533 ;; Mapping of signed max and min
534 (define_code_iterator smaxmin [smax smin])
536 ;; Mapping of unsigned max and min
537 (define_code_iterator umaxmin [umax umin])
539 ;; Base name for integer and FP insn mnemonic
540 (define_code_attr maxminiprefix [(smax "maxs") (smin "mins") (umax "maxu") (umin "minu")])
541 (define_code_attr maxminfprefix [(smax "max") (smin "min")])
543 ;; Mapping of parallel logic operators
544 (define_code_iterator plogic [and ior xor])
546 ;; Base name for insn mnemonic.
547 (define_code_attr plogicprefix [(and "and") (ior "or") (xor "xor")])
549 ;; All single word integer modes.
550 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
552 ;; Instruction suffix for integer modes.
553 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
555 ;; Register class for integer modes.
556 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
558 ;; Immediate operand constraint for integer modes.
559 (define_mode_attr i [(QI "i") (HI "i") (SI "i") (DI "e")])
561 ;; General operand predicate for integer modes.
562 (define_mode_attr general_operand
563 [(QI "general_operand")
564 (HI "general_operand")
565 (SI "general_operand")
566 (DI "x86_64_general_operand")])
568 ;; SSE and x87 SFmode and DFmode floating point modes
569 (define_mode_iterator MODEF [SF DF])
571 ;; All x87 floating point modes
572 (define_mode_iterator X87MODEF [SF DF XF])
574 ;; All integer modes handled by x87 fisttp operator.
575 (define_mode_iterator X87MODEI [HI SI DI])
577 ;; All integer modes handled by integer x87 operators.
578 (define_mode_iterator X87MODEI12 [HI SI])
580 ;; All integer modes handled by SSE cvtts?2si* operators.
581 (define_mode_iterator SSEMODEI24 [SI DI])
583 ;; SSE asm suffix for floating point modes
584 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
586 ;; SSE vector mode corresponding to a scalar mode
587 (define_mode_attr ssevecmode
588 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
590 ;; Instruction suffix for REX 64bit operators.
591 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
593 ;; Scheduling descriptions
595 (include "pentium.md")
598 (include "athlon.md")
602 ;; Operand and operator predicates and constraints
604 (include "predicates.md")
605 (include "constraints.md")
608 ;; Compare instructions.
610 ;; All compare insns have expanders that save the operands away without
611 ;; actually generating RTL. The bCOND or sCOND (emitted immediately
612 ;; after the cmp) will actually emit the cmpM.
614 (define_expand "cmpti"
615 [(set (reg:CC FLAGS_REG)
616 (compare:CC (match_operand:TI 0 "nonimmediate_operand" "")
617 (match_operand:TI 1 "x86_64_general_operand" "")))]
620 if (MEM_P (operands[0]) && MEM_P (operands[1]))
621 operands[0] = force_reg (TImode, operands[0]);
622 ix86_compare_op0 = operands[0];
623 ix86_compare_op1 = operands[1];
627 (define_expand "cmpdi"
628 [(set (reg:CC FLAGS_REG)
629 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
630 (match_operand:DI 1 "x86_64_general_operand" "")))]
633 if (MEM_P (operands[0]) && MEM_P (operands[1]))
634 operands[0] = force_reg (DImode, operands[0]);
635 ix86_compare_op0 = operands[0];
636 ix86_compare_op1 = operands[1];
640 (define_expand "cmpsi"
641 [(set (reg:CC FLAGS_REG)
642 (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
643 (match_operand:SI 1 "general_operand" "")))]
646 if (MEM_P (operands[0]) && MEM_P (operands[1]))
647 operands[0] = force_reg (SImode, operands[0]);
648 ix86_compare_op0 = operands[0];
649 ix86_compare_op1 = operands[1];
653 (define_expand "cmphi"
654 [(set (reg:CC FLAGS_REG)
655 (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
656 (match_operand:HI 1 "general_operand" "")))]
659 if (MEM_P (operands[0]) && MEM_P (operands[1]))
660 operands[0] = force_reg (HImode, operands[0]);
661 ix86_compare_op0 = operands[0];
662 ix86_compare_op1 = operands[1];
666 (define_expand "cmpqi"
667 [(set (reg:CC FLAGS_REG)
668 (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
669 (match_operand:QI 1 "general_operand" "")))]
672 if (MEM_P (operands[0]) && MEM_P (operands[1]))
673 operands[0] = force_reg (QImode, operands[0]);
674 ix86_compare_op0 = operands[0];
675 ix86_compare_op1 = operands[1];
679 (define_insn "cmpdi_ccno_1_rex64"
680 [(set (reg FLAGS_REG)
681 (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
682 (match_operand:DI 1 "const0_operand" "n,n")))]
683 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
686 cmp{q}\t{%1, %0|%0, %1}"
687 [(set_attr "type" "test,icmp")
688 (set_attr "length_immediate" "0,1")
689 (set_attr "mode" "DI")])
691 (define_insn "*cmpdi_minus_1_rex64"
692 [(set (reg FLAGS_REG)
693 (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
694 (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
696 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
697 "cmp{q}\t{%1, %0|%0, %1}"
698 [(set_attr "type" "icmp")
699 (set_attr "mode" "DI")])
701 (define_expand "cmpdi_1_rex64"
702 [(set (reg:CC FLAGS_REG)
703 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
704 (match_operand:DI 1 "general_operand" "")))]
708 (define_insn "cmpdi_1_insn_rex64"
709 [(set (reg FLAGS_REG)
710 (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
711 (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
712 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
713 "cmp{q}\t{%1, %0|%0, %1}"
714 [(set_attr "type" "icmp")
715 (set_attr "mode" "DI")])
718 (define_insn "*cmpsi_ccno_1"
719 [(set (reg FLAGS_REG)
720 (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
721 (match_operand:SI 1 "const0_operand" "n,n")))]
722 "ix86_match_ccmode (insn, CCNOmode)"
725 cmp{l}\t{%1, %0|%0, %1}"
726 [(set_attr "type" "test,icmp")
727 (set_attr "length_immediate" "0,1")
728 (set_attr "mode" "SI")])
730 (define_insn "*cmpsi_minus_1"
731 [(set (reg FLAGS_REG)
732 (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
733 (match_operand:SI 1 "general_operand" "ri,mr"))
735 "ix86_match_ccmode (insn, CCGOCmode)"
736 "cmp{l}\t{%1, %0|%0, %1}"
737 [(set_attr "type" "icmp")
738 (set_attr "mode" "SI")])
740 (define_expand "cmpsi_1"
741 [(set (reg:CC FLAGS_REG)
742 (compare:CC (match_operand:SI 0 "nonimmediate_operand" "")
743 (match_operand:SI 1 "general_operand" "")))]
747 (define_insn "*cmpsi_1_insn"
748 [(set (reg FLAGS_REG)
749 (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
750 (match_operand:SI 1 "general_operand" "ri,mr")))]
751 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
752 && ix86_match_ccmode (insn, CCmode)"
753 "cmp{l}\t{%1, %0|%0, %1}"
754 [(set_attr "type" "icmp")
755 (set_attr "mode" "SI")])
757 (define_insn "*cmphi_ccno_1"
758 [(set (reg FLAGS_REG)
759 (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
760 (match_operand:HI 1 "const0_operand" "n,n")))]
761 "ix86_match_ccmode (insn, CCNOmode)"
764 cmp{w}\t{%1, %0|%0, %1}"
765 [(set_attr "type" "test,icmp")
766 (set_attr "length_immediate" "0,1")
767 (set_attr "mode" "HI")])
769 (define_insn "*cmphi_minus_1"
770 [(set (reg FLAGS_REG)
771 (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
772 (match_operand:HI 1 "general_operand" "ri,mr"))
774 "ix86_match_ccmode (insn, CCGOCmode)"
775 "cmp{w}\t{%1, %0|%0, %1}"
776 [(set_attr "type" "icmp")
777 (set_attr "mode" "HI")])
779 (define_insn "*cmphi_1"
780 [(set (reg FLAGS_REG)
781 (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
782 (match_operand:HI 1 "general_operand" "ri,mr")))]
783 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
784 && ix86_match_ccmode (insn, CCmode)"
785 "cmp{w}\t{%1, %0|%0, %1}"
786 [(set_attr "type" "icmp")
787 (set_attr "mode" "HI")])
789 (define_insn "*cmpqi_ccno_1"
790 [(set (reg FLAGS_REG)
791 (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
792 (match_operand:QI 1 "const0_operand" "n,n")))]
793 "ix86_match_ccmode (insn, CCNOmode)"
796 cmp{b}\t{$0, %0|%0, 0}"
797 [(set_attr "type" "test,icmp")
798 (set_attr "length_immediate" "0,1")
799 (set_attr "mode" "QI")])
801 (define_insn "*cmpqi_1"
802 [(set (reg FLAGS_REG)
803 (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
804 (match_operand:QI 1 "general_operand" "qi,mq")))]
805 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
806 && ix86_match_ccmode (insn, CCmode)"
807 "cmp{b}\t{%1, %0|%0, %1}"
808 [(set_attr "type" "icmp")
809 (set_attr "mode" "QI")])
811 (define_insn "*cmpqi_minus_1"
812 [(set (reg FLAGS_REG)
813 (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
814 (match_operand:QI 1 "general_operand" "qi,mq"))
816 "ix86_match_ccmode (insn, CCGOCmode)"
817 "cmp{b}\t{%1, %0|%0, %1}"
818 [(set_attr "type" "icmp")
819 (set_attr "mode" "QI")])
821 (define_insn "*cmpqi_ext_1"
822 [(set (reg FLAGS_REG)
824 (match_operand:QI 0 "general_operand" "Qm")
827 (match_operand 1 "ext_register_operand" "Q")
830 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
831 "cmp{b}\t{%h1, %0|%0, %h1}"
832 [(set_attr "type" "icmp")
833 (set_attr "mode" "QI")])
835 (define_insn "*cmpqi_ext_1_rex64"
836 [(set (reg FLAGS_REG)
838 (match_operand:QI 0 "register_operand" "Q")
841 (match_operand 1 "ext_register_operand" "Q")
844 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
845 "cmp{b}\t{%h1, %0|%0, %h1}"
846 [(set_attr "type" "icmp")
847 (set_attr "mode" "QI")])
849 (define_insn "*cmpqi_ext_2"
850 [(set (reg FLAGS_REG)
854 (match_operand 0 "ext_register_operand" "Q")
857 (match_operand:QI 1 "const0_operand" "n")))]
858 "ix86_match_ccmode (insn, CCNOmode)"
860 [(set_attr "type" "test")
861 (set_attr "length_immediate" "0")
862 (set_attr "mode" "QI")])
864 (define_expand "cmpqi_ext_3"
865 [(set (reg:CC FLAGS_REG)
869 (match_operand 0 "ext_register_operand" "")
872 (match_operand:QI 1 "general_operand" "")))]
876 (define_insn "cmpqi_ext_3_insn"
877 [(set (reg FLAGS_REG)
881 (match_operand 0 "ext_register_operand" "Q")
884 (match_operand:QI 1 "general_operand" "Qmn")))]
885 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
886 "cmp{b}\t{%1, %h0|%h0, %1}"
887 [(set_attr "type" "icmp")
888 (set_attr "mode" "QI")])
890 (define_insn "cmpqi_ext_3_insn_rex64"
891 [(set (reg FLAGS_REG)
895 (match_operand 0 "ext_register_operand" "Q")
898 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
899 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
900 "cmp{b}\t{%1, %h0|%h0, %1}"
901 [(set_attr "type" "icmp")
902 (set_attr "mode" "QI")])
904 (define_insn "*cmpqi_ext_4"
905 [(set (reg FLAGS_REG)
909 (match_operand 0 "ext_register_operand" "Q")
914 (match_operand 1 "ext_register_operand" "Q")
917 "ix86_match_ccmode (insn, CCmode)"
918 "cmp{b}\t{%h1, %h0|%h0, %h1}"
919 [(set_attr "type" "icmp")
920 (set_attr "mode" "QI")])
922 ;; These implement float point compares.
923 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
924 ;; which would allow mix and match FP modes on the compares. Which is what
925 ;; the old patterns did, but with many more of them.
927 (define_expand "cmpxf"
928 [(set (reg:CC FLAGS_REG)
929 (compare:CC (match_operand:XF 0 "nonmemory_operand" "")
930 (match_operand:XF 1 "nonmemory_operand" "")))]
933 ix86_compare_op0 = operands[0];
934 ix86_compare_op1 = operands[1];
938 (define_expand "cmp<mode>"
939 [(set (reg:CC FLAGS_REG)
940 (compare:CC (match_operand:MODEF 0 "cmp_fp_expander_operand" "")
941 (match_operand:MODEF 1 "cmp_fp_expander_operand" "")))]
942 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
944 ix86_compare_op0 = operands[0];
945 ix86_compare_op1 = operands[1];
949 ;; FP compares, step 1:
950 ;; Set the FP condition codes.
952 ;; CCFPmode compare with exceptions
953 ;; CCFPUmode compare with no exceptions
955 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
956 ;; used to manage the reg stack popping would not be preserved.
958 (define_insn "*cmpfp_0"
959 [(set (match_operand:HI 0 "register_operand" "=a")
962 (match_operand 1 "register_operand" "f")
963 (match_operand 2 "const0_operand" "X"))]
965 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
966 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
967 "* return output_fp_compare (insn, operands, 0, 0);"
968 [(set_attr "type" "multi")
969 (set_attr "unit" "i387")
971 (cond [(match_operand:SF 1 "" "")
973 (match_operand:DF 1 "" "")
976 (const_string "XF")))])
978 (define_insn_and_split "*cmpfp_0_cc"
979 [(set (reg:CCFP FLAGS_REG)
981 (match_operand 1 "register_operand" "f")
982 (match_operand 2 "const0_operand" "X")))
983 (clobber (match_operand:HI 0 "register_operand" "=a"))]
984 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
985 && TARGET_SAHF && !TARGET_CMOVE
986 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
988 "&& reload_completed"
991 [(compare:CCFP (match_dup 1)(match_dup 2))]
993 (set (reg:CC FLAGS_REG)
994 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
996 [(set_attr "type" "multi")
997 (set_attr "unit" "i387")
999 (cond [(match_operand:SF 1 "" "")
1001 (match_operand:DF 1 "" "")
1004 (const_string "XF")))])
1006 (define_insn "*cmpfp_xf"
1007 [(set (match_operand:HI 0 "register_operand" "=a")
1010 (match_operand:XF 1 "register_operand" "f")
1011 (match_operand:XF 2 "register_operand" "f"))]
1014 "* return output_fp_compare (insn, operands, 0, 0);"
1015 [(set_attr "type" "multi")
1016 (set_attr "unit" "i387")
1017 (set_attr "mode" "XF")])
1019 (define_insn_and_split "*cmpfp_xf_cc"
1020 [(set (reg:CCFP FLAGS_REG)
1022 (match_operand:XF 1 "register_operand" "f")
1023 (match_operand:XF 2 "register_operand" "f")))
1024 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1026 && TARGET_SAHF && !TARGET_CMOVE"
1028 "&& reload_completed"
1031 [(compare:CCFP (match_dup 1)(match_dup 2))]
1033 (set (reg:CC FLAGS_REG)
1034 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1036 [(set_attr "type" "multi")
1037 (set_attr "unit" "i387")
1038 (set_attr "mode" "XF")])
1040 (define_insn "*cmpfp_<mode>"
1041 [(set (match_operand:HI 0 "register_operand" "=a")
1044 (match_operand:MODEF 1 "register_operand" "f")
1045 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1048 "* return output_fp_compare (insn, operands, 0, 0);"
1049 [(set_attr "type" "multi")
1050 (set_attr "unit" "i387")
1051 (set_attr "mode" "<MODE>")])
1053 (define_insn_and_split "*cmpfp_<mode>_cc"
1054 [(set (reg:CCFP FLAGS_REG)
1056 (match_operand:MODEF 1 "register_operand" "f")
1057 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1058 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1060 && TARGET_SAHF && !TARGET_CMOVE"
1062 "&& reload_completed"
1065 [(compare:CCFP (match_dup 1)(match_dup 2))]
1067 (set (reg:CC FLAGS_REG)
1068 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1070 [(set_attr "type" "multi")
1071 (set_attr "unit" "i387")
1072 (set_attr "mode" "<MODE>")])
1074 (define_insn "*cmpfp_u"
1075 [(set (match_operand:HI 0 "register_operand" "=a")
1078 (match_operand 1 "register_operand" "f")
1079 (match_operand 2 "register_operand" "f"))]
1081 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1082 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1083 "* return output_fp_compare (insn, operands, 0, 1);"
1084 [(set_attr "type" "multi")
1085 (set_attr "unit" "i387")
1087 (cond [(match_operand:SF 1 "" "")
1089 (match_operand:DF 1 "" "")
1092 (const_string "XF")))])
1094 (define_insn_and_split "*cmpfp_u_cc"
1095 [(set (reg:CCFPU FLAGS_REG)
1097 (match_operand 1 "register_operand" "f")
1098 (match_operand 2 "register_operand" "f")))
1099 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1100 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1101 && TARGET_SAHF && !TARGET_CMOVE
1102 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1104 "&& reload_completed"
1107 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1109 (set (reg:CC FLAGS_REG)
1110 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1112 [(set_attr "type" "multi")
1113 (set_attr "unit" "i387")
1115 (cond [(match_operand:SF 1 "" "")
1117 (match_operand:DF 1 "" "")
1120 (const_string "XF")))])
1122 (define_insn "*cmpfp_<mode>"
1123 [(set (match_operand:HI 0 "register_operand" "=a")
1126 (match_operand 1 "register_operand" "f")
1127 (match_operator 3 "float_operator"
1128 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1130 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1131 && TARGET_USE_<MODE>MODE_FIOP
1132 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1133 "* return output_fp_compare (insn, operands, 0, 0);"
1134 [(set_attr "type" "multi")
1135 (set_attr "unit" "i387")
1136 (set_attr "fp_int_src" "true")
1137 (set_attr "mode" "<MODE>")])
1139 (define_insn_and_split "*cmpfp_<mode>_cc"
1140 [(set (reg:CCFP FLAGS_REG)
1142 (match_operand 1 "register_operand" "f")
1143 (match_operator 3 "float_operator"
1144 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1145 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1146 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1147 && TARGET_SAHF && !TARGET_CMOVE
1148 && TARGET_USE_<MODE>MODE_FIOP
1149 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1151 "&& reload_completed"
1156 (match_op_dup 3 [(match_dup 2)]))]
1158 (set (reg:CC FLAGS_REG)
1159 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1161 [(set_attr "type" "multi")
1162 (set_attr "unit" "i387")
1163 (set_attr "fp_int_src" "true")
1164 (set_attr "mode" "<MODE>")])
1166 ;; FP compares, step 2
1167 ;; Move the fpsw to ax.
1169 (define_insn "x86_fnstsw_1"
1170 [(set (match_operand:HI 0 "register_operand" "=a")
1171 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1174 [(set_attr "length" "2")
1175 (set_attr "mode" "SI")
1176 (set_attr "unit" "i387")])
1178 ;; FP compares, step 3
1179 ;; Get ax into flags, general case.
1181 (define_insn "x86_sahf_1"
1182 [(set (reg:CC FLAGS_REG)
1183 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1187 #ifdef HAVE_AS_IX86_SAHF
1190 return ".byte\t0x9e";
1193 [(set_attr "length" "1")
1194 (set_attr "athlon_decode" "vector")
1195 (set_attr "amdfam10_decode" "direct")
1196 (set_attr "mode" "SI")])
1198 ;; Pentium Pro can do steps 1 through 3 in one go.
1199 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1200 (define_insn "*cmpfp_i_mixed"
1201 [(set (reg:CCFP FLAGS_REG)
1202 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1203 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1204 "TARGET_MIX_SSE_I387
1205 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1206 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1207 "* return output_fp_compare (insn, operands, 1, 0);"
1208 [(set_attr "type" "fcmp,ssecomi")
1210 (if_then_else (match_operand:SF 1 "" "")
1212 (const_string "DF")))
1213 (set_attr "athlon_decode" "vector")
1214 (set_attr "amdfam10_decode" "direct")])
1216 (define_insn "*cmpfp_i_sse"
1217 [(set (reg:CCFP FLAGS_REG)
1218 (compare:CCFP (match_operand 0 "register_operand" "x")
1219 (match_operand 1 "nonimmediate_operand" "xm")))]
1221 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1222 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1223 "* return output_fp_compare (insn, operands, 1, 0);"
1224 [(set_attr "type" "ssecomi")
1226 (if_then_else (match_operand:SF 1 "" "")
1228 (const_string "DF")))
1229 (set_attr "athlon_decode" "vector")
1230 (set_attr "amdfam10_decode" "direct")])
1232 (define_insn "*cmpfp_i_i387"
1233 [(set (reg:CCFP FLAGS_REG)
1234 (compare:CCFP (match_operand 0 "register_operand" "f")
1235 (match_operand 1 "register_operand" "f")))]
1236 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1238 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1239 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1240 "* return output_fp_compare (insn, operands, 1, 0);"
1241 [(set_attr "type" "fcmp")
1243 (cond [(match_operand:SF 1 "" "")
1245 (match_operand:DF 1 "" "")
1248 (const_string "XF")))
1249 (set_attr "athlon_decode" "vector")
1250 (set_attr "amdfam10_decode" "direct")])
1252 (define_insn "*cmpfp_iu_mixed"
1253 [(set (reg:CCFPU FLAGS_REG)
1254 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1255 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1256 "TARGET_MIX_SSE_I387
1257 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1258 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1259 "* return output_fp_compare (insn, operands, 1, 1);"
1260 [(set_attr "type" "fcmp,ssecomi")
1262 (if_then_else (match_operand:SF 1 "" "")
1264 (const_string "DF")))
1265 (set_attr "athlon_decode" "vector")
1266 (set_attr "amdfam10_decode" "direct")])
1268 (define_insn "*cmpfp_iu_sse"
1269 [(set (reg:CCFPU FLAGS_REG)
1270 (compare:CCFPU (match_operand 0 "register_operand" "x")
1271 (match_operand 1 "nonimmediate_operand" "xm")))]
1273 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1274 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1275 "* return output_fp_compare (insn, operands, 1, 1);"
1276 [(set_attr "type" "ssecomi")
1278 (if_then_else (match_operand:SF 1 "" "")
1280 (const_string "DF")))
1281 (set_attr "athlon_decode" "vector")
1282 (set_attr "amdfam10_decode" "direct")])
1284 (define_insn "*cmpfp_iu_387"
1285 [(set (reg:CCFPU FLAGS_REG)
1286 (compare:CCFPU (match_operand 0 "register_operand" "f")
1287 (match_operand 1 "register_operand" "f")))]
1288 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1290 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1291 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1292 "* return output_fp_compare (insn, operands, 1, 1);"
1293 [(set_attr "type" "fcmp")
1295 (cond [(match_operand:SF 1 "" "")
1297 (match_operand:DF 1 "" "")
1300 (const_string "XF")))
1301 (set_attr "athlon_decode" "vector")
1302 (set_attr "amdfam10_decode" "direct")])
1304 ;; Move instructions.
1306 ;; General case of fullword move.
1308 (define_expand "movsi"
1309 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1310 (match_operand:SI 1 "general_operand" ""))]
1312 "ix86_expand_move (SImode, operands); DONE;")
1314 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1317 ;; %%% We don't use a post-inc memory reference because x86 is not a
1318 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1319 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1320 ;; targets without our curiosities, and it is just as easy to represent
1321 ;; this differently.
1323 (define_insn "*pushsi2"
1324 [(set (match_operand:SI 0 "push_operand" "=<")
1325 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1328 [(set_attr "type" "push")
1329 (set_attr "mode" "SI")])
1331 ;; For 64BIT abi we always round up to 8 bytes.
1332 (define_insn "*pushsi2_rex64"
1333 [(set (match_operand:SI 0 "push_operand" "=X")
1334 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1337 [(set_attr "type" "push")
1338 (set_attr "mode" "SI")])
1340 (define_insn "*pushsi2_prologue"
1341 [(set (match_operand:SI 0 "push_operand" "=<")
1342 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1343 (clobber (mem:BLK (scratch)))]
1346 [(set_attr "type" "push")
1347 (set_attr "mode" "SI")])
1349 (define_insn "*popsi1_epilogue"
1350 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1351 (mem:SI (reg:SI SP_REG)))
1352 (set (reg:SI SP_REG)
1353 (plus:SI (reg:SI SP_REG) (const_int 4)))
1354 (clobber (mem:BLK (scratch)))]
1357 [(set_attr "type" "pop")
1358 (set_attr "mode" "SI")])
1360 (define_insn "popsi1"
1361 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1362 (mem:SI (reg:SI SP_REG)))
1363 (set (reg:SI SP_REG)
1364 (plus:SI (reg:SI SP_REG) (const_int 4)))]
1367 [(set_attr "type" "pop")
1368 (set_attr "mode" "SI")])
1370 (define_insn "*movsi_xor"
1371 [(set (match_operand:SI 0 "register_operand" "=r")
1372 (match_operand:SI 1 "const0_operand" "i"))
1373 (clobber (reg:CC FLAGS_REG))]
1374 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1376 [(set_attr "type" "alu1")
1377 (set_attr "mode" "SI")
1378 (set_attr "length_immediate" "0")])
1380 (define_insn "*movsi_or"
1381 [(set (match_operand:SI 0 "register_operand" "=r")
1382 (match_operand:SI 1 "immediate_operand" "i"))
1383 (clobber (reg:CC FLAGS_REG))]
1385 && operands[1] == constm1_rtx
1386 && (TARGET_MOVE_M1_VIA_OR || optimize_size)"
1388 operands[1] = constm1_rtx;
1389 return "or{l}\t{%1, %0|%0, %1}";
1391 [(set_attr "type" "alu1")
1392 (set_attr "mode" "SI")
1393 (set_attr "length_immediate" "1")])
1395 (define_insn "*movsi_1"
1396 [(set (match_operand:SI 0 "nonimmediate_operand"
1397 "=r ,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
1398 (match_operand:SI 1 "general_operand"
1399 "rinm,rin,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
1400 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1402 switch (get_attr_type (insn))
1405 if (get_attr_mode (insn) == MODE_TI)
1406 return "pxor\t%0, %0";
1407 return "xorps\t%0, %0";
1410 switch (get_attr_mode (insn))
1413 return "movdqa\t{%1, %0|%0, %1}";
1415 return "movaps\t{%1, %0|%0, %1}";
1417 return "movd\t{%1, %0|%0, %1}";
1419 return "movss\t{%1, %0|%0, %1}";
1425 return "pxor\t%0, %0";
1428 if (get_attr_mode (insn) == MODE_DI)
1429 return "movq\t{%1, %0|%0, %1}";
1430 return "movd\t{%1, %0|%0, %1}";
1433 return "lea{l}\t{%1, %0|%0, %1}";
1436 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1437 return "mov{l}\t{%1, %0|%0, %1}";
1441 (cond [(eq_attr "alternative" "2")
1442 (const_string "mmxadd")
1443 (eq_attr "alternative" "3,4,5")
1444 (const_string "mmxmov")
1445 (eq_attr "alternative" "6")
1446 (const_string "sselog1")
1447 (eq_attr "alternative" "7,8,9,10,11")
1448 (const_string "ssemov")
1449 (match_operand:DI 1 "pic_32bit_operand" "")
1450 (const_string "lea")
1452 (const_string "imov")))
1454 (cond [(eq_attr "alternative" "2,3")
1456 (eq_attr "alternative" "6,7")
1458 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1459 (const_string "V4SF")
1460 (const_string "TI"))
1461 (and (eq_attr "alternative" "8,9,10,11")
1462 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
1465 (const_string "SI")))])
1467 ;; Stores and loads of ax to arbitrary constant address.
1468 ;; We fake an second form of instruction to force reload to load address
1469 ;; into register when rax is not available
1470 (define_insn "*movabssi_1_rex64"
1471 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1472 (match_operand:SI 1 "nonmemory_operand" "a,er"))]
1473 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1475 movabs{l}\t{%1, %P0|%P0, %1}
1476 mov{l}\t{%1, %a0|%a0, %1}"
1477 [(set_attr "type" "imov")
1478 (set_attr "modrm" "0,*")
1479 (set_attr "length_address" "8,0")
1480 (set_attr "length_immediate" "0,*")
1481 (set_attr "memory" "store")
1482 (set_attr "mode" "SI")])
1484 (define_insn "*movabssi_2_rex64"
1485 [(set (match_operand:SI 0 "register_operand" "=a,r")
1486 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1487 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1489 movabs{l}\t{%P1, %0|%0, %P1}
1490 mov{l}\t{%a1, %0|%0, %a1}"
1491 [(set_attr "type" "imov")
1492 (set_attr "modrm" "0,*")
1493 (set_attr "length_address" "8,0")
1494 (set_attr "length_immediate" "0")
1495 (set_attr "memory" "load")
1496 (set_attr "mode" "SI")])
1498 (define_insn "*swapsi"
1499 [(set (match_operand:SI 0 "register_operand" "+r")
1500 (match_operand:SI 1 "register_operand" "+r"))
1505 [(set_attr "type" "imov")
1506 (set_attr "mode" "SI")
1507 (set_attr "pent_pair" "np")
1508 (set_attr "athlon_decode" "vector")
1509 (set_attr "amdfam10_decode" "double")])
1511 (define_expand "movhi"
1512 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1513 (match_operand:HI 1 "general_operand" ""))]
1515 "ix86_expand_move (HImode, operands); DONE;")
1517 (define_insn "*pushhi2"
1518 [(set (match_operand:HI 0 "push_operand" "=X")
1519 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1522 [(set_attr "type" "push")
1523 (set_attr "mode" "SI")])
1525 ;; For 64BIT abi we always round up to 8 bytes.
1526 (define_insn "*pushhi2_rex64"
1527 [(set (match_operand:HI 0 "push_operand" "=X")
1528 (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1531 [(set_attr "type" "push")
1532 (set_attr "mode" "DI")])
1534 (define_insn "*movhi_1"
1535 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
1536 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
1537 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1539 switch (get_attr_type (insn))
1542 /* movzwl is faster than movw on p2 due to partial word stalls,
1543 though not as fast as an aligned movl. */
1544 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1546 if (get_attr_mode (insn) == MODE_SI)
1547 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1549 return "mov{w}\t{%1, %0|%0, %1}";
1553 (cond [(ne (symbol_ref "optimize_size") (const_int 0))
1554 (const_string "imov")
1555 (and (eq_attr "alternative" "0")
1556 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1558 (eq (symbol_ref "TARGET_HIMODE_MATH")
1560 (const_string "imov")
1561 (and (eq_attr "alternative" "1,2")
1562 (match_operand:HI 1 "aligned_operand" ""))
1563 (const_string "imov")
1564 (and (ne (symbol_ref "TARGET_MOVX")
1566 (eq_attr "alternative" "0,2"))
1567 (const_string "imovx")
1569 (const_string "imov")))
1571 (cond [(eq_attr "type" "imovx")
1573 (and (eq_attr "alternative" "1,2")
1574 (match_operand:HI 1 "aligned_operand" ""))
1576 (and (eq_attr "alternative" "0")
1577 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1579 (eq (symbol_ref "TARGET_HIMODE_MATH")
1583 (const_string "HI")))])
1585 ;; Stores and loads of ax to arbitrary constant address.
1586 ;; We fake an second form of instruction to force reload to load address
1587 ;; into register when rax is not available
1588 (define_insn "*movabshi_1_rex64"
1589 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1590 (match_operand:HI 1 "nonmemory_operand" "a,er"))]
1591 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1593 movabs{w}\t{%1, %P0|%P0, %1}
1594 mov{w}\t{%1, %a0|%a0, %1}"
1595 [(set_attr "type" "imov")
1596 (set_attr "modrm" "0,*")
1597 (set_attr "length_address" "8,0")
1598 (set_attr "length_immediate" "0,*")
1599 (set_attr "memory" "store")
1600 (set_attr "mode" "HI")])
1602 (define_insn "*movabshi_2_rex64"
1603 [(set (match_operand:HI 0 "register_operand" "=a,r")
1604 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1605 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1607 movabs{w}\t{%P1, %0|%0, %P1}
1608 mov{w}\t{%a1, %0|%0, %a1}"
1609 [(set_attr "type" "imov")
1610 (set_attr "modrm" "0,*")
1611 (set_attr "length_address" "8,0")
1612 (set_attr "length_immediate" "0")
1613 (set_attr "memory" "load")
1614 (set_attr "mode" "HI")])
1616 (define_insn "*swaphi_1"
1617 [(set (match_operand:HI 0 "register_operand" "+r")
1618 (match_operand:HI 1 "register_operand" "+r"))
1621 "!TARGET_PARTIAL_REG_STALL || optimize_size"
1623 [(set_attr "type" "imov")
1624 (set_attr "mode" "SI")
1625 (set_attr "pent_pair" "np")
1626 (set_attr "athlon_decode" "vector")
1627 (set_attr "amdfam10_decode" "double")])
1629 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1630 (define_insn "*swaphi_2"
1631 [(set (match_operand:HI 0 "register_operand" "+r")
1632 (match_operand:HI 1 "register_operand" "+r"))
1635 "TARGET_PARTIAL_REG_STALL"
1637 [(set_attr "type" "imov")
1638 (set_attr "mode" "HI")
1639 (set_attr "pent_pair" "np")
1640 (set_attr "athlon_decode" "vector")])
1642 (define_expand "movstricthi"
1643 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1644 (match_operand:HI 1 "general_operand" ""))]
1645 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1647 /* Don't generate memory->memory moves, go through a register */
1648 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1649 operands[1] = force_reg (HImode, operands[1]);
1652 (define_insn "*movstricthi_1"
1653 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1654 (match_operand:HI 1 "general_operand" "rn,m"))]
1655 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1656 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1657 "mov{w}\t{%1, %0|%0, %1}"
1658 [(set_attr "type" "imov")
1659 (set_attr "mode" "HI")])
1661 (define_insn "*movstricthi_xor"
1662 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1663 (match_operand:HI 1 "const0_operand" "i"))
1664 (clobber (reg:CC FLAGS_REG))]
1666 && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
1668 [(set_attr "type" "alu1")
1669 (set_attr "mode" "HI")
1670 (set_attr "length_immediate" "0")])
1672 (define_expand "movqi"
1673 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1674 (match_operand:QI 1 "general_operand" ""))]
1676 "ix86_expand_move (QImode, operands); DONE;")
1678 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1679 ;; "push a byte". But actually we use pushl, which has the effect
1680 ;; of rounding the amount pushed up to a word.
1682 (define_insn "*pushqi2"
1683 [(set (match_operand:QI 0 "push_operand" "=X")
1684 (match_operand:QI 1 "nonmemory_no_elim_operand" "rn"))]
1687 [(set_attr "type" "push")
1688 (set_attr "mode" "SI")])
1690 ;; For 64BIT abi we always round up to 8 bytes.
1691 (define_insn "*pushqi2_rex64"
1692 [(set (match_operand:QI 0 "push_operand" "=X")
1693 (match_operand:QI 1 "nonmemory_no_elim_operand" "qi"))]
1696 [(set_attr "type" "push")
1697 (set_attr "mode" "DI")])
1699 ;; Situation is quite tricky about when to choose full sized (SImode) move
1700 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
1701 ;; partial register dependency machines (such as AMD Athlon), where QImode
1702 ;; moves issue extra dependency and for partial register stalls machines
1703 ;; that don't use QImode patterns (and QImode move cause stall on the next
1706 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1707 ;; register stall machines with, where we use QImode instructions, since
1708 ;; partial register stall can be caused there. Then we use movzx.
1709 (define_insn "*movqi_1"
1710 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1711 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
1712 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1714 switch (get_attr_type (insn))
1717 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
1718 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
1720 if (get_attr_mode (insn) == MODE_SI)
1721 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1723 return "mov{b}\t{%1, %0|%0, %1}";
1727 (cond [(and (eq_attr "alternative" "5")
1728 (not (match_operand:QI 1 "aligned_operand" "")))
1729 (const_string "imovx")
1730 (ne (symbol_ref "optimize_size") (const_int 0))
1731 (const_string "imov")
1732 (and (eq_attr "alternative" "3")
1733 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1735 (eq (symbol_ref "TARGET_QIMODE_MATH")
1737 (const_string "imov")
1738 (eq_attr "alternative" "3,5")
1739 (const_string "imovx")
1740 (and (ne (symbol_ref "TARGET_MOVX")
1742 (eq_attr "alternative" "2"))
1743 (const_string "imovx")
1745 (const_string "imov")))
1747 (cond [(eq_attr "alternative" "3,4,5")
1749 (eq_attr "alternative" "6")
1751 (eq_attr "type" "imovx")
1753 (and (eq_attr "type" "imov")
1754 (and (eq_attr "alternative" "0,1")
1755 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
1757 (and (eq (symbol_ref "optimize_size")
1759 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1762 ;; Avoid partial register stalls when not using QImode arithmetic
1763 (and (eq_attr "type" "imov")
1764 (and (eq_attr "alternative" "0,1")
1765 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
1767 (eq (symbol_ref "TARGET_QIMODE_MATH")
1771 (const_string "QI")))])
1773 (define_expand "reload_outqi"
1774 [(parallel [(match_operand:QI 0 "" "=m")
1775 (match_operand:QI 1 "register_operand" "r")
1776 (match_operand:QI 2 "register_operand" "=&q")])]
1780 op0 = operands[0]; op1 = operands[1]; op2 = operands[2];
1782 gcc_assert (!reg_overlap_mentioned_p (op2, op0));
1783 if (! q_regs_operand (op1, QImode))
1785 emit_insn (gen_movqi (op2, op1));
1788 emit_insn (gen_movqi (op0, op1));
1792 (define_insn "*swapqi_1"
1793 [(set (match_operand:QI 0 "register_operand" "+r")
1794 (match_operand:QI 1 "register_operand" "+r"))
1797 "!TARGET_PARTIAL_REG_STALL || optimize_size"
1799 [(set_attr "type" "imov")
1800 (set_attr "mode" "SI")
1801 (set_attr "pent_pair" "np")
1802 (set_attr "athlon_decode" "vector")
1803 (set_attr "amdfam10_decode" "vector")])
1805 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1806 (define_insn "*swapqi_2"
1807 [(set (match_operand:QI 0 "register_operand" "+q")
1808 (match_operand:QI 1 "register_operand" "+q"))
1811 "TARGET_PARTIAL_REG_STALL"
1813 [(set_attr "type" "imov")
1814 (set_attr "mode" "QI")
1815 (set_attr "pent_pair" "np")
1816 (set_attr "athlon_decode" "vector")])
1818 (define_expand "movstrictqi"
1819 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1820 (match_operand:QI 1 "general_operand" ""))]
1821 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1823 /* Don't generate memory->memory moves, go through a register. */
1824 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1825 operands[1] = force_reg (QImode, operands[1]);
1828 (define_insn "*movstrictqi_1"
1829 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
1830 (match_operand:QI 1 "general_operand" "*qn,m"))]
1831 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1832 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1833 "mov{b}\t{%1, %0|%0, %1}"
1834 [(set_attr "type" "imov")
1835 (set_attr "mode" "QI")])
1837 (define_insn "*movstrictqi_xor"
1838 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
1839 (match_operand:QI 1 "const0_operand" "i"))
1840 (clobber (reg:CC FLAGS_REG))]
1841 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1843 [(set_attr "type" "alu1")
1844 (set_attr "mode" "QI")
1845 (set_attr "length_immediate" "0")])
1847 (define_insn "*movsi_extv_1"
1848 [(set (match_operand:SI 0 "register_operand" "=R")
1849 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
1853 "movs{bl|x}\t{%h1, %0|%0, %h1}"
1854 [(set_attr "type" "imovx")
1855 (set_attr "mode" "SI")])
1857 (define_insn "*movhi_extv_1"
1858 [(set (match_operand:HI 0 "register_operand" "=R")
1859 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
1863 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
1864 [(set_attr "type" "imovx")
1865 (set_attr "mode" "SI")])
1867 (define_insn "*movqi_extv_1"
1868 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
1869 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1874 switch (get_attr_type (insn))
1877 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1879 return "mov{b}\t{%h1, %0|%0, %h1}";
1883 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1884 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1885 (ne (symbol_ref "TARGET_MOVX")
1887 (const_string "imovx")
1888 (const_string "imov")))
1890 (if_then_else (eq_attr "type" "imovx")
1892 (const_string "QI")))])
1894 (define_insn "*movqi_extv_1_rex64"
1895 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
1896 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1901 switch (get_attr_type (insn))
1904 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1906 return "mov{b}\t{%h1, %0|%0, %h1}";
1910 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1911 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1912 (ne (symbol_ref "TARGET_MOVX")
1914 (const_string "imovx")
1915 (const_string "imov")))
1917 (if_then_else (eq_attr "type" "imovx")
1919 (const_string "QI")))])
1921 ;; Stores and loads of ax to arbitrary constant address.
1922 ;; We fake an second form of instruction to force reload to load address
1923 ;; into register when rax is not available
1924 (define_insn "*movabsqi_1_rex64"
1925 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1926 (match_operand:QI 1 "nonmemory_operand" "a,er"))]
1927 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1929 movabs{b}\t{%1, %P0|%P0, %1}
1930 mov{b}\t{%1, %a0|%a0, %1}"
1931 [(set_attr "type" "imov")
1932 (set_attr "modrm" "0,*")
1933 (set_attr "length_address" "8,0")
1934 (set_attr "length_immediate" "0,*")
1935 (set_attr "memory" "store")
1936 (set_attr "mode" "QI")])
1938 (define_insn "*movabsqi_2_rex64"
1939 [(set (match_operand:QI 0 "register_operand" "=a,r")
1940 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1941 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1943 movabs{b}\t{%P1, %0|%0, %P1}
1944 mov{b}\t{%a1, %0|%0, %a1}"
1945 [(set_attr "type" "imov")
1946 (set_attr "modrm" "0,*")
1947 (set_attr "length_address" "8,0")
1948 (set_attr "length_immediate" "0")
1949 (set_attr "memory" "load")
1950 (set_attr "mode" "QI")])
1952 (define_insn "*movdi_extzv_1"
1953 [(set (match_operand:DI 0 "register_operand" "=R")
1954 (zero_extract:DI (match_operand 1 "ext_register_operand" "Q")
1958 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
1959 [(set_attr "type" "imovx")
1960 (set_attr "mode" "DI")])
1962 (define_insn "*movsi_extzv_1"
1963 [(set (match_operand:SI 0 "register_operand" "=R")
1964 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
1968 "movz{bl|x}\t{%h1, %0|%0, %h1}"
1969 [(set_attr "type" "imovx")
1970 (set_attr "mode" "SI")])
1972 (define_insn "*movqi_extzv_2"
1973 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
1974 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
1979 switch (get_attr_type (insn))
1982 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
1984 return "mov{b}\t{%h1, %0|%0, %h1}";
1988 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1989 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1990 (ne (symbol_ref "TARGET_MOVX")
1992 (const_string "imovx")
1993 (const_string "imov")))
1995 (if_then_else (eq_attr "type" "imovx")
1997 (const_string "QI")))])
1999 (define_insn "*movqi_extzv_2_rex64"
2000 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2001 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2006 switch (get_attr_type (insn))
2009 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2011 return "mov{b}\t{%h1, %0|%0, %h1}";
2015 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2016 (ne (symbol_ref "TARGET_MOVX")
2018 (const_string "imovx")
2019 (const_string "imov")))
2021 (if_then_else (eq_attr "type" "imovx")
2023 (const_string "QI")))])
2025 (define_insn "movsi_insv_1"
2026 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2029 (match_operand:SI 1 "general_operand" "Qmn"))]
2031 "mov{b}\t{%b1, %h0|%h0, %b1}"
2032 [(set_attr "type" "imov")
2033 (set_attr "mode" "QI")])
2035 (define_insn "*movsi_insv_1_rex64"
2036 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2039 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2041 "mov{b}\t{%b1, %h0|%h0, %b1}"
2042 [(set_attr "type" "imov")
2043 (set_attr "mode" "QI")])
2045 (define_insn "movdi_insv_1_rex64"
2046 [(set (zero_extract:DI (match_operand 0 "ext_register_operand" "+Q")
2049 (match_operand:DI 1 "nonmemory_operand" "Qn"))]
2051 "mov{b}\t{%b1, %h0|%h0, %b1}"
2052 [(set_attr "type" "imov")
2053 (set_attr "mode" "QI")])
2055 (define_insn "*movqi_insv_2"
2056 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2059 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2062 "mov{b}\t{%h1, %h0|%h0, %h1}"
2063 [(set_attr "type" "imov")
2064 (set_attr "mode" "QI")])
2066 (define_expand "movdi"
2067 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2068 (match_operand:DI 1 "general_operand" ""))]
2070 "ix86_expand_move (DImode, operands); DONE;")
2072 (define_insn "*pushdi"
2073 [(set (match_operand:DI 0 "push_operand" "=<")
2074 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2078 (define_insn "*pushdi2_rex64"
2079 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2080 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2085 [(set_attr "type" "push,multi")
2086 (set_attr "mode" "DI")])
2088 ;; Convert impossible pushes of immediate to existing instructions.
2089 ;; First try to get scratch register and go through it. In case this
2090 ;; fails, push sign extended lower part first and then overwrite
2091 ;; upper part by 32bit move.
2093 [(match_scratch:DI 2 "r")
2094 (set (match_operand:DI 0 "push_operand" "")
2095 (match_operand:DI 1 "immediate_operand" ""))]
2096 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2097 && !x86_64_immediate_operand (operands[1], DImode)"
2098 [(set (match_dup 2) (match_dup 1))
2099 (set (match_dup 0) (match_dup 2))]
2102 ;; We need to define this as both peepholer and splitter for case
2103 ;; peephole2 pass is not run.
2104 ;; "&& 1" is needed to keep it from matching the previous pattern.
2106 [(set (match_operand:DI 0 "push_operand" "")
2107 (match_operand:DI 1 "immediate_operand" ""))]
2108 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2109 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2110 [(set (match_dup 0) (match_dup 1))
2111 (set (match_dup 2) (match_dup 3))]
2112 "split_di (operands + 1, 1, operands + 2, operands + 3);
2113 operands[1] = gen_lowpart (DImode, operands[2]);
2114 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2119 [(set (match_operand:DI 0 "push_operand" "")
2120 (match_operand:DI 1 "immediate_operand" ""))]
2121 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2122 ? epilogue_completed : reload_completed)
2123 && !symbolic_operand (operands[1], DImode)
2124 && !x86_64_immediate_operand (operands[1], DImode)"
2125 [(set (match_dup 0) (match_dup 1))
2126 (set (match_dup 2) (match_dup 3))]
2127 "split_di (operands + 1, 1, operands + 2, operands + 3);
2128 operands[1] = gen_lowpart (DImode, operands[2]);
2129 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2133 (define_insn "*pushdi2_prologue_rex64"
2134 [(set (match_operand:DI 0 "push_operand" "=<")
2135 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2136 (clobber (mem:BLK (scratch)))]
2139 [(set_attr "type" "push")
2140 (set_attr "mode" "DI")])
2142 (define_insn "*popdi1_epilogue_rex64"
2143 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2144 (mem:DI (reg:DI SP_REG)))
2145 (set (reg:DI SP_REG)
2146 (plus:DI (reg:DI SP_REG) (const_int 8)))
2147 (clobber (mem:BLK (scratch)))]
2150 [(set_attr "type" "pop")
2151 (set_attr "mode" "DI")])
2153 (define_insn "popdi1"
2154 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2155 (mem:DI (reg:DI SP_REG)))
2156 (set (reg:DI SP_REG)
2157 (plus:DI (reg:DI SP_REG) (const_int 8)))]
2160 [(set_attr "type" "pop")
2161 (set_attr "mode" "DI")])
2163 (define_insn "*movdi_xor_rex64"
2164 [(set (match_operand:DI 0 "register_operand" "=r")
2165 (match_operand:DI 1 "const0_operand" "i"))
2166 (clobber (reg:CC FLAGS_REG))]
2167 "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
2168 && reload_completed"
2170 [(set_attr "type" "alu1")
2171 (set_attr "mode" "SI")
2172 (set_attr "length_immediate" "0")])
2174 (define_insn "*movdi_or_rex64"
2175 [(set (match_operand:DI 0 "register_operand" "=r")
2176 (match_operand:DI 1 "const_int_operand" "i"))
2177 (clobber (reg:CC FLAGS_REG))]
2178 "TARGET_64BIT && (TARGET_MOVE_M1_VIA_OR || optimize_size)
2180 && operands[1] == constm1_rtx"
2182 operands[1] = constm1_rtx;
2183 return "or{q}\t{%1, %0|%0, %1}";
2185 [(set_attr "type" "alu1")
2186 (set_attr "mode" "DI")
2187 (set_attr "length_immediate" "1")])
2189 (define_insn "*movdi_2"
2190 [(set (match_operand:DI 0 "nonimmediate_operand"
2191 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2192 (match_operand:DI 1 "general_operand"
2193 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2194 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2199 movq\t{%1, %0|%0, %1}
2200 movq\t{%1, %0|%0, %1}
2202 movq\t{%1, %0|%0, %1}
2203 movdqa\t{%1, %0|%0, %1}
2204 movq\t{%1, %0|%0, %1}
2206 movlps\t{%1, %0|%0, %1}
2207 movaps\t{%1, %0|%0, %1}
2208 movlps\t{%1, %0|%0, %1}"
2209 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2210 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2213 [(set (match_operand:DI 0 "push_operand" "")
2214 (match_operand:DI 1 "general_operand" ""))]
2215 "!TARGET_64BIT && reload_completed
2216 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2218 "ix86_split_long_move (operands); DONE;")
2220 ;; %%% This multiword shite has got to go.
2222 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2223 (match_operand:DI 1 "general_operand" ""))]
2224 "!TARGET_64BIT && reload_completed
2225 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2226 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2228 "ix86_split_long_move (operands); DONE;")
2230 (define_insn "*movdi_1_rex64"
2231 [(set (match_operand:DI 0 "nonimmediate_operand"
2232 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
2233 (match_operand:DI 1 "general_operand"
2234 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
2235 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2237 switch (get_attr_type (insn))
2240 if (SSE_REG_P (operands[0]))
2241 return "movq2dq\t{%1, %0|%0, %1}";
2243 return "movdq2q\t{%1, %0|%0, %1}";
2246 if (get_attr_mode (insn) == MODE_TI)
2247 return "movdqa\t{%1, %0|%0, %1}";
2251 /* Moves from and into integer register is done using movd
2252 opcode with REX prefix. */
2253 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2254 return "movd\t{%1, %0|%0, %1}";
2255 return "movq\t{%1, %0|%0, %1}";
2259 return "pxor\t%0, %0";
2265 return "lea{q}\t{%a1, %0|%0, %a1}";
2268 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2269 if (get_attr_mode (insn) == MODE_SI)
2270 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2271 else if (which_alternative == 2)
2272 return "movabs{q}\t{%1, %0|%0, %1}";
2274 return "mov{q}\t{%1, %0|%0, %1}";
2278 (cond [(eq_attr "alternative" "5")
2279 (const_string "mmxadd")
2280 (eq_attr "alternative" "6,7,8,9,10")
2281 (const_string "mmxmov")
2282 (eq_attr "alternative" "11")
2283 (const_string "sselog1")
2284 (eq_attr "alternative" "12,13,14,15,16")
2285 (const_string "ssemov")
2286 (eq_attr "alternative" "17,18")
2287 (const_string "ssecvt")
2288 (eq_attr "alternative" "4")
2289 (const_string "multi")
2290 (match_operand:DI 1 "pic_32bit_operand" "")
2291 (const_string "lea")
2293 (const_string "imov")))
2294 (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")
2295 (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")
2296 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2298 ;; Stores and loads of ax to arbitrary constant address.
2299 ;; We fake an second form of instruction to force reload to load address
2300 ;; into register when rax is not available
2301 (define_insn "*movabsdi_1_rex64"
2302 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2303 (match_operand:DI 1 "nonmemory_operand" "a,er"))]
2304 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2306 movabs{q}\t{%1, %P0|%P0, %1}
2307 mov{q}\t{%1, %a0|%a0, %1}"
2308 [(set_attr "type" "imov")
2309 (set_attr "modrm" "0,*")
2310 (set_attr "length_address" "8,0")
2311 (set_attr "length_immediate" "0,*")
2312 (set_attr "memory" "store")
2313 (set_attr "mode" "DI")])
2315 (define_insn "*movabsdi_2_rex64"
2316 [(set (match_operand:DI 0 "register_operand" "=a,r")
2317 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2318 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2320 movabs{q}\t{%P1, %0|%0, %P1}
2321 mov{q}\t{%a1, %0|%0, %a1}"
2322 [(set_attr "type" "imov")
2323 (set_attr "modrm" "0,*")
2324 (set_attr "length_address" "8,0")
2325 (set_attr "length_immediate" "0")
2326 (set_attr "memory" "load")
2327 (set_attr "mode" "DI")])
2329 ;; Convert impossible stores of immediate to existing instructions.
2330 ;; First try to get scratch register and go through it. In case this
2331 ;; fails, move by 32bit parts.
2333 [(match_scratch:DI 2 "r")
2334 (set (match_operand:DI 0 "memory_operand" "")
2335 (match_operand:DI 1 "immediate_operand" ""))]
2336 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2337 && !x86_64_immediate_operand (operands[1], DImode)"
2338 [(set (match_dup 2) (match_dup 1))
2339 (set (match_dup 0) (match_dup 2))]
2342 ;; We need to define this as both peepholer and splitter for case
2343 ;; peephole2 pass is not run.
2344 ;; "&& 1" is needed to keep it from matching the previous pattern.
2346 [(set (match_operand:DI 0 "memory_operand" "")
2347 (match_operand:DI 1 "immediate_operand" ""))]
2348 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2349 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2350 [(set (match_dup 2) (match_dup 3))
2351 (set (match_dup 4) (match_dup 5))]
2352 "split_di (operands, 2, operands + 2, operands + 4);")
2355 [(set (match_operand:DI 0 "memory_operand" "")
2356 (match_operand:DI 1 "immediate_operand" ""))]
2357 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2358 ? epilogue_completed : reload_completed)
2359 && !symbolic_operand (operands[1], DImode)
2360 && !x86_64_immediate_operand (operands[1], DImode)"
2361 [(set (match_dup 2) (match_dup 3))
2362 (set (match_dup 4) (match_dup 5))]
2363 "split_di (operands, 2, operands + 2, operands + 4);")
2365 (define_insn "*swapdi_rex64"
2366 [(set (match_operand:DI 0 "register_operand" "+r")
2367 (match_operand:DI 1 "register_operand" "+r"))
2372 [(set_attr "type" "imov")
2373 (set_attr "mode" "DI")
2374 (set_attr "pent_pair" "np")
2375 (set_attr "athlon_decode" "vector")
2376 (set_attr "amdfam10_decode" "double")])
2378 (define_expand "movti"
2379 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2380 (match_operand:TI 1 "nonimmediate_operand" ""))]
2381 "TARGET_SSE || TARGET_64BIT"
2384 ix86_expand_move (TImode, operands);
2385 else if (push_operand (operands[0], TImode))
2386 ix86_expand_push (TImode, operands[1]);
2388 ix86_expand_vector_move (TImode, operands);
2392 (define_insn "*movti_internal"
2393 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
2394 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
2395 "TARGET_SSE && !TARGET_64BIT
2396 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2398 switch (which_alternative)
2401 if (get_attr_mode (insn) == MODE_V4SF)
2402 return "xorps\t%0, %0";
2404 return "pxor\t%0, %0";
2407 /* TDmode values are passed as TImode on the stack. Moving them
2408 to stack may result in unaligned memory access. */
2409 if (misaligned_operand (operands[0], TImode)
2410 || misaligned_operand (operands[1], TImode))
2412 if (get_attr_mode (insn) == MODE_V4SF)
2413 return "movups\t{%1, %0|%0, %1}";
2415 return "movdqu\t{%1, %0|%0, %1}";
2419 if (get_attr_mode (insn) == MODE_V4SF)
2420 return "movaps\t{%1, %0|%0, %1}";
2422 return "movdqa\t{%1, %0|%0, %1}";
2428 [(set_attr "type" "sselog1,ssemov,ssemov")
2430 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2431 (ne (symbol_ref "optimize_size") (const_int 0)))
2432 (const_string "V4SF")
2433 (and (eq_attr "alternative" "2")
2434 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2436 (const_string "V4SF")]
2437 (const_string "TI")))])
2439 (define_insn "*movti_rex64"
2440 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,x,xm")
2441 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
2443 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2445 switch (which_alternative)
2451 if (get_attr_mode (insn) == MODE_V4SF)
2452 return "xorps\t%0, %0";
2454 return "pxor\t%0, %0";
2457 /* TDmode values are passed as TImode on the stack. Moving them
2458 to stack may result in unaligned memory access. */
2459 if (misaligned_operand (operands[0], TImode)
2460 || misaligned_operand (operands[1], TImode))
2462 if (get_attr_mode (insn) == MODE_V4SF)
2463 return "movups\t{%1, %0|%0, %1}";
2465 return "movdqu\t{%1, %0|%0, %1}";
2469 if (get_attr_mode (insn) == MODE_V4SF)
2470 return "movaps\t{%1, %0|%0, %1}";
2472 return "movdqa\t{%1, %0|%0, %1}";
2478 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
2480 (cond [(eq_attr "alternative" "2,3")
2482 (ne (symbol_ref "optimize_size")
2484 (const_string "V4SF")
2485 (const_string "TI"))
2486 (eq_attr "alternative" "4")
2488 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2490 (ne (symbol_ref "optimize_size")
2492 (const_string "V4SF")
2493 (const_string "TI"))]
2494 (const_string "DI")))])
2497 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2498 (match_operand:TI 1 "general_operand" ""))]
2499 "reload_completed && !SSE_REG_P (operands[0])
2500 && !SSE_REG_P (operands[1])"
2502 "ix86_split_long_move (operands); DONE;")
2504 ;; This expands to what emit_move_complex would generate if we didn't
2505 ;; have a movti pattern. Having this avoids problems with reload on
2506 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
2507 ;; to have around all the time.
2508 (define_expand "movcdi"
2509 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
2510 (match_operand:CDI 1 "general_operand" ""))]
2513 if (push_operand (operands[0], CDImode))
2514 emit_move_complex_push (CDImode, operands[0], operands[1]);
2516 emit_move_complex_parts (operands[0], operands[1]);
2520 (define_expand "movsf"
2521 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2522 (match_operand:SF 1 "general_operand" ""))]
2524 "ix86_expand_move (SFmode, operands); DONE;")
2526 (define_insn "*pushsf"
2527 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2528 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2531 /* Anything else should be already split before reg-stack. */
2532 gcc_assert (which_alternative == 1);
2533 return "push{l}\t%1";
2535 [(set_attr "type" "multi,push,multi")
2536 (set_attr "unit" "i387,*,*")
2537 (set_attr "mode" "SF,SI,SF")])
2539 (define_insn "*pushsf_rex64"
2540 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2541 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2544 /* Anything else should be already split before reg-stack. */
2545 gcc_assert (which_alternative == 1);
2546 return "push{q}\t%q1";
2548 [(set_attr "type" "multi,push,multi")
2549 (set_attr "unit" "i387,*,*")
2550 (set_attr "mode" "SF,DI,SF")])
2553 [(set (match_operand:SF 0 "push_operand" "")
2554 (match_operand:SF 1 "memory_operand" ""))]
2556 && MEM_P (operands[1])
2557 && (operands[2] = find_constant_src (insn))"
2562 ;; %%% Kill this when call knows how to work this out.
2564 [(set (match_operand:SF 0 "push_operand" "")
2565 (match_operand:SF 1 "any_fp_register_operand" ""))]
2567 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
2568 (set (mem:SF (reg:SI SP_REG)) (match_dup 1))])
2571 [(set (match_operand:SF 0 "push_operand" "")
2572 (match_operand:SF 1 "any_fp_register_operand" ""))]
2574 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2575 (set (mem:SF (reg:DI SP_REG)) (match_dup 1))])
2577 (define_insn "*movsf_1"
2578 [(set (match_operand:SF 0 "nonimmediate_operand"
2579 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
2580 (match_operand:SF 1 "general_operand"
2581 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
2582 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2583 && (reload_in_progress || reload_completed
2584 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2585 || (!TARGET_SSE_MATH && optimize_size
2586 && standard_80387_constant_p (operands[1]))
2587 || GET_CODE (operands[1]) != CONST_DOUBLE
2588 || memory_operand (operands[0], SFmode))"
2590 switch (which_alternative)
2594 return output_387_reg_move (insn, operands);
2597 return standard_80387_constant_opcode (operands[1]);
2601 return "mov{l}\t{%1, %0|%0, %1}";
2603 if (get_attr_mode (insn) == MODE_TI)
2604 return "pxor\t%0, %0";
2606 return "xorps\t%0, %0";
2608 if (get_attr_mode (insn) == MODE_V4SF)
2609 return "movaps\t{%1, %0|%0, %1}";
2611 return "movss\t{%1, %0|%0, %1}";
2613 return "movss\t{%1, %0|%0, %1}";
2616 case 12: case 13: case 14: case 15:
2617 return "movd\t{%1, %0|%0, %1}";
2620 return "movq\t{%1, %0|%0, %1}";
2626 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
2628 (cond [(eq_attr "alternative" "3,4,9,10")
2630 (eq_attr "alternative" "5")
2632 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2634 (ne (symbol_ref "TARGET_SSE2")
2636 (eq (symbol_ref "optimize_size")
2639 (const_string "V4SF"))
2640 /* For architectures resolving dependencies on
2641 whole SSE registers use APS move to break dependency
2642 chains, otherwise use short move to avoid extra work.
2644 Do the same for architectures resolving dependencies on
2645 the parts. While in DF mode it is better to always handle
2646 just register parts, the SF mode is different due to lack
2647 of instructions to load just part of the register. It is
2648 better to maintain the whole registers in single format
2649 to avoid problems on using packed logical operations. */
2650 (eq_attr "alternative" "6")
2652 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2654 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2656 (const_string "V4SF")
2657 (const_string "SF"))
2658 (eq_attr "alternative" "11")
2659 (const_string "DI")]
2660 (const_string "SF")))])
2662 (define_insn "*swapsf"
2663 [(set (match_operand:SF 0 "fp_register_operand" "+f")
2664 (match_operand:SF 1 "fp_register_operand" "+f"))
2667 "reload_completed || TARGET_80387"
2669 if (STACK_TOP_P (operands[0]))
2674 [(set_attr "type" "fxch")
2675 (set_attr "mode" "SF")])
2677 (define_expand "movdf"
2678 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2679 (match_operand:DF 1 "general_operand" ""))]
2681 "ix86_expand_move (DFmode, operands); DONE;")
2683 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2684 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2685 ;; On the average, pushdf using integers can be still shorter. Allow this
2686 ;; pattern for optimize_size too.
2688 (define_insn "*pushdf_nointeger"
2689 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2690 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2691 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2693 /* This insn should be already split before reg-stack. */
2696 [(set_attr "type" "multi")
2697 (set_attr "unit" "i387,*,*,*")
2698 (set_attr "mode" "DF,SI,SI,DF")])
2700 (define_insn "*pushdf_integer"
2701 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2702 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2703 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2705 /* This insn should be already split before reg-stack. */
2708 [(set_attr "type" "multi")
2709 (set_attr "unit" "i387,*,*")
2710 (set_attr "mode" "DF,SI,DF")])
2712 ;; %%% Kill this when call knows how to work this out.
2714 [(set (match_operand:DF 0 "push_operand" "")
2715 (match_operand:DF 1 "any_fp_register_operand" ""))]
2716 "!TARGET_64BIT && reload_completed"
2717 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -8)))
2718 (set (mem:DF (reg:SI SP_REG)) (match_dup 1))]
2722 [(set (match_operand:DF 0 "push_operand" "")
2723 (match_operand:DF 1 "any_fp_register_operand" ""))]
2724 "TARGET_64BIT && reload_completed"
2725 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2726 (set (mem:DF (reg:DI SP_REG)) (match_dup 1))]
2730 [(set (match_operand:DF 0 "push_operand" "")
2731 (match_operand:DF 1 "general_operand" ""))]
2734 "ix86_split_long_move (operands); DONE;")
2736 ;; Moving is usually shorter when only FP registers are used. This separate
2737 ;; movdf pattern avoids the use of integer registers for FP operations
2738 ;; when optimizing for size.
2740 (define_insn "*movdf_nointeger"
2741 [(set (match_operand:DF 0 "nonimmediate_operand"
2742 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
2743 (match_operand:DF 1 "general_operand"
2744 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
2745 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2746 && ((optimize_size || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
2747 && (reload_in_progress || reload_completed
2748 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2749 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
2750 && !memory_operand (operands[0], DFmode)
2751 && standard_80387_constant_p (operands[1]))
2752 || GET_CODE (operands[1]) != CONST_DOUBLE
2754 || !TARGET_MEMORY_MISMATCH_STALL
2755 || reload_in_progress || reload_completed)
2756 && memory_operand (operands[0], DFmode)))"
2758 switch (which_alternative)
2762 return output_387_reg_move (insn, operands);
2765 return standard_80387_constant_opcode (operands[1]);
2771 switch (get_attr_mode (insn))
2774 return "xorps\t%0, %0";
2776 return "xorpd\t%0, %0";
2778 return "pxor\t%0, %0";
2785 switch (get_attr_mode (insn))
2788 return "movaps\t{%1, %0|%0, %1}";
2790 return "movapd\t{%1, %0|%0, %1}";
2792 return "movdqa\t{%1, %0|%0, %1}";
2794 return "movq\t{%1, %0|%0, %1}";
2796 return "movsd\t{%1, %0|%0, %1}";
2798 return "movlpd\t{%1, %0|%0, %1}";
2800 return "movlps\t{%1, %0|%0, %1}";
2809 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
2811 (cond [(eq_attr "alternative" "0,1,2")
2813 (eq_attr "alternative" "3,4")
2816 /* For SSE1, we have many fewer alternatives. */
2817 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2818 (cond [(eq_attr "alternative" "5,6")
2819 (const_string "V4SF")
2821 (const_string "V2SF"))
2823 /* xorps is one byte shorter. */
2824 (eq_attr "alternative" "5")
2825 (cond [(ne (symbol_ref "optimize_size")
2827 (const_string "V4SF")
2828 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2832 (const_string "V2DF"))
2834 /* For architectures resolving dependencies on
2835 whole SSE registers use APD move to break dependency
2836 chains, otherwise use short move to avoid extra work.
2838 movaps encodes one byte shorter. */
2839 (eq_attr "alternative" "6")
2841 [(ne (symbol_ref "optimize_size")
2843 (const_string "V4SF")
2844 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2846 (const_string "V2DF")
2848 (const_string "DF"))
2849 /* For architectures resolving dependencies on register
2850 parts we may avoid extra work to zero out upper part
2852 (eq_attr "alternative" "7")
2854 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2856 (const_string "V1DF")
2857 (const_string "DF"))
2859 (const_string "DF")))])
2861 (define_insn "*movdf_integer_rex64"
2862 [(set (match_operand:DF 0 "nonimmediate_operand"
2863 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2864 (match_operand:DF 1 "general_operand"
2865 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2866 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2867 && (reload_in_progress || reload_completed
2868 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2869 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
2870 && standard_80387_constant_p (operands[1]))
2871 || GET_CODE (operands[1]) != CONST_DOUBLE
2872 || memory_operand (operands[0], DFmode))"
2874 switch (which_alternative)
2878 return output_387_reg_move (insn, operands);
2881 return standard_80387_constant_opcode (operands[1]);
2888 switch (get_attr_mode (insn))
2891 return "xorps\t%0, %0";
2893 return "xorpd\t%0, %0";
2895 return "pxor\t%0, %0";
2902 switch (get_attr_mode (insn))
2905 return "movaps\t{%1, %0|%0, %1}";
2907 return "movapd\t{%1, %0|%0, %1}";
2909 return "movdqa\t{%1, %0|%0, %1}";
2911 return "movq\t{%1, %0|%0, %1}";
2913 return "movsd\t{%1, %0|%0, %1}";
2915 return "movlpd\t{%1, %0|%0, %1}";
2917 return "movlps\t{%1, %0|%0, %1}";
2924 return "movd\t{%1, %0|%0, %1}";
2930 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
2932 (cond [(eq_attr "alternative" "0,1,2")
2934 (eq_attr "alternative" "3,4,9,10")
2937 /* For SSE1, we have many fewer alternatives. */
2938 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2939 (cond [(eq_attr "alternative" "5,6")
2940 (const_string "V4SF")
2942 (const_string "V2SF"))
2944 /* xorps is one byte shorter. */
2945 (eq_attr "alternative" "5")
2946 (cond [(ne (symbol_ref "optimize_size")
2948 (const_string "V4SF")
2949 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2953 (const_string "V2DF"))
2955 /* For architectures resolving dependencies on
2956 whole SSE registers use APD move to break dependency
2957 chains, otherwise use short move to avoid extra work.
2959 movaps encodes one byte shorter. */
2960 (eq_attr "alternative" "6")
2962 [(ne (symbol_ref "optimize_size")
2964 (const_string "V4SF")
2965 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2967 (const_string "V2DF")
2969 (const_string "DF"))
2970 /* For architectures resolving dependencies on register
2971 parts we may avoid extra work to zero out upper part
2973 (eq_attr "alternative" "7")
2975 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2977 (const_string "V1DF")
2978 (const_string "DF"))
2980 (const_string "DF")))])
2982 (define_insn "*movdf_integer"
2983 [(set (match_operand:DF 0 "nonimmediate_operand"
2984 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
2985 (match_operand:DF 1 "general_operand"
2986 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
2987 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2988 && !optimize_size && TARGET_INTEGER_DFMODE_MOVES
2989 && (reload_in_progress || reload_completed
2990 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2991 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
2992 && standard_80387_constant_p (operands[1]))
2993 || GET_CODE (operands[1]) != CONST_DOUBLE
2994 || memory_operand (operands[0], DFmode))"
2996 switch (which_alternative)
3000 return output_387_reg_move (insn, operands);
3003 return standard_80387_constant_opcode (operands[1]);
3010 switch (get_attr_mode (insn))
3013 return "xorps\t%0, %0";
3015 return "xorpd\t%0, %0";
3017 return "pxor\t%0, %0";
3024 switch (get_attr_mode (insn))
3027 return "movaps\t{%1, %0|%0, %1}";
3029 return "movapd\t{%1, %0|%0, %1}";
3031 return "movdqa\t{%1, %0|%0, %1}";
3033 return "movq\t{%1, %0|%0, %1}";
3035 return "movsd\t{%1, %0|%0, %1}";
3037 return "movlpd\t{%1, %0|%0, %1}";
3039 return "movlps\t{%1, %0|%0, %1}";
3048 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3050 (cond [(eq_attr "alternative" "0,1,2")
3052 (eq_attr "alternative" "3,4")
3055 /* For SSE1, we have many fewer alternatives. */
3056 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3057 (cond [(eq_attr "alternative" "5,6")
3058 (const_string "V4SF")
3060 (const_string "V2SF"))
3062 /* xorps is one byte shorter. */
3063 (eq_attr "alternative" "5")
3064 (cond [(ne (symbol_ref "optimize_size")
3066 (const_string "V4SF")
3067 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3071 (const_string "V2DF"))
3073 /* For architectures resolving dependencies on
3074 whole SSE registers use APD move to break dependency
3075 chains, otherwise use short move to avoid extra work.
3077 movaps encodes one byte shorter. */
3078 (eq_attr "alternative" "6")
3080 [(ne (symbol_ref "optimize_size")
3082 (const_string "V4SF")
3083 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3085 (const_string "V2DF")
3087 (const_string "DF"))
3088 /* For architectures resolving dependencies on register
3089 parts we may avoid extra work to zero out upper part
3091 (eq_attr "alternative" "7")
3093 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3095 (const_string "V1DF")
3096 (const_string "DF"))
3098 (const_string "DF")))])
3101 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3102 (match_operand:DF 1 "general_operand" ""))]
3104 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3105 && ! (ANY_FP_REG_P (operands[0]) ||
3106 (GET_CODE (operands[0]) == SUBREG
3107 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3108 && ! (ANY_FP_REG_P (operands[1]) ||
3109 (GET_CODE (operands[1]) == SUBREG
3110 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3112 "ix86_split_long_move (operands); DONE;")
3114 (define_insn "*swapdf"
3115 [(set (match_operand:DF 0 "fp_register_operand" "+f")
3116 (match_operand:DF 1 "fp_register_operand" "+f"))
3119 "reload_completed || TARGET_80387"
3121 if (STACK_TOP_P (operands[0]))
3126 [(set_attr "type" "fxch")
3127 (set_attr "mode" "DF")])
3129 (define_expand "movxf"
3130 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3131 (match_operand:XF 1 "general_operand" ""))]
3133 "ix86_expand_move (XFmode, operands); DONE;")
3135 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3136 ;; Size of pushdf using integer instructions is 3+3*memory operand size
3137 ;; Pushing using integer instructions is longer except for constants
3138 ;; and direct memory references.
3139 ;; (assuming that any given constant is pushed only once, but this ought to be
3140 ;; handled elsewhere).
3142 (define_insn "*pushxf_nointeger"
3143 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
3144 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
3147 /* This insn should be already split before reg-stack. */
3150 [(set_attr "type" "multi")
3151 (set_attr "unit" "i387,*,*")
3152 (set_attr "mode" "XF,SI,SI")])
3154 (define_insn "*pushxf_integer"
3155 [(set (match_operand:XF 0 "push_operand" "=<,<")
3156 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
3159 /* This insn should be already split before reg-stack. */
3162 [(set_attr "type" "multi")
3163 (set_attr "unit" "i387,*")
3164 (set_attr "mode" "XF,SI")])
3167 [(set (match_operand 0 "push_operand" "")
3168 (match_operand 1 "general_operand" ""))]
3170 && (GET_MODE (operands[0]) == XFmode
3171 || GET_MODE (operands[0]) == DFmode)
3172 && !ANY_FP_REG_P (operands[1])"
3174 "ix86_split_long_move (operands); DONE;")
3177 [(set (match_operand:XF 0 "push_operand" "")
3178 (match_operand:XF 1 "any_fp_register_operand" ""))]
3180 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 2)))
3181 (set (mem:XF (reg:SI SP_REG)) (match_dup 1))]
3182 "operands[2] = GEN_INT (TARGET_128BIT_LONG_DOUBLE ? -16 : -12);")
3185 [(set (match_operand:XF 0 "push_operand" "")
3186 (match_operand:XF 1 "any_fp_register_operand" ""))]
3188 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (match_dup 2)))
3189 (set (mem:XF (reg:DI SP_REG)) (match_dup 1))]
3190 "operands[2] = GEN_INT (TARGET_128BIT_LONG_DOUBLE ? -16 : -12);")
3192 ;; Do not use integer registers when optimizing for size
3193 (define_insn "*movxf_nointeger"
3194 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3195 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3197 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3198 && (reload_in_progress || reload_completed
3199 || (optimize_size && standard_80387_constant_p (operands[1]))
3200 || GET_CODE (operands[1]) != CONST_DOUBLE
3201 || memory_operand (operands[0], XFmode))"
3203 switch (which_alternative)
3207 return output_387_reg_move (insn, operands);
3210 return standard_80387_constant_opcode (operands[1]);
3218 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3219 (set_attr "mode" "XF,XF,XF,SI,SI")])
3221 (define_insn "*movxf_integer"
3222 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
3223 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
3225 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3226 && (reload_in_progress || reload_completed
3227 || (optimize_size && standard_80387_constant_p (operands[1]))
3228 || GET_CODE (operands[1]) != CONST_DOUBLE
3229 || memory_operand (operands[0], XFmode))"
3231 switch (which_alternative)
3235 return output_387_reg_move (insn, operands);
3238 return standard_80387_constant_opcode (operands[1]);
3247 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3248 (set_attr "mode" "XF,XF,XF,SI,SI")])
3250 (define_expand "movtf"
3251 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3252 (match_operand:TF 1 "nonimmediate_operand" ""))]
3255 ix86_expand_move (TFmode, operands);
3259 (define_insn "*movtf_internal"
3260 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
3261 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
3263 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
3265 switch (which_alternative)
3269 if (get_attr_mode (insn) == MODE_V4SF)
3270 return "movaps\t{%1, %0|%0, %1}";
3272 return "movdqa\t{%1, %0|%0, %1}";
3274 if (get_attr_mode (insn) == MODE_V4SF)
3275 return "xorps\t%0, %0";
3277 return "pxor\t%0, %0";
3285 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
3287 (cond [(eq_attr "alternative" "0,2")
3289 (ne (symbol_ref "optimize_size")
3291 (const_string "V4SF")
3292 (const_string "TI"))
3293 (eq_attr "alternative" "1")
3295 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
3297 (ne (symbol_ref "optimize_size")
3299 (const_string "V4SF")
3300 (const_string "TI"))]
3301 (const_string "DI")))])
3304 [(set (match_operand 0 "nonimmediate_operand" "")
3305 (match_operand 1 "general_operand" ""))]
3307 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3308 && GET_MODE (operands[0]) == XFmode
3309 && ! (ANY_FP_REG_P (operands[0]) ||
3310 (GET_CODE (operands[0]) == SUBREG
3311 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3312 && ! (ANY_FP_REG_P (operands[1]) ||
3313 (GET_CODE (operands[1]) == SUBREG
3314 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3316 "ix86_split_long_move (operands); DONE;")
3319 [(set (match_operand 0 "register_operand" "")
3320 (match_operand 1 "memory_operand" ""))]
3322 && MEM_P (operands[1])
3323 && (GET_MODE (operands[0]) == TFmode
3324 || GET_MODE (operands[0]) == XFmode
3325 || GET_MODE (operands[0]) == SFmode
3326 || GET_MODE (operands[0]) == DFmode)
3327 && (operands[2] = find_constant_src (insn))"
3328 [(set (match_dup 0) (match_dup 2))]
3330 rtx c = operands[2];
3331 rtx r = operands[0];
3333 if (GET_CODE (r) == SUBREG)
3338 if (!standard_sse_constant_p (c))
3341 else if (FP_REG_P (r))
3343 if (!standard_80387_constant_p (c))
3346 else if (MMX_REG_P (r))