1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
3 ;; 2002, 2003, 2004, 2005
4 ;; Free Software Foundation, Inc.
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; GCC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
23 ;;- Information about MCF5200 port.
25 ;;- The MCF5200 "ColdFire" architecture is a reduced version of the
26 ;;- 68k ISA. Differences include reduced support for byte and word
27 ;;- operands and the removal of BCD, bitfield, rotate, and integer
28 ;;- divide instructions. The TARGET_COLDFIRE flag turns the use of the
29 ;;- removed opcodes and addressing modes off.
33 ;;- instruction definitions
35 ;;- @@The original PO technology requires these to be ordered by speed,
36 ;;- @@ so that assigner will pick the fastest.
38 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
40 ;;- When naming insn's (operand 0 of define_insn) be careful about using
41 ;;- names from other targets machine descriptions.
43 ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
44 ;;- updates for most instructions.
46 ;;- Operand classes for the register allocator:
47 ;;- 'a' one of the address registers can be used.
48 ;;- 'd' one of the data registers can be used.
49 ;;- 'f' one of the m68881 registers can be used
50 ;;- 'r' either a data or an address register can be used.
52 ;;- Immediate Floating point operator constraints
53 ;;- 'G' a floating point constant that is *NOT* one of the standard
54 ;; 68881 constant values (to force calling output_move_const_double
55 ;; to get it from rom if it is a 68881 constant).
57 ;; See the functions standard_XXX_constant_p in output-m68k.c for more
60 ;;- Immediate integer operand constraints:
62 ;;- 'J' -32768 .. 32767
63 ;;- 'K' all integers EXCEPT -128 .. 127
65 ;;- 'M' all integers EXCEPT -256 .. 255
71 ;;- "%." size separator ("." or "") move%.l d0,d1
72 ;;- "%-" push operand "sp@-" move%.l d0,%-
73 ;;- "%+" pop operand "sp@+" move%.l d0,%+
74 ;;- "%@" top of stack "sp@" move%.l d0,%@
75 ;;- "%!" fpcr register
76 ;;- "%$" single-precision fp specifier ("s" or "") f%$add.x fp0,fp1
77 ;;- "%&" double-precision fp specifier ("d" or "") f%&add.x fp0,fp1
79 ;;- Information about 68040 port.
81 ;;- The 68040 executes all 68030 and 68881/2 instructions, but some must
82 ;;- be emulated in software by the OS. It is faster to avoid these
83 ;;- instructions and issue a library call rather than trapping into
84 ;;- the kernel. The affected instructions are fintrz and fscale. The
85 ;;- TARGET_68040 flag turns the use of the opcodes off.
87 ;;- The '040 also implements a set of new floating-point instructions
88 ;;- which specify the rounding precision in the opcode. This finally
89 ;;- permit the 68k series to be truly IEEE compliant, and solves all
90 ;;- issues of excess precision accumulating in the extended registers.
91 ;;- By default, GCC does not use these instructions, since such code will
92 ;;- not run on an '030. To use these instructions, use the -m68040-only
93 ;;- switch. By changing TARGET_DEFAULT to include TARGET_68040_ONLY,
94 ;;- you can make these instructions the default.
96 ;;- These new instructions aren't directly in the md. They are brought
97 ;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather
100 ;;- Information about 68060 port.
102 ;;- The 68060 executes all 68030 and 68881/2 instructions, but some must
103 ;;- be emulated in software by the OS. It is faster to avoid these
104 ;;- instructions and issue a library call rather than trapping into
105 ;;- the kernel. The affected instructions are: divs.l <ea>,Dr:Dq;
106 ;;- divu.l <ea>,Dr:Dq; muls.l <ea>,Dr:Dq; mulu.l <ea>,Dr:Dq; and
107 ;;- fscale. The TARGET_68060 flag turns the use of the opcodes off.
109 ;;- Some of these insn's are composites of several m68000 op codes.
110 ;;- The assembler (or final @@??) insures that the appropriate one is
120 ;; UNSPEC_VOLATILE usage:
123 [(UNSPECV_BLOCKAGE 0)
126 ;; Registers by name.
132 (include "predicates.md")
135 [(set (match_operand:DF 0 "push_operand" "=m")
136 (match_operand:DF 1 "general_operand" "ro<>fyE"))]
139 if (FP_REG_P (operands[1]))
140 return "fmove%.d %f1,%0";
141 return output_move_double (operands);
144 (define_insn "pushdi"
145 [(set (match_operand:DI 0 "push_operand" "=m")
146 (match_operand:DI 1 "general_operand" "ro<>Fyi"))]
149 return output_move_double (operands);
152 ;; We don't want to allow a constant operand for test insns because
153 ;; (set (cc0) (const_int foo)) has no mode information. Such insns will
154 ;; be folded while optimizing anyway.
156 (define_expand "tstdi"
157 [(parallel [(set (cc0)
158 (match_operand:DI 0 "nonimmediate_operand" ""))
159 (clobber (match_scratch:SI 1 ""))
160 (clobber (match_scratch:DI 2 ""))])]
162 "m68k_last_compare_had_fp_operands = 0;")
166 (match_operand:DI 0 "nonimmediate_operand" "am,d"))
167 (clobber (match_scratch:SI 1 "=X,d"))
168 (clobber (match_scratch:DI 2 "=d,X"))]
171 if (which_alternative == 0)
175 xoperands[0] = operands[2];
176 xoperands[1] = operands[0];
177 output_move_double (xoperands);
178 cc_status.flags |= CC_REVERSED;
179 return "neg%.l %R2\;negx%.l %2";
181 if (find_reg_note (insn, REG_DEAD, operands[0]))
183 cc_status.flags |= CC_REVERSED;
184 return "neg%.l %R0\;negx%.l %0";
188 'sub' clears %1, and also clears the X cc bit
189 'tst' sets the Z cc bit according to the low part of the DImode operand
190 'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part.
192 return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
195 (define_expand "tstsi"
197 (match_operand:SI 0 "nonimmediate_operand" ""))]
199 "m68k_last_compare_had_fp_operands = 0;")
203 (match_operand:SI 0 "nonimmediate_operand" "rm"))]
206 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
208 /* If you think that the 68020 does not support tstl a0,
209 reread page B-167 of the 68020 manual more carefully. */
210 /* On an address reg, cmpw may replace cmpl. */
211 return "cmp%.w #0,%0";
214 ;; This can't use an address register, because comparisons
215 ;; with address registers as second operand always test the whole word.
216 (define_expand "tsthi"
218 (match_operand:HI 0 "nonimmediate_operand" ""))]
220 "m68k_last_compare_had_fp_operands = 0;")
224 (match_operand:HI 0 "nonimmediate_operand" "dm"))]
228 (define_expand "tstqi"
230 (match_operand:QI 0 "nonimmediate_operand" ""))]
232 "m68k_last_compare_had_fp_operands = 0;")
236 (match_operand:QI 0 "nonimmediate_operand" "dm"))]
240 (define_expand "tstsf"
242 (match_operand:SF 0 "general_operand" ""))]
245 m68k_last_compare_had_fp_operands = 1;
250 (match_operand:SF 0 "general_operand" "fdm"))]
253 cc_status.flags = CC_IN_68881;
254 if (FP_REG_P (operands[0]))
259 (define_expand "tstdf"
261 (match_operand:DF 0 "general_operand" ""))]
264 m68k_last_compare_had_fp_operands = 1;
269 (match_operand:DF 0 "general_operand" "fm"))]
272 cc_status.flags = CC_IN_68881;
273 if (FP_REG_P (operands[0]))
278 ;; compare instructions.
280 (define_expand "cmpdi"
283 (compare (match_operand:DI 0 "nonimmediate_operand" "")
284 (match_operand:DI 1 "general_operand" "")))
285 (clobber (match_dup 2))])]
287 "m68k_last_compare_had_fp_operands = 0; operands[2] = gen_reg_rtx (DImode);")
291 (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
292 (match_operand:DI 2 "general_operand" "d,0")))
293 (clobber (match_operand:DI 0 "register_operand" "=d,d"))]
296 if (rtx_equal_p (operands[0], operands[1]))
297 return "sub%.l %R2,%R0\;subx%.l %2,%0";
300 cc_status.flags |= CC_REVERSED;
301 return "sub%.l %R1,%R0\;subx%.l %1,%0";
305 ;; This is the second "hook" for PIC code (in addition to movsi). See
306 ;; comment of movsi for a description of PIC handling.
307 (define_expand "cmpsi"
309 (compare (match_operand:SI 0 "nonimmediate_operand" "")
310 (match_operand:SI 1 "general_operand" "")))]
313 m68k_last_compare_had_fp_operands = 0;
314 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
316 /* The source is an address which requires PIC relocation.
317 Call legitimize_pic_address with the source, mode, and a relocation
318 register (a new pseudo, or the final destination if reload_in_progress
319 is set). Then fall through normally */
320 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
321 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
325 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
328 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
329 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
332 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
333 return "cmpm%.l %1,%0";
334 if (REG_P (operands[1])
335 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
337 cc_status.flags |= CC_REVERSED;
338 return "cmp%.l %d0,%d1";
340 if (ADDRESS_REG_P (operands[0])
341 && GET_CODE (operands[1]) == CONST_INT
342 && INTVAL (operands[1]) < 0x8000
343 && INTVAL (operands[1]) >= -0x8000)
344 return "cmp%.w %1,%0";
345 return "cmp%.l %d1,%d0";
350 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
351 (match_operand:SI 1 "general_operand" "r,mrKs")))]
354 if (REG_P (operands[1])
355 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
357 cc_status.flags |= CC_REVERSED;
358 return "cmp%.l %d0,%d1";
360 return "cmp%.l %d1,%d0";
363 (define_expand "cmphi"
365 (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
366 (match_operand:HI 1 "general_src_operand" "")))]
368 "m68k_last_compare_had_fp_operands = 0;")
372 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
373 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
376 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
377 return "cmpm%.w %1,%0";
378 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
379 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
381 cc_status.flags |= CC_REVERSED;
382 return "cmp%.w %d0,%d1";
384 return "cmp%.w %d1,%d0";
387 (define_expand "cmpqi"
389 (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
390 (match_operand:QI 1 "general_src_operand" "")))]
392 "m68k_last_compare_had_fp_operands = 0;")
396 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
397 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
400 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
401 return "cmpm%.b %1,%0";
402 if (REG_P (operands[1])
403 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
405 cc_status.flags |= CC_REVERSED;
406 return "cmp%.b %d0,%d1";
408 return "cmp%.b %d1,%d0";
411 (define_expand "cmpdf"
413 (compare (match_operand:DF 0 "general_operand" "")
414 (match_operand:DF 1 "general_operand" "")))]
417 m68k_last_compare_had_fp_operands = 1;
422 (compare (match_operand:DF 0 "general_operand" "f,mG")
423 (match_operand:DF 1 "general_operand" "fmG,f")))]
426 cc_status.flags = CC_IN_68881;
427 if (REG_P (operands[0]))
429 if (REG_P (operands[1]))
430 return "fcmp%.x %1,%0";
432 return "fcmp%.d %f1,%0";
434 cc_status.flags |= CC_REVERSED;
435 return "fcmp%.d %f0,%1";
438 (define_expand "cmpsf"
440 (compare (match_operand:SF 0 "general_operand" "")
441 (match_operand:SF 1 "general_operand" "")))]
444 m68k_last_compare_had_fp_operands = 1;
449 (compare (match_operand:SF 0 "general_operand" "f,mdG")
450 (match_operand:SF 1 "general_operand" "fmdG,f")))]
453 cc_status.flags = CC_IN_68881;
454 if (FP_REG_P (operands[0]))
456 if (FP_REG_P (operands[1]))
457 return "fcmp%.x %1,%0";
459 return "fcmp%.s %f1,%0";
461 cc_status.flags |= CC_REVERSED;
462 return "fcmp%.s %f0,%1";
465 ;; Recognizers for btst instructions.
467 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
468 ;; specified as a constant, so we must disable all patterns that may extract
469 ;; from a MEM at a constant bit position if we can't use this as a constraint.
472 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
474 (minus:SI (const_int 7)
475 (match_operand:SI 1 "general_operand" "di"))))]
478 return output_btst (operands, operands[1], operands[0], insn, 7);
481 ;; This is the same as the above pattern except for the constraints. The 'i'
485 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
487 (minus:SI (const_int 7)
488 (match_operand:SI 1 "general_operand" "d"))))]
491 return output_btst (operands, operands[1], operands[0], insn, 7);
495 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
497 (minus:SI (const_int 31)
498 (match_operand:SI 1 "general_operand" "di"))))]
501 return output_btst (operands, operands[1], operands[0], insn, 31);
504 ;; The following two patterns are like the previous two
505 ;; except that they use the fact that bit-number operands
506 ;; are automatically masked to 3 or 5 bits.
509 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
511 (minus:SI (const_int 7)
513 (match_operand:SI 1 "register_operand" "d")
517 return output_btst (operands, operands[1], operands[0], insn, 7);
521 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
523 (minus:SI (const_int 31)
525 (match_operand:SI 1 "register_operand" "d")
529 return output_btst (operands, operands[1], operands[0], insn, 31);
532 ;; Nonoffsettable mem refs are ok in this one pattern
533 ;; since we don't try to adjust them.
535 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
537 (match_operand:SI 1 "const_int_operand" "n")))]
538 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
540 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
541 return output_btst (operands, operands[1], operands[0], insn, 7);
545 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
547 (match_operand:SI 1 "const_int_operand" "n")))]
550 if (GET_CODE (operands[0]) == MEM)
552 operands[0] = adjust_address (operands[0], QImode,
553 INTVAL (operands[1]) / 8);
554 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
555 return output_btst (operands, operands[1], operands[0], insn, 7);
557 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
558 return output_btst (operands, operands[1], operands[0], insn, 31);
561 ;; This is the same as the above pattern except for the constraints.
562 ;; The 'o' has been replaced with 'Q'.
565 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
567 (match_operand:SI 1 "const_int_operand" "n")))]
570 if (GET_CODE (operands[0]) == MEM)
572 operands[0] = adjust_address (operands[0], QImode,
573 INTVAL (operands[1]) / 8);
574 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
575 return output_btst (operands, operands[1], operands[0], insn, 7);
577 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
578 return output_btst (operands, operands[1], operands[0], insn, 31);
584 ;; A special case in which it is not desirable
585 ;; to reload the constant into a data register.
586 (define_insn "pushexthisi_const"
587 [(set (match_operand:SI 0 "push_operand" "=m")
588 (match_operand:SI 1 "const_int_operand" "J"))]
589 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
591 if (operands[1] == const0_rtx)
593 if (valid_mov3q_const(operands[1]))
594 return "mov3q%.l %1,%-";
599 ;(define_insn "swapsi"
600 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
601 ; (match_operand:SI 1 "general_operand" "+r"))
602 ; (set (match_dup 1) (match_dup 0))]
606 ;; Special case of fullword move when source is zero.
607 ;; The reason this is special is to avoid loading a zero
608 ;; into a data reg with moveq in order to store it elsewhere.
610 (define_insn "movsi_const0"
611 [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
613 ;; clr insns on 68000 read before writing.
614 ;; This isn't so on the 68010, but we have no TARGET_68010.
615 "((TARGET_68020 || TARGET_COLDFIRE)
616 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
618 if (ADDRESS_REG_P (operands[0]))
620 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
621 if (!TARGET_68040 && !TARGET_68060)
622 return "sub%.l %0,%0";
624 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
626 /* moveq is faster on the 68000. */
627 if (DATA_REG_P (operands[0]) && (!TARGET_68020 && !TARGET_COLDFIRE))
628 return "moveq #0,%0";
632 ;; General case of fullword move.
634 ;; This is the main "hook" for PIC code. When generating
635 ;; PIC, movsi is responsible for determining when the source address
636 ;; needs PIC relocation and appropriately calling legitimize_pic_address
637 ;; to perform the actual relocation.
639 ;; In both the PIC and non-PIC cases the patterns generated will
640 ;; matched by the next define_insn.
641 (define_expand "movsi"
642 [(set (match_operand:SI 0 "nonimmediate_operand" "")
643 (match_operand:SI 1 "general_operand" ""))]
646 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
648 /* The source is an address which requires PIC relocation.
649 Call legitimize_pic_address with the source, mode, and a relocation
650 register (a new pseudo, or the final destination if reload_in_progress
651 is set). Then fall through normally */
652 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
653 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
655 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
657 /* Don't allow writes to memory except via a register;
658 the m68k doesn't consider PC-relative addresses to be writable. */
659 if (symbolic_operand (operands[0], SImode))
660 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
661 else if (GET_CODE (operands[0]) == MEM
662 && symbolic_operand (XEXP (operands[0], 0), SImode))
663 operands[0] = gen_rtx_MEM (SImode,
664 force_reg (SImode, XEXP (operands[0], 0)));
668 ;; General case of fullword move. The register constraints
669 ;; force integer constants in range for a moveq to be reloaded
670 ;; if they are headed for memory.
672 ;; Notes: make sure no alternative allows g vs g.
673 ;; We don't allow f-regs since fixed point cannot go in them.
674 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
675 (match_operand:SI 1 "general_src_operand" "daymSKT,n,i"))]
679 return output_move_simode (operands);
682 (define_insn "*movsi_cf"
683 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
684 (match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
685 "TARGET_COLDFIRE && !TARGET_CFV4"
686 "* return output_move_simode (operands);")
688 (define_insn "*movsi_cfv4"
689 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
690 (match_operand:SI 1 "general_operand" "Rg,Rr<Q>,U"))]
692 "* return output_move_simode (operands);")
694 ;; Special case of fullword move, where we need to get a non-GOT PIC
695 ;; reference into an address register.
697 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
698 (match_operand:SI 1 "pcrel_address" ""))]
701 if (push_operand (operands[0], SImode))
706 (define_expand "movhi"
707 [(set (match_operand:HI 0 "nonimmediate_operand" "")
708 (match_operand:HI 1 "general_operand" ""))]
713 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
714 (match_operand:HI 1 "general_src_operand" "gS"))]
716 "* return output_move_himode (operands);")
719 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
720 (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
722 "* return output_move_himode (operands);")
724 (define_expand "movstricthi"
725 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
726 (match_operand:HI 1 "general_src_operand" ""))]
731 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
732 (match_operand:HI 1 "general_src_operand" "rmSn"))]
734 "* return output_move_stricthi (operands);")
737 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
738 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
740 "* return output_move_stricthi (operands);")
742 (define_expand "movqi"
743 [(set (match_operand:QI 0 "nonimmediate_operand" "")
744 (match_operand:QI 1 "general_src_operand" ""))]
749 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
750 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
752 "* return output_move_qimode (operands);")
755 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
756 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
758 "* return output_move_qimode (operands);")
760 (define_expand "movstrictqi"
761 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
762 (match_operand:QI 1 "general_src_operand" ""))]
767 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
768 (match_operand:QI 1 "general_src_operand" "dmSn"))]
770 "* return output_move_strictqi (operands);")
773 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d,m"))
774 (match_operand:QI 1 "general_src_operand" "dmn,d"))]
776 "* return output_move_strictqi (operands);")
778 (define_expand "pushqi1"
779 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
780 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
781 (match_operand:QI 0 "general_operand" ""))]
785 (define_expand "movsf"
786 [(set (match_operand:SF 0 "nonimmediate_operand" "")
787 (match_operand:SF 1 "general_operand" ""))]
792 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
793 (match_operand:SF 1 "general_operand" "rmfF"))]
796 if (FP_REG_P (operands[0]))
798 if (FP_REG_P (operands[1]))
799 return "f%$move%.x %1,%0";
800 else if (ADDRESS_REG_P (operands[1]))
801 return "move%.l %1,%-\;f%$move%.s %+,%0";
802 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
803 return output_move_const_single (operands);
804 return "f%$move%.s %f1,%0";
806 if (FP_REG_P (operands[1]))
808 if (ADDRESS_REG_P (operands[0]))
809 return "fmove%.s %1,%-\;move%.l %+,%0";
810 return "fmove%.s %f1,%0";
812 if (operands[1] == CONST0_RTX (SFmode)
813 /* clr insns on 68000 read before writing.
814 This isn't so on the 68010, but we have no TARGET_68010. */
815 && ((TARGET_68020 || TARGET_COLDFIRE)
816 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
818 if (ADDRESS_REG_P (operands[0]))
820 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
821 if (!TARGET_68040 && !TARGET_68060)
822 return "sub%.l %0,%0";
824 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
826 /* moveq is faster on the 68000. */
827 if (DATA_REG_P (operands[0]) && !(TARGET_68020 || TARGET_COLDFIRE))
829 return "moveq #0,%0";
833 return "move%.l %1,%0";
837 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,g")
838 (match_operand:SF 1 "general_operand" "g,r"))]
841 return "move%.l %1,%0";
844 (define_expand "movdf"
845 [(set (match_operand:DF 0 "nonimmediate_operand" "")
846 (match_operand:DF 1 "general_operand" ""))]
851 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
852 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
853 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
854 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
857 if (FP_REG_P (operands[0]))
859 if (FP_REG_P (operands[1]))
860 return "f%&move%.x %1,%0";
861 if (REG_P (operands[1]))
864 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
865 output_asm_insn ("move%.l %1,%-", xoperands);
866 output_asm_insn ("move%.l %1,%-", operands);
867 return "f%&move%.d %+,%0";
869 if (GET_CODE (operands[1]) == CONST_DOUBLE)
870 return output_move_const_double (operands);
871 return "f%&move%.d %f1,%0";
873 else if (FP_REG_P (operands[1]))
875 if (REG_P (operands[0]))
877 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
878 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
879 return "move%.l %+,%0";
882 return "fmove%.d %f1,%0";
884 return output_move_double (operands);
888 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
889 (match_operand:DF 1 "general_operand" "g,r"))]
892 return output_move_double (operands);
895 ;; ??? The XFmode patterns are schizophrenic about whether constants are
896 ;; allowed. Most but not all have predicates and constraint that disallow
897 ;; constants. Most but not all have output templates that handle constants.
898 ;; See also LEGITIMATE_CONSTANT_P.
900 (define_expand "movxf"
901 [(set (match_operand:XF 0 "nonimmediate_operand" "")
902 (match_operand:XF 1 "general_operand" ""))]
905 /* We can't rewrite operands during reload. */
906 if (! reload_in_progress)
908 if (CONSTANT_P (operands[1]))
910 operands[1] = force_const_mem (XFmode, operands[1]);
911 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
912 operands[1] = adjust_address (operands[1], XFmode, 0);
914 if (flag_pic && TARGET_PCREL)
916 /* Don't allow writes to memory except via a register; the
917 m68k doesn't consider PC-relative addresses to be writable. */
918 if (GET_CODE (operands[0]) == MEM
919 && symbolic_operand (XEXP (operands[0], 0), SImode))
920 operands[0] = gen_rtx_MEM (XFmode,
921 force_reg (SImode, XEXP (operands[0], 0)));
927 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r")
928 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r"))]
931 if (FP_REG_P (operands[0]))
933 if (FP_REG_P (operands[1]))
934 return "fmove%.x %1,%0";
935 if (REG_P (operands[1]))
938 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
939 output_asm_insn ("move%.l %1,%-", xoperands);
940 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
941 output_asm_insn ("move%.l %1,%-", xoperands);
942 output_asm_insn ("move%.l %1,%-", operands);
943 return "fmove%.x %+,%0";
945 if (GET_CODE (operands[1]) == CONST_DOUBLE)
946 return "fmove%.x %1,%0";
947 return "fmove%.x %f1,%0";
949 if (FP_REG_P (operands[1]))
951 if (REG_P (operands[0]))
953 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
954 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
955 output_asm_insn ("move%.l %+,%0", operands);
956 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
957 return "move%.l %+,%0";
959 /* Must be memory destination. */
960 return "fmove%.x %f1,%0";
962 return output_move_double (operands);
966 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
967 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
968 "! TARGET_68881 && ! TARGET_COLDFIRE"
970 if (FP_REG_P (operands[0]))
972 if (FP_REG_P (operands[1]))
973 return "fmove%.x %1,%0";
974 if (REG_P (operands[1]))
977 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
978 output_asm_insn ("move%.l %1,%-", xoperands);
979 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
980 output_asm_insn ("move%.l %1,%-", xoperands);
981 output_asm_insn ("move%.l %1,%-", operands);
982 return "fmove%.x %+,%0";
984 if (GET_CODE (operands[1]) == CONST_DOUBLE)
985 return "fmove%.x %1,%0";
986 return "fmove%.x %f1,%0";
988 if (FP_REG_P (operands[1]))
990 if (REG_P (operands[0]))
992 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
993 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
994 output_asm_insn ("move%.l %+,%0", operands);
995 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
996 return "move%.l %+,%0";
999 return "fmove%.x %f1,%0";
1001 return output_move_double (operands);
1005 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1006 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1007 "! TARGET_68881 && TARGET_COLDFIRE"
1008 "* return output_move_double (operands);")
1010 (define_expand "movdi"
1011 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1012 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1013 (match_operand:DI 1 "general_operand" ""))]
1017 ;; movdi can apply to fp regs in some cases
1019 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1020 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1021 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1022 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1023 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1024 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1025 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1028 if (FP_REG_P (operands[0]))
1030 if (FP_REG_P (operands[1]))
1031 return "fmove%.x %1,%0";
1032 if (REG_P (operands[1]))
1035 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1036 output_asm_insn ("move%.l %1,%-", xoperands);
1037 output_asm_insn ("move%.l %1,%-", operands);
1038 return "fmove%.d %+,%0";
1040 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1041 return output_move_const_double (operands);
1042 return "fmove%.d %f1,%0";
1044 else if (FP_REG_P (operands[1]))
1046 if (REG_P (operands[0]))
1048 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1049 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1050 return "move%.l %+,%0";
1053 return "fmove%.d %f1,%0";
1055 return output_move_double (operands);
1059 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1060 (match_operand:DI 1 "general_operand" "g,r"))]
1062 "* return output_move_double (operands);")
1064 ;; Thus goes after the move instructions
1065 ;; because the move instructions are better (require no spilling)
1066 ;; when they can apply. It goes before the add/sub insns
1067 ;; so we will prefer it to them.
1069 (define_insn "pushasi"
1070 [(set (match_operand:SI 0 "push_operand" "=m")
1071 (match_operand:SI 1 "address_operand" "p"))]
1075 ;; truncation instructions
1076 (define_insn "truncsiqi2"
1077 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1079 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1082 if (GET_CODE (operands[0]) == REG)
1084 /* Must clear condition codes, since the move.l bases them on
1085 the entire 32 bits, not just the desired 8 bits. */
1087 return "move%.l %1,%0";
1089 if (GET_CODE (operands[1]) == MEM)
1090 operands[1] = adjust_address (operands[1], QImode, 3);
1091 return "move%.b %1,%0";
1094 (define_insn "trunchiqi2"
1095 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1097 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1100 if (GET_CODE (operands[0]) == REG
1101 && (GET_CODE (operands[1]) == MEM
1102 || GET_CODE (operands[1]) == CONST_INT))
1104 /* Must clear condition codes, since the move.w bases them on
1105 the entire 16 bits, not just the desired 8 bits. */
1107 return "move%.w %1,%0";
1109 if (GET_CODE (operands[0]) == REG)
1111 /* Must clear condition codes, since the move.l bases them on
1112 the entire 32 bits, not just the desired 8 bits. */
1114 return "move%.l %1,%0";
1116 if (GET_CODE (operands[1]) == MEM)
1117 operands[1] = adjust_address (operands[1], QImode, 1);
1118 return "move%.b %1,%0";
1121 (define_insn "truncsihi2"
1122 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1124 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1127 if (GET_CODE (operands[0]) == REG)
1129 /* Must clear condition codes, since the move.l bases them on
1130 the entire 32 bits, not just the desired 8 bits. */
1132 return "move%.l %1,%0";
1134 if (GET_CODE (operands[1]) == MEM)
1135 operands[1] = adjust_address (operands[1], QImode, 2);
1136 return "move%.w %1,%0";
1139 ;; zero extension instructions
1141 ;; two special patterns to match various post_inc/pre_dec patterns
1142 (define_insn_and_split "*zero_extend_inc"
1143 [(set (match_operand 0 "post_inc_operand" "")
1144 (zero_extend (match_operand 1 "register_operand" "")))]
1145 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1146 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1147 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1155 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1158 (define_insn_and_split "*zero_extend_dec"
1159 [(set (match_operand 0 "pre_dec_operand" "")
1160 (zero_extend (match_operand 1 "register_operand" "")))]
1161 "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1162 GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1163 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1164 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1172 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1175 (define_insn_and_split "zero_extendqidi2"
1176 [(set (match_operand:DI 0 "register_operand" "")
1177 (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1182 (zero_extend:SI (match_dup 1)))
1186 operands[2] = gen_lowpart (SImode, operands[0]);
1187 operands[3] = gen_highpart (SImode, operands[0]);
1190 (define_insn_and_split "zero_extendhidi2"
1191 [(set (match_operand:DI 0 "register_operand" "")
1192 (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1197 (zero_extend:SI (match_dup 1)))
1201 operands[2] = gen_lowpart (SImode, operands[0]);
1202 operands[3] = gen_highpart (SImode, operands[0]);
1205 (define_expand "zero_extendsidi2"
1206 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1207 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1211 (define_insn_and_split "*zero_extendsidi2"
1212 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1213 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1214 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1222 operands[2] = gen_lowpart (SImode, operands[0]);
1223 operands[3] = gen_highpart (SImode, operands[0]);
1226 (define_insn "*zero_extendhisi2_cf"
1227 [(set (match_operand:SI 0 "register_operand" "=d")
1228 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1232 (define_insn "zero_extendhisi2"
1233 [(set (match_operand:SI 0 "register_operand" "=d")
1234 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1238 (define_expand "zero_extendqihi2"
1239 [(set (match_operand:HI 0 "register_operand" "")
1240 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1244 (define_insn "*zero_extendqihi2"
1245 [(set (match_operand:HI 0 "register_operand" "=d")
1246 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1250 (define_insn "*zero_extendqisi2_cfv4"
1251 [(set (match_operand:SI 0 "register_operand" "=d")
1252 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1256 (define_insn "zero_extendqisi2"
1257 [(set (match_operand:SI 0 "register_operand" "=d")
1258 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1262 ;; these two pattern split everything else which isn't matched by
1263 ;; something else above
1265 [(set (match_operand 0 "register_operand" "")
1266 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1267 "!TARGET_CFV4 && reload_completed && reg_mentioned_p (operands[0], operands[1])"
1268 [(set (strict_low_part (match_dup 2))
1271 (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1273 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1274 operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1275 operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1279 [(set (match_operand 0 "register_operand" "")
1280 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1281 "!TARGET_CFV4 && reload_completed"
1284 (set (strict_low_part (match_dup 2))
1287 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1290 ;; sign extension instructions
1292 (define_insn "extendqidi2"
1293 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1294 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1298 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1300 return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1301 if (TARGET_68020 || TARGET_COLDFIRE)
1302 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1304 return "move%.b %1,%2\;ext%.w %0\;ext%.l %2\;move%.l %2,%0\;smi %0";
1307 (define_insn "extendhidi2"
1308 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1310 (match_operand:HI 1 "general_src_operand" "rmS")))]
1314 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1316 return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1317 if (TARGET_68020 || TARGET_COLDFIRE)
1318 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1320 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1323 (define_insn "extendsidi2"
1324 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1326 (match_operand:SI 1 "general_operand" "rm")))]
1330 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1331 if (TARGET_68020 || TARGET_COLDFIRE)
1332 return "move%.l %1,%2\;smi %0\;extb%.l %0";
1334 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
1337 ;; Special case when one can avoid register clobbering, copy and test
1338 ;; Maybe there is a way to make that the general case, by forcing the
1339 ;; result of the SI tree to be in the lower register of the DI target
1341 (define_insn "extendplussidi"
1342 [(set (match_operand:DI 0 "register_operand" "=d")
1343 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1344 (match_operand:SI 2 "general_operand" "rmn"))))]
1348 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1349 if (GET_CODE (operands[1]) == CONST_INT
1350 && (unsigned) INTVAL (operands[1]) > 8)
1352 rtx tmp = operands[1];
1354 operands[1] = operands[2];
1357 if (GET_CODE (operands[1]) == REG
1358 && REGNO (operands[1]) == REGNO (operands[3]))
1359 output_asm_insn ("add%.l %2,%3", operands);
1361 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1362 if (TARGET_68020 || TARGET_COLDFIRE)
1363 return "smi %0\;extb%.l %0";
1365 return "smi %0\;ext%.w %0\;ext%.l %0";
1368 (define_expand "extendhisi2"
1369 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1371 (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1375 (define_insn "*cfv4_extendhisi2"
1376 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1378 (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1382 (define_insn "*68k_extendhisi2"
1383 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1385 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1388 if (ADDRESS_REG_P (operands[0]))
1389 return "move%.w %1,%0";
1393 (define_insn "extendqihi2"
1394 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1395 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1399 (define_expand "extendqisi2"
1400 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1401 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1402 "TARGET_68020 || TARGET_COLDFIRE"
1405 (define_insn "*cfv4_extendqisi2"
1406 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1407 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1411 (define_insn "*68k_extendqisi2"
1412 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1413 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1414 "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_CFV4)"
1417 ;; Conversions between float and double.
1419 (define_expand "extendsfdf2"
1420 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1422 (match_operand:SF 1 "general_operand" "")))]
1427 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1429 (match_operand:SF 1 "general_operand" "f,dmF")))]
1432 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1434 if (REGNO (operands[0]) == REGNO (operands[1]))
1436 /* Extending float to double in an fp-reg is a no-op.
1437 NOTICE_UPDATE_CC has already assumed that the
1438 cc will be set. So cancel what it did. */
1439 cc_status = cc_prev_status;
1442 return "f%&move%.x %1,%0";
1444 if (FP_REG_P (operands[0]))
1445 return "f%&move%.s %f1,%0";
1446 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1448 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1449 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1450 return "move%.l %+,%0";
1452 return "fmove%.d %f1,%0";
1455 ;; This cannot output into an f-reg because there is no way to be
1456 ;; sure of truncating in that case.
1457 (define_expand "truncdfsf2"
1458 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1460 (match_operand:DF 1 "general_operand" "")))]
1464 ;; On the '040 we can truncate in a register accurately and easily.
1466 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1468 (match_operand:DF 1 "general_operand" "fmG")))]
1469 "TARGET_68881 && TARGET_68040_ONLY"
1471 if (FP_REG_P (operands[1]))
1472 return "f%$move%.x %1,%0";
1473 return "f%$move%.d %f1,%0";
1477 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1479 (match_operand:DF 1 "general_operand" "f")))]
1483 ;; Conversion between fixed point and floating point.
1484 ;; Note that among the fix-to-float insns
1485 ;; the ones that start with SImode come first.
1486 ;; That is so that an operand that is a CONST_INT
1487 ;; (and therefore lacks a specific machine mode).
1488 ;; will be recognized as SImode (which is always valid)
1489 ;; rather than as QImode or HImode.
1491 (define_expand "floatsisf2"
1492 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1493 (float:SF (match_operand:SI 1 "general_operand" "")))]
1498 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1499 (float:SF (match_operand:SI 1 "general_operand" "dmi")))]
1503 (define_expand "floatsidf2"
1504 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1505 (float:DF (match_operand:SI 1 "general_operand" "")))]
1510 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1511 (float:DF (match_operand:SI 1 "general_operand" "dmi")))]
1515 (define_insn "floathisf2"
1516 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1517 (float:SF (match_operand:HI 1 "general_operand" "dmn")))]
1521 (define_insn "floathidf2"
1522 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1523 (float:DF (match_operand:HI 1 "general_operand" "dmn")))]
1527 (define_insn "floatqisf2"
1528 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1529 (float:SF (match_operand:QI 1 "general_operand" "dmn")))]
1533 (define_insn "floatqidf2"
1534 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1535 (float:DF (match_operand:QI 1 "general_operand" "dmn")))]
1539 ;; New routines to convert floating-point values to integers
1540 ;; to be used on the '040. These should be faster than trapping
1541 ;; into the kernel to emulate fintrz. They should also be faster
1542 ;; than calling the subroutines fixsfsi or fixdfsi.
1544 (define_insn "fix_truncdfsi2"
1545 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1546 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1547 (clobber (match_scratch:SI 2 "=d"))
1548 (clobber (match_scratch:SI 3 "=d"))]
1549 "TARGET_68881 && TARGET_68040"
1552 return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.l %1,%0\;fmovem%.l %2,%!";
1555 (define_insn "fix_truncdfhi2"
1556 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1557 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1558 (clobber (match_scratch:SI 2 "=d"))
1559 (clobber (match_scratch:SI 3 "=d"))]
1560 "TARGET_68881 && TARGET_68040"
1563 return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.w %1,%0\;fmovem%.l %2,%!";
1566 (define_insn "fix_truncdfqi2"
1567 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1568 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1569 (clobber (match_scratch:SI 2 "=d"))
1570 (clobber (match_scratch:SI 3 "=d"))]
1571 "TARGET_68881 && TARGET_68040"
1574 return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.b %1,%0\;fmovem%.l %2,%!";
1577 ;; Convert a float to a float whose value is an integer.
1578 ;; This is the first stage of converting it to an integer type.
1580 (define_insn "ftruncdf2"
1581 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1582 (fix:DF (match_operand:DF 1 "general_operand" "fFm")))]
1583 "TARGET_68881 && !TARGET_68040"
1585 if (FP_REG_P (operands[1]))
1586 return "fintrz%.x %f1,%0";
1587 return "fintrz%.d %f1,%0";
1590 (define_insn "ftruncsf2"
1591 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1592 (fix:SF (match_operand:SF 1 "general_operand" "dfFm")))]
1593 "TARGET_68881 && !TARGET_68040"
1595 if (FP_REG_P (operands[1]))
1596 return "fintrz%.x %f1,%0";
1597 return "fintrz%.s %f1,%0";
1600 ;; Convert a float whose value is an integer
1601 ;; to an actual integer. Second stage of converting float to integer type.
1602 (define_insn "fixsfqi2"
1603 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1604 (fix:QI (match_operand:SF 1 "general_operand" "f")))]
1608 (define_insn "fixsfhi2"
1609 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1610 (fix:HI (match_operand:SF 1 "general_operand" "f")))]
1614 (define_insn "fixsfsi2"
1615 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1616 (fix:SI (match_operand:SF 1 "general_operand" "f")))]
1620 (define_insn "fixdfqi2"
1621 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1622 (fix:QI (match_operand:DF 1 "general_operand" "f")))]
1626 (define_insn "fixdfhi2"
1627 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1628 (fix:HI (match_operand:DF 1 "general_operand" "f")))]
1632 (define_insn "fixdfsi2"
1633 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1634 (fix:SI (match_operand:DF 1 "general_operand" "f")))]
1640 (define_insn "adddi_lshrdi_63"
1641 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1642 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
1645 (clobber (match_scratch:SI 2 "=d"))]
1648 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1649 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
1651 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
1652 if (GET_CODE (operands[1]) == REG)
1653 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1654 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
1655 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1656 operands[4] = operands[1];
1658 operands[4] = adjust_address (operands[1], SImode, 4);
1659 if (GET_CODE (operands[1]) == MEM
1660 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1661 output_asm_insn ("move%.l %4,%3", operands);
1662 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
1663 if (TARGET_68020 || TARGET_COLDFIRE)
1664 output_asm_insn ("extb%.l %2", operands);
1666 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
1667 if (GET_CODE (operands[1]) != MEM
1668 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
1669 output_asm_insn ("move%.l %4,%3", operands);
1670 return "sub%.l %2,%3\;subx%.l %2,%0";
1673 (define_insn "adddi_sexthishl32"
1674 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
1675 (plus:DI (ashift:DI (sign_extend:DI
1676 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
1678 (match_operand:DI 2 "general_operand" "0,0,0,0")))
1679 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
1683 if (ADDRESS_REG_P (operands[0]))
1684 return "add%.w %1,%0";
1685 else if (ADDRESS_REG_P (operands[3]))
1686 return "move%.w %1,%3\;add%.l %3,%0";
1688 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
1691 (define_insn "adddi_dilshr32"
1692 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
1693 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1694 ;; (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
1695 ;; (const_int 32))))]
1696 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
1698 (match_operand:DI 2 "general_operand" "0,0")))]
1702 if (GET_CODE (operands[0]) == REG)
1703 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1705 operands[2] = adjust_address (operands[0], SImode, 4);
1706 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
1709 (define_insn "adddi_dishl32"
1710 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
1711 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1712 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
1713 ;; (const_int 32))))]
1714 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
1716 (match_operand:DI 2 "general_operand" "0,0")))]
1720 if (GET_CODE (operands[1]) == REG)
1721 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1723 operands[1] = adjust_address (operands[1], SImode, 4);
1724 return "add%.l %1,%0";
1727 (define_insn "adddi3"
1728 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
1729 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0,0")
1730 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
1731 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
1734 if (DATA_REG_P (operands[0]))
1736 if (DATA_REG_P (operands[2]))
1737 return "add%.l %R2,%R0\;addx%.l %2,%0";
1738 else if (GET_CODE (operands[2]) == MEM
1739 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
1740 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
1746 if (GET_CODE (operands[2]) == REG)
1748 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
1751 else if (CONSTANT_P (operands[2]))
1752 split_double (operands[2], &high, &low);
1755 low = adjust_address (operands[2], SImode, 4);
1759 operands[1] = low, operands[2] = high;
1760 xoperands[0] = operands[3];
1761 if (GET_CODE (operands[1]) == CONST_INT
1762 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1763 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
1765 xoperands[1] = operands[2];
1767 output_asm_insn (output_move_simode (xoperands), xoperands);
1768 if (GET_CODE (operands[1]) == CONST_INT)
1770 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
1771 return "addq%.l %1,%R0\;addx%.l %3,%0";
1772 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1774 operands[1] = GEN_INT (-INTVAL (operands[1]));
1775 return "subq%.l %1,%R0\;subx%.l %3,%0";
1778 return "add%.l %1,%R0\;addx%.l %3,%0";
1783 gcc_assert (GET_CODE (operands[0]) == MEM);
1784 if (GET_CODE (operands[2]) == MEM
1785 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
1786 return "add%.l %2,%0\;addx%.l %2,%0";
1788 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1790 operands[1] = gen_rtx_MEM (SImode,
1791 plus_constant (XEXP(operands[0], 0), -8));
1792 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
1794 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1796 operands[1] = XEXP(operands[0], 0);
1797 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
1801 operands[1] = adjust_address (operands[0], SImode, 4);
1802 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
1807 (define_insn "addsi_lshrsi_31"
1808 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1809 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
1814 operands[2] = operands[0];
1815 operands[3] = gen_label_rtx();
1816 if (GET_CODE (operands[0]) == MEM)
1818 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1819 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
1820 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1821 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
1823 output_asm_insn ("move%.l %1,%0", operands);
1824 output_asm_insn (MOTOROLA ? "jbpl %l3" : "jpl %l3", operands);
1825 output_asm_insn ("addq%.l #1,%2", operands);
1826 (*targetm.asm_out.internal_label) (asm_out_file, "L",
1827 CODE_LABEL_NUMBER (operands[3]));
1831 (define_expand "addsi3"
1832 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1833 (plus:SI (match_operand:SI 1 "general_operand" "")
1834 (match_operand:SI 2 "general_src_operand" "")))]
1838 ;; Note that the middle two alternatives are near-duplicates
1839 ;; in order to handle insns generated by reload.
1840 ;; This is needed since they are not themselves reloaded,
1841 ;; so commutativity won't apply to them.
1842 (define_insn "*addsi3_internal"
1843 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
1844 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
1845 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
1849 "* return output_addsi3 (operands);")
1851 (define_insn "*addsi3_5200"
1852 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
1853 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
1854 (match_operand:SI 2 "general_src_operand" "d,rJK,a,mrIKLs")))]
1856 "* return output_addsi3 (operands);")
1859 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
1860 (plus:SI (match_operand:SI 1 "general_operand" "0")
1862 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
1866 (define_insn "addhi3"
1867 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
1868 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
1869 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
1872 if (GET_CODE (operands[2]) == CONST_INT)
1874 /* If the constant would be a negative number when interpreted as
1875 HImode, make it negative. This is usually, but not always, done
1876 elsewhere in the compiler. First check for constants out of range,
1877 which could confuse us. */
1879 if (INTVAL (operands[2]) >= 32768)
1880 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
1882 if (INTVAL (operands[2]) > 0
1883 && INTVAL (operands[2]) <= 8)
1884 return "addq%.w %2,%0";
1885 if (INTVAL (operands[2]) < 0
1886 && INTVAL (operands[2]) >= -8)
1888 operands[2] = GEN_INT (- INTVAL (operands[2]));
1889 return "subq%.w %2,%0";
1891 /* On the CPU32 it is faster to use two addqw instructions to
1892 add a small integer (8 < N <= 16) to a register.
1893 Likewise for subqw. */
1894 if (TARGET_CPU32 && REG_P (operands[0]))
1896 if (INTVAL (operands[2]) > 8
1897 && INTVAL (operands[2]) <= 16)
1899 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
1900 return "addq%.w #8,%0\;addq%.w %2,%0";
1902 if (INTVAL (operands[2]) < -8
1903 && INTVAL (operands[2]) >= -16)
1905 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
1906 return "subq%.w #8,%0\;subq%.w %2,%0";
1909 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
1910 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
1912 return "add%.w %2,%0";
1915 ;; These insns must use MATCH_DUP instead of the more expected
1916 ;; use of a matching constraint because the "output" here is also
1917 ;; an input, so you can't use the matching constraint. That also means
1918 ;; that you can't use the "%", so you need patterns with the matched
1919 ;; operand in both positions.
1922 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
1923 (plus:HI (match_dup 0)
1924 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
1927 if (GET_CODE (operands[1]) == CONST_INT)
1929 /* If the constant would be a negative number when interpreted as
1930 HImode, make it negative. This is usually, but not always, done
1931 elsewhere in the compiler. First check for constants out of range,
1932 which could confuse us. */
1934 if (INTVAL (operands[1]) >= 32768)
1935 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
1937 if (INTVAL (operands[1]) > 0
1938 && INTVAL (operands[1]) <= 8)
1939 return "addq%.w %1,%0";
1940 if (INTVAL (operands[1]) < 0
1941 && INTVAL (operands[1]) >= -8)
1943 operands[1] = GEN_INT (- INTVAL (operands[1]));
1944 return "subq%.w %1,%0";
1946 /* On the CPU32 it is faster to use two addqw instructions to
1947 add a small integer (8 < N <= 16) to a register.
1948 Likewise for subqw. */
1949 if (TARGET_CPU32 && REG_P (operands[0]))
1951 if (INTVAL (operands[1]) > 8
1952 && INTVAL (operands[1]) <= 16)
1954 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
1955 return "addq%.w #8,%0\;addq%.w %1,%0";
1957 if (INTVAL (operands[1]) < -8
1958 && INTVAL (operands[1]) >= -16)
1960 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
1961 return "subq%.w #8,%0\;subq%.w %1,%0";
1964 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
1965 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
1967 return "add%.w %1,%0";
1971 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
1972 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
1976 if (GET_CODE (operands[1]) == CONST_INT)
1978 /* If the constant would be a negative number when interpreted as
1979 HImode, make it negative. This is usually, but not always, done
1980 elsewhere in the compiler. First check for constants out of range,
1981 which could confuse us. */
1983 if (INTVAL (operands[1]) >= 32768)
1984 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
1986 if (INTVAL (operands[1]) > 0
1987 && INTVAL (operands[1]) <= 8)
1988 return "addq%.w %1,%0";
1989 if (INTVAL (operands[1]) < 0
1990 && INTVAL (operands[1]) >= -8)
1992 operands[1] = GEN_INT (- INTVAL (operands[1]));
1993 return "subq%.w %1,%0";
1995 /* On the CPU32 it is faster to use two addqw instructions to
1996 add a small integer (8 < N <= 16) to a register.
1997 Likewise for subqw. */
1998 if (TARGET_CPU32 && REG_P (operands[0]))
2000 if (INTVAL (operands[1]) > 8
2001 && INTVAL (operands[1]) <= 16)
2003 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2004 return "addq%.w #8,%0\;addq%.w %1,%0";
2006 if (INTVAL (operands[1]) < -8
2007 && INTVAL (operands[1]) >= -16)
2009 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2010 return "subq%.w #8,%0\;subq%.w %1,%0";
2013 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2014 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2016 return "add%.w %1,%0";
2019 (define_insn "addqi3"
2020 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2021 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2022 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2025 if (GET_CODE (operands[2]) == CONST_INT)
2027 if (INTVAL (operands[2]) >= 128)
2028 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2030 if (INTVAL (operands[2]) > 0
2031 && INTVAL (operands[2]) <= 8)
2032 return "addq%.b %2,%0";
2033 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2035 operands[2] = GEN_INT (- INTVAL (operands[2]));
2036 return "subq%.b %2,%0";
2039 return "add%.b %2,%0";
2043 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2044 (plus:QI (match_dup 0)
2045 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2048 if (GET_CODE (operands[1]) == CONST_INT)
2050 if (INTVAL (operands[1]) >= 128)
2051 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2053 if (INTVAL (operands[1]) > 0
2054 && INTVAL (operands[1]) <= 8)
2055 return "addq%.b %1,%0";
2056 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2058 operands[1] = GEN_INT (- INTVAL (operands[1]));
2059 return "subq%.b %1,%0";
2062 return "add%.b %1,%0";
2066 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2067 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2071 if (GET_CODE (operands[1]) == CONST_INT)
2073 if (INTVAL (operands[1]) >= 128)
2074 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2076 if (INTVAL (operands[1]) > 0
2077 && INTVAL (operands[1]) <= 8)
2078 return "addq%.b %1,%0";
2079 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2081 operands[1] = GEN_INT (- INTVAL (operands[1]));
2082 return "subq%.b %1,%0";
2085 return "add%.b %1,%0";
2088 (define_expand "adddf3"
2089 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2090 (plus:DF (match_operand:DF 1 "general_operand" "")
2091 (match_operand:DF 2 "general_operand" "")))]
2096 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2097 (plus:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2098 (match_operand:DF 1 "general_operand" "0")))]
2103 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2104 (plus:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2105 (match_operand:DF 1 "general_operand" "0")))]
2110 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2111 (plus:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2112 (match_operand:DF 1 "general_operand" "0")))]
2117 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2118 (plus:DF (match_operand:DF 1 "general_operand" "%0")
2119 (match_operand:DF 2 "general_operand" "fmG")))]
2122 if (REG_P (operands[2]))
2123 return "f%&add%.x %2,%0";
2124 return "f%&add%.d %f2,%0";
2127 (define_expand "addsf3"
2128 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2129 (plus:SF (match_operand:SF 1 "general_operand" "")
2130 (match_operand:SF 2 "general_operand" "")))]
2135 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2136 (plus:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2137 (match_operand:SF 1 "general_operand" "0")))]
2142 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2143 (plus:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2144 (match_operand:SF 1 "general_operand" "0")))]
2149 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2150 (plus:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2151 (match_operand:SF 1 "general_operand" "0")))]
2156 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2157 (plus:SF (match_operand:SF 1 "general_operand" "%0")
2158 (match_operand:SF 2 "general_operand" "fdmF")))]
2161 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2162 return "f%$add%.x %2,%0";
2163 return "f%$add%.s %f2,%0";
2166 ;; subtract instructions
2168 (define_insn "subdi_sexthishl32"
2169 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2170 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2171 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2173 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2177 if (ADDRESS_REG_P (operands[0]))
2178 return "sub%.w %2,%0";
2179 else if (ADDRESS_REG_P (operands[3]))
2180 return "move%.w %2,%3\;sub%.l %3,%0";
2182 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2185 (define_insn "subdi_dishl32"
2186 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2187 (minus:DI (match_dup 0)
2188 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2193 if (GET_CODE (operands[1]) == REG)
2194 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2196 operands[1] = adjust_address (operands[1], SImode, 4);
2197 return "sub%.l %1,%0";
2200 (define_insn "subdi3"
2201 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
2202 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0,0")
2203 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
2204 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
2207 if (DATA_REG_P (operands[0]))
2209 if (DATA_REG_P (operands[2]))
2210 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2211 else if (GET_CODE (operands[2]) == MEM
2212 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2214 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2221 if (GET_CODE (operands[2]) == REG)
2223 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2226 else if (CONSTANT_P (operands[2]))
2227 split_double (operands[2], &high, &low);
2230 low = adjust_address (operands[2], SImode, 4);
2234 operands[1] = low, operands[2] = high;
2235 xoperands[0] = operands[3];
2236 if (GET_CODE (operands[1]) == CONST_INT
2237 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2238 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2240 xoperands[1] = operands[2];
2242 output_asm_insn (output_move_simode (xoperands), xoperands);
2243 if (GET_CODE (operands[1]) == CONST_INT)
2245 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2246 return "subq%.l %1,%R0\;subx%.l %3,%0";
2247 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2249 operands[1] = GEN_INT (-INTVAL (operands[1]));
2250 return "addq%.l %1,%R0\;addx%.l %3,%0";
2253 return "sub%.l %1,%R0\;subx%.l %3,%0";
2258 gcc_assert (GET_CODE (operands[0]) == MEM);
2259 if (GET_CODE (operands[2]) == MEM
2260 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
2261 return "sub%.l %2,%0\;subx%.l %2,%0";
2263 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2266 = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2267 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2269 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2271 operands[1] = XEXP(operands[0], 0);
2272 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2276 operands[1] = adjust_address (operands[0], SImode, 4);
2277 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2282 (define_insn "subsi3"
2283 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2284 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2285 (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2290 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2291 (minus:SI (match_operand:SI 1 "general_operand" "0")
2293 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2297 (define_insn "subhi3"
2298 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2299 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2300 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2305 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2306 (minus:HI (match_dup 0)
2307 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2311 (define_insn "subqi3"
2312 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2313 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2314 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2319 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2320 (minus:QI (match_dup 0)
2321 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2325 (define_expand "subdf3"
2326 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2327 (minus:DF (match_operand:DF 1 "general_operand" "")
2328 (match_operand:DF 2 "general_operand" "")))]
2333 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2334 (minus:DF (match_operand:DF 1 "general_operand" "0")
2335 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2340 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2341 (minus:DF (match_operand:DF 1 "general_operand" "0")
2342 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2347 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2348 (minus:DF (match_operand:DF 1 "general_operand" "0")
2349 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2354 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2355 (minus:DF (match_operand:DF 1 "general_operand" "0")
2356 (match_operand:DF 2 "general_operand" "fmG")))]
2359 if (REG_P (operands[2]))
2360 return "f%&sub%.x %2,%0";
2361 return "f%&sub%.d %f2,%0";
2364 (define_expand "subsf3"
2365 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2366 (minus:SF (match_operand:SF 1 "general_operand" "")
2367 (match_operand:SF 2 "general_operand" "")))]
2372 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2373 (minus:SF (match_operand:SF 1 "general_operand" "0")
2374 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2379 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2380 (minus:SF (match_operand:SF 1 "general_operand" "0")
2381 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2386 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2387 (minus:SF (match_operand:SF 1 "general_operand" "0")
2388 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2393 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2394 (minus:SF (match_operand:SF 1 "general_operand" "0")
2395 (match_operand:SF 2 "general_operand" "fdmF")))]
2398 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2399 return "f%$sub%.x %2,%0";
2400 return "f%$sub%.s %f2,%0";
2403 ;; multiply instructions
2405 (define_insn "mulhi3"
2406 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2407 (mult:HI (match_operand:HI 1 "general_operand" "%0")
2408 (match_operand:HI 2 "general_src_operand" "dmSn")))]
2411 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2414 (define_insn "mulhisi3"
2415 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2416 (mult:SI (sign_extend:SI
2417 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2419 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2422 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2426 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2427 (mult:SI (sign_extend:SI
2428 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2429 (match_operand:SI 2 "const_int_operand" "n")))]
2430 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2432 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2435 (define_expand "mulsi3"
2436 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2437 (mult:SI (match_operand:SI 1 "general_operand" "")
2438 (match_operand:SI 2 "general_operand" "")))]
2439 "TARGET_68020 || TARGET_COLDFIRE"
2443 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2444 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2445 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2451 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2452 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2453 (match_operand:SI 2 "general_operand" "d<Q>")))]
2457 (define_insn "umulhisi3"
2458 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2459 (mult:SI (zero_extend:SI
2460 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2462 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2465 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2469 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2470 (mult:SI (zero_extend:SI
2471 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2472 (match_operand:SI 2 "const_int_operand" "n")))]
2473 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2475 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2478 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2479 ;; proper matching constraint. This is because the matching is between
2480 ;; the high-numbered word of the DImode operand[0] and operand[1].
2481 (define_expand "umulsidi3"
2483 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2484 (mult:SI (match_operand:SI 1 "register_operand" "")
2485 (match_operand:SI 2 "register_operand" "")))
2486 (set (subreg:SI (match_dup 0) 0)
2487 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2488 (zero_extend:DI (match_dup 2)))
2489 (const_int 32))))])]
2490 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2494 [(set (match_operand:SI 0 "register_operand" "=d")
2495 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2496 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2497 (set (match_operand:SI 3 "register_operand" "=d")
2498 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2499 (zero_extend:DI (match_dup 2)))
2501 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2504 ; Match immediate case. For 2.4 only match things < 2^31.
2505 ; It's tricky with larger values in these patterns since we need to match
2506 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2509 [(set (match_operand:SI 0 "register_operand" "=d")
2510 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2511 (match_operand:SI 2 "const_int_operand" "n")))
2512 (set (match_operand:SI 3 "register_operand" "=d")
2513 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2516 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE
2517 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2520 (define_expand "mulsidi3"
2522 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2523 (mult:SI (match_operand:SI 1 "register_operand" "")
2524 (match_operand:SI 2 "register_operand" "")))
2525 (set (subreg:SI (match_dup 0) 0)
2526 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2527 (sign_extend:DI (match_dup 2)))
2528 (const_int 32))))])]
2529 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2533 [(set (match_operand:SI 0 "register_operand" "=d")
2534 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2535 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2536 (set (match_operand:SI 3 "register_operand" "=d")
2537 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2538 (sign_extend:DI (match_dup 2)))
2540 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2544 [(set (match_operand:SI 0 "register_operand" "=d")
2545 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2546 (match_operand:SI 2 "const_int_operand" "n")))
2547 (set (match_operand:SI 3 "register_operand" "=d")
2548 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2551 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2554 (define_expand "umulsi3_highpart"
2556 [(set (match_operand:SI 0 "register_operand" "")
2559 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2560 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2562 (clobber (match_dup 3))])]
2563 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2565 operands[3] = gen_reg_rtx (SImode);
2567 if (GET_CODE (operands[2]) == CONST_INT)
2569 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2572 /* We have to adjust the operand order for the matching constraints. */
2573 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2574 operands[1], operands[2]));
2580 [(set (match_operand:SI 0 "register_operand" "=d")
2583 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2584 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2586 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2587 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2590 (define_insn "const_umulsi3_highpart"
2591 [(set (match_operand:SI 0 "register_operand" "=d")
2594 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2595 (match_operand:DI 3 "const_uint32_operand" "n"))
2597 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2598 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2601 (define_expand "smulsi3_highpart"
2603 [(set (match_operand:SI 0 "register_operand" "")
2606 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2607 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2609 (clobber (match_dup 3))])]
2610 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2612 operands[3] = gen_reg_rtx (SImode);
2613 if (GET_CODE (operands[2]) == CONST_INT)
2615 /* We have to adjust the operand order for the matching constraints. */
2616 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2617 operands[1], operands[2]));
2623 [(set (match_operand:SI 0 "register_operand" "=d")
2626 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2627 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2629 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2630 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2633 (define_insn "const_smulsi3_highpart"
2634 [(set (match_operand:SI 0 "register_operand" "=d")
2637 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2638 (match_operand:DI 3 "const_sint32_operand" "n"))
2640 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2641 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2644 (define_expand "muldf3"
2645 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2646 (mult:DF (match_operand:DF 1 "general_operand" "")
2647 (match_operand:DF 2 "general_operand" "")))]
2652 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2653 (mult:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2654 (match_operand:DF 1 "general_operand" "0")))]
2659 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2660 (mult:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2661 (match_operand:DF 1 "general_operand" "0")))]
2666 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2667 (mult:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2668 (match_operand:DF 1 "general_operand" "0")))]
2673 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2674 (mult:DF (match_operand:DF 1 "general_operand" "%0")
2675 (match_operand:DF 2 "general_operand" "fmG")))]
2678 if (GET_CODE (operands[2]) == CONST_DOUBLE
2679 && floating_exact_log2 (operands[2]) && !TARGET_68040 && !TARGET_68060)
2681 int i = floating_exact_log2 (operands[2]);
2682 operands[2] = GEN_INT (i);
2683 return "fscale%.l %2,%0";
2685 if (REG_P (operands[2]))
2686 return "f%&mul%.x %2,%0";
2687 return "f%&mul%.d %f2,%0";
2690 (define_expand "mulsf3"
2691 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2692 (mult:SF (match_operand:SF 1 "general_operand" "")
2693 (match_operand:SF 2 "general_operand" "")))]
2698 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2699 (mult:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2700 (match_operand:SF 1 "general_operand" "0")))]
2703 return (TARGET_68040_ONLY
2705 : "fsglmul%.l %2,%0");
2709 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2710 (mult:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2711 (match_operand:SF 1 "general_operand" "0")))]
2714 return (TARGET_68040_ONLY
2716 : "fsglmul%.w %2,%0");
2720 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2721 (mult:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2722 (match_operand:SF 1 "general_operand" "0")))]
2725 return (TARGET_68040_ONLY
2727 : "fsglmul%.b %2,%0");
2731 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2732 (mult:SF (match_operand:SF 1 "general_operand" "%0")
2733 (match_operand:SF 2 "general_operand" "fdmF")))]
2736 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2737 return (TARGET_68040_ONLY
2739 : "fsglmul%.x %2,%0");
2740 return (TARGET_68040_ONLY
2742 : "fsglmul%.s %f2,%0");
2745 ;; divide instructions
2747 (define_expand "divdf3"
2748 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2749 (div:DF (match_operand:DF 1 "general_operand" "")
2750 (match_operand:DF 2 "general_operand" "")))]
2755 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2756 (div:DF (match_operand:DF 1 "general_operand" "0")
2757 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2762 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2763 (div:DF (match_operand:DF 1 "general_operand" "0")
2764 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2769 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2770 (div:DF (match_operand:DF 1 "general_operand" "0")
2771 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2776 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2777 (div:DF (match_operand:DF 1 "general_operand" "0")
2778 (match_operand:DF 2 "general_operand" "fmG")))]
2781 if (REG_P (operands[2]))
2782 return "f%&div%.x %2,%0";
2783 return "f%&div%.d %f2,%0";
2786 (define_expand "divsf3"
2787 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2788 (div:SF (match_operand:SF 1 "general_operand" "")
2789 (match_operand:SF 2 "general_operand" "")))]
2794 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2795 (div:SF (match_operand:SF 1 "general_operand" "0")
2796 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2799 return (TARGET_68040_ONLY
2801 : "fsgldiv%.l %2,%0");
2805 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2806 (div:SF (match_operand:SF 1 "general_operand" "0")
2807 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2810 return (TARGET_68040_ONLY
2812 : "fsgldiv%.w %2,%0");
2816 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2817 (div:SF (match_operand:SF 1 "general_operand" "0")
2818 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2821 return (TARGET_68040_ONLY
2823 : "fsgldiv%.b %2,%0");
2827 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2828 (div:SF (match_operand:SF 1 "general_operand" "0")
2829 (match_operand:SF 2 "general_operand" "fdmF")))]
2832 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2833 return (TARGET_68040_ONLY
2835 : "fsgldiv%.x %2,%0");
2836 return (TARGET_68040_ONLY
2838 : "fsgldiv%.s %f2,%0");
2841 ;; Remainder instructions.
2843 (define_expand "divmodsi4"
2845 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2846 (div:SI (match_operand:SI 1 "general_operand" "")
2847 (match_operand:SI 2 "general_src_operand" "")))
2848 (set (match_operand:SI 3 "nonimmediate_operand" "")
2849 (mod:SI (match_dup 1) (match_dup 2)))])]
2850 "TARGET_68020 || TARGET_CF_HWDIV"
2854 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2855 (div:SI (match_operand:SI 1 "general_operand" "0")
2856 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2857 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2858 (mod:SI (match_dup 1) (match_dup 2)))]
2861 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2862 return "divs%.l %2,%0";
2863 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2864 return "rems%.l %2,%3:%0";
2866 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
2870 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2871 (div:SI (match_operand:SI 1 "general_operand" "0")
2872 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2873 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2874 (mod:SI (match_dup 1) (match_dup 2)))]
2877 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2878 return "divs%.l %2,%0";
2880 return "divsl%.l %2,%3:%0";
2883 (define_expand "udivmodsi4"
2885 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2886 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2887 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2888 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2889 (umod:SI (match_dup 1) (match_dup 2)))])]
2890 "TARGET_68020 || TARGET_CF_HWDIV"
2894 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2895 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2896 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2897 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2898 (umod:SI (match_dup 1) (match_dup 2)))]
2901 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2902 return "divu%.l %2,%0";
2903 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2904 return "remu%.l %2,%3:%0";
2906 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
2910 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2911 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2912 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2913 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2914 (umod:SI (match_dup 1) (match_dup 2)))]
2915 "TARGET_68020 && !TARGET_COLDFIRE"
2917 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2918 return "divu%.l %2,%0";
2920 return "divul%.l %2,%3:%0";
2923 (define_insn "divmodhi4"
2924 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2925 (div:HI (match_operand:HI 1 "general_operand" "0")
2926 (match_operand:HI 2 "general_src_operand" "dmSKT")))
2927 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
2928 (mod:HI (match_dup 1) (match_dup 2)))]
2929 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
2931 output_asm_insn (MOTOROLA ?
2932 "ext%.l %0\;divs%.w %2,%0" :
2933 "extl %0\;divs %2,%0",
2935 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
2938 return "move%.l %0,%3\;swap %3";
2944 (define_insn "udivmodhi4"
2945 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2946 (udiv:HI (match_operand:HI 1 "general_operand" "0")
2947 (match_operand:HI 2 "general_src_operand" "dmSKT")))
2948 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
2949 (umod:HI (match_dup 1) (match_dup 2)))]
2950 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
2953 output_asm_insn (MOTOROLA ?
2954 "mvz%.w %0,%0\;divu%.w %2,%0" :
2955 "mvz%.w %0,%0\;divu %2,%0",
2958 output_asm_insn (MOTOROLA ?
2959 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
2960 "and%.l #0xFFFF,%0\;divu %2,%0",
2963 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
2966 return "move%.l %0,%3\;swap %3";
2972 ;; logical-and instructions
2974 ;; "anddi3" is mainly here to help combine().
2975 (define_insn "anddi3"
2976 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
2977 (and:DI (match_operand:DI 1 "general_operand" "%0,0")
2978 (match_operand:DI 2 "general_operand" "dn,don")))]
2982 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
2983 if (CONSTANT_P (operands[2]))
2987 split_double (operands[2], &hi, &lo);
2989 switch (INTVAL (hi))
2992 output_asm_insn ("clr%.l %0", operands);
3000 xoperands[0] = operands[0];
3002 output_asm_insn (output_andsi3 (xoperands), xoperands);
3005 if (GET_CODE (operands[0]) == REG)
3006 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3008 operands[0] = adjust_address (operands[0], SImode, 4);
3009 switch (INTVAL (lo))
3012 output_asm_insn ("clr%.l %0", operands);
3020 xoperands[0] = operands[0];
3022 output_asm_insn (output_andsi3 (xoperands), xoperands);
3027 if (GET_CODE (operands[0]) != REG)
3029 operands[1] = adjust_address (operands[0], SImode, 4);
3030 return "and%.l %2,%0\;and%.l %R2,%1";
3032 if (GET_CODE (operands[2]) != REG)
3034 operands[1] = adjust_address (operands[2], SImode, 4);
3035 return "and%.l %2,%0\;and%.l %1,%R0";
3037 return "and%.l %2,%0\;and%.l %R2,%R0";
3040 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3041 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3042 ;; can't allocate pseudos into it.
3044 (define_expand "andsi3"
3045 [(set (match_operand:SI 0 "not_sp_operand" "")
3046 (and:SI (match_operand:SI 1 "general_operand" "")
3047 (match_operand:SI 2 "general_src_operand" "")))]
3051 ;; produced by split operations after reload finished
3052 (define_insn "*andsi3_split"
3053 [(set (match_operand:SI 0 "register_operand" "=d")
3054 (and:SI (match_operand:SI 1 "register_operand" "0")
3055 (match_operand:SI 2 "const_int_operand" "i")))]
3056 "reload_completed && !TARGET_COLDFIRE"
3058 return output_andsi3 (operands);
3061 (define_insn "andsi3_internal"
3062 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3063 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3064 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3067 return output_andsi3 (operands);
3070 (define_insn "andsi3_5200"
3071 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3072 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3073 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3076 if (TARGET_CFV4 && DATA_REG_P (operands[0])
3077 && GET_CODE (operands[2]) == CONST_INT)
3079 if (INTVAL (operands[2]) == 0x000000ff)
3080 return "mvz%.b %0,%0";
3081 else if (INTVAL (operands[2]) == 0x0000ffff)
3082 return "mvz%.w %0,%0";
3084 return output_andsi3 (operands);
3087 (define_insn "andhi3"
3088 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3089 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3090 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3095 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3096 (and:HI (match_dup 0)
3097 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3102 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3103 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3108 (define_insn "andqi3"
3109 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3110 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3111 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3116 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3117 (and:QI (match_dup 0)
3118 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3123 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3124 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3129 ;; inclusive-or instructions
3131 (define_insn "iordi_zext"
3132 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3133 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3134 (match_operand:DI 2 "general_operand" "0,0")))]
3140 if (GET_CODE (operands[0]) == REG)
3141 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3143 operands[0] = adjust_address (operands[0], SImode, 4);
3144 if (GET_MODE (operands[1]) == SImode)
3145 return "or%.l %1,%0";
3146 byte_mode = (GET_MODE (operands[1]) == QImode);
3147 if (GET_CODE (operands[0]) == MEM)
3148 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3151 return "or%.b %1,%0";
3153 return "or%.w %1,%0";
3156 ;; "iordi3" is mainly here to help combine().
3157 (define_insn "iordi3"
3158 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3159 (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3160 (match_operand:DI 2 "general_operand" "dn,don")))]
3164 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3165 if (CONSTANT_P (operands[2]))
3169 split_double (operands[2], &hi, &lo);
3171 switch (INTVAL (hi))
3176 /* FIXME : a scratch register would be welcome here if operand[0]
3177 is not a register */
3178 output_asm_insn ("move%.l #-1,%0", operands);
3184 xoperands[0] = operands[0];
3186 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3189 if (GET_CODE (operands[0]) == REG)
3190 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3192 operands[0] = adjust_address (operands[0], SImode, 4);
3193 switch (INTVAL (lo))
3198 /* FIXME : a scratch register would be welcome here if operand[0]
3199 is not a register */
3200 output_asm_insn ("move%.l #-1,%0", operands);
3206 xoperands[0] = operands[0];
3208 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3213 if (GET_CODE (operands[0]) != REG)
3215 operands[1] = adjust_address (operands[0], SImode, 4);
3216 return "or%.l %2,%0\;or%.l %R2,%1";
3218 if (GET_CODE (operands[2]) != REG)
3220 operands[1] = adjust_address (operands[2], SImode, 4);
3221 return "or%.l %2,%0\;or%.l %1,%R0";
3223 return "or%.l %2,%0\;or%.l %R2,%R0";
3226 (define_expand "iorsi3"
3227 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3228 (ior:SI (match_operand:SI 1 "general_operand" "")
3229 (match_operand:SI 2 "general_src_operand" "")))]
3233 (define_insn "iorsi3_internal"
3234 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3235 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3236 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3239 return output_iorsi3 (operands);
3242 (define_insn "iorsi3_5200"
3243 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3244 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3245 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3248 return output_iorsi3 (operands);
3251 (define_insn "iorhi3"
3252 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3253 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3254 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3259 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3260 (ior:HI (match_dup 0)
3261 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3266 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3267 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3272 (define_insn "iorqi3"
3273 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3274 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3275 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3280 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3281 (ior:QI (match_dup 0)
3282 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3287 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3288 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3293 ;; On all 68k models, this makes faster code in a special case.
3294 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3296 (define_insn "iorsi_zexthi_ashl16"
3297 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3298 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3299 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3304 if (GET_CODE (operands[2]) != REG)
3305 operands[2] = adjust_address (operands[2], HImode, 2);
3306 if (GET_CODE (operands[2]) != REG
3307 || REGNO (operands[2]) != REGNO (operands[0]))
3308 output_asm_insn ("move%.w %2,%0", operands);
3309 return "swap %0\;mov%.w %1,%0";
3312 (define_insn "iorsi_zext"
3313 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3314 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3315 (match_operand:SI 2 "general_operand" "0,0")))]
3321 byte_mode = (GET_MODE (operands[1]) == QImode);
3322 if (GET_CODE (operands[0]) == MEM)
3323 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3326 return "or%.b %1,%0";
3328 return "or%.w %1,%0";
3333 ;; "xordi3" is mainly here to help combine().
3334 (define_insn "xordi3"
3335 [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3336 (xor:DI (match_operand:DI 1 "general_operand" "%0")
3337 (match_operand:DI 2 "general_operand" "dn")))]
3341 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3343 if (CONSTANT_P (operands[2]))
3347 split_double (operands[2], &hi, &lo);
3349 switch (INTVAL (hi))
3354 output_asm_insn ("not%.l %0", operands);
3357 /* FIXME : a scratch register would be welcome here if
3358 -128 <= INTVAL (hi) < -1 */
3362 xoperands[0] = operands[0];
3364 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3367 if (GET_CODE (operands[0]) == REG)
3368 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3370 operands[0] = adjust_address (operands[0], SImode, 4);
3371 switch (INTVAL (lo))
3376 output_asm_insn ("not%.l %0", operands);
3379 /* FIXME : a scratch register would be welcome here if
3380 -128 <= INTVAL (lo) < -1 */
3382 /* FIXME : this should be merged with xorsi3 */
3386 xoperands[0] = operands[0];
3388 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3393 if (GET_CODE (operands[0]) != REG)
3395 operands[1] = adjust_address (operands[0], SImode, 4);
3396 return "eor%.l %2,%0\;eor%.l %R2,%1";
3398 if (GET_CODE (operands[2]) != REG)
3400 operands[1] = adjust_address (operands[2], SImode, 4);
3401 return "eor%.l %2,%0\;eor%.l %1,%R0";
3403 return "eor%.l %2,%0\;eor%.l %R2,%R0";
3406 (define_expand "xorsi3"
3407 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3408 (xor:SI (match_operand:SI 1 "general_operand" "")
3409 (match_operand:SI 2 "general_operand" "")))]
3413 (define_insn "xorsi3_internal"
3414 [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3415 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3416 (match_operand:SI 2 "general_operand" "di,dKT")))]
3420 return output_xorsi3 (operands);
3423 (define_insn "xorsi3_5200"
3424 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3425 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3426 (match_operand:SI 2 "general_operand" "d,Ks")))]
3429 return output_xorsi3 (operands);
3432 (define_insn "xorhi3"
3433 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3434 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3435 (match_operand:HI 2 "general_operand" "dn")))]
3440 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3441 (xor:HI (match_dup 0)
3442 (match_operand:HI 1 "general_operand" "dn")))]
3447 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3448 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3453 (define_insn "xorqi3"
3454 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3455 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3456 (match_operand:QI 2 "general_operand" "dn")))]
3461 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3462 (xor:QI (match_dup 0)
3463 (match_operand:QI 1 "general_operand" "dn")))]
3468 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3469 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3474 ;; negation instructions
3476 (define_expand "negdi2"
3477 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3478 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3481 if (TARGET_COLDFIRE)
3482 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3484 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3488 (define_insn "negdi2_internal"
3489 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3490 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3493 if (which_alternative == 0)
3494 return "neg%.l %0\;negx%.l %0";
3495 if (GET_CODE (operands[0]) == REG)
3496 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3498 operands[1] = adjust_address (operands[0], SImode, 4);
3499 if (ADDRESS_REG_P (operands[0]))
3500 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3502 return "neg%.l %1\;negx%.l %0";
3505 (define_insn "negdi2_5200"
3506 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3507 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3510 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3511 return "neg%.l %1\;negx%.l %0";
3514 (define_expand "negsi2"
3515 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3516 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3519 if (TARGET_COLDFIRE)
3520 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3522 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3526 (define_insn "negsi2_internal"
3527 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3528 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3532 (define_insn "negsi2_5200"
3533 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3534 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3538 (define_insn "neghi2"
3539 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3540 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3545 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3546 (neg:HI (match_dup 0)))]
3550 (define_insn "negqi2"
3551 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3552 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3557 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3558 (neg:QI (match_dup 0)))]
3562 ;; If using software floating point, just flip the sign bit.
3564 (define_expand "negsf2"
3565 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3566 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3574 target = operand_subword_force (operands[0], 0, SFmode);
3575 result = expand_binop (SImode, xor_optab,
3576 operand_subword_force (operands[1], 0, SFmode),
3577 GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
3578 gcc_assert (result);
3580 if (result != target)
3581 emit_move_insn (result, target);
3583 /* Make a place for REG_EQUAL. */
3584 emit_move_insn (operands[0], operands[0]);
3590 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d")
3591 (neg:SF (match_operand:SF 1 "general_operand" "fdmF,0")))]
3594 if (DATA_REG_P (operands[0]))
3596 operands[1] = GEN_INT (31);
3597 return "bchg %1,%0";
3599 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3600 return "f%$neg%.x %1,%0";
3601 return "f%$neg%.s %f1,%0";
3604 (define_expand "negdf2"
3605 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3606 (neg:DF (match_operand:DF 1 "general_operand" "")))]
3616 target = operand_subword (operands[0], 0, 1, DFmode);
3617 result = expand_binop (SImode, xor_optab,
3618 operand_subword_force (operands[1], 0, DFmode),
3619 GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
3620 gcc_assert (result);
3622 if (result != target)
3623 emit_move_insn (result, target);
3625 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3626 operand_subword_force (operands[1], 1, DFmode));
3628 insns = get_insns ();
3631 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3637 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,d")
3638 (neg:DF (match_operand:DF 1 "general_operand" "fmF,0")))]
3641 if (DATA_REG_P (operands[0]))
3643 operands[1] = GEN_INT (31);
3644 return "bchg %1,%0";
3646 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3647 return "f%&neg%.x %1,%0";
3648 return "f%&neg%.d %f1,%0";
3651 ;; Sqrt instruction for the 68881
3653 (define_insn "sqrtsf2"
3654 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3655 (sqrt:SF (match_operand:SF 1 "general_operand" "fm")))]
3658 if (FP_REG_P (operands[1]))
3659 return "f%$sqrt%.x %1,%0";
3661 return "f%$sqrt%.s %1,%0";
3664 (define_insn "sqrtdf2"
3665 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3666 (sqrt:DF (match_operand:DF 1 "general_operand" "fm")))]
3669 if (FP_REG_P (operands[1]))
3670 return "f%&sqrt%.x %1,%0";
3672 return "f%&sqrt%.d %1,%0";
3675 ;; Absolute value instructions
3676 ;; If using software floating point, just zero the sign bit.
3678 (define_expand "abssf2"
3679 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3680 (abs:SF (match_operand:SF 1 "general_operand" "")))]
3688 target = operand_subword_force (operands[0], 0, SFmode);
3689 result = expand_binop (SImode, and_optab,
3690 operand_subword_force (operands[1], 0, SFmode),
3691 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3692 gcc_assert (result);
3694 if (result != target)
3695 emit_move_insn (result, target);
3697 /* Make a place for REG_EQUAL. */
3698 emit_move_insn (operands[0], operands[0]);
3704 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3705 (abs:SF (match_operand:SF 1 "general_operand" "fdmF")))]
3708 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3709 return "f%$abs%.x %1,%0";
3710 return "f%$abs%.s %f1,%0";
3713 (define_expand "absdf2"
3714 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3715 (abs:DF (match_operand:DF 1 "general_operand" "")))]
3725 target = operand_subword (operands[0], 0, 1, DFmode);
3726 result = expand_binop (SImode, and_optab,
3727 operand_subword_force (operands[1], 0, DFmode),
3728 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3729 gcc_assert (result);
3731 if (result != target)
3732 emit_move_insn (result, target);
3734 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3735 operand_subword_force (operands[1], 1, DFmode));
3737 insns = get_insns ();
3740 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3746 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3747 (abs:DF (match_operand:DF 1 "general_operand" "fmF")))]
3750 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3751 return "f%&abs%.x %1,%0";
3752 return "f%&abs%.d %f1,%0";
3755 ;; one complement instructions
3757 ;; "one_cmpldi2" is mainly here to help combine().
3758 (define_insn "one_cmpldi2"
3759 [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
3760 (not:DI (match_operand:DI 1 "general_operand" "0")))]
3764 if (GET_CODE (operands[0]) == REG)
3765 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3766 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
3767 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3768 operands[1] = operands[0];
3770 operands[1] = adjust_address (operands[0], SImode, 4);
3771 return "not%.l %1\;not%.l %0";
3774 (define_expand "one_cmplsi2"
3775 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3776 (not:SI (match_operand:SI 1 "general_operand" "")))]
3779 if (TARGET_COLDFIRE)
3780 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
3782 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
3786 (define_insn "one_cmplsi2_internal"
3787 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3788 (not:SI (match_operand:SI 1 "general_operand" "0")))]
3792 (define_insn "one_cmplsi2_5200"
3793 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3794 (not:SI (match_operand:SI 1 "general_operand" "0")))]
3798 (define_insn "one_cmplhi2"
3799 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3800 (not:HI (match_operand:HI 1 "general_operand" "0")))]
3805 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3806 (not:HI (match_dup 0)))]
3810 (define_insn "one_cmplqi2"
3811 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3812 (not:QI (match_operand:QI 1 "general_operand" "0")))]
3817 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3818 (not:QI (match_dup 0)))]
3822 ;; arithmetic shift instructions
3823 ;; We don't need the shift memory by 1 bit instruction
3825 (define_insn "ashldi_extsi"
3826 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
3828 (match_operator:DI 2 "extend_operator"
3829 [(match_operand:SI 1 "general_operand" "rm")])
3834 if (GET_CODE (operands[0]) == REG)
3835 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3837 operands[2] = adjust_address (operands[0], SImode, 4);
3838 if (ADDRESS_REG_P (operands[0]))
3839 return "move%.l %1,%0\;sub%.l %2,%2";
3841 return "move%.l %1,%0\;clr%.l %2";
3844 (define_insn "ashldi_sexthi"
3845 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
3846 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
3848 (clobber (match_scratch:SI 2 "=a,X"))]
3852 if (GET_CODE (operands[0]) == MEM)
3854 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3855 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
3856 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
3857 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
3860 operands[3] = adjust_address (operands[0], SImode, 4);
3861 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
3864 else if (DATA_REG_P (operands[0]))
3865 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
3867 return "move%.w %1,%0\;sub%.l %R0,%R0";
3870 (define_insn "ashldi_const32"
3871 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
3872 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
3877 if (GET_CODE (operands[1]) == REG)
3878 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
3880 operands[3] = adjust_address (operands[1], SImode, 4);
3881 if (GET_CODE (operands[0]) == REG)
3882 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3883 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3884 return "clr%.l %0\;move%.l %3,%0";
3885 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
3886 return "move%.l %3,%0\;clr%.l %0";
3888 operands[2] = adjust_address (operands[0], SImode, 4);
3889 if (ADDRESS_REG_P (operands[2]))
3890 return "move%.l %3,%0\;sub%.l %2,%2";
3892 return "move%.l %3,%0\;clr%.l %2";
3895 ;; The predicate below must be general_operand, because ashldi3 allows that
3896 (define_insn "ashldi_const"
3897 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3898 (ashift:DI (match_operand:DI 1 "general_operand" "0")
3899 (match_operand 2 "const_int_operand" "n")))]
3901 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
3902 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
3903 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
3905 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3906 if (INTVAL (operands[2]) == 1)
3907 return "add%.l %1,%1\;addx%.l %0,%0";
3908 else if (INTVAL (operands[2]) == 8)
3909 return "rol%.l #8,%1\;rol%.l #8,%0\;move%.b %1,%0\;clr%.b %1";
3910 else if (INTVAL (operands[2]) == 16)
3911 return "swap %1\;swap %0\;move%.w %1,%0\;clr%.w %1";
3912 else if (INTVAL (operands[2]) == 48)
3913 return "mov%.l %1,%0\;swap %0\;clr%.l %1\;clr%.w %0";
3914 else if (INTVAL (operands[2]) == 2)
3915 return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
3916 else if (INTVAL (operands[2]) == 3)
3917 return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
3918 else /* 32 < INTVAL (operands[2]) <= 63 */
3920 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
3921 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asl%.l %2,%1" :
3922 "moveq %2,%0\;asl%.l %0,%1", operands);
3923 return "mov%.l %1,%0\;moveq #0,%1";
3927 (define_expand "ashldi3"
3928 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3929 (ashift:DI (match_operand:DI 1 "general_operand" "")
3930 (match_operand 2 "const_int_operand" "")))]
3934 /* ??? This is a named pattern like this is not allowed to FAIL based
3936 if (GET_CODE (operands[2]) != CONST_INT
3937 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
3938 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
3939 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
3943 ;; On most 68k models, this makes faster code in a special case.
3945 (define_insn "ashlsi_16"
3946 [(set (match_operand:SI 0 "register_operand" "=d")
3947 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3952 return "swap %0\;clr%.w %0";
3955 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
3956 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
3958 ;; On the 68000, this makes faster code in a special case.
3960 (define_insn "ashlsi_17_24"
3961 [(set (match_operand:SI 0 "register_operand" "=d")
3962 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3963 (match_operand:SI 2 "const_int_operand" "n")))]
3964 "(! TARGET_68020 && !TARGET_COLDFIRE
3965 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
3969 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
3970 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
3973 (define_insn "ashlsi3"
3974 [(set (match_operand:SI 0 "register_operand" "=d")
3975 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3976 (match_operand:SI 2 "general_operand" "dI")))]
3979 if (operands[2] == const1_rtx)
3981 cc_status.flags = CC_NO_OVERFLOW;
3982 return "add%.l %0,%0";
3984 return "lsl%.l %2,%0";
3987 (define_insn "ashlhi3"
3988 [(set (match_operand:HI 0 "register_operand" "=d")
3989 (ashift:HI (match_operand:HI 1 "register_operand" "0")
3990 (match_operand:HI 2 "general_operand" "dI")))]
3995 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
3996 (ashift:HI (match_dup 0)
3997 (match_operand:HI 1 "general_operand" "dI")))]
4001 (define_insn "ashlqi3"
4002 [(set (match_operand:QI 0 "register_operand" "=d")
4003 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4004 (match_operand:QI 2 "general_operand" "dI")))]
4009 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4010 (ashift:QI (match_dup 0)
4011 (match_operand:QI 1 "general_operand" "dI")))]
4015 ;; On most 68k models, this makes faster code in a special case.
4017 (define_insn "ashrsi_16"
4018 [(set (match_operand:SI 0 "register_operand" "=d")
4019 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4022 "swap %0\;ext%.l %0")
4024 ;; On the 68000, this makes faster code in a special case.
4027 [(set (match_operand:SI 0 "register_operand" "=d")
4028 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4029 (match_operand:SI 2 "const_int_operand" "n")))]
4030 "(! TARGET_68020 && !TARGET_COLDFIRE
4031 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
4033 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4034 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4037 (define_insn "subreghi1ashrdi_const32"
4038 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4039 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4040 (const_int 32)) 6))]
4043 if (GET_CODE (operands[1]) != REG)
4044 operands[1] = adjust_address (operands[1], HImode, 2);
4045 return "move%.w %1,%0";
4048 (define_insn "subregsi1ashrdi_const32"
4049 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4050 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4051 (const_int 32)) 4))]
4054 return "move%.l %1,%0";
4057 (define_insn "ashrdi_const32"
4058 [(set (match_operand:DI 0 "register_operand" "=d")
4059 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4064 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4066 return "move%.l %1,%2\;smi %0\;extb%.l %0";
4068 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
4071 (define_insn "ashrdi_const32_mem"
4072 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,<")
4073 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro")
4075 (clobber (match_scratch:SI 2 "=d,d"))]
4079 if (which_alternative == 1)
4080 operands[3] = operands[0];
4082 operands[3] = adjust_address (operands[0], SImode, 4);
4084 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4086 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4089 ;; The predicate below must be general_operand, because ashrdi3 allows that
4090 (define_insn "ashrdi_const"
4091 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4092 (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
4093 (match_operand 2 "const_int_operand" "n")))]
4095 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4096 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4097 || INTVAL (operands[2]) == 31
4098 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4100 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4101 if (INTVAL (operands[2]) == 63)
4102 return "add%.l %0,%0\;subx%.l %0,%0\;move%.l %0,%1";
4104 if (INTVAL (operands[2]) == 1)
4105 return "asr%.l #1,%0\;roxr%.l #1,%1";
4106 else if (INTVAL (operands[2]) == 8)
4107 return "move%.b %0,%1\;asr%.l #8,%0\;ror%.l #8,%1";
4108 else if (INTVAL (operands[2]) == 16)
4109 return "move%.w %0,%1\;swap %0\;ext%.l %0\;swap %1";
4110 else if (INTVAL (operands[2]) == 48)
4111 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4112 else if (INTVAL (operands[2]) == 31)
4113 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4114 else if (INTVAL (operands[2]) == 2)
4115 return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4116 else if (INTVAL (operands[2]) == 3)
4117 return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4118 else /* 32 < INTVAL (operands[2]) <= 63 */
4120 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4121 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4122 "moveq %2,%1\;asr%.l %1,%0", operands);
4123 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4124 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4125 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4129 (define_expand "ashrdi3"
4130 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4131 (ashiftrt:DI (match_operand:DI 1 "general_operand" "")
4132 (match_operand 2 "const_int_operand" "")))]
4136 /* ??? This is a named pattern like this is not allowed to FAIL based
4138 if (GET_CODE (operands[2]) != CONST_INT
4139 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4140 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4141 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4145 ;; On all 68k models, this makes faster code in a special case.
4147 (define_insn "ashrsi_31"
4148 [(set (match_operand:SI 0 "register_operand" "=d")
4149 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4153 return "add%.l %0,%0\;subx%.l %0,%0";
4156 (define_insn "ashrsi3"
4157 [(set (match_operand:SI 0 "register_operand" "=d")
4158 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4159 (match_operand:SI 2 "general_operand" "dI")))]
4163 (define_insn "ashrhi3"
4164 [(set (match_operand:HI 0 "register_operand" "=d")
4165 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4166 (match_operand:HI 2 "general_operand" "dI")))]
4171 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4172 (ashiftrt:HI (match_dup 0)
4173 (match_operand:HI 1 "general_operand" "dI")))]
4177 (define_insn "ashrqi3"
4178 [(set (match_operand:QI 0 "register_operand" "=d")
4179 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4180 (match_operand:QI 2 "general_operand" "dI")))]
4185 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4186 (ashiftrt:QI (match_dup 0)
4187 (match_operand:QI 1 "general_operand" "dI")))]
4191 ;; logical shift instructions
4193 ;; commented out because of reload problems in 950612-1.c
4196 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4197 ;; (const_int 32)) 4))
4198 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4199 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4200 ;; (const_int 32)) 4))]
4203 ;; return "move%.l %0,%1";
4208 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4209 ;; (const_int 32)) 0))
4210 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4211 ;; (lshiftrt:DI (match_dup 0)
4212 ;; (const_int 32)))]
4215 ;; if (GET_CODE (operands[1]) == REG)
4216 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4218 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4219 ;; return "move%.l %0,%2\;clr%.l %1";
4222 (define_insn "subreg1lshrdi_const32"
4223 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4224 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4225 (const_int 32)) 4))]
4228 return "move%.l %1,%0";
4231 (define_insn "lshrdi_const32"
4232 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro,<,>")
4233 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4238 if (which_alternative == 1)
4239 return "move%.l %1,%0\;clr%.l %0";
4240 if (which_alternative == 2)
4241 return "clr%.l %0\;move%.l %1,%0";
4242 if (GET_CODE (operands[0]) == REG)
4243 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4245 operands[2] = adjust_address (operands[0], SImode, 4);
4246 if (GET_CODE (operands[1]) == REG)
4247 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4249 operands[3] = adjust_address (operands[1], SImode, 4);
4250 if (ADDRESS_REG_P (operands[0]))
4251 return "move%.l %1,%2\;sub%.l %0,%0";
4253 return "move%.l %1,%2\;clr%.l %0";
4256 ;; The predicate below must be general_operand, because lshrdi3 allows that
4257 (define_insn "lshrdi_const"
4258 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4259 (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
4260 (match_operand 2 "const_int_operand" "n")))]
4262 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4263 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4264 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4266 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4267 if (INTVAL (operands[2]) == 63)
4268 return "add%.l %0,%0\;clr%.l %0\;clr%.l %1\;addx%.l %1,%1";
4270 if (INTVAL (operands[2]) == 1)
4271 return "lsr%.l #1,%0\;roxr%.l #1,%1";
4272 else if (INTVAL (operands[2]) == 8)
4273 return "move%.b %0,%1\;lsr%.l #8,%0\;ror%.l #8,%1";
4274 else if (INTVAL (operands[2]) == 16)
4275 return "move%.w %0,%1\;clr%.w %0\;swap %1\;swap %0";
4276 else if (INTVAL (operands[2]) == 48)
4277 return "move%.l %0,%1\;clr%.w %1\;clr%.l %0\;swap %1";
4278 else if (INTVAL (operands[2]) == 2)
4279 return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4280 else if (INTVAL (operands[2]) == 3)
4281 return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4282 else /* 32 < INTVAL (operands[2]) <= 63 */
4284 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4285 output_asm_insn (INTVAL (operands[2]) <= 8 ? "lsr%.l %2,%0" :
4286 "moveq %2,%1\;lsr%.l %1,%0", operands);
4287 return "mov%.l %0,%1\;moveq #0,%0";
4291 (define_expand "lshrdi3"
4292 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4293 (lshiftrt:DI (match_operand:DI 1 "general_operand" "")
4294 (match_operand 2 "const_int_operand" "")))]
4297 /* ??? This is a named pattern like this is not allowed to FAIL based
4299 if (GET_CODE (operands[2]) != CONST_INT
4300 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4301 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4302 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4306 ;; On all 68k models, this makes faster code in a special case.
4308 (define_insn "lshrsi_31"
4309 [(set (match_operand:SI 0 "register_operand" "=d")
4310 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4314 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
4317 ;; On most 68k models, this makes faster code in a special case.
4319 (define_insn "lshrsi_16"
4320 [(set (match_operand:SI 0 "register_operand" "=d")
4321 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4326 return "clr%.w %0\;swap %0";
4329 ;; On the 68000, this makes faster code in a special case.
4331 (define_insn "lshrsi_17_24"
4332 [(set (match_operand:SI 0 "register_operand" "=d")
4333 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4334 (match_operand:SI 2 "const_int_operand" "n")))]
4335 "(! TARGET_68020 && !TARGET_COLDFIRE
4336 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
4338 /* I think lsr%.w sets the CC properly. */
4339 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4340 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
4343 (define_insn "lshrsi3"
4344 [(set (match_operand:SI 0 "register_operand" "=d")
4345 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4346 (match_operand:SI 2 "general_operand" "dI")))]
4350 (define_insn "lshrhi3"
4351 [(set (match_operand:HI 0 "register_operand" "=d")
4352 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
4353 (match_operand:HI 2 "general_operand" "dI")))]
4358 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4359 (lshiftrt:HI (match_dup 0)
4360 (match_operand:HI 1 "general_operand" "dI")))]
4364 (define_insn "lshrqi3"
4365 [(set (match_operand:QI 0 "register_operand" "=d")
4366 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
4367 (match_operand:QI 2 "general_operand" "dI")))]
4372 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4373 (lshiftrt:QI (match_dup 0)
4374 (match_operand:QI 1 "general_operand" "dI")))]
4378 ;; rotate instructions
4380 (define_insn "rotlsi3"
4381 [(set (match_operand:SI 0 "register_operand" "=d")
4382 (rotate:SI (match_operand:SI 1 "register_operand" "0")
4383 (match_operand:SI 2 "general_operand" "dINO")))]
4386 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
4388 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
4390 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4391 return "ror%.l %2,%0";
4394 return "rol%.l %2,%0";
4397 (define_insn "rotlhi3"
4398 [(set (match_operand:HI 0 "register_operand" "=d")
4399 (rotate:HI (match_operand:HI 1 "register_operand" "0")
4400 (match_operand:HI 2 "general_operand" "dIP")))]
4403 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4405 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4406 return "ror%.w %2,%0";
4409 return "rol%.w %2,%0";
4413 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4414 (rotate:HI (match_dup 0)
4415 (match_operand:HI 1 "general_operand" "dIP")))]
4418 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4420 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4421 return "ror%.w %2,%0";
4424 return "rol%.w %2,%0";
4427 (define_insn "rotlqi3"
4428 [(set (match_operand:QI 0 "register_operand" "=d")
4429 (rotate:QI (match_operand:QI 1 "register_operand" "0")
4430 (match_operand:QI 2 "general_operand" "dI")))]
4433 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4435 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4436 return "ror%.b %2,%0";
4439 return "rol%.b %2,%0";
4443 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4444 (rotate:QI (match_dup 0)
4445 (match_operand:QI 1 "general_operand" "dI")))]
4448 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4450 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4451 return "ror%.b %2,%0";
4454 return "rol%.b %2,%0";
4457 (define_insn "rotrsi3"
4458 [(set (match_operand:SI 0 "register_operand" "=d")
4459 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
4460 (match_operand:SI 2 "general_operand" "dI")))]
4464 (define_insn "rotrhi3"
4465 [(set (match_operand:HI 0 "register_operand" "=d")
4466 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
4467 (match_operand:HI 2 "general_operand" "dI")))]
4472 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4473 (rotatert:HI (match_dup 0)
4474 (match_operand:HI 1 "general_operand" "dI")))]
4478 (define_insn "rotrqi3"
4479 [(set (match_operand:QI 0 "register_operand" "=d")
4480 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
4481 (match_operand:QI 2 "general_operand" "dI")))]
4486 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4487 (rotatert:QI (match_dup 0)
4488 (match_operand:QI 1 "general_operand" "dI")))]
4493 ;; Bit set/clear in memory byte.
4495 ;; set bit, bit number is int
4496 (define_insn "bsetmemqi"
4497 [(set (match_operand:QI 0 "memory_operand" "+m")
4498 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4499 (match_operand:SI 1 "general_operand" "d")) 3)
4504 return "bset %1,%0";
4507 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
4509 [(set (match_operand:QI 0 "memory_operand" "+m")
4510 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4511 (match_operator:SI 2 "extend_operator"
4512 [(match_operand 1 "general_operand" "d")])) 3)
4517 return "bset %1,%0";
4520 ;; clear bit, bit number is int
4521 (define_insn "bclrmemqi"
4522 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4524 (minus:SI (const_int 7)
4525 (match_operand:SI 1 "general_operand" "d")))
4530 return "bclr %1,%0";
4533 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
4535 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4537 (minus:SI (const_int 7)
4538 (match_operator:SI 2 "extend_operator"
4539 [(match_operand 1 "general_operand" "d")])))
4544 return "bclr %1,%0";
4547 ;; Special cases of bit-field insns which we should
4548 ;; recognize in preference to the general case.
4549 ;; These handle aligned 8-bit and 16-bit fields,
4550 ;; which can usually be done with move instructions.
4553 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4554 ; alignment of structure members is specified.
4556 ; The move is allowed to be odd byte aligned, because that's still faster
4557 ; than an odd byte aligned bit-field instruction.
4560 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4562 (match_operand:SI 1 "const_int_operand" "n"))
4563 (match_operand:SI 2 "general_src_operand" "rmSi"))]
4564 "TARGET_68020 && TARGET_BITFIELD
4565 && (INTVAL (operands[1]) % 8) == 0
4566 && ! mode_dependent_address_p (XEXP (operands[0], 0))"
4569 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
4571 return "move%.l %2,%0";
4575 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
4576 (match_operand:SI 1 "const_int_operand" "n")
4577 (match_operand:SI 2 "const_int_operand" "n"))
4578 (match_operand:SI 3 "register_operand" "d"))]
4579 "TARGET_68020 && TARGET_BITFIELD
4580 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
4581 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
4582 && (GET_CODE (operands[0]) == REG
4583 || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
4585 if (REG_P (operands[0]))
4587 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
4588 return "bfins %3,%0{%b2:%b1}";
4591 operands[0] = adjust_address (operands[0],
4592 INTVAL (operands[1]) == 8 ? QImode : HImode,
4593 INTVAL (operands[2]) / 8);
4595 if (GET_CODE (operands[3]) == MEM)
4596 operands[3] = adjust_address (operands[3],
4597 INTVAL (operands[1]) == 8 ? QImode : HImode,
4598 (32 - INTVAL (operands[1])) / 8);
4600 if (INTVAL (operands[1]) == 8)
4601 return "move%.b %3,%0";
4602 return "move%.w %3,%0";
4607 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4608 ; alignment of structure members is specified.
4610 ; The move is allowed to be odd byte aligned, because that's still faster
4611 ; than an odd byte aligned bit-field instruction.
4614 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4615 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4617 (match_operand:SI 2 "const_int_operand" "n")))]
4618 "TARGET_68020 && TARGET_BITFIELD
4619 && (INTVAL (operands[2]) % 8) == 0
4620 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4623 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4625 return "move%.l %1,%0";
4629 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
4630 (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
4631 (match_operand:SI 2 "const_int_operand" "n")
4632 (match_operand:SI 3 "const_int_operand" "n")))]
4633 "TARGET_68020 && TARGET_BITFIELD
4634 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4635 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4636 && (GET_CODE (operands[1]) == REG
4637 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4639 cc_status.flags |= CC_NOT_NEGATIVE;
4640 if (REG_P (operands[1]))
4642 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4643 return "bfextu %1{%b3:%b2},%0";
4647 = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
4649 output_asm_insn ("clr%.l %0", operands);
4650 if (GET_CODE (operands[0]) == MEM)
4651 operands[0] = adjust_address (operands[0],
4652 INTVAL (operands[2]) == 8 ? QImode : HImode,
4653 (32 - INTVAL (operands[1])) / 8);
4655 if (INTVAL (operands[2]) == 8)
4656 return "move%.b %1,%0";
4657 return "move%.w %1,%0";
4661 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4662 ; alignment of structure members is specified.
4664 ; The move is allowed to be odd byte aligned, because that's still faster
4665 ; than an odd byte aligned bit-field instruction.
4668 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4669 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4671 (match_operand:SI 2 "const_int_operand" "n")))]
4672 "TARGET_68020 && TARGET_BITFIELD
4673 && (INTVAL (operands[2]) % 8) == 0
4674 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4677 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4679 return "move%.l %1,%0";
4683 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4684 (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
4685 (match_operand:SI 2 "const_int_operand" "n")
4686 (match_operand:SI 3 "const_int_operand" "n")))]
4687 "TARGET_68020 && TARGET_BITFIELD
4688 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4689 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4690 && (GET_CODE (operands[1]) == REG
4691 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4693 if (REG_P (operands[1]))
4695 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4696 return "bfexts %1{%b3:%b2},%0";
4700 = adjust_address (operands[1],
4701 INTVAL (operands[2]) == 8 ? QImode : HImode,
4702 INTVAL (operands[3]) / 8);
4704 if (INTVAL (operands[2]) == 8)
4705 return "move%.b %1,%0\;extb%.l %0";
4706 return "move%.w %1,%0\;ext%.l %0";
4709 ;; Bit-field instructions, general cases.
4710 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
4711 ;; so that its address is reloaded.
4713 (define_expand "extv"
4714 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4715 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
4716 (match_operand:SI 2 "general_operand" "")
4717 (match_operand:SI 3 "general_operand" "")))]
4718 "TARGET_68020 && TARGET_BITFIELD"
4722 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4723 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
4724 (match_operand:SI 2 "general_operand" "dn")
4725 (match_operand:SI 3 "general_operand" "dn")))]
4726 "TARGET_68020 && TARGET_BITFIELD"
4727 "bfexts %1{%b3:%b2},%0")
4729 (define_expand "extzv"
4730 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4731 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
4732 (match_operand:SI 2 "general_operand" "")
4733 (match_operand:SI 3 "general_operand" "")))]
4734 "TARGET_68020 && TARGET_BITFIELD"
4738 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d")
4739 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o,d")
4740 (match_operand:SI 2 "general_operand" "dn,dn")
4741 (match_operand:SI 3 "general_operand" "dn,dn")))]
4742 "TARGET_68020 && TARGET_BITFIELD"
4744 if (GET_CODE (operands[2]) == CONST_INT)
4746 if (INTVAL (operands[2]) != 32)
4747 cc_status.flags |= CC_NOT_NEGATIVE;
4753 return "bfextu %1{%b3:%b2},%0";
4757 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4758 (match_operand:SI 1 "general_operand" "dn")
4759 (match_operand:SI 2 "general_operand" "dn"))
4760 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
4761 (match_operand 3 "const_int_operand" "n")))]
4762 "TARGET_68020 && TARGET_BITFIELD
4763 && (INTVAL (operands[3]) == -1
4764 || (GET_CODE (operands[1]) == CONST_INT
4765 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
4768 return "bfchg %0{%b2:%b1}";
4772 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4773 (match_operand:SI 1 "general_operand" "dn")
4774 (match_operand:SI 2 "general_operand" "dn"))
4776 "TARGET_68020 && TARGET_BITFIELD"
4779 return "bfclr %0{%b2:%b1}";
4783 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4784 (match_operand:SI 1 "general_operand" "dn")
4785 (match_operand:SI 2 "general_operand" "dn"))
4787 "TARGET_68020 && TARGET_BITFIELD"
4790 return "bfset %0{%b2:%b1}";
4793 (define_expand "insv"
4794 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
4795 (match_operand:SI 1 "general_operand" "")
4796 (match_operand:SI 2 "general_operand" ""))
4797 (match_operand:SI 3 "register_operand" ""))]
4798 "TARGET_68020 && TARGET_BITFIELD"
4802 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4803 (match_operand:SI 1 "general_operand" "dn")
4804 (match_operand:SI 2 "general_operand" "dn"))
4805 (match_operand:SI 3 "register_operand" "d"))]
4806 "TARGET_68020 && TARGET_BITFIELD"
4807 "bfins %3,%0{%b2:%b1}")
4809 ;; Now recognize bit-field insns that operate on registers
4810 ;; (or at least were intended to do so).
4813 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4814 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
4815 (match_operand:SI 2 "general_operand" "dn")
4816 (match_operand:SI 3 "general_operand" "dn")))]
4817 "TARGET_68020 && TARGET_BITFIELD"
4818 "bfexts %1{%b3:%b2},%0")
4821 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4822 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
4823 (match_operand:SI 2 "general_operand" "dn")
4824 (match_operand:SI 3 "general_operand" "dn")))]
4825 "TARGET_68020 && TARGET_BITFIELD"
4827 if (GET_CODE (operands[2]) == CONST_INT)
4829 if (INTVAL (operands[2]) != 32)
4830 cc_status.flags |= CC_NOT_NEGATIVE;
4836 return "bfextu %1{%b3:%b2},%0";
4840 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4841 (match_operand:SI 1 "general_operand" "dn")
4842 (match_operand:SI 2 "general_operand" "dn"))
4844 "TARGET_68020 && TARGET_BITFIELD"
4847 return "bfclr %0{%b2:%b1}";
4851 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4852 (match_operand:SI 1 "general_operand" "dn")
4853 (match_operand:SI 2 "general_operand" "dn"))
4855 "TARGET_68020 && TARGET_BITFIELD"
4858 return "bfset %0{%b2:%b1}";
4862 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4863 (match_operand:SI 1 "general_operand" "dn")
4864 (match_operand:SI 2 "general_operand" "dn"))
4865 (match_operand:SI 3 "register_operand" "d"))]
4866 "TARGET_68020 && TARGET_BITFIELD"
4869 /* These special cases are now recognized by a specific pattern. */
4870 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
4871 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
4872 return "move%.w %3,%0";
4873 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
4874 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
4875 return "move%.b %3,%0";
4877 return "bfins %3,%0{%b2:%b1}";
4880 ;; Special patterns for optimizing bit-field instructions.
4884 (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
4885 (match_operand:SI 1 "const_int_operand" "n")
4886 (match_operand:SI 2 "general_operand" "dn")))]
4887 "TARGET_68020 && TARGET_BITFIELD"
4889 if (operands[1] == const1_rtx
4890 && GET_CODE (operands[2]) == CONST_INT)
4892 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
4893 return output_btst (operands,
4894 GEN_INT (width - INTVAL (operands[2])),
4895 operands[0], insn, 1000);
4896 /* Pass 1000 as SIGNPOS argument so that btst will
4897 not think we are testing the sign bit for an `and'
4898 and assume that nonzero implies a negative result. */
4900 if (INTVAL (operands[1]) != 32)
4901 cc_status.flags = CC_NOT_NEGATIVE;
4902 return "bftst %0{%b2:%b1}";
4906 ;;; now handle the register cases
4909 (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
4910 (match_operand:SI 1 "const_int_operand" "n")
4911 (match_operand:SI 2 "general_operand" "dn")))]
4912 "TARGET_68020 && TARGET_BITFIELD"
4914 if (operands[1] == const1_rtx
4915 && GET_CODE (operands[2]) == CONST_INT)
4917 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
4918 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
4919 operands[0], insn, 1000);
4920 /* Pass 1000 as SIGNPOS argument so that btst will
4921 not think we are testing the sign bit for an `and'
4922 and assume that nonzero implies a negative result. */
4924 if (INTVAL (operands[1]) != 32)
4925 cc_status.flags = CC_NOT_NEGATIVE;
4926 return "bftst %0{%b2:%b1}";
4929 (define_insn "scc0_di"
4930 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4931 (match_operator 1 "valid_dbcc_comparison_p"
4932 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
4935 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
4938 (define_insn "scc0_di_5200"
4939 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
4940 (match_operator 1 "valid_dbcc_comparison_p"
4941 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
4944 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
4947 (define_insn "scc_di"
4948 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
4949 (match_operator 1 "valid_dbcc_comparison_p"
4950 [(match_operand:DI 2 "general_operand" "ro,r")
4951 (match_operand:DI 3 "general_operand" "r,ro")]))]
4954 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
4957 (define_insn "scc_di_5200"
4958 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
4959 (match_operator 1 "valid_dbcc_comparison_p"
4960 [(match_operand:DI 2 "general_operand" "ro,r")
4961 (match_operand:DI 3 "general_operand" "r,ro")]))]
4964 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
4967 ;; Note that operand 0 of an SCC insn is supported in the hardware as
4968 ;; memory, but we cannot allow it to be in memory in case the address
4969 ;; needs to be reloaded.
4971 (define_expand "seq"
4972 [(set (match_operand:QI 0 "register_operand" "")
4973 (eq:QI (cc0) (const_int 0)))]
4976 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
4978 m68k_last_compare_had_fp_operands = 0;
4984 [(set (match_operand:QI 0 "register_operand" "=d")
4985 (eq:QI (cc0) (const_int 0)))]
4988 cc_status = cc_prev_status;
4989 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
4992 (define_expand "sne"
4993 [(set (match_operand:QI 0 "register_operand" "")
4994 (ne:QI (cc0) (const_int 0)))]
4997 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
4999 m68k_last_compare_had_fp_operands = 0;
5005 [(set (match_operand:QI 0 "register_operand" "=d")
5006 (ne:QI (cc0) (const_int 0)))]
5009 cc_status = cc_prev_status;
5010 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5013 (define_expand "sgt"
5014 [(set (match_operand:QI 0 "register_operand" "")
5015 (gt:QI (cc0) (const_int 0)))]
5018 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5020 m68k_last_compare_had_fp_operands = 0;
5026 [(set (match_operand:QI 0 "register_operand" "=d")
5027 (gt:QI (cc0) (const_int 0)))]
5030 cc_status = cc_prev_status;
5031 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5034 (define_expand "sgtu"
5035 [(set (match_operand:QI 0 "register_operand" "")
5036 (gtu:QI (cc0) (const_int 0)))]
5041 [(set (match_operand:QI 0 "register_operand" "=d")
5042 (gtu:QI (cc0) (const_int 0)))]
5045 cc_status = cc_prev_status;
5049 (define_expand "slt"
5050 [(set (match_operand:QI 0 "register_operand" "")
5051 (lt:QI (cc0) (const_int 0)))]
5054 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5056 m68k_last_compare_had_fp_operands = 0;
5062 [(set (match_operand:QI 0 "register_operand" "=d")
5063 (lt:QI (cc0) (const_int 0)))]
5066 cc_status = cc_prev_status;
5067 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5070 (define_expand "sltu"
5071 [(set (match_operand:QI 0 "register_operand" "")
5072 (ltu:QI (cc0) (const_int 0)))]
5077 [(set (match_operand:QI 0 "register_operand" "=d")
5078 (ltu:QI (cc0) (const_int 0)))]
5081 cc_status = cc_prev_status;
5085 (define_expand "sge"
5086 [(set (match_operand:QI 0 "register_operand" "")
5087 (ge:QI (cc0) (const_int 0)))]
5090 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5092 m68k_last_compare_had_fp_operands = 0;
5098 [(set (match_operand:QI 0 "register_operand" "=d")
5099 (ge:QI (cc0) (const_int 0)))]
5102 cc_status = cc_prev_status;
5103 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5106 (define_expand "sgeu"
5107 [(set (match_operand:QI 0 "register_operand" "")
5108 (geu:QI (cc0) (const_int 0)))]
5113 [(set (match_operand:QI 0 "register_operand" "=d")
5114 (geu:QI (cc0) (const_int 0)))]
5117 cc_status = cc_prev_status;
5121 (define_expand "sle"
5122 [(set (match_operand:QI 0 "register_operand" "")
5123 (le:QI (cc0) (const_int 0)))]
5126 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5128 m68k_last_compare_had_fp_operands = 0;
5134 [(set (match_operand:QI 0 "register_operand" "=d")
5135 (le:QI (cc0) (const_int 0)))]
5138 cc_status = cc_prev_status;
5139 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5142 (define_expand "sleu"
5143 [(set (match_operand:QI 0 "register_operand" "")
5144 (leu:QI (cc0) (const_int 0)))]
5149 [(set (match_operand:QI 0 "register_operand" "=d")
5150 (leu:QI (cc0) (const_int 0)))]
5153 cc_status = cc_prev_status;
5157 (define_expand "sordered"
5158 [(set (match_operand:QI 0 "register_operand" "")
5159 (ordered:QI (cc0) (const_int 0)))]
5160 "TARGET_68881 && !TARGET_68060"
5162 gcc_assert (m68k_last_compare_had_fp_operands);
5163 m68k_last_compare_had_fp_operands = 0;
5166 (define_insn "*sordered_1"
5167 [(set (match_operand:QI 0 "register_operand" "=d")
5168 (ordered:QI (cc0) (const_int 0)))]
5169 "TARGET_68881 && !TARGET_68060"
5171 cc_status = cc_prev_status;
5175 (define_expand "sunordered"
5176 [(set (match_operand:QI 0 "register_operand" "")
5177 (unordered:QI (cc0) (const_int 0)))]
5178 "TARGET_68881 && !TARGET_68060"
5180 gcc_assert (m68k_last_compare_had_fp_operands);
5181 m68k_last_compare_had_fp_operands = 0;
5184 (define_insn "*sunordered_1"
5185 [(set (match_operand:QI 0 "register_operand" "=d")
5186 (unordered:QI (cc0) (const_int 0)))]
5187 "TARGET_68881 && !TARGET_68060"
5189 cc_status = cc_prev_status;
5193 (define_expand "suneq"
5194 [(set (match_operand:QI 0 "register_operand" "")
5195 (uneq:QI (cc0) (const_int 0)))]
5196 "TARGET_68881 && !TARGET_68060"
5198 gcc_assert (m68k_last_compare_had_fp_operands);
5199 m68k_last_compare_had_fp_operands = 0;
5202 (define_insn "*suneq_1"
5203 [(set (match_operand:QI 0 "register_operand" "=d")
5204 (uneq:QI (cc0) (const_int 0)))]
5205 "TARGET_68881 && !TARGET_68060"
5207 cc_status = cc_prev_status;
5211 (define_expand "sunge"
5212 [(set (match_operand:QI 0 "register_operand" "")
5213 (unge:QI (cc0) (const_int 0)))]
5214 "TARGET_68881 && !TARGET_68060"
5216 gcc_assert (m68k_last_compare_had_fp_operands);
5217 m68k_last_compare_had_fp_operands = 0;
5220 (define_insn "*sunge_1"
5221 [(set (match_operand:QI 0 "register_operand" "=d")
5222 (unge:QI (cc0) (const_int 0)))]
5223 "TARGET_68881 && !TARGET_68060"
5225 cc_status = cc_prev_status;
5229 (define_expand "sungt"
5230 [(set (match_operand:QI 0 "register_operand" "")
5231 (ungt:QI (cc0) (const_int 0)))]
5232 "TARGET_68881 && !TARGET_68060"
5234 gcc_assert (m68k_last_compare_had_fp_operands);
5235 m68k_last_compare_had_fp_operands = 0;
5238 (define_insn "*sungt_1"
5239 [(set (match_operand:QI 0 "register_operand" "=d")
5240 (ungt:QI (cc0) (const_int 0)))]
5241 "TARGET_68881 && !TARGET_68060"
5243 cc_status = cc_prev_status;
5247 (define_expand "sunle"
5248 [(set (match_operand:QI 0 "register_operand" "")
5249 (unle:QI (cc0) (const_int 0)))]
5250 "TARGET_68881 && !TARGET_68060"
5252 gcc_assert (m68k_last_compare_had_fp_operands);
5253 m68k_last_compare_had_fp_operands = 0;
5256 (define_insn "*sunle_1"
5257 [(set (match_operand:QI 0 "register_operand" "=d")
5258 (unle:QI (cc0) (const_int 0)))]
5259 "TARGET_68881 && !TARGET_68060"
5261 cc_status = cc_prev_status;
5265 (define_expand "sunlt"
5266 [(set (match_operand:QI 0 "register_operand" "")
5267 (unlt:QI (cc0) (const_int 0)))]
5268 "TARGET_68881 && !TARGET_68060"
5270 gcc_assert (m68k_last_compare_had_fp_operands);
5271 m68k_last_compare_had_fp_operands = 0;
5274 (define_insn "*sunlt_1"
5275 [(set (match_operand:QI 0 "register_operand" "=d")
5276 (unlt:QI (cc0) (const_int 0)))]
5277 "TARGET_68881 && !TARGET_68060"
5279 cc_status = cc_prev_status;
5283 (define_expand "sltgt"
5284 [(set (match_operand:QI 0 "register_operand" "")
5285 (ltgt:QI (cc0) (const_int 0)))]
5286 "TARGET_68881 && !TARGET_68060"
5288 gcc_assert (m68k_last_compare_had_fp_operands);
5289 m68k_last_compare_had_fp_operands = 0;
5292 (define_insn "*sltgt_1"
5293 [(set (match_operand:QI 0 "register_operand" "=d")
5294 (ltgt:QI (cc0) (const_int 0)))]
5295 "TARGET_68881 && !TARGET_68060"
5297 cc_status = cc_prev_status;
5301 (define_insn "*fsogt_1"
5302 [(set (match_operand:QI 0 "register_operand" "=d")
5303 (not:QI (unle:QI (cc0) (const_int 0))))]
5304 "TARGET_68881 && !TARGET_68060"
5306 cc_status = cc_prev_status;
5310 (define_insn "*fsoge_1"
5311 [(set (match_operand:QI 0 "register_operand" "=d")
5312 (not:QI (unlt:QI (cc0) (const_int 0))))]
5313 "TARGET_68881 && !TARGET_68060"
5315 cc_status = cc_prev_status;
5319 (define_insn "*fsolt_1"
5320 [(set (match_operand:QI 0 "register_operand" "=d")
5321 (not:QI (unge:QI (cc0) (const_int 0))))]
5322 "TARGET_68881 && !TARGET_68060"
5324 cc_status = cc_prev_status;
5328 (define_insn "*fsole_1"
5329 [(set (match_operand:QI 0 "register_operand" "=d")
5330 (not:QI (ungt:QI (cc0) (const_int 0))))]
5331 "TARGET_68881 && !TARGET_68060"
5333 cc_status = cc_prev_status;
5337 ;; Basic conditional jump instructions.
5339 (define_insn "beq0_di"
5341 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
5343 (label_ref (match_operand 1 "" ","))
5345 (clobber (match_scratch:SI 2 "=d,d"))]
5349 if (which_alternative == 1)
5352 return "move%.l %0,%2\;or%.l %0,%2\;jbeq %l1";
5354 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5356 if ((cc_prev_status.value1
5357 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5358 || (cc_prev_status.value2
5359 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5361 cc_status = cc_prev_status;
5362 return MOTOROLA ? "jbeq %l1" : "jeq %l1";
5364 if (GET_CODE (operands[0]) == REG)
5365 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5367 operands[3] = adjust_address (operands[0], SImode, 4);
5368 if (! ADDRESS_REG_P (operands[0]))
5370 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5372 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5375 return "or%.l %0,%2\;jbeq %l1";
5377 return "or%.l %0,%2\;jeq %l1";
5382 return "or%.l %3,%2\;jbeq %l1";
5384 return "or%.l %3,%2\;jeq %l1";
5388 return "move%.l %0,%2\;or%.l %3,%2\;jbeq %l1";
5390 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5392 operands[4] = gen_label_rtx();
5393 if (TARGET_68020 || TARGET_COLDFIRE)
5396 output_asm_insn ("tst%.l %0\;jbne %l4\;tst%.l %3\;jbeq %l1", operands);
5398 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
5403 output_asm_insn ("cmp%.w #0,%0\;jbne %l4\;cmp%.w #0,%3\;jbeq %l1", operands);
5405 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
5407 (*targetm.asm_out.internal_label) (asm_out_file, "L",
5408 CODE_LABEL_NUMBER (operands[4]));
5412 (define_insn "bne0_di"
5414 (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
5416 (label_ref (match_operand 1 "" ","))
5418 (clobber (match_scratch:SI 2 "=d,X"))]
5421 if ((cc_prev_status.value1
5422 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5423 || (cc_prev_status.value2
5424 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5426 cc_status = cc_prev_status;
5427 return MOTOROLA ? "jbne %l1" : "jne %l1";
5430 if (GET_CODE (operands[0]) == REG)
5431 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5433 operands[3] = adjust_address (operands[0], SImode, 4);
5434 if (!ADDRESS_REG_P (operands[0]))
5436 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5438 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5441 return "or%.l %0,%2\;jbne %l1";
5443 return "or%.l %0,%2\;jne %l1";
5448 return "or%.l %3,%2\;jbne %l1";
5450 return "or%.l %3,%2\;jne %l1";
5454 return "move%.l %0,%2\;or%.l %3,%2\;jbne %l1";
5456 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
5458 if (TARGET_68020 || TARGET_COLDFIRE)
5461 return "tst%.l %0\;jbne %l1\;tst%.l %3\;jbne %l1";
5463 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
5468 return "cmp%.w #0,%0\;jbne %l1\;cmp%.w #0,%3\;jbne %l1";
5470 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
5474 (define_insn "bge0_di"
5476 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
5478 (label_ref (match_operand 1 "" ""))
5482 if ((cc_prev_status.value1
5483 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5484 || (cc_prev_status.value2
5485 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5487 cc_status = cc_prev_status;
5488 if (cc_status.flags & CC_REVERSED)
5490 return MOTOROLA ? "jble %l1" : "jle %l1";
5494 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5498 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5499 output_asm_insn("tst%.l %0", operands);
5502 /* On an address reg, cmpw may replace cmpl. */
5503 output_asm_insn("cmp%.w #0,%0", operands);
5505 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5508 (define_insn "blt0_di"
5510 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
5512 (label_ref (match_operand 1 "" ""))
5516 if ((cc_prev_status.value1
5517 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5518 || (cc_prev_status.value2
5519 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5521 cc_status = cc_prev_status;
5522 if (cc_status.flags & CC_REVERSED)
5524 return MOTOROLA ? "jbgt %l1" : "jgt %l1";
5528 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5532 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5533 output_asm_insn("tst%.l %0", operands);
5536 /* On an address reg, cmpw may replace cmpl. */
5537 output_asm_insn("cmp%.w #0,%0", operands);
5540 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5545 (if_then_else (eq (cc0)
5547 (label_ref (match_operand 0 "" ""))
5552 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5554 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5559 (if_then_else (ne (cc0)
5561 (label_ref (match_operand 0 "" ""))
5566 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5568 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5573 (if_then_else (gt (cc0)
5575 (label_ref (match_operand 0 "" ""))
5580 OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0);
5582 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
5587 (if_then_else (gtu (cc0)
5589 (label_ref (match_operand 0 "" ""))
5593 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5598 (if_then_else (lt (cc0)
5600 (label_ref (match_operand 0 "" ""))
5605 OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0");
5607 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
5612 (if_then_else (ltu (cc0)
5614 (label_ref (match_operand 0 "" ""))
5618 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5623 (if_then_else (ge (cc0)
5625 (label_ref (match_operand 0 "" ""))
5630 OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0");
5632 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
5637 (if_then_else (geu (cc0)
5639 (label_ref (match_operand 0 "" ""))
5643 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5648 (if_then_else (le (cc0)
5650 (label_ref (match_operand 0 "" ""))
5655 OUTPUT_JUMP ("jble %l0", "fble %l0", 0);
5657 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
5662 (if_then_else (leu (cc0)
5664 (label_ref (match_operand 0 "" ""))
5668 return MOTOROLA ? "jbls %l0" : "jls %l0";
5671 (define_insn "bordered"
5673 (if_then_else (ordered (cc0) (const_int 0))
5674 (label_ref (match_operand 0 "" ""))
5678 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5679 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5682 (define_insn "bunordered"
5684 (if_then_else (unordered (cc0) (const_int 0))
5685 (label_ref (match_operand 0 "" ""))
5689 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5690 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5693 (define_insn "buneq"
5695 (if_then_else (uneq (cc0) (const_int 0))
5696 (label_ref (match_operand 0 "" ""))
5700 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5701 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5704 (define_insn "bunge"
5706 (if_then_else (unge (cc0) (const_int 0))
5707 (label_ref (match_operand 0 "" ""))
5711 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5712 return MOTOROLA ? "fbuge %l0" : "fjuge %l0";
5715 (define_insn "bungt"
5717 (if_then_else (ungt (cc0) (const_int 0))
5718 (label_ref (match_operand 0 "" ""))
5722 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5723 return MOTOROLA ? "fbugt %l0" : "fjugt %l0";
5726 (define_insn "bunle"
5728 (if_then_else (unle (cc0) (const_int 0))
5729 (label_ref (match_operand 0 "" ""))
5733 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5734 return MOTOROLA ? "fbule %l0" : "fjule %l0";
5737 (define_insn "bunlt"
5739 (if_then_else (unlt (cc0) (const_int 0))
5740 (label_ref (match_operand 0 "" ""))
5744 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5745 return MOTOROLA ? "fbult %l0" : "fjult %l0";
5748 (define_insn "bltgt"
5750 (if_then_else (ltgt (cc0) (const_int 0))
5751 (label_ref (match_operand 0 "" ""))
5755 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5756 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5759 ;; Negated conditional jump instructions.
5763 (if_then_else (eq (cc0)
5766 (label_ref (match_operand 0 "" ""))))]
5770 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5772 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5777 (if_then_else (ne (cc0)
5780 (label_ref (match_operand 0 "" ""))))]
5784 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5786 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5791 (if_then_else (gt (cc0)
5794 (label_ref (match_operand 0 "" ""))))]
5798 OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0);
5800 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
5805 (if_then_else (gtu (cc0)
5808 (label_ref (match_operand 0 "" ""))))]
5811 return MOTOROLA ? "jbls %l0" : "jls %l0";
5816 (if_then_else (lt (cc0)
5819 (label_ref (match_operand 0 "" ""))))]
5823 OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0");
5825 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
5830 (if_then_else (ltu (cc0)
5833 (label_ref (match_operand 0 "" ""))))]
5836 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5841 (if_then_else (ge (cc0)
5844 (label_ref (match_operand 0 "" ""))))]
5848 OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0");
5850 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
5855 (if_then_else (geu (cc0)
5858 (label_ref (match_operand 0 "" ""))))]
5861 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5866 (if_then_else (le (cc0)
5869 (label_ref (match_operand 0 "" ""))))]
5873 OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0);
5875 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
5880 (if_then_else (leu (cc0)
5883 (label_ref (match_operand 0 "" ""))))]
5886 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5889 (define_insn "*bordered_rev"
5891 (if_then_else (ordered (cc0) (const_int 0))
5893 (label_ref (match_operand 0 "" ""))))]
5896 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5897 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5900 (define_insn "*bunordered_rev"
5902 (if_then_else (unordered (cc0) (const_int 0))
5904 (label_ref (match_operand 0 "" ""))))]
5907 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5908 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5911 (define_insn "*buneq_rev"
5913 (if_then_else (uneq (cc0) (const_int 0))
5915 (label_ref (match_operand 0 "" ""))))]
5918 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5919 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5922 (define_insn "*bunge_rev"
5924 (if_then_else (unge (cc0) (const_int 0))
5926 (label_ref (match_operand 0 "" ""))))]
5929 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5930 return MOTOROLA ? "fbolt %l0" : "fjolt %l0";
5933 (define_insn "*bunle_rev"
5935 (if_then_else (unle (cc0) (const_int 0))
5937 (label_ref (match_operand 0 "" ""))))]
5940 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5941 return MOTOROLA ? "fbogt %l0" : "fjogt %l0";
5944 (define_insn "*bunlt_rev"
5946 (if_then_else (unlt (cc0) (const_int 0))
5948 (label_ref (match_operand 0 "" ""))))]
5951 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5952 return MOTOROLA ? "fboge %l0" : "fjoge %l0";
5955 (define_insn "*bltgt_rev"
5957 (if_then_else (ltgt (cc0) (const_int 0))
5959 (label_ref (match_operand 0 "" ""))))]
5962 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5963 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5966 ;; Unconditional and other jump instructions
5969 (label_ref (match_operand 0 "" "")))]
5972 return MOTOROLA ? "jbra %l0" : "jra %l0";
5975 (define_expand "tablejump"
5976 [(parallel [(set (pc) (match_operand 0 "" ""))
5977 (use (label_ref (match_operand 1 "" "")))])]
5980 #ifdef CASE_VECTOR_PC_RELATIVE
5981 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
5982 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
5986 ;; Jump to variable address from dispatch table of absolute addresses.
5988 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
5989 (use (label_ref (match_operand 1 "" "")))]
5992 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
5995 ;; Jump to variable address from dispatch table of relative addresses.
5999 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6000 (use (label_ref (match_operand 1 "" "")))]
6003 #ifdef ASM_RETURN_CASE_JUMP
6004 ASM_RETURN_CASE_JUMP;
6006 if (TARGET_COLDFIRE)
6008 if (ADDRESS_REG_P (operands[0]))
6009 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6011 return "ext%.l %0\;jmp (2,pc,%0.l)";
6013 return "extl %0\;jmp pc@(2,%0:l)";
6016 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6020 ;; Decrement-and-branch insns.
6024 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6026 (label_ref (match_operand 1 "" ""))
6029 (plus:HI (match_dup 0)
6034 if (DATA_REG_P (operands[0]))
6035 return "dbra %0,%l1";
6036 if (GET_CODE (operands[0]) == MEM)
6038 "subq%.w #1,%0\;jbcc %l1" :
6039 "subqw #1,%0\;jcc %l1";
6041 "subq%.w #1,%0\;cmp%.w #-1,%0\;jbne %l1" :
6042 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6048 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6050 (label_ref (match_operand 1 "" ""))
6053 (plus:SI (match_dup 0)
6058 if (DATA_REG_P (operands[0]))
6060 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6061 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6062 if (GET_CODE (operands[0]) == MEM)
6064 "subq%.l #1,%0\;jbcc %l1" :
6065 "subq%.l #1,%0\;jcc %l1";
6067 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6068 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6071 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6076 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6079 (label_ref (match_operand 1 "" ""))
6082 (plus:HI (match_dup 0)
6084 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6087 if (DATA_REG_P (operands[0]))
6088 return "dbra %0,%l1";
6089 if (GET_CODE (operands[0]) == MEM)
6091 "subq%.w #1,%0\;jbcc %l1" :
6092 "subq%.w #1,%0\;jcc %l1";
6094 "subq.w #1,%0\;cmp.w #-1,%0\;jbne %l1" :
6095 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6098 (define_expand "decrement_and_branch_until_zero"
6099 [(parallel [(set (pc)
6101 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6104 (label_ref (match_operand 1 "" ""))
6107 (plus:SI (match_dup 0)
6115 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6118 (label_ref (match_operand 1 "" ""))
6121 (plus:SI (match_dup 0)
6123 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6126 if (DATA_REG_P (operands[0]))
6128 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6129 "dbra %0,%l1\;clr%.w %0\;subql #1,%0\;jcc %l1";
6130 if (GET_CODE (operands[0]) == MEM)
6132 "subq%.l #1,%0\;jbcc %l1" :
6133 "subql #1,%0\;jcc %l1";
6135 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6136 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6140 ;; For PIC calls, in order to be able to support
6141 ;; dynamic linker LAZY BINDING, all the procedure calls need to go
6142 ;; through the PLT (Procedure Linkage Table) section in PIC mode.
6144 ;; PIC calls are handled by loading the address of the function into a
6145 ;; register (via movsi), then emitting a register indirect call using
6146 ;; the "jsr" function call syntax.
6148 ;; When outputting MIT syntax (e.g. on Suns), we add a bogus extra
6149 ;; operand to the jbsr statement to indicate that this call should
6150 ;; go through the PLT (why? because this is the way that Sun does it).
6152 ;; We have different patterns for PIC calls and non-PIC calls. The
6153 ;; different patterns are only used to choose the right syntax.
6155 ;; The svr4 m68k assembler recognizes this syntax: `bsr FUNC@PLTPC' and it
6156 ;; will create the correct relocation entry (R_68K_PLT32) for `FUNC',
6157 ;; that tells the linker editor to create an entry for `FUNC' in PLT
6158 ;; section at link time. However, all global objects reference are still
6159 ;; done by using `OBJ@GOT'. So, the goal here is to output the function
6160 ;; call operand as `FUNC@PLTPC', but output object operand as `OBJ@GOT'.
6161 ;; We need to have a way to differentiate these two different operands.
6163 ;; The strategy I use here is to use SYMBOL_REF_FLAG to differentiate
6164 ;; these two different operands. The macro LEGITIMATE_PIC_OPERAND_P needs
6165 ;; to be changed to recognize function calls symbol_ref operand as a valid
6166 ;; PIC operand (by checking whether SYMBOL_REF_FLAG is set). This will
6167 ;; avoid the compiler to load this symbol_ref operand into a register.
6168 ;; Remember, the operand "foo@PLTPC" cannot be called via jsr directly
6169 ;; since the value is a PC relative offset, not a real address.
6171 ;; All global objects are treated in the similar way as in SUN3. The only
6172 ;; difference is: on m68k svr4, the reference of such global object needs
6173 ;; to end with a suffix "@GOT" so the assembler and linker know to create
6174 ;; an entry for it in GOT (Global Offset Table) section. This is done in
6177 ;; Call subroutine with no return value.
6178 (define_expand "call"
6179 [(call (match_operand:QI 0 "memory_operand" "")
6180 (match_operand:SI 1 "general_operand" ""))]
6181 ;; Operand 1 not really used on the m68000.
6185 if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
6186 SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1;
6189 ;; This is a normal call sequence.
6191 [(call (match_operand:QI 0 "memory_operand" "o")
6192 (match_operand:SI 1 "general_operand" "g"))]
6193 ;; Operand 1 not really used on the m68000.
6197 #if MOTOROLA && !defined (USE_GAS)
6204 ;; This is a PIC call sequence.
6206 [(call (match_operand:QI 0 "memory_operand" "o")
6207 (match_operand:SI 1 "general_operand" "g"))]
6208 ;; Operand 1 not really used on the m68000.
6212 m68k_output_pic_call(operands[0]);
6216 ;; Call subroutine, returning value in operand 0
6217 ;; (which must be a hard register).
6218 ;; See comments before "call" regarding PIC calls.
6219 (define_expand "call_value"
6220 [(set (match_operand 0 "" "")
6221 (call (match_operand:QI 1 "memory_operand" "")
6222 (match_operand:SI 2 "general_operand" "")))]
6223 ;; Operand 2 not really used on the m68000.
6226 if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
6227 SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1;
6230 ;; This is a normal call_value
6232 [(set (match_operand 0 "" "=rf")
6233 (call (match_operand:QI 1 "memory_operand" "o")
6234 (match_operand:SI 2 "general_operand" "g")))]
6235 ;; Operand 2 not really used on the m68000.
6238 #if MOTOROLA && !defined (USE_GAS)
6245 ;; This is a PIC call_value
6247 [(set (match_operand 0 "" "=rf")
6248 (call (match_operand:QI 1 "memory_operand" "o")
6249 (match_operand:SI 2 "general_operand" "g")))]
6250 ;; Operand 2 not really used on the m68000.
6253 m68k_output_pic_call(operands[1]);
6257 ;; Call subroutine returning any type.
6259 (define_expand "untyped_call"
6260 [(parallel [(call (match_operand 0 "" "")
6262 (match_operand 1 "" "")
6263 (match_operand 2 "" "")])]
6264 "NEEDS_UNTYPED_CALL"
6268 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6270 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6272 rtx set = XVECEXP (operands[2], 0, i);
6273 emit_move_insn (SET_DEST (set), SET_SRC (set));
6276 /* The optimizer does not know that the call sets the function value
6277 registers we stored in the result block. We avoid problems by
6278 claiming that all hard registers are used and clobbered at this
6280 emit_insn (gen_blockage ());
6285 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6286 ;; all of memory. This blocks insns from being moved across this point.
6288 (define_insn "blockage"
6289 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6298 ;; Used for frameless functions which save no regs and allocate no locals.
6299 (define_insn "return"
6303 if (current_function_pops_args == 0)
6305 operands[0] = GEN_INT (current_function_pops_args);
6309 (define_insn "indirect_jump"
6310 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
6314 ;; This should not be used unless the add/sub insns can't be.
6317 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
6318 (match_operand:QI 1 "address_operand" "p"))]
6321 /* Recognize an insn that refers to a table of offsets. Such an insn will
6322 need to refer to a label on the insn. So output one. Use the
6323 label-number of the table of offsets to generate this label. This code,
6324 and similar code above, assumes that there will be at most one reference
6326 if (GET_CODE (operands[1]) == PLUS
6327 && GET_CODE (XEXP (operands[1], 1)) == LABEL_REF
6328 && GET_CODE (XEXP (operands[1], 0)) != PLUS)
6330 rtx labelref = XEXP (operands[1], 1);
6332 asm_fprintf (asm_out_file, "\\t.set %LLI%d,.+2\\n",
6333 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6335 (*targetm.asm_out.internal_label) (asm_out_file, "LI",
6336 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6338 return "lea %a1,%0";
6341 ;; This is the first machine-dependent peephole optimization.
6342 ;; It is useful when a floating value is returned from a function call
6343 ;; and then is moved into an FP register.
6344 ;; But it is mainly intended to test the support for these optimizations.
6347 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
6348 (set (match_operand:DF 0 "register_operand" "=f")
6349 (match_operand:DF 1 "register_operand" "ad"))]
6350 "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
6353 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6354 output_asm_insn ("move%.l %1,%@", xoperands);
6355 output_asm_insn ("move%.l %1,%-", operands);
6356 return "fmove%.d %+,%0";
6359 ;; Optimize a stack-adjust followed by a push of an argument.
6360 ;; This is said to happen frequently with -msoft-float
6361 ;; when there are consecutive library calls.
6364 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6365 (match_operand:SI 0 "const_int_operand" "n")))
6366 (set (match_operand:SF 1 "push_operand" "=m")
6367 (match_operand:SF 2 "general_operand" "rmfF"))]
6368 "INTVAL (operands[0]) >= 4
6369 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6371 if (INTVAL (operands[0]) > 4)
6374 xoperands[0] = stack_pointer_rtx;
6375 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6376 if (INTVAL (xoperands[1]) <= 8)
6378 if (!TARGET_COLDFIRE)
6379 output_asm_insn ("addq%.w %1,%0", xoperands);
6381 output_asm_insn ("addq%.l %1,%0", xoperands);
6383 else if (TARGET_CPU32 && INTVAL (xoperands[1]) <= 16)
6385 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6386 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6388 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6391 output_asm_insn ("add%.w %1,%0", xoperands);
6393 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6395 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6398 output_asm_insn ("add%.l %1,%0", xoperands);
6400 if (FP_REG_P (operands[2]))
6401 return "fmove%.s %2,%@";
6402 return "move%.l %2,%@";
6405 ;; Speed up stack adjust followed by a fullword fixedpoint push.
6408 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6409 (match_operand:SI 0 "const_int_operand" "n")))
6410 (set (match_operand:SI 1 "push_operand" "=m")
6411 (match_operand:SI 2 "general_operand" "g"))]
6412 "INTVAL (operands[0]) >= 4
6413 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6415 if (INTVAL (operands[0]) > 4)
6418 xoperands[0] = stack_pointer_rtx;
6419 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6420 if (INTVAL (xoperands[1]) <= 8)
6422 if (!TARGET_COLDFIRE)
6423 output_asm_insn ("addq%.w %1,%0", xoperands);
6425 output_asm_insn ("addq%.l %1,%0", xoperands);
6427 else if (TARGET_CPU32 && INTVAL (xoperands[1]) <= 16)
6429 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6430 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6432 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6435 output_asm_insn ("add%.w %1,%0", xoperands);
6437 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6439 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6442 output_asm_insn ("add%.l %1,%0", xoperands);
6444 if (operands[2] == const0_rtx)
6446 return "move%.l %2,%@";
6449 ;; Speed up pushing a single byte but leaving four bytes of space.
6452 [(set (mem:QI (pre_dec:SI (reg:SI SP_REG)))
6453 (match_operand:QI 1 "general_operand" "dami"))
6454 (set (reg:SI SP_REG) (minus:SI (reg:SI SP_REG) (const_int 2)))]
6455 "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
6459 if (GET_CODE (operands[1]) == REG)
6460 return "move%.l %1,%-";
6462 xoperands[1] = operands[1];
6464 = gen_rtx_MEM (QImode, plus_constant (stack_pointer_rtx, 3));
6465 xoperands[3] = stack_pointer_rtx;
6466 if (!TARGET_COLDFIRE)
6467 output_asm_insn ("subq%.w #4,%3\;move%.b %1,%2", xoperands);
6469 output_asm_insn ("subq%.l #4,%3\;move%.b %1,%2", xoperands);
6474 [(set (match_operand:SI 0 "register_operand" "=d")
6476 (set (strict_low_part (subreg:HI (match_dup 0) 2))
6477 (match_operand:HI 1 "general_operand" "rmn"))]
6478 "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
6480 if (GET_CODE (operands[1]) == CONST_INT)
6482 if (operands[1] == const0_rtx
6483 && (DATA_REG_P (operands[0])
6484 || GET_CODE (operands[0]) == MEM)
6485 /* clr insns on 68000 read before writing.
6486 This isn't so on the 68010, but we have no TARGET_68010. */
6487 && ((TARGET_68020 || TARGET_COLDFIRE)
6488 || !(GET_CODE (operands[0]) == MEM
6489 && MEM_VOLATILE_P (operands[0]))))
6492 return "move%.w %1,%0";
6500 ;; jCC label ; abnormal loop termination
6501 ;; dbra dN, loop ; normal loop termination
6509 ;; Which moves the jCC condition outside the inner loop for free.
6513 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6514 [(cc0) (const_int 0)])
6515 (label_ref (match_operand 2 "" ""))
6520 (ne (match_operand:HI 0 "register_operand" "")
6522 (label_ref (match_operand 1 "" ""))
6525 (plus:HI (match_dup 0)
6527 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6530 output_dbcc_and_branch (operands);
6535 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6536 [(cc0) (const_int 0)])
6537 (label_ref (match_operand 2 "" ""))
6542 (ne (match_operand:SI 0 "register_operand" "")
6544 (label_ref (match_operand 1 "" ""))
6547 (plus:SI (match_dup 0)
6549 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6552 output_dbcc_and_branch (operands);
6557 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6558 [(cc0) (const_int 0)])
6559 (label_ref (match_operand 2 "" ""))
6564 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
6567 (label_ref (match_operand 1 "" ""))
6570 (plus:HI (match_dup 0)
6572 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6575 output_dbcc_and_branch (operands);
6580 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6581 [(cc0) (const_int 0)])
6582 (label_ref (match_operand 2 "" ""))
6587 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
6590 (label_ref (match_operand 1 "" ""))
6593 (plus:SI (match_dup 0)
6595 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6598 output_dbcc_and_branch (operands);
6603 (define_expand "tstxf"
6605 (match_operand:XF 0 "nonimmediate_operand" ""))]
6607 "m68k_last_compare_had_fp_operands = 1;")
6611 (match_operand:XF 0 "nonimmediate_operand" "fm"))]
6614 cc_status.flags = CC_IN_68881;
6615 return "ftst%.x %0";
6618 (define_expand "cmpxf"
6620 (compare (match_operand:XF 0 "nonimmediate_operand" "")
6621 (match_operand:XF 1 "nonimmediate_operand" "")))]
6623 "m68k_last_compare_had_fp_operands = 1;")
6627 (compare (match_operand:XF 0 "nonimmediate_operand" "f,m")
6628 (match_operand:XF 1 "nonimmediate_operand" "fm,f")))]
6631 cc_status.flags = CC_IN_68881;
6632 if (REG_P (operands[0]))
6634 if (REG_P (operands[1]))
6635 return "fcmp%.x %1,%0";
6637 return "fcmp%.x %f1,%0";
6639 cc_status.flags |= CC_REVERSED;
6640 return "fcmp%.x %f0,%1";
6643 (define_insn "extendsfxf2"
6644 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6645 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
6648 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6650 if (REGNO (operands[0]) == REGNO (operands[1]))
6652 /* Extending float to double in an fp-reg is a no-op.
6653 NOTICE_UPDATE_CC has already assumed that the
6654 cc will be set. So cancel what it did. */
6655 cc_status = cc_prev_status;
6658 return "f%$move%.x %1,%0";
6660 if (FP_REG_P (operands[0]))
6662 if (FP_REG_P (operands[1]))
6663 return "f%$move%.x %1,%0";
6664 else if (ADDRESS_REG_P (operands[1]))
6665 return "move%.l %1,%-\;f%$move%.s %+,%0";
6666 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
6667 return output_move_const_single (operands);
6668 return "f%$move%.s %f1,%0";
6670 return "fmove%.x %f1,%0";
6674 (define_insn "extenddfxf2"
6675 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6677 (match_operand:DF 1 "general_operand" "f,rmE")))]
6680 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6682 if (REGNO (operands[0]) == REGNO (operands[1]))
6684 /* Extending float to double in an fp-reg is a no-op.
6685 NOTICE_UPDATE_CC has already assumed that the
6686 cc will be set. So cancel what it did. */
6687 cc_status = cc_prev_status;
6690 return "fmove%.x %1,%0";
6692 if (FP_REG_P (operands[0]))
6694 if (REG_P (operands[1]))
6697 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6698 output_asm_insn ("move%.l %1,%-", xoperands);
6699 output_asm_insn ("move%.l %1,%-", operands);
6700 return "f%&move%.d %+,%0";
6702 if (GET_CODE (operands[1]) == CONST_DOUBLE)
6703 return output_move_const_double (operands);
6704 return "f%&move%.d %f1,%0";
6706 return "fmove%.x %f1,%0";
6709 (define_insn "truncxfdf2"
6710 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
6712 (match_operand:XF 1 "general_operand" "f,f")))]
6715 if (REG_P (operands[0]))
6717 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
6718 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6719 return "move%.l %+,%0";
6721 return "fmove%.d %f1,%0";
6724 (define_insn "truncxfsf2"
6725 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
6727 (match_operand:XF 1 "general_operand" "f")))]
6731 (define_insn "floatsixf2"
6732 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6733 (float:XF (match_operand:SI 1 "general_operand" "dmi")))]
6737 (define_insn "floathixf2"
6738 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6739 (float:XF (match_operand:HI 1 "general_operand" "dmn")))]
6743 (define_insn "floatqixf2"
6744 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6745 (float:XF (match_operand:QI 1 "general_operand" "dmn")))]
6749 (define_insn "ftruncxf2"
6750 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6751 (fix:XF (match_operand:XF 1 "general_operand" "fFm")))]
6754 if (FP_REG_P (operands[1]))
6755 return "fintrz%.x %f1,%0";
6756 return "fintrz%.x %f1,%0";
6759 (define_insn "fixxfqi2"
6760 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
6761 (fix:QI (match_operand:XF 1 "general_operand" "f")))]
6765 (define_insn "fixxfhi2"
6766 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
6767 (fix:HI (match_operand:XF 1 "general_operand" "f")))]
6771 (define_insn "fixxfsi2"
6772 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
6773 (fix:SI (match_operand:XF 1 "general_operand" "f")))]
6778 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6779 (plus:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
6780 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6785 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6786 (plus:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
6787 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6792 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6793 (plus:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
6794 (match_operand:XF 1 "general_operand" "0")))]
6798 (define_insn "addxf3"
6799 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6800 (plus:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
6801 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6804 if (REG_P (operands[2]))
6805 return "fadd%.x %2,%0";
6806 return "fadd%.x %f2,%0";
6810 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6811 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6812 (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
6817 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6818 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6819 (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
6824 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6825 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6826 (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
6830 (define_insn "subxf3"
6831 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6832 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6833 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6836 if (REG_P (operands[2]))
6837 return "fsub%.x %2,%0";
6838 return "fsub%.x %f2,%0";
6842 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6843 (mult:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
6844 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6849 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6850 (mult:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
6851 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6856 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6857 (mult:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
6858 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6862 (define_insn "mulxf3"
6863 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6864 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
6865 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6868 if (REG_P (operands[2]))
6869 return "fmul%.x %2,%0";
6870 return "fmul%.x %f2,%0";
6874 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6875 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6876 (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
6881 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6882 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6883 (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
6888 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6889 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6890 (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
6894 (define_insn "divxf3"
6895 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6896 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6897 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6900 if (REG_P (operands[2]))
6901 return "fdiv%.x %2,%0";
6902 return "fdiv%.x %f2,%0";
6905 (define_expand "negxf2"
6906 [(set (match_operand:XF 0 "nonimmediate_operand" "")
6907 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
6917 target = operand_subword (operands[0], 0, 1, XFmode);
6918 result = expand_binop (SImode, xor_optab,
6919 operand_subword_force (operands[1], 0, XFmode),
6920 GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
6921 gcc_assert (result);
6923 if (result != target)
6924 emit_move_insn (result, target);
6926 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
6927 operand_subword_force (operands[1], 1, XFmode));
6928 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
6929 operand_subword_force (operands[1], 2, XFmode));
6931 insns = get_insns ();
6934 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
6939 (define_insn "negxf2_68881"
6940 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6941 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
6944 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
6945 return "fneg%.x %1,%0";
6946 return "fneg%.x %f1,%0";
6949 (define_expand "absxf2"
6950 [(set (match_operand:XF 0 "nonimmediate_operand" "")
6951 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
6961 target = operand_subword (operands[0], 0, 1, XFmode);
6962 result = expand_binop (SImode, and_optab,
6963 operand_subword_force (operands[1], 0, XFmode),
6964 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
6965 gcc_assert (result);
6967 if (result != target)
6968 emit_move_insn (result, target);
6970 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
6971 operand_subword_force (operands[1], 1, XFmode));
6972 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
6973 operand_subword_force (operands[1], 2, XFmode));
6975 insns = get_insns ();
6978 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
6983 (define_insn "absxf2_68881"
6984 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6985 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
6988 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
6989 return "fabs%.x %1,%0";
6990 return "fabs%.x %f1,%0";
6993 (define_insn "sqrtxf2"
6994 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6995 (sqrt:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
6999 (define_insn "sinsf2"
7000 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
7001 (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] UNSPEC_SIN))]
7002 "TARGET_68881 && flag_unsafe_math_optimizations"
7004 if (FP_REG_P (operands[1]))
7005 return "fsin%.x %1,%0";
7007 return "fsin%.s %1,%0";
7010 (define_insn "sindf2"
7011 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
7012 (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] UNSPEC_SIN))]
7013 "TARGET_68881 && flag_unsafe_math_optimizations"
7015 if (FP_REG_P (operands[1]))
7016 return "fsin%.x %1,%0";
7018 return "fsin%.d %1,%0";
7021 (define_insn "sinxf2"
7022 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7023 (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] UNSPEC_SIN))]
7024 "TARGET_68881 && flag_unsafe_math_optimizations"
7027 (define_insn "cossf2"
7028 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
7029 (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] UNSPEC_COS))]
7030 "TARGET_68881 && flag_unsafe_math_optimizations"
7032 if (FP_REG_P (operands[1]))
7033 return "fcos%.x %1,%0";
7035 return "fcos%.s %1,%0";
7038 (define_insn "cosdf2"
7039 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
7040 (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] UNSPEC_COS))]
7041 "TARGET_68881 && flag_unsafe_math_optimizations"
7043 if (FP_REG_P (operands[1]))
7044 return "fcos%.x %1,%0";
7046 return "fcos%.d %1,%0";
7049 (define_insn "cosxf2"
7050 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7051 (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] UNSPEC_COS))]
7052 "TARGET_68881 && flag_unsafe_math_optimizations"
7056 [(trap_if (const_int -1) (const_int 7))]
7060 (define_insn "conditional_trap"
7061 [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
7062 [(cc0) (const_int 0)])
7063 (match_operand:SI 1 "const_int_operand" "I"))]
7064 "TARGET_68020 && ! flags_in_68881 ()"
7066 switch (GET_CODE (operands[0]))
7068 case EQ: return "trapeq";
7069 case NE: return "trapne";
7070 case GT: return "trapgt";
7071 case GTU: return "traphi";
7072 case LT: return "traplt";
7073 case LTU: return "trapcs";
7074 case GE: return "trapge";
7075 case GEU: return "trapcc";
7076 case LE: return "traple";
7077 case LEU: return "trapls";
7078 default: gcc_unreachable ();