1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
3 ;; 2002, 2003, 2004, 2005
4 ;; Free Software Foundation, Inc.
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; GCC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
23 ;;- Information about MCF5200 port.
25 ;;- The MCF5200 "ColdFire" architecture is a reduced version of the
26 ;;- 68k ISA. Differences include reduced support for byte and word
27 ;;- operands and the removal of BCD, bitfield, rotate, and integer
28 ;;- divide instructions. The TARGET_COLDFIRE flag turns the use of the
29 ;;- removed opcodes and addressing modes off.
33 ;;- instruction definitions
35 ;;- @@The original PO technology requires these to be ordered by speed,
36 ;;- @@ so that assigner will pick the fastest.
38 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
40 ;;- When naming insn's (operand 0 of define_insn) be careful about using
41 ;;- names from other targets machine descriptions.
43 ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
44 ;;- updates for most instructions.
46 ;;- Operand classes for the register allocator:
47 ;;- 'a' one of the address registers can be used.
48 ;;- 'd' one of the data registers can be used.
49 ;;- 'f' one of the m68881 registers can be used
50 ;;- 'r' either a data or an address register can be used.
52 ;;- Immediate Floating point operator constraints
53 ;;- 'G' a floating point constant that is *NOT* one of the standard
54 ;; 68881 constant values (to force calling output_move_const_double
55 ;; to get it from rom if it is a 68881 constant).
57 ;; See the functions standard_XXX_constant_p in output-m68k.c for more
60 ;;- Immediate integer operand constraints:
62 ;;- 'J' -32768 .. 32767
63 ;;- 'K' all integers EXCEPT -128 .. 127
65 ;;- 'M' all integers EXCEPT -256 .. 255
71 ;;- "%." size separator ("." or "") move%.l d0,d1
72 ;;- "%-" push operand "sp@-" move%.l d0,%-
73 ;;- "%+" pop operand "sp@+" move%.l d0,%+
74 ;;- "%@" top of stack "sp@" move%.l d0,%@
75 ;;- "%!" fpcr register
76 ;;- "%$" single-precision fp specifier ("s" or "") f%$add.x fp0,fp1
77 ;;- "%&" double-precision fp specifier ("d" or "") f%&add.x fp0,fp1
79 ;;- Information about 68040 port.
81 ;;- The 68040 executes all 68030 and 68881/2 instructions, but some must
82 ;;- be emulated in software by the OS. It is faster to avoid these
83 ;;- instructions and issue a library call rather than trapping into
84 ;;- the kernel. The affected instructions are fintrz and fscale. The
85 ;;- TARGET_68040 flag turns the use of the opcodes off.
87 ;;- The '040 also implements a set of new floating-point instructions
88 ;;- which specify the rounding precision in the opcode. This finally
89 ;;- permit the 68k series to be truly IEEE compliant, and solves all
90 ;;- issues of excess precision accumulating in the extended registers.
91 ;;- By default, GCC does not use these instructions, since such code will
92 ;;- not run on an '030. To use these instructions, use the -m68040-only
93 ;;- switch. By changing TARGET_DEFAULT to include TARGET_68040_ONLY,
94 ;;- you can make these instructions the default.
96 ;;- These new instructions aren't directly in the md. They are brought
97 ;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather
100 ;;- Information about 68060 port.
102 ;;- The 68060 executes all 68030 and 68881/2 instructions, but some must
103 ;;- be emulated in software by the OS. It is faster to avoid these
104 ;;- instructions and issue a library call rather than trapping into
105 ;;- the kernel. The affected instructions are: divs.l <ea>,Dr:Dq;
106 ;;- divu.l <ea>,Dr:Dq; muls.l <ea>,Dr:Dq; mulu.l <ea>,Dr:Dq; and
107 ;;- fscale. The TARGET_68060 flag turns the use of the opcodes off.
109 ;;- Some of these insn's are composites of several m68000 op codes.
110 ;;- The assembler (or final @@??) insures that the appropriate one is
120 ;; UNSPEC_VOLATILE usage:
123 [(UNSPECV_BLOCKAGE 0)
126 ;; Registers by name.
132 (include "predicates.md")
135 [(set (match_operand:DF 0 "push_operand" "=m")
136 (match_operand:DF 1 "general_operand" "ro<>fyE"))]
139 if (FP_REG_P (operands[1]))
140 return "fmove%.d %f1,%0";
141 return output_move_double (operands);
144 (define_insn "pushdi"
145 [(set (match_operand:DI 0 "push_operand" "=m")
146 (match_operand:DI 1 "general_operand" "ro<>Fyi"))]
149 return output_move_double (operands);
152 ;; We don't want to allow a constant operand for test insns because
153 ;; (set (cc0) (const_int foo)) has no mode information. Such insns will
154 ;; be folded while optimizing anyway.
156 (define_expand "tstdi"
157 [(parallel [(set (cc0)
158 (match_operand:DI 0 "nonimmediate_operand" ""))
159 (clobber (match_scratch:SI 1 ""))
160 (clobber (match_scratch:DI 2 ""))])]
162 "m68k_last_compare_had_fp_operands = 0;")
166 (match_operand:DI 0 "nonimmediate_operand" "am,d"))
167 (clobber (match_scratch:SI 1 "=X,d"))
168 (clobber (match_scratch:DI 2 "=d,X"))]
171 if (which_alternative == 0)
175 xoperands[0] = operands[2];
176 xoperands[1] = operands[0];
177 output_move_double (xoperands);
178 cc_status.flags |= CC_REVERSED;
179 return "neg%.l %R2\;negx%.l %2";
181 if (find_reg_note (insn, REG_DEAD, operands[0]))
183 cc_status.flags |= CC_REVERSED;
184 return "neg%.l %R0\;negx%.l %0";
188 'sub' clears %1, and also clears the X cc bit
189 'tst' sets the Z cc bit according to the low part of the DImode operand
190 'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part.
192 return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
195 (define_expand "tstsi"
197 (match_operand:SI 0 "nonimmediate_operand" ""))]
199 "m68k_last_compare_had_fp_operands = 0;")
203 (match_operand:SI 0 "nonimmediate_operand" "rm"))]
206 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
208 /* If you think that the 68020 does not support tstl a0,
209 reread page B-167 of the 68020 manual more carefully. */
210 /* On an address reg, cmpw may replace cmpl. */
211 return "cmp%.w #0,%0";
214 ;; This can't use an address register, because comparisons
215 ;; with address registers as second operand always test the whole word.
216 (define_expand "tsthi"
218 (match_operand:HI 0 "nonimmediate_operand" ""))]
220 "m68k_last_compare_had_fp_operands = 0;")
224 (match_operand:HI 0 "nonimmediate_operand" "dm"))]
228 (define_expand "tstqi"
230 (match_operand:QI 0 "nonimmediate_operand" ""))]
232 "m68k_last_compare_had_fp_operands = 0;")
236 (match_operand:QI 0 "nonimmediate_operand" "dm"))]
240 (define_expand "tstsf"
242 (match_operand:SF 0 "general_operand" ""))]
245 m68k_last_compare_had_fp_operands = 1;
250 (match_operand:SF 0 "general_operand" "fdm"))]
253 cc_status.flags = CC_IN_68881;
254 if (FP_REG_P (operands[0]))
259 (define_expand "tstdf"
261 (match_operand:DF 0 "general_operand" ""))]
264 m68k_last_compare_had_fp_operands = 1;
269 (match_operand:DF 0 "general_operand" "fm"))]
272 cc_status.flags = CC_IN_68881;
273 if (FP_REG_P (operands[0]))
278 ;; compare instructions.
280 (define_expand "cmpdi"
283 (compare (match_operand:DI 0 "nonimmediate_operand" "")
284 (match_operand:DI 1 "general_operand" "")))
285 (clobber (match_dup 2))])]
287 "m68k_last_compare_had_fp_operands = 0; operands[2] = gen_reg_rtx (DImode);")
291 (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
292 (match_operand:DI 2 "general_operand" "d,0")))
293 (clobber (match_operand:DI 0 "register_operand" "=d,d"))]
296 if (rtx_equal_p (operands[0], operands[1]))
297 return "sub%.l %R2,%R0\;subx%.l %2,%0";
300 cc_status.flags |= CC_REVERSED;
301 return "sub%.l %R1,%R0\;subx%.l %1,%0";
305 ;; This is the second "hook" for PIC code (in addition to movsi). See
306 ;; comment of movsi for a description of PIC handling.
307 (define_expand "cmpsi"
309 (compare (match_operand:SI 0 "nonimmediate_operand" "")
310 (match_operand:SI 1 "general_operand" "")))]
313 m68k_last_compare_had_fp_operands = 0;
314 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
316 /* The source is an address which requires PIC relocation.
317 Call legitimize_pic_address with the source, mode, and a relocation
318 register (a new pseudo, or the final destination if reload_in_progress
319 is set). Then fall through normally */
320 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
321 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
325 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
328 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
329 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
332 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
333 return "cmpm%.l %1,%0";
334 if (REG_P (operands[1])
335 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
337 cc_status.flags |= CC_REVERSED;
338 return "cmp%.l %d0,%d1";
340 if (ADDRESS_REG_P (operands[0])
341 && GET_CODE (operands[1]) == CONST_INT
342 && INTVAL (operands[1]) < 0x8000
343 && INTVAL (operands[1]) >= -0x8000)
344 return "cmp%.w %1,%0";
345 return "cmp%.l %d1,%d0";
350 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
351 (match_operand:SI 1 "general_operand" "r,mrKs")))]
354 if (REG_P (operands[1])
355 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
357 cc_status.flags |= CC_REVERSED;
358 return "cmp%.l %d0,%d1";
360 return "cmp%.l %d1,%d0";
363 (define_expand "cmphi"
365 (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
366 (match_operand:HI 1 "general_src_operand" "")))]
368 "m68k_last_compare_had_fp_operands = 0;")
372 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
373 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
376 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
377 return "cmpm%.w %1,%0";
378 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
379 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
381 cc_status.flags |= CC_REVERSED;
382 return "cmp%.w %d0,%d1";
384 return "cmp%.w %d1,%d0";
387 (define_expand "cmpqi"
389 (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
390 (match_operand:QI 1 "general_src_operand" "")))]
392 "m68k_last_compare_had_fp_operands = 0;")
396 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
397 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
400 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
401 return "cmpm%.b %1,%0";
402 if (REG_P (operands[1])
403 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
405 cc_status.flags |= CC_REVERSED;
406 return "cmp%.b %d0,%d1";
408 return "cmp%.b %d1,%d0";
411 (define_expand "cmpdf"
413 (compare (match_operand:DF 0 "general_operand" "")
414 (match_operand:DF 1 "general_operand" "")))]
417 m68k_last_compare_had_fp_operands = 1;
422 (compare (match_operand:DF 0 "general_operand" "f,mG")
423 (match_operand:DF 1 "general_operand" "fmG,f")))]
426 cc_status.flags = CC_IN_68881;
427 if (REG_P (operands[0]))
429 if (REG_P (operands[1]))
430 return "fcmp%.x %1,%0";
432 return "fcmp%.d %f1,%0";
434 cc_status.flags |= CC_REVERSED;
435 return "fcmp%.d %f0,%1";
438 (define_expand "cmpsf"
440 (compare (match_operand:SF 0 "general_operand" "")
441 (match_operand:SF 1 "general_operand" "")))]
444 m68k_last_compare_had_fp_operands = 1;
449 (compare (match_operand:SF 0 "general_operand" "f,mdG")
450 (match_operand:SF 1 "general_operand" "fmdG,f")))]
453 cc_status.flags = CC_IN_68881;
454 if (FP_REG_P (operands[0]))
456 if (FP_REG_P (operands[1]))
457 return "fcmp%.x %1,%0";
459 return "fcmp%.s %f1,%0";
461 cc_status.flags |= CC_REVERSED;
462 return "fcmp%.s %f0,%1";
465 ;; Recognizers for btst instructions.
467 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
468 ;; specified as a constant, so we must disable all patterns that may extract
469 ;; from a MEM at a constant bit position if we can't use this as a constraint.
472 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
474 (minus:SI (const_int 7)
475 (match_operand:SI 1 "general_operand" "di"))))]
478 return output_btst (operands, operands[1], operands[0], insn, 7);
481 ;; This is the same as the above pattern except for the constraints. The 'i'
485 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
487 (minus:SI (const_int 7)
488 (match_operand:SI 1 "general_operand" "d"))))]
491 return output_btst (operands, operands[1], operands[0], insn, 7);
495 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
497 (minus:SI (const_int 31)
498 (match_operand:SI 1 "general_operand" "di"))))]
501 return output_btst (operands, operands[1], operands[0], insn, 31);
504 ;; The following two patterns are like the previous two
505 ;; except that they use the fact that bit-number operands
506 ;; are automatically masked to 3 or 5 bits.
509 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
511 (minus:SI (const_int 7)
513 (match_operand:SI 1 "register_operand" "d")
517 return output_btst (operands, operands[1], operands[0], insn, 7);
521 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
523 (minus:SI (const_int 31)
525 (match_operand:SI 1 "register_operand" "d")
529 return output_btst (operands, operands[1], operands[0], insn, 31);
532 ;; Nonoffsettable mem refs are ok in this one pattern
533 ;; since we don't try to adjust them.
535 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
537 (match_operand:SI 1 "const_int_operand" "n")))]
538 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
540 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
541 return output_btst (operands, operands[1], operands[0], insn, 7);
545 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
547 (match_operand:SI 1 "const_int_operand" "n")))]
550 if (GET_CODE (operands[0]) == MEM)
552 operands[0] = adjust_address (operands[0], QImode,
553 INTVAL (operands[1]) / 8);
554 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
555 return output_btst (operands, operands[1], operands[0], insn, 7);
557 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
558 return output_btst (operands, operands[1], operands[0], insn, 31);
561 ;; This is the same as the above pattern except for the constraints.
562 ;; The 'o' has been replaced with 'Q'.
565 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
567 (match_operand:SI 1 "const_int_operand" "n")))]
570 if (GET_CODE (operands[0]) == MEM)
572 operands[0] = adjust_address (operands[0], QImode,
573 INTVAL (operands[1]) / 8);
574 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
575 return output_btst (operands, operands[1], operands[0], insn, 7);
577 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
578 return output_btst (operands, operands[1], operands[0], insn, 31);
584 ;; A special case in which it is not desirable
585 ;; to reload the constant into a data register.
586 (define_insn "pushexthisi_const"
587 [(set (match_operand:SI 0 "push_operand" "=m")
588 (match_operand:SI 1 "const_int_operand" "J"))]
589 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
591 if (operands[1] == const0_rtx)
593 if (valid_mov3q_const(operands[1]))
594 return "mov3q%.l %1,%-";
599 ;(define_insn "swapsi"
600 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
601 ; (match_operand:SI 1 "general_operand" "+r"))
602 ; (set (match_dup 1) (match_dup 0))]
606 ;; Special case of fullword move when source is zero.
607 ;; The reason this is special is to avoid loading a zero
608 ;; into a data reg with moveq in order to store it elsewhere.
610 (define_insn "movsi_const0"
611 [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
613 ;; clr insns on 68000 read before writing.
614 ;; This isn't so on the 68010, but we have no TARGET_68010.
615 "((TARGET_68020 || TARGET_COLDFIRE)
616 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
618 if (ADDRESS_REG_P (operands[0]))
620 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
621 if (!TARGET_68040 && !TARGET_68060)
622 return "sub%.l %0,%0";
624 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
626 /* moveq is faster on the 68000. */
627 if (DATA_REG_P (operands[0]) && (!TARGET_68020 && !TARGET_COLDFIRE))
628 return "moveq #0,%0";
632 ;; General case of fullword move.
634 ;; This is the main "hook" for PIC code. When generating
635 ;; PIC, movsi is responsible for determining when the source address
636 ;; needs PIC relocation and appropriately calling legitimize_pic_address
637 ;; to perform the actual relocation.
639 ;; In both the PIC and non-PIC cases the patterns generated will
640 ;; matched by the next define_insn.
641 (define_expand "movsi"
642 [(set (match_operand:SI 0 "nonimmediate_operand" "")
643 (match_operand:SI 1 "general_operand" ""))]
646 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
648 /* The source is an address which requires PIC relocation.
649 Call legitimize_pic_address with the source, mode, and a relocation
650 register (a new pseudo, or the final destination if reload_in_progress
651 is set). Then fall through normally */
652 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
653 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
655 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
657 /* Don't allow writes to memory except via a register;
658 the m68k doesn't consider PC-relative addresses to be writable. */
659 if (symbolic_operand (operands[0], SImode))
660 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
661 else if (GET_CODE (operands[0]) == MEM
662 && symbolic_operand (XEXP (operands[0], 0), SImode))
663 operands[0] = gen_rtx_MEM (SImode,
664 force_reg (SImode, XEXP (operands[0], 0)));
668 ;; General case of fullword move. The register constraints
669 ;; force integer constants in range for a moveq to be reloaded
670 ;; if they are headed for memory.
672 ;; Notes: make sure no alternative allows g vs g.
673 ;; We don't allow f-regs since fixed point cannot go in them.
674 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
675 (match_operand:SI 1 "general_src_operand" "daymSKT,n,i"))]
679 return output_move_simode (operands);
682 (define_insn "*movsi_cf"
683 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
684 (match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
685 "TARGET_COLDFIRE && !TARGET_CFV4"
686 "* return output_move_simode (operands);")
688 (define_insn "*movsi_cfv4"
689 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
690 (match_operand:SI 1 "general_operand" "Rg,Rr<Q>,U"))]
692 "* return output_move_simode (operands);")
694 ;; Special case of fullword move, where we need to get a non-GOT PIC
695 ;; reference into an address register.
697 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
698 (match_operand:SI 1 "pcrel_address" ""))]
701 if (push_operand (operands[0], SImode))
706 (define_expand "movhi"
707 [(set (match_operand:HI 0 "nonimmediate_operand" "")
708 (match_operand:HI 1 "general_operand" ""))]
713 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
714 (match_operand:HI 1 "general_src_operand" "gS"))]
716 "* return output_move_himode (operands);")
719 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
720 (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
722 "* return output_move_himode (operands);")
724 (define_expand "movstricthi"
725 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
726 (match_operand:HI 1 "general_src_operand" ""))]
731 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
732 (match_operand:HI 1 "general_src_operand" "rmSn"))]
734 "* return output_move_stricthi (operands);")
737 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
738 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
740 "* return output_move_stricthi (operands);")
742 (define_expand "movqi"
743 [(set (match_operand:QI 0 "nonimmediate_operand" "")
744 (match_operand:QI 1 "general_src_operand" ""))]
749 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
750 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
752 "* return output_move_qimode (operands);")
755 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
756 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
758 "* return output_move_qimode (operands);")
760 (define_expand "movstrictqi"
761 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
762 (match_operand:QI 1 "general_src_operand" ""))]
767 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
768 (match_operand:QI 1 "general_src_operand" "dmSn"))]
770 "* return output_move_strictqi (operands);")
773 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d,m"))
774 (match_operand:QI 1 "general_src_operand" "dmn,d"))]
776 "* return output_move_strictqi (operands);")
778 (define_expand "pushqi1"
779 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
780 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
781 (match_operand:QI 0 "general_operand" ""))]
785 (define_expand "movsf"
786 [(set (match_operand:SF 0 "nonimmediate_operand" "")
787 (match_operand:SF 1 "general_operand" ""))]
792 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
793 (match_operand:SF 1 "general_operand" "rmfF"))]
796 if (FP_REG_P (operands[0]))
798 if (FP_REG_P (operands[1]))
799 return "f%$move%.x %1,%0";
800 else if (ADDRESS_REG_P (operands[1]))
801 return "move%.l %1,%-\;f%$move%.s %+,%0";
802 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
803 return output_move_const_single (operands);
804 return "f%$move%.s %f1,%0";
806 if (FP_REG_P (operands[1]))
808 if (ADDRESS_REG_P (operands[0]))
809 return "fmove%.s %1,%-\;move%.l %+,%0";
810 return "fmove%.s %f1,%0";
812 if (operands[1] == CONST0_RTX (SFmode)
813 /* clr insns on 68000 read before writing.
814 This isn't so on the 68010, but we have no TARGET_68010. */
815 && ((TARGET_68020 || TARGET_COLDFIRE)
816 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
818 if (ADDRESS_REG_P (operands[0]))
820 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
821 if (!TARGET_68040 && !TARGET_68060)
822 return "sub%.l %0,%0";
824 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
826 /* moveq is faster on the 68000. */
827 if (DATA_REG_P (operands[0]) && !(TARGET_68020 || TARGET_COLDFIRE))
829 return "moveq #0,%0";
833 return "move%.l %1,%0";
837 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,g")
838 (match_operand:SF 1 "general_operand" "g,r"))]
841 return "move%.l %1,%0";
844 (define_expand "movdf"
845 [(set (match_operand:DF 0 "nonimmediate_operand" "")
846 (match_operand:DF 1 "general_operand" ""))]
851 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
852 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
853 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
854 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
857 if (FP_REG_P (operands[0]))
859 if (FP_REG_P (operands[1]))
860 return "f%&move%.x %1,%0";
861 if (REG_P (operands[1]))
864 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
865 output_asm_insn ("move%.l %1,%-", xoperands);
866 output_asm_insn ("move%.l %1,%-", operands);
867 return "f%&move%.d %+,%0";
869 if (GET_CODE (operands[1]) == CONST_DOUBLE)
870 return output_move_const_double (operands);
871 return "f%&move%.d %f1,%0";
873 else if (FP_REG_P (operands[1]))
875 if (REG_P (operands[0]))
877 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
878 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
879 return "move%.l %+,%0";
882 return "fmove%.d %f1,%0";
884 return output_move_double (operands);
888 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
889 (match_operand:DF 1 "general_operand" "g,r"))]
892 return output_move_double (operands);
895 ;; ??? The XFmode patterns are schizophrenic about whether constants are
896 ;; allowed. Most but not all have predicates and constraint that disallow
897 ;; constants. Most but not all have output templates that handle constants.
898 ;; See also LEGITIMATE_CONSTANT_P.
900 (define_expand "movxf"
901 [(set (match_operand:XF 0 "nonimmediate_operand" "")
902 (match_operand:XF 1 "general_operand" ""))]
905 /* We can't rewrite operands during reload. */
906 if (! reload_in_progress)
908 if (CONSTANT_P (operands[1]))
910 operands[1] = force_const_mem (XFmode, operands[1]);
911 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
912 operands[1] = adjust_address (operands[1], XFmode, 0);
914 if (flag_pic && TARGET_PCREL)
916 /* Don't allow writes to memory except via a register; the
917 m68k doesn't consider PC-relative addresses to be writable. */
918 if (GET_CODE (operands[0]) == MEM
919 && symbolic_operand (XEXP (operands[0], 0), SImode))
920 operands[0] = gen_rtx_MEM (XFmode,
921 force_reg (SImode, XEXP (operands[0], 0)));
927 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r")
928 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r"))]
931 if (FP_REG_P (operands[0]))
933 if (FP_REG_P (operands[1]))
934 return "fmove%.x %1,%0";
935 if (REG_P (operands[1]))
938 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
939 output_asm_insn ("move%.l %1,%-", xoperands);
940 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
941 output_asm_insn ("move%.l %1,%-", xoperands);
942 output_asm_insn ("move%.l %1,%-", operands);
943 return "fmove%.x %+,%0";
945 if (GET_CODE (operands[1]) == CONST_DOUBLE)
946 return "fmove%.x %1,%0";
947 return "fmove%.x %f1,%0";
949 if (FP_REG_P (operands[1]))
951 if (REG_P (operands[0]))
953 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
954 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
955 output_asm_insn ("move%.l %+,%0", operands);
956 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
957 return "move%.l %+,%0";
959 /* Must be memory destination. */
960 return "fmove%.x %f1,%0";
962 return output_move_double (operands);
966 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
967 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
968 "! TARGET_68881 && ! TARGET_COLDFIRE"
970 if (FP_REG_P (operands[0]))
972 if (FP_REG_P (operands[1]))
973 return "fmove%.x %1,%0";
974 if (REG_P (operands[1]))
977 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
978 output_asm_insn ("move%.l %1,%-", xoperands);
979 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
980 output_asm_insn ("move%.l %1,%-", xoperands);
981 output_asm_insn ("move%.l %1,%-", operands);
982 return "fmove%.x %+,%0";
984 if (GET_CODE (operands[1]) == CONST_DOUBLE)
985 return "fmove%.x %1,%0";
986 return "fmove%.x %f1,%0";
988 if (FP_REG_P (operands[1]))
990 if (REG_P (operands[0]))
992 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
993 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
994 output_asm_insn ("move%.l %+,%0", operands);
995 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
996 return "move%.l %+,%0";
999 return "fmove%.x %f1,%0";
1001 return output_move_double (operands);
1005 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1006 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1007 "! TARGET_68881 && TARGET_COLDFIRE"
1008 "* return output_move_double (operands);")
1010 (define_expand "movdi"
1011 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1012 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1013 (match_operand:DI 1 "general_operand" ""))]
1017 ;; movdi can apply to fp regs in some cases
1019 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1020 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1021 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1022 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1023 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1024 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1025 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1028 if (FP_REG_P (operands[0]))
1030 if (FP_REG_P (operands[1]))
1031 return "fmove%.x %1,%0";
1032 if (REG_P (operands[1]))
1035 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1036 output_asm_insn ("move%.l %1,%-", xoperands);
1037 output_asm_insn ("move%.l %1,%-", operands);
1038 return "fmove%.d %+,%0";
1040 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1041 return output_move_const_double (operands);
1042 return "fmove%.d %f1,%0";
1044 else if (FP_REG_P (operands[1]))
1046 if (REG_P (operands[0]))
1048 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1049 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1050 return "move%.l %+,%0";
1053 return "fmove%.d %f1,%0";
1055 return output_move_double (operands);
1059 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1060 (match_operand:DI 1 "general_operand" "g,r"))]
1062 "* return output_move_double (operands);")
1064 ;; Thus goes after the move instructions
1065 ;; because the move instructions are better (require no spilling)
1066 ;; when they can apply. It goes before the add/sub insns
1067 ;; so we will prefer it to them.
1069 (define_insn "pushasi"
1070 [(set (match_operand:SI 0 "push_operand" "=m")
1071 (match_operand:SI 1 "address_operand" "p"))]
1075 ;; truncation instructions
1076 (define_insn "truncsiqi2"
1077 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1079 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1082 if (GET_CODE (operands[0]) == REG)
1084 /* Must clear condition codes, since the move.l bases them on
1085 the entire 32 bits, not just the desired 8 bits. */
1087 return "move%.l %1,%0";
1089 if (GET_CODE (operands[1]) == MEM)
1090 operands[1] = adjust_address (operands[1], QImode, 3);
1091 return "move%.b %1,%0";
1094 (define_insn "trunchiqi2"
1095 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1097 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1100 if (GET_CODE (operands[0]) == REG
1101 && (GET_CODE (operands[1]) == MEM
1102 || GET_CODE (operands[1]) == CONST_INT))
1104 /* Must clear condition codes, since the move.w bases them on
1105 the entire 16 bits, not just the desired 8 bits. */
1107 return "move%.w %1,%0";
1109 if (GET_CODE (operands[0]) == REG)
1111 /* Must clear condition codes, since the move.l bases them on
1112 the entire 32 bits, not just the desired 8 bits. */
1114 return "move%.l %1,%0";
1116 if (GET_CODE (operands[1]) == MEM)
1117 operands[1] = adjust_address (operands[1], QImode, 1);
1118 return "move%.b %1,%0";
1121 (define_insn "truncsihi2"
1122 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1124 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1127 if (GET_CODE (operands[0]) == REG)
1129 /* Must clear condition codes, since the move.l bases them on
1130 the entire 32 bits, not just the desired 8 bits. */
1132 return "move%.l %1,%0";
1134 if (GET_CODE (operands[1]) == MEM)
1135 operands[1] = adjust_address (operands[1], QImode, 2);
1136 return "move%.w %1,%0";
1139 ;; zero extension instructions
1141 ;; two special patterns to match various post_inc/pre_dec patterns
1142 (define_insn_and_split "*zero_extend_inc"
1143 [(set (match_operand 0 "post_inc_operand" "")
1144 (zero_extend (match_operand 1 "register_operand" "")))]
1145 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1146 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1147 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1155 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1158 (define_insn_and_split "*zero_extend_dec"
1159 [(set (match_operand 0 "pre_dec_operand" "")
1160 (zero_extend (match_operand 1 "register_operand" "")))]
1161 "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1162 GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1163 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1164 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1172 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1175 (define_insn_and_split "zero_extendqidi2"
1176 [(set (match_operand:DI 0 "register_operand" "")
1177 (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1182 (zero_extend:SI (match_dup 1)))
1186 operands[2] = gen_lowpart (SImode, operands[0]);
1187 operands[3] = gen_highpart (SImode, operands[0]);
1190 (define_insn_and_split "zero_extendhidi2"
1191 [(set (match_operand:DI 0 "register_operand" "")
1192 (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1197 (zero_extend:SI (match_dup 1)))
1201 operands[2] = gen_lowpart (SImode, operands[0]);
1202 operands[3] = gen_highpart (SImode, operands[0]);
1205 (define_expand "zero_extendsidi2"
1206 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1207 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1210 if (GET_CODE (operands[0]) == MEM
1211 && GET_CODE (operands[1]) == MEM)
1212 operands[1] = force_reg (SImode, operands[1]);
1215 (define_insn_and_split "*zero_extendsidi2"
1216 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1217 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1218 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1226 operands[2] = gen_lowpart (SImode, operands[0]);
1227 operands[3] = gen_highpart (SImode, operands[0]);
1230 (define_insn "*zero_extendhisi2_cf"
1231 [(set (match_operand:SI 0 "register_operand" "=d")
1232 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1236 (define_insn "zero_extendhisi2"
1237 [(set (match_operand:SI 0 "register_operand" "=d")
1238 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1242 (define_expand "zero_extendqihi2"
1243 [(set (match_operand:HI 0 "register_operand" "")
1244 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1248 (define_insn "*zero_extendqihi2"
1249 [(set (match_operand:HI 0 "register_operand" "=d")
1250 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1254 (define_insn "*zero_extendqisi2_cfv4"
1255 [(set (match_operand:SI 0 "register_operand" "=d")
1256 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1260 (define_insn "zero_extendqisi2"
1261 [(set (match_operand:SI 0 "register_operand" "=d")
1262 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1266 ;; these two pattern split everything else which isn't matched by
1267 ;; something else above
1269 [(set (match_operand 0 "register_operand" "")
1270 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1271 "!TARGET_CFV4 && reload_completed && reg_mentioned_p (operands[0], operands[1])"
1272 [(set (strict_low_part (match_dup 2))
1275 (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1277 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1278 operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1279 operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1283 [(set (match_operand 0 "register_operand" "")
1284 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1285 "!TARGET_CFV4 && reload_completed"
1288 (set (strict_low_part (match_dup 2))
1291 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1294 ;; sign extension instructions
1296 (define_insn "extendqidi2"
1297 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1298 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1302 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1304 return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1305 if (TARGET_68020 || TARGET_COLDFIRE)
1307 if (ADDRESS_REG_P (operands[1]))
1308 return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1310 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1314 if (ADDRESS_REG_P (operands[1]))
1315 return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1317 return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1321 (define_insn "extendhidi2"
1322 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1324 (match_operand:HI 1 "general_src_operand" "rmS")))]
1328 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1330 return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1331 if (TARGET_68020 || TARGET_COLDFIRE)
1332 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1334 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1337 (define_insn "extendsidi2"
1338 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1340 (match_operand:SI 1 "general_operand" "rm")))]
1344 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1345 if (TARGET_68020 || TARGET_COLDFIRE)
1346 return "move%.l %1,%2\;smi %0\;extb%.l %0";
1348 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
1351 ;; Special case when one can avoid register clobbering, copy and test
1352 ;; Maybe there is a way to make that the general case, by forcing the
1353 ;; result of the SI tree to be in the lower register of the DI target
1355 (define_insn "extendplussidi"
1356 [(set (match_operand:DI 0 "register_operand" "=d")
1357 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1358 (match_operand:SI 2 "general_operand" "rmn"))))]
1362 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1363 if (GET_CODE (operands[1]) == CONST_INT
1364 && (unsigned) INTVAL (operands[1]) > 8)
1366 rtx tmp = operands[1];
1368 operands[1] = operands[2];
1371 if (GET_CODE (operands[1]) == REG
1372 && REGNO (operands[1]) == REGNO (operands[3]))
1373 output_asm_insn ("add%.l %2,%3", operands);
1375 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1376 if (TARGET_68020 || TARGET_COLDFIRE)
1377 return "smi %0\;extb%.l %0";
1379 return "smi %0\;ext%.w %0\;ext%.l %0";
1382 (define_expand "extendhisi2"
1383 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1385 (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1389 (define_insn "*cfv4_extendhisi2"
1390 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1392 (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1396 (define_insn "*68k_extendhisi2"
1397 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1399 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1402 if (ADDRESS_REG_P (operands[0]))
1403 return "move%.w %1,%0";
1407 (define_insn "extendqihi2"
1408 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1409 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1413 (define_expand "extendqisi2"
1414 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1415 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1416 "TARGET_68020 || TARGET_COLDFIRE"
1419 (define_insn "*cfv4_extendqisi2"
1420 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1421 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1425 (define_insn "*68k_extendqisi2"
1426 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1427 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1428 "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_CFV4)"
1431 ;; Conversions between float and double.
1433 (define_expand "extendsfdf2"
1434 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1436 (match_operand:SF 1 "general_operand" "")))]
1441 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1443 (match_operand:SF 1 "general_operand" "f,dmF")))]
1446 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1448 if (REGNO (operands[0]) == REGNO (operands[1]))
1450 /* Extending float to double in an fp-reg is a no-op.
1451 NOTICE_UPDATE_CC has already assumed that the
1452 cc will be set. So cancel what it did. */
1453 cc_status = cc_prev_status;
1456 return "f%&move%.x %1,%0";
1458 if (FP_REG_P (operands[0]))
1459 return "f%&move%.s %f1,%0";
1460 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1462 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1463 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1464 return "move%.l %+,%0";
1466 return "fmove%.d %f1,%0";
1469 ;; This cannot output into an f-reg because there is no way to be
1470 ;; sure of truncating in that case.
1471 (define_expand "truncdfsf2"
1472 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1474 (match_operand:DF 1 "general_operand" "")))]
1478 ;; On the '040 we can truncate in a register accurately and easily.
1480 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1482 (match_operand:DF 1 "general_operand" "fmG")))]
1483 "TARGET_68881 && TARGET_68040_ONLY"
1485 if (FP_REG_P (operands[1]))
1486 return "f%$move%.x %1,%0";
1487 return "f%$move%.d %f1,%0";
1491 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1493 (match_operand:DF 1 "general_operand" "f")))]
1497 ;; Conversion between fixed point and floating point.
1498 ;; Note that among the fix-to-float insns
1499 ;; the ones that start with SImode come first.
1500 ;; That is so that an operand that is a CONST_INT
1501 ;; (and therefore lacks a specific machine mode).
1502 ;; will be recognized as SImode (which is always valid)
1503 ;; rather than as QImode or HImode.
1505 (define_expand "floatsisf2"
1506 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1507 (float:SF (match_operand:SI 1 "general_operand" "")))]
1512 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1513 (float:SF (match_operand:SI 1 "general_operand" "dmi")))]
1517 (define_expand "floatsidf2"
1518 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1519 (float:DF (match_operand:SI 1 "general_operand" "")))]
1524 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1525 (float:DF (match_operand:SI 1 "general_operand" "dmi")))]
1529 (define_insn "floathisf2"
1530 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1531 (float:SF (match_operand:HI 1 "general_operand" "dmn")))]
1535 (define_insn "floathidf2"
1536 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1537 (float:DF (match_operand:HI 1 "general_operand" "dmn")))]
1541 (define_insn "floatqisf2"
1542 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1543 (float:SF (match_operand:QI 1 "general_operand" "dmn")))]
1547 (define_insn "floatqidf2"
1548 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1549 (float:DF (match_operand:QI 1 "general_operand" "dmn")))]
1553 ;; New routines to convert floating-point values to integers
1554 ;; to be used on the '040. These should be faster than trapping
1555 ;; into the kernel to emulate fintrz. They should also be faster
1556 ;; than calling the subroutines fixsfsi or fixdfsi.
1558 (define_insn "fix_truncdfsi2"
1559 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1560 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1561 (clobber (match_scratch:SI 2 "=d"))
1562 (clobber (match_scratch:SI 3 "=d"))]
1563 "TARGET_68881 && TARGET_68040"
1566 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,%!";
1569 (define_insn "fix_truncdfhi2"
1570 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1571 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1572 (clobber (match_scratch:SI 2 "=d"))
1573 (clobber (match_scratch:SI 3 "=d"))]
1574 "TARGET_68881 && TARGET_68040"
1577 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,%!";
1580 (define_insn "fix_truncdfqi2"
1581 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1582 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1583 (clobber (match_scratch:SI 2 "=d"))
1584 (clobber (match_scratch:SI 3 "=d"))]
1585 "TARGET_68881 && TARGET_68040"
1588 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,%!";
1591 ;; Convert a float to a float whose value is an integer.
1592 ;; This is the first stage of converting it to an integer type.
1594 (define_insn "ftruncdf2"
1595 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1596 (fix:DF (match_operand:DF 1 "general_operand" "fFm")))]
1597 "TARGET_68881 && !TARGET_68040"
1599 if (FP_REG_P (operands[1]))
1600 return "fintrz%.x %f1,%0";
1601 return "fintrz%.d %f1,%0";
1604 (define_insn "ftruncsf2"
1605 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1606 (fix:SF (match_operand:SF 1 "general_operand" "dfFm")))]
1607 "TARGET_68881 && !TARGET_68040"
1609 if (FP_REG_P (operands[1]))
1610 return "fintrz%.x %f1,%0";
1611 return "fintrz%.s %f1,%0";
1614 ;; Convert a float whose value is an integer
1615 ;; to an actual integer. Second stage of converting float to integer type.
1616 (define_insn "fixsfqi2"
1617 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1618 (fix:QI (match_operand:SF 1 "general_operand" "f")))]
1622 (define_insn "fixsfhi2"
1623 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1624 (fix:HI (match_operand:SF 1 "general_operand" "f")))]
1628 (define_insn "fixsfsi2"
1629 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1630 (fix:SI (match_operand:SF 1 "general_operand" "f")))]
1634 (define_insn "fixdfqi2"
1635 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1636 (fix:QI (match_operand:DF 1 "general_operand" "f")))]
1640 (define_insn "fixdfhi2"
1641 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1642 (fix:HI (match_operand:DF 1 "general_operand" "f")))]
1646 (define_insn "fixdfsi2"
1647 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1648 (fix:SI (match_operand:DF 1 "general_operand" "f")))]
1654 (define_insn "adddi_lshrdi_63"
1655 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1656 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
1659 (clobber (match_scratch:SI 2 "=d"))]
1662 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1663 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
1665 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
1666 if (GET_CODE (operands[1]) == REG)
1667 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1668 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
1669 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1670 operands[4] = operands[1];
1672 operands[4] = adjust_address (operands[1], SImode, 4);
1673 if (GET_CODE (operands[1]) == MEM
1674 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1675 output_asm_insn ("move%.l %4,%3", operands);
1676 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
1677 if (TARGET_68020 || TARGET_COLDFIRE)
1678 output_asm_insn ("extb%.l %2", operands);
1680 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
1681 if (GET_CODE (operands[1]) != MEM
1682 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
1683 output_asm_insn ("move%.l %4,%3", operands);
1684 return "sub%.l %2,%3\;subx%.l %2,%0";
1687 (define_insn "adddi_sexthishl32"
1688 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
1689 (plus:DI (ashift:DI (sign_extend:DI
1690 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
1692 (match_operand:DI 2 "general_operand" "0,0,0,0")))
1693 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
1697 if (ADDRESS_REG_P (operands[0]))
1698 return "add%.w %1,%0";
1699 else if (ADDRESS_REG_P (operands[3]))
1700 return "move%.w %1,%3\;add%.l %3,%0";
1702 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
1705 (define_insn "adddi_dilshr32"
1706 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
1707 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1708 ;; (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
1709 ;; (const_int 32))))]
1710 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
1712 (match_operand:DI 2 "general_operand" "0,0")))]
1716 if (GET_CODE (operands[0]) == REG)
1717 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1719 operands[2] = adjust_address (operands[0], SImode, 4);
1720 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
1723 (define_insn "adddi_dishl32"
1724 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
1725 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1726 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
1727 ;; (const_int 32))))]
1728 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
1730 (match_operand:DI 2 "general_operand" "0,0")))]
1734 if (GET_CODE (operands[1]) == REG)
1735 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1737 operands[1] = adjust_address (operands[1], SImode, 4);
1738 return "add%.l %1,%0";
1741 (define_insn "adddi3"
1742 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
1743 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0,0")
1744 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
1745 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
1748 if (DATA_REG_P (operands[0]))
1750 if (DATA_REG_P (operands[2]))
1751 return "add%.l %R2,%R0\;addx%.l %2,%0";
1752 else if (GET_CODE (operands[2]) == MEM
1753 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
1754 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
1760 if (GET_CODE (operands[2]) == REG)
1762 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
1765 else if (CONSTANT_P (operands[2]))
1766 split_double (operands[2], &high, &low);
1769 low = adjust_address (operands[2], SImode, 4);
1773 operands[1] = low, operands[2] = high;
1774 xoperands[0] = operands[3];
1775 if (GET_CODE (operands[1]) == CONST_INT
1776 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1777 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
1779 xoperands[1] = operands[2];
1781 output_asm_insn (output_move_simode (xoperands), xoperands);
1782 if (GET_CODE (operands[1]) == CONST_INT)
1784 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
1785 return "addq%.l %1,%R0\;addx%.l %3,%0";
1786 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1788 operands[1] = GEN_INT (-INTVAL (operands[1]));
1789 return "subq%.l %1,%R0\;subx%.l %3,%0";
1792 return "add%.l %1,%R0\;addx%.l %3,%0";
1797 gcc_assert (GET_CODE (operands[0]) == MEM);
1798 if (GET_CODE (operands[2]) == MEM
1799 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
1800 return "add%.l %2,%0\;addx%.l %2,%0";
1802 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1804 operands[1] = gen_rtx_MEM (SImode,
1805 plus_constant (XEXP(operands[0], 0), -8));
1806 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
1808 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1810 operands[1] = XEXP(operands[0], 0);
1811 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
1815 operands[1] = adjust_address (operands[0], SImode, 4);
1816 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
1821 (define_insn "addsi_lshrsi_31"
1822 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1823 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
1828 operands[2] = operands[0];
1829 operands[3] = gen_label_rtx();
1830 if (GET_CODE (operands[0]) == MEM)
1832 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1833 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
1834 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1835 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
1837 output_asm_insn ("move%.l %1,%0", operands);
1838 output_asm_insn (MOTOROLA ? "jbpl %l3" : "jpl %l3", operands);
1839 output_asm_insn ("addq%.l #1,%2", operands);
1840 (*targetm.asm_out.internal_label) (asm_out_file, "L",
1841 CODE_LABEL_NUMBER (operands[3]));
1845 (define_expand "addsi3"
1846 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1847 (plus:SI (match_operand:SI 1 "general_operand" "")
1848 (match_operand:SI 2 "general_src_operand" "")))]
1852 ;; Note that the middle two alternatives are near-duplicates
1853 ;; in order to handle insns generated by reload.
1854 ;; This is needed since they are not themselves reloaded,
1855 ;; so commutativity won't apply to them.
1856 (define_insn "*addsi3_internal"
1857 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
1858 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
1859 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
1863 "* return output_addsi3 (operands);")
1865 (define_insn "*addsi3_5200"
1866 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
1867 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
1868 (match_operand:SI 2 "general_src_operand" "d,rJK,a,mrIKLi")))]
1870 "* return output_addsi3 (operands);")
1873 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
1874 (plus:SI (match_operand:SI 1 "general_operand" "0")
1876 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
1880 (define_insn "addhi3"
1881 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
1882 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
1883 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
1886 if (GET_CODE (operands[2]) == CONST_INT)
1888 /* If the constant would be a negative number when interpreted as
1889 HImode, make it negative. This is usually, but not always, done
1890 elsewhere in the compiler. First check for constants out of range,
1891 which could confuse us. */
1893 if (INTVAL (operands[2]) >= 32768)
1894 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
1896 if (INTVAL (operands[2]) > 0
1897 && INTVAL (operands[2]) <= 8)
1898 return "addq%.w %2,%0";
1899 if (INTVAL (operands[2]) < 0
1900 && INTVAL (operands[2]) >= -8)
1902 operands[2] = GEN_INT (- INTVAL (operands[2]));
1903 return "subq%.w %2,%0";
1905 /* On the CPU32 it is faster to use two addqw instructions to
1906 add a small integer (8 < N <= 16) to a register.
1907 Likewise for subqw. */
1908 if (TARGET_CPU32 && REG_P (operands[0]))
1910 if (INTVAL (operands[2]) > 8
1911 && INTVAL (operands[2]) <= 16)
1913 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
1914 return "addq%.w #8,%0\;addq%.w %2,%0";
1916 if (INTVAL (operands[2]) < -8
1917 && INTVAL (operands[2]) >= -16)
1919 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
1920 return "subq%.w #8,%0\;subq%.w %2,%0";
1923 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
1924 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
1926 return "add%.w %2,%0";
1929 ;; These insns must use MATCH_DUP instead of the more expected
1930 ;; use of a matching constraint because the "output" here is also
1931 ;; an input, so you can't use the matching constraint. That also means
1932 ;; that you can't use the "%", so you need patterns with the matched
1933 ;; operand in both positions.
1936 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
1937 (plus:HI (match_dup 0)
1938 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
1941 if (GET_CODE (operands[1]) == CONST_INT)
1943 /* If the constant would be a negative number when interpreted as
1944 HImode, make it negative. This is usually, but not always, done
1945 elsewhere in the compiler. First check for constants out of range,
1946 which could confuse us. */
1948 if (INTVAL (operands[1]) >= 32768)
1949 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
1951 if (INTVAL (operands[1]) > 0
1952 && INTVAL (operands[1]) <= 8)
1953 return "addq%.w %1,%0";
1954 if (INTVAL (operands[1]) < 0
1955 && INTVAL (operands[1]) >= -8)
1957 operands[1] = GEN_INT (- INTVAL (operands[1]));
1958 return "subq%.w %1,%0";
1960 /* On the CPU32 it is faster to use two addqw instructions to
1961 add a small integer (8 < N <= 16) to a register.
1962 Likewise for subqw. */
1963 if (TARGET_CPU32 && REG_P (operands[0]))
1965 if (INTVAL (operands[1]) > 8
1966 && INTVAL (operands[1]) <= 16)
1968 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
1969 return "addq%.w #8,%0\;addq%.w %1,%0";
1971 if (INTVAL (operands[1]) < -8
1972 && INTVAL (operands[1]) >= -16)
1974 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
1975 return "subq%.w #8,%0\;subq%.w %1,%0";
1978 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
1979 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
1981 return "add%.w %1,%0";
1985 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
1986 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
1990 if (GET_CODE (operands[1]) == CONST_INT)
1992 /* If the constant would be a negative number when interpreted as
1993 HImode, make it negative. This is usually, but not always, done
1994 elsewhere in the compiler. First check for constants out of range,
1995 which could confuse us. */
1997 if (INTVAL (operands[1]) >= 32768)
1998 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2000 if (INTVAL (operands[1]) > 0
2001 && INTVAL (operands[1]) <= 8)
2002 return "addq%.w %1,%0";
2003 if (INTVAL (operands[1]) < 0
2004 && INTVAL (operands[1]) >= -8)
2006 operands[1] = GEN_INT (- INTVAL (operands[1]));
2007 return "subq%.w %1,%0";
2009 /* On the CPU32 it is faster to use two addqw instructions to
2010 add a small integer (8 < N <= 16) to a register.
2011 Likewise for subqw. */
2012 if (TARGET_CPU32 && REG_P (operands[0]))
2014 if (INTVAL (operands[1]) > 8
2015 && INTVAL (operands[1]) <= 16)
2017 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2018 return "addq%.w #8,%0\;addq%.w %1,%0";
2020 if (INTVAL (operands[1]) < -8
2021 && INTVAL (operands[1]) >= -16)
2023 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2024 return "subq%.w #8,%0\;subq%.w %1,%0";
2027 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2028 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2030 return "add%.w %1,%0";
2033 (define_insn "addqi3"
2034 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2035 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2036 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2039 if (GET_CODE (operands[2]) == CONST_INT)
2041 if (INTVAL (operands[2]) >= 128)
2042 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2044 if (INTVAL (operands[2]) > 0
2045 && INTVAL (operands[2]) <= 8)
2046 return "addq%.b %2,%0";
2047 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2049 operands[2] = GEN_INT (- INTVAL (operands[2]));
2050 return "subq%.b %2,%0";
2053 return "add%.b %2,%0";
2057 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2058 (plus:QI (match_dup 0)
2059 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2062 if (GET_CODE (operands[1]) == CONST_INT)
2064 if (INTVAL (operands[1]) >= 128)
2065 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2067 if (INTVAL (operands[1]) > 0
2068 && INTVAL (operands[1]) <= 8)
2069 return "addq%.b %1,%0";
2070 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2072 operands[1] = GEN_INT (- INTVAL (operands[1]));
2073 return "subq%.b %1,%0";
2076 return "add%.b %1,%0";
2080 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2081 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2085 if (GET_CODE (operands[1]) == CONST_INT)
2087 if (INTVAL (operands[1]) >= 128)
2088 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2090 if (INTVAL (operands[1]) > 0
2091 && INTVAL (operands[1]) <= 8)
2092 return "addq%.b %1,%0";
2093 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2095 operands[1] = GEN_INT (- INTVAL (operands[1]));
2096 return "subq%.b %1,%0";
2099 return "add%.b %1,%0";
2102 (define_expand "adddf3"
2103 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2104 (plus:DF (match_operand:DF 1 "general_operand" "")
2105 (match_operand:DF 2 "general_operand" "")))]
2110 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2111 (plus:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2112 (match_operand:DF 1 "general_operand" "0")))]
2117 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2118 (plus:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2119 (match_operand:DF 1 "general_operand" "0")))]
2124 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2125 (plus:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2126 (match_operand:DF 1 "general_operand" "0")))]
2131 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2132 (plus:DF (match_operand:DF 1 "general_operand" "%0")
2133 (match_operand:DF 2 "general_operand" "fmG")))]
2136 if (REG_P (operands[2]))
2137 return "f%&add%.x %2,%0";
2138 return "f%&add%.d %f2,%0";
2141 (define_expand "addsf3"
2142 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2143 (plus:SF (match_operand:SF 1 "general_operand" "")
2144 (match_operand:SF 2 "general_operand" "")))]
2149 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2150 (plus:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2151 (match_operand:SF 1 "general_operand" "0")))]
2156 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2157 (plus:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2158 (match_operand:SF 1 "general_operand" "0")))]
2163 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2164 (plus:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2165 (match_operand:SF 1 "general_operand" "0")))]
2170 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2171 (plus:SF (match_operand:SF 1 "general_operand" "%0")
2172 (match_operand:SF 2 "general_operand" "fdmF")))]
2175 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2176 return "f%$add%.x %2,%0";
2177 return "f%$add%.s %f2,%0";
2180 ;; subtract instructions
2182 (define_insn "subdi_sexthishl32"
2183 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2184 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2185 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2187 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2191 if (ADDRESS_REG_P (operands[0]))
2192 return "sub%.w %2,%0";
2193 else if (ADDRESS_REG_P (operands[3]))
2194 return "move%.w %2,%3\;sub%.l %3,%0";
2196 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2199 (define_insn "subdi_dishl32"
2200 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2201 (minus:DI (match_dup 0)
2202 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2207 if (GET_CODE (operands[1]) == REG)
2208 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2210 operands[1] = adjust_address (operands[1], SImode, 4);
2211 return "sub%.l %1,%0";
2214 (define_insn "subdi3"
2215 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
2216 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0,0")
2217 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
2218 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
2221 if (DATA_REG_P (operands[0]))
2223 if (DATA_REG_P (operands[2]))
2224 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2225 else if (GET_CODE (operands[2]) == MEM
2226 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2228 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2235 if (GET_CODE (operands[2]) == REG)
2237 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2240 else if (CONSTANT_P (operands[2]))
2241 split_double (operands[2], &high, &low);
2244 low = adjust_address (operands[2], SImode, 4);
2248 operands[1] = low, operands[2] = high;
2249 xoperands[0] = operands[3];
2250 if (GET_CODE (operands[1]) == CONST_INT
2251 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2252 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2254 xoperands[1] = operands[2];
2256 output_asm_insn (output_move_simode (xoperands), xoperands);
2257 if (GET_CODE (operands[1]) == CONST_INT)
2259 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2260 return "subq%.l %1,%R0\;subx%.l %3,%0";
2261 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2263 operands[1] = GEN_INT (-INTVAL (operands[1]));
2264 return "addq%.l %1,%R0\;addx%.l %3,%0";
2267 return "sub%.l %1,%R0\;subx%.l %3,%0";
2272 gcc_assert (GET_CODE (operands[0]) == MEM);
2273 if (GET_CODE (operands[2]) == MEM
2274 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
2275 return "sub%.l %2,%0\;subx%.l %2,%0";
2277 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2280 = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2281 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2283 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2285 operands[1] = XEXP(operands[0], 0);
2286 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2290 operands[1] = adjust_address (operands[0], SImode, 4);
2291 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2296 (define_insn "subsi3"
2297 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2298 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2299 (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2304 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2305 (minus:SI (match_operand:SI 1 "general_operand" "0")
2307 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2311 (define_insn "subhi3"
2312 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2313 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2314 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2319 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2320 (minus:HI (match_dup 0)
2321 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2325 (define_insn "subqi3"
2326 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2327 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2328 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2333 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2334 (minus:QI (match_dup 0)
2335 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2339 (define_expand "subdf3"
2340 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2341 (minus:DF (match_operand:DF 1 "general_operand" "")
2342 (match_operand:DF 2 "general_operand" "")))]
2347 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2348 (minus:DF (match_operand:DF 1 "general_operand" "0")
2349 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2354 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2355 (minus:DF (match_operand:DF 1 "general_operand" "0")
2356 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2361 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2362 (minus:DF (match_operand:DF 1 "general_operand" "0")
2363 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2368 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2369 (minus:DF (match_operand:DF 1 "general_operand" "0")
2370 (match_operand:DF 2 "general_operand" "fmG")))]
2373 if (REG_P (operands[2]))
2374 return "f%&sub%.x %2,%0";
2375 return "f%&sub%.d %f2,%0";
2378 (define_expand "subsf3"
2379 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2380 (minus:SF (match_operand:SF 1 "general_operand" "")
2381 (match_operand:SF 2 "general_operand" "")))]
2386 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2387 (minus:SF (match_operand:SF 1 "general_operand" "0")
2388 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2393 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2394 (minus:SF (match_operand:SF 1 "general_operand" "0")
2395 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2400 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2401 (minus:SF (match_operand:SF 1 "general_operand" "0")
2402 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2407 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2408 (minus:SF (match_operand:SF 1 "general_operand" "0")
2409 (match_operand:SF 2 "general_operand" "fdmF")))]
2412 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2413 return "f%$sub%.x %2,%0";
2414 return "f%$sub%.s %f2,%0";
2417 ;; multiply instructions
2419 (define_insn "mulhi3"
2420 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2421 (mult:HI (match_operand:HI 1 "general_operand" "%0")
2422 (match_operand:HI 2 "general_src_operand" "dmSn")))]
2425 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2428 (define_insn "mulhisi3"
2429 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2430 (mult:SI (sign_extend:SI
2431 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2433 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2436 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2440 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2441 (mult:SI (sign_extend:SI
2442 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2443 (match_operand:SI 2 "const_int_operand" "n")))]
2444 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2446 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2449 (define_expand "mulsi3"
2450 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2451 (mult:SI (match_operand:SI 1 "general_operand" "")
2452 (match_operand:SI 2 "general_operand" "")))]
2453 "TARGET_68020 || TARGET_COLDFIRE"
2457 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2458 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2459 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2465 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2466 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2467 (match_operand:SI 2 "general_operand" "d<Q>")))]
2471 (define_insn "umulhisi3"
2472 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2473 (mult:SI (zero_extend:SI
2474 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2476 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2479 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2483 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2484 (mult:SI (zero_extend:SI
2485 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2486 (match_operand:SI 2 "const_int_operand" "n")))]
2487 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2489 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2492 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2493 ;; proper matching constraint. This is because the matching is between
2494 ;; the high-numbered word of the DImode operand[0] and operand[1].
2496 ;; Note: life_analysis() does not keep track of the individual halves of the
2497 ;; DImode register. To prevent spurious liveness before the u?mulsidi3 insn
2498 ;; (which causes "uninitialized variable" warnings), we explicitly clobber
2499 ;; the DImode register.
2500 (define_expand "umulsidi3"
2501 [(set (match_operand:DI 0 "register_operand" "")
2502 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2503 (zero_extend:DI (match_operand:SI 2 "register_operand" ""))))]
2504 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2507 (define_insn_and_split "*umulsidi3_split"
2508 [(set (match_operand:DI 0 "register_operand" "")
2509 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2510 (zero_extend:DI (match_operand:SI 2 "register_operand" ""))))]
2511 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2513 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2514 [(clobber (match_dup 0))
2516 [(set (subreg:SI (match_dup 0) 4)
2517 (mult:SI (match_dup 1) (match_dup 2)))
2518 (set (subreg:SI (match_dup 0) 0)
2519 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2520 (zero_extend:DI (match_dup 2)))
2521 (const_int 32))))])]
2525 [(set (match_operand:SI 0 "register_operand" "=d")
2526 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2527 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2528 (set (match_operand:SI 3 "register_operand" "=d")
2529 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2530 (zero_extend:DI (match_dup 2)))
2532 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2535 ; Match immediate case. For 2.4 only match things < 2^31.
2536 ; It's tricky with larger values in these patterns since we need to match
2537 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2540 [(set (match_operand:SI 0 "register_operand" "=d")
2541 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2542 (match_operand:SI 2 "const_int_operand" "n")))
2543 (set (match_operand:SI 3 "register_operand" "=d")
2544 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2547 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE
2548 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2551 (define_expand "mulsidi3"
2552 [(set (match_operand:DI 0 "register_operand" "")
2553 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2554 (sign_extend:DI (match_operand:SI 2 "register_operand" ""))))]
2555 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2558 (define_insn_and_split "*mulsidi3_split"
2559 [(set (match_operand:DI 0 "register_operand" "")
2560 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2561 (sign_extend:DI (match_operand:SI 2 "register_operand" ""))))]
2562 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2564 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2565 [(clobber (match_dup 0))
2567 [(set (subreg:SI (match_dup 0) 4)
2568 (mult:SI (match_dup 1) (match_dup 2)))
2569 (set (subreg:SI (match_dup 0) 0)
2570 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2571 (sign_extend:DI (match_dup 2)))
2572 (const_int 32))))])]
2576 [(set (match_operand:SI 0 "register_operand" "=d")
2577 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2578 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2579 (set (match_operand:SI 3 "register_operand" "=d")
2580 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2581 (sign_extend:DI (match_dup 2)))
2583 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2587 [(set (match_operand:SI 0 "register_operand" "=d")
2588 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2589 (match_operand:SI 2 "const_int_operand" "n")))
2590 (set (match_operand:SI 3 "register_operand" "=d")
2591 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2594 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2597 (define_expand "umulsi3_highpart"
2599 [(set (match_operand:SI 0 "register_operand" "")
2602 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2603 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2605 (clobber (match_dup 3))])]
2606 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2608 operands[3] = gen_reg_rtx (SImode);
2610 if (GET_CODE (operands[2]) == CONST_INT)
2612 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2615 /* We have to adjust the operand order for the matching constraints. */
2616 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2617 operands[1], operands[2]));
2623 [(set (match_operand:SI 0 "register_operand" "=d")
2626 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2627 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2629 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2630 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2633 (define_insn "const_umulsi3_highpart"
2634 [(set (match_operand:SI 0 "register_operand" "=d")
2637 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2638 (match_operand:DI 3 "const_uint32_operand" "n"))
2640 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2641 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2644 (define_expand "smulsi3_highpart"
2646 [(set (match_operand:SI 0 "register_operand" "")
2649 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2650 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2652 (clobber (match_dup 3))])]
2653 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2655 operands[3] = gen_reg_rtx (SImode);
2656 if (GET_CODE (operands[2]) == CONST_INT)
2658 /* We have to adjust the operand order for the matching constraints. */
2659 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2660 operands[1], operands[2]));
2666 [(set (match_operand:SI 0 "register_operand" "=d")
2669 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2670 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2672 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2673 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2676 (define_insn "const_smulsi3_highpart"
2677 [(set (match_operand:SI 0 "register_operand" "=d")
2680 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2681 (match_operand:DI 3 "const_sint32_operand" "n"))
2683 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2684 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2687 (define_expand "muldf3"
2688 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2689 (mult:DF (match_operand:DF 1 "general_operand" "")
2690 (match_operand:DF 2 "general_operand" "")))]
2695 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2696 (mult:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2697 (match_operand:DF 1 "general_operand" "0")))]
2702 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2703 (mult:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2704 (match_operand:DF 1 "general_operand" "0")))]
2709 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2710 (mult:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2711 (match_operand:DF 1 "general_operand" "0")))]
2716 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2717 (mult:DF (match_operand:DF 1 "general_operand" "%0")
2718 (match_operand:DF 2 "general_operand" "fmG")))]
2721 if (GET_CODE (operands[2]) == CONST_DOUBLE
2722 && floating_exact_log2 (operands[2]) && !TARGET_68040 && !TARGET_68060)
2724 int i = floating_exact_log2 (operands[2]);
2725 operands[2] = GEN_INT (i);
2726 return "fscale%.l %2,%0";
2728 if (REG_P (operands[2]))
2729 return "f%&mul%.x %2,%0";
2730 return "f%&mul%.d %f2,%0";
2733 (define_expand "mulsf3"
2734 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2735 (mult:SF (match_operand:SF 1 "general_operand" "")
2736 (match_operand:SF 2 "general_operand" "")))]
2741 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2742 (mult:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2743 (match_operand:SF 1 "general_operand" "0")))]
2746 return (TARGET_68040_ONLY
2748 : "fsglmul%.l %2,%0");
2752 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2753 (mult:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2754 (match_operand:SF 1 "general_operand" "0")))]
2757 return (TARGET_68040_ONLY
2759 : "fsglmul%.w %2,%0");
2763 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2764 (mult:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2765 (match_operand:SF 1 "general_operand" "0")))]
2768 return (TARGET_68040_ONLY
2770 : "fsglmul%.b %2,%0");
2774 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2775 (mult:SF (match_operand:SF 1 "general_operand" "%0")
2776 (match_operand:SF 2 "general_operand" "fdmF")))]
2779 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2780 return (TARGET_68040_ONLY
2782 : "fsglmul%.x %2,%0");
2783 return (TARGET_68040_ONLY
2785 : "fsglmul%.s %f2,%0");
2788 ;; divide instructions
2790 (define_expand "divdf3"
2791 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2792 (div:DF (match_operand:DF 1 "general_operand" "")
2793 (match_operand:DF 2 "general_operand" "")))]
2798 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2799 (div:DF (match_operand:DF 1 "general_operand" "0")
2800 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2805 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2806 (div:DF (match_operand:DF 1 "general_operand" "0")
2807 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2812 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2813 (div:DF (match_operand:DF 1 "general_operand" "0")
2814 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2819 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2820 (div:DF (match_operand:DF 1 "general_operand" "0")
2821 (match_operand:DF 2 "general_operand" "fmG")))]
2824 if (REG_P (operands[2]))
2825 return "f%&div%.x %2,%0";
2826 return "f%&div%.d %f2,%0";
2829 (define_expand "divsf3"
2830 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2831 (div:SF (match_operand:SF 1 "general_operand" "")
2832 (match_operand:SF 2 "general_operand" "")))]
2837 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2838 (div:SF (match_operand:SF 1 "general_operand" "0")
2839 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2842 return (TARGET_68040_ONLY
2844 : "fsgldiv%.l %2,%0");
2848 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2849 (div:SF (match_operand:SF 1 "general_operand" "0")
2850 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2853 return (TARGET_68040_ONLY
2855 : "fsgldiv%.w %2,%0");
2859 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2860 (div:SF (match_operand:SF 1 "general_operand" "0")
2861 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2864 return (TARGET_68040_ONLY
2866 : "fsgldiv%.b %2,%0");
2870 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2871 (div:SF (match_operand:SF 1 "general_operand" "0")
2872 (match_operand:SF 2 "general_operand" "fdmF")))]
2875 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2876 return (TARGET_68040_ONLY
2878 : "fsgldiv%.x %2,%0");
2879 return (TARGET_68040_ONLY
2881 : "fsgldiv%.s %f2,%0");
2884 ;; Remainder instructions.
2886 (define_expand "divmodsi4"
2888 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2889 (div:SI (match_operand:SI 1 "general_operand" "")
2890 (match_operand:SI 2 "general_src_operand" "")))
2891 (set (match_operand:SI 3 "nonimmediate_operand" "")
2892 (mod:SI (match_dup 1) (match_dup 2)))])]
2893 "TARGET_68020 || TARGET_CF_HWDIV"
2897 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2898 (div:SI (match_operand:SI 1 "general_operand" "0")
2899 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2900 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2901 (mod:SI (match_dup 1) (match_dup 2)))]
2904 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2905 return "divs%.l %2,%0";
2906 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2907 return "rems%.l %2,%3:%0";
2909 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
2913 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2914 (div:SI (match_operand:SI 1 "general_operand" "0")
2915 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2916 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2917 (mod:SI (match_dup 1) (match_dup 2)))]
2920 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2921 return "divs%.l %2,%0";
2923 return "divsl%.l %2,%3:%0";
2926 (define_expand "udivmodsi4"
2928 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2929 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2930 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2931 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2932 (umod:SI (match_dup 1) (match_dup 2)))])]
2933 "TARGET_68020 || TARGET_CF_HWDIV"
2937 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2938 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2939 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2940 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2941 (umod:SI (match_dup 1) (match_dup 2)))]
2944 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2945 return "divu%.l %2,%0";
2946 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2947 return "remu%.l %2,%3:%0";
2949 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
2953 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2954 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2955 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2956 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2957 (umod:SI (match_dup 1) (match_dup 2)))]
2958 "TARGET_68020 && !TARGET_COLDFIRE"
2960 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2961 return "divu%.l %2,%0";
2963 return "divul%.l %2,%3:%0";
2966 (define_insn "divmodhi4"
2967 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2968 (div:HI (match_operand:HI 1 "general_operand" "0")
2969 (match_operand:HI 2 "general_src_operand" "dmSKT")))
2970 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
2971 (mod:HI (match_dup 1) (match_dup 2)))]
2972 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
2974 output_asm_insn (MOTOROLA ?
2975 "ext%.l %0\;divs%.w %2,%0" :
2976 "extl %0\;divs %2,%0",
2978 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
2981 return "move%.l %0,%3\;swap %3";
2987 (define_insn "udivmodhi4"
2988 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2989 (udiv:HI (match_operand:HI 1 "general_operand" "0")
2990 (match_operand:HI 2 "general_src_operand" "dmSKT")))
2991 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
2992 (umod:HI (match_dup 1) (match_dup 2)))]
2993 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
2996 output_asm_insn (MOTOROLA ?
2997 "mvz%.w %0,%0\;divu%.w %2,%0" :
2998 "mvz%.w %0,%0\;divu %2,%0",
3001 output_asm_insn (MOTOROLA ?
3002 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3003 "and%.l #0xFFFF,%0\;divu %2,%0",
3006 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3009 return "move%.l %0,%3\;swap %3";
3015 ;; logical-and instructions
3017 ;; "anddi3" is mainly here to help combine().
3018 (define_insn "anddi3"
3019 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3020 (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3021 (match_operand:DI 2 "general_operand" "dn,don")))]
3025 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3026 if (CONSTANT_P (operands[2]))
3030 split_double (operands[2], &hi, &lo);
3032 switch (INTVAL (hi))
3035 output_asm_insn ("clr%.l %0", operands);
3043 xoperands[0] = operands[0];
3045 output_asm_insn (output_andsi3 (xoperands), xoperands);
3048 if (GET_CODE (operands[0]) == REG)
3049 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3051 operands[0] = adjust_address (operands[0], SImode, 4);
3052 switch (INTVAL (lo))
3055 output_asm_insn ("clr%.l %0", operands);
3063 xoperands[0] = operands[0];
3065 output_asm_insn (output_andsi3 (xoperands), xoperands);
3070 if (GET_CODE (operands[0]) != REG)
3072 operands[1] = adjust_address (operands[0], SImode, 4);
3073 return "and%.l %2,%0\;and%.l %R2,%1";
3075 if (GET_CODE (operands[2]) != REG)
3077 operands[1] = adjust_address (operands[2], SImode, 4);
3078 return "and%.l %2,%0\;and%.l %1,%R0";
3080 return "and%.l %2,%0\;and%.l %R2,%R0";
3083 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3084 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3085 ;; can't allocate pseudos into it.
3087 (define_expand "andsi3"
3088 [(set (match_operand:SI 0 "not_sp_operand" "")
3089 (and:SI (match_operand:SI 1 "general_operand" "")
3090 (match_operand:SI 2 "general_src_operand" "")))]
3094 ;; produced by split operations after reload finished
3095 (define_insn "*andsi3_split"
3096 [(set (match_operand:SI 0 "register_operand" "=d")
3097 (and:SI (match_operand:SI 1 "register_operand" "0")
3098 (match_operand:SI 2 "const_int_operand" "i")))]
3099 "reload_completed && !TARGET_COLDFIRE"
3101 return output_andsi3 (operands);
3104 (define_insn "andsi3_internal"
3105 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3106 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3107 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3110 return output_andsi3 (operands);
3113 (define_insn "andsi3_5200"
3114 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3115 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3116 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3119 if (TARGET_CFV4 && DATA_REG_P (operands[0])
3120 && GET_CODE (operands[2]) == CONST_INT)
3122 if (INTVAL (operands[2]) == 0x000000ff)
3123 return "mvz%.b %0,%0";
3124 else if (INTVAL (operands[2]) == 0x0000ffff)
3125 return "mvz%.w %0,%0";
3127 return output_andsi3 (operands);
3130 (define_insn "andhi3"
3131 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3132 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3133 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3138 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3139 (and:HI (match_dup 0)
3140 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3145 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3146 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3151 (define_insn "andqi3"
3152 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3153 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3154 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3159 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3160 (and:QI (match_dup 0)
3161 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3166 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3167 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3172 ;; inclusive-or instructions
3174 (define_insn "iordi_zext"
3175 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3176 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3177 (match_operand:DI 2 "general_operand" "0,0")))]
3183 if (GET_CODE (operands[0]) == REG)
3184 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3186 operands[0] = adjust_address (operands[0], SImode, 4);
3187 if (GET_MODE (operands[1]) == SImode)
3188 return "or%.l %1,%0";
3189 byte_mode = (GET_MODE (operands[1]) == QImode);
3190 if (GET_CODE (operands[0]) == MEM)
3191 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3194 return "or%.b %1,%0";
3196 return "or%.w %1,%0";
3199 ;; "iordi3" is mainly here to help combine().
3200 (define_insn "iordi3"
3201 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3202 (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3203 (match_operand:DI 2 "general_operand" "dn,don")))]
3207 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3208 if (CONSTANT_P (operands[2]))
3212 split_double (operands[2], &hi, &lo);
3214 switch (INTVAL (hi))
3219 /* FIXME : a scratch register would be welcome here if operand[0]
3220 is not a register */
3221 output_asm_insn ("move%.l #-1,%0", operands);
3227 xoperands[0] = operands[0];
3229 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3232 if (GET_CODE (operands[0]) == REG)
3233 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3235 operands[0] = adjust_address (operands[0], SImode, 4);
3236 switch (INTVAL (lo))
3241 /* FIXME : a scratch register would be welcome here if operand[0]
3242 is not a register */
3243 output_asm_insn ("move%.l #-1,%0", operands);
3249 xoperands[0] = operands[0];
3251 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3256 if (GET_CODE (operands[0]) != REG)
3258 operands[1] = adjust_address (operands[0], SImode, 4);
3259 return "or%.l %2,%0\;or%.l %R2,%1";
3261 if (GET_CODE (operands[2]) != REG)
3263 operands[1] = adjust_address (operands[2], SImode, 4);
3264 return "or%.l %2,%0\;or%.l %1,%R0";
3266 return "or%.l %2,%0\;or%.l %R2,%R0";
3269 (define_expand "iorsi3"
3270 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3271 (ior:SI (match_operand:SI 1 "general_operand" "")
3272 (match_operand:SI 2 "general_src_operand" "")))]
3276 (define_insn "iorsi3_internal"
3277 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3278 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3279 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3282 return output_iorsi3 (operands);
3285 (define_insn "iorsi3_5200"
3286 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3287 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3288 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3291 return output_iorsi3 (operands);
3294 (define_insn "iorhi3"
3295 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3296 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3297 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3302 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3303 (ior:HI (match_dup 0)
3304 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3309 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3310 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3315 (define_insn "iorqi3"
3316 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3317 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3318 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3323 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3324 (ior:QI (match_dup 0)
3325 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3330 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3331 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3336 ;; On all 68k models, this makes faster code in a special case.
3337 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3339 (define_insn "iorsi_zexthi_ashl16"
3340 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3341 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3342 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3347 if (GET_CODE (operands[2]) != REG)
3348 operands[2] = adjust_address (operands[2], HImode, 2);
3349 if (GET_CODE (operands[2]) != REG
3350 || REGNO (operands[2]) != REGNO (operands[0]))
3351 output_asm_insn ("move%.w %2,%0", operands);
3352 return "swap %0\;mov%.w %1,%0";
3355 (define_insn "iorsi_zext"
3356 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3357 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3358 (match_operand:SI 2 "general_operand" "0,0")))]
3364 byte_mode = (GET_MODE (operands[1]) == QImode);
3365 if (GET_CODE (operands[0]) == MEM)
3366 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3369 return "or%.b %1,%0";
3371 return "or%.w %1,%0";
3376 ;; "xordi3" is mainly here to help combine().
3377 (define_insn "xordi3"
3378 [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3379 (xor:DI (match_operand:DI 1 "general_operand" "%0")
3380 (match_operand:DI 2 "general_operand" "dn")))]
3384 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3386 if (CONSTANT_P (operands[2]))
3390 split_double (operands[2], &hi, &lo);
3392 switch (INTVAL (hi))
3397 output_asm_insn ("not%.l %0", operands);
3400 /* FIXME : a scratch register would be welcome here if
3401 -128 <= INTVAL (hi) < -1 */
3405 xoperands[0] = operands[0];
3407 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3410 if (GET_CODE (operands[0]) == REG)
3411 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3413 operands[0] = adjust_address (operands[0], SImode, 4);
3414 switch (INTVAL (lo))
3419 output_asm_insn ("not%.l %0", operands);
3422 /* FIXME : a scratch register would be welcome here if
3423 -128 <= INTVAL (lo) < -1 */
3425 /* FIXME : this should be merged with xorsi3 */
3429 xoperands[0] = operands[0];
3431 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3436 if (GET_CODE (operands[0]) != REG)
3438 operands[1] = adjust_address (operands[0], SImode, 4);
3439 return "eor%.l %2,%0\;eor%.l %R2,%1";
3441 if (GET_CODE (operands[2]) != REG)
3443 operands[1] = adjust_address (operands[2], SImode, 4);
3444 return "eor%.l %2,%0\;eor%.l %1,%R0";
3446 return "eor%.l %2,%0\;eor%.l %R2,%R0";
3449 (define_expand "xorsi3"
3450 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3451 (xor:SI (match_operand:SI 1 "general_operand" "")
3452 (match_operand:SI 2 "general_operand" "")))]
3456 (define_insn "xorsi3_internal"
3457 [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3458 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3459 (match_operand:SI 2 "general_operand" "di,dKT")))]
3463 return output_xorsi3 (operands);
3466 (define_insn "xorsi3_5200"
3467 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3468 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3469 (match_operand:SI 2 "general_operand" "d,Ks")))]
3472 return output_xorsi3 (operands);
3475 (define_insn "xorhi3"
3476 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3477 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3478 (match_operand:HI 2 "general_operand" "dn")))]
3483 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3484 (xor:HI (match_dup 0)
3485 (match_operand:HI 1 "general_operand" "dn")))]
3490 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3491 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3496 (define_insn "xorqi3"
3497 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3498 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3499 (match_operand:QI 2 "general_operand" "dn")))]
3504 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3505 (xor:QI (match_dup 0)
3506 (match_operand:QI 1 "general_operand" "dn")))]
3511 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3512 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3517 ;; negation instructions
3519 (define_expand "negdi2"
3520 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3521 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3524 if (TARGET_COLDFIRE)
3525 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3527 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3531 (define_insn "negdi2_internal"
3532 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3533 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3536 if (which_alternative == 0)
3537 return "neg%.l %0\;negx%.l %0";
3538 if (GET_CODE (operands[0]) == REG)
3539 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3541 operands[1] = adjust_address (operands[0], SImode, 4);
3542 if (ADDRESS_REG_P (operands[0]))
3543 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3545 return "neg%.l %1\;negx%.l %0";
3548 (define_insn "negdi2_5200"
3549 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3550 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3553 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3554 return "neg%.l %1\;negx%.l %0";
3557 (define_expand "negsi2"
3558 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3559 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3562 if (TARGET_COLDFIRE)
3563 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3565 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3569 (define_insn "negsi2_internal"
3570 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3571 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3575 (define_insn "negsi2_5200"
3576 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3577 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3581 (define_insn "neghi2"
3582 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3583 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3588 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3589 (neg:HI (match_dup 0)))]
3593 (define_insn "negqi2"
3594 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3595 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3600 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3601 (neg:QI (match_dup 0)))]
3605 ;; If using software floating point, just flip the sign bit.
3607 (define_expand "negsf2"
3608 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3609 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3617 target = operand_subword_force (operands[0], 0, SFmode);
3618 result = expand_binop (SImode, xor_optab,
3619 operand_subword_force (operands[1], 0, SFmode),
3620 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3621 gcc_assert (result);
3623 if (result != target)
3624 emit_move_insn (result, target);
3626 /* Make a place for REG_EQUAL. */
3627 emit_move_insn (operands[0], operands[0]);
3633 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d")
3634 (neg:SF (match_operand:SF 1 "general_operand" "fdmF,0")))]
3637 if (DATA_REG_P (operands[0]))
3639 operands[1] = GEN_INT (31);
3640 return "bchg %1,%0";
3642 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3643 return "f%$neg%.x %1,%0";
3644 return "f%$neg%.s %f1,%0";
3647 (define_expand "negdf2"
3648 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3649 (neg:DF (match_operand:DF 1 "general_operand" "")))]
3659 target = operand_subword (operands[0], 0, 1, DFmode);
3660 result = expand_binop (SImode, xor_optab,
3661 operand_subword_force (operands[1], 0, DFmode),
3662 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3663 gcc_assert (result);
3665 if (result != target)
3666 emit_move_insn (result, target);
3668 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3669 operand_subword_force (operands[1], 1, DFmode));
3671 insns = get_insns ();
3674 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3680 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,d")
3681 (neg:DF (match_operand:DF 1 "general_operand" "fmF,0")))]
3684 if (DATA_REG_P (operands[0]))
3686 operands[1] = GEN_INT (31);
3687 return "bchg %1,%0";
3689 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3690 return "f%&neg%.x %1,%0";
3691 return "f%&neg%.d %f1,%0";
3694 ;; Sqrt instruction for the 68881
3696 (define_insn "sqrtsf2"
3697 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3698 (sqrt:SF (match_operand:SF 1 "general_operand" "fm")))]
3701 if (FP_REG_P (operands[1]))
3702 return "f%$sqrt%.x %1,%0";
3704 return "f%$sqrt%.s %1,%0";
3707 (define_insn "sqrtdf2"
3708 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3709 (sqrt:DF (match_operand:DF 1 "general_operand" "fm")))]
3712 if (FP_REG_P (operands[1]))
3713 return "f%&sqrt%.x %1,%0";
3715 return "f%&sqrt%.d %1,%0";
3718 ;; Absolute value instructions
3719 ;; If using software floating point, just zero the sign bit.
3721 (define_expand "abssf2"
3722 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3723 (abs:SF (match_operand:SF 1 "general_operand" "")))]
3731 target = operand_subword_force (operands[0], 0, SFmode);
3732 result = expand_binop (SImode, and_optab,
3733 operand_subword_force (operands[1], 0, SFmode),
3734 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3735 gcc_assert (result);
3737 if (result != target)
3738 emit_move_insn (result, target);
3740 /* Make a place for REG_EQUAL. */
3741 emit_move_insn (operands[0], operands[0]);
3747 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3748 (abs:SF (match_operand:SF 1 "general_operand" "fdmF")))]
3751 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3752 return "f%$abs%.x %1,%0";
3753 return "f%$abs%.s %f1,%0";
3756 (define_expand "absdf2"
3757 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3758 (abs:DF (match_operand:DF 1 "general_operand" "")))]
3768 target = operand_subword (operands[0], 0, 1, DFmode);
3769 result = expand_binop (SImode, and_optab,
3770 operand_subword_force (operands[1], 0, DFmode),
3771 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3772 gcc_assert (result);
3774 if (result != target)
3775 emit_move_insn (result, target);
3777 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3778 operand_subword_force (operands[1], 1, DFmode));
3780 insns = get_insns ();
3783 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3789 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3790 (abs:DF (match_operand:DF 1 "general_operand" "fmF")))]
3793 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3794 return "f%&abs%.x %1,%0";
3795 return "f%&abs%.d %f1,%0";
3798 ;; one complement instructions
3800 ;; "one_cmpldi2" is mainly here to help combine().
3801 (define_insn "one_cmpldi2"
3802 [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
3803 (not:DI (match_operand:DI 1 "general_operand" "0")))]
3807 if (GET_CODE (operands[0]) == REG)
3808 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3809 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
3810 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3811 operands[1] = operands[0];
3813 operands[1] = adjust_address (operands[0], SImode, 4);
3814 return "not%.l %1\;not%.l %0";
3817 (define_expand "one_cmplsi2"
3818 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3819 (not:SI (match_operand:SI 1 "general_operand" "")))]
3822 if (TARGET_COLDFIRE)
3823 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
3825 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
3829 (define_insn "one_cmplsi2_internal"
3830 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3831 (not:SI (match_operand:SI 1 "general_operand" "0")))]
3835 (define_insn "one_cmplsi2_5200"
3836 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3837 (not:SI (match_operand:SI 1 "general_operand" "0")))]
3841 (define_insn "one_cmplhi2"
3842 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3843 (not:HI (match_operand:HI 1 "general_operand" "0")))]
3848 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3849 (not:HI (match_dup 0)))]
3853 (define_insn "one_cmplqi2"
3854 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3855 (not:QI (match_operand:QI 1 "general_operand" "0")))]
3860 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3861 (not:QI (match_dup 0)))]
3865 ;; arithmetic shift instructions
3866 ;; We don't need the shift memory by 1 bit instruction
3868 (define_insn "ashldi_extsi"
3869 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
3871 (match_operator:DI 2 "extend_operator"
3872 [(match_operand:SI 1 "general_operand" "rm")])
3877 if (GET_CODE (operands[0]) == REG)
3878 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3880 operands[2] = adjust_address (operands[0], SImode, 4);
3881 if (ADDRESS_REG_P (operands[0]))
3882 return "move%.l %1,%0\;sub%.l %2,%2";
3884 return "move%.l %1,%0\;clr%.l %2";
3887 (define_insn "ashldi_sexthi"
3888 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
3889 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
3891 (clobber (match_scratch:SI 2 "=a,X"))]
3895 if (GET_CODE (operands[0]) == MEM)
3897 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3898 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
3899 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
3900 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
3903 operands[3] = adjust_address (operands[0], SImode, 4);
3904 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
3907 else if (DATA_REG_P (operands[0]))
3908 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
3910 return "move%.w %1,%0\;sub%.l %R0,%R0";
3913 (define_insn "ashldi_const32"
3914 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
3915 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
3920 if (GET_CODE (operands[1]) == REG)
3921 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
3923 operands[3] = adjust_address (operands[1], SImode, 4);
3924 if (GET_CODE (operands[0]) == REG)
3925 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3926 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3927 return "clr%.l %0\;move%.l %3,%0";
3928 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
3929 return "move%.l %3,%0\;clr%.l %0";
3931 operands[2] = adjust_address (operands[0], SImode, 4);
3932 if (ADDRESS_REG_P (operands[2]))
3933 return "move%.l %3,%0\;sub%.l %2,%2";
3935 return "move%.l %3,%0\;clr%.l %2";
3938 ;; The predicate below must be general_operand, because ashldi3 allows that
3939 (define_insn "ashldi_const"
3940 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3941 (ashift:DI (match_operand:DI 1 "general_operand" "0")
3942 (match_operand 2 "const_int_operand" "n")))]
3944 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
3945 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
3946 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
3948 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3949 if (INTVAL (operands[2]) == 1)
3950 return "add%.l %1,%1\;addx%.l %0,%0";
3951 else if (INTVAL (operands[2]) == 8)
3952 return "rol%.l #8,%1\;rol%.l #8,%0\;move%.b %1,%0\;clr%.b %1";
3953 else if (INTVAL (operands[2]) == 16)
3954 return "swap %1\;swap %0\;move%.w %1,%0\;clr%.w %1";
3955 else if (INTVAL (operands[2]) == 48)
3956 return "mov%.l %1,%0\;swap %0\;clr%.l %1\;clr%.w %0";
3957 else if (INTVAL (operands[2]) == 2)
3958 return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
3959 else if (INTVAL (operands[2]) == 3)
3960 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";
3961 else /* 32 < INTVAL (operands[2]) <= 63 */
3963 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
3964 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asl%.l %2,%1" :
3965 "moveq %2,%0\;asl%.l %0,%1", operands);
3966 return "mov%.l %1,%0\;moveq #0,%1";
3970 (define_expand "ashldi3"
3971 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3972 (ashift:DI (match_operand:DI 1 "general_operand" "")
3973 (match_operand 2 "const_int_operand" "")))]
3977 /* ??? This is a named pattern like this is not allowed to FAIL based
3979 if (GET_CODE (operands[2]) != CONST_INT
3980 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
3981 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
3982 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
3986 ;; On most 68k models, this makes faster code in a special case.
3988 (define_insn "ashlsi_16"
3989 [(set (match_operand:SI 0 "register_operand" "=d")
3990 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3995 return "swap %0\;clr%.w %0";
3998 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
3999 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4001 ;; On the 68000, this makes faster code in a special case.
4003 (define_insn "ashlsi_17_24"
4004 [(set (match_operand:SI 0 "register_operand" "=d")
4005 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4006 (match_operand:SI 2 "const_int_operand" "n")))]
4007 "(! TARGET_68020 && !TARGET_COLDFIRE
4008 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
4012 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4013 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4016 (define_insn "ashlsi3"
4017 [(set (match_operand:SI 0 "register_operand" "=d")
4018 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4019 (match_operand:SI 2 "general_operand" "dI")))]
4022 if (operands[2] == const1_rtx)
4024 cc_status.flags = CC_NO_OVERFLOW;
4025 return "add%.l %0,%0";
4027 return "lsl%.l %2,%0";
4030 (define_insn "ashlhi3"
4031 [(set (match_operand:HI 0 "register_operand" "=d")
4032 (ashift:HI (match_operand:HI 1 "register_operand" "0")
4033 (match_operand:HI 2 "general_operand" "dI")))]
4038 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4039 (ashift:HI (match_dup 0)
4040 (match_operand:HI 1 "general_operand" "dI")))]
4044 (define_insn "ashlqi3"
4045 [(set (match_operand:QI 0 "register_operand" "=d")
4046 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4047 (match_operand:QI 2 "general_operand" "dI")))]
4052 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4053 (ashift:QI (match_dup 0)
4054 (match_operand:QI 1 "general_operand" "dI")))]
4058 ;; On most 68k models, this makes faster code in a special case.
4060 (define_insn "ashrsi_16"
4061 [(set (match_operand:SI 0 "register_operand" "=d")
4062 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4065 "swap %0\;ext%.l %0")
4067 ;; On the 68000, this makes faster code in a special case.
4070 [(set (match_operand:SI 0 "register_operand" "=d")
4071 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4072 (match_operand:SI 2 "const_int_operand" "n")))]
4073 "(! TARGET_68020 && !TARGET_COLDFIRE
4074 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
4076 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4077 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4080 (define_insn "subreghi1ashrdi_const32"
4081 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4082 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4083 (const_int 32)) 6))]
4086 if (GET_CODE (operands[1]) != REG)
4087 operands[1] = adjust_address (operands[1], HImode, 2);
4088 return "move%.w %1,%0";
4091 (define_insn "subregsi1ashrdi_const32"
4092 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4093 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4094 (const_int 32)) 4))]
4097 return "move%.l %1,%0";
4100 (define_insn "ashrdi_const32"
4101 [(set (match_operand:DI 0 "register_operand" "=d")
4102 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4107 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4109 return "move%.l %1,%2\;smi %0\;extb%.l %0";
4111 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
4114 (define_insn "ashrdi_const32_mem"
4115 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,<")
4116 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro")
4118 (clobber (match_scratch:SI 2 "=d,d"))]
4122 if (which_alternative == 1)
4123 operands[3] = operands[0];
4125 operands[3] = adjust_address (operands[0], SImode, 4);
4127 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4129 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4132 ;; The predicate below must be general_operand, because ashrdi3 allows that
4133 (define_insn "ashrdi_const"
4134 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4135 (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
4136 (match_operand 2 "const_int_operand" "n")))]
4138 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4139 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4140 || INTVAL (operands[2]) == 31
4141 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4143 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4144 if (INTVAL (operands[2]) == 63)
4145 return "add%.l %0,%0\;subx%.l %0,%0\;move%.l %0,%1";
4147 if (INTVAL (operands[2]) == 1)
4148 return "asr%.l #1,%0\;roxr%.l #1,%1";
4149 else if (INTVAL (operands[2]) == 8)
4150 return "move%.b %0,%1\;asr%.l #8,%0\;ror%.l #8,%1";
4151 else if (INTVAL (operands[2]) == 16)
4152 return "move%.w %0,%1\;swap %0\;ext%.l %0\;swap %1";
4153 else if (INTVAL (operands[2]) == 48)
4154 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4155 else if (INTVAL (operands[2]) == 31)
4156 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4157 else if (INTVAL (operands[2]) == 2)
4158 return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4159 else if (INTVAL (operands[2]) == 3)
4160 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";
4161 else /* 32 < INTVAL (operands[2]) <= 63 */
4163 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4164 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4165 "moveq %2,%1\;asr%.l %1,%0", operands);
4166 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4167 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4168 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4172 (define_expand "ashrdi3"
4173 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4174 (ashiftrt:DI (match_operand:DI 1 "general_operand" "")
4175 (match_operand 2 "const_int_operand" "")))]
4179 /* ??? This is a named pattern like this is not allowed to FAIL based
4181 if (GET_CODE (operands[2]) != CONST_INT
4182 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4183 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4184 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4188 ;; On all 68k models, this makes faster code in a special case.
4190 (define_insn "ashrsi_31"
4191 [(set (match_operand:SI 0 "register_operand" "=d")
4192 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4196 return "add%.l %0,%0\;subx%.l %0,%0";
4199 (define_insn "ashrsi3"
4200 [(set (match_operand:SI 0 "register_operand" "=d")
4201 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4202 (match_operand:SI 2 "general_operand" "dI")))]
4206 (define_insn "ashrhi3"
4207 [(set (match_operand:HI 0 "register_operand" "=d")
4208 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4209 (match_operand:HI 2 "general_operand" "dI")))]
4214 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4215 (ashiftrt:HI (match_dup 0)
4216 (match_operand:HI 1 "general_operand" "dI")))]
4220 (define_insn "ashrqi3"
4221 [(set (match_operand:QI 0 "register_operand" "=d")
4222 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4223 (match_operand:QI 2 "general_operand" "dI")))]
4228 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4229 (ashiftrt:QI (match_dup 0)
4230 (match_operand:QI 1 "general_operand" "dI")))]
4234 ;; logical shift instructions
4236 ;; commented out because of reload problems in 950612-1.c
4239 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4240 ;; (const_int 32)) 4))
4241 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4242 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4243 ;; (const_int 32)) 4))]
4246 ;; return "move%.l %0,%1";
4251 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4252 ;; (const_int 32)) 0))
4253 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4254 ;; (lshiftrt:DI (match_dup 0)
4255 ;; (const_int 32)))]
4258 ;; if (GET_CODE (operands[1]) == REG)
4259 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4261 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4262 ;; return "move%.l %0,%2\;clr%.l %1";
4265 (define_insn "subreg1lshrdi_const32"
4266 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4267 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4268 (const_int 32)) 4))]
4271 return "move%.l %1,%0";
4274 (define_insn "lshrdi_const32"
4275 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro,<,>")
4276 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4281 if (which_alternative == 1)
4282 return "move%.l %1,%0\;clr%.l %0";
4283 if (which_alternative == 2)
4284 return "clr%.l %0\;move%.l %1,%0";
4285 if (GET_CODE (operands[0]) == REG)
4286 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4288 operands[2] = adjust_address (operands[0], SImode, 4);
4289 if (GET_CODE (operands[1]) == REG)
4290 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4292 operands[3] = adjust_address (operands[1], SImode, 4);
4293 if (ADDRESS_REG_P (operands[0]))
4294 return "move%.l %1,%2\;sub%.l %0,%0";
4296 return "move%.l %1,%2\;clr%.l %0";
4299 ;; The predicate below must be general_operand, because lshrdi3 allows that
4300 (define_insn "lshrdi_const"
4301 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4302 (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
4303 (match_operand 2 "const_int_operand" "n")))]
4305 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4306 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4307 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4309 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4310 if (INTVAL (operands[2]) == 63)
4311 return "add%.l %0,%0\;clr%.l %0\;clr%.l %1\;addx%.l %1,%1";
4313 if (INTVAL (operands[2]) == 1)
4314 return "lsr%.l #1,%0\;roxr%.l #1,%1";
4315 else if (INTVAL (operands[2]) == 8)
4316 return "move%.b %0,%1\;lsr%.l #8,%0\;ror%.l #8,%1";
4317 else if (INTVAL (operands[2]) == 16)
4318 return "move%.w %0,%1\;clr%.w %0\;swap %1\;swap %0";
4319 else if (INTVAL (operands[2]) == 48)
4320 return "move%.l %0,%1\;clr%.w %1\;clr%.l %0\;swap %1";
4321 else if (INTVAL (operands[2]) == 2)
4322 return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4323 else if (INTVAL (operands[2]) == 3)
4324 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";
4325 else /* 32 < INTVAL (operands[2]) <= 63 */
4327 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4328 output_asm_insn (INTVAL (operands[2]) <= 8 ? "lsr%.l %2,%0" :
4329 "moveq %2,%1\;lsr%.l %1,%0", operands);
4330 return "mov%.l %0,%1\;moveq #0,%0";
4334 (define_expand "lshrdi3"
4335 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4336 (lshiftrt:DI (match_operand:DI 1 "general_operand" "")
4337 (match_operand 2 "const_int_operand" "")))]
4340 /* ??? This is a named pattern like this is not allowed to FAIL based
4342 if (GET_CODE (operands[2]) != CONST_INT
4343 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4344 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4345 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4349 ;; On all 68k models, this makes faster code in a special case.
4351 (define_insn "lshrsi_31"
4352 [(set (match_operand:SI 0 "register_operand" "=d")
4353 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4357 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
4360 ;; On most 68k models, this makes faster code in a special case.
4362 (define_insn "lshrsi_16"
4363 [(set (match_operand:SI 0 "register_operand" "=d")
4364 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4369 return "clr%.w %0\;swap %0";
4372 ;; On the 68000, this makes faster code in a special case.
4374 (define_insn "lshrsi_17_24"
4375 [(set (match_operand:SI 0 "register_operand" "=d")
4376 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4377 (match_operand:SI 2 "const_int_operand" "n")))]
4378 "(! TARGET_68020 && !TARGET_COLDFIRE
4379 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
4381 /* I think lsr%.w sets the CC properly. */
4382 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4383 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
4386 (define_insn "lshrsi3"
4387 [(set (match_operand:SI 0 "register_operand" "=d")
4388 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4389 (match_operand:SI 2 "general_operand" "dI")))]
4393 (define_insn "lshrhi3"
4394 [(set (match_operand:HI 0 "register_operand" "=d")
4395 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
4396 (match_operand:HI 2 "general_operand" "dI")))]
4401 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4402 (lshiftrt:HI (match_dup 0)
4403 (match_operand:HI 1 "general_operand" "dI")))]
4407 (define_insn "lshrqi3"
4408 [(set (match_operand:QI 0 "register_operand" "=d")
4409 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
4410 (match_operand:QI 2 "general_operand" "dI")))]
4415 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4416 (lshiftrt:QI (match_dup 0)
4417 (match_operand:QI 1 "general_operand" "dI")))]
4421 ;; rotate instructions
4423 (define_insn "rotlsi3"
4424 [(set (match_operand:SI 0 "register_operand" "=d")
4425 (rotate:SI (match_operand:SI 1 "register_operand" "0")
4426 (match_operand:SI 2 "general_operand" "dINO")))]
4429 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
4431 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
4433 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4434 return "ror%.l %2,%0";
4437 return "rol%.l %2,%0";
4440 (define_insn "rotlhi3"
4441 [(set (match_operand:HI 0 "register_operand" "=d")
4442 (rotate:HI (match_operand:HI 1 "register_operand" "0")
4443 (match_operand:HI 2 "general_operand" "dIP")))]
4446 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4448 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4449 return "ror%.w %2,%0";
4452 return "rol%.w %2,%0";
4456 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4457 (rotate:HI (match_dup 0)
4458 (match_operand:HI 1 "general_operand" "dIP")))]
4461 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4463 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4464 return "ror%.w %2,%0";
4467 return "rol%.w %2,%0";
4470 (define_insn "rotlqi3"
4471 [(set (match_operand:QI 0 "register_operand" "=d")
4472 (rotate:QI (match_operand:QI 1 "register_operand" "0")
4473 (match_operand:QI 2 "general_operand" "dI")))]
4476 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4478 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4479 return "ror%.b %2,%0";
4482 return "rol%.b %2,%0";
4486 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4487 (rotate:QI (match_dup 0)
4488 (match_operand:QI 1 "general_operand" "dI")))]
4491 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4493 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4494 return "ror%.b %2,%0";
4497 return "rol%.b %2,%0";
4500 (define_insn "rotrsi3"
4501 [(set (match_operand:SI 0 "register_operand" "=d")
4502 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
4503 (match_operand:SI 2 "general_operand" "dI")))]
4507 (define_insn "rotrhi3"
4508 [(set (match_operand:HI 0 "register_operand" "=d")
4509 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
4510 (match_operand:HI 2 "general_operand" "dI")))]
4515 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4516 (rotatert:HI (match_dup 0)
4517 (match_operand:HI 1 "general_operand" "dI")))]
4521 (define_insn "rotrqi3"
4522 [(set (match_operand:QI 0 "register_operand" "=d")
4523 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
4524 (match_operand:QI 2 "general_operand" "dI")))]
4529 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4530 (rotatert:QI (match_dup 0)
4531 (match_operand:QI 1 "general_operand" "dI")))]
4536 ;; Bit set/clear in memory byte.
4538 ;; set bit, bit number is int
4539 (define_insn "bsetmemqi"
4540 [(set (match_operand:QI 0 "memory_operand" "+m")
4541 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4542 (match_operand:SI 1 "general_operand" "d")) 3)
4547 return "bset %1,%0";
4550 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
4552 [(set (match_operand:QI 0 "memory_operand" "+m")
4553 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4554 (match_operator:SI 2 "extend_operator"
4555 [(match_operand 1 "general_operand" "d")])) 3)
4560 return "bset %1,%0";
4563 ;; clear bit, bit number is int
4564 (define_insn "bclrmemqi"
4565 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4567 (minus:SI (const_int 7)
4568 (match_operand:SI 1 "general_operand" "d")))
4573 return "bclr %1,%0";
4576 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
4578 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4580 (minus:SI (const_int 7)
4581 (match_operator:SI 2 "extend_operator"
4582 [(match_operand 1 "general_operand" "d")])))
4587 return "bclr %1,%0";
4590 ;; Special cases of bit-field insns which we should
4591 ;; recognize in preference to the general case.
4592 ;; These handle aligned 8-bit and 16-bit fields,
4593 ;; which can usually be done with move instructions.
4596 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4597 ; alignment of structure members is specified.
4599 ; The move is allowed to be odd byte aligned, because that's still faster
4600 ; than an odd byte aligned bit-field instruction.
4603 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4605 (match_operand:SI 1 "const_int_operand" "n"))
4606 (match_operand:SI 2 "general_src_operand" "rmSi"))]
4607 "TARGET_68020 && TARGET_BITFIELD
4608 && (INTVAL (operands[1]) % 8) == 0
4609 && ! mode_dependent_address_p (XEXP (operands[0], 0))"
4612 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
4614 return "move%.l %2,%0";
4618 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
4619 (match_operand:SI 1 "const_int_operand" "n")
4620 (match_operand:SI 2 "const_int_operand" "n"))
4621 (match_operand:SI 3 "register_operand" "d"))]
4622 "TARGET_68020 && TARGET_BITFIELD
4623 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
4624 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
4625 && (GET_CODE (operands[0]) == REG
4626 || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
4628 if (REG_P (operands[0]))
4630 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
4631 return "bfins %3,%0{%b2:%b1}";
4634 operands[0] = adjust_address (operands[0],
4635 INTVAL (operands[1]) == 8 ? QImode : HImode,
4636 INTVAL (operands[2]) / 8);
4638 if (GET_CODE (operands[3]) == MEM)
4639 operands[3] = adjust_address (operands[3],
4640 INTVAL (operands[1]) == 8 ? QImode : HImode,
4641 (32 - INTVAL (operands[1])) / 8);
4643 if (INTVAL (operands[1]) == 8)
4644 return "move%.b %3,%0";
4645 return "move%.w %3,%0";
4650 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4651 ; alignment of structure members is specified.
4653 ; The move is allowed to be odd byte aligned, because that's still faster
4654 ; than an odd byte aligned bit-field instruction.
4657 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4658 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4660 (match_operand:SI 2 "const_int_operand" "n")))]
4661 "TARGET_68020 && TARGET_BITFIELD
4662 && (INTVAL (operands[2]) % 8) == 0
4663 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4666 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4668 return "move%.l %1,%0";
4672 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
4673 (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
4674 (match_operand:SI 2 "const_int_operand" "n")
4675 (match_operand:SI 3 "const_int_operand" "n")))]
4676 "TARGET_68020 && TARGET_BITFIELD
4677 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4678 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4679 && (GET_CODE (operands[1]) == REG
4680 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4682 cc_status.flags |= CC_NOT_NEGATIVE;
4683 if (REG_P (operands[1]))
4685 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4686 return "bfextu %1{%b3:%b2},%0";
4690 = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
4692 output_asm_insn ("clr%.l %0", operands);
4693 if (GET_CODE (operands[0]) == MEM)
4694 operands[0] = adjust_address (operands[0],
4695 INTVAL (operands[2]) == 8 ? QImode : HImode,
4696 (32 - INTVAL (operands[1])) / 8);
4698 if (INTVAL (operands[2]) == 8)
4699 return "move%.b %1,%0";
4700 return "move%.w %1,%0";
4704 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4705 ; alignment of structure members is specified.
4707 ; The move is allowed to be odd byte aligned, because that's still faster
4708 ; than an odd byte aligned bit-field instruction.
4711 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4712 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4714 (match_operand:SI 2 "const_int_operand" "n")))]
4715 "TARGET_68020 && TARGET_BITFIELD
4716 && (INTVAL (operands[2]) % 8) == 0
4717 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4720 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4722 return "move%.l %1,%0";
4726 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4727 (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
4728 (match_operand:SI 2 "const_int_operand" "n")
4729 (match_operand:SI 3 "const_int_operand" "n")))]
4730 "TARGET_68020 && TARGET_BITFIELD
4731 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4732 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4733 && (GET_CODE (operands[1]) == REG
4734 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4736 if (REG_P (operands[1]))
4738 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4739 return "bfexts %1{%b3:%b2},%0";
4743 = adjust_address (operands[1],
4744 INTVAL (operands[2]) == 8 ? QImode : HImode,
4745 INTVAL (operands[3]) / 8);
4747 if (INTVAL (operands[2]) == 8)
4748 return "move%.b %1,%0\;extb%.l %0";
4749 return "move%.w %1,%0\;ext%.l %0";
4752 ;; Bit-field instructions, general cases.
4753 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
4754 ;; so that its address is reloaded.
4756 (define_expand "extv"
4757 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4758 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
4759 (match_operand:SI 2 "general_operand" "")
4760 (match_operand:SI 3 "general_operand" "")))]
4761 "TARGET_68020 && TARGET_BITFIELD"
4765 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4766 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
4767 (match_operand:SI 2 "general_operand" "dn")
4768 (match_operand:SI 3 "general_operand" "dn")))]
4769 "TARGET_68020 && TARGET_BITFIELD"
4770 "bfexts %1{%b3:%b2},%0")
4772 (define_expand "extzv"
4773 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4774 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
4775 (match_operand:SI 2 "general_operand" "")
4776 (match_operand:SI 3 "general_operand" "")))]
4777 "TARGET_68020 && TARGET_BITFIELD"
4781 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d")
4782 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o,d")
4783 (match_operand:SI 2 "general_operand" "dn,dn")
4784 (match_operand:SI 3 "general_operand" "dn,dn")))]
4785 "TARGET_68020 && TARGET_BITFIELD"
4787 if (GET_CODE (operands[2]) == CONST_INT)
4789 if (INTVAL (operands[2]) != 32)
4790 cc_status.flags |= CC_NOT_NEGATIVE;
4796 return "bfextu %1{%b3:%b2},%0";
4800 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4801 (match_operand:SI 1 "general_operand" "dn")
4802 (match_operand:SI 2 "general_operand" "dn"))
4803 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
4804 (match_operand 3 "const_int_operand" "n")))]
4805 "TARGET_68020 && TARGET_BITFIELD
4806 && (INTVAL (operands[3]) == -1
4807 || (GET_CODE (operands[1]) == CONST_INT
4808 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
4811 return "bfchg %0{%b2:%b1}";
4815 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4816 (match_operand:SI 1 "general_operand" "dn")
4817 (match_operand:SI 2 "general_operand" "dn"))
4819 "TARGET_68020 && TARGET_BITFIELD"
4822 return "bfclr %0{%b2:%b1}";
4826 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4827 (match_operand:SI 1 "general_operand" "dn")
4828 (match_operand:SI 2 "general_operand" "dn"))
4830 "TARGET_68020 && TARGET_BITFIELD"
4833 return "bfset %0{%b2:%b1}";
4836 (define_expand "insv"
4837 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
4838 (match_operand:SI 1 "general_operand" "")
4839 (match_operand:SI 2 "general_operand" ""))
4840 (match_operand:SI 3 "register_operand" ""))]
4841 "TARGET_68020 && TARGET_BITFIELD"
4845 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4846 (match_operand:SI 1 "general_operand" "dn")
4847 (match_operand:SI 2 "general_operand" "dn"))
4848 (match_operand:SI 3 "register_operand" "d"))]
4849 "TARGET_68020 && TARGET_BITFIELD"
4850 "bfins %3,%0{%b2:%b1}")
4852 ;; Now recognize bit-field insns that operate on registers
4853 ;; (or at least were intended to do so).
4856 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4857 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
4858 (match_operand:SI 2 "general_operand" "dn")
4859 (match_operand:SI 3 "general_operand" "dn")))]
4860 "TARGET_68020 && TARGET_BITFIELD"
4861 "bfexts %1{%b3:%b2},%0")
4864 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4865 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
4866 (match_operand:SI 2 "general_operand" "dn")
4867 (match_operand:SI 3 "general_operand" "dn")))]
4868 "TARGET_68020 && TARGET_BITFIELD"
4870 if (GET_CODE (operands[2]) == CONST_INT)
4872 if (INTVAL (operands[2]) != 32)
4873 cc_status.flags |= CC_NOT_NEGATIVE;
4879 return "bfextu %1{%b3:%b2},%0";
4883 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4884 (match_operand:SI 1 "general_operand" "dn")
4885 (match_operand:SI 2 "general_operand" "dn"))
4887 "TARGET_68020 && TARGET_BITFIELD"
4890 return "bfclr %0{%b2:%b1}";
4894 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4895 (match_operand:SI 1 "general_operand" "dn")
4896 (match_operand:SI 2 "general_operand" "dn"))
4898 "TARGET_68020 && TARGET_BITFIELD"
4901 return "bfset %0{%b2:%b1}";
4905 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4906 (match_operand:SI 1 "general_operand" "dn")
4907 (match_operand:SI 2 "general_operand" "dn"))
4908 (match_operand:SI 3 "register_operand" "d"))]
4909 "TARGET_68020 && TARGET_BITFIELD"
4912 /* These special cases are now recognized by a specific pattern. */
4913 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
4914 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
4915 return "move%.w %3,%0";
4916 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
4917 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
4918 return "move%.b %3,%0";
4920 return "bfins %3,%0{%b2:%b1}";
4923 ;; Special patterns for optimizing bit-field instructions.
4927 (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
4928 (match_operand:SI 1 "const_int_operand" "n")
4929 (match_operand:SI 2 "general_operand" "dn")))]
4930 "TARGET_68020 && TARGET_BITFIELD"
4932 if (operands[1] == const1_rtx
4933 && GET_CODE (operands[2]) == CONST_INT)
4935 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
4936 return output_btst (operands,
4937 GEN_INT (width - INTVAL (operands[2])),
4938 operands[0], insn, 1000);
4939 /* Pass 1000 as SIGNPOS argument so that btst will
4940 not think we are testing the sign bit for an `and'
4941 and assume that nonzero implies a negative result. */
4943 if (INTVAL (operands[1]) != 32)
4944 cc_status.flags = CC_NOT_NEGATIVE;
4945 return "bftst %0{%b2:%b1}";
4949 ;;; now handle the register cases
4952 (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
4953 (match_operand:SI 1 "const_int_operand" "n")
4954 (match_operand:SI 2 "general_operand" "dn")))]
4955 "TARGET_68020 && TARGET_BITFIELD"
4957 if (operands[1] == const1_rtx
4958 && GET_CODE (operands[2]) == CONST_INT)
4960 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
4961 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
4962 operands[0], insn, 1000);
4963 /* Pass 1000 as SIGNPOS argument so that btst will
4964 not think we are testing the sign bit for an `and'
4965 and assume that nonzero implies a negative result. */
4967 if (INTVAL (operands[1]) != 32)
4968 cc_status.flags = CC_NOT_NEGATIVE;
4969 return "bftst %0{%b2:%b1}";
4972 (define_insn "scc0_di"
4973 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4974 (match_operator 1 "valid_dbcc_comparison_p"
4975 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
4978 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
4981 (define_insn "scc0_di_5200"
4982 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
4983 (match_operator 1 "valid_dbcc_comparison_p"
4984 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
4987 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
4990 (define_insn "scc_di"
4991 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
4992 (match_operator 1 "valid_dbcc_comparison_p"
4993 [(match_operand:DI 2 "general_operand" "ro,r")
4994 (match_operand:DI 3 "general_operand" "r,ro")]))]
4997 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5000 (define_insn "scc_di_5200"
5001 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5002 (match_operator 1 "valid_dbcc_comparison_p"
5003 [(match_operand:DI 2 "general_operand" "ro,r")
5004 (match_operand:DI 3 "general_operand" "r,ro")]))]
5007 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5010 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5011 ;; memory, but we cannot allow it to be in memory in case the address
5012 ;; needs to be reloaded.
5014 (define_expand "seq"
5015 [(set (match_operand:QI 0 "register_operand" "")
5016 (eq:QI (cc0) (const_int 0)))]
5019 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5021 m68k_last_compare_had_fp_operands = 0;
5027 [(set (match_operand:QI 0 "register_operand" "=d")
5028 (eq:QI (cc0) (const_int 0)))]
5031 cc_status = cc_prev_status;
5032 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5035 (define_expand "sne"
5036 [(set (match_operand:QI 0 "register_operand" "")
5037 (ne:QI (cc0) (const_int 0)))]
5040 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5042 m68k_last_compare_had_fp_operands = 0;
5048 [(set (match_operand:QI 0 "register_operand" "=d")
5049 (ne:QI (cc0) (const_int 0)))]
5052 cc_status = cc_prev_status;
5053 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5056 (define_expand "sgt"
5057 [(set (match_operand:QI 0 "register_operand" "")
5058 (gt:QI (cc0) (const_int 0)))]
5061 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5063 m68k_last_compare_had_fp_operands = 0;
5069 [(set (match_operand:QI 0 "register_operand" "=d")
5070 (gt:QI (cc0) (const_int 0)))]
5073 cc_status = cc_prev_status;
5074 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5077 (define_expand "sgtu"
5078 [(set (match_operand:QI 0 "register_operand" "")
5079 (gtu:QI (cc0) (const_int 0)))]
5084 [(set (match_operand:QI 0 "register_operand" "=d")
5085 (gtu:QI (cc0) (const_int 0)))]
5088 cc_status = cc_prev_status;
5092 (define_expand "slt"
5093 [(set (match_operand:QI 0 "register_operand" "")
5094 (lt:QI (cc0) (const_int 0)))]
5097 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5099 m68k_last_compare_had_fp_operands = 0;
5105 [(set (match_operand:QI 0 "register_operand" "=d")
5106 (lt:QI (cc0) (const_int 0)))]
5109 cc_status = cc_prev_status;
5110 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5113 (define_expand "sltu"
5114 [(set (match_operand:QI 0 "register_operand" "")
5115 (ltu:QI (cc0) (const_int 0)))]
5120 [(set (match_operand:QI 0 "register_operand" "=d")
5121 (ltu:QI (cc0) (const_int 0)))]
5124 cc_status = cc_prev_status;
5128 (define_expand "sge"
5129 [(set (match_operand:QI 0 "register_operand" "")
5130 (ge:QI (cc0) (const_int 0)))]
5133 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5135 m68k_last_compare_had_fp_operands = 0;
5141 [(set (match_operand:QI 0 "register_operand" "=d")
5142 (ge:QI (cc0) (const_int 0)))]
5145 cc_status = cc_prev_status;
5146 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5149 (define_expand "sgeu"
5150 [(set (match_operand:QI 0 "register_operand" "")
5151 (geu:QI (cc0) (const_int 0)))]
5156 [(set (match_operand:QI 0 "register_operand" "=d")
5157 (geu:QI (cc0) (const_int 0)))]
5160 cc_status = cc_prev_status;
5164 (define_expand "sle"
5165 [(set (match_operand:QI 0 "register_operand" "")
5166 (le:QI (cc0) (const_int 0)))]
5169 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5171 m68k_last_compare_had_fp_operands = 0;
5177 [(set (match_operand:QI 0 "register_operand" "=d")
5178 (le:QI (cc0) (const_int 0)))]
5181 cc_status = cc_prev_status;
5182 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5185 (define_expand "sleu"
5186 [(set (match_operand:QI 0 "register_operand" "")
5187 (leu:QI (cc0) (const_int 0)))]
5192 [(set (match_operand:QI 0 "register_operand" "=d")
5193 (leu:QI (cc0) (const_int 0)))]
5196 cc_status = cc_prev_status;
5200 (define_expand "sordered"
5201 [(set (match_operand:QI 0 "register_operand" "")
5202 (ordered:QI (cc0) (const_int 0)))]
5203 "TARGET_68881 && !TARGET_68060"
5205 gcc_assert (m68k_last_compare_had_fp_operands);
5206 m68k_last_compare_had_fp_operands = 0;
5209 (define_insn "*sordered_1"
5210 [(set (match_operand:QI 0 "register_operand" "=d")
5211 (ordered:QI (cc0) (const_int 0)))]
5212 "TARGET_68881 && !TARGET_68060"
5214 cc_status = cc_prev_status;
5218 (define_expand "sunordered"
5219 [(set (match_operand:QI 0 "register_operand" "")
5220 (unordered:QI (cc0) (const_int 0)))]
5221 "TARGET_68881 && !TARGET_68060"
5223 gcc_assert (m68k_last_compare_had_fp_operands);
5224 m68k_last_compare_had_fp_operands = 0;
5227 (define_insn "*sunordered_1"
5228 [(set (match_operand:QI 0 "register_operand" "=d")
5229 (unordered:QI (cc0) (const_int 0)))]
5230 "TARGET_68881 && !TARGET_68060"
5232 cc_status = cc_prev_status;
5236 (define_expand "suneq"
5237 [(set (match_operand:QI 0 "register_operand" "")
5238 (uneq:QI (cc0) (const_int 0)))]
5239 "TARGET_68881 && !TARGET_68060"
5241 gcc_assert (m68k_last_compare_had_fp_operands);
5242 m68k_last_compare_had_fp_operands = 0;
5245 (define_insn "*suneq_1"
5246 [(set (match_operand:QI 0 "register_operand" "=d")
5247 (uneq:QI (cc0) (const_int 0)))]
5248 "TARGET_68881 && !TARGET_68060"
5250 cc_status = cc_prev_status;
5254 (define_expand "sunge"
5255 [(set (match_operand:QI 0 "register_operand" "")
5256 (unge:QI (cc0) (const_int 0)))]
5257 "TARGET_68881 && !TARGET_68060"
5259 gcc_assert (m68k_last_compare_had_fp_operands);
5260 m68k_last_compare_had_fp_operands = 0;
5263 (define_insn "*sunge_1"
5264 [(set (match_operand:QI 0 "register_operand" "=d")
5265 (unge:QI (cc0) (const_int 0)))]
5266 "TARGET_68881 && !TARGET_68060"
5268 cc_status = cc_prev_status;
5272 (define_expand "sungt"
5273 [(set (match_operand:QI 0 "register_operand" "")
5274 (ungt:QI (cc0) (const_int 0)))]
5275 "TARGET_68881 && !TARGET_68060"
5277 gcc_assert (m68k_last_compare_had_fp_operands);
5278 m68k_last_compare_had_fp_operands = 0;
5281 (define_insn "*sungt_1"
5282 [(set (match_operand:QI 0 "register_operand" "=d")
5283 (ungt:QI (cc0) (const_int 0)))]
5284 "TARGET_68881 && !TARGET_68060"
5286 cc_status = cc_prev_status;
5290 (define_expand "sunle"
5291 [(set (match_operand:QI 0 "register_operand" "")
5292 (unle:QI (cc0) (const_int 0)))]
5293 "TARGET_68881 && !TARGET_68060"
5295 gcc_assert (m68k_last_compare_had_fp_operands);
5296 m68k_last_compare_had_fp_operands = 0;
5299 (define_insn "*sunle_1"
5300 [(set (match_operand:QI 0 "register_operand" "=d")
5301 (unle:QI (cc0) (const_int 0)))]
5302 "TARGET_68881 && !TARGET_68060"
5304 cc_status = cc_prev_status;
5308 (define_expand "sunlt"
5309 [(set (match_operand:QI 0 "register_operand" "")
5310 (unlt:QI (cc0) (const_int 0)))]
5311 "TARGET_68881 && !TARGET_68060"
5313 gcc_assert (m68k_last_compare_had_fp_operands);
5314 m68k_last_compare_had_fp_operands = 0;
5317 (define_insn "*sunlt_1"
5318 [(set (match_operand:QI 0 "register_operand" "=d")
5319 (unlt:QI (cc0) (const_int 0)))]
5320 "TARGET_68881 && !TARGET_68060"
5322 cc_status = cc_prev_status;
5326 (define_expand "sltgt"
5327 [(set (match_operand:QI 0 "register_operand" "")
5328 (ltgt:QI (cc0) (const_int 0)))]
5329 "TARGET_68881 && !TARGET_68060"
5331 gcc_assert (m68k_last_compare_had_fp_operands);
5332 m68k_last_compare_had_fp_operands = 0;
5335 (define_insn "*sltgt_1"
5336 [(set (match_operand:QI 0 "register_operand" "=d")
5337 (ltgt:QI (cc0) (const_int 0)))]
5338 "TARGET_68881 && !TARGET_68060"
5340 cc_status = cc_prev_status;
5344 (define_insn "*fsogt_1"
5345 [(set (match_operand:QI 0 "register_operand" "=d")
5346 (not:QI (unle:QI (cc0) (const_int 0))))]
5347 "TARGET_68881 && !TARGET_68060"
5349 cc_status = cc_prev_status;
5353 (define_insn "*fsoge_1"
5354 [(set (match_operand:QI 0 "register_operand" "=d")
5355 (not:QI (unlt:QI (cc0) (const_int 0))))]
5356 "TARGET_68881 && !TARGET_68060"
5358 cc_status = cc_prev_status;
5362 (define_insn "*fsolt_1"
5363 [(set (match_operand:QI 0 "register_operand" "=d")
5364 (not:QI (unge:QI (cc0) (const_int 0))))]
5365 "TARGET_68881 && !TARGET_68060"
5367 cc_status = cc_prev_status;
5371 (define_insn "*fsole_1"
5372 [(set (match_operand:QI 0 "register_operand" "=d")
5373 (not:QI (ungt:QI (cc0) (const_int 0))))]
5374 "TARGET_68881 && !TARGET_68060"
5376 cc_status = cc_prev_status;
5380 ;; Basic conditional jump instructions.
5382 (define_insn "beq0_di"
5384 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
5386 (label_ref (match_operand 1 "" ","))
5388 (clobber (match_scratch:SI 2 "=d,d"))]
5392 if (which_alternative == 1)
5395 return "move%.l %0,%2\;or%.l %0,%2\;jbeq %l1";
5397 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5399 if ((cc_prev_status.value1
5400 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5401 || (cc_prev_status.value2
5402 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5404 cc_status = cc_prev_status;
5405 return MOTOROLA ? "jbeq %l1" : "jeq %l1";
5407 if (GET_CODE (operands[0]) == REG)
5408 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5410 operands[3] = adjust_address (operands[0], SImode, 4);
5411 if (! ADDRESS_REG_P (operands[0]))
5413 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5415 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5418 return "or%.l %0,%2\;jbeq %l1";
5420 return "or%.l %0,%2\;jeq %l1";
5425 return "or%.l %3,%2\;jbeq %l1";
5427 return "or%.l %3,%2\;jeq %l1";
5431 return "move%.l %0,%2\;or%.l %3,%2\;jbeq %l1";
5433 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5435 operands[4] = gen_label_rtx();
5436 if (TARGET_68020 || TARGET_COLDFIRE)
5439 output_asm_insn ("tst%.l %0\;jbne %l4\;tst%.l %3\;jbeq %l1", operands);
5441 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
5446 output_asm_insn ("cmp%.w #0,%0\;jbne %l4\;cmp%.w #0,%3\;jbeq %l1", operands);
5448 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
5450 (*targetm.asm_out.internal_label) (asm_out_file, "L",
5451 CODE_LABEL_NUMBER (operands[4]));
5455 (define_insn "bne0_di"
5457 (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
5459 (label_ref (match_operand 1 "" ","))
5461 (clobber (match_scratch:SI 2 "=d,X"))]
5464 if ((cc_prev_status.value1
5465 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5466 || (cc_prev_status.value2
5467 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5469 cc_status = cc_prev_status;
5470 return MOTOROLA ? "jbne %l1" : "jne %l1";
5473 if (GET_CODE (operands[0]) == REG)
5474 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5476 operands[3] = adjust_address (operands[0], SImode, 4);
5477 if (!ADDRESS_REG_P (operands[0]))
5479 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5481 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5484 return "or%.l %0,%2\;jbne %l1";
5486 return "or%.l %0,%2\;jne %l1";
5491 return "or%.l %3,%2\;jbne %l1";
5493 return "or%.l %3,%2\;jne %l1";
5497 return "move%.l %0,%2\;or%.l %3,%2\;jbne %l1";
5499 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
5501 if (TARGET_68020 || TARGET_COLDFIRE)
5504 return "tst%.l %0\;jbne %l1\;tst%.l %3\;jbne %l1";
5506 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
5511 return "cmp%.w #0,%0\;jbne %l1\;cmp%.w #0,%3\;jbne %l1";
5513 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
5517 (define_insn "bge0_di"
5519 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
5521 (label_ref (match_operand 1 "" ""))
5525 if ((cc_prev_status.value1
5526 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5527 || (cc_prev_status.value2
5528 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5530 cc_status = cc_prev_status;
5531 if (cc_status.flags & CC_REVERSED)
5533 return MOTOROLA ? "jble %l1" : "jle %l1";
5537 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5541 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5542 output_asm_insn("tst%.l %0", operands);
5545 /* On an address reg, cmpw may replace cmpl. */
5546 output_asm_insn("cmp%.w #0,%0", operands);
5548 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5551 (define_insn "blt0_di"
5553 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
5555 (label_ref (match_operand 1 "" ""))
5559 if ((cc_prev_status.value1
5560 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5561 || (cc_prev_status.value2
5562 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5564 cc_status = cc_prev_status;
5565 if (cc_status.flags & CC_REVERSED)
5567 return MOTOROLA ? "jbgt %l1" : "jgt %l1";
5571 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5575 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5576 output_asm_insn("tst%.l %0", operands);
5579 /* On an address reg, cmpw may replace cmpl. */
5580 output_asm_insn("cmp%.w #0,%0", operands);
5583 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5588 (if_then_else (eq (cc0)
5590 (label_ref (match_operand 0 "" ""))
5595 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5597 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5602 (if_then_else (ne (cc0)
5604 (label_ref (match_operand 0 "" ""))
5609 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5611 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5616 (if_then_else (gt (cc0)
5618 (label_ref (match_operand 0 "" ""))
5623 OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0);
5625 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
5630 (if_then_else (gtu (cc0)
5632 (label_ref (match_operand 0 "" ""))
5636 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5641 (if_then_else (lt (cc0)
5643 (label_ref (match_operand 0 "" ""))
5648 OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0");
5650 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
5655 (if_then_else (ltu (cc0)
5657 (label_ref (match_operand 0 "" ""))
5661 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5666 (if_then_else (ge (cc0)
5668 (label_ref (match_operand 0 "" ""))
5673 OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0");
5675 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
5680 (if_then_else (geu (cc0)
5682 (label_ref (match_operand 0 "" ""))
5686 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5691 (if_then_else (le (cc0)
5693 (label_ref (match_operand 0 "" ""))
5698 OUTPUT_JUMP ("jble %l0", "fble %l0", 0);
5700 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
5705 (if_then_else (leu (cc0)
5707 (label_ref (match_operand 0 "" ""))
5711 return MOTOROLA ? "jbls %l0" : "jls %l0";
5714 (define_insn "bordered"
5716 (if_then_else (ordered (cc0) (const_int 0))
5717 (label_ref (match_operand 0 "" ""))
5721 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5722 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5725 (define_insn "bunordered"
5727 (if_then_else (unordered (cc0) (const_int 0))
5728 (label_ref (match_operand 0 "" ""))
5732 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5733 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5736 (define_insn "buneq"
5738 (if_then_else (uneq (cc0) (const_int 0))
5739 (label_ref (match_operand 0 "" ""))
5743 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5744 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5747 (define_insn "bunge"
5749 (if_then_else (unge (cc0) (const_int 0))
5750 (label_ref (match_operand 0 "" ""))
5754 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5755 return MOTOROLA ? "fbuge %l0" : "fjuge %l0";
5758 (define_insn "bungt"
5760 (if_then_else (ungt (cc0) (const_int 0))
5761 (label_ref (match_operand 0 "" ""))
5765 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5766 return MOTOROLA ? "fbugt %l0" : "fjugt %l0";
5769 (define_insn "bunle"
5771 (if_then_else (unle (cc0) (const_int 0))
5772 (label_ref (match_operand 0 "" ""))
5776 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5777 return MOTOROLA ? "fbule %l0" : "fjule %l0";
5780 (define_insn "bunlt"
5782 (if_then_else (unlt (cc0) (const_int 0))
5783 (label_ref (match_operand 0 "" ""))
5787 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5788 return MOTOROLA ? "fbult %l0" : "fjult %l0";
5791 (define_insn "bltgt"
5793 (if_then_else (ltgt (cc0) (const_int 0))
5794 (label_ref (match_operand 0 "" ""))
5798 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5799 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5802 ;; Negated conditional jump instructions.
5806 (if_then_else (eq (cc0)
5809 (label_ref (match_operand 0 "" ""))))]
5813 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5815 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5820 (if_then_else (ne (cc0)
5823 (label_ref (match_operand 0 "" ""))))]
5827 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5829 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5834 (if_then_else (gt (cc0)
5837 (label_ref (match_operand 0 "" ""))))]
5841 OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0);
5843 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
5848 (if_then_else (gtu (cc0)
5851 (label_ref (match_operand 0 "" ""))))]
5854 return MOTOROLA ? "jbls %l0" : "jls %l0";
5859 (if_then_else (lt (cc0)
5862 (label_ref (match_operand 0 "" ""))))]
5866 OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0");
5868 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
5873 (if_then_else (ltu (cc0)
5876 (label_ref (match_operand 0 "" ""))))]
5879 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5884 (if_then_else (ge (cc0)
5887 (label_ref (match_operand 0 "" ""))))]
5891 OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0");
5893 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
5898 (if_then_else (geu (cc0)
5901 (label_ref (match_operand 0 "" ""))))]
5904 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5909 (if_then_else (le (cc0)
5912 (label_ref (match_operand 0 "" ""))))]
5916 OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0);
5918 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
5923 (if_then_else (leu (cc0)
5926 (label_ref (match_operand 0 "" ""))))]
5929 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5932 (define_insn "*bordered_rev"
5934 (if_then_else (ordered (cc0) (const_int 0))
5936 (label_ref (match_operand 0 "" ""))))]
5939 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5940 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5943 (define_insn "*bunordered_rev"
5945 (if_then_else (unordered (cc0) (const_int 0))
5947 (label_ref (match_operand 0 "" ""))))]
5950 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5951 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5954 (define_insn "*buneq_rev"
5956 (if_then_else (uneq (cc0) (const_int 0))
5958 (label_ref (match_operand 0 "" ""))))]
5961 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5962 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5965 (define_insn "*bunge_rev"
5967 (if_then_else (unge (cc0) (const_int 0))
5969 (label_ref (match_operand 0 "" ""))))]
5972 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5973 return MOTOROLA ? "fbolt %l0" : "fjolt %l0";
5976 (define_insn "*bunle_rev"
5978 (if_then_else (unle (cc0) (const_int 0))
5980 (label_ref (match_operand 0 "" ""))))]
5983 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5984 return MOTOROLA ? "fbogt %l0" : "fjogt %l0";
5987 (define_insn "*bunlt_rev"
5989 (if_then_else (unlt (cc0) (const_int 0))
5991 (label_ref (match_operand 0 "" ""))))]
5994 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5995 return MOTOROLA ? "fboge %l0" : "fjoge %l0";
5998 (define_insn "*bltgt_rev"
6000 (if_then_else (ltgt (cc0) (const_int 0))
6002 (label_ref (match_operand 0 "" ""))))]
6005 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6006 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
6009 ;; Unconditional and other jump instructions
6012 (label_ref (match_operand 0 "" "")))]
6015 return MOTOROLA ? "jbra %l0" : "jra %l0";
6018 (define_expand "tablejump"
6019 [(parallel [(set (pc) (match_operand 0 "" ""))
6020 (use (label_ref (match_operand 1 "" "")))])]
6023 #ifdef CASE_VECTOR_PC_RELATIVE
6024 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6025 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6029 ;; Jump to variable address from dispatch table of absolute addresses.
6031 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6032 (use (label_ref (match_operand 1 "" "")))]
6035 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6038 ;; Jump to variable address from dispatch table of relative addresses.
6042 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6043 (use (label_ref (match_operand 1 "" "")))]
6046 #ifdef ASM_RETURN_CASE_JUMP
6047 ASM_RETURN_CASE_JUMP;
6049 if (TARGET_COLDFIRE)
6051 if (ADDRESS_REG_P (operands[0]))
6052 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6054 return "ext%.l %0\;jmp (2,pc,%0.l)";
6056 return "extl %0\;jmp pc@(2,%0:l)";
6059 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6063 ;; Decrement-and-branch insns.
6067 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6069 (label_ref (match_operand 1 "" ""))
6072 (plus:HI (match_dup 0)
6077 if (DATA_REG_P (operands[0]))
6078 return "dbra %0,%l1";
6079 if (GET_CODE (operands[0]) == MEM)
6081 "subq%.w #1,%0\;jbcc %l1" :
6082 "subqw #1,%0\;jcc %l1";
6084 "subq%.w #1,%0\;cmp%.w #-1,%0\;jbne %l1" :
6085 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6091 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6093 (label_ref (match_operand 1 "" ""))
6096 (plus:SI (match_dup 0)
6101 if (DATA_REG_P (operands[0]))
6103 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6104 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6105 if (GET_CODE (operands[0]) == MEM)
6107 "subq%.l #1,%0\;jbcc %l1" :
6108 "subq%.l #1,%0\;jcc %l1";
6110 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6111 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6114 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6119 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6122 (label_ref (match_operand 1 "" ""))
6125 (plus:HI (match_dup 0)
6127 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6130 if (DATA_REG_P (operands[0]))
6131 return "dbra %0,%l1";
6132 if (GET_CODE (operands[0]) == MEM)
6134 "subq%.w #1,%0\;jbcc %l1" :
6135 "subq%.w #1,%0\;jcc %l1";
6137 "subq.w #1,%0\;cmp.w #-1,%0\;jbne %l1" :
6138 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6141 (define_expand "decrement_and_branch_until_zero"
6142 [(parallel [(set (pc)
6144 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6147 (label_ref (match_operand 1 "" ""))
6150 (plus:SI (match_dup 0)
6158 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6161 (label_ref (match_operand 1 "" ""))
6164 (plus:SI (match_dup 0)
6166 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6169 if (DATA_REG_P (operands[0]))
6171 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6172 "dbra %0,%l1\;clr%.w %0\;subql #1,%0\;jcc %l1";
6173 if (GET_CODE (operands[0]) == MEM)
6175 "subq%.l #1,%0\;jbcc %l1" :
6176 "subql #1,%0\;jcc %l1";
6178 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6179 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6183 ;; For PIC calls, in order to be able to support
6184 ;; dynamic linker LAZY BINDING, all the procedure calls need to go
6185 ;; through the PLT (Procedure Linkage Table) section in PIC mode.
6187 ;; PIC calls are handled by loading the address of the function into a
6188 ;; register (via movsi), then emitting a register indirect call using
6189 ;; the "jsr" function call syntax.
6191 ;; When outputting MIT syntax (e.g. on Suns), we add a bogus extra
6192 ;; operand to the jbsr statement to indicate that this call should
6193 ;; go through the PLT (why? because this is the way that Sun does it).
6195 ;; We have different patterns for PIC calls and non-PIC calls. The
6196 ;; different patterns are only used to choose the right syntax.
6198 ;; The svr4 m68k assembler recognizes this syntax: `bsr FUNC@PLTPC' and it
6199 ;; will create the correct relocation entry (R_68K_PLT32) for `FUNC',
6200 ;; that tells the linker editor to create an entry for `FUNC' in PLT
6201 ;; section at link time. However, all global objects reference are still
6202 ;; done by using `OBJ@GOT'. So, the goal here is to output the function
6203 ;; call operand as `FUNC@PLTPC', but output object operand as `OBJ@GOT'.
6204 ;; We need to have a way to differentiate these two different operands.
6206 ;; The strategy I use here is to use SYMBOL_REF_FLAG to differentiate
6207 ;; these two different operands. The macro LEGITIMATE_PIC_OPERAND_P needs
6208 ;; to be changed to recognize function calls symbol_ref operand as a valid
6209 ;; PIC operand (by checking whether SYMBOL_REF_FLAG is set). This will
6210 ;; avoid the compiler to load this symbol_ref operand into a register.
6211 ;; Remember, the operand "foo@PLTPC" cannot be called via jsr directly
6212 ;; since the value is a PC relative offset, not a real address.
6214 ;; All global objects are treated in the similar way as in SUN3. The only
6215 ;; difference is: on m68k svr4, the reference of such global object needs
6216 ;; to end with a suffix "@GOT" so the assembler and linker know to create
6217 ;; an entry for it in GOT (Global Offset Table) section. This is done in
6220 ;; Call subroutine with no return value.
6221 (define_expand "call"
6222 [(call (match_operand:QI 0 "memory_operand" "")
6223 (match_operand:SI 1 "general_operand" ""))]
6224 ;; Operand 1 not really used on the m68000.
6228 if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
6229 SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1;
6232 ;; This is a normal call sequence.
6234 [(call (match_operand:QI 0 "memory_operand" "o")
6235 (match_operand:SI 1 "general_operand" "g"))]
6236 ;; Operand 1 not really used on the m68000.
6240 #if MOTOROLA && !defined (USE_GAS)
6247 ;; This is a PIC call sequence.
6249 [(call (match_operand:QI 0 "memory_operand" "o")
6250 (match_operand:SI 1 "general_operand" "g"))]
6251 ;; Operand 1 not really used on the m68000.
6255 m68k_output_pic_call(operands[0]);
6259 ;; Call subroutine, returning value in operand 0
6260 ;; (which must be a hard register).
6261 ;; See comments before "call" regarding PIC calls.
6262 (define_expand "call_value"
6263 [(set (match_operand 0 "" "")
6264 (call (match_operand:QI 1 "memory_operand" "")
6265 (match_operand:SI 2 "general_operand" "")))]
6266 ;; Operand 2 not really used on the m68000.
6269 if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
6270 SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1;
6273 ;; This is a normal call_value
6275 [(set (match_operand 0 "" "=rf")
6276 (call (match_operand:QI 1 "memory_operand" "o")
6277 (match_operand:SI 2 "general_operand" "g")))]
6278 ;; Operand 2 not really used on the m68000.
6281 #if MOTOROLA && !defined (USE_GAS)
6288 ;; This is a PIC call_value
6290 [(set (match_operand 0 "" "=rf")
6291 (call (match_operand:QI 1 "memory_operand" "o")
6292 (match_operand:SI 2 "general_operand" "g")))]
6293 ;; Operand 2 not really used on the m68000.
6296 m68k_output_pic_call(operands[1]);
6300 ;; Call subroutine returning any type.
6302 (define_expand "untyped_call"
6303 [(parallel [(call (match_operand 0 "" "")
6305 (match_operand 1 "" "")
6306 (match_operand 2 "" "")])]
6307 "NEEDS_UNTYPED_CALL"
6311 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6313 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6315 rtx set = XVECEXP (operands[2], 0, i);
6316 emit_move_insn (SET_DEST (set), SET_SRC (set));
6319 /* The optimizer does not know that the call sets the function value
6320 registers we stored in the result block. We avoid problems by
6321 claiming that all hard registers are used and clobbered at this
6323 emit_insn (gen_blockage ());
6328 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6329 ;; all of memory. This blocks insns from being moved across this point.
6331 (define_insn "blockage"
6332 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6341 ;; Used for frameless functions which save no regs and allocate no locals.
6342 (define_insn "return"
6346 if (current_function_pops_args == 0)
6348 operands[0] = GEN_INT (current_function_pops_args);
6352 (define_insn "indirect_jump"
6353 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
6357 ;; This should not be used unless the add/sub insns can't be.
6360 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
6361 (match_operand:QI 1 "address_operand" "p"))]
6365 ;; This is the first machine-dependent peephole optimization.
6366 ;; It is useful when a floating value is returned from a function call
6367 ;; and then is moved into an FP register.
6368 ;; But it is mainly intended to test the support for these optimizations.
6371 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
6372 (set (match_operand:DF 0 "register_operand" "=f")
6373 (match_operand:DF 1 "register_operand" "ad"))]
6374 "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
6377 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6378 output_asm_insn ("move%.l %1,%@", xoperands);
6379 output_asm_insn ("move%.l %1,%-", operands);
6380 return "fmove%.d %+,%0";
6383 ;; Optimize a stack-adjust followed by a push of an argument.
6384 ;; This is said to happen frequently with -msoft-float
6385 ;; when there are consecutive library calls.
6388 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6389 (match_operand:SI 0 "const_int_operand" "n")))
6390 (set (match_operand:SF 1 "push_operand" "=m")
6391 (match_operand:SF 2 "general_operand" "rmfF"))]
6392 "INTVAL (operands[0]) >= 4
6393 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6395 if (INTVAL (operands[0]) > 4)
6398 xoperands[0] = stack_pointer_rtx;
6399 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6400 if (INTVAL (xoperands[1]) <= 8)
6402 if (!TARGET_COLDFIRE)
6403 output_asm_insn ("addq%.w %1,%0", xoperands);
6405 output_asm_insn ("addq%.l %1,%0", xoperands);
6407 else if (TARGET_CPU32 && INTVAL (xoperands[1]) <= 16)
6409 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6410 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6412 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6415 output_asm_insn ("add%.w %1,%0", xoperands);
6417 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6419 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6422 output_asm_insn ("add%.l %1,%0", xoperands);
6424 if (FP_REG_P (operands[2]))
6425 return "fmove%.s %2,%@";
6426 return "move%.l %2,%@";
6429 ;; Speed up stack adjust followed by a fullword fixedpoint push.
6432 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6433 (match_operand:SI 0 "const_int_operand" "n")))
6434 (set (match_operand:SI 1 "push_operand" "=m")
6435 (match_operand:SI 2 "general_operand" "g"))]
6436 "INTVAL (operands[0]) >= 4
6437 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6439 if (INTVAL (operands[0]) > 4)
6442 xoperands[0] = stack_pointer_rtx;
6443 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6444 if (INTVAL (xoperands[1]) <= 8)
6446 if (!TARGET_COLDFIRE)
6447 output_asm_insn ("addq%.w %1,%0", xoperands);
6449 output_asm_insn ("addq%.l %1,%0", xoperands);
6451 else if (TARGET_CPU32 && INTVAL (xoperands[1]) <= 16)
6453 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6454 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6456 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6459 output_asm_insn ("add%.w %1,%0", xoperands);
6461 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6463 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6466 output_asm_insn ("add%.l %1,%0", xoperands);
6468 if (operands[2] == const0_rtx)
6470 return "move%.l %2,%@";
6473 ;; Speed up pushing a single byte but leaving four bytes of space.
6476 [(set (mem:QI (pre_dec:SI (reg:SI SP_REG)))
6477 (match_operand:QI 1 "general_operand" "dami"))
6478 (set (reg:SI SP_REG) (minus:SI (reg:SI SP_REG) (const_int 2)))]
6479 "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
6483 if (GET_CODE (operands[1]) == REG)
6484 return "move%.l %1,%-";
6486 xoperands[1] = operands[1];
6488 = gen_rtx_MEM (QImode, plus_constant (stack_pointer_rtx, 3));
6489 xoperands[3] = stack_pointer_rtx;
6490 if (!TARGET_COLDFIRE)
6491 output_asm_insn ("subq%.w #4,%3\;move%.b %1,%2", xoperands);
6493 output_asm_insn ("subq%.l #4,%3\;move%.b %1,%2", xoperands);
6498 [(set (match_operand:SI 0 "register_operand" "=d")
6500 (set (strict_low_part (subreg:HI (match_dup 0) 2))
6501 (match_operand:HI 1 "general_operand" "rmn"))]
6502 "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
6504 if (GET_CODE (operands[1]) == CONST_INT)
6506 if (operands[1] == const0_rtx
6507 && (DATA_REG_P (operands[0])
6508 || GET_CODE (operands[0]) == MEM)
6509 /* clr insns on 68000 read before writing.
6510 This isn't so on the 68010, but we have no TARGET_68010. */
6511 && ((TARGET_68020 || TARGET_COLDFIRE)
6512 || !(GET_CODE (operands[0]) == MEM
6513 && MEM_VOLATILE_P (operands[0]))))
6516 return "move%.w %1,%0";
6524 ;; jCC label ; abnormal loop termination
6525 ;; dbra dN, loop ; normal loop termination
6533 ;; Which moves the jCC condition outside the inner loop for free.
6537 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6538 [(cc0) (const_int 0)])
6539 (label_ref (match_operand 2 "" ""))
6544 (ne (match_operand:HI 0 "register_operand" "")
6546 (label_ref (match_operand 1 "" ""))
6549 (plus:HI (match_dup 0)
6551 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6554 output_dbcc_and_branch (operands);
6559 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6560 [(cc0) (const_int 0)])
6561 (label_ref (match_operand 2 "" ""))
6566 (ne (match_operand:SI 0 "register_operand" "")
6568 (label_ref (match_operand 1 "" ""))
6571 (plus:SI (match_dup 0)
6573 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6576 output_dbcc_and_branch (operands);
6581 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6582 [(cc0) (const_int 0)])
6583 (label_ref (match_operand 2 "" ""))
6588 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
6591 (label_ref (match_operand 1 "" ""))
6594 (plus:HI (match_dup 0)
6596 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6599 output_dbcc_and_branch (operands);
6604 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6605 [(cc0) (const_int 0)])
6606 (label_ref (match_operand 2 "" ""))
6611 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
6614 (label_ref (match_operand 1 "" ""))
6617 (plus:SI (match_dup 0)
6619 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6622 output_dbcc_and_branch (operands);
6627 (define_expand "tstxf"
6629 (match_operand:XF 0 "nonimmediate_operand" ""))]
6631 "m68k_last_compare_had_fp_operands = 1;")
6635 (match_operand:XF 0 "nonimmediate_operand" "fm"))]
6638 cc_status.flags = CC_IN_68881;
6639 return "ftst%.x %0";
6642 (define_expand "cmpxf"
6644 (compare (match_operand:XF 0 "nonimmediate_operand" "")
6645 (match_operand:XF 1 "nonimmediate_operand" "")))]
6647 "m68k_last_compare_had_fp_operands = 1;")
6651 (compare (match_operand:XF 0 "nonimmediate_operand" "f,m")
6652 (match_operand:XF 1 "nonimmediate_operand" "fm,f")))]
6655 cc_status.flags = CC_IN_68881;
6656 if (REG_P (operands[0]))
6658 if (REG_P (operands[1]))
6659 return "fcmp%.x %1,%0";
6661 return "fcmp%.x %f1,%0";
6663 cc_status.flags |= CC_REVERSED;
6664 return "fcmp%.x %f0,%1";
6667 (define_insn "extendsfxf2"
6668 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6669 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
6672 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6674 if (REGNO (operands[0]) == REGNO (operands[1]))
6676 /* Extending float to double in an fp-reg is a no-op.
6677 NOTICE_UPDATE_CC has already assumed that the
6678 cc will be set. So cancel what it did. */
6679 cc_status = cc_prev_status;
6682 return "f%$move%.x %1,%0";
6684 if (FP_REG_P (operands[0]))
6686 if (FP_REG_P (operands[1]))
6687 return "f%$move%.x %1,%0";
6688 else if (ADDRESS_REG_P (operands[1]))
6689 return "move%.l %1,%-\;f%$move%.s %+,%0";
6690 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
6691 return output_move_const_single (operands);
6692 return "f%$move%.s %f1,%0";
6694 return "fmove%.x %f1,%0";
6698 (define_insn "extenddfxf2"
6699 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6701 (match_operand:DF 1 "general_operand" "f,rmE")))]
6704 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6706 if (REGNO (operands[0]) == REGNO (operands[1]))
6708 /* Extending float to double in an fp-reg is a no-op.
6709 NOTICE_UPDATE_CC has already assumed that the
6710 cc will be set. So cancel what it did. */
6711 cc_status = cc_prev_status;
6714 return "fmove%.x %1,%0";
6716 if (FP_REG_P (operands[0]))
6718 if (REG_P (operands[1]))
6721 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6722 output_asm_insn ("move%.l %1,%-", xoperands);
6723 output_asm_insn ("move%.l %1,%-", operands);
6724 return "f%&move%.d %+,%0";
6726 if (GET_CODE (operands[1]) == CONST_DOUBLE)
6727 return output_move_const_double (operands);
6728 return "f%&move%.d %f1,%0";
6730 return "fmove%.x %f1,%0";
6733 (define_insn "truncxfdf2"
6734 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
6736 (match_operand:XF 1 "general_operand" "f,f")))]
6739 if (REG_P (operands[0]))
6741 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
6742 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6743 return "move%.l %+,%0";
6745 return "fmove%.d %f1,%0";
6748 (define_insn "truncxfsf2"
6749 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
6751 (match_operand:XF 1 "general_operand" "f")))]
6755 (define_insn "floatsixf2"
6756 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6757 (float:XF (match_operand:SI 1 "general_operand" "dmi")))]
6761 (define_insn "floathixf2"
6762 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6763 (float:XF (match_operand:HI 1 "general_operand" "dmn")))]
6767 (define_insn "floatqixf2"
6768 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6769 (float:XF (match_operand:QI 1 "general_operand" "dmn")))]
6773 (define_insn "ftruncxf2"
6774 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6775 (fix:XF (match_operand:XF 1 "general_operand" "fFm")))]
6778 if (FP_REG_P (operands[1]))
6779 return "fintrz%.x %f1,%0";
6780 return "fintrz%.x %f1,%0";
6783 (define_insn "fixxfqi2"
6784 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
6785 (fix:QI (match_operand:XF 1 "general_operand" "f")))]
6789 (define_insn "fixxfhi2"
6790 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
6791 (fix:HI (match_operand:XF 1 "general_operand" "f")))]
6795 (define_insn "fixxfsi2"
6796 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
6797 (fix:SI (match_operand:XF 1 "general_operand" "f")))]
6802 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6803 (plus:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
6804 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6809 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6810 (plus:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
6811 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6816 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6817 (plus:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
6818 (match_operand:XF 1 "general_operand" "0")))]
6822 (define_insn "addxf3"
6823 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6824 (plus:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
6825 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6828 if (REG_P (operands[2]))
6829 return "fadd%.x %2,%0";
6830 return "fadd%.x %f2,%0";
6834 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6835 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6836 (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
6841 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6842 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6843 (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
6848 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6849 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6850 (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
6854 (define_insn "subxf3"
6855 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6856 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6857 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6860 if (REG_P (operands[2]))
6861 return "fsub%.x %2,%0";
6862 return "fsub%.x %f2,%0";
6866 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6867 (mult:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
6868 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6873 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6874 (mult:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
6875 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6880 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6881 (mult:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
6882 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6886 (define_insn "mulxf3"
6887 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6888 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
6889 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6892 if (REG_P (operands[2]))
6893 return "fmul%.x %2,%0";
6894 return "fmul%.x %f2,%0";
6898 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6899 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6900 (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
6905 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6906 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6907 (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
6912 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6913 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6914 (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
6918 (define_insn "divxf3"
6919 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6920 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6921 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6924 if (REG_P (operands[2]))
6925 return "fdiv%.x %2,%0";
6926 return "fdiv%.x %f2,%0";
6929 (define_expand "negxf2"
6930 [(set (match_operand:XF 0 "nonimmediate_operand" "")
6931 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
6941 target = operand_subword (operands[0], 0, 1, XFmode);
6942 result = expand_binop (SImode, xor_optab,
6943 operand_subword_force (operands[1], 0, XFmode),
6944 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
6945 gcc_assert (result);
6947 if (result != target)
6948 emit_move_insn (result, target);
6950 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
6951 operand_subword_force (operands[1], 1, XFmode));
6952 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
6953 operand_subword_force (operands[1], 2, XFmode));
6955 insns = get_insns ();
6958 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
6963 (define_insn "negxf2_68881"
6964 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6965 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
6968 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
6969 return "fneg%.x %1,%0";
6970 return "fneg%.x %f1,%0";
6973 (define_expand "absxf2"
6974 [(set (match_operand:XF 0 "nonimmediate_operand" "")
6975 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
6985 target = operand_subword (operands[0], 0, 1, XFmode);
6986 result = expand_binop (SImode, and_optab,
6987 operand_subword_force (operands[1], 0, XFmode),
6988 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
6989 gcc_assert (result);
6991 if (result != target)
6992 emit_move_insn (result, target);
6994 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
6995 operand_subword_force (operands[1], 1, XFmode));
6996 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
6997 operand_subword_force (operands[1], 2, XFmode));
6999 insns = get_insns ();
7002 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
7007 (define_insn "absxf2_68881"
7008 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7009 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
7012 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
7013 return "fabs%.x %1,%0";
7014 return "fabs%.x %f1,%0";
7017 (define_insn "sqrtxf2"
7018 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7019 (sqrt:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
7023 (define_insn "sinsf2"
7024 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
7025 (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] UNSPEC_SIN))]
7026 "TARGET_68881 && flag_unsafe_math_optimizations"
7028 if (FP_REG_P (operands[1]))
7029 return "fsin%.x %1,%0";
7031 return "fsin%.s %1,%0";
7034 (define_insn "sindf2"
7035 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
7036 (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] UNSPEC_SIN))]
7037 "TARGET_68881 && flag_unsafe_math_optimizations"
7039 if (FP_REG_P (operands[1]))
7040 return "fsin%.x %1,%0";
7042 return "fsin%.d %1,%0";
7045 (define_insn "sinxf2"
7046 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7047 (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] UNSPEC_SIN))]
7048 "TARGET_68881 && flag_unsafe_math_optimizations"
7051 (define_insn "cossf2"
7052 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
7053 (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] UNSPEC_COS))]
7054 "TARGET_68881 && flag_unsafe_math_optimizations"
7056 if (FP_REG_P (operands[1]))
7057 return "fcos%.x %1,%0";
7059 return "fcos%.s %1,%0";
7062 (define_insn "cosdf2"
7063 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
7064 (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] UNSPEC_COS))]
7065 "TARGET_68881 && flag_unsafe_math_optimizations"
7067 if (FP_REG_P (operands[1]))
7068 return "fcos%.x %1,%0";
7070 return "fcos%.d %1,%0";
7073 (define_insn "cosxf2"
7074 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7075 (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] UNSPEC_COS))]
7076 "TARGET_68881 && flag_unsafe_math_optimizations"
7080 [(trap_if (const_int -1) (const_int 7))]
7084 (define_insn "conditional_trap"
7085 [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
7086 [(cc0) (const_int 0)])
7087 (match_operand:SI 1 "const_int_operand" "I"))]
7088 "TARGET_68020 && ! flags_in_68881 ()"
7090 switch (GET_CODE (operands[0]))
7092 case EQ: return "trapeq";
7093 case NE: return "trapne";
7094 case GT: return "trapgt";
7095 case GTU: return "traphi";
7096 case LT: return "traplt";
7097 case LTU: return "trapcs";
7098 case GE: return "trapge";
7099 case GEU: return "trapcc";
7100 case LE: return "traple";
7101 case LEU: return "trapls";
7102 default: gcc_unreachable ();