1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
4 ;; Free Software Foundation, Inc.
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; GCC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
23 ;;- Information about MCF5200 port.
25 ;;- The MCF5200 "ColdFire" architecture is a reduced version of the
26 ;;- 68k ISA. Differences include reduced support for byte and word
27 ;;- operands and the removal of BCD, bitfield, rotate, and integer
28 ;;- divide instructions. The TARGET_COLDFIRE flag turns the use of the
29 ;;- removed opcodes and addressing modes off.
33 ;;- instruction definitions
35 ;;- @@The original PO technology requires these to be ordered by speed,
36 ;;- @@ so that assigner will pick the fastest.
38 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
40 ;;- When naming insn's (operand 0 of define_insn) be careful about using
41 ;;- names from other targets machine descriptions.
43 ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
44 ;;- updates for most instructions.
46 ;;- Operand classes for the register allocator:
47 ;;- 'a' one of the address registers can be used.
48 ;;- 'd' one of the data registers can be used.
49 ;;- 'f' one of the m68881 registers can be used
50 ;;- 'r' either a data or an address register can be used.
52 ;;- Immediate Floating point operator constraints
53 ;;- 'G' a floating point constant that is *NOT* one of the standard
54 ;; 68881 constant values (to force calling output_move_const_double
55 ;; to get it from rom if it is a 68881 constant).
57 ;; See the functions standard_XXX_constant_p in output-m68k.c for more
60 ;;- Immediate integer operand constraints:
62 ;;- 'J' -32768 .. 32767
63 ;;- 'K' all integers EXCEPT -128 .. 127
65 ;;- 'M' all integers EXCEPT -256 .. 255
71 ;;- "%." size separator ("." or "") move%.l d0,d1
72 ;;- "%-" push operand "sp@-" move%.l d0,%-
73 ;;- "%+" pop operand "sp@+" move%.l d0,%+
74 ;;- "%@" top of stack "sp@" move%.l d0,%@
75 ;;- "%!" fpcr register
76 ;;- "%$" single-precision fp specifier ("s" or "") f%$add.x fp0,fp1
77 ;;- "%&" double-precision fp specifier ("d" or "") f%&add.x fp0,fp1
79 ;;- Information about 68040 port.
81 ;;- The 68040 executes all 68030 and 68881/2 instructions, but some must
82 ;;- be emulated in software by the OS. It is faster to avoid these
83 ;;- instructions and issue a library call rather than trapping into
84 ;;- the kernel. The affected instructions are fintrz and fscale. The
85 ;;- TARGET_68040 flag turns the use of the opcodes off.
87 ;;- The '040 also implements a set of new floating-point instructions
88 ;;- which specify the rounding precision in the opcode. This finally
89 ;;- permit the 68k series to be truly IEEE compliant, and solves all
90 ;;- issues of excess precision accumulating in the extended registers.
91 ;;- By default, GCC does not use these instructions, since such code will
92 ;;- not run on an '030. To use these instructions, use the -m68040-only
93 ;;- switch. By changing TARGET_DEFAULT to include TARGET_68040_ONLY,
94 ;;- you can make these instructions the default.
96 ;;- These new instructions aren't directly in the md. They are brought
97 ;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather
100 ;;- Information about 68060 port.
102 ;;- The 68060 executes all 68030 and 68881/2 instructions, but some must
103 ;;- be emulated in software by the OS. It is faster to avoid these
104 ;;- instructions and issue a library call rather than trapping into
105 ;;- the kernel. The affected instructions are: divs.l <ea>,Dr:Dq;
106 ;;- divu.l <ea>,Dr:Dq; muls.l <ea>,Dr:Dq; mulu.l <ea>,Dr:Dq; and
107 ;;- fscale. The TARGET_68060 flag turns the use of the opcodes off.
109 ;;- Some of these insn's are composites of several m68000 op codes.
110 ;;- The assembler (or final @@??) insures that the appropriate one is
120 ;; UNSPEC_VOLATILE usage:
123 [(UNSPECV_BLOCKAGE 0)
127 [(set (match_operand:DF 0 "push_operand" "=m")
128 (match_operand:DF 1 "general_operand" "ro<>fyE"))]
131 if (FP_REG_P (operands[1]))
132 return "fmove%.d %f1,%0";
133 return output_move_double (operands);
136 (define_insn "pushdi"
137 [(set (match_operand:DI 0 "push_operand" "=m")
138 (match_operand:DI 1 "general_operand" "ro<>Fyi"))]
141 return output_move_double (operands);
144 ;; We don't want to allow a constant operand for test insns because
145 ;; (set (cc0) (const_int foo)) has no mode information. Such insns will
146 ;; be folded while optimizing anyway.
148 (define_expand "tstdi"
149 [(parallel [(set (cc0)
150 (match_operand:DI 0 "nonimmediate_operand" ""))
151 (clobber (match_scratch:SI 1 ""))
152 (clobber (match_scratch:DI 2 ""))])]
154 "m68k_last_compare_had_fp_operands = 0;")
158 (match_operand:DI 0 "nonimmediate_operand" "am,d"))
159 (clobber (match_scratch:SI 1 "=X,d"))
160 (clobber (match_scratch:DI 2 "=d,X"))]
163 if (which_alternative == 0)
167 xoperands[0] = operands[2];
168 xoperands[1] = operands[0];
169 output_move_double (xoperands);
170 cc_status.flags |= CC_REVERSED;
171 return "neg%.l %R2\;negx%.l %2";
173 if (find_reg_note (insn, REG_DEAD, operands[0]))
175 cc_status.flags |= CC_REVERSED;
176 return "neg%.l %R0\;negx%.l %0";
180 'sub' clears %1, and also clears the X cc bit
181 'tst' sets the Z cc bit according to the low part of the DImode operand
182 'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part.
184 return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
187 (define_expand "tstsi"
189 (match_operand:SI 0 "nonimmediate_operand" ""))]
191 "m68k_last_compare_had_fp_operands = 0;")
195 (match_operand:SI 0 "nonimmediate_operand" "rm"))]
198 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
200 /* If you think that the 68020 does not support tstl a0,
201 reread page B-167 of the 68020 manual more carefully. */
202 /* On an address reg, cmpw may replace cmpl. */
203 return "cmp%.w #0,%0";
206 ;; This can't use an address register, because comparisons
207 ;; with address registers as second operand always test the whole word.
208 (define_expand "tsthi"
210 (match_operand:HI 0 "nonimmediate_operand" ""))]
212 "m68k_last_compare_had_fp_operands = 0;")
216 (match_operand:HI 0 "nonimmediate_operand" "dm"))]
220 (define_expand "tstqi"
222 (match_operand:QI 0 "nonimmediate_operand" ""))]
224 "m68k_last_compare_had_fp_operands = 0;")
228 (match_operand:QI 0 "nonimmediate_operand" "dm"))]
232 (define_expand "tstsf"
234 (match_operand:SF 0 "general_operand" ""))]
238 m68k_last_compare_had_fp_operands = 1;
243 (match_operand:SF 0 "general_operand" "fdm"))]
246 cc_status.flags = CC_IN_68881;
247 if (FP_REG_P (operands[0]))
252 (define_expand "tstdf"
254 (match_operand:DF 0 "general_operand" ""))]
258 m68k_last_compare_had_fp_operands = 1;
263 (match_operand:DF 0 "general_operand" "fm"))]
266 cc_status.flags = CC_IN_68881;
267 if (FP_REG_P (operands[0]))
272 ;; compare instructions.
274 (define_expand "cmpdi"
277 (compare (match_operand:DI 0 "nonimmediate_operand" "")
278 (match_operand:DI 1 "general_operand" "")))
279 (clobber (match_dup 2))])]
281 "m68k_last_compare_had_fp_operands = 0; operands[2] = gen_reg_rtx (DImode);")
285 (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
286 (match_operand:DI 2 "general_operand" "d,0")))
287 (clobber (match_operand:DI 0 "register_operand" "=d,d"))]
290 if (rtx_equal_p (operands[0], operands[1]))
291 return "sub%.l %R2,%R0\;subx%.l %2,%0";
294 cc_status.flags |= CC_REVERSED;
295 return "sub%.l %R1,%R0\;subx%.l %1,%0";
299 ;; This is the second "hook" for PIC code (in addition to movsi). See
300 ;; comment of movsi for a description of PIC handling.
301 (define_expand "cmpsi"
303 (compare (match_operand:SI 0 "nonimmediate_operand" "")
304 (match_operand:SI 1 "general_operand" "")))]
308 m68k_last_compare_had_fp_operands = 0;
309 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
311 /* The source is an address which requires PIC relocation.
312 Call legitimize_pic_address with the source, mode, and a relocation
313 register (a new pseudo, or the final destination if reload_in_progress
314 is set). Then fall through normally */
315 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
316 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
320 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
323 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
324 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
327 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
328 return "cmpm%.l %1,%0";
329 if (REG_P (operands[1])
330 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
332 cc_status.flags |= CC_REVERSED;
333 return "cmp%.l %d0,%d1";
335 if (ADDRESS_REG_P (operands[0])
336 && GET_CODE (operands[1]) == CONST_INT
337 && INTVAL (operands[1]) < 0x8000
338 && INTVAL (operands[1]) >= -0x8000)
339 return "cmp%.w %1,%0";
340 return "cmp%.l %d1,%d0";
345 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
346 (match_operand:SI 1 "general_operand" "r,mrKs")))]
349 if (REG_P (operands[1])
350 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
352 cc_status.flags |= CC_REVERSED;
353 return "cmp%.l %d0,%d1";
355 return "cmp%.l %d1,%d0";
358 (define_expand "cmphi"
360 (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
361 (match_operand:HI 1 "general_src_operand" "")))]
363 "m68k_last_compare_had_fp_operands = 0;")
367 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
368 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
371 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
372 return "cmpm%.w %1,%0";
373 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
374 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
376 cc_status.flags |= CC_REVERSED;
377 return "cmp%.w %d0,%d1";
379 return "cmp%.w %d1,%d0";
382 (define_expand "cmpqi"
384 (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
385 (match_operand:QI 1 "general_src_operand" "")))]
387 "m68k_last_compare_had_fp_operands = 0;")
391 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
392 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
395 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
396 return "cmpm%.b %1,%0";
397 if (REG_P (operands[1])
398 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
400 cc_status.flags |= CC_REVERSED;
401 return "cmp%.b %d0,%d1";
403 return "cmp%.b %d1,%d0";
406 (define_expand "cmpdf"
408 (compare (match_operand:DF 0 "general_operand" "")
409 (match_operand:DF 1 "general_operand" "")))]
413 m68k_last_compare_had_fp_operands = 1;
418 (compare (match_operand:DF 0 "general_operand" "f,mG")
419 (match_operand:DF 1 "general_operand" "fmG,f")))]
422 cc_status.flags = CC_IN_68881;
423 if (REG_P (operands[0]))
425 if (REG_P (operands[1]))
426 return "fcmp%.x %1,%0";
428 return "fcmp%.d %f1,%0";
430 cc_status.flags |= CC_REVERSED;
431 return "fcmp%.d %f0,%1";
434 (define_expand "cmpsf"
436 (compare (match_operand:SF 0 "general_operand" "")
437 (match_operand:SF 1 "general_operand" "")))]
441 m68k_last_compare_had_fp_operands = 1;
446 (compare (match_operand:SF 0 "general_operand" "f,mdG")
447 (match_operand:SF 1 "general_operand" "fmdG,f")))]
450 cc_status.flags = CC_IN_68881;
451 if (FP_REG_P (operands[0]))
453 if (FP_REG_P (operands[1]))
454 return "fcmp%.x %1,%0";
456 return "fcmp%.s %f1,%0";
458 cc_status.flags |= CC_REVERSED;
459 return "fcmp%.s %f0,%1";
462 ;; Recognizers for btst instructions.
464 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
465 ;; specified as a constant, so we must disable all patterns that may extract
466 ;; from a MEM at a constant bit position if we can't use this as a constraint.
469 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
471 (minus:SI (const_int 7)
472 (match_operand:SI 1 "general_operand" "di"))))]
475 return output_btst (operands, operands[1], operands[0], insn, 7);
478 ;; This is the same as the above pattern except for the constraints. The 'i'
482 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
484 (minus:SI (const_int 7)
485 (match_operand:SI 1 "general_operand" "d"))))]
488 return output_btst (operands, operands[1], operands[0], insn, 7);
492 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
494 (minus:SI (const_int 31)
495 (match_operand:SI 1 "general_operand" "di"))))]
498 return output_btst (operands, operands[1], operands[0], insn, 31);
501 ;; The following two patterns are like the previous two
502 ;; except that they use the fact that bit-number operands
503 ;; are automatically masked to 3 or 5 bits.
506 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
508 (minus:SI (const_int 7)
510 (match_operand:SI 1 "register_operand" "d")
514 return output_btst (operands, operands[1], operands[0], insn, 7);
518 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
520 (minus:SI (const_int 31)
522 (match_operand:SI 1 "register_operand" "d")
526 return output_btst (operands, operands[1], operands[0], insn, 31);
529 ;; Nonoffsettable mem refs are ok in this one pattern
530 ;; since we don't try to adjust them.
532 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
534 (match_operand:SI 1 "const_int_operand" "n")))]
535 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
537 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
538 return output_btst (operands, operands[1], operands[0], insn, 7);
542 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
544 (match_operand:SI 1 "const_int_operand" "n")))]
547 if (GET_CODE (operands[0]) == MEM)
549 operands[0] = adjust_address (operands[0], QImode,
550 INTVAL (operands[1]) / 8);
551 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
552 return output_btst (operands, operands[1], operands[0], insn, 7);
554 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
555 return output_btst (operands, operands[1], operands[0], insn, 31);
558 ;; This is the same as the above pattern except for the constraints.
559 ;; The 'o' has been replaced with 'Q'.
562 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
564 (match_operand:SI 1 "const_int_operand" "n")))]
567 if (GET_CODE (operands[0]) == MEM)
569 operands[0] = adjust_address (operands[0], QImode,
570 INTVAL (operands[1]) / 8);
571 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
572 return output_btst (operands, operands[1], operands[0], insn, 7);
574 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
575 return output_btst (operands, operands[1], operands[0], insn, 31);
581 ;; A special case in which it is not desirable
582 ;; to reload the constant into a data register.
583 (define_insn "pushexthisi_const"
584 [(set (match_operand:SI 0 "push_operand" "=m")
585 (match_operand:SI 1 "const_int_operand" "J"))]
586 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
588 if (operands[1] == const0_rtx)
594 ;(define_insn "swapsi"
595 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
596 ; (match_operand:SI 1 "general_operand" "+r"))
597 ; (set (match_dup 1) (match_dup 0))]
601 ;; Special case of fullword move when source is zero.
602 ;; The reason this is special is to avoid loading a zero
603 ;; into a data reg with moveq in order to store it elsewhere.
605 (define_insn "movsi_const0"
606 [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
608 ;; clr insns on 68000 read before writing.
609 ;; This isn't so on the 68010, but we have no TARGET_68010.
610 "((TARGET_68020 || TARGET_COLDFIRE)
611 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
613 if (ADDRESS_REG_P (operands[0]))
615 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
616 if (!TARGET_68040 && !TARGET_68060)
617 return "sub%.l %0,%0";
619 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
621 /* moveq is faster on the 68000. */
622 if (DATA_REG_P (operands[0]) && (!TARGET_68020 && !TARGET_COLDFIRE))
623 return "moveq #0,%0";
627 ;; General case of fullword move.
629 ;; This is the main "hook" for PIC code. When generating
630 ;; PIC, movsi is responsible for determining when the source address
631 ;; needs PIC relocation and appropriately calling legitimize_pic_address
632 ;; to perform the actual relocation.
634 ;; In both the PIC and non-PIC cases the patterns generated will
635 ;; matched by the next define_insn.
636 (define_expand "movsi"
637 [(set (match_operand:SI 0 "nonimmediate_operand" "")
638 (match_operand:SI 1 "general_operand" ""))]
642 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
644 /* The source is an address which requires PIC relocation.
645 Call legitimize_pic_address with the source, mode, and a relocation
646 register (a new pseudo, or the final destination if reload_in_progress
647 is set). Then fall through normally */
648 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
649 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
651 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
653 /* Don't allow writes to memory except via a register;
654 the m68k doesn't consider PC-relative addresses to be writable. */
655 if (symbolic_operand (operands[0], SImode))
656 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
657 else if (GET_CODE (operands[0]) == MEM
658 && symbolic_operand (XEXP (operands[0], 0), SImode))
659 operands[0] = gen_rtx_MEM (SImode,
660 force_reg (SImode, XEXP (operands[0], 0)));
664 ;; General case of fullword move. The register constraints
665 ;; force integer constants in range for a moveq to be reloaded
666 ;; if they are headed for memory.
668 ;; Notes: make sure no alternative allows g vs g.
669 ;; We don't allow f-regs since fixed point cannot go in them.
670 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
671 (match_operand:SI 1 "general_src_operand" "daymSKT,n,i"))]
675 return output_move_simode (operands);
679 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g")
680 (match_operand:SI 1 "general_operand" "g,r<Q>"))]
682 "* return output_move_simode (operands);")
684 ;; Special case of fullword move, where we need to get a non-GOT PIC
685 ;; reference into an address register.
687 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
688 (match_operand:SI 1 "pcrel_address" ""))]
691 if (push_operand (operands[0], SImode))
696 (define_expand "movhi"
697 [(set (match_operand:HI 0 "nonimmediate_operand" "")
698 (match_operand:HI 1 "general_operand" ""))]
703 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
704 (match_operand:HI 1 "general_src_operand" "gS"))]
706 "* return output_move_himode (operands);")
709 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g")
710 (match_operand:HI 1 "general_operand" "g,r<Q>"))]
712 "* return output_move_himode (operands);")
714 (define_expand "movstricthi"
715 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
716 (match_operand:HI 1 "general_src_operand" ""))]
721 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
722 (match_operand:HI 1 "general_src_operand" "rmSn"))]
724 "* return output_move_stricthi (operands);")
727 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
728 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
730 "* return output_move_stricthi (operands);")
732 (define_expand "movqi"
733 [(set (match_operand:QI 0 "nonimmediate_operand" "")
734 (match_operand:QI 1 "general_src_operand" ""))]
739 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
740 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
742 "* return output_move_qimode (operands);")
745 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,d*a")
746 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,di*a"))]
748 "* return output_move_qimode (operands);")
750 (define_expand "movstrictqi"
751 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
752 (match_operand:QI 1 "general_src_operand" ""))]
757 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
758 (match_operand:QI 1 "general_src_operand" "dmSn"))]
760 "* return output_move_strictqi (operands);")
763 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d,m"))
764 (match_operand:QI 1 "general_src_operand" "dmn,d"))]
766 "* return output_move_strictqi (operands);")
768 (define_expand "pushqi1"
769 [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int -2)))
770 (set (mem:QI (plus:SI (reg:SI 15) (const_int 1)))
771 (match_operand:QI 0 "general_operand" ""))]
775 (define_expand "movsf"
776 [(set (match_operand:SF 0 "nonimmediate_operand" "")
777 (match_operand:SF 1 "general_operand" ""))]
782 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
783 (match_operand:SF 1 "general_operand" "rmfF"))]
786 if (FP_REG_P (operands[0]))
788 if (FP_REG_P (operands[1]))
789 return "f%$move%.x %1,%0";
790 else if (ADDRESS_REG_P (operands[1]))
791 return "move%.l %1,%-\;f%$move%.s %+,%0";
792 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
793 return output_move_const_single (operands);
794 return "f%$move%.s %f1,%0";
796 if (FP_REG_P (operands[1]))
798 if (ADDRESS_REG_P (operands[0]))
799 return "fmove%.s %1,%-\;move%.l %+,%0";
800 return "fmove%.s %f1,%0";
802 if (operands[1] == CONST0_RTX (SFmode)
803 /* clr insns on 68000 read before writing.
804 This isn't so on the 68010, but we have no TARGET_68010. */
805 && ((TARGET_68020 || TARGET_COLDFIRE)
806 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
808 if (ADDRESS_REG_P (operands[0]))
810 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
811 if (!TARGET_68040 && !TARGET_68060)
812 return "sub%.l %0,%0";
814 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
816 /* moveq is faster on the 68000. */
817 if (DATA_REG_P (operands[0]) && !(TARGET_68020 || TARGET_COLDFIRE))
819 return "moveq #0,%0";
823 return "move%.l %1,%0";
827 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,g")
828 (match_operand:SF 1 "general_operand" "g,r"))]
831 return "move%.l %1,%0";
834 (define_expand "movdf"
835 [(set (match_operand:DF 0 "nonimmediate_operand" "")
836 (match_operand:DF 1 "general_operand" ""))]
841 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
842 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
843 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
844 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
847 if (FP_REG_P (operands[0]))
849 if (FP_REG_P (operands[1]))
850 return "f%&move%.x %1,%0";
851 if (REG_P (operands[1]))
854 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
855 output_asm_insn ("move%.l %1,%-", xoperands);
856 output_asm_insn ("move%.l %1,%-", operands);
857 return "f%&move%.d %+,%0";
859 if (GET_CODE (operands[1]) == CONST_DOUBLE)
860 return output_move_const_double (operands);
861 return "f%&move%.d %f1,%0";
863 else if (FP_REG_P (operands[1]))
865 if (REG_P (operands[0]))
867 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
868 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
869 return "move%.l %+,%0";
872 return "fmove%.d %f1,%0";
874 return output_move_double (operands);
878 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
879 (match_operand:DF 1 "general_operand" "g,r"))]
882 return output_move_double (operands);
885 ;; ??? The XFmode patterns are schizophrenic about whether constants are
886 ;; allowed. Most but not all have predicates and constraint that disallow
887 ;; constants. Most but not all have output templates that handle constants.
888 ;; See also LEGITIMATE_CONSTANT_P.
890 (define_expand "movxf"
891 [(set (match_operand:XF 0 "nonimmediate_operand" "")
892 (match_operand:XF 1 "general_operand" ""))]
896 /* We can't rewrite operands during reload. */
897 if (! reload_in_progress)
899 if (CONSTANT_P (operands[1]))
901 operands[1] = force_const_mem (XFmode, operands[1]);
902 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
903 operands[1] = adjust_address (operands[1], XFmode, 0);
905 if (flag_pic && TARGET_PCREL)
907 /* Don't allow writes to memory except via a register; the
908 m68k doesn't consider PC-relative addresses to be writable. */
909 if (GET_CODE (operands[0]) == MEM
910 && symbolic_operand (XEXP (operands[0], 0), SImode))
911 operands[0] = gen_rtx_MEM (XFmode,
912 force_reg (SImode, XEXP (operands[0], 0)));
918 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r")
919 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r"))]
922 if (FP_REG_P (operands[0]))
924 if (FP_REG_P (operands[1]))
925 return "fmove%.x %1,%0";
926 if (REG_P (operands[1]))
929 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
930 output_asm_insn ("move%.l %1,%-", xoperands);
931 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
932 output_asm_insn ("move%.l %1,%-", xoperands);
933 output_asm_insn ("move%.l %1,%-", operands);
934 return "fmove%.x %+,%0";
936 if (GET_CODE (operands[1]) == CONST_DOUBLE)
937 return "fmove%.x %1,%0";
938 return "fmove%.x %f1,%0";
940 if (FP_REG_P (operands[1]))
942 if (REG_P (operands[0]))
944 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
945 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
946 output_asm_insn ("move%.l %+,%0", operands);
947 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
948 return "move%.l %+,%0";
950 /* Must be memory destination. */
951 return "fmove%.x %f1,%0";
953 return output_move_double (operands);
957 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
958 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
959 "! TARGET_68881 && ! TARGET_COLDFIRE"
961 if (FP_REG_P (operands[0]))
963 if (FP_REG_P (operands[1]))
964 return "fmove%.x %1,%0";
965 if (REG_P (operands[1]))
968 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
969 output_asm_insn ("move%.l %1,%-", xoperands);
970 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
971 output_asm_insn ("move%.l %1,%-", xoperands);
972 output_asm_insn ("move%.l %1,%-", operands);
973 return "fmove%.x %+,%0";
975 if (GET_CODE (operands[1]) == CONST_DOUBLE)
976 return "fmove%.x %1,%0";
977 return "fmove%.x %f1,%0";
979 if (FP_REG_P (operands[1]))
981 if (REG_P (operands[0]))
983 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
984 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
985 output_asm_insn ("move%.l %+,%0", operands);
986 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
987 return "move%.l %+,%0";
990 return "fmove%.x %f1,%0";
992 return output_move_double (operands);
996 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
997 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
998 "! TARGET_68881 && TARGET_COLDFIRE"
999 "* return output_move_double (operands);")
1001 (define_expand "movdi"
1002 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1003 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1004 (match_operand:DI 1 "general_operand" ""))]
1008 ;; movdi can apply to fp regs in some cases
1010 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1011 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1012 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1013 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1014 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1015 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1016 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1019 if (FP_REG_P (operands[0]))
1021 if (FP_REG_P (operands[1]))
1022 return "fmove%.x %1,%0";
1023 if (REG_P (operands[1]))
1026 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1027 output_asm_insn ("move%.l %1,%-", xoperands);
1028 output_asm_insn ("move%.l %1,%-", operands);
1029 return "fmove%.d %+,%0";
1031 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1032 return output_move_const_double (operands);
1033 return "fmove%.d %f1,%0";
1035 else if (FP_REG_P (operands[1]))
1037 if (REG_P (operands[0]))
1039 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1040 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1041 return "move%.l %+,%0";
1044 return "fmove%.d %f1,%0";
1046 return output_move_double (operands);
1050 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1051 (match_operand:DI 1 "general_operand" "g,r"))]
1053 "* return output_move_double (operands);")
1055 ;; Thus goes after the move instructions
1056 ;; because the move instructions are better (require no spilling)
1057 ;; when they can apply. It goes before the add/sub insns
1058 ;; so we will prefer it to them.
1060 (define_insn "pushasi"
1061 [(set (match_operand:SI 0 "push_operand" "=m")
1062 (match_operand:SI 1 "address_operand" "p"))]
1066 ;; truncation instructions
1067 (define_insn "truncsiqi2"
1068 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1070 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1073 if (GET_CODE (operands[0]) == REG)
1075 /* Must clear condition codes, since the move.l bases them on
1076 the entire 32 bits, not just the desired 8 bits. */
1078 return "move%.l %1,%0";
1080 if (GET_CODE (operands[1]) == MEM)
1081 operands[1] = adjust_address (operands[1], QImode, 3);
1082 return "move%.b %1,%0";
1085 (define_insn "trunchiqi2"
1086 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1088 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1091 if (GET_CODE (operands[0]) == REG
1092 && (GET_CODE (operands[1]) == MEM
1093 || GET_CODE (operands[1]) == CONST_INT))
1095 /* Must clear condition codes, since the move.w bases them on
1096 the entire 16 bits, not just the desired 8 bits. */
1098 return "move%.w %1,%0";
1100 if (GET_CODE (operands[0]) == REG)
1102 /* Must clear condition codes, since the move.l bases them on
1103 the entire 32 bits, not just the desired 8 bits. */
1105 return "move%.l %1,%0";
1107 if (GET_CODE (operands[1]) == MEM)
1108 operands[1] = adjust_address (operands[1], QImode, 1);
1109 return "move%.b %1,%0";
1112 (define_insn "truncsihi2"
1113 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1115 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1118 if (GET_CODE (operands[0]) == REG)
1120 /* Must clear condition codes, since the move.l bases them on
1121 the entire 32 bits, not just the desired 8 bits. */
1123 return "move%.l %1,%0";
1125 if (GET_CODE (operands[1]) == MEM)
1126 operands[1] = adjust_address (operands[1], QImode, 2);
1127 return "move%.w %1,%0";
1130 ;; zero extension instructions
1132 (define_insn "zero_extendqidi2"
1133 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
1134 (zero_extend:DI (match_operand:QI 1 "general_operand" "dm")))]
1138 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1139 return "moveq #0,%0\;moveq #0,%2\;move%.b %1,%2";
1142 (define_insn "zero_extendhidi2"
1143 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
1144 (zero_extend:DI (match_operand:HI 1 "general_operand" "rm")))]
1148 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1149 return "moveq #0,%0\;moveq #0,%2\;move%.w %1,%2";
1152 ;; this is the canonical form for (lshiftrt:DI x 32)
1153 (define_expand "zero_extendsidi2"
1154 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1155 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))]
1159 (define_insn "*zero_extendsidi2_cf"
1160 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,m")
1161 (zero_extend:DI (match_operand:SI 1 "general_operand" "rm,r")))]
1165 if (GET_CODE (operands[0]) == REG)
1166 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1167 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1168 return "move%.l %1,%0\;clr%.l %0";
1169 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1170 return "clr%.l %0\;move%.l %1,%0";
1172 operands[2] = adjust_address (operands[0], SImode, 4);
1173 if (GET_CODE (operands[1]) != REG || GET_CODE (operands[2]) != REG
1174 || REGNO (operands[1]) != REGNO (operands[2]))
1175 output_asm_insn ("move%.l %1,%2", operands);
1176 if (ADDRESS_REG_P (operands[0]))
1177 return "sub%.l %0,%0";
1182 (define_insn "*zero_extendsidi2"
1183 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
1184 (zero_extend:DI (match_operand:SI 1 "general_operand" "rm")))]
1188 if (GET_CODE (operands[0]) == REG)
1189 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1190 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1191 return "move%.l %1,%0\;clr%.l %0";
1192 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1193 return "clr%.l %0\;move%.l %1,%0";
1195 operands[2] = adjust_address (operands[0], SImode, 4);
1196 if (GET_CODE (operands[1]) != REG || GET_CODE (operands[2]) != REG
1197 || REGNO (operands[1]) != REGNO (operands[2]))
1198 output_asm_insn ("move%.l %1,%2", operands);
1199 if (ADDRESS_REG_P (operands[0]))
1200 return "sub%.l %0,%0";
1205 (define_expand "zero_extendhisi2"
1206 [(set (match_operand:SI 0 "register_operand" "")
1208 (set (strict_low_part (match_dup 2))
1209 (match_operand:HI 1 "general_operand" ""))]
1213 operands[1] = make_safe_from (operands[1], operands[0]);
1214 operands[2] = gen_lowpart_SUBREG (HImode, operands[0]);
1217 (define_expand "zero_extendqihi2"
1218 [(set (match_operand:HI 0 "register_operand" "")
1220 (set (strict_low_part (match_dup 2))
1221 (match_operand:QI 1 "general_operand" ""))]
1225 operands[1] = make_safe_from (operands[1], operands[0]);
1226 operands[2] = gen_lowpart_SUBREG (QImode, operands[0]);
1229 (define_expand "zero_extendqisi2"
1230 [(set (match_operand:SI 0 "register_operand" "")
1232 (set (strict_low_part (match_dup 2))
1233 (match_operand:QI 1 "general_operand" ""))]
1237 operands[1] = make_safe_from (operands[1], operands[0]);
1238 operands[2] = gen_lowpart_SUBREG (QImode, operands[0]);
1241 ;; Patterns to recognize zero-extend insns produced by the combiner.
1242 ;; We don't allow both operands in memory, because of aliasing problems.
1243 ;; Explicitly disallow two memory operands via the condition since reloading
1244 ;; of this case will result in worse code than the uncombined patterns.
1247 [(set (match_operand:SI 0 "nonimmediate_operand" "=do<>,d<")
1248 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "r,mS")))]
1249 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1251 if (DATA_REG_P (operands[0]))
1253 if (GET_CODE (operands[1]) == REG
1254 && REGNO (operands[0]) == REGNO (operands[1]))
1255 return "and%.l #0xFFFF,%0";
1256 if (reg_mentioned_p (operands[0], operands[1]))
1257 return "move%.w %1,%0\;and%.l #0xFFFF,%0";
1258 return "clr%.l %0\;move%.w %1,%0";
1260 else if (GET_CODE (operands[0]) == MEM
1261 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1262 return "move%.w %1,%0\;clr%.w %0";
1263 else if (GET_CODE (operands[0]) == MEM
1264 && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1265 return "clr%.w %0\;move%.w %1,%0";
1268 output_asm_insn ("clr%.w %0", operands);
1269 operands[0] = adjust_address (operands[0], HImode, 2);
1270 return "move%.w %1,%0";
1275 [(set (match_operand:HI 0 "nonimmediate_operand" "=do<>,d")
1276 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "d,mS")))]
1277 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1279 if (DATA_REG_P (operands[0]))
1281 if (GET_CODE (operands[1]) == REG
1282 && REGNO (operands[0]) == REGNO (operands[1]))
1283 return (!TARGET_COLDFIRE ? "and%.w #0xFF,%0" : "and%.l #0xFF,%0");
1284 if (reg_mentioned_p (operands[0], operands[1]))
1285 return (!TARGET_COLDFIRE ? "move%.b %1,%0\;and%.w #0xFF,%0"
1286 : "move%.b %1,%0\;and%.l #0xFF,%0");
1287 return "clr%.w %0\;move%.b %1,%0";
1289 else if (GET_CODE (operands[0]) == MEM
1290 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1292 if (REGNO (XEXP (XEXP (operands[0], 0), 0))
1293 == STACK_POINTER_REGNUM)
1295 output_asm_insn ("clr%.w %-", operands);
1296 operands[0] = gen_rtx_MEM (GET_MODE (operands[0]),
1297 plus_constant (stack_pointer_rtx, 1));
1298 return "move%.b %1,%0";
1301 return "move%.b %1,%0\;clr%.b %0";
1303 else if (GET_CODE (operands[0]) == MEM
1304 && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1305 return "clr%.b %0\;move%.b %1,%0";
1308 output_asm_insn ("clr%.b %0", operands);
1309 operands[0] = adjust_address (operands[0], QImode, 1);
1310 return "move%.b %1,%0";
1315 [(set (match_operand:SI 0 "nonimmediate_operand" "=do<>,d")
1316 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "d,mS")))]
1317 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1319 if (DATA_REG_P (operands[0]))
1321 if (GET_CODE (operands[1]) == REG
1322 && REGNO (operands[0]) == REGNO (operands[1]))
1323 return "and%.l #0xFF,%0";
1324 if (reg_mentioned_p (operands[0], operands[1]))
1325 return "move%.b %1,%0\;and%.l #0xFF,%0";
1326 return "clr%.l %0\;move%.b %1,%0";
1328 else if (GET_CODE (operands[0]) == MEM
1329 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1331 operands[0] = XEXP (XEXP (operands[0], 0), 0);
1333 "clr%.l -(%0)\;move%.b %1,(3,%0)" :
1334 "clrl %0@-\;moveb %1,%0@(3)";
1336 else if (GET_CODE (operands[0]) == MEM
1337 && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1339 operands[0] = XEXP (XEXP (operands[0], 0), 0);
1341 "clr%.l (%0)+\;move%.b %1,(-1,%0)" :
1342 "clrl %0@+\;moveb %1,%0@(-1)";
1346 output_asm_insn ("clr%.l %0", operands);
1347 operands[0] = adjust_address (operands[0], QImode, 3);
1348 return "move%.b %1,%0";
1352 ;; sign extension instructions
1354 (define_insn "extendqidi2"
1355 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1356 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1360 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1361 if (TARGET_68020 || TARGET_COLDFIRE)
1362 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1364 return "move%.b %1,%2\;ext%.w %0\;ext%.l %2\;move%.l %2,%0\;smi %0";
1367 (define_insn "extendhidi2"
1368 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1370 (match_operand:HI 1 "general_src_operand" "rmS")))]
1374 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1375 if (TARGET_68020 || TARGET_COLDFIRE)
1376 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1378 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1381 (define_insn "extendsidi2"
1382 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1384 (match_operand:SI 1 "general_operand" "rm")))]
1388 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1389 if (TARGET_68020 || TARGET_COLDFIRE)
1390 return "move%.l %1,%2\;smi %0\;extb%.l %0";
1392 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
1395 ;; Special case when one can avoid register clobbering, copy and test
1396 ;; Maybe there is a way to make that the general case, by forcing the
1397 ;; result of the SI tree to be in the lower register of the DI target
1399 (define_insn "extendplussidi"
1400 [(set (match_operand:DI 0 "register_operand" "=d")
1401 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1402 (match_operand:SI 2 "general_operand" "rmn"))))]
1406 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1407 if (GET_CODE (operands[1]) == CONST_INT
1408 && (unsigned) INTVAL (operands[1]) > 8)
1410 rtx tmp = operands[1];
1412 operands[1] = operands[2];
1415 if (GET_CODE (operands[1]) == REG
1416 && REGNO (operands[1]) == REGNO (operands[3]))
1417 output_asm_insn ("add%.l %2,%3", operands);
1419 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1420 if (TARGET_68020 || TARGET_COLDFIRE)
1421 return "smi %0\;extb%.l %0";
1423 return "smi %0\;ext%.w %0\;ext%.l %0";
1426 (define_insn "extendhisi2"
1427 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1429 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1432 if (ADDRESS_REG_P (operands[0]))
1433 return "move%.w %1,%0";
1437 (define_insn "extendqihi2"
1438 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1439 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1443 (define_insn "extendqisi2"
1444 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1445 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1446 "TARGET_68020 || TARGET_COLDFIRE"
1449 ;; Conversions between float and double.
1451 (define_expand "extendsfdf2"
1452 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1454 (match_operand:SF 1 "general_operand" "")))]
1459 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1461 (match_operand:SF 1 "general_operand" "f,dmF")))]
1464 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1466 if (REGNO (operands[0]) == REGNO (operands[1]))
1468 /* Extending float to double in an fp-reg is a no-op.
1469 NOTICE_UPDATE_CC has already assumed that the
1470 cc will be set. So cancel what it did. */
1471 cc_status = cc_prev_status;
1474 return "f%&move%.x %1,%0";
1476 if (FP_REG_P (operands[0]))
1477 return "f%&move%.s %f1,%0";
1478 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1480 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1481 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1482 return "move%.l %+,%0";
1484 return "fmove%.d %f1,%0";
1487 ;; This cannot output into an f-reg because there is no way to be
1488 ;; sure of truncating in that case.
1489 (define_expand "truncdfsf2"
1490 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1492 (match_operand:DF 1 "general_operand" "")))]
1496 ;; On the '040 we can truncate in a register accurately and easily.
1498 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1500 (match_operand:DF 1 "general_operand" "fmG")))]
1503 if (FP_REG_P (operands[1]))
1504 return "f%$move%.x %1,%0";
1505 return "f%$move%.d %f1,%0";
1509 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1511 (match_operand:DF 1 "general_operand" "f")))]
1515 ;; Conversion between fixed point and floating point.
1516 ;; Note that among the fix-to-float insns
1517 ;; the ones that start with SImode come first.
1518 ;; That is so that an operand that is a CONST_INT
1519 ;; (and therefore lacks a specific machine mode).
1520 ;; will be recognized as SImode (which is always valid)
1521 ;; rather than as QImode or HImode.
1523 (define_expand "floatsisf2"
1524 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1525 (float:SF (match_operand:SI 1 "general_operand" "")))]
1530 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1531 (float:SF (match_operand:SI 1 "general_operand" "dmi")))]
1535 (define_expand "floatsidf2"
1536 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1537 (float:DF (match_operand:SI 1 "general_operand" "")))]
1542 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1543 (float:DF (match_operand:SI 1 "general_operand" "dmi")))]
1547 (define_insn "floathisf2"
1548 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1549 (float:SF (match_operand:HI 1 "general_operand" "dmn")))]
1553 (define_insn "floathidf2"
1554 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1555 (float:DF (match_operand:HI 1 "general_operand" "dmn")))]
1559 (define_insn "floatqisf2"
1560 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1561 (float:SF (match_operand:QI 1 "general_operand" "dmn")))]
1565 (define_insn "floatqidf2"
1566 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1567 (float:DF (match_operand:QI 1 "general_operand" "dmn")))]
1571 ;; New routines to convert floating-point values to integers
1572 ;; to be used on the '040. These should be faster than trapping
1573 ;; into the kernel to emulate fintrz. They should also be faster
1574 ;; than calling the subroutines fixsfsi or fixdfsi.
1576 (define_insn "fix_truncdfsi2"
1577 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1578 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1579 (clobber (match_scratch:SI 2 "=d"))
1580 (clobber (match_scratch:SI 3 "=d"))]
1581 "TARGET_68881 && TARGET_68040"
1584 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,%!";
1587 (define_insn "fix_truncdfhi2"
1588 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1589 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1590 (clobber (match_scratch:SI 2 "=d"))
1591 (clobber (match_scratch:SI 3 "=d"))]
1592 "TARGET_68881 && TARGET_68040"
1595 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,%!";
1598 (define_insn "fix_truncdfqi2"
1599 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1600 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1601 (clobber (match_scratch:SI 2 "=d"))
1602 (clobber (match_scratch:SI 3 "=d"))]
1603 "TARGET_68881 && TARGET_68040"
1606 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,%!";
1609 ;; Convert a float to a float whose value is an integer.
1610 ;; This is the first stage of converting it to an integer type.
1612 (define_insn "ftruncdf2"
1613 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1614 (fix:DF (match_operand:DF 1 "general_operand" "fFm")))]
1615 "TARGET_68881 && !TARGET_68040"
1617 if (FP_REG_P (operands[1]))
1618 return "fintrz%.x %f1,%0";
1619 return "fintrz%.d %f1,%0";
1622 (define_insn "ftruncsf2"
1623 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1624 (fix:SF (match_operand:SF 1 "general_operand" "dfFm")))]
1625 "TARGET_68881 && !TARGET_68040"
1627 if (FP_REG_P (operands[1]))
1628 return "fintrz%.x %f1,%0";
1629 return "fintrz%.s %f1,%0";
1632 ;; Convert a float whose value is an integer
1633 ;; to an actual integer. Second stage of converting float to integer type.
1634 (define_insn "fixsfqi2"
1635 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1636 (fix:QI (match_operand:SF 1 "general_operand" "f")))]
1640 (define_insn "fixsfhi2"
1641 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1642 (fix:HI (match_operand:SF 1 "general_operand" "f")))]
1646 (define_insn "fixsfsi2"
1647 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1648 (fix:SI (match_operand:SF 1 "general_operand" "f")))]
1652 (define_insn "fixdfqi2"
1653 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1654 (fix:QI (match_operand:DF 1 "general_operand" "f")))]
1658 (define_insn "fixdfhi2"
1659 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1660 (fix:HI (match_operand:DF 1 "general_operand" "f")))]
1664 (define_insn "fixdfsi2"
1665 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1666 (fix:SI (match_operand:DF 1 "general_operand" "f")))]
1672 (define_insn "adddi_lshrdi_63"
1673 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1674 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
1677 (clobber (match_scratch:SI 2 "=d"))]
1680 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1681 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
1683 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
1684 if (GET_CODE (operands[1]) == REG)
1685 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1686 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
1687 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1688 operands[4] = operands[1];
1690 operands[4] = adjust_address (operands[1], SImode, 4);
1691 if (GET_CODE (operands[1]) == MEM
1692 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1693 output_asm_insn ("move%.l %4,%3", operands);
1694 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
1695 if (TARGET_68020 || TARGET_COLDFIRE)
1696 output_asm_insn ("extb%.l %2", operands);
1698 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
1699 if (GET_CODE (operands[1]) != MEM
1700 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
1701 output_asm_insn ("move%.l %4,%3", operands);
1702 return "sub%.l %2,%3\;subx%.l %2,%0";
1705 (define_insn "adddi_sexthishl32"
1706 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
1707 (plus:DI (ashift:DI (sign_extend:DI
1708 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
1710 (match_operand:DI 2 "general_operand" "0,0,0,0")))
1711 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
1715 if (ADDRESS_REG_P (operands[0]))
1716 return "add%.w %1,%0";
1717 else if (ADDRESS_REG_P (operands[3]))
1718 return "move%.w %1,%3\;add%.l %3,%0";
1720 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
1723 (define_insn "adddi_dilshr32"
1724 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
1725 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1726 ;; (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
1727 ;; (const_int 32))))]
1728 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
1730 (match_operand:DI 2 "general_operand" "0,0")))]
1734 if (GET_CODE (operands[0]) == REG)
1735 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1737 operands[2] = adjust_address (operands[0], SImode, 4);
1738 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
1741 (define_insn "adddi_dishl32"
1742 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
1743 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1744 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
1745 ;; (const_int 32))))]
1746 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
1748 (match_operand:DI 2 "general_operand" "0,0")))]
1752 if (GET_CODE (operands[1]) == REG)
1753 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1755 operands[1] = adjust_address (operands[1], SImode, 4);
1756 return "add%.l %1,%0";
1759 (define_insn "adddi3"
1760 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
1761 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0,0")
1762 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
1763 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
1766 if (DATA_REG_P (operands[0]))
1768 if (DATA_REG_P (operands[2]))
1769 return "add%.l %R2,%R0\;addx%.l %2,%0";
1770 else if (GET_CODE (operands[2]) == MEM
1771 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
1772 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
1778 if (GET_CODE (operands[2]) == REG)
1780 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
1783 else if (CONSTANT_P (operands[2]))
1784 split_double (operands[2], &high, &low);
1787 low = adjust_address (operands[2], SImode, 4);
1791 operands[1] = low, operands[2] = high;
1792 xoperands[0] = operands[3];
1793 if (GET_CODE (operands[1]) == CONST_INT
1794 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1795 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
1797 xoperands[1] = operands[2];
1799 output_asm_insn (output_move_simode (xoperands), xoperands);
1800 if (GET_CODE (operands[1]) == CONST_INT)
1802 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
1803 return "addq%.l %1,%R0\;addx%.l %3,%0";
1804 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1806 operands[1] = GEN_INT (-INTVAL (operands[1]));
1807 return "subq%.l %1,%R0\;subx%.l %3,%0";
1810 return "add%.l %1,%R0\;addx%.l %3,%0";
1813 else if (GET_CODE (operands[0]) == MEM)
1815 if (GET_CODE (operands[2]) == MEM
1816 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
1817 return "add%.l %2,%0\;addx%.l %2,%0";
1819 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1821 operands[1] = gen_rtx_MEM (SImode,
1822 plus_constant (XEXP(operands[0], 0), -8));
1823 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
1825 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1827 operands[1] = XEXP(operands[0], 0);
1828 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
1832 operands[1] = adjust_address (operands[0], SImode, 4);
1833 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
1840 (define_insn "addsi_lshrsi_31"
1841 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1842 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
1847 operands[2] = operands[0];
1848 operands[3] = gen_label_rtx();
1849 if (GET_CODE (operands[0]) == MEM)
1851 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1852 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
1853 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1854 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
1856 output_asm_insn ("move%.l %1,%0", operands);
1857 output_asm_insn (MOTOROLA ? "jbpl %l3" : "jpl %l3", operands);
1858 output_asm_insn ("addq%.l #1,%2", operands);
1859 (*targetm.asm_out.internal_label) (asm_out_file, "L",
1860 CODE_LABEL_NUMBER (operands[3]));
1864 (define_expand "addsi3"
1865 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1866 (plus:SI (match_operand:SI 1 "general_operand" "")
1867 (match_operand:SI 2 "general_src_operand" "")))]
1871 ;; Note that the middle two alternatives are near-duplicates
1872 ;; in order to handle insns generated by reload.
1873 ;; This is needed since they are not themselves reloaded,
1874 ;; so commutativity won't apply to them.
1875 (define_insn "*addsi3_internal"
1876 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
1877 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
1878 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
1882 "* return output_addsi3 (operands);")
1884 (define_insn "*addsi3_5200"
1885 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
1886 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
1887 (match_operand:SI 2 "general_src_operand" "d,rJK,a,mrIKLs")))]
1889 "* return output_addsi3 (operands);")
1892 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
1893 (plus:SI (match_operand:SI 1 "general_operand" "0")
1895 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
1899 (define_insn "addhi3"
1900 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
1901 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
1902 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
1905 if (GET_CODE (operands[2]) == CONST_INT)
1907 /* If the constant would be a negative number when interpreted as
1908 HImode, make it negative. This is usually, but not always, done
1909 elsewhere in the compiler. First check for constants out of range,
1910 which could confuse us. */
1912 if (INTVAL (operands[2]) >= 32768)
1913 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
1915 if (INTVAL (operands[2]) > 0
1916 && INTVAL (operands[2]) <= 8)
1917 return "addq%.w %2,%0";
1918 if (INTVAL (operands[2]) < 0
1919 && INTVAL (operands[2]) >= -8)
1921 operands[2] = GEN_INT (- INTVAL (operands[2]));
1922 return "subq%.w %2,%0";
1924 /* On the CPU32 it is faster to use two addqw instructions to
1925 add a small integer (8 < N <= 16) to a register.
1926 Likewise for subqw. */
1927 if (TARGET_CPU32 && REG_P (operands[0]))
1929 if (INTVAL (operands[2]) > 8
1930 && INTVAL (operands[2]) <= 16)
1932 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
1933 return "addq%.w #8,%0\;addq%.w %2,%0";
1935 if (INTVAL (operands[2]) < -8
1936 && INTVAL (operands[2]) >= -16)
1938 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
1939 return "subq%.w #8,%0\;subq%.w %2,%0";
1942 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
1943 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
1945 return "add%.w %2,%0";
1948 ;; These insns must use MATCH_DUP instead of the more expected
1949 ;; use of a matching constraint because the "output" here is also
1950 ;; an input, so you can't use the matching constraint. That also means
1951 ;; that you can't use the "%", so you need patterns with the matched
1952 ;; operand in both positions.
1955 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
1956 (plus:HI (match_dup 0)
1957 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
1960 if (GET_CODE (operands[1]) == CONST_INT)
1962 /* If the constant would be a negative number when interpreted as
1963 HImode, make it negative. This is usually, but not always, done
1964 elsewhere in the compiler. First check for constants out of range,
1965 which could confuse us. */
1967 if (INTVAL (operands[1]) >= 32768)
1968 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
1970 if (INTVAL (operands[1]) > 0
1971 && INTVAL (operands[1]) <= 8)
1972 return "addq%.w %1,%0";
1973 if (INTVAL (operands[1]) < 0
1974 && INTVAL (operands[1]) >= -8)
1976 operands[1] = GEN_INT (- INTVAL (operands[1]));
1977 return "subq%.w %1,%0";
1979 /* On the CPU32 it is faster to use two addqw instructions to
1980 add a small integer (8 < N <= 16) to a register.
1981 Likewise for subqw. */
1982 if (TARGET_CPU32 && REG_P (operands[0]))
1984 if (INTVAL (operands[1]) > 8
1985 && INTVAL (operands[1]) <= 16)
1987 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
1988 return "addq%.w #8,%0\;addq%.w %1,%0";
1990 if (INTVAL (operands[1]) < -8
1991 && INTVAL (operands[1]) >= -16)
1993 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
1994 return "subq%.w #8,%0\;subq%.w %1,%0";
1997 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
1998 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2000 return "add%.w %1,%0";
2004 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2005 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2009 if (GET_CODE (operands[1]) == CONST_INT)
2011 /* If the constant would be a negative number when interpreted as
2012 HImode, make it negative. This is usually, but not always, done
2013 elsewhere in the compiler. First check for constants out of range,
2014 which could confuse us. */
2016 if (INTVAL (operands[1]) >= 32768)
2017 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2019 if (INTVAL (operands[1]) > 0
2020 && INTVAL (operands[1]) <= 8)
2021 return "addq%.w %1,%0";
2022 if (INTVAL (operands[1]) < 0
2023 && INTVAL (operands[1]) >= -8)
2025 operands[1] = GEN_INT (- INTVAL (operands[1]));
2026 return "subq%.w %1,%0";
2028 /* On the CPU32 it is faster to use two addqw instructions to
2029 add a small integer (8 < N <= 16) to a register.
2030 Likewise for subqw. */
2031 if (TARGET_CPU32 && REG_P (operands[0]))
2033 if (INTVAL (operands[1]) > 8
2034 && INTVAL (operands[1]) <= 16)
2036 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2037 return "addq%.w #8,%0\;addq%.w %1,%0";
2039 if (INTVAL (operands[1]) < -8
2040 && INTVAL (operands[1]) >= -16)
2042 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2043 return "subq%.w #8,%0\;subq%.w %1,%0";
2046 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2047 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2049 return "add%.w %1,%0";
2052 (define_insn "addqi3"
2053 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2054 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2055 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2058 if (GET_CODE (operands[2]) == CONST_INT)
2060 if (INTVAL (operands[2]) >= 128)
2061 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2063 if (INTVAL (operands[2]) > 0
2064 && INTVAL (operands[2]) <= 8)
2065 return "addq%.b %2,%0";
2066 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2068 operands[2] = GEN_INT (- INTVAL (operands[2]));
2069 return "subq%.b %2,%0";
2072 return "add%.b %2,%0";
2076 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2077 (plus:QI (match_dup 0)
2078 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2081 if (GET_CODE (operands[1]) == CONST_INT)
2083 if (INTVAL (operands[1]) >= 128)
2084 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2086 if (INTVAL (operands[1]) > 0
2087 && INTVAL (operands[1]) <= 8)
2088 return "addq%.b %1,%0";
2089 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2091 operands[1] = GEN_INT (- INTVAL (operands[1]));
2092 return "subq%.b %1,%0";
2095 return "add%.b %1,%0";
2099 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2100 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2104 if (GET_CODE (operands[1]) == CONST_INT)
2106 if (INTVAL (operands[1]) >= 128)
2107 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2109 if (INTVAL (operands[1]) > 0
2110 && INTVAL (operands[1]) <= 8)
2111 return "addq%.b %1,%0";
2112 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2114 operands[1] = GEN_INT (- INTVAL (operands[1]));
2115 return "subq%.b %1,%0";
2118 return "add%.b %1,%0";
2121 (define_expand "adddf3"
2122 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2123 (plus:DF (match_operand:DF 1 "general_operand" "")
2124 (match_operand:DF 2 "general_operand" "")))]
2129 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2130 (plus:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2131 (match_operand:DF 1 "general_operand" "0")))]
2136 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2137 (plus:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2138 (match_operand:DF 1 "general_operand" "0")))]
2143 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2144 (plus:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2145 (match_operand:DF 1 "general_operand" "0")))]
2150 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2151 (plus:DF (match_operand:DF 1 "general_operand" "%0")
2152 (match_operand:DF 2 "general_operand" "fmG")))]
2155 if (REG_P (operands[2]))
2156 return "f%&add%.x %2,%0";
2157 return "f%&add%.d %f2,%0";
2160 (define_expand "addsf3"
2161 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2162 (plus:SF (match_operand:SF 1 "general_operand" "")
2163 (match_operand:SF 2 "general_operand" "")))]
2168 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2169 (plus:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2170 (match_operand:SF 1 "general_operand" "0")))]
2175 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2176 (plus:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2177 (match_operand:SF 1 "general_operand" "0")))]
2182 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2183 (plus:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2184 (match_operand:SF 1 "general_operand" "0")))]
2189 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2190 (plus:SF (match_operand:SF 1 "general_operand" "%0")
2191 (match_operand:SF 2 "general_operand" "fdmF")))]
2194 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2195 return "f%$add%.x %2,%0";
2196 return "f%$add%.s %f2,%0";
2199 ;; subtract instructions
2201 (define_insn "subdi_sexthishl32"
2202 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2203 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2204 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2206 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2210 if (ADDRESS_REG_P (operands[0]))
2211 return "sub%.w %2,%0";
2212 else if (ADDRESS_REG_P (operands[3]))
2213 return "move%.w %2,%3\;sub%.l %3,%0";
2215 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2218 (define_insn "subdi_dishl32"
2219 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2220 (minus:DI (match_dup 0)
2221 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2226 if (GET_CODE (operands[1]) == REG)
2227 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2229 operands[1] = adjust_address (operands[1], SImode, 4);
2230 return "sub%.l %1,%0";
2233 (define_insn "subdi3"
2234 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
2235 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0,0")
2236 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
2237 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
2240 if (DATA_REG_P (operands[0]))
2242 if (DATA_REG_P (operands[2]))
2243 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2244 else if (GET_CODE (operands[2]) == MEM
2245 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2247 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2254 if (GET_CODE (operands[2]) == REG)
2256 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2259 else if (CONSTANT_P (operands[2]))
2260 split_double (operands[2], &high, &low);
2263 low = adjust_address (operands[2], SImode, 4);
2267 operands[1] = low, operands[2] = high;
2268 xoperands[0] = operands[3];
2269 if (GET_CODE (operands[1]) == CONST_INT
2270 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2271 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2273 xoperands[1] = operands[2];
2275 output_asm_insn (output_move_simode (xoperands), xoperands);
2276 if (GET_CODE (operands[1]) == CONST_INT)
2278 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2279 return "subq%.l %1,%R0\;subx%.l %3,%0";
2280 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2282 operands[1] = GEN_INT (-INTVAL (operands[1]));
2283 return "addq%.l %1,%R0\;addx%.l %3,%0";
2286 return "sub%.l %1,%R0\;subx%.l %3,%0";
2289 else if (GET_CODE (operands[0]) == MEM)
2291 if (GET_CODE (operands[2]) == MEM
2292 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
2293 return "sub%.l %2,%0\;subx%.l %2,%0";
2295 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2298 = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2299 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2301 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2303 operands[1] = XEXP(operands[0], 0);
2304 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2308 operands[1] = adjust_address (operands[0], SImode, 4);
2309 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2316 (define_insn "subsi3"
2317 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2318 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2319 (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2324 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2325 (minus:SI (match_operand:SI 1 "general_operand" "0")
2327 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2331 (define_insn "subhi3"
2332 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2333 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2334 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2339 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2340 (minus:HI (match_dup 0)
2341 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2345 (define_insn "subqi3"
2346 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2347 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2348 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2353 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2354 (minus:QI (match_dup 0)
2355 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2359 (define_expand "subdf3"
2360 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2361 (minus:DF (match_operand:DF 1 "general_operand" "")
2362 (match_operand:DF 2 "general_operand" "")))]
2367 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2368 (minus:DF (match_operand:DF 1 "general_operand" "0")
2369 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2374 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2375 (minus:DF (match_operand:DF 1 "general_operand" "0")
2376 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2381 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2382 (minus:DF (match_operand:DF 1 "general_operand" "0")
2383 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2388 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2389 (minus:DF (match_operand:DF 1 "general_operand" "0")
2390 (match_operand:DF 2 "general_operand" "fmG")))]
2393 if (REG_P (operands[2]))
2394 return "f%&sub%.x %2,%0";
2395 return "f%&sub%.d %f2,%0";
2398 (define_expand "subsf3"
2399 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2400 (minus:SF (match_operand:SF 1 "general_operand" "")
2401 (match_operand:SF 2 "general_operand" "")))]
2406 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2407 (minus:SF (match_operand:SF 1 "general_operand" "0")
2408 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2413 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2414 (minus:SF (match_operand:SF 1 "general_operand" "0")
2415 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2420 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2421 (minus:SF (match_operand:SF 1 "general_operand" "0")
2422 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2427 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2428 (minus:SF (match_operand:SF 1 "general_operand" "0")
2429 (match_operand:SF 2 "general_operand" "fdmF")))]
2432 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2433 return "f%$sub%.x %2,%0";
2434 return "f%$sub%.s %f2,%0";
2437 ;; multiply instructions
2439 (define_insn "mulhi3"
2440 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2441 (mult:HI (match_operand:HI 1 "general_operand" "%0")
2442 (match_operand:HI 2 "general_src_operand" "dmSn")))]
2445 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2448 (define_insn "mulhisi3"
2449 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2450 (mult:SI (sign_extend:SI
2451 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2453 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2456 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2460 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2461 (mult:SI (sign_extend:SI
2462 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2463 (match_operand:SI 2 "const_int_operand" "n")))]
2464 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2466 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2469 (define_expand "mulsi3"
2470 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2471 (mult:SI (match_operand:SI 1 "general_operand" "")
2472 (match_operand:SI 2 "general_operand" "")))]
2473 "TARGET_68020 || TARGET_COLDFIRE"
2477 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2478 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2479 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2485 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2486 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2487 (match_operand:SI 2 "general_operand" "d<Q>")))]
2491 (define_insn "umulhisi3"
2492 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2493 (mult:SI (zero_extend:SI
2494 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2496 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2499 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2503 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2504 (mult:SI (zero_extend:SI
2505 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2506 (match_operand:SI 2 "const_int_operand" "n")))]
2507 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2509 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2512 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2513 ;; proper matching constraint. This is because the matching is between
2514 ;; the high-numbered word of the DImode operand[0] and operand[1].
2515 (define_expand "umulsidi3"
2517 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2518 (mult:SI (match_operand:SI 1 "register_operand" "")
2519 (match_operand:SI 2 "register_operand" "")))
2520 (set (subreg:SI (match_dup 0) 0)
2521 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2522 (zero_extend:DI (match_dup 2)))
2523 (const_int 32))))])]
2524 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2528 [(set (match_operand:SI 0 "register_operand" "=d")
2529 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2530 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2531 (set (match_operand:SI 3 "register_operand" "=d")
2532 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2533 (zero_extend:DI (match_dup 2)))
2535 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2538 ; Match immediate case. For 2.4 only match things < 2^31.
2539 ; It's tricky with larger values in these patterns since we need to match
2540 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2543 [(set (match_operand:SI 0 "register_operand" "=d")
2544 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2545 (match_operand:SI 2 "const_int_operand" "n")))
2546 (set (match_operand:SI 3 "register_operand" "=d")
2547 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2550 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE
2551 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2554 (define_expand "mulsidi3"
2556 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2557 (mult:SI (match_operand:SI 1 "register_operand" "")
2558 (match_operand:SI 2 "register_operand" "")))
2559 (set (subreg:SI (match_dup 0) 0)
2560 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2561 (sign_extend:DI (match_dup 2)))
2562 (const_int 32))))])]
2563 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2567 [(set (match_operand:SI 0 "register_operand" "=d")
2568 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2569 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2570 (set (match_operand:SI 3 "register_operand" "=d")
2571 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2572 (sign_extend:DI (match_dup 2)))
2574 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2578 [(set (match_operand:SI 0 "register_operand" "=d")
2579 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2580 (match_operand:SI 2 "const_int_operand" "n")))
2581 (set (match_operand:SI 3 "register_operand" "=d")
2582 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2585 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2588 (define_expand "umulsi3_highpart"
2590 [(set (match_operand:SI 0 "register_operand" "")
2593 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2594 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2596 (clobber (match_dup 3))])]
2597 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2600 operands[3] = gen_reg_rtx (SImode);
2602 if (GET_CODE (operands[2]) == CONST_INT)
2604 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2607 /* We have to adjust the operand order for the matching constraints. */
2608 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2609 operands[1], operands[2]));
2615 [(set (match_operand:SI 0 "register_operand" "=d")
2618 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2619 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2621 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2622 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2625 (define_insn "const_umulsi3_highpart"
2626 [(set (match_operand:SI 0 "register_operand" "=d")
2629 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2630 (match_operand:DI 3 "const_uint32_operand" "n"))
2632 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2633 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2636 (define_expand "smulsi3_highpart"
2638 [(set (match_operand:SI 0 "register_operand" "")
2641 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2642 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2644 (clobber (match_dup 3))])]
2645 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2648 operands[3] = gen_reg_rtx (SImode);
2649 if (GET_CODE (operands[2]) == CONST_INT)
2651 /* We have to adjust the operand order for the matching constraints. */
2652 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2653 operands[1], operands[2]));
2659 [(set (match_operand:SI 0 "register_operand" "=d")
2662 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2663 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2665 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2666 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2669 (define_insn "const_smulsi3_highpart"
2670 [(set (match_operand:SI 0 "register_operand" "=d")
2673 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2674 (match_operand:DI 3 "const_sint32_operand" "n"))
2676 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2677 "TARGET_68020 && !TARGET_68060 && !TARGET_COLDFIRE"
2680 (define_expand "muldf3"
2681 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2682 (mult:DF (match_operand:DF 1 "general_operand" "")
2683 (match_operand:DF 2 "general_operand" "")))]
2688 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2689 (mult:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2690 (match_operand:DF 1 "general_operand" "0")))]
2695 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2696 (mult:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2697 (match_operand:DF 1 "general_operand" "0")))]
2702 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2703 (mult:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2704 (match_operand:DF 1 "general_operand" "0")))]
2709 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2710 (mult:DF (match_operand:DF 1 "general_operand" "%0")
2711 (match_operand:DF 2 "general_operand" "fmG")))]
2714 if (GET_CODE (operands[2]) == CONST_DOUBLE
2715 && floating_exact_log2 (operands[2]) && !TARGET_68040 && !TARGET_68060)
2717 int i = floating_exact_log2 (operands[2]);
2718 operands[2] = GEN_INT (i);
2719 return "fscale%.l %2,%0";
2721 if (REG_P (operands[2]))
2722 return "f%&mul%.x %2,%0";
2723 return "f%&mul%.d %f2,%0";
2726 (define_expand "mulsf3"
2727 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2728 (mult:SF (match_operand:SF 1 "general_operand" "")
2729 (match_operand:SF 2 "general_operand" "")))]
2734 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2735 (mult:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2736 (match_operand:SF 1 "general_operand" "0")))]
2739 return (TARGET_68040_ONLY
2741 : "fsglmul%.l %2,%0");
2745 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2746 (mult:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2747 (match_operand:SF 1 "general_operand" "0")))]
2750 return (TARGET_68040_ONLY
2752 : "fsglmul%.w %2,%0");
2756 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2757 (mult:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2758 (match_operand:SF 1 "general_operand" "0")))]
2761 return (TARGET_68040_ONLY
2763 : "fsglmul%.b %2,%0");
2767 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2768 (mult:SF (match_operand:SF 1 "general_operand" "%0")
2769 (match_operand:SF 2 "general_operand" "fdmF")))]
2772 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2773 return (TARGET_68040_ONLY
2775 : "fsglmul%.x %2,%0");
2776 return (TARGET_68040_ONLY
2778 : "fsglmul%.s %f2,%0");
2781 ;; divide instructions
2783 (define_expand "divdf3"
2784 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2785 (div:DF (match_operand:DF 1 "general_operand" "")
2786 (match_operand:DF 2 "general_operand" "")))]
2791 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2792 (div:DF (match_operand:DF 1 "general_operand" "0")
2793 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2798 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2799 (div:DF (match_operand:DF 1 "general_operand" "0")
2800 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2805 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2806 (div:DF (match_operand:DF 1 "general_operand" "0")
2807 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2812 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2813 (div:DF (match_operand:DF 1 "general_operand" "0")
2814 (match_operand:DF 2 "general_operand" "fmG")))]
2817 if (REG_P (operands[2]))
2818 return "f%&div%.x %2,%0";
2819 return "f%&div%.d %f2,%0";
2822 (define_expand "divsf3"
2823 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2824 (div:SF (match_operand:SF 1 "general_operand" "")
2825 (match_operand:SF 2 "general_operand" "")))]
2830 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2831 (div:SF (match_operand:SF 1 "general_operand" "0")
2832 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2835 return (TARGET_68040_ONLY
2837 : "fsgldiv%.l %2,%0");
2841 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2842 (div:SF (match_operand:SF 1 "general_operand" "0")
2843 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2846 return (TARGET_68040_ONLY
2848 : "fsgldiv%.w %2,%0");
2852 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2853 (div:SF (match_operand:SF 1 "general_operand" "0")
2854 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2857 return (TARGET_68040_ONLY
2859 : "fsgldiv%.b %2,%0");
2863 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2864 (div:SF (match_operand:SF 1 "general_operand" "0")
2865 (match_operand:SF 2 "general_operand" "fdmF")))]
2868 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2869 return (TARGET_68040_ONLY
2871 : "fsgldiv%.x %2,%0");
2872 return (TARGET_68040_ONLY
2874 : "fsgldiv%.s %f2,%0");
2877 ;; Remainder instructions.
2879 (define_expand "divmodsi4"
2881 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2882 (div:SI (match_operand:SI 1 "general_operand" "")
2883 (match_operand:SI 2 "general_src_operand" "")))
2884 (set (match_operand:SI 3 "nonimmediate_operand" "")
2885 (mod:SI (match_dup 1) (match_dup 2)))])]
2886 "TARGET_68020 || TARGET_CF_HWDIV"
2890 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2891 (div:SI (match_operand:SI 1 "general_operand" "0")
2892 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2893 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2894 (mod:SI (match_dup 1) (match_dup 2)))]
2897 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2898 return "divs%.l %2,%0";
2899 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2900 return "rems%.l %2,%3:%0";
2902 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
2906 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2907 (div:SI (match_operand:SI 1 "general_operand" "0")
2908 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2909 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2910 (mod:SI (match_dup 1) (match_dup 2)))]
2913 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2914 return "divs%.l %2,%0";
2916 return "divsl%.l %2,%3:%0";
2919 (define_expand "udivmodsi4"
2921 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2922 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2923 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2924 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2925 (umod:SI (match_dup 1) (match_dup 2)))])]
2926 "TARGET_68020 || TARGET_CF_HWDIV"
2930 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2931 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2932 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2933 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2934 (umod:SI (match_dup 1) (match_dup 2)))]
2937 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2938 return "divu%.l %2,%0";
2939 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2940 return "remu%.l %2,%3:%0";
2942 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
2946 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2947 (udiv:SI (match_operand:SI 1 "general_operand" "0")
2948 (match_operand:SI 2 "general_src_operand" "dmSTK")))
2949 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
2950 (umod:SI (match_dup 1) (match_dup 2)))]
2951 "TARGET_68020 && !TARGET_COLDFIRE"
2953 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2954 return "divu%.l %2,%0";
2956 return "divul%.l %2,%3:%0";
2959 (define_insn "divmodhi4"
2960 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2961 (div:HI (match_operand:HI 1 "general_operand" "0")
2962 (match_operand:HI 2 "general_src_operand" "dmSKT")))
2963 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
2964 (mod:HI (match_dup 1) (match_dup 2)))]
2965 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
2967 output_asm_insn (MOTOROLA ?
2968 "ext%.l %0\;divs%.w %2,%0" :
2969 "extl %0\;divs %2,%0",
2971 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
2974 return "move%.l %0,%3\;swap %3";
2980 (define_insn "udivmodhi4"
2981 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2982 (udiv:HI (match_operand:HI 1 "general_operand" "0")
2983 (match_operand:HI 2 "general_src_operand" "dmSKT")))
2984 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
2985 (umod:HI (match_dup 1) (match_dup 2)))]
2986 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
2988 output_asm_insn (MOTOROLA ?
2989 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
2990 "and%.l #0xFFFF,%0\;divu %2,%0",
2992 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
2995 return "move%.l %0,%3\;swap %3";
3001 ;; logical-and instructions
3003 ;; "anddi3" is mainly here to help combine().
3004 (define_insn "anddi3"
3005 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3006 (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3007 (match_operand:DI 2 "general_operand" "dn,don")))]
3011 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3012 if (CONSTANT_P (operands[2]))
3016 split_double (operands[2], &hi, &lo);
3018 switch (INTVAL (hi))
3021 output_asm_insn ("clr%.l %0", operands);
3029 xoperands[0] = operands[0];
3031 output_asm_insn (output_andsi3 (xoperands), xoperands);
3034 if (GET_CODE (operands[0]) == REG)
3035 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3037 operands[0] = adjust_address (operands[0], SImode, 4);
3038 switch (INTVAL (lo))
3041 output_asm_insn ("clr%.l %0", operands);
3049 xoperands[0] = operands[0];
3051 output_asm_insn (output_andsi3 (xoperands), xoperands);
3056 if (GET_CODE (operands[0]) != REG)
3058 operands[1] = adjust_address (operands[0], SImode, 4);
3059 return "and%.l %2,%0\;and%.l %R2,%1";
3061 if (GET_CODE (operands[2]) != REG)
3063 operands[1] = adjust_address (operands[2], SImode, 4);
3064 return "and%.l %2,%0\;and%.l %1,%R0";
3066 return "and%.l %2,%0\;and%.l %R2,%R0";
3069 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3070 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3071 ;; can't allocate pseudos into it.
3073 (define_expand "andsi3"
3074 [(set (match_operand:SI 0 "not_sp_operand" "")
3075 (and:SI (match_operand:SI 1 "general_operand" "")
3076 (match_operand:SI 2 "general_src_operand" "")))]
3080 (define_insn "andsi3_internal"
3081 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3082 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3083 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3086 return output_andsi3 (operands);
3089 (define_insn "andsi3_5200"
3090 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3091 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3092 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3096 (define_insn "andhi3"
3097 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3098 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3099 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3104 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3105 (and:HI (match_dup 0)
3106 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3111 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3112 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3117 (define_insn "andqi3"
3118 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3119 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3120 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3125 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3126 (and:QI (match_dup 0)
3127 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3132 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3133 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3138 ;; inclusive-or instructions
3140 (define_insn "iordi_zext"
3141 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3142 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3143 (match_operand:DI 2 "general_operand" "0,0")))]
3149 if (GET_CODE (operands[0]) == REG)
3150 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3152 operands[0] = adjust_address (operands[0], SImode, 4);
3153 if (GET_MODE (operands[1]) == SImode)
3154 return "or%.l %1,%0";
3155 byte_mode = (GET_MODE (operands[1]) == QImode);
3156 if (GET_CODE (operands[0]) == MEM)
3157 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3160 return "or%.b %1,%0";
3162 return "or%.w %1,%0";
3165 ;; "iordi3" is mainly here to help combine().
3166 (define_insn "iordi3"
3167 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3168 (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3169 (match_operand:DI 2 "general_operand" "dn,don")))]
3173 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3174 if (CONSTANT_P (operands[2]))
3178 split_double (operands[2], &hi, &lo);
3180 switch (INTVAL (hi))
3185 /* FIXME : a scratch register would be welcome here if operand[0]
3186 is not a register */
3187 output_asm_insn ("move%.l #-1,%0", operands);
3193 xoperands[0] = operands[0];
3195 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3198 if (GET_CODE (operands[0]) == REG)
3199 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3201 operands[0] = adjust_address (operands[0], SImode, 4);
3202 switch (INTVAL (lo))
3207 /* FIXME : a scratch register would be welcome here if operand[0]
3208 is not a register */
3209 output_asm_insn ("move%.l #-1,%0", operands);
3215 xoperands[0] = operands[0];
3217 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3222 if (GET_CODE (operands[0]) != REG)
3224 operands[1] = adjust_address (operands[0], SImode, 4);
3225 return "or%.l %2,%0\;or%.l %R2,%1";
3227 if (GET_CODE (operands[2]) != REG)
3229 operands[1] = adjust_address (operands[2], SImode, 4);
3230 return "or%.l %2,%0\;or%.l %1,%R0";
3232 return "or%.l %2,%0\;or%.l %R2,%R0";
3235 (define_expand "iorsi3"
3236 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3237 (ior:SI (match_operand:SI 1 "general_operand" "")
3238 (match_operand:SI 2 "general_src_operand" "")))]
3242 (define_insn "iorsi3_internal"
3243 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3244 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3245 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3248 return output_iorsi3 (operands);
3251 (define_insn "iorsi3_5200"
3252 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3253 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3254 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3258 (define_insn "iorhi3"
3259 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3260 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3261 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3266 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3267 (ior:HI (match_dup 0)
3268 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3273 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3274 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3279 (define_insn "iorqi3"
3280 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3281 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3282 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3287 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3288 (ior:QI (match_dup 0)
3289 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3294 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3295 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3300 ;; On all 68k models, this makes faster code in a special case.
3301 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3303 (define_insn "iorsi_zexthi_ashl16"
3304 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3305 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3306 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3311 if (GET_CODE (operands[2]) != REG)
3312 operands[2] = adjust_address (operands[2], HImode, 2);
3313 if (GET_CODE (operands[2]) != REG
3314 || REGNO (operands[2]) != REGNO (operands[0]))
3315 output_asm_insn ("move%.w %2,%0", operands);
3316 return "swap %0\;mov%.w %1,%0";
3319 (define_insn "iorsi_zext"
3320 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3321 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3322 (match_operand:SI 2 "general_operand" "0,0")))]
3328 byte_mode = (GET_MODE (operands[1]) == QImode);
3329 if (GET_CODE (operands[0]) == MEM)
3330 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3333 return "or%.b %1,%0";
3335 return "or%.w %1,%0";
3340 ;; "xordi3" is mainly here to help combine().
3341 (define_insn "xordi3"
3342 [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3343 (xor:DI (match_operand:DI 1 "general_operand" "%0")
3344 (match_operand:DI 2 "general_operand" "dn")))]
3348 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3350 if (CONSTANT_P (operands[2]))
3354 split_double (operands[2], &hi, &lo);
3356 switch (INTVAL (hi))
3361 output_asm_insn ("not%.l %0", operands);
3364 /* FIXME : a scratch register would be welcome here if
3365 -128 <= INTVAL (hi) < -1 */
3369 xoperands[0] = operands[0];
3371 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3374 if (GET_CODE (operands[0]) == REG)
3375 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3377 operands[0] = adjust_address (operands[0], SImode, 4);
3378 switch (INTVAL (lo))
3383 output_asm_insn ("not%.l %0", operands);
3386 /* FIXME : a scratch register would be welcome here if
3387 -128 <= INTVAL (lo) < -1 */
3389 /* FIXME : this should be merged with xorsi3 */
3393 xoperands[0] = operands[0];
3395 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3400 if (GET_CODE (operands[0]) != REG)
3402 operands[1] = adjust_address (operands[0], SImode, 4);
3403 return "eor%.l %2,%0\;eor%.l %R2,%1";
3405 if (GET_CODE (operands[2]) != REG)
3407 operands[1] = adjust_address (operands[2], SImode, 4);
3408 return "eor%.l %2,%0\;eor%.l %1,%R0";
3410 return "eor%.l %2,%0\;eor%.l %R2,%R0";
3413 (define_expand "xorsi3"
3414 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3415 (xor:SI (match_operand:SI 1 "general_operand" "")
3416 (match_operand:SI 2 "general_operand" "")))]
3420 (define_insn "xorsi3_internal"
3421 [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3422 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3423 (match_operand:SI 2 "general_operand" "di,dKT")))]
3427 return output_xorsi3 (operands);
3430 (define_insn "xorsi3_5200"
3431 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3432 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3433 (match_operand:SI 2 "general_operand" "d,Ks")))]
3437 (define_insn "xorhi3"
3438 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3439 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3440 (match_operand:HI 2 "general_operand" "dn")))]
3445 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3446 (xor:HI (match_dup 0)
3447 (match_operand:HI 1 "general_operand" "dn")))]
3452 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3453 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3458 (define_insn "xorqi3"
3459 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3460 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3461 (match_operand:QI 2 "general_operand" "dn")))]
3466 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3467 (xor:QI (match_dup 0)
3468 (match_operand:QI 1 "general_operand" "dn")))]
3473 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3474 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3479 ;; negation instructions
3481 (define_expand "negdi2"
3482 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3483 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3487 if (TARGET_COLDFIRE)
3488 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3490 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3494 (define_insn "negdi2_internal"
3495 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3496 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3499 if (which_alternative == 0)
3500 return "neg%.l %0\;negx%.l %0";
3501 if (GET_CODE (operands[0]) == REG)
3502 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3504 operands[1] = adjust_address (operands[0], SImode, 4);
3505 if (ADDRESS_REG_P (operands[0]))
3506 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3508 return "neg%.l %1\;negx%.l %0";
3511 (define_insn "negdi2_5200"
3512 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3513 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3516 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3517 return "neg%.l %1\;negx%.l %0";
3520 (define_expand "negsi2"
3521 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3522 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3526 if (TARGET_COLDFIRE)
3527 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3529 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3533 (define_insn "negsi2_internal"
3534 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3535 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3539 (define_insn "negsi2_5200"
3540 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3541 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3545 (define_insn "neghi2"
3546 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3547 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3552 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3553 (neg:HI (match_dup 0)))]
3557 (define_insn "negqi2"
3558 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3559 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3564 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3565 (neg:QI (match_dup 0)))]
3569 ;; If using software floating point, just flip the sign bit.
3571 (define_expand "negsf2"
3572 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3573 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3582 target = operand_subword_force (operands[0], 0, SFmode);
3583 result = expand_binop (SImode, xor_optab,
3584 operand_subword_force (operands[1], 0, SFmode),
3585 GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
3589 if (result != target)
3590 emit_move_insn (result, target);
3592 /* Make a place for REG_EQUAL. */
3593 emit_move_insn (operands[0], operands[0]);
3599 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d")
3600 (neg:SF (match_operand:SF 1 "general_operand" "fdmF,0")))]
3603 if (DATA_REG_P (operands[0]))
3605 operands[1] = GEN_INT (31);
3606 return "bchg %1,%0";
3608 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3609 return "f%$neg%.x %1,%0";
3610 return "f%$neg%.s %f1,%0";
3613 (define_expand "negdf2"
3614 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3615 (neg:DF (match_operand:DF 1 "general_operand" "")))]
3626 target = operand_subword (operands[0], 0, 1, DFmode);
3627 result = expand_binop (SImode, xor_optab,
3628 operand_subword_force (operands[1], 0, DFmode),
3629 GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
3633 if (result != target)
3634 emit_move_insn (result, target);
3636 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3637 operand_subword_force (operands[1], 1, DFmode));
3639 insns = get_insns ();
3642 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3648 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,d")
3649 (neg:DF (match_operand:DF 1 "general_operand" "fmF,0")))]
3652 if (DATA_REG_P (operands[0]))
3654 operands[1] = GEN_INT (31);
3655 return "bchg %1,%0";
3657 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3658 return "f%&neg%.x %1,%0";
3659 return "f%&neg%.d %f1,%0";
3662 ;; Sqrt instruction for the 68881
3664 (define_insn "sqrtsf2"
3665 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3666 (sqrt:SF (match_operand:SF 1 "general_operand" "fm")))]
3669 if (FP_REG_P (operands[1]))
3670 return "f%$sqrt%.x %1,%0";
3672 return "f%$sqrt%.s %1,%0";
3675 (define_insn "sqrtdf2"
3676 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3677 (sqrt:DF (match_operand:DF 1 "general_operand" "fm")))]
3680 if (FP_REG_P (operands[1]))
3681 return "f%&sqrt%.x %1,%0";
3683 return "f%&sqrt%.d %1,%0";
3686 ;; Absolute value instructions
3687 ;; If using software floating point, just zero the sign bit.
3689 (define_expand "abssf2"
3690 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3691 (abs:SF (match_operand:SF 1 "general_operand" "")))]
3700 target = operand_subword_force (operands[0], 0, SFmode);
3701 result = expand_binop (SImode, and_optab,
3702 operand_subword_force (operands[1], 0, SFmode),
3703 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3707 if (result != target)
3708 emit_move_insn (result, target);
3710 /* Make a place for REG_EQUAL. */
3711 emit_move_insn (operands[0], operands[0]);
3717 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3718 (abs:SF (match_operand:SF 1 "general_operand" "fdmF")))]
3721 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3722 return "f%$abs%.x %1,%0";
3723 return "f%$abs%.s %f1,%0";
3726 (define_expand "absdf2"
3727 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3728 (abs:DF (match_operand:DF 1 "general_operand" "")))]
3739 target = operand_subword (operands[0], 0, 1, DFmode);
3740 result = expand_binop (SImode, and_optab,
3741 operand_subword_force (operands[1], 0, DFmode),
3742 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3746 if (result != target)
3747 emit_move_insn (result, target);
3749 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3750 operand_subword_force (operands[1], 1, DFmode));
3752 insns = get_insns ();
3755 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3761 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3762 (abs:DF (match_operand:DF 1 "general_operand" "fmF")))]
3765 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
3766 return "f%&abs%.x %1,%0";
3767 return "f%&abs%.d %f1,%0";
3770 ;; one complement instructions
3772 ;; "one_cmpldi2" is mainly here to help combine().
3773 (define_insn "one_cmpldi2"
3774 [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
3775 (not:DI (match_operand:DI 1 "general_operand" "0")))]
3779 if (GET_CODE (operands[0]) == REG)
3780 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3781 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
3782 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3783 operands[1] = operands[0];
3785 operands[1] = adjust_address (operands[0], SImode, 4);
3786 return "not%.l %1\;not%.l %0";
3789 (define_expand "one_cmplsi2"
3790 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3791 (not:SI (match_operand:SI 1 "general_operand" "")))]
3795 if (TARGET_COLDFIRE)
3796 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
3798 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
3802 (define_insn "one_cmplsi2_internal"
3803 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3804 (not:SI (match_operand:SI 1 "general_operand" "0")))]
3808 (define_insn "one_cmplsi2_5200"
3809 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3810 (not:SI (match_operand:SI 1 "general_operand" "0")))]
3814 (define_insn "one_cmplhi2"
3815 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3816 (not:HI (match_operand:HI 1 "general_operand" "0")))]
3821 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3822 (not:HI (match_dup 0)))]
3826 (define_insn "one_cmplqi2"
3827 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3828 (not:QI (match_operand:QI 1 "general_operand" "0")))]
3833 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3834 (not:QI (match_dup 0)))]
3838 ;; arithmetic shift instructions
3839 ;; We don't need the shift memory by 1 bit instruction
3841 (define_insn "ashldi_extsi"
3842 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
3844 (match_operator:DI 2 "extend_operator"
3845 [(match_operand:SI 1 "general_operand" "rm")])
3850 if (GET_CODE (operands[0]) == REG)
3851 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3853 operands[2] = adjust_address (operands[0], SImode, 4);
3854 if (ADDRESS_REG_P (operands[0]))
3855 return "move%.l %1,%0\;sub%.l %2,%2";
3857 return "move%.l %1,%0\;clr%.l %2";
3860 (define_insn "ashldi_sexthi"
3861 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
3862 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
3864 (clobber (match_scratch:SI 2 "=a,X"))]
3868 if (GET_CODE (operands[0]) == MEM)
3870 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3871 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
3872 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
3873 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
3876 operands[3] = adjust_address (operands[0], SImode, 4);
3877 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
3880 else if (DATA_REG_P (operands[0]))
3881 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
3883 return "move%.w %1,%0\;sub%.l %R0,%R0";
3886 (define_insn "ashldi_const32"
3887 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
3888 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
3893 if (GET_CODE (operands[1]) == REG)
3894 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
3896 operands[3] = adjust_address (operands[1], SImode, 4);
3897 if (GET_CODE (operands[0]) == REG)
3898 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3899 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3900 return "clr%.l %0\;move%.l %3,%0";
3901 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
3902 return "move%.l %3,%0\;clr%.l %0";
3904 operands[2] = adjust_address (operands[0], SImode, 4);
3905 if (ADDRESS_REG_P (operands[2]))
3906 return "move%.l %3,%0\;sub%.l %2,%2";
3908 return "move%.l %3,%0\;clr%.l %2";
3911 ;; The predicate below must be general_operand, because ashldi3 allows that
3912 (define_insn "ashldi_const"
3913 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3914 (ashift:DI (match_operand:DI 1 "general_operand" "0")
3915 (match_operand 2 "const_int_operand" "n")))]
3917 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
3918 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
3919 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
3921 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3922 if (INTVAL (operands[2]) == 1)
3923 return "add%.l %1,%1\;addx%.l %0,%0";
3924 else if (INTVAL (operands[2]) == 8)
3925 return "rol%.l #8,%1\;rol%.l #8,%0\;move%.b %1,%0\;clr%.b %1";
3926 else if (INTVAL (operands[2]) == 16)
3927 return "swap %1\;swap %0\;move%.w %1,%0\;clr%.w %1";
3928 else if (INTVAL (operands[2]) == 48)
3929 return "mov%.l %1,%0\;swap %0\;clr%.l %1\;clr%.w %0";
3930 else if (INTVAL (operands[2]) == 2)
3931 return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
3932 else if (INTVAL (operands[2]) == 3)
3933 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";
3934 else /* 32 < INTVAL (operands[2]) <= 63 */
3936 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
3937 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asl%.l %2,%1" :
3938 "moveq %2,%0\;asl%.l %0,%1", operands);
3939 return "mov%.l %1,%0\;moveq #0,%1";
3943 (define_expand "ashldi3"
3944 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3945 (ashift:DI (match_operand:DI 1 "general_operand" "")
3946 (match_operand 2 "const_int_operand" "")))]
3950 /* ??? This is a named pattern like this is not allowed to FAIL based
3952 if (GET_CODE (operands[2]) != CONST_INT
3953 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
3954 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
3955 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
3959 ;; On most 68k models, this makes faster code in a special case.
3961 (define_insn "ashlsi_16"
3962 [(set (match_operand:SI 0 "register_operand" "=d")
3963 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3968 return "swap %0\;clr%.w %0";
3971 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
3972 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
3974 ;; On the 68000, this makes faster code in a special case.
3976 (define_insn "ashlsi_17_24"
3977 [(set (match_operand:SI 0 "register_operand" "=d")
3978 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3979 (match_operand:SI 2 "const_int_operand" "n")))]
3980 "(! TARGET_68020 && !TARGET_COLDFIRE
3981 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
3985 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
3986 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
3989 (define_insn "ashlsi3"
3990 [(set (match_operand:SI 0 "register_operand" "=d")
3991 (ashift:SI (match_operand:SI 1 "register_operand" "0")
3992 (match_operand:SI 2 "general_operand" "dI")))]
3995 if (operands[2] == const1_rtx)
3997 cc_status.flags = CC_NO_OVERFLOW;
3998 return "add%.l %0,%0";
4000 return "lsl%.l %2,%0";
4003 (define_insn "ashlhi3"
4004 [(set (match_operand:HI 0 "register_operand" "=d")
4005 (ashift:HI (match_operand:HI 1 "register_operand" "0")
4006 (match_operand:HI 2 "general_operand" "dI")))]
4011 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4012 (ashift:HI (match_dup 0)
4013 (match_operand:HI 1 "general_operand" "dI")))]
4017 (define_insn "ashlqi3"
4018 [(set (match_operand:QI 0 "register_operand" "=d")
4019 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4020 (match_operand:QI 2 "general_operand" "dI")))]
4025 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4026 (ashift:QI (match_dup 0)
4027 (match_operand:QI 1 "general_operand" "dI")))]
4031 ;; On most 68k models, this makes faster code in a special case.
4033 (define_insn "ashrsi_16"
4034 [(set (match_operand:SI 0 "register_operand" "=d")
4035 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4038 "swap %0\;ext%.l %0")
4040 ;; On the 68000, this makes faster code in a special case.
4043 [(set (match_operand:SI 0 "register_operand" "=d")
4044 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4045 (match_operand:SI 2 "const_int_operand" "n")))]
4046 "(! TARGET_68020 && !TARGET_COLDFIRE
4047 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
4049 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4050 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4053 (define_insn "subreghi1ashrdi_const32"
4054 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4055 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4056 (const_int 32)) 6))]
4059 if (GET_CODE (operands[1]) != REG)
4060 operands[1] = adjust_address (operands[1], HImode, 2);
4061 return "move%.w %1,%0";
4064 (define_insn "subregsi1ashrdi_const32"
4065 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4066 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4067 (const_int 32)) 4))]
4070 return "move%.l %1,%0";
4073 (define_insn "ashrdi_const32"
4074 [(set (match_operand:DI 0 "register_operand" "=d")
4075 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4080 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4082 return "move%.l %1,%2\;smi %0\;extb%.l %0";
4084 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
4087 (define_insn "ashrdi_const32_mem"
4088 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,<")
4089 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro")
4091 (clobber (match_scratch:SI 2 "=d,d"))]
4095 if (which_alternative == 1)
4096 operands[3] = operands[0];
4098 operands[3] = adjust_address (operands[0], SImode, 4);
4100 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4102 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4105 ;; The predicate below must be general_operand, because ashrdi3 allows that
4106 (define_insn "ashrdi_const"
4107 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4108 (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
4109 (match_operand 2 "const_int_operand" "n")))]
4111 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4112 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4113 || INTVAL (operands[2]) == 31
4114 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4116 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4117 if (INTVAL (operands[2]) == 63)
4118 return "add%.l %0,%0\;subx%.l %0,%0\;move%.l %0,%1";
4120 if (INTVAL (operands[2]) == 1)
4121 return "asr%.l #1,%0\;roxr%.l #1,%1";
4122 else if (INTVAL (operands[2]) == 8)
4123 return "move%.b %0,%1\;asr%.l #8,%0\;ror%.l #8,%1";
4124 else if (INTVAL (operands[2]) == 16)
4125 return "move%.w %0,%1\;swap %0\;ext%.l %0\;swap %1";
4126 else if (INTVAL (operands[2]) == 48)
4127 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4128 else if (INTVAL (operands[2]) == 31)
4129 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4130 else if (INTVAL (operands[2]) == 2)
4131 return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4132 else if (INTVAL (operands[2]) == 3)
4133 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";
4134 else /* 32 < INTVAL (operands[2]) <= 63 */
4136 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4137 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4138 "moveq %2,%1\;asr%.l %1,%0", operands);
4139 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4140 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4141 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4145 (define_expand "ashrdi3"
4146 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4147 (ashiftrt:DI (match_operand:DI 1 "general_operand" "")
4148 (match_operand 2 "const_int_operand" "")))]
4152 /* ??? This is a named pattern like this is not allowed to FAIL based
4154 if (GET_CODE (operands[2]) != CONST_INT
4155 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4156 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4157 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4161 ;; On all 68k models, this makes faster code in a special case.
4163 (define_insn "ashrsi_31"
4164 [(set (match_operand:SI 0 "register_operand" "=d")
4165 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4169 return "add%.l %0,%0\;subx%.l %0,%0";
4172 (define_insn "ashrsi3"
4173 [(set (match_operand:SI 0 "register_operand" "=d")
4174 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4175 (match_operand:SI 2 "general_operand" "dI")))]
4179 (define_insn "ashrhi3"
4180 [(set (match_operand:HI 0 "register_operand" "=d")
4181 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4182 (match_operand:HI 2 "general_operand" "dI")))]
4187 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4188 (ashiftrt:HI (match_dup 0)
4189 (match_operand:HI 1 "general_operand" "dI")))]
4193 (define_insn "ashrqi3"
4194 [(set (match_operand:QI 0 "register_operand" "=d")
4195 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4196 (match_operand:QI 2 "general_operand" "dI")))]
4201 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4202 (ashiftrt:QI (match_dup 0)
4203 (match_operand:QI 1 "general_operand" "dI")))]
4207 ;; logical shift instructions
4209 ;; commented out because of reload problems in 950612-1.c
4212 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4213 ;; (const_int 32)) 4))
4214 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4215 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4216 ;; (const_int 32)) 4))]
4219 ;; return "move%.l %0,%1";
4224 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4225 ;; (const_int 32)) 0))
4226 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4227 ;; (lshiftrt:DI (match_dup 0)
4228 ;; (const_int 32)))]
4231 ;; if (GET_CODE (operands[1]) == REG)
4232 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4234 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4235 ;; return "move%.l %0,%2\;clr%.l %1";
4238 (define_insn "subreg1lshrdi_const32"
4239 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4240 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4241 (const_int 32)) 4))]
4244 return "move%.l %1,%0";
4247 (define_insn "lshrdi_const32"
4248 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro,<,>")
4249 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4254 if (which_alternative == 1)
4255 return "move%.l %1,%0\;clr%.l %0";
4256 if (which_alternative == 2)
4257 return "clr%.l %0\;move%.l %1,%0";
4258 if (GET_CODE (operands[0]) == REG)
4259 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4261 operands[2] = adjust_address (operands[0], SImode, 4);
4262 if (GET_CODE (operands[1]) == REG)
4263 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4265 operands[3] = adjust_address (operands[1], SImode, 4);
4266 if (ADDRESS_REG_P (operands[0]))
4267 return "move%.l %1,%2\;sub%.l %0,%0";
4269 return "move%.l %1,%2\;clr%.l %0";
4272 ;; The predicate below must be general_operand, because lshrdi3 allows that
4273 (define_insn "lshrdi_const"
4274 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4275 (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
4276 (match_operand 2 "const_int_operand" "n")))]
4278 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4279 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4280 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4282 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4283 if (INTVAL (operands[2]) == 63)
4284 return "add%.l %0,%0\;clr%.l %0\;clr%.l %1\;addx%.l %1,%1";
4286 if (INTVAL (operands[2]) == 1)
4287 return "lsr%.l #1,%0\;roxr%.l #1,%1";
4288 else if (INTVAL (operands[2]) == 8)
4289 return "move%.b %0,%1\;lsr%.l #8,%0\;ror%.l #8,%1";
4290 else if (INTVAL (operands[2]) == 16)
4291 return "move%.w %0,%1\;clr%.w %0\;swap %1\;swap %0";
4292 else if (INTVAL (operands[2]) == 48)
4293 return "move%.l %0,%1\;clr%.w %1\;clr%.l %0\;swap %1";
4294 else if (INTVAL (operands[2]) == 2)
4295 return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4296 else if (INTVAL (operands[2]) == 3)
4297 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";
4298 else /* 32 < INTVAL (operands[2]) <= 63 */
4300 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4301 output_asm_insn (INTVAL (operands[2]) <= 8 ? "lsr%.l %2,%0" :
4302 "moveq %2,%1\;lsr%.l %1,%0", operands);
4303 return "mov%.l %0,%1\;moveq #0,%0";
4307 (define_expand "lshrdi3"
4308 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4309 (lshiftrt:DI (match_operand:DI 1 "general_operand" "")
4310 (match_operand 2 "const_int_operand" "")))]
4313 /* ??? This is a named pattern like this is not allowed to FAIL based
4315 if (GET_CODE (operands[2]) != CONST_INT
4316 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4317 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4318 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4322 ;; On all 68k models, this makes faster code in a special case.
4324 (define_insn "lshrsi_31"
4325 [(set (match_operand:SI 0 "register_operand" "=d")
4326 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4330 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
4333 ;; On most 68k models, this makes faster code in a special case.
4335 (define_insn "lshrsi_16"
4336 [(set (match_operand:SI 0 "register_operand" "=d")
4337 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4342 return "clr%.w %0\;swap %0";
4345 ;; On the 68000, this makes faster code in a special case.
4347 (define_insn "lshrsi_17_24"
4348 [(set (match_operand:SI 0 "register_operand" "=d")
4349 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4350 (match_operand:SI 2 "const_int_operand" "n")))]
4351 "(! TARGET_68020 && !TARGET_COLDFIRE
4352 && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24)"
4354 /* I think lsr%.w sets the CC properly. */
4355 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4356 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
4359 (define_insn "lshrsi3"
4360 [(set (match_operand:SI 0 "register_operand" "=d")
4361 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4362 (match_operand:SI 2 "general_operand" "dI")))]
4366 (define_insn "lshrhi3"
4367 [(set (match_operand:HI 0 "register_operand" "=d")
4368 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
4369 (match_operand:HI 2 "general_operand" "dI")))]
4374 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4375 (lshiftrt:HI (match_dup 0)
4376 (match_operand:HI 1 "general_operand" "dI")))]
4380 (define_insn "lshrqi3"
4381 [(set (match_operand:QI 0 "register_operand" "=d")
4382 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
4383 (match_operand:QI 2 "general_operand" "dI")))]
4388 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4389 (lshiftrt:QI (match_dup 0)
4390 (match_operand:QI 1 "general_operand" "dI")))]
4394 ;; rotate instructions
4396 (define_insn "rotlsi3"
4397 [(set (match_operand:SI 0 "register_operand" "=d")
4398 (rotate:SI (match_operand:SI 1 "register_operand" "0")
4399 (match_operand:SI 2 "general_operand" "dINO")))]
4402 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
4404 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
4406 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4407 return "ror%.l %2,%0";
4410 return "rol%.l %2,%0";
4413 (define_insn "rotlhi3"
4414 [(set (match_operand:HI 0 "register_operand" "=d")
4415 (rotate:HI (match_operand:HI 1 "register_operand" "0")
4416 (match_operand:HI 2 "general_operand" "dIP")))]
4419 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4421 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4422 return "ror%.w %2,%0";
4425 return "rol%.w %2,%0";
4429 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4430 (rotate:HI (match_dup 0)
4431 (match_operand:HI 1 "general_operand" "dIP")))]
4434 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4436 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4437 return "ror%.w %2,%0";
4440 return "rol%.w %2,%0";
4443 (define_insn "rotlqi3"
4444 [(set (match_operand:QI 0 "register_operand" "=d")
4445 (rotate:QI (match_operand:QI 1 "register_operand" "0")
4446 (match_operand:QI 2 "general_operand" "dI")))]
4449 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4451 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4452 return "ror%.b %2,%0";
4455 return "rol%.b %2,%0";
4459 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4460 (rotate:QI (match_dup 0)
4461 (match_operand:QI 1 "general_operand" "dI")))]
4464 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4466 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4467 return "ror%.b %2,%0";
4470 return "rol%.b %2,%0";
4473 (define_insn "rotrsi3"
4474 [(set (match_operand:SI 0 "register_operand" "=d")
4475 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
4476 (match_operand:SI 2 "general_operand" "dI")))]
4480 (define_insn "rotrhi3"
4481 [(set (match_operand:HI 0 "register_operand" "=d")
4482 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
4483 (match_operand:HI 2 "general_operand" "dI")))]
4488 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4489 (rotatert:HI (match_dup 0)
4490 (match_operand:HI 1 "general_operand" "dI")))]
4494 (define_insn "rotrqi3"
4495 [(set (match_operand:QI 0 "register_operand" "=d")
4496 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
4497 (match_operand:QI 2 "general_operand" "dI")))]
4502 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4503 (rotatert:QI (match_dup 0)
4504 (match_operand:QI 1 "general_operand" "dI")))]
4509 ;; Bit set/clear in memory byte.
4511 ;; set bit, bit number is int
4512 (define_insn "bsetmemqi"
4513 [(set (match_operand:QI 0 "memory_operand" "+m")
4514 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4515 (match_operand:SI 1 "general_operand" "d")) 3)
4520 return "bset %1,%0";
4523 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
4525 [(set (match_operand:QI 0 "memory_operand" "+m")
4526 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4527 (match_operator:SI 2 "extend_operator"
4528 [(match_operand 1 "general_operand" "d")])) 3)
4533 return "bset %1,%0";
4536 ;; clear bit, bit number is int
4537 (define_insn "bclrmemqi"
4538 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4540 (minus:SI (const_int 7)
4541 (match_operand:SI 1 "general_operand" "d")))
4546 return "bclr %1,%0";
4549 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
4551 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4553 (minus:SI (const_int 7)
4554 (match_operator:SI 2 "extend_operator"
4555 [(match_operand 1 "general_operand" "d")])))
4560 return "bclr %1,%0";
4563 ;; Special cases of bit-field insns which we should
4564 ;; recognize in preference to the general case.
4565 ;; These handle aligned 8-bit and 16-bit fields,
4566 ;; which can usually be done with move instructions.
4569 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4570 ; alignment of structure members is specified.
4572 ; The move is allowed to be odd byte aligned, because that's still faster
4573 ; than an odd byte aligned bit-field instruction.
4576 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4578 (match_operand:SI 1 "const_int_operand" "n"))
4579 (match_operand:SI 2 "general_src_operand" "rmSi"))]
4580 "TARGET_68020 && TARGET_BITFIELD
4581 && (INTVAL (operands[1]) % 8) == 0
4582 && ! mode_dependent_address_p (XEXP (operands[0], 0))"
4585 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
4587 return "move%.l %2,%0";
4591 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
4592 (match_operand:SI 1 "const_int_operand" "n")
4593 (match_operand:SI 2 "const_int_operand" "n"))
4594 (match_operand:SI 3 "register_operand" "d"))]
4595 "TARGET_68020 && TARGET_BITFIELD
4596 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
4597 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
4598 && (GET_CODE (operands[0]) == REG
4599 || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
4601 if (REG_P (operands[0]))
4603 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
4604 return "bfins %3,%0{%b2:%b1}";
4607 operands[0] = adjust_address (operands[0],
4608 INTVAL (operands[1]) == 8 ? QImode : HImode,
4609 INTVAL (operands[2]) / 8);
4611 if (GET_CODE (operands[3]) == MEM)
4612 operands[3] = adjust_address (operands[3],
4613 INTVAL (operands[1]) == 8 ? QImode : HImode,
4614 (32 - INTVAL (operands[1])) / 8);
4616 if (INTVAL (operands[1]) == 8)
4617 return "move%.b %3,%0";
4618 return "move%.w %3,%0";
4623 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4624 ; alignment of structure members is specified.
4626 ; The move is allowed to be odd byte aligned, because that's still faster
4627 ; than an odd byte aligned bit-field instruction.
4630 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4631 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4633 (match_operand:SI 2 "const_int_operand" "n")))]
4634 "TARGET_68020 && TARGET_BITFIELD
4635 && (INTVAL (operands[2]) % 8) == 0
4636 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4639 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4641 return "move%.l %1,%0";
4645 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
4646 (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
4647 (match_operand:SI 2 "const_int_operand" "n")
4648 (match_operand:SI 3 "const_int_operand" "n")))]
4649 "TARGET_68020 && TARGET_BITFIELD
4650 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4651 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4652 && (GET_CODE (operands[1]) == REG
4653 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4655 cc_status.flags |= CC_NOT_NEGATIVE;
4656 if (REG_P (operands[1]))
4658 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4659 return "bfextu %1{%b3:%b2},%0";
4663 = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
4665 output_asm_insn ("clr%.l %0", operands);
4666 if (GET_CODE (operands[0]) == MEM)
4667 operands[0] = adjust_address (operands[0],
4668 INTVAL (operands[2]) == 8 ? QImode : HImode,
4669 (32 - INTVAL (operands[1])) / 8);
4671 if (INTVAL (operands[2]) == 8)
4672 return "move%.b %1,%0";
4673 return "move%.w %1,%0";
4677 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4678 ; alignment of structure members is specified.
4680 ; The move is allowed to be odd byte aligned, because that's still faster
4681 ; than an odd byte aligned bit-field instruction.
4684 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4685 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4687 (match_operand:SI 2 "const_int_operand" "n")))]
4688 "TARGET_68020 && TARGET_BITFIELD
4689 && (INTVAL (operands[2]) % 8) == 0
4690 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4693 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4695 return "move%.l %1,%0";
4699 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4700 (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
4701 (match_operand:SI 2 "const_int_operand" "n")
4702 (match_operand:SI 3 "const_int_operand" "n")))]
4703 "TARGET_68020 && TARGET_BITFIELD
4704 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4705 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4706 && (GET_CODE (operands[1]) == REG
4707 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4709 if (REG_P (operands[1]))
4711 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4712 return "bfexts %1{%b3:%b2},%0";
4716 = adjust_address (operands[1],
4717 INTVAL (operands[2]) == 8 ? QImode : HImode,
4718 INTVAL (operands[3]) / 8);
4720 if (INTVAL (operands[2]) == 8)
4721 return "move%.b %1,%0\;extb%.l %0";
4722 return "move%.w %1,%0\;ext%.l %0";
4725 ;; Bit-field instructions, general cases.
4726 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
4727 ;; so that its address is reloaded.
4729 (define_expand "extv"
4730 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4731 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
4732 (match_operand:SI 2 "general_operand" "")
4733 (match_operand:SI 3 "general_operand" "")))]
4734 "TARGET_68020 && TARGET_BITFIELD"
4738 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4739 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
4740 (match_operand:SI 2 "general_operand" "dn")
4741 (match_operand:SI 3 "general_operand" "dn")))]
4742 "TARGET_68020 && TARGET_BITFIELD"
4743 "bfexts %1{%b3:%b2},%0")
4745 (define_expand "extzv"
4746 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4747 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
4748 (match_operand:SI 2 "general_operand" "")
4749 (match_operand:SI 3 "general_operand" "")))]
4750 "TARGET_68020 && TARGET_BITFIELD"
4754 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d")
4755 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o,d")
4756 (match_operand:SI 2 "general_operand" "dn,dn")
4757 (match_operand:SI 3 "general_operand" "dn,dn")))]
4758 "TARGET_68020 && TARGET_BITFIELD"
4760 if (GET_CODE (operands[2]) == CONST_INT)
4762 if (INTVAL (operands[2]) != 32)
4763 cc_status.flags |= CC_NOT_NEGATIVE;
4769 return "bfextu %1{%b3:%b2},%0";
4773 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4774 (match_operand:SI 1 "general_operand" "dn")
4775 (match_operand:SI 2 "general_operand" "dn"))
4776 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
4777 (match_operand 3 "const_int_operand" "n")))]
4778 "TARGET_68020 && TARGET_BITFIELD
4779 && (INTVAL (operands[3]) == -1
4780 || (GET_CODE (operands[1]) == CONST_INT
4781 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
4784 return "bfchg %0{%b2:%b1}";
4788 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4789 (match_operand:SI 1 "general_operand" "dn")
4790 (match_operand:SI 2 "general_operand" "dn"))
4792 "TARGET_68020 && TARGET_BITFIELD"
4795 return "bfclr %0{%b2:%b1}";
4799 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4800 (match_operand:SI 1 "general_operand" "dn")
4801 (match_operand:SI 2 "general_operand" "dn"))
4803 "TARGET_68020 && TARGET_BITFIELD"
4806 return "bfset %0{%b2:%b1}";
4809 (define_expand "insv"
4810 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
4811 (match_operand:SI 1 "general_operand" "")
4812 (match_operand:SI 2 "general_operand" ""))
4813 (match_operand:SI 3 "register_operand" ""))]
4814 "TARGET_68020 && TARGET_BITFIELD"
4818 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4819 (match_operand:SI 1 "general_operand" "dn")
4820 (match_operand:SI 2 "general_operand" "dn"))
4821 (match_operand:SI 3 "register_operand" "d"))]
4822 "TARGET_68020 && TARGET_BITFIELD"
4823 "bfins %3,%0{%b2:%b1}")
4825 ;; Now recognize bit-field insns that operate on registers
4826 ;; (or at least were intended to do so).
4829 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4830 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
4831 (match_operand:SI 2 "general_operand" "dn")
4832 (match_operand:SI 3 "general_operand" "dn")))]
4833 "TARGET_68020 && TARGET_BITFIELD"
4834 "bfexts %1{%b3:%b2},%0")
4837 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4838 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
4839 (match_operand:SI 2 "general_operand" "dn")
4840 (match_operand:SI 3 "general_operand" "dn")))]
4841 "TARGET_68020 && TARGET_BITFIELD"
4843 if (GET_CODE (operands[2]) == CONST_INT)
4845 if (INTVAL (operands[2]) != 32)
4846 cc_status.flags |= CC_NOT_NEGATIVE;
4852 return "bfextu %1{%b3:%b2},%0";
4856 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4857 (match_operand:SI 1 "general_operand" "dn")
4858 (match_operand:SI 2 "general_operand" "dn"))
4860 "TARGET_68020 && TARGET_BITFIELD"
4863 return "bfclr %0{%b2:%b1}";
4867 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4868 (match_operand:SI 1 "general_operand" "dn")
4869 (match_operand:SI 2 "general_operand" "dn"))
4871 "TARGET_68020 && TARGET_BITFIELD"
4874 return "bfset %0{%b2:%b1}";
4878 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
4879 (match_operand:SI 1 "general_operand" "dn")
4880 (match_operand:SI 2 "general_operand" "dn"))
4881 (match_operand:SI 3 "register_operand" "d"))]
4882 "TARGET_68020 && TARGET_BITFIELD"
4885 /* These special cases are now recognized by a specific pattern. */
4886 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
4887 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
4888 return "move%.w %3,%0";
4889 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
4890 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
4891 return "move%.b %3,%0";
4893 return "bfins %3,%0{%b2:%b1}";
4896 ;; Special patterns for optimizing bit-field instructions.
4900 (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
4901 (match_operand:SI 1 "const_int_operand" "n")
4902 (match_operand:SI 2 "general_operand" "dn")))]
4903 "TARGET_68020 && TARGET_BITFIELD"
4905 if (operands[1] == const1_rtx
4906 && GET_CODE (operands[2]) == CONST_INT)
4908 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
4909 return output_btst (operands,
4910 GEN_INT (width - INTVAL (operands[2])),
4911 operands[0], insn, 1000);
4912 /* Pass 1000 as SIGNPOS argument so that btst will
4913 not think we are testing the sign bit for an `and'
4914 and assume that nonzero implies a negative result. */
4916 if (INTVAL (operands[1]) != 32)
4917 cc_status.flags = CC_NOT_NEGATIVE;
4918 return "bftst %0{%b2:%b1}";
4922 ;;; now handle the register cases
4925 (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
4926 (match_operand:SI 1 "const_int_operand" "n")
4927 (match_operand:SI 2 "general_operand" "dn")))]
4928 "TARGET_68020 && TARGET_BITFIELD"
4930 if (operands[1] == const1_rtx
4931 && GET_CODE (operands[2]) == CONST_INT)
4933 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
4934 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
4935 operands[0], insn, 1000);
4936 /* Pass 1000 as SIGNPOS argument so that btst will
4937 not think we are testing the sign bit for an `and'
4938 and assume that nonzero implies a negative result. */
4940 if (INTVAL (operands[1]) != 32)
4941 cc_status.flags = CC_NOT_NEGATIVE;
4942 return "bftst %0{%b2:%b1}";
4945 (define_insn "scc0_di"
4946 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4947 (match_operator 1 "valid_dbcc_comparison_p"
4948 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
4951 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
4954 (define_insn "scc0_di_5200"
4955 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
4956 (match_operator 1 "valid_dbcc_comparison_p"
4957 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
4960 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
4963 (define_insn "scc_di"
4964 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
4965 (match_operator 1 "valid_dbcc_comparison_p"
4966 [(match_operand:DI 2 "general_operand" "ro,r")
4967 (match_operand:DI 3 "general_operand" "r,ro")]))]
4970 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
4973 (define_insn "scc_di_5200"
4974 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
4975 (match_operator 1 "valid_dbcc_comparison_p"
4976 [(match_operand:DI 2 "general_operand" "ro,r")
4977 (match_operand:DI 3 "general_operand" "r,ro")]))]
4980 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
4983 ;; Note that operand 0 of an SCC insn is supported in the hardware as
4984 ;; memory, but we cannot allow it to be in memory in case the address
4985 ;; needs to be reloaded.
4987 (define_expand "seq"
4988 [(set (match_operand:QI 0 "register_operand" "")
4989 (eq:QI (cc0) (const_int 0)))]
4993 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
4995 m68k_last_compare_had_fp_operands = 0;
5001 [(set (match_operand:QI 0 "register_operand" "=d")
5002 (eq:QI (cc0) (const_int 0)))]
5005 cc_status = cc_prev_status;
5006 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5009 (define_expand "sne"
5010 [(set (match_operand:QI 0 "register_operand" "")
5011 (ne:QI (cc0) (const_int 0)))]
5015 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5017 m68k_last_compare_had_fp_operands = 0;
5023 [(set (match_operand:QI 0 "register_operand" "=d")
5024 (ne:QI (cc0) (const_int 0)))]
5027 cc_status = cc_prev_status;
5028 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5031 (define_expand "sgt"
5032 [(set (match_operand:QI 0 "register_operand" "")
5033 (gt:QI (cc0) (const_int 0)))]
5037 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5039 m68k_last_compare_had_fp_operands = 0;
5045 [(set (match_operand:QI 0 "register_operand" "=d")
5046 (gt:QI (cc0) (const_int 0)))]
5049 cc_status = cc_prev_status;
5050 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5053 (define_expand "sgtu"
5054 [(set (match_operand:QI 0 "register_operand" "")
5055 (gtu:QI (cc0) (const_int 0)))]
5060 [(set (match_operand:QI 0 "register_operand" "=d")
5061 (gtu:QI (cc0) (const_int 0)))]
5064 cc_status = cc_prev_status;
5068 (define_expand "slt"
5069 [(set (match_operand:QI 0 "register_operand" "")
5070 (lt:QI (cc0) (const_int 0)))]
5074 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5076 m68k_last_compare_had_fp_operands = 0;
5082 [(set (match_operand:QI 0 "register_operand" "=d")
5083 (lt:QI (cc0) (const_int 0)))]
5086 cc_status = cc_prev_status;
5087 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5090 (define_expand "sltu"
5091 [(set (match_operand:QI 0 "register_operand" "")
5092 (ltu:QI (cc0) (const_int 0)))]
5097 [(set (match_operand:QI 0 "register_operand" "=d")
5098 (ltu:QI (cc0) (const_int 0)))]
5101 cc_status = cc_prev_status;
5105 (define_expand "sge"
5106 [(set (match_operand:QI 0 "register_operand" "")
5107 (ge:QI (cc0) (const_int 0)))]
5111 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5113 m68k_last_compare_had_fp_operands = 0;
5119 [(set (match_operand:QI 0 "register_operand" "=d")
5120 (ge:QI (cc0) (const_int 0)))]
5123 cc_status = cc_prev_status;
5124 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5127 (define_expand "sgeu"
5128 [(set (match_operand:QI 0 "register_operand" "")
5129 (geu:QI (cc0) (const_int 0)))]
5134 [(set (match_operand:QI 0 "register_operand" "=d")
5135 (geu:QI (cc0) (const_int 0)))]
5138 cc_status = cc_prev_status;
5142 (define_expand "sle"
5143 [(set (match_operand:QI 0 "register_operand" "")
5144 (le:QI (cc0) (const_int 0)))]
5148 if (TARGET_68060 && m68k_last_compare_had_fp_operands)
5150 m68k_last_compare_had_fp_operands = 0;
5156 [(set (match_operand:QI 0 "register_operand" "=d")
5157 (le:QI (cc0) (const_int 0)))]
5160 cc_status = cc_prev_status;
5161 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5164 (define_expand "sleu"
5165 [(set (match_operand:QI 0 "register_operand" "")
5166 (leu:QI (cc0) (const_int 0)))]
5171 [(set (match_operand:QI 0 "register_operand" "=d")
5172 (leu:QI (cc0) (const_int 0)))]
5175 cc_status = cc_prev_status;
5179 (define_expand "sordered"
5180 [(set (match_operand:QI 0 "register_operand" "")
5181 (ordered:QI (cc0) (const_int 0)))]
5182 "TARGET_68881 && !TARGET_68060"
5184 if (! m68k_last_compare_had_fp_operands)
5186 m68k_last_compare_had_fp_operands = 0;
5189 (define_insn "*sordered_1"
5190 [(set (match_operand:QI 0 "register_operand" "=d")
5191 (ordered:QI (cc0) (const_int 0)))]
5192 "TARGET_68881 && !TARGET_68060"
5194 cc_status = cc_prev_status;
5198 (define_expand "sunordered"
5199 [(set (match_operand:QI 0 "register_operand" "")
5200 (unordered:QI (cc0) (const_int 0)))]
5201 "TARGET_68881 && !TARGET_68060"
5203 if (! m68k_last_compare_had_fp_operands)
5205 m68k_last_compare_had_fp_operands = 0;
5208 (define_insn "*sunordered_1"
5209 [(set (match_operand:QI 0 "register_operand" "=d")
5210 (unordered:QI (cc0) (const_int 0)))]
5211 "TARGET_68881 && !TARGET_68060"
5213 cc_status = cc_prev_status;
5217 (define_expand "suneq"
5218 [(set (match_operand:QI 0 "register_operand" "")
5219 (uneq:QI (cc0) (const_int 0)))]
5220 "TARGET_68881 && !TARGET_68060"
5222 if (! m68k_last_compare_had_fp_operands)
5224 m68k_last_compare_had_fp_operands = 0;
5227 (define_insn "*suneq_1"
5228 [(set (match_operand:QI 0 "register_operand" "=d")
5229 (uneq:QI (cc0) (const_int 0)))]
5230 "TARGET_68881 && !TARGET_68060"
5232 cc_status = cc_prev_status;
5236 (define_expand "sunge"
5237 [(set (match_operand:QI 0 "register_operand" "")
5238 (unge:QI (cc0) (const_int 0)))]
5239 "TARGET_68881 && !TARGET_68060"
5241 if (! m68k_last_compare_had_fp_operands)
5243 m68k_last_compare_had_fp_operands = 0;
5246 (define_insn "*sunge_1"
5247 [(set (match_operand:QI 0 "register_operand" "=d")
5248 (unge:QI (cc0) (const_int 0)))]
5249 "TARGET_68881 && !TARGET_68060"
5251 cc_status = cc_prev_status;
5255 (define_expand "sungt"
5256 [(set (match_operand:QI 0 "register_operand" "")
5257 (ungt:QI (cc0) (const_int 0)))]
5258 "TARGET_68881 && !TARGET_68060"
5260 if (! m68k_last_compare_had_fp_operands)
5262 m68k_last_compare_had_fp_operands = 0;
5265 (define_insn "*sungt_1"
5266 [(set (match_operand:QI 0 "register_operand" "=d")
5267 (ungt:QI (cc0) (const_int 0)))]
5268 "TARGET_68881 && !TARGET_68060"
5270 cc_status = cc_prev_status;
5274 (define_expand "sunle"
5275 [(set (match_operand:QI 0 "register_operand" "")
5276 (unle:QI (cc0) (const_int 0)))]
5277 "TARGET_68881 && !TARGET_68060"
5279 if (! m68k_last_compare_had_fp_operands)
5281 m68k_last_compare_had_fp_operands = 0;
5284 (define_insn "*sunle_1"
5285 [(set (match_operand:QI 0 "register_operand" "=d")
5286 (unle:QI (cc0) (const_int 0)))]
5287 "TARGET_68881 && !TARGET_68060"
5289 cc_status = cc_prev_status;
5293 (define_expand "sunlt"
5294 [(set (match_operand:QI 0 "register_operand" "")
5295 (unlt:QI (cc0) (const_int 0)))]
5296 "TARGET_68881 && !TARGET_68060"
5298 if (! m68k_last_compare_had_fp_operands)
5300 m68k_last_compare_had_fp_operands = 0;
5303 (define_insn "*sunlt_1"
5304 [(set (match_operand:QI 0 "register_operand" "=d")
5305 (unlt:QI (cc0) (const_int 0)))]
5306 "TARGET_68881 && !TARGET_68060"
5308 cc_status = cc_prev_status;
5312 (define_expand "sltgt"
5313 [(set (match_operand:QI 0 "register_operand" "")
5314 (ltgt:QI (cc0) (const_int 0)))]
5315 "TARGET_68881 && !TARGET_68060"
5317 if (! m68k_last_compare_had_fp_operands)
5319 m68k_last_compare_had_fp_operands = 0;
5322 (define_insn "*sltgt_1"
5323 [(set (match_operand:QI 0 "register_operand" "=d")
5324 (ltgt:QI (cc0) (const_int 0)))]
5325 "TARGET_68881 && !TARGET_68060"
5327 cc_status = cc_prev_status;
5331 (define_insn "*fsogt_1"
5332 [(set (match_operand:QI 0 "register_operand" "=d")
5333 (not:QI (unle:QI (cc0) (const_int 0))))]
5334 "TARGET_68881 && !TARGET_68060"
5336 cc_status = cc_prev_status;
5340 (define_insn "*fsoge_1"
5341 [(set (match_operand:QI 0 "register_operand" "=d")
5342 (not:QI (unlt:QI (cc0) (const_int 0))))]
5343 "TARGET_68881 && !TARGET_68060"
5345 cc_status = cc_prev_status;
5349 (define_insn "*fsolt_1"
5350 [(set (match_operand:QI 0 "register_operand" "=d")
5351 (not:QI (unge:QI (cc0) (const_int 0))))]
5352 "TARGET_68881 && !TARGET_68060"
5354 cc_status = cc_prev_status;
5358 (define_insn "*fsole_1"
5359 [(set (match_operand:QI 0 "register_operand" "=d")
5360 (not:QI (ungt:QI (cc0) (const_int 0))))]
5361 "TARGET_68881 && !TARGET_68060"
5363 cc_status = cc_prev_status;
5367 ;; Basic conditional jump instructions.
5369 (define_insn "beq0_di"
5371 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
5373 (label_ref (match_operand 1 "" ","))
5375 (clobber (match_scratch:SI 2 "=d,d"))]
5379 if (which_alternative == 1)
5382 return "move%.l %0,%2\;or%.l %0,%2\;jbeq %l1";
5384 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5386 if ((cc_prev_status.value1
5387 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5388 || (cc_prev_status.value2
5389 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5391 cc_status = cc_prev_status;
5392 return MOTOROLA ? "jbeq %l1" : "jeq %l1";
5394 if (GET_CODE (operands[0]) == REG)
5395 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5397 operands[3] = adjust_address (operands[0], SImode, 4);
5398 if (! ADDRESS_REG_P (operands[0]))
5400 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5402 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5405 return "or%.l %0,%2\;jbeq %l1";
5407 return "or%.l %0,%2\;jeq %l1";
5412 return "or%.l %3,%2\;jbeq %l1";
5414 return "or%.l %3,%2\;jeq %l1";
5418 return "move%.l %0,%2\;or%.l %3,%2\;jbeq %l1";
5420 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5422 operands[4] = gen_label_rtx();
5423 if (TARGET_68020 || TARGET_COLDFIRE)
5426 output_asm_insn ("tst%.l %0\;jbne %l4\;tst%.l %3\;jbeq %l1", operands);
5428 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
5433 output_asm_insn ("cmp%.w #0,%0\;jbne %l4\;cmp%.w #0,%3\;jbeq %l1", operands);
5435 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
5437 (*targetm.asm_out.internal_label) (asm_out_file, "L",
5438 CODE_LABEL_NUMBER (operands[4]));
5442 (define_insn "bne0_di"
5444 (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
5446 (label_ref (match_operand 1 "" ","))
5448 (clobber (match_scratch:SI 2 "=d,X"))]
5451 if ((cc_prev_status.value1
5452 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5453 || (cc_prev_status.value2
5454 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5456 cc_status = cc_prev_status;
5457 return MOTOROLA ? "jbne %l1" : "jne %l1";
5460 if (GET_CODE (operands[0]) == REG)
5461 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5463 operands[3] = adjust_address (operands[0], SImode, 4);
5464 if (!ADDRESS_REG_P (operands[0]))
5466 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5468 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5471 return "or%.l %0,%2\;jbne %l1";
5473 return "or%.l %0,%2\;jne %l1";
5478 return "or%.l %3,%2\;jbne %l1";
5480 return "or%.l %3,%2\;jne %l1";
5484 return "move%.l %0,%2\;or%.l %3,%2\;jbne %l1";
5486 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
5488 if (TARGET_68020 || TARGET_COLDFIRE)
5491 return "tst%.l %0\;jbne %l1\;tst%.l %3\;jbne %l1";
5493 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
5498 return "cmp%.w #0,%0\;jbne %l1\;cmp%.w #0,%3\;jbne %l1";
5500 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
5504 (define_insn "bge0_di"
5506 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
5508 (label_ref (match_operand 1 "" ""))
5512 if ((cc_prev_status.value1
5513 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5514 || (cc_prev_status.value2
5515 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5517 cc_status = cc_prev_status;
5518 if (cc_status.flags & CC_REVERSED)
5520 return MOTOROLA ? "jble %l1" : "jle %l1";
5524 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5528 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5529 output_asm_insn("tst%.l %0", operands);
5532 /* On an address reg, cmpw may replace cmpl. */
5533 output_asm_insn("cmp%.w #0,%0", operands);
5535 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5538 (define_insn "blt0_di"
5540 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
5542 (label_ref (match_operand 1 "" ""))
5546 if ((cc_prev_status.value1
5547 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5548 || (cc_prev_status.value2
5549 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5551 cc_status = cc_prev_status;
5552 if (cc_status.flags & CC_REVERSED)
5554 return MOTOROLA ? "jbgt %l1" : "jgt %l1";
5558 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5562 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5563 output_asm_insn("tst%.l %0", operands);
5566 /* On an address reg, cmpw may replace cmpl. */
5567 output_asm_insn("cmp%.w #0,%0", operands);
5570 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5575 (if_then_else (eq (cc0)
5577 (label_ref (match_operand 0 "" ""))
5582 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5584 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5589 (if_then_else (ne (cc0)
5591 (label_ref (match_operand 0 "" ""))
5596 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5598 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5603 (if_then_else (gt (cc0)
5605 (label_ref (match_operand 0 "" ""))
5610 OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0);
5612 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
5617 (if_then_else (gtu (cc0)
5619 (label_ref (match_operand 0 "" ""))
5623 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5628 (if_then_else (lt (cc0)
5630 (label_ref (match_operand 0 "" ""))
5635 OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0");
5637 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
5642 (if_then_else (ltu (cc0)
5644 (label_ref (match_operand 0 "" ""))
5648 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5653 (if_then_else (ge (cc0)
5655 (label_ref (match_operand 0 "" ""))
5660 OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0");
5662 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
5667 (if_then_else (geu (cc0)
5669 (label_ref (match_operand 0 "" ""))
5673 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5678 (if_then_else (le (cc0)
5680 (label_ref (match_operand 0 "" ""))
5685 OUTPUT_JUMP ("jble %l0", "fble %l0", 0);
5687 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
5692 (if_then_else (leu (cc0)
5694 (label_ref (match_operand 0 "" ""))
5698 return MOTOROLA ? "jbls %l0" : "jls %l0";
5701 (define_insn "bordered"
5703 (if_then_else (ordered (cc0) (const_int 0))
5704 (label_ref (match_operand 0 "" ""))
5708 if (!(cc_prev_status.flags & CC_IN_68881))
5710 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5713 (define_insn "bunordered"
5715 (if_then_else (unordered (cc0) (const_int 0))
5716 (label_ref (match_operand 0 "" ""))
5720 if (!(cc_prev_status.flags & CC_IN_68881))
5722 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5725 (define_insn "buneq"
5727 (if_then_else (uneq (cc0) (const_int 0))
5728 (label_ref (match_operand 0 "" ""))
5732 if (!(cc_prev_status.flags & CC_IN_68881))
5734 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5737 (define_insn "bunge"
5739 (if_then_else (unge (cc0) (const_int 0))
5740 (label_ref (match_operand 0 "" ""))
5744 if (!(cc_prev_status.flags & CC_IN_68881))
5746 return MOTOROLA ? "fbuge %l0" : "fjuge %l0";
5749 (define_insn "bungt"
5751 (if_then_else (ungt (cc0) (const_int 0))
5752 (label_ref (match_operand 0 "" ""))
5756 if (!(cc_prev_status.flags & CC_IN_68881))
5758 return MOTOROLA ? "fbugt %l0" : "fjugt %l0";
5761 (define_insn "bunle"
5763 (if_then_else (unle (cc0) (const_int 0))
5764 (label_ref (match_operand 0 "" ""))
5768 if (!(cc_prev_status.flags & CC_IN_68881))
5770 return MOTOROLA ? "fbule %l0" : "fjule %l0";
5773 (define_insn "bunlt"
5775 (if_then_else (unlt (cc0) (const_int 0))
5776 (label_ref (match_operand 0 "" ""))
5780 if (!(cc_prev_status.flags & CC_IN_68881))
5782 return MOTOROLA ? "fbult %l0" : "fjult %l0";
5785 (define_insn "bltgt"
5787 (if_then_else (ltgt (cc0) (const_int 0))
5788 (label_ref (match_operand 0 "" ""))
5792 if (!(cc_prev_status.flags & CC_IN_68881))
5794 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5797 ;; Negated conditional jump instructions.
5801 (if_then_else (eq (cc0)
5804 (label_ref (match_operand 0 "" ""))))]
5808 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5810 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5815 (if_then_else (ne (cc0)
5818 (label_ref (match_operand 0 "" ""))))]
5822 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5824 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5829 (if_then_else (gt (cc0)
5832 (label_ref (match_operand 0 "" ""))))]
5836 OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0);
5838 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
5843 (if_then_else (gtu (cc0)
5846 (label_ref (match_operand 0 "" ""))))]
5849 return MOTOROLA ? "jbls %l0" : "jls %l0";
5854 (if_then_else (lt (cc0)
5857 (label_ref (match_operand 0 "" ""))))]
5861 OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0");
5863 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
5868 (if_then_else (ltu (cc0)
5871 (label_ref (match_operand 0 "" ""))))]
5874 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5879 (if_then_else (ge (cc0)
5882 (label_ref (match_operand 0 "" ""))))]
5886 OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0");
5888 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
5893 (if_then_else (geu (cc0)
5896 (label_ref (match_operand 0 "" ""))))]
5899 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5904 (if_then_else (le (cc0)
5907 (label_ref (match_operand 0 "" ""))))]
5911 OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0);
5913 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
5918 (if_then_else (leu (cc0)
5921 (label_ref (match_operand 0 "" ""))))]
5924 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5927 (define_insn "*bordered_rev"
5929 (if_then_else (ordered (cc0) (const_int 0))
5931 (label_ref (match_operand 0 "" ""))))]
5934 if (!(cc_prev_status.flags & CC_IN_68881))
5936 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5939 (define_insn "*bunordered_rev"
5941 (if_then_else (unordered (cc0) (const_int 0))
5943 (label_ref (match_operand 0 "" ""))))]
5946 if (!(cc_prev_status.flags & CC_IN_68881))
5948 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5951 (define_insn "*buneq_rev"
5953 (if_then_else (uneq (cc0) (const_int 0))
5955 (label_ref (match_operand 0 "" ""))))]
5958 if (!(cc_prev_status.flags & CC_IN_68881))
5960 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5963 (define_insn "*bunge_rev"
5965 (if_then_else (unge (cc0) (const_int 0))
5967 (label_ref (match_operand 0 "" ""))))]
5970 if (!(cc_prev_status.flags & CC_IN_68881))
5972 return MOTOROLA ? "fbolt %l0" : "fjolt %l0";
5975 (define_insn "*bunle_rev"
5977 (if_then_else (unle (cc0) (const_int 0))
5979 (label_ref (match_operand 0 "" ""))))]
5982 if (!(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 if (!(cc_prev_status.flags & CC_IN_68881))
5996 return MOTOROLA ? "fboge %l0" : "fjoge %l0";
5999 (define_insn "*bltgt_rev"
6001 (if_then_else (ltgt (cc0) (const_int 0))
6003 (label_ref (match_operand 0 "" ""))))]
6006 if (!(cc_prev_status.flags & CC_IN_68881))
6008 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
6011 ;; Unconditional and other jump instructions
6014 (label_ref (match_operand 0 "" "")))]
6017 return MOTOROLA ? "jbra %l0" : "jra %l0";
6020 (define_expand "tablejump"
6021 [(parallel [(set (pc) (match_operand 0 "" ""))
6022 (use (label_ref (match_operand 1 "" "")))])]
6026 #ifdef CASE_VECTOR_PC_RELATIVE
6027 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6028 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6032 ;; Jump to variable address from dispatch table of absolute addresses.
6034 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6035 (use (label_ref (match_operand 1 "" "")))]
6038 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6041 ;; Jump to variable address from dispatch table of relative addresses.
6045 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6046 (use (label_ref (match_operand 1 "" "")))]
6049 #ifdef ASM_RETURN_CASE_JUMP
6050 ASM_RETURN_CASE_JUMP;
6052 if (TARGET_COLDFIRE)
6054 if (ADDRESS_REG_P (operands[0]))
6055 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6057 return "ext%.l %0\;jmp (2,pc,%0.l)";
6059 return "extl %0\;jmp pc@(2,%0:l)";
6062 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6066 ;; Decrement-and-branch insns.
6070 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6072 (label_ref (match_operand 1 "" ""))
6075 (plus:HI (match_dup 0)
6080 if (DATA_REG_P (operands[0]))
6081 return "dbra %0,%l1";
6082 if (GET_CODE (operands[0]) == MEM)
6084 "subq%.w #1,%0\;jbcc %l1" :
6085 "subqw #1,%0\;jcc %l1";
6087 "subq%.w #1,%0\;cmp%.w #-1,%0\;jbne %l1" :
6088 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6094 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6096 (label_ref (match_operand 1 "" ""))
6099 (plus:SI (match_dup 0)
6104 if (DATA_REG_P (operands[0]))
6106 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6107 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6108 if (GET_CODE (operands[0]) == MEM)
6110 "subq%.l #1,%0\;jbcc %l1" :
6111 "subq%.l #1,%0\;jcc %l1";
6113 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6114 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6117 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6122 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6125 (label_ref (match_operand 1 "" ""))
6128 (plus:HI (match_dup 0)
6130 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6133 if (DATA_REG_P (operands[0]))
6134 return "dbra %0,%l1";
6135 if (GET_CODE (operands[0]) == MEM)
6137 "subq%.w #1,%0\;jbcc %l1" :
6138 "subq%.w #1,%0\;jcc %l1";
6140 "subq.w #1,%0\;cmp.w #-1,%0\;jbne %l1" :
6141 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6144 (define_expand "decrement_and_branch_until_zero"
6145 [(parallel [(set (pc)
6147 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6150 (label_ref (match_operand 1 "" ""))
6153 (plus:SI (match_dup 0)
6161 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6164 (label_ref (match_operand 1 "" ""))
6167 (plus:SI (match_dup 0)
6169 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6172 if (DATA_REG_P (operands[0]))
6174 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6175 "dbra %0,%l1\;clr%.w %0\;subql #1,%0\;jcc %l1";
6176 if (GET_CODE (operands[0]) == MEM)
6178 "subq%.l #1,%0\;jbcc %l1" :
6179 "subql #1,%0\;jcc %l1";
6181 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6182 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6186 ;; For PIC calls, in order to be able to support
6187 ;; dynamic linker LAZY BINDING, all the procedure calls need to go
6188 ;; through the PLT (Procedure Linkage Table) section in PIC mode.
6190 ;; PIC calls are handled by loading the address of the function into a
6191 ;; register (via movsi), then emitting a register indirect call using
6192 ;; the "jsr" function call syntax.
6194 ;; When outputting MIT syntax (e.g. on Suns), we add a bogus extra
6195 ;; operand to the jbsr statement to indicate that this call should
6196 ;; go through the PLT (why? because this is the way that Sun does it).
6198 ;; We have different patterns for PIC calls and non-PIC calls. The
6199 ;; different patterns are only used to choose the right syntax.
6201 ;; The svr4 m68k assembler recognizes this syntax: `bsr FUNC@PLTPC' and it
6202 ;; will create the correct relocation entry (R_68K_PLT32) for `FUNC',
6203 ;; that tells the linker editor to create an entry for `FUNC' in PLT
6204 ;; section at link time. However, all global objects reference are still
6205 ;; done by using `OBJ@GOT'. So, the goal here is to output the function
6206 ;; call operand as `FUNC@PLTPC', but output object operand as `OBJ@GOT'.
6207 ;; We need to have a way to differentiate these two different operands.
6209 ;; The strategy I use here is to use SYMBOL_REF_FLAG to differentiate
6210 ;; these two different operands. The macro LEGITIMATE_PIC_OPERAND_P needs
6211 ;; to be changed to recognize function calls symbol_ref operand as a valid
6212 ;; PIC operand (by checking whether SYMBOL_REF_FLAG is set). This will
6213 ;; avoid the compiler to load this symbol_ref operand into a register.
6214 ;; Remember, the operand "foo@PLTPC" cannot be called via jsr directly
6215 ;; since the value is a PC relative offset, not a real address.
6217 ;; All global objects are treated in the similar way as in SUN3. The only
6218 ;; difference is: on m68k svr4, the reference of such global object needs
6219 ;; to end with a suffix "@GOT" so the assembler and linker know to create
6220 ;; an entry for it in GOT (Global Offset Table) section. This is done in
6223 ;; Call subroutine with no return value.
6224 (define_expand "call"
6225 [(call (match_operand:QI 0 "memory_operand" "")
6226 (match_operand:SI 1 "general_operand" ""))]
6227 ;; Operand 1 not really used on the m68000.
6232 if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
6233 SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1;
6236 ;; This is a normal call sequence.
6238 [(call (match_operand:QI 0 "memory_operand" "o")
6239 (match_operand:SI 1 "general_operand" "g"))]
6240 ;; Operand 1 not really used on the m68000.
6244 #if MOTOROLA && !defined (USE_GAS)
6251 ;; This is a PIC call sequence.
6253 [(call (match_operand:QI 0 "memory_operand" "o")
6254 (match_operand:SI 1 "general_operand" "g"))]
6255 ;; Operand 1 not really used on the m68000.
6259 m68k_output_pic_call(operands[0]);
6263 ;; Call subroutine, returning value in operand 0
6264 ;; (which must be a hard register).
6265 ;; See comments before "call" regarding PIC calls.
6266 (define_expand "call_value"
6267 [(set (match_operand 0 "" "")
6268 (call (match_operand:QI 1 "memory_operand" "")
6269 (match_operand:SI 2 "general_operand" "")))]
6270 ;; Operand 2 not really used on the m68000.
6274 if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
6275 SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1;
6278 ;; This is a normal call_value
6280 [(set (match_operand 0 "" "=rf")
6281 (call (match_operand:QI 1 "memory_operand" "o")
6282 (match_operand:SI 2 "general_operand" "g")))]
6283 ;; Operand 2 not really used on the m68000.
6286 #if MOTOROLA && !defined (USE_GAS)
6293 ;; This is a PIC call_value
6295 [(set (match_operand 0 "" "=rf")
6296 (call (match_operand:QI 1 "memory_operand" "o")
6297 (match_operand:SI 2 "general_operand" "g")))]
6298 ;; Operand 2 not really used on the m68000.
6301 m68k_output_pic_call(operands[1]);
6305 ;; Call subroutine returning any type.
6307 (define_expand "untyped_call"
6308 [(parallel [(call (match_operand 0 "" "")
6310 (match_operand 1 "" "")
6311 (match_operand 2 "" "")])]
6312 "NEEDS_UNTYPED_CALL"
6317 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6319 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6321 rtx set = XVECEXP (operands[2], 0, i);
6322 emit_move_insn (SET_DEST (set), SET_SRC (set));
6325 /* The optimizer does not know that the call sets the function value
6326 registers we stored in the result block. We avoid problems by
6327 claiming that all hard registers are used and clobbered at this
6329 emit_insn (gen_blockage ());
6334 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6335 ;; all of memory. This blocks insns from being moved across this point.
6337 (define_insn "blockage"
6338 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6347 ;; Used for frameless functions which save no regs and allocate no locals.
6348 (define_insn "return"
6352 if (current_function_pops_args == 0)
6354 operands[0] = GEN_INT (current_function_pops_args);
6358 (define_insn "indirect_jump"
6359 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
6363 ;; This should not be used unless the add/sub insns can't be.
6366 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
6367 (match_operand:QI 1 "address_operand" "p"))]
6370 /* Recognize an insn that refers to a table of offsets. Such an insn will
6371 need to refer to a label on the insn. So output one. Use the
6372 label-number of the table of offsets to generate this label. This code,
6373 and similar code above, assumes that there will be at most one reference
6375 if (GET_CODE (operands[1]) == PLUS
6376 && GET_CODE (XEXP (operands[1], 1)) == LABEL_REF
6377 && GET_CODE (XEXP (operands[1], 0)) != PLUS)
6379 rtx labelref = XEXP (operands[1], 1);
6381 asm_fprintf (asm_out_file, "\\t.set %LLI%d,.+2\\n",
6382 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6384 (*targetm.asm_out.internal_label) (asm_out_file, "LI",
6385 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6387 return "lea %a1,%0";
6390 ;; This is the first machine-dependent peephole optimization.
6391 ;; It is useful when a floating value is returned from a function call
6392 ;; and then is moved into an FP register.
6393 ;; But it is mainly intended to test the support for these optimizations.
6396 [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int 4)))
6397 (set (match_operand:DF 0 "register_operand" "=f")
6398 (match_operand:DF 1 "register_operand" "ad"))]
6399 "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
6402 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6403 output_asm_insn ("move%.l %1,%@", xoperands);
6404 output_asm_insn ("move%.l %1,%-", operands);
6405 return "fmove%.d %+,%0";
6408 ;; Optimize a stack-adjust followed by a push of an argument.
6409 ;; This is said to happen frequently with -msoft-float
6410 ;; when there are consecutive library calls.
6413 [(set (reg:SI 15) (plus:SI (reg:SI 15)
6414 (match_operand:SI 0 "const_int_operand" "n")))
6415 (set (match_operand:SF 1 "push_operand" "=m")
6416 (match_operand:SF 2 "general_operand" "rmfF"))]
6417 "INTVAL (operands[0]) >= 4
6418 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6420 if (INTVAL (operands[0]) > 4)
6423 xoperands[0] = stack_pointer_rtx;
6424 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6425 if (INTVAL (xoperands[1]) <= 8)
6427 if (!TARGET_COLDFIRE)
6428 output_asm_insn ("addq%.w %1,%0", xoperands);
6430 output_asm_insn ("addq%.l %1,%0", xoperands);
6432 else if (TARGET_CPU32 && INTVAL (xoperands[1]) <= 16)
6434 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6435 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6437 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6440 output_asm_insn ("add%.w %1,%0", xoperands);
6442 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6444 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6447 output_asm_insn ("add%.l %1,%0", xoperands);
6449 if (FP_REG_P (operands[2]))
6450 return "fmove%.s %2,%@";
6451 return "move%.l %2,%@";
6454 ;; Speed up stack adjust followed by a fullword fixedpoint push.
6457 [(set (reg:SI 15) (plus:SI (reg:SI 15)
6458 (match_operand:SI 0 "const_int_operand" "n")))
6459 (set (match_operand:SI 1 "push_operand" "=m")
6460 (match_operand:SI 2 "general_operand" "g"))]
6461 "INTVAL (operands[0]) >= 4
6462 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6464 if (INTVAL (operands[0]) > 4)
6467 xoperands[0] = stack_pointer_rtx;
6468 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6469 if (INTVAL (xoperands[1]) <= 8)
6471 if (!TARGET_COLDFIRE)
6472 output_asm_insn ("addq%.w %1,%0", xoperands);
6474 output_asm_insn ("addq%.l %1,%0", xoperands);
6476 else if (TARGET_CPU32 && INTVAL (xoperands[1]) <= 16)
6478 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6479 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6481 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6484 output_asm_insn ("add%.w %1,%0", xoperands);
6486 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6488 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6491 output_asm_insn ("add%.l %1,%0", xoperands);
6493 if (operands[2] == const0_rtx)
6495 return "move%.l %2,%@";
6498 ;; Speed up pushing a single byte but leaving four bytes of space.
6501 [(set (mem:QI (pre_dec:SI (reg:SI 15)))
6502 (match_operand:QI 1 "general_operand" "dami"))
6503 (set (reg:SI 15) (minus:SI (reg:SI 15) (const_int 2)))]
6504 "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
6508 if (GET_CODE (operands[1]) == REG)
6509 return "move%.l %1,%-";
6511 xoperands[1] = operands[1];
6513 = gen_rtx_MEM (QImode, plus_constant (stack_pointer_rtx, 3));
6514 xoperands[3] = stack_pointer_rtx;
6515 if (!TARGET_COLDFIRE)
6516 output_asm_insn ("subq%.w #4,%3\;move%.b %1,%2", xoperands);
6518 output_asm_insn ("subq%.l #4,%3\;move%.b %1,%2", xoperands);
6523 [(set (match_operand:SI 0 "register_operand" "=d")
6525 (set (strict_low_part (subreg:HI (match_dup 0) 2))
6526 (match_operand:HI 1 "general_operand" "rmn"))]
6527 "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
6529 if (GET_CODE (operands[1]) == CONST_INT)
6531 if (operands[1] == const0_rtx
6532 && (DATA_REG_P (operands[0])
6533 || GET_CODE (operands[0]) == MEM)
6534 /* clr insns on 68000 read before writing.
6535 This isn't so on the 68010, but we have no TARGET_68010. */
6536 && ((TARGET_68020 || TARGET_COLDFIRE)
6537 || !(GET_CODE (operands[0]) == MEM
6538 && MEM_VOLATILE_P (operands[0]))))
6541 return "move%.w %1,%0";
6549 ;; jCC label ; abnormal loop termination
6550 ;; dbra dN, loop ; normal loop termination
6558 ;; Which moves the jCC condition outside the inner loop for free.
6562 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6563 [(cc0) (const_int 0)])
6564 (label_ref (match_operand 2 "" ""))
6569 (ne (match_operand:HI 0 "register_operand" "")
6571 (label_ref (match_operand 1 "" ""))
6574 (plus:HI (match_dup 0)
6576 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6579 output_dbcc_and_branch (operands);
6584 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6585 [(cc0) (const_int 0)])
6586 (label_ref (match_operand 2 "" ""))
6591 (ne (match_operand:SI 0 "register_operand" "")
6593 (label_ref (match_operand 1 "" ""))
6596 (plus:SI (match_dup 0)
6598 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6601 output_dbcc_and_branch (operands);
6606 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6607 [(cc0) (const_int 0)])
6608 (label_ref (match_operand 2 "" ""))
6613 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
6616 (label_ref (match_operand 1 "" ""))
6619 (plus:HI (match_dup 0)
6621 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6624 output_dbcc_and_branch (operands);
6629 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6630 [(cc0) (const_int 0)])
6631 (label_ref (match_operand 2 "" ""))
6636 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
6639 (label_ref (match_operand 1 "" ""))
6642 (plus:SI (match_dup 0)
6644 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6647 output_dbcc_and_branch (operands);
6652 (define_expand "tstxf"
6654 (match_operand:XF 0 "nonimmediate_operand" ""))]
6656 "m68k_last_compare_had_fp_operands = 1;")
6660 (match_operand:XF 0 "nonimmediate_operand" "fm"))]
6663 cc_status.flags = CC_IN_68881;
6664 return "ftst%.x %0";
6667 (define_expand "cmpxf"
6669 (compare (match_operand:XF 0 "nonimmediate_operand" "")
6670 (match_operand:XF 1 "nonimmediate_operand" "")))]
6672 "m68k_last_compare_had_fp_operands = 1;")
6676 (compare (match_operand:XF 0 "nonimmediate_operand" "f,m")
6677 (match_operand:XF 1 "nonimmediate_operand" "fm,f")))]
6680 cc_status.flags = CC_IN_68881;
6681 if (REG_P (operands[0]))
6683 if (REG_P (operands[1]))
6684 return "fcmp%.x %1,%0";
6686 return "fcmp%.x %f1,%0";
6688 cc_status.flags |= CC_REVERSED;
6689 return "fcmp%.x %f0,%1";
6692 (define_insn "extendsfxf2"
6693 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6694 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
6697 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6699 if (REGNO (operands[0]) == REGNO (operands[1]))
6701 /* Extending float to double in an fp-reg is a no-op.
6702 NOTICE_UPDATE_CC has already assumed that the
6703 cc will be set. So cancel what it did. */
6704 cc_status = cc_prev_status;
6707 return "f%$move%.x %1,%0";
6709 if (FP_REG_P (operands[0]))
6711 if (FP_REG_P (operands[1]))
6712 return "f%$move%.x %1,%0";
6713 else if (ADDRESS_REG_P (operands[1]))
6714 return "move%.l %1,%-\;f%$move%.s %+,%0";
6715 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
6716 return output_move_const_single (operands);
6717 return "f%$move%.s %f1,%0";
6719 return "fmove%.x %f1,%0";
6723 (define_insn "extenddfxf2"
6724 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6726 (match_operand:DF 1 "general_operand" "f,rmE")))]
6729 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6731 if (REGNO (operands[0]) == REGNO (operands[1]))
6733 /* Extending float to double in an fp-reg is a no-op.
6734 NOTICE_UPDATE_CC has already assumed that the
6735 cc will be set. So cancel what it did. */
6736 cc_status = cc_prev_status;
6739 return "fmove%.x %1,%0";
6741 if (FP_REG_P (operands[0]))
6743 if (REG_P (operands[1]))
6746 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6747 output_asm_insn ("move%.l %1,%-", xoperands);
6748 output_asm_insn ("move%.l %1,%-", operands);
6749 return "f%&move%.d %+,%0";
6751 if (GET_CODE (operands[1]) == CONST_DOUBLE)
6752 return output_move_const_double (operands);
6753 return "f%&move%.d %f1,%0";
6755 return "fmove%.x %f1,%0";
6758 (define_insn "truncxfdf2"
6759 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
6761 (match_operand:XF 1 "general_operand" "f,f")))]
6764 if (REG_P (operands[0]))
6766 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
6767 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6768 return "move%.l %+,%0";
6770 return "fmove%.d %f1,%0";
6773 (define_insn "truncxfsf2"
6774 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
6776 (match_operand:XF 1 "general_operand" "f")))]
6780 (define_insn "floatsixf2"
6781 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6782 (float:XF (match_operand:SI 1 "general_operand" "dmi")))]
6786 (define_insn "floathixf2"
6787 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6788 (float:XF (match_operand:HI 1 "general_operand" "dmn")))]
6792 (define_insn "floatqixf2"
6793 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6794 (float:XF (match_operand:QI 1 "general_operand" "dmn")))]
6798 (define_insn "ftruncxf2"
6799 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6800 (fix:XF (match_operand:XF 1 "general_operand" "fFm")))]
6803 if (FP_REG_P (operands[1]))
6804 return "fintrz%.x %f1,%0";
6805 return "fintrz%.x %f1,%0";
6808 (define_insn "fixxfqi2"
6809 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
6810 (fix:QI (match_operand:XF 1 "general_operand" "f")))]
6814 (define_insn "fixxfhi2"
6815 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
6816 (fix:HI (match_operand:XF 1 "general_operand" "f")))]
6820 (define_insn "fixxfsi2"
6821 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
6822 (fix:SI (match_operand:XF 1 "general_operand" "f")))]
6827 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6828 (plus:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
6829 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6834 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6835 (plus:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
6836 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6841 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6842 (plus:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
6843 (match_operand:XF 1 "general_operand" "0")))]
6847 (define_insn "addxf3"
6848 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6849 (plus:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
6850 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6853 if (REG_P (operands[2]))
6854 return "fadd%.x %2,%0";
6855 return "fadd%.x %f2,%0";
6859 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6860 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6861 (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
6866 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6867 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6868 (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
6873 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6874 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6875 (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
6879 (define_insn "subxf3"
6880 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6881 (minus:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6882 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6885 if (REG_P (operands[2]))
6886 return "fsub%.x %2,%0";
6887 return "fsub%.x %f2,%0";
6891 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6892 (mult:XF (float:XF (match_operand:SI 2 "general_operand" "dmi"))
6893 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6898 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6899 (mult:XF (float:XF (match_operand:HI 2 "general_operand" "dmn"))
6900 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6905 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6906 (mult:XF (float:XF (match_operand:QI 2 "general_operand" "dmn"))
6907 (match_operand:XF 1 "nonimmediate_operand" "0")))]
6911 (define_insn "mulxf3"
6912 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6913 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
6914 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6917 if (REG_P (operands[2]))
6918 return "fmul%.x %2,%0";
6919 return "fmul%.x %f2,%0";
6923 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6924 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6925 (float:XF (match_operand:SI 2 "general_operand" "dmi"))))]
6930 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6931 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6932 (float:XF (match_operand:HI 2 "general_operand" "dmn"))))]
6937 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6938 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6939 (float:XF (match_operand:QI 2 "general_operand" "dmn"))))]
6943 (define_insn "divxf3"
6944 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6945 (div:XF (match_operand:XF 1 "nonimmediate_operand" "0")
6946 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
6949 if (REG_P (operands[2]))
6950 return "fdiv%.x %2,%0";
6951 return "fdiv%.x %f2,%0";
6954 (define_expand "negxf2"
6955 [(set (match_operand:XF 0 "nonimmediate_operand" "")
6956 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
6967 target = operand_subword (operands[0], 0, 1, XFmode);
6968 result = expand_binop (SImode, xor_optab,
6969 operand_subword_force (operands[1], 0, XFmode),
6970 GEN_INT (0x80000000), target, 0, OPTAB_WIDEN);
6974 if (result != target)
6975 emit_move_insn (result, target);
6977 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
6978 operand_subword_force (operands[1], 1, XFmode));
6979 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
6980 operand_subword_force (operands[1], 2, XFmode));
6982 insns = get_insns ();
6985 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
6990 (define_insn "negxf2_68881"
6991 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
6992 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
6995 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
6996 return "fneg%.x %1,%0";
6997 return "fneg%.x %f1,%0";
7000 (define_expand "absxf2"
7001 [(set (match_operand:XF 0 "nonimmediate_operand" "")
7002 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
7013 target = operand_subword (operands[0], 0, 1, XFmode);
7014 result = expand_binop (SImode, and_optab,
7015 operand_subword_force (operands[1], 0, XFmode),
7016 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
7020 if (result != target)
7021 emit_move_insn (result, target);
7023 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
7024 operand_subword_force (operands[1], 1, XFmode));
7025 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
7026 operand_subword_force (operands[1], 2, XFmode));
7028 insns = get_insns ();
7031 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
7036 (define_insn "absxf2_68881"
7037 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7038 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
7041 if (REG_P (operands[1]) && ! DATA_REG_P (operands[1]))
7042 return "fabs%.x %1,%0";
7043 return "fabs%.x %f1,%0";
7046 (define_insn "sqrtxf2"
7047 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7048 (sqrt:XF (match_operand:XF 1 "nonimmediate_operand" "fm")))]
7052 (define_insn "sinsf2"
7053 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
7054 (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] UNSPEC_SIN))]
7055 "TARGET_68881 && flag_unsafe_math_optimizations"
7057 if (FP_REG_P (operands[1]))
7058 return "fsin%.x %1,%0";
7060 return "fsin%.s %1,%0";
7063 (define_insn "sindf2"
7064 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
7065 (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] UNSPEC_SIN))]
7066 "TARGET_68881 && flag_unsafe_math_optimizations"
7068 if (FP_REG_P (operands[1]))
7069 return "fsin%.x %1,%0";
7071 return "fsin%.d %1,%0";
7074 (define_insn "sinxf2"
7075 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7076 (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] UNSPEC_SIN))]
7077 "TARGET_68881 && flag_unsafe_math_optimizations"
7080 (define_insn "cossf2"
7081 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
7082 (unspec:SF [(match_operand:SF 1 "general_operand" "fm")] UNSPEC_COS))]
7083 "TARGET_68881 && flag_unsafe_math_optimizations"
7085 if (FP_REG_P (operands[1]))
7086 return "fcos%.x %1,%0";
7088 return "fcos%.s %1,%0";
7091 (define_insn "cosdf2"
7092 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
7093 (unspec:DF [(match_operand:DF 1 "general_operand" "fm")] UNSPEC_COS))]
7094 "TARGET_68881 && flag_unsafe_math_optimizations"
7096 if (FP_REG_P (operands[1]))
7097 return "fcos%.x %1,%0";
7099 return "fcos%.d %1,%0";
7102 (define_insn "cosxf2"
7103 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
7104 (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] UNSPEC_COS))]
7105 "TARGET_68881 && flag_unsafe_math_optimizations"
7109 [(trap_if (const_int -1) (const_int 7))]
7113 (define_insn "conditional_trap"
7114 [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
7115 [(cc0) (const_int 0)])
7116 (match_operand:SI 1 "const_int_operand" "I"))]
7117 "TARGET_68020 && ! flags_in_68881 ()"
7119 switch (GET_CODE (operands[0]))
7121 case EQ: return "trapeq";
7122 case NE: return "trapne";
7123 case GT: return "trapgt";
7124 case GTU: return "traphi";
7125 case LT: return "traplt";
7126 case LTU: return "trapcs";
7127 case GE: return "trapge";
7128 case GEU: return "trapcc";
7129 case LE: return "traple";
7130 case LEU: return "trapls";