1 ;; GCC machine description for IA-32 and x86-64.
2 ;; Copyright (C) 1988, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 ;; Free Software Foundation, Inc.
5 ;; Mostly by William Schelter.
6 ;; x86_64 support added by Jan Hubicka
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>. */
24 ;; The original PO technology requires these to be ordered by speed,
25 ;; so that assigner will pick the fastest.
27 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
29 ;; The special asm out single letter directives following a '%' are:
30 ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
32 ;; 'L' Print the opcode suffix for a 32-bit integer opcode.
33 ;; 'W' Print the opcode suffix for a 16-bit integer opcode.
34 ;; 'B' Print the opcode suffix for an 8-bit integer opcode.
35 ;; 'Q' Print the opcode suffix for a 64-bit float opcode.
36 ;; 'S' Print the opcode suffix for a 32-bit float opcode.
37 ;; 'T' Print the opcode suffix for an 80-bit extended real XFmode float opcode.
38 ;; 'J' Print the appropriate jump operand.
40 ;; 'b' Print the QImode name of the register for the indicated operand.
41 ;; %b0 would print %al if operands[0] is reg 0.
42 ;; 'w' Likewise, print the HImode name of the register.
43 ;; 'k' Likewise, print the SImode name of the register.
44 ;; 'h' Print the QImode name for a "high" register, either ah, bh, ch or dh.
45 ;; 'y' Print "st(0)" instead of "st" as a register.
50 [; Relocation specifiers
63 (UNSPEC_STACK_ALLOC 11)
65 (UNSPEC_SSE_PROLOGUE_SAVE 13)
69 (UNSPEC_SET_GOT_OFFSET 17)
74 (UNSPEC_TLS_LD_BASE 20)
77 ; Other random patterns
86 (UNSPEC_LD_MPIC 38) ; load_macho_picbase
87 (UNSPEC_TRUNC_NOOP 39)
89 ; For SSE/MMX support:
90 (UNSPEC_FIX_NOTRUNC 40)
108 ; Generic math support
110 (UNSPEC_IEEE_MIN 51) ; not commutative
111 (UNSPEC_IEEE_MAX 52) ; not commutative
126 (UNSPEC_FRNDINT_FLOOR 70)
127 (UNSPEC_FRNDINT_CEIL 71)
128 (UNSPEC_FRNDINT_TRUNC 72)
129 (UNSPEC_FRNDINT_MASK_PM 73)
130 (UNSPEC_FIST_FLOOR 74)
131 (UNSPEC_FIST_CEIL 75)
133 ; x87 Double output FP
134 (UNSPEC_SINCOS_COS 80)
135 (UNSPEC_SINCOS_SIN 81)
136 (UNSPEC_XTRACT_FRACT 84)
137 (UNSPEC_XTRACT_EXP 85)
138 (UNSPEC_FSCALE_FRACT 86)
139 (UNSPEC_FSCALE_EXP 87)
150 (UNSPEC_SP_TLS_SET 102)
151 (UNSPEC_SP_TLS_TEST 103)
161 (UNSPEC_INSERTQI 132)
166 (UNSPEC_INSERTPS 135)
168 (UNSPEC_MOVNTDQA 137)
170 (UNSPEC_PHMINPOSUW 139)
176 (UNSPEC_PCMPESTR 144)
177 (UNSPEC_PCMPISTR 145)
180 (UNSPEC_SSE5_INTRINSIC 150)
181 (UNSPEC_SSE5_UNSIGNED_CMP 151)
182 (UNSPEC_SSE5_TRUEFALSE 152)
183 (UNSPEC_SSE5_PERMUTE 153)
185 (UNSPEC_CVTPH2PS 155)
186 (UNSPEC_CVTPS2PH 156)
190 (UNSPEC_AESENCLAST 160)
192 (UNSPEC_AESDECLAST 162)
194 (UNSPEC_AESKEYGENASSIST 164)
201 [(UNSPECV_BLOCKAGE 0)
202 (UNSPECV_STACK_PROBE 1)
211 (UNSPECV_CMPXCHG_1 10)
212 (UNSPECV_CMPXCHG_2 11)
215 (UNSPECV_PROLOGUE_USE 14)
219 ;; Constants to represent pcomtrue/pcomfalse variants
229 ;; Constants used in the SSE5 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.
259 ;; Insns whose names begin with "x86_" are emitted by gen_FOO calls
262 ;; In C guard expressions, put expressions which may be compile-time
263 ;; constants first. This allows for better optimization. For
264 ;; example, write "TARGET_64BIT && reload_completed", not
265 ;; "reload_completed && TARGET_64BIT".
268 ;; Processor type. This attribute must exactly match the processor_type
269 ;; enumeration in i386.h.
270 (define_attr "cpu" "i386,i486,pentium,pentiumpro,geode,k6,athlon,pentium4,k8,
271 nocona,core2,generic32,generic64,amdfam10"
272 (const (symbol_ref "ix86_tune")))
274 ;; A basic instruction type. Refinements due to arguments to be
275 ;; provided in other attributes.
278 alu,alu1,negnot,imov,imovx,lea,
279 incdec,ishift,ishift1,rotate,rotate1,imul,idiv,
280 icmp,test,ibr,setcc,icmov,
281 push,pop,call,callv,leave,
283 fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint,
284 sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
285 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,ssediv,sseins,
287 mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft"
288 (const_string "other"))
290 ;; Main data type used by the insn
292 "unknown,none,QI,HI,SI,DI,SF,DF,XF,TI,V4SF,V2DF,V2SF,V1DF"
293 (const_string "unknown"))
295 ;; The CPU unit operations uses.
296 (define_attr "unit" "integer,i387,sse,mmx,unknown"
297 (cond [(eq_attr "type" "fmov,fop,fsgn,fmul,fdiv,fpspc,fcmov,fcmp,fxch,fistp,fisttp,frndint")
298 (const_string "i387")
299 (eq_attr "type" "sselog,sselog1,sseiadd,sseiadd1,sseishft,sseimul,
300 sse,ssemov,sseadd,ssemul,ssecmp,ssecomi,ssecvt,
301 ssecvt1,sseicvt,ssediv,sseins,ssemuladd,sse4arg")
303 (eq_attr "type" "mmx,mmxmov,mmxadd,mmxmul,mmxcmp,mmxcvt,mmxshft")
305 (eq_attr "type" "other")
306 (const_string "unknown")]
307 (const_string "integer")))
309 ;; The (bounding maximum) length of an instruction immediate.
310 (define_attr "length_immediate" ""
311 (cond [(eq_attr "type" "incdec,setcc,icmov,str,lea,other,multi,idiv,leave,
314 (eq_attr "unit" "i387,sse,mmx")
316 (eq_attr "type" "alu,alu1,negnot,imovx,ishift,rotate,ishift1,rotate1,
318 (symbol_ref "ix86_attr_length_immediate_default(insn,1)")
319 (eq_attr "type" "imov,test")
320 (symbol_ref "ix86_attr_length_immediate_default(insn,0)")
321 (eq_attr "type" "call")
322 (if_then_else (match_operand 0 "constant_call_address_operand" "")
325 (eq_attr "type" "callv")
326 (if_then_else (match_operand 1 "constant_call_address_operand" "")
329 ;; We don't know the size before shorten_branches. Expect
330 ;; the instruction to fit for better scheduling.
331 (eq_attr "type" "ibr")
334 (symbol_ref "/* Update immediate_length and other attributes! */
335 gcc_unreachable (),1")))
337 ;; The (bounding maximum) length of an instruction address.
338 (define_attr "length_address" ""
339 (cond [(eq_attr "type" "str,other,multi,fxch")
341 (and (eq_attr "type" "call")
342 (match_operand 0 "constant_call_address_operand" ""))
344 (and (eq_attr "type" "callv")
345 (match_operand 1 "constant_call_address_operand" ""))
348 (symbol_ref "ix86_attr_length_address_default (insn)")))
350 ;; Set when length prefix is used.
351 (define_attr "prefix_data16" ""
352 (if_then_else (ior (eq_attr "mode" "HI")
353 (and (eq_attr "unit" "sse") (eq_attr "mode" "V2DF")))
357 ;; Set when string REP prefix is used.
358 (define_attr "prefix_rep" ""
359 (if_then_else (and (eq_attr "unit" "sse") (eq_attr "mode" "SF,DF"))
363 ;; Set when 0f opcode prefix is used.
364 (define_attr "prefix_0f" ""
366 (ior (eq_attr "type" "imovx,setcc,icmov,bitmanip")
367 (eq_attr "unit" "sse,mmx"))
371 ;; Set when REX opcode prefix is used.
372 (define_attr "prefix_rex" ""
373 (cond [(and (eq_attr "mode" "DI")
374 (eq_attr "type" "!push,pop,call,callv,leave,ibr"))
376 (and (eq_attr "mode" "QI")
377 (ne (symbol_ref "x86_extended_QIreg_mentioned_p (insn)")
380 (ne (symbol_ref "x86_extended_reg_mentioned_p (insn)")
386 ;; There are also additional prefixes in SSSE3.
387 (define_attr "prefix_extra" "" (const_int 0))
389 ;; Set when modrm byte is used.
390 (define_attr "modrm" ""
391 (cond [(eq_attr "type" "str,leave")
393 (eq_attr "unit" "i387")
395 (and (eq_attr "type" "incdec")
396 (ior (match_operand:SI 1 "register_operand" "")
397 (match_operand:HI 1 "register_operand" "")))
399 (and (eq_attr "type" "push")
400 (not (match_operand 1 "memory_operand" "")))
402 (and (eq_attr "type" "pop")
403 (not (match_operand 0 "memory_operand" "")))
405 (and (eq_attr "type" "imov")
406 (ior (and (match_operand 0 "register_operand" "")
407 (match_operand 1 "immediate_operand" ""))
408 (ior (and (match_operand 0 "ax_reg_operand" "")
409 (match_operand 1 "memory_displacement_only_operand" ""))
410 (and (match_operand 0 "memory_displacement_only_operand" "")
411 (match_operand 1 "ax_reg_operand" "")))))
413 (and (eq_attr "type" "call")
414 (match_operand 0 "constant_call_address_operand" ""))
416 (and (eq_attr "type" "callv")
417 (match_operand 1 "constant_call_address_operand" ""))
422 ;; The (bounding maximum) length of an instruction in bytes.
423 ;; ??? fistp and frndint are in fact fldcw/{fistp,frndint}/fldcw sequences.
424 ;; Later we may want to split them and compute proper length as for
426 (define_attr "length" ""
427 (cond [(eq_attr "type" "other,multi,fistp,frndint")
429 (eq_attr "type" "fcmp")
431 (eq_attr "unit" "i387")
433 (plus (attr "prefix_data16")
434 (attr "length_address")))]
435 (plus (plus (attr "modrm")
436 (plus (attr "prefix_0f")
437 (plus (attr "prefix_rex")
438 (plus (attr "prefix_extra")
440 (plus (attr "prefix_rep")
441 (plus (attr "prefix_data16")
442 (plus (attr "length_immediate")
443 (attr "length_address")))))))
445 ;; The `memory' attribute is `none' if no memory is referenced, `load' or
446 ;; `store' if there is a simple memory reference therein, or `unknown'
447 ;; if the instruction is complex.
449 (define_attr "memory" "none,load,store,both,unknown"
450 (cond [(eq_attr "type" "other,multi,str")
451 (const_string "unknown")
452 (eq_attr "type" "lea,fcmov,fpspc")
453 (const_string "none")
454 (eq_attr "type" "fistp,leave")
455 (const_string "both")
456 (eq_attr "type" "frndint")
457 (const_string "load")
458 (eq_attr "type" "push")
459 (if_then_else (match_operand 1 "memory_operand" "")
460 (const_string "both")
461 (const_string "store"))
462 (eq_attr "type" "pop")
463 (if_then_else (match_operand 0 "memory_operand" "")
464 (const_string "both")
465 (const_string "load"))
466 (eq_attr "type" "setcc")
467 (if_then_else (match_operand 0 "memory_operand" "")
468 (const_string "store")
469 (const_string "none"))
470 (eq_attr "type" "icmp,test,ssecmp,ssecomi,mmxcmp,fcmp")
471 (if_then_else (ior (match_operand 0 "memory_operand" "")
472 (match_operand 1 "memory_operand" ""))
473 (const_string "load")
474 (const_string "none"))
475 (eq_attr "type" "ibr")
476 (if_then_else (match_operand 0 "memory_operand" "")
477 (const_string "load")
478 (const_string "none"))
479 (eq_attr "type" "call")
480 (if_then_else (match_operand 0 "constant_call_address_operand" "")
481 (const_string "none")
482 (const_string "load"))
483 (eq_attr "type" "callv")
484 (if_then_else (match_operand 1 "constant_call_address_operand" "")
485 (const_string "none")
486 (const_string "load"))
487 (and (eq_attr "type" "alu1,negnot,ishift1,sselog1")
488 (match_operand 1 "memory_operand" ""))
489 (const_string "both")
490 (and (match_operand 0 "memory_operand" "")
491 (match_operand 1 "memory_operand" ""))
492 (const_string "both")
493 (match_operand 0 "memory_operand" "")
494 (const_string "store")
495 (match_operand 1 "memory_operand" "")
496 (const_string "load")
498 "!alu1,negnot,ishift1,
499 imov,imovx,icmp,test,bitmanip,
501 sse,ssemov,ssecmp,ssecomi,ssecvt,ssecvt1,sseicvt,sselog1,
502 sseiadd1,mmx,mmxmov,mmxcmp,mmxcvt")
503 (match_operand 2 "memory_operand" ""))
504 (const_string "load")
505 (and (eq_attr "type" "icmov,ssemuladd,sse4arg")
506 (match_operand 3 "memory_operand" ""))
507 (const_string "load")
509 (const_string "none")))
511 ;; Indicates if an instruction has both an immediate and a displacement.
513 (define_attr "imm_disp" "false,true,unknown"
514 (cond [(eq_attr "type" "other,multi")
515 (const_string "unknown")
516 (and (eq_attr "type" "icmp,test,imov,alu1,ishift1,rotate1")
517 (and (match_operand 0 "memory_displacement_operand" "")
518 (match_operand 1 "immediate_operand" "")))
519 (const_string "true")
520 (and (eq_attr "type" "alu,ishift,rotate,imul,idiv")
521 (and (match_operand 0 "memory_displacement_operand" "")
522 (match_operand 2 "immediate_operand" "")))
523 (const_string "true")
525 (const_string "false")))
527 ;; Indicates if an FP operation has an integer source.
529 (define_attr "fp_int_src" "false,true"
530 (const_string "false"))
532 ;; Defines rounding mode of an FP operation.
534 (define_attr "i387_cw" "trunc,floor,ceil,mask_pm,uninitialized,any"
535 (const_string "any"))
537 ;; Describe a user's asm statement.
538 (define_asm_attributes
539 [(set_attr "length" "128")
540 (set_attr "type" "multi")])
542 ;; All integer comparison codes.
543 (define_code_iterator int_cond [ne eq ge gt le lt geu gtu leu ltu ])
545 ;; All floating-point comparison codes.
546 (define_code_iterator fp_cond [unordered ordered
547 uneq unge ungt unle unlt ltgt ])
549 (define_code_iterator plusminus [plus minus])
551 (define_code_iterator sat_plusminus [ss_plus us_plus ss_minus us_minus])
553 ;; Base name for define_insn
554 (define_code_attr plusminus_insn
555 [(plus "add") (ss_plus "ssadd") (us_plus "usadd")
556 (minus "sub") (ss_minus "sssub") (us_minus "ussub")])
558 ;; Base name for insn mnemonic.
559 (define_code_attr plusminus_mnemonic
560 [(plus "add") (ss_plus "adds") (us_plus "addus")
561 (minus "sub") (ss_minus "subs") (us_minus "subus")])
563 ;; Mark commutative operators as such in constraints.
564 (define_code_attr comm [(plus "%") (ss_plus "%") (us_plus "%")
565 (minus "") (ss_minus "") (us_minus "")])
567 ;; Mapping of signed max and min
568 (define_code_iterator smaxmin [smax smin])
570 ;; Mapping of unsigned max and min
571 (define_code_iterator umaxmin [umax umin])
573 ;; Base name for integer and FP insn mnemonic
574 (define_code_attr maxminiprefix [(smax "maxs") (smin "mins")
575 (umax "maxu") (umin "minu")])
576 (define_code_attr maxminfprefix [(smax "max") (smin "min")])
578 ;; Mapping of parallel logic operators
579 (define_code_iterator plogic [and ior xor])
581 ;; Base name for insn mnemonic.
582 (define_code_attr plogicprefix [(and "and") (ior "or") (xor "xor")])
584 ;; Mapping of abs neg operators
585 (define_code_iterator absneg [abs neg])
587 ;; Base name for x87 insn mnemonic.
588 (define_code_attr absnegprefix [(abs "abs") (neg "chs")])
590 ;; All single word integer modes.
591 (define_mode_iterator SWI [QI HI SI (DI "TARGET_64BIT")])
593 ;; Instruction suffix for integer modes.
594 (define_mode_attr imodesuffix [(QI "b") (HI "w") (SI "l") (DI "q")])
596 ;; Register class for integer modes.
597 (define_mode_attr r [(QI "q") (HI "r") (SI "r") (DI "r")])
599 ;; Immediate operand constraint for integer modes.
600 (define_mode_attr i [(QI "i") (HI "i") (SI "i") (DI "e")])
602 ;; General operand predicate for integer modes.
603 (define_mode_attr general_operand
604 [(QI "general_operand")
605 (HI "general_operand")
606 (SI "general_operand")
607 (DI "x86_64_general_operand")])
609 ;; SSE and x87 SFmode and DFmode floating point modes
610 (define_mode_iterator MODEF [SF DF])
612 ;; All x87 floating point modes
613 (define_mode_iterator X87MODEF [SF DF XF])
615 ;; All integer modes handled by x87 fisttp operator.
616 (define_mode_iterator X87MODEI [HI SI DI])
618 ;; All integer modes handled by integer x87 operators.
619 (define_mode_iterator X87MODEI12 [HI SI])
621 ;; All integer modes handled by SSE cvtts?2si* operators.
622 (define_mode_iterator SSEMODEI24 [SI DI])
624 ;; SSE asm suffix for floating point modes
625 (define_mode_attr ssemodefsuffix [(SF "s") (DF "d")])
627 ;; SSE vector mode corresponding to a scalar mode
628 (define_mode_attr ssevecmode
629 [(QI "V16QI") (HI "V8HI") (SI "V4SI") (DI "V2DI") (SF "V4SF") (DF "V2DF")])
631 ;; Instruction suffix for REX 64bit operators.
632 (define_mode_attr rex64suffix [(SI "") (DI "{q}")])
634 ;; Scheduling descriptions
636 (include "pentium.md")
639 (include "athlon.md")
643 ;; Operand and operator predicates and constraints
645 (include "predicates.md")
646 (include "constraints.md")
649 ;; Compare instructions.
651 ;; All compare insns have expanders that save the operands away without
652 ;; actually generating RTL. The bCOND or sCOND (emitted immediately
653 ;; after the cmp) will actually emit the cmpM.
655 (define_expand "cmpti"
656 [(set (reg:CC FLAGS_REG)
657 (compare:CC (match_operand:TI 0 "nonimmediate_operand" "")
658 (match_operand:TI 1 "x86_64_general_operand" "")))]
661 if (MEM_P (operands[0]) && MEM_P (operands[1]))
662 operands[0] = force_reg (TImode, operands[0]);
663 ix86_compare_op0 = operands[0];
664 ix86_compare_op1 = operands[1];
668 (define_expand "cmpdi"
669 [(set (reg:CC FLAGS_REG)
670 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
671 (match_operand:DI 1 "x86_64_general_operand" "")))]
674 if (MEM_P (operands[0]) && MEM_P (operands[1]))
675 operands[0] = force_reg (DImode, operands[0]);
676 ix86_compare_op0 = operands[0];
677 ix86_compare_op1 = operands[1];
681 (define_expand "cmpsi"
682 [(set (reg:CC FLAGS_REG)
683 (compare:CC (match_operand:SI 0 "cmpsi_operand" "")
684 (match_operand:SI 1 "general_operand" "")))]
687 if (MEM_P (operands[0]) && MEM_P (operands[1]))
688 operands[0] = force_reg (SImode, operands[0]);
689 ix86_compare_op0 = operands[0];
690 ix86_compare_op1 = operands[1];
694 (define_expand "cmphi"
695 [(set (reg:CC FLAGS_REG)
696 (compare:CC (match_operand:HI 0 "nonimmediate_operand" "")
697 (match_operand:HI 1 "general_operand" "")))]
700 if (MEM_P (operands[0]) && MEM_P (operands[1]))
701 operands[0] = force_reg (HImode, operands[0]);
702 ix86_compare_op0 = operands[0];
703 ix86_compare_op1 = operands[1];
707 (define_expand "cmpqi"
708 [(set (reg:CC FLAGS_REG)
709 (compare:CC (match_operand:QI 0 "nonimmediate_operand" "")
710 (match_operand:QI 1 "general_operand" "")))]
713 if (MEM_P (operands[0]) && MEM_P (operands[1]))
714 operands[0] = force_reg (QImode, operands[0]);
715 ix86_compare_op0 = operands[0];
716 ix86_compare_op1 = operands[1];
720 (define_insn "cmpdi_ccno_1_rex64"
721 [(set (reg FLAGS_REG)
722 (compare (match_operand:DI 0 "nonimmediate_operand" "r,?mr")
723 (match_operand:DI 1 "const0_operand" "n,n")))]
724 "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)"
727 cmp{q}\t{%1, %0|%0, %1}"
728 [(set_attr "type" "test,icmp")
729 (set_attr "length_immediate" "0,1")
730 (set_attr "mode" "DI")])
732 (define_insn "*cmpdi_minus_1_rex64"
733 [(set (reg FLAGS_REG)
734 (compare (minus:DI (match_operand:DI 0 "nonimmediate_operand" "rm,r")
735 (match_operand:DI 1 "x86_64_general_operand" "re,mr"))
737 "TARGET_64BIT && ix86_match_ccmode (insn, CCGOCmode)"
738 "cmp{q}\t{%1, %0|%0, %1}"
739 [(set_attr "type" "icmp")
740 (set_attr "mode" "DI")])
742 (define_expand "cmpdi_1_rex64"
743 [(set (reg:CC FLAGS_REG)
744 (compare:CC (match_operand:DI 0 "nonimmediate_operand" "")
745 (match_operand:DI 1 "general_operand" "")))]
749 (define_insn "cmpdi_1_insn_rex64"
750 [(set (reg FLAGS_REG)
751 (compare (match_operand:DI 0 "nonimmediate_operand" "mr,r")
752 (match_operand:DI 1 "x86_64_general_operand" "re,mr")))]
753 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
754 "cmp{q}\t{%1, %0|%0, %1}"
755 [(set_attr "type" "icmp")
756 (set_attr "mode" "DI")])
759 (define_insn "*cmpsi_ccno_1"
760 [(set (reg FLAGS_REG)
761 (compare (match_operand:SI 0 "nonimmediate_operand" "r,?mr")
762 (match_operand:SI 1 "const0_operand" "n,n")))]
763 "ix86_match_ccmode (insn, CCNOmode)"
766 cmp{l}\t{%1, %0|%0, %1}"
767 [(set_attr "type" "test,icmp")
768 (set_attr "length_immediate" "0,1")
769 (set_attr "mode" "SI")])
771 (define_insn "*cmpsi_minus_1"
772 [(set (reg FLAGS_REG)
773 (compare (minus:SI (match_operand:SI 0 "nonimmediate_operand" "rm,r")
774 (match_operand:SI 1 "general_operand" "ri,mr"))
776 "ix86_match_ccmode (insn, CCGOCmode)"
777 "cmp{l}\t{%1, %0|%0, %1}"
778 [(set_attr "type" "icmp")
779 (set_attr "mode" "SI")])
781 (define_expand "cmpsi_1"
782 [(set (reg:CC FLAGS_REG)
783 (compare:CC (match_operand:SI 0 "nonimmediate_operand" "")
784 (match_operand:SI 1 "general_operand" "")))]
788 (define_insn "*cmpsi_1_insn"
789 [(set (reg FLAGS_REG)
790 (compare (match_operand:SI 0 "nonimmediate_operand" "rm,r")
791 (match_operand:SI 1 "general_operand" "ri,mr")))]
792 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
793 && ix86_match_ccmode (insn, CCmode)"
794 "cmp{l}\t{%1, %0|%0, %1}"
795 [(set_attr "type" "icmp")
796 (set_attr "mode" "SI")])
798 (define_insn "*cmphi_ccno_1"
799 [(set (reg FLAGS_REG)
800 (compare (match_operand:HI 0 "nonimmediate_operand" "r,?mr")
801 (match_operand:HI 1 "const0_operand" "n,n")))]
802 "ix86_match_ccmode (insn, CCNOmode)"
805 cmp{w}\t{%1, %0|%0, %1}"
806 [(set_attr "type" "test,icmp")
807 (set_attr "length_immediate" "0,1")
808 (set_attr "mode" "HI")])
810 (define_insn "*cmphi_minus_1"
811 [(set (reg FLAGS_REG)
812 (compare (minus:HI (match_operand:HI 0 "nonimmediate_operand" "rm,r")
813 (match_operand:HI 1 "general_operand" "ri,mr"))
815 "ix86_match_ccmode (insn, CCGOCmode)"
816 "cmp{w}\t{%1, %0|%0, %1}"
817 [(set_attr "type" "icmp")
818 (set_attr "mode" "HI")])
820 (define_insn "*cmphi_1"
821 [(set (reg FLAGS_REG)
822 (compare (match_operand:HI 0 "nonimmediate_operand" "rm,r")
823 (match_operand:HI 1 "general_operand" "ri,mr")))]
824 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
825 && ix86_match_ccmode (insn, CCmode)"
826 "cmp{w}\t{%1, %0|%0, %1}"
827 [(set_attr "type" "icmp")
828 (set_attr "mode" "HI")])
830 (define_insn "*cmpqi_ccno_1"
831 [(set (reg FLAGS_REG)
832 (compare (match_operand:QI 0 "nonimmediate_operand" "q,?mq")
833 (match_operand:QI 1 "const0_operand" "n,n")))]
834 "ix86_match_ccmode (insn, CCNOmode)"
837 cmp{b}\t{$0, %0|%0, 0}"
838 [(set_attr "type" "test,icmp")
839 (set_attr "length_immediate" "0,1")
840 (set_attr "mode" "QI")])
842 (define_insn "*cmpqi_1"
843 [(set (reg FLAGS_REG)
844 (compare (match_operand:QI 0 "nonimmediate_operand" "qm,q")
845 (match_operand:QI 1 "general_operand" "qi,mq")))]
846 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
847 && ix86_match_ccmode (insn, CCmode)"
848 "cmp{b}\t{%1, %0|%0, %1}"
849 [(set_attr "type" "icmp")
850 (set_attr "mode" "QI")])
852 (define_insn "*cmpqi_minus_1"
853 [(set (reg FLAGS_REG)
854 (compare (minus:QI (match_operand:QI 0 "nonimmediate_operand" "qm,q")
855 (match_operand:QI 1 "general_operand" "qi,mq"))
857 "ix86_match_ccmode (insn, CCGOCmode)"
858 "cmp{b}\t{%1, %0|%0, %1}"
859 [(set_attr "type" "icmp")
860 (set_attr "mode" "QI")])
862 (define_insn "*cmpqi_ext_1"
863 [(set (reg FLAGS_REG)
865 (match_operand:QI 0 "general_operand" "Qm")
868 (match_operand 1 "ext_register_operand" "Q")
871 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
872 "cmp{b}\t{%h1, %0|%0, %h1}"
873 [(set_attr "type" "icmp")
874 (set_attr "mode" "QI")])
876 (define_insn "*cmpqi_ext_1_rex64"
877 [(set (reg FLAGS_REG)
879 (match_operand:QI 0 "register_operand" "Q")
882 (match_operand 1 "ext_register_operand" "Q")
885 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
886 "cmp{b}\t{%h1, %0|%0, %h1}"
887 [(set_attr "type" "icmp")
888 (set_attr "mode" "QI")])
890 (define_insn "*cmpqi_ext_2"
891 [(set (reg FLAGS_REG)
895 (match_operand 0 "ext_register_operand" "Q")
898 (match_operand:QI 1 "const0_operand" "n")))]
899 "ix86_match_ccmode (insn, CCNOmode)"
901 [(set_attr "type" "test")
902 (set_attr "length_immediate" "0")
903 (set_attr "mode" "QI")])
905 (define_expand "cmpqi_ext_3"
906 [(set (reg:CC FLAGS_REG)
910 (match_operand 0 "ext_register_operand" "")
913 (match_operand:QI 1 "general_operand" "")))]
917 (define_insn "cmpqi_ext_3_insn"
918 [(set (reg FLAGS_REG)
922 (match_operand 0 "ext_register_operand" "Q")
925 (match_operand:QI 1 "general_operand" "Qmn")))]
926 "!TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
927 "cmp{b}\t{%1, %h0|%h0, %1}"
928 [(set_attr "type" "icmp")
929 (set_attr "mode" "QI")])
931 (define_insn "cmpqi_ext_3_insn_rex64"
932 [(set (reg FLAGS_REG)
936 (match_operand 0 "ext_register_operand" "Q")
939 (match_operand:QI 1 "nonmemory_operand" "Qn")))]
940 "TARGET_64BIT && ix86_match_ccmode (insn, CCmode)"
941 "cmp{b}\t{%1, %h0|%h0, %1}"
942 [(set_attr "type" "icmp")
943 (set_attr "mode" "QI")])
945 (define_insn "*cmpqi_ext_4"
946 [(set (reg FLAGS_REG)
950 (match_operand 0 "ext_register_operand" "Q")
955 (match_operand 1 "ext_register_operand" "Q")
958 "ix86_match_ccmode (insn, CCmode)"
959 "cmp{b}\t{%h1, %h0|%h0, %h1}"
960 [(set_attr "type" "icmp")
961 (set_attr "mode" "QI")])
963 ;; These implement float point compares.
964 ;; %%% See if we can get away with VOIDmode operands on the actual insns,
965 ;; which would allow mix and match FP modes on the compares. Which is what
966 ;; the old patterns did, but with many more of them.
968 (define_expand "cmpxf"
969 [(set (reg:CC FLAGS_REG)
970 (compare:CC (match_operand:XF 0 "nonmemory_operand" "")
971 (match_operand:XF 1 "nonmemory_operand" "")))]
974 ix86_compare_op0 = operands[0];
975 ix86_compare_op1 = operands[1];
979 (define_expand "cmp<mode>"
980 [(set (reg:CC FLAGS_REG)
981 (compare:CC (match_operand:MODEF 0 "cmp_fp_expander_operand" "")
982 (match_operand:MODEF 1 "cmp_fp_expander_operand" "")))]
983 "TARGET_80387 || (SSE_FLOAT_MODE_P (<MODE>mode) && TARGET_SSE_MATH)"
985 ix86_compare_op0 = operands[0];
986 ix86_compare_op1 = operands[1];
990 ;; FP compares, step 1:
991 ;; Set the FP condition codes.
993 ;; CCFPmode compare with exceptions
994 ;; CCFPUmode compare with no exceptions
996 ;; We may not use "#" to split and emit these, since the REG_DEAD notes
997 ;; used to manage the reg stack popping would not be preserved.
999 (define_insn "*cmpfp_0"
1000 [(set (match_operand:HI 0 "register_operand" "=a")
1003 (match_operand 1 "register_operand" "f")
1004 (match_operand 2 "const0_operand" "X"))]
1006 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1007 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1008 "* return output_fp_compare (insn, operands, 0, 0);"
1009 [(set_attr "type" "multi")
1010 (set_attr "unit" "i387")
1012 (cond [(match_operand:SF 1 "" "")
1014 (match_operand:DF 1 "" "")
1017 (const_string "XF")))])
1019 (define_insn_and_split "*cmpfp_0_cc"
1020 [(set (reg:CCFP FLAGS_REG)
1022 (match_operand 1 "register_operand" "f")
1023 (match_operand 2 "const0_operand" "X")))
1024 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1025 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1026 && TARGET_SAHF && !TARGET_CMOVE
1027 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1029 "&& reload_completed"
1032 [(compare:CCFP (match_dup 1)(match_dup 2))]
1034 (set (reg:CC FLAGS_REG)
1035 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1037 [(set_attr "type" "multi")
1038 (set_attr "unit" "i387")
1040 (cond [(match_operand:SF 1 "" "")
1042 (match_operand:DF 1 "" "")
1045 (const_string "XF")))])
1047 (define_insn "*cmpfp_xf"
1048 [(set (match_operand:HI 0 "register_operand" "=a")
1051 (match_operand:XF 1 "register_operand" "f")
1052 (match_operand:XF 2 "register_operand" "f"))]
1055 "* return output_fp_compare (insn, operands, 0, 0);"
1056 [(set_attr "type" "multi")
1057 (set_attr "unit" "i387")
1058 (set_attr "mode" "XF")])
1060 (define_insn_and_split "*cmpfp_xf_cc"
1061 [(set (reg:CCFP FLAGS_REG)
1063 (match_operand:XF 1 "register_operand" "f")
1064 (match_operand:XF 2 "register_operand" "f")))
1065 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1067 && TARGET_SAHF && !TARGET_CMOVE"
1069 "&& reload_completed"
1072 [(compare:CCFP (match_dup 1)(match_dup 2))]
1074 (set (reg:CC FLAGS_REG)
1075 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1077 [(set_attr "type" "multi")
1078 (set_attr "unit" "i387")
1079 (set_attr "mode" "XF")])
1081 (define_insn "*cmpfp_<mode>"
1082 [(set (match_operand:HI 0 "register_operand" "=a")
1085 (match_operand:MODEF 1 "register_operand" "f")
1086 (match_operand:MODEF 2 "nonimmediate_operand" "fm"))]
1089 "* return output_fp_compare (insn, operands, 0, 0);"
1090 [(set_attr "type" "multi")
1091 (set_attr "unit" "i387")
1092 (set_attr "mode" "<MODE>")])
1094 (define_insn_and_split "*cmpfp_<mode>_cc"
1095 [(set (reg:CCFP FLAGS_REG)
1097 (match_operand:MODEF 1 "register_operand" "f")
1098 (match_operand:MODEF 2 "nonimmediate_operand" "fm")))
1099 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1101 && TARGET_SAHF && !TARGET_CMOVE"
1103 "&& reload_completed"
1106 [(compare:CCFP (match_dup 1)(match_dup 2))]
1108 (set (reg:CC FLAGS_REG)
1109 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1111 [(set_attr "type" "multi")
1112 (set_attr "unit" "i387")
1113 (set_attr "mode" "<MODE>")])
1115 (define_insn "*cmpfp_u"
1116 [(set (match_operand:HI 0 "register_operand" "=a")
1119 (match_operand 1 "register_operand" "f")
1120 (match_operand 2 "register_operand" "f"))]
1122 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1123 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1124 "* return output_fp_compare (insn, operands, 0, 1);"
1125 [(set_attr "type" "multi")
1126 (set_attr "unit" "i387")
1128 (cond [(match_operand:SF 1 "" "")
1130 (match_operand:DF 1 "" "")
1133 (const_string "XF")))])
1135 (define_insn_and_split "*cmpfp_u_cc"
1136 [(set (reg:CCFPU FLAGS_REG)
1138 (match_operand 1 "register_operand" "f")
1139 (match_operand 2 "register_operand" "f")))
1140 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1141 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1142 && TARGET_SAHF && !TARGET_CMOVE
1143 && GET_MODE (operands[1]) == GET_MODE (operands[2])"
1145 "&& reload_completed"
1148 [(compare:CCFPU (match_dup 1)(match_dup 2))]
1150 (set (reg:CC FLAGS_REG)
1151 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1153 [(set_attr "type" "multi")
1154 (set_attr "unit" "i387")
1156 (cond [(match_operand:SF 1 "" "")
1158 (match_operand:DF 1 "" "")
1161 (const_string "XF")))])
1163 (define_insn "*cmpfp_<mode>"
1164 [(set (match_operand:HI 0 "register_operand" "=a")
1167 (match_operand 1 "register_operand" "f")
1168 (match_operator 3 "float_operator"
1169 [(match_operand:X87MODEI12 2 "memory_operand" "m")]))]
1171 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1172 && TARGET_USE_<MODE>MODE_FIOP
1173 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1174 "* return output_fp_compare (insn, operands, 0, 0);"
1175 [(set_attr "type" "multi")
1176 (set_attr "unit" "i387")
1177 (set_attr "fp_int_src" "true")
1178 (set_attr "mode" "<MODE>")])
1180 (define_insn_and_split "*cmpfp_<mode>_cc"
1181 [(set (reg:CCFP FLAGS_REG)
1183 (match_operand 1 "register_operand" "f")
1184 (match_operator 3 "float_operator"
1185 [(match_operand:X87MODEI12 2 "memory_operand" "m")])))
1186 (clobber (match_operand:HI 0 "register_operand" "=a"))]
1187 "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
1188 && TARGET_SAHF && !TARGET_CMOVE
1189 && TARGET_USE_<MODE>MODE_FIOP
1190 && (GET_MODE (operands [3]) == GET_MODE (operands[1]))"
1192 "&& reload_completed"
1197 (match_op_dup 3 [(match_dup 2)]))]
1199 (set (reg:CC FLAGS_REG)
1200 (unspec:CC [(match_dup 0)] UNSPEC_SAHF))]
1202 [(set_attr "type" "multi")
1203 (set_attr "unit" "i387")
1204 (set_attr "fp_int_src" "true")
1205 (set_attr "mode" "<MODE>")])
1207 ;; FP compares, step 2
1208 ;; Move the fpsw to ax.
1210 (define_insn "x86_fnstsw_1"
1211 [(set (match_operand:HI 0 "register_operand" "=a")
1212 (unspec:HI [(reg:CCFP FPSR_REG)] UNSPEC_FNSTSW))]
1215 [(set_attr "length" "2")
1216 (set_attr "mode" "SI")
1217 (set_attr "unit" "i387")])
1219 ;; FP compares, step 3
1220 ;; Get ax into flags, general case.
1222 (define_insn "x86_sahf_1"
1223 [(set (reg:CC FLAGS_REG)
1224 (unspec:CC [(match_operand:HI 0 "register_operand" "a")]
1228 #ifdef HAVE_AS_IX86_SAHF
1231 return ".byte\t0x9e";
1234 [(set_attr "length" "1")
1235 (set_attr "athlon_decode" "vector")
1236 (set_attr "amdfam10_decode" "direct")
1237 (set_attr "mode" "SI")])
1239 ;; Pentium Pro can do steps 1 through 3 in one go.
1240 ;; comi*, ucomi*, fcomi*, ficomi*,fucomi* (i387 instructions set condition codes)
1241 (define_insn "*cmpfp_i_mixed"
1242 [(set (reg:CCFP FLAGS_REG)
1243 (compare:CCFP (match_operand 0 "register_operand" "f,x")
1244 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1245 "TARGET_MIX_SSE_I387
1246 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1247 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1248 "* return output_fp_compare (insn, operands, 1, 0);"
1249 [(set_attr "type" "fcmp,ssecomi")
1251 (if_then_else (match_operand:SF 1 "" "")
1253 (const_string "DF")))
1254 (set_attr "athlon_decode" "vector")
1255 (set_attr "amdfam10_decode" "direct")])
1257 (define_insn "*cmpfp_i_sse"
1258 [(set (reg:CCFP FLAGS_REG)
1259 (compare:CCFP (match_operand 0 "register_operand" "x")
1260 (match_operand 1 "nonimmediate_operand" "xm")))]
1262 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1263 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1264 "* return output_fp_compare (insn, operands, 1, 0);"
1265 [(set_attr "type" "ssecomi")
1267 (if_then_else (match_operand:SF 1 "" "")
1269 (const_string "DF")))
1270 (set_attr "athlon_decode" "vector")
1271 (set_attr "amdfam10_decode" "direct")])
1273 (define_insn "*cmpfp_i_i387"
1274 [(set (reg:CCFP FLAGS_REG)
1275 (compare:CCFP (match_operand 0 "register_operand" "f")
1276 (match_operand 1 "register_operand" "f")))]
1277 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1279 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1280 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1281 "* return output_fp_compare (insn, operands, 1, 0);"
1282 [(set_attr "type" "fcmp")
1284 (cond [(match_operand:SF 1 "" "")
1286 (match_operand:DF 1 "" "")
1289 (const_string "XF")))
1290 (set_attr "athlon_decode" "vector")
1291 (set_attr "amdfam10_decode" "direct")])
1293 (define_insn "*cmpfp_iu_mixed"
1294 [(set (reg:CCFPU FLAGS_REG)
1295 (compare:CCFPU (match_operand 0 "register_operand" "f,x")
1296 (match_operand 1 "nonimmediate_operand" "f,xm")))]
1297 "TARGET_MIX_SSE_I387
1298 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1299 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1300 "* return output_fp_compare (insn, operands, 1, 1);"
1301 [(set_attr "type" "fcmp,ssecomi")
1303 (if_then_else (match_operand:SF 1 "" "")
1305 (const_string "DF")))
1306 (set_attr "athlon_decode" "vector")
1307 (set_attr "amdfam10_decode" "direct")])
1309 (define_insn "*cmpfp_iu_sse"
1310 [(set (reg:CCFPU FLAGS_REG)
1311 (compare:CCFPU (match_operand 0 "register_operand" "x")
1312 (match_operand 1 "nonimmediate_operand" "xm")))]
1314 && SSE_FLOAT_MODE_P (GET_MODE (operands[0]))
1315 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1316 "* return output_fp_compare (insn, operands, 1, 1);"
1317 [(set_attr "type" "ssecomi")
1319 (if_then_else (match_operand:SF 1 "" "")
1321 (const_string "DF")))
1322 (set_attr "athlon_decode" "vector")
1323 (set_attr "amdfam10_decode" "direct")])
1325 (define_insn "*cmpfp_iu_387"
1326 [(set (reg:CCFPU FLAGS_REG)
1327 (compare:CCFPU (match_operand 0 "register_operand" "f")
1328 (match_operand 1 "register_operand" "f")))]
1329 "X87_FLOAT_MODE_P (GET_MODE (operands[0]))
1331 && !(SSE_FLOAT_MODE_P (GET_MODE (operands[0])) && TARGET_SSE_MATH)
1332 && GET_MODE (operands[0]) == GET_MODE (operands[1])"
1333 "* return output_fp_compare (insn, operands, 1, 1);"
1334 [(set_attr "type" "fcmp")
1336 (cond [(match_operand:SF 1 "" "")
1338 (match_operand:DF 1 "" "")
1341 (const_string "XF")))
1342 (set_attr "athlon_decode" "vector")
1343 (set_attr "amdfam10_decode" "direct")])
1345 ;; Move instructions.
1347 ;; General case of fullword move.
1349 (define_expand "movsi"
1350 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1351 (match_operand:SI 1 "general_operand" ""))]
1353 "ix86_expand_move (SImode, operands); DONE;")
1355 ;; Push/pop instructions. They are separate since autoinc/dec is not a
1358 ;; %%% We don't use a post-inc memory reference because x86 is not a
1359 ;; general AUTO_INC_DEC host, which impacts how it is treated in flow.
1360 ;; Changing this impacts compiler performance on other non-AUTO_INC_DEC
1361 ;; targets without our curiosities, and it is just as easy to represent
1362 ;; this differently.
1364 (define_insn "*pushsi2"
1365 [(set (match_operand:SI 0 "push_operand" "=<")
1366 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))]
1369 [(set_attr "type" "push")
1370 (set_attr "mode" "SI")])
1372 ;; For 64BIT abi we always round up to 8 bytes.
1373 (define_insn "*pushsi2_rex64"
1374 [(set (match_operand:SI 0 "push_operand" "=X")
1375 (match_operand:SI 1 "nonmemory_no_elim_operand" "ri"))]
1378 [(set_attr "type" "push")
1379 (set_attr "mode" "SI")])
1381 (define_insn "*pushsi2_prologue"
1382 [(set (match_operand:SI 0 "push_operand" "=<")
1383 (match_operand:SI 1 "general_no_elim_operand" "ri*m"))
1384 (clobber (mem:BLK (scratch)))]
1387 [(set_attr "type" "push")
1388 (set_attr "mode" "SI")])
1390 (define_insn "*popsi1_epilogue"
1391 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1392 (mem:SI (reg:SI SP_REG)))
1393 (set (reg:SI SP_REG)
1394 (plus:SI (reg:SI SP_REG) (const_int 4)))
1395 (clobber (mem:BLK (scratch)))]
1398 [(set_attr "type" "pop")
1399 (set_attr "mode" "SI")])
1401 (define_insn "popsi1"
1402 [(set (match_operand:SI 0 "nonimmediate_operand" "=r*m")
1403 (mem:SI (reg:SI SP_REG)))
1404 (set (reg:SI SP_REG)
1405 (plus:SI (reg:SI SP_REG) (const_int 4)))]
1408 [(set_attr "type" "pop")
1409 (set_attr "mode" "SI")])
1411 (define_insn "*movsi_xor"
1412 [(set (match_operand:SI 0 "register_operand" "=r")
1413 (match_operand:SI 1 "const0_operand" "i"))
1414 (clobber (reg:CC FLAGS_REG))]
1415 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1417 [(set_attr "type" "alu1")
1418 (set_attr "mode" "SI")
1419 (set_attr "length_immediate" "0")])
1421 (define_insn "*movsi_or"
1422 [(set (match_operand:SI 0 "register_operand" "=r")
1423 (match_operand:SI 1 "immediate_operand" "i"))
1424 (clobber (reg:CC FLAGS_REG))]
1426 && operands[1] == constm1_rtx
1427 && (TARGET_MOVE_M1_VIA_OR || optimize_size)"
1429 operands[1] = constm1_rtx;
1430 return "or{l}\t{%1, %0|%0, %1}";
1432 [(set_attr "type" "alu1")
1433 (set_attr "mode" "SI")
1434 (set_attr "length_immediate" "1")])
1436 (define_insn "*movsi_1"
1437 [(set (match_operand:SI 0 "nonimmediate_operand"
1438 "=r ,m ,*y,*y,?rm,?*y,*x,*x,?r ,m ,?*Yi,*x")
1439 (match_operand:SI 1 "general_operand"
1440 "rinm,rin,C ,*y,*y ,rm ,C ,*x,*Yi,*x,r ,m "))]
1441 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1443 switch (get_attr_type (insn))
1446 if (get_attr_mode (insn) == MODE_TI)
1447 return "pxor\t%0, %0";
1448 return "xorps\t%0, %0";
1451 switch (get_attr_mode (insn))
1454 return "movdqa\t{%1, %0|%0, %1}";
1456 return "movaps\t{%1, %0|%0, %1}";
1458 return "movd\t{%1, %0|%0, %1}";
1460 return "movss\t{%1, %0|%0, %1}";
1466 return "pxor\t%0, %0";
1469 if (get_attr_mode (insn) == MODE_DI)
1470 return "movq\t{%1, %0|%0, %1}";
1471 return "movd\t{%1, %0|%0, %1}";
1474 return "lea{l}\t{%1, %0|%0, %1}";
1477 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
1478 return "mov{l}\t{%1, %0|%0, %1}";
1482 (cond [(eq_attr "alternative" "2")
1483 (const_string "mmxadd")
1484 (eq_attr "alternative" "3,4,5")
1485 (const_string "mmxmov")
1486 (eq_attr "alternative" "6")
1487 (const_string "sselog1")
1488 (eq_attr "alternative" "7,8,9,10,11")
1489 (const_string "ssemov")
1490 (match_operand:DI 1 "pic_32bit_operand" "")
1491 (const_string "lea")
1493 (const_string "imov")))
1495 (cond [(eq_attr "alternative" "2,3")
1497 (eq_attr "alternative" "6,7")
1499 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
1500 (const_string "V4SF")
1501 (const_string "TI"))
1502 (and (eq_attr "alternative" "8,9,10,11")
1503 (eq (symbol_ref "TARGET_SSE2") (const_int 0)))
1506 (const_string "SI")))])
1508 ;; Stores and loads of ax to arbitrary constant address.
1509 ;; We fake an second form of instruction to force reload to load address
1510 ;; into register when rax is not available
1511 (define_insn "*movabssi_1_rex64"
1512 [(set (mem:SI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1513 (match_operand:SI 1 "nonmemory_operand" "a,er"))]
1514 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1516 movabs{l}\t{%1, %P0|%P0, %1}
1517 mov{l}\t{%1, %a0|%a0, %1}"
1518 [(set_attr "type" "imov")
1519 (set_attr "modrm" "0,*")
1520 (set_attr "length_address" "8,0")
1521 (set_attr "length_immediate" "0,*")
1522 (set_attr "memory" "store")
1523 (set_attr "mode" "SI")])
1525 (define_insn "*movabssi_2_rex64"
1526 [(set (match_operand:SI 0 "register_operand" "=a,r")
1527 (mem:SI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1528 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1530 movabs{l}\t{%P1, %0|%0, %P1}
1531 mov{l}\t{%a1, %0|%0, %a1}"
1532 [(set_attr "type" "imov")
1533 (set_attr "modrm" "0,*")
1534 (set_attr "length_address" "8,0")
1535 (set_attr "length_immediate" "0")
1536 (set_attr "memory" "load")
1537 (set_attr "mode" "SI")])
1539 (define_insn "*swapsi"
1540 [(set (match_operand:SI 0 "register_operand" "+r")
1541 (match_operand:SI 1 "register_operand" "+r"))
1546 [(set_attr "type" "imov")
1547 (set_attr "mode" "SI")
1548 (set_attr "pent_pair" "np")
1549 (set_attr "athlon_decode" "vector")
1550 (set_attr "amdfam10_decode" "double")])
1552 (define_expand "movhi"
1553 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1554 (match_operand:HI 1 "general_operand" ""))]
1556 "ix86_expand_move (HImode, operands); DONE;")
1558 (define_insn "*pushhi2"
1559 [(set (match_operand:HI 0 "push_operand" "=X")
1560 (match_operand:HI 1 "nonmemory_no_elim_operand" "rn"))]
1563 [(set_attr "type" "push")
1564 (set_attr "mode" "SI")])
1566 ;; For 64BIT abi we always round up to 8 bytes.
1567 (define_insn "*pushhi2_rex64"
1568 [(set (match_operand:HI 0 "push_operand" "=X")
1569 (match_operand:HI 1 "nonmemory_no_elim_operand" "ri"))]
1572 [(set_attr "type" "push")
1573 (set_attr "mode" "DI")])
1575 (define_insn "*movhi_1"
1576 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m")
1577 (match_operand:HI 1 "general_operand" "r,rn,rm,rn"))]
1578 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1580 switch (get_attr_type (insn))
1583 /* movzwl is faster than movw on p2 due to partial word stalls,
1584 though not as fast as an aligned movl. */
1585 return "movz{wl|x}\t{%1, %k0|%k0, %1}";
1587 if (get_attr_mode (insn) == MODE_SI)
1588 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1590 return "mov{w}\t{%1, %0|%0, %1}";
1594 (cond [(ne (symbol_ref "optimize_size") (const_int 0))
1595 (const_string "imov")
1596 (and (eq_attr "alternative" "0")
1597 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1599 (eq (symbol_ref "TARGET_HIMODE_MATH")
1601 (const_string "imov")
1602 (and (eq_attr "alternative" "1,2")
1603 (match_operand:HI 1 "aligned_operand" ""))
1604 (const_string "imov")
1605 (and (ne (symbol_ref "TARGET_MOVX")
1607 (eq_attr "alternative" "0,2"))
1608 (const_string "imovx")
1610 (const_string "imov")))
1612 (cond [(eq_attr "type" "imovx")
1614 (and (eq_attr "alternative" "1,2")
1615 (match_operand:HI 1 "aligned_operand" ""))
1617 (and (eq_attr "alternative" "0")
1618 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1620 (eq (symbol_ref "TARGET_HIMODE_MATH")
1624 (const_string "HI")))])
1626 ;; Stores and loads of ax to arbitrary constant address.
1627 ;; We fake an second form of instruction to force reload to load address
1628 ;; into register when rax is not available
1629 (define_insn "*movabshi_1_rex64"
1630 [(set (mem:HI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1631 (match_operand:HI 1 "nonmemory_operand" "a,er"))]
1632 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1634 movabs{w}\t{%1, %P0|%P0, %1}
1635 mov{w}\t{%1, %a0|%a0, %1}"
1636 [(set_attr "type" "imov")
1637 (set_attr "modrm" "0,*")
1638 (set_attr "length_address" "8,0")
1639 (set_attr "length_immediate" "0,*")
1640 (set_attr "memory" "store")
1641 (set_attr "mode" "HI")])
1643 (define_insn "*movabshi_2_rex64"
1644 [(set (match_operand:HI 0 "register_operand" "=a,r")
1645 (mem:HI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1646 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1648 movabs{w}\t{%P1, %0|%0, %P1}
1649 mov{w}\t{%a1, %0|%0, %a1}"
1650 [(set_attr "type" "imov")
1651 (set_attr "modrm" "0,*")
1652 (set_attr "length_address" "8,0")
1653 (set_attr "length_immediate" "0")
1654 (set_attr "memory" "load")
1655 (set_attr "mode" "HI")])
1657 (define_insn "*swaphi_1"
1658 [(set (match_operand:HI 0 "register_operand" "+r")
1659 (match_operand:HI 1 "register_operand" "+r"))
1662 "!TARGET_PARTIAL_REG_STALL || optimize_size"
1664 [(set_attr "type" "imov")
1665 (set_attr "mode" "SI")
1666 (set_attr "pent_pair" "np")
1667 (set_attr "athlon_decode" "vector")
1668 (set_attr "amdfam10_decode" "double")])
1670 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1671 (define_insn "*swaphi_2"
1672 [(set (match_operand:HI 0 "register_operand" "+r")
1673 (match_operand:HI 1 "register_operand" "+r"))
1676 "TARGET_PARTIAL_REG_STALL"
1678 [(set_attr "type" "imov")
1679 (set_attr "mode" "HI")
1680 (set_attr "pent_pair" "np")
1681 (set_attr "athlon_decode" "vector")])
1683 (define_expand "movstricthi"
1684 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1685 (match_operand:HI 1 "general_operand" ""))]
1686 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1688 /* Don't generate memory->memory moves, go through a register */
1689 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1690 operands[1] = force_reg (HImode, operands[1]);
1693 (define_insn "*movstricthi_1"
1694 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+rm,r"))
1695 (match_operand:HI 1 "general_operand" "rn,m"))]
1696 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1697 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1698 "mov{w}\t{%1, %0|%0, %1}"
1699 [(set_attr "type" "imov")
1700 (set_attr "mode" "HI")])
1702 (define_insn "*movstricthi_xor"
1703 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
1704 (match_operand:HI 1 "const0_operand" "i"))
1705 (clobber (reg:CC FLAGS_REG))]
1707 && ((!TARGET_USE_MOV0 && !TARGET_PARTIAL_REG_STALL) || optimize_size)"
1709 [(set_attr "type" "alu1")
1710 (set_attr "mode" "HI")
1711 (set_attr "length_immediate" "0")])
1713 (define_expand "movqi"
1714 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1715 (match_operand:QI 1 "general_operand" ""))]
1717 "ix86_expand_move (QImode, operands); DONE;")
1719 ;; emit_push_insn when it calls move_by_pieces requires an insn to
1720 ;; "push a byte". But actually we use pushl, which has the effect
1721 ;; of rounding the amount pushed up to a word.
1723 (define_insn "*pushqi2"
1724 [(set (match_operand:QI 0 "push_operand" "=X")
1725 (match_operand:QI 1 "nonmemory_no_elim_operand" "rn"))]
1728 [(set_attr "type" "push")
1729 (set_attr "mode" "SI")])
1731 ;; For 64BIT abi we always round up to 8 bytes.
1732 (define_insn "*pushqi2_rex64"
1733 [(set (match_operand:QI 0 "push_operand" "=X")
1734 (match_operand:QI 1 "nonmemory_no_elim_operand" "qi"))]
1737 [(set_attr "type" "push")
1738 (set_attr "mode" "DI")])
1740 ;; Situation is quite tricky about when to choose full sized (SImode) move
1741 ;; over QImode moves. For Q_REG -> Q_REG move we use full size only for
1742 ;; partial register dependency machines (such as AMD Athlon), where QImode
1743 ;; moves issue extra dependency and for partial register stalls machines
1744 ;; that don't use QImode patterns (and QImode move cause stall on the next
1747 ;; For loads of Q_REG to NONQ_REG we use full sized moves except for partial
1748 ;; register stall machines with, where we use QImode instructions, since
1749 ;; partial register stall can be caused there. Then we use movzx.
1750 (define_insn "*movqi_1"
1751 [(set (match_operand:QI 0 "nonimmediate_operand" "=q,q ,q ,r,r ,?r,m")
1752 (match_operand:QI 1 "general_operand" " q,qn,qm,q,rn,qm,qn"))]
1753 "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
1755 switch (get_attr_type (insn))
1758 gcc_assert (ANY_QI_REG_P (operands[1]) || MEM_P (operands[1]));
1759 return "movz{bl|x}\t{%1, %k0|%k0, %1}";
1761 if (get_attr_mode (insn) == MODE_SI)
1762 return "mov{l}\t{%k1, %k0|%k0, %k1}";
1764 return "mov{b}\t{%1, %0|%0, %1}";
1768 (cond [(and (eq_attr "alternative" "5")
1769 (not (match_operand:QI 1 "aligned_operand" "")))
1770 (const_string "imovx")
1771 (ne (symbol_ref "optimize_size") (const_int 0))
1772 (const_string "imov")
1773 (and (eq_attr "alternative" "3")
1774 (ior (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1776 (eq (symbol_ref "TARGET_QIMODE_MATH")
1778 (const_string "imov")
1779 (eq_attr "alternative" "3,5")
1780 (const_string "imovx")
1781 (and (ne (symbol_ref "TARGET_MOVX")
1783 (eq_attr "alternative" "2"))
1784 (const_string "imovx")
1786 (const_string "imov")))
1788 (cond [(eq_attr "alternative" "3,4,5")
1790 (eq_attr "alternative" "6")
1792 (eq_attr "type" "imovx")
1794 (and (eq_attr "type" "imov")
1795 (and (eq_attr "alternative" "0,1")
1796 (and (ne (symbol_ref "TARGET_PARTIAL_REG_DEPENDENCY")
1798 (and (eq (symbol_ref "optimize_size")
1800 (eq (symbol_ref "TARGET_PARTIAL_REG_STALL")
1803 ;; Avoid partial register stalls when not using QImode arithmetic
1804 (and (eq_attr "type" "imov")
1805 (and (eq_attr "alternative" "0,1")
1806 (and (ne (symbol_ref "TARGET_PARTIAL_REG_STALL")
1808 (eq (symbol_ref "TARGET_QIMODE_MATH")
1812 (const_string "QI")))])
1814 (define_insn "*swapqi_1"
1815 [(set (match_operand:QI 0 "register_operand" "+r")
1816 (match_operand:QI 1 "register_operand" "+r"))
1819 "!TARGET_PARTIAL_REG_STALL || optimize_size"
1821 [(set_attr "type" "imov")
1822 (set_attr "mode" "SI")
1823 (set_attr "pent_pair" "np")
1824 (set_attr "athlon_decode" "vector")
1825 (set_attr "amdfam10_decode" "vector")])
1827 ;; Not added amdfam10_decode since TARGET_PARTIAL_REG_STALL is disabled for AMDFAM10
1828 (define_insn "*swapqi_2"
1829 [(set (match_operand:QI 0 "register_operand" "+q")
1830 (match_operand:QI 1 "register_operand" "+q"))
1833 "TARGET_PARTIAL_REG_STALL"
1835 [(set_attr "type" "imov")
1836 (set_attr "mode" "QI")
1837 (set_attr "pent_pair" "np")
1838 (set_attr "athlon_decode" "vector")])
1840 (define_expand "movstrictqi"
1841 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1842 (match_operand:QI 1 "general_operand" ""))]
1843 "! TARGET_PARTIAL_REG_STALL || optimize_size"
1845 /* Don't generate memory->memory moves, go through a register. */
1846 if (MEM_P (operands[0]) && MEM_P (operands[1]))
1847 operands[1] = force_reg (QImode, operands[1]);
1850 (define_insn "*movstrictqi_1"
1851 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+qm,q"))
1852 (match_operand:QI 1 "general_operand" "*qn,m"))]
1853 "(! TARGET_PARTIAL_REG_STALL || optimize_size)
1854 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
1855 "mov{b}\t{%1, %0|%0, %1}"
1856 [(set_attr "type" "imov")
1857 (set_attr "mode" "QI")])
1859 (define_insn "*movstrictqi_xor"
1860 [(set (strict_low_part (match_operand:QI 0 "q_regs_operand" "+q"))
1861 (match_operand:QI 1 "const0_operand" "i"))
1862 (clobber (reg:CC FLAGS_REG))]
1863 "reload_completed && (!TARGET_USE_MOV0 || optimize_size)"
1865 [(set_attr "type" "alu1")
1866 (set_attr "mode" "QI")
1867 (set_attr "length_immediate" "0")])
1869 (define_insn "*movsi_extv_1"
1870 [(set (match_operand:SI 0 "register_operand" "=R")
1871 (sign_extract:SI (match_operand 1 "ext_register_operand" "Q")
1875 "movs{bl|x}\t{%h1, %0|%0, %h1}"
1876 [(set_attr "type" "imovx")
1877 (set_attr "mode" "SI")])
1879 (define_insn "*movhi_extv_1"
1880 [(set (match_operand:HI 0 "register_operand" "=R")
1881 (sign_extract:HI (match_operand 1 "ext_register_operand" "Q")
1885 "movs{bl|x}\t{%h1, %k0|%k0, %h1}"
1886 [(set_attr "type" "imovx")
1887 (set_attr "mode" "SI")])
1889 (define_insn "*movqi_extv_1"
1890 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?r")
1891 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1896 switch (get_attr_type (insn))
1899 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1901 return "mov{b}\t{%h1, %0|%0, %h1}";
1905 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1906 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1907 (ne (symbol_ref "TARGET_MOVX")
1909 (const_string "imovx")
1910 (const_string "imov")))
1912 (if_then_else (eq_attr "type" "imovx")
1914 (const_string "QI")))])
1916 (define_insn "*movqi_extv_1_rex64"
1917 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
1918 (sign_extract:QI (match_operand 1 "ext_register_operand" "Q,Q")
1923 switch (get_attr_type (insn))
1926 return "movs{bl|x}\t{%h1, %k0|%k0, %h1}";
1928 return "mov{b}\t{%h1, %0|%0, %h1}";
1932 (if_then_else (and (match_operand:QI 0 "register_operand" "")
1933 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
1934 (ne (symbol_ref "TARGET_MOVX")
1936 (const_string "imovx")
1937 (const_string "imov")))
1939 (if_then_else (eq_attr "type" "imovx")
1941 (const_string "QI")))])
1943 ;; Stores and loads of ax to arbitrary constant address.
1944 ;; We fake an second form of instruction to force reload to load address
1945 ;; into register when rax is not available
1946 (define_insn "*movabsqi_1_rex64"
1947 [(set (mem:QI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
1948 (match_operand:QI 1 "nonmemory_operand" "a,er"))]
1949 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
1951 movabs{b}\t{%1, %P0|%P0, %1}
1952 mov{b}\t{%1, %a0|%a0, %1}"
1953 [(set_attr "type" "imov")
1954 (set_attr "modrm" "0,*")
1955 (set_attr "length_address" "8,0")
1956 (set_attr "length_immediate" "0,*")
1957 (set_attr "memory" "store")
1958 (set_attr "mode" "QI")])
1960 (define_insn "*movabsqi_2_rex64"
1961 [(set (match_operand:QI 0 "register_operand" "=a,r")
1962 (mem:QI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
1963 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
1965 movabs{b}\t{%P1, %0|%0, %P1}
1966 mov{b}\t{%a1, %0|%0, %a1}"
1967 [(set_attr "type" "imov")
1968 (set_attr "modrm" "0,*")
1969 (set_attr "length_address" "8,0")
1970 (set_attr "length_immediate" "0")
1971 (set_attr "memory" "load")
1972 (set_attr "mode" "QI")])
1974 (define_insn "*movdi_extzv_1"
1975 [(set (match_operand:DI 0 "register_operand" "=R")
1976 (zero_extract:DI (match_operand 1 "ext_register_operand" "Q")
1980 "movz{bl|x}\t{%h1, %k0|%k0, %h1}"
1981 [(set_attr "type" "imovx")
1982 (set_attr "mode" "DI")])
1984 (define_insn "*movsi_extzv_1"
1985 [(set (match_operand:SI 0 "register_operand" "=R")
1986 (zero_extract:SI (match_operand 1 "ext_register_operand" "Q")
1990 "movz{bl|x}\t{%h1, %0|%0, %h1}"
1991 [(set_attr "type" "imovx")
1992 (set_attr "mode" "SI")])
1994 (define_insn "*movqi_extzv_2"
1995 [(set (match_operand:QI 0 "nonimmediate_operand" "=Qm,?R")
1996 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2001 switch (get_attr_type (insn))
2004 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2006 return "mov{b}\t{%h1, %0|%0, %h1}";
2010 (if_then_else (and (match_operand:QI 0 "register_operand" "")
2011 (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2012 (ne (symbol_ref "TARGET_MOVX")
2014 (const_string "imovx")
2015 (const_string "imov")))
2017 (if_then_else (eq_attr "type" "imovx")
2019 (const_string "QI")))])
2021 (define_insn "*movqi_extzv_2_rex64"
2022 [(set (match_operand:QI 0 "register_operand" "=Q,?R")
2023 (subreg:QI (zero_extract:SI (match_operand 1 "ext_register_operand" "Q,Q")
2028 switch (get_attr_type (insn))
2031 return "movz{bl|x}\t{%h1, %k0|%k0, %h1}";
2033 return "mov{b}\t{%h1, %0|%0, %h1}";
2037 (if_then_else (ior (not (match_operand:QI 0 "q_regs_operand" ""))
2038 (ne (symbol_ref "TARGET_MOVX")
2040 (const_string "imovx")
2041 (const_string "imov")))
2043 (if_then_else (eq_attr "type" "imovx")
2045 (const_string "QI")))])
2047 (define_insn "movsi_insv_1"
2048 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2051 (match_operand:SI 1 "general_operand" "Qmn"))]
2053 "mov{b}\t{%b1, %h0|%h0, %b1}"
2054 [(set_attr "type" "imov")
2055 (set_attr "mode" "QI")])
2057 (define_insn "*movsi_insv_1_rex64"
2058 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2061 (match_operand:SI 1 "nonmemory_operand" "Qn"))]
2063 "mov{b}\t{%b1, %h0|%h0, %b1}"
2064 [(set_attr "type" "imov")
2065 (set_attr "mode" "QI")])
2067 (define_insn "movdi_insv_1_rex64"
2068 [(set (zero_extract:DI (match_operand 0 "ext_register_operand" "+Q")
2071 (match_operand:DI 1 "nonmemory_operand" "Qn"))]
2073 "mov{b}\t{%b1, %h0|%h0, %b1}"
2074 [(set_attr "type" "imov")
2075 (set_attr "mode" "QI")])
2077 (define_insn "*movqi_insv_2"
2078 [(set (zero_extract:SI (match_operand 0 "ext_register_operand" "+Q")
2081 (lshiftrt:SI (match_operand:SI 1 "register_operand" "Q")
2084 "mov{b}\t{%h1, %h0|%h0, %h1}"
2085 [(set_attr "type" "imov")
2086 (set_attr "mode" "QI")])
2088 (define_expand "movdi"
2089 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2090 (match_operand:DI 1 "general_operand" ""))]
2092 "ix86_expand_move (DImode, operands); DONE;")
2094 (define_insn "*pushdi"
2095 [(set (match_operand:DI 0 "push_operand" "=<")
2096 (match_operand:DI 1 "general_no_elim_operand" "riF*m"))]
2100 (define_insn "*pushdi2_rex64"
2101 [(set (match_operand:DI 0 "push_operand" "=<,!<")
2102 (match_operand:DI 1 "general_no_elim_operand" "re*m,n"))]
2107 [(set_attr "type" "push,multi")
2108 (set_attr "mode" "DI")])
2110 ;; Convert impossible pushes of immediate to existing instructions.
2111 ;; First try to get scratch register and go through it. In case this
2112 ;; fails, push sign extended lower part first and then overwrite
2113 ;; upper part by 32bit move.
2115 [(match_scratch:DI 2 "r")
2116 (set (match_operand:DI 0 "push_operand" "")
2117 (match_operand:DI 1 "immediate_operand" ""))]
2118 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2119 && !x86_64_immediate_operand (operands[1], DImode)"
2120 [(set (match_dup 2) (match_dup 1))
2121 (set (match_dup 0) (match_dup 2))]
2124 ;; We need to define this as both peepholer and splitter for case
2125 ;; peephole2 pass is not run.
2126 ;; "&& 1" is needed to keep it from matching the previous pattern.
2128 [(set (match_operand:DI 0 "push_operand" "")
2129 (match_operand:DI 1 "immediate_operand" ""))]
2130 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2131 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2132 [(set (match_dup 0) (match_dup 1))
2133 (set (match_dup 2) (match_dup 3))]
2134 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2135 operands[1] = gen_lowpart (DImode, operands[2]);
2136 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2141 [(set (match_operand:DI 0 "push_operand" "")
2142 (match_operand:DI 1 "immediate_operand" ""))]
2143 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2144 ? epilogue_completed : reload_completed)
2145 && !symbolic_operand (operands[1], DImode)
2146 && !x86_64_immediate_operand (operands[1], DImode)"
2147 [(set (match_dup 0) (match_dup 1))
2148 (set (match_dup 2) (match_dup 3))]
2149 "split_di (&operands[1], 1, &operands[2], &operands[3]);
2150 operands[1] = gen_lowpart (DImode, operands[2]);
2151 operands[2] = gen_rtx_MEM (SImode, gen_rtx_PLUS (DImode, stack_pointer_rtx,
2155 (define_insn "*pushdi2_prologue_rex64"
2156 [(set (match_operand:DI 0 "push_operand" "=<")
2157 (match_operand:DI 1 "general_no_elim_operand" "re*m"))
2158 (clobber (mem:BLK (scratch)))]
2161 [(set_attr "type" "push")
2162 (set_attr "mode" "DI")])
2164 (define_insn "*popdi1_epilogue_rex64"
2165 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2166 (mem:DI (reg:DI SP_REG)))
2167 (set (reg:DI SP_REG)
2168 (plus:DI (reg:DI SP_REG) (const_int 8)))
2169 (clobber (mem:BLK (scratch)))]
2172 [(set_attr "type" "pop")
2173 (set_attr "mode" "DI")])
2175 (define_insn "popdi1"
2176 [(set (match_operand:DI 0 "nonimmediate_operand" "=r*m")
2177 (mem:DI (reg:DI SP_REG)))
2178 (set (reg:DI SP_REG)
2179 (plus:DI (reg:DI SP_REG) (const_int 8)))]
2182 [(set_attr "type" "pop")
2183 (set_attr "mode" "DI")])
2185 (define_insn "*movdi_xor_rex64"
2186 [(set (match_operand:DI 0 "register_operand" "=r")
2187 (match_operand:DI 1 "const0_operand" "i"))
2188 (clobber (reg:CC FLAGS_REG))]
2189 "TARGET_64BIT && (!TARGET_USE_MOV0 || optimize_size)
2190 && reload_completed"
2192 [(set_attr "type" "alu1")
2193 (set_attr "mode" "SI")
2194 (set_attr "length_immediate" "0")])
2196 (define_insn "*movdi_or_rex64"
2197 [(set (match_operand:DI 0 "register_operand" "=r")
2198 (match_operand:DI 1 "const_int_operand" "i"))
2199 (clobber (reg:CC FLAGS_REG))]
2200 "TARGET_64BIT && (TARGET_MOVE_M1_VIA_OR || optimize_size)
2202 && operands[1] == constm1_rtx"
2204 operands[1] = constm1_rtx;
2205 return "or{q}\t{%1, %0|%0, %1}";
2207 [(set_attr "type" "alu1")
2208 (set_attr "mode" "DI")
2209 (set_attr "length_immediate" "1")])
2211 (define_insn "*movdi_2"
2212 [(set (match_operand:DI 0 "nonimmediate_operand"
2213 "=r ,o ,*y,m*y,*y,*Y2,m ,*Y2,*Y2,*x,m ,*x,*x")
2214 (match_operand:DI 1 "general_operand"
2215 "riFo,riF,C ,*y ,m ,C ,*Y2,*Y2,m ,C ,*x,*x,m "))]
2216 "!TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2221 movq\t{%1, %0|%0, %1}
2222 movq\t{%1, %0|%0, %1}
2224 movq\t{%1, %0|%0, %1}
2225 movdqa\t{%1, %0|%0, %1}
2226 movq\t{%1, %0|%0, %1}
2228 movlps\t{%1, %0|%0, %1}
2229 movaps\t{%1, %0|%0, %1}
2230 movlps\t{%1, %0|%0, %1}"
2231 [(set_attr "type" "*,*,mmx,mmxmov,mmxmov,sselog1,ssemov,ssemov,ssemov,sselog1,ssemov,ssemov,ssemov")
2232 (set_attr "mode" "DI,DI,DI,DI,DI,TI,DI,TI,DI,V4SF,V2SF,V4SF,V2SF")])
2235 [(set (match_operand:DI 0 "push_operand" "")
2236 (match_operand:DI 1 "general_operand" ""))]
2237 "!TARGET_64BIT && reload_completed
2238 && (! MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2240 "ix86_split_long_move (operands); DONE;")
2242 ;; %%% This multiword shite has got to go.
2244 [(set (match_operand:DI 0 "nonimmediate_operand" "")
2245 (match_operand:DI 1 "general_operand" ""))]
2246 "!TARGET_64BIT && reload_completed
2247 && (!MMX_REG_P (operands[0]) && !SSE_REG_P (operands[0]))
2248 && (!MMX_REG_P (operands[1]) && !SSE_REG_P (operands[1]))"
2250 "ix86_split_long_move (operands); DONE;")
2252 (define_insn "*movdi_1_rex64"
2253 [(set (match_operand:DI 0 "nonimmediate_operand"
2254 "=r,r ,r,m ,!m,*y,*y,?r ,m ,?*Ym,?*y,*x,*x,?r ,m,?*Yi,*x,?*x,?*Ym")
2255 (match_operand:DI 1 "general_operand"
2256 "Z ,rem,i,re,n ,C ,*y,*Ym,*y,r ,m ,C ,*x,*Yi,*x,r ,m ,*Ym,*x"))]
2257 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2259 switch (get_attr_type (insn))
2262 if (SSE_REG_P (operands[0]))
2263 return "movq2dq\t{%1, %0|%0, %1}";
2265 return "movdq2q\t{%1, %0|%0, %1}";
2268 if (get_attr_mode (insn) == MODE_TI)
2269 return "movdqa\t{%1, %0|%0, %1}";
2273 /* Moves from and into integer register is done using movd
2274 opcode with REX prefix. */
2275 if (GENERAL_REG_P (operands[0]) || GENERAL_REG_P (operands[1]))
2276 return "movd\t{%1, %0|%0, %1}";
2277 return "movq\t{%1, %0|%0, %1}";
2281 return "pxor\t%0, %0";
2287 return "lea{q}\t{%a1, %0|%0, %a1}";
2290 gcc_assert (!flag_pic || LEGITIMATE_PIC_OPERAND_P (operands[1]));
2291 if (get_attr_mode (insn) == MODE_SI)
2292 return "mov{l}\t{%k1, %k0|%k0, %k1}";
2293 else if (which_alternative == 2)
2294 return "movabs{q}\t{%1, %0|%0, %1}";
2296 return "mov{q}\t{%1, %0|%0, %1}";
2300 (cond [(eq_attr "alternative" "5")
2301 (const_string "mmxadd")
2302 (eq_attr "alternative" "6,7,8,9,10")
2303 (const_string "mmxmov")
2304 (eq_attr "alternative" "11")
2305 (const_string "sselog1")
2306 (eq_attr "alternative" "12,13,14,15,16")
2307 (const_string "ssemov")
2308 (eq_attr "alternative" "17,18")
2309 (const_string "ssecvt")
2310 (eq_attr "alternative" "4")
2311 (const_string "multi")
2312 (match_operand:DI 1 "pic_32bit_operand" "")
2313 (const_string "lea")
2315 (const_string "imov")))
2316 (set_attr "modrm" "*,0,0,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")
2317 (set_attr "length_immediate" "*,4,8,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*,*")
2318 (set_attr "mode" "SI,DI,DI,DI,SI,DI,DI,DI,DI,DI,DI,TI,TI,DI,DI,DI,DI,DI,DI")])
2320 ;; Stores and loads of ax to arbitrary constant address.
2321 ;; We fake an second form of instruction to force reload to load address
2322 ;; into register when rax is not available
2323 (define_insn "*movabsdi_1_rex64"
2324 [(set (mem:DI (match_operand:DI 0 "x86_64_movabs_operand" "i,r"))
2325 (match_operand:DI 1 "nonmemory_operand" "a,er"))]
2326 "TARGET_64BIT && ix86_check_movabs (insn, 0)"
2328 movabs{q}\t{%1, %P0|%P0, %1}
2329 mov{q}\t{%1, %a0|%a0, %1}"
2330 [(set_attr "type" "imov")
2331 (set_attr "modrm" "0,*")
2332 (set_attr "length_address" "8,0")
2333 (set_attr "length_immediate" "0,*")
2334 (set_attr "memory" "store")
2335 (set_attr "mode" "DI")])
2337 (define_insn "*movabsdi_2_rex64"
2338 [(set (match_operand:DI 0 "register_operand" "=a,r")
2339 (mem:DI (match_operand:DI 1 "x86_64_movabs_operand" "i,r")))]
2340 "TARGET_64BIT && ix86_check_movabs (insn, 1)"
2342 movabs{q}\t{%P1, %0|%0, %P1}
2343 mov{q}\t{%a1, %0|%0, %a1}"
2344 [(set_attr "type" "imov")
2345 (set_attr "modrm" "0,*")
2346 (set_attr "length_address" "8,0")
2347 (set_attr "length_immediate" "0")
2348 (set_attr "memory" "load")
2349 (set_attr "mode" "DI")])
2351 ;; Convert impossible stores of immediate to existing instructions.
2352 ;; First try to get scratch register and go through it. In case this
2353 ;; fails, move by 32bit parts.
2355 [(match_scratch:DI 2 "r")
2356 (set (match_operand:DI 0 "memory_operand" "")
2357 (match_operand:DI 1 "immediate_operand" ""))]
2358 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2359 && !x86_64_immediate_operand (operands[1], DImode)"
2360 [(set (match_dup 2) (match_dup 1))
2361 (set (match_dup 0) (match_dup 2))]
2364 ;; We need to define this as both peepholer and splitter for case
2365 ;; peephole2 pass is not run.
2366 ;; "&& 1" is needed to keep it from matching the previous pattern.
2368 [(set (match_operand:DI 0 "memory_operand" "")
2369 (match_operand:DI 1 "immediate_operand" ""))]
2370 "TARGET_64BIT && !symbolic_operand (operands[1], DImode)
2371 && !x86_64_immediate_operand (operands[1], DImode) && 1"
2372 [(set (match_dup 2) (match_dup 3))
2373 (set (match_dup 4) (match_dup 5))]
2374 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2377 [(set (match_operand:DI 0 "memory_operand" "")
2378 (match_operand:DI 1 "immediate_operand" ""))]
2379 "TARGET_64BIT && ((optimize > 0 && flag_peephole2)
2380 ? epilogue_completed : reload_completed)
2381 && !symbolic_operand (operands[1], DImode)
2382 && !x86_64_immediate_operand (operands[1], DImode)"
2383 [(set (match_dup 2) (match_dup 3))
2384 (set (match_dup 4) (match_dup 5))]
2385 "split_di (&operands[0], 2, &operands[2], &operands[4]);")
2387 (define_insn "*swapdi_rex64"
2388 [(set (match_operand:DI 0 "register_operand" "+r")
2389 (match_operand:DI 1 "register_operand" "+r"))
2394 [(set_attr "type" "imov")
2395 (set_attr "mode" "DI")
2396 (set_attr "pent_pair" "np")
2397 (set_attr "athlon_decode" "vector")
2398 (set_attr "amdfam10_decode" "double")])
2400 (define_expand "movti"
2401 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2402 (match_operand:TI 1 "nonimmediate_operand" ""))]
2403 "TARGET_SSE || TARGET_64BIT"
2406 ix86_expand_move (TImode, operands);
2407 else if (push_operand (operands[0], TImode))
2408 ix86_expand_push (TImode, operands[1]);
2410 ix86_expand_vector_move (TImode, operands);
2414 (define_insn "*movti_internal"
2415 [(set (match_operand:TI 0 "nonimmediate_operand" "=x,x,m")
2416 (match_operand:TI 1 "vector_move_operand" "C,xm,x"))]
2417 "TARGET_SSE && !TARGET_64BIT
2418 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2420 switch (which_alternative)
2423 if (get_attr_mode (insn) == MODE_V4SF)
2424 return "xorps\t%0, %0";
2426 return "pxor\t%0, %0";
2429 /* TDmode values are passed as TImode on the stack. Moving them
2430 to stack may result in unaligned memory access. */
2431 if (misaligned_operand (operands[0], TImode)
2432 || misaligned_operand (operands[1], TImode))
2434 if (get_attr_mode (insn) == MODE_V4SF)
2435 return "movups\t{%1, %0|%0, %1}";
2437 return "movdqu\t{%1, %0|%0, %1}";
2441 if (get_attr_mode (insn) == MODE_V4SF)
2442 return "movaps\t{%1, %0|%0, %1}";
2444 return "movdqa\t{%1, %0|%0, %1}";
2450 [(set_attr "type" "sselog1,ssemov,ssemov")
2452 (cond [(ior (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2453 (ne (symbol_ref "optimize_size") (const_int 0)))
2454 (const_string "V4SF")
2455 (and (eq_attr "alternative" "2")
2456 (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2458 (const_string "V4SF")]
2459 (const_string "TI")))])
2461 (define_insn "*movti_rex64"
2462 [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o,x,x,xm")
2463 (match_operand:TI 1 "general_operand" "riFo,riF,C,xm,x"))]
2465 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
2467 switch (which_alternative)
2473 if (get_attr_mode (insn) == MODE_V4SF)
2474 return "xorps\t%0, %0";
2476 return "pxor\t%0, %0";
2479 /* TDmode values are passed as TImode on the stack. Moving them
2480 to stack may result in unaligned memory access. */
2481 if (misaligned_operand (operands[0], TImode)
2482 || misaligned_operand (operands[1], TImode))
2484 if (get_attr_mode (insn) == MODE_V4SF)
2485 return "movups\t{%1, %0|%0, %1}";
2487 return "movdqu\t{%1, %0|%0, %1}";
2491 if (get_attr_mode (insn) == MODE_V4SF)
2492 return "movaps\t{%1, %0|%0, %1}";
2494 return "movdqa\t{%1, %0|%0, %1}";
2500 [(set_attr "type" "*,*,sselog1,ssemov,ssemov")
2502 (cond [(eq_attr "alternative" "2,3")
2504 (ne (symbol_ref "optimize_size")
2506 (const_string "V4SF")
2507 (const_string "TI"))
2508 (eq_attr "alternative" "4")
2510 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
2512 (ne (symbol_ref "optimize_size")
2514 (const_string "V4SF")
2515 (const_string "TI"))]
2516 (const_string "DI")))])
2519 [(set (match_operand:TI 0 "nonimmediate_operand" "")
2520 (match_operand:TI 1 "general_operand" ""))]
2521 "reload_completed && !SSE_REG_P (operands[0])
2522 && !SSE_REG_P (operands[1])"
2524 "ix86_split_long_move (operands); DONE;")
2526 ;; This expands to what emit_move_complex would generate if we didn't
2527 ;; have a movti pattern. Having this avoids problems with reload on
2528 ;; 32-bit targets when SSE is present, but doesn't seem to be harmful
2529 ;; to have around all the time.
2530 (define_expand "movcdi"
2531 [(set (match_operand:CDI 0 "nonimmediate_operand" "")
2532 (match_operand:CDI 1 "general_operand" ""))]
2535 if (push_operand (operands[0], CDImode))
2536 emit_move_complex_push (CDImode, operands[0], operands[1]);
2538 emit_move_complex_parts (operands[0], operands[1]);
2542 (define_expand "movsf"
2543 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2544 (match_operand:SF 1 "general_operand" ""))]
2546 "ix86_expand_move (SFmode, operands); DONE;")
2548 (define_insn "*pushsf"
2549 [(set (match_operand:SF 0 "push_operand" "=<,<,<")
2550 (match_operand:SF 1 "general_no_elim_operand" "f,rFm,x"))]
2553 /* Anything else should be already split before reg-stack. */
2554 gcc_assert (which_alternative == 1);
2555 return "push{l}\t%1";
2557 [(set_attr "type" "multi,push,multi")
2558 (set_attr "unit" "i387,*,*")
2559 (set_attr "mode" "SF,SI,SF")])
2561 (define_insn "*pushsf_rex64"
2562 [(set (match_operand:SF 0 "push_operand" "=X,X,X")
2563 (match_operand:SF 1 "nonmemory_no_elim_operand" "f,rF,x"))]
2566 /* Anything else should be already split before reg-stack. */
2567 gcc_assert (which_alternative == 1);
2568 return "push{q}\t%q1";
2570 [(set_attr "type" "multi,push,multi")
2571 (set_attr "unit" "i387,*,*")
2572 (set_attr "mode" "SF,DI,SF")])
2575 [(set (match_operand:SF 0 "push_operand" "")
2576 (match_operand:SF 1 "memory_operand" ""))]
2578 && MEM_P (operands[1])
2579 && (operands[2] = find_constant_src (insn))"
2584 ;; %%% Kill this when call knows how to work this out.
2586 [(set (match_operand:SF 0 "push_operand" "")
2587 (match_operand:SF 1 "any_fp_register_operand" ""))]
2589 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
2590 (set (mem:SF (reg:SI SP_REG)) (match_dup 1))])
2593 [(set (match_operand:SF 0 "push_operand" "")
2594 (match_operand:SF 1 "any_fp_register_operand" ""))]
2596 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2597 (set (mem:SF (reg:DI SP_REG)) (match_dup 1))])
2599 (define_insn "*movsf_1"
2600 [(set (match_operand:SF 0 "nonimmediate_operand"
2601 "=f,m,f,r ,m ,x,x,x ,m,!*y,!m,!*y,?Yi,?r,!*Ym,!r")
2602 (match_operand:SF 1 "general_operand"
2603 "fm,f,G,rmF,Fr,C,x,xm,x,m ,*y,*y ,r ,Yi,r ,*Ym"))]
2604 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2605 && (reload_in_progress || reload_completed
2606 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2607 || (!TARGET_SSE_MATH && optimize_size
2608 && standard_80387_constant_p (operands[1]))
2609 || GET_CODE (operands[1]) != CONST_DOUBLE
2610 || memory_operand (operands[0], SFmode))"
2612 switch (which_alternative)
2616 return output_387_reg_move (insn, operands);
2619 return standard_80387_constant_opcode (operands[1]);
2623 return "mov{l}\t{%1, %0|%0, %1}";
2625 if (get_attr_mode (insn) == MODE_TI)
2626 return "pxor\t%0, %0";
2628 return "xorps\t%0, %0";
2630 if (get_attr_mode (insn) == MODE_V4SF)
2631 return "movaps\t{%1, %0|%0, %1}";
2633 return "movss\t{%1, %0|%0, %1}";
2635 return "movss\t{%1, %0|%0, %1}";
2638 case 12: case 13: case 14: case 15:
2639 return "movd\t{%1, %0|%0, %1}";
2642 return "movq\t{%1, %0|%0, %1}";
2648 [(set_attr "type" "fmov,fmov,fmov,imov,imov,sselog1,ssemov,ssemov,ssemov,mmxmov,mmxmov,mmxmov,ssemov,ssemov,mmxmov,mmxmov")
2650 (cond [(eq_attr "alternative" "3,4,9,10")
2652 (eq_attr "alternative" "5")
2654 (and (and (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2656 (ne (symbol_ref "TARGET_SSE2")
2658 (eq (symbol_ref "optimize_size")
2661 (const_string "V4SF"))
2662 /* For architectures resolving dependencies on
2663 whole SSE registers use APS move to break dependency
2664 chains, otherwise use short move to avoid extra work.
2666 Do the same for architectures resolving dependencies on
2667 the parts. While in DF mode it is better to always handle
2668 just register parts, the SF mode is different due to lack
2669 of instructions to load just part of the register. It is
2670 better to maintain the whole registers in single format
2671 to avoid problems on using packed logical operations. */
2672 (eq_attr "alternative" "6")
2674 (ior (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2676 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2678 (const_string "V4SF")
2679 (const_string "SF"))
2680 (eq_attr "alternative" "11")
2681 (const_string "DI")]
2682 (const_string "SF")))])
2684 (define_insn "*swapsf"
2685 [(set (match_operand:SF 0 "fp_register_operand" "+f")
2686 (match_operand:SF 1 "fp_register_operand" "+f"))
2689 "reload_completed || TARGET_80387"
2691 if (STACK_TOP_P (operands[0]))
2696 [(set_attr "type" "fxch")
2697 (set_attr "mode" "SF")])
2699 (define_expand "movdf"
2700 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2701 (match_operand:DF 1 "general_operand" ""))]
2703 "ix86_expand_move (DFmode, operands); DONE;")
2705 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
2706 ;; Size of pushdf using integer instructions is 2+2*memory operand size
2707 ;; On the average, pushdf using integers can be still shorter. Allow this
2708 ;; pattern for optimize_size too.
2710 (define_insn "*pushdf_nointeger"
2711 [(set (match_operand:DF 0 "push_operand" "=<,<,<,<")
2712 (match_operand:DF 1 "general_no_elim_operand" "f,Fo,*r,Y2"))]
2713 "!TARGET_64BIT && !TARGET_INTEGER_DFMODE_MOVES"
2715 /* This insn should be already split before reg-stack. */
2718 [(set_attr "type" "multi")
2719 (set_attr "unit" "i387,*,*,*")
2720 (set_attr "mode" "DF,SI,SI,DF")])
2722 (define_insn "*pushdf_integer"
2723 [(set (match_operand:DF 0 "push_operand" "=<,<,<")
2724 (match_operand:DF 1 "general_no_elim_operand" "f,rFo,Y2"))]
2725 "TARGET_64BIT || TARGET_INTEGER_DFMODE_MOVES"
2727 /* This insn should be already split before reg-stack. */
2730 [(set_attr "type" "multi")
2731 (set_attr "unit" "i387,*,*")
2732 (set_attr "mode" "DF,SI,DF")])
2734 ;; %%% Kill this when call knows how to work this out.
2736 [(set (match_operand:DF 0 "push_operand" "")
2737 (match_operand:DF 1 "any_fp_register_operand" ""))]
2738 "!TARGET_64BIT && reload_completed"
2739 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -8)))
2740 (set (mem:DF (reg:SI SP_REG)) (match_dup 1))]
2744 [(set (match_operand:DF 0 "push_operand" "")
2745 (match_operand:DF 1 "any_fp_register_operand" ""))]
2746 "TARGET_64BIT && reload_completed"
2747 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (const_int -8)))
2748 (set (mem:DF (reg:DI SP_REG)) (match_dup 1))]
2752 [(set (match_operand:DF 0 "push_operand" "")
2753 (match_operand:DF 1 "general_operand" ""))]
2756 "ix86_split_long_move (operands); DONE;")
2758 ;; Moving is usually shorter when only FP registers are used. This separate
2759 ;; movdf pattern avoids the use of integer registers for FP operations
2760 ;; when optimizing for size.
2762 (define_insn "*movdf_nointeger"
2763 [(set (match_operand:DF 0 "nonimmediate_operand"
2764 "=f,m,f,*r ,o ,Y2*x,Y2*x,Y2*x ,m ")
2765 (match_operand:DF 1 "general_operand"
2766 "fm,f,G,*roF,*Fr,C ,Y2*x,mY2*x,Y2*x"))]
2767 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
2768 && ((optimize_size || !TARGET_INTEGER_DFMODE_MOVES) && !TARGET_64BIT)
2769 && (reload_in_progress || reload_completed
2770 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2771 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
2772 && !memory_operand (operands[0], DFmode)
2773 && standard_80387_constant_p (operands[1]))
2774 || GET_CODE (operands[1]) != CONST_DOUBLE
2776 || !TARGET_MEMORY_MISMATCH_STALL
2777 || reload_in_progress || reload_completed)
2778 && memory_operand (operands[0], DFmode)))"
2780 switch (which_alternative)
2784 return output_387_reg_move (insn, operands);
2787 return standard_80387_constant_opcode (operands[1]);
2793 switch (get_attr_mode (insn))
2796 return "xorps\t%0, %0";
2798 return "xorpd\t%0, %0";
2800 return "pxor\t%0, %0";
2807 switch (get_attr_mode (insn))
2810 return "movaps\t{%1, %0|%0, %1}";
2812 return "movapd\t{%1, %0|%0, %1}";
2814 return "movdqa\t{%1, %0|%0, %1}";
2816 return "movq\t{%1, %0|%0, %1}";
2818 return "movsd\t{%1, %0|%0, %1}";
2820 return "movlpd\t{%1, %0|%0, %1}";
2822 return "movlps\t{%1, %0|%0, %1}";
2831 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
2833 (cond [(eq_attr "alternative" "0,1,2")
2835 (eq_attr "alternative" "3,4")
2838 /* For SSE1, we have many fewer alternatives. */
2839 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2840 (cond [(eq_attr "alternative" "5,6")
2841 (const_string "V4SF")
2843 (const_string "V2SF"))
2845 /* xorps is one byte shorter. */
2846 (eq_attr "alternative" "5")
2847 (cond [(ne (symbol_ref "optimize_size")
2849 (const_string "V4SF")
2850 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2854 (const_string "V2DF"))
2856 /* For architectures resolving dependencies on
2857 whole SSE registers use APD move to break dependency
2858 chains, otherwise use short move to avoid extra work.
2860 movaps encodes one byte shorter. */
2861 (eq_attr "alternative" "6")
2863 [(ne (symbol_ref "optimize_size")
2865 (const_string "V4SF")
2866 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2868 (const_string "V2DF")
2870 (const_string "DF"))
2871 /* For architectures resolving dependencies on register
2872 parts we may avoid extra work to zero out upper part
2874 (eq_attr "alternative" "7")
2876 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2878 (const_string "V1DF")
2879 (const_string "DF"))
2881 (const_string "DF")))])
2883 (define_insn "*movdf_integer_rex64"
2884 [(set (match_operand:DF 0 "nonimmediate_operand"
2885 "=f,m,f,r ,m ,Y2*x,Y2*x,Y2*x,m ,Yi,r ")
2886 (match_operand:DF 1 "general_operand"
2887 "fm,f,G,rmF,Fr,C ,Y2*x,m ,Y2*x,r ,Yi"))]
2888 "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))
2889 && (reload_in_progress || reload_completed
2890 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
2891 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
2892 && standard_80387_constant_p (operands[1]))
2893 || GET_CODE (operands[1]) != CONST_DOUBLE
2894 || memory_operand (operands[0], DFmode))"
2896 switch (which_alternative)
2900 return output_387_reg_move (insn, operands);
2903 return standard_80387_constant_opcode (operands[1]);
2910 switch (get_attr_mode (insn))
2913 return "xorps\t%0, %0";
2915 return "xorpd\t%0, %0";
2917 return "pxor\t%0, %0";
2924 switch (get_attr_mode (insn))
2927 return "movaps\t{%1, %0|%0, %1}";
2929 return "movapd\t{%1, %0|%0, %1}";
2931 return "movdqa\t{%1, %0|%0, %1}";
2933 return "movq\t{%1, %0|%0, %1}";
2935 return "movsd\t{%1, %0|%0, %1}";
2937 return "movlpd\t{%1, %0|%0, %1}";
2939 return "movlps\t{%1, %0|%0, %1}";
2946 return "movd\t{%1, %0|%0, %1}";
2952 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov,ssemov,ssemov")
2954 (cond [(eq_attr "alternative" "0,1,2")
2956 (eq_attr "alternative" "3,4,9,10")
2959 /* For SSE1, we have many fewer alternatives. */
2960 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
2961 (cond [(eq_attr "alternative" "5,6")
2962 (const_string "V4SF")
2964 (const_string "V2SF"))
2966 /* xorps is one byte shorter. */
2967 (eq_attr "alternative" "5")
2968 (cond [(ne (symbol_ref "optimize_size")
2970 (const_string "V4SF")
2971 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
2975 (const_string "V2DF"))
2977 /* For architectures resolving dependencies on
2978 whole SSE registers use APD move to break dependency
2979 chains, otherwise use short move to avoid extra work.
2981 movaps encodes one byte shorter. */
2982 (eq_attr "alternative" "6")
2984 [(ne (symbol_ref "optimize_size")
2986 (const_string "V4SF")
2987 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
2989 (const_string "V2DF")
2991 (const_string "DF"))
2992 /* For architectures resolving dependencies on register
2993 parts we may avoid extra work to zero out upper part
2995 (eq_attr "alternative" "7")
2997 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
2999 (const_string "V1DF")
3000 (const_string "DF"))
3002 (const_string "DF")))])
3004 (define_insn "*movdf_integer"
3005 [(set (match_operand:DF 0 "nonimmediate_operand"
3006 "=f,m,f,r ,o ,Y2*x,Y2*x,Y2*x,m ")
3007 (match_operand:DF 1 "general_operand"
3008 "fm,f,G,roF,Fr,C ,Y2*x,m ,Y2*x"))]
3009 "!(MEM_P (operands[0]) && MEM_P (operands[1]))
3010 && !optimize_size && TARGET_INTEGER_DFMODE_MOVES
3011 && (reload_in_progress || reload_completed
3012 || (ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_LARGE)
3013 || (!(TARGET_SSE2 && TARGET_SSE_MATH) && optimize_size
3014 && standard_80387_constant_p (operands[1]))
3015 || GET_CODE (operands[1]) != CONST_DOUBLE
3016 || memory_operand (operands[0], DFmode))"
3018 switch (which_alternative)
3022 return output_387_reg_move (insn, operands);
3025 return standard_80387_constant_opcode (operands[1]);
3032 switch (get_attr_mode (insn))
3035 return "xorps\t%0, %0";
3037 return "xorpd\t%0, %0";
3039 return "pxor\t%0, %0";
3046 switch (get_attr_mode (insn))
3049 return "movaps\t{%1, %0|%0, %1}";
3051 return "movapd\t{%1, %0|%0, %1}";
3053 return "movdqa\t{%1, %0|%0, %1}";
3055 return "movq\t{%1, %0|%0, %1}";
3057 return "movsd\t{%1, %0|%0, %1}";
3059 return "movlpd\t{%1, %0|%0, %1}";
3061 return "movlps\t{%1, %0|%0, %1}";
3070 [(set_attr "type" "fmov,fmov,fmov,multi,multi,sselog1,ssemov,ssemov,ssemov")
3072 (cond [(eq_attr "alternative" "0,1,2")
3074 (eq_attr "alternative" "3,4")
3077 /* For SSE1, we have many fewer alternatives. */
3078 (eq (symbol_ref "TARGET_SSE2") (const_int 0))
3079 (cond [(eq_attr "alternative" "5,6")
3080 (const_string "V4SF")
3082 (const_string "V2SF"))
3084 /* xorps is one byte shorter. */
3085 (eq_attr "alternative" "5")
3086 (cond [(ne (symbol_ref "optimize_size")
3088 (const_string "V4SF")
3089 (ne (symbol_ref "TARGET_SSE_LOAD0_BY_PXOR")
3093 (const_string "V2DF"))
3095 /* For architectures resolving dependencies on
3096 whole SSE registers use APD move to break dependency
3097 chains, otherwise use short move to avoid extra work.
3099 movaps encodes one byte shorter. */
3100 (eq_attr "alternative" "6")
3102 [(ne (symbol_ref "optimize_size")
3104 (const_string "V4SF")
3105 (ne (symbol_ref "TARGET_SSE_PARTIAL_REG_DEPENDENCY")
3107 (const_string "V2DF")
3109 (const_string "DF"))
3110 /* For architectures resolving dependencies on register
3111 parts we may avoid extra work to zero out upper part
3113 (eq_attr "alternative" "7")
3115 (ne (symbol_ref "TARGET_SSE_SPLIT_REGS")
3117 (const_string "V1DF")
3118 (const_string "DF"))
3120 (const_string "DF")))])
3123 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3124 (match_operand:DF 1 "general_operand" ""))]
3126 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3127 && ! (ANY_FP_REG_P (operands[0]) ||
3128 (GET_CODE (operands[0]) == SUBREG
3129 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3130 && ! (ANY_FP_REG_P (operands[1]) ||
3131 (GET_CODE (operands[1]) == SUBREG
3132 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3134 "ix86_split_long_move (operands); DONE;")
3136 (define_insn "*swapdf"
3137 [(set (match_operand:DF 0 "fp_register_operand" "+f")
3138 (match_operand:DF 1 "fp_register_operand" "+f"))
3141 "reload_completed || TARGET_80387"
3143 if (STACK_TOP_P (operands[0]))
3148 [(set_attr "type" "fxch")
3149 (set_attr "mode" "DF")])
3151 (define_expand "movxf"
3152 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3153 (match_operand:XF 1 "general_operand" ""))]
3155 "ix86_expand_move (XFmode, operands); DONE;")
3157 ;; Size of pushdf is 3 (for sub) + 2 (for fstp) + memory operand size.
3158 ;; Size of pushdf using integer instructions is 3+3*memory operand size
3159 ;; Pushing using integer instructions is longer except for constants
3160 ;; and direct memory references.
3161 ;; (assuming that any given constant is pushed only once, but this ought to be
3162 ;; handled elsewhere).
3164 (define_insn "*pushxf_nointeger"
3165 [(set (match_operand:XF 0 "push_operand" "=X,X,X")
3166 (match_operand:XF 1 "general_no_elim_operand" "f,Fo,*r"))]
3169 /* This insn should be already split before reg-stack. */
3172 [(set_attr "type" "multi")
3173 (set_attr "unit" "i387,*,*")
3174 (set_attr "mode" "XF,SI,SI")])
3176 (define_insn "*pushxf_integer"
3177 [(set (match_operand:XF 0 "push_operand" "=<,<")
3178 (match_operand:XF 1 "general_no_elim_operand" "f,ro"))]
3181 /* This insn should be already split before reg-stack. */
3184 [(set_attr "type" "multi")
3185 (set_attr "unit" "i387,*")
3186 (set_attr "mode" "XF,SI")])
3189 [(set (match_operand 0 "push_operand" "")
3190 (match_operand 1 "general_operand" ""))]
3192 && (GET_MODE (operands[0]) == XFmode
3193 || GET_MODE (operands[0]) == DFmode)
3194 && !ANY_FP_REG_P (operands[1])"
3196 "ix86_split_long_move (operands); DONE;")
3199 [(set (match_operand:XF 0 "push_operand" "")
3200 (match_operand:XF 1 "any_fp_register_operand" ""))]
3202 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 2)))
3203 (set (mem:XF (reg:SI SP_REG)) (match_dup 1))]
3204 "operands[2] = GEN_INT (TARGET_128BIT_LONG_DOUBLE ? -16 : -12);")
3207 [(set (match_operand:XF 0 "push_operand" "")
3208 (match_operand:XF 1 "any_fp_register_operand" ""))]
3210 [(set (reg:DI SP_REG) (plus:DI (reg:DI SP_REG) (match_dup 2)))
3211 (set (mem:XF (reg:DI SP_REG)) (match_dup 1))]
3212 "operands[2] = GEN_INT (TARGET_128BIT_LONG_DOUBLE ? -16 : -12);")
3214 ;; Do not use integer registers when optimizing for size
3215 (define_insn "*movxf_nointeger"
3216 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,*r,o")
3217 (match_operand:XF 1 "general_operand" "fm,f,G,*roF,F*r"))]
3219 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3220 && (reload_in_progress || reload_completed
3221 || (optimize_size && standard_80387_constant_p (operands[1]))
3222 || GET_CODE (operands[1]) != CONST_DOUBLE
3223 || memory_operand (operands[0], XFmode))"
3225 switch (which_alternative)
3229 return output_387_reg_move (insn, operands);
3232 return standard_80387_constant_opcode (operands[1]);
3240 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3241 (set_attr "mode" "XF,XF,XF,SI,SI")])
3243 (define_insn "*movxf_integer"
3244 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,r,o")
3245 (match_operand:XF 1 "general_operand" "fm,f,G,roF,Fr"))]
3247 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3248 && (reload_in_progress || reload_completed
3249 || (optimize_size && standard_80387_constant_p (operands[1]))
3250 || GET_CODE (operands[1]) != CONST_DOUBLE
3251 || memory_operand (operands[0], XFmode))"
3253 switch (which_alternative)
3257 return output_387_reg_move (insn, operands);
3260 return standard_80387_constant_opcode (operands[1]);
3269 [(set_attr "type" "fmov,fmov,fmov,multi,multi")
3270 (set_attr "mode" "XF,XF,XF,SI,SI")])
3272 (define_expand "movtf"
3273 [(set (match_operand:TF 0 "nonimmediate_operand" "")
3274 (match_operand:TF 1 "nonimmediate_operand" ""))]
3277 ix86_expand_move (TFmode, operands);
3281 (define_insn "*movtf_internal"
3282 [(set (match_operand:TF 0 "nonimmediate_operand" "=x,m,x,?r,?o")
3283 (match_operand:TF 1 "general_operand" "xm,x,C,roF,Fr"))]
3285 && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
3287 switch (which_alternative)
3291 if (get_attr_mode (insn) == MODE_V4SF)
3292 return "movaps\t{%1, %0|%0, %1}";
3294 return "movdqa\t{%1, %0|%0, %1}";
3296 if (get_attr_mode (insn) == MODE_V4SF)
3297 return "xorps\t%0, %0";
3299 return "pxor\t%0, %0";
3307 [(set_attr "type" "ssemov,ssemov,sselog1,*,*")
3309 (cond [(eq_attr "alternative" "0,2")
3311 (ne (symbol_ref "optimize_size")
3313 (const_string "V4SF")
3314 (const_string "TI"))
3315 (eq_attr "alternative" "1")
3317 (ior (ne (symbol_ref "TARGET_SSE_TYPELESS_STORES")
3319 (ne (symbol_ref "optimize_size")
3321 (const_string "V4SF")
3322 (const_string "TI"))]
3323 (const_string "DI")))])
3326 [(set (match_operand 0 "nonimmediate_operand" "")
3327 (match_operand 1 "general_operand" ""))]
3329 && !(MEM_P (operands[0]) && MEM_P (operands[1]))
3330 && GET_MODE (operands[0]) == XFmode
3331 && ! (ANY_FP_REG_P (operands[0]) ||
3332 (GET_CODE (operands[0]) == SUBREG
3333 && ANY_FP_REG_P (SUBREG_REG (operands[0]))))
3334 && ! (ANY_FP_REG_P (operands[1]) ||
3335 (GET_CODE (operands[1]) == SUBREG
3336 && ANY_FP_REG_P (SUBREG_REG (operands[1]))))"
3338 "ix86_split_long_move (operands); DONE;")
3341 [(set (match_operand 0 "register_operand" "")