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, 2010
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 ;; F,f -- likewise, but for floating-point.
34 ;; O -- if HAVE_AS_IX86_CMOV_SUN_SYNTAX, expand to "w.", "l." or "q.",
36 ;; R -- print the prefix for register names.
37 ;; z -- print the opcode suffix for the size of the current operand.
38 ;; Z -- likewise, with special suffixes for x87 instructions.
39 ;; * -- print a star (in certain assembler syntax)
40 ;; A -- print an absolute memory reference.
41 ;; w -- print the operand as if it's a "word" (HImode) even if it isn't.
42 ;; s -- print a shift double count, followed by the assemblers argument
44 ;; b -- print the QImode name of the register for the indicated operand.
45 ;; %b0 would print %al if operands[0] is reg 0.
46 ;; w -- likewise, print the HImode name of the register.
47 ;; k -- likewise, print the SImode name of the register.
48 ;; q -- likewise, print the DImode name of the register.
49 ;; x -- likewise, print the V4SFmode name of the register.
50 ;; t -- likewise, print the V8SFmode name of the register.
51 ;; h -- print the QImode name for a "high" register, either ah, bh, ch or dh.
52 ;; y -- print "st(0)" instead of "st" as a register.
53 ;; d -- print duplicated register operand for AVX instruction.
54 ;; D -- print condition for SSE cmp instruction.
55 ;; P -- if PIC, print an @PLT suffix.
56 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
57 ;; & -- print some in-use local-dynamic symbol name.
58 ;; H -- print a memory address offset by 8; used for sse high-parts
59 ;; Y -- print condition for XOP pcom* instruction.
60 ;; + -- print a branch hint as 'cs' or 'ds' prefix
61 ;; ; -- print a semicolon (after prefixes due to bug in older gas).
66 [; Relocation specifiers
77 (UNSPEC_MACHOPIC_OFFSET 10)
80 (UNSPEC_STACK_ALLOC 11)
82 (UNSPEC_SSE_PROLOGUE_SAVE 13)
86 (UNSPEC_SET_GOT_OFFSET 17)
87 (UNSPEC_MEMORY_BLOCKAGE 18)
88 (UNSPEC_SSE_PROLOGUE_SAVE_LOW 19)
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)
210 (UNSPEC_AESENCLAST 160)
212 (UNSPEC_AESDECLAST 162)
214 (UNSPEC_AESKEYGENASSIST 164)
222 (UNSPEC_VPERMIL2 168)
223 (UNSPEC_VPERMIL2F128 169)
224 (UNSPEC_MASKLOAD 170)
225 (UNSPEC_MASKSTORE 171)
231 [(UNSPECV_BLOCKAGE 0)
232 (UNSPECV_STACK_PROBE 1)
244 (UNSPECV_PROLOGUE_USE 14)
246 (UNSPECV_VZEROALL 16)
247 (UNSPECV_VZEROUPPER 17)
251 (UNSPECV_VSWAPMOV 21)
252 (UNSPECV_LLWP_INTRINSIC 22)
253 (UNSPECV_SLWP_INTRINSIC 23)
254 (UNSPECV_LWPVAL_INTRINSIC 24)
255 (UNSPECV_LWPINS_INTRINSIC 25)
258 ;; Constants to represent pcomtrue/pcomfalse variants
268 ;; Constants used in the XOP pperm instruction
270 [(PPERM_SRC 0x00) /* copy source */
271 (PPERM_INVERT 0x20) /* invert source */
272 (PPERM_REVERSE 0x40) /* bit reverse source */
273 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
274 (PPERM_ZERO 0x80) /* all 0's */
275 (PPERM_ONES 0xa0) /* all 1's */
276 (PPERM_SIGN 0xc0) /* propagate sign bit */
277 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
278 (PPERM_SRC1 0x00) /* use first source byte */
279 (PPERM_SRC2 0x10) /* use second source byte */
282 ;; Registers by name.
335 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
338 ;; In C guard expressions, put expressions which may be compile-time
339 ;; constants first. This allows for better optimization. For
340 ;; example, write "TARGET_64BIT && reload_completed", not
341 ;; "reload_completed && TARGET_64BIT".
345 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,atom,
346 generic64,amdfam10,bdver1"
347 (const (symbol_ref "ix86_schedule")))
349 ;; A basic instruction type. Refinements due to arguments to be
350 ;; provided in other attributes.
353 alu,alu1,negnot,imov,imovx,lea,
354 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
355 icmp,test,ibr,setcc,icmov,
356 push,pop,call,callv,leave,
358 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
359 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
360 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
361 ssemuladd,sse4arg,lwp,
362 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
363 (const_string "other"))
365 ;; Main data type used by the insn
367 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
368 (const_string "unknown"))
370 ;; The CPU unit operations uses.
371 (define_attr "unit" "integer,i387,sse,mmx,unknown"
372 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
373 (const_string "i387")
374 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
375 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
376 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
378 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
380 (eq_attr "type" "other")
381 (const_string "unknown")]
382 (const_string "integer")))
384 ;; The (bounding maximum) length of an instruction immediate.
385 (define_attr "length_immediate" ""
386 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
389 (eq_attr "unit" "i387,sse,mmx")
391 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
393 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
394 (eq_attr "type" "imov,test")
395 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
396 (eq_attr "type" "call")
397 (if_then_else (match_operand 0 "constant_call_address_operand" "")
400 (eq_attr "type" "callv")
401 (if_then_else (match_operand 1 "constant_call_address_operand" "")
404 ;; We don't know the size before shorten_branches. Expect
405 ;; the instruction to fit for better scheduling.
406 (eq_attr "type" "ibr")
409 (symbol_ref "/* Update immediate_length and other attributes! */
410 gcc_unreachable (),1")))
412 ;; The (bounding maximum) length of an instruction address.
413 (define_attr "length_address" ""
414 (cond [(eq_attr "type" "str,other,multi,fxch")
416 (and (eq_attr "type" "call")
417 (match_operand 0 "constant_call_address_operand" ""))
419 (and (eq_attr "type" "callv")
420 (match_operand 1 "constant_call_address_operand" ""))
423 (symbol_ref "ix86_attr_length_address_default (insn)")))
425 ;; Set when length prefix is used.
426 (define_attr "prefix_data16" ""
427 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
429 (eq_attr "mode" "HI")
431 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
436 ;; Set when string REP prefix is used.
437 (define_attr "prefix_rep" ""
438 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
440 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
445 ;; Set when 0f opcode prefix is used.
446 (define_attr "prefix_0f" ""
448 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
449 (eq_attr "unit" "sse,mmx"))
453 ;; Set when REX opcode prefix is used.
454 (define_attr "prefix_rex" ""
455 (cond [(ne (symbol_ref "!TARGET_64BIT") (const_int 0))
457 (and (eq_attr "mode" "DI")
458 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
459 (eq_attr "unit" "!mmx")))
461 (and (eq_attr "mode" "QI")
462 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
465 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
468 (and (eq_attr "type" "imovx")
469 (match_operand:QI 1 "ext_QIreg_operand" ""))
474 ;; There are also additional prefixes in 3DNOW, SSSE3.
475 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
476 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
477 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
478 (define_attr "prefix_extra" ""
479 (cond [(eq_attr "type" "ssemuladd,sse4arg")
481 (eq_attr "type" "sseiadd1,ssecvt1")
486 ;; Prefix used: original, VEX or maybe VEX.
487 (define_attr "prefix" "orig,vex,maybe_vex"
488 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
490 (const_string "orig")))
492 ;; VEX W bit is used.
493 (define_attr "prefix_vex_w" "" (const_int 0))
495 ;; The length of VEX prefix
496 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
497 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
498 ;; still prefix_0f 1, with prefix_extra 1.
499 (define_attr "length_vex" ""
500 (if_then_else (and (eq_attr "prefix_0f" "1")
501 (eq_attr "prefix_extra" "0"))
502 (if_then_else (eq_attr "prefix_vex_w" "1")
503 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
504 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
505 (if_then_else (eq_attr "prefix_vex_w" "1")
506 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
507 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
509 ;; Set when modrm byte is used.
510 (define_attr "modrm" ""
511 (cond [(eq_attr "type" "str,leave")
513 (eq_attr "unit" "i387")
515 (and (eq_attr "type" "incdec")
516 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
517 (ior (match_operand:SI 1 "register_operand" "")
518 (match_operand:HI 1 "register_operand" ""))))
520 (and (eq_attr "type" "push")
521 (not (match_operand 1 "memory_operand" "")))
523 (and (eq_attr "type" "pop")
524 (not (match_operand 0 "memory_operand" "")))
526 (and (eq_attr "type" "imov")
527 (and (not (eq_attr "mode" "DI"))
528 (ior (and (match_operand 0 "register_operand" "")
529 (match_operand 1 "immediate_operand" ""))
530 (ior (and (match_operand 0 "ax_reg_operand" "")
531 (match_operand 1 "memory_displacement_only_operand" ""))
532 (and (match_operand 0 "memory_displacement_only_operand" "")
533 (match_operand 1 "ax_reg_operand" ""))))))
535 (and (eq_attr "type" "call")
536 (match_operand 0 "constant_call_address_operand" ""))
538 (and (eq_attr "type" "callv")
539 (match_operand 1 "constant_call_address_operand" ""))
541 (and (eq_attr "type" "alu,alu1,icmp,test")
542 (match_operand 0 "ax_reg_operand" ""))
543 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
547 ;; The (bounding maximum) length of an instruction in bytes.
548 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
549 ;; Later we may want to split them and compute proper length as for
551 (define_attr "length" ""
552 (cond [(eq_attr "type" "other,multi,fistp,frndint")
554 (eq_attr "type" "fcmp")
556 (eq_attr "unit" "i387")
558 (plus (attr "prefix_data16")
559 (attr "length_address")))
560 (ior (eq_attr "prefix" "vex")
561 (and (eq_attr "prefix" "maybe_vex")
562 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
563 (plus (attr "length_vex")
564 (plus (attr "length_immediate")
566 (attr "length_address"))))]
567 (plus (plus (attr "modrm")
568 (plus (attr "prefix_0f")
569 (plus (attr "prefix_rex")
570 (plus (attr "prefix_extra")
572 (plus (attr "prefix_rep")
573 (plus (attr "prefix_data16")
574 (plus (attr "length_immediate")
575 (attr "length_address")))))))
577 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
578 ;; `store' if there is a simple memory reference therein, or `unknown'
579 ;; if the instruction is complex.
581 (define_attr "memory" "none,load,store,both,unknown"
582 (cond [(eq_attr "type" "other,multi,str,lwp")
583 (const_string "unknown")
584 (eq_attr "type" "lea,fcmov,fpspc")
585 (const_string "none")
586 (eq_attr "type" "fistp,leave")
587 (const_string "both")
588 (eq_attr "type" "frndint")
589 (const_string "load")
590 (eq_attr "type" "push")
591 (if_then_else (match_operand 1 "memory_operand" "")
592 (const_string "both")
593 (const_string "store"))
594 (eq_attr "type" "pop")
595 (if_then_else (match_operand 0 "memory_operand" "")
596 (const_string "both")
597 (const_string "load"))
598 (eq_attr "type" "setcc")
599 (if_then_else (match_operand 0 "memory_operand" "")
600 (const_string "store")
601 (const_string "none"))
602 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
603 (if_then_else (ior (match_operand 0 "memory_operand" "")
604 (match_operand 1 "memory_operand" ""))
605 (const_string "load")
606 (const_string "none"))
607 (eq_attr "type" "ibr")
608 (if_then_else (match_operand 0 "memory_operand" "")
609 (const_string "load")
610 (const_string "none"))
611 (eq_attr "type" "call")
612 (if_then_else (match_operand 0 "constant_call_address_operand" "")
613 (const_string "none")
614 (const_string "load"))
615 (eq_attr "type" "callv")
616 (if_then_else (match_operand 1 "constant_call_address_operand" "")
617 (const_string "none")
618 (const_string "load"))
619 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
620 (match_operand 1 "memory_operand" ""))
621 (const_string "both")
622 (and (match_operand 0 "memory_operand" "")
623 (match_operand 1 "memory_operand" ""))
624 (const_string "both")
625 (match_operand 0 "memory_operand" "")
626 (const_string "store")
627 (match_operand 1 "memory_operand" "")
628 (const_string "load")
630 "!alu1,negnot,ishift1,
631 imov,imovx,icmp,test,bitmanip,
633 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
634 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
635 (match_operand 2 "memory_operand" ""))
636 (const_string "load")
637 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
638 (match_operand 3 "memory_operand" ""))
639 (const_string "load")
641 (const_string "none")))
643 ;; Indicates if an instruction has both an immediate and a displacement.
645 (define_attr "imm_disp" "false,true,unknown"
646 (cond [(eq_attr "type" "other,multi")
647 (const_string "unknown")
648 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
649 (and (match_operand 0 "memory_displacement_operand" "")
650 (match_operand 1 "immediate_operand" "")))
651 (const_string "true")
652 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
653 (and (match_operand 0 "memory_displacement_operand" "")
654 (match_operand 2 "immediate_operand" "")))
655 (const_string "true")
657 (const_string "false")))
659 ;; Indicates if an FP operation has an integer source.
661 (define_attr "fp_int_src" "false,true"
662 (const_string "false"))
664 ;; Defines rounding mode of an FP operation.
666 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
667 (const_string "any"))
669 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
670 (define_attr "use_carry" "0,1" (const_string "0"))
672 ;; Define attribute to indicate unaligned ssemov insns
673 (define_attr "movu" "0,1" (const_string "0"))
675 ;; Describe a user's asm statement.
676 (define_asm_attributes
677 [(set_attr "length" "128")
678 (set_attr "type" "multi")])
680 ;; All integer comparison codes.
681 (define_code_iterator int_cond [ne eq ge gt le lt geu gtu leu ltu])
683 ;; All floating-point comparison codes.
684 (define_code_iterator fp_cond [unordered ordered
685 uneq unge ungt unle unlt ltgt])
687 (define_code_iterator plusminus [plus minus])
689 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
691 ;; Base name for define_insn
692 (define_code_attr plusminus_insn
693 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
694 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
696 ;; Base name for insn mnemonic.
697 (define_code_attr plusminus_mnemonic
698 [(plus "add") (ss_plus "adds") (us_plus "addus")
699 (minus "sub") (ss_minus "subs") (us_minus "subus")])
700 (define_code_attr plusminus_carry_mnemonic
701 [(plus "adc") (minus "sbb")])
703 ;; Mark commutative operators as such in constraints.
704 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
705 (minus "") (ss_minus "") (us_minus "")])
707 ;; Mapping of signed max and min
708 (define_code_iterator smaxmin [smax smin])
710 ;; Mapping of unsigned max and min
711 (define_code_iterator umaxmin [umax umin])
713 ;; Mapping of signed/unsigned max and min
714 (define_code_iterator maxmin [smax smin umax umin])
716 ;; Base name for integer and FP insn mnemonic
717 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
718 (umax "maxu") (umin "minu")])
719 (define_code_attr maxmin_float [(smax "max") (smin "min")])
721 ;; Mapping of logic operators
722 (define_code_iterator any_logic [and ior xor])
723 (define_code_iterator any_or [ior xor])
725 ;; Base name for insn mnemonic.
726 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
728 ;; Mapping of shift-right operators
729 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
731 ;; Base name for define_insn
732 (define_code_attr shiftrt_insn [(lshiftrt "lshr") (ashiftrt "ashr")])
734 ;; Base name for insn mnemonic.
735 (define_code_attr shiftrt [(lshiftrt "shr") (ashiftrt "sar")])
737 ;; Mapping of rotate operators
738 (define_code_iterator any_rotate [rotate rotatert])
740 ;; Base name for define_insn
741 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
743 ;; Base name for insn mnemonic.
744 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
746 ;; Mapping of abs neg operators
747 (define_code_iterator absneg [abs neg])
749 ;; Base name for x87 insn mnemonic.
750 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
752 ;; Used in signed and unsigned widening multiplications.
753 (define_code_iterator any_extend [sign_extend zero_extend])
755 ;; Various insn prefixes for signed and unsigned operations.
756 (define_code_attr u [(sign_extend "") (zero_extend "u")
757 (div "") (udiv "u")])
758 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
760 ;; Used in signed and unsigned divisions.
761 (define_code_iterator any_div [div udiv])
763 ;; Instruction prefix for signed and unsigned operations.
764 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
765 (div "i") (udiv "")])
767 ;; All single word integer modes.
768 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
770 ;; Single word integer modes without DImode.
771 (define_mode_iterator SWI124 [QI HI SI])
773 ;; Single word integer modes without QImode.
774 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
776 ;; Single word integer modes without QImode and HImode.
777 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
779 ;; All math-dependant single and double word integer modes.
780 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
781 (HI "TARGET_HIMODE_MATH")
782 SI DI (TI "TARGET_64BIT")])
784 ;; Math-dependant single word integer modes.
785 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
786 (HI "TARGET_HIMODE_MATH")
787 SI (DI "TARGET_64BIT")])
789 ;; Math-dependant single word integer modes without DImode.
790 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
791 (HI "TARGET_HIMODE_MATH")
794 ;; Math-dependant single word integer modes without QImode.
795 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
796 SI (DI "TARGET_64BIT")])
798 ;; Double word integer modes.
799 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
800 (TI "TARGET_64BIT")])
802 ;; Double word integer modes as mode attribute.
803 (define_mode_attr DWI [(SI "DI") (DI "TI")])
804 (define_mode_attr dwi [(SI "di") (DI "ti")])
806 ;; Half mode for double word integer modes.
807 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
808 (DI "TARGET_64BIT")])
810 ;; Instruction suffix for integer modes.
811 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
813 ;; Register class for integer modes.
814 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
816 ;; Immediate operand constraint for integer modes.
817 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
819 ;; General operand constraint for word modes.
820 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "g") (DI "rme")])
822 ;; Immediate operand constraint for double integer modes.
823 (define_mode_attr di [(SI "iF") (DI "e")])
825 ;; Immediate operand constraint for shifts.
826 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
828 ;; General operand predicate for integer modes.
829 (define_mode_attr general_operand
830 [(QI "general_operand")
831 (HI "general_operand")
832 (SI "general_operand")
833 (DI "x86_64_general_operand")
834 (TI "x86_64_general_operand")])
836 ;; General sign/zero extend operand predicate for integer modes.
837 (define_mode_attr general_szext_operand
838 [(QI "general_operand")
839 (HI "general_operand")
840 (SI "general_operand")
841 (DI "x86_64_szext_general_operand")])
843 ;; Operand predicate for shifts.
844 (define_mode_attr shift_operand
845 [(QI "nonimmediate_operand")
846 (HI "nonimmediate_operand")
847 (SI "nonimmediate_operand")
848 (DI "shiftdi_operand")
849 (TI "register_operand")])
851 ;; Operand predicate for shift argument.
852 (define_mode_attr shift_immediate_operand
853 [(QI "const_1_to_31_operand")
854 (HI "const_1_to_31_operand")
855 (SI "const_1_to_31_operand")
856 (DI "const_1_to_63_operand")])
858 ;; Input operand predicate for arithmetic left shifts.
859 (define_mode_attr ashl_input_operand
860 [(QI "nonimmediate_operand")
861 (HI "nonimmediate_operand")
862 (SI "nonimmediate_operand")
863 (DI "ashldi_input_operand")
864 (TI "reg_or_pm1_operand")])
866 ;; SSE and x87 SFmode and DFmode floating point modes
867 (define_mode_iterator MODEF [SF DF])
869 ;; All x87 floating point modes
870 (define_mode_iterator X87MODEF [SF DF XF])
872 ;; All integer modes handled by x87 fisttp operator.
873 (define_mode_iterator X87MODEI [HI SI DI])
875 ;; All integer modes handled by integer x87 operators.
876 (define_mode_iterator X87MODEI12 [HI SI])
878 ;; All integer modes handled by SSE cvtts?2si* operators.
879 (define_mode_iterator SSEMODEI24 [SI DI])
881 ;; SSE asm suffix for floating point modes
882 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
884 ;; SSE vector mode corresponding to a scalar mode
885 (define_mode_attr ssevecmode
886 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
888 ;; Instruction suffix for REX 64bit operators.
889 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
891 ;; This mode iterator allows :P to be used for patterns that operate on
892 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
893 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
895 ;; Scheduling descriptions
897 (include "pentium.md")
900 (include "athlon.md")
905 ;; Operand and operator predicates and constraints
907 (include "predicates.md")
908 (include "constraints.md")
911 ;; Compare and branch/compare and store instructions.
913 (define_expand "cbranch<mode>4"
914 [(set (reg:CC FLAGS_REG)
915 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
916 (match_operand:SDWIM 2 "<general_operand>" "")))
917 (set (pc) (if_then_else
918 (match_operator 0 "comparison_operator"
919 [(reg:CC FLAGS_REG) (const_int 0)])
920 (label_ref (match_operand 3 "" ""))
924 if (MEM_P (operands[1]) && MEM_P (operands[2]))
925 operands[1] = force_reg (<MODE>mode, operands[1]);
926 ix86_compare_op0 = operands[1];
927 ix86_compare_op1 = operands[2];
928 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
932 (define_expand "cstore<mode>4"
933 [(set (reg:CC FLAGS_REG)
934 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
935 (match_operand:SWIM 3 "<general_operand>" "")))
936 (set (match_operand:QI 0 "register_operand" "")
937 (match_operator 1 "comparison_operator"
938 [(reg:CC FLAGS_REG) (const_int 0)]))]
941 if (MEM_P (operands[2]) && MEM_P (operands[3]))
942 operands[2] = force_reg (<MODE>mode, operands[2]);
943 ix86_compare_op0 = operands[2];
944 ix86_compare_op1 = operands[3];
945 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
949 (define_expand "cmp<mode>_1"
950 [(set (reg:CC FLAGS_REG)
951 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
952 (match_operand:SWI48 1 "<general_operand>" "")))]
956 (define_insn "*cmp<mode>_ccno_1"
957 [(set (reg FLAGS_REG)
958 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
959 (match_operand:SWI 1 "const0_operand" "")))]
960 "ix86_match_ccmode (insn, CCNOmode)"
962 test{<imodesuffix>}\t%0, %0
963 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
964 [(set_attr "type" "test,icmp")
965 (set_attr "length_immediate" "0,1")
966 (set_attr "mode" "<MODE>")])
968 (define_insn "*cmp<mode>_1"
969 [(set (reg FLAGS_REG)
970 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
971 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
972 "ix86_match_ccmode (insn, CCmode)"
973 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
974 [(set_attr "type" "icmp")
975 (set_attr "mode" "<MODE>")])
977 (define_insn "*cmp<mode>_minus_1"
978 [(set (reg FLAGS_REG)
980 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
981 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
983 "ix86_match_ccmode (insn, CCGOCmode)"
984 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
985 [(set_attr "type" "icmp")
986 (set_attr "mode" "<MODE>")])
988 (define_insn "*cmpqi_ext_1"
989 [(set (reg FLAGS_REG)
991 (match_operand:QI 0 "general_operand" "Qm")
994 (match_operand 1 "ext_register_operand" "Q")
997 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
998 "cmp{b}\t{%h1, %0|%0, %h1}"
999 [(set_attr "type" "icmp")
1000 (set_attr "mode" "QI")])
1002 (define_insn "*cmpqi_ext_1_rex64"
1003 [(set (reg FLAGS_REG)
1005 (match_operand:QI 0 "register_operand" "Q")
1008 (match_operand 1 "ext_register_operand" "Q")
1010 (const_int 8)) 0)))]
1011 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1012 "cmp{b}\t{%h1, %0|%0, %h1}"
1013 [(set_attr "type" "icmp")
1014 (set_attr "mode" "QI")])
1016 (define_insn "*cmpqi_ext_2"
1017 [(set (reg FLAGS_REG)
1021 (match_operand 0 "ext_register_operand" "Q")
1024 (match_operand:QI 1 "const0_operand" "")))]
1025 "ix86_match_ccmode (insn, CCNOmode)"
1027 [(set_attr "type" "test")
1028 (set_attr "length_immediate" "0")
1029 (set_attr "mode" "QI")])
1031 (define_expand "cmpqi_ext_3"
1032 [(set (reg:CC FLAGS_REG)
1036 (match_operand 0 "ext_register_operand" "")
1039 (match_operand:QI 1 "immediate_operand" "")))]
1043 (define_insn "*cmpqi_ext_3_insn"
1044 [(set (reg FLAGS_REG)
1048 (match_operand 0 "ext_register_operand" "Q")
1051 (match_operand:QI 1 "general_operand" "Qmn")))]
1052 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1053 "cmp{b}\t{%1, %h0|%h0, %1}"
1054 [(set_attr "type" "icmp")
1055 (set_attr "modrm" "1")
1056 (set_attr "mode" "QI")])
1058 (define_insn "*cmpqi_ext_3_insn_rex64"
1059 [(set (reg FLAGS_REG)
1063 (match_operand 0 "ext_register_operand" "Q")
1066 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1067 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1068 "cmp{b}\t{%1, %h0|%h0, %1}"
1069 [(set_attr "type" "icmp")
1070 (set_attr "modrm" "1")
1071 (set_attr "mode" "QI")])
1073 (define_insn "*cmpqi_ext_4"
1074 [(set (reg FLAGS_REG)
1078 (match_operand 0 "ext_register_operand" "Q")
1083 (match_operand 1 "ext_register_operand" "Q")
1085 (const_int 8)) 0)))]
1086 "ix86_match_ccmode (insn, CCmode)"
1087 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1088 [(set_attr "type" "icmp")
1089 (set_attr "mode" "QI")])
1091 ;; These implement float point compares.
1092 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1093 ;; which would allow mix and match FP modes on the compares. Which is what
1094 ;; the old patterns did, but with many more of them.
1096 (define_expand "cbranchxf4"
1097 [(set (reg:CC FLAGS_REG)
1098 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1099 (match_operand:XF 2 "nonmemory_operand" "")))
1100 (set (pc) (if_then_else
1101 (match_operator 0 "ix86_fp_comparison_operator"
1104 (label_ref (match_operand 3 "" ""))
1108 ix86_compare_op0 = operands[1];
1109 ix86_compare_op1 = operands[2];
1110 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1114 (define_expand "cstorexf4"
1115 [(set (reg:CC FLAGS_REG)
1116 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1117 (match_operand:XF 3 "nonmemory_operand" "")))
1118 (set (match_operand:QI 0 "register_operand" "")
1119 (match_operator 1 "ix86_fp_comparison_operator"
1124 ix86_compare_op0 = operands[2];
1125 ix86_compare_op1 = operands[3];
1126 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1130 (define_expand "cbranch<mode>4"
1131 [(set (reg:CC FLAGS_REG)
1132 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1133 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1134 (set (pc) (if_then_else
1135 (match_operator 0 "ix86_fp_comparison_operator"
1138 (label_ref (match_operand 3 "" ""))
1140 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1142 ix86_compare_op0 = operands[1];
1143 ix86_compare_op1 = operands[2];
1144 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1148 (define_expand "cstore<mode>4"
1149 [(set (reg:CC FLAGS_REG)
1150 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1151 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1152 (set (match_operand:QI 0 "register_operand" "")
1153 (match_operator 1 "ix86_fp_comparison_operator"
1156 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1158 ix86_compare_op0 = operands[2];
1159 ix86_compare_op1 = operands[3];
1160 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1164 (define_expand "cbranchcc4"
1165 [(set (pc) (if_then_else
1166 (match_operator 0 "comparison_operator"
1167 [(match_operand 1 "flags_reg_operand" "")
1168 (match_operand 2 "const0_operand" "")])
1169 (label_ref (match_operand 3 "" ""))
1173 ix86_compare_op0 = operands[1];
1174 ix86_compare_op1 = operands[2];
1175 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1179 (define_expand "cstorecc4"
1180 [(set (match_operand:QI 0 "register_operand" "")
1181 (match_operator 1 "comparison_operator"
1182 [(match_operand 2 "flags_reg_operand" "")
1183 (match_operand 3 "const0_operand" "")]))]
1186 ix86_compare_op0 = operands[2];
1187 ix86_compare_op1 = operands[3];
1188 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1193 ;; FP compares, step 1:
1194 ;; Set the FP condition codes.
1196 ;; CCFPmode compare with exceptions
1197 ;; CCFPUmode compare with no exceptions
1199 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1200 ;; used to manage the reg stack popping would not be preserved.
1202 (define_insn "*cmpfp_0"
1203 [(set (match_operand:HI 0 "register_operand" "=a")
1206 (match_operand 1 "register_operand" "f")
1207 (match_operand 2 "const0_operand" ""))]
1209 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1210 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1211 "* return output_fp_compare (insn, operands, 0, 0);"
1212 [(set_attr "type" "multi")
1213 (set_attr "unit" "i387")
1215 (cond [(match_operand:SF 1 "" "")
1217 (match_operand:DF 1 "" "")
1220 (const_string "XF")))])
1222 (define_insn_and_split "*cmpfp_0_cc"
1223 [(set (reg:CCFP FLAGS_REG)
1225 (match_operand 1 "register_operand" "f")
1226 (match_operand 2 "const0_operand" "")))
1227 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1228 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1229 && TARGET_SAHF && !TARGET_CMOVE
1230 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1232 "&& reload_completed"
1235 [(compare:CCFP (match_dup 1)(match_dup 2))]
1237 (set (reg:CC FLAGS_REG)
1238 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1240 [(set_attr "type" "multi")
1241 (set_attr "unit" "i387")
1243 (cond [(match_operand:SF 1 "" "")
1245 (match_operand:DF 1 "" "")
1248 (const_string "XF")))])
1250 (define_insn "*cmpfp_xf"
1251 [(set (match_operand:HI 0 "register_operand" "=a")
1254 (match_operand:XF 1 "register_operand" "f")
1255 (match_operand:XF 2 "register_operand" "f"))]
1258 "* return output_fp_compare (insn, operands, 0, 0);"
1259 [(set_attr "type" "multi")
1260 (set_attr "unit" "i387")
1261 (set_attr "mode" "XF")])
1263 (define_insn_and_split "*cmpfp_xf_cc"
1264 [(set (reg:CCFP FLAGS_REG)
1266 (match_operand:XF 1 "register_operand" "f")
1267 (match_operand:XF 2 "register_operand" "f")))
1268 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1270 && TARGET_SAHF && !TARGET_CMOVE"
1272 "&& reload_completed"
1275 [(compare:CCFP (match_dup 1)(match_dup 2))]
1277 (set (reg:CC FLAGS_REG)
1278 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1280 [(set_attr "type" "multi")
1281 (set_attr "unit" "i387")
1282 (set_attr "mode" "XF")])
1284 (define_insn "*cmpfp_<mode>"
1285 [(set (match_operand:HI 0 "register_operand" "=a")
1288 (match_operand:MODEF 1 "register_operand" "f")
1289 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1292 "* return output_fp_compare (insn, operands, 0, 0);"
1293 [(set_attr "type" "multi")
1294 (set_attr "unit" "i387")
1295 (set_attr "mode" "<MODE>")])
1297 (define_insn_and_split "*cmpfp_<mode>_cc"
1298 [(set (reg:CCFP FLAGS_REG)
1300 (match_operand:MODEF 1 "register_operand" "f")
1301 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1302 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1304 && TARGET_SAHF && !TARGET_CMOVE"
1306 "&& reload_completed"
1309 [(compare:CCFP (match_dup 1)(match_dup 2))]
1311 (set (reg:CC FLAGS_REG)
1312 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1314 [(set_attr "type" "multi")
1315 (set_attr "unit" "i387")
1316 (set_attr "mode" "<MODE>")])
1318 (define_insn "*cmpfp_u"
1319 [(set (match_operand:HI 0 "register_operand" "=a")
1322 (match_operand 1 "register_operand" "f")
1323 (match_operand 2 "register_operand" "f"))]
1325 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1326 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1327 "* return output_fp_compare (insn, operands, 0, 1);"
1328 [(set_attr "type" "multi")
1329 (set_attr "unit" "i387")
1331 (cond [(match_operand:SF 1 "" "")
1333 (match_operand:DF 1 "" "")
1336 (const_string "XF")))])
1338 (define_insn_and_split "*cmpfp_u_cc"
1339 [(set (reg:CCFPU FLAGS_REG)
1341 (match_operand 1 "register_operand" "f")
1342 (match_operand 2 "register_operand" "f")))
1343 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1344 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1345 && TARGET_SAHF && !TARGET_CMOVE
1346 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1348 "&& reload_completed"
1351 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1353 (set (reg:CC FLAGS_REG)
1354 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1356 [(set_attr "type" "multi")
1357 (set_attr "unit" "i387")
1359 (cond [(match_operand:SF 1 "" "")
1361 (match_operand:DF 1 "" "")
1364 (const_string "XF")))])
1366 (define_insn "*cmpfp_<mode>"
1367 [(set (match_operand:HI 0 "register_operand" "=a")
1370 (match_operand 1 "register_operand" "f")
1371 (match_operator 3 "float_operator"
1372 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1374 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1375 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1376 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1377 "* return output_fp_compare (insn, operands, 0, 0);"
1378 [(set_attr "type" "multi")
1379 (set_attr "unit" "i387")
1380 (set_attr "fp_int_src" "true")
1381 (set_attr "mode" "<MODE>")])
1383 (define_insn_and_split "*cmpfp_<mode>_cc"
1384 [(set (reg:CCFP FLAGS_REG)
1386 (match_operand 1 "register_operand" "f")
1387 (match_operator 3 "float_operator"
1388 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1389 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1390 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1391 && TARGET_SAHF && !TARGET_CMOVE
1392 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1393 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1395 "&& reload_completed"
1400 (match_op_dup 3 [(match_dup 2)]))]
1402 (set (reg:CC FLAGS_REG)
1403 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1405 [(set_attr "type" "multi")
1406 (set_attr "unit" "i387")
1407 (set_attr "fp_int_src" "true")
1408 (set_attr "mode" "<MODE>")])
1410 ;; FP compares, step 2
1411 ;; Move the fpsw to ax.
1413 (define_insn "x86_fnstsw_1"
1414 [(set (match_operand:HI 0 "register_operand" "=a")
1415 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1418 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1419 (set_attr "mode" "SI")
1420 (set_attr "unit" "i387")])
1422 ;; FP compares, step 3
1423 ;; Get ax into flags, general case.
1425 (define_insn "x86_sahf_1"
1426 [(set (reg:CC FLAGS_REG)
1427 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1431 #ifdef HAVE_AS_IX86_SAHF
1434 return ASM_BYTE "0x9e";
1437 [(set_attr "length" "1")
1438 (set_attr "athlon_decode" "vector")
1439 (set_attr "amdfam10_decode" "direct")
1440 (set_attr "mode" "SI")])
1442 ;; Pentium Pro can do steps 1 through 3 in one go.
1443 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1444 (define_insn "*cmpfp_i_mixed"
1445 [(set (reg:CCFP FLAGS_REG)
1446 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1447 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1448 "TARGET_MIX_SSE_I387
1449 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1450 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1451 "* return output_fp_compare (insn, operands, 1, 0);"
1452 [(set_attr "type" "fcmp,ssecomi")
1453 (set_attr "prefix" "orig,maybe_vex")
1455 (if_then_else (match_operand:SF 1 "" "")
1457 (const_string "DF")))
1458 (set (attr "prefix_rep")
1459 (if_then_else (eq_attr "type" "ssecomi")
1461 (const_string "*")))
1462 (set (attr "prefix_data16")
1463 (cond [(eq_attr "type" "fcmp")
1465 (eq_attr "mode" "DF")
1468 (const_string "0")))
1469 (set_attr "athlon_decode" "vector")
1470 (set_attr "amdfam10_decode" "direct")])
1472 (define_insn "*cmpfp_i_sse"
1473 [(set (reg:CCFP FLAGS_REG)
1474 (compare:CCFP (match_operand 0 "register_operand" "x")
1475 (match_operand 1 "nonimmediate_operand" "xm")))]
1477 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1478 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1479 "* return output_fp_compare (insn, operands, 1, 0);"
1480 [(set_attr "type" "ssecomi")
1481 (set_attr "prefix" "maybe_vex")
1483 (if_then_else (match_operand:SF 1 "" "")
1485 (const_string "DF")))
1486 (set_attr "prefix_rep" "0")
1487 (set (attr "prefix_data16")
1488 (if_then_else (eq_attr "mode" "DF")
1490 (const_string "0")))
1491 (set_attr "athlon_decode" "vector")
1492 (set_attr "amdfam10_decode" "direct")])
1494 (define_insn "*cmpfp_i_i387"
1495 [(set (reg:CCFP FLAGS_REG)
1496 (compare:CCFP (match_operand 0 "register_operand" "f")
1497 (match_operand 1 "register_operand" "f")))]
1498 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1500 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1501 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1502 "* return output_fp_compare (insn, operands, 1, 0);"
1503 [(set_attr "type" "fcmp")
1505 (cond [(match_operand:SF 1 "" "")
1507 (match_operand:DF 1 "" "")
1510 (const_string "XF")))
1511 (set_attr "athlon_decode" "vector")
1512 (set_attr "amdfam10_decode" "direct")])
1514 (define_insn "*cmpfp_iu_mixed"
1515 [(set (reg:CCFPU FLAGS_REG)
1516 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1517 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1518 "TARGET_MIX_SSE_I387
1519 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1520 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1521 "* return output_fp_compare (insn, operands, 1, 1);"
1522 [(set_attr "type" "fcmp,ssecomi")
1523 (set_attr "prefix" "orig,maybe_vex")
1525 (if_then_else (match_operand:SF 1 "" "")
1527 (const_string "DF")))
1528 (set (attr "prefix_rep")
1529 (if_then_else (eq_attr "type" "ssecomi")
1531 (const_string "*")))
1532 (set (attr "prefix_data16")
1533 (cond [(eq_attr "type" "fcmp")
1535 (eq_attr "mode" "DF")
1538 (const_string "0")))
1539 (set_attr "athlon_decode" "vector")
1540 (set_attr "amdfam10_decode" "direct")])
1542 (define_insn "*cmpfp_iu_sse"
1543 [(set (reg:CCFPU FLAGS_REG)
1544 (compare:CCFPU (match_operand 0 "register_operand" "x")
1545 (match_operand 1 "nonimmediate_operand" "xm")))]
1547 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1548 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1549 "* return output_fp_compare (insn, operands, 1, 1);"
1550 [(set_attr "type" "ssecomi")
1551 (set_attr "prefix" "maybe_vex")
1553 (if_then_else (match_operand:SF 1 "" "")
1555 (const_string "DF")))
1556 (set_attr "prefix_rep" "0")
1557 (set (attr "prefix_data16")
1558 (if_then_else (eq_attr "mode" "DF")
1560 (const_string "0")))
1561 (set_attr "athlon_decode" "vector")
1562 (set_attr "amdfam10_decode" "direct")])
1564 (define_insn "*cmpfp_iu_387"
1565 [(set (reg:CCFPU FLAGS_REG)
1566 (compare:CCFPU (match_operand 0 "register_operand" "f")
1567 (match_operand 1 "register_operand" "f")))]
1568 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1570 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1571 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1572 "* return output_fp_compare (insn, operands, 1, 1);"
1573 [(set_attr "type" "fcmp")
1575 (cond [(match_operand:SF 1 "" "")
1577 (match_operand:DF 1 "" "")
1580 (const_string "XF")))
1581 (set_attr "athlon_decode" "vector")
1582 (set_attr "amdfam10_decode" "direct")])
1584 ;; Move instructions.
1586 ;; General case of fullword move.
1588 (define_expand "movsi"
1589 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1590 (match_operand:SI 1 "general_operand" ""))]
1592 "ix86_expand_move (SImode, operands); DONE;")
1594 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1597 ;; %%% We don't use a post-inc memory reference because x86 is not a
1598 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1599 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1600 ;; targets without our curiosities, and it is just as easy to represent
1601 ;; this differently.
1603 (define_insn "*pushsi2"
1604 [(set (match_operand:SI 0 "push_operand" "=<")
1605 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1608 [(set_attr "type" "push")
1609 (set_attr "mode" "SI")])
1611 ;; For 64BIT abi we always round up to 8 bytes.
1612 (define_insn "*pushsi2_rex64"
1613 [(set (match_operand:SI 0 "push_operand" "=X")
1614 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1617 [(set_attr "type" "push")
1618 (set_attr "mode" "SI")])
1620 (define_insn "*pushsi2_prologue"
1621 [(set (match_operand:SI 0 "push_operand" "=<")
1622 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1623 (clobber (mem:BLK (scratch)))]
1626 [(set_attr "type" "push")
1627 (set_attr "mode" "SI")])
1629 (define_insn "*popsi1_epilogue"
1630 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1631 (mem:SI (reg:SI SP_REG)))
1632 (set (reg:SI SP_REG)
1633 (plus:SI (reg:SI SP_REG) (const_int 4)))
1634 (clobber (mem:BLK (scratch)))]
1637 [(set_attr "type" "pop")
1638 (set_attr "mode" "SI")])
1640 (define_insn "popsi1"
1641 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1642 (mem:SI (reg:SI SP_REG)))
1643 (set (reg:SI SP_REG)
1644 (plus:SI (reg:SI SP_REG) (const_int 4)))]
1647 [(set_attr "type" "pop")
1648 (set_attr "mode" "SI")])
1650 (define_insn "*movsi_xor"
1651 [(set (match_operand:SI 0 "register_operand" "=r")
1652 (match_operand:SI 1 "const0_operand" ""))
1653 (clobber (reg:CC FLAGS_REG))]
1656 [(set_attr "type" "alu1")
1657 (set_attr "mode" "SI")
1658 (set_attr "length_immediate" "0")])
1660 (define_insn "*movsi_or"
1661 [(set (match_operand:SI 0 "register_operand" "=r")
1662 (match_operand:SI 1 "immediate_operand" "i"))
1663 (clobber (reg:CC FLAGS_REG))]
1665 && operands[1] == constm1_rtx"
1667 operands[1] = constm1_rtx;
1668 return "or{l}\t{%1, %0|%0, %1}";
1670 [(set_attr "type" "alu1")
1671 (set_attr "mode" "SI")
1672 (set_attr "length_immediate" "1")])
1674 (define_insn "*movsi_1"
1675 [(set (match_operand:SI 0 "nonimmediate_operand"
1676 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
1677 (match_operand:SI 1 "general_operand"
1678 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
1679 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1681 switch (get_attr_type (insn))
1684 if (get_attr_mode (insn) == MODE_TI)
1685 return "%vpxor\t%0, %d0";
1686 return "%vxorps\t%0, %d0";
1689 switch (get_attr_mode (insn))
1692 return "%vmovdqa\t{%1, %0|%0, %1}";
1694 return "%vmovaps\t{%1, %0|%0, %1}";
1696 return "%vmovd\t{%1, %0|%0, %1}";
1698 return "%vmovss\t{%1, %0|%0, %1}";
1704 return "pxor\t%0, %0";
1707 if (get_attr_mode (insn) == MODE_DI)
1708 return "movq\t{%1, %0|%0, %1}";
1709 return "movd\t{%1, %0|%0, %1}";
1712 return "lea{l}\t{%1, %0|%0, %1}";
1715 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1716 return "mov{l}\t{%1, %0|%0, %1}";
1720 (cond [(eq_attr "alternative" "2")
1721 (const_string "mmx")
1722 (eq_attr "alternative" "3,4,5")
1723 (const_string "mmxmov")
1724 (eq_attr "alternative" "6")
1725 (const_string "sselog1")
1726 (eq_attr "alternative" "7,8,9,10,11")
1727 (const_string "ssemov")
1728 (match_operand:DI 1 "pic_32bit_operand" "")
1729 (const_string "lea")
1731 (const_string "imov")))
1732 (set (attr "prefix")
1733 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
1734 (const_string "orig")
1735 (const_string "maybe_vex")))
1736 (set (attr "prefix_data16")
1737 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
1739 (const_string "*")))
1741 (cond [(eq_attr "alternative" "2,3")
1743 (eq_attr "alternative" "6,7")
1745 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1746 (const_string "V4SF")
1747 (const_string "TI"))
1748 (and (eq_attr "alternative" "8,9,10,11")
1749 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
1752 (const_string "SI")))])
1754 ;; Stores and loads of ax to arbitrary constant address.
1755 ;; We fake an second form of instruction to force reload to load address
1756 ;; into register when rax is not available
1757 (define_insn "*movabssi_1_rex64"
1758 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1759 (match_operand:SI 1 "nonmemory_operand" "a,er"))]
1760 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1762 movabs{l}\t{%1, %P0|%P0, %1}
1763 mov{l}\t{%1, %a0|%a0, %1}"
1764 [(set_attr "type" "imov")
1765 (set_attr "modrm" "0,*")
1766 (set_attr "length_address" "8,0")
1767 (set_attr "length_immediate" "0,*")
1768 (set_attr "memory" "store")
1769 (set_attr "mode" "SI")])
1771 (define_insn "*movabssi_2_rex64"
1772 [(set (match_operand:SI 0 "register_operand" "=a,r")
1773 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1774 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1776 movabs{l}\t{%P1, %0|%0, %P1}
1777 mov{l}\t{%a1, %0|%0, %a1}"
1778 [(set_attr "type" "imov")
1779 (set_attr "modrm" "0,*")
1780 (set_attr "length_address" "8,0")
1781 (set_attr "length_immediate" "0")
1782 (set_attr "memory" "load")
1783 (set_attr "mode" "SI")])
1785 (define_insn "*swapsi"
1786 [(set (match_operand:SI 0 "register_operand" "+r")
1787 (match_operand:SI 1 "register_operand" "+r"))
1792 [(set_attr "type" "imov")
1793 (set_attr "mode" "SI")
1794 (set_attr "pent_pair" "np")
1795 (set_attr "athlon_decode" "vector")
1796 (set_attr "amdfam10_decode" "double")])
1798 (define_expand "movhi"
1799 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1800 (match_operand:HI 1 "general_operand" ""))]
1802 "ix86_expand_move (HImode, operands); DONE;")
1804 (define_insn "*pushhi2"
1805 [(set (match_operand:HI 0 "push_operand" "=X")
1806 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1809 [(set_attr "type" "push")
1810 (set_attr "mode" "SI")])
1812 ;; For 64BIT abi we always round up to 8 bytes.
1813 (define_insn "*pushhi2_rex64"
1814 [(set (match_operand:HI 0 "push_operand" "=X")
1815 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1818 [(set_attr "type" "push")
1819 (set_attr "mode" "DI")])
1821 (define_insn "*movhi_1"
1822 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
1823 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
1824 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1826 switch (get_attr_type (insn))
1829 /* movzwl is faster than movw on p2 due to partial word stalls,
1830 though not as fast as an aligned movl. */
1831 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1833 if (get_attr_mode (insn) == MODE_SI)
1834 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1836 return "mov{w}\t{%1, %0|%0, %1}";
1840 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0))
1841 (const_string "imov")
1842 (and (eq_attr "alternative" "0")
1843 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1845 (eq (symbol_ref "TARGET_HIMODE_MATH")
1847 (const_string "imov")
1848 (and (eq_attr "alternative" "1,2")
1849 (match_operand:HI 1 "aligned_operand" ""))
1850 (const_string "imov")
1851 (and (ne (symbol_ref "TARGET_MOVX")
1853 (eq_attr "alternative" "0,2"))
1854 (const_string "imovx")
1856 (const_string "imov")))
1858 (cond [(eq_attr "type" "imovx")
1860 (and (eq_attr "alternative" "1,2")
1861 (match_operand:HI 1 "aligned_operand" ""))
1863 (and (eq_attr "alternative" "0")
1864 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1866 (eq (symbol_ref "TARGET_HIMODE_MATH")
1870 (const_string "HI")))])
1872 ;; Stores and loads of ax to arbitrary constant address.
1873 ;; We fake an second form of instruction to force reload to load address
1874 ;; into register when rax is not available
1875 (define_insn "*movabshi_1_rex64"
1876 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1877 (match_operand:HI 1 "nonmemory_operand" "a,er"))]
1878 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1880 movabs{w}\t{%1, %P0|%P0, %1}
1881 mov{w}\t{%1, %a0|%a0, %1}"
1882 [(set_attr "type" "imov")
1883 (set_attr "modrm" "0,*")
1884 (set_attr "length_address" "8,0")
1885 (set_attr "length_immediate" "0,*")
1886 (set_attr "memory" "store")
1887 (set_attr "mode" "HI")])
1889 (define_insn "*movabshi_2_rex64"
1890 [(set (match_operand:HI 0 "register_operand" "=a,r")
1891 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1892 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1894 movabs{w}\t{%P1, %0|%0, %P1}
1895 mov{w}\t{%a1, %0|%0, %a1}"
1896 [(set_attr "type" "imov")
1897 (set_attr "modrm" "0,*")
1898 (set_attr "length_address" "8,0")
1899 (set_attr "length_immediate" "0")
1900 (set_attr "memory" "load")
1901 (set_attr "mode" "HI")])
1903 (define_insn "*swaphi_1"
1904 [(set (match_operand:HI 0 "register_operand" "+r")
1905 (match_operand:HI 1 "register_operand" "+r"))
1908 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
1910 [(set_attr "type" "imov")
1911 (set_attr "mode" "SI")
1912 (set_attr "pent_pair" "np")
1913 (set_attr "athlon_decode" "vector")
1914 (set_attr "amdfam10_decode" "double")])
1916 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1917 (define_insn "*swaphi_2"
1918 [(set (match_operand:HI 0 "register_operand" "+r")
1919 (match_operand:HI 1 "register_operand" "+r"))
1922 "TARGET_PARTIAL_REG_STALL"
1924 [(set_attr "type" "imov")
1925 (set_attr "mode" "HI")
1926 (set_attr "pent_pair" "np")
1927 (set_attr "athlon_decode" "vector")])
1929 (define_expand "movstricthi"
1930 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1931 (match_operand:HI 1 "general_operand" ""))]
1934 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
1936 /* Don't generate memory->memory moves, go through a register */
1937 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1938 operands[1] = force_reg (HImode, operands[1]);
1941 (define_insn "*movstricthi_1"
1942 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1943 (match_operand:HI 1 "general_operand" "rn,m"))]
1944 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
1945 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1946 "mov{w}\t{%1, %0|%0, %1}"
1947 [(set_attr "type" "imov")
1948 (set_attr "mode" "HI")])
1950 (define_insn "*movstricthi_xor"
1951 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1952 (match_operand:HI 1 "const0_operand" ""))
1953 (clobber (reg:CC FLAGS_REG))]
1956 [(set_attr "type" "alu1")
1957 (set_attr "mode" "HI")
1958 (set_attr "length_immediate" "0")])
1960 (define_expand "movqi"
1961 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1962 (match_operand:QI 1 "general_operand" ""))]
1964 "ix86_expand_move (QImode, operands); DONE;")
1966 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1967 ;; "push a byte". But actually we use pushl, which has the effect
1968 ;; of rounding the amount pushed up to a word.
1970 (define_insn "*pushqi2"
1971 [(set (match_operand:QI 0 "push_operand" "=X")
1972 (match_operand:QI 1 "nonmemory_no_elim_operand" "rn"))]
1975 [(set_attr "type" "push")
1976 (set_attr "mode" "SI")])
1978 ;; For 64BIT abi we always round up to 8 bytes.
1979 (define_insn "*pushqi2_rex64"
1980 [(set (match_operand:QI 0 "push_operand" "=X")
1981 (match_operand:QI 1 "nonmemory_no_elim_operand" "qn"))]
1984 [(set_attr "type" "push")
1985 (set_attr "mode" "DI")])
1987 ;; Situation is quite tricky about when to choose full sized (SImode) move
1988 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
1989 ;; partial register dependency machines (such as AMD Athlon), where QImode
1990 ;; moves issue extra dependency and for partial register stalls machines
1991 ;; that don't use QImode patterns (and QImode move cause stall on the next
1994 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1995 ;; register stall machines with, where we use QImode instructions, since
1996 ;; partial register stall can be caused there. Then we use movzx.
1997 (define_insn "*movqi_1"
1998 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1999 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2000 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2002 switch (get_attr_type (insn))
2005 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2006 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2008 if (get_attr_mode (insn) == MODE_SI)
2009 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2011 return "mov{b}\t{%1, %0|%0, %1}";
2015 (cond [(and (eq_attr "alternative" "5")
2016 (not (match_operand:QI 1 "aligned_operand" "")))
2017 (const_string "imovx")
2018 (ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0))
2019 (const_string "imov")
2020 (and (eq_attr "alternative" "3")
2021 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2023 (eq (symbol_ref "TARGET_QIMODE_MATH")
2025 (const_string "imov")
2026 (eq_attr "alternative" "3,5")
2027 (const_string "imovx")
2028 (and (ne (symbol_ref "TARGET_MOVX")
2030 (eq_attr "alternative" "2"))
2031 (const_string "imovx")
2033 (const_string "imov")))
2035 (cond [(eq_attr "alternative" "3,4,5")
2037 (eq_attr "alternative" "6")
2039 (eq_attr "type" "imovx")
2041 (and (eq_attr "type" "imov")
2042 (and (eq_attr "alternative" "0,1")
2043 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2045 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2047 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2050 ;; Avoid partial register stalls when not using QImode arithmetic
2051 (and (eq_attr "type" "imov")
2052 (and (eq_attr "alternative" "0,1")
2053 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2055 (eq (symbol_ref "TARGET_QIMODE_MATH")
2059 (const_string "QI")))])
2061 (define_insn "*swapqi_1"
2062 [(set (match_operand:QI 0 "register_operand" "+r")
2063 (match_operand:QI 1 "register_operand" "+r"))
2066 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2068 [(set_attr "type" "imov")
2069 (set_attr "mode" "SI")
2070 (set_attr "pent_pair" "np")
2071 (set_attr "athlon_decode" "vector")
2072 (set_attr "amdfam10_decode" "vector")])
2074 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
2075 (define_insn "*swapqi_2"
2076 [(set (match_operand:QI 0 "register_operand" "+q")
2077 (match_operand:QI 1 "register_operand" "+q"))
2080 "TARGET_PARTIAL_REG_STALL"
2082 [(set_attr "type" "imov")
2083 (set_attr "mode" "QI")
2084 (set_attr "pent_pair" "np")
2085 (set_attr "athlon_decode" "vector")])
2087 (define_expand "movstrictqi"
2088 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
2089 (match_operand:QI 1 "general_operand" ""))]
2092 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2094 /* Don't generate memory->memory moves, go through a register. */
2095 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2096 operands[1] = force_reg (QImode, operands[1]);
2099 (define_insn "*movstrictqi_1"
2100 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
2101 (match_operand:QI 1 "general_operand" "*qn,m"))]
2102 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2103 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2104 "mov{b}\t{%1, %0|%0, %1}"
2105 [(set_attr "type" "imov")
2106 (set_attr "mode" "QI")])
2108 (define_insn "*movstrictqi_xor"
2109 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
2110 (match_operand:QI 1 "const0_operand" ""))
2111 (clobber (reg:CC FLAGS_REG))]
2114 [(set_attr "type" "alu1")
2115 (set_attr "mode" "QI")
2116 (set_attr "length_immediate" "0")])
2118 (define_insn "*movsi_extv_1"
2119 [(set (match_operand:SI 0 "register_operand" "=R")
2120 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
2124 "movs{bl|x}\t{%h1, %0|%0, %h1}"
2125 [(set_attr "type" "imovx")
2126 (set_attr "mode" "SI")])
2128 (define_insn "*movhi_extv_1"
2129 [(set (match_operand:HI 0 "register_operand" "=R")
2130 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
2134 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2135 [(set_attr "type" "imovx")
2136 (set_attr "mode" "SI")])
2138 (define_insn "*movqi_extv_1"
2139 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2140 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2145 switch (get_attr_type (insn))
2148 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2150 return "mov{b}\t{%h1, %0|%0, %h1}";
2154 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2155 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2156 (ne (symbol_ref "TARGET_MOVX")
2158 (const_string "imovx")
2159 (const_string "imov")))
2161 (if_then_else (eq_attr "type" "imovx")
2163 (const_string "QI")))])
2165 (define_insn "*movqi_extv_1_rex64"
2166 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2167 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2172 switch (get_attr_type (insn))
2175 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2177 return "mov{b}\t{%h1, %0|%0, %h1}";
2181 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2182 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2183 (ne (symbol_ref "TARGET_MOVX")
2185 (const_string "imovx")
2186 (const_string "imov")))
2188 (if_then_else (eq_attr "type" "imovx")
2190 (const_string "QI")))])
2192 ;; Stores and loads of ax to arbitrary constant address.
2193 ;; We fake an second form of instruction to force reload to load address
2194 ;; into register when rax is not available
2195 (define_insn "*movabsqi_1_rex64"
2196 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2197 (match_operand:QI 1 "nonmemory_operand" "a,er"))]
2198 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2200 movabs{b}\t{%1, %P0|%P0, %1}
2201 mov{b}\t{%1, %a0|%a0, %1}"
2202 [(set_attr "type" "imov")
2203 (set_attr "modrm" "0,*")
2204 (set_attr "length_address" "8,0")
2205 (set_attr "length_immediate" "0,*")
2206 (set_attr "memory" "store")
2207 (set_attr "mode" "QI")])
2209 (define_insn "*movabsqi_2_rex64"
2210 [(set (match_operand:QI 0 "register_operand" "=a,r")
2211 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2212 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2214 movabs{b}\t{%P1, %0|%0, %P1}
2215 mov{b}\t{%a1, %0|%0, %a1}"
2216 [(set_attr "type" "imov")
2217 (set_attr "modrm" "0,*")
2218 (set_attr "length_address" "8,0")
2219 (set_attr "length_immediate" "0")
2220 (set_attr "memory" "load")
2221 (set_attr "mode" "QI")])
2223 (define_insn "*movdi_extzv_1"
2224 [(set (match_operand:DI 0 "register_operand" "=R")
2225 (zero_extract:DI (match_operand 1 "ext_register_operand" "Q")
2229 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2230 [(set_attr "type" "imovx")
2231 (set_attr "mode" "SI")])
2233 (define_insn "*movsi_extzv_1"
2234 [(set (match_operand:SI 0 "register_operand" "=R")
2235 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
2239 "movz{bl|x}\t{%h1, %0|%0, %h1}"
2240 [(set_attr "type" "imovx")
2241 (set_attr "mode" "SI")])
2243 (define_insn "*movqi_extzv_2"
2244 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2245 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2250 switch (get_attr_type (insn))
2253 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2255 return "mov{b}\t{%h1, %0|%0, %h1}";
2259 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2260 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2261 (ne (symbol_ref "TARGET_MOVX")
2263 (const_string "imovx")
2264 (const_string "imov")))
2266 (if_then_else (eq_attr "type" "imovx")
2268 (const_string "QI")))])
2270 (define_insn "*movqi_extzv_2_rex64"
2271 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2272 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2277 switch (get_attr_type (insn))
2280 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2282 return "mov{b}\t{%h1, %0|%0, %h1}";
2286 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2287 (ne (symbol_ref "TARGET_MOVX")
2289 (const_string "imovx")
2290 (const_string "imov")))
2292 (if_then_else (eq_attr "type" "imovx")
2294 (const_string "QI")))])
2296 (define_insn "movsi_insv_1"
2297 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2300 (match_operand:SI 1 "general_operand" "Qmn"))]
2302 "mov{b}\t{%b1, %h0|%h0, %b1}"
2303 [(set_attr "type" "imov")
2304 (set_attr "mode" "QI")])
2306 (define_insn "*movsi_insv_1_rex64"
2307 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2310 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2312 "mov{b}\t{%b1, %h0|%h0, %b1}"
2313 [(set_attr "type" "imov")
2314 (set_attr "mode" "QI")])
2316 (define_insn "movdi_insv_1_rex64"
2317 [(set (zero_extract:DI (match_operand 0 "ext_register_operand" "+Q")
2320 (match_operand:DI 1 "nonmemory_operand" "Qn"))]
2322 "mov{b}\t{%b1, %h0|%h0, %b1}"
2323 [(set_attr "type" "imov")
2324 (set_attr "mode" "QI")])
2326 (define_insn "*movqi_insv_2"
2327 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2330 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2333 "mov{b}\t{%h1, %h0|%h0, %h1}"
2334 [(set_attr "type" "imov")
2335 (set_attr "mode" "QI")])
2337 (define_expand "movdi"
2338 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2339 (match_operand:DI 1 "general_operand" ""))]
2341 "ix86_expand_move (DImode, operands); DONE;")
2343 (define_insn "*pushdi"
2344 [(set (match_operand:DI 0 "push_operand" "=<")
2345 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2349 (define_insn "*pushdi2_rex64"
2350 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2351 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2356 [(set_attr "type" "push,multi")
2357 (set_attr "mode" "DI")])
2359 ;; Convert impossible pushes of immediate to existing instructions.
2360 ;; First try to get scratch register and go through it. In case this
2361 ;; fails, push sign extended lower part first and then overwrite
2362 ;; upper part by 32bit move.
2364 [(match_scratch:DI 2 "r")
2365 (set (match_operand:DI 0 "push_operand" "")
2366 (match_operand:DI 1 "immediate_operand" ""))]
2367 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2368 && !x86_64_immediate_operand (operands[1], DImode)"
2369 [(set (match_dup 2) (match_dup 1))
2370 (set (match_dup 0) (match_dup 2))]
2373 ;; We need to define this as both peepholer and splitter for case
2374 ;; peephole2 pass is not run.
2375 ;; "&& 1" is needed to keep it from matching the previous pattern.
2377 [(set (match_operand:DI 0 "push_operand" "")
2378 (match_operand:DI 1 "immediate_operand" ""))]
2379 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2380 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2381 [(set (match_dup 0) (match_dup 1))
2382 (set (match_dup 2) (match_dup 3))]
2384 split_di (&operands[1], 1, &operands[2], &operands[3]);
2386 operands[1] = gen_lowpart (DImode, operands[2]);
2387 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2392 [(set (match_operand:DI 0 "push_operand" "")
2393 (match_operand:DI 1 "immediate_operand" ""))]
2394 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2395 ? epilogue_completed : reload_completed)
2396 && !symbolic_operand (operands[1], DImode)
2397 && !x86_64_immediate_operand (operands[1], DImode)"
2398 [(set (match_dup 0) (match_dup 1))
2399 (set (match_dup 2) (match_dup 3))]
2401 split_di (&operands[1], 1, &operands[2], &operands[3]);
2403 operands[1] = gen_lowpart (DImode, operands[2]);
2404 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2408 (define_insn "*pushdi2_prologue_rex64"
2409 [(set (match_operand:DI 0 "push_operand" "=<")
2410 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2411 (clobber (mem:BLK (scratch)))]
2414 [(set_attr "type" "push")
2415 (set_attr "mode" "DI")])
2417 (define_insn "*popdi1_epilogue_rex64"
2418 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2419 (mem:DI (reg:DI SP_REG)))
2420 (set (reg:DI SP_REG)
2421 (plus:DI (reg:DI SP_REG) (const_int 8)))
2422 (clobber (mem:BLK (scratch)))]
2425 [(set_attr "type" "pop")
2426 (set_attr "mode" "DI")])
2428 (define_insn "popdi1"
2429 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2430 (mem:DI (reg:DI SP_REG)))
2431 (set (reg:DI SP_REG)
2432 (plus:DI (reg:DI SP_REG) (const_int 8)))]
2435 [(set_attr "type" "pop")
2436 (set_attr "mode" "DI")])
2438 (define_insn "*movdi_xor_rex64"
2439 [(set (match_operand:DI 0 "register_operand" "=r")
2440 (match_operand:DI 1 "const0_operand" ""))
2441 (clobber (reg:CC FLAGS_REG))]
2443 && reload_completed"
2445 [(set_attr "type" "alu1")
2446 (set_attr "mode" "SI")
2447 (set_attr "length_immediate" "0")])
2449 (define_insn "*movdi_or_rex64"
2450 [(set (match_operand:DI 0 "register_operand" "=r")
2451 (match_operand:DI 1 "const_int_operand" "i"))
2452 (clobber (reg:CC FLAGS_REG))]
2455 && operands[1] == constm1_rtx"
2457 operands[1] = constm1_rtx;
2458 return "or{q}\t{%1, %0|%0, %1}";
2460 [(set_attr "type" "alu1")
2461 (set_attr "mode" "DI")
2462 (set_attr "length_immediate" "1")])
2464 (define_insn "*movdi_2"
2465 [(set (match_operand:DI 0 "nonimmediate_operand"
2466 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2467 (match_operand:DI 1 "general_operand"
2468 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2469 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2474 movq\t{%1, %0|%0, %1}
2475 movq\t{%1, %0|%0, %1}
2477 %vmovq\t{%1, %0|%0, %1}
2478 %vmovdqa\t{%1, %0|%0, %1}
2479 %vmovq\t{%1, %0|%0, %1}
2481 movlps\t{%1, %0|%0, %1}
2482 movaps\t{%1, %0|%0, %1}
2483 movlps\t{%1, %0|%0, %1}"
2484 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2485 (set (attr "prefix")
2486 (if_then_else (eq_attr "alternative" "5,6,7,8")
2487 (const_string "vex")
2488 (const_string "orig")))
2489 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2492 [(set (match_operand:DI 0 "push_operand" "")
2493 (match_operand:DI 1 "general_operand" ""))]
2494 "!TARGET_64BIT && reload_completed
2495 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2497 "ix86_split_long_move (operands); DONE;")
2499 ;; %%% This multiword shite has got to go.
2501 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2502 (match_operand:DI 1 "general_operand" ""))]
2503 "!TARGET_64BIT && reload_completed
2504 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2505 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2507 "ix86_split_long_move (operands); DONE;")
2509 (define_insn "*movdi_1_rex64"
2510 [(set (match_operand:DI 0 "nonimmediate_operand"
2511 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
2512 (match_operand:DI 1 "general_operand"
2513 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
2514 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2516 switch (get_attr_type (insn))
2519 if (SSE_REG_P (operands[0]))
2520 return "movq2dq\t{%1, %0|%0, %1}";
2522 return "movdq2q\t{%1, %0|%0, %1}";
2527 if (get_attr_mode (insn) == MODE_TI)
2528 return "vmovdqa\t{%1, %0|%0, %1}";
2530 return "vmovq\t{%1, %0|%0, %1}";
2533 if (get_attr_mode (insn) == MODE_TI)
2534 return "movdqa\t{%1, %0|%0, %1}";
2538 /* Moves from and into integer register is done using movd
2539 opcode with REX prefix. */
2540 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2541 return "movd\t{%1, %0|%0, %1}";
2542 return "movq\t{%1, %0|%0, %1}";
2545 return "%vpxor\t%0, %d0";
2548 return "pxor\t%0, %0";
2554 return "lea{q}\t{%a1, %0|%0, %a1}";
2557 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2558 if (get_attr_mode (insn) == MODE_SI)
2559 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2560 else if (which_alternative == 2)
2561 return "movabs{q}\t{%1, %0|%0, %1}";
2563 return "mov{q}\t{%1, %0|%0, %1}";
2567 (cond [(eq_attr "alternative" "5")
2568 (const_string "mmx")
2569 (eq_attr "alternative" "6,7,8,9,10")
2570 (const_string "mmxmov")
2571 (eq_attr "alternative" "11")
2572 (const_string "sselog1")
2573 (eq_attr "alternative" "12,13,14,15,16")
2574 (const_string "ssemov")
2575 (eq_attr "alternative" "17,18")
2576 (const_string "ssecvt")
2577 (eq_attr "alternative" "4")
2578 (const_string "multi")
2579 (match_operand:DI 1 "pic_32bit_operand" "")
2580 (const_string "lea")
2582 (const_string "imov")))
2585 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2587 (const_string "*")))
2588 (set (attr "length_immediate")
2590 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2592 (const_string "*")))
2593 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2594 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2595 (set (attr "prefix")
2596 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2597 (const_string "maybe_vex")
2598 (const_string "orig")))
2599 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2601 ;; Stores and loads of ax to arbitrary constant address.
2602 ;; We fake an second form of instruction to force reload to load address
2603 ;; into register when rax is not available
2604 (define_insn "*movabsdi_1_rex64"
2605 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2606 (match_operand:DI 1 "nonmemory_operand" "a,er"))]
2607 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2609 movabs{q}\t{%1, %P0|%P0, %1}
2610 mov{q}\t{%1, %a0|%a0, %1}"
2611 [(set_attr "type" "imov")
2612 (set_attr "modrm" "0,*")
2613 (set_attr "length_address" "8,0")
2614 (set_attr "length_immediate" "0,*")
2615 (set_attr "memory" "store")
2616 (set_attr "mode" "DI")])
2618 (define_insn "*movabsdi_2_rex64"
2619 [(set (match_operand:DI 0 "register_operand" "=a,r")
2620 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2621 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2623 movabs{q}\t{%P1, %0|%0, %P1}
2624 mov{q}\t{%a1, %0|%0, %a1}"
2625 [(set_attr "type" "imov")
2626 (set_attr "modrm" "0,*")
2627 (set_attr "length_address" "8,0")
2628 (set_attr "length_immediate" "0")
2629 (set_attr "memory" "load")
2630 (set_attr "mode" "DI")])
2632 ;; Convert impossible stores of immediate to existing instructions.
2633 ;; First try to get scratch register and go through it. In case this
2634 ;; fails, move by 32bit parts.
2636 [(match_scratch:DI 2 "r")
2637 (set (match_operand:DI 0 "memory_operand" "")
2638 (match_operand:DI 1 "immediate_operand" ""))]
2639 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2640 && !x86_64_immediate_operand (operands[1], DImode)"
2641 [(set (match_dup 2) (match_dup 1))
2642 (set (match_dup 0) (match_dup 2))]
2645 ;; We need to define this as both peepholer and splitter for case
2646 ;; peephole2 pass is not run.
2647 ;; "&& 1" is needed to keep it from matching the previous pattern.
2649 [(set (match_operand:DI 0 "memory_operand" "")
2650 (match_operand:DI 1 "immediate_operand" ""))]
2651 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2652 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2653 [(set (match_dup 2) (match_dup 3))
2654 (set (match_dup 4) (match_dup 5))]
2655 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2658 [(set (match_operand:DI 0 "memory_operand" "")
2659 (match_operand:DI 1 "immediate_operand" ""))]
2660 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2661 ? epilogue_completed : reload_completed)
2662 && !symbolic_operand (operands[1], DImode)
2663 && !x86_64_immediate_operand (operands[1], DImode)"
2664 [(set (match_dup 2) (match_dup 3))
2665 (set (match_dup 4) (match_dup 5))]
2666 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2668 (define_insn "*swapdi_rex64"
2669 [(set (match_operand:DI 0 "register_operand" "+r")
2670 (match_operand:DI 1 "register_operand" "+r"))
2675 [(set_attr "type" "imov")
2676 (set_attr "mode" "DI")
2677 (set_attr "pent_pair" "np")
2678 (set_attr "athlon_decode" "vector")
2679 (set_attr "amdfam10_decode" "double")])
2681 (define_expand "movoi"
2682 [(set (match_operand:OI 0 "nonimmediate_operand" "")
2683 (match_operand:OI 1 "general_operand" ""))]
2685 "ix86_expand_move (OImode, operands); DONE;")
2687 (define_insn "*movoi_internal"
2688 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
2689 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
2691 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2693 switch (which_alternative)
2696 return "vxorps\t%0, %0, %0";
2699 if (misaligned_operand (operands[0], OImode)
2700 || misaligned_operand (operands[1], OImode))
2701 return "vmovdqu\t{%1, %0|%0, %1}";
2703 return "vmovdqa\t{%1, %0|%0, %1}";
2708 [(set_attr "type" "sselog1,ssemov,ssemov")
2709 (set_attr "prefix" "vex")
2710 (set_attr "mode" "OI")])
2712 (define_expand "movti"
2713 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2714 (match_operand:TI 1 "nonimmediate_operand" ""))]
2715 "TARGET_SSE || TARGET_64BIT"
2718 ix86_expand_move (TImode, operands);
2719 else if (push_operand (operands[0], TImode))
2720 ix86_expand_push (TImode, operands[1]);
2722 ix86_expand_vector_move (TImode, operands);
2726 (define_insn "*movti_internal"
2727 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
2728 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
2729 "TARGET_SSE && !TARGET_64BIT
2730 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2732 switch (which_alternative)
2735 if (get_attr_mode (insn) == MODE_V4SF)
2736 return "%vxorps\t%0, %d0";
2738 return "%vpxor\t%0, %d0";
2741 /* TDmode values are passed as TImode on the stack. Moving them
2742 to stack may result in unaligned memory access. */
2743 if (misaligned_operand (operands[0], TImode)
2744 || misaligned_operand (operands[1], TImode))
2746 if (get_attr_mode (insn) == MODE_V4SF)
2747 return "%vmovups\t{%1, %0|%0, %1}";
2749 return "%vmovdqu\t{%1, %0|%0, %1}";
2753 if (get_attr_mode (insn) == MODE_V4SF)
2754 return "%vmovaps\t{%1, %0|%0, %1}";
2756 return "%vmovdqa\t{%1, %0|%0, %1}";
2762 [(set_attr "type" "sselog1,ssemov,ssemov")
2763 (set_attr "prefix" "maybe_vex")
2765 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2766 (ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0)))
2767 (const_string "V4SF")
2768 (and (eq_attr "alternative" "2")
2769 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2771 (const_string "V4SF")]
2772 (const_string "TI")))])
2774 (define_insn "*movti_rex64"
2775 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
2776 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
2778 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2780 switch (which_alternative)
2786 if (get_attr_mode (insn) == MODE_V4SF)
2787 return "%vxorps\t%0, %d0";
2789 return "%vpxor\t%0, %d0";
2792 /* TDmode values are passed as TImode on the stack. Moving them
2793 to stack may result in unaligned memory access. */
2794 if (misaligned_operand (operands[0], TImode)
2795 || misaligned_operand (operands[1], TImode))
2797 if (get_attr_mode (insn) == MODE_V4SF)
2798 return "%vmovups\t{%1, %0|%0, %1}";
2800 return "%vmovdqu\t{%1, %0|%0, %1}";
2804 if (get_attr_mode (insn) == MODE_V4SF)
2805 return "%vmovaps\t{%1, %0|%0, %1}";
2807 return "%vmovdqa\t{%1, %0|%0, %1}";
2813 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
2814 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
2816 (cond [(eq_attr "alternative" "2,3")
2818 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2820 (const_string "V4SF")
2821 (const_string "TI"))
2822 (eq_attr "alternative" "4")
2824 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2826 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2828 (const_string "V4SF")
2829 (const_string "TI"))]
2830 (const_string "DI")))])
2833 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2834 (match_operand:TI 1 "general_operand" ""))]
2835 "reload_completed && !SSE_REG_P (operands[0])
2836 && !SSE_REG_P (operands[1])"
2838 "ix86_split_long_move (operands); DONE;")
2840 ;; This expands to what emit_move_complex would generate if we didn't
2841 ;; have a movti pattern. Having this avoids problems with reload on
2842 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
2843 ;; to have around all the time.
2844 (define_expand "movcdi"
2845 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
2846 (match_operand:CDI 1 "general_operand" ""))]
2849 if (push_operand (operands[0], CDImode))
2850 emit_move_complex_push (CDImode, operands[0], operands[1]);
2852 emit_move_complex_parts (operands[0], operands[1]);
2856 (define_expand "movsf"
2857 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2858 (match_operand:SF 1 "general_operand" ""))]
2860 "ix86_expand_move (SFmode, operands); DONE;")
2862 (define_insn "*pushsf"
2863 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2864 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2867 /* Anything else should be already split before reg-stack. */
2868 gcc_assert (which_alternative == 1);
2869 return "push{l}\t%1";
2871 [(set_attr "type" "multi,push,multi")
2872 (set_attr "unit" "i387,*,*")
2873 (set_attr "mode" "SF,SI,SF")])
2875 (define_insn "*pushsf_rex64"
2876 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2877 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2880 /* Anything else should be already split before reg-stack. */
2881 gcc_assert (which_alternative == 1);
2882 return "push{q}\t%q1";
2884 [(set_attr "type" "multi,push,multi")
2885 (set_attr "unit" "i387,*,*")
2886 (set_attr "mode" "SF,DI,SF")])
2889 [(set (match_operand:SF 0 "push_operand" "")
2890 (match_operand:SF 1 "memory_operand" ""))]
2892 && MEM_P (operands[1])
2893 && (operands[2] = find_constant_src (insn))"
2897 ;; %%% Kill this when call knows how to work this out.
2899 [(set (match_operand:SF 0 "push_operand" "")
2900 (match_operand:SF 1 "any_fp_register_operand" ""))]
2902 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
2903 (set (mem:SF (reg:SI SP_REG)) (match_dup 1))])
2906 [(set (match_operand:SF 0 "push_operand" "")
2907 (match_operand:SF 1 "any_fp_register_operand" ""))]
2909 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2910 (set (mem:SF (reg:DI SP_REG)) (match_dup 1))])
2912 (define_insn "*movsf_1"
2913 [(set (match_operand:SF 0 "nonimmediate_operand"
2914 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
2915 (match_operand:SF 1 "general_operand"
2916 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
2917 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2918 && (reload_in_progress || reload_completed
2919 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2920 || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
2921 && standard_80387_constant_p (operands[1]))
2922 || GET_CODE (operands[1]) != CONST_DOUBLE
2923 || memory_operand (operands[0], SFmode))"
2925 switch (which_alternative)
2929 return output_387_reg_move (insn, operands);
2932 return standard_80387_constant_opcode (operands[1]);
2936 return "mov{l}\t{%1, %0|%0, %1}";
2938 if (get_attr_mode (insn) == MODE_TI)
2939 return "%vpxor\t%0, %d0";
2941 return "%vxorps\t%0, %d0";
2943 if (get_attr_mode (insn) == MODE_V4SF)
2944 return "%vmovaps\t{%1, %0|%0, %1}";
2946 return "%vmovss\t{%1, %d0|%d0, %1}";
2949 return REG_P (operands[1]) ? "vmovss\t{%1, %0, %0|%0, %0, %1}"
2950 : "vmovss\t{%1, %0|%0, %1}";
2952 return "movss\t{%1, %0|%0, %1}";
2954 return "%vmovss\t{%1, %0|%0, %1}";
2956 case 9: case 10: case 14: case 15:
2957 return "movd\t{%1, %0|%0, %1}";
2959 return "%vmovd\t{%1, %0|%0, %1}";
2962 return "movq\t{%1, %0|%0, %1}";
2968 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
2969 (set (attr "prefix")
2970 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
2971 (const_string "maybe_vex")
2972 (const_string "orig")))
2974 (cond [(eq_attr "alternative" "3,4,9,10")
2976 (eq_attr "alternative" "5")
2978 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2980 (ne (symbol_ref "TARGET_SSE2")
2982 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2985 (const_string "V4SF"))
2986 /* For architectures resolving dependencies on
2987 whole SSE registers use APS move to break dependency
2988 chains, otherwise use short move to avoid extra work.
2990 Do the same for architectures resolving dependencies on
2991 the parts. While in DF mode it is better to always handle
2992 just register parts, the SF mode is different due to lack
2993 of instructions to load just part of the register. It is
2994 better to maintain the whole registers in single format
2995 to avoid problems on using packed logical operations. */
2996 (eq_attr "alternative" "6")
2998 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3000 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3002 (const_string "V4SF")
3003 (const_string "SF"))
3004 (eq_attr "alternative" "11")
3005 (const_string "DI")]
3006 (const_string "SF")))])
3008 (define_insn "*swapsf"
3009 [(set (match_operand:SF 0 "fp_register_operand" "+f")
3010 (match_operand:SF 1 "fp_register_operand" "+f"))
3013 "reload_completed || TARGET_80387"
3015 if (STACK_TOP_P (operands[0]))
3020 [(set_attr "type" "fxch")
3021 (set_attr "mode" "SF")])
3023 (define_expand "movdf"
3024 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3025 (match_operand:DF 1 "general_operand" ""))]
3027 "ix86_expand_move (DFmode, operands); DONE;")
3029 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3030 ;; Size of pushdf using integer instructions is 2+2*memory operand size
3031 ;; On the average, pushdf using integers can be still shorter. Allow this
3032 ;; pattern for optimize_size too.
3034 (define_insn "*pushdf_nointeger"
3035 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
3036 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
3037 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
3039 /* This insn should be already split before reg-stack. */
3042 [(set_attr "type" "multi")
3043 (set_attr "unit" "i387,*,*,*")
3044 (set_attr "mode" "DF,SI,SI,DF")])
3046 (define_insn "*pushdf_integer"
3047 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
3048 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
3049 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
3051 /* This insn should be already split before reg-stack. */
3054 [(set_attr "type" "multi")
3055 (set_attr "unit" "i387,*,*")
3056 (set_attr "mode" "DF,SI,DF")])
3058 ;; %%% Kill this when call knows how to work this out.
3060 [(set (match_operand:DF 0 "push_operand" "")
3061 (match_operand:DF 1 "any_fp_register_operand" ""))]
3063 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
3064 (set (mem:DF (reg:P SP_REG)) (match_dup 1))]
3068 [(set (match_operand:DF 0 "push_operand" "")
3069 (match_operand:DF 1 "general_operand" ""))]
3072 "ix86_split_long_move (operands); DONE;")
3074 ;; Moving is usually shorter when only FP registers are used. This separate
3075 ;; movdf pattern avoids the use of integer registers for FP operations
3076 ;; when optimizing for size.
3078 (define_insn "*movdf_nointeger"
3079 [(set (match_operand:DF 0 "nonimmediate_operand"
3080 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
3081 (match_operand:DF 1 "general_operand"
3082 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
3083 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3084 && ((optimize_function_for_size_p (cfun)
3085 || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
3086 && (reload_in_progress || reload_completed
3087 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3088 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3089 && optimize_function_for_size_p (cfun)
3090 && !memory_operand (operands[0], DFmode)
3091 && standard_80387_constant_p (operands[1]))
3092 || GET_CODE (operands[1]) != CONST_DOUBLE
3093 || ((optimize_function_for_size_p (cfun)
3094 || !TARGET_MEMORY_MISMATCH_STALL
3095 || reload_in_progress || reload_completed)
3096 && memory_operand (operands[0], DFmode)))"
3098 switch (which_alternative)
3102 return output_387_reg_move (insn, operands);
3105 return standard_80387_constant_opcode (operands[1]);
3111 switch (get_attr_mode (insn))
3114 return "%vxorps\t%0, %d0";
3116 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3117 return "%vxorps\t%0, %d0";
3119 return "%vxorpd\t%0, %d0";
3121 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3122 return "%vxorps\t%0, %d0";
3124 return "%vpxor\t%0, %d0";
3131 switch (get_attr_mode (insn))
3134 return "%vmovaps\t{%1, %0|%0, %1}";
3136 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3137 return "%vmovaps\t{%1, %0|%0, %1}";
3139 return "%vmovapd\t{%1, %0|%0, %1}";
3141 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3142 return "%vmovaps\t{%1, %0|%0, %1}";
3144 return "%vmovdqa\t{%1, %0|%0, %1}";
3146 return "%vmovq\t{%1, %0|%0, %1}";
3150 if (REG_P (operands[0]) && REG_P (operands[1]))
3151 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3153 return "vmovsd\t{%1, %0|%0, %1}";
3156 return "movsd\t{%1, %0|%0, %1}";
3160 if (REG_P (operands[0]))
3161 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3163 return "vmovlpd\t{%1, %0|%0, %1}";
3166 return "movlpd\t{%1, %0|%0, %1}";
3170 if (REG_P (operands[0]))
3171 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3173 return "vmovlps\t{%1, %0|%0, %1}";
3176 return "movlps\t{%1, %0|%0, %1}";
3185 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3186 (set (attr "prefix")
3187 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3188 (const_string "orig")
3189 (const_string "maybe_vex")))
3190 (set (attr "prefix_data16")
3191 (if_then_else (eq_attr "mode" "V1DF")
3193 (const_string "*")))
3195 (cond [(eq_attr "alternative" "0,1,2")
3197 (eq_attr "alternative" "3,4")
3200 /* For SSE1, we have many fewer alternatives. */
3201 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3202 (cond [(eq_attr "alternative" "5,6")
3203 (const_string "V4SF")
3205 (const_string "V2SF"))
3207 /* xorps is one byte shorter. */
3208 (eq_attr "alternative" "5")
3209 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3211 (const_string "V4SF")
3212 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3216 (const_string "V2DF"))
3218 /* For architectures resolving dependencies on
3219 whole SSE registers use APD move to break dependency
3220 chains, otherwise use short move to avoid extra work.
3222 movaps encodes one byte shorter. */
3223 (eq_attr "alternative" "6")
3225 [(ne (symbol_ref "optimize_function_for_size_p (cfun)")
3227 (const_string "V4SF")
3228 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3230 (const_string "V2DF")
3232 (const_string "DF"))
3233 /* For architectures resolving dependencies on register
3234 parts we may avoid extra work to zero out upper part
3236 (eq_attr "alternative" "7")
3238 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3240 (const_string "V1DF")
3241 (const_string "DF"))
3243 (const_string "DF")))])
3245 (define_insn "*movdf_integer_rex64"
3246 [(set (match_operand:DF 0 "nonimmediate_operand"
3247 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
3248 (match_operand:DF 1 "general_operand"
3249 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
3250 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3251 && (reload_in_progress || reload_completed
3252 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3253 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3254 && optimize_function_for_size_p (cfun)
3255 && standard_80387_constant_p (operands[1]))
3256 || GET_CODE (operands[1]) != CONST_DOUBLE
3257 || memory_operand (operands[0], DFmode))"
3259 switch (which_alternative)
3263 return output_387_reg_move (insn, operands);
3266 return standard_80387_constant_opcode (operands[1]);
3273 switch (get_attr_mode (insn))
3276 return "%vxorps\t%0, %d0";
3278 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3279 return "%vxorps\t%0, %d0";
3281 return "%vxorpd\t%0, %d0";
3283 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3284 return "%vxorps\t%0, %d0";
3286 return "%vpxor\t%0, %d0";
3293 switch (get_attr_mode (insn))
3296 return "%vmovaps\t{%1, %0|%0, %1}";
3298 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3299 return "%vmovaps\t{%1, %0|%0, %1}";
3301 return "%vmovapd\t{%1, %0|%0, %1}";
3303 if (TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3304 return "%vmovaps\t{%1, %0|%0, %1}";
3306 return "%vmovdqa\t{%1, %0|%0, %1}";
3308 return "%vmovq\t{%1, %0|%0, %1}";
3312 if (REG_P (operands[0]) && REG_P (operands[1]))
3313 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3315 return "vmovsd\t{%1, %0|%0, %1}";
3318 return "movsd\t{%1, %0|%0, %1}";
3320 return "%vmovlpd\t{%1, %d0|%d0, %1}";
3322 return "%vmovlps\t{%1, %d0|%d0, %1}";