1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; This file is part of GNU CC.
7 ;; GNU CC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; GNU CC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU CC; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
22 ;;- Information about MCF5200 port.
24 ;;- The MCF5200 "ColdFire" architecture is a reduced version of the
25 ;;- 68k ISA. Differences include reduced support for byte and word
26 ;;- operands and the removal of BCD, bitfield, rotate, and integer
27 ;;- divide instructions. The TARGET_5200 flag turns the use of the
28 ;;- removed opcodes and addressing modes off.
32 ;;- instruction definitions
34 ;;- @@The original PO technology requires these to be ordered by speed,
35 ;;- @@ so that assigner will pick the fastest.
37 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
39 ;;- When naming insn's (operand 0 of define_insn) be careful about using
40 ;;- names from other targets machine descriptions.
42 ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
43 ;;- updates for most instructions.
45 ;;- Operand classes for the register allocator:
46 ;;- 'a' one of the address registers can be used.
47 ;;- 'd' one of the data registers can be used.
48 ;;- 'f' one of the m68881 registers can be used
49 ;;- 'r' either a data or an address register can be used.
51 ;;- Immediate Floating point operator constraints
52 ;;- 'G' a floating point constant that is *NOT* one of the standard
53 ;; 68881 constant values (to force calling output_move_const_double
54 ;; to get it from rom if it is a 68881 constant).
56 ;; See the functions standard_XXX_constant_p in output-m68k.c for more
59 ;;- Immediate integer operand constraints:
61 ;;- 'J' -32768 .. 32767
62 ;;- 'K' all integers EXCEPT -128 .. 127
64 ;;- 'M' all integers EXCEPT -256 .. 255
70 ;;- "%." size separator ("." or "") move%.l d0,d1
71 ;;- "%#" immediate separator ("#" or "") move%.l %#0,d0
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"))]
132 if (FP_REG_P (operands[1]))
133 return \"fmove%.d %f1,%0\";
134 return output_move_double (operands);
137 (define_insn "pushdi"
138 [(set (match_operand:DI 0 "push_operand" "=m")
139 (match_operand:DI 1 "general_operand" "ro<>Fyi"))]
143 return output_move_double (operands);
146 ;; We don't want to allow a constant operand for test insns because
147 ;; (set (cc0) (const_int foo)) has no mode information. Such insns will
148 ;; be folded while optimizing anyway.
150 (define_expand "tstdi"
151 [(parallel [(set (cc0)
152 (match_operand:DI 0 "nonimmediate_operand" ""))
153 (clobber (match_scratch:SI 1 ""))
154 (clobber (match_scratch:DI 2 ""))])]
156 "m68k_last_compare_had_fp_operands = 0;")
160 (match_operand:DI 0 "nonimmediate_operand" "am,d"))
161 (clobber (match_scratch:SI 1 "=X,d"))
162 (clobber (match_scratch:DI 2 "=d,X"))]
166 if (which_alternative == 0)
170 xoperands[0] = operands[2];
171 xoperands[1] = operands[0];
172 output_move_double (xoperands);
173 cc_status.flags |= CC_REVERSED;
174 return \"neg%.l %R2\;negx%.l %2\";
176 if (find_reg_note (insn, REG_DEAD, operands[0]))
178 cc_status.flags |= CC_REVERSED;
179 return \"neg%.l %R0\;negx%.l %0\";
183 ** 'sub' clears %1, and also clears the X cc bit
184 ** 'tst' sets the Z cc bit according to the low part of the DImode operand
185 ** 'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part
187 return \"sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0\";
190 (define_expand "tstsi"
192 (match_operand:SI 0 "nonimmediate_operand" ""))]
194 "m68k_last_compare_had_fp_operands = 0;")
198 (match_operand:SI 0 "nonimmediate_operand" "rm"))]
203 /* ISI's assembler fails to handle tstl a0. */
204 if (! ADDRESS_REG_P (operands[0]))
206 if (TARGET_68020 || TARGET_5200 || ! ADDRESS_REG_P (operands[0]))
208 return \"tst%.l %0\";
209 /* If you think that the 68020 does not support tstl a0,
210 reread page B-167 of the 68020 manual more carefully. */
211 /* On an address reg, cmpw may replace cmpl. */
213 return \"cmp%.w %0,%#0\";
215 return \"cmp%.w %#0,%0\";
219 ;; This can't use an address register, because comparisons
220 ;; with address registers as second operand always test the whole word.
221 (define_expand "tsthi"
223 (match_operand:HI 0 "nonimmediate_operand" ""))]
225 "m68k_last_compare_had_fp_operands = 0;")
229 (match_operand:HI 0 "nonimmediate_operand" "dm"))]
233 (define_expand "tstqi"
235 (match_operand:QI 0 "nonimmediate_operand" ""))]
237 "m68k_last_compare_had_fp_operands = 0;")
241 (match_operand:QI 0 "nonimmediate_operand" "dm"))]
245 (define_expand "tstsf"
247 (match_operand:SF 0 "general_operand" ""))]
251 m68k_last_compare_had_fp_operands = 1;
256 (match_operand:SF 0 "general_operand" "fdm"))]
260 cc_status.flags = CC_IN_68881;
261 if (FP_REG_P (operands[0]))
262 return \"ftst%.x %0\";
263 return \"ftst%.s %0\";
266 (define_expand "tstdf"
268 (match_operand:DF 0 "general_operand" ""))]
272 m68k_last_compare_had_fp_operands = 1;
277 (match_operand:DF 0 "general_operand" "fm"))]
281 cc_status.flags = CC_IN_68881;
282 if (FP_REG_P (operands[0]))
283 return \"ftst%.x %0\";
284 return \"ftst%.d %0\";
287 ;; compare instructions.
289 (define_expand "cmpdi"
292 (compare (match_operand:DI 0 "nonimmediate_operand" "")
293 (match_operand:DI 1 "general_operand" "")))
294 (clobber (match_dup 2))])]
296 "m68k_last_compare_had_fp_operands = 0; operands[2] = gen_reg_rtx (DImode);")
300 (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
301 (match_operand:DI 2 "general_operand" "d,0")))
302 (clobber (match_operand:DI 0 "register_operand" "=d,d"))]
306 if (rtx_equal_p (operands[0], operands[1]))
307 return \"sub%.l %R2,%R0\;subx%.l %2,%0\";
310 cc_status.flags |= CC_REVERSED;
311 return \"sub%.l %R1,%R0\;subx%.l %1,%0\";
315 ;; This is the second "hook" for PIC code (in addition to movsi). See
316 ;; comment of movsi for a description of PIC handling.
317 (define_expand "cmpsi"
319 (compare (match_operand:SI 0 "nonimmediate_operand" "")
320 (match_operand:SI 1 "general_operand" "")))]
324 m68k_last_compare_had_fp_operands = 0;
325 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
327 /* The source is an address which requires PIC relocation.
328 Call legitimize_pic_address with the source, mode, and a relocation
329 register (a new pseudo, or the final destination if reload_in_progress
330 is set). Then fall through normally */
331 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
332 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
336 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
339 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
340 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
344 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
346 return \"cmpm%.l %0,%1\";
348 return \"cmpm%.l %1,%0\";
350 if (REG_P (operands[1])
351 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
352 { cc_status.flags |= CC_REVERSED;
354 return \"cmp%.l %d1,%d0\";
356 return \"cmp%.l %d0,%d1\";
359 if (ADDRESS_REG_P (operands[0])
360 && GET_CODE (operands[1]) == CONST_INT
361 && INTVAL (operands[1]) < 0x8000
362 && INTVAL (operands[1]) >= -0x8000)
365 return \"cmp%.w %0,%1\";
367 return \"cmp%.w %1,%0\";
371 return \"cmp%.l %d0,%d1\";
373 return \"cmp%.l %d1,%d0\";
379 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
380 (match_operand:SI 1 "general_operand" "r,mrKs")))]
384 if (REG_P (operands[1])
385 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
386 { cc_status.flags |= CC_REVERSED;
388 return \"cmp%.l %d1,%d0\";
390 return \"cmp%.l %d0,%d1\";
394 return \"cmp%.l %d0,%d1\";
396 return \"cmp%.l %d1,%d0\";
400 (define_expand "cmphi"
402 (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
403 (match_operand:HI 1 "general_src_operand" "")))]
405 "m68k_last_compare_had_fp_operands = 0;")
409 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
410 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
414 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
416 return \"cmpm%.w %0,%1\";
418 return \"cmpm%.w %1,%0\";
420 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
421 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
422 { cc_status.flags |= CC_REVERSED;
424 return \"cmp%.w %d1,%d0\";
426 return \"cmp%.w %d0,%d1\";
430 return \"cmp%.w %d0,%d1\";
432 return \"cmp%.w %d1,%d0\";
436 (define_expand "cmpqi"
438 (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
439 (match_operand:QI 1 "general_src_operand" "")))]
441 "m68k_last_compare_had_fp_operands = 0;")
445 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
446 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
450 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
452 return \"cmpm%.b %0,%1\";
454 return \"cmpm%.b %1,%0\";
456 if (REG_P (operands[1])
457 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
458 { cc_status.flags |= CC_REVERSED;
460 return \"cmp%.b %d1,%d0\";
462 return \"cmp%.b %d0,%d1\";
466 return \"cmp%.b %d0,%d1\";
468 return \"cmp%.b %d1,%d0\";
472 (define_expand "cmpdf"
474 (compare (match_operand:DF 0 "general_operand" "")
475 (match_operand:DF 1 "general_operand" "")))]
479 m68k_last_compare_had_fp_operands = 1;
484 (compare (match_operand:DF 0 "general_operand" "f,mG")
485 (match_operand:DF 1 "general_operand" "fmG,f")))]
489 cc_status.flags = CC_IN_68881;
491 if (REG_P (operands[0]))
493 if (REG_P (operands[1]))
494 return \"fcmp%.x %0,%1\";
496 return \"fcmp%.d %0,%f1\";
498 cc_status.flags |= CC_REVERSED;
499 return \"fcmp%.d %1,%f0\";
501 if (REG_P (operands[0]))
503 if (REG_P (operands[1]))
504 return \"fcmp%.x %1,%0\";
506 return \"fcmp%.d %f1,%0\";
508 cc_status.flags |= CC_REVERSED;
509 return \"fcmp%.d %f0,%1\";
513 (define_expand "cmpsf"
515 (compare (match_operand:SF 0 "general_operand" "")
516 (match_operand:SF 1 "general_operand" "")))]
520 m68k_last_compare_had_fp_operands = 1;
525 (compare (match_operand:SF 0 "general_operand" "f,mdG")
526 (match_operand:SF 1 "general_operand" "fmdG,f")))]
530 cc_status.flags = CC_IN_68881;
532 if (FP_REG_P (operands[0]))
534 if (FP_REG_P (operands[1]))
535 return \"fcmp%.x %0,%1\";
537 return \"fcmp%.s %0,%f1\";
539 cc_status.flags |= CC_REVERSED;
540 return \"fcmp%.s %1,%f0\";
542 if (FP_REG_P (operands[0]))
544 if (FP_REG_P (operands[1]))
545 return \"fcmp%.x %1,%0\";
547 return \"fcmp%.s %f1,%0\";
549 cc_status.flags |= CC_REVERSED;
550 return \"fcmp%.s %f0,%1\";
554 ;; Recognizers for btst instructions.
556 ;; Coldfire/5200 only allows "<Q>" type addresses when the bit position is
557 ;; specified as a constant, so we must disable all patterns that may extract
558 ;; from a MEM at a constant bit position if we can't use this as a constraint.
561 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
563 (minus:SI (const_int 7)
564 (match_operand:SI 1 "general_operand" "di"))))]
566 "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
568 ;; This is the same as the above pattern except for the constraints. The 'i'
572 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
574 (minus:SI (const_int 7)
575 (match_operand:SI 1 "general_operand" "d"))))]
577 "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
580 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
582 (minus:SI (const_int 31)
583 (match_operand:SI 1 "general_operand" "di"))))]
585 "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
587 ;; The following two patterns are like the previous two
588 ;; except that they use the fact that bit-number operands
589 ;; are automatically masked to 3 or 5 bits.
592 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
594 (minus:SI (const_int 7)
596 (match_operand:SI 1 "register_operand" "d")
599 "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
602 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
604 (minus:SI (const_int 31)
606 (match_operand:SI 1 "register_operand" "d")
609 "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
611 ;; Nonoffsettable mem refs are ok in this one pattern
612 ;; since we don't try to adjust them.
614 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
616 (match_operand:SI 1 "const_int_operand" "n")))]
617 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_5200"
620 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
621 return output_btst (operands, operands[1], operands[0], insn, 7);
625 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
627 (match_operand:SI 1 "const_int_operand" "n")))]
631 if (GET_CODE (operands[0]) == MEM)
633 operands[0] = adjust_address (operands[0], QImode,
634 INTVAL (operands[1]) / 8);
635 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
636 return output_btst (operands, operands[1], operands[0], insn, 7);
638 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
639 return output_btst (operands, operands[1], operands[0], insn, 31);
642 ;; This is the same as the above pattern except for the constraints.
643 ;; The 'o' has been replaced with 'Q'.
646 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
648 (match_operand:SI 1 "const_int_operand" "n")))]
652 if (GET_CODE (operands[0]) == MEM)
654 operands[0] = adjust_address (operands[0], QImode,
655 INTVAL (operands[1]) / 8);
656 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
657 return output_btst (operands, operands[1], operands[0], insn, 7);
659 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
660 return output_btst (operands, operands[1], operands[0], insn, 31);
666 ;; A special case in which it is not desirable
667 ;; to reload the constant into a data register.
668 (define_insn "pushexthisi_const"
669 [(set (match_operand:SI 0 "push_operand" "=m")
670 (match_operand:SI 1 "const_int_operand" "J"))]
671 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
674 if (operands[1] == const0_rtx)
675 return \"clr%.l %0\";
680 ;(define_insn "swapsi"
681 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
682 ; (match_operand:SI 1 "general_operand" "+r"))
683 ; (set (match_dup 1) (match_dup 0))]
687 ;; Special case of fullword move when source is zero.
688 ;; The reason this is special is to avoid loading a zero
689 ;; into a data reg with moveq in order to store it elsewhere.
691 (define_insn "movsi_const0"
692 [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
694 ;; clr insns on 68000 read before writing.
695 ;; This isn't so on the 68010, but we have no TARGET_68010.
696 "((TARGET_68020 || TARGET_5200)
697 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
700 if (ADDRESS_REG_P (operands[0]))
702 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
703 if (!TARGET_68040 && !TARGET_68060)
704 return \"sub%.l %0,%0\";
709 /* Many SGS assemblers croak on size specifiers for constants. */
712 return \"lea 0.w,%0\";
715 return \"lea 0:w,%0\";
719 /* moveq is faster on the 68000. */
720 if (DATA_REG_P (operands[0]) && (!TARGET_68020 && !TARGET_5200))
721 #if defined(MOTOROLA)
722 return \"moveq%.l %#0,%0\";
724 return \"moveq %#0,%0\";
726 return \"clr%.l %0\";
729 ;; General case of fullword move.
731 ;; This is the main "hook" for PIC code. When generating
732 ;; PIC, movsi is responsible for determining when the source address
733 ;; needs PIC relocation and appropriately calling legitimize_pic_address
734 ;; to perform the actual relocation.
736 ;; In both the PIC and non-PIC cases the patterns generated will
737 ;; matched by the next define_insn.
738 (define_expand "movsi"
739 [(set (match_operand:SI 0 "nonimmediate_operand" "")
740 (match_operand:SI 1 "general_operand" ""))]
744 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
746 /* The source is an address which requires PIC relocation.
747 Call legitimize_pic_address with the source, mode, and a relocation
748 register (a new pseudo, or the final destination if reload_in_progress
749 is set). Then fall through normally */
750 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
751 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
753 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
755 /* Don't allow writes to memory except via a register;
756 the m68k doesn't consider PC-relative addresses to be writable. */
757 if (symbolic_operand (operands[0], SImode))
758 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
759 else if (GET_CODE (operands[0]) == MEM
760 && symbolic_operand (XEXP (operands[0], 0), SImode))
761 operands[0] = gen_rtx (MEM, SImode,
762 force_reg (SImode, XEXP (operands[0], 0)));
766 ;; General case of fullword move. The register constraints
767 ;; force integer constants in range for a moveq to be reloaded
768 ;; if they are headed for memory.
770 ;; Notes: make sure no alternative allows g vs g.
771 ;; We don't allow f-regs since fixed point cannot go in them.
772 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
773 (match_operand:SI 1 "general_src_operand" "daymSKT,n,i"))]
778 return output_move_simode (operands);
782 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g")
783 (match_operand:SI 1 "general_operand" "g,r<Q>"))]
785 "* return output_move_simode (operands);")
787 ;; Special case of fullword move, where we need to get a non-GOT PIC
788 ;; reference into an address register.
790 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
791 (match_operand:SI 1 "pcrel_address" ""))]
795 if (push_operand (operands[0], SImode))
797 return \"lea %a1,%0\";
800 (define_expand "movhi"
801 [(set (match_operand:HI 0 "nonimmediate_operand" "")
802 (match_operand:HI 1 "general_operand" ""))]
807 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
808 (match_operand:HI 1 "general_src_operand" "gS"))]
810 "* return output_move_himode (operands);")
813 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g")
814 (match_operand:HI 1 "general_operand" "g,r<Q>"))]
816 "* return output_move_himode (operands);")
818 (define_expand "movstricthi"
819 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
820 (match_operand:HI 1 "general_src_operand" ""))]
825 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
826 (match_operand:HI 1 "general_src_operand" "rmSn"))]
828 "* return output_move_stricthi (operands);")
831 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
832 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
834 "* return output_move_stricthi (operands);")
836 (define_expand "movqi"
837 [(set (match_operand:QI 0 "nonimmediate_operand" "")
838 (match_operand:QI 1 "general_src_operand" ""))]
843 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
844 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
846 "* return output_move_qimode (operands);")
849 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,d*a")
850 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,di*a"))]
852 "* return output_move_qimode (operands);")
854 (define_expand "movstrictqi"
855 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
856 (match_operand:QI 1 "general_src_operand" ""))]
861 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
862 (match_operand:QI 1 "general_src_operand" "dmSn"))]
864 "* return output_move_strictqi (operands);")
867 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d,m"))
868 (match_operand:QI 1 "general_src_operand" "dmn,d"))]
870 "* return output_move_strictqi (operands);")
872 (define_expand "pushqi1"
873 [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int -2)))
874 (set (mem:QI (plus:SI (reg:SI 15) (const_int 1)))
875 (match_operand:QI 0 "general_operand" ""))]
879 (define_expand "movsf"
880 [(set (match_operand:SF 0 "nonimmediate_operand" "")
881 (match_operand:SF 1 "general_operand" ""))]
886 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
887 (match_operand:SF 1 "general_operand" "rmfF"))]
891 if (FP_REG_P (operands[0]))
893 if (FP_REG_P (operands[1]))
894 return \"f%$move%.x %1,%0\";
895 else if (ADDRESS_REG_P (operands[1]))
896 return \"move%.l %1,%-\;f%$move%.s %+,%0\";
897 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
898 return output_move_const_single (operands);
899 return \"f%$move%.s %f1,%0\";
901 if (FP_REG_P (operands[1]))
903 if (ADDRESS_REG_P (operands[0]))
904 return \"fmove%.s %1,%-\;move%.l %+,%0\";
905 return \"fmove%.s %f1,%0\";
907 if (operands[1] == CONST0_RTX (SFmode)
908 /* clr insns on 68000 read before writing.
909 This isn't so on the 68010, but we have no TARGET_68010. */
910 && ((TARGET_68020 || TARGET_5200)
911 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
913 if (ADDRESS_REG_P (operands[0]))
915 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
916 if (!TARGET_68040 && !TARGET_68060)
917 return \"sub%.l %0,%0\";
922 /* Many SGS assemblers croak on size specifiers for constants. */
925 return \"lea 0.w,%0\";
928 return \"lea 0:w,%0\";
932 /* moveq is faster on the 68000. */
933 if (DATA_REG_P (operands[0]) && !(TARGET_68020 || TARGET_5200))
935 #if defined(MOTOROLA)
936 return \"moveq%.l %#0,%0\";
938 return \"moveq %#0,%0\";
941 return \"clr%.l %0\";
943 return \"move%.l %1,%0\";
947 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,g")
948 (match_operand:SF 1 "general_operand" "g,r"))]
950 "* return \"move%.l %1,%0\";")
952 (define_expand "movdf"
953 [(set (match_operand:DF 0 "nonimmediate_operand" "")
954 (match_operand:DF 1 "general_operand" ""))]
959 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
960 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
961 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
962 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
966 if (FP_REG_P (operands[0]))
968 if (FP_REG_P (operands[1]))
969 return \"f%&move%.x %1,%0\";
970 if (REG_P (operands[1]))
973 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
974 output_asm_insn (\"move%.l %1,%-\", xoperands);
975 output_asm_insn (\"move%.l %1,%-\", operands);
976 return \"f%&move%.d %+,%0\";
978 if (GET_CODE (operands[1]) == CONST_DOUBLE)
979 return output_move_const_double (operands);
980 return \"f%&move%.d %f1,%0\";
982 else if (FP_REG_P (operands[1]))
984 if (REG_P (operands[0]))
986 output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
987 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
988 return \"move%.l %+,%0\";
991 return \"fmove%.d %f1,%0\";
993 return output_move_double (operands);
997 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
998 (match_operand:DF 1 "general_operand" "g,r"))]
1000 "* return output_move_double (operands);")
1002 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1003 ;; allowed. Most but not all have predicates and constraint that disallow
1004 ;; constants. Most but not all have output templates that handle constants.
1005 ;; See also LEGITIMATE_CONSTANT_P.
1007 (define_expand "movxf"
1008 [(set (match_operand:XF 0 "nonimmediate_operand" "")
1009 (match_operand:XF 1 "general_operand" ""))]
1013 /* We can't rewrite operands during reload. */
1014 if (! reload_in_progress)
1016 if (CONSTANT_P (operands[1]))
1018 operands[1] = force_const_mem (XFmode, operands[1]);
1019 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1020 operands[1] = adjust_address (operands[1], XFmode, 0);
1022 if (flag_pic && TARGET_PCREL)
1024 /* Don't allow writes to memory except via a register; the
1025 m68k doesn't consider PC-relative addresses to be writable. */
1026 if (GET_CODE (operands[0]) == MEM
1027 && symbolic_operand (XEXP (operands[0], 0), SImode))
1028 operands[0] = gen_rtx (MEM, XFmode,
1029 force_reg (SImode, XEXP (operands[0], 0)));
1035 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r")
1036 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r"))]
1040 if (FP_REG_P (operands[0]))
1042 if (FP_REG_P (operands[1]))
1043 return \"fmove%.x %1,%0\";
1044 if (REG_P (operands[1]))
1047 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1048 output_asm_insn (\"move%.l %1,%-\", xoperands);
1049 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1050 output_asm_insn (\"move%.l %1,%-\", xoperands);
1051 output_asm_insn (\"move%.l %1,%-\", operands);
1052 return \"fmove%.x %+,%0\";
1054 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1055 return \"fmove%.x %1,%0\";
1056 return \"fmove%.x %f1,%0\";
1058 if (FP_REG_P (operands[1]))
1060 if (REG_P (operands[0]))
1062 output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands);
1063 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1064 output_asm_insn (\"move%.l %+,%0\", operands);
1065 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1066 return \"move%.l %+,%0\";
1068 /* Must be memory destination. */
1069 return \"fmove%.x %f1,%0\";
1071 return output_move_double (operands);
1076 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1077 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1078 "! TARGET_68881 && ! TARGET_5200"
1081 if (FP_REG_P (operands[0]))
1083 if (FP_REG_P (operands[1]))
1084 return \"fmove%.x %1,%0\";
1085 if (REG_P (operands[1]))
1088 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1089 output_asm_insn (\"move%.l %1,%-\", xoperands);
1090 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1091 output_asm_insn (\"move%.l %1,%-\", xoperands);
1092 output_asm_insn (\"move%.l %1,%-\", operands);
1093 return \"fmove%.x %+,%0\";
1095 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1096 return \"fmove%.x %1,%0\";
1097 return \"fmove%.x %f1,%0\";
1099 if (FP_REG_P (operands[1]))
1101 if (REG_P (operands[0]))
1103 output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands);
1104 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1105 output_asm_insn (\"move%.l %+,%0\", operands);
1106 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1107 return \"move%.l %+,%0\";
1110 return \"fmove%.x %f1,%0\";
1112 return output_move_double (operands);
1117 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1118 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1119 "! TARGET_68881 && TARGET_5200"
1120 "* return output_move_double (operands);")
1122 (define_expand "movdi"
1123 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1124 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1125 (match_operand:DI 1 "general_operand" ""))]
1129 ;; movdi can apply to fp regs in some cases
1131 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1132 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1133 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1134 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1135 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1136 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1137 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1141 if (FP_REG_P (operands[0]))
1143 if (FP_REG_P (operands[1]))
1144 return \"fmove%.x %1,%0\";
1145 if (REG_P (operands[1]))
1148 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1149 output_asm_insn (\"move%.l %1,%-\", xoperands);
1150 output_asm_insn (\"move%.l %1,%-\", operands);
1151 return \"fmove%.d %+,%0\";
1153 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1154 return output_move_const_double (operands);
1155 return \"fmove%.d %f1,%0\";
1157 else if (FP_REG_P (operands[1]))
1159 if (REG_P (operands[0]))
1161 output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
1162 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1163 return \"move%.l %+,%0\";
1166 return \"fmove%.d %f1,%0\";
1168 return output_move_double (operands);
1172 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1173 (match_operand:DI 1 "general_operand" "g,r"))]
1175 "* return output_move_double (operands);")
1177 ;; Thus goes after the move instructions
1178 ;; because the move instructions are better (require no spilling)
1179 ;; when they can apply. It goes before the add/sub insns
1180 ;; so we will prefer it to them.
1182 (define_insn "pushasi"
1183 [(set (match_operand:SI 0 "push_operand" "=m")
1184 (match_operand:SI 1 "address_operand" "p"))]
1188 ;; truncation instructions
1189 (define_insn "truncsiqi2"
1190 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1192 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1196 if (GET_CODE (operands[0]) == REG)
1198 /* Must clear condition codes, since the move.l bases them on
1199 the entire 32 bits, not just the desired 8 bits. */
1201 return \"move%.l %1,%0\";
1203 if (GET_CODE (operands[1]) == MEM)
1204 operands[1] = adjust_address (operands[1], QImode, 3);
1205 return \"move%.b %1,%0\";
1208 (define_insn "trunchiqi2"
1209 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1211 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1215 if (GET_CODE (operands[0]) == REG
1216 && (GET_CODE (operands[1]) == MEM
1217 || GET_CODE (operands[1]) == CONST_INT))
1219 /* Must clear condition codes, since the move.w bases them on
1220 the entire 16 bits, not just the desired 8 bits. */
1222 return \"move%.w %1,%0\";
1224 if (GET_CODE (operands[0]) == REG)
1226 /* Must clear condition codes, since the move.l bases them on
1227 the entire 32 bits, not just the desired 8 bits. */
1229 return \"move%.l %1,%0\";
1231 if (GET_CODE (operands[1]) == MEM)
1232 operands[1] = adjust_address (operands[1], QImode, 1);
1233 return \"move%.b %1,%0\";
1236 (define_insn "truncsihi2"
1237 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1239 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1243 if (GET_CODE (operands[0]) == REG)
1245 /* Must clear condition codes, since the move.l bases them on
1246 the entire 32 bits, not just the desired 8 bits. */
1248 return \"move%.l %1,%0\";
1250 if (GET_CODE (operands[1]) == MEM)
1251 operands[1] = adjust_address (operands[1], QImode, 2);
1252 return \"move%.w %1,%0\";
1255 ;; zero extension instructions
1257 (define_insn "zero_extendqidi2"
1258 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
1259 (zero_extend:DI (match_operand:QI 1 "general_operand" "dm")))]
1264 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1265 return \"moveq %#0,%0\;moveq %#0,%2\;move%.b %1,%2\";
1268 (define_insn "zero_extendhidi2"
1269 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
1270 (zero_extend:DI (match_operand:HI 1 "general_operand" "rm")))]
1275 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1276 return \"moveq %#0,%0\;moveq %#0,%2\;move%.w %1,%2\";
1279 ;; this is the canonical form for (lshiftrt:DI x 32)
1280 (define_expand "zero_extendsidi2"
1281 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1282 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))]
1286 (define_insn "*zero_extendsidi2_cf"
1287 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,m")
1288 (zero_extend:DI (match_operand:SI 1 "general_operand" "rm,r")))]
1293 if (GET_CODE (operands[0]) == REG)
1294 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1295 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1296 return \"move%.l %1,%0\;clr%.l %0\";
1297 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1298 return \"clr%.l %0\;move%.l %1,%0\";
1300 operands[2] = adjust_address (operands[0], SImode, 4);
1301 if (GET_CODE (operands[1]) != REG || GET_CODE (operands[2]) != REG
1302 || REGNO (operands[1]) != REGNO (operands[2]))
1303 output_asm_insn (\"move%.l %1,%2\", operands);
1304 if (ADDRESS_REG_P (operands[0]))
1305 return \"sub%.l %0,%0\";
1307 return \"clr%.l %0\";
1310 (define_insn "*zero_extendsidi2"
1311 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
1312 (zero_extend:DI (match_operand:SI 1 "general_operand" "rm")))]
1317 if (GET_CODE (operands[0]) == REG)
1318 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1319 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1320 return \"move%.l %1,%0\;clr%.l %0\";
1321 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1322 return \"clr%.l %0\;move%.l %1,%0\";
1324 operands[2] = adjust_address (operands[0], SImode, 4);
1325 if (GET_CODE (operands[1]) != REG || GET_CODE (operands[2]) != REG
1326 || REGNO (operands[1]) != REGNO (operands[2]))
1327 output_asm_insn (\"move%.l %1,%2\", operands);
1328 if (ADDRESS_REG_P (operands[0]))
1329 return \"sub%.l %0,%0\";
1331 return \"clr%.l %0\";
1334 (define_expand "zero_extendhisi2"
1335 [(set (match_operand:SI 0 "register_operand" "")
1337 (set (strict_low_part (match_dup 2))
1338 (match_operand:HI 1 "general_operand" ""))]
1342 operands[1] = make_safe_from (operands[1], operands[0]);
1343 operands[2] = gen_lowpart_SUBREG (HImode, operands[0]);
1346 (define_expand "zero_extendqihi2"
1347 [(set (match_operand:HI 0 "register_operand" "")
1349 (set (strict_low_part (match_dup 2))
1350 (match_operand:QI 1 "general_operand" ""))]
1354 operands[1] = make_safe_from (operands[1], operands[0]);
1355 operands[2] = gen_lowpart_SUBREG (QImode, operands[0]);
1358 (define_expand "zero_extendqisi2"
1359 [(set (match_operand:SI 0 "register_operand" "")
1361 (set (strict_low_part (match_dup 2))
1362 (match_operand:QI 1 "general_operand" ""))]
1366 operands[1] = make_safe_from (operands[1], operands[0]);
1367 operands[2] = gen_lowpart_SUBREG (QImode, operands[0]);
1370 ;; Patterns to recognize zero-extend insns produced by the combiner.
1371 ;; We don't allow both operands in memory, because of aliasing problems.
1372 ;; Explicitly disallow two memory operands via the condition since reloading
1373 ;; of this case will result in worse code than the uncombined patterns.
1376 [(set (match_operand:SI 0 "nonimmediate_operand" "=do<>,d<")
1377 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "r,mS")))]
1378 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1381 if (DATA_REG_P (operands[0]))
1383 if (GET_CODE (operands[1]) == REG
1384 && REGNO (operands[0]) == REGNO (operands[1]))
1385 return \"and%.l %#0xFFFF,%0\";
1386 if (reg_mentioned_p (operands[0], operands[1]))
1387 return \"move%.w %1,%0\;and%.l %#0xFFFF,%0\";
1388 return \"clr%.l %0\;move%.w %1,%0\";
1390 else if (GET_CODE (operands[0]) == MEM
1391 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1392 return \"move%.w %1,%0\;clr%.w %0\";
1393 else if (GET_CODE (operands[0]) == MEM
1394 && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1395 return \"clr%.w %0\;move%.w %1,%0\";
1398 output_asm_insn (\"clr%.w %0\", operands);
1399 operands[0] = adjust_address (operands[0], HImode, 2);
1400 return \"move%.w %1,%0\";
1405 [(set (match_operand:HI 0 "nonimmediate_operand" "=do<>,d")
1406 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "d,mS")))]
1407 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1410 if (DATA_REG_P (operands[0]))
1412 if (GET_CODE (operands[1]) == REG
1413 && REGNO (operands[0]) == REGNO (operands[1]))
1414 return (!TARGET_5200 ? \"and%.w %#0xFF,%0\" : \"and%.l %#0xFF,%0\");
1415 if (reg_mentioned_p (operands[0], operands[1]))
1416 return (!TARGET_5200 ? \"move%.b %1,%0\;and%.w %#0xFF,%0\"
1417 : \"move%.b %1,%0\;and%.l %#0xFF,%0\");
1418 return \"clr%.w %0\;move%.b %1,%0\";
1420 else if (GET_CODE (operands[0]) == MEM
1421 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1423 if (REGNO (XEXP (XEXP (operands[0], 0), 0))
1424 == STACK_POINTER_REGNUM)
1426 output_asm_insn (\"clr%.w %-\", operands);
1427 operands[0] = gen_rtx_MEM (GET_MODE (operands[0]),
1428 plus_constant (stack_pointer_rtx, 1));
1429 return \"move%.b %1,%0\";
1432 return \"move%.b %1,%0\;clr%.b %0\";
1434 else if (GET_CODE (operands[0]) == MEM
1435 && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1436 return \"clr%.b %0\;move%.b %1,%0\";
1439 output_asm_insn (\"clr%.b %0\", operands);
1440 operands[0] = adjust_address (operands[0], QImode, 1);
1441 return \"move%.b %1,%0\";
1446 [(set (match_operand:SI 0 "nonimmediate_operand" "=do<>,d")
1447 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "d,mS")))]
1448 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1451 if (DATA_REG_P (operands[0]))
1453 if (GET_CODE (operands[1]) == REG
1454 && REGNO (operands[0]) == REGNO (operands[1]))
1455 return \"and%.l %#0xFF,%0\";
1456 if (reg_mentioned_p (operands[0], operands[1]))
1457 return \"move%.b %1,%0\;and%.l %#0xFF,%0\";
1458 return \"clr%.l %0\;move%.b %1,%0\";
1460 else if (GET_CODE (operands[0]) == MEM
1461 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1463 operands[0] = XEXP (XEXP (operands[0], 0), 0);
1466 return \"clr%.l -(%0)\;move%.b %1,3(%0)\";
1468 return \"clr%.l -(%0)\;move%.b %1,(3,%0)\";
1471 return \"clrl %0@-\;moveb %1,%0@(3)\";
1474 else if (GET_CODE (operands[0]) == MEM
1475 && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1477 operands[0] = XEXP (XEXP (operands[0], 0), 0);
1480 return \"clr%.l (%0)+\;move%.b %1,-1(%0)\";
1482 return \"clr%.l (%0)+\;move%.b %1,(-1,%0)\";
1485 return \"clrl %0@+\;moveb %1,%0@(-1)\";
1490 output_asm_insn (\"clr%.l %0\", operands);
1491 operands[0] = adjust_address (operands[0], QImode, 3);
1492 return \"move%.b %1,%0\";
1496 ;; sign extension instructions
1498 (define_insn "extendqidi2"
1499 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1500 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1505 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1506 if (TARGET_68020 || TARGET_5200)
1507 return \"move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0\";
1509 return \"move%.b %1,%2\;ext%.w %0\;ext%.l %2\;move%.l %2,%0\;smi %0\";
1512 (define_insn "extendhidi2"
1513 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1515 (match_operand:HI 1 "general_src_operand" "rmS")))]
1520 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1521 if (TARGET_68020 || TARGET_5200)
1522 return \"move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0\";
1524 return \"move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0\";
1527 (define_insn "extendsidi2"
1528 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1530 (match_operand:SI 1 "general_operand" "rm")))]
1535 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1536 if (TARGET_68020 || TARGET_5200)
1537 return \"move%.l %1,%2\;smi %0\;extb%.l %0\";
1539 return \"move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0\";
1542 ;; Special case when one can avoid register clobbering, copy and test
1543 ;; Maybe there is a way to make that the general case, by forcing the
1544 ;; result of the SI tree to be in the lower register of the DI target
1546 (define_insn "extendplussidi"
1547 [(set (match_operand:DI 0 "register_operand" "=d")
1548 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1549 (match_operand:SI 2 "general_operand" "rmn"))))]
1554 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1555 if (GET_CODE (operands[1]) == CONST_INT
1556 && (unsigned) INTVAL (operands[1]) > 8)
1558 rtx tmp = operands[1];
1560 operands[1] = operands[2];
1563 if (GET_CODE (operands[1]) == REG
1564 && REGNO (operands[1]) == REGNO (operands[3]))
1565 output_asm_insn (\"add%.l %2,%3\", operands);
1567 output_asm_insn (\"move%.l %2,%3\;add%.l %1,%3\", operands);
1568 if (TARGET_68020 || TARGET_5200)
1569 return \"smi %0\;extb%.l %0\";
1571 return \"smi %0\;ext%.w %0\;ext%.l %0\";
1574 (define_insn "extendhisi2"
1575 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1577 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1581 if (ADDRESS_REG_P (operands[0]))
1582 return \"move%.w %1,%0\";
1583 return \"ext%.l %0\";
1586 (define_insn "extendqihi2"
1587 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1588 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1592 (define_insn "extendqisi2"
1593 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1594 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1595 "TARGET_68020 || TARGET_5200"
1598 ;; Conversions between float and double.
1600 (define_expand "extendsfdf2"
1601 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1603 (match_operand:SF 1 "general_operand" "")))]
1608 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1610 (match_operand:SF 1 "general_operand" "f,dmF")))]
1614 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1616 if (REGNO (operands[0]) == REGNO (operands[1]))
1618 /* Extending float to double in an fp-reg is a no-op.
1619 NOTICE_UPDATE_CC has already assumed that the
1620 cc will be set. So cancel what it did. */
1621 cc_status = cc_prev_status;
1624 return \"f%&move%.x %1,%0\";
1626 if (FP_REG_P (operands[0]))
1627 return \"f%&move%.s %f1,%0\";
1628 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1630 output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
1631 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1632 return \"move%.l %+,%0\";
1634 return \"fmove%.d %f1,%0\";
1637 ;; This cannot output into an f-reg because there is no way to be
1638 ;; sure of truncating in that case.
1639 (define_expand "truncdfsf2"
1640 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1642 (match_operand:DF 1 "general_operand" "")))]
1646 ;; On the '040 we can truncate in a register accurately and easily.
1648 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1650 (match_operand:DF 1 "general_operand" "fmG")))]
1654 if (FP_REG_P (operands[1]))
1655 return \"f%$move%.x %1,%0\";
1656 return \"f%$move%.d %f1,%0\";
1660 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1662 (match_operand:DF 1 "general_operand" "f")))]
1666 ;; Conversion between fixed point and floating point.
1667 ;; Note that among the fix-to-float insns
1668 ;; the ones that start with SImode come first.
1669 ;; That is so that an operand that is a CONST_INT
1670 ;; (and therefore lacks a specific machine mode).
1671 ;; will be recognized as SImode (which is always valid)
1672 ;; rather than as QImode or HImode.
1674 (define_expand "floatsisf2"
1675 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1676 (float:SF (match_operand:SI 1 "general_operand" "")))]
1681 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1682 (float:SF (match_operand:SI 1 "general_operand" "dmi")))]
1686 (define_expand "floatsidf2"
1687 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1688 (float:DF (match_operand:SI 1 "general_operand" "")))]
1693 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1694 (float:DF (match_operand:SI 1 "general_operand" "dmi")))]
1698 (define_insn "floathisf2"
1699 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1700 (float:SF (match_operand:HI 1 "general_operand" "dmn")))]
1704 (define_insn "floathidf2"
1705 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1706 (float:DF (match_operand:HI 1 "general_operand" "dmn")))]
1710 (define_insn "floatqisf2"
1711 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1712 (float:SF (match_operand:QI 1 "general_operand" "dmn")))]
1716 (define_insn "floatqidf2"
1717 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1718 (float:DF (match_operand:QI 1 "general_operand" "dmn")))]
1722 ;; New routines to convert floating-point values to integers
1723 ;; to be used on the '040. These should be faster than trapping
1724 ;; into the kernel to emulate fintrz. They should also be faster
1725 ;; than calling the subroutines fixsfsi or fixdfsi.
1727 (define_insn "fix_truncdfsi2"
1728 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1729 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1730 (clobber (match_scratch:SI 2 "=d"))
1731 (clobber (match_scratch:SI 3 "=d"))]
1732 "TARGET_68881 && TARGET_68040"
1736 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,%!\";
1739 (define_insn "fix_truncdfhi2"
1740 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1741 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1742 (clobber (match_scratch:SI 2 "=d"))
1743 (clobber (match_scratch:SI 3 "=d"))]
1744 "TARGET_68881 && TARGET_68040"
1748 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,%!\";
1751 (define_insn "fix_truncdfqi2"
1752 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1753 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1754 (clobber (match_scratch:SI 2 "=d"))
1755 (clobber (match_scratch:SI 3 "=d"))]
1756 "TARGET_68881 && TARGET_68040"
1760 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,%!\";
1763 ;; Convert a float to a float whose value is an integer.
1764 ;; This is the first stage of converting it to an integer type.
1766 (define_insn "ftruncdf2"
1767 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1768 (fix:DF (match_operand:DF 1 "general_operand" "fFm")))]
1769 "TARGET_68881 && !TARGET_68040"
1772 if (FP_REG_P (operands[1]))
1773 return \"fintrz%.x %f1,%0\";
1774 return \"fintrz%.d %f1,%0\";
1777 (define_insn "ftruncsf2"
1778 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1779 (fix:SF (match_operand:SF 1 "general_operand" "dfFm")))]
1780 "TARGET_68881 && !TARGET_68040"
1783 if (FP_REG_P (operands[1]))
1784 return \"fintrz%.x %f1,%0\";
1785 return \"fintrz%.s %f1,%0\";
1788 ;; Convert a float whose value is an integer
1789 ;; to an actual integer. Second stage of converting float to integer type.
1790 (define_insn "fixsfqi2"
1791 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1792 (fix:QI (match_operand:SF 1 "general_operand" "f")))]
1796 (define_insn "fixsfhi2"
1797 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1798 (fix:HI (match_operand:SF 1 "general_operand" "f")))]
1802 (define_insn "fixsfsi2"
1803 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1804 (fix:SI (match_operand:SF 1 "general_operand" "f")))]
1808 (define_insn "fixdfqi2"
1809 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1810 (fix:QI (match_operand:DF 1 "general_operand" "f")))]
1814 (define_insn "fixdfhi2"
1815 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1816 (fix:HI (match_operand:DF 1 "general_operand" "f")))]
1820 (define_insn "fixdfsi2"
1821 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1822 (fix:SI (match_operand:DF 1 "general_operand" "f")))]
1828 (define_insn "adddi_lshrdi_63"
1829 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1830 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
1833 (clobber (match_scratch:SI 2 "=d"))]
1837 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1838 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
1840 \"move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0\";
1841 if (GET_CODE (operands[1]) == REG)
1842 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1843 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
1844 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1845 operands[4] = operands[1];
1847 operands[4] = adjust_address (operands[1], SImode, 4);
1848 if (GET_CODE (operands[1]) == MEM
1849 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1850 output_asm_insn (\"move%.l %4,%3\", operands);
1851 output_asm_insn (\"move%.l %1,%0\;smi %2\", operands);
1852 if (TARGET_68020 || TARGET_5200)
1853 output_asm_insn (\"extb%.l %2\", operands);
1855 output_asm_insn (\"ext%.w %2\;ext%.l %2\", operands);
1856 if (GET_CODE (operands[1]) != MEM
1857 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
1858 output_asm_insn (\"move%.l %4,%3\", operands);
1859 return \"sub%.l %2,%3\;subx%.l %2,%0\";
1862 (define_insn "adddi_sexthishl32"
1863 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
1864 (plus:DI (ashift:DI (sign_extend:DI
1865 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
1867 (match_operand:DI 2 "general_operand" "0,0,0,0")))
1868 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
1873 if (ADDRESS_REG_P (operands[0]))
1874 return \"add%.w %1,%0\";
1875 else if (ADDRESS_REG_P (operands[3]))
1876 return \"move%.w %1,%3\;add%.l %3,%0\";
1878 return \"move%.w %1,%3\;ext%.l %3\;add%.l %3,%0\";
1881 (define_insn "adddi_dilshr32"
1882 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
1883 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1884 ;; (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
1885 ;; (const_int 32))))]
1886 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
1888 (match_operand:DI 2 "general_operand" "0,0")))]
1893 if (GET_CODE (operands[0]) == REG)
1894 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1896 operands[2] = adjust_address (operands[0], SImode, 4);
1897 return \"add%.l %1,%2\;negx%.l %0\;neg%.l %0\";
1900 (define_insn "adddi_dishl32"
1901 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
1902 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1903 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
1904 ;; (const_int 32))))]
1905 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
1907 (match_operand:DI 2 "general_operand" "0,0")))]
1912 if (GET_CODE (operands[1]) == REG)
1913 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1915 operands[1] = adjust_address (operands[1], SImode, 4);
1916 return \"add%.l %1,%0\";
1919 (define_insn "adddi3"
1920 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
1921 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0,0")
1922 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
1923 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
1927 if (DATA_REG_P (operands[0]))
1929 if (DATA_REG_P (operands[2]))
1930 return \"add%.l %R2,%R0\;addx%.l %2,%0\";
1931 else if (GET_CODE (operands[2]) == MEM
1932 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
1933 return \"move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0\";
1939 if (GET_CODE (operands[2]) == REG)
1941 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
1944 else if (CONSTANT_P (operands[2]))
1945 split_double (operands[2], &high, &low);
1948 low = adjust_address (operands[2], SImode, 4);
1952 operands[1] = low, operands[2] = high;
1953 xoperands[0] = operands[3];
1954 if (GET_CODE (operands[1]) == CONST_INT
1955 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1956 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
1958 xoperands[1] = operands[2];
1960 output_asm_insn (output_move_simode (xoperands), xoperands);
1961 if (GET_CODE (operands[1]) == CONST_INT)
1963 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
1966 return \"add%.l %1,%R0\;addx%.l %3,%0\";
1968 return \"addq%.l %1,%R0\;addx%.l %3,%0\";
1971 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1973 operands[1] = GEN_INT (-INTVAL (operands[1]));
1975 return \"sub%.l %1,%R0\;subx%.l %3,%0\";
1977 return \"subq%.l %1,%R0\;subx%.l %3,%0\";
1981 return \"add%.l %1,%R0\;addx%.l %3,%0\";
1984 else if (GET_CODE (operands[0]) == MEM)
1986 if (GET_CODE (operands[2]) == MEM
1987 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
1988 return \"add%.l %2,%0\;addx%.l %2,%0\";
1990 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1992 operands[1] = gen_rtx_MEM (SImode,
1993 plus_constant (XEXP(operands[0], 0), -8));
1994 return \"move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1\";
1996 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1998 operands[1] = XEXP(operands[0], 0);
1999 return \"add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1\";
2003 operands[1] = adjust_address (operands[0], SImode, 4);
2004 return \"add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0\";
2011 (define_insn "addsi_lshrsi_31"
2012 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2013 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
2019 operands[2] = operands[0];
2020 operands[3] = gen_label_rtx();
2021 if (GET_CODE (operands[0]) == MEM)
2023 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2024 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2025 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2026 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2028 output_asm_insn (\"move%.l %1,%0\", operands);
2030 output_asm_insn (\"jbpl %l3\", operands);
2032 output_asm_insn (\"jpl %l3\", operands);
2035 output_asm_insn (\"addq%.l %#1,%2\", operands);
2037 output_asm_insn (\"add%.l %#1,%2\", operands);
2039 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2040 CODE_LABEL_NUMBER (operands[3]));
2044 (define_expand "addsi3"
2045 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2046 (plus:SI (match_operand:SI 1 "general_operand" "")
2047 (match_operand:SI 2 "general_src_operand" "")))]
2051 ;; Note that the middle two alternatives are near-duplicates
2052 ;; in order to handle insns generated by reload.
2053 ;; This is needed since they are not themselves reloaded,
2054 ;; so commutativity won't apply to them.
2055 (define_insn "*addsi3_internal"
2056 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2057 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2058 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2062 "* return output_addsi3 (operands);")
2064 (define_insn "*addsi3_5200"
2065 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
2066 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
2067 (match_operand:SI 2 "general_src_operand" "d,rJK,a,mrIKLs")))]
2069 "* return output_addsi3 (operands);")
2072 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2073 (plus:SI (match_operand:SI 1 "general_operand" "0")
2075 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2079 (define_insn "addhi3"
2080 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2081 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2082 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2086 if (GET_CODE (operands[2]) == CONST_INT)
2089 /* If the constant would be a negative number when interpreted as
2090 HImode, make it negative. This is usually, but not always, done
2091 elsewhere in the compiler. First check for constants out of range,
2092 which could confuse us. */
2094 if (INTVAL (operands[2]) >= 32768)
2095 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2097 if (INTVAL (operands[2]) > 0
2098 && INTVAL (operands[2]) <= 8)
2099 return \"addq%.w %2,%0\";
2100 if (INTVAL (operands[2]) < 0
2101 && INTVAL (operands[2]) >= -8)
2103 operands[2] = GEN_INT (- INTVAL (operands[2]));
2104 return \"subq%.w %2,%0\";
2106 /* On the CPU32 it is faster to use two addqw instructions to
2107 add a small integer (8 < N <= 16) to a register.
2108 Likewise for subqw. */
2109 if (TARGET_CPU32 && REG_P (operands[0]))
2111 if (INTVAL (operands[2]) > 8
2112 && INTVAL (operands[2]) <= 16)
2114 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2115 return \"addq%.w %#8,%0\;addq%.w %2,%0\";
2117 if (INTVAL (operands[2]) < -8
2118 && INTVAL (operands[2]) >= -16)
2120 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2121 return \"subq%.w %#8,%0\;subq%.w %2,%0\";
2125 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2127 return \"lea (%c2,%0),%0\";
2129 return \"lea %0@(%c2),%0\";
2132 return \"add%.w %2,%0\";
2135 ;; These insns must use MATCH_DUP instead of the more expected
2136 ;; use of a matching constraint because the "output" here is also
2137 ;; an input, so you can't use the matching constraint. That also means
2138 ;; that you can't use the "%", so you need patterns with the matched
2139 ;; operand in both positions.
2142 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2143 (plus:HI (match_dup 0)
2144 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2148 if (GET_CODE (operands[1]) == CONST_INT)
2151 /* If the constant would be a negative number when interpreted as
2152 HImode, make it negative. This is usually, but not always, done
2153 elsewhere in the compiler. First check for constants out of range,
2154 which could confuse us. */
2156 if (INTVAL (operands[1]) >= 32768)
2157 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2159 if (INTVAL (operands[1]) > 0
2160 && INTVAL (operands[1]) <= 8)
2161 return \"addq%.w %1,%0\";
2162 if (INTVAL (operands[1]) < 0
2163 && INTVAL (operands[1]) >= -8)
2165 operands[1] = GEN_INT (- INTVAL (operands[1]));
2166 return \"subq%.w %1,%0\";
2168 /* On the CPU32 it is faster to use two addqw instructions to
2169 add a small integer (8 < N <= 16) to a register.
2170 Likewise for subqw. */
2171 if (TARGET_CPU32 && REG_P (operands[0]))
2173 if (INTVAL (operands[1]) > 8
2174 && INTVAL (operands[1]) <= 16)
2176 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2177 return \"addq%.w %#8,%0\;addq%.w %1,%0\";
2179 if (INTVAL (operands[1]) < -8
2180 && INTVAL (operands[1]) >= -16)
2182 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2183 return \"subq%.w %#8,%0\;subq%.w %1,%0\";
2187 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2189 return \"lea (%c1,%0),%0\";
2191 return \"lea %0@(%c1),%0\";
2194 return \"add%.w %1,%0\";
2198 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2199 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2204 if (GET_CODE (operands[1]) == CONST_INT)
2207 /* If the constant would be a negative number when interpreted as
2208 HImode, make it negative. This is usually, but not always, done
2209 elsewhere in the compiler. First check for constants out of range,
2210 which could confuse us. */
2212 if (INTVAL (operands[1]) >= 32768)
2213 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2215 if (INTVAL (operands[1]) > 0
2216 && INTVAL (operands[1]) <= 8)
2217 return \"addq%.w %1,%0\";
2218 if (INTVAL (operands[1]) < 0
2219 && INTVAL (operands[1]) >= -8)
2221 operands[1] = GEN_INT (- INTVAL (operands[1]));
2222 return \"subq%.w %1,%0\";
2224 /* On the CPU32 it is faster to use two addqw instructions to
2225 add a small integer (8 < N <= 16) to a register.
2226 Likewise for subqw. */
2227 if (TARGET_CPU32 && REG_P (operands[0]))
2229 if (INTVAL (operands[1]) > 8
2230 && INTVAL (operands[1]) <= 16)
2232 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2233 return \"addq%.w %#8,%0\;addq%.w %1,%0\";
2235 if (INTVAL (operands[1]) < -8
2236 && INTVAL (operands[1]) >= -16)
2238 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2239 return \"subq%.w %#8,%0\;subq%.w %1,%0\";
2243 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2245 return \"lea (%c1,%0),%0\";
2247 return \"lea %0@(%c1),%0\";
2250 return \"add%.w %1,%0\";
2253 (define_insn "addqi3"
2254 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2255 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2256 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2261 if (GET_CODE (operands[2]) == CONST_INT)
2263 if (INTVAL (operands[2]) >= 128)
2264 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2266 if (INTVAL (operands[2]) > 0
2267 && INTVAL (operands[2]) <= 8)
2268 return \"addq%.b %2,%0\";
2269 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2271 operands[2] = GEN_INT (- INTVAL (operands[2]));
2272 return \"subq%.b %2,%0\";
2276 return \"add%.b %2,%0\";
2280 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2281 (plus:QI (match_dup 0)
2282 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2287 if (GET_CODE (operands[1]) == CONST_INT)
2289 if (INTVAL (operands[1]) >= 128)
2290 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2292 if (INTVAL (operands[1]) > 0
2293 && INTVAL (operands[1]) <= 8)
2294 return \"addq%.b %1,%0\";
2295 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2297 operands[1] = GEN_INT (- INTVAL (operands[1]));
2298 return \"subq%.b %1,%0\";
2302 return \"add%.b %1,%0\";
2306 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2307 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2313 if (GET_CODE (operands[1]) == CONST_INT)
2315 if (INTVAL (operands[1]) >= 128)
2316 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2318 if (INTVAL (operands[1]) > 0
2319 && INTVAL (operands[1]) <= 8)
2320 return \"addq%.b %1,%0\";
2321 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2323 operands[1] = GEN_INT (- INTVAL (operands[1]));
2324 return \"subq%.b %1,%0\";
2328 return \"add%.b %1,%0\";
2331 (define_expand "adddf3"
2332 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2333 (plus:DF (match_operand:DF 1 "general_operand" "")
2334 (match_operand:DF 2 "general_operand" "")))]
2339 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2340 (plus:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2341 (match_operand:DF 1 "general_operand" "0")))]
2346 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2347 (plus:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2348 (match_operand:DF 1 "general_operand" "0")))]
2353 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2354 (plus:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2355 (match_operand:DF 1 "general_operand" "0")))]
2360 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2361 (plus:DF (match_operand:DF 1 "general_operand" "%0")
2362 (match_operand:DF 2 "general_operand" "fmG")))]
2366 if (REG_P (operands[2]))
2367 return \"f%&add%.x %2,%0\";
2368 return \"f%&add%.d %f2,%0\";
2371 (define_expand "addsf3"
2372 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2373 (plus:SF (match_operand:SF 1 "general_operand" "")
2374 (match_operand:SF 2 "general_operand" "")))]
2379 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2380 (plus:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2381 (match_operand:SF 1 "general_operand" "0")))]
2386 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2387 (plus:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2388 (match_operand:SF 1 "general_operand" "0")))]
2393 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2394 (plus:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2395 (match_operand:SF 1 "general_operand" "0")))]
2400 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2401 (plus:SF (match_operand:SF 1 "general_operand" "%0")
2402 (match_operand:SF 2 "general_operand" "fdmF")))]
2406 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2407 return \"f%$add%.x %2,%0\";
2408 return \"f%$add%.s %f2,%0\";
2411 ;; subtract instructions
2413 (define_insn "subdi_sexthishl32"
2414 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2415 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2416 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2418 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2423 if (ADDRESS_REG_P (operands[0]))
2424 return \"sub%.w %2,%0\";
2425 else if (ADDRESS_REG_P (operands[3]))
2426 return \"move%.w %2,%3\;sub%.l %3,%0\";
2428 return \"move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0\";
2431 (define_insn "subdi_dishl32"
2432 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2433 (minus:DI (match_dup 0)
2434 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2440 if (GET_CODE (operands[1]) == REG)
2441 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2443 operands[1] = adjust_address (operands[1], SImode, 4);
2444 return \"sub%.l %1,%0\";
2447 (define_insn "subdi3"
2448 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
2449 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0,0")
2450 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
2451 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
2455 if (DATA_REG_P (operands[0]))
2457 if (DATA_REG_P (operands[2]))
2458 return \"sub%.l %R2,%R0\;subx%.l %2,%0\";
2459 else if (GET_CODE (operands[2]) == MEM
2460 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2462 return \"move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0\";
2469 if (GET_CODE (operands[2]) == REG)
2471 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2474 else if (CONSTANT_P (operands[2]))
2475 split_double (operands[2], &high, &low);
2478 low = adjust_address (operands[2], SImode, 4);
2482 operands[1] = low, operands[2] = high;
2483 xoperands[0] = operands[3];
2484 if (GET_CODE (operands[1]) == CONST_INT
2485 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2486 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2488 xoperands[1] = operands[2];
2490 output_asm_insn (output_move_simode (xoperands), xoperands);
2491 if (GET_CODE (operands[1]) == CONST_INT)
2493 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2496 return \"sub%.l %1,%R0\;subx%.l %3,%0\";
2498 return \"subq%.l %1,%R0\;subx%.l %3,%0\";
2501 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2503 operands[1] = GEN_INT (-INTVAL (operands[1]));
2505 return \"add%.l %1,%R0\;addx%.l %3,%0\";
2507 return \"addq%.l %1,%R0\;addx%.l %3,%0\";
2511 return \"sub%.l %1,%R0\;subx%.l %3,%0\";
2514 else if (GET_CODE (operands[0]) == MEM)
2516 if (GET_CODE (operands[2]) == MEM
2517 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
2518 return \"sub%.l %2,%0\;subx%.l %2,%0\";
2520 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2523 = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2524 return \"move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1\";
2526 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2528 operands[1] = XEXP(operands[0], 0);
2529 return \"sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1\";
2533 operands[1] = adjust_address (operands[0], SImode, 4);
2534 return \"sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0\";
2541 (define_insn "subsi3"
2542 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2543 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2544 (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2549 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2550 (minus:SI (match_operand:SI 1 "general_operand" "0")
2552 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2556 (define_insn "subhi3"
2557 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2558 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2559 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2564 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2565 (minus:HI (match_dup 0)
2566 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2570 (define_insn "subqi3"
2571 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2572 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2573 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2578 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2579 (minus:QI (match_dup 0)
2580 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2584 (define_expand "subdf3"
2585 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2586 (minus:DF (match_operand:DF 1 "general_operand" "")
2587 (match_operand:DF 2 "general_operand" "")))]
2592 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2593 (minus:DF (match_operand:DF 1 "general_operand" "0")
2594 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2599 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2600 (minus:DF (match_operand:DF 1 "general_operand" "0")
2601 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2606 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2607 (minus:DF (match_operand:DF 1 "general_operand" "0")
2608 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2613 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2614 (minus:DF (match_operand:DF 1 "general_operand" "0")
2615 (match_operand:DF 2 "general_operand" "fmG")))]
2619 if (REG_P (operands[2]))
2620 return \"f%&sub%.x %2,%0\";
2621 return \"f%&sub%.d %f2,%0\";
2624 (define_expand "subsf3"
2625 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2626 (minus:SF (match_operand:SF 1 "general_operand" "")
2627 (match_operand:SF 2 "general_operand" "")))]
2632 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2633 (minus:SF (match_operand:SF 1 "general_operand" "0")
2634 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2639 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2640 (minus:SF (match_operand:SF 1 "general_operand" "0")
2641 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2646 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2647 (minus:SF (match_operand:SF 1 "general_operand" "0")
2648 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2653 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2654 (minus:SF (match_operand:SF 1 "general_operand" "0")
2655 (match_operand:SF 2 "general_operand" "fdmF")))]
2659 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2660 return \"f%$sub%.x %2,%0\";
2661 return \"f%$sub%.s %f2,%0\";
2664 ;; multiply instructions
2666 (define_insn "mulhi3"
2667 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2668 (mult:HI (match_operand:HI 1 "general_operand" "%0")
2669 (match_operand:HI 2 "general_src_operand" "dmSn")))]
2673 #if defined(MOTOROLA)
2674 return \"muls%.w %2,%0\";
2676 return \"muls %2,%0\";
2680 (define_insn "mulhisi3"
2681 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2682 (mult:SI (sign_extend:SI
2683 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2685 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2689 #if defined(MOTOROLA)
2690 return \"muls%.w %2,%0\";
2692 return \"muls %2,%0\";
2697 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2698 (mult:SI (sign_extend:SI
2699 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2700 (match_operand:SI 2 "const_int_operand" "n")))]
2701 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2704 #if defined(MOTOROLA)
2705 return \"muls%.w %2,%0\";
2707 return \"muls %2,%0\";
2711 (define_expand "mulsi3"
2712 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2713 (mult:SI (match_operand:SI 1 "general_operand" "")
2714 (match_operand:SI 2 "general_operand" "")))]
2715 "TARGET_68020 || TARGET_5200"
2719 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2720 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2721 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2727 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2728 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2729 (match_operand:SI 2 "general_operand" "d<Q>")))]
2733 (define_insn "umulhisi3"
2734 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2735 (mult:SI (zero_extend:SI
2736 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2738 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2742 #if defined(MOTOROLA)
2743 return \"mulu%.w %2,%0\";
2745 return \"mulu %2,%0\";
2750 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2751 (mult:SI (zero_extend:SI
2752 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2753 (match_operand:SI 2 "const_int_operand" "n")))]
2754 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2757 #if defined(MOTOROLA)
2758 return \"mulu%.w %2,%0\";
2760 return \"mulu %2,%0\";
2764 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2765 ;; proper matching constraint. This is because the matching is between
2766 ;; the high-numbered word of the DImode operand[0] and operand[1].
2767 (define_expand "umulsidi3"
2769 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2770 (mult:SI (match_operand:SI 1 "register_operand" "")
2771 (match_operand:SI 2 "register_operand" "")))
2772 (set (subreg:SI (match_dup 0) 0)
2773 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2774 (zero_extend:DI (match_dup 2)))
2775 (const_int 32))))])]
2776 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2780 [(set (match_operand:SI 0 "register_operand" "=d")
2781 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2782 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2783 (set (match_operand:SI 3 "register_operand" "=d")
2784 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2785 (zero_extend:DI (match_dup 2)))
2787 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2790 ; Match immediate case. For 2.4 only match things < 2^31.
2791 ; It's tricky with larger values in these patterns since we need to match
2792 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2795 [(set (match_operand:SI 0 "register_operand" "=d")
2796 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2797 (match_operand:SI 2 "const_int_operand" "n")))
2798 (set (match_operand:SI 3 "register_operand" "=d")
2799 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2802 "TARGET_68020 && !TARGET_68060 && !TARGET_5200
2803 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2806 (define_expand "mulsidi3"
2808 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2809 (mult:SI (match_operand:SI 1 "register_operand" "")
2810 (match_operand:SI 2 "register_operand" "")))
2811 (set (subreg:SI (match_dup 0) 0)
2812 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2813 (sign_extend:DI (match_dup 2)))
2814 (const_int 32))))])]
2815 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2819 [(set (match_operand:SI 0 "register_operand" "=d")
2820 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2821 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2822 (set (match_operand:SI 3 "register_operand" "=d")
2823 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2824 (sign_extend:DI (match_dup 2)))
2826 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2830 [(set (match_operand:SI 0 "register_operand" "=d")
2831 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2832 (match_operand:SI 2 "const_int_operand" "n")))
2833 (set (match_operand:SI 3 "register_operand" "=d")
2834 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2837 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2840 (define_expand "umulsi3_highpart"
2842 [(set (match_operand:SI 0 "register_operand" "")
2845 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2846 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2848 (clobber (match_dup 3))])]
2849 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2852 operands[3] = gen_reg_rtx (SImode);
2854 if (GET_CODE (operands[2]) == CONST_INT)
2856 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2859 /* We have to adjust the operand order for the matching constraints. */
2860 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2861 operands[1], operands[2]));
2867 [(set (match_operand:SI 0 "register_operand" "=d")
2870 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2871 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2873 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2874 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2877 (define_insn "const_umulsi3_highpart"
2878 [(set (match_operand:SI 0 "register_operand" "=d")
2881 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2882 (match_operand:DI 3 "const_uint32_operand" "n"))
2884 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2885 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2888 (define_expand "smulsi3_highpart"
2890 [(set (match_operand:SI 0 "register_operand" "")
2893 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2894 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2896 (clobber (match_dup 3))])]
2897 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2900 operands[3] = gen_reg_rtx (SImode);
2901 if (GET_CODE (operands[2]) == CONST_INT)
2903 /* We have to adjust the operand order for the matching constraints. */
2904 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2905 operands[1], operands[2]));
2911 [(set (match_operand:SI 0 "register_operand" "=d")
2914 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2915 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2917 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2918 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2921 (define_insn "const_smulsi3_highpart"
2922 [(set (match_operand:SI 0 "register_operand" "=d")
2925 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2926 (match_operand:DI 3 "const_sint32_operand" "n"))
2928 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2929 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2932 (define_expand "muldf3"
2933 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2934 (mult:DF (match_operand:DF 1 "general_operand" "")
2935 (match_operand:DF 2 "general_operand" "")))]
2940 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2941 (mult:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2942 (match_operand:DF 1 "general_operand" "0")))]
2947 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2948 (mult:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2949 (match_operand:DF 1 "general_operand" "0")))]
2954 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2955 (mult:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2956 (match_operand:DF 1 "general_operand" "0")))]
2961 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2962 (mult:DF (match_operand:DF 1 "general_operand" "%0")
2963 (match_operand:DF 2 "general_operand" "fmG")))]
2967 if (GET_CODE (operands[2]) == CONST_DOUBLE
2968 && floating_exact_log2 (operands[2]) && !TARGET_68040 && !TARGET_68060)
2970 int i = floating_exact_log2 (operands[2]);
2971 operands[2] = GEN_INT (i);
2972 return \"fscale%.l %2,%0\";
2974 if (REG_P (operands[2]))
2975 return \"f%&mul%.x %2,%0\";
2976 return \"f%&mul%.d %f2,%0\";
2979 (define_expand "mulsf3"
2980 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2981 (mult:SF (match_operand:SF 1 "general_operand" "")
2982 (match_operand:SF 2 "general_operand" "")))]
2987 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2988 (mult:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2989 (match_operand:SF 1 "general_operand" "0")))]
2993 return (TARGET_68040_ONLY
2994 ? \"fsmul%.l %2,%0\"
2995 : \"fsglmul%.l %2,%0\");
2999 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3000 (mult:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
3001 (match_operand:SF 1 "general_operand" "0")))]
3005 return (TARGET_68040_ONLY
3006 ? \"fsmul%.w %2,%0\"
3007 : \"fsglmul%.w %2,%0\");
3011 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3012 (mult:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
3013 (match_operand:SF 1 "general_operand" "0")))]
3017 return (TARGET_68040_ONLY
3018 ? \"fsmul%.b %2,%0\"
3019 : \"fsglmul%.b %2,%0\");
3023 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3024 (mult:SF (match_operand:SF 1 "general_operand" "%0")
3025 (match_operand:SF 2 "general_operand" "fdmF")))]
3029 #ifdef FSGLMUL_USE_S
3030 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
3031 return (TARGET_68040_ONLY
3032 ? \"fsmul%.s %2,%0\"
3033 : \"fsglmul%.s %2,%0\");
3035 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
3036 return (TARGET_68040_ONLY
3037 ? \"fsmul%.x %2,%0\"
3038 : \"fsglmul%.x %2,%0\");
3040 return (TARGET_68040_ONLY
3041 ? \"fsmul%.s %f2,%0\"
3042 : \"fsglmul%.s %f2,%0\");
3045 ;; divide instructions
3047 (define_expand "divdf3"
3048 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3049 (div:DF (match_operand:DF 1 "general_operand" "")
3050 (match_operand:DF 2 "general_operand" "")))]
3055 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3056 (div:DF (match_operand:DF 1 "general_operand" "0")
3057 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
3062 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3063 (div:DF (match_operand:DF 1 "general_operand" "0")
3064 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
3069 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3070 (div:DF (match_operand:DF 1 "general_operand" "0")
3071 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
3076 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3077 (div:DF (match_operand:DF 1 "general_operand" "0")
3078 (match_operand:DF 2 "general_operand" "fmG")))]
3082 if (REG_P (operands[2]))
3083 return \"f%&div%.x %2,%0\";
3084 return \"f%&div%.d %f2,%0\";
3087 (define_expand "divsf3"
3088 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3089 (div:SF (match_operand:SF 1 "general_operand" "")
3090 (match_operand:SF 2 "general_operand" "")))]
3095 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3096 (div:SF (match_operand:SF 1 "general_operand" "0")
3097 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
3101 return (TARGET_68040_ONLY
3102 ? \"fsdiv%.l %2,%0\"
3103 : \"fsgldiv%.l %2,%0\");
3107 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3108 (div:SF (match_operand:SF 1 "general_operand" "0")
3109 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
3113 return (TARGET_68040_ONLY
3114 ? \"fsdiv%.w %2,%0\"
3115 : \"fsgldiv%.w %2,%0\");
3119 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3120 (div:SF (match_operand:SF 1 "general_operand" "0")
3121 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
3125 return (TARGET_68040_ONLY
3126 ? \"fsdiv%.b %2,%0\"
3127 : \"fsgldiv%.b %2,%0\");
3131 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3132 (div:SF (match_operand:SF 1 "general_operand" "0")
3133 (match_operand:SF 2 "general_operand" "fdmF")))]
3137 #ifdef FSGLDIV_USE_S
3138 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
3139 return (TARGET_68040_ONLY
3140 ? \"fsdiv%.s %2,%0\"
3141 : \"fsgldiv%.s %2,%0\");
3143 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
3144 return (TARGET_68040_ONLY
3145 ? \"fsdiv%.x %2,%0\"
3146 : \"fsgldiv%.x %2,%0\");
3148 return (TARGET_68040_ONLY
3149 ? \"fsdiv%.s %f2,%0\"
3150 : \"fsgldiv%.s %f2,%0\");
3153 ;; Remainder instructions.
3155 (define_insn "divmodsi4"
3156 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3157 (div:SI (match_operand:SI 1 "general_operand" "0")
3158 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3159 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3160 (mod:SI (match_dup 1) (match_dup 2)))]
3161 "TARGET_68020 && !TARGET_5200"
3164 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3165 return \"divs%.l %2,%0\";
3167 return \"divsl%.l %2,%3:%0\";
3170 (define_insn "udivmodsi4"
3171 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3172 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3173 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3174 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3175 (umod:SI (match_dup 1) (match_dup 2)))]
3176 "TARGET_68020 && !TARGET_5200"
3179 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3180 return \"divu%.l %2,%0\";
3182 return \"divul%.l %2,%3:%0\";
3185 (define_insn "divmodhi4"
3186 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3187 (div:HI (match_operand:HI 1 "general_operand" "0")
3188 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3189 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3190 (mod:HI (match_dup 1) (match_dup 2)))]
3195 output_asm_insn (\"ext%.l %0\;divs%.w %2,%0\", operands);
3197 output_asm_insn (\"extl %0\;divs %2,%0\", operands);
3199 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3202 return \"move%.l %0,%3\;swap %3\";
3208 (define_insn "udivmodhi4"
3209 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3210 (udiv:HI (match_operand:HI 1 "general_operand" "0")
3211 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3212 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3213 (umod:HI (match_dup 1) (match_dup 2)))]
3218 output_asm_insn (\"and%.l %#0xFFFF,%0\;divu%.w %2,%0\", operands);
3220 output_asm_insn (\"and%.l %#0xFFFF,%0\;divu %2,%0\", operands);
3222 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3225 return \"move%.l %0,%3\;swap %3\";
3231 ;; logical-and instructions
3233 ;; "anddi3" is mainly here to help combine().
3234 (define_insn "anddi3"
3235 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3236 (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3237 (match_operand:DI 2 "general_operand" "dn,don")))]
3242 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3243 if (CONSTANT_P (operands[2]))
3247 split_double (operands[2], &hi, &lo);
3249 switch (INTVAL (hi))
3252 output_asm_insn (\"clr%.l %0\", operands);
3260 xoperands[0] = operands[0];
3262 output_asm_insn (output_andsi3 (xoperands), xoperands);
3265 if (GET_CODE (operands[0]) == REG)
3266 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3268 operands[0] = adjust_address (operands[0], SImode, 4);
3269 switch (INTVAL (lo))
3272 output_asm_insn (\"clr%.l %0\", operands);
3280 xoperands[0] = operands[0];
3282 output_asm_insn (output_andsi3 (xoperands), xoperands);
3287 if (GET_CODE (operands[0]) != REG)
3289 operands[1] = adjust_address (operands[0], SImode, 4);
3290 return \"and%.l %2,%0\;and%.l %R2,%1\";
3292 if (GET_CODE (operands[2]) != REG)
3294 operands[1] = adjust_address (operands[2], SImode, 4);
3295 return \"and%.l %2,%0\;and%.l %1,%R0\";
3297 return \"and%.l %2,%0\;and%.l %R2,%R0\";
3300 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3301 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3302 ;; can't allocate pseudos into it.
3304 (define_expand "andsi3"
3305 [(set (match_operand:SI 0 "not_sp_operand" "")
3306 (and:SI (match_operand:SI 1 "general_operand" "")
3307 (match_operand:SI 2 "general_src_operand" "")))]
3311 (define_insn "andsi3_internal"
3312 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3313 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3314 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3318 return output_andsi3 (operands);
3321 (define_insn "andsi3_5200"
3322 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3323 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3324 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3328 (define_insn "andhi3"
3329 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3330 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3331 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3336 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3337 (and:HI (match_dup 0)
3338 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3343 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3344 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3349 (define_insn "andqi3"
3350 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3351 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3352 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3357 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3358 (and:QI (match_dup 0)
3359 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3364 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3365 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3370 ;; inclusive-or instructions
3372 (define_insn "iordi_zext"
3373 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3374 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3375 (match_operand:DI 2 "general_operand" "0,0")))]
3382 if (GET_CODE (operands[0]) == REG)
3383 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3385 operands[0] = adjust_address (operands[0], SImode, 4);
3386 if (GET_MODE (operands[1]) == SImode)
3387 return \"or%.l %1,%0\";
3388 byte_mode = (GET_MODE (operands[1]) == QImode);
3389 if (GET_CODE (operands[0]) == MEM)
3390 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3393 return \"or%.b %1,%0\";
3395 return \"or%.w %1,%0\";
3398 ;; "iordi3" is mainly here to help combine().
3399 (define_insn "iordi3"
3400 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3401 (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3402 (match_operand:DI 2 "general_operand" "dn,don")))]
3407 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3408 if (CONSTANT_P (operands[2]))
3412 split_double (operands[2], &hi, &lo);
3414 switch (INTVAL (hi))
3419 /* FIXME : a scratch register would be welcome here if operand[0]
3420 is not a register */
3421 output_asm_insn (\"move%.l %#-1,%0\", operands);
3427 xoperands[0] = operands[0];
3429 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3432 if (GET_CODE (operands[0]) == REG)
3433 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3435 operands[0] = adjust_address (operands[0], SImode, 4);
3436 switch (INTVAL (lo))
3441 /* FIXME : a scratch register would be welcome here if operand[0]
3442 is not a register */
3443 output_asm_insn (\"move%.l %#-1,%0\", operands);
3449 xoperands[0] = operands[0];
3451 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3456 if (GET_CODE (operands[0]) != REG)
3458 operands[1] = adjust_address (operands[0], SImode, 4);
3459 return \"or%.l %2,%0\;or%.l %R2,%1\";
3461 if (GET_CODE (operands[2]) != REG)
3463 operands[1] = adjust_address (operands[2], SImode, 4);
3464 return \"or%.l %2,%0\;or%.l %1,%R0\";
3466 return \"or%.l %2,%0\;or%.l %R2,%R0\";
3469 (define_expand "iorsi3"
3470 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3471 (ior:SI (match_operand:SI 1 "general_operand" "")
3472 (match_operand:SI 2 "general_src_operand" "")))]
3476 (define_insn "iorsi3_internal"