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.
132 (include "predicates.md")
134 ;; Mode macros for floating point operations.
135 ;; Valid floating point modes
136 (define_mode_macro FP [SF DF (XF "TARGET_68881")])
137 ;; Mnemonic infix to round result
138 (define_mode_attr round [(SF "%$") (DF "%&") (XF "")])
139 ;; Mnemonic infix to round result for mul or div instruction
140 (define_mode_attr round_mul [(SF "sgl") (DF "%&") (XF "")])
141 ;; Suffix specifying source operand format
142 (define_mode_attr prec [(SF "s") (DF "d") (XF "x")])
143 ;; Allowable D registers
144 (define_mode_attr dreg [(SF "d") (DF "") (XF "")])
145 ;; Allowable 68881 constant constraints
146 (define_mode_attr const [(SF "F") (DF "G") (XF "")])
149 [(set (match_operand:DF 0 "push_operand" "=m")
150 (match_operand:DF 1 "general_operand" "ro<>fE"))]
153 if (FP_REG_P (operands[1]))
154 return "fmove%.d %f1,%0";
155 return output_move_double (operands);
158 (define_insn "pushdi"
159 [(set (match_operand:DI 0 "push_operand" "=m")
160 (match_operand:DI 1 "general_operand" "ro<>Fi"))]
163 return output_move_double (operands);
166 ;; We don't want to allow a constant operand for test insns because
167 ;; (set (cc0) (const_int foo)) has no mode information. Such insns will
168 ;; be folded while optimizing anyway.
170 (define_expand "tstdi"
171 [(parallel [(set (cc0)
172 (match_operand:DI 0 "nonimmediate_operand" ""))
173 (clobber (match_scratch:SI 1 ""))
174 (clobber (match_scratch:DI 2 ""))])]
176 "m68k_last_compare_had_fp_operands = 0;")
180 (match_operand:DI 0 "nonimmediate_operand" "am,d"))
181 (clobber (match_scratch:SI 1 "=X,d"))
182 (clobber (match_scratch:DI 2 "=d,X"))]
185 if (which_alternative == 0)
189 xoperands[0] = operands[2];
190 xoperands[1] = operands[0];
191 output_move_double (xoperands);
192 cc_status.flags |= CC_REVERSED;
193 return "neg%.l %R2\;negx%.l %2";
195 if (find_reg_note (insn, REG_DEAD, operands[0]))
197 cc_status.flags |= CC_REVERSED;
198 return "neg%.l %R0\;negx%.l %0";
202 'sub' clears %1, and also clears the X cc bit
203 'tst' sets the Z cc bit according to the low part of the DImode operand
204 'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part.
206 return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
209 (define_expand "tstsi"
211 (match_operand:SI 0 "nonimmediate_operand" ""))]
213 "m68k_last_compare_had_fp_operands = 0;")
217 (match_operand:SI 0 "nonimmediate_operand" "rm"))]
220 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
222 /* If you think that the 68020 does not support tstl a0,
223 reread page B-167 of the 68020 manual more carefully. */
224 /* On an address reg, cmpw may replace cmpl. */
225 return "cmp%.w #0,%0";
228 ;; This can't use an address register, because comparisons
229 ;; with address registers as second operand always test the whole word.
230 (define_expand "tsthi"
232 (match_operand:HI 0 "nonimmediate_operand" ""))]
234 "m68k_last_compare_had_fp_operands = 0;")
238 (match_operand:HI 0 "nonimmediate_operand" "dm"))]
242 (define_expand "tstqi"
244 (match_operand:QI 0 "nonimmediate_operand" ""))]
246 "m68k_last_compare_had_fp_operands = 0;")
250 (match_operand:QI 0 "nonimmediate_operand" "dm"))]
254 (define_expand "tst<mode>"
256 (match_operand:FP 0 "general_operand" ""))]
259 m68k_last_compare_had_fp_operands = 1;
262 (define_insn "tst<mode>_68881"
264 (match_operand:FP 0 "general_operand" "f<FP:dreg>m"))]
267 cc_status.flags = CC_IN_68881;
268 if (FP_REG_P (operands[0]))
270 return "ftst%.<FP:prec> %0";
273 (define_insn "tst<mode>_cf"
275 (match_operand:FP 0 "general_operand" "f<FP:dreg><Q>U"))]
276 "TARGET_COLDFIRE_FPU"
278 cc_status.flags = CC_IN_68881;
279 if (FP_REG_P (operands[0]))
281 return "ftst%.<FP:prec> %0";
285 ;; compare instructions.
287 (define_expand "cmpdi"
290 (compare (match_operand:DI 0 "nonimmediate_operand" "")
291 (match_operand:DI 1 "general_operand" "")))
292 (clobber (match_dup 2))])]
294 "m68k_last_compare_had_fp_operands = 0; operands[2] = gen_reg_rtx (DImode);")
298 (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
299 (match_operand:DI 2 "general_operand" "d,0")))
300 (clobber (match_operand:DI 0 "register_operand" "=d,d"))]
303 if (rtx_equal_p (operands[0], operands[1]))
304 return "sub%.l %R2,%R0\;subx%.l %2,%0";
307 cc_status.flags |= CC_REVERSED;
308 return "sub%.l %R1,%R0\;subx%.l %1,%0";
312 (define_expand "cmpsi"
314 (compare (match_operand:SI 0 "nonimmediate_operand" "")
315 (match_operand:SI 1 "general_operand" "")))]
318 m68k_last_compare_had_fp_operands = 0;
321 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
324 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
325 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
328 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
329 return "cmpm%.l %1,%0";
330 if (REG_P (operands[1])
331 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
333 cc_status.flags |= CC_REVERSED;
334 return "cmp%.l %d0,%d1";
336 if (ADDRESS_REG_P (operands[0])
337 && GET_CODE (operands[1]) == CONST_INT
338 && INTVAL (operands[1]) < 0x8000
339 && INTVAL (operands[1]) >= -0x8000)
340 return "cmp%.w %1,%0";
341 return "cmp%.l %d1,%d0";
346 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
347 (match_operand:SI 1 "general_operand" "r,mrKs")))]
350 if (REG_P (operands[1])
351 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
353 cc_status.flags |= CC_REVERSED;
354 return "cmp%.l %d0,%d1";
356 return "cmp%.l %d1,%d0";
359 (define_expand "cmphi"
361 (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
362 (match_operand:HI 1 "general_src_operand" "")))]
364 "m68k_last_compare_had_fp_operands = 0;")
368 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
369 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
372 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
373 return "cmpm%.w %1,%0";
374 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
375 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
377 cc_status.flags |= CC_REVERSED;
378 return "cmp%.w %d0,%d1";
380 return "cmp%.w %d1,%d0";
383 (define_expand "cmpqi"
385 (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
386 (match_operand:QI 1 "general_src_operand" "")))]
388 "m68k_last_compare_had_fp_operands = 0;")
392 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
393 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
396 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
397 return "cmpm%.b %1,%0";
398 if (REG_P (operands[1])
399 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
401 cc_status.flags |= CC_REVERSED;
402 return "cmp%.b %d0,%d1";
404 return "cmp%.b %d1,%d0";
407 (define_expand "cmp<mode>"
409 (compare (match_operand:FP 0 "general_operand" "")
410 (match_operand:FP 1 "general_operand" "")))]
413 m68k_last_compare_had_fp_operands = 1;
414 if (TARGET_COLDFIRE && !reload_completed)
415 operands[1] = force_reg (<MODE>mode, operands[1]);
418 (define_insn "cmp<mode>_68881"
420 (compare (match_operand:FP 0 "general_operand" "f,m<FP:const>")
421 (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,f")))]
424 cc_status.flags = CC_IN_68881;
425 if (FP_REG_P (operands[0]))
427 if (FP_REG_P (operands[1]))
428 return "fcmp%.x %1,%0";
430 return "fcmp%.<FP:prec> %f1,%0";
432 cc_status.flags |= CC_REVERSED;
433 return "fcmp%.<FP:prec> %f0,%1";
436 (define_insn "cmp<mode>_cf"
438 (compare (match_operand:FP 0 "general_operand" "f,<FP:dreg><Q>U")
439 (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,f")))]
440 "TARGET_COLDFIRE_FPU"
442 cc_status.flags = CC_IN_68881;
443 if (FP_REG_P (operands[0]))
445 if (FP_REG_P (operands[1]))
446 return "fcmp%.d %1,%0";
448 return "fcmp%.<FP:prec> %f1,%0";
450 cc_status.flags |= CC_REVERSED;
451 return "fcmp%.<FP:prec> %f0,%1";
454 ;; Recognizers for btst instructions.
456 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
457 ;; specified as a constant, so we must disable all patterns that may extract
458 ;; from a MEM at a constant bit position if we can't use this as a constraint.
461 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
463 (minus:SI (const_int 7)
464 (match_operand:SI 1 "general_operand" "di"))))]
467 return output_btst (operands, operands[1], operands[0], insn, 7);
470 ;; This is the same as the above pattern except for the constraints. The 'i'
474 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
476 (minus:SI (const_int 7)
477 (match_operand:SI 1 "general_operand" "d"))))]
480 return output_btst (operands, operands[1], operands[0], insn, 7);
484 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
486 (minus:SI (const_int 31)
487 (match_operand:SI 1 "general_operand" "di"))))]
490 return output_btst (operands, operands[1], operands[0], insn, 31);
493 ;; The following two patterns are like the previous two
494 ;; except that they use the fact that bit-number operands
495 ;; are automatically masked to 3 or 5 bits.
498 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
500 (minus:SI (const_int 7)
502 (match_operand:SI 1 "register_operand" "d")
506 return output_btst (operands, operands[1], operands[0], insn, 7);
510 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
512 (minus:SI (const_int 31)
514 (match_operand:SI 1 "register_operand" "d")
518 return output_btst (operands, operands[1], operands[0], insn, 31);
521 ;; Nonoffsettable mem refs are ok in this one pattern
522 ;; since we don't try to adjust them.
524 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
526 (match_operand:SI 1 "const_int_operand" "n")))]
527 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
529 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
530 return output_btst (operands, operands[1], operands[0], insn, 7);
534 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
536 (match_operand:SI 1 "const_int_operand" "n")))]
539 if (GET_CODE (operands[0]) == MEM)
541 operands[0] = adjust_address (operands[0], QImode,
542 INTVAL (operands[1]) / 8);
543 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
544 return output_btst (operands, operands[1], operands[0], insn, 7);
546 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
547 return output_btst (operands, operands[1], operands[0], insn, 31);
550 ;; This is the same as the above pattern except for the constraints.
551 ;; The 'o' has been replaced with 'Q'.
554 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
556 (match_operand:SI 1 "const_int_operand" "n")))]
559 if (GET_CODE (operands[0]) == MEM)
561 operands[0] = adjust_address (operands[0], QImode,
562 INTVAL (operands[1]) / 8);
563 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
564 return output_btst (operands, operands[1], operands[0], insn, 7);
566 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
567 return output_btst (operands, operands[1], operands[0], insn, 31);
573 ;; A special case in which it is not desirable
574 ;; to reload the constant into a data register.
575 (define_insn "pushexthisi_const"
576 [(set (match_operand:SI 0 "push_operand" "=m")
577 (match_operand:SI 1 "const_int_operand" "J"))]
578 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
580 if (operands[1] == const0_rtx)
582 if (valid_mov3q_const (INTVAL (operands[1])))
583 return "mov3q%.l %1,%-";
588 ;(define_insn "swapsi"
589 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
590 ; (match_operand:SI 1 "general_operand" "+r"))
591 ; (set (match_dup 1) (match_dup 0))]
595 ;; Special case of fullword move when source is zero.
596 ;; The reason this is special is to avoid loading a zero
597 ;; into a data reg with moveq in order to store it elsewhere.
599 (define_insn "movsi_const0"
600 [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
602 ;; clr insns on 68000 read before writing.
603 "((TARGET_68010 || TARGET_COLDFIRE)
604 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
606 if (ADDRESS_REG_P (operands[0]))
608 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
610 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
612 return "sub%.l %0,%0";
614 /* moveq is faster on the 68000. */
615 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
616 return "moveq #0,%0";
620 ;; General case of fullword move.
622 ;; This is the main "hook" for PIC code. When generating
623 ;; PIC, movsi is responsible for determining when the source address
624 ;; needs PIC relocation and appropriately calling legitimize_pic_address
625 ;; to perform the actual relocation.
627 ;; In both the PIC and non-PIC cases the patterns generated will
628 ;; matched by the next define_insn.
629 (define_expand "movsi"
630 [(set (match_operand:SI 0 "nonimmediate_operand" "")
631 (match_operand:SI 1 "general_operand" ""))]
634 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
636 /* The source is an address which requires PIC relocation.
637 Call legitimize_pic_address with the source, mode, and a relocation
638 register (a new pseudo, or the final destination if reload_in_progress
639 is set). Then fall through normally */
640 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
641 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
643 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
645 /* Don't allow writes to memory except via a register;
646 the m68k doesn't consider PC-relative addresses to be writable. */
647 if (symbolic_operand (operands[0], SImode))
648 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
649 else if (GET_CODE (operands[0]) == MEM
650 && symbolic_operand (XEXP (operands[0], 0), SImode))
651 operands[0] = gen_rtx_MEM (SImode,
652 force_reg (SImode, XEXP (operands[0], 0)));
656 ;; General case of fullword move. The register constraints
657 ;; force integer constants in range for a moveq to be reloaded
658 ;; if they are headed for memory.
660 ;; Notes: make sure no alternative allows g vs g.
661 ;; We don't allow f-regs since fixed point cannot go in them.
662 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
663 (match_operand:SI 1 "general_src_operand" "damSKT,n,i"))]
667 return output_move_simode (operands);
670 ;; ColdFire move instructions can have at most one operand of mode >= 6.
671 (define_insn "*movsi_cf"
672 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
673 (match_operand:SI 1 "general_operand" "g,Rr<Q>,U"))]
675 "* return output_move_simode (operands);")
677 ;; Special case of fullword move, where we need to get a non-GOT PIC
678 ;; reference into an address register.
680 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
681 (match_operand:SI 1 "pcrel_address" ""))]
684 if (push_operand (operands[0], SImode))
689 (define_expand "movhi"
690 [(set (match_operand:HI 0 "nonimmediate_operand" "")
691 (match_operand:HI 1 "general_operand" ""))]
696 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
697 (match_operand:HI 1 "general_src_operand" "gS"))]
699 "* return output_move_himode (operands);")
702 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
703 (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
705 "* return output_move_himode (operands);")
707 (define_expand "movstricthi"
708 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
709 (match_operand:HI 1 "general_src_operand" ""))]
714 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
715 (match_operand:HI 1 "general_src_operand" "rmSn"))]
717 "* return output_move_stricthi (operands);")
720 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
721 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
723 "* return output_move_stricthi (operands);")
725 (define_expand "movqi"
726 [(set (match_operand:QI 0 "nonimmediate_operand" "")
727 (match_operand:QI 1 "general_src_operand" ""))]
732 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
733 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
735 "* return output_move_qimode (operands);")
738 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
739 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
741 "* return output_move_qimode (operands);")
743 (define_expand "movstrictqi"
744 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
745 (match_operand:QI 1 "general_src_operand" ""))]
750 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
751 (match_operand:QI 1 "general_src_operand" "dmSn"))]
753 "* return output_move_strictqi (operands);")
756 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d,m"))
757 (match_operand:QI 1 "general_src_operand" "dmn,d"))]
759 "* return output_move_strictqi (operands);")
761 (define_expand "pushqi1"
762 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
763 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
764 (match_operand:QI 0 "general_operand" ""))]
768 (define_expand "reload_insf"
769 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
770 (match_operand:SF 1 "general_operand" "mf"))
771 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
772 "TARGET_COLDFIRE_FPU"
774 if (emit_move_sequence (operands, SFmode, operands[2]))
777 /* We don't want the clobber emitted, so handle this ourselves. */
778 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
782 (define_expand "reload_outsf"
783 [(set (match_operand:SF 0 "general_operand" "")
784 (match_operand:SF 1 "register_operand" "f"))
785 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
786 "TARGET_COLDFIRE_FPU"
788 if (emit_move_sequence (operands, SFmode, operands[2]))
791 /* We don't want the clobber emitted, so handle this ourselves. */
792 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
796 (define_expand "movsf"
797 [(set (match_operand:SF 0 "nonimmediate_operand" "")
798 (match_operand:SF 1 "general_operand" ""))]
803 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
804 (match_operand:SF 1 "general_operand" "rmfF"))]
807 if (FP_REG_P (operands[0]))
809 if (FP_REG_P (operands[1]))
810 return "f%$move%.x %1,%0";
811 else if (ADDRESS_REG_P (operands[1]))
812 return "move%.l %1,%-\;f%$move%.s %+,%0";
813 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
814 return output_move_const_single (operands);
815 return "f%$move%.s %f1,%0";
817 if (FP_REG_P (operands[1]))
819 if (ADDRESS_REG_P (operands[0]))
820 return "fmove%.s %1,%-\;move%.l %+,%0";
821 return "fmove%.s %f1,%0";
823 if (operands[1] == CONST0_RTX (SFmode)
824 /* clr insns on 68000 read before writing. */
825 && ((TARGET_68010 || TARGET_COLDFIRE)
826 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
828 if (ADDRESS_REG_P (operands[0]))
830 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
832 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
834 return "sub%.l %0,%0";
836 /* moveq is faster on the 68000. */
837 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
838 return "moveq #0,%0";
841 return "move%.l %1,%0";
844 (define_insn "movsf_cf_soft"
845 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,g")
846 (match_operand:SF 1 "general_operand" "g,r"))]
847 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
849 return "move%.l %1,%0";
852 (define_insn "movsf_cf_hard"
853 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f, f,mr,f,r<Q>,f
855 (match_operand:SF 1 "general_operand" " f, r<Q>U,f,rm,F,F, m
857 "TARGET_COLDFIRE_FPU"
859 if (which_alternative == 4 || which_alternative == 5) {
863 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
864 REAL_VALUE_TO_TARGET_SINGLE (r, l);
865 xoperands[0] = operands[0];
866 xoperands[1] = GEN_INT (l);
867 if (which_alternative == 5) {
869 if (ADDRESS_REG_P (xoperands[0]))
870 output_asm_insn ("sub%.l %0,%0", xoperands);
872 output_asm_insn ("clr%.l %0", xoperands);
874 if (GET_CODE (operands[0]) == MEM
875 && symbolic_operand (XEXP (operands[0], 0), SImode))
876 output_asm_insn ("move%.l %1,%-;move%.l %+,%0", xoperands);
878 output_asm_insn ("move%.l %1,%0", xoperands);
882 output_asm_insn ("move%.l %1,%-;fsmove%.s %+,%0", xoperands);
884 output_asm_insn ("clr%.l %-;fsmove%.s %+,%0", xoperands);
887 if (FP_REG_P (operands[0]))
889 if (ADDRESS_REG_P (operands[1]))
890 return "move%.l %1,%-;fsmove%.s %+,%0";
891 if (FP_REG_P (operands[1]))
892 return "fsmove%.d %1,%0";
893 return "fsmove%.s %f1,%0";
895 if (FP_REG_P (operands[1]))
897 if (ADDRESS_REG_P (operands[0]))
898 return "fmove%.s %1,%-;move%.l %+,%0";
899 return "fmove%.s %f1,%0";
901 if (operands[1] == CONST0_RTX (SFmode))
903 if (ADDRESS_REG_P (operands[0]))
904 return "sub%.l %0,%0";
907 return "move%.l %1,%0";
910 (define_expand "reload_indf"
911 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
912 (match_operand:DF 1 "general_operand" "mf"))
913 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
914 "TARGET_COLDFIRE_FPU"
916 if (emit_move_sequence (operands, DFmode, operands[2]))
919 /* We don't want the clobber emitted, so handle this ourselves. */
920 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
924 (define_expand "reload_outdf"
925 [(set (match_operand:DF 0 "general_operand" "")
926 (match_operand:DF 1 "register_operand" "f"))
927 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
928 "TARGET_COLDFIRE_FPU"
930 if (emit_move_sequence (operands, DFmode, operands[2]))
933 /* We don't want the clobber emitted, so handle this ourselves. */
934 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
938 (define_expand "movdf"
939 [(set (match_operand:DF 0 "nonimmediate_operand" "")
940 (match_operand:DF 1 "general_operand" ""))]
943 if (TARGET_COLDFIRE_FPU)
944 if (emit_move_sequence (operands, DFmode, 0))
949 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
950 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
951 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
952 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
955 if (FP_REG_P (operands[0]))
957 if (FP_REG_P (operands[1]))
958 return "f%&move%.x %1,%0";
959 if (REG_P (operands[1]))
962 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
963 output_asm_insn ("move%.l %1,%-", xoperands);
964 output_asm_insn ("move%.l %1,%-", operands);
965 return "f%&move%.d %+,%0";
967 if (GET_CODE (operands[1]) == CONST_DOUBLE)
968 return output_move_const_double (operands);
969 return "f%&move%.d %f1,%0";
971 else if (FP_REG_P (operands[1]))
973 if (REG_P (operands[0]))
975 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
976 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
977 return "move%.l %+,%0";
980 return "fmove%.d %f1,%0";
982 return output_move_double (operands);
985 (define_insn "movdf_cf_soft"
986 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
987 (match_operand:DF 1 "general_operand" "g,r"))]
988 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
990 return output_move_double (operands);
993 (define_insn "movdf_cf_hard"
994 [(set (match_operand:DF 0 "nonimmediate_operand" "=f, <Q>U,r,f,r,r,m,f")
995 (match_operand:DF 1 "general_operand" " f<Q>U,f, f,r,r,m,r,E"))]
996 "TARGET_COLDFIRE_FPU"
1002 switch (which_alternative)
1005 return "fdmove%.d %1,%0";
1007 return "fmove%.d %1,%0";
1009 return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1011 return "move%.l %R1,%-;move%.l %1,%-;fdmove%.d %+,%0";
1012 case 4: case 5: case 6:
1013 return output_move_double (operands);
1015 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1016 REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1017 xoperands[0] = operands[0];
1018 xoperands[1] = GEN_INT (l[0]);
1019 xoperands[2] = GEN_INT (l[1]);
1020 if (operands[1] == CONST0_RTX (DFmode))
1021 output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1025 output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1028 output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1034 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1035 ;; allowed. Most but not all have predicates and constraint that disallow
1036 ;; constants. Most but not all have output templates that handle constants.
1037 ;; See also LEGITIMATE_CONSTANT_P.
1039 (define_expand "movxf"
1040 [(set (match_operand:XF 0 "nonimmediate_operand" "")
1041 (match_operand:XF 1 "general_operand" ""))]
1044 /* We can't rewrite operands during reload. */
1045 if (! reload_in_progress)
1047 if (CONSTANT_P (operands[1]))
1049 operands[1] = force_const_mem (XFmode, operands[1]);
1050 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1051 operands[1] = adjust_address (operands[1], XFmode, 0);
1053 if (flag_pic && TARGET_PCREL)
1055 /* Don't allow writes to memory except via a register; the
1056 m68k doesn't consider PC-relative addresses to be writable. */
1057 if (GET_CODE (operands[0]) == MEM
1058 && symbolic_operand (XEXP (operands[0], 0), SImode))
1059 operands[0] = gen_rtx_MEM (XFmode,
1060 force_reg (SImode, XEXP (operands[0], 0)));
1066 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1067 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1070 if (FP_REG_P (operands[0]))
1072 if (FP_REG_P (operands[1]))
1073 return "fmove%.x %1,%0";
1074 if (REG_P (operands[1]))
1077 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1078 output_asm_insn ("move%.l %1,%-", xoperands);
1079 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1080 output_asm_insn ("move%.l %1,%-", xoperands);
1081 output_asm_insn ("move%.l %1,%-", operands);
1082 return "fmove%.x %+,%0";
1084 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1085 return "fmove%.x %1,%0";
1086 return "fmove%.x %f1,%0";
1088 if (FP_REG_P (operands[1]))
1090 if (REG_P (operands[0]))
1092 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1093 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1094 output_asm_insn ("move%.l %+,%0", operands);
1095 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1096 return "move%.l %+,%0";
1098 /* Must be memory destination. */
1099 return "fmove%.x %f1,%0";
1101 return output_move_double (operands);
1105 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1106 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1107 "! TARGET_68881 && ! TARGET_COLDFIRE"
1109 if (FP_REG_P (operands[0]))
1111 if (FP_REG_P (operands[1]))
1112 return "fmove%.x %1,%0";
1113 if (REG_P (operands[1]))
1116 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1117 output_asm_insn ("move%.l %1,%-", xoperands);
1118 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1119 output_asm_insn ("move%.l %1,%-", xoperands);
1120 output_asm_insn ("move%.l %1,%-", operands);
1121 return "fmove%.x %+,%0";
1123 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1124 return "fmove%.x %1,%0";
1125 return "fmove%.x %f1,%0";
1127 if (FP_REG_P (operands[1]))
1129 if (REG_P (operands[0]))
1131 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1132 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1133 output_asm_insn ("move%.l %+,%0", operands);
1134 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1135 return "move%.l %+,%0";
1138 return "fmove%.x %f1,%0";
1140 return output_move_double (operands);
1144 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1145 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1146 "! TARGET_68881 && TARGET_COLDFIRE"
1147 "* return output_move_double (operands);")
1149 (define_expand "movdi"
1150 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1151 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1152 (match_operand:DI 1 "general_operand" ""))]
1156 ;; movdi can apply to fp regs in some cases
1158 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1159 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1160 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1161 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1162 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1163 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1164 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1167 if (FP_REG_P (operands[0]))
1169 if (FP_REG_P (operands[1]))
1170 return "fmove%.x %1,%0";
1171 if (REG_P (operands[1]))
1174 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1175 output_asm_insn ("move%.l %1,%-", xoperands);
1176 output_asm_insn ("move%.l %1,%-", operands);
1177 return "fmove%.d %+,%0";
1179 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1180 return output_move_const_double (operands);
1181 return "fmove%.d %f1,%0";
1183 else if (FP_REG_P (operands[1]))
1185 if (REG_P (operands[0]))
1187 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1188 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1189 return "move%.l %+,%0";
1192 return "fmove%.d %f1,%0";
1194 return output_move_double (operands);
1198 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1199 (match_operand:DI 1 "general_operand" "g,r"))]
1201 "* return output_move_double (operands);")
1203 ;; Thus goes after the move instructions
1204 ;; because the move instructions are better (require no spilling)
1205 ;; when they can apply. It goes before the add/sub insns
1206 ;; so we will prefer it to them.
1208 (define_insn "pushasi"
1209 [(set (match_operand:SI 0 "push_operand" "=m")
1210 (match_operand:SI 1 "address_operand" "p"))]
1214 ;; truncation instructions
1215 (define_insn "truncsiqi2"
1216 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1218 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1221 if (GET_CODE (operands[0]) == REG)
1223 /* Must clear condition codes, since the move.l bases them on
1224 the entire 32 bits, not just the desired 8 bits. */
1226 return "move%.l %1,%0";
1228 if (GET_CODE (operands[1]) == MEM)
1229 operands[1] = adjust_address (operands[1], QImode, 3);
1230 return "move%.b %1,%0";
1233 (define_insn "trunchiqi2"
1234 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1236 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1239 if (GET_CODE (operands[0]) == REG
1240 && (GET_CODE (operands[1]) == MEM
1241 || GET_CODE (operands[1]) == CONST_INT))
1243 /* Must clear condition codes, since the move.w bases them on
1244 the entire 16 bits, not just the desired 8 bits. */
1246 return "move%.w %1,%0";
1248 if (GET_CODE (operands[0]) == REG)
1250 /* Must clear condition codes, since the move.l bases them on
1251 the entire 32 bits, not just the desired 8 bits. */
1253 return "move%.l %1,%0";
1255 if (GET_CODE (operands[1]) == MEM)
1256 operands[1] = adjust_address (operands[1], QImode, 1);
1257 return "move%.b %1,%0";
1260 (define_insn "truncsihi2"
1261 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1263 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1266 if (GET_CODE (operands[0]) == REG)
1268 /* Must clear condition codes, since the move.l bases them on
1269 the entire 32 bits, not just the desired 8 bits. */
1271 return "move%.l %1,%0";
1273 if (GET_CODE (operands[1]) == MEM)
1274 operands[1] = adjust_address (operands[1], QImode, 2);
1275 return "move%.w %1,%0";
1278 ;; zero extension instructions
1280 ;; two special patterns to match various post_inc/pre_dec patterns
1281 (define_insn_and_split "*zero_extend_inc"
1282 [(set (match_operand 0 "post_inc_operand" "")
1283 (zero_extend (match_operand 1 "register_operand" "")))]
1284 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1285 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1286 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1294 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1297 (define_insn_and_split "*zero_extend_dec"
1298 [(set (match_operand 0 "pre_dec_operand" "")
1299 (zero_extend (match_operand 1 "register_operand" "")))]
1300 "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1301 GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1302 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1303 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1311 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1314 (define_insn_and_split "zero_extendqidi2"
1315 [(set (match_operand:DI 0 "register_operand" "")
1316 (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1321 (zero_extend:SI (match_dup 1)))
1325 operands[2] = gen_lowpart (SImode, operands[0]);
1326 operands[3] = gen_highpart (SImode, operands[0]);
1329 (define_insn_and_split "zero_extendhidi2"
1330 [(set (match_operand:DI 0 "register_operand" "")
1331 (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1336 (zero_extend:SI (match_dup 1)))
1340 operands[2] = gen_lowpart (SImode, operands[0]);
1341 operands[3] = gen_highpart (SImode, operands[0]);
1344 (define_expand "zero_extendsidi2"
1345 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1346 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1349 if (GET_CODE (operands[0]) == MEM
1350 && GET_CODE (operands[1]) == MEM)
1351 operands[1] = force_reg (SImode, operands[1]);
1354 (define_insn_and_split "*zero_extendsidi2"
1355 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1356 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1357 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1365 operands[2] = gen_lowpart (SImode, operands[0]);
1366 operands[3] = gen_highpart (SImode, operands[0]);
1369 (define_insn "*zero_extendhisi2_cf"
1370 [(set (match_operand:SI 0 "register_operand" "=d")
1371 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1375 (define_insn "zero_extendhisi2"
1376 [(set (match_operand:SI 0 "register_operand" "=d")
1377 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1381 (define_expand "zero_extendqihi2"
1382 [(set (match_operand:HI 0 "register_operand" "")
1383 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1387 (define_insn "*zero_extendqihi2"
1388 [(set (match_operand:HI 0 "register_operand" "=d")
1389 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1393 (define_insn "*zero_extendqisi2_cfv4"
1394 [(set (match_operand:SI 0 "register_operand" "=d")
1395 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1399 (define_insn "zero_extendqisi2"
1400 [(set (match_operand:SI 0 "register_operand" "=d")
1401 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1405 ;; these two pattern split everything else which isn't matched by
1406 ;; something else above
1408 [(set (match_operand 0 "register_operand" "")
1409 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1412 && reg_mentioned_p (operands[0], operands[1])"
1413 [(set (strict_low_part (match_dup 2))
1416 (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1418 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1419 operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1420 operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1424 [(set (match_operand 0 "register_operand" "")
1425 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1426 "!TARGET_ISAB && reload_completed"
1429 (set (strict_low_part (match_dup 2))
1432 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1435 ;; sign extension instructions
1437 (define_insn "extendqidi2"
1438 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1439 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1443 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1445 return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1446 if (TARGET_68020 || TARGET_COLDFIRE)
1448 if (ADDRESS_REG_P (operands[1]))
1449 return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1451 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1455 if (ADDRESS_REG_P (operands[1]))
1456 return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1458 return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1462 (define_insn "extendhidi2"
1463 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1465 (match_operand:HI 1 "general_src_operand" "rmS")))]
1469 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1471 return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1472 if (TARGET_68020 || TARGET_COLDFIRE)
1473 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1475 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1478 (define_insn "extendsidi2"
1479 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1481 (match_operand:SI 1 "general_operand" "rm")))]
1485 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1486 if (TARGET_68020 || TARGET_COLDFIRE)
1487 return "move%.l %1,%2\;smi %0\;extb%.l %0";
1489 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
1492 ;; Special case when one can avoid register clobbering, copy and test
1493 ;; Maybe there is a way to make that the general case, by forcing the
1494 ;; result of the SI tree to be in the lower register of the DI target
1496 (define_insn "extendplussidi"
1497 [(set (match_operand:DI 0 "register_operand" "=d")
1498 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1499 (match_operand:SI 2 "general_operand" "rmn"))))]
1503 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1504 if (GET_CODE (operands[1]) == CONST_INT
1505 && (unsigned) INTVAL (operands[1]) > 8)
1507 rtx tmp = operands[1];
1509 operands[1] = operands[2];
1512 if (GET_CODE (operands[1]) == REG
1513 && REGNO (operands[1]) == REGNO (operands[3]))
1514 output_asm_insn ("add%.l %2,%3", operands);
1516 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1517 if (TARGET_68020 || TARGET_COLDFIRE)
1518 return "smi %0\;extb%.l %0";
1520 return "smi %0\;ext%.w %0\;ext%.l %0";
1523 (define_expand "extendhisi2"
1524 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1526 (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1530 (define_insn "*cfv4_extendhisi2"
1531 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1533 (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1537 (define_insn "*68k_extendhisi2"
1538 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1540 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1543 if (ADDRESS_REG_P (operands[0]))
1544 return "move%.w %1,%0";
1548 (define_insn "extendqihi2"
1549 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1550 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1554 (define_expand "extendqisi2"
1555 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1556 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1557 "TARGET_68020 || TARGET_COLDFIRE"
1560 (define_insn "*cfv4_extendqisi2"
1561 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1562 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1566 (define_insn "*68k_extendqisi2"
1567 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1568 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1569 "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_ISAB)"
1572 ;; Conversions between float and double.
1574 (define_expand "extendsfdf2"
1575 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1577 (match_operand:SF 1 "general_operand" "")))]
1582 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1584 (match_operand:SF 1 "general_operand" "f,dmF")))]
1587 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1589 if (REGNO (operands[0]) == REGNO (operands[1]))
1591 /* Extending float to double in an fp-reg is a no-op.
1592 NOTICE_UPDATE_CC has already assumed that the
1593 cc will be set. So cancel what it did. */
1594 cc_status = cc_prev_status;
1597 return "f%&move%.x %1,%0";
1599 if (FP_REG_P (operands[0]))
1600 return "f%&move%.s %f1,%0";
1601 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1603 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1604 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1605 return "move%.l %+,%0";
1607 return "fmove%.d %f1,%0";
1610 (define_insn "extendsfdf2_cf"
1611 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
1613 (match_operand:SF 1 "general_operand" "f,<Q>U")))]
1614 "TARGET_COLDFIRE_FPU"
1616 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1618 if (REGNO (operands[0]) == REGNO (operands[1]))
1620 /* Extending float to double in an fp-reg is a no-op.
1621 NOTICE_UPDATE_CC has already assumed that the
1622 cc will be set. So cancel what it did. */
1623 cc_status = cc_prev_status;
1626 return "fdmove%.d %1,%0";
1628 return "fdmove%.s %f1,%0";
1631 ;; This cannot output into an f-reg because there is no way to be
1632 ;; sure of truncating in that case.
1633 (define_expand "truncdfsf2"
1634 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1636 (match_operand:DF 1 "general_operand" "")))]
1640 ;; On the '040 we can truncate in a register accurately and easily.
1642 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1644 (match_operand:DF 1 "general_operand" "fmG")))]
1645 "TARGET_68881 && TARGET_68040"
1647 if (FP_REG_P (operands[1]))
1648 return "f%$move%.x %1,%0";
1649 return "f%$move%.d %f1,%0";
1652 (define_insn "truncdfsf2_cf"
1653 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
1655 (match_operand:DF 1 "general_operand" "<Q>U,f")))]
1656 "TARGET_COLDFIRE_FPU"
1662 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1664 (match_operand:DF 1 "general_operand" "f")))]
1668 ;; Conversion between fixed point and floating point.
1669 ;; Note that among the fix-to-float insns
1670 ;; the ones that start with SImode come first.
1671 ;; That is so that an operand that is a CONST_INT
1672 ;; (and therefore lacks a specific machine mode).
1673 ;; will be recognized as SImode (which is always valid)
1674 ;; rather than as QImode or HImode.
1676 (define_expand "floatsi<mode>2"
1677 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1678 (float:FP (match_operand:SI 1 "general_operand" "")))]
1682 (define_insn "floatsi<mode>2_68881"
1683 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1684 (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
1686 "f<FP:round>move%.l %1,%0")
1688 (define_insn "floatsi<mode>2_cf"
1689 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1690 (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
1691 "TARGET_COLDFIRE_FPU"
1692 "f<FP:prec>move%.l %1,%0")
1695 (define_expand "floathi<mode>2"
1696 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1697 (float:FP (match_operand:HI 1 "general_operand" "")))]
1701 (define_insn "floathi<mode>2_68881"
1702 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1703 (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
1707 (define_insn "floathi<mode>2_cf"
1708 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1709 (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
1710 "TARGET_COLDFIRE_FPU"
1714 (define_expand "floatqi<mode>2"
1715 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1716 (float:FP (match_operand:QI 1 "general_operand" "")))]
1720 (define_insn "floatqi<mode>2_68881"
1721 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1722 (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
1726 (define_insn "floatqi<mode>2_cf"
1727 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1728 (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
1729 "TARGET_COLDFIRE_FPU"
1733 ;; New routines to convert floating-point values to integers
1734 ;; to be used on the '040. These should be faster than trapping
1735 ;; into the kernel to emulate fintrz. They should also be faster
1736 ;; than calling the subroutines fixsfsi or fixdfsi.
1738 (define_insn "fix_truncdfsi2"
1739 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1740 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1741 (clobber (match_scratch:SI 2 "=d"))
1742 (clobber (match_scratch:SI 3 "=d"))]
1743 "TARGET_68881 && TUNE_68040"
1746 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,%!";
1749 (define_insn "fix_truncdfhi2"
1750 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1751 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1752 (clobber (match_scratch:SI 2 "=d"))
1753 (clobber (match_scratch:SI 3 "=d"))]
1754 "TARGET_68881 && TUNE_68040"
1757 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,%!";
1760 (define_insn "fix_truncdfqi2"
1761 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1762 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1763 (clobber (match_scratch:SI 2 "=d"))
1764 (clobber (match_scratch:SI 3 "=d"))]
1765 "TARGET_68881 && TUNE_68040"
1768 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,%!";
1771 ;; Convert a float to a float whose value is an integer.
1772 ;; This is the first stage of converting it to an integer type.
1774 (define_expand "ftrunc<mode>2"
1775 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1776 (fix:FP (match_operand:FP 1 "general_operand" "")))]
1777 "TARGET_HARD_FLOAT && !TUNE_68040"
1780 (define_insn "ftrunc<mode>2_68881"
1781 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1782 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
1783 "TARGET_68881 && !TUNE_68040"
1785 if (FP_REG_P (operands[1]))
1786 return "fintrz%.x %f1,%0";
1787 return "fintrz%.<FP:prec> %f1,%0";
1790 (define_insn "ftrunc<mode>2_cf"
1791 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1792 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
1793 "TARGET_COLDFIRE_FPU"
1795 if (FP_REG_P (operands[1]))
1796 return "fintrz%.d %f1,%0";
1797 return "fintrz%.<FP:prec> %f1,%0";
1800 ;; Convert a float whose value is an integer
1801 ;; to an actual integer. Second stage of converting float to integer type.
1802 (define_expand "fix<mode>qi2"
1803 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1804 (fix:QI (match_operand:FP 1 "general_operand" "")))]
1808 (define_insn "fix<mode>qi2_68881"
1809 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1810 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
1814 (define_insn "fix<mode>qi2_cf"
1815 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
1816 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
1817 "TARGET_COLDFIRE_FPU"
1820 (define_expand "fix<mode>hi2"
1821 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1822 (fix:HI (match_operand:FP 1 "general_operand" "")))]
1826 (define_insn "fix<mode>hi2_68881"
1827 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1828 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
1832 (define_insn "fix<mode>hi2_cf"
1833 [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
1834 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
1835 "TARGET_COLDFIRE_FPU"
1838 (define_expand "fix<mode>si2"
1839 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1840 (fix:SI (match_operand:FP 1 "general_operand" "")))]
1844 (define_insn "fix<mode>si2_68881"
1845 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1846 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
1850 (define_insn "fix<mode>si2_cf"
1851 [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
1852 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
1853 "TARGET_COLDFIRE_FPU"
1859 (define_insn "adddi_lshrdi_63"
1860 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1861 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
1864 (clobber (match_scratch:SI 2 "=d"))]
1867 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1868 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
1870 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
1871 if (GET_CODE (operands[1]) == REG)
1872 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1873 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
1874 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1875 operands[4] = operands[1];
1877 operands[4] = adjust_address (operands[1], SImode, 4);
1878 if (GET_CODE (operands[1]) == MEM
1879 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1880 output_asm_insn ("move%.l %4,%3", operands);
1881 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
1882 if (TARGET_68020 || TARGET_COLDFIRE)
1883 output_asm_insn ("extb%.l %2", operands);
1885 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
1886 if (GET_CODE (operands[1]) != MEM
1887 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
1888 output_asm_insn ("move%.l %4,%3", operands);
1889 return "sub%.l %2,%3\;subx%.l %2,%0";
1892 (define_insn "adddi_sexthishl32"
1893 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
1894 (plus:DI (ashift:DI (sign_extend:DI
1895 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
1897 (match_operand:DI 2 "general_operand" "0,0,0,0")))
1898 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
1902 if (ADDRESS_REG_P (operands[0]))
1903 return "add%.w %1,%0";
1904 else if (ADDRESS_REG_P (operands[3]))
1905 return "move%.w %1,%3\;add%.l %3,%0";
1907 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
1910 (define_insn "*adddi_dilshr32"
1911 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
1912 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
1914 (match_operand:DI 2 "general_operand" "0,0")))]
1918 if (GET_CODE (operands[0]) == REG)
1919 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1921 operands[2] = adjust_address (operands[0], SImode, 4);
1922 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
1925 (define_insn "*adddi_dilshr32_cf"
1926 [(set (match_operand:DI 0 "register_operand" "=d")
1927 (plus:DI (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
1929 (match_operand:DI 2 "register_operand" "0")))]
1933 return "add%.l %1,%R0\;negx%.l %0\;neg%.l %0";
1936 (define_insn "adddi_dishl32"
1937 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
1938 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1939 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
1940 ;; (const_int 32))))]
1941 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
1943 (match_operand:DI 2 "general_operand" "0,0")))]
1947 if (GET_CODE (operands[1]) == REG)
1948 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1950 operands[1] = adjust_address (operands[1], SImode, 4);
1951 return "add%.l %1,%0";
1954 (define_insn "adddi3"
1955 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
1956 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0")
1957 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
1958 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
1961 if (DATA_REG_P (operands[0]))
1963 if (DATA_REG_P (operands[2]))
1964 return "add%.l %R2,%R0\;addx%.l %2,%0";
1965 else if (GET_CODE (operands[2]) == MEM
1966 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
1967 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
1973 if (GET_CODE (operands[2]) == REG)
1975 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
1978 else if (CONSTANT_P (operands[2]))
1979 split_double (operands[2], &high, &low);
1982 low = adjust_address (operands[2], SImode, 4);
1986 operands[1] = low, operands[2] = high;
1987 xoperands[0] = operands[3];
1988 if (GET_CODE (operands[1]) == CONST_INT
1989 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1990 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
1992 xoperands[1] = operands[2];
1994 output_asm_insn (output_move_simode (xoperands), xoperands);
1995 if (GET_CODE (operands[1]) == CONST_INT)
1997 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
1998 return "addq%.l %1,%R0\;addx%.l %3,%0";
1999 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2001 operands[1] = GEN_INT (-INTVAL (operands[1]));
2002 return "subq%.l %1,%R0\;subx%.l %3,%0";
2005 return "add%.l %1,%R0\;addx%.l %3,%0";
2010 gcc_assert (GET_CODE (operands[0]) == MEM);
2012 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2014 operands[1] = gen_rtx_MEM (SImode,
2015 plus_constant (XEXP(operands[0], 0), -8));
2016 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2018 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2020 operands[1] = XEXP(operands[0], 0);
2021 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2025 operands[1] = adjust_address (operands[0], SImode, 4);
2026 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2031 (define_insn "addsi_lshrsi_31"
2032 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2033 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
2038 operands[2] = operands[0];
2039 operands[3] = gen_label_rtx();
2040 if (GET_CODE (operands[0]) == MEM)
2042 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2043 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2044 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2045 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2047 output_asm_insn ("move%.l %1,%0", operands);
2048 output_asm_insn (MOTOROLA ? "jbpl %l3" : "jpl %l3", operands);
2049 output_asm_insn ("addq%.l #1,%2", operands);
2050 (*targetm.asm_out.internal_label) (asm_out_file, "L",
2051 CODE_LABEL_NUMBER (operands[3]));
2055 (define_expand "addsi3"
2056 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2057 (plus:SI (match_operand:SI 1 "general_operand" "")
2058 (match_operand:SI 2 "general_src_operand" "")))]
2062 ;; Note that the middle two alternatives are near-duplicates
2063 ;; in order to handle insns generated by reload.
2064 ;; This is needed since they are not themselves reloaded,
2065 ;; so commutativity won't apply to them.
2066 (define_insn "*addsi3_internal"
2067 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2068 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2069 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2073 "* return output_addsi3 (operands);")
2075 (define_insn "*addsi3_5200"
2076 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
2077 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
2078 (match_operand:SI 2 "general_src_operand" "dIL,rJK,a,mrIKLi")))]
2080 "* return output_addsi3 (operands);")
2083 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2084 (plus:SI (match_operand:SI 1 "general_operand" "0")
2086 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2090 (define_insn "addhi3"
2091 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2092 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2093 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2096 if (GET_CODE (operands[2]) == CONST_INT)
2098 /* If the constant would be a negative number when interpreted as
2099 HImode, make it negative. This is usually, but not always, done
2100 elsewhere in the compiler. First check for constants out of range,
2101 which could confuse us. */
2103 if (INTVAL (operands[2]) >= 32768)
2104 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2106 if (INTVAL (operands[2]) > 0
2107 && INTVAL (operands[2]) <= 8)
2108 return "addq%.w %2,%0";
2109 if (INTVAL (operands[2]) < 0
2110 && INTVAL (operands[2]) >= -8)
2112 operands[2] = GEN_INT (- INTVAL (operands[2]));
2113 return "subq%.w %2,%0";
2115 /* On the CPU32 it is faster to use two addqw instructions to
2116 add a small integer (8 < N <= 16) to a register.
2117 Likewise for subqw. */
2118 if (TUNE_CPU32 && REG_P (operands[0]))
2120 if (INTVAL (operands[2]) > 8
2121 && INTVAL (operands[2]) <= 16)
2123 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2124 return "addq%.w #8,%0\;addq%.w %2,%0";
2126 if (INTVAL (operands[2]) < -8
2127 && INTVAL (operands[2]) >= -16)
2129 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2130 return "subq%.w #8,%0\;subq%.w %2,%0";
2133 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2134 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2136 return "add%.w %2,%0";
2139 ;; These insns must use MATCH_DUP instead of the more expected
2140 ;; use of a matching constraint because the "output" here is also
2141 ;; an input, so you can't use the matching constraint. That also means
2142 ;; that you can't use the "%", so you need patterns with the matched
2143 ;; operand in both positions.
2146 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2147 (plus:HI (match_dup 0)
2148 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2151 if (GET_CODE (operands[1]) == CONST_INT)
2153 /* If the constant would be a negative number when interpreted as
2154 HImode, make it negative. This is usually, but not always, done
2155 elsewhere in the compiler. First check for constants out of range,
2156 which could confuse us. */
2158 if (INTVAL (operands[1]) >= 32768)
2159 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2161 if (INTVAL (operands[1]) > 0
2162 && INTVAL (operands[1]) <= 8)
2163 return "addq%.w %1,%0";
2164 if (INTVAL (operands[1]) < 0
2165 && INTVAL (operands[1]) >= -8)
2167 operands[1] = GEN_INT (- INTVAL (operands[1]));
2168 return "subq%.w %1,%0";
2170 /* On the CPU32 it is faster to use two addqw instructions to
2171 add a small integer (8 < N <= 16) to a register.
2172 Likewise for subqw. */
2173 if (TUNE_CPU32 && REG_P (operands[0]))
2175 if (INTVAL (operands[1]) > 8
2176 && INTVAL (operands[1]) <= 16)
2178 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2179 return "addq%.w #8,%0\;addq%.w %1,%0";
2181 if (INTVAL (operands[1]) < -8
2182 && INTVAL (operands[1]) >= -16)
2184 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2185 return "subq%.w #8,%0\;subq%.w %1,%0";
2188 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2189 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2191 return "add%.w %1,%0";
2195 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2196 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2200 if (GET_CODE (operands[1]) == CONST_INT)
2202 /* If the constant would be a negative number when interpreted as
2203 HImode, make it negative. This is usually, but not always, done
2204 elsewhere in the compiler. First check for constants out of range,
2205 which could confuse us. */
2207 if (INTVAL (operands[1]) >= 32768)
2208 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2210 if (INTVAL (operands[1]) > 0
2211 && INTVAL (operands[1]) <= 8)
2212 return "addq%.w %1,%0";
2213 if (INTVAL (operands[1]) < 0
2214 && INTVAL (operands[1]) >= -8)
2216 operands[1] = GEN_INT (- INTVAL (operands[1]));
2217 return "subq%.w %1,%0";
2219 /* On the CPU32 it is faster to use two addqw instructions to
2220 add a small integer (8 < N <= 16) to a register.
2221 Likewise for subqw. */
2222 if (TUNE_CPU32 && REG_P (operands[0]))
2224 if (INTVAL (operands[1]) > 8
2225 && INTVAL (operands[1]) <= 16)
2227 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2228 return "addq%.w #8,%0\;addq%.w %1,%0";
2230 if (INTVAL (operands[1]) < -8
2231 && INTVAL (operands[1]) >= -16)
2233 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2234 return "subq%.w #8,%0\;subq%.w %1,%0";
2237 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2238 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2240 return "add%.w %1,%0";
2243 (define_insn "addqi3"
2244 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2245 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2246 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2249 if (GET_CODE (operands[2]) == CONST_INT)
2251 if (INTVAL (operands[2]) >= 128)
2252 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2254 if (INTVAL (operands[2]) > 0
2255 && INTVAL (operands[2]) <= 8)
2256 return "addq%.b %2,%0";
2257 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2259 operands[2] = GEN_INT (- INTVAL (operands[2]));
2260 return "subq%.b %2,%0";
2263 return "add%.b %2,%0";
2267 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2268 (plus:QI (match_dup 0)
2269 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2272 if (GET_CODE (operands[1]) == CONST_INT)
2274 if (INTVAL (operands[1]) >= 128)
2275 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2277 if (INTVAL (operands[1]) > 0
2278 && INTVAL (operands[1]) <= 8)
2279 return "addq%.b %1,%0";
2280 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2282 operands[1] = GEN_INT (- INTVAL (operands[1]));
2283 return "subq%.b %1,%0";
2286 return "add%.b %1,%0";
2290 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2291 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2295 if (GET_CODE (operands[1]) == CONST_INT)
2297 if (INTVAL (operands[1]) >= 128)
2298 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2300 if (INTVAL (operands[1]) > 0
2301 && INTVAL (operands[1]) <= 8)
2302 return "addq%.b %1,%0";
2303 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2305 operands[1] = GEN_INT (- INTVAL (operands[1]));
2306 return "subq%.b %1,%0";
2309 return "add%.b %1,%0";
2312 (define_expand "add<mode>3"
2313 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2314 (plus:FP (match_operand:FP 1 "general_operand" "")
2315 (match_operand:FP 2 "general_operand" "")))]
2319 (define_insn "add<mode>3_floatsi_68881"
2320 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2321 (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2322 (match_operand:FP 1 "general_operand" "0")))]
2324 "f<FP:round>add%.l %2,%0")
2326 (define_insn "add<mode>3_floathi_68881"
2327 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2328 (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2329 (match_operand:FP 1 "general_operand" "0")))]
2331 "f<FP:round>add%.w %2,%0")
2333 (define_insn "add<mode>3_floatqi_68881"
2334 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2335 (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2336 (match_operand:FP 1 "general_operand" "0")))]
2338 "f<FP:round>add%.b %2,%0")
2340 (define_insn "add<mode>3_68881"
2341 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2342 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2343 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2346 if (FP_REG_P (operands[2]))
2347 return "f<FP:round>add%.x %2,%0";
2348 return "f<FP:round>add%.<FP:prec> %f2,%0";
2351 (define_insn "add<mode>3_cf"
2352 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2353 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2354 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2355 "TARGET_COLDFIRE_FPU"
2357 if (FP_REG_P (operands[2]))
2358 return "f<FP:prec>add%.d %2,%0";
2359 return "f<FP:prec>add%.<FP:prec> %2,%0";
2362 ;; subtract instructions
2364 (define_insn "subdi_sexthishl32"
2365 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2366 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2367 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2369 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2373 if (ADDRESS_REG_P (operands[0]))
2374 return "sub%.w %2,%0";
2375 else if (ADDRESS_REG_P (operands[3]))
2376 return "move%.w %2,%3\;sub%.l %3,%0";
2378 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2381 (define_insn "subdi_dishl32"
2382 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2383 (minus:DI (match_dup 0)
2384 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2389 if (GET_CODE (operands[1]) == REG)
2390 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2392 operands[1] = adjust_address (operands[1], SImode, 4);
2393 return "sub%.l %1,%0";
2396 (define_insn "subdi3"
2397 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2398 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2399 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2400 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2403 if (DATA_REG_P (operands[0]))
2405 if (DATA_REG_P (operands[2]))
2406 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2407 else if (GET_CODE (operands[2]) == MEM
2408 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2410 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2417 if (GET_CODE (operands[2]) == REG)
2419 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2422 else if (CONSTANT_P (operands[2]))
2423 split_double (operands[2], &high, &low);
2426 low = adjust_address (operands[2], SImode, 4);
2430 operands[1] = low, operands[2] = high;
2431 xoperands[0] = operands[3];
2432 if (GET_CODE (operands[1]) == CONST_INT
2433 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2434 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2436 xoperands[1] = operands[2];
2438 output_asm_insn (output_move_simode (xoperands), xoperands);
2439 if (GET_CODE (operands[1]) == CONST_INT)
2441 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2442 return "subq%.l %1,%R0\;subx%.l %3,%0";
2443 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2445 operands[1] = GEN_INT (-INTVAL (operands[1]));
2446 return "addq%.l %1,%R0\;addx%.l %3,%0";
2449 return "sub%.l %1,%R0\;subx%.l %3,%0";
2454 gcc_assert (GET_CODE (operands[0]) == MEM);
2456 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2459 = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2460 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2462 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2464 operands[1] = XEXP(operands[0], 0);
2465 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2469 operands[1] = adjust_address (operands[0], SImode, 4);
2470 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2475 (define_insn "subsi3"
2476 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2477 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2478 (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2483 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2484 (minus:SI (match_operand:SI 1 "general_operand" "0")
2486 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2490 (define_insn "subhi3"
2491 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2492 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2493 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2498 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2499 (minus:HI (match_dup 0)
2500 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2504 (define_insn "subqi3"
2505 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2506 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2507 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2512 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2513 (minus:QI (match_dup 0)
2514 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2518 (define_expand "sub<mode>3"
2519 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2520 (minus:FP (match_operand:FP 1 "general_operand" "")
2521 (match_operand:FP 2 "general_operand" "")))]
2525 (define_insn "sub<mode>3_floatsi_68881"
2526 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2527 (minus:FP (match_operand:FP 1 "general_operand" "0")
2528 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2530 "f<FP:round>sub%.l %2,%0")
2532 (define_insn "sub<mode>3_floathi_68881"
2533 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2534 (minus:FP (match_operand:FP 1 "general_operand" "0")
2535 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2537 "f<FP:round>sub%.w %2,%0")
2539 (define_insn "sub<mode>3_floatqi_68881"
2540 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2541 (minus:FP (match_operand:FP 1 "general_operand" "0")
2542 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2544 "f<FP:round>sub%.b %2,%0")
2546 (define_insn "sub<mode>3_68881"
2547 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2548 (minus:FP (match_operand:FP 1 "general_operand" "0")
2549 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2552 if (FP_REG_P (operands[2]))
2553 return "f<FP:round>sub%.x %2,%0";
2554 return "f<FP:round>sub%.<FP:prec> %f2,%0";
2557 (define_insn "sub<mode>3_cf"
2558 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2559 (minus:FP (match_operand:FP 1 "general_operand" "0")
2560 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2561 "TARGET_COLDFIRE_FPU"
2563 if (FP_REG_P (operands[2]))
2564 return "f<FP:prec>sub%.d %2,%0";
2565 return "f<FP:prec>sub%.<FP:prec> %2,%0";
2568 ;; multiply instructions
2570 (define_insn "mulhi3"
2571 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2572 (mult:HI (match_operand:HI 1 "general_operand" "%0")
2573 (match_operand:HI 2 "general_src_operand" "dmSn")))]
2576 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2579 (define_insn "mulhisi3"
2580 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2581 (mult:SI (sign_extend:SI
2582 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2584 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2587 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2591 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2592 (mult:SI (sign_extend:SI
2593 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2594 (match_operand:SI 2 "const_int_operand" "n")))]
2595 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2597 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2600 (define_expand "mulsi3"
2601 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2602 (mult:SI (match_operand:SI 1 "general_operand" "")
2603 (match_operand:SI 2 "general_operand" "")))]
2604 "TARGET_68020 || TARGET_COLDFIRE"
2608 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2609 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2610 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2616 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2617 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2618 (match_operand:SI 2 "general_operand" "d<Q>")))]
2622 (define_insn "umulhisi3"
2623 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2624 (mult:SI (zero_extend:SI
2625 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2627 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2630 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2634 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2635 (mult:SI (zero_extend:SI
2636 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2637 (match_operand:SI 2 "const_int_operand" "n")))]
2638 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2640 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2643 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2644 ;; proper matching constraint. This is because the matching is between
2645 ;; the high-numbered word of the DImode operand[0] and operand[1].
2646 (define_expand "umulsidi3"
2648 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2649 (mult:SI (match_operand:SI 1 "register_operand" "")
2650 (match_operand:SI 2 "register_operand" "")))
2651 (set (subreg:SI (match_dup 0) 0)
2652 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2653 (zero_extend:DI (match_dup 2)))
2654 (const_int 32))))])]
2655 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2659 [(set (match_operand:SI 0 "register_operand" "=d")
2660 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2661 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2662 (set (match_operand:SI 3 "register_operand" "=d")
2663 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2664 (zero_extend:DI (match_dup 2)))
2666 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2669 ; Match immediate case. For 2.4 only match things < 2^31.
2670 ; It's tricky with larger values in these patterns since we need to match
2671 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2674 [(set (match_operand:SI 0 "register_operand" "=d")
2675 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2676 (match_operand:SI 2 "const_int_operand" "n")))
2677 (set (match_operand:SI 3 "register_operand" "=d")
2678 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2681 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
2682 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2685 (define_expand "mulsidi3"
2687 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2688 (mult:SI (match_operand:SI 1 "register_operand" "")
2689 (match_operand:SI 2 "register_operand" "")))
2690 (set (subreg:SI (match_dup 0) 0)
2691 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2692 (sign_extend:DI (match_dup 2)))
2693 (const_int 32))))])]
2694 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2698 [(set (match_operand:SI 0 "register_operand" "=d")
2699 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2700 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2701 (set (match_operand:SI 3 "register_operand" "=d")
2702 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2703 (sign_extend:DI (match_dup 2)))
2705 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2709 [(set (match_operand:SI 0 "register_operand" "=d")
2710 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2711 (match_operand:SI 2 "const_int_operand" "n")))
2712 (set (match_operand:SI 3 "register_operand" "=d")
2713 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2716 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2719 (define_expand "umulsi3_highpart"
2721 [(set (match_operand:SI 0 "register_operand" "")
2724 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2725 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2727 (clobber (match_dup 3))])]
2728 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2730 operands[3] = gen_reg_rtx (SImode);
2732 if (GET_CODE (operands[2]) == CONST_INT)
2734 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2737 /* We have to adjust the operand order for the matching constraints. */
2738 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2739 operands[1], operands[2]));
2745 [(set (match_operand:SI 0 "register_operand" "=d")
2748 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2749 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2751 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2752 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2755 (define_insn "const_umulsi3_highpart"
2756 [(set (match_operand:SI 0 "register_operand" "=d")
2759 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2760 (match_operand:DI 3 "const_uint32_operand" "n"))
2762 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2763 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2766 (define_expand "smulsi3_highpart"
2768 [(set (match_operand:SI 0 "register_operand" "")
2771 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2772 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2774 (clobber (match_dup 3))])]
2775 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2777 operands[3] = gen_reg_rtx (SImode);
2778 if (GET_CODE (operands[2]) == CONST_INT)
2780 /* We have to adjust the operand order for the matching constraints. */
2781 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2782 operands[1], operands[2]));
2788 [(set (match_operand:SI 0 "register_operand" "=d")
2791 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2792 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2794 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2795 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2798 (define_insn "const_smulsi3_highpart"
2799 [(set (match_operand:SI 0 "register_operand" "=d")
2802 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2803 (match_operand:DI 3 "const_sint32_operand" "n"))
2805 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2806 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2809 (define_expand "mul<mode>3"
2810 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2811 (mult:FP (match_operand:FP 1 "general_operand" "")
2812 (match_operand:FP 2 "general_operand" "")))]
2816 (define_insn "mul<mode>3_floatsi_68881"
2817 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2818 (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2819 (match_operand:FP 1 "general_operand" "0")))]
2823 ? "f<FP:round>mul%.l %2,%0"
2824 : "f<FP:round_mul>mul%.l %2,%0";
2827 (define_insn "mul<mode>3_floathi_68881"
2828 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2829 (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2830 (match_operand:FP 1 "general_operand" "0")))]
2834 ? "f<FP:round>mul%.w %2,%0"
2835 : "f<FP:round_mul>mul%.w %2,%0";
2838 (define_insn "mul<mode>3_floatqi_68881"
2839 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2840 (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2841 (match_operand:FP 1 "general_operand" "0")))]
2845 ? "f<FP:round>mul%.b %2,%0"
2846 : "f<FP:round_mul>mul%.b %2,%0";
2849 (define_insn "muldf_68881"
2850 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2851 (mult:DF (match_operand:DF 1 "general_operand" "%0")
2852 (match_operand:DF 2 "general_operand" "fmG")))]
2855 if (GET_CODE (operands[2]) == CONST_DOUBLE
2856 && floating_exact_log2 (operands[2]) && !TUNE_68040_60)
2858 int i = floating_exact_log2 (operands[2]);
2859 operands[2] = GEN_INT (i);
2860 return "fscale%.l %2,%0";
2862 if (REG_P (operands[2]))
2863 return "f%&mul%.x %2,%0";
2864 return "f%&mul%.d %f2,%0";
2867 (define_insn "mulsf_68881"
2868 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2869 (mult:SF (match_operand:SF 1 "general_operand" "%0")
2870 (match_operand:SF 2 "general_operand" "fdmF")))]
2873 if (FP_REG_P (operands[2]))
2874 return (TARGET_68040
2876 : "fsglmul%.x %2,%0");
2877 return (TARGET_68040
2879 : "fsglmul%.s %f2,%0");
2882 (define_insn "mulxf3_68881"
2883 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
2884 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
2885 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
2888 return "fmul%.x %f2,%0";
2891 (define_insn "fmul<mode>3_cf"
2892 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2893 (mult:FP (match_operand:FP 1 "general_operand" "%0")
2894 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
2895 "TARGET_COLDFIRE_FPU"
2897 if (FP_REG_P (operands[2]))
2898 return "f<FP:prec>mul%.d %2,%0";
2899 return "f<FP:prec>mul%.<FP:prec> %2,%0";
2902 ;; divide instructions
2904 (define_expand "div<mode>3"
2905 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2906 (div:FP (match_operand:FP 1 "general_operand" "")
2907 (match_operand:FP 2 "general_operand" "")))]
2911 (define_insn "div<mode>3_floatsi_68881"
2912 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2913 (div:FP (match_operand:FP 1 "general_operand" "0")
2914 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2918 ? "f<FP:round>div%.l %2,%0"
2919 : "f<FP:round_mul>div%.l %2,%0";
2922 (define_insn "div<mode>3_floathi_68881"
2923 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2924 (div:FP (match_operand:FP 1 "general_operand" "0")
2925 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2929 ? "f<FP:round>div%.w %2,%0"
2930 : "f<FP:round_mul>div%.w %2,%0";
2933 (define_insn "div<mode>3_floatqi_68881"
2934 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2935 (div:FP (match_operand:FP 1 "general_operand" "0")
2936 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2940 ? "f<FP:round>div%.b %2,%0"
2941 : "f<FP:round_mul>div%.b %2,%0";
2944 (define_insn "div<mode>3_68881"
2945 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2946 (div:FP (match_operand:FP 1 "general_operand" "0")
2947 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2950 if (FP_REG_P (operands[2]))
2951 return (TARGET_68040
2952 ? "f<FP:round>div%.x %2,%0"
2953 : "f<FP:round_mul>div%.x %2,%0");
2954 return (TARGET_68040
2955 ? "f<FP:round>div%.<FP:prec> %f2,%0"
2956 : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
2959 (define_insn "div<mode>3_cf"
2960 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2961 (div:FP (match_operand:FP 1 "general_operand" "0")
2962 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
2963 "TARGET_COLDFIRE_FPU"
2965 if (FP_REG_P (operands[2]))
2966 return "f<FP:prec>div%.d %2,%0";
2967 return "f<FP:prec>div%.<FP:prec> %2,%0";
2970 ;; Remainder instructions.
2972 (define_expand "divmodsi4"
2974 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2975 (div:SI (match_operand:SI 1 "general_operand" "")
2976 (match_operand:SI 2 "general_src_operand" "")))
2977 (set (match_operand:SI 3 "nonimmediate_operand" "")
2978 (mod:SI (match_dup 1) (match_dup 2)))])]
2979 "TARGET_68020 || TARGET_CF_HWDIV"
2983 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2984 (div:SI (match_operand:SI 1 "general_operand" "0")
2985 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2986 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2987 (mod:SI (match_dup 1) (match_dup 2)))]
2990 if (find_reg_note (insn, REG_UNUSED, operands[3]))
2991 return "divs%.l %2,%0";
2992 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2993 return "rems%.l %2,%3:%0";
2995 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
2999 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3000 (div:SI (match_operand:SI 1 "general_operand" "0")
3001 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3002 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3003 (mod:SI (match_dup 1) (match_dup 2)))]
3006 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3007 return "divs%.l %2,%0";
3009 return "divsl%.l %2,%3:%0";
3012 (define_expand "udivmodsi4"
3014 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3015 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3016 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3017 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3018 (umod:SI (match_dup 1) (match_dup 2)))])]
3019 "TARGET_68020 || TARGET_CF_HWDIV"
3023 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3024 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3025 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3026 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3027 (umod:SI (match_dup 1) (match_dup 2)))]
3030 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3031 return "divu%.l %2,%0";
3032 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3033 return "remu%.l %2,%3:%0";
3035 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3039 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3040 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3041 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3042 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3043 (umod:SI (match_dup 1) (match_dup 2)))]
3044 "TARGET_68020 && !TARGET_COLDFIRE"
3046 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3047 return "divu%.l %2,%0";
3049 return "divul%.l %2,%3:%0";
3052 (define_insn "divmodhi4"
3053 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3054 (div:HI (match_operand:HI 1 "general_operand" "0")
3055 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3056 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3057 (mod:HI (match_dup 1) (match_dup 2)))]
3058 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3060 output_asm_insn (MOTOROLA ?
3061 "ext%.l %0\;divs%.w %2,%0" :
3062 "extl %0\;divs %2,%0",
3064 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3067 return "move%.l %0,%3\;swap %3";
3073 (define_insn "udivmodhi4"
3074 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3075 (udiv:HI (match_operand:HI 1 "general_operand" "0")
3076 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3077 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3078 (umod:HI (match_dup 1) (match_dup 2)))]
3079 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3082 output_asm_insn (MOTOROLA ?
3083 "mvz%.w %0,%0\;divu%.w %2,%0" :
3084 "mvz%.w %0,%0\;divu %2,%0",
3087 output_asm_insn (MOTOROLA ?
3088 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3089 "and%.l #0xFFFF,%0\;divu %2,%0",
3092 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3095 return "move%.l %0,%3\;swap %3";
3101 ;; logical-and instructions
3103 ;; "anddi3" is mainly here to help combine().
3104 (define_insn "anddi3"
3105 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3106 (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3107 (match_operand:DI 2 "general_operand" "dn,don")))]
3111 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3112 if (CONSTANT_P (operands[2]))
3116 split_double (operands[2], &hi, &lo);
3118 switch (INTVAL (hi))
3121 output_asm_insn ("clr%.l %0", operands);
3129 xoperands[0] = operands[0];
3131 output_asm_insn (output_andsi3 (xoperands), xoperands);
3134 if (GET_CODE (operands[0]) == REG)
3135 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3137 operands[0] = adjust_address (operands[0], SImode, 4);
3138 switch (INTVAL (lo))
3141 output_asm_insn ("clr%.l %0", operands);
3149 xoperands[0] = operands[0];
3151 output_asm_insn (output_andsi3 (xoperands), xoperands);
3156 if (GET_CODE (operands[0]) != REG)
3158 operands[1] = adjust_address (operands[0], SImode, 4);
3159 return "and%.l %2,%0\;and%.l %R2,%1";
3161 if (GET_CODE (operands[2]) != REG)
3163 operands[1] = adjust_address (operands[2], SImode, 4);
3164 return "and%.l %2,%0\;and%.l %1,%R0";
3166 return "and%.l %2,%0\;and%.l %R2,%R0";
3169 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3170 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3171 ;; can't allocate pseudos into it.
3173 (define_expand "andsi3"
3174 [(set (match_operand:SI 0 "not_sp_operand" "")
3175 (and:SI (match_operand:SI 1 "general_operand" "")
3176 (match_operand:SI 2 "general_src_operand" "")))]
3180 ;; produced by split operations after reload finished
3181 (define_insn "*andsi3_split"
3182 [(set (match_operand:SI 0 "register_operand" "=d")
3183 (and:SI (match_operand:SI 1 "register_operand" "0")
3184 (match_operand:SI 2 "const_int_operand" "i")))]
3185 "reload_completed && !TARGET_COLDFIRE"
3187 return output_andsi3 (operands);
3190 (define_insn "andsi3_internal"
3191 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3192 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3193 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3196 return output_andsi3 (operands);
3199 (define_insn "andsi3_5200"
3200 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3201 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3202 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3206 && DATA_REG_P (operands[0])
3207 && GET_CODE (operands[2]) == CONST_INT)
3209 if (INTVAL (operands[2]) == 0x000000ff)
3210 return "mvz%.b %0,%0";
3211 else if (INTVAL (operands[2]) == 0x0000ffff)
3212 return "mvz%.w %0,%0";
3214 return output_andsi3 (operands);
3217 (define_insn "andhi3"
3218 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3219 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3220 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3225 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3226 (and:HI (match_dup 0)
3227 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3232 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3233 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3238 (define_insn "andqi3"
3239 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3240 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3241 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3246 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3247 (and:QI (match_dup 0)
3248 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3253 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3254 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3259 ;; inclusive-or instructions
3261 (define_insn "iordi_zext"
3262 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3263 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3264 (match_operand:DI 2 "general_operand" "0,0")))]
3270 if (GET_CODE (operands[0]) == REG)
3271 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3273 operands[0] = adjust_address (operands[0], SImode, 4);
3274 if (GET_MODE (operands[1]) == SImode)
3275 return "or%.l %1,%0";
3276 byte_mode = (GET_MODE (operands[1]) == QImode);
3277 if (GET_CODE (operands[0]) == MEM)
3278 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3281 return "or%.b %1,%0";
3283 return "or%.w %1,%0";
3286 ;; "iordi3" is mainly here to help combine().
3287 (define_insn "iordi3"
3288 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3289 (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3290 (match_operand:DI 2 "general_operand" "dn,don")))]
3294 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3295 if (CONSTANT_P (operands[2]))
3299 split_double (operands[2], &hi, &lo);
3301 switch (INTVAL (hi))
3306 /* FIXME : a scratch register would be welcome here if operand[0]
3307 is not a register */
3308 output_asm_insn ("move%.l #-1,%0", operands);
3314 xoperands[0] = operands[0];
3316 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3319 if (GET_CODE (operands[0]) == REG)
3320 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3322 operands[0] = adjust_address (operands[0], SImode, 4);
3323 switch (INTVAL (lo))
3328 /* FIXME : a scratch register would be welcome here if operand[0]
3329 is not a register */
3330 output_asm_insn ("move%.l #-1,%0", operands);
3336 xoperands[0] = operands[0];
3338 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3343 if (GET_CODE (operands[0]) != REG)
3345 operands[1] = adjust_address (operands[0], SImode, 4);
3346 return "or%.l %2,%0\;or%.l %R2,%1";
3348 if (GET_CODE (operands[2]) != REG)
3350 operands[1] = adjust_address (operands[2], SImode, 4);
3351 return "or%.l %2,%0\;or%.l %1,%R0";
3353 return "or%.l %2,%0\;or%.l %R2,%R0";
3356 (define_expand "iorsi3"
3357 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3358 (ior:SI (match_operand:SI 1 "general_operand" "")
3359 (match_operand:SI 2 "general_src_operand" "")))]
3363 (define_insn "iorsi3_internal"
3364 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3365 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3366 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3369 return output_iorsi3 (operands);
3372 (define_insn "iorsi3_5200"
3373 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3374 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3375 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3378 return output_iorsi3 (operands);
3381 (define_insn "iorhi3"
3382 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3383 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3384 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3389 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3390 (ior:HI (match_dup 0)
3391 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3396 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3397 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3402 (define_insn "iorqi3"
3403 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3404 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3405 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3410 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3411 (ior:QI (match_dup 0)
3412 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3417 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3418 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3423 ;; On all 68k models, this makes faster code in a special case.
3424 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3426 (define_insn "iorsi_zexthi_ashl16"
3427 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3428 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3429 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3434 if (GET_CODE (operands[2]) != REG)
3435 operands[2] = adjust_address (operands[2], HImode, 2);
3436 if (GET_CODE (operands[2]) != REG
3437 || REGNO (operands[2]) != REGNO (operands[0]))
3438 output_asm_insn ("move%.w %2,%0", operands);
3439 return "swap %0\;mov%.w %1,%0";
3442 (define_insn "iorsi_zext"
3443 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3444 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3445 (match_operand:SI 2 "general_operand" "0,0")))]
3451 byte_mode = (GET_MODE (operands[1]) == QImode);
3452 if (GET_CODE (operands[0]) == MEM)
3453 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3456 return "or%.b %1,%0";
3458 return "or%.w %1,%0";
3463 ;; "xordi3" is mainly here to help combine().
3464 (define_insn "xordi3"
3465 [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3466 (xor:DI (match_operand:DI 1 "general_operand" "%0")
3467 (match_operand:DI 2 "general_operand" "dn")))]
3471 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3473 if (CONSTANT_P (operands[2]))
3477 split_double (operands[2], &hi, &lo);
3479 switch (INTVAL (hi))
3484 output_asm_insn ("not%.l %0", operands);
3487 /* FIXME : a scratch register would be welcome here if
3488 -128 <= INTVAL (hi) < -1 */
3492 xoperands[0] = operands[0];
3494 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3497 if (GET_CODE (operands[0]) == REG)
3498 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3500 operands[0] = adjust_address (operands[0], SImode, 4);
3501 switch (INTVAL (lo))
3506 output_asm_insn ("not%.l %0", operands);
3509 /* FIXME : a scratch register would be welcome here if
3510 -128 <= INTVAL (lo) < -1 */
3512 /* FIXME : this should be merged with xorsi3 */
3516 xoperands[0] = operands[0];
3518 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3523 if (GET_CODE (operands[0]) != REG)
3525 operands[1] = adjust_address (operands[0], SImode, 4);
3526 return "eor%.l %2,%0\;eor%.l %R2,%1";
3528 if (GET_CODE (operands[2]) != REG)
3530 operands[1] = adjust_address (operands[2], SImode, 4);
3531 return "eor%.l %2,%0\;eor%.l %1,%R0";
3533 return "eor%.l %2,%0\;eor%.l %R2,%R0";
3536 (define_expand "xorsi3"
3537 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3538 (xor:SI (match_operand:SI 1 "general_operand" "")
3539 (match_operand:SI 2 "general_operand" "")))]
3543 (define_insn "xorsi3_internal"
3544 [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3545 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3546 (match_operand:SI 2 "general_operand" "di,dKT")))]
3550 return output_xorsi3 (operands);
3553 (define_insn "xorsi3_5200"
3554 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3555 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3556 (match_operand:SI 2 "general_operand" "d,Ks")))]
3559 return output_xorsi3 (operands);
3562 (define_insn "xorhi3"
3563 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3564 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3565 (match_operand:HI 2 "general_operand" "dn")))]
3570 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3571 (xor:HI (match_dup 0)
3572 (match_operand:HI 1 "general_operand" "dn")))]
3577 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3578 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3583 (define_insn "xorqi3"
3584 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3585 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3586 (match_operand:QI 2 "general_operand" "dn")))]
3591 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3592 (xor:QI (match_dup 0)
3593 (match_operand:QI 1 "general_operand" "dn")))]
3598 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3599 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3604 ;; negation instructions
3606 (define_expand "negdi2"
3607 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3608 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3611 if (TARGET_COLDFIRE)
3612 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3614 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3618 (define_insn "negdi2_internal"
3619 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3620 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3623 if (which_alternative == 0)
3624 return "neg%.l %0\;negx%.l %0";
3625 if (GET_CODE (operands[0]) == REG)
3626 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3628 operands[1] = adjust_address (operands[0], SImode, 4);
3629 if (ADDRESS_REG_P (operands[0]))
3630 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3632 return "neg%.l %1\;negx%.l %0";
3635 (define_insn "negdi2_5200"
3636 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3637 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3640 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3641 return "neg%.l %1\;negx%.l %0";
3644 (define_expand "negsi2"
3645 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3646 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3649 if (TARGET_COLDFIRE)
3650 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3652 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3656 (define_insn "negsi2_internal"
3657 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3658 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3662 (define_insn "negsi2_5200"
3663 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3664 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3668 (define_insn "neghi2"
3669 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3670 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3675 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3676 (neg:HI (match_dup 0)))]
3680 (define_insn "negqi2"
3681 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3682 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3687 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3688 (neg:QI (match_dup 0)))]
3692 ;; If using software floating point, just flip the sign bit.
3694 (define_expand "negsf2"
3695 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3696 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3699 if (!TARGET_HARD_FLOAT)
3704 target = operand_subword_force (operands[0], 0, SFmode);
3705 result = expand_binop (SImode, xor_optab,
3706 operand_subword_force (operands[1], 0, SFmode),
3707 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3708 gcc_assert (result);
3710 if (result != target)
3711 emit_move_insn (result, target);
3713 /* Make a place for REG_EQUAL. */
3714 emit_move_insn (operands[0], operands[0]);
3719 (define_expand "negdf2"
3720 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3721 (neg:DF (match_operand:DF 1 "general_operand" "")))]
3724 if (!TARGET_HARD_FLOAT)
3731 target = operand_subword (operands[0], 0, 1, DFmode);
3732 result = expand_binop (SImode, xor_optab,
3733 operand_subword_force (operands[1], 0, DFmode),
3734 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3735 gcc_assert (result);
3737 if (result != target)
3738 emit_move_insn (result, target);
3740 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3741 operand_subword_force (operands[1], 1, DFmode));
3743 insns = get_insns ();
3746 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3751 (define_expand "negxf2"
3752 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3753 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
3763 target = operand_subword (operands[0], 0, 1, XFmode);
3764 result = expand_binop (SImode, xor_optab,
3765 operand_subword_force (operands[1], 0, XFmode),
3766 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3767 gcc_assert (result);
3769 if (result != target)
3770 emit_move_insn (result, target);
3772 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
3773 operand_subword_force (operands[1], 1, XFmode));
3774 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
3775 operand_subword_force (operands[1], 2, XFmode));
3777 insns = get_insns ();
3780 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3785 (define_insn "neg<mode>2_68881"
3786 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3787 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
3790 if (DATA_REG_P (operands[0]))
3792 operands[1] = GEN_INT (31);
3793 return "bchg %1,%0";
3795 if (FP_REG_P (operands[1]))
3796 return "f<FP:round>neg%.x %1,%0";
3797 return "f<FP:round>neg%.<FP:prec> %f1,%0";
3800 (define_insn "neg<mode>2_cf"
3801 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3802 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
3803 "TARGET_COLDFIRE_FPU"
3805 if (DATA_REG_P (operands[0]))
3807 operands[1] = GEN_INT (31);
3808 return "bchg %1,%0";
3810 if (FP_REG_P (operands[1]))
3811 return "f<FP:prec>neg%.d %1,%0";
3812 return "f<FP:prec>neg%.<FP:prec> %1,%0";
3815 ;; Sqrt instruction for the 68881
3817 (define_expand "sqrt<mode>2"
3818 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3819 (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
3823 (define_insn "sqrt<mode>2_68881"
3824 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3825 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
3828 if (FP_REG_P (operands[1]))
3829 return "f<FP:round>sqrt%.x %1,%0";
3830 return "f<FP:round>sqrt%.<FP:prec> %1,%0";
3833 (define_insn "sqrt<mode>2_cf"
3834 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3835 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
3836 "TARGET_COLDFIRE_FPU"
3838 if (FP_REG_P (operands[1]))
3839 return "f<FP:prec>sqrt%.d %1,%0";
3840 return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
3842 ;; Absolute value instructions
3843 ;; If using software floating point, just zero the sign bit.
3845 (define_expand "abssf2"
3846 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3847 (abs:SF (match_operand:SF 1 "general_operand" "")))]
3850 if (!TARGET_HARD_FLOAT)
3855 target = operand_subword_force (operands[0], 0, SFmode);
3856 result = expand_binop (SImode, and_optab,
3857 operand_subword_force (operands[1], 0, SFmode),
3858 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3859 gcc_assert (result);
3861 if (result != target)
3862 emit_move_insn (result, target);
3864 /* Make a place for REG_EQUAL. */
3865 emit_move_insn (operands[0], operands[0]);
3870 (define_expand "absdf2"
3871 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3872 (abs:DF (match_operand:DF 1 "general_operand" "")))]
3875 if (!TARGET_HARD_FLOAT)
3882 target = operand_subword (operands[0], 0, 1, DFmode);
3883 result = expand_binop (SImode, and_optab,
3884 operand_subword_force (operands[1], 0, DFmode),
3885 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3886 gcc_assert (result);
3888 if (result != target)
3889 emit_move_insn (result, target);
3891 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3892 operand_subword_force (operands[1], 1, DFmode));
3894 insns = get_insns ();
3897 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3902 (define_expand "absxf2"
3903 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3904 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
3914 target = operand_subword (operands[0], 0, 1, XFmode);
3915 result = expand_binop (SImode, and_optab,
3916 operand_subword_force (operands[1], 0, XFmode),
3917 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3918 gcc_assert (result);
3920 if (result != target)
3921 emit_move_insn (result, target);
3923 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
3924 operand_subword_force (operands[1], 1, XFmode));
3925 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
3926 operand_subword_force (operands[1], 2, XFmode));
3928 insns = get_insns ();
3931 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3936 (define_insn "abs<mode>2_68881"
3937 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3938 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
3941 if (DATA_REG_P (operands[0]))
3943 operands[1] = GEN_INT (31);
3944 return "bclr %1,%0";
3946 if (FP_REG_P (operands[1]))
3947 return "f<FP:round>abs%.x %1,%0";
3948 return "f<FP:round>abs%.<FP:prec> %f1,%0";
3951 (define_insn "abs<mode>2_cf"
3952 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3953 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
3954 "TARGET_COLDFIRE_FPU"
3956 if (DATA_REG_P (operands[0]))
3958 operands[1] = GEN_INT (31);
3959 return "bclr %1,%0";
3961 if (FP_REG_P (operands[1]))
3962 return "f<FP:prec>abs%.d %1,%0";
3963 return "f<FP:prec>abs%.<FP:prec> %1,%0";
3966 ;; bit indexing instructions
3968 ;; ColdFire ff1 instruction implements clz.
3969 (define_insn "clzsi2"
3970 [(set (match_operand:SI 0 "register_operand" "=d")
3971 (clz:SI (match_operand:SI 1 "register_operand" "0")))]
3972 "TARGET_ISAAPLUS || TARGET_ISAC"
3975 ;; one complement instructions
3977 ;; "one_cmpldi2" is mainly here to help combine().
3978 (define_insn "one_cmpldi2"
3979 [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
3980 (not:DI (match_operand:DI 1 "general_operand" "0")))]
3984 if (GET_CODE (operands[0]) == REG)
3985 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3986 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
3987 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3988 operands[1] = operands[0];
3990 operands[1] = adjust_address (operands[0], SImode, 4);
3991 return "not%.l %1\;not%.l %0";
3994 (define_expand "one_cmplsi2"
3995 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3996 (not:SI (match_operand:SI 1 "general_operand" "")))]
3999 if (TARGET_COLDFIRE)
4000 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
4002 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
4006 (define_insn "one_cmplsi2_internal"
4007 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4008 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4012 (define_insn "one_cmplsi2_5200"
4013 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4014 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4018 (define_insn "one_cmplhi2"
4019 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4020 (not:HI (match_operand:HI 1 "general_operand" "0")))]
4025 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4026 (not:HI (match_dup 0)))]
4030 (define_insn "one_cmplqi2"
4031 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4032 (not:QI (match_operand:QI 1 "general_operand" "0")))]
4037 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4038 (not:QI (match_dup 0)))]
4042 ;; arithmetic shift instructions
4043 ;; We don't need the shift memory by 1 bit instruction
4045 (define_insn "ashldi_extsi"
4046 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4048 (match_operator:DI 2 "extend_operator"
4049 [(match_operand:SI 1 "general_operand" "rm")])
4054 if (GET_CODE (operands[0]) == REG)
4055 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4057 operands[2] = adjust_address (operands[0], SImode, 4);
4058 if (ADDRESS_REG_P (operands[0]))
4059 return "move%.l %1,%0\;sub%.l %2,%2";
4061 return "move%.l %1,%0\;clr%.l %2";
4064 (define_insn "ashldi_sexthi"
4065 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
4066 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
4068 (clobber (match_scratch:SI 2 "=a,X"))]
4072 if (GET_CODE (operands[0]) == MEM)
4074 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4075 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
4076 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4077 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
4080 operands[3] = adjust_address (operands[0], SImode, 4);
4081 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
4084 else if (DATA_REG_P (operands[0]))
4085 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
4087 return "move%.w %1,%0\;sub%.l %R0,%R0";
4090 (define_insn "ashldi_const32"
4091 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
4092 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
4097 if (GET_CODE (operands[1]) == REG)
4098 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4100 operands[3] = adjust_address (operands[1], SImode, 4);
4101 if (GET_CODE (operands[0]) == REG)
4102 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4103 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4104 return "clr%.l %0\;move%.l %3,%0";
4105 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4106 return "move%.l %3,%0\;clr%.l %0";
4108 operands[2] = adjust_address (operands[0], SImode, 4);
4109 if (ADDRESS_REG_P (operands[2]))
4110 return "move%.l %3,%0\;sub%.l %2,%2";
4112 return "move%.l %3,%0\;clr%.l %2";
4115 ;; The predicate below must be general_operand, because ashldi3 allows that
4116 (define_insn "ashldi_const"
4117 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4118 (ashift:DI (match_operand:DI 1 "general_operand" "0")
4119 (match_operand 2 "const_int_operand" "n")))]
4121 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4122 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4123 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4125 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4126 if (INTVAL (operands[2]) == 1)
4127 return "add%.l %1,%1\;addx%.l %0,%0";
4128 else if (INTVAL (operands[2]) == 8)
4129 return "rol%.l #8,%1\;rol%.l #8,%0\;move%.b %1,%0\;clr%.b %1";
4130 else if (INTVAL (operands[2]) == 16)
4131 return "swap %1\;swap %0\;move%.w %1,%0\;clr%.w %1";
4132 else if (INTVAL (operands[2]) == 48)
4133 return "mov%.l %1,%0\;swap %0\;clr%.l %1\;clr%.w %0";
4134 else if (INTVAL (operands[2]) == 2)
4135 return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
4136 else if (INTVAL (operands[2]) == 3)
4137 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";
4138 else /* 32 < INTVAL (operands[2]) <= 63 */
4140 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4141 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asl%.l %2,%1" :
4142 "moveq %2,%0\;asl%.l %0,%1", operands);
4143 return "mov%.l %1,%0\;moveq #0,%1";
4147 (define_expand "ashldi3"
4148 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4149 (ashift:DI (match_operand:DI 1 "general_operand" "")
4150 (match_operand 2 "const_int_operand" "")))]
4154 /* ??? This is a named pattern like this is not allowed to FAIL based
4156 if (GET_CODE (operands[2]) != CONST_INT
4157 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4158 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4159 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4163 ;; On most 68k models, this makes faster code in a special case.
4165 (define_insn "ashlsi_16"
4166 [(set (match_operand:SI 0 "register_operand" "=d")
4167 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4172 return "swap %0\;clr%.w %0";
4175 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
4176 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4178 ;; On the 68000, this makes faster code in a special case.
4180 (define_insn "ashlsi_17_24"
4181 [(set (match_operand:SI 0 "register_operand" "=d")
4182 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4183 (match_operand:SI 2 "const_int_operand" "n")))]
4185 && INTVAL (operands[2]) > 16
4186 && INTVAL (operands[2]) <= 24"
4190 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4191 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4194 (define_insn "ashlsi3"
4195 [(set (match_operand:SI 0 "register_operand" "=d")
4196 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4197 (match_operand:SI 2 "general_operand" "dI")))]
4200 if (operands[2] == const1_rtx)
4202 cc_status.flags = CC_NO_OVERFLOW;
4203 return "add%.l %0,%0";
4205 return "lsl%.l %2,%0";
4208 (define_insn "ashlhi3"
4209 [(set (match_operand:HI 0 "register_operand" "=d")
4210 (ashift:HI (match_operand:HI 1 "register_operand" "0")
4211 (match_operand:HI 2 "general_operand" "dI")))]
4216 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4217 (ashift:HI (match_dup 0)
4218 (match_operand:HI 1 "general_operand" "dI")))]
4222 (define_insn "ashlqi3"
4223 [(set (match_operand:QI 0 "register_operand" "=d")
4224 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4225 (match_operand:QI 2 "general_operand" "dI")))]
4230 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4231 (ashift:QI (match_dup 0)
4232 (match_operand:QI 1 "general_operand" "dI")))]
4236 ;; On most 68k models, this makes faster code in a special case.
4238 (define_insn "ashrsi_16"
4239 [(set (match_operand:SI 0 "register_operand" "=d")
4240 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4243 "swap %0\;ext%.l %0")
4245 ;; On the 68000, this makes faster code in a special case.
4248 [(set (match_operand:SI 0 "register_operand" "=d")
4249 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4250 (match_operand:SI 2 "const_int_operand" "n")))]
4252 && INTVAL (operands[2]) > 16
4253 && INTVAL (operands[2]) <= 24"
4255 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4256 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4259 (define_insn "subreghi1ashrdi_const32"
4260 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4261 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4262 (const_int 32)) 6))]
4265 if (GET_CODE (operands[1]) != REG)
4266 operands[1] = adjust_address (operands[1], HImode, 2);
4267 return "move%.w %1,%0";
4270 (define_insn "subregsi1ashrdi_const32"
4271 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4272 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4273 (const_int 32)) 4))]
4276 return "move%.l %1,%0";
4279 (define_insn "ashrdi_const32"
4280 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o,<")
4281 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4283 (clobber (match_scratch:SI 2 "=X,d,d"))]
4287 if (which_alternative == 0)
4289 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4291 return "move%.l %1,%2\;smi %0\;extb%.l %0";
4293 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
4297 if (which_alternative == 2)
4298 operands[3] = operands[0];
4299 else if (which_alternative == 1)
4300 operands[3] = adjust_address (operands[0], SImode, 4);
4302 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4304 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4308 ;; The predicate below must be general_operand, because ashrdi3 allows that
4309 (define_insn "ashrdi_const"
4310 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4311 (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
4312 (match_operand 2 "const_int_operand" "n")))
4313 (clobber (match_scratch:SI 3 "=X"))]
4315 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4316 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4317 || INTVAL (operands[2]) == 31
4318 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4320 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4321 if (INTVAL (operands[2]) == 63)
4322 return "add%.l %0,%0\;subx%.l %0,%0\;move%.l %0,%1";
4324 if (INTVAL (operands[2]) == 1)
4325 return "asr%.l #1,%0\;roxr%.l #1,%1";
4326 else if (INTVAL (operands[2]) == 8)
4327 return "move%.b %0,%1\;asr%.l #8,%0\;ror%.l #8,%1";
4328 else if (INTVAL (operands[2]) == 16)
4329 return "move%.w %0,%1\;swap %0\;ext%.l %0\;swap %1";
4330 else if (INTVAL (operands[2]) == 48)
4331 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4332 else if (INTVAL (operands[2]) == 31)
4333 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4334 else if (INTVAL (operands[2]) == 2)
4335 return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4336 else if (INTVAL (operands[2]) == 3)
4337 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";
4338 else /* 32 < INTVAL (operands[2]) <= 63 */
4340 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4341 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4342 "moveq %2,%1\;asr%.l %1,%0", operands);
4343 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4344 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4345 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4349 (define_expand "ashrdi3"
4350 [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
4351 (ashiftrt:DI (match_operand:DI 1 "general_operand" "")
4352 (match_operand 2 "const_int_operand" "")))
4353 (clobber (match_scratch:SI 3 ""))])]
4357 /* ??? This is a named pattern like this is not allowed to FAIL based
4359 if (GET_CODE (operands[2]) != CONST_INT
4360 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4361 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4362 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4364 operands[3] = gen_rtx_SCRATCH (SImode);
4367 ;; On all 68k models, this makes faster code in a special case.
4369 (define_insn "ashrsi_31"
4370 [(set (match_operand:SI 0 "register_operand" "=d")
4371 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4375 return "add%.l %0,%0\;subx%.l %0,%0";
4378 (define_insn "ashrsi3"
4379 [(set (match_operand:SI 0 "register_operand" "=d")
4380 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4381 (match_operand:SI 2 "general_operand" "dI")))]
4385 (define_insn "ashrhi3"
4386 [(set (match_operand:HI 0 "register_operand" "=d")
4387 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4388 (match_operand:HI 2 "general_operand" "dI")))]
4393 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4394 (ashiftrt:HI (match_dup 0)
4395 (match_operand:HI 1 "general_operand" "dI")))]
4399 (define_insn "ashrqi3"
4400 [(set (match_operand:QI 0 "register_operand" "=d")
4401 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4402 (match_operand:QI 2 "general_operand" "dI")))]
4407 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4408 (ashiftrt:QI (match_dup 0)
4409 (match_operand:QI 1 "general_operand" "dI")))]
4413 ;; logical shift instructions
4415 ;; commented out because of reload problems in 950612-1.c
4418 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4419 ;; (const_int 32)) 4))
4420 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4421 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4422 ;; (const_int 32)) 4))]
4425 ;; return "move%.l %0,%1";
4430 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4431 ;; (const_int 32)) 0))
4432 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4433 ;; (lshiftrt:DI (match_dup 0)
4434 ;; (const_int 32)))]
4437 ;; if (GET_CODE (operands[1]) == REG)
4438 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4440 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4441 ;; return "move%.l %0,%2\;clr%.l %1";
4444 (define_insn "subreg1lshrdi_const32"
4445 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4446 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4447 (const_int 32)) 4))]
4450 return "move%.l %1,%0";
4453 (define_insn "lshrdi_const32"
4454 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro,<,>")
4455 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4460 if (which_alternative == 1)
4461 return "move%.l %1,%0\;clr%.l %0";
4462 if (which_alternative == 2)
4463 return "clr%.l %0\;move%.l %1,%0";
4464 if (GET_CODE (operands[0]) == REG)
4465 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4467 operands[2] = adjust_address (operands[0], SImode, 4);
4468 if (GET_CODE (operands[1]) == REG)
4469 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4471 operands[3] = adjust_address (operands[1], SImode, 4);
4472 if (ADDRESS_REG_P (operands[0]))
4473 return "move%.l %1,%2\;sub%.l %0,%0";
4475 return "move%.l %1,%2\;clr%.l %0";
4478 ;; The predicate below must be general_operand, because lshrdi3 allows that
4479 (define_insn "lshrdi_const"
4480 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4481 (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
4482 (match_operand 2 "const_int_operand" "n")))]
4484 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4485 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4486 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4488 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4489 if (INTVAL (operands[2]) == 63)
4490 return "add%.l %0,%0\;clr%.l %0\;clr%.l %1\;addx%.l %1,%1";
4492 if (INTVAL (operands[2]) == 1)
4493 return "lsr%.l #1,%0\;roxr%.l #1,%1";
4494 else if (INTVAL (operands[2]) == 8)
4495 return "move%.b %0,%1\;lsr%.l #8,%0\;ror%.l #8,%1";
4496 else if (INTVAL (operands[2]) == 16)
4497 return "move%.w %0,%1\;clr%.w %0\;swap %1\;swap %0";
4498 else if (INTVAL (operands[2]) == 48)
4499 return "move%.l %0,%1\;clr%.w %1\;clr%.l %0\;swap %1";
4500 else if (INTVAL (operands[2]) == 2)
4501 return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4502 else if (INTVAL (operands[2]) == 3)
4503 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";
4504 else /* 32 < INTVAL (operands[2]) <= 63 */
4506 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4507 output_asm_insn (INTVAL (operands[2]) <= 8 ? "lsr%.l %2,%0" :
4508 "moveq %2,%1\;lsr%.l %1,%0", operands);
4509 return "mov%.l %0,%1\;moveq #0,%0";
4513 (define_expand "lshrdi3"
4514 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4515 (lshiftrt:DI (match_operand:DI 1 "general_operand" "")
4516 (match_operand 2 "const_int_operand" "")))]
4519 /* ??? This is a named pattern like this is not allowed to FAIL based
4521 if (GET_CODE (operands[2]) != CONST_INT
4522 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4523 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4524 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4528 ;; On all 68k models, this makes faster code in a special case.
4530 (define_insn "lshrsi_31"
4531 [(set (match_operand:SI 0 "register_operand" "=d")
4532 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4536 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
4539 ;; On most 68k models, this makes faster code in a special case.
4541 (define_insn "lshrsi_16"
4542 [(set (match_operand:SI 0 "register_operand" "=d")
4543 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4548 return "clr%.w %0\;swap %0";
4551 ;; On the 68000, this makes faster code in a special case.
4553 (define_insn "lshrsi_17_24"
4554 [(set (match_operand:SI 0 "register_operand" "=d")
4555 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4556 (match_operand:SI 2 "const_int_operand" "n")))]
4558 && INTVAL (operands[2]) > 16
4559 && INTVAL (operands[2]) <= 24"
4561 /* I think lsr%.w sets the CC properly. */
4562 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4563 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
4566 (define_insn "lshrsi3"
4567 [(set (match_operand:SI 0 "register_operand" "=d")
4568 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4569 (match_operand:SI 2 "general_operand" "dI")))]
4573 (define_insn "lshrhi3"
4574 [(set (match_operand:HI 0 "register_operand" "=d")
4575 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
4576 (match_operand:HI 2 "general_operand" "dI")))]
4581 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4582 (lshiftrt:HI (match_dup 0)
4583 (match_operand:HI 1 "general_operand" "dI")))]
4587 (define_insn "lshrqi3"
4588 [(set (match_operand:QI 0 "register_operand" "=d")
4589 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
4590 (match_operand:QI 2 "general_operand" "dI")))]
4595 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4596 (lshiftrt:QI (match_dup 0)
4597 (match_operand:QI 1 "general_operand" "dI")))]
4601 ;; rotate instructions
4603 (define_insn "rotlsi3"
4604 [(set (match_operand:SI 0 "register_operand" "=d")
4605 (rotate:SI (match_operand:SI 1 "register_operand" "0")
4606 (match_operand:SI 2 "general_operand" "dINO")))]
4609 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
4611 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
4613 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4614 return "ror%.l %2,%0";
4617 return "rol%.l %2,%0";
4620 (define_insn "rotlhi3"
4621 [(set (match_operand:HI 0 "register_operand" "=d")
4622 (rotate:HI (match_operand:HI 1 "register_operand" "0")
4623 (match_operand:HI 2 "general_operand" "dIP")))]
4626 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4628 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4629 return "ror%.w %2,%0";
4632 return "rol%.w %2,%0";
4636 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4637 (rotate:HI (match_dup 0)
4638 (match_operand:HI 1 "general_operand" "dIP")))]
4641 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4643 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4644 return "ror%.w %2,%0";
4647 return "rol%.w %2,%0";
4650 (define_insn "rotlqi3"
4651 [(set (match_operand:QI 0 "register_operand" "=d")
4652 (rotate:QI (match_operand:QI 1 "register_operand" "0")
4653 (match_operand:QI 2 "general_operand" "dI")))]
4656 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4658 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4659 return "ror%.b %2,%0";
4662 return "rol%.b %2,%0";
4666 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4667 (rotate:QI (match_dup 0)
4668 (match_operand:QI 1 "general_operand" "dI")))]
4671 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4673 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4674 return "ror%.b %2,%0";
4677 return "rol%.b %2,%0";
4680 (define_insn "rotrsi3"
4681 [(set (match_operand:SI 0 "register_operand" "=d")
4682 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
4683 (match_operand:SI 2 "general_operand" "dI")))]
4687 (define_insn "rotrhi3"
4688 [(set (match_operand:HI 0 "register_operand" "=d")
4689 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
4690 (match_operand:HI 2 "general_operand" "dI")))]
4695 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4696 (rotatert:HI (match_dup 0)
4697 (match_operand:HI 1 "general_operand" "dI")))]
4701 (define_insn "rotrqi3"
4702 [(set (match_operand:QI 0 "register_operand" "=d")
4703 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
4704 (match_operand:QI 2 "general_operand" "dI")))]
4709 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4710 (rotatert:QI (match_dup 0)
4711 (match_operand:QI 1 "general_operand" "dI")))]
4716 ;; Bit set/clear in memory byte.
4718 ;; set bit, bit number is int
4719 (define_insn "bsetmemqi"
4720 [(set (match_operand:QI 0 "memory_operand" "+m")
4721 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4722 (match_operand:SI 1 "general_operand" "d")) 3)
4727 return "bset %1,%0";
4730 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
4732 [(set (match_operand:QI 0 "memory_operand" "+m")
4733 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4734 (match_operator:SI 2 "extend_operator"
4735 [(match_operand 1 "general_operand" "d")])) 3)
4740 return "bset %1,%0";
4743 ;; clear bit, bit number is int
4744 (define_insn "bclrmemqi"
4745 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4747 (minus:SI (const_int 7)
4748 (match_operand:SI 1 "general_operand" "d")))
4753 return "bclr %1,%0";
4756 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
4758 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4760 (minus:SI (const_int 7)
4761 (match_operator:SI 2 "extend_operator"
4762 [(match_operand 1 "general_operand" "d")])))
4767 return "bclr %1,%0";
4770 ;; Special cases of bit-field insns which we should
4771 ;; recognize in preference to the general case.
4772 ;; These handle aligned 8-bit and 16-bit fields,
4773 ;; which can usually be done with move instructions.
4776 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4777 ; alignment of structure members is specified.
4779 ; The move is allowed to be odd byte aligned, because that's still faster
4780 ; than an odd byte aligned bit-field instruction.
4783 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4785 (match_operand:SI 1 "const_int_operand" "n"))
4786 (match_operand:SI 2 "general_src_operand" "rmSi"))]
4787 "TARGET_68020 && TARGET_BITFIELD
4788 && (INTVAL (operands[1]) % 8) == 0
4789 && ! mode_dependent_address_p (XEXP (operands[0], 0))"
4792 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
4794 return "move%.l %2,%0";
4798 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
4799 (match_operand:SI 1 "const_int_operand" "n")
4800 (match_operand:SI 2 "const_int_operand" "n"))
4801 (match_operand:SI 3 "register_operand" "d"))]
4802 "TARGET_68020 && TARGET_BITFIELD
4803 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
4804 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
4805 && (GET_CODE (operands[0]) == REG
4806 || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
4808 if (REG_P (operands[0]))
4810 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
4811 return "bfins %3,%0{%b2:%b1}";
4814 operands[0] = adjust_address (operands[0],
4815 INTVAL (operands[1]) == 8 ? QImode : HImode,
4816 INTVAL (operands[2]) / 8);
4818 if (GET_CODE (operands[3]) == MEM)
4819 operands[3] = adjust_address (operands[3],
4820 INTVAL (operands[1]) == 8 ? QImode : HImode,
4821 (32 - INTVAL (operands[1])) / 8);
4823 if (INTVAL (operands[1]) == 8)
4824 return "move%.b %3,%0";
4825 return "move%.w %3,%0";
4830 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4831 ; alignment of structure members is specified.
4833 ; The move is allowed to be odd byte aligned, because that's still faster
4834 ; than an odd byte aligned bit-field instruction.
4837 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4838 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4840 (match_operand:SI 2 "const_int_operand" "n")))]
4841 "TARGET_68020 && TARGET_BITFIELD
4842 && (INTVAL (operands[2]) % 8) == 0
4843 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4846 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4848 return "move%.l %1,%0";
4852 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
4853 (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
4854 (match_operand:SI 2 "const_int_operand" "n")
4855 (match_operand:SI 3 "const_int_operand" "n")))]
4856 "TARGET_68020 && TARGET_BITFIELD
4857 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4858 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4859 && (GET_CODE (operands[1]) == REG
4860 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4862 cc_status.flags |= CC_NOT_NEGATIVE;
4863 if (REG_P (operands[1]))
4865 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4866 return "bfextu %1{%b3:%b2},%0";
4870 = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
4872 output_asm_insn ("clr%.l %0", operands);
4873 if (GET_CODE (operands[0]) == MEM)
4874 operands[0] = adjust_address (operands[0],
4875 INTVAL (operands[2]) == 8 ? QImode : HImode,
4876 (32 - INTVAL (operands[1])) / 8);
4878 if (INTVAL (operands[2]) == 8)
4879 return "move%.b %1,%0";
4880 return "move%.w %1,%0";
4884 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4885 ; alignment of structure members is specified.
4887 ; The move is allowed to be odd byte aligned, because that's still faster
4888 ; than an odd byte aligned bit-field instruction.
4891 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4892 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4894 (match_operand:SI 2 "const_int_operand" "n")))]
4895 "TARGET_68020 && TARGET_BITFIELD
4896 && (INTVAL (operands[2]) % 8) == 0
4897 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4900 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4902 return "move%.l %1,%0";
4906 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4907 (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
4908 (match_operand:SI 2 "const_int_operand" "n")
4909 (match_operand:SI 3 "const_int_operand" "n")))]
4910 "TARGET_68020 && TARGET_BITFIELD
4911 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4912 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4913 && (GET_CODE (operands[1]) == REG
4914 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4916 if (REG_P (operands[1]))
4918 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4919 return "bfexts %1{%b3:%b2},%0";
4923 = adjust_address (operands[1],
4924 INTVAL (operands[2]) == 8 ? QImode : HImode,
4925 INTVAL (operands[3]) / 8);
4927 if (INTVAL (operands[2]) == 8)
4928 return "move%.b %1,%0\;extb%.l %0";
4929 return "move%.w %1,%0\;ext%.l %0";
4932 ;; Bit-field instructions, general cases.
4933 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
4934 ;; so that its address is reloaded.
4936 (define_expand "extv"
4937 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4938 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
4939 (match_operand:SI 2 "general_operand" "")
4940 (match_operand:SI 3 "general_operand" "")))]
4941 "TARGET_68020 && TARGET_BITFIELD"
4945 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4946 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
4947 (match_operand:SI 2 "general_operand" "dn")
4948 (match_operand:SI 3 "general_operand" "dn")))]
4949 "TARGET_68020 && TARGET_BITFIELD"
4950 "bfexts %1{%b3:%b2},%0")
4952 (define_expand "extzv"
4953 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4954 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
4955 (match_operand:SI 2 "general_operand" "")
4956 (match_operand:SI 3 "general_operand" "")))]
4957 "TARGET_68020 && TARGET_BITFIELD"
4961 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d")
4962 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o,d")
4963 (match_operand:SI 2 "general_operand" "dn,dn")
4964 (match_operand:SI 3 "general_operand" "dn,dn")))]
4965 "TARGET_68020 && TARGET_BITFIELD"
4967 if (GET_CODE (operands[2]) == CONST_INT)
4969 if (INTVAL (operands[2]) != 32)
4970 cc_status.flags |= CC_NOT_NEGATIVE;
4976 return "bfextu %1{%b3:%b2},%0";
4980 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4981 (match_operand:SI 1 "general_operand" "dn")
4982 (match_operand:SI 2 "general_operand" "dn"))
4983 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
4984 (match_operand 3 "const_int_operand" "n")))]
4985 "TARGET_68020 && TARGET_BITFIELD
4986 && (INTVAL (operands[3]) == -1
4987 || (GET_CODE (operands[1]) == CONST_INT
4988 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
4991 return "bfchg %0{%b2:%b1}";
4995 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4996 (match_operand:SI 1 "general_operand" "dn")
4997 (match_operand:SI 2 "general_operand" "dn"))
4999 "TARGET_68020 && TARGET_BITFIELD"
5002 return "bfclr %0{%b2:%b1}";
5006 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5007 (match_operand:SI 1 "general_operand" "dn")
5008 (match_operand:SI 2 "general_operand" "dn"))
5010 "TARGET_68020 && TARGET_BITFIELD"
5013 return "bfset %0{%b2:%b1}";
5016 (define_expand "insv"
5017 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5018 (match_operand:SI 1 "general_operand" "")
5019 (match_operand:SI 2 "general_operand" ""))
5020 (match_operand:SI 3 "register_operand" ""))]
5021 "TARGET_68020 && TARGET_BITFIELD"
5025 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5026 (match_operand:SI 1 "general_operand" "dn")
5027 (match_operand:SI 2 "general_operand" "dn"))
5028 (match_operand:SI 3 "register_operand" "d"))]
5029 "TARGET_68020 && TARGET_BITFIELD"
5030 "bfins %3,%0{%b2:%b1}")
5032 ;; Now recognize bit-field insns that operate on registers
5033 ;; (or at least were intended to do so).
5036 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5037 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5038 (match_operand:SI 2 "general_operand" "dn")
5039 (match_operand:SI 3 "general_operand" "dn")))]
5040 "TARGET_68020 && TARGET_BITFIELD"
5041 "bfexts %1{%b3:%b2},%0")
5044 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5045 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5046 (match_operand:SI 2 "general_operand" "dn")
5047 (match_operand:SI 3 "general_operand" "dn")))]
5048 "TARGET_68020 && TARGET_BITFIELD"
5050 if (GET_CODE (operands[2]) == CONST_INT)
5052 if (INTVAL (operands[2]) != 32)
5053 cc_status.flags |= CC_NOT_NEGATIVE;
5059 return "bfextu %1{%b3:%b2},%0";
5063 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5064 (match_operand:SI 1 "general_operand" "dn")
5065 (match_operand:SI 2 "general_operand" "dn"))
5067 "TARGET_68020 && TARGET_BITFIELD"
5070 return "bfclr %0{%b2:%b1}";
5074 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5075 (match_operand:SI 1 "general_operand" "dn")
5076 (match_operand:SI 2 "general_operand" "dn"))
5078 "TARGET_68020 && TARGET_BITFIELD"
5081 return "bfset %0{%b2:%b1}";
5085 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5086 (match_operand:SI 1 "general_operand" "dn")
5087 (match_operand:SI 2 "general_operand" "dn"))
5088 (match_operand:SI 3 "register_operand" "d"))]
5089 "TARGET_68020 && TARGET_BITFIELD"
5092 /* These special cases are now recognized by a specific pattern. */
5093 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5094 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5095 return "move%.w %3,%0";
5096 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5097 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5098 return "move%.b %3,%0";
5100 return "bfins %3,%0{%b2:%b1}";
5103 ;; Special patterns for optimizing bit-field instructions.
5107 (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5108 (match_operand:SI 1 "const_int_operand" "n")
5109 (match_operand:SI 2 "general_operand" "dn")))]
5110 "TARGET_68020 && TARGET_BITFIELD"
5112 if (operands[1] == const1_rtx
5113 && GET_CODE (operands[2]) == CONST_INT)
5115 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5116 return output_btst (operands,
5117 GEN_INT (width - INTVAL (operands[2])),
5118 operands[0], insn, 1000);
5119 /* Pass 1000 as SIGNPOS argument so that btst will
5120 not think we are testing the sign bit for an `and'
5121 and assume that nonzero implies a negative result. */
5123 if (INTVAL (operands[1]) != 32)
5124 cc_status.flags = CC_NOT_NEGATIVE;
5125 return "bftst %0{%b2:%b1}";
5129 ;;; now handle the register cases
5132 (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5133 (match_operand:SI 1 "const_int_operand" "n")
5134 (match_operand:SI 2 "general_operand" "dn")))]
5135 "TARGET_68020 && TARGET_BITFIELD"
5137 if (operands[1] == const1_rtx
5138 && GET_CODE (operands[2]) == CONST_INT)
5140 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5141 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5142 operands[0], insn, 1000);
5143 /* Pass 1000 as SIGNPOS argument so that btst will
5144 not think we are testing the sign bit for an `and'
5145 and assume that nonzero implies a negative result. */
5147 if (INTVAL (operands[1]) != 32)
5148 cc_status.flags = CC_NOT_NEGATIVE;
5149 return "bftst %0{%b2:%b1}";
5152 (define_insn "scc0_di"
5153 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5154 (match_operator 1 "valid_dbcc_comparison_p"
5155 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5158 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5161 (define_insn "scc0_di_5200"
5162 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5163 (match_operator 1 "valid_dbcc_comparison_p"
5164 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5167 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5170 (define_insn "scc_di"
5171 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5172 (match_operator 1 "valid_dbcc_comparison_p"
5173 [(match_operand:DI 2 "general_operand" "ro,r")
5174 (match_operand:DI 3 "general_operand" "r,ro")]))]
5177 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5180 (define_insn "scc_di_5200"
5181 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5182 (match_operator 1 "valid_dbcc_comparison_p"
5183 [(match_operand:DI 2 "general_operand" "ro,r")
5184 (match_operand:DI 3 "general_operand" "r,ro")]))]
5187 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5190 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5191 ;; memory, but we cannot allow it to be in memory in case the address
5192 ;; needs to be reloaded.
5194 (define_expand "seq"
5195 [(set (match_operand:QI 0 "register_operand" "")
5196 (eq:QI (cc0) (const_int 0)))]
5199 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5200 && m68k_last_compare_had_fp_operands)
5202 m68k_last_compare_had_fp_operands = 0;
5208 [(set (match_operand:QI 0 "register_operand" "=d")
5209 (eq:QI (cc0) (const_int 0)))]
5212 cc_status = cc_prev_status;
5213 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5216 (define_expand "sne"
5217 [(set (match_operand:QI 0 "register_operand" "")
5218 (ne:QI (cc0) (const_int 0)))]
5221 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5222 && m68k_last_compare_had_fp_operands)
5224 m68k_last_compare_had_fp_operands = 0;
5230 [(set (match_operand:QI 0 "register_operand" "=d")
5231 (ne:QI (cc0) (const_int 0)))]
5234 cc_status = cc_prev_status;
5235 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5238 (define_expand "sgt"
5239 [(set (match_operand:QI 0 "register_operand" "")
5240 (gt:QI (cc0) (const_int 0)))]
5243 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5244 && m68k_last_compare_had_fp_operands)
5246 m68k_last_compare_had_fp_operands = 0;
5252 [(set (match_operand:QI 0 "register_operand" "=d")
5253 (gt:QI (cc0) (const_int 0)))]
5256 cc_status = cc_prev_status;
5257 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5260 (define_expand "sgtu"
5261 [(set (match_operand:QI 0 "register_operand" "")
5262 (gtu:QI (cc0) (const_int 0)))]
5267 [(set (match_operand:QI 0 "register_operand" "=d")
5268 (gtu:QI (cc0) (const_int 0)))]
5271 cc_status = cc_prev_status;
5275 (define_expand "slt"
5276 [(set (match_operand:QI 0 "register_operand" "")
5277 (lt:QI (cc0) (const_int 0)))]
5280 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5281 && m68k_last_compare_had_fp_operands)
5283 m68k_last_compare_had_fp_operands = 0;
5289 [(set (match_operand:QI 0 "register_operand" "=d")
5290 (lt:QI (cc0) (const_int 0)))]
5293 cc_status = cc_prev_status;
5294 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5297 (define_expand "sltu"
5298 [(set (match_operand:QI 0 "register_operand" "")
5299 (ltu:QI (cc0) (const_int 0)))]
5304 [(set (match_operand:QI 0 "register_operand" "=d")
5305 (ltu:QI (cc0) (const_int 0)))]
5308 cc_status = cc_prev_status;
5312 (define_expand "sge"
5313 [(set (match_operand:QI 0 "register_operand" "")
5314 (ge:QI (cc0) (const_int 0)))]
5317 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5318 && m68k_last_compare_had_fp_operands)
5320 m68k_last_compare_had_fp_operands = 0;
5326 [(set (match_operand:QI 0 "register_operand" "=d")
5327 (ge:QI (cc0) (const_int 0)))]
5330 cc_status = cc_prev_status;
5331 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5334 (define_expand "sgeu"
5335 [(set (match_operand:QI 0 "register_operand" "")
5336 (geu:QI (cc0) (const_int 0)))]
5341 [(set (match_operand:QI 0 "register_operand" "=d")
5342 (geu:QI (cc0) (const_int 0)))]
5345 cc_status = cc_prev_status;
5349 (define_expand "sle"
5350 [(set (match_operand:QI 0 "register_operand" "")
5351 (le:QI (cc0) (const_int 0)))]
5354 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5355 && m68k_last_compare_had_fp_operands)
5357 m68k_last_compare_had_fp_operands = 0;
5363 [(set (match_operand:QI 0 "register_operand" "=d")
5364 (le:QI (cc0) (const_int 0)))]
5367 cc_status = cc_prev_status;
5368 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5371 (define_expand "sleu"
5372 [(set (match_operand:QI 0 "register_operand" "")
5373 (leu:QI (cc0) (const_int 0)))]
5378 [(set (match_operand:QI 0 "register_operand" "=d")
5379 (leu:QI (cc0) (const_int 0)))]
5382 cc_status = cc_prev_status;
5386 (define_expand "sordered"
5387 [(set (match_operand:QI 0 "register_operand" "")
5388 (ordered:QI (cc0) (const_int 0)))]
5389 "TARGET_68881 && !TUNE_68060"
5391 gcc_assert (m68k_last_compare_had_fp_operands);
5392 m68k_last_compare_had_fp_operands = 0;
5395 (define_insn "*sordered_1"
5396 [(set (match_operand:QI 0 "register_operand" "=d")
5397 (ordered:QI (cc0) (const_int 0)))]
5398 "TARGET_68881 && !TUNE_68060"
5400 cc_status = cc_prev_status;
5404 (define_expand "sunordered"
5405 [(set (match_operand:QI 0 "register_operand" "")
5406 (unordered:QI (cc0) (const_int 0)))]
5407 "TARGET_68881 && !TUNE_68060"
5409 gcc_assert (m68k_last_compare_had_fp_operands);
5410 m68k_last_compare_had_fp_operands = 0;
5413 (define_insn "*sunordered_1"
5414 [(set (match_operand:QI 0 "register_operand" "=d")
5415 (unordered:QI (cc0) (const_int 0)))]
5416 "TARGET_68881 && !TUNE_68060"
5418 cc_status = cc_prev_status;
5422 (define_expand "suneq"
5423 [(set (match_operand:QI 0 "register_operand" "")
5424 (uneq:QI (cc0) (const_int 0)))]
5425 "TARGET_68881 && !TUNE_68060"
5427 gcc_assert (m68k_last_compare_had_fp_operands);
5428 m68k_last_compare_had_fp_operands = 0;
5431 (define_insn "*suneq_1"
5432 [(set (match_operand:QI 0 "register_operand" "=d")
5433 (uneq:QI (cc0) (const_int 0)))]
5434 "TARGET_68881 && !TUNE_68060"
5436 cc_status = cc_prev_status;
5440 (define_expand "sunge"
5441 [(set (match_operand:QI 0 "register_operand" "")
5442 (unge:QI (cc0) (const_int 0)))]
5443 "TARGET_68881 && !TUNE_68060"
5445 gcc_assert (m68k_last_compare_had_fp_operands);
5446 m68k_last_compare_had_fp_operands = 0;
5449 (define_insn "*sunge_1"
5450 [(set (match_operand:QI 0 "register_operand" "=d")
5451 (unge:QI (cc0) (const_int 0)))]
5452 "TARGET_68881 && !TUNE_68060"
5454 cc_status = cc_prev_status;
5458 (define_expand "sungt"
5459 [(set (match_operand:QI 0 "register_operand" "")
5460 (ungt:QI (cc0) (const_int 0)))]
5461 "TARGET_68881 && !TUNE_68060"
5463 gcc_assert (m68k_last_compare_had_fp_operands);
5464 m68k_last_compare_had_fp_operands = 0;
5467 (define_insn "*sungt_1"
5468 [(set (match_operand:QI 0 "register_operand" "=d")
5469 (ungt:QI (cc0) (const_int 0)))]
5470 "TARGET_68881 && !TUNE_68060"
5472 cc_status = cc_prev_status;
5476 (define_expand "sunle"
5477 [(set (match_operand:QI 0 "register_operand" "")
5478 (unle:QI (cc0) (const_int 0)))]
5479 "TARGET_68881 && !TUNE_68060"
5481 gcc_assert (m68k_last_compare_had_fp_operands);
5482 m68k_last_compare_had_fp_operands = 0;
5485 (define_insn "*sunle_1"
5486 [(set (match_operand:QI 0 "register_operand" "=d")
5487 (unle:QI (cc0) (const_int 0)))]
5488 "TARGET_68881 && !TUNE_68060"
5490 cc_status = cc_prev_status;
5494 (define_expand "sunlt"
5495 [(set (match_operand:QI 0 "register_operand" "")
5496 (unlt:QI (cc0) (const_int 0)))]
5497 "TARGET_68881 && !TUNE_68060"
5499 gcc_assert (m68k_last_compare_had_fp_operands);
5500 m68k_last_compare_had_fp_operands = 0;
5503 (define_insn "*sunlt_1"
5504 [(set (match_operand:QI 0 "register_operand" "=d")
5505 (unlt:QI (cc0) (const_int 0)))]
5506 "TARGET_68881 && !TUNE_68060"
5508 cc_status = cc_prev_status;
5512 (define_expand "sltgt"
5513 [(set (match_operand:QI 0 "register_operand" "")
5514 (ltgt:QI (cc0) (const_int 0)))]
5515 "TARGET_68881 && !TUNE_68060"
5517 gcc_assert (m68k_last_compare_had_fp_operands);
5518 m68k_last_compare_had_fp_operands = 0;
5521 (define_insn "*sltgt_1"
5522 [(set (match_operand:QI 0 "register_operand" "=d")
5523 (ltgt:QI (cc0) (const_int 0)))]
5524 "TARGET_68881 && !TUNE_68060"
5526 cc_status = cc_prev_status;
5530 (define_insn "*fsogt_1"
5531 [(set (match_operand:QI 0 "register_operand" "=d")
5532 (not:QI (unle:QI (cc0) (const_int 0))))]
5533 "TARGET_68881 && !TUNE_68060"
5535 cc_status = cc_prev_status;
5539 (define_insn "*fsoge_1"
5540 [(set (match_operand:QI 0 "register_operand" "=d")
5541 (not:QI (unlt:QI (cc0) (const_int 0))))]
5542 "TARGET_68881 && !TUNE_68060"
5544 cc_status = cc_prev_status;
5548 (define_insn "*fsolt_1"
5549 [(set (match_operand:QI 0 "register_operand" "=d")
5550 (not:QI (unge:QI (cc0) (const_int 0))))]
5551 "TARGET_68881 && !TUNE_68060"
5553 cc_status = cc_prev_status;
5557 (define_insn "*fsole_1"
5558 [(set (match_operand:QI 0 "register_operand" "=d")
5559 (not:QI (ungt:QI (cc0) (const_int 0))))]
5560 "TARGET_68881 && !TUNE_68060"
5562 cc_status = cc_prev_status;
5566 ;; Basic conditional jump instructions.
5568 (define_insn "beq0_di"
5570 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
5572 (label_ref (match_operand 1 "" ","))
5574 (clobber (match_scratch:SI 2 "=d,d"))]
5578 if (which_alternative == 1)
5581 return "move%.l %0,%2\;or%.l %0,%2\;jbeq %l1";
5583 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5585 if ((cc_prev_status.value1
5586 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5587 || (cc_prev_status.value2
5588 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5590 cc_status = cc_prev_status;
5591 return MOTOROLA ? "jbeq %l1" : "jeq %l1";
5593 if (GET_CODE (operands[0]) == REG)
5594 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5596 operands[3] = adjust_address (operands[0], SImode, 4);
5597 if (! ADDRESS_REG_P (operands[0]))
5599 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5601 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5604 return "or%.l %0,%2\;jbeq %l1";
5606 return "or%.l %0,%2\;jeq %l1";
5611 return "or%.l %3,%2\;jbeq %l1";
5613 return "or%.l %3,%2\;jeq %l1";
5617 return "move%.l %0,%2\;or%.l %3,%2\;jbeq %l1";
5619 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5621 operands[4] = gen_label_rtx();
5622 if (TARGET_68020 || TARGET_COLDFIRE)
5625 output_asm_insn ("tst%.l %0\;jbne %l4\;tst%.l %3\;jbeq %l1", operands);
5627 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
5632 output_asm_insn ("cmp%.w #0,%0\;jbne %l4\;cmp%.w #0,%3\;jbeq %l1", operands);
5634 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
5636 (*targetm.asm_out.internal_label) (asm_out_file, "L",
5637 CODE_LABEL_NUMBER (operands[4]));
5641 (define_insn "bne0_di"
5643 (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
5645 (label_ref (match_operand 1 "" ","))
5647 (clobber (match_scratch:SI 2 "=d,X"))]
5650 if ((cc_prev_status.value1
5651 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5652 || (cc_prev_status.value2
5653 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5655 cc_status = cc_prev_status;
5656 return MOTOROLA ? "jbne %l1" : "jne %l1";
5659 if (GET_CODE (operands[0]) == REG)
5660 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5662 operands[3] = adjust_address (operands[0], SImode, 4);
5663 if (!ADDRESS_REG_P (operands[0]))
5665 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5667 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5670 return "or%.l %0,%2\;jbne %l1";
5672 return "or%.l %0,%2\;jne %l1";
5677 return "or%.l %3,%2\;jbne %l1";
5679 return "or%.l %3,%2\;jne %l1";
5683 return "move%.l %0,%2\;or%.l %3,%2\;jbne %l1";
5685 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
5687 if (TARGET_68020 || TARGET_COLDFIRE)
5690 return "tst%.l %0\;jbne %l1\;tst%.l %3\;jbne %l1";
5692 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
5697 return "cmp%.w #0,%0\;jbne %l1\;cmp%.w #0,%3\;jbne %l1";
5699 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
5703 (define_insn "bge0_di"
5705 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
5707 (label_ref (match_operand 1 "" ""))
5711 if ((cc_prev_status.value1
5712 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5713 || (cc_prev_status.value2
5714 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5716 cc_status = cc_prev_status;
5717 if (cc_status.flags & CC_REVERSED)
5719 return MOTOROLA ? "jble %l1" : "jle %l1";
5723 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5727 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5728 output_asm_insn("tst%.l %0", operands);
5731 /* On an address reg, cmpw may replace cmpl. */
5732 output_asm_insn("cmp%.w #0,%0", operands);
5734 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5737 (define_insn "blt0_di"
5739 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
5741 (label_ref (match_operand 1 "" ""))
5745 if ((cc_prev_status.value1
5746 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5747 || (cc_prev_status.value2
5748 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5750 cc_status = cc_prev_status;
5751 if (cc_status.flags & CC_REVERSED)
5753 return MOTOROLA ? "jbgt %l1" : "jgt %l1";
5757 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5761 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5762 output_asm_insn("tst%.l %0", operands);
5765 /* On an address reg, cmpw may replace cmpl. */
5766 output_asm_insn("cmp%.w #0,%0", operands);
5769 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5774 (if_then_else (eq (cc0)
5776 (label_ref (match_operand 0 "" ""))
5781 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5783 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5788 (if_then_else (ne (cc0)
5790 (label_ref (match_operand 0 "" ""))
5795 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5797 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5802 (if_then_else (gt (cc0)
5804 (label_ref (match_operand 0 "" ""))
5809 OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0);
5811 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
5816 (if_then_else (gtu (cc0)
5818 (label_ref (match_operand 0 "" ""))
5822 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5827 (if_then_else (lt (cc0)
5829 (label_ref (match_operand 0 "" ""))
5834 OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0");
5836 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
5841 (if_then_else (ltu (cc0)
5843 (label_ref (match_operand 0 "" ""))
5847 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5852 (if_then_else (ge (cc0)
5854 (label_ref (match_operand 0 "" ""))
5859 OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0");
5861 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
5866 (if_then_else (geu (cc0)
5868 (label_ref (match_operand 0 "" ""))
5872 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5877 (if_then_else (le (cc0)
5879 (label_ref (match_operand 0 "" ""))
5884 OUTPUT_JUMP ("jble %l0", "fble %l0", 0);
5886 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
5891 (if_then_else (leu (cc0)
5893 (label_ref (match_operand 0 "" ""))
5897 return MOTOROLA ? "jbls %l0" : "jls %l0";
5900 (define_insn "bordered"
5902 (if_then_else (ordered (cc0) (const_int 0))
5903 (label_ref (match_operand 0 "" ""))
5907 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5908 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5911 (define_insn "bunordered"
5913 (if_then_else (unordered (cc0) (const_int 0))
5914 (label_ref (match_operand 0 "" ""))
5918 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5919 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5922 (define_insn "buneq"
5924 (if_then_else (uneq (cc0) (const_int 0))
5925 (label_ref (match_operand 0 "" ""))
5929 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5930 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5933 (define_insn "bunge"
5935 (if_then_else (unge (cc0) (const_int 0))
5936 (label_ref (match_operand 0 "" ""))
5940 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5941 return MOTOROLA ? "fbuge %l0" : "fjuge %l0";
5944 (define_insn "bungt"
5946 (if_then_else (ungt (cc0) (const_int 0))
5947 (label_ref (match_operand 0 "" ""))
5951 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5952 return MOTOROLA ? "fbugt %l0" : "fjugt %l0";
5955 (define_insn "bunle"
5957 (if_then_else (unle (cc0) (const_int 0))
5958 (label_ref (match_operand 0 "" ""))
5962 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5963 return MOTOROLA ? "fbule %l0" : "fjule %l0";
5966 (define_insn "bunlt"
5968 (if_then_else (unlt (cc0) (const_int 0))
5969 (label_ref (match_operand 0 "" ""))
5973 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5974 return MOTOROLA ? "fbult %l0" : "fjult %l0";
5977 (define_insn "bltgt"
5979 (if_then_else (ltgt (cc0) (const_int 0))
5980 (label_ref (match_operand 0 "" ""))
5984 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5985 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5988 ;; Negated conditional jump instructions.
5992 (if_then_else (eq (cc0)
5995 (label_ref (match_operand 0 "" ""))))]
5999 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
6001 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6006 (if_then_else (ne (cc0)
6009 (label_ref (match_operand 0 "" ""))))]
6013 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
6015 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6020 (if_then_else (gt (cc0)
6023 (label_ref (match_operand 0 "" ""))))]
6027 OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0);
6029 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6034 (if_then_else (gtu (cc0)
6037 (label_ref (match_operand 0 "" ""))))]
6040 return MOTOROLA ? "jbls %l0" : "jls %l0";
6045 (if_then_else (lt (cc0)
6048 (label_ref (match_operand 0 "" ""))))]
6052 OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0");
6054 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6059 (if_then_else (ltu (cc0)
6062 (label_ref (match_operand 0 "" ""))))]
6065 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
6070 (if_then_else (ge (cc0)
6073 (label_ref (match_operand 0 "" ""))))]
6077 OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0");
6079 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6084 (if_then_else (geu (cc0)
6087 (label_ref (match_operand 0 "" ""))))]
6090 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
6095 (if_then_else (le (cc0)
6098 (label_ref (match_operand 0 "" ""))))]
6102 OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0);
6104 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6109 (if_then_else (leu (cc0)
6112 (label_ref (match_operand 0 "" ""))))]
6115 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
6118 (define_insn "*bordered_rev"
6120 (if_then_else (ordered (cc0) (const_int 0))
6122 (label_ref (match_operand 0 "" ""))))]
6125 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6126 return MOTOROLA ? "fbun %l0" : "fjun %l0";
6129 (define_insn "*bunordered_rev"
6131 (if_then_else (unordered (cc0) (const_int 0))
6133 (label_ref (match_operand 0 "" ""))))]
6136 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6137 return MOTOROLA ? "fbor %l0" : "fjor %l0";
6140 (define_insn "*buneq_rev"
6142 (if_then_else (uneq (cc0) (const_int 0))
6144 (label_ref (match_operand 0 "" ""))))]
6147 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6148 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
6151 (define_insn "*bunge_rev"
6153 (if_then_else (unge (cc0) (const_int 0))
6155 (label_ref (match_operand 0 "" ""))))]
6158 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6159 return MOTOROLA ? "fbolt %l0" : "fjolt %l0";
6162 (define_insn "*bungt_rev"
6164 (if_then_else (ungt (cc0) (const_int 0))
6166 (label_ref (match_operand 0 "" ""))))]
6169 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6170 return MOTOROLA ? "fbole %l0" : "fjole %l0";
6173 (define_insn "*bunle_rev"
6175 (if_then_else (unle (cc0) (const_int 0))
6177 (label_ref (match_operand 0 "" ""))))]
6180 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6181 return MOTOROLA ? "fbogt %l0" : "fjogt %l0";
6184 (define_insn "*bunlt_rev"
6186 (if_then_else (unlt (cc0) (const_int 0))
6188 (label_ref (match_operand 0 "" ""))))]
6191 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6192 return MOTOROLA ? "fboge %l0" : "fjoge %l0";
6195 (define_insn "*bltgt_rev"
6197 (if_then_else (ltgt (cc0) (const_int 0))
6199 (label_ref (match_operand 0 "" ""))))]
6202 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6203 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
6206 ;; Unconditional and other jump instructions
6209 (label_ref (match_operand 0 "" "")))]
6212 return MOTOROLA ? "jbra %l0" : "jra %l0";
6215 (define_expand "tablejump"
6216 [(parallel [(set (pc) (match_operand 0 "" ""))
6217 (use (label_ref (match_operand 1 "" "")))])]
6220 #ifdef CASE_VECTOR_PC_RELATIVE
6221 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6222 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6226 ;; Jump to variable address from dispatch table of absolute addresses.
6228 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6229 (use (label_ref (match_operand 1 "" "")))]
6232 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6235 ;; Jump to variable address from dispatch table of relative addresses.
6239 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6240 (use (label_ref (match_operand 1 "" "")))]
6243 #ifdef ASM_RETURN_CASE_JUMP
6244 ASM_RETURN_CASE_JUMP;
6246 if (TARGET_COLDFIRE)
6248 if (ADDRESS_REG_P (operands[0]))
6249 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6251 return "ext%.l %0\;jmp (2,pc,%0.l)";
6253 return "extl %0\;jmp pc@(2,%0:l)";
6256 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6260 ;; Decrement-and-branch insns.
6264 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6266 (label_ref (match_operand 1 "" ""))
6269 (plus:HI (match_dup 0)
6274 if (DATA_REG_P (operands[0]))
6275 return "dbra %0,%l1";
6276 if (GET_CODE (operands[0]) == MEM)
6278 "subq%.w #1,%0\;jbcc %l1" :
6279 "subqw #1,%0\;jcc %l1";
6281 "subq%.w #1,%0\;cmp%.w #-1,%0\;jbne %l1" :
6282 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6288 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6290 (label_ref (match_operand 1 "" ""))
6293 (plus:SI (match_dup 0)
6298 if (DATA_REG_P (operands[0]))
6300 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6301 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6302 if (GET_CODE (operands[0]) == MEM)
6304 "subq%.l #1,%0\;jbcc %l1" :
6305 "subq%.l #1,%0\;jcc %l1";
6307 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6308 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6311 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6316 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6319 (label_ref (match_operand 1 "" ""))
6322 (plus:HI (match_dup 0)
6324 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6327 if (DATA_REG_P (operands[0]))
6328 return "dbra %0,%l1";
6329 if (GET_CODE (operands[0]) == MEM)
6331 "subq%.w #1,%0\;jbcc %l1" :
6332 "subq%.w #1,%0\;jcc %l1";
6334 "subq.w #1,%0\;cmp.w #-1,%0\;jbne %l1" :
6335 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6338 (define_expand "decrement_and_branch_until_zero"
6339 [(parallel [(set (pc)
6341 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6344 (label_ref (match_operand 1 "" ""))
6347 (plus:SI (match_dup 0)
6355 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6358 (label_ref (match_operand 1 "" ""))
6361 (plus:SI (match_dup 0)
6363 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6366 if (DATA_REG_P (operands[0]))
6368 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6369 "dbra %0,%l1\;clr%.w %0\;subql #1,%0\;jcc %l1";
6370 if (GET_CODE (operands[0]) == MEM)
6372 "subq%.l #1,%0\;jbcc %l1" :
6373 "subql #1,%0\;jcc %l1";
6375 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6376 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6379 ;; Call subroutine with no return value.
6380 (define_expand "call"
6381 [(call (match_operand:QI 0 "memory_operand" "")
6382 (match_operand:SI 1 "general_operand" ""))]
6383 ;; Operand 1 not really used on the m68000.
6386 operands[0] = m68k_legitimize_call_address (operands[0]);
6389 (define_insn "*call"
6390 [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
6391 (match_operand:SI 1 "general_operand" "g,g"))]
6392 ;; Operand 1 not really used on the m68000.
6395 return output_call (operands[0]);
6398 ;; Call subroutine, returning value in operand 0
6399 ;; (which must be a hard register).
6400 (define_expand "call_value"
6401 [(set (match_operand 0 "" "")
6402 (call (match_operand:QI 1 "memory_operand" "")
6403 (match_operand:SI 2 "general_operand" "")))]
6404 ;; Operand 2 not really used on the m68000.
6407 operands[1] = m68k_legitimize_call_address (operands[1]);
6410 (define_insn "*call_value"
6411 [(set (match_operand 0 "" "=rf,rf")
6412 (call (mem:QI (match_operand:SI 1 "call_operand" "a,W"))
6413 (match_operand:SI 2 "general_operand" "g,g")))]
6414 ;; Operand 2 not really used on the m68000.
6417 operands[0] = operands[1];
6418 return output_call (operands[0]);
6421 ;; Call subroutine returning any type.
6423 (define_expand "untyped_call"
6424 [(parallel [(call (match_operand 0 "" "")
6426 (match_operand 1 "" "")
6427 (match_operand 2 "" "")])]
6428 "NEEDS_UNTYPED_CALL"
6432 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6434 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6436 rtx set = XVECEXP (operands[2], 0, i);
6437 emit_move_insn (SET_DEST (set), SET_SRC (set));
6440 /* The optimizer does not know that the call sets the function value
6441 registers we stored in the result block. We avoid problems by
6442 claiming that all hard registers are used and clobbered at this
6444 emit_insn (gen_blockage ());
6449 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6450 ;; all of memory. This blocks insns from being moved across this point.
6452 (define_insn "blockage"
6453 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6462 ;; Used for frameless functions which save no regs and allocate no locals.
6463 (define_insn "return"
6465 "m68k_use_return_insn ()"
6467 if (current_function_pops_args == 0)
6469 operands[0] = GEN_INT (current_function_pops_args);
6473 (define_insn "indirect_jump"
6474 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
6478 ;; This should not be used unless the add/sub insns can't be.
6481 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
6482 (match_operand:QI 1 "address_operand" "p"))]
6485 /* Recognize an insn that refers to a table of offsets. Such an insn will
6486 need to refer to a label on the insn. So output one. Use the
6487 label-number of the table of offsets to generate this label. This code,
6488 and similar code above, assumes that there will be at most one reference
6490 if (GET_CODE (operands[1]) == PLUS
6491 && GET_CODE (XEXP (operands[1], 1)) == LABEL_REF
6492 && GET_CODE (XEXP (operands[1], 0)) != PLUS)
6494 rtx labelref = XEXP (operands[1], 1);
6496 asm_fprintf (asm_out_file, "\\t.set %LLI%d,.+2\\n",
6497 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6499 (*targetm.asm_out.internal_label) (asm_out_file, "LI",
6500 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6502 return "lea %a1,%0";
6505 ;; This is the first machine-dependent peephole optimization.
6506 ;; It is useful when a floating value is returned from a function call
6507 ;; and then is moved into an FP register.
6508 ;; But it is mainly intended to test the support for these optimizations.
6511 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
6512 (set (match_operand:DF 0 "register_operand" "=f")
6513 (match_operand:DF 1 "register_operand" "ad"))]
6514 "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
6517 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6518 output_asm_insn ("move%.l %1,%@", xoperands);
6519 output_asm_insn ("move%.l %1,%-", operands);
6520 return "fmove%.d %+,%0";
6523 ;; Optimize a stack-adjust followed by a push of an argument.
6524 ;; This is said to happen frequently with -msoft-float
6525 ;; when there are consecutive library calls.
6528 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6529 (match_operand:SI 0 "const_int_operand" "n")))
6530 (set (match_operand:SF 1 "push_operand" "=m")
6531 (match_operand:SF 2 "general_operand" "rmfF"))]
6532 "INTVAL (operands[0]) >= 4
6533 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6535 if (INTVAL (operands[0]) > 4)
6538 xoperands[0] = stack_pointer_rtx;
6539 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6540 if (INTVAL (xoperands[1]) <= 8)
6542 if (!TARGET_COLDFIRE)
6543 output_asm_insn ("addq%.w %1,%0", xoperands);
6545 output_asm_insn ("addq%.l %1,%0", xoperands);
6547 else if (TUNE_CPU32 && INTVAL (xoperands[1]) <= 16)
6549 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6550 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6552 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6555 output_asm_insn ("add%.w %1,%0", xoperands);
6557 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6559 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6562 output_asm_insn ("add%.l %1,%0", xoperands);
6564 if (FP_REG_P (operands[2]))
6565 return "fmove%.s %2,%@";
6566 return "move%.l %2,%@";
6569 ;; Speed up stack adjust followed by a fullword fixedpoint push.
6572 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6573 (match_operand:SI 0 "const_int_operand" "n")))
6574 (set (match_operand:SI 1 "push_operand" "=m")
6575 (match_operand:SI 2 "general_operand" "g"))]
6576 "INTVAL (operands[0]) >= 4
6577 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6579 if (INTVAL (operands[0]) > 4)
6582 xoperands[0] = stack_pointer_rtx;
6583 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6584 if (INTVAL (xoperands[1]) <= 8)
6586 if (!TARGET_COLDFIRE)
6587 output_asm_insn ("addq%.w %1,%0", xoperands);
6589 output_asm_insn ("addq%.l %1,%0", xoperands);
6591 else if (TUNE_CPU32 && INTVAL (xoperands[1]) <= 16)
6593 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6594 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6596 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6599 output_asm_insn ("add%.w %1,%0", xoperands);
6601 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6603 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6606 output_asm_insn ("add%.l %1,%0", xoperands);
6608 if (operands[2] == const0_rtx)
6610 return "move%.l %2,%@";
6613 ;; Speed up pushing a single byte but leaving four bytes of space.
6616 [(set (mem:QI (pre_dec:SI (reg:SI SP_REG)))
6617 (match_operand:QI 1 "general_operand" "dami"))
6618 (set (reg:SI SP_REG) (minus:SI (reg:SI SP_REG) (const_int 2)))]
6619 "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
6623 if (GET_CODE (operands[1]) == REG)
6624 return "move%.l %1,%-";
6626 xoperands[1] = operands[1];
6628 = gen_rtx_MEM (QImode, plus_constant (stack_pointer_rtx, 3));
6629 xoperands[3] = stack_pointer_rtx;
6630 if (!TARGET_COLDFIRE)
6631 output_asm_insn ("subq%.w #4,%3\;move%.b %1,%2", xoperands);
6633 output_asm_insn ("subq%.l #4,%3\;move%.b %1,%2", xoperands);
6638 [(set (match_operand:SI 0 "register_operand" "=d")
6640 (set (strict_low_part (subreg:HI (match_dup 0) 2))
6641 (match_operand:HI 1 "general_operand" "rmn"))]
6642 "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
6644 if (GET_CODE (operands[1]) == CONST_INT)
6646 if (operands[1] == const0_rtx
6647 && (DATA_REG_P (operands[0])
6648 || GET_CODE (operands[0]) == MEM)
6649 /* clr insns on 68000 read before writing. */
6650 && ((TARGET_68010 || TARGET_COLDFIRE)
6651 || !(GET_CODE (operands[0]) == MEM
6652 && MEM_VOLATILE_P (operands[0]))))
6655 return "move%.w %1,%0";
6663 ;; jCC label ; abnormal loop termination
6664 ;; dbra dN, loop ; normal loop termination
6672 ;; Which moves the jCC condition outside the inner loop for free.
6676 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6677 [(cc0) (const_int 0)])
6678 (label_ref (match_operand 2 "" ""))
6683 (ne (match_operand:HI 0 "register_operand" "")
6685 (label_ref (match_operand 1 "" ""))
6688 (plus:HI (match_dup 0)
6690 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6693 output_dbcc_and_branch (operands);
6698 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6699 [(cc0) (const_int 0)])
6700 (label_ref (match_operand 2 "" ""))
6705 (ne (match_operand:SI 0 "register_operand" "")
6707 (label_ref (match_operand 1 "" ""))
6710 (plus:SI (match_dup 0)
6712 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6715 output_dbcc_and_branch (operands);
6720 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6721 [(cc0) (const_int 0)])
6722 (label_ref (match_operand 2 "" ""))
6727 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
6730 (label_ref (match_operand 1 "" ""))
6733 (plus:HI (match_dup 0)
6735 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6738 output_dbcc_and_branch (operands);
6743 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6744 [(cc0) (const_int 0)])
6745 (label_ref (match_operand 2 "" ""))
6750 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
6753 (label_ref (match_operand 1 "" ""))
6756 (plus:SI (match_dup 0)
6758 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6761 output_dbcc_and_branch (operands);
6766 (define_insn "extendsfxf2"
6767 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6768 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
6771 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6773 if (REGNO (operands[0]) == REGNO (operands[1]))
6775 /* Extending float to double in an fp-reg is a no-op.
6776 NOTICE_UPDATE_CC has already assumed that the
6777 cc will be set. So cancel what it did. */
6778 cc_status = cc_prev_status;
6781 return "f%$move%.x %1,%0";
6783 if (FP_REG_P (operands[0]))
6785 if (FP_REG_P (operands[1]))
6786 return "f%$move%.x %1,%0";
6787 else if (ADDRESS_REG_P (operands[1]))
6788 return "move%.l %1,%-\;f%$move%.s %+,%0";
6789 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
6790 return output_move_const_single (operands);
6791 return "f%$move%.s %f1,%0";
6793 return "fmove%.x %f1,%0";
6797 (define_insn "extenddfxf2"
6798 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6800 (match_operand:DF 1 "general_operand" "f,rmE")))]
6803 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6805 if (REGNO (operands[0]) == REGNO (operands[1]))
6807 /* Extending float to double in an fp-reg is a no-op.
6808 NOTICE_UPDATE_CC has already assumed that the
6809 cc will be set. So cancel what it did. */
6810 cc_status = cc_prev_status;
6813 return "fmove%.x %1,%0";
6815 if (FP_REG_P (operands[0]))
6817 if (REG_P (operands[1]))
6820 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6821 output_asm_insn ("move%.l %1,%-", xoperands);
6822 output_asm_insn ("move%.l %1,%-", operands);
6823 return "f%&move%.d %+,%0";
6825 if (GET_CODE (operands[1]) == CONST_DOUBLE)
6826 return output_move_const_double (operands);
6827 return "f%&move%.d %f1,%0";
6829 return "fmove%.x %f1,%0";
6832 (define_insn "truncxfdf2"
6833 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
6835 (match_operand:XF 1 "general_operand" "f,f")))]
6838 if (REG_P (operands[0]))
6840 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
6841 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6842 return "move%.l %+,%0";
6844 return "fmove%.d %f1,%0";
6847 (define_insn "truncxfsf2"
6848 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
6850 (match_operand:XF 1 "general_operand" "f")))]
6854 (define_insn "sin<mode>2"
6855 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
6857 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
6858 "TARGET_68881 && flag_unsafe_math_optimizations"
6860 if (FP_REG_P (operands[1]))
6861 return "fsin%.x %1,%0";
6863 return "fsin%.<FP:prec> %1,%0";
6866 (define_insn "cos<mode>2"
6867 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
6869 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
6870 "TARGET_68881 && flag_unsafe_math_optimizations"
6872 if (FP_REG_P (operands[1]))
6873 return "fcos%.x %1,%0";
6875 return "fcos%.<FP:prec> %1,%0";
6879 [(trap_if (const_int -1) (const_int 7))]
6883 (define_insn "conditional_trap"
6884 [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
6885 [(cc0) (const_int 0)])
6886 (match_operand:SI 1 "const_int_operand" "I"))]
6887 "TARGET_68020 && ! flags_in_68881 ()"
6889 switch (GET_CODE (operands[0]))
6891 case EQ: return "trapeq";
6892 case NE: return "trapne";
6893 case GT: return "trapgt";
6894 case GTU: return "traphi";
6895 case LT: return "traplt";
6896 case LTU: return "trapcs";
6897 case GE: return "trapge";
6898 case GEU: return "trapcc";
6899 case LE: return "traple";
6900 case LEU: return "trapls";
6901 default: gcc_unreachable ();