1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
3 ;; 2002, 2003, 2004, 2005, 2006
4 ;; Free Software Foundation, Inc.
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; GCC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
23 ;;- Information about MCF5200 port.
25 ;;- The MCF5200 "ColdFire" architecture is a reduced version of the
26 ;;- 68k ISA. Differences include reduced support for byte and word
27 ;;- operands and the removal of BCD, bitfield, rotate, and integer
28 ;;- divide instructions. The TARGET_COLDFIRE flag turns the use of the
29 ;;- removed opcodes and addressing modes off.
33 ;;- instruction definitions
35 ;;- @@The original PO technology requires these to be ordered by speed,
36 ;;- @@ so that assigner will pick the fastest.
38 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
40 ;;- When naming insn's (operand 0 of define_insn) be careful about using
41 ;;- names from other targets machine descriptions.
43 ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
44 ;;- updates for most instructions.
46 ;;- Operand classes for the register allocator:
47 ;;- 'a' one of the address registers can be used.
48 ;;- 'd' one of the data registers can be used.
49 ;;- 'f' one of the m68881/fpu registers can be used
50 ;;- 'r' either a data or an address register can be used.
52 ;;- Immediate Floating point operator constraints
53 ;;- 'G' a floating point constant that is *NOT* one of the standard
54 ;; 68881 constant values (to force calling output_move_const_double
55 ;; to get it from rom if it is a 68881 constant).
57 ;; See the functions standard_XXX_constant_p in output-m68k.c for more
60 ;;- Immediate integer operand constraints:
62 ;;- 'J' -32768 .. 32767
63 ;;- 'K' all integers EXCEPT -128 .. 127
65 ;;- 'M' all integers EXCEPT -256 .. 255
71 ;;- "%." size separator ("." or "") move%.l d0,d1
72 ;;- "%-" push operand "sp@-" move%.l d0,%-
73 ;;- "%+" pop operand "sp@+" move%.l d0,%+
74 ;;- "%@" top of stack "sp@" move%.l d0,%@
75 ;;- "%!" fpcr register
76 ;;- "%$" single-precision fp specifier ("s" or "") f%$add.x fp0,fp1
77 ;;- "%&" double-precision fp specifier ("d" or "") f%&add.x fp0,fp1
79 ;;- Information about 68040 port.
81 ;;- The 68040 executes all 68030 and 68881/2 instructions, but some must
82 ;;- be emulated in software by the OS. It is faster to avoid these
83 ;;- instructions and issue a library call rather than trapping into
84 ;;- the kernel. The affected instructions are fintrz and fscale. The
85 ;;- TUNE_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
95 ;;- These new instructions aren't directly in the md. They are brought
96 ;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather
99 ;;- Information about 68060 port.
101 ;;- The 68060 executes all 68030 and 68881/2 instructions, but some must
102 ;;- be emulated in software by the OS. It is faster to avoid these
103 ;;- instructions and issue a library call rather than trapping into
104 ;;- the kernel. The affected instructions are: divs.l <ea>,Dr:Dq;
105 ;;- divu.l <ea>,Dr:Dq; muls.l <ea>,Dr:Dq; mulu.l <ea>,Dr:Dq; and
106 ;;- fscale. The TUNE_68060 flag turns the use of the opcodes off.
108 ;;- Some of these insn's are composites of several m68000 op codes.
109 ;;- The assembler (or final @@??) insures that the appropriate one is
119 ;; UNSPEC_VOLATILE usage:
122 [(UNSPECV_BLOCKAGE 0)
125 ;; Registers by name.
131 (include "predicates.md")
133 ;; Mode macros for floating point operations.
134 ;; Valid floating point modes
135 (define_mode_macro FP [SF DF (XF "TARGET_68881")])
136 ;; Mnemonic infix to round result
137 (define_mode_attr round [(SF "%$") (DF "%&") (XF "")])
138 ;; Mnemonic infix to round result for mul or div instruction
139 (define_mode_attr round_mul [(SF "sgl") (DF "%&") (XF "")])
140 ;; Suffix specifying source operand format
141 (define_mode_attr prec [(SF "s") (DF "d") (XF "x")])
142 ;; Allowable D registers
143 (define_mode_attr dreg [(SF "d") (DF "") (XF "")])
144 ;; Allowable 68881 constant constraints
145 (define_mode_attr const [(SF "F") (DF "G") (XF "")])
148 [(set (match_operand:DF 0 "push_operand" "=m")
149 (match_operand:DF 1 "general_operand" "ro<>fyE"))]
152 if (FP_REG_P (operands[1]))
153 return "fmove%.d %f1,%0";
154 return output_move_double (operands);
157 (define_insn "pushdi"
158 [(set (match_operand:DI 0 "push_operand" "=m")
159 (match_operand:DI 1 "general_operand" "ro<>Fyi"))]
162 return output_move_double (operands);
165 ;; We don't want to allow a constant operand for test insns because
166 ;; (set (cc0) (const_int foo)) has no mode information. Such insns will
167 ;; be folded while optimizing anyway.
169 (define_expand "tstdi"
170 [(parallel [(set (cc0)
171 (match_operand:DI 0 "nonimmediate_operand" ""))
172 (clobber (match_scratch:SI 1 ""))
173 (clobber (match_scratch:DI 2 ""))])]
175 "m68k_last_compare_had_fp_operands = 0;")
179 (match_operand:DI 0 "nonimmediate_operand" "am,d"))
180 (clobber (match_scratch:SI 1 "=X,d"))
181 (clobber (match_scratch:DI 2 "=d,X"))]
184 if (which_alternative == 0)
188 xoperands[0] = operands[2];
189 xoperands[1] = operands[0];
190 output_move_double (xoperands);
191 cc_status.flags |= CC_REVERSED;
192 return "neg%.l %R2\;negx%.l %2";
194 if (find_reg_note (insn, REG_DEAD, operands[0]))
196 cc_status.flags |= CC_REVERSED;
197 return "neg%.l %R0\;negx%.l %0";
201 'sub' clears %1, and also clears the X cc bit
202 'tst' sets the Z cc bit according to the low part of the DImode operand
203 'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part.
205 return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
208 (define_expand "tstsi"
210 (match_operand:SI 0 "nonimmediate_operand" ""))]
212 "m68k_last_compare_had_fp_operands = 0;")
216 (match_operand:SI 0 "nonimmediate_operand" "rm"))]
219 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
221 /* If you think that the 68020 does not support tstl a0,
222 reread page B-167 of the 68020 manual more carefully. */
223 /* On an address reg, cmpw may replace cmpl. */
224 return "cmp%.w #0,%0";
227 ;; This can't use an address register, because comparisons
228 ;; with address registers as second operand always test the whole word.
229 (define_expand "tsthi"
231 (match_operand:HI 0 "nonimmediate_operand" ""))]
233 "m68k_last_compare_had_fp_operands = 0;")
237 (match_operand:HI 0 "nonimmediate_operand" "dm"))]
241 (define_expand "tstqi"
243 (match_operand:QI 0 "nonimmediate_operand" ""))]
245 "m68k_last_compare_had_fp_operands = 0;")
249 (match_operand:QI 0 "nonimmediate_operand" "dm"))]
253 (define_expand "tst<mode>"
255 (match_operand:FP 0 "general_operand" ""))]
258 m68k_last_compare_had_fp_operands = 1;
261 (define_insn "tst<mode>_68881"
263 (match_operand:FP 0 "general_operand" "f<FP:dreg>m"))]
266 cc_status.flags = CC_IN_68881;
267 if (FP_REG_P (operands[0]))
269 return "ftst%.<FP:prec> %0";
272 (define_insn "tst<mode>_cf"
274 (match_operand:FP 0 "general_operand" "f<FP:dreg><Q>U"))]
275 "TARGET_COLDFIRE_FPU"
277 cc_status.flags = CC_IN_68881;
278 if (FP_REG_P (operands[0]))
280 return "ftst%.<FP:prec> %0";
284 ;; compare instructions.
286 (define_expand "cmpdi"
289 (compare (match_operand:DI 0 "nonimmediate_operand" "")
290 (match_operand:DI 1 "general_operand" "")))
291 (clobber (match_dup 2))])]
293 "m68k_last_compare_had_fp_operands = 0; operands[2] = gen_reg_rtx (DImode);")
297 (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
298 (match_operand:DI 2 "general_operand" "d,0")))
299 (clobber (match_operand:DI 0 "register_operand" "=d,d"))]
302 if (rtx_equal_p (operands[0], operands[1]))
303 return "sub%.l %R2,%R0\;subx%.l %2,%0";
306 cc_status.flags |= CC_REVERSED;
307 return "sub%.l %R1,%R0\;subx%.l %1,%0";
311 (define_expand "cmpsi"
313 (compare (match_operand:SI 0 "nonimmediate_operand" "")
314 (match_operand:SI 1 "general_operand" "")))]
317 m68k_last_compare_had_fp_operands = 0;
320 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
323 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
324 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
327 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
328 return "cmpm%.l %1,%0";
329 if (REG_P (operands[1])
330 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
332 cc_status.flags |= CC_REVERSED;
333 return "cmp%.l %d0,%d1";
335 if (ADDRESS_REG_P (operands[0])
336 && GET_CODE (operands[1]) == CONST_INT
337 && INTVAL (operands[1]) < 0x8000
338 && INTVAL (operands[1]) >= -0x8000)
339 return "cmp%.w %1,%0";
340 return "cmp%.l %d1,%d0";
345 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
346 (match_operand:SI 1 "general_operand" "r,mrKs")))]
349 if (REG_P (operands[1])
350 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
352 cc_status.flags |= CC_REVERSED;
353 return "cmp%.l %d0,%d1";
355 return "cmp%.l %d1,%d0";
358 (define_expand "cmphi"
360 (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
361 (match_operand:HI 1 "general_src_operand" "")))]
363 "m68k_last_compare_had_fp_operands = 0;")
367 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
368 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
371 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
372 return "cmpm%.w %1,%0";
373 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
374 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
376 cc_status.flags |= CC_REVERSED;
377 return "cmp%.w %d0,%d1";
379 return "cmp%.w %d1,%d0";
382 (define_expand "cmpqi"
384 (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
385 (match_operand:QI 1 "general_src_operand" "")))]
387 "m68k_last_compare_had_fp_operands = 0;")
391 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
392 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
395 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
396 return "cmpm%.b %1,%0";
397 if (REG_P (operands[1])
398 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
400 cc_status.flags |= CC_REVERSED;
401 return "cmp%.b %d0,%d1";
403 return "cmp%.b %d1,%d0";
406 (define_expand "cmp<mode>"
408 (compare (match_operand:FP 0 "general_operand" "")
409 (match_operand:FP 1 "general_operand" "")))]
412 m68k_last_compare_had_fp_operands = 1;
413 if (TARGET_COLDFIRE && !reload_completed)
414 operands[1] = force_reg (<MODE>mode, operands[1]);
417 (define_insn "cmp<mode>_68881"
419 (compare (match_operand:FP 0 "general_operand" "f,m<FP:const>")
420 (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,f")))]
423 cc_status.flags = CC_IN_68881;
424 if (FP_REG_P (operands[0]))
426 if (FP_REG_P (operands[1]))
427 return "fcmp%.x %1,%0";
429 return "fcmp%.<FP:prec> %f1,%0";
431 cc_status.flags |= CC_REVERSED;
432 return "fcmp%.<FP:prec> %f0,%1";
435 (define_insn "cmp<mode>_cf"
437 (compare (match_operand:FP 0 "general_operand" "f,<FP:dreg><Q>U")
438 (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,f")))]
439 "TARGET_COLDFIRE_FPU"
441 cc_status.flags = CC_IN_68881;
442 if (FP_REG_P (operands[0]))
444 if (FP_REG_P (operands[1]))
445 return "fcmp%.d %1,%0";
447 return "fcmp%.<FP:prec> %f1,%0";
449 cc_status.flags |= CC_REVERSED;
450 return "fcmp%.<FP:prec> %f0,%1";
453 ;; Recognizers for btst instructions.
455 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
456 ;; specified as a constant, so we must disable all patterns that may extract
457 ;; from a MEM at a constant bit position if we can't use this as a constraint.
460 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
462 (minus:SI (const_int 7)
463 (match_operand:SI 1 "general_operand" "di"))))]
466 return output_btst (operands, operands[1], operands[0], insn, 7);
469 ;; This is the same as the above pattern except for the constraints. The 'i'
473 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
475 (minus:SI (const_int 7)
476 (match_operand:SI 1 "general_operand" "d"))))]
479 return output_btst (operands, operands[1], operands[0], insn, 7);
483 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
485 (minus:SI (const_int 31)
486 (match_operand:SI 1 "general_operand" "di"))))]
489 return output_btst (operands, operands[1], operands[0], insn, 31);
492 ;; The following two patterns are like the previous two
493 ;; except that they use the fact that bit-number operands
494 ;; are automatically masked to 3 or 5 bits.
497 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
499 (minus:SI (const_int 7)
501 (match_operand:SI 1 "register_operand" "d")
505 return output_btst (operands, operands[1], operands[0], insn, 7);
509 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
511 (minus:SI (const_int 31)
513 (match_operand:SI 1 "register_operand" "d")
517 return output_btst (operands, operands[1], operands[0], insn, 31);
520 ;; Nonoffsettable mem refs are ok in this one pattern
521 ;; since we don't try to adjust them.
523 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
525 (match_operand:SI 1 "const_int_operand" "n")))]
526 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
528 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
529 return output_btst (operands, operands[1], operands[0], insn, 7);
533 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
535 (match_operand:SI 1 "const_int_operand" "n")))]
538 if (GET_CODE (operands[0]) == MEM)
540 operands[0] = adjust_address (operands[0], QImode,
541 INTVAL (operands[1]) / 8);
542 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
543 return output_btst (operands, operands[1], operands[0], insn, 7);
545 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
546 return output_btst (operands, operands[1], operands[0], insn, 31);
549 ;; This is the same as the above pattern except for the constraints.
550 ;; The 'o' has been replaced with 'Q'.
553 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
555 (match_operand:SI 1 "const_int_operand" "n")))]
558 if (GET_CODE (operands[0]) == MEM)
560 operands[0] = adjust_address (operands[0], QImode,
561 INTVAL (operands[1]) / 8);
562 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
563 return output_btst (operands, operands[1], operands[0], insn, 7);
565 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
566 return output_btst (operands, operands[1], operands[0], insn, 31);
572 ;; A special case in which it is not desirable
573 ;; to reload the constant into a data register.
574 (define_insn "pushexthisi_const"
575 [(set (match_operand:SI 0 "push_operand" "=m")
576 (match_operand:SI 1 "const_int_operand" "J"))]
577 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
579 if (operands[1] == const0_rtx)
581 if (valid_mov3q_const(operands[1]))
582 return "mov3q%.l %1,%-";
587 ;(define_insn "swapsi"
588 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
589 ; (match_operand:SI 1 "general_operand" "+r"))
590 ; (set (match_dup 1) (match_dup 0))]
594 ;; Special case of fullword move when source is zero.
595 ;; The reason this is special is to avoid loading a zero
596 ;; into a data reg with moveq in order to store it elsewhere.
598 (define_insn "movsi_const0"
599 [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
601 ;; clr insns on 68000 read before writing.
602 "((TARGET_68010 || TARGET_COLDFIRE)
603 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
605 if (ADDRESS_REG_P (operands[0]))
607 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
609 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
611 return "sub%.l %0,%0";
613 /* moveq is faster on the 68000. */
614 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
615 return "moveq #0,%0";
619 ;; General case of fullword move.
621 ;; This is the main "hook" for PIC code. When generating
622 ;; PIC, movsi is responsible for determining when the source address
623 ;; needs PIC relocation and appropriately calling legitimize_pic_address
624 ;; to perform the actual relocation.
626 ;; In both the PIC and non-PIC cases the patterns generated will
627 ;; matched by the next define_insn.
628 (define_expand "movsi"
629 [(set (match_operand:SI 0 "nonimmediate_operand" "")
630 (match_operand:SI 1 "general_operand" ""))]
633 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
635 /* The source is an address which requires PIC relocation.
636 Call legitimize_pic_address with the source, mode, and a relocation
637 register (a new pseudo, or the final destination if reload_in_progress
638 is set). Then fall through normally */
639 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
640 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
642 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
644 /* Don't allow writes to memory except via a register;
645 the m68k doesn't consider PC-relative addresses to be writable. */
646 if (symbolic_operand (operands[0], SImode))
647 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
648 else if (GET_CODE (operands[0]) == MEM
649 && symbolic_operand (XEXP (operands[0], 0), SImode))
650 operands[0] = gen_rtx_MEM (SImode,
651 force_reg (SImode, XEXP (operands[0], 0)));
655 ;; General case of fullword move. The register constraints
656 ;; force integer constants in range for a moveq to be reloaded
657 ;; if they are headed for memory.
659 ;; Notes: make sure no alternative allows g vs g.
660 ;; We don't allow f-regs since fixed point cannot go in them.
661 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
662 (match_operand:SI 1 "general_src_operand" "daymSKT,n,i"))]
666 return output_move_simode (operands);
669 (define_insn "*movsi_cf"
670 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
671 (match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
672 "TARGET_COLDFIRE && !TARGET_ISAB"
673 "* return output_move_simode (operands);")
675 (define_insn "*movsi_cfv4"
676 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
677 (match_operand:SI 1 "general_operand" "Rg,Rr<Q>,U"))]
679 "* return output_move_simode (operands);")
681 ;; Special case of fullword move, where we need to get a non-GOT PIC
682 ;; reference into an address register.
684 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
685 (match_operand:SI 1 "pcrel_address" ""))]
688 if (push_operand (operands[0], SImode))
693 (define_expand "movhi"
694 [(set (match_operand:HI 0 "nonimmediate_operand" "")
695 (match_operand:HI 1 "general_operand" ""))]
700 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
701 (match_operand:HI 1 "general_src_operand" "gS"))]
703 "* return output_move_himode (operands);")
706 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
707 (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
709 "* return output_move_himode (operands);")
711 (define_expand "movstricthi"
712 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
713 (match_operand:HI 1 "general_src_operand" ""))]
718 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
719 (match_operand:HI 1 "general_src_operand" "rmSn"))]
721 "* return output_move_stricthi (operands);")
724 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
725 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
727 "* return output_move_stricthi (operands);")
729 (define_expand "movqi"
730 [(set (match_operand:QI 0 "nonimmediate_operand" "")
731 (match_operand:QI 1 "general_src_operand" ""))]
736 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
737 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
739 "* return output_move_qimode (operands);")
742 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
743 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
745 "* return output_move_qimode (operands);")
747 (define_expand "movstrictqi"
748 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
749 (match_operand:QI 1 "general_src_operand" ""))]
754 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
755 (match_operand:QI 1 "general_src_operand" "dmSn"))]
757 "* return output_move_strictqi (operands);")
760 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d,m"))
761 (match_operand:QI 1 "general_src_operand" "dmn,d"))]
763 "* return output_move_strictqi (operands);")
765 (define_expand "pushqi1"
766 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
767 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
768 (match_operand:QI 0 "general_operand" ""))]
772 (define_expand "reload_insf"
773 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
774 (match_operand:SF 1 "general_operand" "mf"))
775 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
776 "TARGET_COLDFIRE_FPU"
778 if (emit_move_sequence (operands, SFmode, operands[2]))
781 /* We don't want the clobber emitted, so handle this ourselves. */
782 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
786 (define_expand "reload_outsf"
787 [(set (match_operand:SF 0 "general_operand" "")
788 (match_operand:SF 1 "register_operand" "f"))
789 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
790 "TARGET_COLDFIRE_FPU"
792 if (emit_move_sequence (operands, SFmode, operands[2]))
795 /* We don't want the clobber emitted, so handle this ourselves. */
796 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
800 (define_expand "movsf"
801 [(set (match_operand:SF 0 "nonimmediate_operand" "")
802 (match_operand:SF 1 "general_operand" ""))]
807 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
808 (match_operand:SF 1 "general_operand" "rmfF"))]
811 if (FP_REG_P (operands[0]))
813 if (FP_REG_P (operands[1]))
814 return "f%$move%.x %1,%0";
815 else if (ADDRESS_REG_P (operands[1]))
816 return "move%.l %1,%-\;f%$move%.s %+,%0";
817 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
818 return output_move_const_single (operands);
819 return "f%$move%.s %f1,%0";
821 if (FP_REG_P (operands[1]))
823 if (ADDRESS_REG_P (operands[0]))
824 return "fmove%.s %1,%-\;move%.l %+,%0";
825 return "fmove%.s %f1,%0";
827 if (operands[1] == CONST0_RTX (SFmode)
828 /* clr insns on 68000 read before writing. */
829 && ((TARGET_68010 || TARGET_COLDFIRE)
830 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
832 if (ADDRESS_REG_P (operands[0]))
834 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
836 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
838 return "sub%.l %0,%0";
840 /* moveq is faster on the 68000. */
841 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
842 return "moveq #0,%0";
845 return "move%.l %1,%0";
848 (define_insn "movsf_cf_soft"
849 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,g")
850 (match_operand:SF 1 "general_operand" "g,r"))]
851 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
853 return "move%.l %1,%0";
856 (define_insn "movsf_cf_hard"
857 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f, f,mr,f,r<Q>,f
859 (match_operand:SF 1 "general_operand" " f, r<Q>U,f,rm,F,F, m
861 "TARGET_COLDFIRE_FPU"
863 if (which_alternative == 4 || which_alternative == 5) {
867 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
868 REAL_VALUE_TO_TARGET_SINGLE (r, l);
869 xoperands[0] = operands[0];
870 xoperands[1] = GEN_INT (l);
871 if (which_alternative == 5) {
873 if (ADDRESS_REG_P (xoperands[0]))
874 output_asm_insn ("sub%.l %0,%0", xoperands);
876 output_asm_insn ("clr%.l %0", xoperands);
878 if (GET_CODE (operands[0]) == MEM
879 && symbolic_operand (XEXP (operands[0], 0), SImode))
880 output_asm_insn ("move%.l %1,%-;move%.l %+,%0", xoperands);
882 output_asm_insn ("move%.l %1,%0", xoperands);
886 output_asm_insn ("move%.l %1,%-;fsmove%.s %+,%0", xoperands);
888 output_asm_insn ("clr%.l %-;fsmove%.s %+,%0", xoperands);
891 if (FP_REG_P (operands[0]))
893 if (ADDRESS_REG_P (operands[1]))
894 return "move%.l %1,%-;fsmove%.s %+,%0";
895 if (FP_REG_P (operands[1]))
896 return "fsmove%.d %1,%0";
897 return "fsmove%.s %f1,%0";
899 if (FP_REG_P (operands[1]))
901 if (ADDRESS_REG_P (operands[0]))
902 return "fmove%.s %1,%-;move%.l %+,%0";
903 return "fmove%.s %f1,%0";
905 if (operands[1] == CONST0_RTX (SFmode))
907 if (ADDRESS_REG_P (operands[0]))
908 return "sub%.l %0,%0";
911 return "move%.l %1,%0";
914 (define_expand "reload_indf"
915 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
916 (match_operand:DF 1 "general_operand" "mf"))
917 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
918 "TARGET_COLDFIRE_FPU"
920 if (emit_move_sequence (operands, DFmode, operands[2]))
923 /* We don't want the clobber emitted, so handle this ourselves. */
924 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
928 (define_expand "reload_outdf"
929 [(set (match_operand:DF 0 "general_operand" "")
930 (match_operand:DF 1 "register_operand" "f"))
931 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
932 "TARGET_COLDFIRE_FPU"
934 if (emit_move_sequence (operands, DFmode, operands[2]))
937 /* We don't want the clobber emitted, so handle this ourselves. */
938 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
942 (define_expand "movdf"
943 [(set (match_operand:DF 0 "nonimmediate_operand" "")
944 (match_operand:DF 1 "general_operand" ""))]
947 if (TARGET_COLDFIRE_FPU)
948 if (emit_move_sequence (operands, DFmode, 0))
953 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
954 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
955 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
956 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
959 if (FP_REG_P (operands[0]))
961 if (FP_REG_P (operands[1]))
962 return "f%&move%.x %1,%0";
963 if (REG_P (operands[1]))
966 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
967 output_asm_insn ("move%.l %1,%-", xoperands);
968 output_asm_insn ("move%.l %1,%-", operands);
969 return "f%&move%.d %+,%0";
971 if (GET_CODE (operands[1]) == CONST_DOUBLE)
972 return output_move_const_double (operands);
973 return "f%&move%.d %f1,%0";
975 else if (FP_REG_P (operands[1]))
977 if (REG_P (operands[0]))
979 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
980 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
981 return "move%.l %+,%0";
984 return "fmove%.d %f1,%0";
986 return output_move_double (operands);
989 (define_insn "movdf_cf_soft"
990 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
991 (match_operand:DF 1 "general_operand" "g,r"))]
992 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
994 return output_move_double (operands);
997 (define_insn "movdf_cf_hard"
998 [(set (match_operand:DF 0 "nonimmediate_operand" "=f, <Q>U,r,f,r,r,m,f")
999 (match_operand:DF 1 "general_operand" " f<Q>U,f, f,r,r,m,r,E"))]
1000 "TARGET_COLDFIRE_FPU"
1006 switch (which_alternative)
1009 return "fdmove%.d %1,%0";
1011 return "fmove%.d %1,%0";
1013 return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1015 return "move%.l %R1,%-;move%.l %1,%-;fdmove%.d %+,%0";
1016 case 4: case 5: case 6:
1017 return output_move_double (operands);
1019 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1020 REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1021 xoperands[0] = operands[0];
1022 xoperands[1] = GEN_INT (l[0]);
1023 xoperands[2] = GEN_INT (l[1]);
1024 if (operands[1] == CONST0_RTX (DFmode))
1025 output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1029 output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1032 output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1038 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1039 ;; allowed. Most but not all have predicates and constraint that disallow
1040 ;; constants. Most but not all have output templates that handle constants.
1041 ;; See also LEGITIMATE_CONSTANT_P.
1043 (define_expand "movxf"
1044 [(set (match_operand:XF 0 "nonimmediate_operand" "")
1045 (match_operand:XF 1 "general_operand" ""))]
1048 /* We can't rewrite operands during reload. */
1049 if (! reload_in_progress)
1051 if (CONSTANT_P (operands[1]))
1053 operands[1] = force_const_mem (XFmode, operands[1]);
1054 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1055 operands[1] = adjust_address (operands[1], XFmode, 0);
1057 if (flag_pic && TARGET_PCREL)
1059 /* Don't allow writes to memory except via a register; the
1060 m68k doesn't consider PC-relative addresses to be writable. */
1061 if (GET_CODE (operands[0]) == MEM
1062 && symbolic_operand (XEXP (operands[0], 0), SImode))
1063 operands[0] = gen_rtx_MEM (XFmode,
1064 force_reg (SImode, XEXP (operands[0], 0)));
1070 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1071 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1074 if (FP_REG_P (operands[0]))
1076 if (FP_REG_P (operands[1]))
1077 return "fmove%.x %1,%0";
1078 if (REG_P (operands[1]))
1081 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1082 output_asm_insn ("move%.l %1,%-", xoperands);
1083 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1084 output_asm_insn ("move%.l %1,%-", xoperands);
1085 output_asm_insn ("move%.l %1,%-", operands);
1086 return "fmove%.x %+,%0";
1088 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1089 return "fmove%.x %1,%0";
1090 return "fmove%.x %f1,%0";
1092 if (FP_REG_P (operands[1]))
1094 if (REG_P (operands[0]))
1096 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1097 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1098 output_asm_insn ("move%.l %+,%0", operands);
1099 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1100 return "move%.l %+,%0";
1102 /* Must be memory destination. */
1103 return "fmove%.x %f1,%0";
1105 return output_move_double (operands);
1109 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1110 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1111 "! TARGET_68881 && ! TARGET_COLDFIRE"
1113 if (FP_REG_P (operands[0]))
1115 if (FP_REG_P (operands[1]))
1116 return "fmove%.x %1,%0";
1117 if (REG_P (operands[1]))
1120 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1121 output_asm_insn ("move%.l %1,%-", xoperands);
1122 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1123 output_asm_insn ("move%.l %1,%-", xoperands);
1124 output_asm_insn ("move%.l %1,%-", operands);
1125 return "fmove%.x %+,%0";
1127 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1128 return "fmove%.x %1,%0";
1129 return "fmove%.x %f1,%0";
1131 if (FP_REG_P (operands[1]))
1133 if (REG_P (operands[0]))
1135 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1136 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1137 output_asm_insn ("move%.l %+,%0", operands);
1138 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1139 return "move%.l %+,%0";
1142 return "fmove%.x %f1,%0";
1144 return output_move_double (operands);
1148 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1149 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1150 "! TARGET_68881 && TARGET_COLDFIRE"
1151 "* return output_move_double (operands);")
1153 (define_expand "movdi"
1154 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1155 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1156 (match_operand:DI 1 "general_operand" ""))]
1160 ;; movdi can apply to fp regs in some cases
1162 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1163 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1164 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1165 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1166 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1167 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1168 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1171 if (FP_REG_P (operands[0]))
1173 if (FP_REG_P (operands[1]))
1174 return "fmove%.x %1,%0";
1175 if (REG_P (operands[1]))
1178 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1179 output_asm_insn ("move%.l %1,%-", xoperands);
1180 output_asm_insn ("move%.l %1,%-", operands);
1181 return "fmove%.d %+,%0";
1183 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1184 return output_move_const_double (operands);
1185 return "fmove%.d %f1,%0";
1187 else if (FP_REG_P (operands[1]))
1189 if (REG_P (operands[0]))
1191 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1192 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1193 return "move%.l %+,%0";
1196 return "fmove%.d %f1,%0";
1198 return output_move_double (operands);
1202 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1203 (match_operand:DI 1 "general_operand" "g,r"))]
1205 "* return output_move_double (operands);")
1207 ;; Thus goes after the move instructions
1208 ;; because the move instructions are better (require no spilling)
1209 ;; when they can apply. It goes before the add/sub insns
1210 ;; so we will prefer it to them.
1212 (define_insn "pushasi"
1213 [(set (match_operand:SI 0 "push_operand" "=m")
1214 (match_operand:SI 1 "address_operand" "p"))]
1218 ;; truncation instructions
1219 (define_insn "truncsiqi2"
1220 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1222 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1225 if (GET_CODE (operands[0]) == REG)
1227 /* Must clear condition codes, since the move.l bases them on
1228 the entire 32 bits, not just the desired 8 bits. */
1230 return "move%.l %1,%0";
1232 if (GET_CODE (operands[1]) == MEM)
1233 operands[1] = adjust_address (operands[1], QImode, 3);
1234 return "move%.b %1,%0";
1237 (define_insn "trunchiqi2"
1238 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1240 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1243 if (GET_CODE (operands[0]) == REG
1244 && (GET_CODE (operands[1]) == MEM
1245 || GET_CODE (operands[1]) == CONST_INT))
1247 /* Must clear condition codes, since the move.w bases them on
1248 the entire 16 bits, not just the desired 8 bits. */
1250 return "move%.w %1,%0";
1252 if (GET_CODE (operands[0]) == REG)
1254 /* Must clear condition codes, since the move.l bases them on
1255 the entire 32 bits, not just the desired 8 bits. */
1257 return "move%.l %1,%0";
1259 if (GET_CODE (operands[1]) == MEM)
1260 operands[1] = adjust_address (operands[1], QImode, 1);
1261 return "move%.b %1,%0";
1264 (define_insn "truncsihi2"
1265 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1267 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1270 if (GET_CODE (operands[0]) == REG)
1272 /* Must clear condition codes, since the move.l bases them on
1273 the entire 32 bits, not just the desired 8 bits. */
1275 return "move%.l %1,%0";
1277 if (GET_CODE (operands[1]) == MEM)
1278 operands[1] = adjust_address (operands[1], QImode, 2);
1279 return "move%.w %1,%0";
1282 ;; zero extension instructions
1284 ;; two special patterns to match various post_inc/pre_dec patterns
1285 (define_insn_and_split "*zero_extend_inc"
1286 [(set (match_operand 0 "post_inc_operand" "")
1287 (zero_extend (match_operand 1 "register_operand" "")))]
1288 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1289 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1290 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1298 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1301 (define_insn_and_split "*zero_extend_dec"
1302 [(set (match_operand 0 "pre_dec_operand" "")
1303 (zero_extend (match_operand 1 "register_operand" "")))]
1304 "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1305 GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1306 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1307 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1315 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1318 (define_insn_and_split "zero_extendqidi2"
1319 [(set (match_operand:DI 0 "register_operand" "")
1320 (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1325 (zero_extend:SI (match_dup 1)))
1329 operands[2] = gen_lowpart (SImode, operands[0]);
1330 operands[3] = gen_highpart (SImode, operands[0]);
1333 (define_insn_and_split "zero_extendhidi2"
1334 [(set (match_operand:DI 0 "register_operand" "")
1335 (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1340 (zero_extend:SI (match_dup 1)))
1344 operands[2] = gen_lowpart (SImode, operands[0]);
1345 operands[3] = gen_highpart (SImode, operands[0]);
1348 (define_expand "zero_extendsidi2"
1349 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1350 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1353 if (GET_CODE (operands[0]) == MEM
1354 && GET_CODE (operands[1]) == MEM)
1355 operands[1] = force_reg (SImode, operands[1]);
1358 (define_insn_and_split "*zero_extendsidi2"
1359 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1360 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1361 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1369 operands[2] = gen_lowpart (SImode, operands[0]);
1370 operands[3] = gen_highpart (SImode, operands[0]);
1373 (define_insn "*zero_extendhisi2_cf"
1374 [(set (match_operand:SI 0 "register_operand" "=d")
1375 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1379 (define_insn "zero_extendhisi2"
1380 [(set (match_operand:SI 0 "register_operand" "=d")
1381 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1385 (define_expand "zero_extendqihi2"
1386 [(set (match_operand:HI 0 "register_operand" "")
1387 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1391 (define_insn "*zero_extendqihi2"
1392 [(set (match_operand:HI 0 "register_operand" "=d")
1393 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1397 (define_insn "*zero_extendqisi2_cfv4"
1398 [(set (match_operand:SI 0 "register_operand" "=d")
1399 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1403 (define_insn "zero_extendqisi2"
1404 [(set (match_operand:SI 0 "register_operand" "=d")
1405 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1409 ;; these two pattern split everything else which isn't matched by
1410 ;; something else above
1412 [(set (match_operand 0 "register_operand" "")
1413 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1416 && reg_mentioned_p (operands[0], operands[1])"
1417 [(set (strict_low_part (match_dup 2))
1420 (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1422 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1423 operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1424 operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1428 [(set (match_operand 0 "register_operand" "")
1429 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1430 "!TARGET_ISAB && reload_completed"
1433 (set (strict_low_part (match_dup 2))
1436 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1439 ;; sign extension instructions
1441 (define_insn "extendqidi2"
1442 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1443 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1447 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1449 return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1450 if (TARGET_68020 || TARGET_COLDFIRE)
1452 if (ADDRESS_REG_P (operands[1]))
1453 return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1455 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1459 if (ADDRESS_REG_P (operands[1]))
1460 return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1462 return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1466 (define_insn "extendhidi2"
1467 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1469 (match_operand:HI 1 "general_src_operand" "rmS")))]
1473 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1475 return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1476 if (TARGET_68020 || TARGET_COLDFIRE)
1477 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1479 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1482 (define_insn "extendsidi2"
1483 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1485 (match_operand:SI 1 "general_operand" "rm")))]
1489 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1490 if (TARGET_68020 || TARGET_COLDFIRE)
1491 return "move%.l %1,%2\;smi %0\;extb%.l %0";
1493 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
1496 ;; Special case when one can avoid register clobbering, copy and test
1497 ;; Maybe there is a way to make that the general case, by forcing the
1498 ;; result of the SI tree to be in the lower register of the DI target
1500 (define_insn "extendplussidi"
1501 [(set (match_operand:DI 0 "register_operand" "=d")
1502 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1503 (match_operand:SI 2 "general_operand" "rmn"))))]
1507 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1508 if (GET_CODE (operands[1]) == CONST_INT
1509 && (unsigned) INTVAL (operands[1]) > 8)
1511 rtx tmp = operands[1];
1513 operands[1] = operands[2];
1516 if (GET_CODE (operands[1]) == REG
1517 && REGNO (operands[1]) == REGNO (operands[3]))
1518 output_asm_insn ("add%.l %2,%3", operands);
1520 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1521 if (TARGET_68020 || TARGET_COLDFIRE)
1522 return "smi %0\;extb%.l %0";
1524 return "smi %0\;ext%.w %0\;ext%.l %0";
1527 (define_expand "extendhisi2"
1528 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1530 (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1534 (define_insn "*cfv4_extendhisi2"
1535 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1537 (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1541 (define_insn "*68k_extendhisi2"
1542 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1544 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1547 if (ADDRESS_REG_P (operands[0]))
1548 return "move%.w %1,%0";
1552 (define_insn "extendqihi2"
1553 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1554 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1558 (define_expand "extendqisi2"
1559 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1560 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1561 "TARGET_68020 || TARGET_COLDFIRE"
1564 (define_insn "*cfv4_extendqisi2"
1565 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1566 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1570 (define_insn "*68k_extendqisi2"
1571 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1572 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1573 "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_ISAB)"
1576 ;; Conversions between float and double.
1578 (define_expand "extendsfdf2"
1579 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1581 (match_operand:SF 1 "general_operand" "")))]
1586 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1588 (match_operand:SF 1 "general_operand" "f,dmF")))]
1591 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1593 if (REGNO (operands[0]) == REGNO (operands[1]))
1595 /* Extending float to double in an fp-reg is a no-op.
1596 NOTICE_UPDATE_CC has already assumed that the
1597 cc will be set. So cancel what it did. */
1598 cc_status = cc_prev_status;
1601 return "f%&move%.x %1,%0";
1603 if (FP_REG_P (operands[0]))
1604 return "f%&move%.s %f1,%0";
1605 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1607 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1608 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1609 return "move%.l %+,%0";
1611 return "fmove%.d %f1,%0";
1614 (define_insn "extendsfdf2_cf"
1615 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
1617 (match_operand:SF 1 "general_operand" "f,<Q>U")))]
1618 "TARGET_COLDFIRE_FPU"
1620 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1622 if (REGNO (operands[0]) == REGNO (operands[1]))
1624 /* Extending float to double in an fp-reg is a no-op.
1625 NOTICE_UPDATE_CC has already assumed that the
1626 cc will be set. So cancel what it did. */
1627 cc_status = cc_prev_status;
1630 return "fdmove%.d %1,%0";
1632 return "fdmove%.s %f1,%0";
1635 ;; This cannot output into an f-reg because there is no way to be
1636 ;; sure of truncating in that case.
1637 (define_expand "truncdfsf2"
1638 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1640 (match_operand:DF 1 "general_operand" "")))]
1644 ;; On the '040 we can truncate in a register accurately and easily.
1646 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1648 (match_operand:DF 1 "general_operand" "fmG")))]
1649 "TARGET_68881 && TARGET_68040"
1651 if (FP_REG_P (operands[1]))
1652 return "f%$move%.x %1,%0";
1653 return "f%$move%.d %f1,%0";
1656 (define_insn "truncdfsf2_cf"
1657 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
1659 (match_operand:DF 1 "general_operand" "<Q>U,f")))]
1660 "TARGET_COLDFIRE_FPU"
1666 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1668 (match_operand:DF 1 "general_operand" "f")))]
1672 ;; Conversion between fixed point and floating point.
1673 ;; Note that among the fix-to-float insns
1674 ;; the ones that start with SImode come first.
1675 ;; That is so that an operand that is a CONST_INT
1676 ;; (and therefore lacks a specific machine mode).
1677 ;; will be recognized as SImode (which is always valid)
1678 ;; rather than as QImode or HImode.
1680 (define_expand "floatsi<mode>2"
1681 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1682 (float:FP (match_operand:SI 1 "general_operand" "")))]
1686 (define_insn "floatsi<mode>2_68881"
1687 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1688 (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
1690 "f<FP:round>move%.l %1,%0")
1692 (define_insn "floatsi<mode>2_cf"
1693 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1694 (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
1695 "TARGET_COLDFIRE_FPU"
1696 "f<FP:prec>move%.l %1,%0")
1699 (define_expand "floathi<mode>2"
1700 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1701 (float:FP (match_operand:HI 1 "general_operand" "")))]
1705 (define_insn "floathi<mode>2_68881"
1706 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1707 (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
1711 (define_insn "floathi<mode>2_cf"
1712 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1713 (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
1714 "TARGET_COLDFIRE_FPU"
1718 (define_expand "floatqi<mode>2"
1719 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1720 (float:FP (match_operand:QI 1 "general_operand" "")))]
1724 (define_insn "floatqi<mode>2_68881"
1725 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1726 (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
1730 (define_insn "floatqi<mode>2_cf"
1731 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1732 (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
1733 "TARGET_COLDFIRE_FPU"
1737 ;; New routines to convert floating-point values to integers
1738 ;; to be used on the '040. These should be faster than trapping
1739 ;; into the kernel to emulate fintrz. They should also be faster
1740 ;; than calling the subroutines fixsfsi or fixdfsi.
1742 (define_insn "fix_truncdfsi2"
1743 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1744 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1745 (clobber (match_scratch:SI 2 "=d"))
1746 (clobber (match_scratch:SI 3 "=d"))]
1747 "TARGET_68881 && TUNE_68040"
1750 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,%!";
1753 (define_insn "fix_truncdfhi2"
1754 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1755 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1756 (clobber (match_scratch:SI 2 "=d"))
1757 (clobber (match_scratch:SI 3 "=d"))]
1758 "TARGET_68881 && TUNE_68040"
1761 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,%!";
1764 (define_insn "fix_truncdfqi2"
1765 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1766 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1767 (clobber (match_scratch:SI 2 "=d"))
1768 (clobber (match_scratch:SI 3 "=d"))]
1769 "TARGET_68881 && TUNE_68040"
1772 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,%!";
1775 ;; Convert a float to a float whose value is an integer.
1776 ;; This is the first stage of converting it to an integer type.
1778 (define_expand "ftrunc<mode>2"
1779 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1780 (fix:FP (match_operand:FP 1 "general_operand" "")))]
1781 "TARGET_HARD_FLOAT && !TUNE_68040"
1784 (define_insn "ftrunc<mode>2_68881"
1785 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1786 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
1787 "TARGET_68881 && !TUNE_68040"
1789 if (FP_REG_P (operands[1]))
1790 return "fintrz%.x %f1,%0";
1791 return "fintrz%.<FP:prec> %f1,%0";
1794 (define_insn "ftrunc<mode>2_cf"
1795 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1796 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
1797 "TARGET_COLDFIRE_FPU"
1799 if (FP_REG_P (operands[1]))
1800 return "fintrz%.d %f1,%0";
1801 return "fintrz%.<FP:prec> %f1,%0";
1804 ;; Convert a float whose value is an integer
1805 ;; to an actual integer. Second stage of converting float to integer type.
1806 (define_expand "fix<mode>qi2"
1807 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1808 (fix:QI (match_operand:FP 1 "general_operand" "")))]
1812 (define_insn "fix<mode>qi2_68881"
1813 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1814 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
1818 (define_insn "fix<mode>qi2_cf"
1819 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
1820 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
1821 "TARGET_COLDFIRE_FPU"
1824 (define_expand "fix<mode>hi2"
1825 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1826 (fix:HI (match_operand:FP 1 "general_operand" "")))]
1830 (define_insn "fix<mode>hi2_68881"
1831 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1832 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
1836 (define_insn "fix<mode>hi2_cf"
1837 [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
1838 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
1839 "TARGET_COLDFIRE_FPU"
1842 (define_expand "fix<mode>si2"
1843 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1844 (fix:SI (match_operand:FP 1 "general_operand" "")))]
1848 (define_insn "fix<mode>si2_68881"
1849 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1850 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
1854 (define_insn "fix<mode>si2_cf"
1855 [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
1856 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
1857 "TARGET_COLDFIRE_FPU"
1863 (define_insn "adddi_lshrdi_63"
1864 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1865 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
1868 (clobber (match_scratch:SI 2 "=d"))]
1871 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1872 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
1874 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
1875 if (GET_CODE (operands[1]) == REG)
1876 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1877 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
1878 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1879 operands[4] = operands[1];
1881 operands[4] = adjust_address (operands[1], SImode, 4);
1882 if (GET_CODE (operands[1]) == MEM
1883 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1884 output_asm_insn ("move%.l %4,%3", operands);
1885 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
1886 if (TARGET_68020 || TARGET_COLDFIRE)
1887 output_asm_insn ("extb%.l %2", operands);
1889 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
1890 if (GET_CODE (operands[1]) != MEM
1891 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
1892 output_asm_insn ("move%.l %4,%3", operands);
1893 return "sub%.l %2,%3\;subx%.l %2,%0";
1896 (define_insn "adddi_sexthishl32"
1897 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
1898 (plus:DI (ashift:DI (sign_extend:DI
1899 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
1901 (match_operand:DI 2 "general_operand" "0,0,0,0")))
1902 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
1906 if (ADDRESS_REG_P (operands[0]))
1907 return "add%.w %1,%0";
1908 else if (ADDRESS_REG_P (operands[3]))
1909 return "move%.w %1,%3\;add%.l %3,%0";
1911 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
1914 (define_insn "adddi_dilshr32"
1915 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
1916 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1917 ;; (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
1918 ;; (const_int 32))))]
1919 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
1921 (match_operand:DI 2 "general_operand" "0,0")))]
1925 if (GET_CODE (operands[0]) == REG)
1926 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1928 operands[2] = adjust_address (operands[0], SImode, 4);
1929 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
1932 (define_insn "adddi_dishl32"
1933 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
1934 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1935 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
1936 ;; (const_int 32))))]
1937 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
1939 (match_operand:DI 2 "general_operand" "0,0")))]
1943 if (GET_CODE (operands[1]) == REG)
1944 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1946 operands[1] = adjust_address (operands[1], SImode, 4);
1947 return "add%.l %1,%0";
1950 (define_insn "adddi3"
1951 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
1952 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0,0")
1953 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
1954 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
1957 if (DATA_REG_P (operands[0]))
1959 if (DATA_REG_P (operands[2]))
1960 return "add%.l %R2,%R0\;addx%.l %2,%0";
1961 else if (GET_CODE (operands[2]) == MEM
1962 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
1963 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
1969 if (GET_CODE (operands[2]) == REG)
1971 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
1974 else if (CONSTANT_P (operands[2]))
1975 split_double (operands[2], &high, &low);
1978 low = adjust_address (operands[2], SImode, 4);
1982 operands[1] = low, operands[2] = high;
1983 xoperands[0] = operands[3];
1984 if (GET_CODE (operands[1]) == CONST_INT
1985 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1986 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
1988 xoperands[1] = operands[2];
1990 output_asm_insn (output_move_simode (xoperands), xoperands);
1991 if (GET_CODE (operands[1]) == CONST_INT)
1993 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
1994 return "addq%.l %1,%R0\;addx%.l %3,%0";
1995 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1997 operands[1] = GEN_INT (-INTVAL (operands[1]));
1998 return "subq%.l %1,%R0\;subx%.l %3,%0";
2001 return "add%.l %1,%R0\;addx%.l %3,%0";
2006 gcc_assert (GET_CODE (operands[0]) == MEM);
2007 if (GET_CODE (operands[2]) == MEM
2008 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
2009 return "add%.l %2,%0\;addx%.l %2,%0";
2011 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2013 operands[1] = gen_rtx_MEM (SImode,
2014 plus_constant (XEXP(operands[0], 0), -8));
2015 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2017 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2019 operands[1] = XEXP(operands[0], 0);
2020 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2024 operands[1] = adjust_address (operands[0], SImode, 4);
2025 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2030 (define_insn "addsi_lshrsi_31"
2031 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2032 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
2037 operands[2] = operands[0];
2038 operands[3] = gen_label_rtx();
2039 if (GET_CODE (operands[0]) == MEM)
2041 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2042 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2043 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2044 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2046 output_asm_insn ("move%.l %1,%0", operands);
2047 output_asm_insn (MOTOROLA ? "jbpl %l3" : "jpl %l3", operands);
2048 output_asm_insn ("addq%.l #1,%2", operands);
2049 (*targetm.asm_out.internal_label) (asm_out_file, "L",
2050 CODE_LABEL_NUMBER (operands[3]));
2054 (define_expand "addsi3"
2055 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2056 (plus:SI (match_operand:SI 1 "general_operand" "")
2057 (match_operand:SI 2 "general_src_operand" "")))]
2061 ;; Note that the middle two alternatives are near-duplicates
2062 ;; in order to handle insns generated by reload.
2063 ;; This is needed since they are not themselves reloaded,
2064 ;; so commutativity won't apply to them.
2065 (define_insn "*addsi3_internal"
2066 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2067 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2068 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2072 "* return output_addsi3 (operands);")
2074 (define_insn "*addsi3_5200"
2075 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
2076 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
2077 (match_operand:SI 2 "general_src_operand" "dIL,rJK,a,mrIKLi")))]
2079 "* return output_addsi3 (operands);")
2082 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2083 (plus:SI (match_operand:SI 1 "general_operand" "0")
2085 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2089 (define_insn "addhi3"
2090 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2091 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2092 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2095 if (GET_CODE (operands[2]) == CONST_INT)
2097 /* If the constant would be a negative number when interpreted as
2098 HImode, make it negative. This is usually, but not always, done
2099 elsewhere in the compiler. First check for constants out of range,
2100 which could confuse us. */
2102 if (INTVAL (operands[2]) >= 32768)
2103 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2105 if (INTVAL (operands[2]) > 0
2106 && INTVAL (operands[2]) <= 8)
2107 return "addq%.w %2,%0";
2108 if (INTVAL (operands[2]) < 0
2109 && INTVAL (operands[2]) >= -8)
2111 operands[2] = GEN_INT (- INTVAL (operands[2]));
2112 return "subq%.w %2,%0";
2114 /* On the CPU32 it is faster to use two addqw instructions to
2115 add a small integer (8 < N <= 16) to a register.
2116 Likewise for subqw. */
2117 if (TUNE_CPU32 && REG_P (operands[0]))
2119 if (INTVAL (operands[2]) > 8
2120 && INTVAL (operands[2]) <= 16)
2122 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2123 return "addq%.w #8,%0\;addq%.w %2,%0";
2125 if (INTVAL (operands[2]) < -8
2126 && INTVAL (operands[2]) >= -16)
2128 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2129 return "subq%.w #8,%0\;subq%.w %2,%0";
2132 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2133 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2135 return "add%.w %2,%0";
2138 ;; These insns must use MATCH_DUP instead of the more expected
2139 ;; use of a matching constraint because the "output" here is also
2140 ;; an input, so you can't use the matching constraint. That also means
2141 ;; that you can't use the "%", so you need patterns with the matched
2142 ;; operand in both positions.
2145 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2146 (plus:HI (match_dup 0)
2147 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2150 if (GET_CODE (operands[1]) == CONST_INT)
2152 /* If the constant would be a negative number when interpreted as
2153 HImode, make it negative. This is usually, but not always, done
2154 elsewhere in the compiler. First check for constants out of range,
2155 which could confuse us. */
2157 if (INTVAL (operands[1]) >= 32768)
2158 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2160 if (INTVAL (operands[1]) > 0
2161 && INTVAL (operands[1]) <= 8)
2162 return "addq%.w %1,%0";
2163 if (INTVAL (operands[1]) < 0
2164 && INTVAL (operands[1]) >= -8)
2166 operands[1] = GEN_INT (- INTVAL (operands[1]));
2167 return "subq%.w %1,%0";
2169 /* On the CPU32 it is faster to use two addqw instructions to
2170 add a small integer (8 < N <= 16) to a register.
2171 Likewise for subqw. */
2172 if (TUNE_CPU32 && REG_P (operands[0]))
2174 if (INTVAL (operands[1]) > 8
2175 && INTVAL (operands[1]) <= 16)
2177 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2178 return "addq%.w #8,%0\;addq%.w %1,%0";
2180 if (INTVAL (operands[1]) < -8
2181 && INTVAL (operands[1]) >= -16)
2183 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2184 return "subq%.w #8,%0\;subq%.w %1,%0";
2187 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2188 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2190 return "add%.w %1,%0";
2194 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2195 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2199 if (GET_CODE (operands[1]) == CONST_INT)
2201 /* If the constant would be a negative number when interpreted as
2202 HImode, make it negative. This is usually, but not always, done
2203 elsewhere in the compiler. First check for constants out of range,
2204 which could confuse us. */
2206 if (INTVAL (operands[1]) >= 32768)
2207 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2209 if (INTVAL (operands[1]) > 0
2210 && INTVAL (operands[1]) <= 8)
2211 return "addq%.w %1,%0";
2212 if (INTVAL (operands[1]) < 0
2213 && INTVAL (operands[1]) >= -8)
2215 operands[1] = GEN_INT (- INTVAL (operands[1]));
2216 return "subq%.w %1,%0";
2218 /* On the CPU32 it is faster to use two addqw instructions to
2219 add a small integer (8 < N <= 16) to a register.
2220 Likewise for subqw. */
2221 if (TUNE_CPU32 && REG_P (operands[0]))
2223 if (INTVAL (operands[1]) > 8
2224 && INTVAL (operands[1]) <= 16)
2226 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2227 return "addq%.w #8,%0\;addq%.w %1,%0";
2229 if (INTVAL (operands[1]) < -8
2230 && INTVAL (operands[1]) >= -16)
2232 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2233 return "subq%.w #8,%0\;subq%.w %1,%0";
2236 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2237 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2239 return "add%.w %1,%0";
2242 (define_insn "addqi3"
2243 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2244 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2245 (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";
2262 return "add%.b %2,%0";
2266 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2267 (plus:QI (match_dup 0)
2268 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2271 if (GET_CODE (operands[1]) == CONST_INT)
2273 if (INTVAL (operands[1]) >= 128)
2274 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2276 if (INTVAL (operands[1]) > 0
2277 && INTVAL (operands[1]) <= 8)
2278 return "addq%.b %1,%0";
2279 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2281 operands[1] = GEN_INT (- INTVAL (operands[1]));
2282 return "subq%.b %1,%0";
2285 return "add%.b %1,%0";
2289 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2290 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2294 if (GET_CODE (operands[1]) == CONST_INT)
2296 if (INTVAL (operands[1]) >= 128)
2297 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2299 if (INTVAL (operands[1]) > 0
2300 && INTVAL (operands[1]) <= 8)
2301 return "addq%.b %1,%0";
2302 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2304 operands[1] = GEN_INT (- INTVAL (operands[1]));
2305 return "subq%.b %1,%0";
2308 return "add%.b %1,%0";
2311 (define_expand "add<mode>3"
2312 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2313 (plus:FP (match_operand:FP 1 "general_operand" "")
2314 (match_operand:FP 2 "general_operand" "")))]
2318 (define_insn "add<mode>3_floatsi_68881"
2319 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2320 (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2321 (match_operand:FP 1 "general_operand" "0")))]
2323 "f<FP:round>add%.l %2,%0")
2325 (define_insn "add<mode>3_floathi_68881"
2326 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2327 (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2328 (match_operand:FP 1 "general_operand" "0")))]
2330 "f<FP:round>add%.w %2,%0")
2332 (define_insn "add<mode>3_floatqi_68881"
2333 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2334 (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2335 (match_operand:FP 1 "general_operand" "0")))]
2337 "f<FP:round>add%.b %2,%0")
2339 (define_insn "add<mode>3_68881"
2340 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2341 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2342 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2345 if (FP_REG_P (operands[2]))
2346 return "f<FP:round>add%.x %2,%0";
2347 return "f<FP:round>add%.<FP:prec> %f2,%0";
2350 (define_insn "add<mode>3_cf"
2351 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2352 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2353 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2354 "TARGET_COLDFIRE_FPU"
2356 if (FP_REG_P (operands[2]))
2357 return "f<FP:prec>add%.d %2,%0";
2358 return "f<FP:prec>add%.<FP:prec> %2,%0";
2361 ;; subtract instructions
2363 (define_insn "subdi_sexthishl32"
2364 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2365 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2366 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2368 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2372 if (ADDRESS_REG_P (operands[0]))
2373 return "sub%.w %2,%0";
2374 else if (ADDRESS_REG_P (operands[3]))
2375 return "move%.w %2,%3\;sub%.l %3,%0";
2377 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2380 (define_insn "subdi_dishl32"
2381 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2382 (minus:DI (match_dup 0)
2383 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2388 if (GET_CODE (operands[1]) == REG)
2389 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2391 operands[1] = adjust_address (operands[1], SImode, 4);
2392 return "sub%.l %1,%0";
2395 (define_insn "subdi3"
2396 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
2397 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0,0")
2398 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
2399 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
2402 if (DATA_REG_P (operands[0]))
2404 if (DATA_REG_P (operands[2]))
2405 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2406 else if (GET_CODE (operands[2]) == MEM
2407 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2409 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2416 if (GET_CODE (operands[2]) == REG)
2418 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2421 else if (CONSTANT_P (operands[2]))
2422 split_double (operands[2], &high, &low);
2425 low = adjust_address (operands[2], SImode, 4);
2429 operands[1] = low, operands[2] = high;
2430 xoperands[0] = operands[3];
2431 if (GET_CODE (operands[1]) == CONST_INT
2432 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2433 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2435 xoperands[1] = operands[2];
2437 output_asm_insn (output_move_simode (xoperands), xoperands);
2438 if (GET_CODE (operands[1]) == CONST_INT)
2440 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2441 return "subq%.l %1,%R0\;subx%.l %3,%0";
2442 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2444 operands[1] = GEN_INT (-INTVAL (operands[1]));
2445 return "addq%.l %1,%R0\;addx%.l %3,%0";
2448 return "sub%.l %1,%R0\;subx%.l %3,%0";
2453 gcc_assert (GET_CODE (operands[0]) == MEM);
2454 if (GET_CODE (operands[2]) == MEM
2455 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
2456 return "sub%.l %2,%0\;subx%.l %2,%0";
2458 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2461 = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2462 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2464 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2466 operands[1] = XEXP(operands[0], 0);
2467 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2471 operands[1] = adjust_address (operands[0], SImode, 4);
2472 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2477 (define_insn "subsi3"
2478 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2479 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2480 (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2485 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2486 (minus:SI (match_operand:SI 1 "general_operand" "0")
2488 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2492 (define_insn "subhi3"
2493 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2494 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2495 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2500 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2501 (minus:HI (match_dup 0)
2502 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2506 (define_insn "subqi3"
2507 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2508 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2509 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2514 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2515 (minus:QI (match_dup 0)
2516 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2520 (define_expand "sub<mode>3"
2521 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2522 (minus:FP (match_operand:FP 1 "general_operand" "")
2523 (match_operand:FP 2 "general_operand" "")))]
2527 (define_insn "sub<mode>3_floatsi_68881"
2528 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2529 (minus:FP (match_operand:FP 1 "general_operand" "0")
2530 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2532 "f<FP:round>sub%.l %2,%0")
2534 (define_insn "sub<mode>3_floathi_68881"
2535 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2536 (minus:FP (match_operand:FP 1 "general_operand" "0")
2537 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2539 "f<FP:round>sub%.w %2,%0")
2541 (define_insn "sub<mode>3_floatqi_68881"
2542 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2543 (minus:FP (match_operand:FP 1 "general_operand" "0")
2544 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2546 "f<FP:round>sub%.b %2,%0")
2548 (define_insn "sub<mode>3_68881"
2549 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2550 (minus:FP (match_operand:FP 1 "general_operand" "0")
2551 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2554 if (FP_REG_P (operands[2]))
2555 return "f<FP:round>sub%.x %2,%0";
2556 return "f<FP:round>sub%.<FP:prec> %f2,%0";
2559 (define_insn "sub<mode>3_cf"
2560 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2561 (minus:FP (match_operand:FP 1 "general_operand" "0")
2562 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2563 "TARGET_COLDFIRE_FPU"
2565 if (FP_REG_P (operands[2]))
2566 return "f<FP:prec>sub%.d %2,%0";
2567 return "f<FP:prec>sub%.<FP:prec> %2,%0";
2570 ;; multiply instructions
2572 (define_insn "mulhi3"
2573 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2574 (mult:HI (match_operand:HI 1 "general_operand" "%0")
2575 (match_operand:HI 2 "general_src_operand" "dmSn")))]
2578 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2581 (define_insn "mulhisi3"
2582 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2583 (mult:SI (sign_extend:SI
2584 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2586 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2589 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2593 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2594 (mult:SI (sign_extend:SI
2595 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2596 (match_operand:SI 2 "const_int_operand" "n")))]
2597 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2599 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2602 (define_expand "mulsi3"
2603 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2604 (mult:SI (match_operand:SI 1 "general_operand" "")
2605 (match_operand:SI 2 "general_operand" "")))]
2606 "TARGET_68020 || TARGET_COLDFIRE"
2610 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2611 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2612 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2618 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2619 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2620 (match_operand:SI 2 "general_operand" "d<Q>")))]
2624 (define_insn "umulhisi3"
2625 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2626 (mult:SI (zero_extend:SI
2627 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2629 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2632 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2636 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2637 (mult:SI (zero_extend:SI
2638 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2639 (match_operand:SI 2 "const_int_operand" "n")))]
2640 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2642 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2645 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2646 ;; proper matching constraint. This is because the matching is between
2647 ;; the high-numbered word of the DImode operand[0] and operand[1].
2648 (define_expand "umulsidi3"
2650 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2651 (mult:SI (match_operand:SI 1 "register_operand" "")
2652 (match_operand:SI 2 "register_operand" "")))
2653 (set (subreg:SI (match_dup 0) 0)
2654 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2655 (zero_extend:DI (match_dup 2)))
2656 (const_int 32))))])]
2657 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2661 [(set (match_operand:SI 0 "register_operand" "=d")
2662 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2663 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2664 (set (match_operand:SI 3 "register_operand" "=d")
2665 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2666 (zero_extend:DI (match_dup 2)))
2668 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2671 ; Match immediate case. For 2.4 only match things < 2^31.
2672 ; It's tricky with larger values in these patterns since we need to match
2673 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2676 [(set (match_operand:SI 0 "register_operand" "=d")
2677 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2678 (match_operand:SI 2 "const_int_operand" "n")))
2679 (set (match_operand:SI 3 "register_operand" "=d")
2680 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2683 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
2684 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2687 (define_expand "mulsidi3"
2689 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2690 (mult:SI (match_operand:SI 1 "register_operand" "")
2691 (match_operand:SI 2 "register_operand" "")))
2692 (set (subreg:SI (match_dup 0) 0)
2693 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2694 (sign_extend:DI (match_dup 2)))
2695 (const_int 32))))])]
2696 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2700 [(set (match_operand:SI 0 "register_operand" "=d")
2701 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2702 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2703 (set (match_operand:SI 3 "register_operand" "=d")
2704 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2705 (sign_extend:DI (match_dup 2)))
2707 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2711 [(set (match_operand:SI 0 "register_operand" "=d")
2712 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2713 (match_operand:SI 2 "const_int_operand" "n")))
2714 (set (match_operand:SI 3 "register_operand" "=d")
2715 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2718 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2721 (define_expand "umulsi3_highpart"
2723 [(set (match_operand:SI 0 "register_operand" "")
2726 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2727 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2729 (clobber (match_dup 3))])]
2730 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2732 operands[3] = gen_reg_rtx (SImode);
2734 if (GET_CODE (operands[2]) == CONST_INT)
2736 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2739 /* We have to adjust the operand order for the matching constraints. */
2740 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2741 operands[1], operands[2]));
2747 [(set (match_operand:SI 0 "register_operand" "=d")
2750 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2751 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2753 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2754 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2757 (define_insn "const_umulsi3_highpart"
2758 [(set (match_operand:SI 0 "register_operand" "=d")
2761 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2762 (match_operand:DI 3 "const_uint32_operand" "n"))
2764 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2765 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2768 (define_expand "smulsi3_highpart"
2770 [(set (match_operand:SI 0 "register_operand" "")
2773 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2774 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2776 (clobber (match_dup 3))])]
2777 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2779 operands[3] = gen_reg_rtx (SImode);
2780 if (GET_CODE (operands[2]) == CONST_INT)
2782 /* We have to adjust the operand order for the matching constraints. */
2783 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2784 operands[1], operands[2]));
2790 [(set (match_operand:SI 0 "register_operand" "=d")
2793 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2794 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2796 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2797 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2800 (define_insn "const_smulsi3_highpart"
2801 [(set (match_operand:SI 0 "register_operand" "=d")
2804 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2805 (match_operand:DI 3 "const_sint32_operand" "n"))
2807 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2808 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2811 (define_expand "mul<mode>3"
2812 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2813 (mult:FP (match_operand:FP 1 "general_operand" "")
2814 (match_operand:FP 2 "general_operand" "")))]
2818 (define_insn "mul<mode>3_floatsi_68881"
2819 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2820 (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2821 (match_operand:FP 1 "general_operand" "0")))]
2825 ? "f<FP:round>mul%.l %2,%0"
2826 : "f<FP:round_mul>mul%.l %2,%0";
2829 (define_insn "mul<mode>3_floathi_68881"
2830 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2831 (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2832 (match_operand:FP 1 "general_operand" "0")))]
2836 ? "f<FP:round>mul%.w %2,%0"
2837 : "f<FP:round_mul>mul%.w %2,%0";
2840 (define_insn "mul<mode>3_floatqi_68881"
2841 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2842 (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2843 (match_operand:FP 1 "general_operand" "0")))]
2847 ? "f<FP:round>mul%.b %2,%0"
2848 : "f<FP:round_mul>mul%.b %2,%0";
2851 (define_insn "muldf_68881"
2852 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2853 (mult:DF (match_operand:DF 1 "general_operand" "%0")
2854 (match_operand:DF 2 "general_operand" "fmG")))]
2857 if (GET_CODE (operands[2]) == CONST_DOUBLE
2858 && floating_exact_log2 (operands[2]) && !TUNE_68040_60)
2860 int i = floating_exact_log2 (operands[2]);
2861 operands[2] = GEN_INT (i);
2862 return "fscale%.l %2,%0";
2864 if (REG_P (operands[2]))
2865 return "f%&mul%.x %2,%0";
2866 return "f%&mul%.d %f2,%0";
2869 (define_insn "mulsf_68881"
2870 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2871 (mult:SF (match_operand:SF 1 "general_operand" "%0")
2872 (match_operand:SF 2 "general_operand" "fdmF")))]
2875 if (FP_REG_P (operands[2]))
2876 return (TARGET_68040
2878 : "fsglmul%.x %2,%0");
2879 return (TARGET_68040
2881 : "fsglmul%.s %f2,%0");
2884 (define_insn "mulxf3_68881"
2885 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
2886 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
2887 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
2890 return "fmul%.x %f2,%0";
2893 (define_insn "fmul<mode>3_cf"
2894 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2895 (mult:FP (match_operand:FP 1 "general_operand" "%0")
2896 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
2897 "TARGET_COLDFIRE_FPU"
2899 if (FP_REG_P (operands[2]))
2900 return "f<FP:prec>mul%.d %2,%0";
2901 return "f<FP:prec>mul%.<FP:prec> %2,%0";
2904 ;; divide instructions
2906 (define_expand "div<mode>3"
2907 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2908 (div:FP (match_operand:FP 1 "general_operand" "")
2909 (match_operand:FP 2 "general_operand" "")))]
2913 (define_insn "div<mode>3_floatsi_68881"
2914 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2915 (div:FP (match_operand:FP 1 "general_operand" "0")
2916 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2920 ? "f<FP:round>div%.l %2,%0"
2921 : "f<FP:round_mul>div%.l %2,%0";
2924 (define_insn "div<mode>3_floathi_68881"
2925 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2926 (div:FP (match_operand:FP 1 "general_operand" "0")
2927 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2931 ? "f<FP:round>div%.w %2,%0"
2932 : "f<FP:round_mul>div%.w %2,%0";
2935 (define_insn "div<mode>3_floatqi_68881"
2936 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2937 (div:FP (match_operand:FP 1 "general_operand" "0")
2938 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2942 ? "f<FP:round>div%.b %2,%0"
2943 : "f<FP:round_mul>div%.b %2,%0";
2946 (define_insn "div<mode>3_68881"
2947 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2948 (div:FP (match_operand:FP 1 "general_operand" "0")
2949 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2952 if (FP_REG_P (operands[2]))
2953 return (TARGET_68040
2954 ? "f<FP:round>div%.x %2,%0"
2955 : "f<FP:round_mul>div%.x %2,%0");
2956 return (TARGET_68040
2957 ? "f<FP:round>div%.<FP:prec> %f2,%0"
2958 : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
2961 (define_insn "div<mode>3_cf"
2962 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2963 (div:FP (match_operand:FP 1 "general_operand" "0")
2964 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
2965 "TARGET_COLDFIRE_FPU"
2967 if (FP_REG_P (operands[2]))
2968 return "f<FP:prec>div%.d %2,%0";
2969 return "f<FP:prec>div%.<FP:prec> %2,%0";
2972 ;; Remainder instructions.
2974 (define_expand "divmodsi4"
2976 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2977 (div:SI (match_operand:SI 1 "general_operand" "")
2978 (match_operand:SI 2 "general_src_operand" "")))
2979 (set (match_operand:SI 3 "nonimmediate_operand" "")
2980 (mod:SI (match_dup 1) (match_dup 2)))])]
2981 "TARGET_68020 || TARGET_CF_HWDIV"
2985 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2986 (div:SI (match_operand:SI 1 "general_operand" "0")
2987 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2988 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2989 (mod:SI (match_dup 1) (match_dup 2)))]
2992 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2993 return "divs%.l %2,%0";
2994 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2995 return "rems%.l %2,%3:%0";
2997 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
3001 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3002 (div:SI (match_operand:SI 1 "general_operand" "0")
3003 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3004 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3005 (mod:SI (match_dup 1) (match_dup 2)))]
3008 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3009 return "divs%.l %2,%0";
3011 return "divsl%.l %2,%3:%0";
3014 (define_expand "udivmodsi4"
3016 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3017 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3018 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3019 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3020 (umod:SI (match_dup 1) (match_dup 2)))])]
3021 "TARGET_68020 || TARGET_CF_HWDIV"
3025 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3026 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3027 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3028 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3029 (umod:SI (match_dup 1) (match_dup 2)))]
3032 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3033 return "divu%.l %2,%0";
3034 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3035 return "remu%.l %2,%3:%0";
3037 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3041 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3042 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3043 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3044 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3045 (umod:SI (match_dup 1) (match_dup 2)))]
3046 "TARGET_68020 && !TARGET_COLDFIRE"
3048 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3049 return "divu%.l %2,%0";
3051 return "divul%.l %2,%3:%0";
3054 (define_insn "divmodhi4"
3055 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3056 (div:HI (match_operand:HI 1 "general_operand" "0")
3057 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3058 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3059 (mod:HI (match_dup 1) (match_dup 2)))]
3060 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3062 output_asm_insn (MOTOROLA ?
3063 "ext%.l %0\;divs%.w %2,%0" :
3064 "extl %0\;divs %2,%0",
3066 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3069 return "move%.l %0,%3\;swap %3";
3075 (define_insn "udivmodhi4"
3076 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3077 (udiv:HI (match_operand:HI 1 "general_operand" "0")
3078 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3079 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3080 (umod:HI (match_dup 1) (match_dup 2)))]
3081 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3084 output_asm_insn (MOTOROLA ?
3085 "mvz%.w %0,%0\;divu%.w %2,%0" :
3086 "mvz%.w %0,%0\;divu %2,%0",
3089 output_asm_insn (MOTOROLA ?
3090 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3091 "and%.l #0xFFFF,%0\;divu %2,%0",
3094 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3097 return "move%.l %0,%3\;swap %3";
3103 ;; logical-and instructions
3105 ;; "anddi3" is mainly here to help combine().
3106 (define_insn "anddi3"
3107 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3108 (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3109 (match_operand:DI 2 "general_operand" "dn,don")))]
3113 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3114 if (CONSTANT_P (operands[2]))
3118 split_double (operands[2], &hi, &lo);
3120 switch (INTVAL (hi))
3123 output_asm_insn ("clr%.l %0", operands);
3131 xoperands[0] = operands[0];
3133 output_asm_insn (output_andsi3 (xoperands), xoperands);
3136 if (GET_CODE (operands[0]) == REG)
3137 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3139 operands[0] = adjust_address (operands[0], SImode, 4);
3140 switch (INTVAL (lo))
3143 output_asm_insn ("clr%.l %0", operands);
3151 xoperands[0] = operands[0];
3153 output_asm_insn (output_andsi3 (xoperands), xoperands);
3158 if (GET_CODE (operands[0]) != REG)
3160 operands[1] = adjust_address (operands[0], SImode, 4);
3161 return "and%.l %2,%0\;and%.l %R2,%1";
3163 if (GET_CODE (operands[2]) != REG)
3165 operands[1] = adjust_address (operands[2], SImode, 4);
3166 return "and%.l %2,%0\;and%.l %1,%R0";
3168 return "and%.l %2,%0\;and%.l %R2,%R0";
3171 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3172 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3173 ;; can't allocate pseudos into it.
3175 (define_expand "andsi3"
3176 [(set (match_operand:SI 0 "not_sp_operand" "")
3177 (and:SI (match_operand:SI 1 "general_operand" "")
3178 (match_operand:SI 2 "general_src_operand" "")))]
3182 ;; produced by split operations after reload finished
3183 (define_insn "*andsi3_split"
3184 [(set (match_operand:SI 0 "register_operand" "=d")
3185 (and:SI (match_operand:SI 1 "register_operand" "0")
3186 (match_operand:SI 2 "const_int_operand" "i")))]
3187 "reload_completed && !TARGET_COLDFIRE"
3189 return output_andsi3 (operands);
3192 (define_insn "andsi3_internal"
3193 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3194 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3195 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3198 return output_andsi3 (operands);
3201 (define_insn "andsi3_5200"
3202 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3203 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3204 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3208 && DATA_REG_P (operands[0])
3209 && GET_CODE (operands[2]) == CONST_INT)
3211 if (INTVAL (operands[2]) == 0x000000ff)
3212 return "mvz%.b %0,%0";
3213 else if (INTVAL (operands[2]) == 0x0000ffff)
3214 return "mvz%.w %0,%0";
3216 return output_andsi3 (operands);
3219 (define_insn "andhi3"
3220 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3221 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3222 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3227 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3228 (and:HI (match_dup 0)
3229 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3234 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3235 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3240 (define_insn "andqi3"
3241 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3242 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3243 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3248 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3249 (and:QI (match_dup 0)
3250 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3255 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3256 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3261 ;; inclusive-or instructions
3263 (define_insn "iordi_zext"
3264 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3265 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3266 (match_operand:DI 2 "general_operand" "0,0")))]
3272 if (GET_CODE (operands[0]) == REG)
3273 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3275 operands[0] = adjust_address (operands[0], SImode, 4);
3276 if (GET_MODE (operands[1]) == SImode)
3277 return "or%.l %1,%0";
3278 byte_mode = (GET_MODE (operands[1]) == QImode);
3279 if (GET_CODE (operands[0]) == MEM)
3280 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3283 return "or%.b %1,%0";
3285 return "or%.w %1,%0";
3288 ;; "iordi3" is mainly here to help combine().
3289 (define_insn "iordi3"
3290 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3291 (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3292 (match_operand:DI 2 "general_operand" "dn,don")))]
3296 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3297 if (CONSTANT_P (operands[2]))
3301 split_double (operands[2], &hi, &lo);
3303 switch (INTVAL (hi))
3308 /* FIXME : a scratch register would be welcome here if operand[0]
3309 is not a register */
3310 output_asm_insn ("move%.l #-1,%0", operands);
3316 xoperands[0] = operands[0];
3318 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3321 if (GET_CODE (operands[0]) == REG)
3322 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3324 operands[0] = adjust_address (operands[0], SImode, 4);
3325 switch (INTVAL (lo))
3330 /* FIXME : a scratch register would be welcome here if operand[0]
3331 is not a register */
3332 output_asm_insn ("move%.l #-1,%0", operands);
3338 xoperands[0] = operands[0];
3340 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3345 if (GET_CODE (operands[0]) != REG)
3347 operands[1] = adjust_address (operands[0], SImode, 4);
3348 return "or%.l %2,%0\;or%.l %R2,%1";
3350 if (GET_CODE (operands[2]) != REG)
3352 operands[1] = adjust_address (operands[2], SImode, 4);
3353 return "or%.l %2,%0\;or%.l %1,%R0";
3355 return "or%.l %2,%0\;or%.l %R2,%R0";
3358 (define_expand "iorsi3"
3359 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3360 (ior:SI (match_operand:SI 1 "general_operand" "")
3361 (match_operand:SI 2 "general_src_operand" "")))]
3365 (define_insn "iorsi3_internal"
3366 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3367 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3368 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3371 return output_iorsi3 (operands);
3374 (define_insn "iorsi3_5200"
3375 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3376 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3377 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3380 return output_iorsi3 (operands);
3383 (define_insn "iorhi3"
3384 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3385 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3386 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3391 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3392 (ior:HI (match_dup 0)
3393 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3398 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3399 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3404 (define_insn "iorqi3"
3405 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3406 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3407 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3412 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3413 (ior:QI (match_dup 0)
3414 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3419 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3420 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3425 ;; On all 68k models, this makes faster code in a special case.
3426 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3428 (define_insn "iorsi_zexthi_ashl16"
3429 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3430 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3431 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3436 if (GET_CODE (operands[2]) != REG)
3437 operands[2] = adjust_address (operands[2], HImode, 2);
3438 if (GET_CODE (operands[2]) != REG
3439 || REGNO (operands[2]) != REGNO (operands[0]))
3440 output_asm_insn ("move%.w %2,%0", operands);
3441 return "swap %0\;mov%.w %1,%0";
3444 (define_insn "iorsi_zext"
3445 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3446 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3447 (match_operand:SI 2 "general_operand" "0,0")))]
3453 byte_mode = (GET_MODE (operands[1]) == QImode);
3454 if (GET_CODE (operands[0]) == MEM)
3455 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3458 return "or%.b %1,%0";
3460 return "or%.w %1,%0";
3465 ;; "xordi3" is mainly here to help combine().
3466 (define_insn "xordi3"
3467 [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3468 (xor:DI (match_operand:DI 1 "general_operand" "%0")
3469 (match_operand:DI 2 "general_operand" "dn")))]
3473 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3475 if (CONSTANT_P (operands[2]))
3479 split_double (operands[2], &hi, &lo);
3481 switch (INTVAL (hi))
3486 output_asm_insn ("not%.l %0", operands);
3489 /* FIXME : a scratch register would be welcome here if
3490 -128 <= INTVAL (hi) < -1 */
3494 xoperands[0] = operands[0];
3496 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3499 if (GET_CODE (operands[0]) == REG)
3500 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3502 operands[0] = adjust_address (operands[0], SImode, 4);
3503 switch (INTVAL (lo))
3508 output_asm_insn ("not%.l %0", operands);
3511 /* FIXME : a scratch register would be welcome here if
3512 -128 <= INTVAL (lo) < -1 */
3514 /* FIXME : this should be merged with xorsi3 */
3518 xoperands[0] = operands[0];
3520 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3525 if (GET_CODE (operands[0]) != REG)
3527 operands[1] = adjust_address (operands[0], SImode, 4);
3528 return "eor%.l %2,%0\;eor%.l %R2,%1";
3530 if (GET_CODE (operands[2]) != REG)
3532 operands[1] = adjust_address (operands[2], SImode, 4);
3533 return "eor%.l %2,%0\;eor%.l %1,%R0";
3535 return "eor%.l %2,%0\;eor%.l %R2,%R0";
3538 (define_expand "xorsi3"
3539 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3540 (xor:SI (match_operand:SI 1 "general_operand" "")
3541 (match_operand:SI 2 "general_operand" "")))]
3545 (define_insn "xorsi3_internal"
3546 [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3547 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3548 (match_operand:SI 2 "general_operand" "di,dKT")))]
3552 return output_xorsi3 (operands);
3555 (define_insn "xorsi3_5200"
3556 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3557 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3558 (match_operand:SI 2 "general_operand" "d,Ks")))]
3561 return output_xorsi3 (operands);
3564 (define_insn "xorhi3"
3565 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3566 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3567 (match_operand:HI 2 "general_operand" "dn")))]
3572 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3573 (xor:HI (match_dup 0)
3574 (match_operand:HI 1 "general_operand" "dn")))]
3579 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3580 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3585 (define_insn "xorqi3"
3586 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3587 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3588 (match_operand:QI 2 "general_operand" "dn")))]
3593 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3594 (xor:QI (match_dup 0)
3595 (match_operand:QI 1 "general_operand" "dn")))]
3600 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3601 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3606 ;; negation instructions
3608 (define_expand "negdi2"
3609 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3610 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3613 if (TARGET_COLDFIRE)
3614 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3616 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3620 (define_insn "negdi2_internal"
3621 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3622 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3625 if (which_alternative == 0)
3626 return "neg%.l %0\;negx%.l %0";
3627 if (GET_CODE (operands[0]) == REG)
3628 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3630 operands[1] = adjust_address (operands[0], SImode, 4);
3631 if (ADDRESS_REG_P (operands[0]))
3632 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3634 return "neg%.l %1\;negx%.l %0";
3637 (define_insn "negdi2_5200"
3638 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3639 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3642 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3643 return "neg%.l %1\;negx%.l %0";
3646 (define_expand "negsi2"
3647 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3648 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3651 if (TARGET_COLDFIRE)
3652 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3654 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3658 (define_insn "negsi2_internal"
3659 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3660 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3664 (define_insn "negsi2_5200"
3665 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3666 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3670 (define_insn "neghi2"
3671 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3672 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3677 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3678 (neg:HI (match_dup 0)))]
3682 (define_insn "negqi2"
3683 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3684 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3689 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3690 (neg:QI (match_dup 0)))]
3694 ;; If using software floating point, just flip the sign bit.
3696 (define_expand "negsf2"
3697 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3698 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3701 if (!TARGET_HARD_FLOAT)
3706 target = operand_subword_force (operands[0], 0, SFmode);
3707 result = expand_binop (SImode, xor_optab,
3708 operand_subword_force (operands[1], 0, SFmode),
3709 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3710 gcc_assert (result);
3712 if (result != target)
3713 emit_move_insn (result, target);
3715 /* Make a place for REG_EQUAL. */
3716 emit_move_insn (operands[0], operands[0]);
3721 (define_expand "negdf2"
3722 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3723 (neg:DF (match_operand:DF 1 "general_operand" "")))]
3726 if (!TARGET_HARD_FLOAT)
3733 target = operand_subword (operands[0], 0, 1, DFmode);
3734 result = expand_binop (SImode, xor_optab,
3735 operand_subword_force (operands[1], 0, DFmode),
3736 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3737 gcc_assert (result);
3739 if (result != target)
3740 emit_move_insn (result, target);
3742 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3743 operand_subword_force (operands[1], 1, DFmode));
3745 insns = get_insns ();
3748 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3753 (define_expand "negxf2"
3754 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3755 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
3765 target = operand_subword (operands[0], 0, 1, XFmode);
3766 result = expand_binop (SImode, xor_optab,
3767 operand_subword_force (operands[1], 0, XFmode),
3768 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3769 gcc_assert (result);
3771 if (result != target)
3772 emit_move_insn (result, target);
3774 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
3775 operand_subword_force (operands[1], 1, XFmode));
3776 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
3777 operand_subword_force (operands[1], 2, XFmode));
3779 insns = get_insns ();
3782 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3787 (define_insn "neg<mode>2_68881"
3788 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3789 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
3792 if (DATA_REG_P (operands[0]))
3794 operands[1] = GEN_INT (31);
3795 return "bchg %1,%0";
3797 if (FP_REG_P (operands[1]))
3798 return "f<FP:round>neg%.x %1,%0";
3799 return "f<FP:round>neg%.<FP:prec> %f1,%0";
3802 (define_insn "neg<mode>2_cf"
3803 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3804 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
3805 "TARGET_COLDFIRE_FPU"
3807 if (DATA_REG_P (operands[0]))
3809 operands[1] = GEN_INT (31);
3810 return "bchg %1,%0";
3812 if (FP_REG_P (operands[1]))
3813 return "f<FP:prec>neg%.d %1,%0";
3814 return "f<FP:prec>neg%.<FP:prec> %1,%0";
3817 ;; Sqrt instruction for the 68881
3819 (define_expand "sqrt<mode>2"
3820 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3821 (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
3825 (define_insn "sqrt<mode>2_68881"
3826 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3827 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
3830 if (FP_REG_P (operands[1]))
3831 return "f<FP:round>sqrt%.x %1,%0";
3832 return "f<FP:round>sqrt%.<FP:prec> %1,%0";
3835 (define_insn "sqrt<mode>2_cf"
3836 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3837 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
3838 "TARGET_COLDFIRE_FPU"
3840 if (FP_REG_P (operands[1]))
3841 return "f<FP:prec>sqrt%.d %1,%0";
3842 return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
3844 ;; Absolute value instructions
3845 ;; If using software floating point, just zero the sign bit.
3847 (define_expand "abssf2"
3848 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3849 (abs:SF (match_operand:SF 1 "general_operand" "")))]
3852 if (!TARGET_HARD_FLOAT)
3857 target = operand_subword_force (operands[0], 0, SFmode);
3858 result = expand_binop (SImode, and_optab,
3859 operand_subword_force (operands[1], 0, SFmode),
3860 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3861 gcc_assert (result);
3863 if (result != target)
3864 emit_move_insn (result, target);
3866 /* Make a place for REG_EQUAL. */
3867 emit_move_insn (operands[0], operands[0]);
3872 (define_expand "absdf2"
3873 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3874 (abs:DF (match_operand:DF 1 "general_operand" "")))]
3877 if (!TARGET_HARD_FLOAT)
3884 target = operand_subword (operands[0], 0, 1, DFmode);
3885 result = expand_binop (SImode, and_optab,
3886 operand_subword_force (operands[1], 0, DFmode),
3887 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3888 gcc_assert (result);
3890 if (result != target)
3891 emit_move_insn (result, target);
3893 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3894 operand_subword_force (operands[1], 1, DFmode));
3896 insns = get_insns ();
3899 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3904 (define_expand "absxf2"
3905 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3906 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
3916 target = operand_subword (operands[0], 0, 1, XFmode);
3917 result = expand_binop (SImode, and_optab,
3918 operand_subword_force (operands[1], 0, XFmode),
3919 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3920 gcc_assert (result);
3922 if (result != target)
3923 emit_move_insn (result, target);
3925 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
3926 operand_subword_force (operands[1], 1, XFmode));
3927 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
3928 operand_subword_force (operands[1], 2, XFmode));
3930 insns = get_insns ();
3933 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3938 (define_insn "abs<mode>2_68881"
3939 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3940 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
3943 if (DATA_REG_P (operands[0]))
3945 operands[1] = GEN_INT (31);
3946 return "bclr %1,%0";
3948 if (FP_REG_P (operands[1]))
3949 return "f<FP:round>abs%.x %1,%0";
3950 return "f<FP:round>abs%.<FP:prec> %f1,%0";
3953 (define_insn "abs<mode>2_cf"
3954 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3955 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
3956 "TARGET_COLDFIRE_FPU"
3958 if (DATA_REG_P (operands[0]))
3960 operands[1] = GEN_INT (31);
3961 return "bclr %1,%0";
3963 if (FP_REG_P (operands[1]))
3964 return "f<FP:prec>abs%.d %1,%0";
3965 return "f<FP:prec>abs%.<FP:prec> %1,%0";
3968 ;; one complement instructions
3970 ;; "one_cmpldi2" is mainly here to help combine().
3971 (define_insn "one_cmpldi2"
3972 [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
3973 (not:DI (match_operand:DI 1 "general_operand" "0")))]
3977 if (GET_CODE (operands[0]) == REG)
3978 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3979 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
3980 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3981 operands[1] = operands[0];
3983 operands[1] = adjust_address (operands[0], SImode, 4);
3984 return "not%.l %1\;not%.l %0";
3987 (define_expand "one_cmplsi2"
3988 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3989 (not:SI (match_operand:SI 1 "general_operand" "")))]
3992 if (TARGET_COLDFIRE)
3993 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
3995 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
3999 (define_insn "one_cmplsi2_internal"
4000 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4001 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4005 (define_insn "one_cmplsi2_5200"
4006 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4007 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4011 (define_insn "one_cmplhi2"
4012 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4013 (not:HI (match_operand:HI 1 "general_operand" "0")))]
4018 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4019 (not:HI (match_dup 0)))]
4023 (define_insn "one_cmplqi2"
4024 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4025 (not:QI (match_operand:QI 1 "general_operand" "0")))]
4030 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4031 (not:QI (match_dup 0)))]
4035 ;; arithmetic shift instructions
4036 ;; We don't need the shift memory by 1 bit instruction
4038 (define_insn "ashldi_extsi"
4039 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4041 (match_operator:DI 2 "extend_operator"
4042 [(match_operand:SI 1 "general_operand" "rm")])
4047 if (GET_CODE (operands[0]) == REG)
4048 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4050 operands[2] = adjust_address (operands[0], SImode, 4);
4051 if (ADDRESS_REG_P (operands[0]))
4052 return "move%.l %1,%0\;sub%.l %2,%2";
4054 return "move%.l %1,%0\;clr%.l %2";
4057 (define_insn "ashldi_sexthi"
4058 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
4059 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
4061 (clobber (match_scratch:SI 2 "=a,X"))]
4065 if (GET_CODE (operands[0]) == MEM)
4067 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4068 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
4069 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4070 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
4073 operands[3] = adjust_address (operands[0], SImode, 4);
4074 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
4077 else if (DATA_REG_P (operands[0]))
4078 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
4080 return "move%.w %1,%0\;sub%.l %R0,%R0";
4083 (define_insn "ashldi_const32"
4084 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
4085 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
4090 if (GET_CODE (operands[1]) == REG)
4091 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4093 operands[3] = adjust_address (operands[1], SImode, 4);
4094 if (GET_CODE (operands[0]) == REG)
4095 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4096 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4097 return "clr%.l %0\;move%.l %3,%0";
4098 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4099 return "move%.l %3,%0\;clr%.l %0";
4101 operands[2] = adjust_address (operands[0], SImode, 4);
4102 if (ADDRESS_REG_P (operands[2]))
4103 return "move%.l %3,%0\;sub%.l %2,%2";
4105 return "move%.l %3,%0\;clr%.l %2";
4108 ;; The predicate below must be general_operand, because ashldi3 allows that
4109 (define_insn "ashldi_const"
4110 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4111 (ashift:DI (match_operand:DI 1 "general_operand" "0")
4112 (match_operand 2 "const_int_operand" "n")))]
4114 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4115 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4116 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4118 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4119 if (INTVAL (operands[2]) == 1)
4120 return "add%.l %1,%1\;addx%.l %0,%0";
4121 else if (INTVAL (operands[2]) == 8)
4122 return "rol%.l #8,%1\;rol%.l #8,%0\;move%.b %1,%0\;clr%.b %1";
4123 else if (INTVAL (operands[2]) == 16)
4124 return "swap %1\;swap %0\;move%.w %1,%0\;clr%.w %1";
4125 else if (INTVAL (operands[2]) == 48)
4126 return "mov%.l %1,%0\;swap %0\;clr%.l %1\;clr%.w %0";
4127 else if (INTVAL (operands[2]) == 2)
4128 return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
4129 else if (INTVAL (operands[2]) == 3)
4130 return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
4131 else /* 32 < INTVAL (operands[2]) <= 63 */
4133 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4134 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asl%.l %2,%1" :
4135 "moveq %2,%0\;asl%.l %0,%1", operands);
4136 return "mov%.l %1,%0\;moveq #0,%1";
4140 (define_expand "ashldi3"
4141 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4142 (ashift:DI (match_operand:DI 1 "general_operand" "")
4143 (match_operand 2 "const_int_operand" "")))]
4147 /* ??? This is a named pattern like this is not allowed to FAIL based
4149 if (GET_CODE (operands[2]) != CONST_INT
4150 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4151 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4152 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4156 ;; On most 68k models, this makes faster code in a special case.
4158 (define_insn "ashlsi_16"
4159 [(set (match_operand:SI 0 "register_operand" "=d")
4160 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4165 return "swap %0\;clr%.w %0";
4168 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
4169 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4171 ;; On the 68000, this makes faster code in a special case.
4173 (define_insn "ashlsi_17_24"
4174 [(set (match_operand:SI 0 "register_operand" "=d")
4175 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4176 (match_operand:SI 2 "const_int_operand" "n")))]
4178 && INTVAL (operands[2]) > 16
4179 && INTVAL (operands[2]) <= 24"
4183 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4184 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4187 (define_insn "ashlsi3"
4188 [(set (match_operand:SI 0 "register_operand" "=d")
4189 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4190 (match_operand:SI 2 "general_operand" "dI")))]
4193 if (operands[2] == const1_rtx)
4195 cc_status.flags = CC_NO_OVERFLOW;
4196 return "add%.l %0,%0";
4198 return "lsl%.l %2,%0";
4201 (define_insn "ashlhi3"
4202 [(set (match_operand:HI 0 "register_operand" "=d")
4203 (ashift:HI (match_operand:HI 1 "register_operand" "0")
4204 (match_operand:HI 2 "general_operand" "dI")))]
4209 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4210 (ashift:HI (match_dup 0)
4211 (match_operand:HI 1 "general_operand" "dI")))]
4215 (define_insn "ashlqi3"
4216 [(set (match_operand:QI 0 "register_operand" "=d")
4217 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4218 (match_operand:QI 2 "general_operand" "dI")))]
4223 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4224 (ashift:QI (match_dup 0)
4225 (match_operand:QI 1 "general_operand" "dI")))]
4229 ;; On most 68k models, this makes faster code in a special case.
4231 (define_insn "ashrsi_16"
4232 [(set (match_operand:SI 0 "register_operand" "=d")
4233 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4236 "swap %0\;ext%.l %0")
4238 ;; On the 68000, this makes faster code in a special case.
4241 [(set (match_operand:SI 0 "register_operand" "=d")
4242 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4243 (match_operand:SI 2 "const_int_operand" "n")))]
4245 && INTVAL (operands[2]) > 16
4246 && INTVAL (operands[2]) <= 24"
4248 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4249 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4252 (define_insn "subreghi1ashrdi_const32"
4253 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4254 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4255 (const_int 32)) 6))]
4258 if (GET_CODE (operands[1]) != REG)
4259 operands[1] = adjust_address (operands[1], HImode, 2);
4260 return "move%.w %1,%0";
4263 (define_insn "subregsi1ashrdi_const32"
4264 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4265 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4266 (const_int 32)) 4))]
4269 return "move%.l %1,%0";
4272 (define_insn "ashrdi_const32"
4273 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o,<")
4274 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4276 (clobber (match_scratch:SI 2 "=X,d,d"))]
4280 if (which_alternative == 0)
4282 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4284 return "move%.l %1,%2\;smi %0\;extb%.l %0";
4286 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
4290 if (which_alternative == 2)
4291 operands[3] = operands[0];
4292 else if (which_alternative == 1)
4293 operands[3] = adjust_address (operands[0], SImode, 4);
4295 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4297 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4301 ;; The predicate below must be general_operand, because ashrdi3 allows that
4302 (define_insn "ashrdi_const"
4303 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4304 (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
4305 (match_operand 2 "const_int_operand" "n")))
4306 (clobber (match_scratch:SI 3 "=X"))]
4308 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4309 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4310 || INTVAL (operands[2]) == 31
4311 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4313 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4314 if (INTVAL (operands[2]) == 63)
4315 return "add%.l %0,%0\;subx%.l %0,%0\;move%.l %0,%1";
4317 if (INTVAL (operands[2]) == 1)
4318 return "asr%.l #1,%0\;roxr%.l #1,%1";
4319 else if (INTVAL (operands[2]) == 8)
4320 return "move%.b %0,%1\;asr%.l #8,%0\;ror%.l #8,%1";
4321 else if (INTVAL (operands[2]) == 16)
4322 return "move%.w %0,%1\;swap %0\;ext%.l %0\;swap %1";
4323 else if (INTVAL (operands[2]) == 48)
4324 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4325 else if (INTVAL (operands[2]) == 31)
4326 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4327 else if (INTVAL (operands[2]) == 2)
4328 return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4329 else if (INTVAL (operands[2]) == 3)
4330 return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4331 else /* 32 < INTVAL (operands[2]) <= 63 */
4333 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4334 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4335 "moveq %2,%1\;asr%.l %1,%0", operands);
4336 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4337 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4338 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4342 (define_expand "ashrdi3"
4343 [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
4344 (ashiftrt:DI (match_operand:DI 1 "general_operand" "")
4345 (match_operand 2 "const_int_operand" "")))
4346 (clobber (match_scratch:SI 3 ""))])]
4350 /* ??? This is a named pattern like this is not allowed to FAIL based
4352 if (GET_CODE (operands[2]) != CONST_INT
4353 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4354 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4355 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4357 operands[3] = gen_rtx_SCRATCH (SImode);
4360 ;; On all 68k models, this makes faster code in a special case.
4362 (define_insn "ashrsi_31"
4363 [(set (match_operand:SI 0 "register_operand" "=d")
4364 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4368 return "add%.l %0,%0\;subx%.l %0,%0";
4371 (define_insn "ashrsi3"
4372 [(set (match_operand:SI 0 "register_operand" "=d")
4373 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4374 (match_operand:SI 2 "general_operand" "dI")))]
4378 (define_insn "ashrhi3"
4379 [(set (match_operand:HI 0 "register_operand" "=d")
4380 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4381 (match_operand:HI 2 "general_operand" "dI")))]
4386 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4387 (ashiftrt:HI (match_dup 0)
4388 (match_operand:HI 1 "general_operand" "dI")))]
4392 (define_insn "ashrqi3"
4393 [(set (match_operand:QI 0 "register_operand" "=d")
4394 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4395 (match_operand:QI 2 "general_operand" "dI")))]
4400 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4401 (ashiftrt:QI (match_dup 0)
4402 (match_operand:QI 1 "general_operand" "dI")))]
4406 ;; logical shift instructions
4408 ;; commented out because of reload problems in 950612-1.c
4411 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4412 ;; (const_int 32)) 4))
4413 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4414 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4415 ;; (const_int 32)) 4))]
4418 ;; return "move%.l %0,%1";
4423 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4424 ;; (const_int 32)) 0))
4425 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4426 ;; (lshiftrt:DI (match_dup 0)
4427 ;; (const_int 32)))]
4430 ;; if (GET_CODE (operands[1]) == REG)
4431 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4433 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4434 ;; return "move%.l %0,%2\;clr%.l %1";
4437 (define_insn "subreg1lshrdi_const32"
4438 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4439 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4440 (const_int 32)) 4))]
4443 return "move%.l %1,%0";
4446 (define_insn "lshrdi_const32"
4447 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro,<,>")
4448 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4453 if (which_alternative == 1)
4454 return "move%.l %1,%0\;clr%.l %0";
4455 if (which_alternative == 2)
4456 return "clr%.l %0\;move%.l %1,%0";
4457 if (GET_CODE (operands[0]) == REG)
4458 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4460 operands[2] = adjust_address (operands[0], SImode, 4);
4461 if (GET_CODE (operands[1]) == REG)
4462 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4464 operands[3] = adjust_address (operands[1], SImode, 4);
4465 if (ADDRESS_REG_P (operands[0]))
4466 return "move%.l %1,%2\;sub%.l %0,%0";
4468 return "move%.l %1,%2\;clr%.l %0";
4471 ;; The predicate below must be general_operand, because lshrdi3 allows that
4472 (define_insn "lshrdi_const"
4473 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4474 (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
4475 (match_operand 2 "const_int_operand" "n")))]
4477 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4478 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4479 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4481 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4482 if (INTVAL (operands[2]) == 63)
4483 return "add%.l %0,%0\;clr%.l %0\;clr%.l %1\;addx%.l %1,%1";
4485 if (INTVAL (operands[2]) == 1)
4486 return "lsr%.l #1,%0\;roxr%.l #1,%1";
4487 else if (INTVAL (operands[2]) == 8)
4488 return "move%.b %0,%1\;lsr%.l #8,%0\;ror%.l #8,%1";
4489 else if (INTVAL (operands[2]) == 16)
4490 return "move%.w %0,%1\;clr%.w %0\;swap %1\;swap %0";
4491 else if (INTVAL (operands[2]) == 48)
4492 return "move%.l %0,%1\;clr%.w %1\;clr%.l %0\;swap %1";
4493 else if (INTVAL (operands[2]) == 2)
4494 return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4495 else if (INTVAL (operands[2]) == 3)
4496 return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4497 else /* 32 < INTVAL (operands[2]) <= 63 */
4499 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4500 output_asm_insn (INTVAL (operands[2]) <= 8 ? "lsr%.l %2,%0" :
4501 "moveq %2,%1\;lsr%.l %1,%0", operands);
4502 return "mov%.l %0,%1\;moveq #0,%0";
4506 (define_expand "lshrdi3"
4507 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4508 (lshiftrt:DI (match_operand:DI 1 "general_operand" "")
4509 (match_operand 2 "const_int_operand" "")))]
4512 /* ??? This is a named pattern like this is not allowed to FAIL based
4514 if (GET_CODE (operands[2]) != CONST_INT
4515 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4516 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4517 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4521 ;; On all 68k models, this makes faster code in a special case.
4523 (define_insn "lshrsi_31"
4524 [(set (match_operand:SI 0 "register_operand" "=d")
4525 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4529 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
4532 ;; On most 68k models, this makes faster code in a special case.
4534 (define_insn "lshrsi_16"
4535 [(set (match_operand:SI 0 "register_operand" "=d")
4536 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4541 return "clr%.w %0\;swap %0";
4544 ;; On the 68000, this makes faster code in a special case.
4546 (define_insn "lshrsi_17_24"
4547 [(set (match_operand:SI 0 "register_operand" "=d")
4548 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4549 (match_operand:SI 2 "const_int_operand" "n")))]
4551 && INTVAL (operands[2]) > 16
4552 && INTVAL (operands[2]) <= 24"
4554 /* I think lsr%.w sets the CC properly. */
4555 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4556 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
4559 (define_insn "lshrsi3"
4560 [(set (match_operand:SI 0 "register_operand" "=d")
4561 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4562 (match_operand:SI 2 "general_operand" "dI")))]
4566 (define_insn "lshrhi3"
4567 [(set (match_operand:HI 0 "register_operand" "=d")
4568 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
4569 (match_operand:HI 2 "general_operand" "dI")))]
4574 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4575 (lshiftrt:HI (match_dup 0)
4576 (match_operand:HI 1 "general_operand" "dI")))]
4580 (define_insn "lshrqi3"
4581 [(set (match_operand:QI 0 "register_operand" "=d")
4582 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
4583 (match_operand:QI 2 "general_operand" "dI")))]
4588 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4589 (lshiftrt:QI (match_dup 0)
4590 (match_operand:QI 1 "general_operand" "dI")))]
4594 ;; rotate instructions
4596 (define_insn "rotlsi3"
4597 [(set (match_operand:SI 0 "register_operand" "=d")
4598 (rotate:SI (match_operand:SI 1 "register_operand" "0")
4599 (match_operand:SI 2 "general_operand" "dINO")))]
4602 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
4604 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
4606 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4607 return "ror%.l %2,%0";
4610 return "rol%.l %2,%0";
4613 (define_insn "rotlhi3"
4614 [(set (match_operand:HI 0 "register_operand" "=d")
4615 (rotate:HI (match_operand:HI 1 "register_operand" "0")
4616 (match_operand:HI 2 "general_operand" "dIP")))]
4619 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4621 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4622 return "ror%.w %2,%0";
4625 return "rol%.w %2,%0";
4629 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4630 (rotate:HI (match_dup 0)
4631 (match_operand:HI 1 "general_operand" "dIP")))]
4634 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4636 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4637 return "ror%.w %2,%0";
4640 return "rol%.w %2,%0";
4643 (define_insn "rotlqi3"
4644 [(set (match_operand:QI 0 "register_operand" "=d")
4645 (rotate:QI (match_operand:QI 1 "register_operand" "0")
4646 (match_operand:QI 2 "general_operand" "dI")))]
4649 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4651 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4652 return "ror%.b %2,%0";
4655 return "rol%.b %2,%0";
4659 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4660 (rotate:QI (match_dup 0)
4661 (match_operand:QI 1 "general_operand" "dI")))]
4664 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4666 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4667 return "ror%.b %2,%0";
4670 return "rol%.b %2,%0";
4673 (define_insn "rotrsi3"
4674 [(set (match_operand:SI 0 "register_operand" "=d")
4675 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
4676 (match_operand:SI 2 "general_operand" "dI")))]
4680 (define_insn "rotrhi3"
4681 [(set (match_operand:HI 0 "register_operand" "=d")
4682 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
4683 (match_operand:HI 2 "general_operand" "dI")))]
4688 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4689 (rotatert:HI (match_dup 0)
4690 (match_operand:HI 1 "general_operand" "dI")))]
4694 (define_insn "rotrqi3"
4695 [(set (match_operand:QI 0 "register_operand" "=d")
4696 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
4697 (match_operand:QI 2 "general_operand" "dI")))]
4702 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4703 (rotatert:QI (match_dup 0)
4704 (match_operand:QI 1 "general_operand" "dI")))]
4709 ;; Bit set/clear in memory byte.
4711 ;; set bit, bit number is int
4712 (define_insn "bsetmemqi"
4713 [(set (match_operand:QI 0 "memory_operand" "+m")
4714 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4715 (match_operand:SI 1 "general_operand" "d")) 3)
4720 return "bset %1,%0";
4723 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
4725 [(set (match_operand:QI 0 "memory_operand" "+m")
4726 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4727 (match_operator:SI 2 "extend_operator"
4728 [(match_operand 1 "general_operand" "d")])) 3)
4733 return "bset %1,%0";
4736 ;; clear bit, bit number is int
4737 (define_insn "bclrmemqi"
4738 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4740 (minus:SI (const_int 7)
4741 (match_operand:SI 1 "general_operand" "d")))
4746 return "bclr %1,%0";
4749 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
4751 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4753 (minus:SI (const_int 7)
4754 (match_operator:SI 2 "extend_operator"
4755 [(match_operand 1 "general_operand" "d")])))
4760 return "bclr %1,%0";
4763 ;; Special cases of bit-field insns which we should
4764 ;; recognize in preference to the general case.
4765 ;; These handle aligned 8-bit and 16-bit fields,
4766 ;; which can usually be done with move instructions.
4769 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4770 ; alignment of structure members is specified.
4772 ; The move is allowed to be odd byte aligned, because that's still faster
4773 ; than an odd byte aligned bit-field instruction.
4776 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4778 (match_operand:SI 1 "const_int_operand" "n"))
4779 (match_operand:SI 2 "general_src_operand" "rmSi"))]
4780 "TARGET_68020 && TARGET_BITFIELD
4781 && (INTVAL (operands[1]) % 8) == 0
4782 && ! mode_dependent_address_p (XEXP (operands[0], 0))"
4785 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
4787 return "move%.l %2,%0";
4791 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
4792 (match_operand:SI 1 "const_int_operand" "n")
4793 (match_operand:SI 2 "const_int_operand" "n"))
4794 (match_operand:SI 3 "register_operand" "d"))]
4795 "TARGET_68020 && TARGET_BITFIELD
4796 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
4797 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
4798 && (GET_CODE (operands[0]) == REG
4799 || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
4801 if (REG_P (operands[0]))
4803 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
4804 return "bfins %3,%0{%b2:%b1}";
4807 operands[0] = adjust_address (operands[0],
4808 INTVAL (operands[1]) == 8 ? QImode : HImode,
4809 INTVAL (operands[2]) / 8);
4811 if (GET_CODE (operands[3]) == MEM)
4812 operands[3] = adjust_address (operands[3],
4813 INTVAL (operands[1]) == 8 ? QImode : HImode,
4814 (32 - INTVAL (operands[1])) / 8);
4816 if (INTVAL (operands[1]) == 8)
4817 return "move%.b %3,%0";
4818 return "move%.w %3,%0";
4823 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4824 ; alignment of structure members is specified.
4826 ; The move is allowed to be odd byte aligned, because that's still faster
4827 ; than an odd byte aligned bit-field instruction.
4830 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4831 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4833 (match_operand:SI 2 "const_int_operand" "n")))]
4834 "TARGET_68020 && TARGET_BITFIELD
4835 && (INTVAL (operands[2]) % 8) == 0
4836 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4839 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4841 return "move%.l %1,%0";
4845 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
4846 (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
4847 (match_operand:SI 2 "const_int_operand" "n")
4848 (match_operand:SI 3 "const_int_operand" "n")))]
4849 "TARGET_68020 && TARGET_BITFIELD
4850 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4851 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4852 && (GET_CODE (operands[1]) == REG
4853 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4855 cc_status.flags |= CC_NOT_NEGATIVE;
4856 if (REG_P (operands[1]))
4858 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4859 return "bfextu %1{%b3:%b2},%0";
4863 = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
4865 output_asm_insn ("clr%.l %0", operands);
4866 if (GET_CODE (operands[0]) == MEM)
4867 operands[0] = adjust_address (operands[0],
4868 INTVAL (operands[2]) == 8 ? QImode : HImode,
4869 (32 - INTVAL (operands[1])) / 8);
4871 if (INTVAL (operands[2]) == 8)
4872 return "move%.b %1,%0";
4873 return "move%.w %1,%0";
4877 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4878 ; alignment of structure members is specified.
4880 ; The move is allowed to be odd byte aligned, because that's still faster
4881 ; than an odd byte aligned bit-field instruction.
4884 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4885 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4887 (match_operand:SI 2 "const_int_operand" "n")))]
4888 "TARGET_68020 && TARGET_BITFIELD
4889 && (INTVAL (operands[2]) % 8) == 0
4890 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4893 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4895 return "move%.l %1,%0";
4899 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4900 (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
4901 (match_operand:SI 2 "const_int_operand" "n")
4902 (match_operand:SI 3 "const_int_operand" "n")))]
4903 "TARGET_68020 && TARGET_BITFIELD
4904 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4905 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4906 && (GET_CODE (operands[1]) == REG
4907 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4909 if (REG_P (operands[1]))
4911 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4912 return "bfexts %1{%b3:%b2},%0";
4916 = adjust_address (operands[1],
4917 INTVAL (operands[2]) == 8 ? QImode : HImode,
4918 INTVAL (operands[3]) / 8);
4920 if (INTVAL (operands[2]) == 8)
4921 return "move%.b %1,%0\;extb%.l %0";
4922 return "move%.w %1,%0\;ext%.l %0";
4925 ;; Bit-field instructions, general cases.
4926 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
4927 ;; so that its address is reloaded.
4929 (define_expand "extv"
4930 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4931 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
4932 (match_operand:SI 2 "general_operand" "")
4933 (match_operand:SI 3 "general_operand" "")))]
4934 "TARGET_68020 && TARGET_BITFIELD"
4938 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4939 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
4940 (match_operand:SI 2 "general_operand" "dn")
4941 (match_operand:SI 3 "general_operand" "dn")))]
4942 "TARGET_68020 && TARGET_BITFIELD"
4943 "bfexts %1{%b3:%b2},%0")
4945 (define_expand "extzv"
4946 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4947 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
4948 (match_operand:SI 2 "general_operand" "")
4949 (match_operand:SI 3 "general_operand" "")))]
4950 "TARGET_68020 && TARGET_BITFIELD"
4954 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d")
4955 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o,d")
4956 (match_operand:SI 2 "general_operand" "dn,dn")
4957 (match_operand:SI 3 "general_operand" "dn,dn")))]
4958 "TARGET_68020 && TARGET_BITFIELD"
4960 if (GET_CODE (operands[2]) == CONST_INT)
4962 if (INTVAL (operands[2]) != 32)
4963 cc_status.flags |= CC_NOT_NEGATIVE;
4969 return "bfextu %1{%b3:%b2},%0";
4973 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4974 (match_operand:SI 1 "general_operand" "dn")
4975 (match_operand:SI 2 "general_operand" "dn"))
4976 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
4977 (match_operand 3 "const_int_operand" "n")))]
4978 "TARGET_68020 && TARGET_BITFIELD
4979 && (INTVAL (operands[3]) == -1
4980 || (GET_CODE (operands[1]) == CONST_INT
4981 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
4984 return "bfchg %0{%b2:%b1}";
4988 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4989 (match_operand:SI 1 "general_operand" "dn")
4990 (match_operand:SI 2 "general_operand" "dn"))
4992 "TARGET_68020 && TARGET_BITFIELD"
4995 return "bfclr %0{%b2:%b1}";
4999 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5000 (match_operand:SI 1 "general_operand" "dn")
5001 (match_operand:SI 2 "general_operand" "dn"))
5003 "TARGET_68020 && TARGET_BITFIELD"
5006 return "bfset %0{%b2:%b1}";
5009 (define_expand "insv"
5010 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5011 (match_operand:SI 1 "general_operand" "")
5012 (match_operand:SI 2 "general_operand" ""))
5013 (match_operand:SI 3 "register_operand" ""))]
5014 "TARGET_68020 && TARGET_BITFIELD"
5018 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5019 (match_operand:SI 1 "general_operand" "dn")
5020 (match_operand:SI 2 "general_operand" "dn"))
5021 (match_operand:SI 3 "register_operand" "d"))]
5022 "TARGET_68020 && TARGET_BITFIELD"
5023 "bfins %3,%0{%b2:%b1}")
5025 ;; Now recognize bit-field insns that operate on registers
5026 ;; (or at least were intended to do so).
5029 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5030 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5031 (match_operand:SI 2 "general_operand" "dn")
5032 (match_operand:SI 3 "general_operand" "dn")))]
5033 "TARGET_68020 && TARGET_BITFIELD"
5034 "bfexts %1{%b3:%b2},%0")
5037 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5038 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5039 (match_operand:SI 2 "general_operand" "dn")
5040 (match_operand:SI 3 "general_operand" "dn")))]
5041 "TARGET_68020 && TARGET_BITFIELD"
5043 if (GET_CODE (operands[2]) == CONST_INT)
5045 if (INTVAL (operands[2]) != 32)
5046 cc_status.flags |= CC_NOT_NEGATIVE;
5052 return "bfextu %1{%b3:%b2},%0";
5056 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5057 (match_operand:SI 1 "general_operand" "dn")
5058 (match_operand:SI 2 "general_operand" "dn"))
5060 "TARGET_68020 && TARGET_BITFIELD"
5063 return "bfclr %0{%b2:%b1}";
5067 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5068 (match_operand:SI 1 "general_operand" "dn")
5069 (match_operand:SI 2 "general_operand" "dn"))
5071 "TARGET_68020 && TARGET_BITFIELD"
5074 return "bfset %0{%b2:%b1}";
5078 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5079 (match_operand:SI 1 "general_operand" "dn")
5080 (match_operand:SI 2 "general_operand" "dn"))
5081 (match_operand:SI 3 "register_operand" "d"))]
5082 "TARGET_68020 && TARGET_BITFIELD"
5085 /* These special cases are now recognized by a specific pattern. */
5086 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5087 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5088 return "move%.w %3,%0";
5089 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5090 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5091 return "move%.b %3,%0";
5093 return "bfins %3,%0{%b2:%b1}";
5096 ;; Special patterns for optimizing bit-field instructions.
5100 (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5101 (match_operand:SI 1 "const_int_operand" "n")
5102 (match_operand:SI 2 "general_operand" "dn")))]
5103 "TARGET_68020 && TARGET_BITFIELD"
5105 if (operands[1] == const1_rtx
5106 && GET_CODE (operands[2]) == CONST_INT)
5108 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5109 return output_btst (operands,
5110 GEN_INT (width - INTVAL (operands[2])),
5111 operands[0], insn, 1000);
5112 /* Pass 1000 as SIGNPOS argument so that btst will
5113 not think we are testing the sign bit for an `and'
5114 and assume that nonzero implies a negative result. */
5116 if (INTVAL (operands[1]) != 32)
5117 cc_status.flags = CC_NOT_NEGATIVE;
5118 return "bftst %0{%b2:%b1}";
5122 ;;; now handle the register cases
5125 (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5126 (match_operand:SI 1 "const_int_operand" "n")
5127 (match_operand:SI 2 "general_operand" "dn")))]
5128 "TARGET_68020 && TARGET_BITFIELD"
5130 if (operands[1] == const1_rtx
5131 && GET_CODE (operands[2]) == CONST_INT)
5133 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5134 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5135 operands[0], insn, 1000);
5136 /* Pass 1000 as SIGNPOS argument so that btst will
5137 not think we are testing the sign bit for an `and'
5138 and assume that nonzero implies a negative result. */
5140 if (INTVAL (operands[1]) != 32)
5141 cc_status.flags = CC_NOT_NEGATIVE;
5142 return "bftst %0{%b2:%b1}";
5145 (define_insn "scc0_di"
5146 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5147 (match_operator 1 "valid_dbcc_comparison_p"
5148 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5151 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5154 (define_insn "scc0_di_5200"
5155 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5156 (match_operator 1 "valid_dbcc_comparison_p"
5157 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5160 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5163 (define_insn "scc_di"
5164 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5165 (match_operator 1 "valid_dbcc_comparison_p"
5166 [(match_operand:DI 2 "general_operand" "ro,r")
5167 (match_operand:DI 3 "general_operand" "r,ro")]))]
5170 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5173 (define_insn "scc_di_5200"
5174 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5175 (match_operator 1 "valid_dbcc_comparison_p"
5176 [(match_operand:DI 2 "general_operand" "ro,r")
5177 (match_operand:DI 3 "general_operand" "r,ro")]))]
5180 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5183 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5184 ;; memory, but we cannot allow it to be in memory in case the address
5185 ;; needs to be reloaded.
5187 (define_expand "seq"
5188 [(set (match_operand:QI 0 "register_operand" "")
5189 (eq:QI (cc0) (const_int 0)))]
5192 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5193 && m68k_last_compare_had_fp_operands)
5195 m68k_last_compare_had_fp_operands = 0;
5201 [(set (match_operand:QI 0 "register_operand" "=d")
5202 (eq:QI (cc0) (const_int 0)))]
5205 cc_status = cc_prev_status;
5206 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5209 (define_expand "sne"
5210 [(set (match_operand:QI 0 "register_operand" "")
5211 (ne:QI (cc0) (const_int 0)))]
5214 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5215 && m68k_last_compare_had_fp_operands)
5217 m68k_last_compare_had_fp_operands = 0;
5223 [(set (match_operand:QI 0 "register_operand" "=d")
5224 (ne:QI (cc0) (const_int 0)))]
5227 cc_status = cc_prev_status;
5228 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5231 (define_expand "sgt"
5232 [(set (match_operand:QI 0 "register_operand" "")
5233 (gt:QI (cc0) (const_int 0)))]
5236 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5237 && m68k_last_compare_had_fp_operands)
5239 m68k_last_compare_had_fp_operands = 0;
5245 [(set (match_operand:QI 0 "register_operand" "=d")
5246 (gt:QI (cc0) (const_int 0)))]
5249 cc_status = cc_prev_status;
5250 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5253 (define_expand "sgtu"
5254 [(set (match_operand:QI 0 "register_operand" "")
5255 (gtu:QI (cc0) (const_int 0)))]
5260 [(set (match_operand:QI 0 "register_operand" "=d")
5261 (gtu:QI (cc0) (const_int 0)))]
5264 cc_status = cc_prev_status;
5268 (define_expand "slt"
5269 [(set (match_operand:QI 0 "register_operand" "")
5270 (lt:QI (cc0) (const_int 0)))]
5273 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5274 && m68k_last_compare_had_fp_operands)
5276 m68k_last_compare_had_fp_operands = 0;
5282 [(set (match_operand:QI 0 "register_operand" "=d")
5283 (lt:QI (cc0) (const_int 0)))]
5286 cc_status = cc_prev_status;
5287 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5290 (define_expand "sltu"
5291 [(set (match_operand:QI 0 "register_operand" "")
5292 (ltu:QI (cc0) (const_int 0)))]
5297 [(set (match_operand:QI 0 "register_operand" "=d")
5298 (ltu:QI (cc0) (const_int 0)))]
5301 cc_status = cc_prev_status;
5305 (define_expand "sge"
5306 [(set (match_operand:QI 0 "register_operand" "")
5307 (ge:QI (cc0) (const_int 0)))]
5310 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5311 && m68k_last_compare_had_fp_operands)
5313 m68k_last_compare_had_fp_operands = 0;
5319 [(set (match_operand:QI 0 "register_operand" "=d")
5320 (ge:QI (cc0) (const_int 0)))]
5323 cc_status = cc_prev_status;
5324 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5327 (define_expand "sgeu"
5328 [(set (match_operand:QI 0 "register_operand" "")
5329 (geu:QI (cc0) (const_int 0)))]
5334 [(set (match_operand:QI 0 "register_operand" "=d")
5335 (geu:QI (cc0) (const_int 0)))]
5338 cc_status = cc_prev_status;
5342 (define_expand "sle"
5343 [(set (match_operand:QI 0 "register_operand" "")
5344 (le:QI (cc0) (const_int 0)))]
5347 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5348 && m68k_last_compare_had_fp_operands)
5350 m68k_last_compare_had_fp_operands = 0;
5356 [(set (match_operand:QI 0 "register_operand" "=d")
5357 (le:QI (cc0) (const_int 0)))]
5360 cc_status = cc_prev_status;
5361 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5364 (define_expand "sleu"
5365 [(set (match_operand:QI 0 "register_operand" "")
5366 (leu:QI (cc0) (const_int 0)))]
5371 [(set (match_operand:QI 0 "register_operand" "=d")
5372 (leu:QI (cc0) (const_int 0)))]
5375 cc_status = cc_prev_status;
5379 (define_expand "sordered"
5380 [(set (match_operand:QI 0 "register_operand" "")
5381 (ordered:QI (cc0) (const_int 0)))]
5382 "TARGET_68881 && !TUNE_68060"
5384 gcc_assert (m68k_last_compare_had_fp_operands);
5385 m68k_last_compare_had_fp_operands = 0;
5388 (define_insn "*sordered_1"
5389 [(set (match_operand:QI 0 "register_operand" "=d")
5390 (ordered:QI (cc0) (const_int 0)))]
5391 "TARGET_68881 && !TUNE_68060"
5393 cc_status = cc_prev_status;
5397 (define_expand "sunordered"
5398 [(set (match_operand:QI 0 "register_operand" "")
5399 (unordered:QI (cc0) (const_int 0)))]
5400 "TARGET_68881 && !TUNE_68060"
5402 gcc_assert (m68k_last_compare_had_fp_operands);
5403 m68k_last_compare_had_fp_operands = 0;
5406 (define_insn "*sunordered_1"
5407 [(set (match_operand:QI 0 "register_operand" "=d")
5408 (unordered:QI (cc0) (const_int 0)))]
5409 "TARGET_68881 && !TUNE_68060"
5411 cc_status = cc_prev_status;
5415 (define_expand "suneq"
5416 [(set (match_operand:QI 0 "register_operand" "")
5417 (uneq:QI (cc0) (const_int 0)))]
5418 "TARGET_68881 && !TUNE_68060"
5420 gcc_assert (m68k_last_compare_had_fp_operands);
5421 m68k_last_compare_had_fp_operands = 0;
5424 (define_insn "*suneq_1"
5425 [(set (match_operand:QI 0 "register_operand" "=d")
5426 (uneq:QI (cc0) (const_int 0)))]
5427 "TARGET_68881 && !TUNE_68060"
5429 cc_status = cc_prev_status;
5433 (define_expand "sunge"
5434 [(set (match_operand:QI 0 "register_operand" "")
5435 (unge:QI (cc0) (const_int 0)))]
5436 "TARGET_68881 && !TUNE_68060"
5438 gcc_assert (m68k_last_compare_had_fp_operands);
5439 m68k_last_compare_had_fp_operands = 0;
5442 (define_insn "*sunge_1"
5443 [(set (match_operand:QI 0 "register_operand" "=d")
5444 (unge:QI (cc0) (const_int 0)))]
5445 "TARGET_68881 && !TUNE_68060"
5447 cc_status = cc_prev_status;
5451 (define_expand "sungt"
5452 [(set (match_operand:QI 0 "register_operand" "")
5453 (ungt:QI (cc0) (const_int 0)))]
5454 "TARGET_68881 && !TUNE_68060"
5456 gcc_assert (m68k_last_compare_had_fp_operands);
5457 m68k_last_compare_had_fp_operands = 0;
5460 (define_insn "*sungt_1"
5461 [(set (match_operand:QI 0 "register_operand" "=d")
5462 (ungt:QI (cc0) (const_int 0)))]
5463 "TARGET_68881 && !TUNE_68060"
5465 cc_status = cc_prev_status;
5469 (define_expand "sunle"
5470 [(set (match_operand:QI 0 "register_operand" "")
5471 (unle:QI (cc0) (const_int 0)))]
5472 "TARGET_68881 && !TUNE_68060"
5474 gcc_assert (m68k_last_compare_had_fp_operands);
5475 m68k_last_compare_had_fp_operands = 0;
5478 (define_insn "*sunle_1"
5479 [(set (match_operand:QI 0 "register_operand" "=d")
5480 (unle:QI (cc0) (const_int 0)))]
5481 "TARGET_68881 && !TUNE_68060"
5483 cc_status = cc_prev_status;
5487 (define_expand "sunlt"
5488 [(set (match_operand:QI 0 "register_operand" "")
5489 (unlt:QI (cc0) (const_int 0)))]
5490 "TARGET_68881 && !TUNE_68060"
5492 gcc_assert (m68k_last_compare_had_fp_operands);
5493 m68k_last_compare_had_fp_operands = 0;
5496 (define_insn "*sunlt_1"
5497 [(set (match_operand:QI 0 "register_operand" "=d")
5498 (unlt:QI (cc0) (const_int 0)))]
5499 "TARGET_68881 && !TUNE_68060"
5501 cc_status = cc_prev_status;
5505 (define_expand "sltgt"
5506 [(set (match_operand:QI 0 "register_operand" "")
5507 (ltgt:QI (cc0) (const_int 0)))]
5508 "TARGET_68881 && !TUNE_68060"
5510 gcc_assert (m68k_last_compare_had_fp_operands);
5511 m68k_last_compare_had_fp_operands = 0;
5514 (define_insn "*sltgt_1"
5515 [(set (match_operand:QI 0 "register_operand" "=d")
5516 (ltgt:QI (cc0) (const_int 0)))]
5517 "TARGET_68881 && !TUNE_68060"
5519 cc_status = cc_prev_status;
5523 (define_insn "*fsogt_1"
5524 [(set (match_operand:QI 0 "register_operand" "=d")
5525 (not:QI (unle:QI (cc0) (const_int 0))))]
5526 "TARGET_68881 && !TUNE_68060"
5528 cc_status = cc_prev_status;
5532 (define_insn "*fsoge_1"
5533 [(set (match_operand:QI 0 "register_operand" "=d")
5534 (not:QI (unlt:QI (cc0) (const_int 0))))]
5535 "TARGET_68881 && !TUNE_68060"
5537 cc_status = cc_prev_status;
5541 (define_insn "*fsolt_1"
5542 [(set (match_operand:QI 0 "register_operand" "=d")
5543 (not:QI (unge:QI (cc0) (const_int 0))))]
5544 "TARGET_68881 && !TUNE_68060"
5546 cc_status = cc_prev_status;
5550 (define_insn "*fsole_1"
5551 [(set (match_operand:QI 0 "register_operand" "=d")
5552 (not:QI (ungt:QI (cc0) (const_int 0))))]
5553 "TARGET_68881 && !TUNE_68060"
5555 cc_status = cc_prev_status;
5559 ;; Basic conditional jump instructions.
5561 (define_insn "beq0_di"
5563 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
5565 (label_ref (match_operand 1 "" ","))
5567 (clobber (match_scratch:SI 2 "=d,d"))]
5571 if (which_alternative == 1)
5574 return "move%.l %0,%2\;or%.l %0,%2\;jbeq %l1";
5576 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5578 if ((cc_prev_status.value1
5579 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5580 || (cc_prev_status.value2
5581 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5583 cc_status = cc_prev_status;
5584 return MOTOROLA ? "jbeq %l1" : "jeq %l1";
5586 if (GET_CODE (operands[0]) == REG)
5587 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5589 operands[3] = adjust_address (operands[0], SImode, 4);
5590 if (! ADDRESS_REG_P (operands[0]))
5592 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5594 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5597 return "or%.l %0,%2\;jbeq %l1";
5599 return "or%.l %0,%2\;jeq %l1";
5604 return "or%.l %3,%2\;jbeq %l1";
5606 return "or%.l %3,%2\;jeq %l1";
5610 return "move%.l %0,%2\;or%.l %3,%2\;jbeq %l1";
5612 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5614 operands[4] = gen_label_rtx();
5615 if (TARGET_68020 || TARGET_COLDFIRE)
5618 output_asm_insn ("tst%.l %0\;jbne %l4\;tst%.l %3\;jbeq %l1", operands);
5620 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
5625 output_asm_insn ("cmp%.w #0,%0\;jbne %l4\;cmp%.w #0,%3\;jbeq %l1", operands);
5627 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
5629 (*targetm.asm_out.internal_label) (asm_out_file, "L",
5630 CODE_LABEL_NUMBER (operands[4]));
5634 (define_insn "bne0_di"
5636 (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
5638 (label_ref (match_operand 1 "" ","))
5640 (clobber (match_scratch:SI 2 "=d,X"))]
5643 if ((cc_prev_status.value1
5644 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5645 || (cc_prev_status.value2
5646 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5648 cc_status = cc_prev_status;
5649 return MOTOROLA ? "jbne %l1" : "jne %l1";
5652 if (GET_CODE (operands[0]) == REG)
5653 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5655 operands[3] = adjust_address (operands[0], SImode, 4);
5656 if (!ADDRESS_REG_P (operands[0]))
5658 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5660 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5663 return "or%.l %0,%2\;jbne %l1";
5665 return "or%.l %0,%2\;jne %l1";
5670 return "or%.l %3,%2\;jbne %l1";
5672 return "or%.l %3,%2\;jne %l1";
5676 return "move%.l %0,%2\;or%.l %3,%2\;jbne %l1";
5678 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
5680 if (TARGET_68020 || TARGET_COLDFIRE)
5683 return "tst%.l %0\;jbne %l1\;tst%.l %3\;jbne %l1";
5685 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
5690 return "cmp%.w #0,%0\;jbne %l1\;cmp%.w #0,%3\;jbne %l1";
5692 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
5696 (define_insn "bge0_di"
5698 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
5700 (label_ref (match_operand 1 "" ""))
5704 if ((cc_prev_status.value1
5705 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5706 || (cc_prev_status.value2
5707 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5709 cc_status = cc_prev_status;
5710 if (cc_status.flags & CC_REVERSED)
5712 return MOTOROLA ? "jble %l1" : "jle %l1";
5716 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5720 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5721 output_asm_insn("tst%.l %0", operands);
5724 /* On an address reg, cmpw may replace cmpl. */
5725 output_asm_insn("cmp%.w #0,%0", operands);
5727 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5730 (define_insn "blt0_di"
5732 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
5734 (label_ref (match_operand 1 "" ""))
5738 if ((cc_prev_status.value1
5739 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5740 || (cc_prev_status.value2
5741 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5743 cc_status = cc_prev_status;
5744 if (cc_status.flags & CC_REVERSED)
5746 return MOTOROLA ? "jbgt %l1" : "jgt %l1";
5750 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5754 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5755 output_asm_insn("tst%.l %0", operands);
5758 /* On an address reg, cmpw may replace cmpl. */
5759 output_asm_insn("cmp%.w #0,%0", operands);
5762 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5767 (if_then_else (eq (cc0)
5769 (label_ref (match_operand 0 "" ""))
5774 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5776 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5781 (if_then_else (ne (cc0)
5783 (label_ref (match_operand 0 "" ""))
5788 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5790 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5795 (if_then_else (gt (cc0)
5797 (label_ref (match_operand 0 "" ""))
5802 OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0);
5804 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
5809 (if_then_else (gtu (cc0)
5811 (label_ref (match_operand 0 "" ""))
5815 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5820 (if_then_else (lt (cc0)
5822 (label_ref (match_operand 0 "" ""))
5827 OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0");
5829 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
5834 (if_then_else (ltu (cc0)
5836 (label_ref (match_operand 0 "" ""))
5840 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5845 (if_then_else (ge (cc0)
5847 (label_ref (match_operand 0 "" ""))
5852 OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0");
5854 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
5859 (if_then_else (geu (cc0)
5861 (label_ref (match_operand 0 "" ""))
5865 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5870 (if_then_else (le (cc0)
5872 (label_ref (match_operand 0 "" ""))
5877 OUTPUT_JUMP ("jble %l0", "fble %l0", 0);
5879 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
5884 (if_then_else (leu (cc0)
5886 (label_ref (match_operand 0 "" ""))
5890 return MOTOROLA ? "jbls %l0" : "jls %l0";
5893 (define_insn "bordered"
5895 (if_then_else (ordered (cc0) (const_int 0))
5896 (label_ref (match_operand 0 "" ""))
5900 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5901 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5904 (define_insn "bunordered"
5906 (if_then_else (unordered (cc0) (const_int 0))
5907 (label_ref (match_operand 0 "" ""))
5911 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5912 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5915 (define_insn "buneq"
5917 (if_then_else (uneq (cc0) (const_int 0))
5918 (label_ref (match_operand 0 "" ""))
5922 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5923 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5926 (define_insn "bunge"
5928 (if_then_else (unge (cc0) (const_int 0))
5929 (label_ref (match_operand 0 "" ""))
5933 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5934 return MOTOROLA ? "fbuge %l0" : "fjuge %l0";
5937 (define_insn "bungt"
5939 (if_then_else (ungt (cc0) (const_int 0))
5940 (label_ref (match_operand 0 "" ""))
5944 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5945 return MOTOROLA ? "fbugt %l0" : "fjugt %l0";
5948 (define_insn "bunle"
5950 (if_then_else (unle (cc0) (const_int 0))
5951 (label_ref (match_operand 0 "" ""))
5955 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5956 return MOTOROLA ? "fbule %l0" : "fjule %l0";
5959 (define_insn "bunlt"
5961 (if_then_else (unlt (cc0) (const_int 0))
5962 (label_ref (match_operand 0 "" ""))
5966 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5967 return MOTOROLA ? "fbult %l0" : "fjult %l0";
5970 (define_insn "bltgt"
5972 (if_then_else (ltgt (cc0) (const_int 0))
5973 (label_ref (match_operand 0 "" ""))
5977 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5978 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5981 ;; Negated conditional jump instructions.
5985 (if_then_else (eq (cc0)
5988 (label_ref (match_operand 0 "" ""))))]
5992 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5994 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5999 (if_then_else (ne (cc0)
6002 (label_ref (match_operand 0 "" ""))))]
6006 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
6008 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6013 (if_then_else (gt (cc0)
6016 (label_ref (match_operand 0 "" ""))))]
6020 OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0);
6022 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6027 (if_then_else (gtu (cc0)
6030 (label_ref (match_operand 0 "" ""))))]
6033 return MOTOROLA ? "jbls %l0" : "jls %l0";
6038 (if_then_else (lt (cc0)
6041 (label_ref (match_operand 0 "" ""))))]
6045 OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0");
6047 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6052 (if_then_else (ltu (cc0)
6055 (label_ref (match_operand 0 "" ""))))]
6058 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
6063 (if_then_else (ge (cc0)
6066 (label_ref (match_operand 0 "" ""))))]
6070 OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0");
6072 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6077 (if_then_else (geu (cc0)
6080 (label_ref (match_operand 0 "" ""))))]
6083 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
6088 (if_then_else (le (cc0)
6091 (label_ref (match_operand 0 "" ""))))]
6095 OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0);
6097 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6102 (if_then_else (leu (cc0)
6105 (label_ref (match_operand 0 "" ""))))]
6108 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
6111 (define_insn "*bordered_rev"
6113 (if_then_else (ordered (cc0) (const_int 0))
6115 (label_ref (match_operand 0 "" ""))))]
6118 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6119 return MOTOROLA ? "fbun %l0" : "fjun %l0";
6122 (define_insn "*bunordered_rev"
6124 (if_then_else (unordered (cc0) (const_int 0))
6126 (label_ref (match_operand 0 "" ""))))]
6129 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6130 return MOTOROLA ? "fbor %l0" : "fjor %l0";
6133 (define_insn "*buneq_rev"
6135 (if_then_else (uneq (cc0) (const_int 0))
6137 (label_ref (match_operand 0 "" ""))))]
6140 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6141 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
6144 (define_insn "*bunge_rev"
6146 (if_then_else (unge (cc0) (const_int 0))
6148 (label_ref (match_operand 0 "" ""))))]
6151 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6152 return MOTOROLA ? "fbolt %l0" : "fjolt %l0";
6155 (define_insn "*bungt_rev"
6157 (if_then_else (ungt (cc0) (const_int 0))
6159 (label_ref (match_operand 0 "" ""))))]
6162 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6163 return MOTOROLA ? "fbole %l0" : "fjole %l0";
6166 (define_insn "*bunle_rev"
6168 (if_then_else (unle (cc0) (const_int 0))
6170 (label_ref (match_operand 0 "" ""))))]
6173 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6174 return MOTOROLA ? "fbogt %l0" : "fjogt %l0";
6177 (define_insn "*bunlt_rev"
6179 (if_then_else (unlt (cc0) (const_int 0))
6181 (label_ref (match_operand 0 "" ""))))]
6184 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6185 return MOTOROLA ? "fboge %l0" : "fjoge %l0";
6188 (define_insn "*bltgt_rev"
6190 (if_then_else (ltgt (cc0) (const_int 0))
6192 (label_ref (match_operand 0 "" ""))))]
6195 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6196 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
6199 ;; Unconditional and other jump instructions
6202 (label_ref (match_operand 0 "" "")))]
6205 return MOTOROLA ? "jbra %l0" : "jra %l0";
6208 (define_expand "tablejump"
6209 [(parallel [(set (pc) (match_operand 0 "" ""))
6210 (use (label_ref (match_operand 1 "" "")))])]
6213 #ifdef CASE_VECTOR_PC_RELATIVE
6214 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6215 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6219 ;; Jump to variable address from dispatch table of absolute addresses.
6221 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6222 (use (label_ref (match_operand 1 "" "")))]
6225 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6228 ;; Jump to variable address from dispatch table of relative addresses.
6232 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6233 (use (label_ref (match_operand 1 "" "")))]
6236 #ifdef ASM_RETURN_CASE_JUMP
6237 ASM_RETURN_CASE_JUMP;
6239 if (TARGET_COLDFIRE)
6241 if (ADDRESS_REG_P (operands[0]))
6242 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6244 return "ext%.l %0\;jmp (2,pc,%0.l)";
6246 return "extl %0\;jmp pc@(2,%0:l)";
6249 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6253 ;; Decrement-and-branch insns.
6257 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6259 (label_ref (match_operand 1 "" ""))
6262 (plus:HI (match_dup 0)
6267 if (DATA_REG_P (operands[0]))
6268 return "dbra %0,%l1";
6269 if (GET_CODE (operands[0]) == MEM)
6271 "subq%.w #1,%0\;jbcc %l1" :
6272 "subqw #1,%0\;jcc %l1";
6274 "subq%.w #1,%0\;cmp%.w #-1,%0\;jbne %l1" :
6275 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6281 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6283 (label_ref (match_operand 1 "" ""))
6286 (plus:SI (match_dup 0)
6291 if (DATA_REG_P (operands[0]))
6293 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6294 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6295 if (GET_CODE (operands[0]) == MEM)
6297 "subq%.l #1,%0\;jbcc %l1" :
6298 "subq%.l #1,%0\;jcc %l1";
6300 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6301 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6304 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6309 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6312 (label_ref (match_operand 1 "" ""))
6315 (plus:HI (match_dup 0)
6317 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6320 if (DATA_REG_P (operands[0]))
6321 return "dbra %0,%l1";
6322 if (GET_CODE (operands[0]) == MEM)
6324 "subq%.w #1,%0\;jbcc %l1" :
6325 "subq%.w #1,%0\;jcc %l1";
6327 "subq.w #1,%0\;cmp.w #-1,%0\;jbne %l1" :
6328 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6331 (define_expand "decrement_and_branch_until_zero"
6332 [(parallel [(set (pc)
6334 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6337 (label_ref (match_operand 1 "" ""))
6340 (plus:SI (match_dup 0)
6348 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6351 (label_ref (match_operand 1 "" ""))
6354 (plus:SI (match_dup 0)
6356 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6359 if (DATA_REG_P (operands[0]))
6361 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6362 "dbra %0,%l1\;clr%.w %0\;subql #1,%0\;jcc %l1";
6363 if (GET_CODE (operands[0]) == MEM)
6365 "subq%.l #1,%0\;jbcc %l1" :
6366 "subql #1,%0\;jcc %l1";
6368 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6369 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6372 ;; Call subroutine with no return value.
6373 (define_expand "call"
6374 [(call (match_operand:QI 0 "memory_operand" "")
6375 (match_operand:SI 1 "general_operand" ""))]
6376 ;; Operand 1 not really used on the m68000.
6379 operands[0] = m68k_legitimize_call_address (operands[0]);
6382 (define_insn "*call"
6383 [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
6384 (match_operand:SI 1 "general_operand" "g,g"))]
6385 ;; Operand 1 not really used on the m68000.
6388 return output_call (operands[0]);
6391 ;; Call subroutine, returning value in operand 0
6392 ;; (which must be a hard register).
6393 (define_expand "call_value"
6394 [(set (match_operand 0 "" "")
6395 (call (match_operand:QI 1 "memory_operand" "")
6396 (match_operand:SI 2 "general_operand" "")))]
6397 ;; Operand 2 not really used on the m68000.
6400 operands[1] = m68k_legitimize_call_address (operands[1]);
6403 (define_insn "*call_value"
6404 [(set (match_operand 0 "" "=rf,rf")
6405 (call (mem:QI (match_operand:SI 1 "call_operand" "a,W"))
6406 (match_operand:SI 2 "general_operand" "g,g")))]
6407 ;; Operand 2 not really used on the m68000.
6410 operands[0] = operands[1];
6411 return output_call (operands[0]);
6414 ;; Call subroutine returning any type.
6416 (define_expand "untyped_call"
6417 [(parallel [(call (match_operand 0 "" "")
6419 (match_operand 1 "" "")
6420 (match_operand 2 "" "")])]
6421 "NEEDS_UNTYPED_CALL"
6425 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6427 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6429 rtx set = XVECEXP (operands[2], 0, i);
6430 emit_move_insn (SET_DEST (set), SET_SRC (set));
6433 /* The optimizer does not know that the call sets the function value
6434 registers we stored in the result block. We avoid problems by
6435 claiming that all hard registers are used and clobbered at this
6437 emit_insn (gen_blockage ());
6442 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6443 ;; all of memory. This blocks insns from being moved across this point.
6445 (define_insn "blockage"
6446 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6455 ;; Used for frameless functions which save no regs and allocate no locals.
6456 (define_insn "return"
6458 "m68k_use_return_insn ()"
6460 if (current_function_pops_args == 0)
6462 operands[0] = GEN_INT (current_function_pops_args);
6466 (define_insn "indirect_jump"
6467 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
6471 ;; This should not be used unless the add/sub insns can't be.
6474 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
6475 (match_operand:QI 1 "address_operand" "p"))]
6478 /* Recognize an insn that refers to a table of offsets. Such an insn will
6479 need to refer to a label on the insn. So output one. Use the
6480 label-number of the table of offsets to generate this label. This code,
6481 and similar code above, assumes that there will be at most one reference
6483 if (GET_CODE (operands[1]) == PLUS
6484 && GET_CODE (XEXP (operands[1], 1)) == LABEL_REF
6485 && GET_CODE (XEXP (operands[1], 0)) != PLUS)
6487 rtx labelref = XEXP (operands[1], 1);
6489 asm_fprintf (asm_out_file, "\\t.set %LLI%d,.+2\\n",
6490 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6492 (*targetm.asm_out.internal_label) (asm_out_file, "LI",
6493 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6495 return "lea %a1,%0";
6498 ;; This is the first machine-dependent peephole optimization.
6499 ;; It is useful when a floating value is returned from a function call
6500 ;; and then is moved into an FP register.
6501 ;; But it is mainly intended to test the support for these optimizations.
6504 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
6505 (set (match_operand:DF 0 "register_operand" "=f")
6506 (match_operand:DF 1 "register_operand" "ad"))]
6507 "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
6510 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6511 output_asm_insn ("move%.l %1,%@", xoperands);
6512 output_asm_insn ("move%.l %1,%-", operands);
6513 return "fmove%.d %+,%0";
6516 ;; Optimize a stack-adjust followed by a push of an argument.
6517 ;; This is said to happen frequently with -msoft-float
6518 ;; when there are consecutive library calls.
6521 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6522 (match_operand:SI 0 "const_int_operand" "n")))
6523 (set (match_operand:SF 1 "push_operand" "=m")
6524 (match_operand:SF 2 "general_operand" "rmfF"))]
6525 "INTVAL (operands[0]) >= 4
6526 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6528 if (INTVAL (operands[0]) > 4)
6531 xoperands[0] = stack_pointer_rtx;
6532 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6533 if (INTVAL (xoperands[1]) <= 8)
6535 if (!TARGET_COLDFIRE)
6536 output_asm_insn ("addq%.w %1,%0", xoperands);
6538 output_asm_insn ("addq%.l %1,%0", xoperands);
6540 else if (TUNE_CPU32 && INTVAL (xoperands[1]) <= 16)
6542 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6543 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6545 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6548 output_asm_insn ("add%.w %1,%0", xoperands);
6550 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6552 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6555 output_asm_insn ("add%.l %1,%0", xoperands);
6557 if (FP_REG_P (operands[2]))
6558 return "fmove%.s %2,%@";
6559 return "move%.l %2,%@";
6562 ;; Speed up stack adjust followed by a fullword fixedpoint push.
6565 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6566 (match_operand:SI 0 "const_int_operand" "n")))
6567 (set (match_operand:SI 1 "push_operand" "=m")
6568 (match_operand:SI 2 "general_operand" "g"))]
6569 "INTVAL (operands[0]) >= 4
6570 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6572 if (INTVAL (operands[0]) > 4)
6575 xoperands[0] = stack_pointer_rtx;
6576 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6577 if (INTVAL (xoperands[1]) <= 8)
6579 if (!TARGET_COLDFIRE)
6580 output_asm_insn ("addq%.w %1,%0", xoperands);
6582 output_asm_insn ("addq%.l %1,%0", xoperands);
6584 else if (TUNE_CPU32 && INTVAL (xoperands[1]) <= 16)
6586 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6587 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6589 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6592 output_asm_insn ("add%.w %1,%0", xoperands);
6594 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6596 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6599 output_asm_insn ("add%.l %1,%0", xoperands);
6601 if (operands[2] == const0_rtx)
6603 return "move%.l %2,%@";
6606 ;; Speed up pushing a single byte but leaving four bytes of space.
6609 [(set (mem:QI (pre_dec:SI (reg:SI SP_REG)))
6610 (match_operand:QI 1 "general_operand" "dami"))
6611 (set (reg:SI SP_REG) (minus:SI (reg:SI SP_REG) (const_int 2)))]
6612 "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
6616 if (GET_CODE (operands[1]) == REG)
6617 return "move%.l %1,%-";
6619 xoperands[1] = operands[1];
6621 = gen_rtx_MEM (QImode, plus_constant (stack_pointer_rtx, 3));
6622 xoperands[3] = stack_pointer_rtx;
6623 if (!TARGET_COLDFIRE)
6624 output_asm_insn ("subq%.w #4,%3\;move%.b %1,%2", xoperands);
6626 output_asm_insn ("subq%.l #4,%3\;move%.b %1,%2", xoperands);
6631 [(set (match_operand:SI 0 "register_operand" "=d")
6633 (set (strict_low_part (subreg:HI (match_dup 0) 2))
6634 (match_operand:HI 1 "general_operand" "rmn"))]
6635 "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
6637 if (GET_CODE (operands[1]) == CONST_INT)
6639 if (operands[1] == const0_rtx
6640 && (DATA_REG_P (operands[0])
6641 || GET_CODE (operands[0]) == MEM)
6642 /* clr insns on 68000 read before writing. */
6643 && ((TARGET_68010 || TARGET_COLDFIRE)
6644 || !(GET_CODE (operands[0]) == MEM
6645 && MEM_VOLATILE_P (operands[0]))))
6648 return "move%.w %1,%0";
6656 ;; jCC label ; abnormal loop termination
6657 ;; dbra dN, loop ; normal loop termination
6665 ;; Which moves the jCC condition outside the inner loop for free.
6669 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6670 [(cc0) (const_int 0)])
6671 (label_ref (match_operand 2 "" ""))
6676 (ne (match_operand:HI 0 "register_operand" "")
6678 (label_ref (match_operand 1 "" ""))
6681 (plus:HI (match_dup 0)
6683 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6686 output_dbcc_and_branch (operands);
6691 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6692 [(cc0) (const_int 0)])
6693 (label_ref (match_operand 2 "" ""))
6698 (ne (match_operand:SI 0 "register_operand" "")
6700 (label_ref (match_operand 1 "" ""))
6703 (plus:SI (match_dup 0)
6705 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6708 output_dbcc_and_branch (operands);
6713 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6714 [(cc0) (const_int 0)])
6715 (label_ref (match_operand 2 "" ""))
6720 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
6723 (label_ref (match_operand 1 "" ""))
6726 (plus:HI (match_dup 0)
6728 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6731 output_dbcc_and_branch (operands);
6736 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6737 [(cc0) (const_int 0)])
6738 (label_ref (match_operand 2 "" ""))
6743 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
6746 (label_ref (match_operand 1 "" ""))
6749 (plus:SI (match_dup 0)
6751 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6754 output_dbcc_and_branch (operands);
6759 (define_insn "extendsfxf2"
6760 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6761 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
6764 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6766 if (REGNO (operands[0]) == REGNO (operands[1]))
6768 /* Extending float to double in an fp-reg is a no-op.
6769 NOTICE_UPDATE_CC has already assumed that the
6770 cc will be set. So cancel what it did. */
6771 cc_status = cc_prev_status;
6774 return "f%$move%.x %1,%0";
6776 if (FP_REG_P (operands[0]))
6778 if (FP_REG_P (operands[1]))
6779 return "f%$move%.x %1,%0";
6780 else if (ADDRESS_REG_P (operands[1]))
6781 return "move%.l %1,%-\;f%$move%.s %+,%0";
6782 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
6783 return output_move_const_single (operands);
6784 return "f%$move%.s %f1,%0";
6786 return "fmove%.x %f1,%0";
6790 (define_insn "extenddfxf2"
6791 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6793 (match_operand:DF 1 "general_operand" "f,rmE")))]
6796 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6798 if (REGNO (operands[0]) == REGNO (operands[1]))
6800 /* Extending float to double in an fp-reg is a no-op.
6801 NOTICE_UPDATE_CC has already assumed that the
6802 cc will be set. So cancel what it did. */
6803 cc_status = cc_prev_status;
6806 return "fmove%.x %1,%0";
6808 if (FP_REG_P (operands[0]))
6810 if (REG_P (operands[1]))
6813 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6814 output_asm_insn ("move%.l %1,%-", xoperands);
6815 output_asm_insn ("move%.l %1,%-", operands);
6816 return "f%&move%.d %+,%0";
6818 if (GET_CODE (operands[1]) == CONST_DOUBLE)
6819 return output_move_const_double (operands);
6820 return "f%&move%.d %f1,%0";
6822 return "fmove%.x %f1,%0";
6825 (define_insn "truncxfdf2"
6826 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
6828 (match_operand:XF 1 "general_operand" "f,f")))]
6831 if (REG_P (operands[0]))
6833 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
6834 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6835 return "move%.l %+,%0";
6837 return "fmove%.d %f1,%0";
6840 (define_insn "truncxfsf2"
6841 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
6843 (match_operand:XF 1 "general_operand" "f")))]
6847 (define_insn "sin<mode>2"
6848 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
6850 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
6851 "TARGET_68881 && flag_unsafe_math_optimizations"
6853 if (FP_REG_P (operands[1]))
6854 return "fsin%.x %1,%0";
6856 return "fsin%.<FP:prec> %1,%0";
6859 (define_insn "cos<mode>2"
6860 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
6862 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
6863 "TARGET_68881 && flag_unsafe_math_optimizations"
6865 if (FP_REG_P (operands[1]))
6866 return "fcos%.x %1,%0";
6868 return "fcos%.<FP:prec> %1,%0";
6872 [(trap_if (const_int -1) (const_int 7))]
6876 (define_insn "conditional_trap"
6877 [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
6878 [(cc0) (const_int 0)])
6879 (match_operand:SI 1 "const_int_operand" "I"))]
6880 "TARGET_68020 && ! flags_in_68881 ()"
6882 switch (GET_CODE (operands[0]))
6884 case EQ: return "trapeq";
6885 case NE: return "trapne";
6886 case GT: return "trapgt";
6887 case GTU: return "traphi";
6888 case LT: return "traplt";
6889 case LTU: return "trapcs";
6890 case GE: return "trapge";
6891 case GEU: return "trapcc";
6892 case LE: return "traple";
6893 case LEU: return "trapls";
6894 default: gcc_unreachable ();