1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
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, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, 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";
1781 else if (GET_CODE (operands[0]) == MEM)
1783 if (GET_CODE (operands[2]) == MEM
1784 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
1785 return "add%.l %2,%0\;addx%.l %2,%0";
1787 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1789 operands[1] = gen_rtx_MEM (SImode,
1790 plus_constant (XEXP(operands[0], 0), -8));
1791 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
1793 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1795 operands[1] = XEXP(operands[0], 0);
1796 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
1800 operands[1] = adjust_address (operands[0], SImode, 4);
1801 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
1808 (define_insn "addsi_lshrsi_31"
1809 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1810 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
1815 operands[2] = operands[0];
1816 operands[3] = gen_label_rtx();
1817 if (GET_CODE (operands[0]) == MEM)
1819 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1820 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
1821 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1822 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
1824 output_asm_insn ("move%.l %1,%0", operands);
1825 output_asm_insn (MOTOROLA ? "jbpl %l3" : "jpl %l3", operands);
1826 output_asm_insn ("addq%.l #1,%2", operands);
1827 (*targetm.asm_out.internal_label) (asm_out_file, "L",
1828 CODE_LABEL_NUMBER (operands[3]));
1832 (define_expand "addsi3"
1833 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1834 (plus:SI (match_operand:SI 1 "general_operand" "")
1835 (match_operand:SI 2 "general_src_operand" "")))]
1839 ;; Note that the middle two alternatives are near-duplicates
1840 ;; in order to handle insns generated by reload.
1841 ;; This is needed since they are not themselves reloaded,
1842 ;; so commutativity won't apply to them.
1843 (define_insn "*addsi3_internal"
1844 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
1845 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
1846 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
1850 "* return output_addsi3 (operands);")
1852 (define_insn "*addsi3_5200"
1853 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
1854 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
1855 (match_operand:SI 2 "general_src_operand" "d,rJK,a,mrIKLs")))]
1857 "* return output_addsi3 (operands);")
1860 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
1861 (plus:SI (match_operand:SI 1 "general_operand" "0")
1863 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
1867 (define_insn "addhi3"
1868 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
1869 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
1870 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
1873 if (GET_CODE (operands[2]) == CONST_INT)
1875 /* If the constant would be a negative number when interpreted as
1876 HImode, make it negative. This is usually, but not always, done
1877 elsewhere in the compiler. First check for constants out of range,
1878 which could confuse us. */
1880 if (INTVAL (operands[2]) >= 32768)
1881 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
1883 if (INTVAL (operands[2]) > 0
1884 && INTVAL (operands[2]) <= 8)
1885 return "addq%.w %2,%0";
1886 if (INTVAL (operands[2]) < 0
1887 && INTVAL (operands[2]) >= -8)
1889 operands[2] = GEN_INT (- INTVAL (operands[2]));
1890 return "subq%.w %2,%0";
1892 /* On the CPU32 it is faster to use two addqw instructions to
1893 add a small integer (8 < N <= 16) to a register.
1894 Likewise for subqw. */
1895 if (TARGET_CPU32 && REG_P (operands[0]))
1897 if (INTVAL (operands[2]) > 8
1898 && INTVAL (operands[2]) <= 16)
1900 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
1901 return "addq%.w #8,%0\;addq%.w %2,%0";
1903 if (INTVAL (operands[2]) < -8
1904 && INTVAL (operands[2]) >= -16)
1906 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
1907 return "subq%.w #8,%0\;subq%.w %2,%0";
1910 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
1911 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
1913 return "add%.w %2,%0";
1916 ;; These insns must use MATCH_DUP instead of the more expected
1917 ;; use of a matching constraint because the "output" here is also
1918 ;; an input, so you can't use the matching constraint. That also means
1919 ;; that you can't use the "%", so you need patterns with the matched
1920 ;; operand in both positions.
1923 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
1924 (plus:HI (match_dup 0)
1925 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
1928 if (GET_CODE (operands[1]) == CONST_INT)
1930 /* If the constant would be a negative number when interpreted as
1931 HImode, make it negative. This is usually, but not always, done
1932 elsewhere in the compiler. First check for constants out of range,
1933 which could confuse us. */
1935 if (INTVAL (operands[1]) >= 32768)
1936 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
1938 if (INTVAL (operands[1]) > 0
1939 && INTVAL (operands[1]) <= 8)
1940 return "addq%.w %1,%0";
1941 if (INTVAL (operands[1]) < 0
1942 && INTVAL (operands[1]) >= -8)
1944 operands[1] = GEN_INT (- INTVAL (operands[1]));
1945 return "subq%.w %1,%0";
1947 /* On the CPU32 it is faster to use two addqw instructions to
1948 add a small integer (8 < N <= 16) to a register.
1949 Likewise for subqw. */
1950 if (TARGET_CPU32 && REG_P (operands[0]))
1952 if (INTVAL (operands[1]) > 8
1953 && INTVAL (operands[1]) <= 16)
1955 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
1956 return "addq%.w #8,%0\;addq%.w %1,%0";
1958 if (INTVAL (operands[1]) < -8
1959 && INTVAL (operands[1]) >= -16)
1961 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
1962 return "subq%.w #8,%0\;subq%.w %1,%0";
1965 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
1966 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
1968 return "add%.w %1,%0";
1972 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
1973 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
1977 if (GET_CODE (operands[1]) == CONST_INT)
1979 /* If the constant would be a negative number when interpreted as
1980 HImode, make it negative. This is usually, but not always, done
1981 elsewhere in the compiler. First check for constants out of range,
1982 which could confuse us. */
1984 if (INTVAL (operands[1]) >= 32768)
1985 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
1987 if (INTVAL (operands[1]) > 0
1988 && INTVAL (operands[1]) <= 8)
1989 return "addq%.w %1,%0";
1990 if (INTVAL (operands[1]) < 0
1991 && INTVAL (operands[1]) >= -8)
1993 operands[1] = GEN_INT (- INTVAL (operands[1]));
1994 return "subq%.w %1,%0";
1996 /* On the CPU32 it is faster to use two addqw instructions to
1997 add a small integer (8 < N <= 16) to a register.
1998 Likewise for subqw. */
1999 if (TARGET_CPU32 && REG_P (operands[0]))
2001 if (INTVAL (operands[1]) > 8
2002 && INTVAL (operands[1]) <= 16)
2004 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2005 return "addq%.w #8,%0\;addq%.w %1,%0";
2007 if (INTVAL (operands[1]) < -8
2008 && INTVAL (operands[1]) >= -16)
2010 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2011 return "subq%.w #8,%0\;subq%.w %1,%0";
2014 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2015 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2017 return "add%.w %1,%0";
2020 (define_insn "addqi3"
2021 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2022 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2023 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2026 if (GET_CODE (operands[2]) == CONST_INT)
2028 if (INTVAL (operands[2]) >= 128)
2029 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2031 if (INTVAL (operands[2]) > 0
2032 && INTVAL (operands[2]) <= 8)
2033 return "addq%.b %2,%0";
2034 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2036 operands[2] = GEN_INT (- INTVAL (operands[2]));
2037 return "subq%.b %2,%0";
2040 return "add%.b %2,%0";
2044 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2045 (plus:QI (match_dup 0)
2046 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2049 if (GET_CODE (operands[1]) == CONST_INT)
2051 if (INTVAL (operands[1]) >= 128)
2052 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2054 if (INTVAL (operands[1]) > 0
2055 && INTVAL (operands[1]) <= 8)
2056 return "addq%.b %1,%0";
2057 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2059 operands[1] = GEN_INT (- INTVAL (operands[1]));
2060 return "subq%.b %1,%0";
2063 return "add%.b %1,%0";
2067 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2068 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2072 if (GET_CODE (operands[1]) == CONST_INT)
2074 if (INTVAL (operands[1]) >= 128)
2075 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2077 if (INTVAL (operands[1]) > 0
2078 && INTVAL (operands[1]) <= 8)
2079 return "addq%.b %1,%0";
2080 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2082 operands[1] = GEN_INT (- INTVAL (operands[1]));
2083 return "subq%.b %1,%0";
2086 return "add%.b %1,%0";
2089 (define_expand "adddf3"
2090 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2091 (plus:DF (match_operand:DF 1 "general_operand" "")
2092 (match_operand:DF 2 "general_operand" "")))]
2097 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2098 (plus:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2099 (match_operand:DF 1 "general_operand" "0")))]
2104 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2105 (plus:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2106 (match_operand:DF 1 "general_operand" "0")))]
2111 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2112 (plus:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2113 (match_operand:DF 1 "general_operand" "0")))]
2118 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2119 (plus:DF (match_operand:DF 1 "general_operand" "%0")
2120 (match_operand:DF 2 "general_operand" "fmG")))]
2123 if (REG_P (operands[2]))
2124 return "f%&add%.x %2,%0";
2125 return "f%&add%.d %f2,%0";
2128 (define_expand "addsf3"
2129 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2130 (plus:SF (match_operand:SF 1 "general_operand" "")
2131 (match_operand:SF 2 "general_operand" "")))]
2136 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2137 (plus:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2138 (match_operand:SF 1 "general_operand" "0")))]
2143 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2144 (plus:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2145 (match_operand:SF 1 "general_operand" "0")))]
2150 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2151 (plus:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2152 (match_operand:SF 1 "general_operand" "0")))]
2157 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2158 (plus:SF (match_operand:SF 1 "general_operand" "%0")
2159 (match_operand:SF 2 "general_operand" "fdmF")))]
2162 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2163 return "f%$add%.x %2,%0";
2164 return "f%$add%.s %f2,%0";
2167 ;; subtract instructions
2169 (define_insn "subdi_sexthishl32"
2170 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2171 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2172 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2174 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2178 if (ADDRESS_REG_P (operands[0]))
2179 return "sub%.w %2,%0";
2180 else if (ADDRESS_REG_P (operands[3]))
2181 return "move%.w %2,%3\;sub%.l %3,%0";
2183 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2186 (define_insn "subdi_dishl32"
2187 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2188 (minus:DI (match_dup 0)
2189 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2194 if (GET_CODE (operands[1]) == REG)
2195 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2197 operands[1] = adjust_address (operands[1], SImode, 4);
2198 return "sub%.l %1,%0";
2201 (define_insn "subdi3"
2202 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
2203 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0,0")
2204 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
2205 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
2208 if (DATA_REG_P (operands[0]))
2210 if (DATA_REG_P (operands[2]))
2211 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2212 else if (GET_CODE (operands[2]) == MEM
2213 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2215 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2222 if (GET_CODE (operands[2]) == REG)
2224 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2227 else if (CONSTANT_P (operands[2]))
2228 split_double (operands[2], &high, &low);
2231 low = adjust_address (operands[2], SImode, 4);
2235 operands[1] = low, operands[2] = high;
2236 xoperands[0] = operands[3];
2237 if (GET_CODE (operands[1]) == CONST_INT
2238 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2239 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2241 xoperands[1] = operands[2];
2243 output_asm_insn (output_move_simode (xoperands), xoperands);
2244 if (GET_CODE (operands[1]) == CONST_INT)
2246 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2247 return "subq%.l %1,%R0\;subx%.l %3,%0";
2248 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2250 operands[1] = GEN_INT (-INTVAL (operands[1]));
2251 return "addq%.l %1,%R0\;addx%.l %3,%0";
2254 return "sub%.l %1,%R0\;subx%.l %3,%0";
2257 else if (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";
2284 (define_insn "subsi3"
2285 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2286 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2287 (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2292 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2293 (minus:SI (match_operand:SI 1 "general_operand" "0")
2295 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2299 (define_insn "subhi3"
2300 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2301 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2302 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2307 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2308 (minus:HI (match_dup 0)
2309 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2313 (define_insn "subqi3"
2314 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2315 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2316 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2321 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2322 (minus:QI (match_dup 0)
2323 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2327 (define_expand "subdf3"
2328 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2329 (minus:DF (match_operand:DF 1 "general_operand" "")
2330 (match_operand:DF 2 "general_operand" "")))]
2335 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2336 (minus:DF (match_operand:DF 1 "general_operand" "0")
2337 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2342 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2343 (minus:DF (match_operand:DF 1 "general_operand" "0")
2344 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2349 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2350 (minus:DF (match_operand:DF 1 "general_operand" "0")
2351 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2356 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2357 (minus:DF (match_operand:DF 1 "general_operand" "0")
2358 (match_operand:DF 2 "general_operand" "fmG")))]
2361 if (REG_P (operands[2]))
2362 return "f%&sub%.x %2,%0";
2363 return "f%&sub%.d %f2,%0";
2366 (define_expand "subsf3"
2367 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2368 (minus:SF (match_operand:SF 1 "general_operand" "")
2369 (match_operand:SF 2 "general_operand" "")))]
2374 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2375 (minus:SF (match_operand:SF 1 "general_operand" "0")
2376 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2381 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2382 (minus:SF (match_operand:SF 1 "general_operand" "0")
2383 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2388 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2389 (minus:SF (match_operand:SF 1 "general_operand" "0")
2390 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2395 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2396 (minus:SF (match_operand:SF 1 "general_operand" "0")
2397 (match_operand:SF 2 "general_operand" "fdmF")))]
2400 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2401 return "f%$sub%.x %2,%0";
2402 return "f%$sub%.s %f2,%0";
2405 ;; multiply instructions
2407 (define_insn "mulhi3"
2408 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2409 (mult:HI (match_operand:HI 1 "general_operand" "%0")
2410 (match_operand:HI 2 "general_src_operand" "dmSn")))]
2413 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2416 (define_insn "mulhisi3"
2417 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2418 (mult:SI (sign_extend:SI
2419 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2421 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2424 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2428 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2429 (mult:SI (sign_extend:SI
2430 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2431 (match_operand:SI 2 "const_int_operand" "n")))]
2432 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2434 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2437 (define_expand "mulsi3"
2438 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2439 (mult:SI (match_operand:SI 1 "general_operand" "")
2440 (match_operand:SI 2 "general_operand" "")))]
2441 "TARGET_68020 || TARGET_COLDFIRE"
2445 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2446 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2447 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2453 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2454 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2455 (match_operand:SI 2 "general_operand" "d<Q>")))]
2459 (define_insn "umulhisi3"
2460 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2461 (mult:SI (zero_extend:SI
2462 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2464 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2467 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2471 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2472 (mult:SI (zero_extend:SI
2473 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2474 (match_operand:SI 2 "const_int_operand" "n")))]
2475 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2477 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2480 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2481 ;; proper matching constraint. This is because the matching is between
2482 ;; the high-numbered word of the DImode operand[0] and operand[1].
2483 (define_expand "umulsidi3"
2485 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2486 (mult:SI (match_operand:SI 1 "register_operand" "")
2487 (match_operand:SI 2 "register_operand" "")))
2488 (set (subreg:SI (match_dup 0) 0)
2489 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2490 (zero_extend:DI (match_dup 2)))
2491 (const_int 32))))])]
2492 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2496 [(set (match_operand:SI 0 "register_operand" "=d")
2497 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2498 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2499 (set (match_operand:SI 3 "register_operand" "=d")
2500 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2501 (zero_extend:DI (match_dup 2)))
2503 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2506 ; Match immediate case. For 2.4 only match things < 2^31.
2507 ; It's tricky with larger values in these patterns since we need to match
2508 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2511 [(set (match_operand:SI 0 "register_operand" "=d")
2512 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2513 (match_operand:SI 2 "const_int_operand" "n")))
2514 (set (match_operand:SI 3 "register_operand" "=d")
2515 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2518 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE
2519 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2522 (define_expand "mulsidi3"
2524 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2525 (mult:SI (match_operand:SI 1 "register_operand" "")
2526 (match_operand:SI 2 "register_operand" "")))
2527 (set (subreg:SI (match_dup 0) 0)
2528 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2529 (sign_extend:DI (match_dup 2)))
2530 (const_int 32))))])]
2531 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2535 [(set (match_operand:SI 0 "register_operand" "=d")
2536 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2537 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2538 (set (match_operand:SI 3 "register_operand" "=d")
2539 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2540 (sign_extend:DI (match_dup 2)))
2542 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2546 [(set (match_operand:SI 0 "register_operand" "=d")
2547 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2548 (match_operand:SI 2 "const_int_operand" "n")))
2549 (set (match_operand:SI 3 "register_operand" "=d")
2550 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2553 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2556 (define_expand "umulsi3_highpart"
2558 [(set (match_operand:SI 0 "register_operand" "")
2561 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2562 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2564 (clobber (match_dup 3))])]
2565 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2567 operands[3] = gen_reg_rtx (SImode);
2569 if (GET_CODE (operands[2]) == CONST_INT)
2571 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2574 /* We have to adjust the operand order for the matching constraints. */
2575 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2576 operands[1], operands[2]));
2582 [(set (match_operand:SI 0 "register_operand" "=d")
2585 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2586 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2588 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2589 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2592 (define_insn "const_umulsi3_highpart"
2593 [(set (match_operand:SI 0 "register_operand" "=d")
2596 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2597 (match_operand:DI 3 "const_uint32_operand" "n"))
2599 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2600 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2603 (define_expand "smulsi3_highpart"
2605 [(set (match_operand:SI 0 "register_operand" "")
2608 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2609 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2611 (clobber (match_dup 3))])]
2612 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2614 operands[3] = gen_reg_rtx (SImode);
2615 if (GET_CODE (operands[2]) == CONST_INT)
2617 /* We have to adjust the operand order for the matching constraints. */
2618 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2619 operands[1], operands[2]));
2625 [(set (match_operand:SI 0 "register_operand" "=d")
2628 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2629 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2631 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2632 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2635 (define_insn "const_smulsi3_highpart"
2636 [(set (match_operand:SI 0 "register_operand" "=d")
2639 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2640 (match_operand:DI 3 "const_sint32_operand" "n"))
2642 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2643 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2646 (define_expand "muldf3"
2647 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2648 (mult:DF (match_operand:DF 1 "general_operand" "")
2649 (match_operand:DF 2 "general_operand" "")))]
2654 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2655 (mult:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2656 (match_operand:DF 1 "general_operand" "0")))]
2661 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2662 (mult:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2663 (match_operand:DF 1 "general_operand" "0")))]
2668 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2669 (mult:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2670 (match_operand:DF 1 "general_operand" "0")))]
2675 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2676 (mult:DF (match_operand:DF 1 "general_operand" "%0")
2677 (match_operand:DF 2 "general_operand" "fmG")))]
2680 if (GET_CODE (operands[2]) == CONST_DOUBLE
2681 && floating_exact_log2 (operands[2]) && !TARGET_68040 && !TARGET_68060)
2683 int i = floating_exact_log2 (operands[2]);
2684 operands[2] = GEN_INT (i);
2685 return "fscale%.l %2,%0";
2687 if (REG_P (operands[2]))
2688 return "f%&mul%.x %2,%0";
2689 return "f%&mul%.d %f2,%0";
2692 (define_expand "mulsf3"
2693 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2694 (mult:SF (match_operand:SF 1 "general_operand" "")
2695 (match_operand:SF 2 "general_operand" "")))]
2700 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2701 (mult:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2702 (match_operand:SF 1 "general_operand" "0")))]
2705 return (TARGET_68040_ONLY
2707 : "fsglmul%.l %2,%0");
2711 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2712 (mult:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2713 (match_operand:SF 1 "general_operand" "0")))]
2716 return (TARGET_68040_ONLY
2718 : "fsglmul%.w %2,%0");
2722 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2723 (mult:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2724 (match_operand:SF 1 "general_operand" "0")))]
2727 return (TARGET_68040_ONLY
2729 : "fsglmul%.b %2,%0");
2733 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2734 (mult:SF (match_operand:SF 1 "general_operand" "%0")
2735 (match_operand:SF 2 "general_operand" "fdmF")))]
2738 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2739 return (TARGET_68040_ONLY
2741 : "fsglmul%.x %2,%0");
2742 return (TARGET_68040_ONLY
2744 : "fsglmul%.s %f2,%0");
2747 ;; divide instructions
2749 (define_expand "divdf3"
2750 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2751 (div:DF (match_operand:DF 1 "general_operand" "")
2752 (match_operand:DF 2 "general_operand" "")))]
2757 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2758 (div:DF (match_operand:DF 1 "general_operand" "0")
2759 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2764 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2765 (div:DF (match_operand:DF 1 "general_operand" "0")
2766 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2771 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2772 (div:DF (match_operand:DF 1 "general_operand" "0")
2773 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2778 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2779 (div:DF (match_operand:DF 1 "general_operand" "0")
2780 (match_operand:DF 2 "general_operand" "fmG")))]
2783 if (REG_P (operands[2]))
2784 return "f%&div%.x %2,%0";
2785 return "f%&div%.d %f2,%0";
2788 (define_expand "divsf3"
2789 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2790 (div:SF (match_operand:SF 1 "general_operand" "")
2791 (match_operand:SF 2 "general_operand" "")))]
2796 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2797 (div:SF (match_operand:SF 1 "general_operand" "0")
2798 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2801 return (TARGET_68040_ONLY
2803 : "fsgldiv%.l %2,%0");
2807 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2808 (div:SF (match_operand:SF 1 "general_operand" "0")
2809 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2812 return (TARGET_68040_ONLY
2814 : "fsgldiv%.w %2,%0");
2818 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2819 (div:SF (match_operand:SF 1 "general_operand" "0")
2820 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2823 return (TARGET_68040_ONLY
2825 : "fsgldiv%.b %2,%0");
2829 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2830 (div:SF (match_operand:SF 1 "general_operand" "0")
2831 (match_operand:SF 2 "general_operand" "fdmF")))]
2834 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2835 return (TARGET_68040_ONLY
2837 : "fsgldiv%.x %2,%0");
2838 return (TARGET_68040_ONLY
2840 : "fsgldiv%.s %f2,%0");
2843 ;; Remainder instructions.
2845 (define_expand "divmodsi4"
2847 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2848 (div:SI (match_operand:SI 1 "general_operand" "")
2849 (match_operand:SI 2 "general_src_operand" "")))
2850 (set (match_operand:SI 3 "nonimmediate_operand" "")
2851 (mod:SI (match_dup 1) (match_dup 2)))])]
2852 "TARGET_68020 || TARGET_CF_HWDIV"
2856 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2857 (div:SI (match_operand:SI 1 "general_operand" "0")
2858 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2859 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2860 (mod:SI (match_dup 1) (match_dup 2)))]
2863 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2864 return "divs%.l %2,%0";
2865 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2866 return "rems%.l %2,%3:%0";
2868 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
2872 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2873 (div:SI (match_operand:SI 1 "general_operand" "0")
2874 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2875 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2876 (mod:SI (match_dup 1) (match_dup 2)))]
2879 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2880 return "divs%.l %2,%0";
2882 return "divsl%.l %2,%3:%0";
2885 (define_expand "udivmodsi4"
2887 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2888 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2889 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2890 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2891 (umod:SI (match_dup 1) (match_dup 2)))])]
2892 "TARGET_68020 || TARGET_CF_HWDIV"
2896 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2897 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2898 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2899 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2900 (umod:SI (match_dup 1) (match_dup 2)))]
2903 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2904 return "divu%.l %2,%0";
2905 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2906 return "remu%.l %2,%3:%0";
2908 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
2912 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2913 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2914 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2915 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2916 (umod:SI (match_dup 1) (match_dup 2)))]
2917 "TARGET_68020 && !TARGET_COLDFIRE"
2919 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2920 return "divu%.l %2,%0";
2922 return "divul%.l %2,%3:%0";
2925 (define_insn "divmodhi4"
2926 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2927 (div:HI (match_operand:HI 1 "general_operand" "0")
2928 (match_operand:HI 2 "general_src_operand" "dmSKT")))
2929 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
2930 (mod:HI (match_dup 1) (match_dup 2)))]
2931 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
2933 output_asm_insn (MOTOROLA ?
2934 "ext%.l %0\;divs%.w %2,%0" :
2935 "extl %0\;divs %2,%0",
2937 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
2940 return "move%.l %0,%3\;swap %3";
2946 (define_insn "udivmodhi4"
2947 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2948 (udiv:HI (match_operand:HI 1 "general_operand" "0")
2949 (match_operand:HI 2 "general_src_operand" "dmSKT")))
2950 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
2951 (umod:HI (match_dup 1) (match_dup 2)))]
2952 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
2955 output_asm_insn (MOTOROLA ?
2956 "mvz%.w %0,%0\;divu%.w %2,%0" :
2957 "mvz%.w %0,%0\;divu %2,%0",
2960 output_asm_insn (MOTOROLA ?
2961 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
2962 "and%.l #0xFFFF,%0\;divu %2,%0",
2965 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
2968 return "move%.l %0,%3\;swap %3";
2974 ;; logical-and instructions
2976 ;; "anddi3" is mainly here to help combine().
2977 (define_insn "anddi3"
2978 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
2979 (and:DI (match_operand:DI 1 "general_operand" "%0,0")
2980 (match_operand:DI 2 "general_operand" "dn,don")))]
2984 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
2985 if (CONSTANT_P (operands[2]))
2989 split_double (operands[2], &hi, &lo);
2991 switch (INTVAL (hi))
2994 output_asm_insn ("clr%.l %0", operands);
3002 xoperands[0] = operands[0];
3004 output_asm_insn (output_andsi3 (xoperands), xoperands);
3007 if (GET_CODE (operands[0]) == REG)
3008 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3010 operands[0] = adjust_address (operands[0], SImode, 4);
3011 switch (INTVAL (lo))
3014 output_asm_insn ("clr%.l %0", operands);
3022 xoperands[0] = operands[0];
3024 output_asm_insn (output_andsi3 (xoperands), xoperands);
3029 if (GET_CODE (operands[0]) != REG)
3031 operands[1] = adjust_address (operands[0], SImode, 4);
3032 return "and%.l %2,%0\;and%.l %R2,%1";
3034 if (GET_CODE (operands[2]) != REG)
3036 operands[1] = adjust_address (operands[2], SImode, 4);
3037 return "and%.l %2,%0\;and%.l %1,%R0";
3039 return "and%.l %2,%0\;and%.l %R2,%R0";
3042 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3043 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3044 ;; can't allocate pseudos into it.
3046 (define_expand "andsi3"
3047 [(set (match_operand:SI 0 "not_sp_operand" "")
3048 (and:SI (match_operand:SI 1 "general_operand" "")
3049 (match_operand:SI 2 "general_src_operand" "")))]
3053 ;; produced by split operations after reload finished
3054 (define_insn "*andsi3_split"
3055 [(set (match_operand:SI 0 "register_operand" "=d")
3056 (and:SI (match_operand:SI 1 "register_operand" "0")
3057 (match_operand:SI 2 "const_int_operand" "i")))]
3058 "reload_completed && !TARGET_COLDFIRE"
3060 return output_andsi3 (operands);
3063 (define_insn "andsi3_internal"
3064 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3065 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3066 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3069 return output_andsi3 (operands);
3072 (define_insn "andsi3_5200"
3073 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3074 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3075 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3078 if (TARGET_CFV4 && DATA_REG_P (operands[0])
3079 && GET_CODE (operands[2]) == CONST_INT)
3081 if (INTVAL (operands[2]) == 0x000000ff)
3082 return "mvz%.b %0,%0";
3083 else if (INTVAL (operands[2]) == 0x0000ffff)
3084 return "mvz%.w %0,%0";
3086 return output_andsi3 (operands);
3089 (define_insn "andhi3"
3090 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3091 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3092 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3097 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3098 (and:HI (match_dup 0)
3099 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3104 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3105 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3110 (define_insn "andqi3"
3111 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3112 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3113 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3118 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3119 (and:QI (match_dup 0)
3120 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3125 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3126 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3131 ;; inclusive-or instructions
3133 (define_insn "iordi_zext"
3134 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3135 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3136 (match_operand:DI 2 "general_operand" "0,0")))]
3142 if (GET_CODE (operands[0]) == REG)
3143 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3145 operands[0] = adjust_address (operands[0], SImode, 4);
3146 if (GET_MODE (operands[1]) == SImode)
3147 return "or%.l %1,%0";
3148 byte_mode = (GET_MODE (operands[1]) == QImode);
3149 if (GET_CODE (operands[0]) == MEM)
3150 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3153 return "or%.b %1,%0";
3155 return "or%.w %1,%0";
3158 ;; "iordi3" is mainly here to help combine().
3159 (define_insn "iordi3"
3160 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3161 (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3162 (match_operand:DI 2 "general_operand" "dn,don")))]
3166 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3167 if (CONSTANT_P (operands[2]))
3171 split_double (operands[2], &hi, &lo);
3173 switch (INTVAL (hi))
3178 /* FIXME : a scratch register would be welcome here if operand[0]
3179 is not a register */
3180 output_asm_insn ("move%.l #-1,%0", operands);
3186 xoperands[0] = operands[0];
3188 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3191 if (GET_CODE (operands[0]) == REG)
3192 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3194 operands[0] = adjust_address (operands[0], SImode, 4);
3195 switch (INTVAL (lo))
3200 /* FIXME : a scratch register would be welcome here if operand[0]
3201 is not a register */
3202 output_asm_insn ("move%.l #-1,%0", operands);
3208 xoperands[0] = operands[0];
3210 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3215 if (GET_CODE (operands[0]) != REG)
3217 operands[1] = adjust_address (operands[0], SImode, 4);
3218 return "or%.l %2,%0\;or%.l %R2,%1";
3220 if (GET_CODE (operands[2]) != REG)
3222 operands[1] = adjust_address (operands[2], SImode, 4);
3223 return "or%.l %2,%0\;or%.l %1,%R0";
3225 return "or%.l %2,%0\;or%.l %R2,%R0";
3228 (define_expand "iorsi3"
3229 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3230 (ior:SI (match_operand:SI 1 "general_operand" "")
3231 (match_operand:SI 2 "general_src_operand" "")))]
3235 (define_insn "iorsi3_internal"
3236 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3237 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3238 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3241 return output_iorsi3 (operands);
3244 (define_insn "iorsi3_5200"
3245 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3246 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3247 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3250 return output_iorsi3 (operands);
3253 (define_insn "iorhi3"
3254 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3255 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3256 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3261 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3262 (ior:HI (match_dup 0)
3263 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3268 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3269 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3274 (define_insn "iorqi3"
3275 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3276 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3277 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3282 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3283 (ior:QI (match_dup 0)
3284 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3289 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3290 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3295 ;; On all 68k models, this makes faster code in a special case.
3296 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3298 (define_insn "iorsi_zexthi_ashl16"
3299 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3300 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3301 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3306 if (GET_CODE (operands[2]) != REG)
3307 operands[2] = adjust_address (operands[2], HImode, 2);
3308 if (GET_CODE (operands[2]) != REG
3309 || REGNO (operands[2]) != REGNO (operands[0]))
3310 output_asm_insn ("move%.w %2,%0", operands);
3311 return "swap %0\;mov%.w %1,%0";
3314 (define_insn "iorsi_zext"
3315 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3316 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3317 (match_operand:SI 2 "general_operand" "0,0")))]
3323 byte_mode = (GET_MODE (operands[1]) == QImode);
3324 if (GET_CODE (operands[0]) == MEM)
3325 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3328 return "or%.b %1,%0";
3330 return "or%.w %1,%0";
3335 ;; "xordi3" is mainly here to help combine().
3336 (define_insn "xordi3"
3337 [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3338 (xor:DI (match_operand:DI 1 "general_operand" "%0")
3339 (match_operand:DI 2 "general_operand" "dn")))]
3343 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3345 if (CONSTANT_P (operands[2]))
3349 split_double (operands[2], &hi, &lo);
3351 switch (INTVAL (hi))
3356 output_asm_insn ("not%.l %0", operands);
3359 /* FIXME : a scratch register would be welcome here if
3360 -128 <= INTVAL (hi) < -1 */
3364 xoperands[0] = operands[0];
3366 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3369 if (GET_CODE (operands[0]) == REG)
3370 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3372 operands[0] = adjust_address (operands[0], SImode, 4);
3373 switch (INTVAL (lo))
3378 output_asm_insn ("not%.l %0", operands);
3381 /* FIXME : a scratch register would be welcome here if
3382 -128 <= INTVAL (lo) < -1 */
3384 /* FIXME : this should be merged with xorsi3 */
3388 xoperands[0] = operands[0];
3390 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3395 if (GET_CODE (operands[0]) != REG)
3397 operands[1] = adjust_address (operands[0], SImode, 4);
3398 return "eor%.l %2,%0\;eor%.l %R2,%1";
3400 if (GET_CODE (operands[2]) != REG)
3402 operands[1] = adjust_address (operands[2], SImode, 4);
3403 return "eor%.l %2,%0\;eor%.l %1,%R0";
3405 return "eor%.l %2,%0\;eor%.l %R2,%R0";
3408 (define_expand "xorsi3"
3409 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3410 (xor:SI (match_operand:SI 1 "general_operand" "")
3411 (match_operand:SI 2 "general_operand" "")))]
3415 (define_insn "xorsi3_internal"
3416 [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3417 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3418 (match_operand:SI 2 "general_operand" "di,dKT")))]
3422 return output_xorsi3 (operands);
3425 (define_insn "xorsi3_5200"
3426 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3427 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3428 (match_operand:SI 2 "general_operand" "d,Ks")))]
3431 return output_xorsi3 (operands);
3434 (define_insn "xorhi3"
3435 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3436 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3437 (match_operand:HI 2 "general_operand" "dn")))]
3442 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3443 (xor:HI (match_dup 0)
3444 (match_operand:HI 1 "general_operand" "dn")))]
3449 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3450 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3455 (define_insn "xorqi3"
3456 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3457 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3458 (match_operand:QI 2 "general_operand" "dn")))]
3463 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3464 (xor:QI (match_dup 0)
3465 (match_operand:QI 1 "general_operand" "dn")))]
3470 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3471 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3476 ;; negation instructions
3478 (define_expand "negdi2"
3479 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3480 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3483 if (TARGET_COLDFIRE)
3484 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3486 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3490 (define_insn "negdi2_internal"
3491 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3492 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3495 if (which_alternative == 0)
3496 return "neg%.l %0\;negx%.l %0";
3497 if (GET_CODE (operands[0]) == REG)
3498 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3500 operands[1] = adjust_address (operands[0], SImode, 4);
3501 if (ADDRESS_REG_P (operands[0]))
3502 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3504 return "neg%.l %1\;negx%.l %0";
3507 (define_insn "negdi2_5200"
3508 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3509 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3512 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3513 return "neg%.l %1\;negx%.l %0";
3516 (define_expand "negsi2"
3517 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3518 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3521 if (TARGET_COLDFIRE)
3522 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3524 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3528 (define_insn "negsi2_internal"
3529 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3530 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3534 (define_insn "negsi2_5200"
3535 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3536 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3540 (define_insn "neghi2"
3541 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3542 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3547 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3548 (neg:HI (match_dup 0)))]
3552 (define_insn "negqi2"
3553 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3554 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3559 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3560 (neg:QI (match_dup 0)))]
3564 ;; If using software floating point, just flip the sign bit.
3566 (define_expand "negsf2"
3567 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3568 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3576 target = operand_subword_force (operands[0], 0, SFmode);
3577 result = expand_binop (SImode, xor_optab,
3578 operand_subword_force (operands[1], 0, SFmode),
3579 GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
3583 if (result != target)
3584 emit_move_insn (result, target);
3586 /* Make a place for REG_EQUAL. */
3587 emit_move_insn (operands[0], operands[0]);
3593 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d")
3594 (neg:SF (match_operand:SF 1 "general_operand" "fdmF,0")))]
3597 if (DATA_REG_P (operands[0]))
3599 operands[1] = GEN_INT (31);
3600 return "bchg %1,%0";
3602 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3603 return "f%$neg%.x %1,%0";
3604 return "f%$neg%.s %f1,%0";
3607 (define_expand "negdf2"
3608 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3609 (neg:DF (match_operand:DF 1 "general_operand" "")))]
3619 target = operand_subword (operands[0], 0, 1, DFmode);
3620 result = expand_binop (SImode, xor_optab,
3621 operand_subword_force (operands[1], 0, DFmode),
3622 GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
3626 if (result != target)
3627 emit_move_insn (result, target);
3629 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3630 operand_subword_force (operands[1], 1, DFmode));
3632 insns = get_insns ();
3635 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3641 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,d")
3642 (neg:DF (match_operand:DF 1 "general_operand" "fmF,0")))]
3645 if (DATA_REG_P (operands[0]))
3647 operands[1] = GEN_INT (31);
3648 return "bchg %1,%0";
3650 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3651 return "f%&neg%.x %1,%0";
3652 return "f%&neg%.d %f1,%0";
3655 ;; Sqrt instruction for the 68881
3657 (define_insn "sqrtsf2"
3658 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3659 (sqrt:SF (match_operand:SF 1 "general_operand" "fm")))]
3662 if (FP_REG_P (operands[1]))
3663 return "f%$sqrt%.x %1,%0";
3665 return "f%$sqrt%.s %1,%0";
3668 (define_insn "sqrtdf2"
3669 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3670 (sqrt:DF (match_operand:DF 1 "general_operand" "fm")))]
3673 if (FP_REG_P (operands[1]))
3674 return "f%&sqrt%.x %1,%0";
3676 return "f%&sqrt%.d %1,%0";
3679 ;; Absolute value instructions
3680 ;; If using software floating point, just zero the sign bit.
3682 (define_expand "abssf2"
3683 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3684 (abs:SF (match_operand:SF 1 "general_operand" "")))]
3692 target = operand_subword_force (operands[0], 0, SFmode);
3693 result = expand_binop (SImode, and_optab,
3694 operand_subword_force (operands[1], 0, SFmode),
3695 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3699 if (result != target)
3700 emit_move_insn (result, target);
3702 /* Make a place for REG_EQUAL. */
3703 emit_move_insn (operands[0], operands[0]);
3709 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3710 (abs:SF (match_operand:SF 1 "general_operand" "fdmF")))]
3713 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3714 return "f%$abs%.x %1,%0";
3715 return "f%$abs%.s %f1,%0";
3718 (define_expand "absdf2"
3719 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3720 (abs:DF (match_operand:DF 1 "general_operand" "")))]
3730 target = operand_subword (operands[0], 0, 1, DFmode);
3731 result = expand_binop (SImode, and_optab,
3732 operand_subword_force (operands[1], 0, DFmode),
3733 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3737 if (result != target)
3738 emit_move_insn (result, target);
3740 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3741 operand_subword_force (operands[1], 1, DFmode));
3743 insns = get_insns ();
3746 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3752 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3753 (abs:DF (match_operand:DF 1 "general_operand" "fmF")))]
3756 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3757 return "f%&abs%.x %1,%0";
3758 return "f%&abs%.d %f1,%0";
3761 ;; one complement instructions
3763 ;; "one_cmpldi2" is mainly here to help combine().
3764 (define_insn "one_cmpldi2"
3765 [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
3766 (not:DI (match_operand:DI 1 "general_operand" "0")))]
3770 if (GET_CODE (operands[0]) == REG)
3771 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3772 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
3773 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3774 operands[1] = operands[0];
3776 operands[1] = adjust_address (operands[0], SImode, 4);
3777 return "not%.l %1\;not%.l %0";
3780 (define_expand "one_cmplsi2"
3781 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3782 (not:SI (match_operand:SI 1 "general_operand" "")))]
3785 if (TARGET_COLDFIRE)
3786 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
3788 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
3792 (define_insn "one_cmplsi2_internal"
3793 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3794 (not:SI (match_operand:SI 1 "general_operand" "0")))]
3798 (define_insn "one_cmplsi2_5200"
3799 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3800 (not:SI (match_operand:SI 1 "general_operand" "0")))]
3804 (define_insn "one_cmplhi2"
3805 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3806 (not:HI (match_operand:HI 1 "general_operand" "0")))]
3811 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3812 (not:HI (match_dup 0)))]
3816 (define_insn "one_cmplqi2"
3817 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3818 (not:QI (match_operand:QI 1 "general_operand" "0")))]
3823 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3824 (not:QI (match_dup 0)))]
3828 ;; arithmetic shift instructions
3829 ;; We don't need the shift memory by 1 bit instruction
3831 (define_insn "ashldi_extsi"
3832 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
3834 (match_operator:DI 2 "extend_operator"
3835 [(match_operand:SI 1 "general_operand" "rm")])
3840 if (GET_CODE (operands[0]) == REG)
3841 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3843 operands[2] = adjust_address (operands[0], SImode, 4);
3844 if (ADDRESS_REG_P (operands[0]))
3845 return "move%.l %1,%0\;sub%.l %2,%2";
3847 return "move%.l %1,%0\;clr%.l %2";
3850 (define_insn "ashldi_sexthi"
3851 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
3852 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
3854 (clobber (match_scratch:SI 2 "=a,X"))]
3858 if (GET_CODE (operands[0]) == MEM)
3860 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3861 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
3862 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
3863 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
3866 operands[3] = adjust_address (operands[0], SImode, 4);
3867 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
3870 else if (DATA_REG_P (operands[0]))
3871 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
3873 return "move%.w %1,%0\;sub%.l %R0,%R0";
3876 (define_insn "ashldi_const32"
3877 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
3878 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
3883 if (GET_CODE (operands[1]) == REG)
3884 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
3886 operands[3] = adjust_address (operands[1], SImode, 4);
3887 if (GET_CODE (operands[0]) == REG)
3888 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3889 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3890 return "clr%.l %0\;move%.l %3,%0";
3891 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
3892 return "move%.l %3,%0\;clr%.l %0";
3894 operands[2] = adjust_address (operands[0], SImode, 4);
3895 if (ADDRESS_REG_P (operands[2]))
3896 return "move%.l %3,%0\;sub%.l %2,%2";
3898 return "move%.l %3,%0\;clr%.l %2";
3901 ;; The predicate below must be general_operand, because ashldi3 allows that
3902 (define_insn "ashldi_const"
3903 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3904 (ashift:DI (match_operand:DI 1 "general_operand" "0")
3905 (match_operand 2 "const_int_operand" "n")))]
3907 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
3908 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
3909 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
3911 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3912 if (INTVAL (operands[2]) == 1)
3913 return "add%.l %1,%1\;addx%.l %0,%0";
3914 else if (INTVAL (operands[2]) == 8)
3915 return "rol%.l #8,%1\;rol%.l #8,%0\;move%.b %1,%0\;clr%.b %1";
3916 else if (INTVAL (operands[2]) == 16)
3917 return "swap %1\;swap %0\;move%.w %1,%0\;clr%.w %1";
3918 else if (INTVAL (operands[2]) == 48)
3919 return "mov%.l %1,%0\;swap %0\;clr%.l %1\;clr%.w %0";
3920 else if (INTVAL (operands[2]) == 2)
3921 return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
3922 else if (INTVAL (operands[2]) == 3)
3923 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";
3924 else /* 32 < INTVAL (operands[2]) <= 63 */
3926 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
3927 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asl%.l %2,%1" :
3928 "moveq %2,%0\;asl%.l %0,%1", operands);
3929 return "mov%.l %1,%0\;moveq #0,%1";
3933 (define_expand "ashldi3"
3934 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3935 (ashift:DI (match_operand:DI 1 "general_operand" "")
3936 (match_operand 2 "const_int_operand" "")))]
3940 /* ??? This is a named pattern like this is not allowed to FAIL based
3942 if (GET_CODE (operands[2]) != CONST_INT
3943 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
3944 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
3945 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
3949 ;; On most 68k models, this makes faster code in a special case.
3951 (define_insn "ashlsi_16"
3952 [(set (match_operand:SI 0 "register_operand" "=d")
3953 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3958 return "swap %0\;clr%.w %0";
3961 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
3962 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
3964 ;; On the 68000, this makes faster code in a special case.
3966 (define_insn "ashlsi_17_24"
3967 [(set (match_operand:SI 0 "register_operand" "=d")
3968 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3969 (match_operand:SI 2 "const_int_operand" "n")))]
3970 "(! TARGET_68020 && !TARGET_COLDFIRE
3971 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
3975 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
3976 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
3979 (define_insn "ashlsi3"
3980 [(set (match_operand:SI 0 "register_operand" "=d")
3981 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3982 (match_operand:SI 2 "general_operand" "dI")))]
3985 if (operands[2] == const1_rtx)
3987 cc_status.flags = CC_NO_OVERFLOW;
3988 return "add%.l %0,%0";
3990 return "lsl%.l %2,%0";
3993 (define_insn "ashlhi3"
3994 [(set (match_operand:HI 0 "register_operand" "=d")
3995 (ashift:HI (match_operand:HI 1 "register_operand" "0")
3996 (match_operand:HI 2 "general_operand" "dI")))]
4001 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4002 (ashift:HI (match_dup 0)
4003 (match_operand:HI 1 "general_operand" "dI")))]
4007 (define_insn "ashlqi3"
4008 [(set (match_operand:QI 0 "register_operand" "=d")
4009 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4010 (match_operand:QI 2 "general_operand" "dI")))]
4015 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4016 (ashift:QI (match_dup 0)
4017 (match_operand:QI 1 "general_operand" "dI")))]
4021 ;; On most 68k models, this makes faster code in a special case.
4023 (define_insn "ashrsi_16"
4024 [(set (match_operand:SI 0 "register_operand" "=d")
4025 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4028 "swap %0\;ext%.l %0")
4030 ;; On the 68000, this makes faster code in a special case.
4033 [(set (match_operand:SI 0 "register_operand" "=d")
4034 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4035 (match_operand:SI 2 "const_int_operand" "n")))]
4036 "(! TARGET_68020 && !TARGET_COLDFIRE
4037 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
4039 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4040 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4043 (define_insn "subreghi1ashrdi_const32"
4044 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4045 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4046 (const_int 32)) 6))]
4049 if (GET_CODE (operands[1]) != REG)
4050 operands[1] = adjust_address (operands[1], HImode, 2);
4051 return "move%.w %1,%0";
4054 (define_insn "subregsi1ashrdi_const32"
4055 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4056 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4057 (const_int 32)) 4))]
4060 return "move%.l %1,%0";
4063 (define_insn "ashrdi_const32"
4064 [(set (match_operand:DI 0 "register_operand" "=d")
4065 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4070 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4072 return "move%.l %1,%2\;smi %0\;extb%.l %0";
4074 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
4077 (define_insn "ashrdi_const32_mem"
4078 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,<")
4079 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro")
4081 (clobber (match_scratch:SI 2 "=d,d"))]
4085 if (which_alternative == 1)
4086 operands[3] = operands[0];
4088 operands[3] = adjust_address (operands[0], SImode, 4);
4090 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4092 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4095 ;; The predicate below must be general_operand, because ashrdi3 allows that
4096 (define_insn "ashrdi_const"
4097 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4098 (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
4099 (match_operand 2 "const_int_operand" "n")))]
4101 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4102 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4103 || INTVAL (operands[2]) == 31
4104 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4106 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4107 if (INTVAL (operands[2]) == 63)
4108 return "add%.l %0,%0\;subx%.l %0,%0\;move%.l %0,%1";
4110 if (INTVAL (operands[2]) == 1)
4111 return "asr%.l #1,%0\;roxr%.l #1,%1";
4112 else if (INTVAL (operands[2]) == 8)
4113 return "move%.b %0,%1\;asr%.l #8,%0\;ror%.l #8,%1";
4114 else if (INTVAL (operands[2]) == 16)
4115 return "move%.w %0,%1\;swap %0\;ext%.l %0\;swap %1";
4116 else if (INTVAL (operands[2]) == 48)
4117 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4118 else if (INTVAL (operands[2]) == 31)
4119 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4120 else if (INTVAL (operands[2]) == 2)
4121 return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4122 else if (INTVAL (operands[2]) == 3)
4123 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";
4124 else /* 32 < INTVAL (operands[2]) <= 63 */
4126 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4127 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4128 "moveq %2,%1\;asr%.l %1,%0", operands);
4129 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4130 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4131 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4135 (define_expand "ashrdi3"
4136 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4137 (ashiftrt:DI (match_operand:DI 1 "general_operand" "")
4138 (match_operand 2 "const_int_operand" "")))]
4142 /* ??? This is a named pattern like this is not allowed to FAIL based
4144 if (GET_CODE (operands[2]) != CONST_INT
4145 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4146 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4147 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4151 ;; On all 68k models, this makes faster code in a special case.
4153 (define_insn "ashrsi_31"
4154 [(set (match_operand:SI 0 "register_operand" "=d")
4155 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4159 return "add%.l %0,%0\;subx%.l %0,%0";
4162 (define_insn "ashrsi3"
4163 [(set (match_operand:SI 0 "register_operand" "=d")
4164 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4165 (match_operand:SI 2 "general_operand" "dI")))]
4169 (define_insn "ashrhi3"
4170 [(set (match_operand:HI 0 "register_operand" "=d")
4171 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4172 (match_operand:HI 2 "general_operand" "dI")))]
4177 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4178 (ashiftrt:HI (match_dup 0)
4179 (match_operand:HI 1 "general_operand" "dI")))]
4183 (define_insn "ashrqi3"
4184 [(set (match_operand:QI 0 "register_operand" "=d")
4185 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4186 (match_operand:QI 2 "general_operand" "dI")))]
4191 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4192 (ashiftrt:QI (match_dup 0)
4193 (match_operand:QI 1 "general_operand" "dI")))]
4197 ;; logical shift instructions
4199 ;; commented out because of reload problems in 950612-1.c
4202 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4203 ;; (const_int 32)) 4))
4204 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4205 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4206 ;; (const_int 32)) 4))]
4209 ;; return "move%.l %0,%1";
4214 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4215 ;; (const_int 32)) 0))
4216 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4217 ;; (lshiftrt:DI (match_dup 0)
4218 ;; (const_int 32)))]
4221 ;; if (GET_CODE (operands[1]) == REG)
4222 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4224 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4225 ;; return "move%.l %0,%2\;clr%.l %1";
4228 (define_insn "subreg1lshrdi_const32"
4229 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4230 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4231 (const_int 32)) 4))]
4234 return "move%.l %1,%0";
4237 (define_insn "lshrdi_const32"
4238 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro,<,>")
4239 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4244 if (which_alternative == 1)
4245 return "move%.l %1,%0\;clr%.l %0";
4246 if (which_alternative == 2)
4247 return "clr%.l %0\;move%.l %1,%0";
4248 if (GET_CODE (operands[0]) == REG)
4249 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4251 operands[2] = adjust_address (operands[0], SImode, 4);
4252 if (GET_CODE (operands[1]) == REG)
4253 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4255 operands[3] = adjust_address (operands[1], SImode, 4);
4256 if (ADDRESS_REG_P (operands[0]))
4257 return "move%.l %1,%2\;sub%.l %0,%0";
4259 return "move%.l %1,%2\;clr%.l %0";
4262 ;; The predicate below must be general_operand, because lshrdi3 allows that
4263 (define_insn "lshrdi_const"
4264 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4265 (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
4266 (match_operand 2 "const_int_operand" "n")))]
4268 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4269 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4270 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4272 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4273 if (INTVAL (operands[2]) == 63)
4274 return "add%.l %0,%0\;clr%.l %0\;clr%.l %1\;addx%.l %1,%1";
4276 if (INTVAL (operands[2]) == 1)
4277 return "lsr%.l #1,%0\;roxr%.l #1,%1";
4278 else if (INTVAL (operands[2]) == 8)
4279 return "move%.b %0,%1\;lsr%.l #8,%0\;ror%.l #8,%1";
4280 else if (INTVAL (operands[2]) == 16)
4281 return "move%.w %0,%1\;clr%.w %0\;swap %1\;swap %0";
4282 else if (INTVAL (operands[2]) == 48)
4283 return "move%.l %0,%1\;clr%.w %1\;clr%.l %0\;swap %1";
4284 else if (INTVAL (operands[2]) == 2)
4285 return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4286 else if (INTVAL (operands[2]) == 3)
4287 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";
4288 else /* 32 < INTVAL (operands[2]) <= 63 */
4290 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4291 output_asm_insn (INTVAL (operands[2]) <= 8 ? "lsr%.l %2,%0" :
4292 "moveq %2,%1\;lsr%.l %1,%0", operands);
4293 return "mov%.l %0,%1\;moveq #0,%0";
4297 (define_expand "lshrdi3"
4298 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4299 (lshiftrt:DI (match_operand:DI 1 "general_operand" "")
4300 (match_operand 2 "const_int_operand" "")))]
4303 /* ??? This is a named pattern like this is not allowed to FAIL based
4305 if (GET_CODE (operands[2]) != CONST_INT
4306 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4307 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4308 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4312 ;; On all 68k models, this makes faster code in a special case.
4314 (define_insn "lshrsi_31"
4315 [(set (match_operand:SI 0 "register_operand" "=d")
4316 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4320 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
4323 ;; On most 68k models, this makes faster code in a special case.
4325 (define_insn "lshrsi_16"
4326 [(set (match_operand:SI 0 "register_operand" "=d")
4327 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4332 return "clr%.w %0\;swap %0";
4335 ;; On the 68000, this makes faster code in a special case.
4337 (define_insn "lshrsi_17_24"
4338 [(set (match_operand:SI 0 "register_operand" "=d")
4339 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4340 (match_operand:SI 2 "const_int_operand" "n")))]
4341 "(! TARGET_68020 && !TARGET_COLDFIRE
4342 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
4344 /* I think lsr%.w sets the CC properly. */
4345 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4346 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
4349 (define_insn "lshrsi3"
4350 [(set (match_operand:SI 0 "register_operand" "=d")
4351 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4352 (match_operand:SI 2 "general_operand" "dI")))]
4356 (define_insn "lshrhi3"
4357 [(set (match_operand:HI 0 "register_operand" "=d")
4358 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
4359 (match_operand:HI 2 "general_operand" "dI")))]
4364 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4365 (lshiftrt:HI (match_dup 0)
4366 (match_operand:HI 1 "general_operand" "dI")))]
4370 (define_insn "lshrqi3"
4371 [(set (match_operand:QI 0 "register_operand" "=d")
4372 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
4373 (match_operand:QI 2 "general_operand" "dI")))]
4378 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4379 (lshiftrt:QI (match_dup 0)
4380 (match_operand:QI 1 "general_operand" "dI")))]
4384 ;; rotate instructions
4386 (define_insn "rotlsi3"
4387 [(set (match_operand:SI 0 "register_operand" "=d")
4388 (rotate:SI (match_operand:SI 1 "register_operand" "0")
4389 (match_operand:SI 2 "general_operand" "dINO")))]
4392 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
4394 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
4396 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4397 return "ror%.l %2,%0";
4400 return "rol%.l %2,%0";
4403 (define_insn "rotlhi3"
4404 [(set (match_operand:HI 0 "register_operand" "=d")
4405 (rotate:HI (match_operand:HI 1 "register_operand" "0")
4406 (match_operand:HI 2 "general_operand" "dIP")))]
4409 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4411 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4412 return "ror%.w %2,%0";
4415 return "rol%.w %2,%0";
4419 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4420 (rotate:HI (match_dup 0)
4421 (match_operand:HI 1 "general_operand" "dIP")))]
4424 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4426 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4427 return "ror%.w %2,%0";
4430 return "rol%.w %2,%0";
4433 (define_insn "rotlqi3"
4434 [(set (match_operand:QI 0 "register_operand" "=d")
4435 (rotate:QI (match_operand:QI 1 "register_operand" "0")
4436 (match_operand:QI 2 "general_operand" "dI")))]
4439 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4441 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4442 return "ror%.b %2,%0";
4445 return "rol%.b %2,%0";
4449 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4450 (rotate:QI (match_dup 0)
4451 (match_operand:QI 1 "general_operand" "dI")))]
4454 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4456 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4457 return "ror%.b %2,%0";
4460 return "rol%.b %2,%0";
4463 (define_insn "rotrsi3"
4464 [(set (match_operand:SI 0 "register_operand" "=d")
4465 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
4466 (match_operand:SI 2 "general_operand" "dI")))]
4470 (define_insn "rotrhi3"
4471 [(set (match_operand:HI 0 "register_operand" "=d")
4472 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
4473 (match_operand:HI 2 "general_operand" "dI")))]
4478 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4479 (rotatert:HI (match_dup 0)
4480 (match_operand:HI 1 "general_operand" "dI")))]
4484 (define_insn "rotrqi3"
4485 [(set (match_operand:QI 0 "register_operand" "=d")
4486 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
4487 (match_operand:QI 2 "general_operand" "dI")))]
4492 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4493 (rotatert:QI (match_dup 0)
4494 (match_operand:QI 1 "general_operand" "dI")))]
4499 ;; Bit set/clear in memory byte.
4501 ;; set bit, bit number is int
4502 (define_insn "bsetmemqi"
4503 [(set (match_operand:QI 0 "memory_operand" "+m")
4504 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4505 (match_operand:SI 1 "general_operand" "d")) 3)
4510 return "bset %1,%0";
4513 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
4515 [(set (match_operand:QI 0 "memory_operand" "+m")
4516 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4517 (match_operator:SI 2 "extend_operator"
4518 [(match_operand 1 "general_operand" "d")])) 3)
4523 return "bset %1,%0";
4526 ;; clear bit, bit number is int
4527 (define_insn "bclrmemqi"
4528 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4530 (minus:SI (const_int 7)
4531 (match_operand:SI 1 "general_operand" "d")))
4536 return "bclr %1,%0";
4539 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
4541 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4543 (minus:SI (const_int 7)
4544 (match_operator:SI 2 "extend_operator"
4545 [(match_operand 1 "general_operand" "d")])))
4550 return "bclr %1,%0";
4553 ;; Special cases of bit-field insns which we should
4554 ;; recognize in preference to the general case.
4555 ;; These handle aligned 8-bit and 16-bit fields,
4556 ;; which can usually be done with move instructions.
4559 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4560 ; alignment of structure members is specified.
4562 ; The move is allowed to be odd byte aligned, because that's still faster
4563 ; than an odd byte aligned bit-field instruction.
4566 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4568 (match_operand:SI 1 "const_int_operand" "n"))
4569 (match_operand:SI 2 "general_src_operand" "rmSi"))]
4570 "TARGET_68020 && TARGET_BITFIELD
4571 && (INTVAL (operands[1]) % 8) == 0
4572 && ! mode_dependent_address_p (XEXP (operands[0], 0))"
4575 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
4577 return "move%.l %2,%0";
4581 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
4582 (match_operand:SI 1 "const_int_operand" "n")
4583 (match_operand:SI 2 "const_int_operand" "n"))
4584 (match_operand:SI 3 "register_operand" "d"))]
4585 "TARGET_68020 && TARGET_BITFIELD
4586 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
4587 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
4588 && (GET_CODE (operands[0]) == REG
4589 || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
4591 if (REG_P (operands[0]))
4593 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
4594 return "bfins %3,%0{%b2:%b1}";
4597 operands[0] = adjust_address (operands[0],
4598 INTVAL (operands[1]) == 8 ? QImode : HImode,
4599 INTVAL (operands[2]) / 8);
4601 if (GET_CODE (operands[3]) == MEM)
4602 operands[3] = adjust_address (operands[3],
4603 INTVAL (operands[1]) == 8 ? QImode : HImode,
4604 (32 - INTVAL (operands[1])) / 8);
4606 if (INTVAL (operands[1]) == 8)
4607 return "move%.b %3,%0";
4608 return "move%.w %3,%0";
4613 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4614 ; alignment of structure members is specified.
4616 ; The move is allowed to be odd byte aligned, because that's still faster
4617 ; than an odd byte aligned bit-field instruction.
4620 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4621 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4623 (match_operand:SI 2 "const_int_operand" "n")))]
4624 "TARGET_68020 && TARGET_BITFIELD
4625 && (INTVAL (operands[2]) % 8) == 0
4626 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4629 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4631 return "move%.l %1,%0";
4635 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
4636 (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
4637 (match_operand:SI 2 "const_int_operand" "n")
4638 (match_operand:SI 3 "const_int_operand" "n")))]
4639 "TARGET_68020 && TARGET_BITFIELD
4640 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4641 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4642 && (GET_CODE (operands[1]) == REG
4643 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4645 cc_status.flags |= CC_NOT_NEGATIVE;
4646 if (REG_P (operands[1]))
4648 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4649 return "bfextu %1{%b3:%b2},%0";
4653 = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
4655 output_asm_insn ("clr%.l %0", operands);
4656 if (GET_CODE (operands[0]) == MEM)
4657 operands[0] = adjust_address (operands[0],
4658 INTVAL (operands[2]) == 8 ? QImode : HImode,
4659 (32 - INTVAL (operands[1])) / 8);
4661 if (INTVAL (operands[2]) == 8)
4662 return "move%.b %1,%0";
4663 return "move%.w %1,%0";
4667 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4668 ; alignment of structure members is specified.
4670 ; The move is allowed to be odd byte aligned, because that's still faster
4671 ; than an odd byte aligned bit-field instruction.
4674 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4675 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4677 (match_operand:SI 2 "const_int_operand" "n")))]
4678 "TARGET_68020 && TARGET_BITFIELD
4679 && (INTVAL (operands[2]) % 8) == 0
4680 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4683 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4685 return "move%.l %1,%0";
4689 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4690 (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
4691 (match_operand:SI 2 "const_int_operand" "n")
4692 (match_operand:SI 3 "const_int_operand" "n")))]
4693 "TARGET_68020 && TARGET_BITFIELD
4694 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4695 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4696 && (GET_CODE (operands[1]) == REG
4697 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4699 if (REG_P (operands[1]))
4701 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4702 return "bfexts %1{%b3:%b2},%0";
4706 = adjust_address (operands[1],
4707 INTVAL (operands[2]) == 8 ? QImode : HImode,
4708 INTVAL (operands[3]) / 8);
4710 if (INTVAL (operands[2]) == 8)
4711 return "move%.b %1,%0\;extb%.l %0";
4712 return "move%.w %1,%0\;ext%.l %0";
4715 ;; Bit-field instructions, general cases.
4716 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
4717 ;; so that its address is reloaded.
4719 (define_expand "extv"
4720 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4721 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
4722 (match_operand:SI 2 "general_operand" "")
4723 (match_operand:SI 3 "general_operand" "")))]
4724 "TARGET_68020 && TARGET_BITFIELD"
4728 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4729 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
4730 (match_operand:SI 2 "general_operand" "dn")
4731 (match_operand:SI 3 "general_operand" "dn")))]
4732 "TARGET_68020 && TARGET_BITFIELD"
4733 "bfexts %1{%b3:%b2},%0")
4735 (define_expand "extzv"
4736 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4737 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
4738 (match_operand:SI 2 "general_operand" "")
4739 (match_operand:SI 3 "general_operand" "")))]
4740 "TARGET_68020 && TARGET_BITFIELD"
4744 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d")
4745 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o,d")
4746 (match_operand:SI 2 "general_operand" "dn,dn")
4747 (match_operand:SI 3 "general_operand" "dn,dn")))]
4748 "TARGET_68020 && TARGET_BITFIELD"
4750 if (GET_CODE (operands[2]) == CONST_INT)
4752 if (INTVAL (operands[2]) != 32)
4753 cc_status.flags |= CC_NOT_NEGATIVE;
4759 return "bfextu %1{%b3:%b2},%0";
4763 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4764 (match_operand:SI 1 "general_operand" "dn")
4765 (match_operand:SI 2 "general_operand" "dn"))
4766 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
4767 (match_operand 3 "const_int_operand" "n")))]
4768 "TARGET_68020 && TARGET_BITFIELD
4769 && (INTVAL (operands[3]) == -1
4770 || (GET_CODE (operands[1]) == CONST_INT
4771 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
4774 return "bfchg %0{%b2:%b1}";
4778 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4779 (match_operand:SI 1 "general_operand" "dn")
4780 (match_operand:SI 2 "general_operand" "dn"))
4782 "TARGET_68020 && TARGET_BITFIELD"
4785 return "bfclr %0{%b2:%b1}";
4789 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4790 (match_operand:SI 1 "general_operand" "dn")
4791 (match_operand:SI 2 "general_operand" "dn"))
4793 "TARGET_68020 && TARGET_BITFIELD"
4796 return "bfset %0{%b2:%b1}";
4799 (define_expand "insv"
4800 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
4801 (match_operand:SI 1 "general_operand" "")
4802 (match_operand:SI 2 "general_operand" ""))
4803 (match_operand:SI 3 "register_operand" ""))]
4804 "TARGET_68020 && TARGET_BITFIELD"
4808 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4809 (match_operand:SI 1 "general_operand" "dn")
4810 (match_operand:SI 2 "general_operand" "dn"))
4811 (match_operand:SI 3 "register_operand" "d"))]
4812 "TARGET_68020 && TARGET_BITFIELD"
4813 "bfins %3,%0{%b2:%b1}")
4815 ;; Now recognize bit-field insns that operate on registers
4816 ;; (or at least were intended to do so).
4819 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4820 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
4821 (match_operand:SI 2 "general_operand" "dn")
4822 (match_operand:SI 3 "general_operand" "dn")))]
4823 "TARGET_68020 && TARGET_BITFIELD"
4824 "bfexts %1{%b3:%b2},%0")
4827 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4828 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
4829 (match_operand:SI 2 "general_operand" "dn")
4830 (match_operand:SI 3 "general_operand" "dn")))]
4831 "TARGET_68020 && TARGET_BITFIELD"
4833 if (GET_CODE (operands[2]) == CONST_INT)
4835 if (INTVAL (operands[2]) != 32)
4836 cc_status.flags |= CC_NOT_NEGATIVE;
4842 return "bfextu %1{%b3:%b2},%0";
4846 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4847 (match_operand:SI 1 "general_operand" "dn")
4848 (match_operand:SI 2 "general_operand" "dn"))
4850 "TARGET_68020 && TARGET_BITFIELD"
4853 return "bfclr %0{%b2:%b1}";
4857 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4858 (match_operand:SI 1 "general_operand" "dn")
4859 (match_operand:SI 2 "general_operand" "dn"))
4861 "TARGET_68020 && TARGET_BITFIELD"
4864 return "bfset %0{%b2:%b1}";
4868 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4869 (match_operand:SI 1 "general_operand" "dn")
4870 (match_operand:SI 2 "general_operand" "dn"))
4871 (match_operand:SI 3 "register_operand" "d"))]
4872 "TARGET_68020 && TARGET_BITFIELD"
4875 /* These special cases are now recognized by a specific pattern. */
4876 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
4877 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
4878 return "move%.w %3,%0";
4879 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
4880 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
4881 return "move%.b %3,%0";
4883 return "bfins %3,%0{%b2:%b1}";
4886 ;; Special patterns for optimizing bit-field instructions.
4890 (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
4891 (match_operand:SI 1 "const_int_operand" "n")
4892 (match_operand:SI 2 "general_operand" "dn")))]
4893 "TARGET_68020 && TARGET_BITFIELD"
4895 if (operands[1] == const1_rtx
4896 && GET_CODE (operands[2]) == CONST_INT)
4898 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
4899 return output_btst (operands,
4900 GEN_INT (width - INTVAL (operands[2])),
4901 operands[0], insn, 1000);
4902 /* Pass 1000 as SIGNPOS argument so that btst will
4903 not think we are testing the sign bit for an `and'
4904 and assume that nonzero implies a negative result. */
4906 if (INTVAL (operands[1]) != 32)
4907 cc_status.flags = CC_NOT_NEGATIVE;
4908 return "bftst %0{%b2:%b1}";
4912 ;;; now handle the register cases
4915 (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
4916 (match_operand:SI 1 "const_int_operand" "n")
4917 (match_operand:SI 2 "general_operand" "dn")))]
4918 "TARGET_68020 && TARGET_BITFIELD"
4920 if (operands[1] == const1_rtx
4921 && GET_CODE (operands[2]) == CONST_INT)
4923 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
4924 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
4925 operands[0], insn, 1000);
4926 /* Pass 1000 as SIGNPOS argument so that btst will
4927 not think we are testing the sign bit for an `and'
4928 and assume that nonzero implies a negative result. */
4930 if (INTVAL (operands[1]) != 32)
4931 cc_status.flags = CC_NOT_NEGATIVE;
4932 return "bftst %0{%b2:%b1}";
4935 (define_insn "scc0_di"
4936 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4937 (match_operator 1 "valid_dbcc_comparison_p"
4938 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
4941 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
4944 (define_insn "scc0_di_5200"
4945 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
4946 (match_operator 1 "valid_dbcc_comparison_p"
4947 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
4950 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
4953 (define_insn "scc_di"
4954 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
4955 (match_operator 1 "valid_dbcc_comparison_p"
4956 [(match_operand:DI 2 "general_operand" "ro,r")
4957 (match_operand:DI 3 "general_operand" "r,ro")]))]
4960 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
4963 (define_insn "scc_di_5200"
4964 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
4965 (match_operator 1 "valid_dbcc_comparison_p"
4966 [(match_operand:DI 2 "general_operand" "ro,r")
4967 (match_operand:DI 3 "general_operand" "r,ro")]))]
4970 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
4973 ;; Note that operand 0 of an SCC insn is supported in the hardware as
4974 ;; memory, but we cannot allow it to be in memory in case the address
4975 ;; needs to be reloaded.
4977 (define_expand "seq"
4978 [(set (match_operand:QI 0 "register_operand" "")
4979 (eq:QI (cc0) (const_int 0)))]
4982 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
4984 m68k_last_compare_had_fp_operands = 0;
4990 [(set (match_operand:QI 0 "register_operand" "=d")
4991 (eq:QI (cc0) (const_int 0)))]
4994 cc_status = cc_prev_status;
4995 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
4998 (define_expand "sne"
4999 [(set (match_operand:QI 0 "register_operand" "")
5000 (ne:QI (cc0) (const_int 0)))]
5003 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5005 m68k_last_compare_had_fp_operands = 0;
5011 [(set (match_operand:QI 0 "register_operand" "=d")
5012 (ne:QI (cc0) (const_int 0)))]
5015 cc_status = cc_prev_status;
5016 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5019 (define_expand "sgt"
5020 [(set (match_operand:QI 0 "register_operand" "")
5021 (gt:QI (cc0) (const_int 0)))]
5024 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5026 m68k_last_compare_had_fp_operands = 0;
5032 [(set (match_operand:QI 0 "register_operand" "=d")
5033 (gt:QI (cc0) (const_int 0)))]
5036 cc_status = cc_prev_status;
5037 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5040 (define_expand "sgtu"
5041 [(set (match_operand:QI 0 "register_operand" "")
5042 (gtu:QI (cc0) (const_int 0)))]
5047 [(set (match_operand:QI 0 "register_operand" "=d")
5048 (gtu:QI (cc0) (const_int 0)))]
5051 cc_status = cc_prev_status;
5055 (define_expand "slt"
5056 [(set (match_operand:QI 0 "register_operand" "")
5057 (lt:QI (cc0) (const_int 0)))]
5060 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5062 m68k_last_compare_had_fp_operands = 0;
5068 [(set (match_operand:QI 0 "register_operand" "=d")
5069 (lt:QI (cc0) (const_int 0)))]
5072 cc_status = cc_prev_status;
5073 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5076 (define_expand "sltu"
5077 [(set (match_operand:QI 0 "register_operand" "")
5078 (ltu:QI (cc0) (const_int 0)))]
5083 [(set (match_operand:QI 0 "register_operand" "=d")
5084 (ltu:QI (cc0) (const_int 0)))]
5087 cc_status = cc_prev_status;
5091 (define_expand "sge"
5092 [(set (match_operand:QI 0 "register_operand" "")
5093 (ge:QI (cc0) (const_int 0)))]
5096 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5098 m68k_last_compare_had_fp_operands = 0;
5104 [(set (match_operand:QI 0 "register_operand" "=d")
5105 (ge:QI (cc0) (const_int 0)))]
5108 cc_status = cc_prev_status;
5109 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5112 (define_expand "sgeu"
5113 [(set (match_operand:QI 0 "register_operand" "")
5114 (geu:QI (cc0) (const_int 0)))]
5119 [(set (match_operand:QI 0 "register_operand" "=d")
5120 (geu:QI (cc0) (const_int 0)))]
5123 cc_status = cc_prev_status;
5127 (define_expand "sle"
5128 [(set (match_operand:QI 0 "register_operand" "")
5129 (le:QI (cc0) (const_int 0)))]
5132 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5134 m68k_last_compare_had_fp_operands = 0;
5140 [(set (match_operand:QI 0 "register_operand" "=d")
5141 (le:QI (cc0) (const_int 0)))]
5144 cc_status = cc_prev_status;
5145 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5148 (define_expand "sleu"
5149 [(set (match_operand:QI 0 "register_operand" "")
5150 (leu:QI (cc0) (const_int 0)))]
5155 [(set (match_operand:QI 0 "register_operand" "=d")
5156 (leu:QI (cc0) (const_int 0)))]
5159 cc_status = cc_prev_status;
5163 (define_expand "sordered"
5164 [(set (match_operand:QI 0 "register_operand" "")
5165 (ordered:QI (cc0) (const_int 0)))]
5166 "TARGET_68881 && !TARGET_68060"
5168 if (! m68k_last_compare_had_fp_operands)
5170 m68k_last_compare_had_fp_operands = 0;
5173 (define_insn "*sordered_1"
5174 [(set (match_operand:QI 0 "register_operand" "=d")
5175 (ordered:QI (cc0) (const_int 0)))]
5176 "TARGET_68881 && !TARGET_68060"
5178 cc_status = cc_prev_status;
5182 (define_expand "sunordered"
5183 [(set (match_operand:QI 0 "register_operand" "")
5184 (unordered:QI (cc0) (const_int 0)))]
5185 "TARGET_68881 && !TARGET_68060"
5187 if (! m68k_last_compare_had_fp_operands)
5189 m68k_last_compare_had_fp_operands = 0;
5192 (define_insn "*sunordered_1"
5193 [(set (match_operand:QI 0 "register_operand" "=d")
5194 (unordered:QI (cc0) (const_int 0)))]
5195 "TARGET_68881 && !TARGET_68060"
5197 cc_status = cc_prev_status;
5201 (define_expand "suneq"
5202 [(set (match_operand:QI 0 "register_operand" "")
5203 (uneq:QI (cc0) (const_int 0)))]
5204 "TARGET_68881 && !TARGET_68060"
5206 if (! m68k_last_compare_had_fp_operands)
5208 m68k_last_compare_had_fp_operands = 0;
5211 (define_insn "*suneq_1"
5212 [(set (match_operand:QI 0 "register_operand" "=d")
5213 (uneq:QI (cc0) (const_int 0)))]
5214 "TARGET_68881 && !TARGET_68060"
5216 cc_status = cc_prev_status;
5220 (define_expand "sunge"
5221 [(set (match_operand:QI 0 "register_operand" "")
5222 (unge:QI (cc0) (const_int 0)))]
5223 "TARGET_68881 && !TARGET_68060"
5225 if (! m68k_last_compare_had_fp_operands)
5227 m68k_last_compare_had_fp_operands = 0;
5230 (define_insn "*sunge_1"
5231 [(set (match_operand:QI 0 "register_operand" "=d")
5232 (unge:QI (cc0) (const_int 0)))]
5233 "TARGET_68881 && !TARGET_68060"
5235 cc_status = cc_prev_status;
5239 (define_expand "sungt"
5240 [(set (match_operand:QI 0 "register_operand" "")
5241 (ungt:QI (cc0) (const_int 0)))]
5242 "TARGET_68881 && !TARGET_68060"
5244 if (! m68k_last_compare_had_fp_operands)
5246 m68k_last_compare_had_fp_operands = 0;
5249 (define_insn "*sungt_1"
5250 [(set (match_operand:QI 0 "register_operand" "=d")
5251 (ungt:QI (cc0) (const_int 0)))]
5252 "TARGET_68881 && !TARGET_68060"
5254 cc_status = cc_prev_status;
5258 (define_expand "sunle"
5259 [(set (match_operand:QI 0 "register_operand" "")
5260 (unle:QI (cc0) (const_int 0)))]
5261 "TARGET_68881 && !TARGET_68060"
5263 if (! m68k_last_compare_had_fp_operands)
5265 m68k_last_compare_had_fp_operands = 0;
5268 (define_insn "*sunle_1"
5269 [(set (match_operand:QI 0 "register_operand" "=d")
5270 (unle:QI (cc0) (const_int 0)))]
5271 "TARGET_68881 && !TARGET_68060"
5273 cc_status = cc_prev_status;
5277 (define_expand "sunlt"
5278 [(set (match_operand:QI 0 "register_operand" "")
5279 (unlt:QI (cc0) (const_int 0)))]
5280 "TARGET_68881 && !TARGET_68060"
5282 if (! m68k_last_compare_had_fp_operands)
5284 m68k_last_compare_had_fp_operands = 0;
5287 (define_insn "*sunlt_1"
5288 [(set (match_operand:QI 0 "register_operand" "=d")
5289 (unlt:QI (cc0) (const_int 0)))]
5290 "TARGET_68881 && !TARGET_68060"
5292 cc_status = cc_prev_status;
5296 (define_expand "sltgt"
5297 [(set (match_operand:QI 0 "register_operand" "")
5298 (ltgt:QI (cc0) (const_int 0)))]
5299 "TARGET_68881 && !TARGET_68060"
5301 if (! m68k_last_compare_had_fp_operands)
5303 m68k_last_compare_had_fp_operands = 0;
5306 (define_insn "*sltgt_1"
5307 [(set (match_operand:QI 0 "register_operand" "=d")
5308 (ltgt:QI (cc0) (const_int 0)))]
5309 "TARGET_68881 && !TARGET_68060"
5311 cc_status = cc_prev_status;
5315 (define_insn "*fsogt_1"
5316 [(set (match_operand:QI 0 "register_operand" "=d")
5317 (not:QI (unle:QI (cc0) (const_int 0))))]
5318 "TARGET_68881 && !TARGET_68060"
5320 cc_status = cc_prev_status;
5324 (define_insn "*fsoge_1"
5325 [(set (match_operand:QI 0 "register_operand" "=d")
5326 (not:QI (unlt:QI (cc0) (const_int 0))))]
5327 "TARGET_68881 && !TARGET_68060"
5329 cc_status = cc_prev_status;
5333 (define_insn "*fsolt_1"
5334 [(set (match_operand:QI 0 "register_operand" "=d")
5335 (not:QI (unge:QI (cc0) (const_int 0))))]
5336 "TARGET_68881 && !TARGET_68060"
5338 cc_status = cc_prev_status;
5342 (define_insn "*fsole_1"
5343 [(set (match_operand:QI 0 "register_operand" "=d")
5344 (not:QI (ungt:QI (cc0) (const_int 0))))]
5345 "TARGET_68881 && !TARGET_68060"
5347 cc_status = cc_prev_status;
5351 ;; Basic conditional jump instructions.
5353 (define_insn "beq0_di"
5355 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
5357 (label_ref (match_operand 1 "" ","))
5359 (clobber (match_scratch:SI 2 "=d,d"))]
5363 if (which_alternative == 1)
5366 return "move%.l %0,%2\;or%.l %0,%2\;jbeq %l1";
5368 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5370 if ((cc_prev_status.value1
5371 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5372 || (cc_prev_status.value2
5373 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5375 cc_status = cc_prev_status;
5376 return MOTOROLA ? "jbeq %l1" : "jeq %l1";
5378 if (GET_CODE (operands[0]) == REG)
5379 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5381 operands[3] = adjust_address (operands[0], SImode, 4);
5382 if (! ADDRESS_REG_P (operands[0]))
5384 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5386 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5389 return "or%.l %0,%2\;jbeq %l1";
5391 return "or%.l %0,%2\;jeq %l1";
5396 return "or%.l %3,%2\;jbeq %l1";
5398 return "or%.l %3,%2\;jeq %l1";
5402 return "move%.l %0,%2\;or%.l %3,%2\;jbeq %l1";
5404 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5406 operands[4] = gen_label_rtx();
5407 if (TARGET_68020 || TARGET_COLDFIRE)
5410 output_asm_insn ("tst%.l %0\;jbne %l4\;tst%.l %3\;jbeq %l1", operands);
5412 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
5417 output_asm_insn ("cmp%.w #0,%0\;jbne %l4\;cmp%.w #0,%3\;jbeq %l1", operands);
5419 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
5421 (*targetm.asm_out.internal_label) (asm_out_file, "L",
5422 CODE_LABEL_NUMBER (operands[4]));
5426 (define_insn "bne0_di"
5428 (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
5430 (label_ref (match_operand 1 "" ","))
5432 (clobber (match_scratch:SI 2 "=d,X"))]
5435 if ((cc_prev_status.value1
5436 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5437 || (cc_prev_status.value2
5438 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5440 cc_status = cc_prev_status;
5441 return MOTOROLA ? "jbne %l1" : "jne %l1";
5444 if (GET_CODE (operands[0]) == REG)
5445 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5447 operands[3] = adjust_address (operands[0], SImode, 4);
5448 if (!ADDRESS_REG_P (operands[0]))
5450 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5452 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5455 return "or%.l %0,%2\;jbne %l1";
5457 return "or%.l %0,%2\;jne %l1";
5462 return "or%.l %3,%2\;jbne %l1";
5464 return "or%.l %3,%2\;jne %l1";
5468 return "move%.l %0,%2\;or%.l %3,%2\;jbne %l1";
5470 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
5472 if (TARGET_68020 || TARGET_COLDFIRE)
5475 return "tst%.l %0\;jbne %l1\;tst%.l %3\;jbne %l1";
5477 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
5482 return "cmp%.w #0,%0\;jbne %l1\;cmp%.w #0,%3\;jbne %l1";
5484 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
5488 (define_insn "bge0_di"
5490 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
5492 (label_ref (match_operand 1 "" ""))
5496 if ((cc_prev_status.value1
5497 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5498 || (cc_prev_status.value2
5499 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5501 cc_status = cc_prev_status;
5502 if (cc_status.flags & CC_REVERSED)
5504 return MOTOROLA ? "jble %l1" : "jle %l1";
5508 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5512 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5513 output_asm_insn("tst%.l %0", operands);
5516 /* On an address reg, cmpw may replace cmpl. */
5517 output_asm_insn("cmp%.w #0,%0", operands);
5519 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5522 (define_insn "blt0_di"
5524 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
5526 (label_ref (match_operand 1 "" ""))
5530 if ((cc_prev_status.value1
5531 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5532 || (cc_prev_status.value2
5533 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5535 cc_status = cc_prev_status;
5536 if (cc_status.flags & CC_REVERSED)
5538 return MOTOROLA ? "jbgt %l1" : "jgt %l1";
5542 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5546 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5547 output_asm_insn("tst%.l %0", operands);
5550 /* On an address reg, cmpw may replace cmpl. */
5551 output_asm_insn("cmp%.w #0,%0", operands);
5554 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5559 (if_then_else (eq (cc0)
5561 (label_ref (match_operand 0 "" ""))
5566 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5568 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5573 (if_then_else (ne (cc0)
5575 (label_ref (match_operand 0 "" ""))
5580 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5582 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5587 (if_then_else (gt (cc0)
5589 (label_ref (match_operand 0 "" ""))
5594 OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0);
5596 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
5601 (if_then_else (gtu (cc0)
5603 (label_ref (match_operand 0 "" ""))
5607 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5612 (if_then_else (lt (cc0)
5614 (label_ref (match_operand 0 "" ""))
5619 OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0");
5621 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
5626 (if_then_else (ltu (cc0)
5628 (label_ref (match_operand 0 "" ""))
5632 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5637 (if_then_else (ge (cc0)
5639 (label_ref (match_operand 0 "" ""))
5644 OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0");
5646 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
5651 (if_then_else (geu (cc0)
5653 (label_ref (match_operand 0 "" ""))
5657 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5662 (if_then_else (le (cc0)
5664 (label_ref (match_operand 0 "" ""))
5669 OUTPUT_JUMP ("jble %l0", "fble %l0", 0);
5671 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
5676 (if_then_else (leu (cc0)
5678 (label_ref (match_operand 0 "" ""))
5682 return MOTOROLA ? "jbls %l0" : "jls %l0";
5685 (define_insn "bordered"
5687 (if_then_else (ordered (cc0) (const_int 0))
5688 (label_ref (match_operand 0 "" ""))
5692 if (!(cc_prev_status.flags & CC_IN_68881))
5694 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5697 (define_insn "bunordered"
5699 (if_then_else (unordered (cc0) (const_int 0))
5700 (label_ref (match_operand 0 "" ""))
5704 if (!(cc_prev_status.flags & CC_IN_68881))
5706 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5709 (define_insn "buneq"
5711 (if_then_else (uneq (cc0) (const_int 0))
5712 (label_ref (match_operand 0 "" ""))
5716 if (!(cc_prev_status.flags & CC_IN_68881))
5718 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5721 (define_insn "bunge"
5723 (if_then_else (unge (cc0) (const_int 0))
5724 (label_ref (match_operand 0 "" ""))
5728 if (!(cc_prev_status.flags & CC_IN_68881))
5730 return MOTOROLA ? "fbuge %l0" : "fjuge %l0";
5733 (define_insn "bungt"
5735 (if_then_else (ungt (cc0) (const_int 0))
5736 (label_ref (match_operand 0 "" ""))
5740 if (!(cc_prev_status.flags & CC_IN_68881))
5742 return MOTOROLA ? "fbugt %l0" : "fjugt %l0";
5745 (define_insn "bunle"
5747 (if_then_else (unle (cc0) (const_int 0))
5748 (label_ref (match_operand 0 "" ""))
5752 if (!(cc_prev_status.flags & CC_IN_68881))
5754 return MOTOROLA ? "fbule %l0" : "fjule %l0";
5757 (define_insn "bunlt"
5759 (if_then_else (unlt (cc0) (const_int 0))
5760 (label_ref (match_operand 0 "" ""))
5764 if (!(cc_prev_status.flags & CC_IN_68881))
5766 return MOTOROLA ? "fbult %l0" : "fjult %l0";
5769 (define_insn "bltgt"
5771 (if_then_else (ltgt (cc0) (const_int 0))
5772 (label_ref (match_operand 0 "" ""))
5776 if (!(cc_prev_status.flags & CC_IN_68881))
5778 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5781 ;; Negated conditional jump instructions.
5785 (if_then_else (eq (cc0)
5788 (label_ref (match_operand 0 "" ""))))]
5792 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5794 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5799 (if_then_else (ne (cc0)
5802 (label_ref (match_operand 0 "" ""))))]
5806 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5808 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5813 (if_then_else (gt (cc0)
5816 (label_ref (match_operand 0 "" ""))))]
5820 OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0);
5822 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
5827 (if_then_else (gtu (cc0)
5830 (label_ref (match_operand 0 "" ""))))]
5833 return MOTOROLA ? "jbls %l0" : "jls %l0";
5838 (if_then_else (lt (cc0)
5841 (label_ref (match_operand 0 "" ""))))]
5845 OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0");
5847 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
5852 (if_then_else (ltu (cc0)
5855 (label_ref (match_operand 0 "" ""))))]
5858 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5863 (if_then_else (ge (cc0)
5866 (label_ref (match_operand 0 "" ""))))]
5870 OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0");
5872 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
5877 (if_then_else (geu (cc0)
5880 (label_ref (match_operand 0 "" ""))))]
5883 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5888 (if_then_else (le (cc0)
5891 (label_ref (match_operand 0 "" ""))))]
5895 OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0);
5897 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
5902 (if_then_else (leu (cc0)
5905 (label_ref (match_operand 0 "" ""))))]
5908 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5911 (define_insn "*bordered_rev"
5913 (if_then_else (ordered (cc0) (const_int 0))
5915 (label_ref (match_operand 0 "" ""))))]
5918 if (!(cc_prev_status.flags & CC_IN_68881))
5920 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5923 (define_insn "*bunordered_rev"
5925 (if_then_else (unordered (cc0) (const_int 0))
5927 (label_ref (match_operand 0 "" ""))))]
5930 if (!(cc_prev_status.flags & CC_IN_68881))
5932 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5935 (define_insn "*buneq_rev"
5937 (if_then_else (uneq (cc0) (const_int 0))
5939 (label_ref (match_operand 0 "" ""))))]
5942 if (!(cc_prev_status.flags & CC_IN_68881))
5944 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5947 (define_insn "*bunge_rev"
5949 (if_then_else (unge (cc0) (const_int 0))
5951 (label_ref (match_operand 0 "" ""))))]
5954 if (!(cc_prev_status.flags & CC_IN_68881))
5956 return MOTOROLA ? "fbolt %l0" : "fjolt %l0";
5959 (define_insn "*bunle_rev"
5961 (if_then_else (unle (cc0) (const_int 0))
5963 (label_ref (match_operand 0 "" ""))))]
5966 if (!(cc_prev_status.flags & CC_IN_68881))
5968 return MOTOROLA ? "fbogt %l0" : "fjogt %l0";
5971 (define_insn "*bunlt_rev"
5973 (if_then_else (unlt (cc0) (const_int 0))
5975 (label_ref (match_operand 0 "" ""))))]
5978 if (!(cc_prev_status.flags & CC_IN_68881))
5980 return MOTOROLA ? "fboge %l0" : "fjoge %l0";
5983 (define_insn "*bltgt_rev"
5985 (if_then_else (ltgt (cc0) (const_int 0))
5987 (label_ref (match_operand 0 "" ""))))]
5990 if (!(cc_prev_status.flags & CC_IN_68881))
5992 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5995 ;; Unconditional and other jump instructions
5998 (label_ref (match_operand 0 "" "")))]
6001 return MOTOROLA ? "jbra %l0" : "jra %l0";
6004 (define_expand "tablejump"
6005 [(parallel [(set (pc) (match_operand 0 "" ""))
6006 (use (label_ref (match_operand 1 "" "")))])]
6009 #ifdef CASE_VECTOR_PC_RELATIVE
6010 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6011 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6015 ;; Jump to variable address from dispatch table of absolute addresses.
6017 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6018 (use (label_ref (match_operand 1 "" "")))]
6021 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6024 ;; Jump to variable address from dispatch table of relative addresses.
6028 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6029 (use (label_ref (match_operand 1 "" "")))]
6032 #ifdef ASM_RETURN_CASE_JUMP
6033 ASM_RETURN_CASE_JUMP;
6035 if (TARGET_COLDFIRE)
6037 if (ADDRESS_REG_P (operands[0]))
6038 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6040 return "ext%.l %0\;jmp (2,pc,%0.l)";
6042 return "extl %0\;jmp pc@(2,%0:l)";
6045 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6049 ;; Decrement-and-branch insns.
6053 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6055 (label_ref (match_operand 1 "" ""))
6058 (plus:HI (match_dup 0)
6063 if (DATA_REG_P (operands[0]))
6064 return "dbra %0,%l1";
6065 if (GET_CODE (operands[0]) == MEM)
6067 "subq%.w #1,%0\;jbcc %l1" :
6068 "subqw #1,%0\;jcc %l1";
6070 "subq%.w #1,%0\;cmp%.w #-1,%0\;jbne %l1" :
6071 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6077 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6079 (label_ref (match_operand 1 "" ""))
6082 (plus:SI (match_dup 0)
6087 if (DATA_REG_P (operands[0]))
6089 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6090 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6091 if (GET_CODE (operands[0]) == MEM)
6093 "subq%.l #1,%0\;jbcc %l1" :
6094 "subq%.l #1,%0\;jcc %l1";
6096 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6097 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6100 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6105 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6108 (label_ref (match_operand 1 "" ""))
6111 (plus:HI (match_dup 0)
6113 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6116 if (DATA_REG_P (operands[0]))
6117 return "dbra %0,%l1";
6118 if (GET_CODE (operands[0]) == MEM)
6120 "subq%.w #1,%0\;jbcc %l1" :
6121 "subq%.w #1,%0\;jcc %l1";
6123 "subq.w #1,%0\;cmp.w #-1,%0\;jbne %l1" :
6124 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6127 (define_expand "decrement_and_branch_until_zero"
6128 [(parallel [(set (pc)
6130 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6133 (label_ref (match_operand 1 "" ""))
6136 (plus:SI (match_dup 0)
6144 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6147 (label_ref (match_operand 1 "" ""))
6150 (plus:SI (match_dup 0)
6152 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6155 if (DATA_REG_P (operands[0]))
6157 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6158 "dbra %0,%l1\;clr%.w %0\;subql #1,%0\;jcc %l1";
6159 if (GET_CODE (operands[0]) == MEM)
6161 "subq%.l #1,%0\;jbcc %l1" :
6162 "subql #1,%0\;jcc %l1";
6164 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6165 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6169 ;; For PIC calls, in order to be able to support
6170 ;; dynamic linker LAZY BINDING, all the procedure calls need to go
6171 ;; through the PLT (Procedure Linkage Table) section in PIC mode.
6173 ;; PIC calls are handled by loading the address of the function into a
6174 ;; register (via movsi), then emitting a register indirect call using
6175 ;; the "jsr" function call syntax.
6177 ;; When outputting MIT syntax (e.g. on Suns), we add a bogus extra
6178 ;; operand to the jbsr statement to indicate that this call should
6179 ;; go through the PLT (why? because this is the way that Sun does it).
6181 ;; We have different patterns for PIC calls and non-PIC calls. The
6182 ;; different patterns are only used to choose the right syntax.
6184 ;; The svr4 m68k assembler recognizes this syntax: `bsr FUNC@PLTPC' and it
6185 ;; will create the correct relocation entry (R_68K_PLT32) for `FUNC',
6186 ;; that tells the linker editor to create an entry for `FUNC' in PLT
6187 ;; section at link time. However, all global objects reference are still
6188 ;; done by using `OBJ@GOT'. So, the goal here is to output the function
6189 ;; call operand as `FUNC@PLTPC', but output object operand as `OBJ@GOT'.
6190 ;; We need to have a way to differentiate these two different operands.
6192 ;; The strategy I use here is to use SYMBOL_REF_FLAG to differentiate
6193 ;; these two different operands. The macro LEGITIMATE_PIC_OPERAND_P needs
6194 ;; to be changed to recognize function calls symbol_ref operand as a valid
6195 ;; PIC operand (by checking whether SYMBOL_REF_FLAG is set). This will
6196 ;; avoid the compiler to load this symbol_ref operand into a register.
6197 ;; Remember, the operand "foo@PLTPC" cannot be called via jsr directly
6198 ;; since the value is a PC relative offset, not a real address.
6200 ;; All global objects are treated in the similar way as in SUN3. The only
6201 ;; difference is: on m68k svr4, the reference of such global object needs
6202 ;; to end with a suffix "@GOT" so the assembler and linker know to create
6203 ;; an entry for it in GOT (Global Offset Table) section. This is done in
6206 ;; Call subroutine with no return value.
6207 (define_expand "call"
6208 [(call (match_operand:QI 0 "memory_operand" "")
6209 (match_operand:SI 1 "general_operand" ""))]
6210 ;; Operand 1 not really used on the m68000.
6214 if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
6215 SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1;
6218 ;; This is a normal call sequence.
6220 [(call (match_operand:QI 0 "memory_operand" "o")
6221 (match_operand:SI 1 "general_operand" "g"))]
6222 ;; Operand 1 not really used on the m68000.
6226 #if MOTOROLA && !defined (USE_GAS)
6233 ;; This is a PIC call sequence.
6235 [(call (match_operand:QI 0 "memory_operand" "o")
6236 (match_operand:SI 1 "general_operand" "g"))]
6237 ;; Operand 1 not really used on the m68000.
6241 m68k_output_pic_call(operands[0]);
6245 ;; Call subroutine, returning value in operand 0
6246 ;; (which must be a hard register).
6247 ;; See comments before "call" regarding PIC calls.
6248 (define_expand "call_value"
6249 [(set (match_operand 0 "" "")
6250 (call (match_operand:QI 1 "memory_operand" "")
6251 (match_operand:SI 2 "general_operand" "")))]
6252 ;; Operand 2 not really used on the m68000.
6255 if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
6256 SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1;
6259 ;; This is a normal call_value
6261 [(set (match_operand 0 "" "=rf")
6262 (call (match_operand:QI 1 "memory_operand" "o")
6263 (match_operand:SI 2 "general_operand" "g")))]
6264 ;; Operand 2 not really used on the m68000.
6267 #if MOTOROLA && !defined (USE_GAS)
6274 ;; This is a PIC call_value
6276 [(set (match_operand 0 "" "=rf")
6277 (call (match_operand:QI 1 "memory_operand" "o")
6278 (match_operand:SI 2 "general_operand" "g")))]
6279 ;; Operand 2 not really used on the m68000.
6282 m68k_output_pic_call(operands[1]);
6286 ;; Call subroutine returning any type.
6288 (define_expand "untyped_call"
6289 [(parallel [(call (match_operand 0 "" "")
6291 (match_operand 1 "" "")
6292 (match_operand 2 "" "")])]
6293 "NEEDS_UNTYPED_CALL"
6297 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6299 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6301 rtx set = XVECEXP (operands[2], 0, i);
6302 emit_move_insn (SET_DEST (set), SET_SRC (set));
6305 /* The optimizer does not know that the call sets the function value
6306 registers we stored in the result block. We avoid problems by
6307 claiming that all hard registers are used and clobbered at this
6309 emit_insn (gen_blockage ());
6314 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6315 ;; all of memory. This blocks insns from being moved across this point.
6317 (define_insn "blockage"
6318 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6327 ;; Used for frameless functions which save no regs and allocate no locals.
6328 (define_insn "return"
6332 if (current_function_pops_args == 0)
6334 operands[0] = GEN_INT (current_function_pops_args);
6338 (define_insn "indirect_jump"
6339 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
6343 ;; This should not be used unless the add/sub insns can't be.
6346 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
6347 (match_operand:QI 1 "address_operand" "p"))]
6350 /* Recognize an insn that refers to a table of offsets. Such an insn will
6351 need to refer to a label on the insn. So output one. Use the
6352 label-number of the table of offsets to generate this label. This code,
6353 and similar code above, assumes that there will be at most one reference
6355 if (GET_CODE (operands[1]) == PLUS
6356 && GET_CODE (XEXP (operands[1], 1)) == LABEL_REF
6357 && GET_CODE (XEXP (operands[1], 0)) != PLUS)
6359 rtx labelref = XEXP (operands[1], 1);
6361 asm_fprintf (asm_out_file, "\\t.set %LLI%d,.+2\\n",
6362 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6364 (*targetm.asm_out.internal_label) (asm_out_file, "LI",
6365 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6367 return "lea %a1,%0";
6370 ;; This is the first machine-dependent peephole optimization.
6371 ;; It is useful when a floating value is returned from a function call
6372 ;; and then is moved into an FP register.
6373 ;; But it is mainly intended to test the support for these optimizations.
6376 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
6377 (set (match_operand:DF 0 "register_operand" "=f")
6378 (match_operand:DF 1 "register_operand" "ad"))]
6379 "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
6382 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6383 output_asm_insn ("move%.l %1,%@", xoperands);
6384 output_asm_insn ("move%.l %1,%-", operands);
6385 return "fmove%.d %+,%0";
6388 ;; Optimize a stack-adjust followed by a push of an argument.
6389 ;; This is said to happen frequently with -msoft-float
6390 ;; when there are consecutive library calls.
6393 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6394 (match_operand:SI 0 "const_int_operand" "n")))
6395 (set (match_operand:SF 1 "push_operand" "=m")
6396 (match_operand:SF 2 "general_operand" "rmfF"))]
6397 "INTVAL (operands[0]) >= 4
6398 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6400 if (INTVAL (operands[0]) > 4)
6403 xoperands[0] = stack_pointer_rtx;
6404 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6405 if (INTVAL (xoperands[1]) <= 8)
6407 if (!TARGET_COLDFIRE)
6408 output_asm_insn ("addq%.w %1,%0", xoperands);
6410 output_asm_insn ("addq%.l %1,%0", xoperands);
6412 else if (TARGET_CPU32 && INTVAL (xoperands[1]) <= 16)
6414 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6415 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6417 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6420 output_asm_insn ("add%.w %1,%0", xoperands);
6422 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6424 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6427 output_asm_insn ("add%.l %1,%0", xoperands);
6429 if (FP_REG_P (operands[2]))
6430 return "fmove%.s %2,%@";
6431 return "move%.l %2,%@";
6434 ;; Speed up stack adjust followed by a fullword fixedpoint push.
6437 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6438 (match_operand:SI 0 "const_int_operand" "n")))
6439 (set (match_operand:SI 1 "push_operand" "=m")
6440 (match_operand:SI 2 "general_operand" "g"))]
6441 "INTVAL (operands[0]) >= 4
6442 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6444 if (INTVAL (operands[0]) > 4)
6447 xoperands[0] = stack_pointer_rtx;
6448 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6449 if (INTVAL (xoperands[1]) <= 8)
6451 if (!TARGET_COLDFIRE)
6452 output_asm_insn ("addq%.w %1,%0", xoperands);
6454 output_asm_insn ("addq%.l %1,%0", xoperands);
6456 else if (TARGET_CPU32 && INTVAL (xoperands[1]) <= 16)
6458 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6459 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6461 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6464 output_asm_insn ("add%.w %1,%0", xoperands);
6466 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6468 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6471 output_asm_insn ("add%.l %1,%0", xoperands);
6473 if (operands[2] == const0_rtx)
6475 return "move%.l %2,%@";
6478 ;; Speed up pushing a single byte but leaving four bytes of space.
6481 [(set (mem:QI (pre_dec:SI (reg:SI SP_REG)))
6482 (match_operand:QI 1 "general_operand" "dami"))
6483 (set (reg:SI SP_REG) (minus:SI (reg:SI SP_REG) (const_int 2)))]
6484 "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
6488 if (GET_CODE (operands[1]) == REG)
6489 return "move%.l %1,%-";
6491 xoperands[1] = operands[1];
6493 = gen_rtx_MEM (QImode, plus_constant (stack_pointer_rtx, 3));
6494 xoperands[3] = stack_pointer_rtx;
6495 if (!TARGET_COLDFIRE)
6496 output_asm_insn ("subq%.w #4,%3\;move%.b %1,%2", xoperands);
6498 output_asm_insn ("subq%.l #4,%3\;move%.b %1,%2", xoperands);
6503 [(set (match_operand:SI 0 "register_operand" "=d")
6505 (set (strict_low_part (subreg:HI (match_dup 0) 2))
6506 (match_operand:HI 1 "general_operand" "rmn"))]
6507 "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
6509 if (GET_CODE (operands[1]) == CONST_INT)
6511 if (operands[1] == const0_rtx
6512 && (DATA_REG_P (operands[0])
6513 || GET_CODE (operands[0]) == MEM)
6514 /* clr insns on 68000 read before writing.
6515 This isn't so on the 68010, but we have no TARGET_68010. */
6516 && ((TARGET_68020 || TARGET_COLDFIRE)
6517 || !(GET_CODE (operands[0]) == MEM
6518 && MEM_VOLATILE_P (operands[0]))))
6521 return "move%.w %1,%0";
6529 ;; jCC label ; abnormal loop termination
6530 ;; dbra dN, loop ; normal loop termination
6538 ;; Which moves the jCC condition outside the inner loop for free.
6542 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6543 [(cc0) (const_int 0)])
6544 (label_ref (match_operand 2 "" ""))
6549 (ne (match_operand:HI 0 "register_operand" "")
6551 (label_ref (match_operand 1 "" ""))
6554 (plus:HI (match_dup 0)
6556 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6559 output_dbcc_and_branch (operands);
6564 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6565 [(cc0) (const_int 0)])
6566 (label_ref (match_operand 2 "" ""))
6571 (ne (match_operand:SI 0 "register_operand" "")
6573 (label_ref (match_operand 1 "" ""))
6576 (plus:SI (match_dup 0)
6578 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6581 output_dbcc_and_branch (operands);
6586 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6587 [(cc0) (const_int 0)])
6588 (label_ref (match_operand 2 "" ""))
6593 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
6596 (label_ref (match_operand 1 "" ""))
6599 (plus:HI (match_dup 0)
6601 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6604 output_dbcc_and_branch (operands);
6609 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6610 [(cc0) (const_int 0)])
6611 (label_ref (match_operand 2 "" ""))
6616 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
6619 (label_ref (match_operand 1 "" ""))
6622 (plus:SI (match_dup 0)
6624 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6627 output_dbcc_and_branch (operands);
6632 (define_expand "tstxf"
6634 (match_operand:XF 0 "nonimmediate_operand" ""))]
6636 "m68k_last_compare_had_fp_operands = 1;")
6640 (match_operand:XF 0 "nonimmediate_operand" "fm"))]
6643 cc_status.flags = CC_IN_68881;
6644 return "ftst%.x %0";
6647 (define_expand "cmpxf"
6649 (compare (match_operand:XF 0 "nonimmediate_operand" "")
6650 (match_operand:XF 1 "nonimmediate_operand" "")))]
6652 "m68k_last_compare_had_fp_operands = 1;")
6656 (compare (match_operand:XF 0 "nonimmediate_operand" "f,m")
6657 (match_operand:XF 1 "nonimmediate_operand" "fm,f")))]
6660 cc_status.flags = CC_IN_68881;
6661 if (REG_P (operands[0]))
6663 if (REG_P (operands[1]))
6664 return "fcmp%.x %1,%0";
6666 return "fcmp%.x %f1,%0";
6668 cc_status.flags |= CC_REVERSED;
6669 return "fcmp%.x %f0,%1";
6672 (define_insn "extendsfxf2"
6673 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6674 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
6677 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6679 if (REGNO (operands[0]) == REGNO (operands[1]))
6681 /* Extending float to double in an fp-reg is a no-op.
6682 NOTICE_UPDATE_CC has already assumed that the
6683 cc will be set. So cancel what it did. */
6684 cc_status = cc_prev_status;
6687 return "f%$move%.x %1,%0";
6689 if (FP_REG_P (operands[0]))
6691 if (FP_REG_P (operands[1]))
6692 return "f%$move%.x %1,%0";
6693 else if (ADDRESS_REG_P (operands[1]))
6694 return "move%.l %1,%-\;f%$move%.s %+,%0";
6695 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
6696 return output_move_const_single (operands);
6697 return "f%$move%.s %f1,%0";
6699 return "fmove%.x %f1,%0";
6703 (define_insn "extenddfxf2"
6704 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6706 (match_operand:DF 1 "general_operand" "f,rmE")))]
6709 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6711 if (REGNO (operands[0]) == REGNO (operands[1]))
6713 /* Extending float to double in an fp-reg is a no-op.
6714 NOTICE_UPDATE_CC has already assumed that the
6715 cc will be set. So cancel what it did. */
6716 cc_status = cc_prev_status;
6719 return "fmove%.x %1,%0";
6721 if (FP_REG_P (operands[0]))
6723 if (REG_P (operands[1]))
6726 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6727 output_asm_insn ("move%.l %1,%-", xoperands);
6728 output_asm_insn ("move%.l %1,%-", operands);
6729 return "f%&move%.d %+,%0";
6731 if (GET_CODE (operands[1]) == CONST_DOUBLE)
6732 return output_move_const_double (operands);
6733 return "f%&move%.d %f1,%0";
6735 return "fmove%.x %f1,%0";
6738 (define_insn "truncxfdf2"
6739 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
6741 (match_operand:XF 1 "general_operand" "f,f")))]
6744 if (REG_P (operands[0]))
6746 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
6747 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6748 return "move%.l %+,%0";
6750 return "fmove%.d %f1,%0";
6753 (define_insn "truncxfsf2"
6754 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
6756 (match_operand:XF 1 "general_operand" "f")))]
6760 (define_insn "floatsixf2"
6761 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6762 (float:XF (match_operand:SI 1 "general_operand" "dmi")))]
6766 (define_insn "floathixf2"
6767 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6768 (float:XF (match_operand:HI 1 "general_operand" "dmn")))]
6772 (define_insn "floatqixf2"
6773 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6774 (float:XF (match_operand:QI 1 "general_operand" "dmn")))]
6778 (define_insn "ftruncxf2"
6779 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6780 (fix:XF (match_operand:XF 1 "general_operand" "fFm")))]
6783 if (FP_REG_P (operands[1]))
6784 return "fintrz%.x %f1,%0";
6785 return "fintrz%.x %f1,%0";
6788 (define_insn "fixxfqi2"
6789 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
6790 (fix:QI (match_operand:XF 1 "general_operand" "f")))]
6794 (define_insn "fixxfhi2"
6795 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
6796 (fix:HI (match_operand:XF 1 "general_operand" "f")))]
6800 (define_insn "fixxfsi2"
6801 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
6802 (fix:SI (match_operand:XF 1 "general_operand" "f")))]
6807 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6808 (plus:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
6809 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6814 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6815 (plus:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
6816 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6821 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6822 (plus:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
6823 (match_operand:XF 1 "general_operand" "0")))]
6827 (define_insn "addxf3"
6828 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6829 (plus:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
6830 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6833 if (REG_P (operands[2]))
6834 return "fadd%.x %2,%0";
6835 return "fadd%.x %f2,%0";
6839 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6840 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6841 (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
6846 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6847 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6848 (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
6853 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6854 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6855 (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
6859 (define_insn "subxf3"
6860 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6861 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6862 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6865 if (REG_P (operands[2]))
6866 return "fsub%.x %2,%0";
6867 return "fsub%.x %f2,%0";
6871 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6872 (mult:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
6873 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6878 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6879 (mult:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
6880 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6885 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6886 (mult:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
6887 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6891 (define_insn "mulxf3"
6892 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6893 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
6894 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6897 if (REG_P (operands[2]))
6898 return "fmul%.x %2,%0";
6899 return "fmul%.x %f2,%0";
6903 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6904 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6905 (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
6910 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6911 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6912 (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
6917 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6918 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6919 (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
6923 (define_insn "divxf3"
6924 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6925 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6926 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6929 if (REG_P (operands[2]))
6930 return "fdiv%.x %2,%0";
6931 return "fdiv%.x %f2,%0";
6934 (define_expand "negxf2"
6935 [(set (match_operand:XF 0 "nonimmediate_operand" "")
6936 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
6946 target = operand_subword (operands[0], 0, 1, XFmode);
6947 result = expand_binop (SImode, xor_optab,
6948 operand_subword_force (operands[1], 0, XFmode),
6949 GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
6953 if (result != target)
6954 emit_move_insn (result, target);
6956 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
6957 operand_subword_force (operands[1], 1, XFmode));
6958 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
6959 operand_subword_force (operands[1], 2, XFmode));
6961 insns = get_insns ();
6964 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
6969 (define_insn "negxf2_68881"
6970 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6971 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
6974 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
6975 return "fneg%.x %1,%0";
6976 return "fneg%.x %f1,%0";
6979 (define_expand "absxf2"
6980 [(set (match_operand:XF 0 "nonimmediate_operand" "")
6981 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
6991 target = operand_subword (operands[0], 0, 1, XFmode);
6992 result = expand_binop (SImode, and_optab,
6993 operand_subword_force (operands[1], 0, XFmode),
6994 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
6998 if (result != target)
6999 emit_move_insn (result, target);
7001 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
7002 operand_subword_force (operands[1], 1, XFmode));
7003 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
7004 operand_subword_force (operands[1], 2, XFmode));
7006 insns = get_insns ();
7009 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
7014 (define_insn "absxf2_68881"
7015 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7016 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
7019 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
7020 return "fabs%.x %1,%0";
7021 return "fabs%.x %f1,%0";
7024 (define_insn "sqrtxf2"
7025 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7026 (sqrt:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
7030 (define_insn "sinsf2"
7031 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
7032 (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] UNSPEC_SIN))]
7033 "TARGET_68881 && flag_unsafe_math_optimizations"
7035 if (FP_REG_P (operands[1]))
7036 return "fsin%.x %1,%0";
7038 return "fsin%.s %1,%0";
7041 (define_insn "sindf2"
7042 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
7043 (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] UNSPEC_SIN))]
7044 "TARGET_68881 && flag_unsafe_math_optimizations"
7046 if (FP_REG_P (operands[1]))
7047 return "fsin%.x %1,%0";
7049 return "fsin%.d %1,%0";
7052 (define_insn "sinxf2"
7053 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7054 (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] UNSPEC_SIN))]
7055 "TARGET_68881 && flag_unsafe_math_optimizations"
7058 (define_insn "cossf2"
7059 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
7060 (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] UNSPEC_COS))]
7061 "TARGET_68881 && flag_unsafe_math_optimizations"
7063 if (FP_REG_P (operands[1]))
7064 return "fcos%.x %1,%0";
7066 return "fcos%.s %1,%0";
7069 (define_insn "cosdf2"
7070 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
7071 (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] UNSPEC_COS))]
7072 "TARGET_68881 && flag_unsafe_math_optimizations"
7074 if (FP_REG_P (operands[1]))
7075 return "fcos%.x %1,%0";
7077 return "fcos%.d %1,%0";
7080 (define_insn "cosxf2"
7081 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7082 (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] UNSPEC_COS))]
7083 "TARGET_68881 && flag_unsafe_math_optimizations"
7087 [(trap_if (const_int -1) (const_int 7))]
7091 (define_insn "conditional_trap"
7092 [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
7093 [(cc0) (const_int 0)])
7094 (match_operand:SI 1 "const_int_operand" "I"))]
7095 "TARGET_68020 && ! flags_in_68881 ()"
7097 switch (GET_CODE (operands[0]))
7099 case EQ: return "trapeq";
7100 case NE: return "trapne";
7101 case GT: return "trapgt";
7102 case GTU: return "traphi";
7103 case LT: return "traplt";
7104 case LTU: return "trapcs";
7105 case GE: return "trapge";
7106 case GEU: return "trapcc";
7107 case LE: return "traple";
7108 case LEU: return "trapls";