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
93 ;;- switch. By changing TARGET_DEFAULT to include TARGET_68040_ONLY,
94 ;;- you can make these instructions the default.
96 ;;- These new instructions aren't directly in the md. They are brought
97 ;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather
100 ;;- Information about 68060 port.
102 ;;- The 68060 executes all 68030 and 68881/2 instructions, but some must
103 ;;- be emulated in software by the OS. It is faster to avoid these
104 ;;- instructions and issue a library call rather than trapping into
105 ;;- the kernel. The affected instructions are: divs.l <ea>,Dr:Dq;
106 ;;- divu.l <ea>,Dr:Dq; muls.l <ea>,Dr:Dq; mulu.l <ea>,Dr:Dq; and
107 ;;- fscale. The TUNE_68060 flag turns the use of the opcodes off.
109 ;;- Some of these insn's are composites of several m68000 op codes.
110 ;;- The assembler (or final @@??) insures that the appropriate one is
120 ;; UNSPEC_VOLATILE usage:
123 [(UNSPECV_BLOCKAGE 0)
126 ;; 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<>fyE"))]
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<>Fyi"))]
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 ;; This is the second "hook" for PIC code (in addition to movsi). See
313 ;; comment of movsi for a description of PIC handling.
314 (define_expand "cmpsi"
316 (compare (match_operand:SI 0 "nonimmediate_operand" "")
317 (match_operand:SI 1 "general_operand" "")))]
320 m68k_last_compare_had_fp_operands = 0;
321 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
323 /* The source is an address which requires PIC relocation.
324 Call legitimize_pic_address with the source, mode, and a relocation
325 register (a new pseudo, or the final destination if reload_in_progress
326 is set). Then fall through normally */
327 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
328 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
332 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
335 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
336 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
339 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
340 return "cmpm%.l %1,%0";
341 if (REG_P (operands[1])
342 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
344 cc_status.flags |= CC_REVERSED;
345 return "cmp%.l %d0,%d1";
347 if (ADDRESS_REG_P (operands[0])
348 && GET_CODE (operands[1]) == CONST_INT
349 && INTVAL (operands[1]) < 0x8000
350 && INTVAL (operands[1]) >= -0x8000)
351 return "cmp%.w %1,%0";
352 return "cmp%.l %d1,%d0";
357 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
358 (match_operand:SI 1 "general_operand" "r,mrKs")))]
361 if (REG_P (operands[1])
362 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
364 cc_status.flags |= CC_REVERSED;
365 return "cmp%.l %d0,%d1";
367 return "cmp%.l %d1,%d0";
370 (define_expand "cmphi"
372 (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
373 (match_operand:HI 1 "general_src_operand" "")))]
375 "m68k_last_compare_had_fp_operands = 0;")
379 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
380 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
383 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
384 return "cmpm%.w %1,%0";
385 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
386 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
388 cc_status.flags |= CC_REVERSED;
389 return "cmp%.w %d0,%d1";
391 return "cmp%.w %d1,%d0";
394 (define_expand "cmpqi"
396 (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
397 (match_operand:QI 1 "general_src_operand" "")))]
399 "m68k_last_compare_had_fp_operands = 0;")
403 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
404 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
407 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
408 return "cmpm%.b %1,%0";
409 if (REG_P (operands[1])
410 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
412 cc_status.flags |= CC_REVERSED;
413 return "cmp%.b %d0,%d1";
415 return "cmp%.b %d1,%d0";
418 (define_expand "cmp<mode>"
420 (compare (match_operand:FP 0 "general_operand" "")
421 (match_operand:FP 1 "general_operand" "")))]
424 m68k_last_compare_had_fp_operands = 1;
425 if (TARGET_COLDFIRE && !reload_completed)
426 operands[1] = force_reg (<MODE>mode, operands[1]);
429 (define_insn "cmp<mode>_68881"
431 (compare (match_operand:FP 0 "general_operand" "f,m<FP:const>")
432 (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,f")))]
435 cc_status.flags = CC_IN_68881;
436 if (FP_REG_P (operands[0]))
438 if (FP_REG_P (operands[1]))
439 return "fcmp%.x %1,%0";
441 return "fcmp%.<FP:prec> %f1,%0";
443 cc_status.flags |= CC_REVERSED;
444 return "fcmp%.<FP:prec> %f0,%1";
447 (define_insn "cmp<mode>_cf"
449 (compare (match_operand:FP 0 "general_operand" "f,<FP:dreg><Q>U")
450 (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,f")))]
451 "TARGET_COLDFIRE_FPU"
453 cc_status.flags = CC_IN_68881;
454 if (FP_REG_P (operands[0]))
456 if (FP_REG_P (operands[1]))
457 return "fcmp%.d %1,%0";
459 return "fcmp%.<FP:prec> %f1,%0";
461 cc_status.flags |= CC_REVERSED;
462 return "fcmp%.<FP:prec> %f0,%1";
465 ;; Recognizers for btst instructions.
467 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
468 ;; specified as a constant, so we must disable all patterns that may extract
469 ;; from a MEM at a constant bit position if we can't use this as a constraint.
472 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
474 (minus:SI (const_int 7)
475 (match_operand:SI 1 "general_operand" "di"))))]
478 return output_btst (operands, operands[1], operands[0], insn, 7);
481 ;; This is the same as the above pattern except for the constraints. The 'i'
485 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
487 (minus:SI (const_int 7)
488 (match_operand:SI 1 "general_operand" "d"))))]
491 return output_btst (operands, operands[1], operands[0], insn, 7);
495 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
497 (minus:SI (const_int 31)
498 (match_operand:SI 1 "general_operand" "di"))))]
501 return output_btst (operands, operands[1], operands[0], insn, 31);
504 ;; The following two patterns are like the previous two
505 ;; except that they use the fact that bit-number operands
506 ;; are automatically masked to 3 or 5 bits.
509 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
511 (minus:SI (const_int 7)
513 (match_operand:SI 1 "register_operand" "d")
517 return output_btst (operands, operands[1], operands[0], insn, 7);
521 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
523 (minus:SI (const_int 31)
525 (match_operand:SI 1 "register_operand" "d")
529 return output_btst (operands, operands[1], operands[0], insn, 31);
532 ;; Nonoffsettable mem refs are ok in this one pattern
533 ;; since we don't try to adjust them.
535 [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
537 (match_operand:SI 1 "const_int_operand" "n")))]
538 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
540 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
541 return output_btst (operands, operands[1], operands[0], insn, 7);
545 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
547 (match_operand:SI 1 "const_int_operand" "n")))]
550 if (GET_CODE (operands[0]) == MEM)
552 operands[0] = adjust_address (operands[0], QImode,
553 INTVAL (operands[1]) / 8);
554 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
555 return output_btst (operands, operands[1], operands[0], insn, 7);
557 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
558 return output_btst (operands, operands[1], operands[0], insn, 31);
561 ;; This is the same as the above pattern except for the constraints.
562 ;; The 'o' has been replaced with 'Q'.
565 [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
567 (match_operand:SI 1 "const_int_operand" "n")))]
570 if (GET_CODE (operands[0]) == MEM)
572 operands[0] = adjust_address (operands[0], QImode,
573 INTVAL (operands[1]) / 8);
574 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
575 return output_btst (operands, operands[1], operands[0], insn, 7);
577 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
578 return output_btst (operands, operands[1], operands[0], insn, 31);
584 ;; A special case in which it is not desirable
585 ;; to reload the constant into a data register.
586 (define_insn "pushexthisi_const"
587 [(set (match_operand:SI 0 "push_operand" "=m")
588 (match_operand:SI 1 "const_int_operand" "J"))]
589 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
591 if (operands[1] == const0_rtx)
593 if (valid_mov3q_const(operands[1]))
594 return "mov3q%.l %1,%-";
599 ;(define_insn "swapsi"
600 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
601 ; (match_operand:SI 1 "general_operand" "+r"))
602 ; (set (match_dup 1) (match_dup 0))]
606 ;; Special case of fullword move when source is zero.
607 ;; The reason this is special is to avoid loading a zero
608 ;; into a data reg with moveq in order to store it elsewhere.
610 (define_insn "movsi_const0"
611 [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
613 ;; clr insns on 68000 read before writing.
614 ;; This isn't so on the 68010, but we have no TARGET_68010.
615 "((TARGET_68020 || TARGET_COLDFIRE)
616 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
618 if (ADDRESS_REG_P (operands[0]))
620 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
621 if (!TUNE_68040 && !TUNE_68060)
622 return "sub%.l %0,%0";
624 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
626 /* moveq is faster on the 68000. */
627 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
628 return "moveq #0,%0";
632 ;; General case of fullword move.
634 ;; This is the main "hook" for PIC code. When generating
635 ;; PIC, movsi is responsible for determining when the source address
636 ;; needs PIC relocation and appropriately calling legitimize_pic_address
637 ;; to perform the actual relocation.
639 ;; In both the PIC and non-PIC cases the patterns generated will
640 ;; matched by the next define_insn.
641 (define_expand "movsi"
642 [(set (match_operand:SI 0 "nonimmediate_operand" "")
643 (match_operand:SI 1 "general_operand" ""))]
646 if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
648 /* The source is an address which requires PIC relocation.
649 Call legitimize_pic_address with the source, mode, and a relocation
650 register (a new pseudo, or the final destination if reload_in_progress
651 is set). Then fall through normally */
652 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
653 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
655 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
657 /* Don't allow writes to memory except via a register;
658 the m68k doesn't consider PC-relative addresses to be writable. */
659 if (symbolic_operand (operands[0], SImode))
660 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
661 else if (GET_CODE (operands[0]) == MEM
662 && symbolic_operand (XEXP (operands[0], 0), SImode))
663 operands[0] = gen_rtx_MEM (SImode,
664 force_reg (SImode, XEXP (operands[0], 0)));
668 ;; General case of fullword move. The register constraints
669 ;; force integer constants in range for a moveq to be reloaded
670 ;; if they are headed for memory.
672 ;; Notes: make sure no alternative allows g vs g.
673 ;; We don't allow f-regs since fixed point cannot go in them.
674 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
675 (match_operand:SI 1 "general_src_operand" "daymSKT,n,i"))]
679 return output_move_simode (operands);
682 (define_insn "*movsi_cf"
683 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
684 (match_operand:SI 1 "general_operand" "g,r<Q>,U"))]
685 "TARGET_COLDFIRE && !TARGET_CFV4"
686 "* return output_move_simode (operands);")
688 (define_insn "*movsi_cfv4"
689 [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
690 (match_operand:SI 1 "general_operand" "Rg,Rr<Q>,U"))]
692 "* return output_move_simode (operands);")
694 ;; Special case of fullword move, where we need to get a non-GOT PIC
695 ;; reference into an address register.
697 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
698 (match_operand:SI 1 "pcrel_address" ""))]
701 if (push_operand (operands[0], SImode))
706 (define_expand "movhi"
707 [(set (match_operand:HI 0 "nonimmediate_operand" "")
708 (match_operand:HI 1 "general_operand" ""))]
713 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
714 (match_operand:HI 1 "general_src_operand" "gS"))]
716 "* return output_move_himode (operands);")
719 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
720 (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
722 "* return output_move_himode (operands);")
724 (define_expand "movstricthi"
725 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
726 (match_operand:HI 1 "general_src_operand" ""))]
731 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
732 (match_operand:HI 1 "general_src_operand" "rmSn"))]
734 "* return output_move_stricthi (operands);")
737 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
738 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
740 "* return output_move_stricthi (operands);")
742 (define_expand "movqi"
743 [(set (match_operand:QI 0 "nonimmediate_operand" "")
744 (match_operand:QI 1 "general_src_operand" ""))]
749 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
750 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
752 "* return output_move_qimode (operands);")
755 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
756 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
758 "* return output_move_qimode (operands);")
760 (define_expand "movstrictqi"
761 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
762 (match_operand:QI 1 "general_src_operand" ""))]
767 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
768 (match_operand:QI 1 "general_src_operand" "dmSn"))]
770 "* return output_move_strictqi (operands);")
773 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d,m"))
774 (match_operand:QI 1 "general_src_operand" "dmn,d"))]
776 "* return output_move_strictqi (operands);")
778 (define_expand "pushqi1"
779 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
780 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
781 (match_operand:QI 0 "general_operand" ""))]
785 (define_expand "reload_insf"
786 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
787 (match_operand:SF 1 "general_operand" "mf"))
788 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
789 "TARGET_COLDFIRE_FPU"
791 if (emit_move_sequence (operands, SFmode, operands[2]))
794 /* We don't want the clobber emitted, so handle this ourselves. */
795 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
799 (define_expand "reload_outsf"
800 [(set (match_operand:SF 0 "general_operand" "")
801 (match_operand:SF 1 "register_operand" "f"))
802 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
803 "TARGET_COLDFIRE_FPU"
805 if (emit_move_sequence (operands, SFmode, operands[2]))
808 /* We don't want the clobber emitted, so handle this ourselves. */
809 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
813 (define_expand "movsf"
814 [(set (match_operand:SF 0 "nonimmediate_operand" "")
815 (match_operand:SF 1 "general_operand" ""))]
820 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
821 (match_operand:SF 1 "general_operand" "rmfF"))]
824 if (FP_REG_P (operands[0]))
826 if (FP_REG_P (operands[1]))
827 return "f%$move%.x %1,%0";
828 else if (ADDRESS_REG_P (operands[1]))
829 return "move%.l %1,%-\;f%$move%.s %+,%0";
830 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
831 return output_move_const_single (operands);
832 return "f%$move%.s %f1,%0";
834 if (FP_REG_P (operands[1]))
836 if (ADDRESS_REG_P (operands[0]))
837 return "fmove%.s %1,%-\;move%.l %+,%0";
838 return "fmove%.s %f1,%0";
840 if (operands[1] == CONST0_RTX (SFmode)
841 /* clr insns on 68000 read before writing.
842 This isn't so on the 68010, but we have no TARGET_68010. */
843 && ((TARGET_68020 || TARGET_COLDFIRE)
844 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
846 if (ADDRESS_REG_P (operands[0]))
848 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
849 if (!TUNE_68040 && !TUNE_68060)
850 return "sub%.l %0,%0";
852 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
854 /* moveq is faster on the 68000. */
855 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
856 return "moveq #0,%0";
859 return "move%.l %1,%0";
862 (define_insn "movsf_cf_soft"
863 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,g")
864 (match_operand:SF 1 "general_operand" "g,r"))]
865 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
867 return "move%.l %1,%0";
870 (define_insn "movsf_cf_hard"
871 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f, f,mr,f,r<Q>,f
873 (match_operand:SF 1 "general_operand" " f, r<Q>U,f,rm,F,F, m
875 "TARGET_COLDFIRE_FPU"
877 if (which_alternative == 4 || which_alternative == 5) {
881 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
882 REAL_VALUE_TO_TARGET_SINGLE (r, l);
883 xoperands[0] = operands[0];
884 xoperands[1] = GEN_INT (l);
885 if (which_alternative == 5) {
887 if (ADDRESS_REG_P (xoperands[0]))
888 output_asm_insn ("sub%.l %0,%0", xoperands);
890 output_asm_insn ("clr%.l %0", xoperands);
892 if (GET_CODE (operands[0]) == MEM
893 && symbolic_operand (XEXP (operands[0], 0), SImode))
894 output_asm_insn ("move%.l %1,%-;move%.l %+,%0", xoperands);
896 output_asm_insn ("move%.l %1,%0", xoperands);
900 output_asm_insn ("move%.l %1,%-;fsmove%.s %+,%0", xoperands);
902 output_asm_insn ("clr%.l %-;fsmove%.s %+,%0", xoperands);
905 if (FP_REG_P (operands[0]))
907 if (ADDRESS_REG_P (operands[1]))
908 return "move%.l %1,%-;f%$smove%.s %+,%0";
909 if (FP_REG_P (operands[1]))
910 return "f%$move%.d %1,%0";
911 if (GET_CODE (operands[1]) == CONST_DOUBLE)
912 return output_move_const_single (operands);
913 return "f%$move%.s %f1,%0";
915 if (FP_REG_P (operands[1]))
917 if (ADDRESS_REG_P (operands[0]))
918 return "fmove%.s %1,%-;move%.l %+,%0";
919 return "fmove%.s %f1,%0";
921 if (operands[1] == CONST0_RTX (SFmode))
923 if (ADDRESS_REG_P (operands[0]))
924 return "sub%.l %0,%0";
927 return "move%.l %1,%0";
930 (define_expand "reload_indf"
931 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
932 (match_operand:DF 1 "general_operand" "mf"))
933 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
934 "TARGET_COLDFIRE_FPU"
936 if (emit_move_sequence (operands, DFmode, operands[2]))
939 /* We don't want the clobber emitted, so handle this ourselves. */
940 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
944 (define_expand "reload_outdf"
945 [(set (match_operand:DF 0 "general_operand" "")
946 (match_operand:DF 1 "register_operand" "f"))
947 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
948 "TARGET_COLDFIRE_FPU"
950 if (emit_move_sequence (operands, DFmode, operands[2]))
953 /* We don't want the clobber emitted, so handle this ourselves. */
954 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
958 (define_expand "movdf"
959 [(set (match_operand:DF 0 "nonimmediate_operand" "")
960 (match_operand:DF 1 "general_operand" ""))]
963 if (TARGET_COLDFIRE_FPU)
964 if (emit_move_sequence (operands, DFmode, 0))
969 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
970 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
971 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
972 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
975 if (FP_REG_P (operands[0]))
977 if (FP_REG_P (operands[1]))
978 return "f%&move%.x %1,%0";
979 if (REG_P (operands[1]))
982 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
983 output_asm_insn ("move%.l %1,%-", xoperands);
984 output_asm_insn ("move%.l %1,%-", operands);
985 return "f%&move%.d %+,%0";
987 if (GET_CODE (operands[1]) == CONST_DOUBLE)
988 return output_move_const_double (operands);
989 return "f%&move%.d %f1,%0";
991 else if (FP_REG_P (operands[1]))
993 if (REG_P (operands[0]))
995 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
996 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
997 return "move%.l %+,%0";
1000 return "fmove%.d %f1,%0";
1002 return output_move_double (operands);
1005 (define_insn "movdf_cf_soft"
1006 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
1007 (match_operand:DF 1 "general_operand" "g,r"))]
1008 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1010 return output_move_double (operands);
1013 (define_insn "movdf_cf_hard"
1014 [(set (match_operand:DF 0 "nonimmediate_operand" "=f, <Q>U,r,f,r,r,m,f")
1015 (match_operand:DF 1 "general_operand" " f<Q>U,f, f,r,r,m,r,E"))]
1016 "TARGET_COLDFIRE_FPU"
1022 switch (which_alternative)
1025 return "fmove%.d %1,%0";
1027 return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1029 return "move%.l %R1,%-;move%.l %1,%-;f%&move%.d %+,%0";
1031 return "move%.l %1,%0;move%.l %R1,%R0";
1033 return output_move_double (operands);
1035 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1036 REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1037 xoperands[0] = operands[0];
1038 xoperands[1] = GEN_INT (l[0]);
1039 xoperands[2] = GEN_INT (l[1]);
1040 if (operands[1] == CONST0_RTX (DFmode))
1041 output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1045 output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1048 output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1054 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1055 ;; allowed. Most but not all have predicates and constraint that disallow
1056 ;; constants. Most but not all have output templates that handle constants.
1057 ;; See also LEGITIMATE_CONSTANT_P.
1059 (define_expand "movxf"
1060 [(set (match_operand:XF 0 "nonimmediate_operand" "")
1061 (match_operand:XF 1 "general_operand" ""))]
1064 /* We can't rewrite operands during reload. */
1065 if (! reload_in_progress)
1067 if (CONSTANT_P (operands[1]))
1069 operands[1] = force_const_mem (XFmode, operands[1]);
1070 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1071 operands[1] = adjust_address (operands[1], XFmode, 0);
1073 if (flag_pic && TARGET_PCREL)
1075 /* Don't allow writes to memory except via a register; the
1076 m68k doesn't consider PC-relative addresses to be writable. */
1077 if (GET_CODE (operands[0]) == MEM
1078 && symbolic_operand (XEXP (operands[0], 0), SImode))
1079 operands[0] = gen_rtx_MEM (XFmode,
1080 force_reg (SImode, XEXP (operands[0], 0)));
1086 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1087 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1090 if (FP_REG_P (operands[0]))
1092 if (FP_REG_P (operands[1]))
1093 return "fmove%.x %1,%0";
1094 if (REG_P (operands[1]))
1097 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1098 output_asm_insn ("move%.l %1,%-", xoperands);
1099 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1100 output_asm_insn ("move%.l %1,%-", xoperands);
1101 output_asm_insn ("move%.l %1,%-", operands);
1102 return "fmove%.x %+,%0";
1104 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1105 return "fmove%.x %1,%0";
1106 return "fmove%.x %f1,%0";
1108 if (FP_REG_P (operands[1]))
1110 if (REG_P (operands[0]))
1112 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1113 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1114 output_asm_insn ("move%.l %+,%0", operands);
1115 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1116 return "move%.l %+,%0";
1118 /* Must be memory destination. */
1119 return "fmove%.x %f1,%0";
1121 return output_move_double (operands);
1125 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1126 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1127 "! TARGET_68881 && ! TARGET_COLDFIRE"
1129 if (FP_REG_P (operands[0]))
1131 if (FP_REG_P (operands[1]))
1132 return "fmove%.x %1,%0";
1133 if (REG_P (operands[1]))
1136 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1137 output_asm_insn ("move%.l %1,%-", xoperands);
1138 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1139 output_asm_insn ("move%.l %1,%-", xoperands);
1140 output_asm_insn ("move%.l %1,%-", operands);
1141 return "fmove%.x %+,%0";
1143 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1144 return "fmove%.x %1,%0";
1145 return "fmove%.x %f1,%0";
1147 if (FP_REG_P (operands[1]))
1149 if (REG_P (operands[0]))
1151 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1152 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1153 output_asm_insn ("move%.l %+,%0", operands);
1154 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1155 return "move%.l %+,%0";
1158 return "fmove%.x %f1,%0";
1160 return output_move_double (operands);
1164 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1165 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1166 "! TARGET_68881 && TARGET_COLDFIRE"
1167 "* return output_move_double (operands);")
1169 (define_expand "movdi"
1170 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1171 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1172 (match_operand:DI 1 "general_operand" ""))]
1176 ;; movdi can apply to fp regs in some cases
1178 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1179 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1180 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1181 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1182 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1183 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1184 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1187 if (FP_REG_P (operands[0]))
1189 if (FP_REG_P (operands[1]))
1190 return "fmove%.x %1,%0";
1191 if (REG_P (operands[1]))
1194 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1195 output_asm_insn ("move%.l %1,%-", xoperands);
1196 output_asm_insn ("move%.l %1,%-", operands);
1197 return "fmove%.d %+,%0";
1199 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1200 return output_move_const_double (operands);
1201 return "fmove%.d %f1,%0";
1203 else if (FP_REG_P (operands[1]))
1205 if (REG_P (operands[0]))
1207 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1208 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1209 return "move%.l %+,%0";
1212 return "fmove%.d %f1,%0";
1214 return output_move_double (operands);
1218 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1219 (match_operand:DI 1 "general_operand" "g,r"))]
1221 "* return output_move_double (operands);")
1223 ;; Thus goes after the move instructions
1224 ;; because the move instructions are better (require no spilling)
1225 ;; when they can apply. It goes before the add/sub insns
1226 ;; so we will prefer it to them.
1228 (define_insn "pushasi"
1229 [(set (match_operand:SI 0 "push_operand" "=m")
1230 (match_operand:SI 1 "address_operand" "p"))]
1234 ;; truncation instructions
1235 (define_insn "truncsiqi2"
1236 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1238 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1241 if (GET_CODE (operands[0]) == REG)
1243 /* Must clear condition codes, since the move.l bases them on
1244 the entire 32 bits, not just the desired 8 bits. */
1246 return "move%.l %1,%0";
1248 if (GET_CODE (operands[1]) == MEM)
1249 operands[1] = adjust_address (operands[1], QImode, 3);
1250 return "move%.b %1,%0";
1253 (define_insn "trunchiqi2"
1254 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1256 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1259 if (GET_CODE (operands[0]) == REG
1260 && (GET_CODE (operands[1]) == MEM
1261 || GET_CODE (operands[1]) == CONST_INT))
1263 /* Must clear condition codes, since the move.w bases them on
1264 the entire 16 bits, not just the desired 8 bits. */
1266 return "move%.w %1,%0";
1268 if (GET_CODE (operands[0]) == REG)
1270 /* Must clear condition codes, since the move.l bases them on
1271 the entire 32 bits, not just the desired 8 bits. */
1273 return "move%.l %1,%0";
1275 if (GET_CODE (operands[1]) == MEM)
1276 operands[1] = adjust_address (operands[1], QImode, 1);
1277 return "move%.b %1,%0";
1280 (define_insn "truncsihi2"
1281 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1283 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1286 if (GET_CODE (operands[0]) == REG)
1288 /* Must clear condition codes, since the move.l bases them on
1289 the entire 32 bits, not just the desired 8 bits. */
1291 return "move%.l %1,%0";
1293 if (GET_CODE (operands[1]) == MEM)
1294 operands[1] = adjust_address (operands[1], QImode, 2);
1295 return "move%.w %1,%0";
1298 ;; zero extension instructions
1300 ;; two special patterns to match various post_inc/pre_dec patterns
1301 (define_insn_and_split "*zero_extend_inc"
1302 [(set (match_operand 0 "post_inc_operand" "")
1303 (zero_extend (match_operand 1 "register_operand" "")))]
1304 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1305 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1306 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1314 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1317 (define_insn_and_split "*zero_extend_dec"
1318 [(set (match_operand 0 "pre_dec_operand" "")
1319 (zero_extend (match_operand 1 "register_operand" "")))]
1320 "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1321 GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1322 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1323 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1331 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1334 (define_insn_and_split "zero_extendqidi2"
1335 [(set (match_operand:DI 0 "register_operand" "")
1336 (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1341 (zero_extend:SI (match_dup 1)))
1345 operands[2] = gen_lowpart (SImode, operands[0]);
1346 operands[3] = gen_highpart (SImode, operands[0]);
1349 (define_insn_and_split "zero_extendhidi2"
1350 [(set (match_operand:DI 0 "register_operand" "")
1351 (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1356 (zero_extend:SI (match_dup 1)))
1360 operands[2] = gen_lowpart (SImode, operands[0]);
1361 operands[3] = gen_highpart (SImode, operands[0]);
1364 (define_expand "zero_extendsidi2"
1365 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1366 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1369 if (GET_CODE (operands[0]) == MEM
1370 && GET_CODE (operands[1]) == MEM)
1371 operands[1] = force_reg (SImode, operands[1]);
1374 (define_insn_and_split "*zero_extendsidi2"
1375 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1376 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1377 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1385 operands[2] = gen_lowpart (SImode, operands[0]);
1386 operands[3] = gen_highpart (SImode, operands[0]);
1389 (define_insn "*zero_extendhisi2_cf"
1390 [(set (match_operand:SI 0 "register_operand" "=d")
1391 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1395 (define_insn "zero_extendhisi2"
1396 [(set (match_operand:SI 0 "register_operand" "=d")
1397 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1401 (define_expand "zero_extendqihi2"
1402 [(set (match_operand:HI 0 "register_operand" "")
1403 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1407 (define_insn "*zero_extendqihi2"
1408 [(set (match_operand:HI 0 "register_operand" "=d")
1409 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1413 (define_insn "*zero_extendqisi2_cfv4"
1414 [(set (match_operand:SI 0 "register_operand" "=d")
1415 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1419 (define_insn "zero_extendqisi2"
1420 [(set (match_operand:SI 0 "register_operand" "=d")
1421 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1425 ;; these two pattern split everything else which isn't matched by
1426 ;; something else above
1428 [(set (match_operand 0 "register_operand" "")
1429 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1430 "!TARGET_CFV4 && reload_completed && reg_mentioned_p (operands[0], operands[1])"
1431 [(set (strict_low_part (match_dup 2))
1434 (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1436 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1437 operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1438 operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1442 [(set (match_operand 0 "register_operand" "")
1443 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1444 "!TARGET_CFV4 && reload_completed"
1447 (set (strict_low_part (match_dup 2))
1450 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1453 ;; sign extension instructions
1455 (define_insn "extendqidi2"
1456 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1457 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1461 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1463 return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1464 if (TARGET_68020 || TARGET_COLDFIRE)
1466 if (ADDRESS_REG_P (operands[1]))
1467 return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1469 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1473 if (ADDRESS_REG_P (operands[1]))
1474 return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1476 return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1480 (define_insn "extendhidi2"
1481 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1483 (match_operand:HI 1 "general_src_operand" "rmS")))]
1487 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1489 return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1490 if (TARGET_68020 || TARGET_COLDFIRE)
1491 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1493 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1496 (define_insn "extendsidi2"
1497 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1499 (match_operand:SI 1 "general_operand" "rm")))]
1503 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1504 if (TARGET_68020 || TARGET_COLDFIRE)
1505 return "move%.l %1,%2\;smi %0\;extb%.l %0";
1507 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
1510 ;; Special case when one can avoid register clobbering, copy and test
1511 ;; Maybe there is a way to make that the general case, by forcing the
1512 ;; result of the SI tree to be in the lower register of the DI target
1514 (define_insn "extendplussidi"
1515 [(set (match_operand:DI 0 "register_operand" "=d")
1516 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1517 (match_operand:SI 2 "general_operand" "rmn"))))]
1521 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1522 if (GET_CODE (operands[1]) == CONST_INT
1523 && (unsigned) INTVAL (operands[1]) > 8)
1525 rtx tmp = operands[1];
1527 operands[1] = operands[2];
1530 if (GET_CODE (operands[1]) == REG
1531 && REGNO (operands[1]) == REGNO (operands[3]))
1532 output_asm_insn ("add%.l %2,%3", operands);
1534 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1535 if (TARGET_68020 || TARGET_COLDFIRE)
1536 return "smi %0\;extb%.l %0";
1538 return "smi %0\;ext%.w %0\;ext%.l %0";
1541 (define_expand "extendhisi2"
1542 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1544 (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1548 (define_insn "*cfv4_extendhisi2"
1549 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1551 (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1555 (define_insn "*68k_extendhisi2"
1556 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1558 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1561 if (ADDRESS_REG_P (operands[0]))
1562 return "move%.w %1,%0";
1566 (define_insn "extendqihi2"
1567 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1568 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1572 (define_expand "extendqisi2"
1573 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1574 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1575 "TARGET_68020 || TARGET_COLDFIRE"
1578 (define_insn "*cfv4_extendqisi2"
1579 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1580 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1584 (define_insn "*68k_extendqisi2"
1585 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1586 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1587 "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_CFV4)"
1590 ;; Conversions between float and double.
1592 (define_expand "extendsfdf2"
1593 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1595 (match_operand:SF 1 "general_operand" "")))]
1600 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1602 (match_operand:SF 1 "general_operand" "f,dmF")))]
1605 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1607 if (REGNO (operands[0]) == REGNO (operands[1]))
1609 /* Extending float to double in an fp-reg is a no-op.
1610 NOTICE_UPDATE_CC has already assumed that the
1611 cc will be set. So cancel what it did. */
1612 cc_status = cc_prev_status;
1615 return "f%&move%.x %1,%0";
1617 if (FP_REG_P (operands[0]))
1618 return "f%&move%.s %f1,%0";
1619 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1621 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1622 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1623 return "move%.l %+,%0";
1625 return "fmove%.d %f1,%0";
1628 (define_insn "extendsfdf2_cf"
1629 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
1631 (match_operand:SF 1 "general_operand" "f,<Q>U")))]
1632 "TARGET_COLDFIRE_FPU"
1634 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1636 if (REGNO (operands[0]) == REGNO (operands[1]))
1638 /* Extending float to double in an fp-reg is a no-op.
1639 NOTICE_UPDATE_CC has already assumed that the
1640 cc will be set. So cancel what it did. */
1641 cc_status = cc_prev_status;
1644 return "f%&move%.d %1,%0";
1646 return "f%&move%.s %f1,%0";
1649 ;; This cannot output into an f-reg because there is no way to be
1650 ;; sure of truncating in that case.
1651 (define_expand "truncdfsf2"
1652 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1654 (match_operand:DF 1 "general_operand" "")))]
1658 ;; On the '040 we can truncate in a register accurately and easily.
1660 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1662 (match_operand:DF 1 "general_operand" "fmG")))]
1663 "TARGET_68881 && TARGET_68040_ONLY"
1665 if (FP_REG_P (operands[1]))
1666 return "f%$move%.x %1,%0";
1667 return "f%$move%.d %f1,%0";
1670 (define_insn "truncdfsf2_cf"
1671 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
1673 (match_operand:DF 1 "general_operand" "<Q>U,f")))]
1674 "TARGET_COLDFIRE_FPU"
1680 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1682 (match_operand:DF 1 "general_operand" "f")))]
1686 ;; Conversion between fixed point and floating point.
1687 ;; Note that among the fix-to-float insns
1688 ;; the ones that start with SImode come first.
1689 ;; That is so that an operand that is a CONST_INT
1690 ;; (and therefore lacks a specific machine mode).
1691 ;; will be recognized as SImode (which is always valid)
1692 ;; rather than as QImode or HImode.
1694 (define_expand "floatsi<mode>2"
1695 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1696 (float:FP (match_operand:SI 1 "general_operand" "")))]
1700 (define_insn "floatsi<mode>2_68881"
1701 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1702 (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
1704 "f<FP:round>move%.l %1,%0")
1706 (define_insn "floatsi<mode>2_cf"
1707 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1708 (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
1709 "TARGET_COLDFIRE_FPU"
1710 "f<FP:prec>move%.l %1,%0")
1713 (define_expand "floathi<mode>2"
1714 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1715 (float:FP (match_operand:HI 1 "general_operand" "")))]
1719 (define_insn "floathi<mode>2_68881"
1720 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1721 (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
1725 (define_insn "floathi<mode>2_cf"
1726 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1727 (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
1728 "TARGET_COLDFIRE_FPU"
1732 (define_expand "floatqi<mode>2"
1733 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1734 (float:FP (match_operand:QI 1 "general_operand" "")))]
1738 (define_insn "floatqi<mode>2_68881"
1739 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1740 (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
1744 (define_insn "floatqi<mode>2_cf"
1745 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1746 (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
1747 "TARGET_COLDFIRE_FPU"
1751 ;; New routines to convert floating-point values to integers
1752 ;; to be used on the '040. These should be faster than trapping
1753 ;; into the kernel to emulate fintrz. They should also be faster
1754 ;; than calling the subroutines fixsfsi or fixdfsi.
1756 (define_insn "fix_truncdfsi2"
1757 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1758 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1759 (clobber (match_scratch:SI 2 "=d"))
1760 (clobber (match_scratch:SI 3 "=d"))]
1761 "TARGET_68881 && TUNE_68040"
1764 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,%!";
1767 (define_insn "fix_truncdfhi2"
1768 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1769 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1770 (clobber (match_scratch:SI 2 "=d"))
1771 (clobber (match_scratch:SI 3 "=d"))]
1772 "TARGET_68881 && TUNE_68040"
1775 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,%!";
1778 (define_insn "fix_truncdfqi2"
1779 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1780 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1781 (clobber (match_scratch:SI 2 "=d"))
1782 (clobber (match_scratch:SI 3 "=d"))]
1783 "TARGET_68881 && TUNE_68040"
1786 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,%!";
1789 ;; Convert a float to a float whose value is an integer.
1790 ;; This is the first stage of converting it to an integer type.
1792 (define_expand "ftrunc<mode>2"
1793 [(set (match_operand:FP 0 "nonimmediate_operand" "")
1794 (fix:FP (match_operand:FP 1 "general_operand" "")))]
1795 "TARGET_HARD_FLOAT && !TUNE_68040"
1798 (define_insn "ftrunc<mode>2_68881"
1799 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1800 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
1801 "TARGET_68881 && !TUNE_68040"
1803 if (FP_REG_P (operands[1]))
1804 return "fintrz%.x %f1,%0";
1805 return "fintrz%.<FP:prec> %f1,%0";
1808 (define_insn "ftrunc<mode>2_cf"
1809 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1810 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
1811 "TARGET_COLDFIRE_FPU"
1813 if (FP_REG_P (operands[1]))
1814 return "fintrz%.d %f1,%0";
1815 return "fintrz%.<FP:prec> %f1,%0";
1818 ;; Convert a float whose value is an integer
1819 ;; to an actual integer. Second stage of converting float to integer type.
1820 (define_expand "fix<mode>qi2"
1821 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1822 (fix:QI (match_operand:FP 1 "general_operand" "")))]
1826 (define_insn "fix<mode>qi2_68881"
1827 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1828 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
1832 (define_insn "fix<mode>qi2_cf"
1833 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
1834 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
1835 "TARGET_COLDFIRE_FPU"
1838 (define_expand "fix<mode>hi2"
1839 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1840 (fix:HI (match_operand:FP 1 "general_operand" "")))]
1844 (define_insn "fix<mode>hi2_68881"
1845 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1846 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
1850 (define_insn "fix<mode>hi2_cf"
1851 [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
1852 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
1853 "TARGET_COLDFIRE_FPU"
1856 (define_expand "fix<mode>si2"
1857 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1858 (fix:SI (match_operand:FP 1 "general_operand" "")))]
1862 (define_insn "fix<mode>si2_68881"
1863 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1864 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
1868 (define_insn "fix<mode>si2_cf"
1869 [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
1870 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
1871 "TARGET_COLDFIRE_FPU"
1877 (define_insn "adddi_lshrdi_63"
1878 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1879 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
1882 (clobber (match_scratch:SI 2 "=d"))]
1885 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1886 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
1888 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
1889 if (GET_CODE (operands[1]) == REG)
1890 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1891 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
1892 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1893 operands[4] = operands[1];
1895 operands[4] = adjust_address (operands[1], SImode, 4);
1896 if (GET_CODE (operands[1]) == MEM
1897 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1898 output_asm_insn ("move%.l %4,%3", operands);
1899 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
1900 if (TARGET_68020 || TARGET_COLDFIRE)
1901 output_asm_insn ("extb%.l %2", operands);
1903 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
1904 if (GET_CODE (operands[1]) != MEM
1905 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
1906 output_asm_insn ("move%.l %4,%3", operands);
1907 return "sub%.l %2,%3\;subx%.l %2,%0";
1910 (define_insn "adddi_sexthishl32"
1911 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
1912 (plus:DI (ashift:DI (sign_extend:DI
1913 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
1915 (match_operand:DI 2 "general_operand" "0,0,0,0")))
1916 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
1920 if (ADDRESS_REG_P (operands[0]))
1921 return "add%.w %1,%0";
1922 else if (ADDRESS_REG_P (operands[3]))
1923 return "move%.w %1,%3\;add%.l %3,%0";
1925 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
1928 (define_insn "adddi_dilshr32"
1929 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
1930 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1931 ;; (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
1932 ;; (const_int 32))))]
1933 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
1935 (match_operand:DI 2 "general_operand" "0,0")))]
1939 if (GET_CODE (operands[0]) == REG)
1940 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1942 operands[2] = adjust_address (operands[0], SImode, 4);
1943 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
1946 (define_insn "adddi_dishl32"
1947 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
1948 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
1949 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
1950 ;; (const_int 32))))]
1951 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
1953 (match_operand:DI 2 "general_operand" "0,0")))]
1957 if (GET_CODE (operands[1]) == REG)
1958 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1960 operands[1] = adjust_address (operands[1], SImode, 4);
1961 return "add%.l %1,%0";
1964 (define_insn "adddi3"
1965 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
1966 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0,0")
1967 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
1968 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
1971 if (DATA_REG_P (operands[0]))
1973 if (DATA_REG_P (operands[2]))
1974 return "add%.l %R2,%R0\;addx%.l %2,%0";
1975 else if (GET_CODE (operands[2]) == MEM
1976 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
1977 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
1983 if (GET_CODE (operands[2]) == REG)
1985 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
1988 else if (CONSTANT_P (operands[2]))
1989 split_double (operands[2], &high, &low);
1992 low = adjust_address (operands[2], SImode, 4);
1996 operands[1] = low, operands[2] = high;
1997 xoperands[0] = operands[3];
1998 if (GET_CODE (operands[1]) == CONST_INT
1999 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2000 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2002 xoperands[1] = operands[2];
2004 output_asm_insn (output_move_simode (xoperands), xoperands);
2005 if (GET_CODE (operands[1]) == CONST_INT)
2007 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2008 return "addq%.l %1,%R0\;addx%.l %3,%0";
2009 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2011 operands[1] = GEN_INT (-INTVAL (operands[1]));
2012 return "subq%.l %1,%R0\;subx%.l %3,%0";
2015 return "add%.l %1,%R0\;addx%.l %3,%0";
2020 gcc_assert (GET_CODE (operands[0]) == MEM);
2021 if (GET_CODE (operands[2]) == MEM
2022 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
2023 return "add%.l %2,%0\;addx%.l %2,%0";
2025 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2027 operands[1] = gen_rtx_MEM (SImode,
2028 plus_constant (XEXP(operands[0], 0), -8));
2029 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2031 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2033 operands[1] = XEXP(operands[0], 0);
2034 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2038 operands[1] = adjust_address (operands[0], SImode, 4);
2039 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2044 (define_insn "addsi_lshrsi_31"
2045 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2046 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
2051 operands[2] = operands[0];
2052 operands[3] = gen_label_rtx();
2053 if (GET_CODE (operands[0]) == MEM)
2055 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2056 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2057 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2058 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2060 output_asm_insn ("move%.l %1,%0", operands);
2061 output_asm_insn (MOTOROLA ? "jbpl %l3" : "jpl %l3", operands);
2062 output_asm_insn ("addq%.l #1,%2", operands);
2063 (*targetm.asm_out.internal_label) (asm_out_file, "L",
2064 CODE_LABEL_NUMBER (operands[3]));
2068 (define_expand "addsi3"
2069 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2070 (plus:SI (match_operand:SI 1 "general_operand" "")
2071 (match_operand:SI 2 "general_src_operand" "")))]
2075 ;; Note that the middle two alternatives are near-duplicates
2076 ;; in order to handle insns generated by reload.
2077 ;; This is needed since they are not themselves reloaded,
2078 ;; so commutativity won't apply to them.
2079 (define_insn "*addsi3_internal"
2080 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2081 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2082 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2086 "* return output_addsi3 (operands);")
2088 (define_insn "*addsi3_5200"
2089 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
2090 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
2091 (match_operand:SI 2 "general_src_operand" "dIL,rJK,a,mrIKLi")))]
2093 "* return output_addsi3 (operands);")
2096 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2097 (plus:SI (match_operand:SI 1 "general_operand" "0")
2099 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2103 (define_insn "addhi3"
2104 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2105 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2106 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2109 if (GET_CODE (operands[2]) == CONST_INT)
2111 /* If the constant would be a negative number when interpreted as
2112 HImode, make it negative. This is usually, but not always, done
2113 elsewhere in the compiler. First check for constants out of range,
2114 which could confuse us. */
2116 if (INTVAL (operands[2]) >= 32768)
2117 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2119 if (INTVAL (operands[2]) > 0
2120 && INTVAL (operands[2]) <= 8)
2121 return "addq%.w %2,%0";
2122 if (INTVAL (operands[2]) < 0
2123 && INTVAL (operands[2]) >= -8)
2125 operands[2] = GEN_INT (- INTVAL (operands[2]));
2126 return "subq%.w %2,%0";
2128 /* On the CPU32 it is faster to use two addqw instructions to
2129 add a small integer (8 < N <= 16) to a register.
2130 Likewise for subqw. */
2131 if (TUNE_CPU32 && REG_P (operands[0]))
2133 if (INTVAL (operands[2]) > 8
2134 && INTVAL (operands[2]) <= 16)
2136 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2137 return "addq%.w #8,%0\;addq%.w %2,%0";
2139 if (INTVAL (operands[2]) < -8
2140 && INTVAL (operands[2]) >= -16)
2142 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2143 return "subq%.w #8,%0\;subq%.w %2,%0";
2146 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2147 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2149 return "add%.w %2,%0";
2152 ;; These insns must use MATCH_DUP instead of the more expected
2153 ;; use of a matching constraint because the "output" here is also
2154 ;; an input, so you can't use the matching constraint. That also means
2155 ;; that you can't use the "%", so you need patterns with the matched
2156 ;; operand in both positions.
2159 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2160 (plus:HI (match_dup 0)
2161 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2164 if (GET_CODE (operands[1]) == CONST_INT)
2166 /* If the constant would be a negative number when interpreted as
2167 HImode, make it negative. This is usually, but not always, done
2168 elsewhere in the compiler. First check for constants out of range,
2169 which could confuse us. */
2171 if (INTVAL (operands[1]) >= 32768)
2172 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2174 if (INTVAL (operands[1]) > 0
2175 && INTVAL (operands[1]) <= 8)
2176 return "addq%.w %1,%0";
2177 if (INTVAL (operands[1]) < 0
2178 && INTVAL (operands[1]) >= -8)
2180 operands[1] = GEN_INT (- INTVAL (operands[1]));
2181 return "subq%.w %1,%0";
2183 /* On the CPU32 it is faster to use two addqw instructions to
2184 add a small integer (8 < N <= 16) to a register.
2185 Likewise for subqw. */
2186 if (TUNE_CPU32 && REG_P (operands[0]))
2188 if (INTVAL (operands[1]) > 8
2189 && INTVAL (operands[1]) <= 16)
2191 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2192 return "addq%.w #8,%0\;addq%.w %1,%0";
2194 if (INTVAL (operands[1]) < -8
2195 && INTVAL (operands[1]) >= -16)
2197 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2198 return "subq%.w #8,%0\;subq%.w %1,%0";
2201 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2202 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2204 return "add%.w %1,%0";
2208 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2209 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2213 if (GET_CODE (operands[1]) == CONST_INT)
2215 /* If the constant would be a negative number when interpreted as
2216 HImode, make it negative. This is usually, but not always, done
2217 elsewhere in the compiler. First check for constants out of range,
2218 which could confuse us. */
2220 if (INTVAL (operands[1]) >= 32768)
2221 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2223 if (INTVAL (operands[1]) > 0
2224 && INTVAL (operands[1]) <= 8)
2225 return "addq%.w %1,%0";
2226 if (INTVAL (operands[1]) < 0
2227 && INTVAL (operands[1]) >= -8)
2229 operands[1] = GEN_INT (- INTVAL (operands[1]));
2230 return "subq%.w %1,%0";
2232 /* On the CPU32 it is faster to use two addqw instructions to
2233 add a small integer (8 < N <= 16) to a register.
2234 Likewise for subqw. */
2235 if (TUNE_CPU32 && REG_P (operands[0]))
2237 if (INTVAL (operands[1]) > 8
2238 && INTVAL (operands[1]) <= 16)
2240 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2241 return "addq%.w #8,%0\;addq%.w %1,%0";
2243 if (INTVAL (operands[1]) < -8
2244 && INTVAL (operands[1]) >= -16)
2246 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2247 return "subq%.w #8,%0\;subq%.w %1,%0";
2250 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2251 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2253 return "add%.w %1,%0";
2256 (define_insn "addqi3"
2257 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2258 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2259 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2262 if (GET_CODE (operands[2]) == CONST_INT)
2264 if (INTVAL (operands[2]) >= 128)
2265 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2267 if (INTVAL (operands[2]) > 0
2268 && INTVAL (operands[2]) <= 8)
2269 return "addq%.b %2,%0";
2270 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2272 operands[2] = GEN_INT (- INTVAL (operands[2]));
2273 return "subq%.b %2,%0";
2276 return "add%.b %2,%0";
2280 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2281 (plus:QI (match_dup 0)
2282 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2285 if (GET_CODE (operands[1]) == CONST_INT)
2287 if (INTVAL (operands[1]) >= 128)
2288 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2290 if (INTVAL (operands[1]) > 0
2291 && INTVAL (operands[1]) <= 8)
2292 return "addq%.b %1,%0";
2293 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2295 operands[1] = GEN_INT (- INTVAL (operands[1]));
2296 return "subq%.b %1,%0";
2299 return "add%.b %1,%0";
2303 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2304 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2308 if (GET_CODE (operands[1]) == CONST_INT)
2310 if (INTVAL (operands[1]) >= 128)
2311 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2313 if (INTVAL (operands[1]) > 0
2314 && INTVAL (operands[1]) <= 8)
2315 return "addq%.b %1,%0";
2316 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2318 operands[1] = GEN_INT (- INTVAL (operands[1]));
2319 return "subq%.b %1,%0";
2322 return "add%.b %1,%0";
2325 (define_expand "add<mode>3"
2326 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2327 (plus:FP (match_operand:FP 1 "general_operand" "")
2328 (match_operand:FP 2 "general_operand" "")))]
2332 (define_insn "add<mode>3_floatsi_68881"
2333 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2334 (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2335 (match_operand:FP 1 "general_operand" "0")))]
2337 "f<FP:round>add%.l %2,%0")
2339 (define_insn "add<mode>3_floathi_68881"
2340 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2341 (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2342 (match_operand:FP 1 "general_operand" "0")))]
2344 "f<FP:round>add%.w %2,%0")
2346 (define_insn "add<mode>3_floatqi_68881"
2347 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2348 (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2349 (match_operand:FP 1 "general_operand" "0")))]
2351 "f<FP:round>add%.b %2,%0")
2353 (define_insn "add<mode>3_68881"
2354 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2355 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2356 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2359 if (FP_REG_P (operands[2]))
2360 return "f<FP:round>add%.x %2,%0";
2361 return "f<FP:round>add%.<FP:prec> %f2,%0";
2364 (define_insn "add<mode>3_cf"
2365 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2366 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2367 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2368 "TARGET_COLDFIRE_FPU"
2370 if (FP_REG_P (operands[2]))
2371 return "f<FP:round>add%.d %2,%0";
2372 return "f<FP:round>add%.<FP:prec> %2,%0";
2375 ;; subtract instructions
2377 (define_insn "subdi_sexthishl32"
2378 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2379 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2380 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2382 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2386 if (ADDRESS_REG_P (operands[0]))
2387 return "sub%.w %2,%0";
2388 else if (ADDRESS_REG_P (operands[3]))
2389 return "move%.w %2,%3\;sub%.l %3,%0";
2391 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2394 (define_insn "subdi_dishl32"
2395 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2396 (minus:DI (match_dup 0)
2397 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2402 if (GET_CODE (operands[1]) == REG)
2403 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2405 operands[1] = adjust_address (operands[1], SImode, 4);
2406 return "sub%.l %1,%0";
2409 (define_insn "subdi3"
2410 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,o<>,d,d,d")
2411 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0,0")
2412 (match_operand:DI 2 "general_operand" "<,d,no>,d,a")))
2413 (clobber (match_scratch:SI 3 "=X,&d,&d,X,&d"))]
2416 if (DATA_REG_P (operands[0]))
2418 if (DATA_REG_P (operands[2]))
2419 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2420 else if (GET_CODE (operands[2]) == MEM
2421 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2423 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2430 if (GET_CODE (operands[2]) == REG)
2432 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2435 else if (CONSTANT_P (operands[2]))
2436 split_double (operands[2], &high, &low);
2439 low = adjust_address (operands[2], SImode, 4);
2443 operands[1] = low, operands[2] = high;
2444 xoperands[0] = operands[3];
2445 if (GET_CODE (operands[1]) == CONST_INT
2446 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2447 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2449 xoperands[1] = operands[2];
2451 output_asm_insn (output_move_simode (xoperands), xoperands);
2452 if (GET_CODE (operands[1]) == CONST_INT)
2454 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2455 return "subq%.l %1,%R0\;subx%.l %3,%0";
2456 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2458 operands[1] = GEN_INT (-INTVAL (operands[1]));
2459 return "addq%.l %1,%R0\;addx%.l %3,%0";
2462 return "sub%.l %1,%R0\;subx%.l %3,%0";
2467 gcc_assert (GET_CODE (operands[0]) == MEM);
2468 if (GET_CODE (operands[2]) == MEM
2469 && GET_CODE (XEXP (operands[2], 0)) == PRE_DEC)
2470 return "sub%.l %2,%0\;subx%.l %2,%0";
2472 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2475 = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2476 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2478 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2480 operands[1] = XEXP(operands[0], 0);
2481 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2485 operands[1] = adjust_address (operands[0], SImode, 4);
2486 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2491 (define_insn "subsi3"
2492 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2493 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2494 (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2499 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2500 (minus:SI (match_operand:SI 1 "general_operand" "0")
2502 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2506 (define_insn "subhi3"
2507 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2508 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2509 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2514 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2515 (minus:HI (match_dup 0)
2516 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2520 (define_insn "subqi3"
2521 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2522 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2523 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2528 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2529 (minus:QI (match_dup 0)
2530 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2534 (define_expand "sub<mode>3"
2535 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2536 (minus:FP (match_operand:FP 1 "general_operand" "")
2537 (match_operand:FP 2 "general_operand" "")))]
2541 (define_insn "sub<mode>3_floatsi_68881"
2542 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2543 (minus:FP (match_operand:FP 1 "general_operand" "0")
2544 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2546 "f<FP:round>sub%.l %2,%0")
2548 (define_insn "sub<mode>3_floathi_68881"
2549 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2550 (minus:FP (match_operand:FP 1 "general_operand" "0")
2551 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2553 "f<FP:round>sub%.w %2,%0")
2555 (define_insn "sub<mode>3_floatqi_68881"
2556 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2557 (minus:FP (match_operand:FP 1 "general_operand" "0")
2558 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2560 "f<FP:round>sub%.b %2,%0")
2562 (define_insn "sub<mode>3_68881"
2563 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2564 (minus:FP (match_operand:FP 1 "general_operand" "0")
2565 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2568 if (FP_REG_P (operands[2]))
2569 return "f<FP:round>sub%.x %2,%0";
2570 return "f<FP:round>sub%.<FP:prec> %f2,%0";
2573 (define_insn "sub<mode>3_cf"
2574 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2575 (minus:FP (match_operand:FP 1 "general_operand" "0")
2576 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2577 "TARGET_COLDFIRE_FPU"
2579 if (FP_REG_P (operands[2]))
2580 return "f<FP:round>sub%.d %2,%0";
2581 return "f<FP:round>sub%.<FP:prec> %2,%0";
2584 ;; multiply instructions
2586 (define_insn "mulhi3"
2587 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2588 (mult:HI (match_operand:HI 1 "general_operand" "%0")
2589 (match_operand:HI 2 "general_src_operand" "dmSn")))]
2592 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2595 (define_insn "mulhisi3"
2596 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2597 (mult:SI (sign_extend:SI
2598 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2600 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2603 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2607 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2608 (mult:SI (sign_extend:SI
2609 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2610 (match_operand:SI 2 "const_int_operand" "n")))]
2611 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2613 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2616 (define_expand "mulsi3"
2617 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2618 (mult:SI (match_operand:SI 1 "general_operand" "")
2619 (match_operand:SI 2 "general_operand" "")))]
2620 "TARGET_68020 || TARGET_COLDFIRE"
2624 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2625 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2626 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2632 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2633 (mult:SI (match_operand:SI 1 "general_operand" "%0")
2634 (match_operand:SI 2 "general_operand" "d<Q>")))]
2638 (define_insn "umulhisi3"
2639 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2640 (mult:SI (zero_extend:SI
2641 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2643 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2646 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2650 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2651 (mult:SI (zero_extend:SI
2652 (match_operand:HI 1 "nonimmediate_operand" "%0"))
2653 (match_operand:SI 2 "const_int_operand" "n")))]
2654 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2656 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2659 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2660 ;; proper matching constraint. This is because the matching is between
2661 ;; the high-numbered word of the DImode operand[0] and operand[1].
2662 (define_expand "umulsidi3"
2664 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2665 (mult:SI (match_operand:SI 1 "register_operand" "")
2666 (match_operand:SI 2 "register_operand" "")))
2667 (set (subreg:SI (match_dup 0) 0)
2668 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2669 (zero_extend:DI (match_dup 2)))
2670 (const_int 32))))])]
2671 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2675 [(set (match_operand:SI 0 "register_operand" "=d")
2676 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2677 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2678 (set (match_operand:SI 3 "register_operand" "=d")
2679 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2680 (zero_extend:DI (match_dup 2)))
2682 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2685 ; Match immediate case. For 2.4 only match things < 2^31.
2686 ; It's tricky with larger values in these patterns since we need to match
2687 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2690 [(set (match_operand:SI 0 "register_operand" "=d")
2691 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2692 (match_operand:SI 2 "const_int_operand" "n")))
2693 (set (match_operand:SI 3 "register_operand" "=d")
2694 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2697 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
2698 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2701 (define_expand "mulsidi3"
2703 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2704 (mult:SI (match_operand:SI 1 "register_operand" "")
2705 (match_operand:SI 2 "register_operand" "")))
2706 (set (subreg:SI (match_dup 0) 0)
2707 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2708 (sign_extend:DI (match_dup 2)))
2709 (const_int 32))))])]
2710 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2714 [(set (match_operand:SI 0 "register_operand" "=d")
2715 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2716 (match_operand:SI 2 "nonimmediate_operand" "dm")))
2717 (set (match_operand:SI 3 "register_operand" "=d")
2718 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2719 (sign_extend:DI (match_dup 2)))
2721 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2725 [(set (match_operand:SI 0 "register_operand" "=d")
2726 (mult:SI (match_operand:SI 1 "register_operand" "%0")
2727 (match_operand:SI 2 "const_int_operand" "n")))
2728 (set (match_operand:SI 3 "register_operand" "=d")
2729 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2732 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2735 (define_expand "umulsi3_highpart"
2737 [(set (match_operand:SI 0 "register_operand" "")
2740 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2741 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2743 (clobber (match_dup 3))])]
2744 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2746 operands[3] = gen_reg_rtx (SImode);
2748 if (GET_CODE (operands[2]) == CONST_INT)
2750 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2753 /* We have to adjust the operand order for the matching constraints. */
2754 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2755 operands[1], operands[2]));
2761 [(set (match_operand:SI 0 "register_operand" "=d")
2764 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2765 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2767 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2768 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2771 (define_insn "const_umulsi3_highpart"
2772 [(set (match_operand:SI 0 "register_operand" "=d")
2775 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2776 (match_operand:DI 3 "const_uint32_operand" "n"))
2778 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2779 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2782 (define_expand "smulsi3_highpart"
2784 [(set (match_operand:SI 0 "register_operand" "")
2787 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2788 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2790 (clobber (match_dup 3))])]
2791 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2793 operands[3] = gen_reg_rtx (SImode);
2794 if (GET_CODE (operands[2]) == CONST_INT)
2796 /* We have to adjust the operand order for the matching constraints. */
2797 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2798 operands[1], operands[2]));
2804 [(set (match_operand:SI 0 "register_operand" "=d")
2807 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2808 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2810 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2811 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2814 (define_insn "const_smulsi3_highpart"
2815 [(set (match_operand:SI 0 "register_operand" "=d")
2818 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2819 (match_operand:DI 3 "const_sint32_operand" "n"))
2821 (clobber (match_operand:SI 1 "register_operand" "=d"))]
2822 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2825 (define_expand "mul<mode>3"
2826 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2827 (mult:FP (match_operand:FP 1 "general_operand" "")
2828 (match_operand:FP 2 "general_operand" "")))]
2832 (define_insn "mul<mode>3_floatsi_68881"
2833 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2834 (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2835 (match_operand:FP 1 "general_operand" "0")))]
2838 return TARGET_68040_ONLY
2839 ? "f<FP:round>mul%.l %2,%0"
2840 : "f<FP:round_mul>mul%.l %2,%0";
2843 (define_insn "mul<mode>3_floathi_68881"
2844 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2845 (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2846 (match_operand:FP 1 "general_operand" "0")))]
2849 return TARGET_68040_ONLY
2850 ? "f<FP:round>mul%.w %2,%0"
2851 : "f<FP:round_mul>mul%.w %2,%0";
2854 (define_insn "mul<mode>3_floatqi_68881"
2855 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2856 (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2857 (match_operand:FP 1 "general_operand" "0")))]
2860 return TARGET_68040_ONLY
2861 ? "f<FP:round>mul%.b %2,%0"
2862 : "f<FP:round_mul>mul%.b %2,%0";
2865 (define_insn "muldf_68881"
2866 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2867 (mult:DF (match_operand:DF 1 "general_operand" "%0")
2868 (match_operand:DF 2 "general_operand" "fmG")))]
2871 if (GET_CODE (operands[2]) == CONST_DOUBLE
2872 && floating_exact_log2 (operands[2]) && !TUNE_68040 && !TUNE_68060)
2874 int i = floating_exact_log2 (operands[2]);
2875 operands[2] = GEN_INT (i);
2876 return "fscale%.l %2,%0";
2878 if (REG_P (operands[2]))
2879 return "f%&mul%.x %2,%0";
2880 return "f%&mul%.d %f2,%0";
2883 (define_insn "mulsf_68881"
2884 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2885 (mult:SF (match_operand:SF 1 "general_operand" "%0")
2886 (match_operand:SF 2 "general_operand" "fdmF")))]
2889 if (FP_REG_P (operands[2]))
2890 return (TARGET_68040_ONLY
2892 : "fsglmul%.x %2,%0");
2893 return (TARGET_68040_ONLY
2895 : "fsglmul%.s %f2,%0");
2898 (define_insn "mulxf3_68881"
2899 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
2900 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
2901 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
2904 return "fmul%.x %f2,%0";
2907 (define_insn "fmul<mode>3_cf"
2908 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2909 (mult:FP (match_operand:FP 1 "general_operand" "%0")
2910 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
2911 "TARGET_COLDFIRE_FPU"
2913 if (FP_REG_P (operands[2]))
2914 return "f<FP:prec>mul%.d %2,%0";
2915 return "f<FP:prec>mul%.<FP:prec> %2,%0";
2918 ;; divide instructions
2920 (define_expand "div<mode>3"
2921 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2922 (div:FP (match_operand:FP 1 "general_operand" "")
2923 (match_operand:FP 2 "general_operand" "")))]
2927 (define_insn "div<mode>3_floatsi_68881"
2928 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2929 (div:FP (match_operand:FP 1 "general_operand" "0")
2930 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2933 return TARGET_68040_ONLY
2934 ? "f<FP:round>div%.l %2,%0"
2935 : "f<FP:round_mul>div%.l %2,%0";
2938 (define_insn "div<mode>3_floathi_68881"
2939 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2940 (div:FP (match_operand:FP 1 "general_operand" "0")
2941 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2944 return TARGET_68040_ONLY
2945 ? "f<FP:round>div%.w %2,%0"
2946 : "f<FP:round_mul>div%.w %2,%0";
2949 (define_insn "div<mode>3_floatqi_68881"
2950 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2951 (div:FP (match_operand:FP 1 "general_operand" "0")
2952 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2955 return TARGET_68040_ONLY
2956 ? "f<FP:round>div%.b %2,%0"
2957 : "f<FP:round_mul>div%.b %2,%0";
2960 (define_insn "div<mode>3_68881"
2961 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2962 (div:FP (match_operand:FP 1 "general_operand" "0")
2963 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2966 if (FP_REG_P (operands[2]))
2967 return (TARGET_68040_ONLY
2968 ? "f<FP:round>div%.x %2,%0"
2969 : "f<FP:round_mul>div%.x %2,%0");
2970 return (TARGET_68040_ONLY
2971 ? "f<FP:round>div%.<FP:prec> %f2,%0"
2972 : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
2975 (define_insn "div<mode>3_cf"
2976 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2977 (div:FP (match_operand:FP 1 "general_operand" "0")
2978 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
2979 "TARGET_COLDFIRE_FPU"
2981 if (FP_REG_P (operands[2]))
2982 return "f<FP:prec>div%.d %2,%0";
2983 return "f<FP:prec>div%.<FP:prec> %2,%0";
2986 ;; Remainder instructions.
2988 (define_expand "divmodsi4"
2990 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2991 (div:SI (match_operand:SI 1 "general_operand" "")
2992 (match_operand:SI 2 "general_src_operand" "")))
2993 (set (match_operand:SI 3 "nonimmediate_operand" "")
2994 (mod:SI (match_dup 1) (match_dup 2)))])]
2995 "TARGET_68020 || TARGET_CF_HWDIV"
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" "d<Q>U")))
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";
3008 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3009 return "rems%.l %2,%3:%0";
3011 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
3015 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3016 (div:SI (match_operand:SI 1 "general_operand" "0")
3017 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3018 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3019 (mod:SI (match_dup 1) (match_dup 2)))]
3022 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3023 return "divs%.l %2,%0";
3025 return "divsl%.l %2,%3:%0";
3028 (define_expand "udivmodsi4"
3030 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3031 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3032 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3033 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3034 (umod:SI (match_dup 1) (match_dup 2)))])]
3035 "TARGET_68020 || TARGET_CF_HWDIV"
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" "d<Q>U")))
3042 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3043 (umod:SI (match_dup 1) (match_dup 2)))]
3046 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3047 return "divu%.l %2,%0";
3048 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3049 return "remu%.l %2,%3:%0";
3051 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3055 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3056 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3057 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3058 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3059 (umod:SI (match_dup 1) (match_dup 2)))]
3060 "TARGET_68020 && !TARGET_COLDFIRE"
3062 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3063 return "divu%.l %2,%0";
3065 return "divul%.l %2,%3:%0";
3068 (define_insn "divmodhi4"
3069 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3070 (div:HI (match_operand:HI 1 "general_operand" "0")
3071 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3072 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3073 (mod:HI (match_dup 1) (match_dup 2)))]
3074 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3076 output_asm_insn (MOTOROLA ?
3077 "ext%.l %0\;divs%.w %2,%0" :
3078 "extl %0\;divs %2,%0",
3080 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3083 return "move%.l %0,%3\;swap %3";
3089 (define_insn "udivmodhi4"
3090 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3091 (udiv:HI (match_operand:HI 1 "general_operand" "0")
3092 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3093 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3094 (umod:HI (match_dup 1) (match_dup 2)))]
3095 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3098 output_asm_insn (MOTOROLA ?
3099 "mvz%.w %0,%0\;divu%.w %2,%0" :
3100 "mvz%.w %0,%0\;divu %2,%0",
3103 output_asm_insn (MOTOROLA ?
3104 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3105 "and%.l #0xFFFF,%0\;divu %2,%0",
3108 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3111 return "move%.l %0,%3\;swap %3";
3117 ;; logical-and instructions
3119 ;; "anddi3" is mainly here to help combine().
3120 (define_insn "anddi3"
3121 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3122 (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3123 (match_operand:DI 2 "general_operand" "dn,don")))]
3127 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3128 if (CONSTANT_P (operands[2]))
3132 split_double (operands[2], &hi, &lo);
3134 switch (INTVAL (hi))
3137 output_asm_insn ("clr%.l %0", operands);
3145 xoperands[0] = operands[0];
3147 output_asm_insn (output_andsi3 (xoperands), xoperands);
3150 if (GET_CODE (operands[0]) == REG)
3151 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3153 operands[0] = adjust_address (operands[0], SImode, 4);
3154 switch (INTVAL (lo))
3157 output_asm_insn ("clr%.l %0", operands);
3165 xoperands[0] = operands[0];
3167 output_asm_insn (output_andsi3 (xoperands), xoperands);
3172 if (GET_CODE (operands[0]) != REG)
3174 operands[1] = adjust_address (operands[0], SImode, 4);
3175 return "and%.l %2,%0\;and%.l %R2,%1";
3177 if (GET_CODE (operands[2]) != REG)
3179 operands[1] = adjust_address (operands[2], SImode, 4);
3180 return "and%.l %2,%0\;and%.l %1,%R0";
3182 return "and%.l %2,%0\;and%.l %R2,%R0";
3185 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3186 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3187 ;; can't allocate pseudos into it.
3189 (define_expand "andsi3"
3190 [(set (match_operand:SI 0 "not_sp_operand" "")
3191 (and:SI (match_operand:SI 1 "general_operand" "")
3192 (match_operand:SI 2 "general_src_operand" "")))]
3196 ;; produced by split operations after reload finished
3197 (define_insn "*andsi3_split"
3198 [(set (match_operand:SI 0 "register_operand" "=d")
3199 (and:SI (match_operand:SI 1 "register_operand" "0")
3200 (match_operand:SI 2 "const_int_operand" "i")))]
3201 "reload_completed && !TARGET_COLDFIRE"
3203 return output_andsi3 (operands);
3206 (define_insn "andsi3_internal"
3207 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3208 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3209 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3212 return output_andsi3 (operands);
3215 (define_insn "andsi3_5200"
3216 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3217 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3218 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3221 if (TARGET_CFV4 && DATA_REG_P (operands[0])
3222 && GET_CODE (operands[2]) == CONST_INT)
3224 if (INTVAL (operands[2]) == 0x000000ff)
3225 return "mvz%.b %0,%0";
3226 else if (INTVAL (operands[2]) == 0x0000ffff)
3227 return "mvz%.w %0,%0";
3229 return output_andsi3 (operands);
3232 (define_insn "andhi3"
3233 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3234 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3235 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3240 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3241 (and:HI (match_dup 0)
3242 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3247 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3248 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3253 (define_insn "andqi3"
3254 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3255 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3256 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3261 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3262 (and:QI (match_dup 0)
3263 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3268 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3269 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3274 ;; inclusive-or instructions
3276 (define_insn "iordi_zext"
3277 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3278 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3279 (match_operand:DI 2 "general_operand" "0,0")))]
3285 if (GET_CODE (operands[0]) == REG)
3286 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3288 operands[0] = adjust_address (operands[0], SImode, 4);
3289 if (GET_MODE (operands[1]) == SImode)
3290 return "or%.l %1,%0";
3291 byte_mode = (GET_MODE (operands[1]) == QImode);
3292 if (GET_CODE (operands[0]) == MEM)
3293 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3296 return "or%.b %1,%0";
3298 return "or%.w %1,%0";
3301 ;; "iordi3" is mainly here to help combine().
3302 (define_insn "iordi3"
3303 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3304 (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3305 (match_operand:DI 2 "general_operand" "dn,don")))]
3309 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3310 if (CONSTANT_P (operands[2]))
3314 split_double (operands[2], &hi, &lo);
3316 switch (INTVAL (hi))
3321 /* FIXME : a scratch register would be welcome here if operand[0]
3322 is not a register */
3323 output_asm_insn ("move%.l #-1,%0", operands);
3329 xoperands[0] = operands[0];
3331 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3334 if (GET_CODE (operands[0]) == REG)
3335 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3337 operands[0] = adjust_address (operands[0], SImode, 4);
3338 switch (INTVAL (lo))
3343 /* FIXME : a scratch register would be welcome here if operand[0]
3344 is not a register */
3345 output_asm_insn ("move%.l #-1,%0", operands);
3351 xoperands[0] = operands[0];
3353 output_asm_insn (output_iorsi3 (xoperands), xoperands);
3358 if (GET_CODE (operands[0]) != REG)
3360 operands[1] = adjust_address (operands[0], SImode, 4);
3361 return "or%.l %2,%0\;or%.l %R2,%1";
3363 if (GET_CODE (operands[2]) != REG)
3365 operands[1] = adjust_address (operands[2], SImode, 4);
3366 return "or%.l %2,%0\;or%.l %1,%R0";
3368 return "or%.l %2,%0\;or%.l %R2,%R0";
3371 (define_expand "iorsi3"
3372 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3373 (ior:SI (match_operand:SI 1 "general_operand" "")
3374 (match_operand:SI 2 "general_src_operand" "")))]
3378 (define_insn "iorsi3_internal"
3379 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3380 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3381 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3384 return output_iorsi3 (operands);
3387 (define_insn "iorsi3_5200"
3388 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3389 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3390 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3393 return output_iorsi3 (operands);
3396 (define_insn "iorhi3"
3397 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3398 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3399 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3404 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3405 (ior:HI (match_dup 0)
3406 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3411 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3412 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3417 (define_insn "iorqi3"
3418 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3419 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3420 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3425 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3426 (ior:QI (match_dup 0)
3427 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3432 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3433 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3438 ;; On all 68k models, this makes faster code in a special case.
3439 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3441 (define_insn "iorsi_zexthi_ashl16"
3442 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3443 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3444 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3449 if (GET_CODE (operands[2]) != REG)
3450 operands[2] = adjust_address (operands[2], HImode, 2);
3451 if (GET_CODE (operands[2]) != REG
3452 || REGNO (operands[2]) != REGNO (operands[0]))
3453 output_asm_insn ("move%.w %2,%0", operands);
3454 return "swap %0\;mov%.w %1,%0";
3457 (define_insn "iorsi_zext"
3458 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3459 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3460 (match_operand:SI 2 "general_operand" "0,0")))]
3466 byte_mode = (GET_MODE (operands[1]) == QImode);
3467 if (GET_CODE (operands[0]) == MEM)
3468 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3471 return "or%.b %1,%0";
3473 return "or%.w %1,%0";
3478 ;; "xordi3" is mainly here to help combine().
3479 (define_insn "xordi3"
3480 [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3481 (xor:DI (match_operand:DI 1 "general_operand" "%0")
3482 (match_operand:DI 2 "general_operand" "dn")))]
3486 /* We can get CONST_DOUBLE, but also const1_rtx etc. */
3488 if (CONSTANT_P (operands[2]))
3492 split_double (operands[2], &hi, &lo);
3494 switch (INTVAL (hi))
3499 output_asm_insn ("not%.l %0", operands);
3502 /* FIXME : a scratch register would be welcome here if
3503 -128 <= INTVAL (hi) < -1 */
3507 xoperands[0] = operands[0];
3509 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3512 if (GET_CODE (operands[0]) == REG)
3513 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3515 operands[0] = adjust_address (operands[0], SImode, 4);
3516 switch (INTVAL (lo))
3521 output_asm_insn ("not%.l %0", operands);
3524 /* FIXME : a scratch register would be welcome here if
3525 -128 <= INTVAL (lo) < -1 */
3527 /* FIXME : this should be merged with xorsi3 */
3531 xoperands[0] = operands[0];
3533 output_asm_insn (output_xorsi3 (xoperands), xoperands);
3538 if (GET_CODE (operands[0]) != REG)
3540 operands[1] = adjust_address (operands[0], SImode, 4);
3541 return "eor%.l %2,%0\;eor%.l %R2,%1";
3543 if (GET_CODE (operands[2]) != REG)
3545 operands[1] = adjust_address (operands[2], SImode, 4);
3546 return "eor%.l %2,%0\;eor%.l %1,%R0";
3548 return "eor%.l %2,%0\;eor%.l %R2,%R0";
3551 (define_expand "xorsi3"
3552 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3553 (xor:SI (match_operand:SI 1 "general_operand" "")
3554 (match_operand:SI 2 "general_operand" "")))]
3558 (define_insn "xorsi3_internal"
3559 [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3560 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3561 (match_operand:SI 2 "general_operand" "di,dKT")))]
3565 return output_xorsi3 (operands);
3568 (define_insn "xorsi3_5200"
3569 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3570 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3571 (match_operand:SI 2 "general_operand" "d,Ks")))]
3574 return output_xorsi3 (operands);
3577 (define_insn "xorhi3"
3578 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3579 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3580 (match_operand:HI 2 "general_operand" "dn")))]
3585 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3586 (xor:HI (match_dup 0)
3587 (match_operand:HI 1 "general_operand" "dn")))]
3592 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3593 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3598 (define_insn "xorqi3"
3599 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3600 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3601 (match_operand:QI 2 "general_operand" "dn")))]
3606 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3607 (xor:QI (match_dup 0)
3608 (match_operand:QI 1 "general_operand" "dn")))]
3613 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3614 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3619 ;; negation instructions
3621 (define_expand "negdi2"
3622 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3623 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3626 if (TARGET_COLDFIRE)
3627 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3629 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3633 (define_insn "negdi2_internal"
3634 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3635 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3638 if (which_alternative == 0)
3639 return "neg%.l %0\;negx%.l %0";
3640 if (GET_CODE (operands[0]) == REG)
3641 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3643 operands[1] = adjust_address (operands[0], SImode, 4);
3644 if (ADDRESS_REG_P (operands[0]))
3645 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3647 return "neg%.l %1\;negx%.l %0";
3650 (define_insn "negdi2_5200"
3651 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3652 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3655 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3656 return "neg%.l %1\;negx%.l %0";
3659 (define_expand "negsi2"
3660 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3661 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3664 if (TARGET_COLDFIRE)
3665 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3667 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3671 (define_insn "negsi2_internal"
3672 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3673 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3677 (define_insn "negsi2_5200"
3678 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3679 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3683 (define_insn "neghi2"
3684 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3685 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3690 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3691 (neg:HI (match_dup 0)))]
3695 (define_insn "negqi2"
3696 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3697 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3702 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3703 (neg:QI (match_dup 0)))]
3707 ;; If using software floating point, just flip the sign bit.
3709 (define_expand "negsf2"
3710 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3711 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3714 if (!TARGET_HARD_FLOAT)
3719 target = operand_subword_force (operands[0], 0, SFmode);
3720 result = expand_binop (SImode, xor_optab,
3721 operand_subword_force (operands[1], 0, SFmode),
3722 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3723 gcc_assert (result);
3725 if (result != target)
3726 emit_move_insn (result, target);
3728 /* Make a place for REG_EQUAL. */
3729 emit_move_insn (operands[0], operands[0]);
3734 (define_expand "negdf2"
3735 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3736 (neg:DF (match_operand:DF 1 "general_operand" "")))]
3739 if (!TARGET_HARD_FLOAT)
3746 target = operand_subword (operands[0], 0, 1, DFmode);
3747 result = expand_binop (SImode, xor_optab,
3748 operand_subword_force (operands[1], 0, DFmode),
3749 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3750 gcc_assert (result);
3752 if (result != target)
3753 emit_move_insn (result, target);
3755 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3756 operand_subword_force (operands[1], 1, DFmode));
3758 insns = get_insns ();
3761 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3766 (define_expand "negxf2"
3767 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3768 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
3778 target = operand_subword (operands[0], 0, 1, XFmode);
3779 result = expand_binop (SImode, xor_optab,
3780 operand_subword_force (operands[1], 0, XFmode),
3781 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3782 gcc_assert (result);
3784 if (result != target)
3785 emit_move_insn (result, target);
3787 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
3788 operand_subword_force (operands[1], 1, XFmode));
3789 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
3790 operand_subword_force (operands[1], 2, XFmode));
3792 insns = get_insns ();
3795 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3800 (define_insn "neg<mode>2_68881"
3801 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3802 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
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:round>neg%.x %1,%0";
3812 return "f<FP:round>neg%.<FP:prec> %f1,%0";
3815 (define_insn "neg<mode>2_cf"
3816 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3817 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
3818 "TARGET_COLDFIRE_FPU"
3820 if (DATA_REG_P (operands[0]))
3822 operands[1] = GEN_INT (31);
3823 return "bchg %1,%0";
3825 if (FP_REG_P (operands[1]))
3826 return "f<FP:prec>neg%.d %1,%0";
3827 return "f<FP:prec>neg%.<FP:prec> %1,%0";
3830 ;; Sqrt instruction for the 68881
3832 (define_expand "sqrt<mode>2"
3833 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3834 (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
3838 (define_insn "sqrt<mode>2_68881"
3839 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3840 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
3843 if (FP_REG_P (operands[1]))
3844 return "f<FP:round>sqrt%.x %1,%0";
3845 return "f<FP:round>sqrt%.<FP:prec> %1,%0";
3848 (define_insn "sqrt<mode>2_cf"
3849 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3850 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
3851 "TARGET_COLDFIRE_FPU"
3853 if (FP_REG_P (operands[1]))
3854 return "f<FP:prec>sqrt%.d %1,%0";
3855 return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
3857 ;; Absolute value instructions
3858 ;; If using software floating point, just zero the sign bit.
3860 (define_expand "abssf2"
3861 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3862 (abs:SF (match_operand:SF 1 "general_operand" "")))]
3865 if (!TARGET_HARD_FLOAT)
3870 target = operand_subword_force (operands[0], 0, SFmode);
3871 result = expand_binop (SImode, and_optab,
3872 operand_subword_force (operands[1], 0, SFmode),
3873 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3874 gcc_assert (result);
3876 if (result != target)
3877 emit_move_insn (result, target);
3879 /* Make a place for REG_EQUAL. */
3880 emit_move_insn (operands[0], operands[0]);
3885 (define_expand "absdf2"
3886 [(set (match_operand:DF 0 "nonimmediate_operand" "")
3887 (abs:DF (match_operand:DF 1 "general_operand" "")))]
3890 if (!TARGET_HARD_FLOAT)
3897 target = operand_subword (operands[0], 0, 1, DFmode);
3898 result = expand_binop (SImode, and_optab,
3899 operand_subword_force (operands[1], 0, DFmode),
3900 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3901 gcc_assert (result);
3903 if (result != target)
3904 emit_move_insn (result, target);
3906 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3907 operand_subword_force (operands[1], 1, DFmode));
3909 insns = get_insns ();
3912 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3917 (define_expand "absxf2"
3918 [(set (match_operand:XF 0 "nonimmediate_operand" "")
3919 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
3929 target = operand_subword (operands[0], 0, 1, XFmode);
3930 result = expand_binop (SImode, and_optab,
3931 operand_subword_force (operands[1], 0, XFmode),
3932 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3933 gcc_assert (result);
3935 if (result != target)
3936 emit_move_insn (result, target);
3938 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
3939 operand_subword_force (operands[1], 1, XFmode));
3940 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
3941 operand_subword_force (operands[1], 2, XFmode));
3943 insns = get_insns ();
3946 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3951 (define_insn "abs<mode>2_68881"
3952 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3953 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
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:round>abs%.x %1,%0";
3963 return "f<FP:round>abs%.<FP:prec> %f1,%0";
3966 (define_insn "abs<mode>2_cf"
3967 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3968 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
3969 "TARGET_COLDFIRE_FPU"
3971 if (DATA_REG_P (operands[0]))
3973 operands[1] = GEN_INT (31);
3974 return "bclr %1,%0";
3976 if (FP_REG_P (operands[1]))
3977 return "f<FP:prec>abs%.d %1,%0";
3978 return "f<FP:prec>abs%.<FP:prec> %1,%0";
3981 ;; one complement instructions
3983 ;; "one_cmpldi2" is mainly here to help combine().
3984 (define_insn "one_cmpldi2"
3985 [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
3986 (not:DI (match_operand:DI 1 "general_operand" "0")))]
3990 if (GET_CODE (operands[0]) == REG)
3991 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3992 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
3993 || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3994 operands[1] = operands[0];
3996 operands[1] = adjust_address (operands[0], SImode, 4);
3997 return "not%.l %1\;not%.l %0";
4000 (define_expand "one_cmplsi2"
4001 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4002 (not:SI (match_operand:SI 1 "general_operand" "")))]
4005 if (TARGET_COLDFIRE)
4006 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
4008 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
4012 (define_insn "one_cmplsi2_internal"
4013 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4014 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4018 (define_insn "one_cmplsi2_5200"
4019 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4020 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4024 (define_insn "one_cmplhi2"
4025 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4026 (not:HI (match_operand:HI 1 "general_operand" "0")))]
4031 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4032 (not:HI (match_dup 0)))]
4036 (define_insn "one_cmplqi2"
4037 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4038 (not:QI (match_operand:QI 1 "general_operand" "0")))]
4043 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4044 (not:QI (match_dup 0)))]
4048 ;; arithmetic shift instructions
4049 ;; We don't need the shift memory by 1 bit instruction
4051 (define_insn "ashldi_extsi"
4052 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4054 (match_operator:DI 2 "extend_operator"
4055 [(match_operand:SI 1 "general_operand" "rm")])
4060 if (GET_CODE (operands[0]) == REG)
4061 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4063 operands[2] = adjust_address (operands[0], SImode, 4);
4064 if (ADDRESS_REG_P (operands[0]))
4065 return "move%.l %1,%0\;sub%.l %2,%2";
4067 return "move%.l %1,%0\;clr%.l %2";
4070 (define_insn "ashldi_sexthi"
4071 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
4072 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
4074 (clobber (match_scratch:SI 2 "=a,X"))]
4078 if (GET_CODE (operands[0]) == MEM)
4080 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4081 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
4082 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4083 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
4086 operands[3] = adjust_address (operands[0], SImode, 4);
4087 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
4090 else if (DATA_REG_P (operands[0]))
4091 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
4093 return "move%.w %1,%0\;sub%.l %R0,%R0";
4096 (define_insn "ashldi_const32"
4097 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
4098 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
4103 if (GET_CODE (operands[1]) == REG)
4104 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4106 operands[3] = adjust_address (operands[1], SImode, 4);
4107 if (GET_CODE (operands[0]) == REG)
4108 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4109 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4110 return "clr%.l %0\;move%.l %3,%0";
4111 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4112 return "move%.l %3,%0\;clr%.l %0";
4114 operands[2] = adjust_address (operands[0], SImode, 4);
4115 if (ADDRESS_REG_P (operands[2]))
4116 return "move%.l %3,%0\;sub%.l %2,%2";
4118 return "move%.l %3,%0\;clr%.l %2";
4121 ;; The predicate below must be general_operand, because ashldi3 allows that
4122 (define_insn "ashldi_const"
4123 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4124 (ashift:DI (match_operand:DI 1 "general_operand" "0")
4125 (match_operand 2 "const_int_operand" "n")))]
4127 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4128 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4129 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4131 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4132 if (INTVAL (operands[2]) == 1)
4133 return "add%.l %1,%1\;addx%.l %0,%0";
4134 else if (INTVAL (operands[2]) == 8)
4135 return "rol%.l #8,%1\;rol%.l #8,%0\;move%.b %1,%0\;clr%.b %1";
4136 else if (INTVAL (operands[2]) == 16)
4137 return "swap %1\;swap %0\;move%.w %1,%0\;clr%.w %1";
4138 else if (INTVAL (operands[2]) == 48)
4139 return "mov%.l %1,%0\;swap %0\;clr%.l %1\;clr%.w %0";
4140 else if (INTVAL (operands[2]) == 2)
4141 return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
4142 else if (INTVAL (operands[2]) == 3)
4143 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";
4144 else /* 32 < INTVAL (operands[2]) <= 63 */
4146 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4147 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asl%.l %2,%1" :
4148 "moveq %2,%0\;asl%.l %0,%1", operands);
4149 return "mov%.l %1,%0\;moveq #0,%1";
4153 (define_expand "ashldi3"
4154 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4155 (ashift:DI (match_operand:DI 1 "general_operand" "")
4156 (match_operand 2 "const_int_operand" "")))]
4160 /* ??? This is a named pattern like this is not allowed to FAIL based
4162 if (GET_CODE (operands[2]) != CONST_INT
4163 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4164 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4165 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4169 ;; On most 68k models, this makes faster code in a special case.
4171 (define_insn "ashlsi_16"
4172 [(set (match_operand:SI 0 "register_operand" "=d")
4173 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4178 return "swap %0\;clr%.w %0";
4181 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
4182 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4184 ;; On the 68000, this makes faster code in a special case.
4186 (define_insn "ashlsi_17_24"
4187 [(set (match_operand:SI 0 "register_operand" "=d")
4188 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4189 (match_operand:SI 2 "const_int_operand" "n")))]
4191 && INTVAL (operands[2]) > 16
4192 && INTVAL (operands[2]) <= 24"
4196 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4197 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4200 (define_insn "ashlsi3"
4201 [(set (match_operand:SI 0 "register_operand" "=d")
4202 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4203 (match_operand:SI 2 "general_operand" "dI")))]
4206 if (operands[2] == const1_rtx)
4208 cc_status.flags = CC_NO_OVERFLOW;
4209 return "add%.l %0,%0";
4211 return "lsl%.l %2,%0";
4214 (define_insn "ashlhi3"
4215 [(set (match_operand:HI 0 "register_operand" "=d")
4216 (ashift:HI (match_operand:HI 1 "register_operand" "0")
4217 (match_operand:HI 2 "general_operand" "dI")))]
4222 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4223 (ashift:HI (match_dup 0)
4224 (match_operand:HI 1 "general_operand" "dI")))]
4228 (define_insn "ashlqi3"
4229 [(set (match_operand:QI 0 "register_operand" "=d")
4230 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4231 (match_operand:QI 2 "general_operand" "dI")))]
4236 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4237 (ashift:QI (match_dup 0)
4238 (match_operand:QI 1 "general_operand" "dI")))]
4242 ;; On most 68k models, this makes faster code in a special case.
4244 (define_insn "ashrsi_16"
4245 [(set (match_operand:SI 0 "register_operand" "=d")
4246 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4249 "swap %0\;ext%.l %0")
4251 ;; On the 68000, this makes faster code in a special case.
4254 [(set (match_operand:SI 0 "register_operand" "=d")
4255 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4256 (match_operand:SI 2 "const_int_operand" "n")))]
4258 && INTVAL (operands[2]) > 16
4259 && INTVAL (operands[2]) <= 24"
4261 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4262 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4265 (define_insn "subreghi1ashrdi_const32"
4266 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4267 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4268 (const_int 32)) 6))]
4271 if (GET_CODE (operands[1]) != REG)
4272 operands[1] = adjust_address (operands[1], HImode, 2);
4273 return "move%.w %1,%0";
4276 (define_insn "subregsi1ashrdi_const32"
4277 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4278 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4279 (const_int 32)) 4))]
4282 return "move%.l %1,%0";
4285 (define_insn "ashrdi_const32"
4286 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o,<")
4287 (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4289 (clobber (match_scratch:SI 2 "=X,d,d"))]
4293 if (which_alternative == 0)
4295 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4297 return "move%.l %1,%2\;smi %0\;extb%.l %0";
4299 return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
4303 if (which_alternative == 2)
4304 operands[3] = operands[0];
4305 else if (which_alternative == 1)
4306 operands[3] = adjust_address (operands[0], SImode, 4);
4308 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4310 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4314 ;; The predicate below must be general_operand, because ashrdi3 allows that
4315 (define_insn "ashrdi_const"
4316 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4317 (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
4318 (match_operand 2 "const_int_operand" "n")))
4319 (clobber (match_scratch:SI 3 "=X"))]
4321 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4322 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4323 || INTVAL (operands[2]) == 31
4324 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4326 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4327 if (INTVAL (operands[2]) == 63)
4328 return "add%.l %0,%0\;subx%.l %0,%0\;move%.l %0,%1";
4330 if (INTVAL (operands[2]) == 1)
4331 return "asr%.l #1,%0\;roxr%.l #1,%1";
4332 else if (INTVAL (operands[2]) == 8)
4333 return "move%.b %0,%1\;asr%.l #8,%0\;ror%.l #8,%1";
4334 else if (INTVAL (operands[2]) == 16)
4335 return "move%.w %0,%1\;swap %0\;ext%.l %0\;swap %1";
4336 else if (INTVAL (operands[2]) == 48)
4337 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4338 else if (INTVAL (operands[2]) == 31)
4339 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4340 else if (INTVAL (operands[2]) == 2)
4341 return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4342 else if (INTVAL (operands[2]) == 3)
4343 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";
4344 else /* 32 < INTVAL (operands[2]) <= 63 */
4346 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4347 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4348 "moveq %2,%1\;asr%.l %1,%0", operands);
4349 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4350 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4351 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4355 (define_expand "ashrdi3"
4356 [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
4357 (ashiftrt:DI (match_operand:DI 1 "general_operand" "")
4358 (match_operand 2 "const_int_operand" "")))
4359 (clobber (match_scratch:SI 3 ""))])]
4363 /* ??? This is a named pattern like this is not allowed to FAIL based
4365 if (GET_CODE (operands[2]) != CONST_INT
4366 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4367 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4368 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4370 operands[3] = gen_rtx_SCRATCH (SImode);
4373 ;; On all 68k models, this makes faster code in a special case.
4375 (define_insn "ashrsi_31"
4376 [(set (match_operand:SI 0 "register_operand" "=d")
4377 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4381 return "add%.l %0,%0\;subx%.l %0,%0";
4384 (define_insn "ashrsi3"
4385 [(set (match_operand:SI 0 "register_operand" "=d")
4386 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4387 (match_operand:SI 2 "general_operand" "dI")))]
4391 (define_insn "ashrhi3"
4392 [(set (match_operand:HI 0 "register_operand" "=d")
4393 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4394 (match_operand:HI 2 "general_operand" "dI")))]
4399 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4400 (ashiftrt:HI (match_dup 0)
4401 (match_operand:HI 1 "general_operand" "dI")))]
4405 (define_insn "ashrqi3"
4406 [(set (match_operand:QI 0 "register_operand" "=d")
4407 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4408 (match_operand:QI 2 "general_operand" "dI")))]
4413 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4414 (ashiftrt:QI (match_dup 0)
4415 (match_operand:QI 1 "general_operand" "dI")))]
4419 ;; logical shift instructions
4421 ;; commented out because of reload problems in 950612-1.c
4424 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4425 ;; (const_int 32)) 4))
4426 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4427 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4428 ;; (const_int 32)) 4))]
4431 ;; return "move%.l %0,%1";
4436 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4437 ;; (const_int 32)) 0))
4438 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4439 ;; (lshiftrt:DI (match_dup 0)
4440 ;; (const_int 32)))]
4443 ;; if (GET_CODE (operands[1]) == REG)
4444 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4446 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4447 ;; return "move%.l %0,%2\;clr%.l %1";
4450 (define_insn "subreg1lshrdi_const32"
4451 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4452 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4453 (const_int 32)) 4))]
4456 return "move%.l %1,%0";
4459 (define_insn "lshrdi_const32"
4460 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro,<,>")
4461 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4466 if (which_alternative == 1)
4467 return "move%.l %1,%0\;clr%.l %0";
4468 if (which_alternative == 2)
4469 return "clr%.l %0\;move%.l %1,%0";
4470 if (GET_CODE (operands[0]) == REG)
4471 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4473 operands[2] = adjust_address (operands[0], SImode, 4);
4474 if (GET_CODE (operands[1]) == REG)
4475 operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4477 operands[3] = adjust_address (operands[1], SImode, 4);
4478 if (ADDRESS_REG_P (operands[0]))
4479 return "move%.l %1,%2\;sub%.l %0,%0";
4481 return "move%.l %1,%2\;clr%.l %0";
4484 ;; The predicate below must be general_operand, because lshrdi3 allows that
4485 (define_insn "lshrdi_const"
4486 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4487 (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
4488 (match_operand 2 "const_int_operand" "n")))]
4490 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4491 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4492 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4494 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4495 if (INTVAL (operands[2]) == 63)
4496 return "add%.l %0,%0\;clr%.l %0\;clr%.l %1\;addx%.l %1,%1";
4498 if (INTVAL (operands[2]) == 1)
4499 return "lsr%.l #1,%0\;roxr%.l #1,%1";
4500 else if (INTVAL (operands[2]) == 8)
4501 return "move%.b %0,%1\;lsr%.l #8,%0\;ror%.l #8,%1";
4502 else if (INTVAL (operands[2]) == 16)
4503 return "move%.w %0,%1\;clr%.w %0\;swap %1\;swap %0";
4504 else if (INTVAL (operands[2]) == 48)
4505 return "move%.l %0,%1\;clr%.w %1\;clr%.l %0\;swap %1";
4506 else if (INTVAL (operands[2]) == 2)
4507 return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4508 else if (INTVAL (operands[2]) == 3)
4509 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";
4510 else /* 32 < INTVAL (operands[2]) <= 63 */
4512 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4513 output_asm_insn (INTVAL (operands[2]) <= 8 ? "lsr%.l %2,%0" :
4514 "moveq %2,%1\;lsr%.l %1,%0", operands);
4515 return "mov%.l %0,%1\;moveq #0,%0";
4519 (define_expand "lshrdi3"
4520 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4521 (lshiftrt:DI (match_operand:DI 1 "general_operand" "")
4522 (match_operand 2 "const_int_operand" "")))]
4525 /* ??? This is a named pattern like this is not allowed to FAIL based
4527 if (GET_CODE (operands[2]) != CONST_INT
4528 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4529 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4530 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4534 ;; On all 68k models, this makes faster code in a special case.
4536 (define_insn "lshrsi_31"
4537 [(set (match_operand:SI 0 "register_operand" "=d")
4538 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4542 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
4545 ;; On most 68k models, this makes faster code in a special case.
4547 (define_insn "lshrsi_16"
4548 [(set (match_operand:SI 0 "register_operand" "=d")
4549 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4554 return "clr%.w %0\;swap %0";
4557 ;; On the 68000, this makes faster code in a special case.
4559 (define_insn "lshrsi_17_24"
4560 [(set (match_operand:SI 0 "register_operand" "=d")
4561 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4562 (match_operand:SI 2 "const_int_operand" "n")))]
4564 && INTVAL (operands[2]) > 16
4565 && INTVAL (operands[2]) <= 24"
4567 /* I think lsr%.w sets the CC properly. */
4568 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4569 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
4572 (define_insn "lshrsi3"
4573 [(set (match_operand:SI 0 "register_operand" "=d")
4574 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4575 (match_operand:SI 2 "general_operand" "dI")))]
4579 (define_insn "lshrhi3"
4580 [(set (match_operand:HI 0 "register_operand" "=d")
4581 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
4582 (match_operand:HI 2 "general_operand" "dI")))]
4587 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4588 (lshiftrt:HI (match_dup 0)
4589 (match_operand:HI 1 "general_operand" "dI")))]
4593 (define_insn "lshrqi3"
4594 [(set (match_operand:QI 0 "register_operand" "=d")
4595 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
4596 (match_operand:QI 2 "general_operand" "dI")))]
4601 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4602 (lshiftrt:QI (match_dup 0)
4603 (match_operand:QI 1 "general_operand" "dI")))]
4607 ;; rotate instructions
4609 (define_insn "rotlsi3"
4610 [(set (match_operand:SI 0 "register_operand" "=d")
4611 (rotate:SI (match_operand:SI 1 "register_operand" "0")
4612 (match_operand:SI 2 "general_operand" "dINO")))]
4615 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
4617 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
4619 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4620 return "ror%.l %2,%0";
4623 return "rol%.l %2,%0";
4626 (define_insn "rotlhi3"
4627 [(set (match_operand:HI 0 "register_operand" "=d")
4628 (rotate:HI (match_operand:HI 1 "register_operand" "0")
4629 (match_operand:HI 2 "general_operand" "dIP")))]
4632 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4634 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4635 return "ror%.w %2,%0";
4638 return "rol%.w %2,%0";
4642 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4643 (rotate:HI (match_dup 0)
4644 (match_operand:HI 1 "general_operand" "dIP")))]
4647 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4649 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4650 return "ror%.w %2,%0";
4653 return "rol%.w %2,%0";
4656 (define_insn "rotlqi3"
4657 [(set (match_operand:QI 0 "register_operand" "=d")
4658 (rotate:QI (match_operand:QI 1 "register_operand" "0")
4659 (match_operand:QI 2 "general_operand" "dI")))]
4662 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4664 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4665 return "ror%.b %2,%0";
4668 return "rol%.b %2,%0";
4672 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4673 (rotate:QI (match_dup 0)
4674 (match_operand:QI 1 "general_operand" "dI")))]
4677 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4679 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4680 return "ror%.b %2,%0";
4683 return "rol%.b %2,%0";
4686 (define_insn "rotrsi3"
4687 [(set (match_operand:SI 0 "register_operand" "=d")
4688 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
4689 (match_operand:SI 2 "general_operand" "dI")))]
4693 (define_insn "rotrhi3"
4694 [(set (match_operand:HI 0 "register_operand" "=d")
4695 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
4696 (match_operand:HI 2 "general_operand" "dI")))]
4701 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4702 (rotatert:HI (match_dup 0)
4703 (match_operand:HI 1 "general_operand" "dI")))]
4707 (define_insn "rotrqi3"
4708 [(set (match_operand:QI 0 "register_operand" "=d")
4709 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
4710 (match_operand:QI 2 "general_operand" "dI")))]
4715 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4716 (rotatert:QI (match_dup 0)
4717 (match_operand:QI 1 "general_operand" "dI")))]
4722 ;; Bit set/clear in memory byte.
4724 ;; set bit, bit number is int
4725 (define_insn "bsetmemqi"
4726 [(set (match_operand:QI 0 "memory_operand" "+m")
4727 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4728 (match_operand:SI 1 "general_operand" "d")) 3)
4733 return "bset %1,%0";
4736 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
4738 [(set (match_operand:QI 0 "memory_operand" "+m")
4739 (ior:QI (subreg:QI (ashift:SI (const_int 1)
4740 (match_operator:SI 2 "extend_operator"
4741 [(match_operand 1 "general_operand" "d")])) 3)
4746 return "bset %1,%0";
4749 ;; clear bit, bit number is int
4750 (define_insn "bclrmemqi"
4751 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4753 (minus:SI (const_int 7)
4754 (match_operand:SI 1 "general_operand" "d")))
4759 return "bclr %1,%0";
4762 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
4764 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4766 (minus:SI (const_int 7)
4767 (match_operator:SI 2 "extend_operator"
4768 [(match_operand 1 "general_operand" "d")])))
4773 return "bclr %1,%0";
4776 ;; Special cases of bit-field insns which we should
4777 ;; recognize in preference to the general case.
4778 ;; These handle aligned 8-bit and 16-bit fields,
4779 ;; which can usually be done with move instructions.
4782 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4783 ; alignment of structure members is specified.
4785 ; The move is allowed to be odd byte aligned, because that's still faster
4786 ; than an odd byte aligned bit-field instruction.
4789 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4791 (match_operand:SI 1 "const_int_operand" "n"))
4792 (match_operand:SI 2 "general_src_operand" "rmSi"))]
4793 "TARGET_68020 && TARGET_BITFIELD
4794 && (INTVAL (operands[1]) % 8) == 0
4795 && ! mode_dependent_address_p (XEXP (operands[0], 0))"
4798 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
4800 return "move%.l %2,%0";
4804 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
4805 (match_operand:SI 1 "const_int_operand" "n")
4806 (match_operand:SI 2 "const_int_operand" "n"))
4807 (match_operand:SI 3 "register_operand" "d"))]
4808 "TARGET_68020 && TARGET_BITFIELD
4809 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
4810 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
4811 && (GET_CODE (operands[0]) == REG
4812 || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
4814 if (REG_P (operands[0]))
4816 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
4817 return "bfins %3,%0{%b2:%b1}";
4820 operands[0] = adjust_address (operands[0],
4821 INTVAL (operands[1]) == 8 ? QImode : HImode,
4822 INTVAL (operands[2]) / 8);
4824 if (GET_CODE (operands[3]) == MEM)
4825 operands[3] = adjust_address (operands[3],
4826 INTVAL (operands[1]) == 8 ? QImode : HImode,
4827 (32 - INTVAL (operands[1])) / 8);
4829 if (INTVAL (operands[1]) == 8)
4830 return "move%.b %3,%0";
4831 return "move%.w %3,%0";
4836 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4837 ; alignment of structure members is specified.
4839 ; The move is allowed to be odd byte aligned, because that's still faster
4840 ; than an odd byte aligned bit-field instruction.
4843 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4844 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4846 (match_operand:SI 2 "const_int_operand" "n")))]
4847 "TARGET_68020 && TARGET_BITFIELD
4848 && (INTVAL (operands[2]) % 8) == 0
4849 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4852 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4854 return "move%.l %1,%0";
4858 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
4859 (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
4860 (match_operand:SI 2 "const_int_operand" "n")
4861 (match_operand:SI 3 "const_int_operand" "n")))]
4862 "TARGET_68020 && TARGET_BITFIELD
4863 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4864 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4865 && (GET_CODE (operands[1]) == REG
4866 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4868 cc_status.flags |= CC_NOT_NEGATIVE;
4869 if (REG_P (operands[1]))
4871 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4872 return "bfextu %1{%b3:%b2},%0";
4876 = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
4878 output_asm_insn ("clr%.l %0", operands);
4879 if (GET_CODE (operands[0]) == MEM)
4880 operands[0] = adjust_address (operands[0],
4881 INTVAL (operands[2]) == 8 ? QImode : HImode,
4882 (32 - INTVAL (operands[1])) / 8);
4884 if (INTVAL (operands[2]) == 8)
4885 return "move%.b %1,%0";
4886 return "move%.w %1,%0";
4890 ; Special case for 32-bit field in memory. This only occurs when 32-bit
4891 ; alignment of structure members is specified.
4893 ; The move is allowed to be odd byte aligned, because that's still faster
4894 ; than an odd byte aligned bit-field instruction.
4897 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4898 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4900 (match_operand:SI 2 "const_int_operand" "n")))]
4901 "TARGET_68020 && TARGET_BITFIELD
4902 && (INTVAL (operands[2]) % 8) == 0
4903 && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4906 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4908 return "move%.l %1,%0";
4912 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4913 (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
4914 (match_operand:SI 2 "const_int_operand" "n")
4915 (match_operand:SI 3 "const_int_operand" "n")))]
4916 "TARGET_68020 && TARGET_BITFIELD
4917 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4918 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4919 && (GET_CODE (operands[1]) == REG
4920 || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4922 if (REG_P (operands[1]))
4924 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4925 return "bfexts %1{%b3:%b2},%0";
4929 = adjust_address (operands[1],
4930 INTVAL (operands[2]) == 8 ? QImode : HImode,
4931 INTVAL (operands[3]) / 8);
4933 if (INTVAL (operands[2]) == 8)
4934 return "move%.b %1,%0\;extb%.l %0";
4935 return "move%.w %1,%0\;ext%.l %0";
4938 ;; Bit-field instructions, general cases.
4939 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
4940 ;; so that its address is reloaded.
4942 (define_expand "extv"
4943 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4944 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
4945 (match_operand:SI 2 "general_operand" "")
4946 (match_operand:SI 3 "general_operand" "")))]
4947 "TARGET_68020 && TARGET_BITFIELD"
4951 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4952 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
4953 (match_operand:SI 2 "general_operand" "dn")
4954 (match_operand:SI 3 "general_operand" "dn")))]
4955 "TARGET_68020 && TARGET_BITFIELD"
4956 "bfexts %1{%b3:%b2},%0")
4958 (define_expand "extzv"
4959 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4960 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
4961 (match_operand:SI 2 "general_operand" "")
4962 (match_operand:SI 3 "general_operand" "")))]
4963 "TARGET_68020 && TARGET_BITFIELD"
4967 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d")
4968 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o,d")
4969 (match_operand:SI 2 "general_operand" "dn,dn")
4970 (match_operand:SI 3 "general_operand" "dn,dn")))]
4971 "TARGET_68020 && TARGET_BITFIELD"
4973 if (GET_CODE (operands[2]) == CONST_INT)
4975 if (INTVAL (operands[2]) != 32)
4976 cc_status.flags |= CC_NOT_NEGATIVE;
4982 return "bfextu %1{%b3:%b2},%0";
4986 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4987 (match_operand:SI 1 "general_operand" "dn")
4988 (match_operand:SI 2 "general_operand" "dn"))
4989 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
4990 (match_operand 3 "const_int_operand" "n")))]
4991 "TARGET_68020 && TARGET_BITFIELD
4992 && (INTVAL (operands[3]) == -1
4993 || (GET_CODE (operands[1]) == CONST_INT
4994 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
4997 return "bfchg %0{%b2:%b1}";
5001 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5002 (match_operand:SI 1 "general_operand" "dn")
5003 (match_operand:SI 2 "general_operand" "dn"))
5005 "TARGET_68020 && TARGET_BITFIELD"
5008 return "bfclr %0{%b2:%b1}";
5012 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5013 (match_operand:SI 1 "general_operand" "dn")
5014 (match_operand:SI 2 "general_operand" "dn"))
5016 "TARGET_68020 && TARGET_BITFIELD"
5019 return "bfset %0{%b2:%b1}";
5022 (define_expand "insv"
5023 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5024 (match_operand:SI 1 "general_operand" "")
5025 (match_operand:SI 2 "general_operand" ""))
5026 (match_operand:SI 3 "register_operand" ""))]
5027 "TARGET_68020 && TARGET_BITFIELD"
5031 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5032 (match_operand:SI 1 "general_operand" "dn")
5033 (match_operand:SI 2 "general_operand" "dn"))
5034 (match_operand:SI 3 "register_operand" "d"))]
5035 "TARGET_68020 && TARGET_BITFIELD"
5036 "bfins %3,%0{%b2:%b1}")
5038 ;; Now recognize bit-field insns that operate on registers
5039 ;; (or at least were intended to do so).
5042 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5043 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5044 (match_operand:SI 2 "general_operand" "dn")
5045 (match_operand:SI 3 "general_operand" "dn")))]
5046 "TARGET_68020 && TARGET_BITFIELD"
5047 "bfexts %1{%b3:%b2},%0")
5050 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5051 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5052 (match_operand:SI 2 "general_operand" "dn")
5053 (match_operand:SI 3 "general_operand" "dn")))]
5054 "TARGET_68020 && TARGET_BITFIELD"
5056 if (GET_CODE (operands[2]) == CONST_INT)
5058 if (INTVAL (operands[2]) != 32)
5059 cc_status.flags |= CC_NOT_NEGATIVE;
5065 return "bfextu %1{%b3:%b2},%0";
5069 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5070 (match_operand:SI 1 "general_operand" "dn")
5071 (match_operand:SI 2 "general_operand" "dn"))
5073 "TARGET_68020 && TARGET_BITFIELD"
5076 return "bfclr %0{%b2:%b1}";
5080 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5081 (match_operand:SI 1 "general_operand" "dn")
5082 (match_operand:SI 2 "general_operand" "dn"))
5084 "TARGET_68020 && TARGET_BITFIELD"
5087 return "bfset %0{%b2:%b1}";
5091 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5092 (match_operand:SI 1 "general_operand" "dn")
5093 (match_operand:SI 2 "general_operand" "dn"))
5094 (match_operand:SI 3 "register_operand" "d"))]
5095 "TARGET_68020 && TARGET_BITFIELD"
5098 /* These special cases are now recognized by a specific pattern. */
5099 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5100 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5101 return "move%.w %3,%0";
5102 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5103 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5104 return "move%.b %3,%0";
5106 return "bfins %3,%0{%b2:%b1}";
5109 ;; Special patterns for optimizing bit-field instructions.
5113 (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5114 (match_operand:SI 1 "const_int_operand" "n")
5115 (match_operand:SI 2 "general_operand" "dn")))]
5116 "TARGET_68020 && TARGET_BITFIELD"
5118 if (operands[1] == const1_rtx
5119 && GET_CODE (operands[2]) == CONST_INT)
5121 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5122 return output_btst (operands,
5123 GEN_INT (width - INTVAL (operands[2])),
5124 operands[0], insn, 1000);
5125 /* Pass 1000 as SIGNPOS argument so that btst will
5126 not think we are testing the sign bit for an `and'
5127 and assume that nonzero implies a negative result. */
5129 if (INTVAL (operands[1]) != 32)
5130 cc_status.flags = CC_NOT_NEGATIVE;
5131 return "bftst %0{%b2:%b1}";
5135 ;;; now handle the register cases
5138 (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5139 (match_operand:SI 1 "const_int_operand" "n")
5140 (match_operand:SI 2 "general_operand" "dn")))]
5141 "TARGET_68020 && TARGET_BITFIELD"
5143 if (operands[1] == const1_rtx
5144 && GET_CODE (operands[2]) == CONST_INT)
5146 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5147 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5148 operands[0], insn, 1000);
5149 /* Pass 1000 as SIGNPOS argument so that btst will
5150 not think we are testing the sign bit for an `and'
5151 and assume that nonzero implies a negative result. */
5153 if (INTVAL (operands[1]) != 32)
5154 cc_status.flags = CC_NOT_NEGATIVE;
5155 return "bftst %0{%b2:%b1}";
5158 (define_insn "scc0_di"
5159 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5160 (match_operator 1 "valid_dbcc_comparison_p"
5161 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5164 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5167 (define_insn "scc0_di_5200"
5168 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5169 (match_operator 1 "valid_dbcc_comparison_p"
5170 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5173 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5176 (define_insn "scc_di"
5177 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5178 (match_operator 1 "valid_dbcc_comparison_p"
5179 [(match_operand:DI 2 "general_operand" "ro,r")
5180 (match_operand:DI 3 "general_operand" "r,ro")]))]
5183 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5186 (define_insn "scc_di_5200"
5187 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5188 (match_operator 1 "valid_dbcc_comparison_p"
5189 [(match_operand:DI 2 "general_operand" "ro,r")
5190 (match_operand:DI 3 "general_operand" "r,ro")]))]
5193 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5196 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5197 ;; memory, but we cannot allow it to be in memory in case the address
5198 ;; needs to be reloaded.
5200 (define_expand "seq"
5201 [(set (match_operand:QI 0 "register_operand" "")
5202 (eq:QI (cc0) (const_int 0)))]
5205 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5206 && m68k_last_compare_had_fp_operands)
5208 m68k_last_compare_had_fp_operands = 0;
5214 [(set (match_operand:QI 0 "register_operand" "=d")
5215 (eq:QI (cc0) (const_int 0)))]
5218 cc_status = cc_prev_status;
5219 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5222 (define_expand "sne"
5223 [(set (match_operand:QI 0 "register_operand" "")
5224 (ne:QI (cc0) (const_int 0)))]
5227 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5228 && m68k_last_compare_had_fp_operands)
5230 m68k_last_compare_had_fp_operands = 0;
5236 [(set (match_operand:QI 0 "register_operand" "=d")
5237 (ne:QI (cc0) (const_int 0)))]
5240 cc_status = cc_prev_status;
5241 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5244 (define_expand "sgt"
5245 [(set (match_operand:QI 0 "register_operand" "")
5246 (gt:QI (cc0) (const_int 0)))]
5249 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5250 && m68k_last_compare_had_fp_operands)
5252 m68k_last_compare_had_fp_operands = 0;
5258 [(set (match_operand:QI 0 "register_operand" "=d")
5259 (gt:QI (cc0) (const_int 0)))]
5262 cc_status = cc_prev_status;
5263 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5266 (define_expand "sgtu"
5267 [(set (match_operand:QI 0 "register_operand" "")
5268 (gtu:QI (cc0) (const_int 0)))]
5273 [(set (match_operand:QI 0 "register_operand" "=d")
5274 (gtu:QI (cc0) (const_int 0)))]
5277 cc_status = cc_prev_status;
5281 (define_expand "slt"
5282 [(set (match_operand:QI 0 "register_operand" "")
5283 (lt:QI (cc0) (const_int 0)))]
5286 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5287 && m68k_last_compare_had_fp_operands)
5289 m68k_last_compare_had_fp_operands = 0;
5295 [(set (match_operand:QI 0 "register_operand" "=d")
5296 (lt:QI (cc0) (const_int 0)))]
5299 cc_status = cc_prev_status;
5300 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5303 (define_expand "sltu"
5304 [(set (match_operand:QI 0 "register_operand" "")
5305 (ltu:QI (cc0) (const_int 0)))]
5310 [(set (match_operand:QI 0 "register_operand" "=d")
5311 (ltu:QI (cc0) (const_int 0)))]
5314 cc_status = cc_prev_status;
5318 (define_expand "sge"
5319 [(set (match_operand:QI 0 "register_operand" "")
5320 (ge:QI (cc0) (const_int 0)))]
5323 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5324 && m68k_last_compare_had_fp_operands)
5326 m68k_last_compare_had_fp_operands = 0;
5332 [(set (match_operand:QI 0 "register_operand" "=d")
5333 (ge:QI (cc0) (const_int 0)))]
5336 cc_status = cc_prev_status;
5337 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5340 (define_expand "sgeu"
5341 [(set (match_operand:QI 0 "register_operand" "")
5342 (geu:QI (cc0) (const_int 0)))]
5347 [(set (match_operand:QI 0 "register_operand" "=d")
5348 (geu:QI (cc0) (const_int 0)))]
5351 cc_status = cc_prev_status;
5355 (define_expand "sle"
5356 [(set (match_operand:QI 0 "register_operand" "")
5357 (le:QI (cc0) (const_int 0)))]
5360 if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5361 && m68k_last_compare_had_fp_operands)
5363 m68k_last_compare_had_fp_operands = 0;
5369 [(set (match_operand:QI 0 "register_operand" "=d")
5370 (le:QI (cc0) (const_int 0)))]
5373 cc_status = cc_prev_status;
5374 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5377 (define_expand "sleu"
5378 [(set (match_operand:QI 0 "register_operand" "")
5379 (leu:QI (cc0) (const_int 0)))]
5384 [(set (match_operand:QI 0 "register_operand" "=d")
5385 (leu:QI (cc0) (const_int 0)))]
5388 cc_status = cc_prev_status;
5392 (define_expand "sordered"
5393 [(set (match_operand:QI 0 "register_operand" "")
5394 (ordered:QI (cc0) (const_int 0)))]
5395 "TARGET_68881 && !TUNE_68060"
5397 gcc_assert (m68k_last_compare_had_fp_operands);
5398 m68k_last_compare_had_fp_operands = 0;
5401 (define_insn "*sordered_1"
5402 [(set (match_operand:QI 0 "register_operand" "=d")
5403 (ordered:QI (cc0) (const_int 0)))]
5404 "TARGET_68881 && !TUNE_68060"
5406 cc_status = cc_prev_status;
5410 (define_expand "sunordered"
5411 [(set (match_operand:QI 0 "register_operand" "")
5412 (unordered:QI (cc0) (const_int 0)))]
5413 "TARGET_68881 && !TUNE_68060"
5415 gcc_assert (m68k_last_compare_had_fp_operands);
5416 m68k_last_compare_had_fp_operands = 0;
5419 (define_insn "*sunordered_1"
5420 [(set (match_operand:QI 0 "register_operand" "=d")
5421 (unordered:QI (cc0) (const_int 0)))]
5422 "TARGET_68881 && !TUNE_68060"
5424 cc_status = cc_prev_status;
5428 (define_expand "suneq"
5429 [(set (match_operand:QI 0 "register_operand" "")
5430 (uneq:QI (cc0) (const_int 0)))]
5431 "TARGET_68881 && !TUNE_68060"
5433 gcc_assert (m68k_last_compare_had_fp_operands);
5434 m68k_last_compare_had_fp_operands = 0;
5437 (define_insn "*suneq_1"
5438 [(set (match_operand:QI 0 "register_operand" "=d")
5439 (uneq:QI (cc0) (const_int 0)))]
5440 "TARGET_68881 && !TUNE_68060"
5442 cc_status = cc_prev_status;
5446 (define_expand "sunge"
5447 [(set (match_operand:QI 0 "register_operand" "")
5448 (unge:QI (cc0) (const_int 0)))]
5449 "TARGET_68881 && !TUNE_68060"
5451 gcc_assert (m68k_last_compare_had_fp_operands);
5452 m68k_last_compare_had_fp_operands = 0;
5455 (define_insn "*sunge_1"
5456 [(set (match_operand:QI 0 "register_operand" "=d")
5457 (unge:QI (cc0) (const_int 0)))]
5458 "TARGET_68881 && !TUNE_68060"
5460 cc_status = cc_prev_status;
5464 (define_expand "sungt"
5465 [(set (match_operand:QI 0 "register_operand" "")
5466 (ungt:QI (cc0) (const_int 0)))]
5467 "TARGET_68881 && !TUNE_68060"
5469 gcc_assert (m68k_last_compare_had_fp_operands);
5470 m68k_last_compare_had_fp_operands = 0;
5473 (define_insn "*sungt_1"
5474 [(set (match_operand:QI 0 "register_operand" "=d")
5475 (ungt:QI (cc0) (const_int 0)))]
5476 "TARGET_68881 && !TUNE_68060"
5478 cc_status = cc_prev_status;
5482 (define_expand "sunle"
5483 [(set (match_operand:QI 0 "register_operand" "")
5484 (unle:QI (cc0) (const_int 0)))]
5485 "TARGET_68881 && !TUNE_68060"
5487 gcc_assert (m68k_last_compare_had_fp_operands);
5488 m68k_last_compare_had_fp_operands = 0;
5491 (define_insn "*sunle_1"
5492 [(set (match_operand:QI 0 "register_operand" "=d")
5493 (unle:QI (cc0) (const_int 0)))]
5494 "TARGET_68881 && !TUNE_68060"
5496 cc_status = cc_prev_status;
5500 (define_expand "sunlt"
5501 [(set (match_operand:QI 0 "register_operand" "")
5502 (unlt:QI (cc0) (const_int 0)))]
5503 "TARGET_68881 && !TUNE_68060"
5505 gcc_assert (m68k_last_compare_had_fp_operands);
5506 m68k_last_compare_had_fp_operands = 0;
5509 (define_insn "*sunlt_1"
5510 [(set (match_operand:QI 0 "register_operand" "=d")
5511 (unlt:QI (cc0) (const_int 0)))]
5512 "TARGET_68881 && !TUNE_68060"
5514 cc_status = cc_prev_status;
5518 (define_expand "sltgt"
5519 [(set (match_operand:QI 0 "register_operand" "")
5520 (ltgt:QI (cc0) (const_int 0)))]
5521 "TARGET_68881 && !TUNE_68060"
5523 gcc_assert (m68k_last_compare_had_fp_operands);
5524 m68k_last_compare_had_fp_operands = 0;
5527 (define_insn "*sltgt_1"
5528 [(set (match_operand:QI 0 "register_operand" "=d")
5529 (ltgt:QI (cc0) (const_int 0)))]
5530 "TARGET_68881 && !TUNE_68060"
5532 cc_status = cc_prev_status;
5536 (define_insn "*fsogt_1"
5537 [(set (match_operand:QI 0 "register_operand" "=d")
5538 (not:QI (unle:QI (cc0) (const_int 0))))]
5539 "TARGET_68881 && !TUNE_68060"
5541 cc_status = cc_prev_status;
5545 (define_insn "*fsoge_1"
5546 [(set (match_operand:QI 0 "register_operand" "=d")
5547 (not:QI (unlt:QI (cc0) (const_int 0))))]
5548 "TARGET_68881 && !TUNE_68060"
5550 cc_status = cc_prev_status;
5554 (define_insn "*fsolt_1"
5555 [(set (match_operand:QI 0 "register_operand" "=d")
5556 (not:QI (unge:QI (cc0) (const_int 0))))]
5557 "TARGET_68881 && !TUNE_68060"
5559 cc_status = cc_prev_status;
5563 (define_insn "*fsole_1"
5564 [(set (match_operand:QI 0 "register_operand" "=d")
5565 (not:QI (ungt:QI (cc0) (const_int 0))))]
5566 "TARGET_68881 && !TUNE_68060"
5568 cc_status = cc_prev_status;
5572 ;; Basic conditional jump instructions.
5574 (define_insn "beq0_di"
5576 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
5578 (label_ref (match_operand 1 "" ","))
5580 (clobber (match_scratch:SI 2 "=d,d"))]
5584 if (which_alternative == 1)
5587 return "move%.l %0,%2\;or%.l %0,%2\;jbeq %l1";
5589 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5591 if ((cc_prev_status.value1
5592 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5593 || (cc_prev_status.value2
5594 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5596 cc_status = cc_prev_status;
5597 return MOTOROLA ? "jbeq %l1" : "jeq %l1";
5599 if (GET_CODE (operands[0]) == REG)
5600 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5602 operands[3] = adjust_address (operands[0], SImode, 4);
5603 if (! ADDRESS_REG_P (operands[0]))
5605 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5607 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5610 return "or%.l %0,%2\;jbeq %l1";
5612 return "or%.l %0,%2\;jeq %l1";
5617 return "or%.l %3,%2\;jbeq %l1";
5619 return "or%.l %3,%2\;jeq %l1";
5623 return "move%.l %0,%2\;or%.l %3,%2\;jbeq %l1";
5625 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5627 operands[4] = gen_label_rtx();
5628 if (TARGET_68020 || TARGET_COLDFIRE)
5631 output_asm_insn ("tst%.l %0\;jbne %l4\;tst%.l %3\;jbeq %l1", operands);
5633 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
5638 output_asm_insn ("cmp%.w #0,%0\;jbne %l4\;cmp%.w #0,%3\;jbeq %l1", operands);
5640 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
5642 (*targetm.asm_out.internal_label) (asm_out_file, "L",
5643 CODE_LABEL_NUMBER (operands[4]));
5647 (define_insn "bne0_di"
5649 (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
5651 (label_ref (match_operand 1 "" ","))
5653 (clobber (match_scratch:SI 2 "=d,X"))]
5656 if ((cc_prev_status.value1
5657 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5658 || (cc_prev_status.value2
5659 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5661 cc_status = cc_prev_status;
5662 return MOTOROLA ? "jbne %l1" : "jne %l1";
5665 if (GET_CODE (operands[0]) == REG)
5666 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5668 operands[3] = adjust_address (operands[0], SImode, 4);
5669 if (!ADDRESS_REG_P (operands[0]))
5671 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5673 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5676 return "or%.l %0,%2\;jbne %l1";
5678 return "or%.l %0,%2\;jne %l1";
5683 return "or%.l %3,%2\;jbne %l1";
5685 return "or%.l %3,%2\;jne %l1";
5689 return "move%.l %0,%2\;or%.l %3,%2\;jbne %l1";
5691 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
5693 if (TARGET_68020 || TARGET_COLDFIRE)
5696 return "tst%.l %0\;jbne %l1\;tst%.l %3\;jbne %l1";
5698 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
5703 return "cmp%.w #0,%0\;jbne %l1\;cmp%.w #0,%3\;jbne %l1";
5705 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
5709 (define_insn "bge0_di"
5711 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
5713 (label_ref (match_operand 1 "" ""))
5717 if ((cc_prev_status.value1
5718 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5719 || (cc_prev_status.value2
5720 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5722 cc_status = cc_prev_status;
5723 if (cc_status.flags & CC_REVERSED)
5725 return MOTOROLA ? "jble %l1" : "jle %l1";
5729 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5733 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5734 output_asm_insn("tst%.l %0", operands);
5737 /* On an address reg, cmpw may replace cmpl. */
5738 output_asm_insn("cmp%.w #0,%0", operands);
5740 return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5743 (define_insn "blt0_di"
5745 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
5747 (label_ref (match_operand 1 "" ""))
5751 if ((cc_prev_status.value1
5752 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5753 || (cc_prev_status.value2
5754 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5756 cc_status = cc_prev_status;
5757 if (cc_status.flags & CC_REVERSED)
5759 return MOTOROLA ? "jbgt %l1" : "jgt %l1";
5763 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5767 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5768 output_asm_insn("tst%.l %0", operands);
5771 /* On an address reg, cmpw may replace cmpl. */
5772 output_asm_insn("cmp%.w #0,%0", operands);
5775 return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5780 (if_then_else (eq (cc0)
5782 (label_ref (match_operand 0 "" ""))
5787 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5789 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5794 (if_then_else (ne (cc0)
5796 (label_ref (match_operand 0 "" ""))
5801 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5803 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5808 (if_then_else (gt (cc0)
5810 (label_ref (match_operand 0 "" ""))
5815 OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0);
5817 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
5822 (if_then_else (gtu (cc0)
5824 (label_ref (match_operand 0 "" ""))
5828 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5833 (if_then_else (lt (cc0)
5835 (label_ref (match_operand 0 "" ""))
5840 OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0");
5842 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
5847 (if_then_else (ltu (cc0)
5849 (label_ref (match_operand 0 "" ""))
5853 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5858 (if_then_else (ge (cc0)
5860 (label_ref (match_operand 0 "" ""))
5865 OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0");
5867 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
5872 (if_then_else (geu (cc0)
5874 (label_ref (match_operand 0 "" ""))
5878 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5883 (if_then_else (le (cc0)
5885 (label_ref (match_operand 0 "" ""))
5890 OUTPUT_JUMP ("jble %l0", "fble %l0", 0);
5892 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
5897 (if_then_else (leu (cc0)
5899 (label_ref (match_operand 0 "" ""))
5903 return MOTOROLA ? "jbls %l0" : "jls %l0";
5906 (define_insn "bordered"
5908 (if_then_else (ordered (cc0) (const_int 0))
5909 (label_ref (match_operand 0 "" ""))
5913 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5914 return MOTOROLA ? "fbor %l0" : "fjor %l0";
5917 (define_insn "bunordered"
5919 (if_then_else (unordered (cc0) (const_int 0))
5920 (label_ref (match_operand 0 "" ""))
5924 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5925 return MOTOROLA ? "fbun %l0" : "fjun %l0";
5928 (define_insn "buneq"
5930 (if_then_else (uneq (cc0) (const_int 0))
5931 (label_ref (match_operand 0 "" ""))
5935 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5936 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5939 (define_insn "bunge"
5941 (if_then_else (unge (cc0) (const_int 0))
5942 (label_ref (match_operand 0 "" ""))
5946 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5947 return MOTOROLA ? "fbuge %l0" : "fjuge %l0";
5950 (define_insn "bungt"
5952 (if_then_else (ungt (cc0) (const_int 0))
5953 (label_ref (match_operand 0 "" ""))
5957 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5958 return MOTOROLA ? "fbugt %l0" : "fjugt %l0";
5961 (define_insn "bunle"
5963 (if_then_else (unle (cc0) (const_int 0))
5964 (label_ref (match_operand 0 "" ""))
5968 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5969 return MOTOROLA ? "fbule %l0" : "fjule %l0";
5972 (define_insn "bunlt"
5974 (if_then_else (unlt (cc0) (const_int 0))
5975 (label_ref (match_operand 0 "" ""))
5979 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5980 return MOTOROLA ? "fbult %l0" : "fjult %l0";
5983 (define_insn "bltgt"
5985 (if_then_else (ltgt (cc0) (const_int 0))
5986 (label_ref (match_operand 0 "" ""))
5990 gcc_assert (cc_prev_status.flags & CC_IN_68881);
5991 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5994 ;; Negated conditional jump instructions.
5998 (if_then_else (eq (cc0)
6001 (label_ref (match_operand 0 "" ""))))]
6005 OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
6007 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6012 (if_then_else (ne (cc0)
6015 (label_ref (match_operand 0 "" ""))))]
6019 OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
6021 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6026 (if_then_else (gt (cc0)
6029 (label_ref (match_operand 0 "" ""))))]
6033 OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0);
6035 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6040 (if_then_else (gtu (cc0)
6043 (label_ref (match_operand 0 "" ""))))]
6046 return MOTOROLA ? "jbls %l0" : "jls %l0";
6051 (if_then_else (lt (cc0)
6054 (label_ref (match_operand 0 "" ""))))]
6058 OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0");
6060 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6065 (if_then_else (ltu (cc0)
6068 (label_ref (match_operand 0 "" ""))))]
6071 return MOTOROLA ? "jbcc %l0" : "jcc %l0";
6076 (if_then_else (ge (cc0)
6079 (label_ref (match_operand 0 "" ""))))]
6083 OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0");
6085 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6090 (if_then_else (geu (cc0)
6093 (label_ref (match_operand 0 "" ""))))]
6096 return MOTOROLA ? "jbcs %l0" : "jcs %l0";
6101 (if_then_else (le (cc0)
6104 (label_ref (match_operand 0 "" ""))))]
6108 OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0);
6110 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6115 (if_then_else (leu (cc0)
6118 (label_ref (match_operand 0 "" ""))))]
6121 return MOTOROLA ? "jbhi %l0" : "jhi %l0";
6124 (define_insn "*bordered_rev"
6126 (if_then_else (ordered (cc0) (const_int 0))
6128 (label_ref (match_operand 0 "" ""))))]
6131 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6132 return MOTOROLA ? "fbun %l0" : "fjun %l0";
6135 (define_insn "*bunordered_rev"
6137 (if_then_else (unordered (cc0) (const_int 0))
6139 (label_ref (match_operand 0 "" ""))))]
6142 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6143 return MOTOROLA ? "fbor %l0" : "fjor %l0";
6146 (define_insn "*buneq_rev"
6148 (if_then_else (uneq (cc0) (const_int 0))
6150 (label_ref (match_operand 0 "" ""))))]
6153 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6154 return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
6157 (define_insn "*bunge_rev"
6159 (if_then_else (unge (cc0) (const_int 0))
6161 (label_ref (match_operand 0 "" ""))))]
6164 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6165 return MOTOROLA ? "fbolt %l0" : "fjolt %l0";
6168 (define_insn "*bungt_rev"
6170 (if_then_else (ungt (cc0) (const_int 0))
6172 (label_ref (match_operand 0 "" ""))))]
6175 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6176 return MOTOROLA ? "fbole %l0" : "fjole %l0";
6179 (define_insn "*bunle_rev"
6181 (if_then_else (unle (cc0) (const_int 0))
6183 (label_ref (match_operand 0 "" ""))))]
6186 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6187 return MOTOROLA ? "fbogt %l0" : "fjogt %l0";
6190 (define_insn "*bunlt_rev"
6192 (if_then_else (unlt (cc0) (const_int 0))
6194 (label_ref (match_operand 0 "" ""))))]
6197 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6198 return MOTOROLA ? "fboge %l0" : "fjoge %l0";
6201 (define_insn "*bltgt_rev"
6203 (if_then_else (ltgt (cc0) (const_int 0))
6205 (label_ref (match_operand 0 "" ""))))]
6208 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6209 return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
6212 ;; Unconditional and other jump instructions
6215 (label_ref (match_operand 0 "" "")))]
6218 return MOTOROLA ? "jbra %l0" : "jra %l0";
6221 (define_expand "tablejump"
6222 [(parallel [(set (pc) (match_operand 0 "" ""))
6223 (use (label_ref (match_operand 1 "" "")))])]
6226 #ifdef CASE_VECTOR_PC_RELATIVE
6227 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6228 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6232 ;; Jump to variable address from dispatch table of absolute addresses.
6234 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6235 (use (label_ref (match_operand 1 "" "")))]
6238 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6241 ;; Jump to variable address from dispatch table of relative addresses.
6245 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6246 (use (label_ref (match_operand 1 "" "")))]
6249 #ifdef ASM_RETURN_CASE_JUMP
6250 ASM_RETURN_CASE_JUMP;
6252 if (TARGET_COLDFIRE)
6254 if (ADDRESS_REG_P (operands[0]))
6255 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6257 return "ext%.l %0\;jmp (2,pc,%0.l)";
6259 return "extl %0\;jmp pc@(2,%0:l)";
6262 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6266 ;; Decrement-and-branch insns.
6270 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6272 (label_ref (match_operand 1 "" ""))
6275 (plus:HI (match_dup 0)
6280 if (DATA_REG_P (operands[0]))
6281 return "dbra %0,%l1";
6282 if (GET_CODE (operands[0]) == MEM)
6284 "subq%.w #1,%0\;jbcc %l1" :
6285 "subqw #1,%0\;jcc %l1";
6287 "subq%.w #1,%0\;cmp%.w #-1,%0\;jbne %l1" :
6288 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6294 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6296 (label_ref (match_operand 1 "" ""))
6299 (plus:SI (match_dup 0)
6304 if (DATA_REG_P (operands[0]))
6306 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6307 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6308 if (GET_CODE (operands[0]) == MEM)
6310 "subq%.l #1,%0\;jbcc %l1" :
6311 "subq%.l #1,%0\;jcc %l1";
6313 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6314 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6317 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6322 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6325 (label_ref (match_operand 1 "" ""))
6328 (plus:HI (match_dup 0)
6330 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6333 if (DATA_REG_P (operands[0]))
6334 return "dbra %0,%l1";
6335 if (GET_CODE (operands[0]) == MEM)
6337 "subq%.w #1,%0\;jbcc %l1" :
6338 "subq%.w #1,%0\;jcc %l1";
6340 "subq.w #1,%0\;cmp.w #-1,%0\;jbne %l1" :
6341 "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6344 (define_expand "decrement_and_branch_until_zero"
6345 [(parallel [(set (pc)
6347 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6350 (label_ref (match_operand 1 "" ""))
6353 (plus:SI (match_dup 0)
6361 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6364 (label_ref (match_operand 1 "" ""))
6367 (plus:SI (match_dup 0)
6369 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6372 if (DATA_REG_P (operands[0]))
6374 "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6375 "dbra %0,%l1\;clr%.w %0\;subql #1,%0\;jcc %l1";
6376 if (GET_CODE (operands[0]) == MEM)
6378 "subq%.l #1,%0\;jbcc %l1" :
6379 "subql #1,%0\;jcc %l1";
6381 "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6382 "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6386 ;; For PIC calls, in order to be able to support
6387 ;; dynamic linker LAZY BINDING, all the procedure calls need to go
6388 ;; through the PLT (Procedure Linkage Table) section in PIC mode.
6390 ;; PIC calls are handled by loading the address of the function into a
6391 ;; register (via movsi), then emitting a register indirect call using
6392 ;; the "jsr" function call syntax.
6394 ;; When outputting MIT syntax (e.g. on Suns), we add a bogus extra
6395 ;; operand to the jbsr statement to indicate that this call should
6396 ;; go through the PLT (why? because this is the way that Sun does it).
6398 ;; We have different patterns for PIC calls and non-PIC calls. The
6399 ;; different patterns are only used to choose the right syntax.
6401 ;; The svr4 m68k assembler recognizes this syntax: `bsr FUNC@PLTPC' and it
6402 ;; will create the correct relocation entry (R_68K_PLT32) for `FUNC',
6403 ;; that tells the linker editor to create an entry for `FUNC' in PLT
6404 ;; section at link time. However, all global objects reference are still
6405 ;; done by using `OBJ@GOT'. So, the goal here is to output the function
6406 ;; call operand as `FUNC@PLTPC', but output object operand as `OBJ@GOT'.
6407 ;; We need to have a way to differentiate these two different operands.
6409 ;; The strategy I use here is to use SYMBOL_REF_FLAG to differentiate
6410 ;; these two different operands. The macro LEGITIMATE_PIC_OPERAND_P needs
6411 ;; to be changed to recognize function calls symbol_ref operand as a valid
6412 ;; PIC operand (by checking whether SYMBOL_REF_FLAG is set). This will
6413 ;; avoid the compiler to load this symbol_ref operand into a register.
6414 ;; Remember, the operand "foo@PLTPC" cannot be called via jsr directly
6415 ;; since the value is a PC relative offset, not a real address.
6417 ;; All global objects are treated in the similar way as in SUN3. The only
6418 ;; difference is: on m68k svr4, the reference of such global object needs
6419 ;; to end with a suffix "@GOT" so the assembler and linker know to create
6420 ;; an entry for it in GOT (Global Offset Table) section. This is done in
6423 ;; Call subroutine with no return value.
6424 (define_expand "call"
6425 [(call (match_operand:QI 0 "memory_operand" "")
6426 (match_operand:SI 1 "general_operand" ""))]
6427 ;; Operand 1 not really used on the m68000.
6431 if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
6432 SYMBOL_REF_FLAG (XEXP (operands[0], 0)) = 1;
6435 ;; This is a normal call sequence.
6437 [(call (match_operand:QI 0 "memory_operand" "o")
6438 (match_operand:SI 1 "general_operand" "g"))]
6439 ;; Operand 1 not really used on the m68000.
6443 #if MOTOROLA && !defined (USE_GAS)
6450 ;; This is a PIC call sequence.
6452 [(call (match_operand:QI 0 "memory_operand" "o")
6453 (match_operand:SI 1 "general_operand" "g"))]
6454 ;; Operand 1 not really used on the m68000.
6458 m68k_output_pic_call(operands[0]);
6462 ;; Call subroutine, returning value in operand 0
6463 ;; (which must be a hard register).
6464 ;; See comments before "call" regarding PIC calls.
6465 (define_expand "call_value"
6466 [(set (match_operand 0 "" "")
6467 (call (match_operand:QI 1 "memory_operand" "")
6468 (match_operand:SI 2 "general_operand" "")))]
6469 ;; Operand 2 not really used on the m68000.
6472 if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
6473 SYMBOL_REF_FLAG (XEXP (operands[1], 0)) = 1;
6476 ;; This is a normal call_value
6478 [(set (match_operand 0 "" "=rf")
6479 (call (match_operand:QI 1 "memory_operand" "o")
6480 (match_operand:SI 2 "general_operand" "g")))]
6481 ;; Operand 2 not really used on the m68000.
6484 #if MOTOROLA && !defined (USE_GAS)
6491 ;; This is a PIC call_value
6493 [(set (match_operand 0 "" "=rf")
6494 (call (match_operand:QI 1 "memory_operand" "o")
6495 (match_operand:SI 2 "general_operand" "g")))]
6496 ;; Operand 2 not really used on the m68000.
6499 m68k_output_pic_call(operands[1]);
6503 ;; Call subroutine returning any type.
6505 (define_expand "untyped_call"
6506 [(parallel [(call (match_operand 0 "" "")
6508 (match_operand 1 "" "")
6509 (match_operand 2 "" "")])]
6510 "NEEDS_UNTYPED_CALL"
6514 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6516 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6518 rtx set = XVECEXP (operands[2], 0, i);
6519 emit_move_insn (SET_DEST (set), SET_SRC (set));
6522 /* The optimizer does not know that the call sets the function value
6523 registers we stored in the result block. We avoid problems by
6524 claiming that all hard registers are used and clobbered at this
6526 emit_insn (gen_blockage ());
6531 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6532 ;; all of memory. This blocks insns from being moved across this point.
6534 (define_insn "blockage"
6535 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6544 ;; Used for frameless functions which save no regs and allocate no locals.
6545 (define_insn "return"
6549 if (current_function_pops_args == 0)
6551 operands[0] = GEN_INT (current_function_pops_args);
6555 (define_insn "indirect_jump"
6556 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
6560 ;; This should not be used unless the add/sub insns can't be.
6563 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
6564 (match_operand:QI 1 "address_operand" "p"))]
6567 /* Recognize an insn that refers to a table of offsets. Such an insn will
6568 need to refer to a label on the insn. So output one. Use the
6569 label-number of the table of offsets to generate this label. This code,
6570 and similar code above, assumes that there will be at most one reference
6572 if (GET_CODE (operands[1]) == PLUS
6573 && GET_CODE (XEXP (operands[1], 1)) == LABEL_REF
6574 && GET_CODE (XEXP (operands[1], 0)) != PLUS)
6576 rtx labelref = XEXP (operands[1], 1);
6578 asm_fprintf (asm_out_file, "\\t.set %LLI%d,.+2\\n",
6579 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6581 (*targetm.asm_out.internal_label) (asm_out_file, "LI",
6582 CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6584 return "lea %a1,%0";
6587 ;; This is the first machine-dependent peephole optimization.
6588 ;; It is useful when a floating value is returned from a function call
6589 ;; and then is moved into an FP register.
6590 ;; But it is mainly intended to test the support for these optimizations.
6593 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
6594 (set (match_operand:DF 0 "register_operand" "=f")
6595 (match_operand:DF 1 "register_operand" "ad"))]
6596 "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
6599 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6600 output_asm_insn ("move%.l %1,%@", xoperands);
6601 output_asm_insn ("move%.l %1,%-", operands);
6602 return "fmove%.d %+,%0";
6605 ;; Optimize a stack-adjust followed by a push of an argument.
6606 ;; This is said to happen frequently with -msoft-float
6607 ;; when there are consecutive library calls.
6610 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6611 (match_operand:SI 0 "const_int_operand" "n")))
6612 (set (match_operand:SF 1 "push_operand" "=m")
6613 (match_operand:SF 2 "general_operand" "rmfF"))]
6614 "INTVAL (operands[0]) >= 4
6615 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6617 if (INTVAL (operands[0]) > 4)
6620 xoperands[0] = stack_pointer_rtx;
6621 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6622 if (INTVAL (xoperands[1]) <= 8)
6624 if (!TARGET_COLDFIRE)
6625 output_asm_insn ("addq%.w %1,%0", xoperands);
6627 output_asm_insn ("addq%.l %1,%0", xoperands);
6629 else if (TUNE_CPU32 && INTVAL (xoperands[1]) <= 16)
6631 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6632 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6634 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6637 output_asm_insn ("add%.w %1,%0", xoperands);
6639 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6641 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6644 output_asm_insn ("add%.l %1,%0", xoperands);
6646 if (FP_REG_P (operands[2]))
6647 return "fmove%.s %2,%@";
6648 return "move%.l %2,%@";
6651 ;; Speed up stack adjust followed by a fullword fixedpoint push.
6654 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6655 (match_operand:SI 0 "const_int_operand" "n")))
6656 (set (match_operand:SI 1 "push_operand" "=m")
6657 (match_operand:SI 2 "general_operand" "g"))]
6658 "INTVAL (operands[0]) >= 4
6659 && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6661 if (INTVAL (operands[0]) > 4)
6664 xoperands[0] = stack_pointer_rtx;
6665 xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6666 if (INTVAL (xoperands[1]) <= 8)
6668 if (!TARGET_COLDFIRE)
6669 output_asm_insn ("addq%.w %1,%0", xoperands);
6671 output_asm_insn ("addq%.l %1,%0", xoperands);
6673 else if (TUNE_CPU32 && INTVAL (xoperands[1]) <= 16)
6675 xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6676 output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6678 else if (INTVAL (xoperands[1]) <= 0x7FFF)
6681 output_asm_insn ("add%.w %1,%0", xoperands);
6683 output_asm_insn ("lea (%c1,%0),%0", xoperands);
6685 output_asm_insn ("lea %0@(%c1),%0", xoperands);
6688 output_asm_insn ("add%.l %1,%0", xoperands);
6690 if (operands[2] == const0_rtx)
6692 return "move%.l %2,%@";
6695 ;; Speed up pushing a single byte but leaving four bytes of space.
6698 [(set (mem:QI (pre_dec:SI (reg:SI SP_REG)))
6699 (match_operand:QI 1 "general_operand" "dami"))
6700 (set (reg:SI SP_REG) (minus:SI (reg:SI SP_REG) (const_int 2)))]
6701 "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
6705 if (GET_CODE (operands[1]) == REG)
6706 return "move%.l %1,%-";
6708 xoperands[1] = operands[1];
6710 = gen_rtx_MEM (QImode, plus_constant (stack_pointer_rtx, 3));
6711 xoperands[3] = stack_pointer_rtx;
6712 if (!TARGET_COLDFIRE)
6713 output_asm_insn ("subq%.w #4,%3\;move%.b %1,%2", xoperands);
6715 output_asm_insn ("subq%.l #4,%3\;move%.b %1,%2", xoperands);
6720 [(set (match_operand:SI 0 "register_operand" "=d")
6722 (set (strict_low_part (subreg:HI (match_dup 0) 2))
6723 (match_operand:HI 1 "general_operand" "rmn"))]
6724 "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
6726 if (GET_CODE (operands[1]) == CONST_INT)
6728 if (operands[1] == const0_rtx
6729 && (DATA_REG_P (operands[0])
6730 || GET_CODE (operands[0]) == MEM)
6731 /* clr insns on 68000 read before writing.
6732 This isn't so on the 68010, but we have no TARGET_68010. */
6733 && ((TARGET_68020 || TARGET_COLDFIRE)
6734 || !(GET_CODE (operands[0]) == MEM
6735 && MEM_VOLATILE_P (operands[0]))))
6738 return "move%.w %1,%0";
6746 ;; jCC label ; abnormal loop termination
6747 ;; dbra dN, loop ; normal loop termination
6755 ;; Which moves the jCC condition outside the inner loop for free.
6759 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6760 [(cc0) (const_int 0)])
6761 (label_ref (match_operand 2 "" ""))
6766 (ne (match_operand:HI 0 "register_operand" "")
6768 (label_ref (match_operand 1 "" ""))
6771 (plus:HI (match_dup 0)
6773 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6776 output_dbcc_and_branch (operands);
6781 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6782 [(cc0) (const_int 0)])
6783 (label_ref (match_operand 2 "" ""))
6788 (ne (match_operand:SI 0 "register_operand" "")
6790 (label_ref (match_operand 1 "" ""))
6793 (plus:SI (match_dup 0)
6795 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6798 output_dbcc_and_branch (operands);
6803 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6804 [(cc0) (const_int 0)])
6805 (label_ref (match_operand 2 "" ""))
6810 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
6813 (label_ref (match_operand 1 "" ""))
6816 (plus:HI (match_dup 0)
6818 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6821 output_dbcc_and_branch (operands);
6826 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6827 [(cc0) (const_int 0)])
6828 (label_ref (match_operand 2 "" ""))
6833 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
6836 (label_ref (match_operand 1 "" ""))
6839 (plus:SI (match_dup 0)
6841 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6844 output_dbcc_and_branch (operands);
6849 (define_insn "extendsfxf2"
6850 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6851 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
6854 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6856 if (REGNO (operands[0]) == REGNO (operands[1]))
6858 /* Extending float to double in an fp-reg is a no-op.
6859 NOTICE_UPDATE_CC has already assumed that the
6860 cc will be set. So cancel what it did. */
6861 cc_status = cc_prev_status;
6864 return "f%$move%.x %1,%0";
6866 if (FP_REG_P (operands[0]))
6868 if (FP_REG_P (operands[1]))
6869 return "f%$move%.x %1,%0";
6870 else if (ADDRESS_REG_P (operands[1]))
6871 return "move%.l %1,%-\;f%$move%.s %+,%0";
6872 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
6873 return output_move_const_single (operands);
6874 return "f%$move%.s %f1,%0";
6876 return "fmove%.x %f1,%0";
6880 (define_insn "extenddfxf2"
6881 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6883 (match_operand:DF 1 "general_operand" "f,rmE")))]
6886 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6888 if (REGNO (operands[0]) == REGNO (operands[1]))
6890 /* Extending float to double in an fp-reg is a no-op.
6891 NOTICE_UPDATE_CC has already assumed that the
6892 cc will be set. So cancel what it did. */
6893 cc_status = cc_prev_status;
6896 return "fmove%.x %1,%0";
6898 if (FP_REG_P (operands[0]))
6900 if (REG_P (operands[1]))
6903 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6904 output_asm_insn ("move%.l %1,%-", xoperands);
6905 output_asm_insn ("move%.l %1,%-", operands);
6906 return "f%&move%.d %+,%0";
6908 if (GET_CODE (operands[1]) == CONST_DOUBLE)
6909 return output_move_const_double (operands);
6910 return "f%&move%.d %f1,%0";
6912 return "fmove%.x %f1,%0";
6915 (define_insn "truncxfdf2"
6916 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
6918 (match_operand:XF 1 "general_operand" "f,f")))]
6921 if (REG_P (operands[0]))
6923 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
6924 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6925 return "move%.l %+,%0";
6927 return "fmove%.d %f1,%0";
6930 (define_insn "truncxfsf2"
6931 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
6933 (match_operand:XF 1 "general_operand" "f")))]
6937 (define_insn "sin<mode>2"
6938 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
6940 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
6941 "TARGET_68881 && flag_unsafe_math_optimizations"
6943 if (FP_REG_P (operands[1]))
6944 return "fsin%.x %1,%0";
6946 return "fsin%.<FP:prec> %1,%0";
6949 (define_insn "cos<mode>2"
6950 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
6952 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
6953 "TARGET_68881 && flag_unsafe_math_optimizations"
6955 if (FP_REG_P (operands[1]))
6956 return "fcos%.x %1,%0";
6958 return "fcos%.<FP:prec> %1,%0";
6962 [(trap_if (const_int -1) (const_int 7))]
6966 (define_insn "conditional_trap"
6967 [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
6968 [(cc0) (const_int 0)])
6969 (match_operand:SI 1 "const_int_operand" "I"))]
6970 "TARGET_68020 && ! flags_in_68881 ()"
6972 switch (GET_CODE (operands[0]))
6974 case EQ: return "trapeq";
6975 case NE: return "trapne";
6976 case GT: return "trapgt";
6977 case GTU: return "traphi";
6978 case LT: return "traplt";
6979 case LTU: return "trapcs";
6980 case GE: return "trapge";
6981 case GEU: return "trapcc";
6982 case LE: return "traple";
6983 case LEU: return "trapls";
6984 default: gcc_unreachable ();