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 ;; + -- 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)
92 (UNSPEC_TLS_LD_BASE 22)
95 ; Other random patterns
100 (UNSPEC_ADD_CARRY 34)
103 (UNSPEC_LD_MPIC 38) ; load_macho_picbase
104 (UNSPEC_TRUNC_NOOP 39)
106 ; For SSE/MMX support:
107 (UNSPEC_FIX_NOTRUNC 40)
124 (UNSPEC_MS_TO_SYSV_CALL 48)
126 ; Generic math support
128 (UNSPEC_IEEE_MIN 51) ; not commutative
129 (UNSPEC_IEEE_MAX 52) ; not commutative
144 (UNSPEC_FRNDINT_FLOOR 70)
145 (UNSPEC_FRNDINT_CEIL 71)
146 (UNSPEC_FRNDINT_TRUNC 72)
147 (UNSPEC_FRNDINT_MASK_PM 73)
148 (UNSPEC_FIST_FLOOR 74)
149 (UNSPEC_FIST_CEIL 75)
151 ; x87 Double output FP
152 (UNSPEC_SINCOS_COS 80)
153 (UNSPEC_SINCOS_SIN 81)
154 (UNSPEC_XTRACT_FRACT 84)
155 (UNSPEC_XTRACT_EXP 85)
156 (UNSPEC_FSCALE_FRACT 86)
157 (UNSPEC_FSCALE_EXP 87)
169 (UNSPEC_SP_TLS_SET 102)
170 (UNSPEC_SP_TLS_TEST 103)
180 (UNSPEC_INSERTQI 132)
185 (UNSPEC_INSERTPS 135)
187 (UNSPEC_MOVNTDQA 137)
189 (UNSPEC_PHMINPOSUW 139)
195 (UNSPEC_PCMPESTR 144)
196 (UNSPEC_PCMPISTR 145)
199 (UNSPEC_FMA4_INTRINSIC 150)
200 (UNSPEC_FMA4_FMADDSUB 151)
201 (UNSPEC_FMA4_FMSUBADD 152)
204 (UNSPEC_AESENCLAST 160)
206 (UNSPEC_AESDECLAST 162)
208 (UNSPEC_AESKEYGENASSIST 164)
216 (UNSPEC_VPERMIL2F128 168)
217 (UNSPEC_MASKLOAD 169)
218 (UNSPEC_MASKSTORE 170)
224 [(UNSPECV_BLOCKAGE 0)
225 (UNSPECV_STACK_PROBE 1)
237 (UNSPECV_PROLOGUE_USE 14)
239 (UNSPECV_VZEROALL 16)
240 (UNSPECV_VZEROUPPER 17)
244 (UNSPECV_VSWAPMOV 21)
247 ;; Constants to represent pcomtrue/pcomfalse variants
257 ;; Registers by name.
310 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
313 ;; In C guard expressions, put expressions which may be compile-time
314 ;; constants first. This allows for better optimization. For
315 ;; example, write "TARGET_64BIT && reload_completed", not
316 ;; "reload_completed && TARGET_64BIT".
320 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,atom,
322 (const (symbol_ref "ix86_schedule")))
324 ;; A basic instruction type. Refinements due to arguments to be
325 ;; provided in other attributes.
328 alu,alu1,negnot,imov,imovx,lea,
329 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
330 icmp,test,ibr,setcc,icmov,
331 push,pop,call,callv,leave,
333 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
334 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
335 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
337 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
338 (const_string "other"))
340 ;; Main data type used by the insn
342 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
343 (const_string "unknown"))
345 ;; The CPU unit operations uses.
346 (define_attr "unit" "integer,i387,sse,mmx,unknown"
347 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
348 (const_string "i387")
349 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
350 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
351 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
353 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
355 (eq_attr "type" "other")
356 (const_string "unknown")]
357 (const_string "integer")))
359 ;; The (bounding maximum) length of an instruction immediate.
360 (define_attr "length_immediate" ""
361 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
364 (eq_attr "unit" "i387,sse,mmx")
366 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
368 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
369 (eq_attr "type" "imov,test")
370 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
371 (eq_attr "type" "call")
372 (if_then_else (match_operand 0 "constant_call_address_operand" "")
375 (eq_attr "type" "callv")
376 (if_then_else (match_operand 1 "constant_call_address_operand" "")
379 ;; We don't know the size before shorten_branches. Expect
380 ;; the instruction to fit for better scheduling.
381 (eq_attr "type" "ibr")
384 (symbol_ref "/* Update immediate_length and other attributes! */
385 gcc_unreachable (),1")))
387 ;; The (bounding maximum) length of an instruction address.
388 (define_attr "length_address" ""
389 (cond [(eq_attr "type" "str,other,multi,fxch")
391 (and (eq_attr "type" "call")
392 (match_operand 0 "constant_call_address_operand" ""))
394 (and (eq_attr "type" "callv")
395 (match_operand 1 "constant_call_address_operand" ""))
398 (symbol_ref "ix86_attr_length_address_default (insn)")))
400 ;; Set when length prefix is used.
401 (define_attr "prefix_data16" ""
402 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
404 (eq_attr "mode" "HI")
406 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
411 ;; Set when string REP prefix is used.
412 (define_attr "prefix_rep" ""
413 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
415 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
420 ;; Set when 0f opcode prefix is used.
421 (define_attr "prefix_0f" ""
423 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
424 (eq_attr "unit" "sse,mmx"))
428 ;; Set when REX opcode prefix is used.
429 (define_attr "prefix_rex" ""
430 (cond [(ne (symbol_ref "!TARGET_64BIT") (const_int 0))
432 (and (eq_attr "mode" "DI")
433 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
434 (eq_attr "unit" "!mmx")))
436 (and (eq_attr "mode" "QI")
437 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
440 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
443 (and (eq_attr "type" "imovx")
444 (match_operand:QI 1 "ext_QIreg_operand" ""))
449 ;; There are also additional prefixes in 3DNOW, SSSE3.
450 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
451 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
452 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
453 (define_attr "prefix_extra" ""
454 (cond [(eq_attr "type" "ssemuladd,sse4arg")
456 (eq_attr "type" "sseiadd1,ssecvt1")
461 ;; Prefix used: original, VEX or maybe VEX.
462 (define_attr "prefix" "orig,vex,maybe_vex"
463 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
465 (const_string "orig")))
467 ;; VEX W bit is used.
468 (define_attr "prefix_vex_w" "" (const_int 0))
470 ;; The length of VEX prefix
471 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
472 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
473 ;; still prefix_0f 1, with prefix_extra 1.
474 (define_attr "length_vex" ""
475 (if_then_else (and (eq_attr "prefix_0f" "1")
476 (eq_attr "prefix_extra" "0"))
477 (if_then_else (eq_attr "prefix_vex_w" "1")
478 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 1)")
479 (symbol_ref "ix86_attr_length_vex_default (insn, 1, 0)"))
480 (if_then_else (eq_attr "prefix_vex_w" "1")
481 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 1)")
482 (symbol_ref "ix86_attr_length_vex_default (insn, 0, 0)"))))
484 ;; Set when modrm byte is used.
485 (define_attr "modrm" ""
486 (cond [(eq_attr "type" "str,leave")
488 (eq_attr "unit" "i387")
490 (and (eq_attr "type" "incdec")
491 (and (eq (symbol_ref "TARGET_64BIT") (const_int 0))
492 (ior (match_operand:SI 1 "register_operand" "")
493 (match_operand:HI 1 "register_operand" ""))))
495 (and (eq_attr "type" "push")
496 (not (match_operand 1 "memory_operand" "")))
498 (and (eq_attr "type" "pop")
499 (not (match_operand 0 "memory_operand" "")))
501 (and (eq_attr "type" "imov")
502 (and (not (eq_attr "mode" "DI"))
503 (ior (and (match_operand 0 "register_operand" "")
504 (match_operand 1 "immediate_operand" ""))
505 (ior (and (match_operand 0 "ax_reg_operand" "")
506 (match_operand 1 "memory_displacement_only_operand" ""))
507 (and (match_operand 0 "memory_displacement_only_operand" "")
508 (match_operand 1 "ax_reg_operand" ""))))))
510 (and (eq_attr "type" "call")
511 (match_operand 0 "constant_call_address_operand" ""))
513 (and (eq_attr "type" "callv")
514 (match_operand 1 "constant_call_address_operand" ""))
516 (and (eq_attr "type" "alu,alu1,icmp,test")
517 (match_operand 0 "ax_reg_operand" ""))
518 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
522 ;; The (bounding maximum) length of an instruction in bytes.
523 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
524 ;; Later we may want to split them and compute proper length as for
526 (define_attr "length" ""
527 (cond [(eq_attr "type" "other,multi,fistp,frndint")
529 (eq_attr "type" "fcmp")
531 (eq_attr "unit" "i387")
533 (plus (attr "prefix_data16")
534 (attr "length_address")))
535 (ior (eq_attr "prefix" "vex")
536 (and (eq_attr "prefix" "maybe_vex")
537 (ne (symbol_ref "TARGET_AVX") (const_int 0))))
538 (plus (attr "length_vex")
539 (plus (attr "length_immediate")
541 (attr "length_address"))))]
542 (plus (plus (attr "modrm")
543 (plus (attr "prefix_0f")
544 (plus (attr "prefix_rex")
545 (plus (attr "prefix_extra")
547 (plus (attr "prefix_rep")
548 (plus (attr "prefix_data16")
549 (plus (attr "length_immediate")
550 (attr "length_address")))))))
552 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
553 ;; `store' if there is a simple memory reference therein, or `unknown'
554 ;; if the instruction is complex.
556 (define_attr "memory" "none,load,store,both,unknown"
557 (cond [(eq_attr "type" "other,multi,str")
558 (const_string "unknown")
559 (eq_attr "type" "lea,fcmov,fpspc")
560 (const_string "none")
561 (eq_attr "type" "fistp,leave")
562 (const_string "both")
563 (eq_attr "type" "frndint")
564 (const_string "load")
565 (eq_attr "type" "push")
566 (if_then_else (match_operand 1 "memory_operand" "")
567 (const_string "both")
568 (const_string "store"))
569 (eq_attr "type" "pop")
570 (if_then_else (match_operand 0 "memory_operand" "")
571 (const_string "both")
572 (const_string "load"))
573 (eq_attr "type" "setcc")
574 (if_then_else (match_operand 0 "memory_operand" "")
575 (const_string "store")
576 (const_string "none"))
577 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
578 (if_then_else (ior (match_operand 0 "memory_operand" "")
579 (match_operand 1 "memory_operand" ""))
580 (const_string "load")
581 (const_string "none"))
582 (eq_attr "type" "ibr")
583 (if_then_else (match_operand 0 "memory_operand" "")
584 (const_string "load")
585 (const_string "none"))
586 (eq_attr "type" "call")
587 (if_then_else (match_operand 0 "constant_call_address_operand" "")
588 (const_string "none")
589 (const_string "load"))
590 (eq_attr "type" "callv")
591 (if_then_else (match_operand 1 "constant_call_address_operand" "")
592 (const_string "none")
593 (const_string "load"))
594 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
595 (match_operand 1 "memory_operand" ""))
596 (const_string "both")
597 (and (match_operand 0 "memory_operand" "")
598 (match_operand 1 "memory_operand" ""))
599 (const_string "both")
600 (match_operand 0 "memory_operand" "")
601 (const_string "store")
602 (match_operand 1 "memory_operand" "")
603 (const_string "load")
605 "!alu1,negnot,ishift1,
606 imov,imovx,icmp,test,bitmanip,
608 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
609 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
610 (match_operand 2 "memory_operand" ""))
611 (const_string "load")
612 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
613 (match_operand 3 "memory_operand" ""))
614 (const_string "load")
616 (const_string "none")))
618 ;; Indicates if an instruction has both an immediate and a displacement.
620 (define_attr "imm_disp" "false,true,unknown"
621 (cond [(eq_attr "type" "other,multi")
622 (const_string "unknown")
623 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
624 (and (match_operand 0 "memory_displacement_operand" "")
625 (match_operand 1 "immediate_operand" "")))
626 (const_string "true")
627 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
628 (and (match_operand 0 "memory_displacement_operand" "")
629 (match_operand 2 "immediate_operand" "")))
630 (const_string "true")
632 (const_string "false")))
634 ;; Indicates if an FP operation has an integer source.
636 (define_attr "fp_int_src" "false,true"
637 (const_string "false"))
639 ;; Defines rounding mode of an FP operation.
641 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
642 (const_string "any"))
644 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
645 (define_attr "use_carry" "0,1" (const_string "0"))
647 ;; Define attribute to indicate unaligned ssemov insns
648 (define_attr "movu" "0,1" (const_string "0"))
650 ;; Describe a user's asm statement.
651 (define_asm_attributes
652 [(set_attr "length" "128")
653 (set_attr "type" "multi")])
655 ;; All integer comparison codes.
656 (define_code_iterator int_cond [ne eq ge gt le lt geu gtu leu ltu ])
658 ;; All floating-point comparison codes.
659 (define_code_iterator fp_cond [unordered ordered
660 uneq unge ungt unle unlt ltgt ])
662 (define_code_iterator plusminus [plus minus])
664 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
666 ;; Base name for define_insn
667 (define_code_attr plusminus_insn
668 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
669 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
671 ;; Base name for insn mnemonic.
672 (define_code_attr plusminus_mnemonic
673 [(plus "add") (ss_plus "adds") (us_plus "addus")
674 (minus "sub") (ss_minus "subs") (us_minus "subus")])
676 ;; Mark commutative operators as such in constraints.
677 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
678 (minus "") (ss_minus "") (us_minus "")])
680 ;; Mapping of signed max and min
681 (define_code_iterator smaxmin [smax smin])
683 ;; Mapping of unsigned max and min
684 (define_code_iterator umaxmin [umax umin])
686 ;; Mapping of signed/unsigned max and min
687 (define_code_iterator maxmin [smax smin umax umin])
689 ;; Base name for integer and FP insn mnemonic
690 (define_code_attr maxminiprefix [(smax "maxs") (smin "mins")
691 (umax "maxu") (umin "minu")])
692 (define_code_attr maxminfprefix [(smax "max") (smin "min")])
694 ;; Mapping of parallel logic operators
695 (define_code_iterator plogic [and ior xor])
697 ;; Base name for insn mnemonic.
698 (define_code_attr plogicprefix [(and "and") (ior "or") (xor "xor")])
700 ;; Mapping of abs neg operators
701 (define_code_iterator absneg [abs neg])
703 ;; Base name for x87 insn mnemonic.
704 (define_code_attr absnegprefix [(abs "abs") (neg "chs")])
706 ;; Used in signed and unsigned widening multiplications.
707 (define_code_iterator any_extend [sign_extend zero_extend])
709 ;; Used in signed and unsigned divisions.
710 (define_code_iterator any_div [div udiv])
712 ;; Various insn prefixes for signed and unsigned operations.
713 (define_code_attr u [(sign_extend "") (zero_extend "u")
714 (div "") (udiv "u")])
715 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
717 ;; Instruction prefix for signed and unsigned operations.
718 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")
719 (div "i") (udiv "")])
721 ;; All single word integer modes.
722 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
724 ;; Single word integer modes without QImode.
725 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
727 ;; Single word integer modes without QImode and HImode.
728 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
730 ;; All math-dependant single and double word integer modes.
731 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
732 (HI "TARGET_HIMODE_MATH")
733 SI DI (TI "TARGET_64BIT")])
735 ;; Math-dependant single word integer modes.
736 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
737 (HI "TARGET_HIMODE_MATH")
738 SI (DI "TARGET_64BIT")])
740 ;; Math-dependant single word integer modes without QImode.
741 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
742 SI (DI "TARGET_64BIT")])
744 ;; Half mode for double word integer modes.
745 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
746 (DI "TARGET_64BIT")])
748 ;; Double word integer modes.
749 (define_mode_attr DWI [(SI "DI") (DI "TI")])
750 (define_mode_attr dwi [(SI "di") (DI "ti")])
752 ;; Instruction suffix for integer modes.
753 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
755 ;; Register class for integer modes.
756 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
758 ;; Immediate operand constraint for integer modes.
759 (define_mode_attr i [(QI "n") (HI "n") (SI "i") (DI "e")])
761 ;; General operand constraint for word modes.
762 (define_mode_attr g [(SI "g") (DI "rme")])
764 ;; Immediate operand constraint for double integer modes.
765 (define_mode_attr di [(SI "iF") (DI "e")])
767 ;; General operand predicate for integer modes.
768 (define_mode_attr general_operand
769 [(QI "general_operand")
770 (HI "general_operand")
771 (SI "general_operand")
772 (DI "x86_64_general_operand")
773 (TI "x86_64_general_operand")])
775 ;; SSE and x87 SFmode and DFmode floating point modes
776 (define_mode_iterator MODEF [SF DF])
778 ;; All x87 floating point modes
779 (define_mode_iterator X87MODEF [SF DF XF])
781 ;; All integer modes handled by x87 fisttp operator.
782 (define_mode_iterator X87MODEI [HI SI DI])
784 ;; All integer modes handled by integer x87 operators.
785 (define_mode_iterator X87MODEI12 [HI SI])
787 ;; All integer modes handled by SSE cvtts?2si* operators.
788 (define_mode_iterator SSEMODEI24 [SI DI])
790 ;; SSE asm suffix for floating point modes
791 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
793 ;; SSE vector mode corresponding to a scalar mode
794 (define_mode_attr ssevecmode
795 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
797 ;; Instruction suffix for REX 64bit operators.
798 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
800 ;; This mode iterator allows :P to be used for patterns that operate on
801 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
802 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
804 ;; Scheduling descriptions
806 (include "pentium.md")
809 (include "athlon.md")
814 ;; Operand and operator predicates and constraints
816 (include "predicates.md")
817 (include "constraints.md")
820 ;; Compare and branch/compare and store instructions.
822 (define_expand "cbranchti4"
823 [(set (reg:CC FLAGS_REG)
824 (compare:CC (match_operand:TI 1 "nonimmediate_operand" "")
825 (match_operand:TI 2 "x86_64_general_operand" "")))
826 (set (pc) (if_then_else
827 (match_operator 0 "comparison_operator"
830 (label_ref (match_operand 3 "" ""))
834 if (MEM_P (operands[1]) && MEM_P (operands[2]))
835 operands[1] = force_reg (TImode, operands[1]);
836 ix86_compare_op0 = operands[1];
837 ix86_compare_op1 = operands[2];
838 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
842 (define_expand "cbranchdi4"
843 [(set (reg:CC FLAGS_REG)
844 (compare:CC (match_operand:DI 1 "nonimmediate_operand" "")
845 (match_operand:DI 2 "x86_64_general_operand" "")))
846 (set (pc) (if_then_else
847 (match_operator 0 "comparison_operator"
850 (label_ref (match_operand 3 "" ""))
854 if (MEM_P (operands[1]) && MEM_P (operands[2]))
855 operands[1] = force_reg (DImode, operands[1]);
856 ix86_compare_op0 = operands[1];
857 ix86_compare_op1 = operands[2];
858 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
862 (define_expand "cstoredi4"
863 [(set (reg:CC FLAGS_REG)
864 (compare:CC (match_operand:DI 2 "nonimmediate_operand" "")
865 (match_operand:DI 3 "x86_64_general_operand" "")))
866 (set (match_operand:QI 0 "register_operand" "")
867 (match_operator 1 "comparison_operator"
872 if (MEM_P (operands[2]) && MEM_P (operands[3]))
873 operands[2] = force_reg (DImode, operands[2]);
874 ix86_compare_op0 = operands[2];
875 ix86_compare_op1 = operands[3];
876 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
880 (define_expand "cbranchsi4"
881 [(set (reg:CC FLAGS_REG)
882 (compare:CC (match_operand:SI 1 "cmpsi_operand" "")
883 (match_operand:SI 2 "general_operand" "")))
884 (set (pc) (if_then_else
885 (match_operator 0 "comparison_operator"
888 (label_ref (match_operand 3 "" ""))
892 if (MEM_P (operands[1]) && MEM_P (operands[2]))
893 operands[1] = force_reg (SImode, operands[1]);
894 ix86_compare_op0 = operands[1];
895 ix86_compare_op1 = operands[2];
896 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
900 (define_expand "cstoresi4"
901 [(set (reg:CC FLAGS_REG)
902 (compare:CC (match_operand:SI 2 "cmpsi_operand" "")
903 (match_operand:SI 3 "general_operand" "")))
904 (set (match_operand:QI 0 "register_operand" "")
905 (match_operator 1 "comparison_operator"
910 if (MEM_P (operands[2]) && MEM_P (operands[3]))
911 operands[2] = force_reg (SImode, operands[2]);
912 ix86_compare_op0 = operands[2];
913 ix86_compare_op1 = operands[3];
914 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
918 (define_expand "cbranchhi4"
919 [(set (reg:CC FLAGS_REG)
920 (compare:CC (match_operand:HI 1 "nonimmediate_operand" "")
921 (match_operand:HI 2 "general_operand" "")))
922 (set (pc) (if_then_else
923 (match_operator 0 "comparison_operator"
926 (label_ref (match_operand 3 "" ""))
930 if (MEM_P (operands[1]) && MEM_P (operands[2]))
931 operands[1] = force_reg (HImode, operands[1]);
932 ix86_compare_op0 = operands[1];
933 ix86_compare_op1 = operands[2];
934 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
938 (define_expand "cstorehi4"
939 [(set (reg:CC FLAGS_REG)
940 (compare:CC (match_operand:HI 2 "nonimmediate_operand" "")
941 (match_operand:HI 3 "general_operand" "")))
942 (set (match_operand:QI 0 "register_operand" "")
943 (match_operator 1 "comparison_operator"
948 if (MEM_P (operands[2]) && MEM_P (operands[3]))
949 operands[2] = force_reg (HImode, operands[2]);
950 ix86_compare_op0 = operands[2];
951 ix86_compare_op1 = operands[3];
952 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
957 (define_expand "cbranchqi4"
958 [(set (reg:CC FLAGS_REG)
959 (compare:CC (match_operand:QI 1 "nonimmediate_operand" "")
960 (match_operand:QI 2 "general_operand" "")))
961 (set (pc) (if_then_else
962 (match_operator 0 "comparison_operator"
965 (label_ref (match_operand 3 "" ""))
969 if (MEM_P (operands[1]) && MEM_P (operands[2]))
970 operands[1] = force_reg (QImode, operands[1]);
971 ix86_compare_op0 = operands[1];
972 ix86_compare_op1 = operands[2];
973 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
978 (define_expand "cstoreqi4"
979 [(set (reg:CC FLAGS_REG)
980 (compare:CC (match_operand:QI 2 "nonimmediate_operand" "")
981 (match_operand:QI 3 "general_operand" "")))
982 (set (match_operand:QI 0 "register_operand" "")
983 (match_operator 1 "comparison_operator"
988 if (MEM_P (operands[2]) && MEM_P (operands[3]))
989 operands[2] = force_reg (QImode, operands[2]);
990 ix86_compare_op0 = operands[2];
991 ix86_compare_op1 = operands[3];
992 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
997 (define_insn "cmpdi_ccno_1_rex64"
998 [(set (reg FLAGS_REG)
999 (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
1000 (match_operand:DI 1 "const0_operand" "")))]
1001 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
1004 cmp{q}\t{%1, %0|%0, %1}"
1005 [(set_attr "type" "test,icmp")
1006 (set_attr "length_immediate" "0,1")
1007 (set_attr "mode" "DI")])
1009 (define_insn "*cmpdi_minus_1_rex64"
1010 [(set (reg FLAGS_REG)
1011 (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
1012 (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
1014 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
1015 "cmp{q}\t{%1, %0|%0, %1}"
1016 [(set_attr "type" "icmp")
1017 (set_attr "mode" "DI")])
1019 (define_expand "cmpdi_1_rex64"
1020 [(set (reg:CC FLAGS_REG)
1021 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
1022 (match_operand:DI 1 "general_operand" "")))]
1026 (define_insn "cmpdi_1_insn_rex64"
1027 [(set (reg FLAGS_REG)
1028 (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
1029 (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
1030 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1031 "cmp{q}\t{%1, %0|%0, %1}"
1032 [(set_attr "type" "icmp")
1033 (set_attr "mode" "DI")])
1036 (define_insn "*cmpsi_ccno_1"
1037 [(set (reg FLAGS_REG)
1038 (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
1039 (match_operand:SI 1 "const0_operand" "")))]
1040 "ix86_match_ccmode (insn, CCNOmode)"
1043 cmp{l}\t{%1, %0|%0, %1}"
1044 [(set_attr "type" "test,icmp")
1045 (set_attr "length_immediate" "0,1")
1046 (set_attr "mode" "SI")])
1048 (define_insn "*cmpsi_minus_1"
1049 [(set (reg FLAGS_REG)
1050 (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1051 (match_operand:SI 1 "general_operand" "ri,mr"))
1053 "ix86_match_ccmode (insn, CCGOCmode)"
1054 "cmp{l}\t{%1, %0|%0, %1}"
1055 [(set_attr "type" "icmp")
1056 (set_attr "mode" "SI")])
1058 (define_expand "cmpsi_1"
1059 [(set (reg:CC FLAGS_REG)
1060 (compare:CC (match_operand:SI 0 "nonimmediate_operand" "")
1061 (match_operand:SI 1 "general_operand" "")))]
1065 (define_insn "*cmpsi_1_insn"
1066 [(set (reg FLAGS_REG)
1067 (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
1068 (match_operand:SI 1 "general_operand" "ri,mr")))]
1069 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
1070 && ix86_match_ccmode (insn, CCmode)"
1071 "cmp{l}\t{%1, %0|%0, %1}"
1072 [(set_attr "type" "icmp")
1073 (set_attr "mode" "SI")])
1075 (define_insn "*cmphi_ccno_1"
1076 [(set (reg FLAGS_REG)
1077 (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
1078 (match_operand:HI 1 "const0_operand" "")))]
1079 "ix86_match_ccmode (insn, CCNOmode)"
1082 cmp{w}\t{%1, %0|%0, %1}"
1083 [(set_attr "type" "test,icmp")
1084 (set_attr "length_immediate" "0,1")
1085 (set_attr "mode" "HI")])
1087 (define_insn "*cmphi_minus_1"
1088 [(set (reg FLAGS_REG)
1089 (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1090 (match_operand:HI 1 "general_operand" "rn,mr"))
1092 "ix86_match_ccmode (insn, CCGOCmode)"
1093 "cmp{w}\t{%1, %0|%0, %1}"
1094 [(set_attr "type" "icmp")
1095 (set_attr "mode" "HI")])
1097 (define_insn "*cmphi_1"
1098 [(set (reg FLAGS_REG)
1099 (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
1100 (match_operand:HI 1 "general_operand" "rn,mr")))]
1101 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
1102 && ix86_match_ccmode (insn, CCmode)"
1103 "cmp{w}\t{%1, %0|%0, %1}"
1104 [(set_attr "type" "icmp")
1105 (set_attr "mode" "HI")])
1107 (define_insn "*cmpqi_ccno_1"
1108 [(set (reg FLAGS_REG)
1109 (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
1110 (match_operand:QI 1 "const0_operand" "")))]
1111 "ix86_match_ccmode (insn, CCNOmode)"
1114 cmp{b}\t{$0, %0|%0, 0}"
1115 [(set_attr "type" "test,icmp")
1116 (set_attr "length_immediate" "0,1")
1117 (set_attr "mode" "QI")])
1119 (define_insn "*cmpqi_1"
1120 [(set (reg FLAGS_REG)
1121 (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1122 (match_operand:QI 1 "general_operand" "qn,mq")))]
1123 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
1124 && ix86_match_ccmode (insn, CCmode)"
1125 "cmp{b}\t{%1, %0|%0, %1}"
1126 [(set_attr "type" "icmp")
1127 (set_attr "mode" "QI")])
1129 (define_insn "*cmpqi_minus_1"
1130 [(set (reg FLAGS_REG)
1131 (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
1132 (match_operand:QI 1 "general_operand" "qn,mq"))
1134 "ix86_match_ccmode (insn, CCGOCmode)"
1135 "cmp{b}\t{%1, %0|%0, %1}"
1136 [(set_attr "type" "icmp")
1137 (set_attr "mode" "QI")])
1139 (define_insn "*cmpqi_ext_1"
1140 [(set (reg FLAGS_REG)
1142 (match_operand:QI 0 "general_operand" "Qm")
1145 (match_operand 1 "ext_register_operand" "Q")
1147 (const_int 8)) 0)))]
1148 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1149 "cmp{b}\t{%h1, %0|%0, %h1}"
1150 [(set_attr "type" "icmp")
1151 (set_attr "mode" "QI")])
1153 (define_insn "*cmpqi_ext_1_rex64"
1154 [(set (reg FLAGS_REG)
1156 (match_operand:QI 0 "register_operand" "Q")
1159 (match_operand 1 "ext_register_operand" "Q")
1161 (const_int 8)) 0)))]
1162 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1163 "cmp{b}\t{%h1, %0|%0, %h1}"
1164 [(set_attr "type" "icmp")
1165 (set_attr "mode" "QI")])
1167 (define_insn "*cmpqi_ext_2"
1168 [(set (reg FLAGS_REG)
1172 (match_operand 0 "ext_register_operand" "Q")
1175 (match_operand:QI 1 "const0_operand" "")))]
1176 "ix86_match_ccmode (insn, CCNOmode)"
1178 [(set_attr "type" "test")
1179 (set_attr "length_immediate" "0")
1180 (set_attr "mode" "QI")])
1182 (define_expand "cmpqi_ext_3"
1183 [(set (reg:CC FLAGS_REG)
1187 (match_operand 0 "ext_register_operand" "")
1190 (match_operand:QI 1 "general_operand" "")))]
1194 (define_insn "cmpqi_ext_3_insn"
1195 [(set (reg FLAGS_REG)
1199 (match_operand 0 "ext_register_operand" "Q")
1202 (match_operand:QI 1 "general_operand" "Qmn")))]
1203 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1204 "cmp{b}\t{%1, %h0|%h0, %1}"
1205 [(set_attr "type" "icmp")
1206 (set_attr "modrm" "1")
1207 (set_attr "mode" "QI")])
1209 (define_insn "cmpqi_ext_3_insn_rex64"
1210 [(set (reg FLAGS_REG)
1214 (match_operand 0 "ext_register_operand" "Q")
1217 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1218 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1219 "cmp{b}\t{%1, %h0|%h0, %1}"
1220 [(set_attr "type" "icmp")
1221 (set_attr "modrm" "1")
1222 (set_attr "mode" "QI")])
1224 (define_insn "*cmpqi_ext_4"
1225 [(set (reg FLAGS_REG)
1229 (match_operand 0 "ext_register_operand" "Q")
1234 (match_operand 1 "ext_register_operand" "Q")
1236 (const_int 8)) 0)))]
1237 "ix86_match_ccmode (insn, CCmode)"
1238 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1239 [(set_attr "type" "icmp")
1240 (set_attr "mode" "QI")])
1242 ;; These implement float point compares.
1243 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1244 ;; which would allow mix and match FP modes on the compares. Which is what
1245 ;; the old patterns did, but with many more of them.
1247 (define_expand "cbranchxf4"
1248 [(set (reg:CC FLAGS_REG)
1249 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1250 (match_operand:XF 2 "nonmemory_operand" "")))
1251 (set (pc) (if_then_else
1252 (match_operator 0 "ix86_fp_comparison_operator"
1255 (label_ref (match_operand 3 "" ""))
1259 ix86_compare_op0 = operands[1];
1260 ix86_compare_op1 = operands[2];
1261 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1265 (define_expand "cstorexf4"
1266 [(set (reg:CC FLAGS_REG)
1267 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1268 (match_operand:XF 3 "nonmemory_operand" "")))
1269 (set (match_operand:QI 0 "register_operand" "")
1270 (match_operator 1 "ix86_fp_comparison_operator"
1275 ix86_compare_op0 = operands[2];
1276 ix86_compare_op1 = operands[3];
1277 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1281 (define_expand "cbranch<mode>4"
1282 [(set (reg:CC FLAGS_REG)
1283 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1284 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1285 (set (pc) (if_then_else
1286 (match_operator 0 "ix86_fp_comparison_operator"
1289 (label_ref (match_operand 3 "" ""))
1291 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1293 ix86_compare_op0 = operands[1];
1294 ix86_compare_op1 = operands[2];
1295 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1299 (define_expand "cstore<mode>4"
1300 [(set (reg:CC FLAGS_REG)
1301 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1302 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1303 (set (match_operand:QI 0 "register_operand" "")
1304 (match_operator 1 "ix86_fp_comparison_operator"
1307 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1309 ix86_compare_op0 = operands[2];
1310 ix86_compare_op1 = operands[3];
1311 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1315 (define_expand "cbranchcc4"
1316 [(set (pc) (if_then_else
1317 (match_operator 0 "comparison_operator"
1318 [(match_operand 1 "flags_reg_operand" "")
1319 (match_operand 2 "const0_operand" "")])
1320 (label_ref (match_operand 3 "" ""))
1324 ix86_compare_op0 = operands[1];
1325 ix86_compare_op1 = operands[2];
1326 ix86_expand_branch (GET_CODE (operands[0]), operands[3]);
1330 (define_expand "cstorecc4"
1331 [(set (match_operand:QI 0 "register_operand" "")
1332 (match_operator 1 "comparison_operator"
1333 [(match_operand 2 "flags_reg_operand" "")
1334 (match_operand 3 "const0_operand" "")]))]
1337 ix86_compare_op0 = operands[2];
1338 ix86_compare_op1 = operands[3];
1339 ix86_expand_setcc (GET_CODE (operands[1]), operands[0]);
1344 ;; FP compares, step 1:
1345 ;; Set the FP condition codes.
1347 ;; CCFPmode compare with exceptions
1348 ;; CCFPUmode compare with no exceptions
1350 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1351 ;; used to manage the reg stack popping would not be preserved.
1353 (define_insn "*cmpfp_0"
1354 [(set (match_operand:HI 0 "register_operand" "=a")
1357 (match_operand 1 "register_operand" "f")
1358 (match_operand 2 "const0_operand" ""))]
1360 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1361 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1362 "* return output_fp_compare (insn, operands, 0, 0);"
1363 [(set_attr "type" "multi")
1364 (set_attr "unit" "i387")
1366 (cond [(match_operand:SF 1 "" "")
1368 (match_operand:DF 1 "" "")
1371 (const_string "XF")))])
1373 (define_insn_and_split "*cmpfp_0_cc"
1374 [(set (reg:CCFP FLAGS_REG)
1376 (match_operand 1 "register_operand" "f")
1377 (match_operand 2 "const0_operand" "")))
1378 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1379 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1380 && TARGET_SAHF && !TARGET_CMOVE
1381 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1383 "&& reload_completed"
1386 [(compare:CCFP (match_dup 1)(match_dup 2))]
1388 (set (reg:CC FLAGS_REG)
1389 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1391 [(set_attr "type" "multi")
1392 (set_attr "unit" "i387")
1394 (cond [(match_operand:SF 1 "" "")
1396 (match_operand:DF 1 "" "")
1399 (const_string "XF")))])
1401 (define_insn "*cmpfp_xf"
1402 [(set (match_operand:HI 0 "register_operand" "=a")
1405 (match_operand:XF 1 "register_operand" "f")
1406 (match_operand:XF 2 "register_operand" "f"))]
1409 "* return output_fp_compare (insn, operands, 0, 0);"
1410 [(set_attr "type" "multi")
1411 (set_attr "unit" "i387")
1412 (set_attr "mode" "XF")])
1414 (define_insn_and_split "*cmpfp_xf_cc"
1415 [(set (reg:CCFP FLAGS_REG)
1417 (match_operand:XF 1 "register_operand" "f")
1418 (match_operand:XF 2 "register_operand" "f")))
1419 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1421 && TARGET_SAHF && !TARGET_CMOVE"
1423 "&& reload_completed"
1426 [(compare:CCFP (match_dup 1)(match_dup 2))]
1428 (set (reg:CC FLAGS_REG)
1429 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1431 [(set_attr "type" "multi")
1432 (set_attr "unit" "i387")
1433 (set_attr "mode" "XF")])
1435 (define_insn "*cmpfp_<mode>"
1436 [(set (match_operand:HI 0 "register_operand" "=a")
1439 (match_operand:MODEF 1 "register_operand" "f")
1440 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1443 "* return output_fp_compare (insn, operands, 0, 0);"
1444 [(set_attr "type" "multi")
1445 (set_attr "unit" "i387")
1446 (set_attr "mode" "<MODE>")])
1448 (define_insn_and_split "*cmpfp_<mode>_cc"
1449 [(set (reg:CCFP FLAGS_REG)
1451 (match_operand:MODEF 1 "register_operand" "f")
1452 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1453 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1455 && TARGET_SAHF && !TARGET_CMOVE"
1457 "&& reload_completed"
1460 [(compare:CCFP (match_dup 1)(match_dup 2))]
1462 (set (reg:CC FLAGS_REG)
1463 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1465 [(set_attr "type" "multi")
1466 (set_attr "unit" "i387")
1467 (set_attr "mode" "<MODE>")])
1469 (define_insn "*cmpfp_u"
1470 [(set (match_operand:HI 0 "register_operand" "=a")
1473 (match_operand 1 "register_operand" "f")
1474 (match_operand 2 "register_operand" "f"))]
1476 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1477 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1478 "* return output_fp_compare (insn, operands, 0, 1);"
1479 [(set_attr "type" "multi")
1480 (set_attr "unit" "i387")
1482 (cond [(match_operand:SF 1 "" "")
1484 (match_operand:DF 1 "" "")
1487 (const_string "XF")))])
1489 (define_insn_and_split "*cmpfp_u_cc"
1490 [(set (reg:CCFPU FLAGS_REG)
1492 (match_operand 1 "register_operand" "f")
1493 (match_operand 2 "register_operand" "f")))
1494 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1495 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1496 && TARGET_SAHF && !TARGET_CMOVE
1497 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1499 "&& reload_completed"
1502 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1504 (set (reg:CC FLAGS_REG)
1505 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1507 [(set_attr "type" "multi")
1508 (set_attr "unit" "i387")
1510 (cond [(match_operand:SF 1 "" "")
1512 (match_operand:DF 1 "" "")
1515 (const_string "XF")))])
1517 (define_insn "*cmpfp_<mode>"
1518 [(set (match_operand:HI 0 "register_operand" "=a")
1521 (match_operand 1 "register_operand" "f")
1522 (match_operator 3 "float_operator"
1523 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1525 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1526 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1527 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1528 "* return output_fp_compare (insn, operands, 0, 0);"
1529 [(set_attr "type" "multi")
1530 (set_attr "unit" "i387")
1531 (set_attr "fp_int_src" "true")
1532 (set_attr "mode" "<MODE>")])
1534 (define_insn_and_split "*cmpfp_<mode>_cc"
1535 [(set (reg:CCFP FLAGS_REG)
1537 (match_operand 1 "register_operand" "f")
1538 (match_operator 3 "float_operator"
1539 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1540 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1541 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1542 && TARGET_SAHF && !TARGET_CMOVE
1543 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1544 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1546 "&& reload_completed"
1551 (match_op_dup 3 [(match_dup 2)]))]
1553 (set (reg:CC FLAGS_REG)
1554 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1556 [(set_attr "type" "multi")
1557 (set_attr "unit" "i387")
1558 (set_attr "fp_int_src" "true")
1559 (set_attr "mode" "<MODE>")])
1561 ;; FP compares, step 2
1562 ;; Move the fpsw to ax.
1564 (define_insn "x86_fnstsw_1"
1565 [(set (match_operand:HI 0 "register_operand" "=a")
1566 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1569 [(set (attr "length") (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1570 (set_attr "mode" "SI")
1571 (set_attr "unit" "i387")])
1573 ;; FP compares, step 3
1574 ;; Get ax into flags, general case.
1576 (define_insn "x86_sahf_1"
1577 [(set (reg:CC FLAGS_REG)
1578 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1582 #ifdef HAVE_AS_IX86_SAHF
1585 return ASM_BYTE "0x9e";
1588 [(set_attr "length" "1")
1589 (set_attr "athlon_decode" "vector")
1590 (set_attr "amdfam10_decode" "direct")
1591 (set_attr "mode" "SI")])
1593 ;; Pentium Pro can do steps 1 through 3 in one go.
1594 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1595 (define_insn "*cmpfp_i_mixed"
1596 [(set (reg:CCFP FLAGS_REG)
1597 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1598 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1599 "TARGET_MIX_SSE_I387
1600 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1601 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1602 "* return output_fp_compare (insn, operands, 1, 0);"
1603 [(set_attr "type" "fcmp,ssecomi")
1604 (set_attr "prefix" "orig,maybe_vex")
1606 (if_then_else (match_operand:SF 1 "" "")
1608 (const_string "DF")))
1609 (set (attr "prefix_rep")
1610 (if_then_else (eq_attr "type" "ssecomi")
1612 (const_string "*")))
1613 (set (attr "prefix_data16")
1614 (cond [(eq_attr "type" "fcmp")
1616 (eq_attr "mode" "DF")
1619 (const_string "0")))
1620 (set_attr "athlon_decode" "vector")
1621 (set_attr "amdfam10_decode" "direct")])
1623 (define_insn "*cmpfp_i_sse"
1624 [(set (reg:CCFP FLAGS_REG)
1625 (compare:CCFP (match_operand 0 "register_operand" "x")
1626 (match_operand 1 "nonimmediate_operand" "xm")))]
1628 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1629 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1630 "* return output_fp_compare (insn, operands, 1, 0);"
1631 [(set_attr "type" "ssecomi")
1632 (set_attr "prefix" "maybe_vex")
1634 (if_then_else (match_operand:SF 1 "" "")
1636 (const_string "DF")))
1637 (set_attr "prefix_rep" "0")
1638 (set (attr "prefix_data16")
1639 (if_then_else (eq_attr "mode" "DF")
1641 (const_string "0")))
1642 (set_attr "athlon_decode" "vector")
1643 (set_attr "amdfam10_decode" "direct")])
1645 (define_insn "*cmpfp_i_i387"
1646 [(set (reg:CCFP FLAGS_REG)
1647 (compare:CCFP (match_operand 0 "register_operand" "f")
1648 (match_operand 1 "register_operand" "f")))]
1649 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1651 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1652 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1653 "* return output_fp_compare (insn, operands, 1, 0);"
1654 [(set_attr "type" "fcmp")
1656 (cond [(match_operand:SF 1 "" "")
1658 (match_operand:DF 1 "" "")
1661 (const_string "XF")))
1662 (set_attr "athlon_decode" "vector")
1663 (set_attr "amdfam10_decode" "direct")])
1665 (define_insn "*cmpfp_iu_mixed"
1666 [(set (reg:CCFPU FLAGS_REG)
1667 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1668 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1669 "TARGET_MIX_SSE_I387
1670 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1671 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1672 "* return output_fp_compare (insn, operands, 1, 1);"
1673 [(set_attr "type" "fcmp,ssecomi")
1674 (set_attr "prefix" "orig,maybe_vex")
1676 (if_then_else (match_operand:SF 1 "" "")
1678 (const_string "DF")))
1679 (set (attr "prefix_rep")
1680 (if_then_else (eq_attr "type" "ssecomi")
1682 (const_string "*")))
1683 (set (attr "prefix_data16")
1684 (cond [(eq_attr "type" "fcmp")
1686 (eq_attr "mode" "DF")
1689 (const_string "0")))
1690 (set_attr "athlon_decode" "vector")
1691 (set_attr "amdfam10_decode" "direct")])
1693 (define_insn "*cmpfp_iu_sse"
1694 [(set (reg:CCFPU FLAGS_REG)
1695 (compare:CCFPU (match_operand 0 "register_operand" "x")
1696 (match_operand 1 "nonimmediate_operand" "xm")))]
1698 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1699 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1700 "* return output_fp_compare (insn, operands, 1, 1);"
1701 [(set_attr "type" "ssecomi")
1702 (set_attr "prefix" "maybe_vex")
1704 (if_then_else (match_operand:SF 1 "" "")
1706 (const_string "DF")))
1707 (set_attr "prefix_rep" "0")
1708 (set (attr "prefix_data16")
1709 (if_then_else (eq_attr "mode" "DF")
1711 (const_string "0")))
1712 (set_attr "athlon_decode" "vector")
1713 (set_attr "amdfam10_decode" "direct")])
1715 (define_insn "*cmpfp_iu_387"
1716 [(set (reg:CCFPU FLAGS_REG)
1717 (compare:CCFPU (match_operand 0 "register_operand" "f")
1718 (match_operand 1 "register_operand" "f")))]
1719 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1721 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1722 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1723 "* return output_fp_compare (insn, operands, 1, 1);"
1724 [(set_attr "type" "fcmp")
1726 (cond [(match_operand:SF 1 "" "")
1728 (match_operand:DF 1 "" "")
1731 (const_string "XF")))
1732 (set_attr "athlon_decode" "vector")
1733 (set_attr "amdfam10_decode" "direct")])
1735 ;; Move instructions.
1737 ;; General case of fullword move.
1739 (define_expand "movsi"
1740 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1741 (match_operand:SI 1 "general_operand" ""))]
1743 "ix86_expand_move (SImode, operands); DONE;")
1745 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1748 ;; %%% We don't use a post-inc memory reference because x86 is not a
1749 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1750 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1751 ;; targets without our curiosities, and it is just as easy to represent
1752 ;; this differently.
1754 (define_insn "*pushsi2"
1755 [(set (match_operand:SI 0 "push_operand" "=<")
1756 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1759 [(set_attr "type" "push")
1760 (set_attr "mode" "SI")])
1762 ;; For 64BIT abi we always round up to 8 bytes.
1763 (define_insn "*pushsi2_rex64"
1764 [(set (match_operand:SI 0 "push_operand" "=X")
1765 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1768 [(set_attr "type" "push")
1769 (set_attr "mode" "SI")])
1771 (define_insn "*pushsi2_prologue"
1772 [(set (match_operand:SI 0 "push_operand" "=<")
1773 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1774 (clobber (mem:BLK (scratch)))]
1777 [(set_attr "type" "push")
1778 (set_attr "mode" "SI")])
1780 (define_insn "*popsi1_epilogue"
1781 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1782 (mem:SI (reg:SI SP_REG)))
1783 (set (reg:SI SP_REG)
1784 (plus:SI (reg:SI SP_REG) (const_int 4)))
1785 (clobber (mem:BLK (scratch)))]
1788 [(set_attr "type" "pop")
1789 (set_attr "mode" "SI")])
1791 (define_insn "popsi1"
1792 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1793 (mem:SI (reg:SI SP_REG)))
1794 (set (reg:SI SP_REG)
1795 (plus:SI (reg:SI SP_REG) (const_int 4)))]
1798 [(set_attr "type" "pop")
1799 (set_attr "mode" "SI")])
1801 (define_insn "*movsi_xor"
1802 [(set (match_operand:SI 0 "register_operand" "=r")
1803 (match_operand:SI 1 "const0_operand" ""))
1804 (clobber (reg:CC FLAGS_REG))]
1807 [(set_attr "type" "alu1")
1808 (set_attr "mode" "SI")
1809 (set_attr "length_immediate" "0")])
1811 (define_insn "*movsi_or"
1812 [(set (match_operand:SI 0 "register_operand" "=r")
1813 (match_operand:SI 1 "immediate_operand" "i"))
1814 (clobber (reg:CC FLAGS_REG))]
1816 && operands[1] == constm1_rtx"
1818 operands[1] = constm1_rtx;
1819 return "or{l}\t{%1, %0|%0, %1}";
1821 [(set_attr "type" "alu1")
1822 (set_attr "mode" "SI")
1823 (set_attr "length_immediate" "1")])
1825 (define_insn "*movsi_1"
1826 [(set (match_operand:SI 0 "nonimmediate_operand"
1827 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
1828 (match_operand:SI 1 "general_operand"
1829 "g ,ri,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
1830 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1832 switch (get_attr_type (insn))
1835 if (get_attr_mode (insn) == MODE_TI)
1836 return "%vpxor\t%0, %d0";
1837 return "%vxorps\t%0, %d0";
1840 switch (get_attr_mode (insn))
1843 return "%vmovdqa\t{%1, %0|%0, %1}";
1845 return "%vmovaps\t{%1, %0|%0, %1}";
1847 return "%vmovd\t{%1, %0|%0, %1}";
1849 return "%vmovss\t{%1, %0|%0, %1}";
1855 return "pxor\t%0, %0";
1858 if (get_attr_mode (insn) == MODE_DI)
1859 return "movq\t{%1, %0|%0, %1}";
1860 return "movd\t{%1, %0|%0, %1}";
1863 return "lea{l}\t{%1, %0|%0, %1}";
1866 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1867 return "mov{l}\t{%1, %0|%0, %1}";
1871 (cond [(eq_attr "alternative" "2")
1872 (const_string "mmx")
1873 (eq_attr "alternative" "3,4,5")
1874 (const_string "mmxmov")
1875 (eq_attr "alternative" "6")
1876 (const_string "sselog1")
1877 (eq_attr "alternative" "7,8,9,10,11")
1878 (const_string "ssemov")
1879 (match_operand:DI 1 "pic_32bit_operand" "")
1880 (const_string "lea")
1882 (const_string "imov")))
1883 (set (attr "prefix")
1884 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
1885 (const_string "orig")
1886 (const_string "maybe_vex")))
1887 (set (attr "prefix_data16")
1888 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
1890 (const_string "*")))
1892 (cond [(eq_attr "alternative" "2,3")
1894 (eq_attr "alternative" "6,7")
1896 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1897 (const_string "V4SF")
1898 (const_string "TI"))
1899 (and (eq_attr "alternative" "8,9,10,11")
1900 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
1903 (const_string "SI")))])
1905 ;; Stores and loads of ax to arbitrary constant address.
1906 ;; We fake an second form of instruction to force reload to load address
1907 ;; into register when rax is not available
1908 (define_insn "*movabssi_1_rex64"
1909 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1910 (match_operand:SI 1 "nonmemory_operand" "a,er"))]
1911 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1913 movabs{l}\t{%1, %P0|%P0, %1}
1914 mov{l}\t{%1, %a0|%a0, %1}"
1915 [(set_attr "type" "imov")
1916 (set_attr "modrm" "0,*")
1917 (set_attr "length_address" "8,0")
1918 (set_attr "length_immediate" "0,*")
1919 (set_attr "memory" "store")
1920 (set_attr "mode" "SI")])
1922 (define_insn "*movabssi_2_rex64"
1923 [(set (match_operand:SI 0 "register_operand" "=a,r")
1924 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1925 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1927 movabs{l}\t{%P1, %0|%0, %P1}
1928 mov{l}\t{%a1, %0|%0, %a1}"
1929 [(set_attr "type" "imov")
1930 (set_attr "modrm" "0,*")
1931 (set_attr "length_address" "8,0")
1932 (set_attr "length_immediate" "0")
1933 (set_attr "memory" "load")
1934 (set_attr "mode" "SI")])
1936 (define_insn "*swapsi"
1937 [(set (match_operand:SI 0 "register_operand" "+r")
1938 (match_operand:SI 1 "register_operand" "+r"))
1943 [(set_attr "type" "imov")
1944 (set_attr "mode" "SI")
1945 (set_attr "pent_pair" "np")
1946 (set_attr "athlon_decode" "vector")
1947 (set_attr "amdfam10_decode" "double")])
1949 (define_expand "movhi"
1950 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1951 (match_operand:HI 1 "general_operand" ""))]
1953 "ix86_expand_move (HImode, operands); DONE;")
1955 (define_insn "*pushhi2"
1956 [(set (match_operand:HI 0 "push_operand" "=X")
1957 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1960 [(set_attr "type" "push")
1961 (set_attr "mode" "SI")])
1963 ;; For 64BIT abi we always round up to 8 bytes.
1964 (define_insn "*pushhi2_rex64"
1965 [(set (match_operand:HI 0 "push_operand" "=X")
1966 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1969 [(set_attr "type" "push")
1970 (set_attr "mode" "DI")])
1972 (define_insn "*movhi_1"
1973 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
1974 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
1975 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1977 switch (get_attr_type (insn))
1980 /* movzwl is faster than movw on p2 due to partial word stalls,
1981 though not as fast as an aligned movl. */
1982 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1984 if (get_attr_mode (insn) == MODE_SI)
1985 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1987 return "mov{w}\t{%1, %0|%0, %1}";
1991 (cond [(ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0))
1992 (const_string "imov")
1993 (and (eq_attr "alternative" "0")
1994 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1996 (eq (symbol_ref "TARGET_HIMODE_MATH")
1998 (const_string "imov")
1999 (and (eq_attr "alternative" "1,2")
2000 (match_operand:HI 1 "aligned_operand" ""))
2001 (const_string "imov")
2002 (and (ne (symbol_ref "TARGET_MOVX")
2004 (eq_attr "alternative" "0,2"))
2005 (const_string "imovx")
2007 (const_string "imov")))
2009 (cond [(eq_attr "type" "imovx")
2011 (and (eq_attr "alternative" "1,2")
2012 (match_operand:HI 1 "aligned_operand" ""))
2014 (and (eq_attr "alternative" "0")
2015 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2017 (eq (symbol_ref "TARGET_HIMODE_MATH")
2021 (const_string "HI")))])
2023 ;; Stores and loads of ax to arbitrary constant address.
2024 ;; We fake an second form of instruction to force reload to load address
2025 ;; into register when rax is not available
2026 (define_insn "*movabshi_1_rex64"
2027 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2028 (match_operand:HI 1 "nonmemory_operand" "a,er"))]
2029 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2031 movabs{w}\t{%1, %P0|%P0, %1}
2032 mov{w}\t{%1, %a0|%a0, %1}"
2033 [(set_attr "type" "imov")
2034 (set_attr "modrm" "0,*")
2035 (set_attr "length_address" "8,0")
2036 (set_attr "length_immediate" "0,*")
2037 (set_attr "memory" "store")
2038 (set_attr "mode" "HI")])
2040 (define_insn "*movabshi_2_rex64"
2041 [(set (match_operand:HI 0 "register_operand" "=a,r")
2042 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2043 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2045 movabs{w}\t{%P1, %0|%0, %P1}
2046 mov{w}\t{%a1, %0|%0, %a1}"
2047 [(set_attr "type" "imov")
2048 (set_attr "modrm" "0,*")
2049 (set_attr "length_address" "8,0")
2050 (set_attr "length_immediate" "0")
2051 (set_attr "memory" "load")
2052 (set_attr "mode" "HI")])
2054 (define_insn "*swaphi_1"
2055 [(set (match_operand:HI 0 "register_operand" "+r")
2056 (match_operand:HI 1 "register_operand" "+r"))
2059 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2061 [(set_attr "type" "imov")
2062 (set_attr "mode" "SI")
2063 (set_attr "pent_pair" "np")
2064 (set_attr "athlon_decode" "vector")
2065 (set_attr "amdfam10_decode" "double")])
2067 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
2068 (define_insn "*swaphi_2"
2069 [(set (match_operand:HI 0 "register_operand" "+r")
2070 (match_operand:HI 1 "register_operand" "+r"))
2073 "TARGET_PARTIAL_REG_STALL"
2075 [(set_attr "type" "imov")
2076 (set_attr "mode" "HI")
2077 (set_attr "pent_pair" "np")
2078 (set_attr "athlon_decode" "vector")])
2080 (define_expand "movstricthi"
2081 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
2082 (match_operand:HI 1 "general_operand" ""))]
2085 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2087 /* Don't generate memory->memory moves, go through a register */
2088 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2089 operands[1] = force_reg (HImode, operands[1]);
2092 (define_insn "*movstricthi_1"
2093 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
2094 (match_operand:HI 1 "general_operand" "rn,m"))]
2095 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2096 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2097 "mov{w}\t{%1, %0|%0, %1}"
2098 [(set_attr "type" "imov")
2099 (set_attr "mode" "HI")])
2101 (define_insn "*movstricthi_xor"
2102 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
2103 (match_operand:HI 1 "const0_operand" ""))
2104 (clobber (reg:CC FLAGS_REG))]
2107 [(set_attr "type" "alu1")
2108 (set_attr "mode" "HI")
2109 (set_attr "length_immediate" "0")])
2111 (define_expand "movqi"
2112 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2113 (match_operand:QI 1 "general_operand" ""))]
2115 "ix86_expand_move (QImode, operands); DONE;")
2117 ;; emit_push_insn when it calls move_by_pieces requires an insn to
2118 ;; "push a byte". But actually we use pushl, which has the effect
2119 ;; of rounding the amount pushed up to a word.
2121 (define_insn "*pushqi2"
2122 [(set (match_operand:QI 0 "push_operand" "=X")
2123 (match_operand:QI 1 "nonmemory_no_elim_operand" "rn"))]
2126 [(set_attr "type" "push")
2127 (set_attr "mode" "SI")])
2129 ;; For 64BIT abi we always round up to 8 bytes.
2130 (define_insn "*pushqi2_rex64"
2131 [(set (match_operand:QI 0 "push_operand" "=X")
2132 (match_operand:QI 1 "nonmemory_no_elim_operand" "qn"))]
2135 [(set_attr "type" "push")
2136 (set_attr "mode" "DI")])
2138 ;; Situation is quite tricky about when to choose full sized (SImode) move
2139 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2140 ;; partial register dependency machines (such as AMD Athlon), where QImode
2141 ;; moves issue extra dependency and for partial register stalls machines
2142 ;; that don't use QImode patterns (and QImode move cause stall on the next
2145 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2146 ;; register stall machines with, where we use QImode instructions, since
2147 ;; partial register stall can be caused there. Then we use movzx.
2148 (define_insn "*movqi_1"
2149 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2150 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2151 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2153 switch (get_attr_type (insn))
2156 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2157 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2159 if (get_attr_mode (insn) == MODE_SI)
2160 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2162 return "mov{b}\t{%1, %0|%0, %1}";
2166 (cond [(and (eq_attr "alternative" "5")
2167 (not (match_operand:QI 1 "aligned_operand" "")))
2168 (const_string "imovx")
2169 (ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0))
2170 (const_string "imov")
2171 (and (eq_attr "alternative" "3")
2172 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2174 (eq (symbol_ref "TARGET_QIMODE_MATH")
2176 (const_string "imov")
2177 (eq_attr "alternative" "3,5")
2178 (const_string "imovx")
2179 (and (ne (symbol_ref "TARGET_MOVX")
2181 (eq_attr "alternative" "2"))
2182 (const_string "imovx")
2184 (const_string "imov")))
2186 (cond [(eq_attr "alternative" "3,4,5")
2188 (eq_attr "alternative" "6")
2190 (eq_attr "type" "imovx")
2192 (and (eq_attr "type" "imov")
2193 (and (eq_attr "alternative" "0,1")
2194 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
2196 (and (eq (symbol_ref "optimize_function_for_size_p (cfun)")
2198 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
2201 ;; Avoid partial register stalls when not using QImode arithmetic
2202 (and (eq_attr "type" "imov")
2203 (and (eq_attr "alternative" "0,1")
2204 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
2206 (eq (symbol_ref "TARGET_QIMODE_MATH")
2210 (const_string "QI")))])
2212 (define_insn "*swapqi_1"
2213 [(set (match_operand:QI 0 "register_operand" "+r")
2214 (match_operand:QI 1 "register_operand" "+r"))
2217 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2219 [(set_attr "type" "imov")
2220 (set_attr "mode" "SI")
2221 (set_attr "pent_pair" "np")
2222 (set_attr "athlon_decode" "vector")
2223 (set_attr "amdfam10_decode" "vector")])
2225 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
2226 (define_insn "*swapqi_2"
2227 [(set (match_operand:QI 0 "register_operand" "+q")
2228 (match_operand:QI 1 "register_operand" "+q"))
2231 "TARGET_PARTIAL_REG_STALL"
2233 [(set_attr "type" "imov")
2234 (set_attr "mode" "QI")
2235 (set_attr "pent_pair" "np")
2236 (set_attr "athlon_decode" "vector")])
2238 (define_expand "movstrictqi"
2239 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
2240 (match_operand:QI 1 "general_operand" ""))]
2243 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2245 /* Don't generate memory->memory moves, go through a register. */
2246 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2247 operands[1] = force_reg (QImode, operands[1]);
2250 (define_insn "*movstrictqi_1"
2251 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
2252 (match_operand:QI 1 "general_operand" "*qn,m"))]
2253 "(! TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2254 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2255 "mov{b}\t{%1, %0|%0, %1}"
2256 [(set_attr "type" "imov")
2257 (set_attr "mode" "QI")])
2259 (define_insn "*movstrictqi_xor"
2260 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
2261 (match_operand:QI 1 "const0_operand" ""))
2262 (clobber (reg:CC FLAGS_REG))]
2265 [(set_attr "type" "alu1")
2266 (set_attr "mode" "QI")
2267 (set_attr "length_immediate" "0")])
2269 (define_insn "*movsi_extv_1"
2270 [(set (match_operand:SI 0 "register_operand" "=R")
2271 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
2275 "movs{bl|x}\t{%h1, %0|%0, %h1}"
2276 [(set_attr "type" "imovx")
2277 (set_attr "mode" "SI")])
2279 (define_insn "*movhi_extv_1"
2280 [(set (match_operand:HI 0 "register_operand" "=R")
2281 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
2285 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2286 [(set_attr "type" "imovx")
2287 (set_attr "mode" "SI")])
2289 (define_insn "*movqi_extv_1"
2290 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2291 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2296 switch (get_attr_type (insn))
2299 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2301 return "mov{b}\t{%h1, %0|%0, %h1}";
2305 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2306 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2307 (ne (symbol_ref "TARGET_MOVX")
2309 (const_string "imovx")
2310 (const_string "imov")))
2312 (if_then_else (eq_attr "type" "imovx")
2314 (const_string "QI")))])
2316 (define_insn "*movqi_extv_1_rex64"
2317 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2318 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2323 switch (get_attr_type (insn))
2326 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2328 return "mov{b}\t{%h1, %0|%0, %h1}";
2332 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2333 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2334 (ne (symbol_ref "TARGET_MOVX")
2336 (const_string "imovx")
2337 (const_string "imov")))
2339 (if_then_else (eq_attr "type" "imovx")
2341 (const_string "QI")))])
2343 ;; Stores and loads of ax to arbitrary constant address.
2344 ;; We fake an second form of instruction to force reload to load address
2345 ;; into register when rax is not available
2346 (define_insn "*movabsqi_1_rex64"
2347 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2348 (match_operand:QI 1 "nonmemory_operand" "a,er"))]
2349 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2351 movabs{b}\t{%1, %P0|%P0, %1}
2352 mov{b}\t{%1, %a0|%a0, %1}"
2353 [(set_attr "type" "imov")
2354 (set_attr "modrm" "0,*")
2355 (set_attr "length_address" "8,0")
2356 (set_attr "length_immediate" "0,*")
2357 (set_attr "memory" "store")
2358 (set_attr "mode" "QI")])
2360 (define_insn "*movabsqi_2_rex64"
2361 [(set (match_operand:QI 0 "register_operand" "=a,r")
2362 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2363 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2365 movabs{b}\t{%P1, %0|%0, %P1}
2366 mov{b}\t{%a1, %0|%0, %a1}"
2367 [(set_attr "type" "imov")
2368 (set_attr "modrm" "0,*")
2369 (set_attr "length_address" "8,0")
2370 (set_attr "length_immediate" "0")
2371 (set_attr "memory" "load")
2372 (set_attr "mode" "QI")])
2374 (define_insn "*movdi_extzv_1"
2375 [(set (match_operand:DI 0 "register_operand" "=R")
2376 (zero_extract:DI (match_operand 1 "ext_register_operand" "Q")
2380 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2381 [(set_attr "type" "imovx")
2382 (set_attr "mode" "SI")])
2384 (define_insn "*movsi_extzv_1"
2385 [(set (match_operand:SI 0 "register_operand" "=R")
2386 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
2390 "movz{bl|x}\t{%h1, %0|%0, %h1}"
2391 [(set_attr "type" "imovx")
2392 (set_attr "mode" "SI")])
2394 (define_insn "*movqi_extzv_2"
2395 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2396 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2401 switch (get_attr_type (insn))
2404 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2406 return "mov{b}\t{%h1, %0|%0, %h1}";
2410 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2411 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2412 (ne (symbol_ref "TARGET_MOVX")
2414 (const_string "imovx")
2415 (const_string "imov")))
2417 (if_then_else (eq_attr "type" "imovx")
2419 (const_string "QI")))])
2421 (define_insn "*movqi_extzv_2_rex64"
2422 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2423 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2428 switch (get_attr_type (insn))
2431 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2433 return "mov{b}\t{%h1, %0|%0, %h1}";
2437 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2438 (ne (symbol_ref "TARGET_MOVX")
2440 (const_string "imovx")
2441 (const_string "imov")))
2443 (if_then_else (eq_attr "type" "imovx")
2445 (const_string "QI")))])
2447 (define_insn "movsi_insv_1"
2448 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2451 (match_operand:SI 1 "general_operand" "Qmn"))]
2453 "mov{b}\t{%b1, %h0|%h0, %b1}"
2454 [(set_attr "type" "imov")
2455 (set_attr "mode" "QI")])
2457 (define_insn "*movsi_insv_1_rex64"
2458 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2461 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2463 "mov{b}\t{%b1, %h0|%h0, %b1}"
2464 [(set_attr "type" "imov")
2465 (set_attr "mode" "QI")])
2467 (define_insn "movdi_insv_1_rex64"
2468 [(set (zero_extract:DI (match_operand 0 "ext_register_operand" "+Q")
2471 (match_operand:DI 1 "nonmemory_operand" "Qn"))]
2473 "mov{b}\t{%b1, %h0|%h0, %b1}"
2474 [(set_attr "type" "imov")
2475 (set_attr "mode" "QI")])
2477 (define_insn "*movqi_insv_2"
2478 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2481 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2484 "mov{b}\t{%h1, %h0|%h0, %h1}"
2485 [(set_attr "type" "imov")
2486 (set_attr "mode" "QI")])
2488 (define_expand "movdi"
2489 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2490 (match_operand:DI 1 "general_operand" ""))]
2492 "ix86_expand_move (DImode, operands); DONE;")
2494 (define_insn "*pushdi"
2495 [(set (match_operand:DI 0 "push_operand" "=<")
2496 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2500 (define_insn "*pushdi2_rex64"
2501 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2502 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2507 [(set_attr "type" "push,multi")
2508 (set_attr "mode" "DI")])
2510 ;; Convert impossible pushes of immediate to existing instructions.
2511 ;; First try to get scratch register and go through it. In case this
2512 ;; fails, push sign extended lower part first and then overwrite
2513 ;; upper part by 32bit move.
2515 [(match_scratch:DI 2 "r")
2516 (set (match_operand:DI 0 "push_operand" "")
2517 (match_operand:DI 1 "immediate_operand" ""))]
2518 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2519 && !x86_64_immediate_operand (operands[1], DImode)"
2520 [(set (match_dup 2) (match_dup 1))
2521 (set (match_dup 0) (match_dup 2))]
2524 ;; We need to define this as both peepholer and splitter for case
2525 ;; peephole2 pass is not run.
2526 ;; "&& 1" is needed to keep it from matching the previous pattern.
2528 [(set (match_operand:DI 0 "push_operand" "")
2529 (match_operand:DI 1 "immediate_operand" ""))]
2530 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2531 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2532 [(set (match_dup 0) (match_dup 1))
2533 (set (match_dup 2) (match_dup 3))]
2534 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2535 operands[1] = gen_lowpart (DImode, operands[2]);
2536 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2541 [(set (match_operand:DI 0 "push_operand" "")
2542 (match_operand:DI 1 "immediate_operand" ""))]
2543 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2544 ? epilogue_completed : reload_completed)
2545 && !symbolic_operand (operands[1], DImode)
2546 && !x86_64_immediate_operand (operands[1], DImode)"
2547 [(set (match_dup 0) (match_dup 1))
2548 (set (match_dup 2) (match_dup 3))]
2549 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2550 operands[1] = gen_lowpart (DImode, operands[2]);
2551 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2555 (define_insn "*pushdi2_prologue_rex64"
2556 [(set (match_operand:DI 0 "push_operand" "=<")
2557 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2558 (clobber (mem:BLK (scratch)))]
2561 [(set_attr "type" "push")
2562 (set_attr "mode" "DI")])
2564 (define_insn "*popdi1_epilogue_rex64"
2565 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2566 (mem:DI (reg:DI SP_REG)))
2567 (set (reg:DI SP_REG)
2568 (plus:DI (reg:DI SP_REG) (const_int 8)))
2569 (clobber (mem:BLK (scratch)))]
2572 [(set_attr "type" "pop")
2573 (set_attr "mode" "DI")])
2575 (define_insn "popdi1"
2576 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2577 (mem:DI (reg:DI SP_REG)))
2578 (set (reg:DI SP_REG)
2579 (plus:DI (reg:DI SP_REG) (const_int 8)))]
2582 [(set_attr "type" "pop")
2583 (set_attr "mode" "DI")])
2585 (define_insn "*movdi_xor_rex64"
2586 [(set (match_operand:DI 0 "register_operand" "=r")
2587 (match_operand:DI 1 "const0_operand" ""))
2588 (clobber (reg:CC FLAGS_REG))]
2590 && reload_completed"
2592 [(set_attr "type" "alu1")
2593 (set_attr "mode" "SI")
2594 (set_attr "length_immediate" "0")])
2596 (define_insn "*movdi_or_rex64"
2597 [(set (match_operand:DI 0 "register_operand" "=r")
2598 (match_operand:DI 1 "const_int_operand" "i"))
2599 (clobber (reg:CC FLAGS_REG))]
2602 && operands[1] == constm1_rtx"
2604 operands[1] = constm1_rtx;
2605 return "or{q}\t{%1, %0|%0, %1}";
2607 [(set_attr "type" "alu1")
2608 (set_attr "mode" "DI")
2609 (set_attr "length_immediate" "1")])
2611 (define_insn "*movdi_2"
2612 [(set (match_operand:DI 0 "nonimmediate_operand"
2613 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2614 (match_operand:DI 1 "general_operand"
2615 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2616 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2621 movq\t{%1, %0|%0, %1}
2622 movq\t{%1, %0|%0, %1}
2624 %vmovq\t{%1, %0|%0, %1}
2625 %vmovdqa\t{%1, %0|%0, %1}
2626 %vmovq\t{%1, %0|%0, %1}
2628 movlps\t{%1, %0|%0, %1}
2629 movaps\t{%1, %0|%0, %1}
2630 movlps\t{%1, %0|%0, %1}"
2631 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2632 (set (attr "prefix")
2633 (if_then_else (eq_attr "alternative" "5,6,7,8")
2634 (const_string "vex")
2635 (const_string "orig")))
2636 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2639 [(set (match_operand:DI 0 "push_operand" "")
2640 (match_operand:DI 1 "general_operand" ""))]
2641 "!TARGET_64BIT && reload_completed
2642 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2644 "ix86_split_long_move (operands); DONE;")
2646 ;; %%% This multiword shite has got to go.
2648 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2649 (match_operand:DI 1 "general_operand" ""))]
2650 "!TARGET_64BIT && reload_completed
2651 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2652 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2654 "ix86_split_long_move (operands); DONE;")
2656 (define_insn "*movdi_1_rex64"
2657 [(set (match_operand:DI 0 "nonimmediate_operand"
2658 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
2659 (match_operand:DI 1 "general_operand"
2660 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
2661 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2663 switch (get_attr_type (insn))
2666 if (SSE_REG_P (operands[0]))
2667 return "movq2dq\t{%1, %0|%0, %1}";
2669 return "movdq2q\t{%1, %0|%0, %1}";
2674 if (get_attr_mode (insn) == MODE_TI)
2675 return "vmovdqa\t{%1, %0|%0, %1}";
2677 return "vmovq\t{%1, %0|%0, %1}";
2680 if (get_attr_mode (insn) == MODE_TI)
2681 return "movdqa\t{%1, %0|%0, %1}";
2685 /* Moves from and into integer register is done using movd
2686 opcode with REX prefix. */
2687 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2688 return "movd\t{%1, %0|%0, %1}";
2689 return "movq\t{%1, %0|%0, %1}";
2692 return "%vpxor\t%0, %d0";
2695 return "pxor\t%0, %0";
2701 return "lea{q}\t{%a1, %0|%0, %a1}";
2704 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2705 if (get_attr_mode (insn) == MODE_SI)
2706 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2707 else if (which_alternative == 2)
2708 return "movabs{q}\t{%1, %0|%0, %1}";
2710 return "mov{q}\t{%1, %0|%0, %1}";
2714 (cond [(eq_attr "alternative" "5")
2715 (const_string "mmx")
2716 (eq_attr "alternative" "6,7,8,9,10")
2717 (const_string "mmxmov")
2718 (eq_attr "alternative" "11")
2719 (const_string "sselog1")
2720 (eq_attr "alternative" "12,13,14,15,16")
2721 (const_string "ssemov")
2722 (eq_attr "alternative" "17,18")
2723 (const_string "ssecvt")
2724 (eq_attr "alternative" "4")
2725 (const_string "multi")
2726 (match_operand:DI 1 "pic_32bit_operand" "")
2727 (const_string "lea")
2729 (const_string "imov")))
2732 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2734 (const_string "*")))
2735 (set (attr "length_immediate")
2737 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2739 (const_string "*")))
2740 (set_attr "prefix_rex" "*,*,*,*,*,*,*,1,*,1,*,*,*,*,*,*,*,*,*")
2741 (set_attr "prefix_data16" "*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,1,*,*,*")
2742 (set (attr "prefix")
2743 (if_then_else (eq_attr "alternative" "11,12,13,14,15,16")
2744 (const_string "maybe_vex")
2745 (const_string "orig")))
2746 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2748 ;; Stores and loads of ax to arbitrary constant address.
2749 ;; We fake an second form of instruction to force reload to load address
2750 ;; into register when rax is not available
2751 (define_insn "*movabsdi_1_rex64"
2752 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2753 (match_operand:DI 1 "nonmemory_operand" "a,er"))]
2754 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2756 movabs{q}\t{%1, %P0|%P0, %1}
2757 mov{q}\t{%1, %a0|%a0, %1}"
2758 [(set_attr "type" "imov")
2759 (set_attr "modrm" "0,*")
2760 (set_attr "length_address" "8,0")
2761 (set_attr "length_immediate" "0,*")
2762 (set_attr "memory" "store")
2763 (set_attr "mode" "DI")])
2765 (define_insn "*movabsdi_2_rex64"
2766 [(set (match_operand:DI 0 "register_operand" "=a,r")
2767 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2768 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2770 movabs{q}\t{%P1, %0|%0, %P1}
2771 mov{q}\t{%a1, %0|%0, %a1}"
2772 [(set_attr "type" "imov")
2773 (set_attr "modrm" "0,*")
2774 (set_attr "length_address" "8,0")
2775 (set_attr "length_immediate" "0")
2776 (set_attr "memory" "load")
2777 (set_attr "mode" "DI")])
2779 ;; Convert impossible stores of immediate to existing instructions.
2780 ;; First try to get scratch register and go through it. In case this
2781 ;; fails, move by 32bit parts.
2783 [(match_scratch:DI 2 "r")
2784 (set (match_operand:DI 0 "memory_operand" "")
2785 (match_operand:DI 1 "immediate_operand" ""))]
2786 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2787 && !x86_64_immediate_operand (operands[1], DImode)"
2788 [(set (match_dup 2) (match_dup 1))
2789 (set (match_dup 0) (match_dup 2))]
2792 ;; We need to define this as both peepholer and splitter for case
2793 ;; peephole2 pass is not run.
2794 ;; "&& 1" is needed to keep it from matching the previous pattern.
2796 [(set (match_operand:DI 0 "memory_operand" "")
2797 (match_operand:DI 1 "immediate_operand" ""))]
2798 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2799 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2800 [(set (match_dup 2) (match_dup 3))
2801 (set (match_dup 4) (match_dup 5))]
2802 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2805 [(set (match_operand:DI 0 "memory_operand" "")
2806 (match_operand:DI 1 "immediate_operand" ""))]
2807 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2808 ? epilogue_completed : reload_completed)
2809 && !symbolic_operand (operands[1], DImode)
2810 && !x86_64_immediate_operand (operands[1], DImode)"
2811 [(set (match_dup 2) (match_dup 3))
2812 (set (match_dup 4) (match_dup 5))]
2813 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2815 (define_insn "*swapdi_rex64"
2816 [(set (match_operand:DI 0 "register_operand" "+r")
2817 (match_operand:DI 1 "register_operand" "+r"))
2822 [(set_attr "type" "imov")
2823 (set_attr "mode" "DI")
2824 (set_attr "pent_pair" "np")
2825 (set_attr "athlon_decode" "vector")
2826 (set_attr "amdfam10_decode" "double")])
2828 (define_expand "movoi"
2829 [(set (match_operand:OI 0 "nonimmediate_operand" "")
2830 (match_operand:OI 1 "general_operand" ""))]
2832 "ix86_expand_move (OImode, operands); DONE;")
2834 (define_insn "*movoi_internal"
2835 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
2836 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
2838 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2840 switch (which_alternative)
2843 return "vxorps\t%0, %0, %0";
2846 if (misaligned_operand (operands[0], OImode)
2847 || misaligned_operand (operands[1], OImode))
2848 return "vmovdqu\t{%1, %0|%0, %1}";
2850 return "vmovdqa\t{%1, %0|%0, %1}";
2855 [(set_attr "type" "sselog1,ssemov,ssemov")
2856 (set_attr "prefix" "vex")
2857 (set_attr "mode" "OI")])
2859 (define_expand "movti"
2860 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2861 (match_operand:TI 1 "nonimmediate_operand" ""))]
2862 "TARGET_SSE || TARGET_64BIT"
2865 ix86_expand_move (TImode, operands);
2866 else if (push_operand (operands[0], TImode))
2867 ix86_expand_push (TImode, operands[1]);
2869 ix86_expand_vector_move (TImode, operands);
2873 (define_insn "*movti_internal"
2874 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
2875 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
2876 "TARGET_SSE && !TARGET_64BIT
2877 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2879 switch (which_alternative)
2882 if (get_attr_mode (insn) == MODE_V4SF)
2883 return "%vxorps\t%0, %d0";
2885 return "%vpxor\t%0, %d0";
2888 /* TDmode values are passed as TImode on the stack. Moving them
2889 to stack may result in unaligned memory access. */
2890 if (misaligned_operand (operands[0], TImode)
2891 || misaligned_operand (operands[1], TImode))
2893 if (get_attr_mode (insn) == MODE_V4SF)
2894 return "%vmovups\t{%1, %0|%0, %1}";
2896 return "%vmovdqu\t{%1, %0|%0, %1}";
2900 if (get_attr_mode (insn) == MODE_V4SF)
2901 return "%vmovaps\t{%1, %0|%0, %1}";
2903 return "%vmovdqa\t{%1, %0|%0, %1}";
2909 [(set_attr "type" "sselog1,ssemov,ssemov")
2910 (set_attr "prefix" "maybe_vex")
2912 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2913 (ne (symbol_ref "optimize_function_for_size_p (cfun)") (const_int 0)))
2914 (const_string "V4SF")
2915 (and (eq_attr "alternative" "2")
2916 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2918 (const_string "V4SF")]
2919 (const_string "TI")))])
2921 (define_insn "*movti_rex64"
2922 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,xm")
2923 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
2925 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2927 switch (which_alternative)
2933 if (get_attr_mode (insn) == MODE_V4SF)
2934 return "%vxorps\t%0, %d0";
2936 return "%vpxor\t%0, %d0";
2939 /* TDmode values are passed as TImode on the stack. Moving them
2940 to stack may result in unaligned memory access. */
2941 if (misaligned_operand (operands[0], TImode)
2942 || misaligned_operand (operands[1], TImode))
2944 if (get_attr_mode (insn) == MODE_V4SF)
2945 return "%vmovups\t{%1, %0|%0, %1}";
2947 return "%vmovdqu\t{%1, %0|%0, %1}";
2951 if (get_attr_mode (insn) == MODE_V4SF)
2952 return "%vmovaps\t{%1, %0|%0, %1}";
2954 return "%vmovdqa\t{%1, %0|%0, %1}";
2960 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
2961 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
2963 (cond [(eq_attr "alternative" "2,3")
2965 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2967 (const_string "V4SF")
2968 (const_string "TI"))
2969 (eq_attr "alternative" "4")
2971 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2973 (ne (symbol_ref "optimize_function_for_size_p (cfun)")
2975 (const_string "V4SF")
2976 (const_string "TI"))]
2977 (const_string "DI")))])
2980 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2981 (match_operand:TI 1 "general_operand" ""))]
2982 "reload_completed && !SSE_REG_P (operands[0])
2983 && !SSE_REG_P (operands[1])"
2985 "ix86_split_long_move (operands); DONE;")
2987 ;; This expands to what emit_move_complex would generate if we didn't
2988 ;; have a movti pattern. Having this avoids problems with reload on
2989 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
2990 ;; to have around all the time.
2991 (define_expand "movcdi"
2992 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
2993 (match_operand:CDI 1 "general_operand" ""))]
2996 if (push_operand (operands[0], CDImode))
2997 emit_move_complex_push (CDImode, operands[0], operands[1]);
2999 emit_move_complex_parts (operands[0], operands[1]);
3003 (define_expand "movsf"
3004 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3005 (match_operand:SF 1 "general_operand" ""))]
3007 "ix86_expand_move (SFmode, operands); DONE;")
3009 (define_insn "*pushsf"
3010 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
3011 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
3014 /* Anything else should be already split before reg-stack. */
3015 gcc_assert (which_alternative == 1);
3016 return "push{l}\t%1";
3018 [(set_attr "type" "multi,push,multi")
3019 (set_attr "unit" "i387,*,*")
3020 (set_attr "mode" "SF,SI,SF")])
3022 (define_insn "*pushsf_rex64"
3023 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
3024 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
3027 /* Anything else should be already split before reg-stack. */
3028 gcc_assert (which_alternative == 1);
3029 return "push{q}\t%q1";
3031 [(set_attr "type" "multi,push,multi")
3032 (set_attr "unit" "i387,*,*")
3033 (set_attr "mode" "SF,DI,SF")])
3036 [(set (match_operand:SF 0 "push_operand" "")
3037 (match_operand:SF 1 "memory_operand" ""))]
3039 && MEM_P (operands[1])
3040 && (operands[2] = find_constant_src (insn))"
3044 ;; %%% Kill this when call knows how to work this out.
3046 [(set (match_operand:SF 0 "push_operand" "")
3047 (match_operand:SF 1 "any_fp_register_operand" ""))]
3049 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
3050 (set (mem:SF (reg:SI SP_REG)) (match_dup 1))])
3053 [(set (match_operand:SF 0 "push_operand" "")
3054 (match_operand:SF 1 "any_fp_register_operand" ""))]
3056 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
3057 (set (mem:SF (reg:DI SP_REG)) (match_dup 1))])
3059 (define_insn "*movsf_1"
3060 [(set (match_operand:SF 0 "nonimmediate_operand"
3061 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3062 (match_operand:SF 1 "general_operand"
3063 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
3064 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3065 && (reload_in_progress || reload_completed
3066 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3067 || (!TARGET_SSE_MATH && optimize_function_for_size_p (cfun)
3068 && standard_80387_constant_p (operands[1]))
3069 || GET_CODE (operands[1]) != CONST_DOUBLE
3070 || memory_operand (operands[0], SFmode))"
3072 switch (which_alternative)
3076 return output_387_reg_move (insn, operands);
3079 return standard_80387_constant_opcode (operands[1]);
3083 return "mov{l}\t{%1, %0|%0, %1}";
3085 if (get_attr_mode (insn) == MODE_TI)
3086 return "%vpxor\t%0, %d0";
3088 return "%vxorps\t%0, %d0";
3090 if (get_attr_mode (insn) == MODE_V4SF)
3091 return "%vmovaps\t{%1, %0|%0, %1}";
3093 return "%vmovss\t{%1, %d0|%d0, %1}";
3096 return REG_P (operands[1]) ? "vmovss\t{%1, %0, %0|%0, %0, %1}"
3097 : "vmovss\t{%1, %0|%0, %1}";
3099 return "movss\t{%1, %0|%0, %1}";
3101 return "%vmovss\t{%1, %0|%0, %1}";
3103 case 9: case 10: case 14: case 15:
3104 return "movd\t{%1, %0|%0, %1}";
3106 return "%vmovd\t{%1, %0|%0, %1}";
3109 return "movq\t{%1, %0|%0, %1}";
3115 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
3116 (set (attr "prefix")
3117 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3118 (const_string "maybe_vex")
3119 (const_string "orig")))
3121 (cond [(eq_attr "alternative" "3,4,9,10")
3123 (eq_attr "alternative" "5")
3125 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3127 (ne (symbol_ref "TARGET_SSE2")
3129 (eq (symbol_ref "optimize_function_for_size_p (cfun)")
3132 (const_string "V4SF"))
3133 /* For architectures resolving dependencies on
3134 whole SSE registers use APS move to break dependency
3135 chains, otherwise use short move to avoid extra work.
3137 Do the same for architectures resolving dependencies on
3138 the parts. While in DF mode it is better to always handle
3139 just register parts, the SF mode is different due to lack
3140 of instructions to load just part of the register. It is
3141 better to maintain the whole registers in single format
3142 to avoid problems on using packed logical operations. */
3143 (eq_attr "alternative" "6")
3145 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3147 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3149 (const_string "V4SF")
3150 (const_string "SF"))
3151 (eq_attr "alternative" "11")
3152 (const_string "DI")]
3153 (const_string "SF")))])
3155 (define_insn "*swapsf"
3156 [(set (match_operand:SF 0 "fp_register_operand" "+f")
3157 (match_operand:SF 1 "fp_register_operand" "+f"))
3160 "reload_completed || TARGET_80387"
3162 if (STACK_TOP_P (operands[0]))
3167 [(set_attr "type" "fxch")
3168 (set_attr "mode" "SF")])
3170 (define_expand "movdf"
3171 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3172 (match_operand:DF 1 "general_operand" ""))]
3174 "ix86_expand_move (DFmode, operands); DONE;")
3176 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3177 ;; Size of pushdf using integer instructions is 2+2*memory operand size
3178 ;; On the average, pushdf using integers can be still shorter. Allow this
3179 ;; pattern for optimize_size too.
3181 (define_insn "*pushdf_nointeger"
3182 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
3183 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
3184 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
3186 /* This insn should be already split before reg-stack. */
3189 [(set_attr "type" "multi")
3190 (set_attr "unit" "i387,*,*,*")
3191 (set_attr "mode" "DF,SI,SI,DF")])
3193 (define_insn "*pushdf_integer"
3194 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
3195 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
3196 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
3198 /* This insn should be already split before reg-stack. */
3201 [(set_attr "type" "multi")
3202 (set_attr "unit" "i387,*,*")
3203 (set_attr "mode" "DF,SI,DF")])
3205 ;; %%% Kill this when call knows how to work this out.
3207 [(set (match_operand:DF 0 "push_operand" "")
3208 (match_operand:DF 1 "any_fp_register_operand" ""))]
3210 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
3211 (set (mem:DF (reg:P SP_REG)) (match_dup 1))]
3215 [(set (match_operand:DF 0 "push_operand" "")
3216 (match_operand:DF 1 "general_operand" ""))]
3219 "ix86_split_long_move (operands); DONE;")
3221 ;; Moving is usually shorter when only FP registers are used. This separate
3222 ;; movdf pattern avoids the use of integer registers for FP operations
3223 ;; when optimizing for size.
3225 (define_insn "*movdf_nointeger"
3226 [(set (match_operand:DF 0 "nonimmediate_operand"
3227 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
3228 (match_operand:DF 1 "general_operand"
3229 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
3230 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3231 && ((optimize_function_for_size_p (cfun)
3232 || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
3233 && (reload_in_progress || reload_completed
3234 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3235 || (!(TARGET_SSE2 && TARGET_SSE_MATH)
3236 && optimize_function_for_size_p (cfun)
3237 && !memory_operand (operands[0], DFmode)
3238 && standard_80387_constant_p (operands[1]))
3239 || GET_CODE (operands[1]) != CONST_DOUBLE
3240 || ((optimize_function_for_size_p (cfun)
3241 || !TARGET_MEMORY_MISMATCH_STALL
3242 || reload_in_progress || reload_completed)
3243 && memory_operand (operands[0], DFmode)))"
3245 switch (which_alternative)
3249 return output_387_reg_move (insn, operands);
3252 return standard_80387_constant_opcode (operands[1]);
3258 switch (get_attr_mode (insn))
3261 return "%vxorps\t%0, %d0";
3263 return "%vxorpd\t%0, %d0";
3265 return "%vpxor\t%0, %d0";
3272 switch (get_attr_mode (insn))
3275 return "%vmovaps\t{%1, %0|%0, %1}";
3277 return "%vmovapd\t{%1, %0|%0, %1}";
3279 return "%vmovdqa\t{%1, %0|%0, %1}";
3281 return "%vmovq\t{%1, %0|%0, %1}";
3285 if (REG_P (operands[0]) && REG_P (operands[1]))
3286 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3288 return "vmovsd\t{%1, %0|%0, %1}";
3291 return "movsd\t{%1, %0|%0, %1}";
3295 if (REG_P (operands[0]))
3296 return "vmovlpd\t{%1, %0, %0|%0, %0, %1}";
3298 return "vmovlpd\t{%1, %0|%0, %1}";
3301 return "movlpd\t{%1, %0|%0, %1}";
3305 if (REG_P (operands[0]))
3306 return "vmovlps\t{%1, %0, %0|%0, %0, %1}";
3308 return "vmovlps\t{%1, %0|%0, %1}";
3311 return "movlps\t{%1, %0|%0, %1}";
3320 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3321 (set (attr "prefix")
3322 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3323 (const_string "orig")
3324 (const_string "maybe_vex")))
3325 (set (attr "prefix_data16")
3326 (if_then_else (eq_attr "mode" "V1DF")
3328 (const_string "*")))
3330 (cond [(eq_attr "alternative" "0,1,2")
3332 (eq_attr "alternative" "3,4")
3335 /* For SSE1, we have many fewer alternatives. */
3336 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3337 (cond [(eq_attr "alternative" "5,6")
3338 (const_string "V4SF")