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"))]
202 if (TARGET_68020 || TARGET_5200 || ! ADDRESS_REG_P (operands[0]))
203 return \"tst%.l %0\";
204 /* If you think that the 68020 does not support tstl a0,
205 reread page B-167 of the 68020 manual more carefully. */
206 /* On an address reg, cmpw may replace cmpl. */
208 return \"cmp%.w %0,%#0\";
210 return \"cmp%.w %#0,%0\";
214 ;; This can't use an address register, because comparisons
215 ;; with address registers as second operand always test the whole word.
216 (define_expand "tsthi"
218 (match_operand:HI 0 "nonimmediate_operand" ""))]
220 "m68k_last_compare_had_fp_operands = 0;")
224 (match_operand:HI 0 "nonimmediate_operand" "dm"))]
228 (define_expand "tstqi"
230 (match_operand:QI 0 "nonimmediate_operand" ""))]
232 "m68k_last_compare_had_fp_operands = 0;")
236 (match_operand:QI 0 "nonimmediate_operand" "dm"))]
240 (define_expand "tstsf"
242 (match_operand:SF 0 "general_operand" ""))]
246 m68k_last_compare_had_fp_operands = 1;
251 (match_operand:SF 0 "general_operand" "fdm"))]
255 cc_status.flags = CC_IN_68881;
256 if (FP_REG_P (operands[0]))
257 return \"ftst%.x %0\";
258 return \"ftst%.s %0\";
261 (define_expand "tstdf"
263 (match_operand:DF 0 "general_operand" ""))]
267 m68k_last_compare_had_fp_operands = 1;
272 (match_operand:DF 0 "general_operand" "fm"))]
276 cc_status.flags = CC_IN_68881;
277 if (FP_REG_P (operands[0]))
278 return \"ftst%.x %0\";
279 return \"ftst%.d %0\";
282 ;; compare instructions.
284 (define_expand "cmpdi"
287 (compare (match_operand:DI 0 "nonimmediate_operand" "")
288 (match_operand:DI 1 "general_operand" "")))
289 (clobber (match_dup 2))])]
291 "m68k_last_compare_had_fp_operands = 0; operands[2] = gen_reg_rtx (DImode);")
295 (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
296 (match_operand:DI 2 "general_operand" "d,0")))
297 (clobber (match_operand:DI 0 "register_operand" "=d,d"))]
301 if (rtx_equal_p (operands[0], operands[1]))
302 return \"sub%.l %R2,%R0\;subx%.l %2,%0\";
305 cc_status.flags |= CC_REVERSED;
306 return \"sub%.l %R1,%R0\;subx%.l %1,%0\";
310 ;; This is the second "hook" for PIC code (in addition to movsi). See
311 ;; comment of movsi for a description of PIC handling.
312 (define_expand "cmpsi"
314 (compare (match_operand:SI 0 "nonimmediate_operand" "")
315 (match_operand:SI 1 "general_operand" "")))]
319 m68k_last_compare_had_fp_operands = 0;
320 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
322 /* The source is an address which requires PIC relocation.
323 Call legitimize_pic_address with the source, mode, and a relocation
324 register (a new pseudo, or the final destination if reload_in_progress
325 is set). Then fall through normally */
326 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
327 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
331 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
334 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
335 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
339 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
341 return \"cmpm%.l %0,%1\";
343 return \"cmpm%.l %1,%0\";
345 if (REG_P (operands[1])
346 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
347 { cc_status.flags |= CC_REVERSED;
349 return \"cmp%.l %d1,%d0\";
351 return \"cmp%.l %d0,%d1\";
354 if (ADDRESS_REG_P (operands[0])
355 && GET_CODE (operands[1]) == CONST_INT
356 && INTVAL (operands[1]) < 0x8000
357 && INTVAL (operands[1]) >= -0x8000)
360 return \"cmp%.w %0,%1\";
362 return \"cmp%.w %1,%0\";
366 return \"cmp%.l %d0,%d1\";
368 return \"cmp%.l %d1,%d0\";
374 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
375 (match_operand:SI 1 "general_operand" "r,mrKs")))]
379 if (REG_P (operands[1])
380 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
381 { cc_status.flags |= CC_REVERSED;
383 return \"cmp%.l %d1,%d0\";
385 return \"cmp%.l %d0,%d1\";
389 return \"cmp%.l %d0,%d1\";
391 return \"cmp%.l %d1,%d0\";
395 (define_expand "cmphi"
397 (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
398 (match_operand:HI 1 "general_src_operand" "")))]
400 "m68k_last_compare_had_fp_operands = 0;")
404 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
405 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
409 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
411 return \"cmpm%.w %0,%1\";
413 return \"cmpm%.w %1,%0\";
415 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
416 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
417 { cc_status.flags |= CC_REVERSED;
419 return \"cmp%.w %d1,%d0\";
421 return \"cmp%.w %d0,%d1\";
425 return \"cmp%.w %d0,%d1\";
427 return \"cmp%.w %d1,%d0\";
431 (define_expand "cmpqi"
433 (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
434 (match_operand:QI 1 "general_src_operand" "")))]
436 "m68k_last_compare_had_fp_operands = 0;")
440 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
441 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
445 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
447 return \"cmpm%.b %0,%1\";
449 return \"cmpm%.b %1,%0\";
451 if (REG_P (operands[1])
452 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
453 { cc_status.flags |= CC_REVERSED;
455 return \"cmp%.b %d1,%d0\";
457 return \"cmp%.b %d0,%d1\";
461 return \"cmp%.b %d0,%d1\";
463 return \"cmp%.b %d1,%d0\";
467 (define_expand "cmpdf"
469 (compare (match_operand:DF 0 "general_operand" "")
470 (match_operand:DF 1 "general_operand" "")))]
474 m68k_last_compare_had_fp_operands = 1;
479 (compare (match_operand:DF 0 "general_operand" "f,mG")
480 (match_operand:DF 1 "general_operand" "fmG,f")))]
484 cc_status.flags = CC_IN_68881;
486 if (REG_P (operands[0]))
488 if (REG_P (operands[1]))
489 return \"fcmp%.x %0,%1\";
491 return \"fcmp%.d %0,%f1\";
493 cc_status.flags |= CC_REVERSED;
494 return \"fcmp%.d %1,%f0\";
496 if (REG_P (operands[0]))
498 if (REG_P (operands[1]))
499 return \"fcmp%.x %1,%0\";
501 return \"fcmp%.d %f1,%0\";
503 cc_status.flags |= CC_REVERSED;
504 return \"fcmp%.d %f0,%1\";
508 (define_expand "cmpsf"
510 (compare (match_operand:SF 0 "general_operand" "")
511 (match_operand:SF 1 "general_operand" "")))]
515 m68k_last_compare_had_fp_operands = 1;
520 (compare (match_operand:SF 0 "general_operand" "f,mdG")
521 (match_operand:SF 1 "general_operand" "fmdG,f")))]
525 cc_status.flags = CC_IN_68881;
527 if (FP_REG_P (operands[0]))
529 if (FP_REG_P (operands[1]))
530 return \"fcmp%.x %0,%1\";
532 return \"fcmp%.s %0,%f1\";
534 cc_status.flags |= CC_REVERSED;
535 return \"fcmp%.s %1,%f0\";
537 if (FP_REG_P (operands[0]))
539 if (FP_REG_P (operands[1]))
540 return \"fcmp%.x %1,%0\";
542 return \"fcmp%.s %f1,%0\";
544 cc_status.flags |= CC_REVERSED;
545 return \"fcmp%.s %f0,%1\";
549 ;; Recognizers for btst instructions.
551 ;; Coldfire/5200 only allows "<Q>" type addresses when the bit position is
552 ;; specified as a constant, so we must disable all patterns that may extract
553 ;; from a MEM at a constant bit position if we can't use this as a constraint.
556 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
558 (minus:SI (const_int 7)
559 (match_operand:SI 1 "general_operand" "di"))))]
561 "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
563 ;; This is the same as the above pattern except for the constraints. The 'i'
567 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
569 (minus:SI (const_int 7)
570 (match_operand:SI 1 "general_operand" "d"))))]
572 "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
575 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
577 (minus:SI (const_int 31)
578 (match_operand:SI 1 "general_operand" "di"))))]
580 "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
582 ;; The following two patterns are like the previous two
583 ;; except that they use the fact that bit-number operands
584 ;; are automatically masked to 3 or 5 bits.
587 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
589 (minus:SI (const_int 7)
591 (match_operand:SI 1 "register_operand" "d")
594 "* { return output_btst (operands, operands[1], operands[0], insn, 7); }")
597 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
599 (minus:SI (const_int 31)
601 (match_operand:SI 1 "register_operand" "d")
604 "* { return output_btst (operands, operands[1], operands[0], insn, 31); }")
606 ;; Nonoffsettable mem refs are ok in this one pattern
607 ;; since we don't try to adjust them.
609 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
611 (match_operand:SI 1 "const_int_operand" "n")))]
612 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_5200"
615 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
616 return output_btst (operands, operands[1], operands[0], insn, 7);
620 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
622 (match_operand:SI 1 "const_int_operand" "n")))]
626 if (GET_CODE (operands[0]) == MEM)
628 operands[0] = adjust_address (operands[0], QImode,
629 INTVAL (operands[1]) / 8);
630 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
631 return output_btst (operands, operands[1], operands[0], insn, 7);
633 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
634 return output_btst (operands, operands[1], operands[0], insn, 31);
637 ;; This is the same as the above pattern except for the constraints.
638 ;; The 'o' has been replaced with 'Q'.
641 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
643 (match_operand:SI 1 "const_int_operand" "n")))]
647 if (GET_CODE (operands[0]) == MEM)
649 operands[0] = adjust_address (operands[0], QImode,
650 INTVAL (operands[1]) / 8);
651 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
652 return output_btst (operands, operands[1], operands[0], insn, 7);
654 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
655 return output_btst (operands, operands[1], operands[0], insn, 31);
661 ;; A special case in which it is not desirable
662 ;; to reload the constant into a data register.
663 (define_insn "pushexthisi_const"
664 [(set (match_operand:SI 0 "push_operand" "=m")
665 (match_operand:SI 1 "const_int_operand" "J"))]
666 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
669 if (operands[1] == const0_rtx)
670 return \"clr%.l %0\";
675 ;(define_insn "swapsi"
676 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
677 ; (match_operand:SI 1 "general_operand" "+r"))
678 ; (set (match_dup 1) (match_dup 0))]
682 ;; Special case of fullword move when source is zero.
683 ;; The reason this is special is to avoid loading a zero
684 ;; into a data reg with moveq in order to store it elsewhere.
686 (define_insn "movsi_const0"
687 [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
689 ;; clr insns on 68000 read before writing.
690 ;; This isn't so on the 68010, but we have no TARGET_68010.
691 "((TARGET_68020 || TARGET_5200)
692 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
695 if (ADDRESS_REG_P (operands[0]))
697 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
698 if (!TARGET_68040 && !TARGET_68060)
699 return \"sub%.l %0,%0\";
704 /* Many SGS assemblers croak on size specifiers for constants. */
707 return \"lea 0.w,%0\";
710 return \"lea 0:w,%0\";
714 /* moveq is faster on the 68000. */
715 if (DATA_REG_P (operands[0]) && (!TARGET_68020 && !TARGET_5200))
716 return \"moveq %#0,%0\";
717 return \"clr%.l %0\";
720 ;; General case of fullword move.
722 ;; This is the main "hook" for PIC code. When generating
723 ;; PIC, movsi is responsible for determining when the source address
724 ;; needs PIC relocation and appropriately calling legitimize_pic_address
725 ;; to perform the actual relocation.
727 ;; In both the PIC and non-PIC cases the patterns generated will
728 ;; matched by the next define_insn.
729 (define_expand "movsi"
730 [(set (match_operand:SI 0 "nonimmediate_operand" "")
731 (match_operand:SI 1 "general_operand" ""))]
735 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
737 /* The source is an address which requires PIC relocation.
738 Call legitimize_pic_address with the source, mode, and a relocation
739 register (a new pseudo, or the final destination if reload_in_progress
740 is set). Then fall through normally */
741 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
742 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
744 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
746 /* Don't allow writes to memory except via a register;
747 the m68k doesn't consider PC-relative addresses to be writable. */
748 if (symbolic_operand (operands[0], SImode))
749 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
750 else if (GET_CODE (operands[0]) == MEM
751 && symbolic_operand (XEXP (operands[0], 0), SImode))
752 operands[0] = gen_rtx (MEM, SImode,
753 force_reg (SImode, XEXP (operands[0], 0)));
757 ;; General case of fullword move. The register constraints
758 ;; force integer constants in range for a moveq to be reloaded
759 ;; if they are headed for memory.
761 ;; Notes: make sure no alternative allows g vs g.
762 ;; We don't allow f-regs since fixed point cannot go in them.
763 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
764 (match_operand:SI 1 "general_src_operand" "daymSKT,n,i"))]
769 return output_move_simode (operands);
773 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g")
774 (match_operand:SI 1 "general_operand" "g,r<Q>"))]
776 "* return output_move_simode (operands);")
778 ;; Special case of fullword move, where we need to get a non-GOT PIC
779 ;; reference into an address register.
781 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
782 (match_operand:SI 1 "pcrel_address" ""))]
786 if (push_operand (operands[0], SImode))
788 return \"lea %a1,%0\";
791 (define_expand "movhi"
792 [(set (match_operand:HI 0 "nonimmediate_operand" "")
793 (match_operand:HI 1 "general_operand" ""))]
798 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
799 (match_operand:HI 1 "general_src_operand" "gS"))]
801 "* return output_move_himode (operands);")
804 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g")
805 (match_operand:HI 1 "general_operand" "g,r<Q>"))]
807 "* return output_move_himode (operands);")
809 (define_expand "movstricthi"
810 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
811 (match_operand:HI 1 "general_src_operand" ""))]
816 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
817 (match_operand:HI 1 "general_src_operand" "rmSn"))]
819 "* return output_move_stricthi (operands);")
822 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
823 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
825 "* return output_move_stricthi (operands);")
827 (define_expand "movqi"
828 [(set (match_operand:QI 0 "nonimmediate_operand" "")
829 (match_operand:QI 1 "general_src_operand" ""))]
834 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
835 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
837 "* return output_move_qimode (operands);")
840 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,d*a")
841 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,di*a"))]
843 "* return output_move_qimode (operands);")
845 (define_expand "movstrictqi"
846 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
847 (match_operand:QI 1 "general_src_operand" ""))]
852 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
853 (match_operand:QI 1 "general_src_operand" "dmSn"))]
855 "* return output_move_strictqi (operands);")
858 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d,m"))
859 (match_operand:QI 1 "general_src_operand" "dmn,d"))]
861 "* return output_move_strictqi (operands);")
863 (define_expand "pushqi1"
864 [(set (reg:SI 15) (plus:SI (reg:SI 15) (const_int -2)))
865 (set (mem:QI (plus:SI (reg:SI 15) (const_int 1)))
866 (match_operand:QI 0 "general_operand" ""))]
870 (define_expand "movsf"
871 [(set (match_operand:SF 0 "nonimmediate_operand" "")
872 (match_operand:SF 1 "general_operand" ""))]
877 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
878 (match_operand:SF 1 "general_operand" "rmfF"))]
882 if (FP_REG_P (operands[0]))
884 if (FP_REG_P (operands[1]))
885 return \"f%$move%.x %1,%0\";
886 else if (ADDRESS_REG_P (operands[1]))
887 return \"move%.l %1,%-\;f%$move%.s %+,%0\";
888 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
889 return output_move_const_single (operands);
890 return \"f%$move%.s %f1,%0\";
892 if (FP_REG_P (operands[1]))
894 if (ADDRESS_REG_P (operands[0]))
895 return \"fmove%.s %1,%-\;move%.l %+,%0\";
896 return \"fmove%.s %f1,%0\";
898 if (operands[1] == CONST0_RTX (SFmode)
899 /* clr insns on 68000 read before writing.
900 This isn't so on the 68010, but we have no TARGET_68010. */
901 && ((TARGET_68020 || TARGET_5200)
902 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
904 if (ADDRESS_REG_P (operands[0]))
906 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
907 if (!TARGET_68040 && !TARGET_68060)
908 return \"sub%.l %0,%0\";
913 /* Many SGS assemblers croak on size specifiers for constants. */
916 return \"lea 0.w,%0\";
919 return \"lea 0:w,%0\";
923 /* moveq is faster on the 68000. */
924 if (DATA_REG_P (operands[0]) && !(TARGET_68020 || TARGET_5200))
926 return \"moveq %#0,%0\";
928 return \"clr%.l %0\";
930 return \"move%.l %1,%0\";
934 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,g")
935 (match_operand:SF 1 "general_operand" "g,r"))]
937 "* return \"move%.l %1,%0\";")
939 (define_expand "movdf"
940 [(set (match_operand:DF 0 "nonimmediate_operand" "")
941 (match_operand:DF 1 "general_operand" ""))]
946 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
947 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
948 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
949 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
953 if (FP_REG_P (operands[0]))
955 if (FP_REG_P (operands[1]))
956 return \"f%&move%.x %1,%0\";
957 if (REG_P (operands[1]))
960 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
961 output_asm_insn (\"move%.l %1,%-\", xoperands);
962 output_asm_insn (\"move%.l %1,%-\", operands);
963 return \"f%&move%.d %+,%0\";
965 if (GET_CODE (operands[1]) == CONST_DOUBLE)
966 return output_move_const_double (operands);
967 return \"f%&move%.d %f1,%0\";
969 else if (FP_REG_P (operands[1]))
971 if (REG_P (operands[0]))
973 output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
974 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
975 return \"move%.l %+,%0\";
978 return \"fmove%.d %f1,%0\";
980 return output_move_double (operands);
984 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
985 (match_operand:DF 1 "general_operand" "g,r"))]
987 "* return output_move_double (operands);")
989 ;; ??? The XFmode patterns are schizophrenic about whether constants are
990 ;; allowed. Most but not all have predicates and constraint that disallow
991 ;; constants. Most but not all have output templates that handle constants.
992 ;; See also LEGITIMATE_CONSTANT_P.
994 (define_expand "movxf"
995 [(set (match_operand:XF 0 "nonimmediate_operand" "")
996 (match_operand:XF 1 "general_operand" ""))]
1000 /* We can't rewrite operands during reload. */
1001 if (! reload_in_progress)
1003 if (CONSTANT_P (operands[1]))
1005 operands[1] = force_const_mem (XFmode, operands[1]);
1006 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1007 operands[1] = adjust_address (operands[1], XFmode, 0);
1009 if (flag_pic && TARGET_PCREL)
1011 /* Don't allow writes to memory except via a register; the
1012 m68k doesn't consider PC-relative addresses to be writable. */
1013 if (GET_CODE (operands[0]) == MEM
1014 && symbolic_operand (XEXP (operands[0], 0), SImode))
1015 operands[0] = gen_rtx (MEM, XFmode,
1016 force_reg (SImode, XEXP (operands[0], 0)));
1022 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r")
1023 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r"))]
1027 if (FP_REG_P (operands[0]))
1029 if (FP_REG_P (operands[1]))
1030 return \"fmove%.x %1,%0\";
1031 if (REG_P (operands[1]))
1034 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1035 output_asm_insn (\"move%.l %1,%-\", xoperands);
1036 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1037 output_asm_insn (\"move%.l %1,%-\", xoperands);
1038 output_asm_insn (\"move%.l %1,%-\", operands);
1039 return \"fmove%.x %+,%0\";
1041 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1042 return \"fmove%.x %1,%0\";
1043 return \"fmove%.x %f1,%0\";
1045 if (FP_REG_P (operands[1]))
1047 if (REG_P (operands[0]))
1049 output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands);
1050 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1051 output_asm_insn (\"move%.l %+,%0\", operands);
1052 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1053 return \"move%.l %+,%0\";
1055 /* Must be memory destination. */
1056 return \"fmove%.x %f1,%0\";
1058 return output_move_double (operands);
1063 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1064 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1065 "! TARGET_68881 && ! TARGET_5200"
1068 if (FP_REG_P (operands[0]))
1070 if (FP_REG_P (operands[1]))
1071 return \"fmove%.x %1,%0\";
1072 if (REG_P (operands[1]))
1075 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1076 output_asm_insn (\"move%.l %1,%-\", xoperands);
1077 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1078 output_asm_insn (\"move%.l %1,%-\", xoperands);
1079 output_asm_insn (\"move%.l %1,%-\", operands);
1080 return \"fmove%.x %+,%0\";
1082 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1083 return \"fmove%.x %1,%0\";
1084 return \"fmove%.x %f1,%0\";
1086 if (FP_REG_P (operands[1]))
1088 if (REG_P (operands[0]))
1090 output_asm_insn (\"fmove%.x %f1,%-\;move%.l %+,%0\", operands);
1091 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1092 output_asm_insn (\"move%.l %+,%0\", operands);
1093 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1094 return \"move%.l %+,%0\";
1097 return \"fmove%.x %f1,%0\";
1099 return output_move_double (operands);
1104 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1105 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1106 "! TARGET_68881 && TARGET_5200"
1107 "* return output_move_double (operands);")
1109 (define_expand "movdi"
1110 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1111 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1112 (match_operand:DI 1 "general_operand" ""))]
1116 ;; movdi can apply to fp regs in some cases
1118 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1119 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1120 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1121 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1122 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1123 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1124 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1128 if (FP_REG_P (operands[0]))
1130 if (FP_REG_P (operands[1]))
1131 return \"fmove%.x %1,%0\";
1132 if (REG_P (operands[1]))
1135 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1136 output_asm_insn (\"move%.l %1,%-\", xoperands);
1137 output_asm_insn (\"move%.l %1,%-\", operands);
1138 return \"fmove%.d %+,%0\";
1140 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1141 return output_move_const_double (operands);
1142 return \"fmove%.d %f1,%0\";
1144 else if (FP_REG_P (operands[1]))
1146 if (REG_P (operands[0]))
1148 output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
1149 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1150 return \"move%.l %+,%0\";
1153 return \"fmove%.d %f1,%0\";
1155 return output_move_double (operands);
1159 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1160 (match_operand:DI 1 "general_operand" "g,r"))]
1162 "* return output_move_double (operands);")
1164 ;; Thus goes after the move instructions
1165 ;; because the move instructions are better (require no spilling)
1166 ;; when they can apply. It goes before the add/sub insns
1167 ;; so we will prefer it to them.
1169 (define_insn "pushasi"
1170 [(set (match_operand:SI 0 "push_operand" "=m")
1171 (match_operand:SI 1 "address_operand" "p"))]
1175 ;; truncation instructions
1176 (define_insn "truncsiqi2"
1177 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1179 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1183 if (GET_CODE (operands[0]) == REG)
1185 /* Must clear condition codes, since the move.l bases them on
1186 the entire 32 bits, not just the desired 8 bits. */
1188 return \"move%.l %1,%0\";
1190 if (GET_CODE (operands[1]) == MEM)
1191 operands[1] = adjust_address (operands[1], QImode, 3);
1192 return \"move%.b %1,%0\";
1195 (define_insn "trunchiqi2"
1196 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1198 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1202 if (GET_CODE (operands[0]) == REG
1203 && (GET_CODE (operands[1]) == MEM
1204 || GET_CODE (operands[1]) == CONST_INT))
1206 /* Must clear condition codes, since the move.w bases them on
1207 the entire 16 bits, not just the desired 8 bits. */
1209 return \"move%.w %1,%0\";
1211 if (GET_CODE (operands[0]) == REG)
1213 /* Must clear condition codes, since the move.l bases them on
1214 the entire 32 bits, not just the desired 8 bits. */
1216 return \"move%.l %1,%0\";
1218 if (GET_CODE (operands[1]) == MEM)
1219 operands[1] = adjust_address (operands[1], QImode, 1);
1220 return \"move%.b %1,%0\";
1223 (define_insn "truncsihi2"
1224 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1226 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1230 if (GET_CODE (operands[0]) == REG)
1232 /* Must clear condition codes, since the move.l bases them on
1233 the entire 32 bits, not just the desired 8 bits. */
1235 return \"move%.l %1,%0\";
1237 if (GET_CODE (operands[1]) == MEM)
1238 operands[1] = adjust_address (operands[1], QImode, 2);
1239 return \"move%.w %1,%0\";
1242 ;; zero extension instructions
1244 (define_insn "zero_extendqidi2"
1245 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
1246 (zero_extend:DI (match_operand:QI 1 "general_operand" "dm")))]
1251 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1252 return \"moveq %#0,%0\;moveq %#0,%2\;move%.b %1,%2\";
1255 (define_insn "zero_extendhidi2"
1256 [(set (match_operand:DI 0 "nonimmediate_operand" "=&d")
1257 (zero_extend:DI (match_operand:HI 1 "general_operand" "rm")))]
1262 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1263 return \"moveq %#0,%0\;moveq %#0,%2\;move%.w %1,%2\";
1266 ;; this is the canonical form for (lshiftrt:DI x 32)
1267 (define_expand "zero_extendsidi2"
1268 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1269 (zero_extend:DI (match_operand:SI 1 "general_operand" "")))]
1273 (define_insn "*zero_extendsidi2_cf"
1274 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,m")
1275 (zero_extend:DI (match_operand:SI 1 "general_operand" "rm,r")))]
1280 if (GET_CODE (operands[0]) == REG)
1281 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1282 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1283 return \"move%.l %1,%0\;clr%.l %0\";
1284 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1285 return \"clr%.l %0\;move%.l %1,%0\";
1287 operands[2] = adjust_address (operands[0], SImode, 4);
1288 if (GET_CODE (operands[1]) != REG || GET_CODE (operands[2]) != REG
1289 || REGNO (operands[1]) != REGNO (operands[2]))
1290 output_asm_insn (\"move%.l %1,%2\", operands);
1291 if (ADDRESS_REG_P (operands[0]))
1292 return \"sub%.l %0,%0\";
1294 return \"clr%.l %0\";
1297 (define_insn "*zero_extendsidi2"
1298 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
1299 (zero_extend:DI (match_operand:SI 1 "general_operand" "rm")))]
1304 if (GET_CODE (operands[0]) == REG)
1305 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1306 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1307 return \"move%.l %1,%0\;clr%.l %0\";
1308 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1309 return \"clr%.l %0\;move%.l %1,%0\";
1311 operands[2] = adjust_address (operands[0], SImode, 4);
1312 if (GET_CODE (operands[1]) != REG || GET_CODE (operands[2]) != REG
1313 || REGNO (operands[1]) != REGNO (operands[2]))
1314 output_asm_insn (\"move%.l %1,%2\", operands);
1315 if (ADDRESS_REG_P (operands[0]))
1316 return \"sub%.l %0,%0\";
1318 return \"clr%.l %0\";
1321 (define_expand "zero_extendhisi2"
1322 [(set (match_operand:SI 0 "register_operand" "")
1324 (set (strict_low_part (match_dup 2))
1325 (match_operand:HI 1 "general_operand" ""))]
1329 operands[1] = make_safe_from (operands[1], operands[0]);
1330 operands[2] = gen_lowpart_SUBREG (HImode, operands[0]);
1333 (define_expand "zero_extendqihi2"
1334 [(set (match_operand:HI 0 "register_operand" "")
1336 (set (strict_low_part (match_dup 2))
1337 (match_operand:QI 1 "general_operand" ""))]
1341 operands[1] = make_safe_from (operands[1], operands[0]);
1342 operands[2] = gen_lowpart_SUBREG (QImode, operands[0]);
1345 (define_expand "zero_extendqisi2"
1346 [(set (match_operand:SI 0 "register_operand" "")
1348 (set (strict_low_part (match_dup 2))
1349 (match_operand:QI 1 "general_operand" ""))]
1353 operands[1] = make_safe_from (operands[1], operands[0]);
1354 operands[2] = gen_lowpart_SUBREG (QImode, operands[0]);
1357 ;; Patterns to recognize zero-extend insns produced by the combiner.
1358 ;; We don't allow both operands in memory, because of aliasing problems.
1359 ;; Explicitly disallow two memory operands via the condition since reloading
1360 ;; of this case will result in worse code than the uncombined patterns.
1363 [(set (match_operand:SI 0 "nonimmediate_operand" "=do<>,d<")
1364 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "r,mS")))]
1365 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1368 if (DATA_REG_P (operands[0]))
1370 if (GET_CODE (operands[1]) == REG
1371 && REGNO (operands[0]) == REGNO (operands[1]))
1372 return \"and%.l %#0xFFFF,%0\";
1373 if (reg_mentioned_p (operands[0], operands[1]))
1374 return \"move%.w %1,%0\;and%.l %#0xFFFF,%0\";
1375 return \"clr%.l %0\;move%.w %1,%0\";
1377 else if (GET_CODE (operands[0]) == MEM
1378 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1379 return \"move%.w %1,%0\;clr%.w %0\";
1380 else if (GET_CODE (operands[0]) == MEM
1381 && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1382 return \"clr%.w %0\;move%.w %1,%0\";
1385 output_asm_insn (\"clr%.w %0\", operands);
1386 operands[0] = adjust_address (operands[0], HImode, 2);
1387 return \"move%.w %1,%0\";
1392 [(set (match_operand:HI 0 "nonimmediate_operand" "=do<>,d")
1393 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "d,mS")))]
1394 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1397 if (DATA_REG_P (operands[0]))
1399 if (GET_CODE (operands[1]) == REG
1400 && REGNO (operands[0]) == REGNO (operands[1]))
1401 return (!TARGET_5200 ? \"and%.w %#0xFF,%0\" : \"and%.l %#0xFF,%0\");
1402 if (reg_mentioned_p (operands[0], operands[1]))
1403 return (!TARGET_5200 ? \"move%.b %1,%0\;and%.w %#0xFF,%0\"
1404 : \"move%.b %1,%0\;and%.l %#0xFF,%0\");
1405 return \"clr%.w %0\;move%.b %1,%0\";
1407 else if (GET_CODE (operands[0]) == MEM
1408 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1410 if (REGNO (XEXP (XEXP (operands[0], 0), 0))
1411 == STACK_POINTER_REGNUM)
1413 output_asm_insn (\"clr%.w %-\", operands);
1414 operands[0] = gen_rtx_MEM (GET_MODE (operands[0]),
1415 plus_constant (stack_pointer_rtx, 1));
1416 return \"move%.b %1,%0\";
1419 return \"move%.b %1,%0\;clr%.b %0\";
1421 else if (GET_CODE (operands[0]) == MEM
1422 && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1423 return \"clr%.b %0\;move%.b %1,%0\";
1426 output_asm_insn (\"clr%.b %0\", operands);
1427 operands[0] = adjust_address (operands[0], QImode, 1);
1428 return \"move%.b %1,%0\";
1433 [(set (match_operand:SI 0 "nonimmediate_operand" "=do<>,d")
1434 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "d,mS")))]
1435 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1438 if (DATA_REG_P (operands[0]))
1440 if (GET_CODE (operands[1]) == REG
1441 && REGNO (operands[0]) == REGNO (operands[1]))
1442 return \"and%.l %#0xFF,%0\";
1443 if (reg_mentioned_p (operands[0], operands[1]))
1444 return \"move%.b %1,%0\;and%.l %#0xFF,%0\";
1445 return \"clr%.l %0\;move%.b %1,%0\";
1447 else if (GET_CODE (operands[0]) == MEM
1448 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1450 operands[0] = XEXP (XEXP (operands[0], 0), 0);
1453 return \"clr%.l -(%0)\;move%.b %1,3(%0)\";
1455 return \"clr%.l -(%0)\;move%.b %1,(3,%0)\";
1458 return \"clrl %0@-\;moveb %1,%0@(3)\";
1461 else if (GET_CODE (operands[0]) == MEM
1462 && GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1464 operands[0] = XEXP (XEXP (operands[0], 0), 0);
1467 return \"clr%.l (%0)+\;move%.b %1,-1(%0)\";
1469 return \"clr%.l (%0)+\;move%.b %1,(-1,%0)\";
1472 return \"clrl %0@+\;moveb %1,%0@(-1)\";
1477 output_asm_insn (\"clr%.l %0\", operands);
1478 operands[0] = adjust_address (operands[0], QImode, 3);
1479 return \"move%.b %1,%0\";
1483 ;; sign extension instructions
1485 (define_insn "extendqidi2"
1486 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1487 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1492 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1493 if (TARGET_68020 || TARGET_5200)
1494 return \"move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0\";
1496 return \"move%.b %1,%2\;ext%.w %0\;ext%.l %2\;move%.l %2,%0\;smi %0\";
1499 (define_insn "extendhidi2"
1500 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1502 (match_operand:HI 1 "general_src_operand" "rmS")))]
1507 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1508 if (TARGET_68020 || TARGET_5200)
1509 return \"move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0\";
1511 return \"move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0\";
1514 (define_insn "extendsidi2"
1515 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1517 (match_operand:SI 1 "general_operand" "rm")))]
1522 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1523 if (TARGET_68020 || TARGET_5200)
1524 return \"move%.l %1,%2\;smi %0\;extb%.l %0\";
1526 return \"move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0\";
1529 ;; Special case when one can avoid register clobbering, copy and test
1530 ;; Maybe there is a way to make that the general case, by forcing the
1531 ;; result of the SI tree to be in the lower register of the DI target
1533 (define_insn "extendplussidi"
1534 [(set (match_operand:DI 0 "register_operand" "=d")
1535 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1536 (match_operand:SI 2 "general_operand" "rmn"))))]
1541 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1542 if (GET_CODE (operands[1]) == CONST_INT
1543 && (unsigned) INTVAL (operands[1]) > 8)
1545 rtx tmp = operands[1];
1547 operands[1] = operands[2];
1550 if (GET_CODE (operands[1]) == REG
1551 && REGNO (operands[1]) == REGNO (operands[3]))
1552 output_asm_insn (\"add%.l %2,%3\", operands);
1554 output_asm_insn (\"move%.l %2,%3\;add%.l %1,%3\", operands);
1555 if (TARGET_68020 || TARGET_5200)
1556 return \"smi %0\;extb%.l %0\";
1558 return \"smi %0\;ext%.w %0\;ext%.l %0\";
1561 (define_insn "extendhisi2"
1562 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1564 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1568 if (ADDRESS_REG_P (operands[0]))
1569 return \"move%.w %1,%0\";
1570 return \"ext%.l %0\";
1573 (define_insn "extendqihi2"
1574 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1575 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1579 (define_insn "extendqisi2"
1580 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1581 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1582 "TARGET_68020 || TARGET_5200"
1585 ;; Conversions between float and double.
1587 (define_expand "extendsfdf2"
1588 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1590 (match_operand:SF 1 "general_operand" "")))]
1595 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1597 (match_operand:SF 1 "general_operand" "f,dmF")))]
1601 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1603 if (REGNO (operands[0]) == REGNO (operands[1]))
1605 /* Extending float to double in an fp-reg is a no-op.
1606 NOTICE_UPDATE_CC has already assumed that the
1607 cc will be set. So cancel what it did. */
1608 cc_status = cc_prev_status;
1611 return \"f%&move%.x %1,%0\";
1613 if (FP_REG_P (operands[0]))
1614 return \"f%&move%.s %f1,%0\";
1615 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1617 output_asm_insn (\"fmove%.d %f1,%-\;move%.l %+,%0\", operands);
1618 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1619 return \"move%.l %+,%0\";
1621 return \"fmove%.d %f1,%0\";
1624 ;; This cannot output into an f-reg because there is no way to be
1625 ;; sure of truncating in that case.
1626 (define_expand "truncdfsf2"
1627 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1629 (match_operand:DF 1 "general_operand" "")))]
1633 ;; On the '040 we can truncate in a register accurately and easily.
1635 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1637 (match_operand:DF 1 "general_operand" "fmG")))]
1641 if (FP_REG_P (operands[1]))
1642 return \"f%$move%.x %1,%0\";
1643 return \"f%$move%.d %f1,%0\";
1647 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1649 (match_operand:DF 1 "general_operand" "f")))]
1653 ;; Conversion between fixed point and floating point.
1654 ;; Note that among the fix-to-float insns
1655 ;; the ones that start with SImode come first.
1656 ;; That is so that an operand that is a CONST_INT
1657 ;; (and therefore lacks a specific machine mode).
1658 ;; will be recognized as SImode (which is always valid)
1659 ;; rather than as QImode or HImode.
1661 (define_expand "floatsisf2"
1662 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1663 (float:SF (match_operand:SI 1 "general_operand" "")))]
1668 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1669 (float:SF (match_operand:SI 1 "general_operand" "dmi")))]
1673 (define_expand "floatsidf2"
1674 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1675 (float:DF (match_operand:SI 1 "general_operand" "")))]
1680 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1681 (float:DF (match_operand:SI 1 "general_operand" "dmi")))]
1685 (define_insn "floathisf2"
1686 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1687 (float:SF (match_operand:HI 1 "general_operand" "dmn")))]
1691 (define_insn "floathidf2"
1692 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1693 (float:DF (match_operand:HI 1 "general_operand" "dmn")))]
1697 (define_insn "floatqisf2"
1698 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1699 (float:SF (match_operand:QI 1 "general_operand" "dmn")))]
1703 (define_insn "floatqidf2"
1704 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1705 (float:DF (match_operand:QI 1 "general_operand" "dmn")))]
1709 ;; New routines to convert floating-point values to integers
1710 ;; to be used on the '040. These should be faster than trapping
1711 ;; into the kernel to emulate fintrz. They should also be faster
1712 ;; than calling the subroutines fixsfsi or fixdfsi.
1714 (define_insn "fix_truncdfsi2"
1715 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1716 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1717 (clobber (match_scratch:SI 2 "=d"))
1718 (clobber (match_scratch:SI 3 "=d"))]
1719 "TARGET_68881 && TARGET_68040"
1723 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,%!\";
1726 (define_insn "fix_truncdfhi2"
1727 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1728 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1729 (clobber (match_scratch:SI 2 "=d"))
1730 (clobber (match_scratch:SI 3 "=d"))]
1731 "TARGET_68881 && TARGET_68040"
1735 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,%!\";
1738 (define_insn "fix_truncdfqi2"
1739 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1740 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1741 (clobber (match_scratch:SI 2 "=d"))
1742 (clobber (match_scratch:SI 3 "=d"))]
1743 "TARGET_68881 && TARGET_68040"
1747 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,%!\";
1750 ;; Convert a float to a float whose value is an integer.
1751 ;; This is the first stage of converting it to an integer type.
1753 (define_insn "ftruncdf2"
1754 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1755 (fix:DF (match_operand:DF 1 "general_operand" "fFm")))]
1756 "TARGET_68881 && !TARGET_68040"
1759 if (FP_REG_P (operands[1]))
1760 return \"fintrz%.x %f1,%0\";
1761 return \"fintrz%.d %f1,%0\";
1764 (define_insn "ftruncsf2"
1765 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1766 (fix:SF (match_operand:SF 1 "general_operand" "dfFm")))]
1767 "TARGET_68881 && !TARGET_68040"
1770 if (FP_REG_P (operands[1]))
1771 return \"fintrz%.x %f1,%0\";
1772 return \"fintrz%.s %f1,%0\";
1775 ;; Convert a float whose value is an integer
1776 ;; to an actual integer. Second stage of converting float to integer type.
1777 (define_insn "fixsfqi2"
1778 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1779 (fix:QI (match_operand:SF 1 "general_operand" "f")))]
1783 (define_insn "fixsfhi2"
1784 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1785 (fix:HI (match_operand:SF 1 "general_operand" "f")))]
1789 (define_insn "fixsfsi2"
1790 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1791 (fix:SI (match_operand:SF 1 "general_operand" "f")))]
1795 (define_insn "fixdfqi2"
1796 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1797 (fix:QI (match_operand:DF 1 "general_operand" "f")))]
1801 (define_insn "fixdfhi2"
1802 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1803 (fix:HI (match_operand:DF 1 "general_operand" "f")))]
1807 (define_insn "fixdfsi2"
1808 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1809 (fix:SI (match_operand:DF 1 "general_operand" "f")))]
1815 (define_insn "adddi_lshrdi_63"
1816 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1817 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
1820 (clobber (match_scratch:SI 2 "=d"))]
1824 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1825 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
1827 \"move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0\";
1828 if (GET_CODE (operands[1]) == REG)
1829 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1830 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
1831 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1832 operands[4] = operands[1];
1834 operands[4] = adjust_address (operands[1], SImode, 4);
1835 if (GET_CODE (operands[1]) == MEM
1836 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1837 output_asm_insn (\"move%.l %4,%3\", operands);
1838 output_asm_insn (\"move%.l %1,%0\;smi %2\", operands);
1839 if (TARGET_68020 || TARGET_5200)
1840 output_asm_insn (\"extb%.l %2\", operands);
1842 output_asm_insn (\"ext%.w %2\;ext%.l %2\", operands);
1843 if (GET_CODE (operands[1]) != MEM
1844 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
1845 output_asm_insn (\"move%.l %4,%3\", operands);
1846 return \"sub%.l %2,%3\;subx%.l %2,%0\";
1849 (define_insn "adddi_sexthishl32"
1850 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
1851 (plus:DI (ashift:DI (sign_extend:DI
1852 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
1854 (match_operand:DI 2 "general_operand" "0,0,0,0")))
1855 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
1860 if (ADDRESS_REG_P (operands[0]))
1861 return \"add%.w %1,%0\";
1862 else if (ADDRESS_REG_P (operands[3]))
1863 return \"move%.w %1,%3\;add%.l %3,%0\";
1865 return \"move%.w %1,%3\;ext%.l %3\;add%.l %3,%0\";
1868 (define_insn "adddi_dilshr32"
1869 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
1870 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1871 ;; (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
1872 ;; (const_int 32))))]
1873 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
1875 (match_operand:DI 2 "general_operand" "0,0")))]
1880 if (GET_CODE (operands[0]) == REG)
1881 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1883 operands[2] = adjust_address (operands[0], SImode, 4);
1884 return \"add%.l %1,%2\;negx%.l %0\;neg%.l %0\";
1887 (define_insn "adddi_dishl32"
1888 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
1889 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1890 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
1891 ;; (const_int 32))))]
1892 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
1894 (match_operand:DI 2 "general_operand" "0,0")))]
1899 if (GET_CODE (operands[1]) == REG)
1900 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1902 operands[1] = adjust_address (operands[1], SImode, 4);
1903 return \"add%.l %1,%0\";
1906 (define_insn "adddi3"
1907 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
1908 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0,0")
1909 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
1910 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
1914 if (DATA_REG_P (operands[0]))
1916 if (DATA_REG_P (operands[2]))
1917 return \"add%.l %R2,%R0\;addx%.l %2,%0\";
1918 else if (GET_CODE (operands[2]) == MEM
1919 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
1920 return \"move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0\";
1926 if (GET_CODE (operands[2]) == REG)
1928 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
1931 else if (CONSTANT_P (operands[2]))
1932 split_double (operands[2], &high, &low);
1935 low = adjust_address (operands[2], SImode, 4);
1939 operands[1] = low, operands[2] = high;
1940 xoperands[0] = operands[3];
1941 if (GET_CODE (operands[1]) == CONST_INT
1942 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1943 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
1945 xoperands[1] = operands[2];
1947 output_asm_insn (output_move_simode (xoperands), xoperands);
1948 if (GET_CODE (operands[1]) == CONST_INT)
1950 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
1953 return \"add%.l %1,%R0\;addx%.l %3,%0\";
1955 return \"addq%.l %1,%R0\;addx%.l %3,%0\";
1958 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1960 operands[1] = GEN_INT (-INTVAL (operands[1]));
1962 return \"sub%.l %1,%R0\;subx%.l %3,%0\";
1964 return \"subq%.l %1,%R0\;subx%.l %3,%0\";
1968 return \"add%.l %1,%R0\;addx%.l %3,%0\";
1971 else if (GET_CODE (operands[0]) == MEM)
1973 if (GET_CODE (operands[2]) == MEM
1974 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
1975 return \"add%.l %2,%0\;addx%.l %2,%0\";
1977 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
1979 operands[1] = gen_rtx_MEM (SImode,
1980 plus_constant (XEXP(operands[0], 0), -8));
1981 return \"move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1\";
1983 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
1985 operands[1] = XEXP(operands[0], 0);
1986 return \"add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1\";
1990 operands[1] = adjust_address (operands[0], SImode, 4);
1991 return \"add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0\";
1998 (define_insn "addsi_lshrsi_31"
1999 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2000 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
2006 operands[2] = operands[0];
2007 operands[3] = gen_label_rtx();
2008 if (GET_CODE (operands[0]) == MEM)
2010 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2011 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2012 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2013 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2015 output_asm_insn (\"move%.l %1,%0\", operands);
2017 output_asm_insn (\"jbpl %l3\", operands);
2019 output_asm_insn (\"jpl %l3\", operands);
2022 output_asm_insn (\"addq%.l %#1,%2\", operands);
2024 output_asm_insn (\"add%.l %#1,%2\", operands);
2026 (*targetm.asm_out.internal_label) (asm_out_file, \"L\",
2027 CODE_LABEL_NUMBER (operands[3]));
2031 (define_expand "addsi3"
2032 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2033 (plus:SI (match_operand:SI 1 "general_operand" "")
2034 (match_operand:SI 2 "general_src_operand" "")))]
2038 ;; Note that the middle two alternatives are near-duplicates
2039 ;; in order to handle insns generated by reload.
2040 ;; This is needed since they are not themselves reloaded,
2041 ;; so commutativity won't apply to them.
2042 (define_insn "*addsi3_internal"
2043 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2044 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2045 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2049 "* return output_addsi3 (operands);")
2051 (define_insn "*addsi3_5200"
2052 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
2053 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
2054 (match_operand:SI 2 "general_src_operand" "d,rJK,a,mrIKLs")))]
2056 "* return output_addsi3 (operands);")
2059 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2060 (plus:SI (match_operand:SI 1 "general_operand" "0")
2062 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2066 (define_insn "addhi3"
2067 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2068 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2069 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2073 if (GET_CODE (operands[2]) == CONST_INT)
2076 /* If the constant would be a negative number when interpreted as
2077 HImode, make it negative. This is usually, but not always, done
2078 elsewhere in the compiler. First check for constants out of range,
2079 which could confuse us. */
2081 if (INTVAL (operands[2]) >= 32768)
2082 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2084 if (INTVAL (operands[2]) > 0
2085 && INTVAL (operands[2]) <= 8)
2086 return \"addq%.w %2,%0\";
2087 if (INTVAL (operands[2]) < 0
2088 && INTVAL (operands[2]) >= -8)
2090 operands[2] = GEN_INT (- INTVAL (operands[2]));
2091 return \"subq%.w %2,%0\";
2093 /* On the CPU32 it is faster to use two addqw instructions to
2094 add a small integer (8 < N <= 16) to a register.
2095 Likewise for subqw. */
2096 if (TARGET_CPU32 && REG_P (operands[0]))
2098 if (INTVAL (operands[2]) > 8
2099 && INTVAL (operands[2]) <= 16)
2101 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2102 return \"addq%.w %#8,%0\;addq%.w %2,%0\";
2104 if (INTVAL (operands[2]) < -8
2105 && INTVAL (operands[2]) >= -16)
2107 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2108 return \"subq%.w %#8,%0\;subq%.w %2,%0\";
2112 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2114 return \"lea (%c2,%0),%0\";
2116 return \"lea %0@(%c2),%0\";
2119 return \"add%.w %2,%0\";
2122 ;; These insns must use MATCH_DUP instead of the more expected
2123 ;; use of a matching constraint because the "output" here is also
2124 ;; an input, so you can't use the matching constraint. That also means
2125 ;; that you can't use the "%", so you need patterns with the matched
2126 ;; operand in both positions.
2129 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2130 (plus:HI (match_dup 0)
2131 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2135 if (GET_CODE (operands[1]) == CONST_INT)
2138 /* If the constant would be a negative number when interpreted as
2139 HImode, make it negative. This is usually, but not always, done
2140 elsewhere in the compiler. First check for constants out of range,
2141 which could confuse us. */
2143 if (INTVAL (operands[1]) >= 32768)
2144 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2146 if (INTVAL (operands[1]) > 0
2147 && INTVAL (operands[1]) <= 8)
2148 return \"addq%.w %1,%0\";
2149 if (INTVAL (operands[1]) < 0
2150 && INTVAL (operands[1]) >= -8)
2152 operands[1] = GEN_INT (- INTVAL (operands[1]));
2153 return \"subq%.w %1,%0\";
2155 /* On the CPU32 it is faster to use two addqw instructions to
2156 add a small integer (8 < N <= 16) to a register.
2157 Likewise for subqw. */
2158 if (TARGET_CPU32 && REG_P (operands[0]))
2160 if (INTVAL (operands[1]) > 8
2161 && INTVAL (operands[1]) <= 16)
2163 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2164 return \"addq%.w %#8,%0\;addq%.w %1,%0\";
2166 if (INTVAL (operands[1]) < -8
2167 && INTVAL (operands[1]) >= -16)
2169 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2170 return \"subq%.w %#8,%0\;subq%.w %1,%0\";
2174 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2176 return \"lea (%c1,%0),%0\";
2178 return \"lea %0@(%c1),%0\";
2181 return \"add%.w %1,%0\";
2185 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2186 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2191 if (GET_CODE (operands[1]) == CONST_INT)
2194 /* If the constant would be a negative number when interpreted as
2195 HImode, make it negative. This is usually, but not always, done
2196 elsewhere in the compiler. First check for constants out of range,
2197 which could confuse us. */
2199 if (INTVAL (operands[1]) >= 32768)
2200 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2202 if (INTVAL (operands[1]) > 0
2203 && INTVAL (operands[1]) <= 8)
2204 return \"addq%.w %1,%0\";
2205 if (INTVAL (operands[1]) < 0
2206 && INTVAL (operands[1]) >= -8)
2208 operands[1] = GEN_INT (- INTVAL (operands[1]));
2209 return \"subq%.w %1,%0\";
2211 /* On the CPU32 it is faster to use two addqw instructions to
2212 add a small integer (8 < N <= 16) to a register.
2213 Likewise for subqw. */
2214 if (TARGET_CPU32 && REG_P (operands[0]))
2216 if (INTVAL (operands[1]) > 8
2217 && INTVAL (operands[1]) <= 16)
2219 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2220 return \"addq%.w %#8,%0\;addq%.w %1,%0\";
2222 if (INTVAL (operands[1]) < -8
2223 && INTVAL (operands[1]) >= -16)
2225 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2226 return \"subq%.w %#8,%0\;subq%.w %1,%0\";
2230 if (ADDRESS_REG_P (operands[0]) && !TARGET_68040)
2232 return \"lea (%c1,%0),%0\";
2234 return \"lea %0@(%c1),%0\";
2237 return \"add%.w %1,%0\";
2240 (define_insn "addqi3"
2241 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2242 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2243 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2248 if (GET_CODE (operands[2]) == CONST_INT)
2250 if (INTVAL (operands[2]) >= 128)
2251 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2253 if (INTVAL (operands[2]) > 0
2254 && INTVAL (operands[2]) <= 8)
2255 return \"addq%.b %2,%0\";
2256 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2258 operands[2] = GEN_INT (- INTVAL (operands[2]));
2259 return \"subq%.b %2,%0\";
2263 return \"add%.b %2,%0\";
2267 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2268 (plus:QI (match_dup 0)
2269 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2274 if (GET_CODE (operands[1]) == CONST_INT)
2276 if (INTVAL (operands[1]) >= 128)
2277 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2279 if (INTVAL (operands[1]) > 0
2280 && INTVAL (operands[1]) <= 8)
2281 return \"addq%.b %1,%0\";
2282 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2284 operands[1] = GEN_INT (- INTVAL (operands[1]));
2285 return \"subq%.b %1,%0\";
2289 return \"add%.b %1,%0\";
2293 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2294 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2300 if (GET_CODE (operands[1]) == CONST_INT)
2302 if (INTVAL (operands[1]) >= 128)
2303 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2305 if (INTVAL (operands[1]) > 0
2306 && INTVAL (operands[1]) <= 8)
2307 return \"addq%.b %1,%0\";
2308 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2310 operands[1] = GEN_INT (- INTVAL (operands[1]));
2311 return \"subq%.b %1,%0\";
2315 return \"add%.b %1,%0\";
2318 (define_expand "adddf3"
2319 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2320 (plus:DF (match_operand:DF 1 "general_operand" "")
2321 (match_operand:DF 2 "general_operand" "")))]
2326 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2327 (plus:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2328 (match_operand:DF 1 "general_operand" "0")))]
2333 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2334 (plus:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2335 (match_operand:DF 1 "general_operand" "0")))]
2340 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2341 (plus:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2342 (match_operand:DF 1 "general_operand" "0")))]
2347 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2348 (plus:DF (match_operand:DF 1 "general_operand" "%0")
2349 (match_operand:DF 2 "general_operand" "fmG")))]
2353 if (REG_P (operands[2]))
2354 return \"f%&add%.x %2,%0\";
2355 return \"f%&add%.d %f2,%0\";
2358 (define_expand "addsf3"
2359 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2360 (plus:SF (match_operand:SF 1 "general_operand" "")
2361 (match_operand:SF 2 "general_operand" "")))]
2366 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2367 (plus:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2368 (match_operand:SF 1 "general_operand" "0")))]
2373 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2374 (plus:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2375 (match_operand:SF 1 "general_operand" "0")))]
2380 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2381 (plus:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
2382 (match_operand:SF 1 "general_operand" "0")))]
2387 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2388 (plus:SF (match_operand:SF 1 "general_operand" "%0")
2389 (match_operand:SF 2 "general_operand" "fdmF")))]
2393 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2394 return \"f%$add%.x %2,%0\";
2395 return \"f%$add%.s %f2,%0\";
2398 ;; subtract instructions
2400 (define_insn "subdi_sexthishl32"
2401 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2402 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2403 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2405 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2410 if (ADDRESS_REG_P (operands[0]))
2411 return \"sub%.w %2,%0\";
2412 else if (ADDRESS_REG_P (operands[3]))
2413 return \"move%.w %2,%3\;sub%.l %3,%0\";
2415 return \"move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0\";
2418 (define_insn "subdi_dishl32"
2419 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2420 (minus:DI (match_dup 0)
2421 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2427 if (GET_CODE (operands[1]) == REG)
2428 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2430 operands[1] = adjust_address (operands[1], SImode, 4);
2431 return \"sub%.l %1,%0\";
2434 (define_insn "subdi3"
2435 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
2436 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0,0")
2437 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
2438 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
2442 if (DATA_REG_P (operands[0]))
2444 if (DATA_REG_P (operands[2]))
2445 return \"sub%.l %R2,%R0\;subx%.l %2,%0\";
2446 else if (GET_CODE (operands[2]) == MEM
2447 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2449 return \"move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0\";
2456 if (GET_CODE (operands[2]) == REG)
2458 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2461 else if (CONSTANT_P (operands[2]))
2462 split_double (operands[2], &high, &low);
2465 low = adjust_address (operands[2], SImode, 4);
2469 operands[1] = low, operands[2] = high;
2470 xoperands[0] = operands[3];
2471 if (GET_CODE (operands[1]) == CONST_INT
2472 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2473 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2475 xoperands[1] = operands[2];
2477 output_asm_insn (output_move_simode (xoperands), xoperands);
2478 if (GET_CODE (operands[1]) == CONST_INT)
2480 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2483 return \"sub%.l %1,%R0\;subx%.l %3,%0\";
2485 return \"subq%.l %1,%R0\;subx%.l %3,%0\";
2488 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2490 operands[1] = GEN_INT (-INTVAL (operands[1]));
2492 return \"add%.l %1,%R0\;addx%.l %3,%0\";
2494 return \"addq%.l %1,%R0\;addx%.l %3,%0\";
2498 return \"sub%.l %1,%R0\;subx%.l %3,%0\";
2501 else if (GET_CODE (operands[0]) == MEM)
2503 if (GET_CODE (operands[2]) == MEM
2504 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
2505 return \"sub%.l %2,%0\;subx%.l %2,%0\";
2507 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2510 = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2511 return \"move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1\";
2513 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2515 operands[1] = XEXP(operands[0], 0);
2516 return \"sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1\";
2520 operands[1] = adjust_address (operands[0], SImode, 4);
2521 return \"sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0\";
2528 (define_insn "subsi3"
2529 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2530 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2531 (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2536 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2537 (minus:SI (match_operand:SI 1 "general_operand" "0")
2539 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2543 (define_insn "subhi3"
2544 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2545 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2546 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2551 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2552 (minus:HI (match_dup 0)
2553 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2557 (define_insn "subqi3"
2558 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2559 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2560 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2565 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2566 (minus:QI (match_dup 0)
2567 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2571 (define_expand "subdf3"
2572 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2573 (minus:DF (match_operand:DF 1 "general_operand" "")
2574 (match_operand:DF 2 "general_operand" "")))]
2579 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2580 (minus:DF (match_operand:DF 1 "general_operand" "0")
2581 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
2586 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2587 (minus:DF (match_operand:DF 1 "general_operand" "0")
2588 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
2593 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2594 (minus:DF (match_operand:DF 1 "general_operand" "0")
2595 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
2600 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2601 (minus:DF (match_operand:DF 1 "general_operand" "0")
2602 (match_operand:DF 2 "general_operand" "fmG")))]
2606 if (REG_P (operands[2]))
2607 return \"f%&sub%.x %2,%0\";
2608 return \"f%&sub%.d %f2,%0\";
2611 (define_expand "subsf3"
2612 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2613 (minus:SF (match_operand:SF 1 "general_operand" "")
2614 (match_operand:SF 2 "general_operand" "")))]
2619 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2620 (minus:SF (match_operand:SF 1 "general_operand" "0")
2621 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
2626 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2627 (minus:SF (match_operand:SF 1 "general_operand" "0")
2628 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
2633 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2634 (minus:SF (match_operand:SF 1 "general_operand" "0")
2635 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
2640 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2641 (minus:SF (match_operand:SF 1 "general_operand" "0")
2642 (match_operand:SF 2 "general_operand" "fdmF")))]
2646 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
2647 return \"f%$sub%.x %2,%0\";
2648 return \"f%$sub%.s %f2,%0\";
2651 ;; multiply instructions
2653 (define_insn "mulhi3"
2654 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2655 (mult:HI (match_operand:HI 1 "general_operand" "%0")
2656 (match_operand:HI 2 "general_src_operand" "dmSn")))]
2660 #if defined(MOTOROLA)
2661 return \"muls%.w %2,%0\";
2663 return \"muls %2,%0\";
2667 (define_insn "mulhisi3"
2668 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2669 (mult:SI (sign_extend:SI
2670 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2672 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2676 #if defined(MOTOROLA)
2677 return \"muls%.w %2,%0\";
2679 return \"muls %2,%0\";
2684 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2685 (mult:SI (sign_extend:SI
2686 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2687 (match_operand:SI 2 "const_int_operand" "n")))]
2688 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2691 #if defined(MOTOROLA)
2692 return \"muls%.w %2,%0\";
2694 return \"muls %2,%0\";
2698 (define_expand "mulsi3"
2699 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2700 (mult:SI (match_operand:SI 1 "general_operand" "")
2701 (match_operand:SI 2 "general_operand" "")))]
2702 "TARGET_68020 || TARGET_5200"
2706 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2707 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2708 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2714 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2715 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2716 (match_operand:SI 2 "general_operand" "d<Q>")))]
2720 (define_insn "umulhisi3"
2721 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2722 (mult:SI (zero_extend:SI
2723 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2725 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2729 #if defined(MOTOROLA)
2730 return \"mulu%.w %2,%0\";
2732 return \"mulu %2,%0\";
2737 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2738 (mult:SI (zero_extend:SI
2739 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2740 (match_operand:SI 2 "const_int_operand" "n")))]
2741 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2744 #if defined(MOTOROLA)
2745 return \"mulu%.w %2,%0\";
2747 return \"mulu %2,%0\";
2751 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2752 ;; proper matching constraint. This is because the matching is between
2753 ;; the high-numbered word of the DImode operand[0] and operand[1].
2754 (define_expand "umulsidi3"
2756 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2757 (mult:SI (match_operand:SI 1 "register_operand" "")
2758 (match_operand:SI 2 "register_operand" "")))
2759 (set (subreg:SI (match_dup 0) 0)
2760 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2761 (zero_extend:DI (match_dup 2)))
2762 (const_int 32))))])]
2763 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2767 [(set (match_operand:SI 0 "register_operand" "=d")
2768 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2769 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2770 (set (match_operand:SI 3 "register_operand" "=d")
2771 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2772 (zero_extend:DI (match_dup 2)))
2774 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2777 ; Match immediate case. For 2.4 only match things < 2^31.
2778 ; It's tricky with larger values in these patterns since we need to match
2779 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2782 [(set (match_operand:SI 0 "register_operand" "=d")
2783 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2784 (match_operand:SI 2 "const_int_operand" "n")))
2785 (set (match_operand:SI 3 "register_operand" "=d")
2786 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2789 "TARGET_68020 && !TARGET_68060 && !TARGET_5200
2790 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2793 (define_expand "mulsidi3"
2795 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2796 (mult:SI (match_operand:SI 1 "register_operand" "")
2797 (match_operand:SI 2 "register_operand" "")))
2798 (set (subreg:SI (match_dup 0) 0)
2799 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2800 (sign_extend:DI (match_dup 2)))
2801 (const_int 32))))])]
2802 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2806 [(set (match_operand:SI 0 "register_operand" "=d")
2807 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2808 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2809 (set (match_operand:SI 3 "register_operand" "=d")
2810 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2811 (sign_extend:DI (match_dup 2)))
2813 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2817 [(set (match_operand:SI 0 "register_operand" "=d")
2818 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2819 (match_operand:SI 2 "const_int_operand" "n")))
2820 (set (match_operand:SI 3 "register_operand" "=d")
2821 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2824 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2827 (define_expand "umulsi3_highpart"
2829 [(set (match_operand:SI 0 "register_operand" "")
2832 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2833 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2835 (clobber (match_dup 3))])]
2836 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2839 operands[3] = gen_reg_rtx (SImode);
2841 if (GET_CODE (operands[2]) == CONST_INT)
2843 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2846 /* We have to adjust the operand order for the matching constraints. */
2847 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2848 operands[1], operands[2]));
2854 [(set (match_operand:SI 0 "register_operand" "=d")
2857 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2858 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2860 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2861 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2864 (define_insn "const_umulsi3_highpart"
2865 [(set (match_operand:SI 0 "register_operand" "=d")
2868 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2869 (match_operand:DI 3 "const_uint32_operand" "n"))
2871 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2872 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2875 (define_expand "smulsi3_highpart"
2877 [(set (match_operand:SI 0 "register_operand" "")
2880 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2881 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2883 (clobber (match_dup 3))])]
2884 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2887 operands[3] = gen_reg_rtx (SImode);
2888 if (GET_CODE (operands[2]) == CONST_INT)
2890 /* We have to adjust the operand order for the matching constraints. */
2891 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2892 operands[1], operands[2]));
2898 [(set (match_operand:SI 0 "register_operand" "=d")
2901 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2902 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2904 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2905 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2908 (define_insn "const_smulsi3_highpart"
2909 [(set (match_operand:SI 0 "register_operand" "=d")
2912 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2913 (match_operand:DI 3 "const_sint32_operand" "n"))
2915 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2916 "TARGET_68020 && !TARGET_68060 && !TARGET_5200"
2919 (define_expand "muldf3"
2920 [(set (match_operand:DF 0 "nonimmediate_operand" "")
2921 (mult:DF (match_operand:DF 1 "general_operand" "")
2922 (match_operand:DF 2 "general_operand" "")))]
2927 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2928 (mult:DF (float:DF (match_operand:SI 2 "general_operand" "dmi"))
2929 (match_operand:DF 1 "general_operand" "0")))]
2934 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2935 (mult:DF (float:DF (match_operand:HI 2 "general_operand" "dmn"))
2936 (match_operand:DF 1 "general_operand" "0")))]
2941 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2942 (mult:DF (float:DF (match_operand:QI 2 "general_operand" "dmn"))
2943 (match_operand:DF 1 "general_operand" "0")))]
2948 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2949 (mult:DF (match_operand:DF 1 "general_operand" "%0")
2950 (match_operand:DF 2 "general_operand" "fmG")))]
2954 if (GET_CODE (operands[2]) == CONST_DOUBLE
2955 && floating_exact_log2 (operands[2]) && !TARGET_68040 && !TARGET_68060)
2957 int i = floating_exact_log2 (operands[2]);
2958 operands[2] = GEN_INT (i);
2959 return \"fscale%.l %2,%0\";
2961 if (REG_P (operands[2]))
2962 return \"f%&mul%.x %2,%0\";
2963 return \"f%&mul%.d %f2,%0\";
2966 (define_expand "mulsf3"
2967 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2968 (mult:SF (match_operand:SF 1 "general_operand" "")
2969 (match_operand:SF 2 "general_operand" "")))]
2974 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2975 (mult:SF (float:SF (match_operand:SI 2 "general_operand" "dmi"))
2976 (match_operand:SF 1 "general_operand" "0")))]
2980 return (TARGET_68040_ONLY
2981 ? \"fsmul%.l %2,%0\"
2982 : \"fsglmul%.l %2,%0\");
2986 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2987 (mult:SF (float:SF (match_operand:HI 2 "general_operand" "dmn"))
2988 (match_operand:SF 1 "general_operand" "0")))]
2992 return (TARGET_68040_ONLY
2993 ? \"fsmul%.w %2,%0\"
2994 : \"fsglmul%.w %2,%0\");
2998 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2999 (mult:SF (float:SF (match_operand:QI 2 "general_operand" "dmn"))
3000 (match_operand:SF 1 "general_operand" "0")))]
3004 return (TARGET_68040_ONLY
3005 ? \"fsmul%.b %2,%0\"
3006 : \"fsglmul%.b %2,%0\");
3010 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3011 (mult:SF (match_operand:SF 1 "general_operand" "%0")
3012 (match_operand:SF 2 "general_operand" "fdmF")))]
3016 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
3017 return (TARGET_68040_ONLY
3018 ? \"fsmul%.x %2,%0\"
3019 : \"fsglmul%.x %2,%0\");
3020 return (TARGET_68040_ONLY
3021 ? \"fsmul%.s %f2,%0\"
3022 : \"fsglmul%.s %f2,%0\");
3025 ;; divide instructions
3027 (define_expand "divdf3"
3028 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3029 (div:DF (match_operand:DF 1 "general_operand" "")
3030 (match_operand:DF 2 "general_operand" "")))]
3035 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3036 (div:DF (match_operand:DF 1 "general_operand" "0")
3037 (float:DF (match_operand:SI 2 "general_operand" "dmi"))))]
3042 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3043 (div:DF (match_operand:DF 1 "general_operand" "0")
3044 (float:DF (match_operand:HI 2 "general_operand" "dmn"))))]
3049 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3050 (div:DF (match_operand:DF 1 "general_operand" "0")
3051 (float:DF (match_operand:QI 2 "general_operand" "dmn"))))]
3056 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3057 (div:DF (match_operand:DF 1 "general_operand" "0")
3058 (match_operand:DF 2 "general_operand" "fmG")))]
3062 if (REG_P (operands[2]))
3063 return \"f%&div%.x %2,%0\";
3064 return \"f%&div%.d %f2,%0\";
3067 (define_expand "divsf3"
3068 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3069 (div:SF (match_operand:SF 1 "general_operand" "")
3070 (match_operand:SF 2 "general_operand" "")))]
3075 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3076 (div:SF (match_operand:SF 1 "general_operand" "0")
3077 (float:SF (match_operand:SI 2 "general_operand" "dmi"))))]
3081 return (TARGET_68040_ONLY
3082 ? \"fsdiv%.l %2,%0\"
3083 : \"fsgldiv%.l %2,%0\");
3087 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3088 (div:SF (match_operand:SF 1 "general_operand" "0")
3089 (float:SF (match_operand:HI 2 "general_operand" "dmn"))))]
3093 return (TARGET_68040_ONLY
3094 ? \"fsdiv%.w %2,%0\"
3095 : \"fsgldiv%.w %2,%0\");
3099 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3100 (div:SF (match_operand:SF 1 "general_operand" "0")
3101 (float:SF (match_operand:QI 2 "general_operand" "dmn"))))]
3105 return (TARGET_68040_ONLY
3106 ? \"fsdiv%.b %2,%0\"
3107 : \"fsgldiv%.b %2,%0\");
3111 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3112 (div:SF (match_operand:SF 1 "general_operand" "0")
3113 (match_operand:SF 2 "general_operand" "fdmF")))]
3117 if (REG_P (operands[2]) && ! DATA_REG_P (operands[2]))
3118 return (TARGET_68040_ONLY
3119 ? \"fsdiv%.x %2,%0\"
3120 : \"fsgldiv%.x %2,%0\");
3121 return (TARGET_68040_ONLY
3122 ? \"fsdiv%.s %f2,%0\"
3123 : \"fsgldiv%.s %f2,%0\");
3126 ;; Remainder instructions.
3128 (define_insn "divmodsi4"
3129 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3130 (div:SI (match_operand:SI 1 "general_operand" "0")
3131 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3132 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3133 (mod:SI (match_dup 1) (match_dup 2)))]
3134 "TARGET_68020 && !TARGET_5200"
3137 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3138 return \"divs%.l %2,%0\";
3140 return \"divsl%.l %2,%3:%0\";
3143 (define_insn "udivmodsi4"
3144 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3145 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3146 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3147 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3148 (umod:SI (match_dup 1) (match_dup 2)))]
3149 "TARGET_68020 && !TARGET_5200"
3152 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3153 return \"divu%.l %2,%0\";
3155 return \"divul%.l %2,%3:%0\";
3158 (define_insn "divmodhi4"
3159 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3160 (div:HI (match_operand:HI 1 "general_operand" "0")
3161 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3162 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3163 (mod:HI (match_dup 1) (match_dup 2)))]
3168 output_asm_insn (\"ext%.l %0\;divs%.w %2,%0\", operands);
3170 output_asm_insn (\"extl %0\;divs %2,%0\", operands);
3172 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3175 return \"move%.l %0,%3\;swap %3\";
3181 (define_insn "udivmodhi4"
3182 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3183 (udiv:HI (match_operand:HI 1 "general_operand" "0")
3184 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3185 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3186 (umod:HI (match_dup 1) (match_dup 2)))]
3191 output_asm_insn (\"and%.l %#0xFFFF,%0\;divu%.w %2,%0\", operands);
3193 output_asm_insn (\"and%.l %#0xFFFF,%0\;divu %2,%0\", operands);
3195 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3198 return \"move%.l %0,%3\;swap %3\";
3204 ;; logical-and instructions
3206 ;; "anddi3" is mainly here to help combine().
3207 (define_insn "anddi3"
3208 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3209 (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3210 (match_operand:DI 2 "general_operand" "dn,don")))]
3215 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3216 if (CONSTANT_P (operands[2]))
3220 split_double (operands[2], &hi, &lo);
3222 switch (INTVAL (hi))
3225 output_asm_insn (\"clr%.l %0\", operands);
3233 xoperands[0] = operands[0];
3235 output_asm_insn (output_andsi3 (xoperands), xoperands);
3238 if (GET_CODE (operands[0]) == REG)
3239 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3241 operands[0] = adjust_address (operands[0], SImode, 4);
3242 switch (INTVAL (lo))
3245 output_asm_insn (\"clr%.l %0\", operands);
3253 xoperands[0] = operands[0];
3255 output_asm_insn (output_andsi3 (xoperands), xoperands);
3260 if (GET_CODE (operands[0]) != REG)
3262 operands[1] = adjust_address (operands[0], SImode, 4);
3263 return \"and%.l %2,%0\;and%.l %R2,%1\";
3265 if (GET_CODE (operands[2]) != REG)
3267 operands[1] = adjust_address (operands[2], SImode, 4);
3268 return \"and%.l %2,%0\;and%.l %1,%R0\";
3270 return \"and%.l %2,%0\;and%.l %R2,%R0\";
3273 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3274 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3275 ;; can't allocate pseudos into it.
3277 (define_expand "andsi3"
3278 [(set (match_operand:SI 0 "not_sp_operand" "")
3279 (and:SI (match_operand:SI 1 "general_operand" "")
3280 (match_operand:SI 2 "general_src_operand" "")))]
3284 (define_insn "andsi3_internal"
3285 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3286 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3287 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3291 return output_andsi3 (operands);
3294 (define_insn "andsi3_5200"
3295 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3296 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3297 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3301 (define_insn "andhi3"
3302 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3303 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3304 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3309 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3310 (and:HI (match_dup 0)
3311 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3316 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3317 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3322 (define_insn "andqi3"
3323 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3324 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3325 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3330 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3331 (and:QI (match_dup 0)
3332 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3337 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3338 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3343 ;; inclusive-or instructions
3345 (define_insn "iordi_zext"
3346 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3347 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3348 (match_operand:DI 2 "general_operand" "0,0")))]
3355 if (GET_CODE (operands[0]) == REG)
3356 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3358 operands[0] = adjust_address (operands[0], SImode, 4);
3359 if (GET_MODE (operands[1]) == SImode)
3360 return \"or%.l %1,%0\";
3361 byte_mode = (GET_MODE (operands[1]) == QImode);
3362 if (GET_CODE (operands[0]) == MEM)
3363 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3366 return \"or%.b %1,%0\";
3368 return \"or%.w %1,%0\";
3371 ;; "iordi3" is mainly here to help combine().
3372 (define_insn "iordi3"
3373 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3374 (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3375 (match_operand:DI 2 "general_operand" "dn,don")))]
3380 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3381 if (CONSTANT_P (operands[2]))
3385 split_double (operands[2], &hi, &lo);
3387 switch (INTVAL (hi))
3392 /* FIXME : a scratch register would be welcome here if operand[0]
3393 is not a register */
3394 output_asm_insn (\"move%.l %#-1,%0\", operands);
3400 xoperands[0] = operands[0];
3402 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3405 if (GET_CODE (operands[0]) == REG)
3406 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3408 operands[0] = adjust_address (operands[0], SImode, 4);
3409 switch (INTVAL (lo))
3414 /* FIXME : a scratch register would be welcome here if operand[0]
3415 is not a register */
3416 output_asm_insn (\"move%.l %#-1,%0\", operands);
3422 xoperands[0] = operands[0];
3424 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3429 if (GET_CODE (operands[0]) != REG)
3431 operands[1] = adjust_address (operands[0], SImode, 4);
3432 return \"or%.l %2,%0\;or%.l %R2,%1\";
3434 if (GET_CODE (operands[2]) != REG)
3436 operands[1] = adjust_address (operands[2], SImode, 4);
3437 return \"or%.l %2,%0\;or%.l %1,%R0\";
3439 return \"or%.l %2,%0\;or%.l %R2,%R0\";
3442 (define_expand "iorsi3"
3443 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3444 (ior:SI (match_operand:SI 1 "general_operand" "")
3445 (match_operand:SI 2 "general_src_operand" "")))]
3449 (define_insn "iorsi3_internal"
3450 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3451 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3452 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3456 return output_iorsi3 (operands);
3459 (define_insn "iorsi3_5200"
3460 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3461 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3462 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3466 (define_insn "iorhi3"
3467 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3468 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3469 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3474 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3475 (ior:HI (match_dup 0)
3476 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]