1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 ;; Free Software Foundation, Inc.
5 ;; Mostly by William Schelter.
6 ;; x86_64 support added by Jan Hubicka
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>. */
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
29 ;; The special asm out single letter directives following a '%' are:
30 ;; L,W,B,Q,S,T -- print the opcode suffix for specified size of operand.
31 ;; C -- print opcode suffix for set/cmov insn.
32 ;; c -- like C, but print reversed condition
33 ;; F,f -- likewise, but for floating-point.
34 ;; O -- if HAVE_AS_IX86_CMOV_SUN_SYNTAX, expand to "w.", "l." or "q.",
36 ;; R -- print the prefix for register names.
37 ;; z -- print the opcode suffix for the size of the current operand.
38 ;; Z -- likewise, with special suffixes for x87 instructions.
39 ;; * -- print a star (in certain assembler syntax)
40 ;; A -- print an absolute memory reference.
41 ;; E -- print address with DImode register names if TARGET_64BIT.
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 ;; p -- print raw symbol name.
58 ;; X -- don't print any sort of PIC '@' suffix for a symbol.
59 ;; & -- print some in-use local-dynamic symbol name.
60 ;; H -- print a memory address offset by 8; used for sse high-parts
61 ;; Y -- print condition for XOP pcom* instruction.
62 ;; + -- print a branch hint as 'cs' or 'ds' prefix
63 ;; ; -- print a semicolon (after prefixes due to bug in older gas).
64 ;; @ -- print a segment register of thread base pointer load
66 (define_c_enum "unspec" [
67 ;; Relocation specifiers
78 UNSPEC_MACHOPIC_OFFSET
86 UNSPEC_MEMORY_BLOCKAGE
96 ;; Other random patterns
105 UNSPEC_LD_MPIC ; load_macho_picbase
107 UNSPEC_DIV_ALREADY_SPLIT
108 UNSPEC_MS_TO_SYSV_CALL
109 UNSPEC_CALL_NEEDS_VZEROUPPER
114 ;; For SSE/MMX support:
122 ;; Generic math support
124 UNSPEC_IEEE_MIN ; not commutative
125 UNSPEC_IEEE_MAX ; not commutative
127 ;; x87 Floating point
143 UNSPEC_FRNDINT_MASK_PM
147 ;; x87 Double output FP
182 (define_c_enum "unspecv" [
185 UNSPECV_PROBE_STACK_RANGE
188 UNSPECV_SPLIT_STACK_RETURN
194 UNSPECV_LLWP_INTRINSIC
195 UNSPECV_SLWP_INTRINSIC
196 UNSPECV_LWPVAL_INTRINSIC
197 UNSPECV_LWPINS_INTRINSIC
203 ;; For RDRAND support
210 ;; Constants to represent rounding modes in the ROUND instruction
219 ;; Constants to represent pcomtrue/pcomfalse variants
229 ;; Constants used in the XOP pperm instruction
231 [(PPERM_SRC 0x00) /* copy source */
232 (PPERM_INVERT 0x20) /* invert source */
233 (PPERM_REVERSE 0x40) /* bit reverse source */
234 (PPERM_REV_INV 0x60) /* bit reverse & invert src */
235 (PPERM_ZERO 0x80) /* all 0's */
236 (PPERM_ONES 0xa0) /* all 1's */
237 (PPERM_SIGN 0xc0) /* propagate sign bit */
238 (PPERM_INV_SIGN 0xe0) /* invert & propagate sign */
239 (PPERM_SRC1 0x00) /* use first source byte */
240 (PPERM_SRC2 0x10) /* use second source byte */
243 ;; Registers by name.
296 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
299 ;; In C guard expressions, put expressions which may be compile-time
300 ;; constants first. This allows for better optimization. For
301 ;; example, write "TARGET_64BIT && reload_completed", not
302 ;; "reload_completed && TARGET_64BIT".
306 (define_attr "cpu" "none,pentium,pentiumpro,geode,k6,athlon,k8,core2,corei7,
307 atom,generic64,amdfam10,bdver1,bdver2,btver1"
308 (const (symbol_ref "ix86_schedule")))
310 ;; A basic instruction type. Refinements due to arguments to be
311 ;; provided in other attributes.
314 alu,alu1,negnot,imov,imovx,lea,
315 incdec,ishift,ishiftx,ishift1,rotate,rotatex,rotate1,imul,imulx,idiv,
316 icmp,test,ibr,setcc,icmov,
317 push,pop,call,callv,leave,
319 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
320 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
321 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
322 ssemuladd,sse4arg,lwp,
323 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
324 (const_string "other"))
326 ;; Main data type used by the insn
328 "unknown,none,QI,HI,SI,DI,TI,OI,SF,DF,XF,TF,V8SF,V4DF,V4SF,V2DF,V2SF,V1DF"
329 (const_string "unknown"))
331 ;; The CPU unit operations uses.
332 (define_attr "unit" "integer,i387,sse,mmx,unknown"
333 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
334 (const_string "i387")
335 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseishft1,sseimul,
336 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
337 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
339 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
341 (eq_attr "type" "other")
342 (const_string "unknown")]
343 (const_string "integer")))
345 ;; The (bounding maximum) length of an instruction immediate.
346 (define_attr "length_immediate" ""
347 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
350 (eq_attr "unit" "i387,sse,mmx")
352 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,ishiftx,ishift1,
353 rotate,rotatex,rotate1,imul,icmp,push,pop")
354 (symbol_ref "ix86_attr_length_immediate_default (insn, true)")
355 (eq_attr "type" "imov,test")
356 (symbol_ref "ix86_attr_length_immediate_default (insn, false)")
357 (eq_attr "type" "call")
358 (if_then_else (match_operand 0 "constant_call_address_operand" "")
361 (eq_attr "type" "callv")
362 (if_then_else (match_operand 1 "constant_call_address_operand" "")
365 ;; We don't know the size before shorten_branches. Expect
366 ;; the instruction to fit for better scheduling.
367 (eq_attr "type" "ibr")
370 (symbol_ref "/* Update immediate_length and other attributes! */
371 gcc_unreachable (),1")))
373 ;; The (bounding maximum) length of an instruction address.
374 (define_attr "length_address" ""
375 (cond [(eq_attr "type" "str,other,multi,fxch")
377 (and (eq_attr "type" "call")
378 (match_operand 0 "constant_call_address_operand" ""))
380 (and (eq_attr "type" "callv")
381 (match_operand 1 "constant_call_address_operand" ""))
384 (symbol_ref "ix86_attr_length_address_default (insn)")))
386 ;; Set when length prefix is used.
387 (define_attr "prefix_data16" ""
388 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
390 (eq_attr "mode" "HI")
392 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF,TI"))
397 ;; Set when string REP prefix is used.
398 (define_attr "prefix_rep" ""
399 (cond [(eq_attr "type" "ssemuladd,sse4arg,sseiadd1,ssecvt1")
401 (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
406 ;; Set when 0f opcode prefix is used.
407 (define_attr "prefix_0f" ""
409 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
410 (eq_attr "unit" "sse,mmx"))
414 ;; Set when REX opcode prefix is used.
415 (define_attr "prefix_rex" ""
416 (cond [(not (match_test "TARGET_64BIT"))
418 (and (eq_attr "mode" "DI")
419 (and (eq_attr "type" "!push,pop,call,callv,leave,ibr")
420 (eq_attr "unit" "!mmx")))
422 (and (eq_attr "mode" "QI")
423 (match_test "x86_extended_QIreg_mentioned_p (insn)"))
425 (match_test "x86_extended_reg_mentioned_p (insn)")
427 (and (eq_attr "type" "imovx")
428 (match_operand:QI 1 "ext_QIreg_operand" ""))
433 ;; There are also additional prefixes in 3DNOW, SSSE3.
434 ;; ssemuladd,sse4arg default to 0f24/0f25 and DREX byte,
435 ;; sseiadd1,ssecvt1 to 0f7a with no DREX byte.
436 ;; 3DNOW has 0f0f prefix, SSSE3 and SSE4_{1,2} 0f38/0f3a.
437 (define_attr "prefix_extra" ""
438 (cond [(eq_attr "type" "ssemuladd,sse4arg")
440 (eq_attr "type" "sseiadd1,ssecvt1")
445 ;; Prefix used: original, VEX or maybe VEX.
446 (define_attr "prefix" "orig,vex,maybe_vex"
447 (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
449 (const_string "orig")))
451 ;; VEX W bit is used.
452 (define_attr "prefix_vex_w" "" (const_int 0))
454 ;; The length of VEX prefix
455 ;; Only instructions with 0f prefix can have 2 byte VEX prefix,
456 ;; 0f38/0f3a prefixes can't. In i386.md 0f3[8a] is
457 ;; still prefix_0f 1, with prefix_extra 1.
458 (define_attr "length_vex" ""
459 (if_then_else (and (eq_attr "prefix_0f" "1")
460 (eq_attr "prefix_extra" "0"))
461 (if_then_else (eq_attr "prefix_vex_w" "1")
462 (symbol_ref "ix86_attr_length_vex_default (insn, true, true)")
463 (symbol_ref "ix86_attr_length_vex_default (insn, true, false)"))
464 (if_then_else (eq_attr "prefix_vex_w" "1")
465 (symbol_ref "ix86_attr_length_vex_default (insn, false, true)")
466 (symbol_ref "ix86_attr_length_vex_default (insn, false, false)"))))
468 ;; Set when modrm byte is used.
469 (define_attr "modrm" ""
470 (cond [(eq_attr "type" "str,leave")
472 (eq_attr "unit" "i387")
474 (and (eq_attr "type" "incdec")
475 (and (not (match_test "TARGET_64BIT"))
476 (ior (match_operand:SI 1 "register_operand" "")
477 (match_operand:HI 1 "register_operand" ""))))
479 (and (eq_attr "type" "push")
480 (not (match_operand 1 "memory_operand" "")))
482 (and (eq_attr "type" "pop")
483 (not (match_operand 0 "memory_operand" "")))
485 (and (eq_attr "type" "imov")
486 (and (not (eq_attr "mode" "DI"))
487 (ior (and (match_operand 0 "register_operand" "")
488 (match_operand 1 "immediate_operand" ""))
489 (ior (and (match_operand 0 "ax_reg_operand" "")
490 (match_operand 1 "memory_displacement_only_operand" ""))
491 (and (match_operand 0 "memory_displacement_only_operand" "")
492 (match_operand 1 "ax_reg_operand" ""))))))
494 (and (eq_attr "type" "call")
495 (match_operand 0 "constant_call_address_operand" ""))
497 (and (eq_attr "type" "callv")
498 (match_operand 1 "constant_call_address_operand" ""))
500 (and (eq_attr "type" "alu,alu1,icmp,test")
501 (match_operand 0 "ax_reg_operand" ""))
502 (symbol_ref "(get_attr_length_immediate (insn) <= (get_attr_mode (insn) != MODE_QI))")
506 ;; The (bounding maximum) length of an instruction in bytes.
507 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
508 ;; Later we may want to split them and compute proper length as for
510 (define_attr "length" ""
511 (cond [(eq_attr "type" "other,multi,fistp,frndint")
513 (eq_attr "type" "fcmp")
515 (eq_attr "unit" "i387")
517 (plus (attr "prefix_data16")
518 (attr "length_address")))
519 (ior (eq_attr "prefix" "vex")
520 (and (eq_attr "prefix" "maybe_vex")
521 (match_test "TARGET_AVX")))
522 (plus (attr "length_vex")
523 (plus (attr "length_immediate")
525 (attr "length_address"))))]
526 (plus (plus (attr "modrm")
527 (plus (attr "prefix_0f")
528 (plus (attr "prefix_rex")
529 (plus (attr "prefix_extra")
531 (plus (attr "prefix_rep")
532 (plus (attr "prefix_data16")
533 (plus (attr "length_immediate")
534 (attr "length_address")))))))
536 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
537 ;; `store' if there is a simple memory reference therein, or `unknown'
538 ;; if the instruction is complex.
540 (define_attr "memory" "none,load,store,both,unknown"
541 (cond [(eq_attr "type" "other,multi,str,lwp")
542 (const_string "unknown")
543 (eq_attr "type" "lea,fcmov,fpspc")
544 (const_string "none")
545 (eq_attr "type" "fistp,leave")
546 (const_string "both")
547 (eq_attr "type" "frndint")
548 (const_string "load")
549 (eq_attr "type" "push")
550 (if_then_else (match_operand 1 "memory_operand" "")
551 (const_string "both")
552 (const_string "store"))
553 (eq_attr "type" "pop")
554 (if_then_else (match_operand 0 "memory_operand" "")
555 (const_string "both")
556 (const_string "load"))
557 (eq_attr "type" "setcc")
558 (if_then_else (match_operand 0 "memory_operand" "")
559 (const_string "store")
560 (const_string "none"))
561 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
562 (if_then_else (ior (match_operand 0 "memory_operand" "")
563 (match_operand 1 "memory_operand" ""))
564 (const_string "load")
565 (const_string "none"))
566 (eq_attr "type" "ibr")
567 (if_then_else (match_operand 0 "memory_operand" "")
568 (const_string "load")
569 (const_string "none"))
570 (eq_attr "type" "call")
571 (if_then_else (match_operand 0 "constant_call_address_operand" "")
572 (const_string "none")
573 (const_string "load"))
574 (eq_attr "type" "callv")
575 (if_then_else (match_operand 1 "constant_call_address_operand" "")
576 (const_string "none")
577 (const_string "load"))
578 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
579 (match_operand 1 "memory_operand" ""))
580 (const_string "both")
581 (and (match_operand 0 "memory_operand" "")
582 (match_operand 1 "memory_operand" ""))
583 (const_string "both")
584 (match_operand 0 "memory_operand" "")
585 (const_string "store")
586 (match_operand 1 "memory_operand" "")
587 (const_string "load")
589 "!alu1,negnot,ishift1,
590 imov,imovx,icmp,test,bitmanip,
592 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
593 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
594 (match_operand 2 "memory_operand" ""))
595 (const_string "load")
596 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
597 (match_operand 3 "memory_operand" ""))
598 (const_string "load")
600 (const_string "none")))
602 ;; Indicates if an instruction has both an immediate and a displacement.
604 (define_attr "imm_disp" "false,true,unknown"
605 (cond [(eq_attr "type" "other,multi")
606 (const_string "unknown")
607 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
608 (and (match_operand 0 "memory_displacement_operand" "")
609 (match_operand 1 "immediate_operand" "")))
610 (const_string "true")
611 (and (eq_attr "type" "alu,ishift,ishiftx,rotate,rotatex,imul,idiv")
612 (and (match_operand 0 "memory_displacement_operand" "")
613 (match_operand 2 "immediate_operand" "")))
614 (const_string "true")
616 (const_string "false")))
618 ;; Indicates if an FP operation has an integer source.
620 (define_attr "fp_int_src" "false,true"
621 (const_string "false"))
623 ;; Defines rounding mode of an FP operation.
625 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
626 (const_string "any"))
628 ;; Define attribute to classify add/sub insns that consumes carry flag (CF)
629 (define_attr "use_carry" "0,1" (const_string "0"))
631 ;; Define attribute to indicate unaligned ssemov insns
632 (define_attr "movu" "0,1" (const_string "0"))
634 ;; Used to control the "enabled" attribute on a per-instruction basis.
635 (define_attr "isa" "base,sse2,sse2_noavx,sse3,sse4,sse4_noavx,noavx,avx,
637 (const_string "base"))
639 (define_attr "enabled" ""
640 (cond [(eq_attr "isa" "sse2") (symbol_ref "TARGET_SSE2")
641 (eq_attr "isa" "sse2_noavx")
642 (symbol_ref "TARGET_SSE2 && !TARGET_AVX")
643 (eq_attr "isa" "sse3") (symbol_ref "TARGET_SSE3")
644 (eq_attr "isa" "sse4") (symbol_ref "TARGET_SSE4_1")
645 (eq_attr "isa" "sse4_noavx")
646 (symbol_ref "TARGET_SSE4_1 && !TARGET_AVX")
647 (eq_attr "isa" "avx") (symbol_ref "TARGET_AVX")
648 (eq_attr "isa" "noavx") (symbol_ref "!TARGET_AVX")
649 (eq_attr "isa" "bmi2") (symbol_ref "TARGET_BMI2")
650 (eq_attr "isa" "fma4") (symbol_ref "TARGET_FMA4")
651 (eq_attr "isa" "fma") (symbol_ref "TARGET_FMA")
655 ;; Describe a user's asm statement.
656 (define_asm_attributes
657 [(set_attr "length" "128")
658 (set_attr "type" "multi")])
660 (define_code_iterator plusminus [plus minus])
662 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
664 ;; Base name for define_insn
665 (define_code_attr plusminus_insn
666 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
667 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
669 ;; Base name for insn mnemonic.
670 (define_code_attr plusminus_mnemonic
671 [(plus "add") (ss_plus "adds") (us_plus "addus")
672 (minus "sub") (ss_minus "subs") (us_minus "subus")])
673 (define_code_attr plusminus_carry_mnemonic
674 [(plus "adc") (minus "sbb")])
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 max and min
681 (define_code_iterator maxmin [smax smin umax umin])
683 ;; Mapping of signed max and min
684 (define_code_iterator smaxmin [smax smin])
686 ;; Mapping of unsigned max and min
687 (define_code_iterator umaxmin [umax umin])
689 ;; Base name for integer and FP insn mnemonic
690 (define_code_attr maxmin_int [(smax "maxs") (smin "mins")
691 (umax "maxu") (umin "minu")])
692 (define_code_attr maxmin_float [(smax "max") (smin "min")])
694 ;; Mapping of logic operators
695 (define_code_iterator any_logic [and ior xor])
696 (define_code_iterator any_or [ior xor])
698 ;; Base name for insn mnemonic.
699 (define_code_attr logic [(and "and") (ior "or") (xor "xor")])
701 ;; Mapping of logic-shift operators
702 (define_code_iterator any_lshift [ashift lshiftrt])
704 ;; Mapping of shift-right operators
705 (define_code_iterator any_shiftrt [lshiftrt ashiftrt])
707 ;; Base name for define_insn
708 (define_code_attr shift_insn
709 [(ashift "ashl") (lshiftrt "lshr") (ashiftrt "ashr")])
711 ;; Base name for insn mnemonic.
712 (define_code_attr shift [(ashift "sll") (lshiftrt "shr") (ashiftrt "sar")])
713 (define_code_attr vshift [(ashift "sll") (lshiftrt "srl") (ashiftrt "sra")])
715 ;; Mapping of rotate operators
716 (define_code_iterator any_rotate [rotate rotatert])
718 ;; Base name for define_insn
719 (define_code_attr rotate_insn [(rotate "rotl") (rotatert "rotr")])
721 ;; Base name for insn mnemonic.
722 (define_code_attr rotate [(rotate "rol") (rotatert "ror")])
724 ;; Mapping of abs neg operators
725 (define_code_iterator absneg [abs neg])
727 ;; Base name for x87 insn mnemonic.
728 (define_code_attr absneg_mnemonic [(abs "abs") (neg "chs")])
730 ;; Used in signed and unsigned widening multiplications.
731 (define_code_iterator any_extend [sign_extend zero_extend])
733 ;; Prefix for insn menmonic.
734 (define_code_attr sgnprefix [(sign_extend "i") (zero_extend "")])
736 ;; Prefix for define_insn
737 (define_code_attr u [(sign_extend "") (zero_extend "u")])
738 (define_code_attr s [(sign_extend "s") (zero_extend "u")])
740 ;; All integer modes.
741 (define_mode_iterator SWI1248x [QI HI SI DI])
743 ;; All integer modes without QImode.
744 (define_mode_iterator SWI248x [HI SI DI])
746 ;; All integer modes without QImode and HImode.
747 (define_mode_iterator SWI48x [SI DI])
749 ;; All integer modes without SImode and DImode.
750 (define_mode_iterator SWI12 [QI HI])
752 ;; All integer modes without DImode.
753 (define_mode_iterator SWI124 [QI HI SI])
755 ;; All integer modes without QImode and DImode.
756 (define_mode_iterator SWI24 [HI SI])
758 ;; Single word integer modes.
759 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
761 ;; Single word integer modes without QImode.
762 (define_mode_iterator SWI248 [HI SI (DI "TARGET_64BIT")])
764 ;; Single word integer modes without QImode and HImode.
765 (define_mode_iterator SWI48 [SI (DI "TARGET_64BIT")])
767 ;; All math-dependant single and double word integer modes.
768 (define_mode_iterator SDWIM [(QI "TARGET_QIMODE_MATH")
769 (HI "TARGET_HIMODE_MATH")
770 SI DI (TI "TARGET_64BIT")])
772 ;; Math-dependant single word integer modes.
773 (define_mode_iterator SWIM [(QI "TARGET_QIMODE_MATH")
774 (HI "TARGET_HIMODE_MATH")
775 SI (DI "TARGET_64BIT")])
777 ;; Math-dependant integer modes without DImode.
778 (define_mode_iterator SWIM124 [(QI "TARGET_QIMODE_MATH")
779 (HI "TARGET_HIMODE_MATH")
782 ;; Math-dependant single word integer modes without QImode.
783 (define_mode_iterator SWIM248 [(HI "TARGET_HIMODE_MATH")
784 SI (DI "TARGET_64BIT")])
786 ;; Double word integer modes.
787 (define_mode_iterator DWI [(DI "!TARGET_64BIT")
788 (TI "TARGET_64BIT")])
790 ;; Double word integer modes as mode attribute.
791 (define_mode_attr DWI [(SI "DI") (DI "TI")])
792 (define_mode_attr dwi [(SI "di") (DI "ti")])
794 ;; Half mode for double word integer modes.
795 (define_mode_iterator DWIH [(SI "!TARGET_64BIT")
796 (DI "TARGET_64BIT")])
798 ;; Instruction suffix for integer modes.
799 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
801 ;; Pointer size prefix for integer modes (Intel asm dialect)
802 (define_mode_attr iptrsize [(QI "BYTE")
807 ;; Register class for integer modes.
808 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
810 ;; Immediate operand constraint for integer modes.
811 (define_mode_attr i [(QI "n") (HI "n") (SI "e") (DI "e")])
813 ;; General operand constraint for word modes.
814 (define_mode_attr g [(QI "qmn") (HI "rmn") (SI "rme") (DI "rme")])
816 ;; Immediate operand constraint for double integer modes.
817 (define_mode_attr di [(SI "nF") (DI "e")])
819 ;; Immediate operand constraint for shifts.
820 (define_mode_attr S [(QI "I") (HI "I") (SI "I") (DI "J") (TI "O")])
822 ;; General operand predicate for integer modes.
823 (define_mode_attr general_operand
824 [(QI "general_operand")
825 (HI "general_operand")
826 (SI "x86_64_general_operand")
827 (DI "x86_64_general_operand")
828 (TI "x86_64_general_operand")])
830 ;; General sign/zero extend operand predicate for integer modes.
831 (define_mode_attr general_szext_operand
832 [(QI "general_operand")
833 (HI "general_operand")
834 (SI "x86_64_szext_general_operand")
835 (DI "x86_64_szext_general_operand")])
837 ;; Immediate operand predicate for integer modes.
838 (define_mode_attr immediate_operand
839 [(QI "immediate_operand")
840 (HI "immediate_operand")
841 (SI "x86_64_immediate_operand")
842 (DI "x86_64_immediate_operand")])
844 ;; Nonmemory operand predicate for integer modes.
845 (define_mode_attr nonmemory_operand
846 [(QI "nonmemory_operand")
847 (HI "nonmemory_operand")
848 (SI "x86_64_nonmemory_operand")
849 (DI "x86_64_nonmemory_operand")])
851 ;; Operand predicate for shifts.
852 (define_mode_attr shift_operand
853 [(QI "nonimmediate_operand")
854 (HI "nonimmediate_operand")
855 (SI "nonimmediate_operand")
856 (DI "shiftdi_operand")
857 (TI "register_operand")])
859 ;; Operand predicate for shift argument.
860 (define_mode_attr shift_immediate_operand
861 [(QI "const_1_to_31_operand")
862 (HI "const_1_to_31_operand")
863 (SI "const_1_to_31_operand")
864 (DI "const_1_to_63_operand")])
866 ;; Input operand predicate for arithmetic left shifts.
867 (define_mode_attr ashl_input_operand
868 [(QI "nonimmediate_operand")
869 (HI "nonimmediate_operand")
870 (SI "nonimmediate_operand")
871 (DI "ashldi_input_operand")
872 (TI "reg_or_pm1_operand")])
874 ;; SSE and x87 SFmode and DFmode floating point modes
875 (define_mode_iterator MODEF [SF DF])
877 ;; All x87 floating point modes
878 (define_mode_iterator X87MODEF [SF DF XF])
880 ;; SSE instruction suffix for various modes
881 (define_mode_attr ssemodesuffix
883 (V8SF "ps") (V4DF "pd")
884 (V4SF "ps") (V2DF "pd")
885 (V16QI "b") (V8HI "w") (V4SI "d") (V2DI "q")
886 (V32QI "b") (V16HI "w") (V8SI "d") (V4DI "q")])
888 ;; SSE vector suffix for floating point modes
889 (define_mode_attr ssevecmodesuffix [(SF "ps") (DF "pd")])
891 ;; SSE vector mode corresponding to a scalar mode
892 (define_mode_attr ssevecmode
893 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
895 ;; Instruction suffix for REX 64bit operators.
896 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
898 ;; This mode iterator allows :P to be used for patterns that operate on
899 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
900 (define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
902 ;; This mode iterator allows :PTR to be used for patterns that operate on
903 ;; ptr_mode sized quantities.
904 (define_mode_iterator PTR
905 [(SI "ptr_mode == SImode") (DI "ptr_mode == DImode")])
907 ;; Scheduling descriptions
909 (include "pentium.md")
912 (include "athlon.md")
913 (include "bdver1.md")
919 ;; Operand and operator predicates and constraints
921 (include "predicates.md")
922 (include "constraints.md")
925 ;; Compare and branch/compare and store instructions.
927 (define_expand "cbranch<mode>4"
928 [(set (reg:CC FLAGS_REG)
929 (compare:CC (match_operand:SDWIM 1 "nonimmediate_operand" "")
930 (match_operand:SDWIM 2 "<general_operand>" "")))
931 (set (pc) (if_then_else
932 (match_operator 0 "ordered_comparison_operator"
933 [(reg:CC FLAGS_REG) (const_int 0)])
934 (label_ref (match_operand 3 "" ""))
938 if (MEM_P (operands[1]) && MEM_P (operands[2]))
939 operands[1] = force_reg (<MODE>mode, operands[1]);
940 ix86_expand_branch (GET_CODE (operands[0]),
941 operands[1], operands[2], operands[3]);
945 (define_expand "cstore<mode>4"
946 [(set (reg:CC FLAGS_REG)
947 (compare:CC (match_operand:SWIM 2 "nonimmediate_operand" "")
948 (match_operand:SWIM 3 "<general_operand>" "")))
949 (set (match_operand:QI 0 "register_operand" "")
950 (match_operator 1 "ordered_comparison_operator"
951 [(reg:CC FLAGS_REG) (const_int 0)]))]
954 if (MEM_P (operands[2]) && MEM_P (operands[3]))
955 operands[2] = force_reg (<MODE>mode, operands[2]);
956 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
957 operands[2], operands[3]);
961 (define_expand "cmp<mode>_1"
962 [(set (reg:CC FLAGS_REG)
963 (compare:CC (match_operand:SWI48 0 "nonimmediate_operand" "")
964 (match_operand:SWI48 1 "<general_operand>" "")))])
966 (define_insn "*cmp<mode>_ccno_1"
967 [(set (reg FLAGS_REG)
968 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>,?m<r>")
969 (match_operand:SWI 1 "const0_operand" "")))]
970 "ix86_match_ccmode (insn, CCNOmode)"
972 test{<imodesuffix>}\t%0, %0
973 cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
974 [(set_attr "type" "test,icmp")
975 (set_attr "length_immediate" "0,1")
976 (set_attr "mode" "<MODE>")])
978 (define_insn "*cmp<mode>_1"
979 [(set (reg FLAGS_REG)
980 (compare (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
981 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m")))]
982 "ix86_match_ccmode (insn, CCmode)"
983 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
984 [(set_attr "type" "icmp")
985 (set_attr "mode" "<MODE>")])
987 (define_insn "*cmp<mode>_minus_1"
988 [(set (reg FLAGS_REG)
990 (minus:SWI (match_operand:SWI 0 "nonimmediate_operand" "<r>m,<r>")
991 (match_operand:SWI 1 "<general_operand>" "<r><i>,<r>m"))
993 "ix86_match_ccmode (insn, CCGOCmode)"
994 "cmp{<imodesuffix>}\t{%1, %0|%0, %1}"
995 [(set_attr "type" "icmp")
996 (set_attr "mode" "<MODE>")])
998 (define_insn "*cmpqi_ext_1"
999 [(set (reg FLAGS_REG)
1001 (match_operand:QI 0 "general_operand" "Qm")
1004 (match_operand 1 "ext_register_operand" "Q")
1006 (const_int 8)) 0)))]
1007 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1008 "cmp{b}\t{%h1, %0|%0, %h1}"
1009 [(set_attr "type" "icmp")
1010 (set_attr "mode" "QI")])
1012 (define_insn "*cmpqi_ext_1_rex64"
1013 [(set (reg FLAGS_REG)
1015 (match_operand:QI 0 "register_operand" "Q")
1018 (match_operand 1 "ext_register_operand" "Q")
1020 (const_int 8)) 0)))]
1021 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1022 "cmp{b}\t{%h1, %0|%0, %h1}"
1023 [(set_attr "type" "icmp")
1024 (set_attr "mode" "QI")])
1026 (define_insn "*cmpqi_ext_2"
1027 [(set (reg FLAGS_REG)
1031 (match_operand 0 "ext_register_operand" "Q")
1034 (match_operand:QI 1 "const0_operand" "")))]
1035 "ix86_match_ccmode (insn, CCNOmode)"
1037 [(set_attr "type" "test")
1038 (set_attr "length_immediate" "0")
1039 (set_attr "mode" "QI")])
1041 (define_expand "cmpqi_ext_3"
1042 [(set (reg:CC FLAGS_REG)
1046 (match_operand 0 "ext_register_operand" "")
1049 (match_operand:QI 1 "immediate_operand" "")))])
1051 (define_insn "*cmpqi_ext_3_insn"
1052 [(set (reg FLAGS_REG)
1056 (match_operand 0 "ext_register_operand" "Q")
1059 (match_operand:QI 1 "general_operand" "Qmn")))]
1060 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1061 "cmp{b}\t{%1, %h0|%h0, %1}"
1062 [(set_attr "type" "icmp")
1063 (set_attr "modrm" "1")
1064 (set_attr "mode" "QI")])
1066 (define_insn "*cmpqi_ext_3_insn_rex64"
1067 [(set (reg FLAGS_REG)
1071 (match_operand 0 "ext_register_operand" "Q")
1074 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
1075 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
1076 "cmp{b}\t{%1, %h0|%h0, %1}"
1077 [(set_attr "type" "icmp")
1078 (set_attr "modrm" "1")
1079 (set_attr "mode" "QI")])
1081 (define_insn "*cmpqi_ext_4"
1082 [(set (reg FLAGS_REG)
1086 (match_operand 0 "ext_register_operand" "Q")
1091 (match_operand 1 "ext_register_operand" "Q")
1093 (const_int 8)) 0)))]
1094 "ix86_match_ccmode (insn, CCmode)"
1095 "cmp{b}\t{%h1, %h0|%h0, %h1}"
1096 [(set_attr "type" "icmp")
1097 (set_attr "mode" "QI")])
1099 ;; These implement float point compares.
1100 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
1101 ;; which would allow mix and match FP modes on the compares. Which is what
1102 ;; the old patterns did, but with many more of them.
1104 (define_expand "cbranchxf4"
1105 [(set (reg:CC FLAGS_REG)
1106 (compare:CC (match_operand:XF 1 "nonmemory_operand" "")
1107 (match_operand:XF 2 "nonmemory_operand" "")))
1108 (set (pc) (if_then_else
1109 (match_operator 0 "ix86_fp_comparison_operator"
1112 (label_ref (match_operand 3 "" ""))
1116 ix86_expand_branch (GET_CODE (operands[0]),
1117 operands[1], operands[2], operands[3]);
1121 (define_expand "cstorexf4"
1122 [(set (reg:CC FLAGS_REG)
1123 (compare:CC (match_operand:XF 2 "nonmemory_operand" "")
1124 (match_operand:XF 3 "nonmemory_operand" "")))
1125 (set (match_operand:QI 0 "register_operand" "")
1126 (match_operator 1 "ix86_fp_comparison_operator"
1131 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1132 operands[2], operands[3]);
1136 (define_expand "cbranch<mode>4"
1137 [(set (reg:CC FLAGS_REG)
1138 (compare:CC (match_operand:MODEF 1 "cmp_fp_expander_operand" "")
1139 (match_operand:MODEF 2 "cmp_fp_expander_operand" "")))
1140 (set (pc) (if_then_else
1141 (match_operator 0 "ix86_fp_comparison_operator"
1144 (label_ref (match_operand 3 "" ""))
1146 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1148 ix86_expand_branch (GET_CODE (operands[0]),
1149 operands[1], operands[2], operands[3]);
1153 (define_expand "cstore<mode>4"
1154 [(set (reg:CC FLAGS_REG)
1155 (compare:CC (match_operand:MODEF 2 "cmp_fp_expander_operand" "")
1156 (match_operand:MODEF 3 "cmp_fp_expander_operand" "")))
1157 (set (match_operand:QI 0 "register_operand" "")
1158 (match_operator 1 "ix86_fp_comparison_operator"
1161 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
1163 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1164 operands[2], operands[3]);
1168 (define_expand "cbranchcc4"
1169 [(set (pc) (if_then_else
1170 (match_operator 0 "comparison_operator"
1171 [(match_operand 1 "flags_reg_operand" "")
1172 (match_operand 2 "const0_operand" "")])
1173 (label_ref (match_operand 3 "" ""))
1177 ix86_expand_branch (GET_CODE (operands[0]),
1178 operands[1], operands[2], operands[3]);
1182 (define_expand "cstorecc4"
1183 [(set (match_operand:QI 0 "register_operand" "")
1184 (match_operator 1 "comparison_operator"
1185 [(match_operand 2 "flags_reg_operand" "")
1186 (match_operand 3 "const0_operand" "")]))]
1189 ix86_expand_setcc (operands[0], GET_CODE (operands[1]),
1190 operands[2], operands[3]);
1195 ;; FP compares, step 1:
1196 ;; Set the FP condition codes.
1198 ;; CCFPmode compare with exceptions
1199 ;; CCFPUmode compare with no exceptions
1201 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
1202 ;; used to manage the reg stack popping would not be preserved.
1204 (define_insn "*cmpfp_0"
1205 [(set (match_operand:HI 0 "register_operand" "=a")
1208 (match_operand 1 "register_operand" "f")
1209 (match_operand 2 "const0_operand" ""))]
1211 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1212 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1213 "* return output_fp_compare (insn, operands, false, false);"
1214 [(set_attr "type" "multi")
1215 (set_attr "unit" "i387")
1217 (cond [(match_operand:SF 1 "" "")
1219 (match_operand:DF 1 "" "")
1222 (const_string "XF")))])
1224 (define_insn_and_split "*cmpfp_0_cc"
1225 [(set (reg:CCFP FLAGS_REG)
1227 (match_operand 1 "register_operand" "f")
1228 (match_operand 2 "const0_operand" "")))
1229 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1230 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1231 && TARGET_SAHF && !TARGET_CMOVE
1232 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1234 "&& reload_completed"
1237 [(compare:CCFP (match_dup 1)(match_dup 2))]
1239 (set (reg:CC FLAGS_REG)
1240 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1242 [(set_attr "type" "multi")
1243 (set_attr "unit" "i387")
1245 (cond [(match_operand:SF 1 "" "")
1247 (match_operand:DF 1 "" "")
1250 (const_string "XF")))])
1252 (define_insn "*cmpfp_xf"
1253 [(set (match_operand:HI 0 "register_operand" "=a")
1256 (match_operand:XF 1 "register_operand" "f")
1257 (match_operand:XF 2 "register_operand" "f"))]
1260 "* return output_fp_compare (insn, operands, false, false);"
1261 [(set_attr "type" "multi")
1262 (set_attr "unit" "i387")
1263 (set_attr "mode" "XF")])
1265 (define_insn_and_split "*cmpfp_xf_cc"
1266 [(set (reg:CCFP FLAGS_REG)
1268 (match_operand:XF 1 "register_operand" "f")
1269 (match_operand:XF 2 "register_operand" "f")))
1270 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1272 && TARGET_SAHF && !TARGET_CMOVE"
1274 "&& reload_completed"
1277 [(compare:CCFP (match_dup 1)(match_dup 2))]
1279 (set (reg:CC FLAGS_REG)
1280 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1282 [(set_attr "type" "multi")
1283 (set_attr "unit" "i387")
1284 (set_attr "mode" "XF")])
1286 (define_insn "*cmpfp_<mode>"
1287 [(set (match_operand:HI 0 "register_operand" "=a")
1290 (match_operand:MODEF 1 "register_operand" "f")
1291 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1294 "* return output_fp_compare (insn, operands, false, false);"
1295 [(set_attr "type" "multi")
1296 (set_attr "unit" "i387")
1297 (set_attr "mode" "<MODE>")])
1299 (define_insn_and_split "*cmpfp_<mode>_cc"
1300 [(set (reg:CCFP FLAGS_REG)
1302 (match_operand:MODEF 1 "register_operand" "f")
1303 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1304 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1306 && TARGET_SAHF && !TARGET_CMOVE"
1308 "&& reload_completed"
1311 [(compare:CCFP (match_dup 1)(match_dup 2))]
1313 (set (reg:CC FLAGS_REG)
1314 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1316 [(set_attr "type" "multi")
1317 (set_attr "unit" "i387")
1318 (set_attr "mode" "<MODE>")])
1320 (define_insn "*cmpfp_u"
1321 [(set (match_operand:HI 0 "register_operand" "=a")
1324 (match_operand 1 "register_operand" "f")
1325 (match_operand 2 "register_operand" "f"))]
1327 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1328 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1329 "* return output_fp_compare (insn, operands, false, true);"
1330 [(set_attr "type" "multi")
1331 (set_attr "unit" "i387")
1333 (cond [(match_operand:SF 1 "" "")
1335 (match_operand:DF 1 "" "")
1338 (const_string "XF")))])
1340 (define_insn_and_split "*cmpfp_u_cc"
1341 [(set (reg:CCFPU FLAGS_REG)
1343 (match_operand 1 "register_operand" "f")
1344 (match_operand 2 "register_operand" "f")))
1345 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1346 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1347 && TARGET_SAHF && !TARGET_CMOVE
1348 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1350 "&& reload_completed"
1353 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1355 (set (reg:CC FLAGS_REG)
1356 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1358 [(set_attr "type" "multi")
1359 (set_attr "unit" "i387")
1361 (cond [(match_operand:SF 1 "" "")
1363 (match_operand:DF 1 "" "")
1366 (const_string "XF")))])
1368 (define_insn "*cmpfp_<mode>"
1369 [(set (match_operand:HI 0 "register_operand" "=a")
1372 (match_operand 1 "register_operand" "f")
1373 (match_operator 3 "float_operator"
1374 [(match_operand:SWI24 2 "memory_operand" "m")]))]
1376 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1377 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1378 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1379 "* return output_fp_compare (insn, operands, false, false);"
1380 [(set_attr "type" "multi")
1381 (set_attr "unit" "i387")
1382 (set_attr "fp_int_src" "true")
1383 (set_attr "mode" "<MODE>")])
1385 (define_insn_and_split "*cmpfp_<mode>_cc"
1386 [(set (reg:CCFP FLAGS_REG)
1388 (match_operand 1 "register_operand" "f")
1389 (match_operator 3 "float_operator"
1390 [(match_operand:SWI24 2 "memory_operand" "m")])))
1391 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1392 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1393 && TARGET_SAHF && !TARGET_CMOVE
1394 && (TARGET_USE_<MODE>MODE_FIOP || optimize_function_for_size_p (cfun))
1395 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1397 "&& reload_completed"
1402 (match_op_dup 3 [(match_dup 2)]))]
1404 (set (reg:CC FLAGS_REG)
1405 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1407 [(set_attr "type" "multi")
1408 (set_attr "unit" "i387")
1409 (set_attr "fp_int_src" "true")
1410 (set_attr "mode" "<MODE>")])
1412 ;; FP compares, step 2
1413 ;; Move the fpsw to ax.
1415 (define_insn "x86_fnstsw_1"
1416 [(set (match_operand:HI 0 "register_operand" "=a")
1417 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1420 [(set (attr "length")
1421 (symbol_ref "ix86_attr_length_address_default (insn) + 2"))
1422 (set_attr "mode" "SI")
1423 (set_attr "unit" "i387")])
1425 ;; FP compares, step 3
1426 ;; Get ax into flags, general case.
1428 (define_insn "x86_sahf_1"
1429 [(set (reg:CC FLAGS_REG)
1430 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1434 #ifndef HAVE_AS_IX86_SAHF
1436 return ASM_BYTE "0x9e";
1441 [(set_attr "length" "1")
1442 (set_attr "athlon_decode" "vector")
1443 (set_attr "amdfam10_decode" "direct")
1444 (set_attr "bdver1_decode" "direct")
1445 (set_attr "mode" "SI")])
1447 ;; Pentium Pro can do steps 1 through 3 in one go.
1448 ;; comi*, ucomi*, fcomi*, ficomi*, fucomi*
1449 ;; (these i387 instructions set flags directly)
1450 (define_insn "*cmpfp_i_mixed"
1451 [(set (reg:CCFP FLAGS_REG)
1452 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1453 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1454 "TARGET_MIX_SSE_I387
1455 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1456 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1457 "* return output_fp_compare (insn, operands, true, false);"
1458 [(set_attr "type" "fcmp,ssecomi")
1459 (set_attr "prefix" "orig,maybe_vex")
1461 (if_then_else (match_operand:SF 1 "" "")
1463 (const_string "DF")))
1464 (set (attr "prefix_rep")
1465 (if_then_else (eq_attr "type" "ssecomi")
1467 (const_string "*")))
1468 (set (attr "prefix_data16")
1469 (cond [(eq_attr "type" "fcmp")
1471 (eq_attr "mode" "DF")
1474 (const_string "0")))
1475 (set_attr "athlon_decode" "vector")
1476 (set_attr "amdfam10_decode" "direct")
1477 (set_attr "bdver1_decode" "double")])
1479 (define_insn "*cmpfp_i_sse"
1480 [(set (reg:CCFP FLAGS_REG)
1481 (compare:CCFP (match_operand 0 "register_operand" "x")
1482 (match_operand 1 "nonimmediate_operand" "xm")))]
1484 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1485 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1486 "* return output_fp_compare (insn, operands, true, false);"
1487 [(set_attr "type" "ssecomi")
1488 (set_attr "prefix" "maybe_vex")
1490 (if_then_else (match_operand:SF 1 "" "")
1492 (const_string "DF")))
1493 (set_attr "prefix_rep" "0")
1494 (set (attr "prefix_data16")
1495 (if_then_else (eq_attr "mode" "DF")
1497 (const_string "0")))
1498 (set_attr "athlon_decode" "vector")
1499 (set_attr "amdfam10_decode" "direct")
1500 (set_attr "bdver1_decode" "double")])
1502 (define_insn "*cmpfp_i_i387"
1503 [(set (reg:CCFP FLAGS_REG)
1504 (compare:CCFP (match_operand 0 "register_operand" "f")
1505 (match_operand 1 "register_operand" "f")))]
1506 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1508 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1509 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1510 "* return output_fp_compare (insn, operands, true, false);"
1511 [(set_attr "type" "fcmp")
1513 (cond [(match_operand:SF 1 "" "")
1515 (match_operand:DF 1 "" "")
1518 (const_string "XF")))
1519 (set_attr "athlon_decode" "vector")
1520 (set_attr "amdfam10_decode" "direct")
1521 (set_attr "bdver1_decode" "double")])
1523 (define_insn "*cmpfp_iu_mixed"
1524 [(set (reg:CCFPU FLAGS_REG)
1525 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1526 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1527 "TARGET_MIX_SSE_I387
1528 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1529 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1530 "* return output_fp_compare (insn, operands, true, true);"
1531 [(set_attr "type" "fcmp,ssecomi")
1532 (set_attr "prefix" "orig,maybe_vex")
1534 (if_then_else (match_operand:SF 1 "" "")
1536 (const_string "DF")))
1537 (set (attr "prefix_rep")
1538 (if_then_else (eq_attr "type" "ssecomi")
1540 (const_string "*")))
1541 (set (attr "prefix_data16")
1542 (cond [(eq_attr "type" "fcmp")
1544 (eq_attr "mode" "DF")
1547 (const_string "0")))
1548 (set_attr "athlon_decode" "vector")
1549 (set_attr "amdfam10_decode" "direct")
1550 (set_attr "bdver1_decode" "double")])
1552 (define_insn "*cmpfp_iu_sse"
1553 [(set (reg:CCFPU FLAGS_REG)
1554 (compare:CCFPU (match_operand 0 "register_operand" "x")
1555 (match_operand 1 "nonimmediate_operand" "xm")))]
1557 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1558 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1559 "* return output_fp_compare (insn, operands, true, true);"
1560 [(set_attr "type" "ssecomi")
1561 (set_attr "prefix" "maybe_vex")
1563 (if_then_else (match_operand:SF 1 "" "")
1565 (const_string "DF")))
1566 (set_attr "prefix_rep" "0")
1567 (set (attr "prefix_data16")
1568 (if_then_else (eq_attr "mode" "DF")
1570 (const_string "0")))
1571 (set_attr "athlon_decode" "vector")
1572 (set_attr "amdfam10_decode" "direct")
1573 (set_attr "bdver1_decode" "double")])
1575 (define_insn "*cmpfp_iu_387"
1576 [(set (reg:CCFPU FLAGS_REG)
1577 (compare:CCFPU (match_operand 0 "register_operand" "f")
1578 (match_operand 1 "register_operand" "f")))]
1579 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1581 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1582 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1583 "* return output_fp_compare (insn, operands, true, true);"
1584 [(set_attr "type" "fcmp")
1586 (cond [(match_operand:SF 1 "" "")
1588 (match_operand:DF 1 "" "")
1591 (const_string "XF")))
1592 (set_attr "athlon_decode" "vector")
1593 (set_attr "amdfam10_decode" "direct")
1594 (set_attr "bdver1_decode" "direct")])
1596 ;; Push/pop instructions.
1598 (define_insn "*push<mode>2"
1599 [(set (match_operand:DWI 0 "push_operand" "=<")
1600 (match_operand:DWI 1 "general_no_elim_operand" "riF*o"))]
1603 [(set_attr "type" "multi")
1604 (set_attr "mode" "<MODE>")])
1607 [(set (match_operand:TI 0 "push_operand" "")
1608 (match_operand:TI 1 "general_operand" ""))]
1609 "TARGET_64BIT && reload_completed
1610 && !SSE_REG_P (operands[1])"
1612 "ix86_split_long_move (operands); DONE;")
1614 (define_insn "*pushdi2_rex64"
1615 [(set (match_operand:DI 0 "push_operand" "=<,!<")
1616 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
1621 [(set_attr "type" "push,multi")
1622 (set_attr "mode" "DI")])
1624 ;; Convert impossible pushes of immediate to existing instructions.
1625 ;; First try to get scratch register and go through it. In case this
1626 ;; fails, push sign extended lower part first and then overwrite
1627 ;; upper part by 32bit move.
1629 [(match_scratch:DI 2 "r")
1630 (set (match_operand:DI 0 "push_operand" "")
1631 (match_operand:DI 1 "immediate_operand" ""))]
1632 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1633 && !x86_64_immediate_operand (operands[1], DImode)"
1634 [(set (match_dup 2) (match_dup 1))
1635 (set (match_dup 0) (match_dup 2))])
1637 ;; We need to define this as both peepholer and splitter for case
1638 ;; peephole2 pass is not run.
1639 ;; "&& 1" is needed to keep it from matching the previous pattern.
1641 [(set (match_operand:DI 0 "push_operand" "")
1642 (match_operand:DI 1 "immediate_operand" ""))]
1643 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
1644 && !x86_64_immediate_operand (operands[1], DImode) && 1"
1645 [(set (match_dup 0) (match_dup 1))
1646 (set (match_dup 2) (match_dup 3))]
1648 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1650 operands[1] = gen_lowpart (DImode, operands[2]);
1651 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (Pmode, stack_pointer_rtx,
1656 [(set (match_operand:DI 0 "push_operand" "")
1657 (match_operand:DI 1 "immediate_operand" ""))]
1658 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
1659 ? epilogue_completed : reload_completed)
1660 && !symbolic_operand (operands[1], DImode)
1661 && !x86_64_immediate_operand (operands[1], DImode)"
1662 [(set (match_dup 0) (match_dup 1))
1663 (set (match_dup 2) (match_dup 3))]
1665 split_double_mode (DImode, &operands[1], 1, &operands[2], &operands[3]);
1667 operands[1] = gen_lowpart (DImode, operands[2]);
1668 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (Pmode, stack_pointer_rtx,
1673 [(set (match_operand:DI 0 "push_operand" "")
1674 (match_operand:DI 1 "general_operand" ""))]
1675 "!TARGET_64BIT && reload_completed
1676 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
1678 "ix86_split_long_move (operands); DONE;")
1680 (define_insn "*pushsi2"
1681 [(set (match_operand:SI 0 "push_operand" "=<")
1682 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1685 [(set_attr "type" "push")
1686 (set_attr "mode" "SI")])
1688 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1689 ;; "push a byte/word". But actually we use pushl, which has the effect
1690 ;; of rounding the amount pushed up to a word.
1692 ;; For TARGET_64BIT we always round up to 8 bytes.
1693 (define_insn "*push<mode>2_rex64"
1694 [(set (match_operand:SWI124 0 "push_operand" "=X")
1695 (match_operand:SWI124 1 "nonmemory_no_elim_operand" "r<i>"))]
1698 [(set_attr "type" "push")
1699 (set_attr "mode" "DI")])
1701 (define_insn "*push<mode>2"
1702 [(set (match_operand:SWI12 0 "push_operand" "=X")
1703 (match_operand:SWI12 1 "nonmemory_no_elim_operand" "rn"))]
1706 [(set_attr "type" "push")
1707 (set_attr "mode" "SI")])
1709 (define_insn "*push<mode>2_prologue"
1710 [(set (match_operand:P 0 "push_operand" "=<")
1711 (match_operand:P 1 "general_no_elim_operand" "r<i>*m"))
1712 (clobber (mem:BLK (scratch)))]
1714 "push{<imodesuffix>}\t%1"
1715 [(set_attr "type" "push")
1716 (set_attr "mode" "<MODE>")])
1718 (define_insn "*pop<mode>1"
1719 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1720 (match_operand:P 1 "pop_operand" ">"))]
1722 "pop{<imodesuffix>}\t%0"
1723 [(set_attr "type" "pop")
1724 (set_attr "mode" "<MODE>")])
1726 (define_insn "*pop<mode>1_epilogue"
1727 [(set (match_operand:P 0 "nonimmediate_operand" "=r*m")
1728 (match_operand:P 1 "pop_operand" ">"))
1729 (clobber (mem:BLK (scratch)))]
1731 "pop{<imodesuffix>}\t%0"
1732 [(set_attr "type" "pop")
1733 (set_attr "mode" "<MODE>")])
1735 ;; Move instructions.
1737 (define_expand "movoi"
1738 [(set (match_operand:OI 0 "nonimmediate_operand" "")
1739 (match_operand:OI 1 "general_operand" ""))]
1741 "ix86_expand_move (OImode, operands); DONE;")
1743 (define_expand "movti"
1744 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1745 (match_operand:TI 1 "nonimmediate_operand" ""))]
1746 "TARGET_64BIT || TARGET_SSE"
1749 ix86_expand_move (TImode, operands);
1750 else if (push_operand (operands[0], TImode))
1751 ix86_expand_push (TImode, operands[1]);
1753 ix86_expand_vector_move (TImode, operands);
1757 ;; This expands to what emit_move_complex would generate if we didn't
1758 ;; have a movti pattern. Having this avoids problems with reload on
1759 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
1760 ;; to have around all the time.
1761 (define_expand "movcdi"
1762 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
1763 (match_operand:CDI 1 "general_operand" ""))]
1766 if (push_operand (operands[0], CDImode))
1767 emit_move_complex_push (CDImode, operands[0], operands[1]);
1769 emit_move_complex_parts (operands[0], operands[1]);
1773 (define_expand "mov<mode>"
1774 [(set (match_operand:SWI1248x 0 "nonimmediate_operand" "")
1775 (match_operand:SWI1248x 1 "general_operand" ""))]
1777 "ix86_expand_move (<MODE>mode, operands); DONE;")
1779 (define_insn "*mov<mode>_xor"
1780 [(set (match_operand:SWI48 0 "register_operand" "=r")
1781 (match_operand:SWI48 1 "const0_operand" ""))
1782 (clobber (reg:CC FLAGS_REG))]
1785 [(set_attr "type" "alu1")
1786 (set_attr "mode" "SI")
1787 (set_attr "length_immediate" "0")])
1789 (define_insn "*mov<mode>_or"
1790 [(set (match_operand:SWI48 0 "register_operand" "=r")
1791 (match_operand:SWI48 1 "const_int_operand" ""))
1792 (clobber (reg:CC FLAGS_REG))]
1794 && operands[1] == constm1_rtx"
1795 "or{<imodesuffix>}\t{%1, %0|%0, %1}"
1796 [(set_attr "type" "alu1")
1797 (set_attr "mode" "<MODE>")
1798 (set_attr "length_immediate" "1")])
1800 (define_insn "*movoi_internal_avx"
1801 [(set (match_operand:OI 0 "nonimmediate_operand" "=x,x,m")
1802 (match_operand:OI 1 "vector_move_operand" "C,xm,x"))]
1803 "TARGET_AVX && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1805 switch (which_alternative)
1808 return standard_sse_constant_opcode (insn, operands[1]);
1811 if (misaligned_operand (operands[0], OImode)
1812 || misaligned_operand (operands[1], OImode))
1813 return "vmovdqu\t{%1, %0|%0, %1}";
1815 return "vmovdqa\t{%1, %0|%0, %1}";
1820 [(set_attr "type" "sselog1,ssemov,ssemov")
1821 (set_attr "prefix" "vex")
1822 (set_attr "mode" "OI")])
1824 (define_insn "*movti_internal_rex64"
1825 [(set (match_operand:TI 0 "nonimmediate_operand" "=!r,o,x,x,m")
1826 (match_operand:TI 1 "general_operand" "riFo,re,C,xm,x"))]
1827 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1829 switch (which_alternative)
1835 return standard_sse_constant_opcode (insn, operands[1]);
1838 /* TDmode values are passed as TImode on the stack. Moving them
1839 to stack may result in unaligned memory access. */
1840 if (misaligned_operand (operands[0], TImode)
1841 || misaligned_operand (operands[1], TImode))
1843 if (get_attr_mode (insn) == MODE_V4SF)
1844 return "%vmovups\t{%1, %0|%0, %1}";
1846 return "%vmovdqu\t{%1, %0|%0, %1}";
1850 if (get_attr_mode (insn) == MODE_V4SF)
1851 return "%vmovaps\t{%1, %0|%0, %1}";
1853 return "%vmovdqa\t{%1, %0|%0, %1}";
1859 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
1860 (set_attr "prefix" "*,*,maybe_vex,maybe_vex,maybe_vex")
1862 (cond [(eq_attr "alternative" "0,1")
1864 (ior (not (match_test "TARGET_SSE2"))
1865 (match_test "optimize_function_for_size_p (cfun)"))
1866 (const_string "V4SF")
1867 (and (eq_attr "alternative" "4")
1868 (match_test "TARGET_SSE_TYPELESS_STORES"))
1869 (const_string "V4SF")
1871 (const_string "TI")))])
1874 [(set (match_operand:TI 0 "nonimmediate_operand" "")
1875 (match_operand:TI 1 "general_operand" ""))]
1877 && !SSE_REG_P (operands[0]) && !SSE_REG_P (operands[1])"
1879 "ix86_split_long_move (operands); DONE;")
1881 (define_insn "*movti_internal_sse"
1882 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
1883 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
1884 "TARGET_SSE && !TARGET_64BIT
1885 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1887 switch (which_alternative)
1890 return standard_sse_constant_opcode (insn, operands[1]);
1893 /* TDmode values are passed as TImode on the stack. Moving them
1894 to stack may result in unaligned memory access. */
1895 if (misaligned_operand (operands[0], TImode)
1896 || misaligned_operand (operands[1], TImode))
1898 if (get_attr_mode (insn) == MODE_V4SF)
1899 return "%vmovups\t{%1, %0|%0, %1}";
1901 return "%vmovdqu\t{%1, %0|%0, %1}";
1905 if (get_attr_mode (insn) == MODE_V4SF)
1906 return "%vmovaps\t{%1, %0|%0, %1}";
1908 return "%vmovdqa\t{%1, %0|%0, %1}";
1914 [(set_attr "type" "sselog1,ssemov,ssemov")
1915 (set_attr "prefix" "maybe_vex")
1917 (cond [(ior (not (match_test "TARGET_SSE2"))
1918 (match_test "optimize_function_for_size_p (cfun)"))
1919 (const_string "V4SF")
1920 (and (eq_attr "alternative" "2")
1921 (match_test "TARGET_SSE_TYPELESS_STORES"))
1922 (const_string "V4SF")]
1923 (const_string "TI")))])
1925 (define_insn "*movdi_internal_rex64"
1926 [(set (match_operand:DI 0 "nonimmediate_operand"
1927 "=r,r ,r,m ,*y,m*y,?*y,?r ,?*Ym,*x,m ,*x,*x,?r ,?*Yi,?*x,?*Ym")
1928 (match_operand:DI 1 "general_operand"
1929 "Z ,rem,i,re,C ,*y ,m ,*Ym,r ,C ,*x,*x,m ,*Yi,r ,*Ym,*x"))]
1930 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1932 switch (get_attr_type (insn))
1935 if (SSE_REG_P (operands[0]))
1936 return "movq2dq\t{%1, %0|%0, %1}";
1938 return "movdq2q\t{%1, %0|%0, %1}";
1941 if (get_attr_mode (insn) == MODE_TI)
1942 return "%vmovdqa\t{%1, %0|%0, %1}";
1943 /* Handle broken assemblers that require movd instead of movq. */
1944 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
1945 return "%vmovd\t{%1, %0|%0, %1}";
1947 return "%vmovq\t{%1, %0|%0, %1}";
1950 /* Handle broken assemblers that require movd instead of movq. */
1951 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
1952 return "movd\t{%1, %0|%0, %1}";
1954 return "movq\t{%1, %0|%0, %1}";
1957 return standard_sse_constant_opcode (insn, operands[1]);
1960 return "pxor\t%0, %0";
1963 return "lea{q}\t{%E1, %0|%0, %E1}";
1966 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1967 if (get_attr_mode (insn) == MODE_SI)
1968 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1969 else if (which_alternative == 2)
1970 return "movabs{q}\t{%1, %0|%0, %1}";
1971 else if (ix86_use_lea_for_mov (insn, operands))
1972 return "lea{q}\t{%E1, %0|%0, %E1}";
1974 return "mov{q}\t{%1, %0|%0, %1}";
1978 (cond [(eq_attr "alternative" "4")
1979 (const_string "mmx")
1980 (eq_attr "alternative" "5,6,7,8")
1981 (const_string "mmxmov")
1982 (eq_attr "alternative" "9")
1983 (const_string "sselog1")
1984 (eq_attr "alternative" "10,11,12,13,14")
1985 (const_string "ssemov")
1986 (eq_attr "alternative" "15,16")
1987 (const_string "ssecvt")
1988 (match_operand 1 "pic_32bit_operand" "")
1989 (const_string "lea")
1991 (const_string "imov")))
1994 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
1996 (const_string "*")))
1997 (set (attr "length_immediate")
1999 (and (eq_attr "alternative" "2") (eq_attr "type" "imov"))
2001 (const_string "*")))
2002 (set (attr "prefix_rex")
2003 (if_then_else (eq_attr "alternative" "7,8")
2005 (const_string "*")))
2006 (set (attr "prefix_data16")
2007 (if_then_else (eq_attr "alternative" "10")
2009 (const_string "*")))
2010 (set (attr "prefix")
2011 (if_then_else (eq_attr "alternative" "11,12,13,14,15")
2012 (const_string "maybe_vex")
2013 (const_string "orig")))
2014 (set_attr "mode" "SI,DI,DI,DI,DI,DI,DI,DI,DI,TI,DI,TI,DI,DI,DI,DI,DI")])
2016 ;; Reload patterns to support multi-word load/store
2017 ;; with non-offsetable address.
2018 (define_expand "reload_noff_store"
2019 [(parallel [(match_operand 0 "memory_operand" "=m")
2020 (match_operand 1 "register_operand" "r")
2021 (match_operand:DI 2 "register_operand" "=&r")])]
2024 rtx mem = operands[0];
2025 rtx addr = XEXP (mem, 0);
2027 emit_move_insn (operands[2], addr);
2028 mem = replace_equiv_address_nv (mem, operands[2]);
2030 emit_insn (gen_rtx_SET (VOIDmode, mem, operands[1]));
2034 (define_expand "reload_noff_load"
2035 [(parallel [(match_operand 0 "register_operand" "=r")
2036 (match_operand 1 "memory_operand" "m")
2037 (match_operand:DI 2 "register_operand" "=r")])]
2040 rtx mem = operands[1];
2041 rtx addr = XEXP (mem, 0);
2043 emit_move_insn (operands[2], addr);
2044 mem = replace_equiv_address_nv (mem, operands[2]);
2046 emit_insn (gen_rtx_SET (VOIDmode, operands[0], mem));
2050 (define_insn "*movdi_internal"
2051 [(set (match_operand:DI 0 "nonimmediate_operand"
2052 "=r ,o ,*y,m*y,*y,*x,m ,*x,*x,*x,m ,*x,*x,?*x,?*Ym")
2053 (match_operand:DI 1 "general_operand"
2054 "riFo,riF,C ,*y ,m ,C ,*x,*x,m ,C ,*x,*x,m ,*Ym,*x"))]
2055 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2057 switch (get_attr_type (insn))
2060 if (SSE_REG_P (operands[0]))
2061 return "movq2dq\t{%1, %0|%0, %1}";
2063 return "movdq2q\t{%1, %0|%0, %1}";
2066 switch (get_attr_mode (insn))
2069 return "%vmovdqa\t{%1, %0|%0, %1}";
2071 return "%vmovq\t{%1, %0|%0, %1}";
2073 return "movaps\t{%1, %0|%0, %1}";
2075 return "movlps\t{%1, %0|%0, %1}";
2081 return "movq\t{%1, %0|%0, %1}";
2084 return standard_sse_constant_opcode (insn, operands[1]);
2087 return "pxor\t%0, %0";
2097 (cond [(eq_attr "alternative" "5,6,7,8,13,14")
2098 (const_string "sse2")
2099 (eq_attr "alternative" "9,10,11,12")
2100 (const_string "noavx")
2102 (const_string "*")))
2104 (cond [(eq_attr "alternative" "0,1")
2105 (const_string "multi")
2106 (eq_attr "alternative" "2")
2107 (const_string "mmx")
2108 (eq_attr "alternative" "3,4")
2109 (const_string "mmxmov")
2110 (eq_attr "alternative" "5,9")
2111 (const_string "sselog1")
2112 (eq_attr "alternative" "13,14")
2113 (const_string "ssecvt")
2115 (const_string "ssemov")))
2116 (set (attr "prefix")
2117 (if_then_else (eq_attr "alternative" "5,6,7,8")
2118 (const_string "maybe_vex")
2119 (const_string "orig")))
2120 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF,DI,DI")])
2123 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2124 (match_operand:DI 1 "general_operand" ""))]
2125 "!TARGET_64BIT && reload_completed
2126 && !(MMX_REG_P (operands[0]) || SSE_REG_P (operands[0]))
2127 && !(MMX_REG_P (operands[1]) || SSE_REG_P (operands[1]))"
2129 "ix86_split_long_move (operands); DONE;")
2131 (define_insn "*movsi_internal"
2132 [(set (match_operand:SI 0 "nonimmediate_operand"
2133 "=r,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
2134 (match_operand:SI 1 "general_operand"
2135 "g ,re,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
2136 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2138 switch (get_attr_type (insn))
2141 return standard_sse_constant_opcode (insn, operands[1]);
2144 switch (get_attr_mode (insn))
2147 return "%vmovdqa\t{%1, %0|%0, %1}";
2149 return "%vmovaps\t{%1, %0|%0, %1}";
2151 return "%vmovd\t{%1, %0|%0, %1}";
2153 return "%vmovss\t{%1, %0|%0, %1}";
2159 return "pxor\t%0, %0";
2162 if (get_attr_mode (insn) == MODE_DI)
2163 return "movq\t{%1, %0|%0, %1}";
2164 return "movd\t{%1, %0|%0, %1}";
2167 return "lea{l}\t{%E1, %0|%0, %E1}";
2170 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2171 if (ix86_use_lea_for_mov (insn, operands))
2172 return "lea{l}\t{%E1, %0|%0, %E1}";
2174 return "mov{l}\t{%1, %0|%0, %1}";
2178 (cond [(eq_attr "alternative" "2")
2179 (const_string "mmx")
2180 (eq_attr "alternative" "3,4,5")
2181 (const_string "mmxmov")
2182 (eq_attr "alternative" "6")
2183 (const_string "sselog1")
2184 (eq_attr "alternative" "7,8,9,10,11")
2185 (const_string "ssemov")
2186 (match_operand 1 "pic_32bit_operand" "")
2187 (const_string "lea")
2189 (const_string "imov")))
2190 (set (attr "prefix")
2191 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5")
2192 (const_string "orig")
2193 (const_string "maybe_vex")))
2194 (set (attr "prefix_data16")
2195 (if_then_else (and (eq_attr "type" "ssemov") (eq_attr "mode" "SI"))
2197 (const_string "*")))
2199 (cond [(eq_attr "alternative" "2,3")
2201 (eq_attr "alternative" "6,7")
2203 (not (match_test "TARGET_SSE2"))
2204 (const_string "V4SF")
2205 (const_string "TI"))
2206 (and (eq_attr "alternative" "8,9,10,11")
2207 (not (match_test "TARGET_SSE2")))
2210 (const_string "SI")))])
2212 (define_insn "*movhi_internal"
2213 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
2214 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
2215 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2217 switch (get_attr_type (insn))
2220 /* movzwl is faster than movw on p2 due to partial word stalls,
2221 though not as fast as an aligned movl. */
2222 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
2224 if (get_attr_mode (insn) == MODE_SI)
2225 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2227 return "mov{w}\t{%1, %0|%0, %1}";
2231 (cond [(match_test "optimize_function_for_size_p (cfun)")
2232 (const_string "imov")
2233 (and (eq_attr "alternative" "0")
2234 (ior (not (match_test "TARGET_PARTIAL_REG_STALL"))
2235 (not (match_test "TARGET_HIMODE_MATH"))))
2236 (const_string "imov")
2237 (and (eq_attr "alternative" "1,2")
2238 (match_operand:HI 1 "aligned_operand" ""))
2239 (const_string "imov")
2240 (and (match_test "TARGET_MOVX")
2241 (eq_attr "alternative" "0,2"))
2242 (const_string "imovx")
2244 (const_string "imov")))
2246 (cond [(eq_attr "type" "imovx")
2248 (and (eq_attr "alternative" "1,2")
2249 (match_operand:HI 1 "aligned_operand" ""))
2251 (and (eq_attr "alternative" "0")
2252 (ior (not (match_test "TARGET_PARTIAL_REG_STALL"))
2253 (not (match_test "TARGET_HIMODE_MATH"))))
2256 (const_string "HI")))])
2258 ;; Situation is quite tricky about when to choose full sized (SImode) move
2259 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
2260 ;; partial register dependency machines (such as AMD Athlon), where QImode
2261 ;; moves issue extra dependency and for partial register stalls machines
2262 ;; that don't use QImode patterns (and QImode move cause stall on the next
2265 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
2266 ;; register stall machines with, where we use QImode instructions, since
2267 ;; partial register stall can be caused there. Then we use movzx.
2268 (define_insn "*movqi_internal"
2269 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
2270 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
2271 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
2273 switch (get_attr_type (insn))
2276 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
2277 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
2279 if (get_attr_mode (insn) == MODE_SI)
2280 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2282 return "mov{b}\t{%1, %0|%0, %1}";
2286 (cond [(and (eq_attr "alternative" "5")
2287 (not (match_operand:QI 1 "aligned_operand" "")))
2288 (const_string "imovx")
2289 (match_test "optimize_function_for_size_p (cfun)")
2290 (const_string "imov")
2291 (and (eq_attr "alternative" "3")
2292 (ior (not (match_test "TARGET_PARTIAL_REG_STALL"))
2293 (not (match_test "TARGET_QIMODE_MATH"))))
2294 (const_string "imov")
2295 (eq_attr "alternative" "3,5")
2296 (const_string "imovx")
2297 (and (match_test "TARGET_MOVX")
2298 (eq_attr "alternative" "2"))
2299 (const_string "imovx")
2301 (const_string "imov")))
2303 (cond [(eq_attr "alternative" "3,4,5")
2305 (eq_attr "alternative" "6")
2307 (eq_attr "type" "imovx")
2309 (and (eq_attr "type" "imov")
2310 (and (eq_attr "alternative" "0,1")
2311 (and (match_test "TARGET_PARTIAL_REG_DEPENDENCY")
2312 (and (not (match_test "optimize_function_for_size_p (cfun)"))
2313 (not (match_test "TARGET_PARTIAL_REG_STALL"))))))
2315 ;; Avoid partial register stalls when not using QImode arithmetic
2316 (and (eq_attr "type" "imov")
2317 (and (eq_attr "alternative" "0,1")
2318 (and (match_test "TARGET_PARTIAL_REG_STALL")
2319 (not (match_test "TARGET_QIMODE_MATH")))))
2322 (const_string "QI")))])
2324 ;; Stores and loads of ax to arbitrary constant address.
2325 ;; We fake an second form of instruction to force reload to load address
2326 ;; into register when rax is not available
2327 (define_insn "*movabs<mode>_1"
2328 [(set (mem:SWI1248x (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2329 (match_operand:SWI1248x 1 "nonmemory_operand" "a,r<i>"))]
2330 "TARGET_LP64 && ix86_check_movabs (insn, 0)"
2332 movabs{<imodesuffix>}\t{%1, %P0|[%P0], %1}
2333 mov{<imodesuffix>}\t{%1, %a0|<iptrsize> PTR %a0, %1}"
2334 [(set_attr "type" "imov")
2335 (set_attr "modrm" "0,*")
2336 (set_attr "length_address" "8,0")
2337 (set_attr "length_immediate" "0,*")
2338 (set_attr "memory" "store")
2339 (set_attr "mode" "<MODE>")])
2341 (define_insn "*movabs<mode>_2"
2342 [(set (match_operand:SWI1248x 0 "register_operand" "=a,r")
2343 (mem:SWI1248x (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2344 "TARGET_LP64 && ix86_check_movabs (insn, 1)"
2346 movabs{<imodesuffix>}\t{%P1, %0|%0, [%P1]}
2347 mov{<imodesuffix>}\t{%a1, %0|%0, <iptrsize> PTR %a1}"
2348 [(set_attr "type" "imov")
2349 (set_attr "modrm" "0,*")
2350 (set_attr "length_address" "8,0")
2351 (set_attr "length_immediate" "0")
2352 (set_attr "memory" "load")
2353 (set_attr "mode" "<MODE>")])
2355 (define_insn "*swap<mode>"
2356 [(set (match_operand:SWI48 0 "register_operand" "+r")
2357 (match_operand:SWI48 1 "register_operand" "+r"))
2361 "xchg{<imodesuffix>}\t%1, %0"
2362 [(set_attr "type" "imov")
2363 (set_attr "mode" "<MODE>")
2364 (set_attr "pent_pair" "np")
2365 (set_attr "athlon_decode" "vector")
2366 (set_attr "amdfam10_decode" "double")
2367 (set_attr "bdver1_decode" "double")])
2369 (define_insn "*swap<mode>_1"
2370 [(set (match_operand:SWI12 0 "register_operand" "+r")
2371 (match_operand:SWI12 1 "register_operand" "+r"))
2374 "!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun)"
2376 [(set_attr "type" "imov")
2377 (set_attr "mode" "SI")
2378 (set_attr "pent_pair" "np")
2379 (set_attr "athlon_decode" "vector")
2380 (set_attr "amdfam10_decode" "double")
2381 (set_attr "bdver1_decode" "double")])
2383 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL
2384 ;; is disabled for AMDFAM10
2385 (define_insn "*swap<mode>_2"
2386 [(set (match_operand:SWI12 0 "register_operand" "+<r>")
2387 (match_operand:SWI12 1 "register_operand" "+<r>"))
2390 "TARGET_PARTIAL_REG_STALL"
2391 "xchg{<imodesuffix>}\t%1, %0"
2392 [(set_attr "type" "imov")
2393 (set_attr "mode" "<MODE>")
2394 (set_attr "pent_pair" "np")
2395 (set_attr "athlon_decode" "vector")])
2397 (define_expand "movstrict<mode>"
2398 [(set (strict_low_part (match_operand:SWI12 0 "nonimmediate_operand" ""))
2399 (match_operand:SWI12 1 "general_operand" ""))]
2402 if (TARGET_PARTIAL_REG_STALL && optimize_function_for_speed_p (cfun))
2404 if (GET_CODE (operands[0]) == SUBREG
2405 && GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0]))) != MODE_INT)
2407 /* Don't generate memory->memory moves, go through a register */
2408 if (MEM_P (operands[0]) && MEM_P (operands[1]))
2409 operands[1] = force_reg (<MODE>mode, operands[1]);
2412 (define_insn "*movstrict<mode>_1"
2413 [(set (strict_low_part
2414 (match_operand:SWI12 0 "nonimmediate_operand" "+<r>m,<r>"))
2415 (match_operand:SWI12 1 "general_operand" "<r>n,m"))]
2416 "(!TARGET_PARTIAL_REG_STALL || optimize_function_for_size_p (cfun))
2417 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2418 "mov{<imodesuffix>}\t{%1, %0|%0, %1}"
2419 [(set_attr "type" "imov")
2420 (set_attr "mode" "<MODE>")])
2422 (define_insn "*movstrict<mode>_xor"
2423 [(set (strict_low_part (match_operand:SWI12 0 "register_operand" "+<r>"))
2424 (match_operand:SWI12 1 "const0_operand" ""))
2425 (clobber (reg:CC FLAGS_REG))]
2427 "xor{<imodesuffix>}\t%0, %0"
2428 [(set_attr "type" "alu1")
2429 (set_attr "mode" "<MODE>")
2430 (set_attr "length_immediate" "0")])
2432 (define_insn "*mov<mode>_extv_1"
2433 [(set (match_operand:SWI24 0 "register_operand" "=R")
2434 (sign_extract:SWI24 (match_operand 1 "ext_register_operand" "Q")
2438 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
2439 [(set_attr "type" "imovx")
2440 (set_attr "mode" "SI")])
2442 (define_insn "*movqi_extv_1_rex64"
2443 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2444 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2449 switch (get_attr_type (insn))
2452 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2454 return "mov{b}\t{%h1, %0|%0, %h1}";
2458 (if_then_else (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2459 (match_test "TARGET_MOVX"))
2460 (const_string "imovx")
2461 (const_string "imov")))
2463 (if_then_else (eq_attr "type" "imovx")
2465 (const_string "QI")))])
2467 (define_insn "*movqi_extv_1"
2468 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
2469 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
2474 switch (get_attr_type (insn))
2477 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
2479 return "mov{b}\t{%h1, %0|%0, %h1}";
2483 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2484 (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2485 (match_test "TARGET_MOVX")))
2486 (const_string "imovx")
2487 (const_string "imov")))
2489 (if_then_else (eq_attr "type" "imovx")
2491 (const_string "QI")))])
2493 (define_insn "*mov<mode>_extzv_1"
2494 [(set (match_operand:SWI48 0 "register_operand" "=R")
2495 (zero_extract:SWI48 (match_operand 1 "ext_register_operand" "Q")
2499 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
2500 [(set_attr "type" "imovx")
2501 (set_attr "mode" "SI")])
2503 (define_insn "*movqi_extzv_2_rex64"
2504 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2506 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2511 switch (get_attr_type (insn))
2514 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2516 return "mov{b}\t{%h1, %0|%0, %h1}";
2520 (if_then_else (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2521 (match_test "TARGET_MOVX"))
2522 (const_string "imovx")
2523 (const_string "imov")))
2525 (if_then_else (eq_attr "type" "imovx")
2527 (const_string "QI")))])
2529 (define_insn "*movqi_extzv_2"
2530 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
2532 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2537 switch (get_attr_type (insn))
2540 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2542 return "mov{b}\t{%h1, %0|%0, %h1}";
2546 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2547 (ior (not (match_operand:QI 0 "QIreg_operand" ""))
2548 (match_test "TARGET_MOVX")))
2549 (const_string "imovx")
2550 (const_string "imov")))
2552 (if_then_else (eq_attr "type" "imovx")
2554 (const_string "QI")))])
2556 (define_expand "mov<mode>_insv_1"
2557 [(set (zero_extract:SWI48 (match_operand 0 "ext_register_operand" "")
2560 (match_operand:SWI48 1 "nonmemory_operand" ""))])
2562 (define_insn "*mov<mode>_insv_1_rex64"
2563 [(set (zero_extract:SWI48x (match_operand 0 "ext_register_operand" "+Q")
2566 (match_operand:SWI48x 1 "nonmemory_operand" "Qn"))]
2569 if (CONST_INT_P (operands[1]))
2570 operands[1] = simplify_gen_subreg (QImode, operands[1], <MODE>mode, 0);
2571 return "mov{b}\t{%b1, %h0|%h0, %b1}";
2573 [(set_attr "type" "imov")
2574 (set_attr "mode" "QI")])
2576 (define_insn "*movsi_insv_1"
2577 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2580 (match_operand:SI 1 "general_operand" "Qmn"))]
2583 if (CONST_INT_P (operands[1]))
2584 operands[1] = simplify_gen_subreg (QImode, operands[1], SImode, 0);
2585 return "mov{b}\t{%b1, %h0|%h0, %b1}";
2587 [(set_attr "type" "imov")
2588 (set_attr "mode" "QI")])
2590 (define_insn "*movqi_insv_2"
2591 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2594 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2597 "mov{b}\t{%h1, %h0|%h0, %h1}"
2598 [(set_attr "type" "imov")
2599 (set_attr "mode" "QI")])
2601 ;; Floating point push instructions.
2603 (define_insn "*pushtf"
2604 [(set (match_operand:TF 0 "push_operand" "=<,<,<")
2605 (match_operand:TF 1 "general_no_elim_operand" "x,Fo,*r"))]
2608 /* This insn should be already split before reg-stack. */
2611 [(set_attr "type" "multi")
2612 (set_attr "unit" "sse,*,*")
2613 (set_attr "mode" "TF,SI,SI")])
2615 ;; %%% Kill this when call knows how to work this out.
2617 [(set (match_operand:TF 0 "push_operand" "")
2618 (match_operand:TF 1 "sse_reg_operand" ""))]
2619 "TARGET_SSE2 && reload_completed"
2620 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -16)))
2621 (set (mem:TF (reg:P SP_REG)) (match_dup 1))])
2623 (define_insn "*pushxf"
2624 [(set (match_operand:XF 0 "push_operand" "=<,<")
2625 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
2626 "optimize_function_for_speed_p (cfun)"
2628 /* This insn should be already split before reg-stack. */
2631 [(set_attr "type" "multi")
2632 (set_attr "unit" "i387,*")
2633 (set_attr "mode" "XF,SI")])
2635 ;; Size of pushxf is 3 (for sub) + 2 (for fstp) + memory operand size.
2636 ;; Size of pushxf using integer instructions is 3+3*memory operand size
2637 ;; Pushing using integer instructions is longer except for constants
2638 ;; and direct memory references (assuming that any given constant is pushed
2639 ;; only once, but this ought to be handled elsewhere).
2641 (define_insn "*pushxf_nointeger"
2642 [(set (match_operand:XF 0 "push_operand" "=<,<")
2643 (match_operand:XF 1 "general_no_elim_operand" "f,*rFo"))]
2644 "optimize_function_for_size_p (cfun)"
2646 /* This insn should be already split before reg-stack. */
2649 [(set_attr "type" "multi")
2650 (set_attr "unit" "i387,*")
2651 (set_attr "mode" "XF,SI")])
2653 ;; %%% Kill this when call knows how to work this out.
2655 [(set (match_operand:XF 0 "push_operand" "")
2656 (match_operand:XF 1 "fp_register_operand" ""))]
2658 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2659 (set (mem:XF (reg:P SP_REG)) (match_dup 1))]
2660 "operands[2] = GEN_INT (-GET_MODE_SIZE (XFmode));")
2662 (define_insn "*pushdf_rex64"
2663 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2664 (match_operand:DF 1 "general_no_elim_operand" "f,Yd*rFm,x"))]
2667 /* This insn should be already split before reg-stack. */
2670 [(set_attr "type" "multi")
2671 (set_attr "unit" "i387,*,*")
2672 (set_attr "mode" "DF,DI,DF")])
2674 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2675 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2676 ;; On the average, pushdf using integers can be still shorter.
2678 (define_insn "*pushdf"
2679 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2680 (match_operand:DF 1 "general_no_elim_operand" "f,Yd*rFo,x"))]
2683 /* This insn should be already split before reg-stack. */
2686 [(set_attr "isa" "*,*,sse2")
2687 (set_attr "type" "multi")
2688 (set_attr "unit" "i387,*,*")
2689 (set_attr "mode" "DF,DI,DF")])
2691 ;; %%% Kill this when call knows how to work this out.
2693 [(set (match_operand:DF 0 "push_operand" "")
2694 (match_operand:DF 1 "any_fp_register_operand" ""))]
2696 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (const_int -8)))
2697 (set (mem:DF (reg:P SP_REG)) (match_dup 1))])
2699 (define_insn "*pushsf_rex64"
2700 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2701 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2704 /* Anything else should be already split before reg-stack. */
2705 gcc_assert (which_alternative == 1);
2706 return "push{q}\t%q1";
2708 [(set_attr "type" "multi,push,multi")
2709 (set_attr "unit" "i387,*,*")
2710 (set_attr "mode" "SF,DI,SF")])
2712 (define_insn "*pushsf"
2713 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2714 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2717 /* Anything else should be already split before reg-stack. */
2718 gcc_assert (which_alternative == 1);
2719 return "push{l}\t%1";
2721 [(set_attr "type" "multi,push,multi")
2722 (set_attr "unit" "i387,*,*")
2723 (set_attr "mode" "SF,SI,SF")])
2725 ;; %%% Kill this when call knows how to work this out.
2727 [(set (match_operand:SF 0 "push_operand" "")
2728 (match_operand:SF 1 "any_fp_register_operand" ""))]
2730 [(set (reg:P SP_REG) (plus:P (reg:P SP_REG) (match_dup 2)))
2731 (set (mem:SF (reg:P SP_REG)) (match_dup 1))]
2732 "operands[2] = GEN_INT (-GET_MODE_SIZE (<P:MODE>mode));")
2735 [(set (match_operand:SF 0 "push_operand" "")
2736 (match_operand:SF 1 "memory_operand" ""))]
2738 && (operands[2] = find_constant_src (insn))"
2739 [(set (match_dup 0) (match_dup 2))])
2742 [(set (match_operand 0 "push_operand" "")
2743 (match_operand 1 "general_operand" ""))]
2745 && (GET_MODE (operands[0]) == TFmode
2746 || GET_MODE (operands[0]) == XFmode
2747 || GET_MODE (operands[0]) == DFmode)
2748 && !ANY_FP_REG_P (operands[1])"
2750 "ix86_split_long_move (operands); DONE;")
2752 ;; Floating point move instructions.
2754 (define_expand "movtf"
2755 [(set (match_operand:TF 0 "nonimmediate_operand" "")
2756 (match_operand:TF 1 "nonimmediate_operand" ""))]
2757 "TARGET_64BIT || TARGET_SSE2"
2759 ix86_expand_move (TFmode, operands);
2763 (define_expand "mov<mode>"
2764 [(set (match_operand:X87MODEF 0 "nonimmediate_operand" "")
2765 (match_operand:X87MODEF 1 "general_operand" ""))]
2767 "ix86_expand_move (<MODE>mode, operands); DONE;")
2769 (define_insn "*movtf_internal_rex64"
2770 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?*r ,!o")
2771 (match_operand:TF 1 "general_operand" "xm,x,C,*roF,*r"))]
2772 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2773 && (!can_create_pseudo_p ()
2774 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2775 || GET_CODE (operands[1]) != CONST_DOUBLE
2776 || (optimize_function_for_size_p (cfun)
2777 && standard_sse_constant_p (operands[1])
2778 && !memory_operand (operands[0], TFmode))
2779 || (!TARGET_MEMORY_MISMATCH_STALL
2780 && memory_operand (operands[0], TFmode)))"
2782 switch (which_alternative)
2786 /* Handle misaligned load/store since we
2787 don't have movmisaligntf pattern. */
2788 if (misaligned_operand (operands[0], TFmode)
2789 || misaligned_operand (operands[1], TFmode))
2791 if (get_attr_mode (insn) == MODE_V4SF)
2792 return "%vmovups\t{%1, %0|%0, %1}";
2794 return "%vmovdqu\t{%1, %0|%0, %1}";
2798 if (get_attr_mode (insn) == MODE_V4SF)
2799 return "%vmovaps\t{%1, %0|%0, %1}";
2801 return "%vmovdqa\t{%1, %0|%0, %1}";
2805 return standard_sse_constant_opcode (insn, operands[1]);
2815 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
2816 (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,*,*")
2818 (cond [(eq_attr "alternative" "0,2")
2820 (match_test "optimize_function_for_size_p (cfun)")
2821 (const_string "V4SF")
2822 (const_string "TI"))
2823 (eq_attr "alternative" "1")
2825 (ior (match_test "TARGET_SSE_TYPELESS_STORES")
2826 (match_test "optimize_function_for_size_p (cfun)"))
2827 (const_string "V4SF")
2828 (const_string "TI"))]
2829 (const_string "DI")))])
2831 (define_insn "*movtf_internal_sse2"
2832 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x")
2833 (match_operand:TF 1 "general_operand" "xm,x,C"))]
2834 "TARGET_SSE2 && !TARGET_64BIT
2835 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2836 && (!can_create_pseudo_p ()
2837 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2838 || GET_CODE (operands[1]) != CONST_DOUBLE
2839 || (optimize_function_for_size_p (cfun)
2840 && standard_sse_constant_p (operands[1])
2841 && !memory_operand (operands[0], TFmode))
2842 || (!TARGET_MEMORY_MISMATCH_STALL
2843 && memory_operand (operands[0], TFmode)))"
2845 switch (which_alternative)
2849 /* Handle misaligned load/store since we
2850 don't have movmisaligntf pattern. */
2851 if (misaligned_operand (operands[0], TFmode)
2852 || misaligned_operand (operands[1], TFmode))
2854 if (get_attr_mode (insn) == MODE_V4SF)
2855 return "%vmovups\t{%1, %0|%0, %1}";
2857 return "%vmovdqu\t{%1, %0|%0, %1}";
2861 if (get_attr_mode (insn) == MODE_V4SF)
2862 return "%vmovaps\t{%1, %0|%0, %1}";
2864 return "%vmovdqa\t{%1, %0|%0, %1}";
2868 return standard_sse_constant_opcode (insn, operands[1]);
2874 [(set_attr "type" "ssemov,ssemov,sselog1")
2875 (set_attr "prefix" "maybe_vex")
2877 (cond [(eq_attr "alternative" "0,2")
2879 (match_test "optimize_function_for_size_p (cfun)")
2880 (const_string "V4SF")
2881 (const_string "TI"))
2882 (eq_attr "alternative" "1")
2884 (ior (match_test "TARGET_SSE_TYPELESS_STORES")
2885 (match_test "optimize_function_for_size_p (cfun)"))
2886 (const_string "V4SF")
2887 (const_string "TI"))]
2888 (const_string "DI")))])
2890 (define_insn "*movxf_internal_rex64"
2891 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,?Yx*r ,!o")
2892 (match_operand:XF 1 "general_operand" "fm,f,G,Yx*roF,Yx*rC"))]
2893 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2894 && (!can_create_pseudo_p ()
2895 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2896 || GET_CODE (operands[1]) != CONST_DOUBLE
2897 || (optimize_function_for_size_p (cfun)
2898 && standard_80387_constant_p (operands[1]) > 0
2899 && !memory_operand (operands[0], XFmode))
2900 || (!TARGET_MEMORY_MISMATCH_STALL
2901 && memory_operand (operands[0], XFmode)))"
2903 switch (which_alternative)
2907 return output_387_reg_move (insn, operands);
2910 return standard_80387_constant_opcode (operands[1]);
2920 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2921 (set_attr "mode" "XF,XF,XF,SI,SI")])
2923 ;; Possible store forwarding (partial memory) stall in alternative 4.
2924 (define_insn "*movxf_internal"
2925 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,?Yx*r ,!o")
2926 (match_operand:XF 1 "general_operand" "fm,f,G,Yx*roF,Yx*rF"))]
2927 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2928 && (!can_create_pseudo_p ()
2929 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2930 || GET_CODE (operands[1]) != CONST_DOUBLE
2931 || (optimize_function_for_size_p (cfun)
2932 && standard_80387_constant_p (operands[1]) > 0
2933 && !memory_operand (operands[0], XFmode))
2934 || (!TARGET_MEMORY_MISMATCH_STALL
2935 && memory_operand (operands[0], XFmode)))"
2937 switch (which_alternative)
2941 return output_387_reg_move (insn, operands);
2944 return standard_80387_constant_opcode (operands[1]);
2954 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
2955 (set_attr "mode" "XF,XF,XF,SI,SI")])
2957 (define_insn "*movdf_internal_rex64"
2958 [(set (match_operand:DF 0 "nonimmediate_operand"
2959 "=?Yf*f,?m ,?Yf*f,?r,?m,?r,?r,x,x,x,m,Yi,r ")
2960 (match_operand:DF 1 "general_operand"
2961 "Yf*fm ,Yf*f ,G ,rm,rC,C ,F ,C,x,m,x,r ,Yi"))]
2962 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2963 && (!can_create_pseudo_p ()
2964 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2965 || GET_CODE (operands[1]) != CONST_DOUBLE
2966 || (optimize_function_for_size_p (cfun)
2967 && ((!(TARGET_SSE2 && TARGET_SSE_MATH)
2968 && standard_80387_constant_p (operands[1]) > 0)
2969 || (TARGET_SSE2 && TARGET_SSE_MATH
2970 && standard_sse_constant_p (operands[1]))))
2971 || memory_operand (operands[0], DFmode))"
2973 switch (which_alternative)
2977 return output_387_reg_move (insn, operands);
2980 return standard_80387_constant_opcode (operands[1]);
2984 return "mov{q}\t{%1, %0|%0, %1}";
2987 return "mov{l}\t{%1, %k0|%k0, %1}";
2990 return "movabs{q}\t{%1, %0|%0, %1}";
2993 return standard_sse_constant_opcode (insn, operands[1]);
2998 switch (get_attr_mode (insn))
3001 if (!TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3002 return "%vmovapd\t{%1, %0|%0, %1}";
3004 return "%vmovaps\t{%1, %0|%0, %1}";
3007 return "%vmovq\t{%1, %0|%0, %1}";
3009 if (TARGET_AVX && REG_P (operands[0]) && REG_P (operands[1]))
3010 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3011 return "%vmovsd\t{%1, %0|%0, %1}";
3013 return "%vmovlpd\t{%1, %d0|%d0, %1}";
3015 return "%vmovlps\t{%1, %d0|%d0, %1}";
3022 /* Handle broken assemblers that require movd instead of movq. */
3023 return "%vmovd\t{%1, %0|%0, %1}";
3030 (cond [(eq_attr "alternative" "0,1,2")
3031 (const_string "fmov")
3032 (eq_attr "alternative" "3,4,5,6")
3033 (const_string "imov")
3034 (eq_attr "alternative" "7")
3035 (const_string "sselog1")
3037 (const_string "ssemov")))
3040 (and (eq_attr "alternative" "6") (eq_attr "type" "imov"))
3042 (const_string "*")))
3043 (set (attr "length_immediate")
3045 (and (eq_attr "alternative" "6") (eq_attr "type" "imov"))
3047 (const_string "*")))
3048 (set (attr "prefix")
3049 (if_then_else (eq_attr "alternative" "0,1,2,3,4,5,6")
3050 (const_string "orig")
3051 (const_string "maybe_vex")))
3052 (set (attr "prefix_data16")
3053 (if_then_else (eq_attr "mode" "V1DF")
3055 (const_string "*")))
3057 (cond [(eq_attr "alternative" "0,1,2")
3059 (eq_attr "alternative" "3,4,6,11,12")
3061 (eq_attr "alternative" "5")
3064 /* xorps is one byte shorter. */
3065 (eq_attr "alternative" "7")
3066 (cond [(match_test "optimize_function_for_size_p (cfun)")
3067 (const_string "V4SF")
3068 (match_test "TARGET_SSE_LOAD0_BY_PXOR")
3071 (const_string "V2DF"))
3073 /* For architectures resolving dependencies on
3074 whole SSE registers use APD move to break dependency
3075 chains, otherwise use short move to avoid extra work.
3077 movaps encodes one byte shorter. */
3078 (eq_attr "alternative" "8")
3080 [(match_test "optimize_function_for_size_p (cfun)")
3081 (const_string "V4SF")
3082 (match_test "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3083 (const_string "V2DF")
3085 (const_string "DF"))
3086 /* For architectures resolving dependencies on register
3087 parts we may avoid extra work to zero out upper part
3089 (eq_attr "alternative" "9")
3091 (match_test "TARGET_SSE_SPLIT_REGS")
3092 (const_string "V1DF")
3093 (const_string "DF"))
3095 (const_string "DF")))])
3097 ;; Possible store forwarding (partial memory) stall in alternative 4.
3098 (define_insn "*movdf_internal"
3099 [(set (match_operand:DF 0 "nonimmediate_operand"
3100 "=Yf*f,m ,Yf*f,?Yd*r ,!o ,x,x,x,m,*x,*x,*x,m")
3101 (match_operand:DF 1 "general_operand"
3102 "Yf*fm,Yf*f,G ,Yd*roF,Yd*rF,C,x,m,x,C ,*x,m ,*x"))]
3103 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3104 && (!can_create_pseudo_p ()
3105 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3106 || GET_CODE (operands[1]) != CONST_DOUBLE
3107 || (optimize_function_for_size_p (cfun)
3108 && ((!(TARGET_SSE2 && TARGET_SSE_MATH)
3109 && standard_80387_constant_p (operands[1]) > 0)
3110 || (TARGET_SSE2 && TARGET_SSE_MATH
3111 && standard_sse_constant_p (operands[1])))
3112 && !memory_operand (operands[0], DFmode))
3113 || (!TARGET_MEMORY_MISMATCH_STALL
3114 && memory_operand (operands[0], DFmode)))"
3116 switch (which_alternative)
3120 return output_387_reg_move (insn, operands);
3123 return standard_80387_constant_opcode (operands[1]);
3131 return standard_sse_constant_opcode (insn, operands[1]);
3139 switch (get_attr_mode (insn))
3142 if (!TARGET_SSE_PACKED_SINGLE_INSN_OPTIMAL)
3143 return "%vmovapd\t{%1, %0|%0, %1}";
3145 return "%vmovaps\t{%1, %0|%0, %1}";
3148 return "%vmovq\t{%1, %0|%0, %1}";
3150 if (TARGET_AVX && REG_P (operands[0]) && REG_P (operands[1]))
3151 return "vmovsd\t{%1, %0, %0|%0, %0, %1}";
3152 return "%vmovsd\t{%1, %0|%0, %1}";
3154 return "%vmovlpd\t{%1, %d0|%d0, %1}";
3156 return "%vmovlps\t{%1, %d0|%d0, %1}";
3166 (if_then_else (eq_attr "alternative" "5,6,7,8")
3167 (const_string "sse2")
3168 (const_string "*")))
3170 (cond [(eq_attr "alternative" "0,1,2")
3171 (const_string "fmov")
3172 (eq_attr "alternative" "3,4")
3173 (const_string "multi")
3174 (eq_attr "alternative" "5,9")
3175 (const_string "sselog1")
3177 (const_string "ssemov")))
3178 (set (attr "prefix")
3179 (if_then_else (eq_attr "alternative" "0,1,2,3,4")
3180 (const_string "orig")
3181 (const_string "maybe_vex")))
3182 (set (attr "prefix_data16")
3183 (if_then_else (eq_attr "mode" "V1DF")
3185 (const_string "*")))
3187 (cond [(eq_attr "alternative" "0,1,2")
3189 (eq_attr "alternative" "3,4")
3192 /* For SSE1, we have many fewer alternatives. */
3193 (not (match_test "TARGET_SSE2"))
3195 (eq_attr "alternative" "5,6,9,10")
3196 (const_string "V4SF")
3197 (const_string "V2SF"))
3199 /* xorps is one byte shorter. */
3200 (eq_attr "alternative" "5,9")
3201 (cond [(match_test "optimize_function_for_size_p (cfun)")
3202 (const_string "V4SF")
3203 (match_test "TARGET_SSE_LOAD0_BY_PXOR")
3206 (const_string "V2DF"))
3208 /* For architectures resolving dependencies on
3209 whole SSE registers use APD move to break dependency
3210 chains, otherwise use short move to avoid extra work.
3212 movaps encodes one byte shorter. */
3213 (eq_attr "alternative" "6,10")
3215 [(match_test "optimize_function_for_size_p (cfun)")
3216 (const_string "V4SF")
3217 (match_test "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3218 (const_string "V2DF")
3220 (const_string "DF"))
3221 /* For architectures resolving dependencies on register
3222 parts we may avoid extra work to zero out upper part
3224 (eq_attr "alternative" "7,11")
3226 (match_test "TARGET_SSE_SPLIT_REGS")
3227 (const_string "V1DF")
3228 (const_string "DF"))
3230 (const_string "DF")))])
3232 (define_insn "*movsf_internal"
3233 [(set (match_operand:SF 0 "nonimmediate_operand"
3234 "=Yf*f,m ,Yf*f,?r ,?m,x,x,x,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
3235 (match_operand:SF 1 "general_operand"
3236 "Yf*fm,Yf*f,G ,rmF,rF,C,x,m,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
3237 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3238 && (!can_create_pseudo_p ()
3239 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3240 || GET_CODE (operands[1]) != CONST_DOUBLE
3241 || (optimize_function_for_size_p (cfun)
3242 && ((!TARGET_SSE_MATH
3243 && standard_80387_constant_p (operands[1]) > 0)
3245 && standard_sse_constant_p (operands[1]))))
3246 || memory_operand (operands[0], SFmode))"
3248 switch (which_alternative)
3252 return output_387_reg_move (insn, operands);
3255 return standard_80387_constant_opcode (operands[1]);
3259 return "mov{l}\t{%1, %0|%0, %1}";
3262 return standard_sse_constant_opcode (insn, operands[1]);
3265 if (get_attr_mode (insn) == MODE_V4SF)
3266 return "%vmovaps\t{%1, %0|%0, %1}";
3268 return "vmovss\t{%1, %0, %0|%0, %0, %1}";
3272 return "%vmovss\t{%1, %0|%0, %1}";
3278 return "movd\t{%1, %0|%0, %1}";
3281 return "movq\t{%1, %0|%0, %1}";
3285 return "%vmovd\t{%1, %0|%0, %1}";
3292 (cond [(eq_attr "alternative" "0,1,2")
3293 (const_string "fmov")
3294 (eq_attr "alternative" "3,4")
3295 (const_string "imov")
3296 (eq_attr "alternative" "5")
3297 (const_string "sselog1")
3298 (eq_attr "alternative" "9,10,11,14,15")
3299 (const_string "mmxmov")
3301 (const_string "ssemov")))
3302 (set (attr "prefix")
3303 (if_then_else (eq_attr "alternative" "5,6,7,8,12,13")
3304 (const_string "maybe_vex")
3305 (const_string "orig")))
3307 (cond [(eq_attr "alternative" "3,4,9,10")
3309 (eq_attr "alternative" "5")
3311 (and (and (match_test "TARGET_SSE_LOAD0_BY_PXOR")
3312 (match_test "TARGET_SSE2"))
3313 (not (match_test "optimize_function_for_size_p (cfun)")))
3315 (const_string "V4SF"))
3316 /* For architectures resolving dependencies on
3317 whole SSE registers use APS move to break dependency
3318 chains, otherwise use short move to avoid extra work.
3320 Do the same for architectures resolving dependencies on
3321 the parts. While in DF mode it is better to always handle
3322 just register parts, the SF mode is different due to lack
3323 of instructions to load just part of the register. It is
3324 better to maintain the whole registers in single format
3325 to avoid problems on using packed logical operations. */
3326 (eq_attr "alternative" "6")
3328 (ior (match_test "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3329 (match_test "TARGET_SSE_SPLIT_REGS"))
3330 (const_string "V4SF")
3331 (const_string "SF"))
3332 (eq_attr "alternative" "11")
3333 (const_string "DI")]
3334 (const_string "SF")))])
3337 [(set (match_operand 0 "any_fp_register_operand" "")
3338 (match_operand 1 "memory_operand" ""))]
3340 && (GET_MODE (operands[0]) == TFmode
3341 || GET_MODE (operands[0]) == XFmode
3342 || GET_MODE (operands[0]) == DFmode
3343 || GET_MODE (operands[0]) == SFmode)
3344 && (operands[2] = find_constant_src (insn))"
3345 [(set (match_dup 0) (match_dup 2))]
3347 rtx c = operands[2];
3348 int r = REGNO (operands[0]);
3350 if ((SSE_REGNO_P (r) && !standard_sse_constant_p (c))
3351 || (FP_REGNO_P (r) && standard_80387_constant_p (c) < 1))