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, 2009
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 ;; L,W,B,Q,S,T -- print the opcode suffix for specified size of operand.
31 ;; C -- print opcode suffix for set/cmov insn.
32 ;; c -- like C, but print reversed condition
33 ;; E,e -- likewise, but for compare-and-branch fused insn.
34 ;; F,f -- likewise, but for floating-point.
35 ;; O -- if HAVE_AS_IX86_CMOV_SUN_SYNTAX, expand to "w.", "l." or "q.",
37 ;; R -- print the prefix for register names.
38 ;; z -- print the opcode suffix for the size of the current operand.
39 ;; Z -- likewise, with special suffixes for x87 instructions.
40 ;; * -- print a star (in certain assembler syntax)
41 ;; A -- print an absolute memory reference.
42 ;; w -- print the operand as if it's a "word" (HImode) even if it isn't.
43 ;; s -- print a shift double count, followed by the assemblers argument
45 ;; b -- print the QImode name of the register for the indicated operand.
46 ;; %b0 would print %al if operands[0] is reg 0.
47 ;; w -- likewise, print the HImode name of the register.
48 ;; k -- likewise, print the SImode name of the register.
49 ;; q -- likewise, print the DImode name of the register.
50 ;; x -- likewise, print the V4SFmode name of the register.
51 ;; t -- likewise, print the V8SFmode name of the register.
52 ;; h -- print the QImode name for a "high" register, either ah, bh, ch or dh.
53 ;; y -- print "st(0)" instead of "st" as a register.
54 ;; d -- print duplicated register operand for AVX instruction.
55 ;; D -- print condition for SSE cmp instruction.
56 ;; P -- if PIC, print an @PLT suffix.
57 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
58 ;; & -- print some in-use local-dynamic symbol name.
59 ;; H -- print a memory address offset by 8; used for sse high-parts
60 ;; Y -- print condition for XOP pcom* instruction.
61 ;; + -- print a branch hint as 'cs' or 'ds' prefix
62 ;; ; -- print a semicolon (after prefixes due to bug in older gas).
67 [; Relocation specifiers
78 (UNSPEC_MACHOPIC_OFFSET 10)
81 (UNSPEC_STACK_ALLOC 11)
83 (UNSPEC_SSE_PROLOGUE_SAVE 13)
87 (UNSPEC_SET_GOT_OFFSET 17)
88 (UNSPEC_MEMORY_BLOCKAGE 18)
93 (UNSPEC_TLS_LD_BASE 22)
96 ; Other random patterns
101 (UNSPEC_ADD_CARRY 34)
104 (UNSPEC_LD_MPIC 38) ; load_macho_picbase
105 (UNSPEC_TRUNC_NOOP 39)
107 ; For SSE/MMX support:
108 (UNSPEC_FIX_NOTRUNC 40)
125 (UNSPEC_MS_TO_SYSV_CALL 48)
127 ; Generic math support
129 (UNSPEC_IEEE_MIN 51) ; not commutative
130 (UNSPEC_IEEE_MAX 52) ; not commutative
145 (UNSPEC_FRNDINT_FLOOR 70)
146 (UNSPEC_FRNDINT_CEIL 71)
147 (UNSPEC_FRNDINT_TRUNC 72)
148 (UNSPEC_FRNDINT_MASK_PM 73)
149 (UNSPEC_FIST_FLOOR 74)
150 (UNSPEC_FIST_CEIL 75)
152 ; x87 Double output FP
153 (UNSPEC_SINCOS_COS 80)
154 (UNSPEC_SINCOS_SIN 81)
155 (UNSPEC_XTRACT_FRACT 84)
156 (UNSPEC_XTRACT_EXP 85)
157 (UNSPEC_FSCALE_FRACT 86)
158 (UNSPEC_FSCALE_EXP 87)
170 (UNSPEC_SP_TLS_SET 102)
171 (UNSPEC_SP_TLS_TEST 103)
181 (UNSPEC_INSERTQI 132)
186 (UNSPEC_INSERTPS 135)
188 (UNSPEC_MOVNTDQA 137)
190 (UNSPEC_PHMINPOSUW 139)
196 (UNSPEC_PCMPESTR 144)
197 (UNSPEC_PCMPISTR 145)
200 (UNSPEC_FMA4_INTRINSIC 150)
201 (UNSPEC_FMA4_FMADDSUB 151)
202 (UNSPEC_FMA4_FMSUBADD 152)
203 (UNSPEC_XOP_UNSIGNED_CMP 151)
204 (UNSPEC_XOP_TRUEFALSE 152)
205 (UNSPEC_XOP_PERMUTE 153)
207 (UNSPEC_LLWP_INTRINSIC 155)
208 (UNSPEC_SLWP_INTRINSIC 156)
209 (UNSPECV_LWPVAL_INTRINSIC 157)
210 (UNSPECV_LWPINS_INTRINSIC 158)
214 (UNSPEC_AESENCLAST 160)
216 (UNSPEC_AESDECLAST 162)
218 (UNSPEC_AESKEYGENASSIST 164)
226 (UNSPEC_VPERMIL2F128 168)
227 (UNSPEC_MASKLOAD 169)
228 (UNSPEC_MASKSTORE 170)
234 [(UNSPECV_BLOCKAGE 0)
235 (UNSPECV_STACK_PROBE 1)
247 (UNSPECV_PROLOGUE_USE 14)
249 (UNSPECV_VZEROALL 16)
250 (UNSPECV_VZEROUPPER 17)
254 (UNSPECV_VSWAPMOV 21)
257 ;; Constants to represent pcomtrue/pcomfalse variants
267 ;; Constants used in the XOP pperm instruction
269 [(PPERM_SRC 0x00) /* copy source */
270 (PPERM_INVERT 0x20) /* invert source */
271 (PPERM_REVERSE 0x40) /* bit reverse source */
272 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
273 (PPERM_ZERO 0x80) /* all 0's */
274 (PPERM_ONES 0xa0) /* all 1's */
275 (PPERM_SIGN 0xc0) /* propagate sign bit */
276 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
277 (PPERM_SRC1 0x00) /* use first source byte */
278 (PPERM_SRC2 0x10) /* use second source byte */
281 ;; Registers by name.
334 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
337 ;; In C guard expressions, put expressions which may be compile-time
338 ;; constants first. This allows for better optimization. For
339 ;; example, write "TARGET_64BIT && reload_completed", not
340 ;; "reload_completed && TARGET_64BIT".
344 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,atom,
346 (const (symbol_ref "ix86_schedule")))
348 ;; A basic instruction type. Refinements due to arguments to be
349 ;; provided in other attributes.
352 alu,alu1,negnot,imov,imovx,lea,
353 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
354 icmp,test,ibr,setcc,icmov,
355 push,pop,call,callv,leave,
357 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
358 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
359 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
360 ssemuladd,sse4arg,lwp,
361 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
362 (const_string "other"))
364 ;; Main data type used by the insn
366 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
367 (const_string "unknown"))
369 ;; The CPU unit operations uses.
370 (define_attr "unit" "integer,i387,sse,mmx,unknown"
371 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
372 (const_string "i387")
373 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
374 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
375 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
377 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
379 (eq_attr "type" "other")
380 (const_string "unknown")]
381 (const_string "integer")))
383 ;; The (bounding maximum) length of an instruction immediate.
384 (define_attr "length_immediate" ""
385 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
388 (eq_attr "unit" "i387,sse,mmx")
390 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
392 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
393 (eq_attr "type" "imov,test")
394 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
395 (eq_attr "type" "call")
396 (if_then_else (match_operand 0 "constant_call_address_operand" "")
399 (eq_attr "type" "callv")
400 (if_then_else (match_operand 1 "constant_call_address_operand" "")
403 ;; We don't know the size before shorten_branches. Expect
404 ;; the instruction to fit for better scheduling.
405 (eq_attr "type" "ibr")
408 (symbol_ref "/* Update immediate_length and other attributes! */
409 gcc_unreachable (),1")))
411 ;; The (bounding maximum) length of an instruction address.
412 (define_attr "length_address" ""
413 (cond [(eq_attr "type" "str,other,multi,fxch")
415 (and (eq_attr "type" "call")
416 (match_operand 0 "constant_call_address_operand" ""))
418 (and (eq_attr "type" "callv")
419 (match_operand 1 "constant_call_address_operand" ""))
422 (symbol_ref "ix86_attr_length_address_default (insn)")))
424 ;; Set when length prefix is used.
425 (define_attr "prefix_data16" ""
426 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
428 (eq_attr "mode" "HI")
430 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
435 ;; Set when string REP prefix is used.
436 (define_attr "prefix_rep" ""
437 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
439 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
444 ;; Set when 0f opcode prefix is used.
445 (define_attr "prefix_0f" ""
447 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
448 (eq_attr "unit" "sse,mmx"))
452 ;; Set when REX opcode prefix is used.
453 (define_attr "prefix_rex" ""
454 (cond [(ne (symbol_ref "!TARGET_64BIT") (const_int 0))
456 (and (eq_attr "mode" "DI")
457 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
458 (eq_attr "unit" "!mmx")))
460 (and (eq_attr "mode" "QI")
461 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
464 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
467 (and (eq_attr "type" "imovx")
468 (match_operand:QI 1 "ext_QIreg_operand" ""))
473 ;; There are also additional prefixes in 3DNOW, SSSE3.
474 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
475 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
476 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
477 (define_attr "prefix_extra" ""
478 (cond [(eq_attr "type" "ssemuladd,sse4arg")
480 (eq_attr "type" "sseiadd1,ssecvt1")
485 ;; Prefix used: original, VEX or maybe VEX.
486 (define_attr "prefix" "orig,vex,maybe_vex"
487 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
489 (const_string "orig")))
491 ;; VEX W bit is used.
492 (define_attr "prefix_vex_w" "" (const_int 0))
494 ;; The length of VEX prefix
495 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
496 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
497 ;; still prefix_0f 1, with prefix_extra 1.
498 (define_attr "length_vex" ""
499 (if_then_else (and (eq_attr "prefix_0f" "1")
500 (eq_attr "prefix_extra" "0"))
501 (if_then_else (eq_attr "prefix_vex_w" "1")
502 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
503 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
504 (if_then_else (eq_attr "prefix_vex_w" "1")
505 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
506 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
508 ;; Set when modrm byte is used.
509 (define_attr "modrm" ""
510 (cond [(eq_attr "type" "str,leave")
512 (eq_attr "unit" "i387")
514 (and (eq_attr "type" "incdec")
515 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
516 (ior (match_operand:SI 1 "register_operand" "")
517 (match_operand:HI 1 "register_operand" ""))))
519 (and (eq_attr "type" "push")
520 (not (match_operand 1 "memory_operand" "")))
522 (and (eq_attr "type" "pop")
523 (not (match_operand 0 "memory_operand" "")))
525 (and (eq_attr "type" "imov")
526 (and (not (eq_attr "mode" "DI"))
527 (ior (and (match_operand 0 "register_operand" "")
528 (match_operand 1 "immediate_operand" ""))
529 (ior (and (match_operand 0 "ax_reg_operand" "")
530 (match_operand 1 "memory_displacement_only_operand" ""))
531 (and (match_operand 0 "memory_displacement_only_operand" "")
532 (match_operand 1 "ax_reg_operand" ""))))))
534 (and (eq_attr "type" "call")
535 (match_operand 0 "constant_call_address_operand" ""))
537 (and (eq_attr "type" "callv")
538 (match_operand 1 "constant_call_address_operand" ""))
540 (and (eq_attr "type" "alu,alu1,icmp,test")
541 (match_operand 0 "ax_reg_operand" ""))
542 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
546 ;; The (bounding maximum) length of an instruction in bytes.
547 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
548 ;; Later we may want to split them and compute proper length as for
550 (define_attr "length" ""
551 (cond [(eq_attr "type" "other,multi,fistp,frndint")
553 (eq_attr "type" "fcmp")
555 (eq_attr "unit" "i387")
557 (plus (attr "prefix_data16")
558 (attr "length_address")))
559 (ior (eq_attr "prefix" "vex")
560 (and (eq_attr "prefix" "maybe_vex")
561 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
562 (plus (attr "length_vex")
563 (plus (attr "length_immediate")
565 (attr "length_address"))))]
566 (plus (plus (attr "modrm")
567 (plus (attr "prefix_0f")
568 (plus (attr "prefix_rex")
569 (plus (attr "prefix_extra")
571 (plus (attr "prefix_rep")
572 (plus (attr "prefix_data16")
573 (plus (attr "length_immediate")
574 (attr "length_address")))))))
576 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
577 ;; `store' if there is a simple memory reference therein, or `unknown'
578 ;; if the instruction is complex.
580 (define_attr "memory" "none,load,store,both,unknown"
581 (cond [(eq_attr "type" "other,multi,str")
582 (const_string "unknown")
583 (eq_attr "type" "lea,fcmov,fpspc")
584 (const_string "none")
585 (eq_attr "type" "fistp,leave")
586 (const_string "both")
587 (eq_attr "type" "frndint")
588 (const_string "load")
589 (eq_attr "type" "push")
590 (if_then_else (match_operand 1 "memory_operand" "")
591 (const_string "both")
592 (const_string "store"))
593 (eq_attr "type" "pop")
594 (if_then_else (match_operand 0 "memory_operand" "")
595 (const_string "both")
596 (const_string "load"))
597 (eq_attr "type" "setcc")
598 (if_then_else (match_operand 0 "memory_operand" "")
599 (const_string "store")
600 (const_string "none"))
601 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
602 (if_then_else (ior (match_operand 0 "memory_operand" "")
603 (match_operand 1 "memory_operand" ""))
604 (const_string "load")
605 (const_string "none"))
606 (eq_attr "type" "ibr")
607 (if_then_else (match_operand 0 "memory_operand" "")
608 (const_string "load")
609 (const_string "none"))
610 (eq_attr "type" "call")
611 (if_then_else (match_operand 0 "constant_call_address_operand" "")
612 (const_string "none")
613 (const_string "load"))
614 (eq_attr "type" "callv")
615 (if_then_else (match_operand 1 "constant_call_address_operand" "")
616 (const_string "none")
617 (const_string "load"))
618 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
619 (match_operand 1 "memory_operand" ""))
620 (const_string "both")
621 (and (match_operand 0 "memory_operand" "")
622 (match_operand 1 "memory_operand" ""))
623 (const_string "both")
624 (match_operand 0 "memory_operand" "")
625 (const_string "store")
626 (match_operand 1 "memory_operand" "")
627 (const_string "load")
629 "!alu1,negnot,ishift1,
630 imov,imovx,icmp,test,bitmanip,
632 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
633 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
634 (match_operand 2 "memory_operand" ""))
635 (const_string "load")
636 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
637 (match_operand 3 "memory_operand" ""))
638 (const_string "load")
640 (const_string "none")))
642 ;; Indicates if an instruction has both an immediate and a displacement.
644 (define_attr "imm_disp" "false,true,unknown"
645 (cond [(eq_attr "type" "other,multi")
646 (const_string "unknown")
647 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
648 (and (match_operand 0 "memory_displacement_operand" "")
649 (match_operand 1 "immediate_operand" "")))
650 (const_string "true")
651 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
652 (and (match_operand 0 "memory_displacement_operand" "")
653 (match_operand 2 "immediate_operand" "")))
654 (const_string "true")
656 (const_string "false")))
658 ;; Indicates if an FP operation has an integer source.
660 (define_attr "fp_int_src" "false,true"
661 (const_string "false"))
663 ;; Defines rounding mode of an FP operation.
665 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
666 (const_string "any"))
668 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
669 (define_attr "use_carry" "0,1" (const_string "0"))
671 ;; Define attribute to indicate unaligned ssemov insns
672 (define_attr "movu" "0,1" (const_string "0"))
674 ;; Describe a user's asm statement.
675 (define_asm_attributes
676 [(set_attr "length" "128")
677 (set_attr "type" "multi")])
679 ;; All integer comparison codes.
680 (define_code_iterator int_cond [ne eq ge gt le lt geu gtu leu ltu ])
682 ;; All floating-point comparison codes.
683 (define_code_iterator fp_cond [unordered ordered
684 uneq unge ungt unle unlt ltgt ])
686 (define_code_iterator plusminus [plus minus])
688 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
690 ;; Base name for define_insn
691 (define_code_attr plusminus_insn
692 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
693 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
695 ;; Base name for insn mnemonic.
696 (define_code_attr plusminus_mnemonic
697 [(plus "add") (ss_plus "adds") (us_plus "addus")
698 (minus "sub") (ss_minus "subs") (us_minus "subus")])
699 (define_code_attr plusminus_carry_mnemonic
700 [(plus "adc") (minus "sbb")])
702 ;; Mark commutative operators as such in constraints.
703 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
704 (minus "") (ss_minus "") (us_minus "")])
706 ;; Mapping of signed max and min
707 (define_code_iterator smaxmin [smax smin])
709 ;; Mapping of unsigned max and min
710 (define_code_iterator umaxmin [umax umin])
712 ;; Mapping of signed/unsigned max and min
713 (define_code_iterator maxmin [smax smin umax umin])
715 ;; Base name for integer and FP insn mnemonic
716 (define_code_attr maxminiprefix [(smax "maxs") (smin "mins")
717 (umax "maxu") (umin "minu")])
718 (define_code_attr maxminfprefix [(smax "max") (smin "min")])
720 ;; Mapping of parallel logic operators
721 (define_code_iterator plogic [and ior xor])
723 ;; Base name for insn mnemonic.
724 (define_code_attr plogicprefix [(and "and") (ior "or") (xor "xor")])
726 ;; Mapping of abs neg operators
727 (define_code_iterator absneg [abs neg])
729 ;; Base name for x87 insn mnemonic.
730 (define_code_attr absnegprefix [(abs "abs") (neg "chs")])
732 ;; Used in signed and unsigned widening multiplications.
733 (define_code_iterator any_extend [sign_extend zero_extend])
735 ;; Used in signed and unsigned divisions.
736 (define_code_iterator any_div [div udiv])
738 ;; Various insn prefixes for signed and unsigned operations.
739 (define_code_attr u [(sign_extend "") (zero_extend "u")
740 (div "") (udiv "u")])
741 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
743 ;; Instruction prefix for signed and unsigned operations.
744 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
745 (div "i") (udiv "")])
747 ;; All single word integer modes.
748 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
750 ;; Single word integer modes without DImode.
751 (define_mode_iterator SWI124 [QI HI SI])
753 ;; Single word integer modes without QImode.
754 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
756 ;; Single word integer modes without QImode and HImode.
757 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
759 ;; All math-dependant single and double word integer modes.
760 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
761 (HI "TARGET_HIMODE_MATH")
762 SI DI (TI "TARGET_64BIT")])
764 ;; Math-dependant single word integer modes.
765 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
766 (HI "TARGET_HIMODE_MATH")
767 SI (DI "TARGET_64BIT")])
769 ;; Math-dependant single word integer modes without QImode.
770 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
771 SI (DI "TARGET_64BIT")])
773 ;; Half mode for double word integer modes.
774 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
775 (DI "TARGET_64BIT")])
777 ;; Double word integer modes.
778 (define_mode_attr DWI [(SI "DI") (DI "TI")])
779 (define_mode_attr dwi [(SI "di") (DI "ti")])
781 ;; Instruction suffix for integer modes.
782 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
784 ;; Register class for integer modes.
785 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
787 ;; Immediate operand constraint for integer modes.
788 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
790 ;; General operand constraint for word modes.
791 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
793 ;; Immediate operand constraint for double integer modes.
794 (define_mode_attr di [(SI "iF") (DI "e")])
796 ;; General operand predicate for integer modes.
797 (define_mode_attr general_operand
798 [(QI "general_operand")
799 (HI "general_operand")
800 (SI "general_operand")
801 (DI "x86_64_general_operand")
802 (TI "x86_64_general_operand")])
804 ;; General sign/zero extend operand predicate for integer modes.
805 (define_mode_attr general_szext_operand
806 [(QI "general_operand")
807 (HI "general_operand")
808 (SI "general_operand")
809 (DI "x86_64_szext_general_operand")])
811 ;; SSE and x87 SFmode and DFmode floating point modes
812 (define_mode_iterator MODEF [SF DF])
814 ;; All x87 floating point modes
815 (define_mode_iterator X87MODEF [SF DF XF])
817 ;; All integer modes handled by x87 fisttp operator.
818 (define_mode_iterator X87MODEI [HI SI DI])
820 ;; All integer modes handled by integer x87 operators.
821 (define_mode_iterator X87MODEI12 [HI SI])
823 ;; All integer modes handled by SSE cvtts?2si* operators.
824 (define_mode_iterator SSEMODEI24 [SI DI])
826 ;; SSE asm suffix for floating point modes
827 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
829 ;; SSE vector mode corresponding to a scalar mode
830 (define_mode_attr ssevecmode
831 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
833 ;; Instruction suffix for REX 64bit operators.
834 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
836 ;; This mode iterator allows :P to be used for patterns that operate on
837 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
838 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
840 ;; Scheduling descriptions
842 (include "pentium.md")
845 (include "athlon.md")
850 ;; Operand and operator predicates and constraints
852 (include "predicates.md")
853 (include "constraints.md")
856 ;; Compare and branch/compare and store instructions.
858 (define_expand "cbranch<mode>4"
859 [(set (reg:CC FLAGS_REG)
860 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
861 (match_operand:SDWIM 2 "<general_operand>" "")))
862 (set (pc) (if_then_else
863 (match_operator 0 "comparison_operator"
864 [(reg:CC FLAGS_REG) (const_int 0)])
865 (label_ref (match_operand 3 "" ""))
869 if (MEM_P (operands[1]) && MEM_P (operands[2]))
870 operands[1] = force_reg (<MODE>mode, operands[1]);
871 ix86_compare_op0 = operands[1];
872 ix86_compare_op1 = operands[2];
873 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
877 (define_expand "cstore<mode>4"
878 [(set (reg:CC FLAGS_REG)
879 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
880 (match_operand:SWIM 3 "<general_operand>" "")))
881 (set (match_operand:QI 0 "register_operand" "")
882 (match_operator 1 "comparison_operator"
883 [(reg:CC FLAGS_REG) (const_int 0)]))]
886 if (MEM_P (operands[2]) && MEM_P (operands[3]))
887 operands[2] = force_reg (<MODE>mode, operands[2]);
888 ix86_compare_op0 = operands[2];
889 ix86_compare_op1 = operands[3];
890 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
894 (define_expand "cmp<mode>_1"
895 [(set (reg:CC FLAGS_REG)
896 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
897 (match_operand:SWI48 1 "<general_operand>" "")))]
901 (define_insn "*cmp<mode>_ccno_1"
902 [(set (reg FLAGS_REG)
903 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
904 (match_operand:SWI 1 "const0_operand" "")))]
905 "ix86_match_ccmode (insn, CCNOmode)"
907 test{<imodesuffix>}\t%0, %0
908 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
909 [(set_attr "type" "test,icmp")
910 (set_attr "length_immediate" "0,1")
911 (set_attr "mode" "<MODE>")])
913 (define_insn "*cmp<mode>_1"
914 [(set (reg FLAGS_REG)
915 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
916 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
917 "ix86_match_ccmode (insn, CCmode)"
918 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
919 [(set_attr "type" "icmp")
920 (set_attr "mode" "<MODE>")])
922 (define_insn "*cmp<mode>_minus_1"
923 [(set (reg FLAGS_REG)
925 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
926 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
928 "ix86_match_ccmode (insn, CCGOCmode)"
929 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
930 [(set_attr "type" "icmp")
931 (set_attr "mode" "<MODE>")])
933 (define_insn "*cmpqi_ext_1"
934 [(set (reg FLAGS_REG)
936 (match_operand:QI 0 "general_operand" "Qm")
939 (match_operand 1 "ext_register_operand" "Q")
942 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
943 "cmp{b}\t{%h1, %0|%0, %h1}"
944 [(set_attr "type" "icmp")
945 (set_attr "mode" "QI")])
947 (define_insn "*cmpqi_ext_1_rex64"
948 [(set (reg FLAGS_REG)
950 (match_operand:QI 0 "register_operand" "Q")
953 (match_operand 1 "ext_register_operand" "Q")
956 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
957 "cmp{b}\t{%h1, %0|%0, %h1}"
958 [(set_attr "type" "icmp")
959 (set_attr "mode" "QI")])
961 (define_insn "*cmpqi_ext_2"
962 [(set (reg FLAGS_REG)
966 (match_operand 0 "ext_register_operand" "Q")
969 (match_operand:QI 1 "const0_operand" "")))]
970 "ix86_match_ccmode (insn, CCNOmode)"
972 [(set_attr "type" "test")
973 (set_attr "length_immediate" "0")
974 (set_attr "mode" "QI")])
976 (define_expand "cmpqi_ext_3"
977 [(set (reg:CC FLAGS_REG)
981 (match_operand 0 "ext_register_operand" "")
984 (match_operand:QI 1 "immediate_operand" "")))]
988 (define_insn "*cmpqi_ext_3_insn"
989 [(set (reg FLAGS_REG)
993 (match_operand 0 "ext_register_operand" "Q")
996 (match_operand:QI 1 "general_operand" "Qmn")))]
997 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
998 "cmp{b}\t{%1, %h0|%h0, %1}"
999 [(set_attr "type" "icmp")
1000 (set_attr "modrm" "1")
1001 (set_attr "mode" "QI")])
1003 (define_insn "*cmpqi_ext_3_insn_rex64"
1004 [(set (reg FLAGS_REG)
1008 (match_operand 0 "ext_register_operand" "Q")
1011 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1012 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1013 "cmp{b}\t{%1, %h0|%h0, %1}"
1014 [(set_attr "type" "icmp")
1015 (set_attr "modrm" "1")
1016 (set_attr "mode" "QI")])
1018 (define_insn "*cmpqi_ext_4"
1019 [(set (reg FLAGS_REG)
1023 (match_operand 0 "ext_register_operand" "Q")
1028 (match_operand 1 "ext_register_operand" "Q")
1030 (const_int 8)) 0)))]
1031 "ix86_match_ccmode (insn, CCmode)"
1032 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1033 [(set_attr "type" "icmp")
1034 (set_attr "mode" "QI")])
1036 ;; These implement float point compares.
1037 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1038 ;; which would allow mix and match FP modes on the compares. Which is what
1039 ;; the old patterns did, but with many more of them.
1041 (define_expand "cbranchxf4"
1042 [(set (reg:CC FLAGS_REG)
1043 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1044 (match_operand:XF 2 "nonmemory_operand" "")))
1045 (set (pc) (if_then_else
1046 (match_operator 0 "ix86_fp_comparison_operator"
1049 (label_ref (match_operand 3 "" ""))
1053 ix86_compare_op0 = operands[1];
1054 ix86_compare_op1 = operands[2];
1055 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1059 (define_expand "cstorexf4"
1060 [(set (reg:CC FLAGS_REG)
1061 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1062 (match_operand:XF 3 "nonmemory_operand" "")))
1063 (set (match_operand:QI 0 "register_operand" "")
1064 (match_operator 1 "ix86_fp_comparison_operator"
1069 ix86_compare_op0 = operands[2];
1070 ix86_compare_op1 = operands[3];
1071 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1075 (define_expand "cbranch<mode>4"
1076 [(set (reg:CC FLAGS_REG)
1077 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1078 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1079 (set (pc) (if_then_else
1080 (match_operator 0 "ix86_fp_comparison_operator"
1083 (label_ref (match_operand 3 "" ""))
1085 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1087 ix86_compare_op0 = operands[1];
1088 ix86_compare_op1 = operands[2];
1089 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1093 (define_expand "cstore<mode>4"
1094 [(set (reg:CC FLAGS_REG)
1095 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1096 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1097 (set (match_operand:QI 0 "register_operand" "")
1098 (match_operator 1 "ix86_fp_comparison_operator"
1101 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1103 ix86_compare_op0 = operands[2];
1104 ix86_compare_op1 = operands[3];
1105 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1109 (define_expand "cbranchcc4"
1110 [(set (pc) (if_then_else
1111 (match_operator 0 "comparison_operator"
1112 [(match_operand 1 "flags_reg_operand" "")
1113 (match_operand 2 "const0_operand" "")])
1114 (label_ref (match_operand 3 "" ""))
1118 ix86_compare_op0 = operands[1];
1119 ix86_compare_op1 = operands[2];
1120 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1124 (define_expand "cstorecc4"
1125 [(set (match_operand:QI 0 "register_operand" "")
1126 (match_operator 1 "comparison_operator"
1127 [(match_operand 2 "flags_reg_operand" "")
1128 (match_operand 3 "const0_operand" "")]))]
1131 ix86_compare_op0 = operands[2];
1132 ix86_compare_op1 = operands[3];
1133 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1138 ;; FP compares, step 1:
1139 ;; Set the FP condition codes.
1141 ;; CCFPmode compare with exceptions
1142 ;; CCFPUmode compare with no exceptions
1144 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1145 ;; used to manage the reg stack popping would not be preserved.
1147 (define_insn "*cmpfp_0"
1148 [(set (match_operand:HI 0 "register_operand" "=a")
1151 (match_operand 1 "register_operand" "f")
1152 (match_operand 2 "const0_operand" ""))]
1154 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1155 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1156 "* return output_fp_compare (insn, operands, 0, 0);"
1157 [(set_attr "type" "multi")
1158 (set_attr "unit" "i387")
1160 (cond [(match_operand:SF 1 "" "")
1162 (match_operand:DF 1 "" "")
1165 (const_string "XF")))])
1167 (define_insn_and_split "*cmpfp_0_cc"
1168 [(set (reg:CCFP FLAGS_REG)
1170 (match_operand 1 "register_operand" "f")
1171 (match_operand 2 "const0_operand" "")))
1172 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1173 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1174 && TARGET_SAHF && !TARGET_CMOVE
1175 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1177 "&& reload_completed"
1180 [(compare:CCFP (match_dup 1)(match_dup 2))]
1182 (set (reg:CC FLAGS_REG)
1183 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1185 [(set_attr "type" "multi")
1186 (set_attr "unit" "i387")
1188 (cond [(match_operand:SF 1 "" "")
1190 (match_operand:DF 1 "" "")
1193 (const_string "XF")))])
1195 (define_insn "*cmpfp_xf"
1196 [(set (match_operand:HI 0 "register_operand" "=a")
1199 (match_operand:XF 1 "register_operand" "f")
1200 (match_operand:XF 2 "register_operand" "f"))]
1203 "* return output_fp_compare (insn, operands, 0, 0);"
1204 [(set_attr "type" "multi")
1205 (set_attr "unit" "i387")
1206 (set_attr "mode" "XF")])
1208 (define_insn_and_split "*cmpfp_xf_cc"
1209 [(set (reg:CCFP FLAGS_REG)
1211 (match_operand:XF 1 "register_operand" "f")
1212 (match_operand:XF 2 "register_operand" "f")))
1213 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1215 && TARGET_SAHF && !TARGET_CMOVE"
1217 "&& reload_completed"
1220 [(compare:CCFP (match_dup 1)(match_dup 2))]
1222 (set (reg:CC FLAGS_REG)
1223 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1225 [(set_attr "type" "multi")
1226 (set_attr "unit" "i387")
1227 (set_attr "mode" "XF")])
1229 (define_insn "*cmpfp_<mode>"
1230 [(set (match_operand:HI 0 "register_operand" "=a")
1233 (match_operand:MODEF 1 "register_operand" "f")
1234 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1237 "* return output_fp_compare (insn, operands, 0, 0);"
1238 [(set_attr "type" "multi")
1239 (set_attr "unit" "i387")
1240 (set_attr "mode" "<MODE>")])
1242 (define_insn_and_split "*cmpfp_<mode>_cc"
1243 [(set (reg:CCFP FLAGS_REG)
1245 (match_operand:MODEF 1 "register_operand" "f")
1246 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1247 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1249 && TARGET_SAHF && !TARGET_CMOVE"
1251 "&& reload_completed"
1254 [(compare:CCFP (match_dup 1)(match_dup 2))]
1256 (set (reg:CC FLAGS_REG)
1257 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1259 [(set_attr "type" "multi")
1260 (set_attr "unit" "i387")
1261 (set_attr "mode" "<MODE>")])
1263 (define_insn "*cmpfp_u"
1264 [(set (match_operand:HI 0 "register_operand" "=a")
1267 (match_operand 1 "register_operand" "f")
1268 (match_operand 2 "register_operand" "f"))]
1270 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1271 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1272 "* return output_fp_compare (insn, operands, 0, 1);"
1273 [(set_attr "type" "multi")
1274 (set_attr "unit" "i387")
1276 (cond [(match_operand:SF 1 "" "")
1278 (match_operand:DF 1 "" "")
1281 (const_string "XF")))])
1283 (define_insn_and_split "*cmpfp_u_cc"
1284 [(set (reg:CCFPU FLAGS_REG)
1286 (match_operand 1 "register_operand" "f")
1287 (match_operand 2 "register_operand" "f")))
1288 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1289 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1290 && TARGET_SAHF && !TARGET_CMOVE
1291 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1293 "&& reload_completed"
1296 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1298 (set (reg:CC FLAGS_REG)
1299 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1301 [(set_attr "type" "multi")
1302 (set_attr "unit" "i387")
1304 (cond [(match_operand:SF 1 "" "")
1306 (match_operand:DF 1 "" "")
1309 (const_string "XF")))])
1311 (define_insn "*cmpfp_<mode>"
1312 [(set (match_operand:HI 0 "register_operand" "=a")
1315 (match_operand 1 "register_operand" "f")
1316 (match_operator 3 "float_operator"
1317 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1319 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1320 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1321 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1322 "* return output_fp_compare (insn, operands, 0, 0);"
1323 [(set_attr "type" "multi")
1324 (set_attr "unit" "i387")
1325 (set_attr "fp_int_src" "true")
1326 (set_attr "mode" "<MODE>")])
1328 (define_insn_and_split "*cmpfp_<mode>_cc"
1329 [(set (reg:CCFP FLAGS_REG)
1331 (match_operand 1 "register_operand" "f")
1332 (match_operator 3 "float_operator"
1333 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1334 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1335 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1336 && TARGET_SAHF && !TARGET_CMOVE
1337 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1338 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1340 "&& reload_completed"
1345 (match_op_dup 3 [(match_dup 2)]))]
1347 (set (reg:CC FLAGS_REG)
1348 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1350 [(set_attr "type" "multi")
1351 (set_attr "unit" "i387")
1352 (set_attr "fp_int_src" "true")
1353 (set_attr "mode" "<MODE>")])
1355 ;; FP compares, step 2
1356 ;; Move the fpsw to ax.
1358 (define_insn "x86_fnstsw_1"
1359 [(set (match_operand:HI 0 "register_operand" "=a")
1360 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1363 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1364 (set_attr "mode" "SI")
1365 (set_attr "unit" "i387")])
1367 ;; FP compares, step 3
1368 ;; Get ax into flags, general case.
1370 (define_insn "x86_sahf_1"
1371 [(set (reg:CC FLAGS_REG)
1372 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1376 #ifdef HAVE_AS_IX86_SAHF
1379 return ASM_BYTE "0x9e";
1382 [(set_attr "length" "1")
1383 (set_attr "athlon_decode" "vector")
1384 (set_attr "amdfam10_decode" "direct")
1385 (set_attr "mode" "SI")])
1387 ;; Pentium Pro can do steps 1 through 3 in one go.
1388 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1389 (define_insn "*cmpfp_i_mixed"
1390 [(set (reg:CCFP FLAGS_REG)
1391 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1392 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1393 "TARGET_MIX_SSE_I387
1394 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1395 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1396 "* return output_fp_compare (insn, operands, 1, 0);"
1397 [(set_attr "type" "fcmp,ssecomi")
1398 (set_attr "prefix" "orig,maybe_vex")
1400 (if_then_else (match_operand:SF 1 "" "")
1402 (const_string "DF")))
1403 (set (attr "prefix_rep")
1404 (if_then_else (eq_attr "type" "ssecomi")
1406 (const_string "*")))
1407 (set (attr "prefix_data16")
1408 (cond [(eq_attr "type" "fcmp")
1410 (eq_attr "mode" "DF")
1413 (const_string "0")))
1414 (set_attr "athlon_decode" "vector")
1415 (set_attr "amdfam10_decode" "direct")])
1417 (define_insn "*cmpfp_i_sse"
1418 [(set (reg:CCFP FLAGS_REG)
1419 (compare:CCFP (match_operand 0 "register_operand" "x")
1420 (match_operand 1 "nonimmediate_operand" "xm")))]
1422 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1423 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1424 "* return output_fp_compare (insn, operands, 1, 0);"
1425 [(set_attr "type" "ssecomi")
1426 (set_attr "prefix" "maybe_vex")
1428 (if_then_else (match_operand:SF 1 "" "")
1430 (const_string "DF")))
1431 (set_attr "prefix_rep" "0")
1432 (set (attr "prefix_data16")
1433 (if_then_else (eq_attr "mode" "DF")
1435 (const_string "0")))
1436 (set_attr "athlon_decode" "vector")
1437 (set_attr "amdfam10_decode" "direct")])
1439 (define_insn "*cmpfp_i_i387"
1440 [(set (reg:CCFP FLAGS_REG)
1441 (compare:CCFP (match_operand 0 "register_operand" "f")
1442 (match_operand 1 "register_operand" "f")))]
1443 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1445 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1446 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1447 "* return output_fp_compare (insn, operands, 1, 0);"
1448 [(set_attr "type" "fcmp")
1450 (cond [(match_operand:SF 1 "" "")
1452 (match_operand:DF 1 "" "")
1455 (const_string "XF")))
1456 (set_attr "athlon_decode" "vector")
1457 (set_attr "amdfam10_decode" "direct")])
1459 (define_insn "*cmpfp_iu_mixed"
1460 [(set (reg:CCFPU FLAGS_REG)
1461 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1462 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1463 "TARGET_MIX_SSE_I387
1464 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1465 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1466 "* return output_fp_compare (insn, operands, 1, 1);"
1467 [(set_attr "type" "fcmp,ssecomi")
1468 (set_attr "prefix" "orig,maybe_vex")
1470 (if_then_else (match_operand:SF 1 "" "")
1472 (const_string "DF")))
1473 (set (attr "prefix_rep")
1474 (if_then_else (eq_attr "type" "ssecomi")
1476 (const_string "*")))
1477 (set (attr "prefix_data16")
1478 (cond [(eq_attr "type" "fcmp")
1480 (eq_attr "mode" "DF")
1483 (const_string "0")))
1484 (set_attr "athlon_decode" "vector")
1485 (set_attr "amdfam10_decode" "direct")])
1487 (define_insn "*cmpfp_iu_sse"
1488 [(set (reg:CCFPU FLAGS_REG)
1489 (compare:CCFPU (match_operand 0 "register_operand" "x")
1490 (match_operand 1 "nonimmediate_operand" "xm")))]
1492 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1493 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1494 "* return output_fp_compare (insn, operands, 1, 1);"
1495 [(set_attr "type" "ssecomi")
1496 (set_attr "prefix" "maybe_vex")
1498 (if_then_else (match_operand:SF 1 "" "")
1500 (const_string "DF")))
1501 (set_attr "prefix_rep" "0")
1502 (set (attr "prefix_data16")
1503 (if_then_else (eq_attr "mode" "DF")
1505 (const_string "0")))
1506 (set_attr "athlon_decode" "vector")
1507 (set_attr "amdfam10_decode" "direct")])
1509 (define_insn "*cmpfp_iu_387"
1510 [(set (reg:CCFPU FLAGS_REG)
1511 (compare:CCFPU (match_operand 0 "register_operand" "f")
1512 (match_operand 1 "register_operand" "f")))]
1513 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1515 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1516 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1517 "* return output_fp_compare (insn, operands, 1, 1);"
1518 [(set_attr "type" "fcmp")
1520 (cond [(match_operand:SF 1 "" "")
1522 (match_operand:DF 1 "" "")
1525 (const_string "XF")))
1526 (set_attr "athlon_decode" "vector")
1527 (set_attr "amdfam10_decode" "direct")])
1529 ;; Move instructions.
1531 ;; General case of fullword move.
1533 (define_expand "movsi"
1534 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1535 (match_operand:SI 1 "general_operand" ""))]
1537 "ix86_expand_move (SImode, operands); DONE;")
1539 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1542 ;; %%% We don't use a post-inc memory reference because x86 is not a
1543 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1544 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1545 ;; targets without our curiosities, and it is just as easy to represent
1546 ;; this differently.
1548 (define_insn "*pushsi2"
1549 [(set (match_operand:SI 0 "push_operand" "=<")
1550 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1553 [(set_attr "type" "push")
1554 (set_attr "mode" "SI")])
1556 ;; For 64BIT abi we always round up to 8 bytes.
1557 (define_insn "*pushsi2_rex64"
1558 [(set (match_operand:SI 0 "push_operand" "=X")
1559 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1562 [(set_attr "type" "push")
1563 (set_attr "mode" "SI")])
1565 (define_insn "*pushsi2_prologue"
1566 [(set (match_operand:SI 0 "push_operand" "=<")
1567 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1568 (clobber (mem:BLK (scratch)))]
1571 [(set_attr "type" "push")
1572 (set_attr "mode" "SI")])
1574 (define_insn "*popsi1_epilogue"
1575 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1576 (mem:SI (reg:SI SP_REG)))
1577 (set (reg:SI SP_REG)
1578 (plus:SI (reg:SI SP_REG) (const_int 4)))
1579 (clobber (mem:BLK (scratch)))]
1582 [(set_attr "type" "pop")
1583 (set_attr "mode" "SI")])
1585 (define_insn "popsi1"
1586 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1587 (mem:SI (reg:SI SP_REG)))
1588 (set (reg:SI SP_REG)
1589 (plus:SI (reg:SI SP_REG) (const_int 4)))]
1592 [(set_attr "type" "pop")
1593 (set_attr "mode" "SI")])
1595 (define_insn "*movsi_xor"
1596 [(set (match_operand:SI 0 "register_operand" "=r")
1597 (match_operand:SI 1 "const0_operand" ""))
1598 (clobber (reg:CC FLAGS_REG))]
1601 [(set_attr "type" "alu1")
1602 (set_attr "mode" "SI")
1603 (set_attr "length_immediate" "0")])
1605 (define_insn "*movsi_or"
1606 [(set (match_operand:SI 0 "register_operand" "=r")
1607 (match_operand:SI 1 "immediate_operand" "i"))
1608 (clobber (reg:CC FLAGS_REG))]
1610 && operands[1] == constm1_rtx"
1612 operands[1] = constm1_rtx;
1613 return "or{l}\t{%1, %0|%0, %1}";
1615 [(set_attr "type" "alu1")
1616 (set_attr "mode" "SI")
1617 (set_attr "length_immediate" "1")])
1619 (define_insn "*movsi_1"
1620 [(set (match_operand:SI 0 "nonimmediate_operand"
1621 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
1622 (match_operand:SI 1 "general_operand"
1623 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
1624 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1626 switch (get_attr_type (insn))
1629 if (get_attr_mode (insn) == MODE_TI)
1630 return "%vpxor\t%0, %d0";
1631 return "%vxorps\t%0, %d0";
1634 switch (get_attr_mode (insn))
1637 return "%vmovdqa\t{%1, %0|%0, %1}";
1639 return "%vmovaps\t{%1, %0|%0, %1}";
1641 return "%vmovd\t{%1, %0|%0, %1}";
1643 return "%vmovss\t{%1, %0|%0, %1}";
1649 return "pxor\t%0, %0";
1652 if (get_attr_mode (insn) == MODE_DI)
1653 return "movq\t{%1, %0|%0, %1}";
1654 return "movd\t{%1, %0|%0, %1}";
1657 return "lea{l}\t{%1, %0|%0, %1}";
1660 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1661 return "mov{l}\t{%1, %0|%0, %1}";
1665 (cond [(eq_attr "alternative" "2")
1666 (const_string "mmx")
1667 (eq_attr "alternative" "3,4,5")
1668 (const_string "mmxmov")
1669 (eq_attr "alternative" "6")
1670 (const_string "sselog1")
1671 (eq_attr "alternative" "7,8,9,10,11")
1672 (const_string "ssemov")
1673 (match_operand:DI 1 "pic_32bit_operand" "")
1674 (const_string "lea")
1676 (const_string "imov")))
1677 (set (attr "prefix")
1678 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
1679 (const_string "orig")
1680 (const_string "maybe_vex")))
1681 (set (attr "prefix_data16")
1682 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
1684 (const_string "*")))
1686 (cond [(eq_attr "alternative" "2,3")
1688 (eq_attr "alternative" "6,7")
1690 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1691 (const_string "V4SF")
1692 (const_string "TI"))
1693 (and (eq_attr "alternative" "8,9,10,11")
1694 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
1697 (const_string "SI")))])
1699 ;; Stores and loads of ax to arbitrary constant address.
1700 ;; We fake an second form of instruction to force reload to load address
1701 ;; into register when rax is not available
1702 (define_insn "*movabssi_1_rex64"
1703 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1704 (match_operand:SI 1 "nonmemory_operand" "a,er"))]
1705 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1707 movabs{l}\t{%1, %P0|%P0, %1}
1708 mov{l}\t{%1, %a0|%a0, %1}"
1709 [(set_attr "type" "imov")
1710 (set_attr "modrm" "0,*")
1711 (set_attr "length_address" "8,0")
1712 (set_attr "length_immediate" "0,*")
1713 (set_attr "memory" "store")
1714 (set_attr "mode" "SI")])
1716 (define_insn "*movabssi_2_rex64"
1717 [(set (match_operand:SI 0 "register_operand" "=a,r")
1718 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1719 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1721 movabs{l}\t{%P1, %0|%0, %P1}
1722 mov{l}\t{%a1, %0|%0, %a1}"
1723 [(set_attr "type" "imov")
1724 (set_attr "modrm" "0,*")
1725 (set_attr "length_address" "8,0")
1726 (set_attr "length_immediate" "0")
1727 (set_attr "memory" "load")
1728 (set_attr "mode" "SI")])
1730 (define_insn "*swapsi"
1731 [(set (match_operand:SI 0 "register_operand" "+r")
1732 (match_operand:SI 1 "register_operand" "+r"))
1737 [(set_attr "type" "imov")
1738 (set_attr "mode" "SI")
1739 (set_attr "pent_pair" "np")
1740 (set_attr "athlon_decode" "vector")
1741 (set_attr "amdfam10_decode" "double")])
1743 (define_expand "movhi"
1744 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1745 (match_operand:HI 1 "general_operand" ""))]
1747 "ix86_expand_move (HImode, operands); DONE;")
1749 (define_insn "*pushhi2"
1750 [(set (match_operand:HI 0 "push_operand" "=X")
1751 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1754 [(set_attr "type" "push")
1755 (set_attr "mode" "SI")])
1757 ;; For 64BIT abi we always round up to 8 bytes.
1758 (define_insn "*pushhi2_rex64"
1759 [(set (match_operand:HI 0 "push_operand" "=X")
1760 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1763 [(set_attr "type" "push")
1764 (set_attr "mode" "DI")])
1766 (define_insn "*movhi_1"
1767 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
1768 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
1769 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1771 switch (get_attr_type (insn))
1774 /* movzwl is faster than movw on p2 due to partial word stalls,
1775 though not as fast as an aligned movl. */
1776 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1778 if (get_attr_mode (insn) == MODE_SI)
1779 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1781 return "mov{w}\t{%1, %0|%0, %1}";
1785 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0))
1786 (const_string "imov")
1787 (and (eq_attr "alternative" "0")
1788 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1790 (eq (symbol_ref "TARGET_HIMODE_MATH")
1792 (const_string "imov")
1793 (and (eq_attr "alternative" "1,2")
1794 (match_operand:HI 1 "aligned_operand" ""))
1795 (const_string "imov")
1796 (and (ne (symbol_ref "TARGET_MOVX")
1798 (eq_attr "alternative" "0,2"))
1799 (const_string "imovx")
1801 (const_string "imov")))
1803 (cond [(eq_attr "type" "imovx")
1805 (and (eq_attr "alternative" "1,2")
1806 (match_operand:HI 1 "aligned_operand" ""))
1808 (and (eq_attr "alternative" "0")
1809 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1811 (eq (symbol_ref "TARGET_HIMODE_MATH")
1815 (const_string "HI")))])
1817 ;; Stores and loads of ax to arbitrary constant address.
1818 ;; We fake an second form of instruction to force reload to load address
1819 ;; into register when rax is not available
1820 (define_insn "*movabshi_1_rex64"
1821 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1822 (match_operand:HI 1 "nonmemory_operand" "a,er"))]
1823 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1825 movabs{w}\t{%1, %P0|%P0, %1}
1826 mov{w}\t{%1, %a0|%a0, %1}"
1827 [(set_attr "type" "imov")
1828 (set_attr "modrm" "0,*")
1829 (set_attr "length_address" "8,0")
1830 (set_attr "length_immediate" "0,*")
1831 (set_attr "memory" "store")
1832 (set_attr "mode" "HI")])
1834 (define_insn "*movabshi_2_rex64"
1835 [(set (match_operand:HI 0 "register_operand" "=a,r")
1836 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1837 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1839 movabs{w}\t{%P1, %0|%0, %P1}
1840 mov{w}\t{%a1, %0|%0, %a1}"
1841 [(set_attr "type" "imov")
1842 (set_attr "modrm" "0,*")
1843 (set_attr "length_address" "8,0")
1844 (set_attr "length_immediate" "0")
1845 (set_attr "memory" "load")
1846 (set_attr "mode" "HI")])
1848 (define_insn "*swaphi_1"
1849 [(set (match_operand:HI 0 "register_operand" "+r")
1850 (match_operand:HI 1 "register_operand" "+r"))
1853 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
1855 [(set_attr "type" "imov")
1856 (set_attr "mode" "SI")
1857 (set_attr "pent_pair" "np")
1858 (set_attr "athlon_decode" "vector")
1859 (set_attr "amdfam10_decode" "double")])
1861 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1862 (define_insn "*swaphi_2"
1863 [(set (match_operand:HI 0 "register_operand" "+r")
1864 (match_operand:HI 1 "register_operand" "+r"))
1867 "TARGET_PARTIAL_REG_STALL"
1869 [(set_attr "type" "imov")
1870 (set_attr "mode" "HI")
1871 (set_attr "pent_pair" "np")
1872 (set_attr "athlon_decode" "vector")])
1874 (define_expand "movstricthi"
1875 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1876 (match_operand:HI 1 "general_operand" ""))]
1879 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
1881 /* Don't generate memory->memory moves, go through a register */
1882 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1883 operands[1] = force_reg (HImode, operands[1]);
1886 (define_insn "*movstricthi_1"
1887 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1888 (match_operand:HI 1 "general_operand" "rn,m"))]
1889 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
1890 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1891 "mov{w}\t{%1, %0|%0, %1}"
1892 [(set_attr "type" "imov")
1893 (set_attr "mode" "HI")])
1895 (define_insn "*movstricthi_xor"
1896 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1897 (match_operand:HI 1 "const0_operand" ""))
1898 (clobber (reg:CC FLAGS_REG))]
1901 [(set_attr "type" "alu1")
1902 (set_attr "mode" "HI")
1903 (set_attr "length_immediate" "0")])
1905 (define_expand "movqi"
1906 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1907 (match_operand:QI 1 "general_operand" ""))]
1909 "ix86_expand_move (QImode, operands); DONE;")
1911 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1912 ;; "push a byte". But actually we use pushl, which has the effect
1913 ;; of rounding the amount pushed up to a word.
1915 (define_insn "*pushqi2"
1916 [(set (match_operand:QI 0 "push_operand" "=X")
1917 (match_operand:QI 1 "nonmemory_no_elim_operand" "rn"))]
1920 [(set_attr "type" "push")
1921 (set_attr "mode" "SI")])
1923 ;; For 64BIT abi we always round up to 8 bytes.
1924 (define_insn "*pushqi2_rex64"
1925 [(set (match_operand:QI 0 "push_operand" "=X")
1926 (match_operand:QI 1 "nonmemory_no_elim_operand" "qn"))]
1929 [(set_attr "type" "push")
1930 (set_attr "mode" "DI")])
1932 ;; Situation is quite tricky about when to choose full sized (SImode) move
1933 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
1934 ;; partial register dependency machines (such as AMD Athlon), where QImode
1935 ;; moves issue extra dependency and for partial register stalls machines
1936 ;; that don't use QImode patterns (and QImode move cause stall on the next
1939 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1940 ;; register stall machines with, where we use QImode instructions, since
1941 ;; partial register stall can be caused there. Then we use movzx.
1942 (define_insn "*movqi_1"
1943 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1944 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
1945 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1947 switch (get_attr_type (insn))
1950 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
1951 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
1953 if (get_attr_mode (insn) == MODE_SI)
1954 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1956 return "mov{b}\t{%1, %0|%0, %1}";
1960 (cond [(and (eq_attr "alternative" "5")
1961 (not (match_operand:QI 1 "aligned_operand" "")))
1962 (const_string "imovx")
1963 (ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0))
1964 (const_string "imov")
1965 (and (eq_attr "alternative" "3")
1966 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1968 (eq (symbol_ref "TARGET_QIMODE_MATH")
1970 (const_string "imov")
1971 (eq_attr "alternative" "3,5")
1972 (const_string "imovx")
1973 (and (ne (symbol_ref "TARGET_MOVX")
1975 (eq_attr "alternative" "2"))
1976 (const_string "imovx")
1978 (const_string "imov")))
1980 (cond [(eq_attr "alternative" "3,4,5")
1982 (eq_attr "alternative" "6")
1984 (eq_attr "type" "imovx")
1986 (and (eq_attr "type" "imov")
1987 (and (eq_attr "alternative" "0,1")
1988 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
1990 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
1992 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1995 ;; Avoid partial register stalls when not using QImode arithmetic
1996 (and (eq_attr "type" "imov")
1997 (and (eq_attr "alternative" "0,1")
1998 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2000 (eq (symbol_ref "TARGET_QIMODE_MATH")
2004 (const_string "QI")))])
2006 (define_insn "*swapqi_1"
2007 [(set (match_operand:QI 0 "register_operand" "+r")
2008 (match_operand:QI 1 "register_operand" "+r"))
2011 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2013 [(set_attr "type" "imov")
2014 (set_attr "mode" "SI")
2015 (set_attr "pent_pair" "np")
2016 (set_attr "athlon_decode" "vector")
2017 (set_attr "amdfam10_decode" "vector")])
2019 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
2020 (define_insn "*swapqi_2"
2021 [(set (match_operand:QI 0 "register_operand" "+q")
2022 (match_operand:QI 1 "register_operand" "+q"))
2025 "TARGET_PARTIAL_REG_STALL"
2027 [(set_attr "type" "imov")
2028 (set_attr "mode" "QI")
2029 (set_attr "pent_pair" "np")
2030 (set_attr "athlon_decode" "vector")])
2032 (define_expand "movstrictqi"
2033 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
2034 (match_operand:QI 1 "general_operand" ""))]
2037 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2039 /* Don't generate memory->memory moves, go through a register. */
2040 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2041 operands[1] = force_reg (QImode, operands[1]);
2044 (define_insn "*movstrictqi_1"
2045 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
2046 (match_operand:QI 1 "general_operand" "*qn,m"))]
2047 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2048 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2049 "mov{b}\t{%1, %0|%0, %1}"
2050 [(set_attr "type" "imov")
2051 (set_attr "mode" "QI")])
2053 (define_insn "*movstrictqi_xor"
2054 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
2055 (match_operand:QI 1 "const0_operand" ""))
2056 (clobber (reg:CC FLAGS_REG))]
2059 [(set_attr "type" "alu1")
2060 (set_attr "mode" "QI")
2061 (set_attr "length_immediate" "0")])
2063 (define_insn "*movsi_extv_1"
2064 [(set (match_operand:SI 0 "register_operand" "=R")
2065 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
2069 "movs{bl|x}\t{%h1, %0|%0, %h1}"
2070 [(set_attr "type" "imovx")
2071 (set_attr "mode" "SI")])
2073 (define_insn "*movhi_extv_1"
2074 [(set (match_operand:HI 0 "register_operand" "=R")
2075 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
2079 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2080 [(set_attr "type" "imovx")
2081 (set_attr "mode" "SI")])
2083 (define_insn "*movqi_extv_1"
2084 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2085 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2090 switch (get_attr_type (insn))
2093 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2095 return "mov{b}\t{%h1, %0|%0, %h1}";
2099 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2100 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2101 (ne (symbol_ref "TARGET_MOVX")
2103 (const_string "imovx")
2104 (const_string "imov")))
2106 (if_then_else (eq_attr "type" "imovx")
2108 (const_string "QI")))])
2110 (define_insn "*movqi_extv_1_rex64"
2111 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2112 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2117 switch (get_attr_type (insn))
2120 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2122 return "mov{b}\t{%h1, %0|%0, %h1}";
2126 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2127 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2128 (ne (symbol_ref "TARGET_MOVX")
2130 (const_string "imovx")
2131 (const_string "imov")))
2133 (if_then_else (eq_attr "type" "imovx")
2135 (const_string "QI")))])
2137 ;; Stores and loads of ax to arbitrary constant address.
2138 ;; We fake an second form of instruction to force reload to load address
2139 ;; into register when rax is not available
2140 (define_insn "*movabsqi_1_rex64"
2141 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2142 (match_operand:QI 1 "nonmemory_operand" "a,er"))]
2143 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2145 movabs{b}\t{%1, %P0|%P0, %1}
2146 mov{b}\t{%1, %a0|%a0, %1}"
2147 [(set_attr "type" "imov")
2148 (set_attr "modrm" "0,*")
2149 (set_attr "length_address" "8,0")
2150 (set_attr "length_immediate" "0,*")
2151 (set_attr "memory" "store")
2152 (set_attr "mode" "QI")])
2154 (define_insn "*movabsqi_2_rex64"
2155 [(set (match_operand:QI 0 "register_operand" "=a,r")
2156 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2157 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2159 movabs{b}\t{%P1, %0|%0, %P1}
2160 mov{b}\t{%a1, %0|%0, %a1}"
2161 [(set_attr "type" "imov")
2162 (set_attr "modrm" "0,*")
2163 (set_attr "length_address" "8,0")
2164 (set_attr "length_immediate" "0")
2165 (set_attr "memory" "load")
2166 (set_attr "mode" "QI")])
2168 (define_insn "*movdi_extzv_1"
2169 [(set (match_operand:DI 0 "register_operand" "=R")
2170 (zero_extract:DI (match_operand 1 "ext_register_operand" "Q")
2174 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2175 [(set_attr "type" "imovx")
2176 (set_attr "mode" "SI")])
2178 (define_insn "*movsi_extzv_1"
2179 [(set (match_operand:SI 0 "register_operand" "=R")
2180 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
2184 "movz{bl|x}\t{%h1, %0|%0, %h1}"
2185 [(set_attr "type" "imovx")
2186 (set_attr "mode" "SI")])
2188 (define_insn "*movqi_extzv_2"
2189 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2190 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2195 switch (get_attr_type (insn))
2198 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2200 return "mov{b}\t{%h1, %0|%0, %h1}";
2204 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2205 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2206 (ne (symbol_ref "TARGET_MOVX")
2208 (const_string "imovx")
2209 (const_string "imov")))
2211 (if_then_else (eq_attr "type" "imovx")
2213 (const_string "QI")))])
2215 (define_insn "*movqi_extzv_2_rex64"
2216 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2217 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2222 switch (get_attr_type (insn))
2225 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2227 return "mov{b}\t{%h1, %0|%0, %h1}";
2231 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2232 (ne (symbol_ref "TARGET_MOVX")
2234 (const_string "imovx")
2235 (const_string "imov")))
2237 (if_then_else (eq_attr "type" "imovx")
2239 (const_string "QI")))])
2241 (define_insn "movsi_insv_1"
2242 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2245 (match_operand:SI 1 "general_operand" "Qmn"))]
2247 "mov{b}\t{%b1, %h0|%h0, %b1}"
2248 [(set_attr "type" "imov")
2249 (set_attr "mode" "QI")])
2251 (define_insn "*movsi_insv_1_rex64"
2252 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2255 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2257 "mov{b}\t{%b1, %h0|%h0, %b1}"
2258 [(set_attr "type" "imov")
2259 (set_attr "mode" "QI")])
2261 (define_insn "movdi_insv_1_rex64"
2262 [(set (zero_extract:DI (match_operand 0 "ext_register_operand" "+Q")
2265 (match_operand:DI 1 "nonmemory_operand" "Qn"))]
2267 "mov{b}\t{%b1, %h0|%h0, %b1}"
2268 [(set_attr "type" "imov")
2269 (set_attr "mode" "QI")])
2271 (define_insn "*movqi_insv_2"
2272 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2275 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2278 "mov{b}\t{%h1, %h0|%h0, %h1}"
2279 [(set_attr "type" "imov")
2280 (set_attr "mode" "QI")])
2282 (define_expand "movdi"
2283 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2284 (match_operand:DI 1 "general_operand" ""))]
2286 "ix86_expand_move (DImode, operands); DONE;")
2288 (define_insn "*pushdi"
2289 [(set (match_operand:DI 0 "push_operand" "=<")
2290 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2294 (define_insn "*pushdi2_rex64"
2295 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2296 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2301 [(set_attr "type" "push,multi")
2302 (set_attr "mode" "DI")])
2304 ;; Convert impossible pushes of immediate to existing instructions.
2305 ;; First try to get scratch register and go through it. In case this
2306 ;; fails, push sign extended lower part first and then overwrite
2307 ;; upper part by 32bit move.
2309 [(match_scratch:DI 2 "r")
2310 (set (match_operand:DI 0 "push_operand" "")
2311 (match_operand:DI 1 "immediate_operand" ""))]
2312 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2313 && !x86_64_immediate_operand (operands[1], DImode)"
2314 [(set (match_dup 2) (match_dup 1))
2315 (set (match_dup 0) (match_dup 2))]
2318 ;; We need to define this as both peepholer and splitter for case
2319 ;; peephole2 pass is not run.
2320 ;; "&& 1" is needed to keep it from matching the previous pattern.
2322 [(set (match_operand:DI 0 "push_operand" "")
2323 (match_operand:DI 1 "immediate_operand" ""))]
2324 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2325 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2326 [(set (match_dup 0) (match_dup 1))
2327 (set (match_dup 2) (match_dup 3))]
2328 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2329 operands[1] = gen_lowpart (DImode, operands[2]);
2330 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2335 [(set (match_operand:DI 0 "push_operand" "")
2336 (match_operand:DI 1 "immediate_operand" ""))]
2337 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2338 ? epilogue_completed : reload_completed)
2339 && !symbolic_operand (operands[1], DImode)
2340 && !x86_64_immediate_operand (operands[1], DImode)"
2341 [(set (match_dup 0) (match_dup 1))
2342 (set (match_dup 2) (match_dup 3))]
2343 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2344 operands[1] = gen_lowpart (DImode, operands[2]);
2345 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2349 (define_insn "*pushdi2_prologue_rex64"
2350 [(set (match_operand:DI 0 "push_operand" "=<")
2351 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2352 (clobber (mem:BLK (scratch)))]
2355 [(set_attr "type" "push")
2356 (set_attr "mode" "DI")])
2358 (define_insn "*popdi1_epilogue_rex64"
2359 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2360 (mem:DI (reg:DI SP_REG)))
2361 (set (reg:DI SP_REG)
2362 (plus:DI (reg:DI SP_REG) (const_int 8)))
2363 (clobber (mem:BLK (scratch)))]
2366 [(set_attr "type" "pop")
2367 (set_attr "mode" "DI")])
2369 (define_insn "popdi1"
2370 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2371 (mem:DI (reg:DI SP_REG)))
2372 (set (reg:DI SP_REG)
2373 (plus:DI (reg:DI SP_REG) (const_int 8)))]
2376 [(set_attr "type" "pop")
2377 (set_attr "mode" "DI")])
2379 (define_insn "*movdi_xor_rex64"
2380 [(set (match_operand:DI 0 "register_operand" "=r")
2381 (match_operand:DI 1 "const0_operand" ""))
2382 (clobber (reg:CC FLAGS_REG))]
2384 && reload_completed"
2386 [(set_attr "type" "alu1")
2387 (set_attr "mode" "SI")
2388 (set_attr "length_immediate" "0")])
2390 (define_insn "*movdi_or_rex64"
2391 [(set (match_operand:DI 0 "register_operand" "=r")
2392 (match_operand:DI 1 "const_int_operand" "i"))
2393 (clobber (reg:CC FLAGS_REG))]
2396 && operands[1] == constm1_rtx"
2398 operands[1] = constm1_rtx;
2399 return "or{q}\t{%1, %0|%0, %1}";
2401 [(set_attr "type" "alu1")
2402 (set_attr "mode" "DI")
2403 (set_attr "length_immediate" "1")])
2405 (define_insn "*movdi_2"
2406 [(set (match_operand:DI 0 "nonimmediate_operand"
2407 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2408 (match_operand:DI 1 "general_operand"
2409 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2410 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2415 movq\t{%1, %0|%0, %1}
2416 movq\t{%1, %0|%0, %1}
2418 %vmovq\t{%1, %0|%0, %1}
2419 %vmovdqa\t{%1, %0|%0, %1}
2420 %vmovq\t{%1, %0|%0, %1}
2422 movlps\t{%1, %0|%0, %1}
2423 movaps\t{%1, %0|%0, %1}
2424 movlps\t{%1, %0|%0, %1}"
2425 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2426 (set (attr "prefix")
2427 (if_then_else (eq_attr "alternative" "5,6,7,8")
2428 (const_string "vex")
2429 (const_string "orig")))
2430 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2433 [(set (match_operand:DI 0 "push_operand" "")
2434 (match_operand:DI 1 "general_operand" ""))]
2435 "!TARGET_64BIT && reload_completed
2436 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2438 "ix86_split_long_move (operands); DONE;")
2440 ;; %%% This multiword shite has got to go.
2442 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2443 (match_operand:DI 1 "general_operand" ""))]
2444 "!TARGET_64BIT && reload_completed
2445 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2446 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2448 "ix86_split_long_move (operands); DONE;")
2450 (define_insn "*movdi_1_rex64"
2451 [(set (match_operand:DI 0 "nonimmediate_operand"
2452 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
2453 (match_operand:DI 1 "general_operand"
2454 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
2455 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2457 switch (get_attr_type (insn))
2460 if (SSE_REG_P (operands[0]))
2461 return "movq2dq\t{%1, %0|%0, %1}";
2463 return "movdq2q\t{%1, %0|%0, %1}";
2468 if (get_attr_mode (insn) == MODE_TI)
2469 return "vmovdqa\t{%1, %0|%0, %1}";
2471 return "vmovq\t{%1, %0|%0, %1}";
2474 if (get_attr_mode (insn) == MODE_TI)
2475 return "movdqa\t{%1, %0|%0, %1}";
2479 /* Moves from and into integer register is done using movd
2480 opcode with REX prefix. */
2481 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2482 return "movd\t{%1, %0|%0, %1}";
2483 return "movq\t{%1, %0|%0, %1}";
2486 return "%vpxor\t%0, %d0";
2489 return "pxor\t%0, %0";
2495 return "lea{q}\t{%a1, %0|%0, %a1}";
2498 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2499 if (get_attr_mode (insn) == MODE_SI)
2500 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2501 else if (which_alternative == 2)
2502 return "movabs{q}\t{%1, %0|%0, %1}";
2504 return "mov{q}\t{%1, %0|%0, %1}";
2508 (cond [(eq_attr "alternative" "5")
2509 (const_string "mmx")
2510 (eq_attr "alternative" "6,7,8,9,10")
2511 (const_string "mmxmov")
2512 (eq_attr "alternative" "11")
2513 (const_string "sselog1")
2514 (eq_attr "alternative" "12,13,14,15,16")
2515 (const_string "ssemov")
2516 (eq_attr "alternative" "17,18")
2517 (const_string "ssecvt")
2518 (eq_attr "alternative" "4")
2519 (const_string "multi")
2520 (match_operand:DI 1 "pic_32bit_operand" "")
2521 (const_string "lea")
2523 (const_string "imov")))
2526 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2528 (const_string "*")))
2529 (set (attr "length_immediate")
2531 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2533 (const_string "*")))
2534 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2535 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2536 (set (attr "prefix")
2537 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2538 (const_string "maybe_vex")
2539 (const_string "orig")))
2540 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2542 ;; Stores and loads of ax to arbitrary constant address.
2543 ;; We fake an second form of instruction to force reload to load address
2544 ;; into register when rax is not available
2545 (define_insn "*movabsdi_1_rex64"
2546 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2547 (match_operand:DI 1 "nonmemory_operand" "a,er"))]
2548 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2550 movabs{q}\t{%1, %P0|%P0, %1}
2551 mov{q}\t{%1, %a0|%a0, %1}"
2552 [(set_attr "type" "imov")
2553 (set_attr "modrm" "0,*")
2554 (set_attr "length_address" "8,0")
2555 (set_attr "length_immediate" "0,*")
2556 (set_attr "memory" "store")
2557 (set_attr "mode" "DI")])
2559 (define_insn "*movabsdi_2_rex64"
2560 [(set (match_operand:DI 0 "register_operand" "=a,r")
2561 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2562 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2564 movabs{q}\t{%P1, %0|%0, %P1}
2565 mov{q}\t{%a1, %0|%0, %a1}"
2566 [(set_attr "type" "imov")
2567 (set_attr "modrm" "0,*")
2568 (set_attr "length_address" "8,0")
2569 (set_attr "length_immediate" "0")
2570 (set_attr "memory" "load")
2571 (set_attr "mode" "DI")])
2573 ;; Convert impossible stores of immediate to existing instructions.
2574 ;; First try to get scratch register and go through it. In case this
2575 ;; fails, move by 32bit parts.
2577 [(match_scratch:DI 2 "r")
2578 (set (match_operand:DI 0 "memory_operand" "")
2579 (match_operand:DI 1 "immediate_operand" ""))]
2580 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2581 && !x86_64_immediate_operand (operands[1], DImode)"
2582 [(set (match_dup 2) (match_dup 1))
2583 (set (match_dup 0) (match_dup 2))]
2586 ;; We need to define this as both peepholer and splitter for case
2587 ;; peephole2 pass is not run.
2588 ;; "&& 1" is needed to keep it from matching the previous pattern.
2590 [(set (match_operand:DI 0 "memory_operand" "")
2591 (match_operand:DI 1 "immediate_operand" ""))]
2592 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2593 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2594 [(set (match_dup 2) (match_dup 3))
2595 (set (match_dup 4) (match_dup 5))]
2596 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2599 [(set (match_operand:DI 0 "memory_operand" "")
2600 (match_operand:DI 1 "immediate_operand" ""))]
2601 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2602 ? epilogue_completed : reload_completed)
2603 && !symbolic_operand (operands[1], DImode)
2604 && !x86_64_immediate_operand (operands[1], DImode)"
2605 [(set (match_dup 2) (match_dup 3))
2606 (set (match_dup 4) (match_dup 5))]
2607 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2609 (define_insn "*swapdi_rex64"
2610 [(set (match_operand:DI 0 "register_operand" "+r")
2611 (match_operand:DI 1 "register_operand" "+r"))
2616 [(set_attr "type" "imov")
2617 (set_attr "mode" "DI")
2618 (set_attr "pent_pair" "np")
2619 (set_attr "athlon_decode" "vector")
2620 (set_attr "amdfam10_decode" "double")])
2622 (define_expand "movoi"
2623 [(set (match_operand:OI 0 "nonimmediate_operand" "")
2624 (match_operand:OI 1 "general_operand" ""))]
2626 "ix86_expand_move (OImode, operands); DONE;")
2628 (define_insn "*movoi_internal"
2629 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
2630 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
2632 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2634 switch (which_alternative)
2637 return "vxorps\t%0, %0, %0";
2640 if (misaligned_operand (operands[0], OImode)
2641 || misaligned_operand (operands[1], OImode))
2642 return "vmovdqu\t{%1, %0|%0, %1}";
2644 return "vmovdqa\t{%1, %0|%0, %1}";
2649 [(set_attr "type" "sselog1,ssemov,ssemov")
2650 (set_attr "prefix" "vex")
2651 (set_attr "mode" "OI")])
2653 (define_expand "movti"
2654 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2655 (match_operand:TI 1 "nonimmediate_operand" ""))]
2656 "TARGET_SSE || TARGET_64BIT"
2659 ix86_expand_move (TImode, operands);
2660 else if (push_operand (operands[0], TImode))
2661 ix86_expand_push (TImode, operands[1]);
2663 ix86_expand_vector_move (TImode, operands);
2667 (define_insn "*movti_internal"
2668 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
2669 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
2670 "TARGET_SSE && !TARGET_64BIT
2671 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2673 switch (which_alternative)
2676 if (get_attr_mode (insn) == MODE_V4SF)
2677 return "%vxorps\t%0, %d0";
2679 return "%vpxor\t%0, %d0";
2682 /* TDmode values are passed as TImode on the stack. Moving them
2683 to stack may result in unaligned memory access. */
2684 if (misaligned_operand (operands[0], TImode)
2685 || misaligned_operand (operands[1], TImode))
2687 if (get_attr_mode (insn) == MODE_V4SF)
2688 return "%vmovups\t{%1, %0|%0, %1}";
2690 return "%vmovdqu\t{%1, %0|%0, %1}";
2694 if (get_attr_mode (insn) == MODE_V4SF)
2695 return "%vmovaps\t{%1, %0|%0, %1}";
2697 return "%vmovdqa\t{%1, %0|%0, %1}";
2703 [(set_attr "type" "sselog1,ssemov,ssemov")
2704 (set_attr "prefix" "maybe_vex")
2706 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2707 (ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0)))
2708 (const_string "V4SF")
2709 (and (eq_attr "alternative" "2")
2710 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2712 (const_string "V4SF")]
2713 (const_string "TI")))])
2715 (define_insn "*movti_rex64"
2716 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
2717 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
2719 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2721 switch (which_alternative)
2727 if (get_attr_mode (insn) == MODE_V4SF)
2728 return "%vxorps\t%0, %d0";
2730 return "%vpxor\t%0, %d0";
2733 /* TDmode values are passed as TImode on the stack. Moving them
2734 to stack may result in unaligned memory access. */
2735 if (misaligned_operand (operands[0], TImode)
2736 || misaligned_operand (operands[1], TImode))
2738 if (get_attr_mode (insn) == MODE_V4SF)
2739 return "%vmovups\t{%1, %0|%0, %1}";
2741 return "%vmovdqu\t{%1, %0|%0, %1}";
2745 if (get_attr_mode (insn) == MODE_V4SF)
2746 return "%vmovaps\t{%1, %0|%0, %1}";
2748 return "%vmovdqa\t{%1, %0|%0, %1}";
2754 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
2755 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
2757 (cond [(eq_attr "alternative" "2,3")
2759 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2761 (const_string "V4SF")
2762 (const_string "TI"))
2763 (eq_attr "alternative" "4")
2765 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2767 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2769 (const_string "V4SF")
2770 (const_string "TI"))]
2771 (const_string "DI")))])
2774 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2775 (match_operand:TI 1 "general_operand" ""))]
2776 "reload_completed && !SSE_REG_P (operands[0])
2777 && !SSE_REG_P (operands[1])"
2779 "ix86_split_long_move (operands); DONE;")
2781 ;; This expands to what emit_move_complex would generate if we didn't
2782 ;; have a movti pattern. Having this avoids problems with reload on
2783 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
2784 ;; to have around all the time.
2785 (define_expand "movcdi"
2786 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
2787 (match_operand:CDI 1 "general_operand" ""))]
2790 if (push_operand (operands[0], CDImode))
2791 emit_move_complex_push (CDImode, operands[0], operands[1]);
2793 emit_move_complex_parts (operands[0], operands[1]);
2797 (define_expand "movsf"
2798 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2799 (match_operand:SF 1 "general_operand" ""))]
2801 "ix86_expand_move (SFmode, operands); DONE;")
2803 (define_insn "*pushsf"
2804 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2805 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2808 /* Anything else should be already split before reg-stack. */
2809 gcc_assert (which_alternative == 1);
2810 return "push{l}\t%1";
2812 [(set_attr "type" "multi,push,multi")
2813 (set_attr "unit" "i387,*,*")
2814 (set_attr "mode" "SF,SI,SF")])
2816 (define_insn "*pushsf_rex64"
2817 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2818 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2821 /* Anything else should be already split before reg-stack. */
2822 gcc_assert (which_alternative == 1);
2823 return "push{q}\t%q1";
2825 [(set_attr "type" "multi,push,multi")
2826 (set_attr "unit" "i387,*,*")
2827 (set_attr "mode" "SF,DI,SF")])
2830 [(set (match_operand:SF 0 "push_operand" "")
2831 (match_operand:SF 1 "memory_operand" ""))]
2833 && MEM_P (operands[1])
2834 && (operands[2] = find_constant_src (insn))"
2838 ;; %%% Kill this when call knows how to work this out.
2840 [(set (match_operand:SF 0 "push_operand" "")
2841 (match_operand:SF 1 "any_fp_register_operand" ""))]
2843 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
2844 (set (mem:SF (reg:SI SP_REG)) (match_dup 1))])
2847 [(set (match_operand:SF 0 "push_operand" "")
2848 (match_operand:SF 1 "any_fp_register_operand" ""))]
2850 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2851 (set (mem:SF (reg:DI SP_REG)) (match_dup 1))])
2853 (define_insn "*movsf_1"
2854 [(set (match_operand:SF 0 "nonimmediate_operand"
2855 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
2856 (match_operand:SF 1 "general_operand"
2857 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
2858 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2859 && (reload_in_progress || reload_completed
2860 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2861 || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
2862 && standard_80387_constant_p (operands[1]))
2863 || GET_CODE (operands[1]) != CONST_DOUBLE
2864 || memory_operand (operands[0], SFmode))"
2866 switch (which_alternative)
2870 return output_387_reg_move (insn, operands);
2873 return standard_80387_constant_opcode (operands[1]);
2877 return "mov{l}\t{%1, %0|%0, %1}";
2879 if (get_attr_mode (insn) == MODE_TI)
2880 return "%vpxor\t%0, %d0";
2882 return "%vxorps\t%0, %d0";
2884 if (get_attr_mode (insn) == MODE_V4SF)
2885 return "%vmovaps\t{%1, %0|%0, %1}";
2887 return "%vmovss\t{%1, %d0|%d0, %1}";
2890 return REG_P (operands[1]) ? "vmovss\t{%1, %0, %0|%0, %0, %1}"
2891 : "vmovss\t{%1, %0|%0, %1}";
2893 return "movss\t{%1, %0|%0, %1}";
2895 return "%vmovss\t{%1, %0|%0, %1}";
2897 case 9: case 10: case 14: case 15:
2898 return "movd\t{%1, %0|%0, %1}";
2900 return "%vmovd\t{%1, %0|%0, %1}";
2903 return "movq\t{%1, %0|%0, %1}";
2909 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
2910 (set (attr "prefix")
2911 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
2912 (const_string "maybe_vex")
2913 (const_string "orig")))
2915 (cond [(eq_attr "alternative" "3,4,9,10")
2917 (eq_attr "alternative" "5")
2919 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2921 (ne (symbol_ref "TARGET_SSE2")
2923 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2926 (const_string "V4SF"))
2927 /* For architectures resolving dependencies on
2928 whole SSE registers use APS move to break dependency
2929 chains, otherwise use short move to avoid extra work.
2931 Do the same for architectures resolving dependencies on
2932 the parts. While in DF mode it is better to always handle
2933 just register parts, the SF mode is different due to lack
2934 of instructions to load just part of the register. It is
2935 better to maintain the whole registers in single format
2936 to avoid problems on using packed logical operations. */
2937 (eq_attr "alternative" "6")
2939 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2941 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2943 (const_string "V4SF")
2944 (const_string "SF"))
2945 (eq_attr "alternative" "11")
2946 (const_string "DI")]
2947 (const_string "SF")))])
2949 (define_insn "*swapsf"
2950 [(set (match_operand:SF 0 "fp_register_operand" "+f")
2951 (match_operand:SF 1 "fp_register_operand" "+f"))
2954 "reload_completed || TARGET_80387"
2956 if (STACK_TOP_P (operands[0]))
2961 [(set_attr "type" "fxch")
2962 (set_attr "mode" "SF")])
2964 (define_expand "movdf"
2965 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2966 (match_operand:DF 1 "general_operand" ""))]
2968 "ix86_expand_move (DFmode, operands); DONE;")
2970 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2971 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2972 ;; On the average, pushdf using integers can be still shorter. Allow this
2973 ;; pattern for optimize_size too.
2975 (define_insn "*pushdf_nointeger"
2976 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2977 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2978 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2980 /* This insn should be already split before reg-stack. */
2983 [(set_attr "type" "multi")
2984 (set_attr "unit" "i387,*,*,*")
2985 (set_attr "mode" "DF,SI,SI,DF")])
2987 (define_insn "*pushdf_integer"
2988 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2989 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2990 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2992 /* This insn should be already split before reg-stack. */
2995 [(set_attr "type" "multi")
2996 (set_attr "unit" "i387,*,*")
2997 (set_attr "mode" "DF,SI,DF")])
2999 ;; %%% Kill this when call knows how to work this out.
3001 [(set (match_operand:DF 0 "push_operand" "")
3002 (match_operand:DF 1 "any_fp_register_operand" ""))]
3004 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
3005 (set (mem:DF (reg:P SP_REG)) (match_dup 1))]
3009 [(set (match_operand:DF 0 "push_operand" "")
3010 (match_operand:DF 1 "general_operand" ""))]
3013 "ix86_split_long_move (operands); DONE;")
3015 ;; Moving is usually shorter when only FP registers are used. This separate
3016 ;; movdf pattern avoids the use of integer registers for FP operations
3017 ;; when optimizing for size.
3019 (define_insn "*movdf_nointeger"
3020 [(set (match_operand:DF 0 "nonimmediate_operand"
3021 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
3022 (match_operand:DF 1 "general_operand"
3023 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
3024 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3025 && ((optimize_function_for_size_p (cfun)
3026 || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
3027 && (reload_in_progress || reload_completed
3028 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3029 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3030 && optimize_function_for_size_p (cfun)
3031 && !memory_operand (operands[0], DFmode)
3032 && standard_80387_constant_p (operands[1]))
3033 || GET_CODE (operands[1]) != CONST_DOUBLE
3034 || ((optimize_function_for_size_p (cfun)
3035 || !TARGET_MEMORY_MISMATCH_STALL
3036 || reload_in_progress || reload_completed)
3037 && memory_operand (operands[0], DFmode)))"
3039 switch (which_alternative)
3043 return output_387_reg_move (insn, operands);
3046 return standard_80387_constant_opcode (operands[1]);
3052 switch (get_attr_mode (insn))
3055 return "%vxorps\t%0, %d0";
3057 return "%vxorpd\t%0, %d0";
3059 return "%vpxor\t%0, %d0";
3066 switch (get_attr_mode (insn))
3069 return "%vmovaps\t{%1, %0|%0, %1}";
3071 return "%vmovapd\t{%1, %0|%0, %1}";
3073 return "%vmovdqa\t{%1, %0|%0, %1}";
3075 return "%vmovq\t{%1, %0|%0, %1}";
3079 if (REG_P (operands[0]) && REG_P (operands[1]))
3080 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3082 return "vmovsd\t{%1, %0|%0, %1}";
3085 return "movsd\t{%1, %0|%0, %1}";
3089 if (REG_P (operands[0]))
3090 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3092 return "vmovlpd\t{%1, %0|%0, %1}";
3095 return "movlpd\t{%1, %0|%0, %1}";
3099 if (REG_P (operands[0]))
3100 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3102 return "vmovlps\t{%1, %0|%0, %1}";
3105 return "movlps\t{%1, %0|%0, %1}";
3114 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3115 (set (attr "prefix")
3116 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3117 (const_string "orig")
3118 (const_string "maybe_vex")))
3119 (set (attr "prefix_data16")
3120 (if_then_else (eq_attr "mode" "V1DF")
3122 (const_string "*")))
3124 (cond [(eq_attr "alternative" "0,1,2")
3126 (eq_attr "alternative" "3,4")
3129 /* For SSE1, we have many fewer alternatives. */
3130 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3131 (cond [(eq_attr "alternative" "5,6")
3132 (const_string "V4SF")
3134 (const_string "V2SF"))
3136 /* xorps is one byte shorter. */
3137 (eq_attr "alternative" "5")
3138 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3140 (const_string "V4SF")
3141 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3145 (const_string "V2DF"))
3147 /* For architectures resolving dependencies on
3148 whole SSE registers use APD move to break dependency
3149 chains, otherwise use short move to avoid extra work.
3151 movaps encodes one byte shorter. */
3152 (eq_attr "alternative" "6")
3154 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3156 (const_string "V4SF")
3157 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3159 (const_string "V2DF")
3161 (const_string "DF"))
3162 /* For architectures resolving dependencies on register
3163 parts we may avoid extra work to zero out upper part
3165 (eq_attr "alternative" "7")
3167 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3169 (const_string "V1DF")
3170 (const_string "DF"))
3172 (const_string "DF")))])
3174 (define_insn "*movdf_integer_rex64"
3175 [(set (match_operand:DF 0 "nonimmediate_operand"
3176 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
3177 (match_operand:DF 1 "general_operand"
3178 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
3179 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3180 && (reload_in_progress || reload_completed
3181 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3182 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3183 && optimize_function_for_size_p (cfun)
3184 && standard_80387_constant_p (operands[1]))
3185 || GET_CODE (operands[1]) != CONST_DOUBLE
3186 || memory_operand (operands[0], DFmode))"
3188 switch (which_alternative)
3192 return output_387_reg_move (insn, operands);
3195 return standard_80387_constant_opcode (operands[1]);
3202 switch (get_attr_mode (insn))
3205 return "%vxorps\t%0, %d0";
3207 return "%vxorpd\t%0, %d0";
3209 return "%vpxor\t%0, %d0";
3216 switch (get_attr_mode (insn))
3219 return "%vmovaps\t{%1, %0|%0, %1}";
3221 return "%vmovapd\t{%1, %0|%0, %1}";
3223 return "%vmovdqa\t{%1, %0|%0, %1}";
3225 return "%vmovq\t{%1, %0|%0, %1}";
3229 if (REG_P (operands[0]) && REG_P (operands[1]))
3230 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3232 return "vmovsd\t{%1, %0|%0, %1}";
3235 return "movsd\t{%1, %0|%0, %1}";
3237 return "%vmovlpd\t{%1, %d0|%d0, %1}";
3239 return "%vmovlps\t{%1, %d0|%d0, %1}";
3246 return "%vmovd\t{%1, %0|%0, %1}";
3252 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
3253 (set (attr "prefix")
3254 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3255 (const_string "orig")
3256 (const_string "maybe_vex")))
3257 (set (attr "prefix_data16")
3258 (if_then_else (eq_attr "mode" "V1DF")
3260 (const_string "*")))
3262 (cond [(eq_attr "alternative" "0,1,2")
3264 (eq_attr "alternative" "3,4,9,10")
3267 /* For SSE1, we have many fewer alternatives. */
3268 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3269 (cond [(eq_attr "alternative" "5,6")
3270 (const_string "V4SF")
3272 (const_string "V2SF"))
3274 /* xorps is one byte shorter. */
3275 (eq_attr "alternative" "5")
3276 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3278 (const_string "V4SF")
3279 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3283 (const_string "V2DF"))
3285 /* For architectures resolving dependencies on
3286 whole SSE registers use APD move to break dependency
3287 chains, otherwise use short move to avoid extra work.
3289 movaps encodes one byte shorter. */
3290 (eq_attr "alternative" "6")
3292 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3294 (const_string "V4SF")
3295 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3297 (const_string "V2DF")
3299 (const_string "DF"))
3300 /* For architectures resolving dependencies on register
3301 parts we may avoid extra work to zero out upper part
3303 (eq_attr "alternative" "7")
3305 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3307 (const_string "V1DF")
3308 (const_string "DF"))
3310 (const_string "DF")))])
3312 (define_insn "*movdf_integer"
3313 [(set (match_operand:DF 0 "nonimmediate_operand"