* config/m68k/m68k.md (pushdi-1, pushdi, movsi+1): Don't use
[official-gcc.git] / gcc / config / m68k / m68k.md
blobb20b52e63918c3c528908a0abc0cf644712b400b
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)
11 ;; any later version.
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.
30 ;;- 
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
58 ;; info.
60 ;;- Immediate integer operand constraints:
61 ;;- 'I'  1 .. 8
62 ;;- 'J'  -32768 .. 32767
63 ;;- 'K'  all integers EXCEPT -128 .. 127
64 ;;- 'L'  -8 .. -1
65 ;;- 'M'  all integers EXCEPT -256 .. 255
66 ;;- 'N'  24 .. 31
67 ;;- 'O'  16
68 ;;- 'P'  8 .. 15
70 ;;- Assembler specs:
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.
95 ;;- These new instructions aren't directly in the md.  They are brought
96 ;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather
97 ;;- than "".
99 ;;- Information about 68060 port.
101 ;;- The 68060 executes all 68030 and 68881/2 instructions, but some must
102 ;;- be emulated in software by the OS.  It is faster to avoid these
103 ;;- instructions and issue a library call rather than trapping into
104 ;;- the kernel.  The affected instructions are: divs.l <ea>,Dr:Dq;
105 ;;- divu.l <ea>,Dr:Dq; muls.l <ea>,Dr:Dq; mulu.l <ea>,Dr:Dq; and
106 ;;- fscale.  The TUNE_68060 flag turns the use of the opcodes off.
108 ;;- Some of these insn's are composites of several m68000 op codes.
109 ;;- The assembler (or final @@??) insures that the appropriate one is
110 ;;- selected.
112 ;; UNSPEC usage:
114 (define_constants
115   [(UNSPEC_SIN  1)
116    (UNSPEC_COS  2)
117   ])
119 ;; UNSPEC_VOLATILE usage:
121 (define_constants
122   [(UNSPECV_BLOCKAGE    0)
123   ])
125 ;; Registers by name.
126 (define_constants
127   [(D0_REG              0)
128    (A0_REG              8)
129    (SP_REG              15)
130   ])
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 "")])
148 (define_insn ""
149   [(set (match_operand:DF 0 "push_operand" "=m")
150         (match_operand:DF 1 "general_operand" "ro<>fE"))]
151   ""
153   if (FP_REG_P (operands[1]))
154     return "fmove%.d %f1,%0";
155   return output_move_double (operands);
158 (define_insn "pushdi"
159   [(set (match_operand:DI 0 "push_operand" "=m")
160         (match_operand:DI 1 "general_operand" "ro<>Fi"))]
161   ""
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 ""))])]
175   ""
176   "m68k_last_compare_had_fp_operands = 0;")
178 (define_insn ""
179   [(set (cc0)
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"))]
183   ""
185   if (which_alternative == 0)
186     {
187       rtx xoperands[2];
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";
194     }
195   if (find_reg_note (insn, REG_DEAD, operands[0]))
196     {
197       cc_status.flags |= CC_REVERSED;
198       return "neg%.l %R0\;negx%.l %0";
199     }
200   else
201     /*
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.
205     */
206     return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
209 (define_expand "tstsi"
210   [(set (cc0)
211         (match_operand:SI 0 "nonimmediate_operand" ""))]
212   ""
213   "m68k_last_compare_had_fp_operands = 0;")
215 (define_insn ""
216   [(set (cc0)
217         (match_operand:SI 0 "nonimmediate_operand" "rm"))]
218   ""
220   if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
221     return "tst%.l %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"
231   [(set (cc0)
232         (match_operand:HI 0 "nonimmediate_operand" ""))]
233   ""
234   "m68k_last_compare_had_fp_operands = 0;")
236 (define_insn ""
237   [(set (cc0)
238         (match_operand:HI 0 "nonimmediate_operand" "dm"))]
239   ""
240   "tst%.w %0")
242 (define_expand "tstqi"
243   [(set (cc0)
244         (match_operand:QI 0 "nonimmediate_operand" ""))]
245   ""
246   "m68k_last_compare_had_fp_operands = 0;")
248 (define_insn ""
249   [(set (cc0)
250         (match_operand:QI 0 "nonimmediate_operand" "dm"))]
251   ""
252   "tst%.b %0")
254 (define_expand "tst<mode>"
255   [(set (cc0)
256         (match_operand:FP 0 "general_operand" ""))]
257   "TARGET_HARD_FLOAT"
259   m68k_last_compare_had_fp_operands = 1;
262 (define_insn "tst<mode>_68881"
263   [(set (cc0)
264         (match_operand:FP 0 "general_operand" "f<FP:dreg>m"))]
265   "TARGET_68881"
267   cc_status.flags = CC_IN_68881;
268   if (FP_REG_P (operands[0]))
269     return "ftst%.x %0";
270   return "ftst%.<FP:prec> %0";
273 (define_insn "tst<mode>_cf"
274   [(set (cc0)
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]))
280     return "ftst%.d %0";
281   return "ftst%.<FP:prec> %0";
285 ;; compare instructions.
287 (define_expand "cmpdi"
288   [(parallel
289     [(set (cc0)
290           (compare (match_operand:DI 0 "nonimmediate_operand" "")
291                    (match_operand:DI 1 "general_operand" "")))
292      (clobber (match_dup 2))])]
293   ""
294   "m68k_last_compare_had_fp_operands = 0; operands[2] = gen_reg_rtx (DImode);")
296 (define_insn ""
297   [(set (cc0)
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"))]
301   ""
303   if (rtx_equal_p (operands[0], operands[1]))
304     return "sub%.l %R2,%R0\;subx%.l %2,%0";
305   else
306     {
307       cc_status.flags |= CC_REVERSED;
308       return "sub%.l %R1,%R0\;subx%.l %1,%0";
309     }
312 (define_expand "cmpsi"
313   [(set (cc0)
314         (compare (match_operand:SI 0 "nonimmediate_operand" "")
315                  (match_operand:SI 1 "general_operand" "")))]
316   ""
318   m68k_last_compare_had_fp_operands = 0;
321 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
322 (define_insn ""
323   [(set (cc0)
324         (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
325                  (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
326   "!TARGET_COLDFIRE"
328   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
329     return "cmpm%.l %1,%0";
330   if (REG_P (operands[1])
331       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
332     {
333       cc_status.flags |= CC_REVERSED;
334       return "cmp%.l %d0,%d1";
335     }
336   if (ADDRESS_REG_P (operands[0])
337       && GET_CODE (operands[1]) == CONST_INT
338       && INTVAL (operands[1]) < 0x8000
339       && INTVAL (operands[1]) >= -0x8000)
340     return "cmp%.w %1,%0";
341   return "cmp%.l %d1,%d0";
344 (define_insn ""
345   [(set (cc0)
346         (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
347                  (match_operand:SI 1 "general_operand" "r,mrKs")))]
348   "TARGET_COLDFIRE"
350   if (REG_P (operands[1])
351       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
352     {
353       cc_status.flags |= CC_REVERSED;
354       return "cmp%.l %d0,%d1";
355     }
356   return "cmp%.l %d1,%d0";
359 (define_expand "cmphi"
360   [(set (cc0)
361         (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
362                  (match_operand:HI 1 "general_src_operand" "")))]
363   "!TARGET_COLDFIRE"
364   "m68k_last_compare_had_fp_operands = 0;")
366 (define_insn ""
367   [(set (cc0)
368         (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
369                  (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
370   "!TARGET_COLDFIRE"
372   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
373     return "cmpm%.w %1,%0";
374   if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
375       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
376     {
377       cc_status.flags |= CC_REVERSED;
378       return "cmp%.w %d0,%d1";
379     }
380   return "cmp%.w %d1,%d0";
383 (define_expand "cmpqi"
384   [(set (cc0)
385         (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
386                  (match_operand:QI 1 "general_src_operand" "")))]
387   "!TARGET_COLDFIRE"
388   "m68k_last_compare_had_fp_operands = 0;")
390 (define_insn ""
391   [(set (cc0)
392         (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
393                  (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
394   "!TARGET_COLDFIRE"
396   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
397     return "cmpm%.b %1,%0";
398   if (REG_P (operands[1])
399       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
400     {
401       cc_status.flags |= CC_REVERSED;
402       return "cmp%.b %d0,%d1";
403     }
404   return "cmp%.b %d1,%d0";
407 (define_expand "cmp<mode>"
408   [(set (cc0)
409         (compare (match_operand:FP 0 "general_operand" "")
410                  (match_operand:FP 1 "general_operand" "")))]
411   "TARGET_HARD_FLOAT"
413   m68k_last_compare_had_fp_operands = 1;
414   if (TARGET_COLDFIRE && !reload_completed)
415     operands[1] = force_reg (<MODE>mode, operands[1]);
418 (define_insn "cmp<mode>_68881"
419   [(set (cc0)
420         (compare (match_operand:FP 0 "general_operand" "f,m<FP:const>")
421                  (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,f")))]
422   "TARGET_68881"
424   cc_status.flags = CC_IN_68881;
425   if (FP_REG_P (operands[0]))
426     {
427       if (FP_REG_P (operands[1]))
428         return "fcmp%.x %1,%0";
429       else
430         return "fcmp%.<FP:prec> %f1,%0";
431     }
432   cc_status.flags |= CC_REVERSED;
433   return "fcmp%.<FP:prec> %f0,%1";
436 (define_insn "cmp<mode>_cf"
437   [(set (cc0)
438         (compare (match_operand:FP 0 "general_operand" "f,<FP:dreg><Q>U")
439                  (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,f")))]
440   "TARGET_COLDFIRE_FPU"
442   cc_status.flags = CC_IN_68881;
443   if (FP_REG_P (operands[0]))
444     {
445       if (FP_REG_P (operands[1]))
446         return "fcmp%.d %1,%0";
447       else
448         return "fcmp%.<FP:prec> %f1,%0";
449     }
450   cc_status.flags |= CC_REVERSED;
451   return "fcmp%.<FP:prec> %f0,%1";
454 ;; Recognizers for btst instructions.
456 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
457 ;; specified as a constant, so we must disable all patterns that may extract
458 ;; from a MEM at a constant bit position if we can't use this as a constraint.
460 (define_insn ""
461   [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
462                             (const_int 1)
463                             (minus:SI (const_int 7)
464                                       (match_operand:SI 1 "general_operand" "di"))))]
465   "!TARGET_COLDFIRE"
467   return output_btst (operands, operands[1], operands[0], insn, 7);
470 ;; This is the same as the above pattern except for the constraints.  The 'i'
471 ;; has been deleted.
473 (define_insn ""
474   [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
475                             (const_int 1)
476                             (minus:SI (const_int 7)
477                                       (match_operand:SI 1 "general_operand" "d"))))]
478   "TARGET_COLDFIRE"
480   return output_btst (operands, operands[1], operands[0], insn, 7);
483 (define_insn ""
484   [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
485                             (const_int 1)
486                             (minus:SI (const_int 31)
487                                       (match_operand:SI 1 "general_operand" "di"))))]
488   ""
490   return output_btst (operands, operands[1], operands[0], insn, 31);
493 ;; The following two patterns are like the previous two
494 ;; except that they use the fact that bit-number operands
495 ;; are automatically masked to 3 or 5 bits.
497 (define_insn ""
498   [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
499                             (const_int 1)
500                             (minus:SI (const_int 7)
501                                       (and:SI
502                                        (match_operand:SI 1 "register_operand" "d")
503                                        (const_int 7)))))]
504   ""
506   return output_btst (operands, operands[1], operands[0], insn, 7);
509 (define_insn ""
510   [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
511                             (const_int 1)
512                             (minus:SI (const_int 31)
513                                       (and:SI
514                                        (match_operand:SI 1 "register_operand" "d")
515                                        (const_int 31)))))]
516   ""
518   return output_btst (operands, operands[1], operands[0], insn, 31);
521 ;; Nonoffsettable mem refs are ok in this one pattern
522 ;; since we don't try to adjust them.
523 (define_insn ""
524   [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
525                             (const_int 1)
526                             (match_operand:SI 1 "const_int_operand" "n")))]
527   "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
529   operands[1] = GEN_INT (7 - INTVAL (operands[1]));
530   return output_btst (operands, operands[1], operands[0], insn, 7);
533 (define_insn ""
534   [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
535                             (const_int 1)
536                             (match_operand:SI 1 "const_int_operand" "n")))]
537   "!TARGET_COLDFIRE"
539   if (GET_CODE (operands[0]) == MEM)
540     {
541       operands[0] = adjust_address (operands[0], QImode,
542                                     INTVAL (operands[1]) / 8);
543       operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
544       return output_btst (operands, operands[1], operands[0], insn, 7);
545     }
546   operands[1] = GEN_INT (31 - INTVAL (operands[1]));
547   return output_btst (operands, operands[1], operands[0], insn, 31);
550 ;; This is the same as the above pattern except for the constraints.
551 ;; The 'o' has been replaced with 'Q'.
553 (define_insn ""
554   [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
555                             (const_int 1)
556                             (match_operand:SI 1 "const_int_operand" "n")))]
557   "TARGET_COLDFIRE"
559   if (GET_CODE (operands[0]) == MEM)
560     {
561       operands[0] = adjust_address (operands[0], QImode,
562                                     INTVAL (operands[1]) / 8);
563       operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
564       return output_btst (operands, operands[1], operands[0], insn, 7);
565     }
566   operands[1] = GEN_INT (31 - INTVAL (operands[1]));
567   return output_btst (operands, operands[1], operands[0], insn, 31);
571 ;; move instructions
573 ;; A special case in which it is not desirable
574 ;; to reload the constant into a data register.
575 (define_insn "pushexthisi_const"
576   [(set (match_operand:SI 0 "push_operand" "=m")
577         (match_operand:SI 1 "const_int_operand" "J"))]
578   "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
580   if (operands[1] == const0_rtx)
581     return "clr%.l %0";
582   if (valid_mov3q_const (INTVAL (operands[1])))
583     return "mov3q%.l %1,%-";
584   return "pea %a1";
587 ;This is never used.
588 ;(define_insn "swapsi"
589 ;  [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
590 ;       (match_operand:SI 1 "general_operand" "+r"))
591 ;   (set (match_dup 1) (match_dup 0))]
592 ;  ""
593 ;  "exg %1,%0")
595 ;; Special case of fullword move when source is zero.
596 ;; The reason this is special is to avoid loading a zero
597 ;; into a data reg with moveq in order to store it elsewhere.
599 (define_insn "movsi_const0"
600   [(set (match_operand:SI 0 "nonimmediate_operand" "=g")
601         (const_int 0))]
602   ;; clr insns on 68000 read before writing.
603   "((TARGET_68010 || TARGET_COLDFIRE)
604     || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0])))"
606   if (ADDRESS_REG_P (operands[0]))
607     {
608       /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
609       if (TUNE_68040_60)
610         return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
611       else
612         return "sub%.l %0,%0";
613     }
614   /* moveq is faster on the 68000.  */
615   if (DATA_REG_P (operands[0]) && TUNE_68000_10)
616     return "moveq #0,%0";
617   return "clr%.l %0";
620 ;; General case of fullword move.
622 ;; This is the main "hook" for PIC code.  When generating
623 ;; PIC, movsi is responsible for determining when the source address
624 ;; needs PIC relocation and appropriately calling legitimize_pic_address
625 ;; to perform the actual relocation.
627 ;; In both the PIC and non-PIC cases the patterns generated will
628 ;; matched by the next define_insn.
629 (define_expand "movsi"
630   [(set (match_operand:SI 0 "nonimmediate_operand" "")
631         (match_operand:SI 1 "general_operand" ""))]
632   ""
634   if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
635     {
636       /* The source is an address which requires PIC relocation.
637          Call legitimize_pic_address with the source, mode, and a relocation
638          register (a new pseudo, or the final destination if reload_in_progress
639          is set).   Then fall through normally */
640       rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
641       operands[1] = legitimize_pic_address (operands[1], SImode, temp);
642     }
643   else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
644     {
645       /* Don't allow writes to memory except via a register;
646          the m68k doesn't consider PC-relative addresses to be writable.  */
647       if (symbolic_operand (operands[0], SImode))
648         operands[0] = force_reg (SImode, XEXP (operands[0], 0));
649       else if (GET_CODE (operands[0]) == MEM
650                && symbolic_operand (XEXP (operands[0], 0), SImode))
651         operands[0] = gen_rtx_MEM (SImode,
652                                force_reg (SImode, XEXP (operands[0], 0)));
653     }
656 ;; General case of fullword move.  The register constraints
657 ;; force integer constants in range for a moveq to be reloaded
658 ;; if they are headed for memory.
659 (define_insn ""
660   ;; Notes: make sure no alternative allows g vs g.
661   ;; We don't allow f-regs since fixed point cannot go in them.
662   [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
663         (match_operand:SI 1 "general_src_operand" "damSKT,n,i"))]
665   "!TARGET_COLDFIRE"
667   return output_move_simode (operands);
670 ;; ColdFire move instructions can have at most one operand of mode >= 6.
671 (define_insn "*movsi_cf"
672   [(set (match_operand:SI 0 "nonimmediate_operand" "=r<Q>,g,U")
673         (match_operand:SI 1 "general_operand" "g,Rr<Q>,U"))]
674   "TARGET_COLDFIRE"
675   "* return output_move_simode (operands);")
677 ;; Special case of fullword move, where we need to get a non-GOT PIC
678 ;; reference into an address register.
679 (define_insn ""
680   [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
681         (match_operand:SI 1 "pcrel_address" ""))]
682   "TARGET_PCREL"
684   if (push_operand (operands[0], SImode))
685     return "pea %a1";
686   return "lea %a1,%0";
689 (define_expand "movhi"
690   [(set (match_operand:HI 0 "nonimmediate_operand" "")
691         (match_operand:HI 1 "general_operand" ""))]
692   ""
693   "")
695 (define_insn ""
696   [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
697         (match_operand:HI 1 "general_src_operand" "gS"))]
698   "!TARGET_COLDFIRE"
699   "* return output_move_himode (operands);")
701 (define_insn ""
702   [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
703         (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
704   "TARGET_COLDFIRE"
705   "* return output_move_himode (operands);")
707 (define_expand "movstricthi"
708   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
709         (match_operand:HI 1 "general_src_operand" ""))]
710   ""
711   "")
713 (define_insn ""
714   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
715         (match_operand:HI 1 "general_src_operand" "rmSn"))]
716   "!TARGET_COLDFIRE"
717   "* return output_move_stricthi (operands);")
719 (define_insn ""
720   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
721         (match_operand:HI 1 "general_src_operand" "rmn,r"))]
722   "TARGET_COLDFIRE"
723   "* return output_move_stricthi (operands);")
725 (define_expand "movqi"
726   [(set (match_operand:QI 0 "nonimmediate_operand" "")
727         (match_operand:QI 1 "general_src_operand" ""))]
728   ""
729   "")
731 (define_insn ""
732   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
733         (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
734   "!TARGET_COLDFIRE"
735   "* return output_move_qimode (operands);")
737 (define_insn ""
738   [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
739         (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
740   "TARGET_COLDFIRE"
741   "* return output_move_qimode (operands);")
743 (define_expand "movstrictqi"
744   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
745         (match_operand:QI 1 "general_src_operand" ""))]
746   ""
747   "")
749 (define_insn ""
750   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
751         (match_operand:QI 1 "general_src_operand" "dmSn"))]
752   "!TARGET_COLDFIRE"
753   "* return output_move_strictqi (operands);")
755 (define_insn ""
756   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d,m"))
757         (match_operand:QI 1 "general_src_operand" "dmn,d"))]
758   "TARGET_COLDFIRE"
759   "* return output_move_strictqi (operands);")
761 (define_expand "pushqi1"
762   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
763    (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
764         (match_operand:QI 0 "general_operand" ""))]
765   "!TARGET_COLDFIRE"
766   "")
768 (define_expand "reload_insf"
769   [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
770         (match_operand:SF 1 "general_operand" "mf"))
771    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
772   "TARGET_COLDFIRE_FPU"
774   if (emit_move_sequence (operands, SFmode, operands[2]))
775     DONE;
777   /* We don't want the clobber emitted, so handle this ourselves. */
778   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
779   DONE;
782 (define_expand "reload_outsf"
783   [(set (match_operand:SF 0 "general_operand" "")
784         (match_operand:SF 1 "register_operand" "f"))
785    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
786   "TARGET_COLDFIRE_FPU"
788   if (emit_move_sequence (operands, SFmode, operands[2]))
789     DONE;
791   /* We don't want the clobber emitted, so handle this ourselves. */
792   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
793   DONE;
796 (define_expand "movsf"
797   [(set (match_operand:SF 0 "nonimmediate_operand" "")
798         (match_operand:SF 1 "general_operand" ""))]
799   ""
800   "")
802 (define_insn ""
803   [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
804         (match_operand:SF 1 "general_operand" "rmfF"))]
805   "!TARGET_COLDFIRE"
807   if (FP_REG_P (operands[0]))
808     {
809       if (FP_REG_P (operands[1]))
810         return "f%$move%.x %1,%0";
811       else if (ADDRESS_REG_P (operands[1]))
812         return "move%.l %1,%-\;f%$move%.s %+,%0";
813       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
814         return output_move_const_single (operands);
815       return "f%$move%.s %f1,%0";
816     }
817   if (FP_REG_P (operands[1]))
818     {
819       if (ADDRESS_REG_P (operands[0]))
820         return "fmove%.s %1,%-\;move%.l %+,%0";
821       return "fmove%.s %f1,%0";
822     }
823   if (operands[1] == CONST0_RTX (SFmode)
824       /* clr insns on 68000 read before writing.  */
825       && ((TARGET_68010 || TARGET_COLDFIRE)
826           || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
827     {
828       if (ADDRESS_REG_P (operands[0]))
829         {
830           /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
831           if (TUNE_68040_60)
832             return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
833           else
834             return "sub%.l %0,%0";
835         }
836       /* moveq is faster on the 68000.  */
837       if (DATA_REG_P (operands[0]) && TUNE_68000_10)
838         return "moveq #0,%0";
839       return "clr%.l %0";
840     }
841   return "move%.l %1,%0";
844 (define_insn "movsf_cf_soft"
845   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,g")
846         (match_operand:SF 1 "general_operand" "g,r"))]
847   "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
849   return "move%.l %1,%0";
852 (define_insn "movsf_cf_hard"
853   [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f,    f,mr,f,r<Q>,f
854 ,m")
855         (match_operand:SF 1 "general_operand"      " f,     r<Q>U,f,rm,F,F,   m
856 ,f"))]
857   "TARGET_COLDFIRE_FPU"
859   if (which_alternative == 4 || which_alternative == 5) {
860     rtx xoperands[2];
861     REAL_VALUE_TYPE r;
862     long l;
863     REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
864     REAL_VALUE_TO_TARGET_SINGLE (r, l);
865     xoperands[0] = operands[0];
866     xoperands[1] = GEN_INT (l);
867     if (which_alternative == 5) {
868       if (l == 0) {
869         if (ADDRESS_REG_P (xoperands[0]))
870           output_asm_insn ("sub%.l %0,%0", xoperands);
871         else
872           output_asm_insn ("clr%.l %0", xoperands);
873       } else
874         if (GET_CODE (operands[0]) == MEM
875             && symbolic_operand (XEXP (operands[0], 0), SImode))
876           output_asm_insn ("move%.l %1,%-;move%.l %+,%0", xoperands);
877         else
878           output_asm_insn ("move%.l %1,%0", xoperands);
879       return "";
880     }
881     if (l != 0)
882       output_asm_insn ("move%.l %1,%-;fsmove%.s %+,%0", xoperands);
883     else
884       output_asm_insn ("clr%.l %-;fsmove%.s %+,%0", xoperands);
885     return "";
886   }
887   if (FP_REG_P (operands[0]))
888     {
889       if (ADDRESS_REG_P (operands[1]))
890         return "move%.l %1,%-;fsmove%.s %+,%0";
891       if (FP_REG_P (operands[1]))
892         return "fsmove%.d %1,%0";
893       return "fsmove%.s %f1,%0";
894     }
895   if (FP_REG_P (operands[1]))
896     {
897       if (ADDRESS_REG_P (operands[0]))
898         return "fmove%.s %1,%-;move%.l %+,%0";
899       return "fmove%.s %f1,%0";
900     }
901   if (operands[1] == CONST0_RTX (SFmode))
902     {
903       if (ADDRESS_REG_P (operands[0]))
904         return "sub%.l %0,%0";
905       return "clr%.l %0";
906     }
907   return "move%.l %1,%0";
910 (define_expand "reload_indf"
911   [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
912         (match_operand:DF 1 "general_operand" "mf"))
913    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
914   "TARGET_COLDFIRE_FPU"
916   if (emit_move_sequence (operands, DFmode, operands[2]))
917     DONE;
919   /* We don't want the clobber emitted, so handle this ourselves. */
920   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
921   DONE;
924 (define_expand "reload_outdf"
925   [(set (match_operand:DF 0 "general_operand" "")
926         (match_operand:DF 1 "register_operand" "f"))
927    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
928   "TARGET_COLDFIRE_FPU"
930   if (emit_move_sequence (operands, DFmode, operands[2]))
931     DONE;
933   /* We don't want the clobber emitted, so handle this ourselves. */
934   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
935   DONE;
938 (define_expand "movdf"
939   [(set (match_operand:DF 0 "nonimmediate_operand" "")
940         (match_operand:DF 1 "general_operand" ""))]
941   ""
943   if (TARGET_COLDFIRE_FPU)
944     if (emit_move_sequence (operands, DFmode, 0))
945       DONE;
948 (define_insn ""
949   [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
950         (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
951 ;  [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
952 ;       (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
953   "!TARGET_COLDFIRE"
955   if (FP_REG_P (operands[0]))
956     {
957       if (FP_REG_P (operands[1]))
958         return "f%&move%.x %1,%0";
959       if (REG_P (operands[1]))
960         {
961           rtx xoperands[2];
962           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
963           output_asm_insn ("move%.l %1,%-", xoperands);
964           output_asm_insn ("move%.l %1,%-", operands);
965           return "f%&move%.d %+,%0";
966         }
967       if (GET_CODE (operands[1]) == CONST_DOUBLE)
968         return output_move_const_double (operands);
969       return "f%&move%.d %f1,%0";
970     }
971   else if (FP_REG_P (operands[1]))
972     {
973       if (REG_P (operands[0]))
974         {
975           output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
976           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
977           return "move%.l %+,%0";
978         }
979       else
980         return "fmove%.d %f1,%0";
981     }
982   return output_move_double (operands);
985 (define_insn "movdf_cf_soft"
986   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
987         (match_operand:DF 1 "general_operand" "g,r"))]
988   "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
990   return output_move_double (operands);
993 (define_insn "movdf_cf_hard"
994   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,    <Q>U,r,f,r,r,m,f")
995         (match_operand:DF 1 "general_operand"      " f<Q>U,f,   f,r,r,m,r,E"))]
996   "TARGET_COLDFIRE_FPU"
998   rtx xoperands[3];
999   REAL_VALUE_TYPE r;
1000   long l[2];
1002   switch (which_alternative)
1003     {
1004     default:
1005       return "fdmove%.d %1,%0";
1006     case 1:
1007       return "fmove%.d %1,%0";
1008     case 2:
1009       return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1010     case 3:
1011       return "move%.l %R1,%-;move%.l %1,%-;fdmove%.d %+,%0";
1012     case 4: case 5: case 6:
1013       return output_move_double (operands);
1014     case 7:
1015       REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1016       REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1017       xoperands[0] = operands[0];
1018       xoperands[1] = GEN_INT (l[0]);
1019       xoperands[2] = GEN_INT (l[1]);
1020       if (operands[1] == CONST0_RTX (DFmode))
1021         output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1022                         xoperands);
1023       else
1024         if (l[1] == 0)
1025           output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1026                           xoperands);
1027         else
1028           output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1029                           xoperands);
1030       return "";
1031     }
1034 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1035 ;; allowed.  Most but not all have predicates and constraint that disallow
1036 ;; constants.  Most but not all have output templates that handle constants.
1037 ;; See also LEGITIMATE_CONSTANT_P.
1039 (define_expand "movxf"
1040   [(set (match_operand:XF 0 "nonimmediate_operand" "")
1041         (match_operand:XF 1 "general_operand" ""))]
1042   ""
1044   /* We can't rewrite operands during reload.  */
1045   if (! reload_in_progress)
1046     {
1047       if (CONSTANT_P (operands[1]))
1048         {
1049           operands[1] = force_const_mem (XFmode, operands[1]);
1050           if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1051             operands[1] = adjust_address (operands[1], XFmode, 0);
1052         }
1053       if (flag_pic && TARGET_PCREL)
1054         {
1055           /* Don't allow writes to memory except via a register; the
1056              m68k doesn't consider PC-relative addresses to be writable.  */
1057           if (GET_CODE (operands[0]) == MEM
1058               && symbolic_operand (XEXP (operands[0], 0), SImode))
1059             operands[0] = gen_rtx_MEM (XFmode,
1060                                    force_reg (SImode, XEXP (operands[0], 0)));
1061         }
1062     }
1065 (define_insn ""
1066   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1067         (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1068   "TARGET_68881"
1070   if (FP_REG_P (operands[0]))
1071     {
1072       if (FP_REG_P (operands[1]))
1073         return "fmove%.x %1,%0";
1074       if (REG_P (operands[1]))
1075         {
1076           rtx xoperands[2];
1077           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1078           output_asm_insn ("move%.l %1,%-", xoperands);
1079           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1080           output_asm_insn ("move%.l %1,%-", xoperands);
1081           output_asm_insn ("move%.l %1,%-", operands);
1082           return "fmove%.x %+,%0";
1083         }
1084       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1085         return "fmove%.x %1,%0";
1086       return "fmove%.x %f1,%0";
1087     }
1088   if (FP_REG_P (operands[1]))
1089     {
1090       if (REG_P (operands[0]))
1091         {
1092           output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1093           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1094           output_asm_insn ("move%.l %+,%0", operands);
1095           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1096           return "move%.l %+,%0";
1097         }
1098       /* Must be memory destination.  */
1099       return "fmove%.x %f1,%0";
1100     }
1101   return output_move_double (operands);
1104 (define_insn ""
1105   [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1106         (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1107   "! TARGET_68881 && ! TARGET_COLDFIRE"
1109   if (FP_REG_P (operands[0]))
1110     {
1111       if (FP_REG_P (operands[1]))
1112         return "fmove%.x %1,%0";
1113       if (REG_P (operands[1]))
1114         {
1115           rtx xoperands[2];
1116           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1117           output_asm_insn ("move%.l %1,%-", xoperands);
1118           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1119           output_asm_insn ("move%.l %1,%-", xoperands);
1120           output_asm_insn ("move%.l %1,%-", operands);
1121           return "fmove%.x %+,%0";
1122         }
1123       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1124         return "fmove%.x %1,%0";
1125       return "fmove%.x %f1,%0";
1126     }
1127   if (FP_REG_P (operands[1]))
1128     {
1129       if (REG_P (operands[0]))
1130         {
1131           output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1132           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1133           output_asm_insn ("move%.l %+,%0", operands);
1134           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1135           return "move%.l %+,%0";
1136         }
1137       else
1138         return "fmove%.x %f1,%0";
1139     }
1140   return output_move_double (operands);
1143 (define_insn ""
1144   [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1145         (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1146   "! TARGET_68881 && TARGET_COLDFIRE"
1147   "* return output_move_double (operands);")
1149 (define_expand "movdi"
1150   ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1151   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1152         (match_operand:DI 1 "general_operand" ""))]
1153   ""
1154   "")
1156 ;; movdi can apply to fp regs in some cases
1157 (define_insn ""
1158   ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1159   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1160         (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1161 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1162 ;       (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1163 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1164 ;       (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1165   "!TARGET_COLDFIRE"
1167   if (FP_REG_P (operands[0]))
1168     {
1169       if (FP_REG_P (operands[1]))
1170         return "fmove%.x %1,%0";
1171       if (REG_P (operands[1]))
1172         {
1173           rtx xoperands[2];
1174           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1175           output_asm_insn ("move%.l %1,%-", xoperands);
1176           output_asm_insn ("move%.l %1,%-", operands);
1177           return "fmove%.d %+,%0";
1178         }
1179       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1180         return output_move_const_double (operands);
1181       return "fmove%.d %f1,%0";
1182     }
1183   else if (FP_REG_P (operands[1]))
1184     {
1185       if (REG_P (operands[0]))
1186         {
1187           output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1188           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1189           return "move%.l %+,%0";
1190         }
1191       else
1192         return "fmove%.d %f1,%0";
1193     }
1194   return output_move_double (operands);
1197 (define_insn ""
1198   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1199         (match_operand:DI 1 "general_operand" "g,r"))]
1200   "TARGET_COLDFIRE"
1201   "* return output_move_double (operands);")
1203 ;; Thus goes after the move instructions
1204 ;; because the move instructions are better (require no spilling)
1205 ;; when they can apply.  It goes before the add/sub insns
1206 ;; so we will prefer it to them.
1208 (define_insn "pushasi"
1209   [(set (match_operand:SI 0 "push_operand" "=m")
1210         (match_operand:SI 1 "address_operand" "p"))]
1211   ""
1212   "pea %a1")
1214 ;; truncation instructions
1215 (define_insn "truncsiqi2"
1216   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1217         (truncate:QI
1218          (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1219   ""
1221   if (GET_CODE (operands[0]) == REG)
1222     {
1223       /* Must clear condition codes, since the move.l bases them on
1224          the entire 32 bits, not just the desired 8 bits.  */
1225       CC_STATUS_INIT;
1226       return "move%.l %1,%0";
1227     }
1228   if (GET_CODE (operands[1]) == MEM)
1229     operands[1] = adjust_address (operands[1], QImode, 3);
1230   return "move%.b %1,%0";
1233 (define_insn "trunchiqi2"
1234   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1235         (truncate:QI
1236          (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1237   ""
1239   if (GET_CODE (operands[0]) == REG
1240       && (GET_CODE (operands[1]) == MEM
1241           || GET_CODE (operands[1]) == CONST_INT))
1242     {
1243       /* Must clear condition codes, since the move.w bases them on
1244          the entire 16 bits, not just the desired 8 bits.  */
1245       CC_STATUS_INIT;
1246       return "move%.w %1,%0";
1247     }
1248   if (GET_CODE (operands[0]) == REG)
1249     {
1250       /* Must clear condition codes, since the move.l bases them on
1251          the entire 32 bits, not just the desired 8 bits.  */
1252       CC_STATUS_INIT;
1253       return "move%.l %1,%0";
1254     }
1255   if (GET_CODE (operands[1]) == MEM)
1256     operands[1] = adjust_address (operands[1], QImode, 1);
1257   return "move%.b %1,%0";
1260 (define_insn "truncsihi2"
1261   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1262         (truncate:HI
1263          (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1264   ""
1266   if (GET_CODE (operands[0]) == REG)
1267     {
1268       /* Must clear condition codes, since the move.l bases them on
1269          the entire 32 bits, not just the desired 8 bits.  */
1270       CC_STATUS_INIT;
1271       return "move%.l %1,%0";
1272     }
1273   if (GET_CODE (operands[1]) == MEM)
1274     operands[1] = adjust_address (operands[1], QImode, 2);
1275   return "move%.w %1,%0";
1278 ;; zero extension instructions
1280 ;; two special patterns to match various post_inc/pre_dec patterns
1281 (define_insn_and_split "*zero_extend_inc"
1282   [(set (match_operand 0 "post_inc_operand" "")
1283         (zero_extend (match_operand 1 "register_operand" "")))]
1284   "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1285    GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1286    GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1287   "#"
1288   ""
1289   [(set (match_dup 0)
1290         (const_int 0))
1291    (set (match_dup 0)
1292         (match_dup 1))]
1294   operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1297 (define_insn_and_split "*zero_extend_dec"
1298   [(set (match_operand 0 "pre_dec_operand" "")
1299         (zero_extend (match_operand 1 "register_operand" "")))]
1300   "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1301    GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1302    GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1303    GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1304   "#"
1305   ""
1306   [(set (match_dup 0)
1307         (match_dup 1))
1308    (set (match_dup 0)
1309         (const_int 0))]
1311   operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1314 (define_insn_and_split "zero_extendqidi2"
1315   [(set (match_operand:DI 0 "register_operand" "")
1316         (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1317   ""
1318   "#"
1319   ""
1320   [(set (match_dup 2)
1321         (zero_extend:SI (match_dup 1)))
1322    (set (match_dup 3)
1323         (const_int 0))]
1325   operands[2] = gen_lowpart (SImode, operands[0]);
1326   operands[3] = gen_highpart (SImode, operands[0]);
1329 (define_insn_and_split "zero_extendhidi2"
1330   [(set (match_operand:DI 0 "register_operand" "")
1331         (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1332   ""
1333   "#"
1334   ""
1335   [(set (match_dup 2)
1336         (zero_extend:SI (match_dup 1)))
1337    (set (match_dup 3)
1338         (const_int 0))]
1340   operands[2] = gen_lowpart (SImode, operands[0]);
1341   operands[3] = gen_highpart (SImode, operands[0]);
1344 (define_expand "zero_extendsidi2"
1345   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1346         (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1347   ""
1349   if (GET_CODE (operands[0]) == MEM
1350       && GET_CODE (operands[1]) == MEM)
1351     operands[1] = force_reg (SImode, operands[1]);
1354 (define_insn_and_split "*zero_extendsidi2"
1355   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1356         (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1357   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1358   "#"
1359   ""
1360   [(set (match_dup 2)
1361         (match_dup 1))
1362    (set (match_dup 3)
1363         (const_int 0))]
1365   operands[2] = gen_lowpart (SImode, operands[0]);
1366   operands[3] = gen_highpart (SImode, operands[0]);
1369 (define_insn "*zero_extendhisi2_cf"
1370   [(set (match_operand:SI 0 "register_operand" "=d")
1371         (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1372   "TARGET_ISAB"
1373   "mvz%.w %1,%0")
1375 (define_insn "zero_extendhisi2"
1376   [(set (match_operand:SI 0 "register_operand" "=d")
1377         (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1378   ""
1379   "#")
1381 (define_expand "zero_extendqihi2"
1382   [(set (match_operand:HI 0 "register_operand" "")
1383         (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1384   "!TARGET_COLDFIRE"
1385   "")
1387 (define_insn "*zero_extendqihi2"
1388   [(set (match_operand:HI 0 "register_operand" "=d")
1389         (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1390   "!TARGET_COLDFIRE"
1391   "#")
1393 (define_insn "*zero_extendqisi2_cfv4"
1394   [(set (match_operand:SI 0 "register_operand" "=d")
1395         (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1396   "TARGET_ISAB"
1397   "mvz%.b %1,%0")
1399 (define_insn "zero_extendqisi2"
1400   [(set (match_operand:SI 0 "register_operand" "=d")
1401         (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1402   ""
1403   "#")
1405 ;; these two pattern split everything else which isn't matched by
1406 ;; something else above
1407 (define_split
1408   [(set (match_operand 0 "register_operand" "")
1409         (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1410   "!TARGET_ISAB
1411    && reload_completed
1412    && reg_mentioned_p (operands[0], operands[1])"
1413   [(set (strict_low_part (match_dup 2))
1414         (match_dup 1))
1415    (set (match_dup 0)
1416         (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1418   operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1419   operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1420   operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1423 (define_split
1424   [(set (match_operand 0 "register_operand" "")
1425         (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1426   "!TARGET_ISAB && reload_completed"
1427   [(set (match_dup 0)
1428         (const_int 0))
1429    (set (strict_low_part (match_dup 2))
1430         (match_dup 1))]
1432   operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1435 ;; sign extension instructions
1437 (define_insn "extendqidi2"
1438   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1439         (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1440   ""
1442   CC_STATUS_INIT;
1443   operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1444   if (TARGET_ISAB)
1445     return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1446   if (TARGET_68020 || TARGET_COLDFIRE)
1447     {
1448       if (ADDRESS_REG_P (operands[1]))
1449         return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1450       else
1451         return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1452     }
1453   else
1454     {
1455       if (ADDRESS_REG_P (operands[1]))
1456         return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1457       else
1458         return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1459     }
1462 (define_insn "extendhidi2"
1463   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1464         (sign_extend:DI
1465          (match_operand:HI 1 "general_src_operand" "rmS")))]
1466   ""
1468   CC_STATUS_INIT;
1469   operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1470   if (TARGET_ISAB)
1471     return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1472   if (TARGET_68020 || TARGET_COLDFIRE)
1473     return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1474   else
1475     return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1478 (define_insn "extendsidi2"
1479   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1480         (sign_extend:DI
1481          (match_operand:SI 1 "general_operand" "rm")))]
1482   ""
1484   CC_STATUS_INIT;
1485   operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1486   if (TARGET_68020 || TARGET_COLDFIRE)
1487     return "move%.l %1,%2\;smi %0\;extb%.l %0";
1488   else
1489     return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
1492 ;; Special case when one can avoid register clobbering, copy and test
1493 ;; Maybe there is a way to make that the general case, by forcing the
1494 ;; result of the SI tree to be in the lower register of the DI target
1496 (define_insn "extendplussidi"
1497   [(set (match_operand:DI 0 "register_operand" "=d")
1498     (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1499             (match_operand:SI 2 "general_operand" "rmn"))))]
1500   ""
1502   CC_STATUS_INIT;
1503   operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1504   if (GET_CODE (operands[1]) == CONST_INT
1505   && (unsigned) INTVAL (operands[1]) > 8)
1506     {
1507       rtx tmp = operands[1];
1509       operands[1] = operands[2];
1510       operands[2] = tmp;
1511     }
1512   if (GET_CODE (operands[1]) == REG
1513       && REGNO (operands[1]) == REGNO (operands[3]))
1514     output_asm_insn ("add%.l %2,%3", operands);
1515   else
1516     output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1517   if (TARGET_68020 || TARGET_COLDFIRE)
1518     return "smi %0\;extb%.l %0";
1519   else
1520     return "smi %0\;ext%.w %0\;ext%.l %0";
1523 (define_expand "extendhisi2"
1524   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1525         (sign_extend:SI
1526          (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1527   ""
1528   "")
1530 (define_insn "*cfv4_extendhisi2"
1531   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1532         (sign_extend:SI
1533          (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1534   "TARGET_ISAB"
1535   "mvs%.w %1,%0")
1537 (define_insn "*68k_extendhisi2"
1538   [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1539         (sign_extend:SI
1540          (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1541   "!TARGET_ISAB"
1543   if (ADDRESS_REG_P (operands[0]))
1544     return "move%.w %1,%0";
1545   return "ext%.l %0";
1548 (define_insn "extendqihi2"
1549   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1550         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1551   ""
1552   "ext%.w %0")
1554 (define_expand "extendqisi2"
1555   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1556         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1557   "TARGET_68020 || TARGET_COLDFIRE"
1558   "")
1560 (define_insn "*cfv4_extendqisi2"
1561   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1562         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1563   "TARGET_ISAB"
1564   "mvs%.b %1,%0")
1566 (define_insn "*68k_extendqisi2"
1567   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1568         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1569   "TARGET_68020 || (TARGET_COLDFIRE && !TARGET_ISAB)"
1570   "extb%.l %0")
1572 ;; Conversions between float and double.
1574 (define_expand "extendsfdf2"
1575   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1576         (float_extend:DF
1577          (match_operand:SF 1 "general_operand" "")))]
1578   "TARGET_HARD_FLOAT"
1579   "")
1581 (define_insn ""
1582   [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1583         (float_extend:DF
1584           (match_operand:SF 1 "general_operand" "f,dmF")))]
1585   "TARGET_68881"
1587   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1588     {
1589       if (REGNO (operands[0]) == REGNO (operands[1]))
1590         {
1591           /* Extending float to double in an fp-reg is a no-op.
1592              NOTICE_UPDATE_CC has already assumed that the
1593              cc will be set.  So cancel what it did.  */
1594           cc_status = cc_prev_status;
1595           return "";
1596         }
1597       return "f%&move%.x %1,%0";
1598     }
1599   if (FP_REG_P (operands[0]))
1600     return "f%&move%.s %f1,%0";
1601   if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1602     {
1603       output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1604       operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1605       return "move%.l %+,%0";
1606     }
1607   return "fmove%.d %f1,%0";
1610 (define_insn "extendsfdf2_cf"
1611   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
1612         (float_extend:DF
1613          (match_operand:SF 1 "general_operand" "f,<Q>U")))]
1614   "TARGET_COLDFIRE_FPU"
1616   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1617     {
1618       if (REGNO (operands[0]) == REGNO (operands[1]))
1619         {
1620           /* Extending float to double in an fp-reg is a no-op.
1621              NOTICE_UPDATE_CC has already assumed that the
1622              cc will be set.  So cancel what it did.  */
1623           cc_status = cc_prev_status;
1624           return "";
1625         }
1626       return "fdmove%.d %1,%0";
1627     }
1628   return "fdmove%.s %f1,%0";
1631 ;; This cannot output into an f-reg because there is no way to be
1632 ;; sure of truncating in that case.
1633 (define_expand "truncdfsf2"
1634   [(set (match_operand:SF 0 "nonimmediate_operand" "")
1635         (float_truncate:SF
1636           (match_operand:DF 1 "general_operand" "")))]
1637   "TARGET_HARD_FLOAT"
1638   "")
1640 ;; On the '040 we can truncate in a register accurately and easily.
1641 (define_insn ""
1642   [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1643         (float_truncate:SF
1644           (match_operand:DF 1 "general_operand" "fmG")))]
1645   "TARGET_68881 && TARGET_68040"
1647   if (FP_REG_P (operands[1]))
1648     return "f%$move%.x %1,%0";
1649   return "f%$move%.d %f1,%0";
1652 (define_insn "truncdfsf2_cf"
1653   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
1654         (float_truncate:SF
1655           (match_operand:DF 1 "general_operand" "<Q>U,f")))]
1656   "TARGET_COLDFIRE_FPU"
1657   "@
1658   fsmove%.d %1,%0
1659   fmove%.s %1,%0")
1661 (define_insn ""
1662   [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1663         (float_truncate:SF
1664           (match_operand:DF 1 "general_operand" "f")))]
1665   "TARGET_68881"
1666   "fmove%.s %f1,%0")
1668 ;; Conversion between fixed point and floating point.
1669 ;; Note that among the fix-to-float insns
1670 ;; the ones that start with SImode come first.
1671 ;; That is so that an operand that is a CONST_INT
1672 ;; (and therefore lacks a specific machine mode).
1673 ;; will be recognized as SImode (which is always valid)
1674 ;; rather than as QImode or HImode.
1676 (define_expand "floatsi<mode>2"
1677   [(set (match_operand:FP 0 "nonimmediate_operand" "")
1678         (float:FP (match_operand:SI 1 "general_operand" "")))]
1679   "TARGET_HARD_FLOAT"
1680   "")
1682 (define_insn "floatsi<mode>2_68881"
1683   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1684         (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
1685   "TARGET_68881"
1686   "f<FP:round>move%.l %1,%0")
1688 (define_insn "floatsi<mode>2_cf"
1689   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1690         (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
1691   "TARGET_COLDFIRE_FPU"
1692   "f<FP:prec>move%.l %1,%0")
1695 (define_expand "floathi<mode>2"
1696   [(set (match_operand:FP 0 "nonimmediate_operand" "")
1697         (float:FP (match_operand:HI 1 "general_operand" "")))]
1698   "TARGET_HARD_FLOAT"
1699   "")
1701 (define_insn "floathi<mode>2_68881"
1702   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1703         (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
1704   "TARGET_68881"
1705   "fmove%.w %1,%0")
1707 (define_insn "floathi<mode>2_cf"
1708   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1709         (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
1710   "TARGET_COLDFIRE_FPU"
1711   "fmove%.w %1,%0")
1714 (define_expand "floatqi<mode>2"
1715   [(set (match_operand:FP 0 "nonimmediate_operand" "")
1716         (float:FP (match_operand:QI 1 "general_operand" "")))]
1717   "TARGET_HARD_FLOAT"
1718   "")
1720 (define_insn "floatqi<mode>2_68881"
1721   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1722         (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
1723   "TARGET_68881"
1724   "fmove%.b %1,%0")
1726 (define_insn "floatqi<mode>2_cf"
1727   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1728         (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
1729   "TARGET_COLDFIRE_FPU"
1730   "fmove%.b %1,%0")
1733 ;; New routines to convert floating-point values to integers
1734 ;; to be used on the '040.  These should be faster than trapping
1735 ;; into the kernel to emulate fintrz.  They should also be faster
1736 ;; than calling the subroutines fixsfsi or fixdfsi.
1738 (define_insn "fix_truncdfsi2"
1739   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1740         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1741    (clobber (match_scratch:SI 2 "=d"))
1742    (clobber (match_scratch:SI 3 "=d"))]
1743   "TARGET_68881 && TUNE_68040"
1745   CC_STATUS_INIT;
1746   return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.l %1,%0\;fmovem%.l %2,%!";
1749 (define_insn "fix_truncdfhi2"
1750   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1751         (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1752    (clobber (match_scratch:SI 2 "=d"))
1753    (clobber (match_scratch:SI 3 "=d"))]
1754   "TARGET_68881 && TUNE_68040"
1756   CC_STATUS_INIT;
1757   return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.w %1,%0\;fmovem%.l %2,%!";
1760 (define_insn "fix_truncdfqi2"
1761   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1762         (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1763    (clobber (match_scratch:SI 2 "=d"))
1764    (clobber (match_scratch:SI 3 "=d"))]
1765   "TARGET_68881 && TUNE_68040"
1767   CC_STATUS_INIT;
1768   return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.b %1,%0\;fmovem%.l %2,%!";
1771 ;; Convert a float to a float whose value is an integer.
1772 ;; This is the first stage of converting it to an integer type.
1774 (define_expand "ftrunc<mode>2"
1775   [(set (match_operand:FP 0 "nonimmediate_operand" "")
1776         (fix:FP (match_operand:FP 1 "general_operand" "")))]
1777   "TARGET_HARD_FLOAT && !TUNE_68040"
1778   "")
1780 (define_insn "ftrunc<mode>2_68881"
1781   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1782         (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
1783   "TARGET_68881 && !TUNE_68040"
1785   if (FP_REG_P (operands[1]))
1786     return "fintrz%.x %f1,%0";
1787   return "fintrz%.<FP:prec> %f1,%0";
1790 (define_insn "ftrunc<mode>2_cf"
1791   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1792         (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
1793   "TARGET_COLDFIRE_FPU"
1795   if (FP_REG_P (operands[1]))
1796     return "fintrz%.d %f1,%0";
1797   return "fintrz%.<FP:prec> %f1,%0";
1800 ;; Convert a float whose value is an integer
1801 ;; to an actual integer.  Second stage of converting float to integer type.
1802 (define_expand "fix<mode>qi2"
1803   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1804         (fix:QI (match_operand:FP 1 "general_operand" "")))]
1805   "TARGET_HARD_FLOAT"
1806   "")
1808 (define_insn "fix<mode>qi2_68881"
1809   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
1810         (fix:QI (match_operand:FP 1 "general_operand" "f")))]
1811   "TARGET_68881"
1812   "fmove%.b %1,%0")
1814 (define_insn "fix<mode>qi2_cf"
1815   [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
1816         (fix:QI (match_operand:FP 1 "general_operand" "f")))]
1817   "TARGET_COLDFIRE_FPU"
1818   "fmove%.b %1,%0")
1820 (define_expand "fix<mode>hi2"
1821   [(set (match_operand:HI 0 "nonimmediate_operand" "")
1822         (fix:HI (match_operand:FP 1 "general_operand" "")))]
1823   "TARGET_HARD_FLOAT"
1824   "")
1826 (define_insn "fix<mode>hi2_68881"
1827   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1828         (fix:HI (match_operand:FP 1 "general_operand" "f")))]
1829   "TARGET_68881"
1830   "fmove%.w %1,%0")
1832 (define_insn "fix<mode>hi2_cf"
1833   [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
1834         (fix:HI (match_operand:FP 1 "general_operand" "f")))]
1835   "TARGET_COLDFIRE_FPU"
1836   "fmove%.w %1,%0")
1838 (define_expand "fix<mode>si2"
1839   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1840         (fix:SI (match_operand:FP 1 "general_operand" "")))]
1841   "TARGET_HARD_FLOAT"
1842   "")
1844 (define_insn "fix<mode>si2_68881"
1845   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1846         (fix:SI (match_operand:FP 1 "general_operand" "f")))]
1847   "TARGET_68881"
1848   "fmove%.l %1,%0")
1850 (define_insn "fix<mode>si2_cf"
1851   [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
1852         (fix:SI (match_operand:FP 1 "general_operand" "f")))]
1853   "TARGET_COLDFIRE_FPU"
1854   "fmove%.l %1,%0")
1857 ;; add instructions
1859 (define_insn "adddi_lshrdi_63"
1860   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1861     (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
1862             (const_int 63))
1863         (match_dup 1)))
1864    (clobber (match_scratch:SI 2 "=d"))]
1865   ""
1867   operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1868   if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
1869     return
1870     "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
1871   if (GET_CODE (operands[1]) == REG)
1872     operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1873   else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
1874         || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1875     operands[4] = operands[1];
1876   else
1877     operands[4] = adjust_address (operands[1], SImode, 4);
1878   if (GET_CODE (operands[1]) == MEM
1879    && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
1880     output_asm_insn ("move%.l %4,%3", operands);
1881   output_asm_insn ("move%.l %1,%0\;smi %2", operands);
1882   if (TARGET_68020 || TARGET_COLDFIRE)
1883     output_asm_insn ("extb%.l %2", operands);
1884   else
1885     output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
1886   if (GET_CODE (operands[1]) != MEM
1887    || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
1888     output_asm_insn ("move%.l %4,%3", operands);
1889   return "sub%.l %2,%3\;subx%.l %2,%0";
1892 (define_insn "adddi_sexthishl32"
1893   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
1894     (plus:DI (ashift:DI (sign_extend:DI
1895           (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
1896             (const_int 32))
1897         (match_operand:DI 2 "general_operand" "0,0,0,0")))
1898    (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
1899   "!TARGET_COLDFIRE"
1901   CC_STATUS_INIT;
1902   if (ADDRESS_REG_P (operands[0]))
1903     return "add%.w %1,%0";
1904   else if (ADDRESS_REG_P (operands[3]))
1905     return "move%.w %1,%3\;add%.l %3,%0";
1906   else
1907     return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
1910 (define_insn "*adddi_dilshr32"
1911   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
1912         (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
1913                               (const_int 32))
1914                  (match_operand:DI 2 "general_operand" "0,0")))]
1915   "!TARGET_COLDFIRE"
1917   CC_STATUS_INIT;
1918   if (GET_CODE (operands[0]) == REG)
1919     operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1920   else
1921     operands[2] = adjust_address (operands[0], SImode, 4);
1922   return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
1925 (define_insn "*adddi_dilshr32_cf"
1926   [(set (match_operand:DI 0 "register_operand" "=d")
1927         (plus:DI (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
1928                               (const_int 32))
1929                  (match_operand:DI 2 "register_operand" "0")))]
1930   "TARGET_COLDFIRE"
1932   CC_STATUS_INIT;
1933   return "add%.l %1,%R0\;negx%.l %0\;neg%.l %0";
1936 (define_insn "adddi_dishl32"
1937   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
1938 ;;    (plus:DI (match_operand:DI 2 "general_operand" "%0")
1939 ;;      (ashift:DI (match_operand:DI 1 "general_operand" "ro")
1940 ;;            (const_int 32))))]
1941     (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
1942             (const_int 32))
1943         (match_operand:DI 2 "general_operand" "0,0")))]
1944   ""
1946   CC_STATUS_INIT;
1947   if (GET_CODE (operands[1]) == REG)
1948     operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1949   else
1950     operands[1] = adjust_address (operands[1], SImode, 4);
1951   return "add%.l %1,%0";
1954 (define_insn "adddi3"
1955   [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
1956         (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0")
1957                  (match_operand:DI 2 "general_operand" "d,no>,d,a")))
1958    (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
1959   ""
1961   if (DATA_REG_P (operands[0]))
1962     {
1963       if (DATA_REG_P (operands[2]))
1964         return "add%.l %R2,%R0\;addx%.l %2,%0";
1965       else if (GET_CODE (operands[2]) == MEM
1966           && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
1967         return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
1968       else
1969         {
1970           rtx high, low;
1971           rtx xoperands[2];
1973           if (GET_CODE (operands[2]) == REG)
1974             {
1975               low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
1976               high = operands[2];
1977             }
1978           else if (CONSTANT_P (operands[2]))
1979             split_double (operands[2], &high, &low);
1980           else
1981             {
1982               low = adjust_address (operands[2], SImode, 4);
1983               high = operands[2];
1984             }
1986           operands[1] = low, operands[2] = high;
1987           xoperands[0] = operands[3];
1988           if (GET_CODE (operands[1]) == CONST_INT
1989               && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
1990             xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
1991           else
1992             xoperands[1] = operands[2];
1994           output_asm_insn (output_move_simode (xoperands), xoperands);
1995           if (GET_CODE (operands[1]) == CONST_INT)
1996             {
1997               if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
1998                 return "addq%.l %1,%R0\;addx%.l %3,%0";
1999               else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2000                 {
2001                   operands[1] = GEN_INT (-INTVAL (operands[1]));
2002                   return "subq%.l %1,%R0\;subx%.l %3,%0";
2003                 }
2004             }
2005           return "add%.l %1,%R0\;addx%.l %3,%0";
2006         }
2007     }
2008   else
2009     {
2010       gcc_assert (GET_CODE (operands[0]) == MEM);
2011       CC_STATUS_INIT;
2012       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2013         {
2014           operands[1] = gen_rtx_MEM (SImode,
2015                                      plus_constant (XEXP(operands[0], 0), -8));
2016           return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2017         }
2018       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2019         {
2020           operands[1] = XEXP(operands[0], 0);
2021           return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2022         }
2023       else
2024         {
2025           operands[1] = adjust_address (operands[0], SImode, 4);
2026           return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2027         }
2028     }
2031 (define_insn "addsi_lshrsi_31"
2032   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2033     (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
2034             (const_int 31))
2035         (match_dup 1)))]
2036   ""
2038   operands[2] = operands[0];
2039   operands[3] = gen_label_rtx();
2040   if (GET_CODE (operands[0]) == MEM)
2041     {
2042       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2043         operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2044       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2045         operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2046     }
2047   output_asm_insn ("move%.l %1,%0", operands);
2048   output_asm_insn (MOTOROLA ? "jbpl %l3" : "jpl %l3", operands);
2049   output_asm_insn ("addq%.l #1,%2", operands);
2050   (*targetm.asm_out.internal_label) (asm_out_file, "L",
2051                                 CODE_LABEL_NUMBER (operands[3]));
2052   return "";
2055 (define_expand "addsi3"
2056   [(set (match_operand:SI 0 "nonimmediate_operand" "")
2057         (plus:SI (match_operand:SI 1 "general_operand" "")
2058                  (match_operand:SI 2 "general_src_operand" "")))]
2059   ""
2060   "")
2062 ;; Note that the middle two alternatives are near-duplicates
2063 ;; in order to handle insns generated by reload.
2064 ;; This is needed since they are not themselves reloaded,
2065 ;; so commutativity won't apply to them.
2066 (define_insn "*addsi3_internal"
2067   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2068         (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2069                  (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2072   "! TARGET_COLDFIRE"
2073   "* return output_addsi3 (operands);")
2075 (define_insn "*addsi3_5200"
2076   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,r")
2077         (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0")
2078                  (match_operand:SI 2 "general_src_operand" "dIL,rJK,a,mrIKLi")))]
2079   "TARGET_COLDFIRE"
2080   "* return output_addsi3 (operands);")
2082 (define_insn ""
2083   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2084         (plus:SI (match_operand:SI 1 "general_operand" "0")
2085                  (sign_extend:SI
2086                   (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2087   "!TARGET_COLDFIRE"
2088   "add%.w %2,%0")
2090 (define_insn "addhi3"
2091   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2092         (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2093                  (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2094   "!TARGET_COLDFIRE"
2096   if (GET_CODE (operands[2]) == CONST_INT)
2097     {
2098       /* If the constant would be a negative number when interpreted as
2099          HImode, make it negative.  This is usually, but not always, done
2100          elsewhere in the compiler.  First check for constants out of range,
2101          which could confuse us.  */
2103       if (INTVAL (operands[2]) >= 32768)
2104         operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2106       if (INTVAL (operands[2]) > 0
2107           && INTVAL (operands[2]) <= 8)
2108         return "addq%.w %2,%0";
2109       if (INTVAL (operands[2]) < 0
2110           && INTVAL (operands[2]) >= -8)
2111         {
2112           operands[2] = GEN_INT (- INTVAL (operands[2]));
2113           return "subq%.w %2,%0";
2114         }
2115       /* On the CPU32 it is faster to use two addqw instructions to
2116          add a small integer (8 < N <= 16) to a register.  
2117          Likewise for subqw.  */
2118       if (TUNE_CPU32 && REG_P (operands[0]))
2119         {
2120           if (INTVAL (operands[2]) > 8
2121               && INTVAL (operands[2]) <= 16)
2122             {
2123               operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2124               return "addq%.w #8,%0\;addq%.w %2,%0";
2125             }
2126           if (INTVAL (operands[2]) < -8
2127               && INTVAL (operands[2]) >= -16)
2128             {
2129               operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2130               return "subq%.w #8,%0\;subq%.w %2,%0";
2131             }
2132         }
2133       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2134         return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2135     }
2136   return "add%.w %2,%0";
2139 ;; These insns must use MATCH_DUP instead of the more expected
2140 ;; use of a matching constraint because the "output" here is also
2141 ;; an input, so you can't use the matching constraint.  That also means
2142 ;; that you can't use the "%", so you need patterns with the matched
2143 ;; operand in both positions.
2145 (define_insn ""
2146   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2147         (plus:HI (match_dup 0)
2148                  (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2149   "!TARGET_COLDFIRE"
2151   if (GET_CODE (operands[1]) == CONST_INT)
2152     {
2153       /* If the constant would be a negative number when interpreted as
2154          HImode, make it negative.  This is usually, but not always, done
2155          elsewhere in the compiler.  First check for constants out of range,
2156          which could confuse us.  */
2158       if (INTVAL (operands[1]) >= 32768)
2159         operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2161       if (INTVAL (operands[1]) > 0
2162           && INTVAL (operands[1]) <= 8)
2163         return "addq%.w %1,%0";
2164       if (INTVAL (operands[1]) < 0
2165           && INTVAL (operands[1]) >= -8)
2166         {
2167           operands[1] = GEN_INT (- INTVAL (operands[1]));
2168           return "subq%.w %1,%0";
2169         }
2170       /* On the CPU32 it is faster to use two addqw instructions to
2171          add a small integer (8 < N <= 16) to a register. 
2172          Likewise for subqw.  */
2173       if (TUNE_CPU32 && REG_P (operands[0]))
2174         {
2175           if (INTVAL (operands[1]) > 8
2176               && INTVAL (operands[1]) <= 16)
2177             {
2178               operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2179               return "addq%.w #8,%0\;addq%.w %1,%0";
2180             }
2181           if (INTVAL (operands[1]) < -8
2182               && INTVAL (operands[1]) >= -16)
2183             {
2184               operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2185               return "subq%.w #8,%0\;subq%.w %1,%0";
2186             }
2187         }
2188       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2189         return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2190     }
2191   return "add%.w %1,%0";
2194 (define_insn ""
2195   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2196         (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2197                  (match_dup 0)))]
2198   "!TARGET_COLDFIRE"
2200   if (GET_CODE (operands[1]) == CONST_INT)
2201     {
2202       /* If the constant would be a negative number when interpreted as
2203          HImode, make it negative.  This is usually, but not always, done
2204          elsewhere in the compiler.  First check for constants out of range,
2205          which could confuse us.  */
2207       if (INTVAL (operands[1]) >= 32768)
2208         operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2210       if (INTVAL (operands[1]) > 0
2211           && INTVAL (operands[1]) <= 8)
2212         return "addq%.w %1,%0";
2213       if (INTVAL (operands[1]) < 0
2214           && INTVAL (operands[1]) >= -8)
2215         {
2216           operands[1] = GEN_INT (- INTVAL (operands[1]));
2217           return "subq%.w %1,%0";
2218         }
2219       /* On the CPU32 it is faster to use two addqw instructions to
2220          add a small integer (8 < N <= 16) to a register.
2221          Likewise for subqw.  */
2222       if (TUNE_CPU32 && REG_P (operands[0]))
2223         {
2224           if (INTVAL (operands[1]) > 8
2225               && INTVAL (operands[1]) <= 16)
2226             {
2227               operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2228               return "addq%.w #8,%0\;addq%.w %1,%0";
2229             }
2230           if (INTVAL (operands[1]) < -8
2231               && INTVAL (operands[1]) >= -16)
2232             {
2233               operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2234               return "subq%.w #8,%0\;subq%.w %1,%0";
2235             }
2236         }
2237       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2238         return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2239     }
2240   return "add%.w %1,%0";
2243 (define_insn "addqi3"
2244   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2245         (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2246                  (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2247   "!TARGET_COLDFIRE"
2249   if (GET_CODE (operands[2]) == CONST_INT)
2250     {
2251       if (INTVAL (operands[2]) >= 128)
2252         operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2254       if (INTVAL (operands[2]) > 0
2255           && INTVAL (operands[2]) <= 8)
2256         return "addq%.b %2,%0";
2257       if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2258        {
2259          operands[2] = GEN_INT (- INTVAL (operands[2]));
2260          return "subq%.b %2,%0";
2261        }
2262     }
2263   return "add%.b %2,%0";
2266 (define_insn ""
2267   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2268         (plus:QI (match_dup 0)
2269                  (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2270   "!TARGET_COLDFIRE"
2272   if (GET_CODE (operands[1]) == CONST_INT)
2273     {
2274       if (INTVAL (operands[1]) >= 128)
2275         operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2277       if (INTVAL (operands[1]) > 0
2278           && INTVAL (operands[1]) <= 8)
2279         return "addq%.b %1,%0";
2280       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2281        {
2282          operands[1] = GEN_INT (- INTVAL (operands[1]));
2283          return "subq%.b %1,%0";
2284        }
2285     }
2286   return "add%.b %1,%0";
2289 (define_insn ""
2290   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2291         (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2292                  (match_dup 0)))]
2293   "!TARGET_COLDFIRE"
2295   if (GET_CODE (operands[1]) == CONST_INT)
2296     {
2297       if (INTVAL (operands[1]) >= 128)
2298         operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2300       if (INTVAL (operands[1]) > 0
2301           && INTVAL (operands[1]) <= 8)
2302         return "addq%.b %1,%0";
2303       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2304        {
2305          operands[1] = GEN_INT (- INTVAL (operands[1]));
2306          return "subq%.b %1,%0";
2307        }
2308     }
2309   return "add%.b %1,%0";
2312 (define_expand "add<mode>3"
2313   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2314         (plus:FP (match_operand:FP 1 "general_operand" "")
2315                  (match_operand:FP 2 "general_operand" "")))]
2316   "TARGET_HARD_FLOAT"
2317   "")
2319 (define_insn "add<mode>3_floatsi_68881"
2320   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2321         (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2322                  (match_operand:FP 1 "general_operand" "0")))]
2323   "TARGET_68881"
2324   "f<FP:round>add%.l %2,%0")
2326 (define_insn "add<mode>3_floathi_68881"
2327   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2328         (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2329                  (match_operand:FP 1 "general_operand" "0")))]
2330   "TARGET_68881"
2331   "f<FP:round>add%.w %2,%0")
2333 (define_insn "add<mode>3_floatqi_68881"
2334   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2335         (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2336                  (match_operand:FP 1 "general_operand" "0")))]
2337   "TARGET_68881"
2338   "f<FP:round>add%.b %2,%0")
2340 (define_insn "add<mode>3_68881"
2341   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2342         (plus:FP (match_operand:FP 1 "general_operand" "%0")
2343                  (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2344   "TARGET_68881"
2346   if (FP_REG_P (operands[2]))
2347     return "f<FP:round>add%.x %2,%0";
2348   return "f<FP:round>add%.<FP:prec> %f2,%0";
2351 (define_insn "add<mode>3_cf"
2352   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2353         (plus:FP (match_operand:FP 1 "general_operand" "%0")
2354                  (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2355   "TARGET_COLDFIRE_FPU"
2357   if (FP_REG_P (operands[2]))
2358     return "f<FP:prec>add%.d %2,%0";
2359   return "f<FP:prec>add%.<FP:prec> %2,%0";
2362 ;; subtract instructions
2364 (define_insn "subdi_sexthishl32"
2365   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2366     (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2367         (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2368             (const_int 32))))
2369    (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2370   "!TARGET_COLDFIRE"
2372   CC_STATUS_INIT;
2373   if (ADDRESS_REG_P (operands[0]))
2374     return "sub%.w %2,%0";
2375   else if (ADDRESS_REG_P (operands[3]))
2376     return "move%.w %2,%3\;sub%.l %3,%0";
2377   else
2378     return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2381 (define_insn "subdi_dishl32"
2382   [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2383     (minus:DI (match_dup 0)
2384         (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2385             (const_int 32))))]
2386   ""
2388   CC_STATUS_INIT;
2389   if (GET_CODE (operands[1]) == REG)
2390     operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2391   else
2392     operands[1] = adjust_address (operands[1], SImode, 4);
2393   return "sub%.l %1,%0";
2396 (define_insn "subdi3"
2397   [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2398         (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2399                  (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2400    (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2401   ""
2403   if (DATA_REG_P (operands[0]))
2404     {
2405       if (DATA_REG_P (operands[2]))
2406         return "sub%.l %R2,%R0\;subx%.l %2,%0";
2407       else if (GET_CODE (operands[2]) == MEM
2408           && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2409         {
2410           return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2411         }
2412       else
2413         {
2414           rtx high, low;
2415           rtx xoperands[2];
2417           if (GET_CODE (operands[2]) == REG)
2418             {
2419               low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2420               high = operands[2];
2421             }
2422           else if (CONSTANT_P (operands[2]))
2423             split_double (operands[2], &high, &low);
2424           else
2425             {
2426               low = adjust_address (operands[2], SImode, 4);
2427               high = operands[2];
2428             }
2430           operands[1] = low, operands[2] = high;
2431           xoperands[0] = operands[3];
2432           if (GET_CODE (operands[1]) == CONST_INT
2433               && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2434             xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2435           else
2436             xoperands[1] = operands[2];
2438           output_asm_insn (output_move_simode (xoperands), xoperands);
2439           if (GET_CODE (operands[1]) == CONST_INT)
2440             {
2441               if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2442                 return "subq%.l %1,%R0\;subx%.l %3,%0";
2443               else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2444                 {
2445                   operands[1] = GEN_INT (-INTVAL (operands[1]));
2446                   return "addq%.l %1,%R0\;addx%.l %3,%0";
2447                 }
2448             }
2449           return "sub%.l %1,%R0\;subx%.l %3,%0";
2450         }
2451     }
2452   else
2453     {
2454       gcc_assert (GET_CODE (operands[0]) == MEM);
2455       CC_STATUS_INIT;
2456       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2457         {
2458           operands[1]
2459             = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2460           return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2461         }
2462       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2463         {
2464           operands[1] = XEXP(operands[0], 0);
2465           return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2466         }
2467       else
2468         {
2469           operands[1] = adjust_address (operands[0], SImode, 4);
2470           return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2471         }
2472     }
2475 (define_insn "subsi3"
2476   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d,a")
2477         (minus:SI (match_operand:SI 1 "general_operand" "0,0,0")
2478                   (match_operand:SI 2 "general_src_operand" "dT,mSrT,mSrs")))]
2479   ""
2480   "sub%.l %2,%0")
2482 (define_insn ""
2483   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2484         (minus:SI (match_operand:SI 1 "general_operand" "0")
2485                   (sign_extend:SI
2486                    (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2487   "!TARGET_COLDFIRE"
2488   "sub%.w %2,%0")
2490 (define_insn "subhi3"
2491   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2492         (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2493                   (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2494   "!TARGET_COLDFIRE"
2495   "sub%.w %2,%0")
2497 (define_insn ""
2498   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2499         (minus:HI (match_dup 0)
2500                   (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2501   "!TARGET_COLDFIRE"
2502   "sub%.w %1,%0")
2504 (define_insn "subqi3"
2505   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2506         (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2507                   (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2508   "!TARGET_COLDFIRE"
2509   "sub%.b %2,%0")
2511 (define_insn ""
2512   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2513         (minus:QI (match_dup 0)
2514                   (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2515   "!TARGET_COLDFIRE"
2516   "sub%.b %1,%0")
2518 (define_expand "sub<mode>3"
2519   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2520         (minus:FP (match_operand:FP 1 "general_operand" "")
2521                   (match_operand:FP 2 "general_operand" "")))]
2522   "TARGET_HARD_FLOAT"
2523   "")
2525 (define_insn "sub<mode>3_floatsi_68881"
2526   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2527         (minus:FP (match_operand:FP 1 "general_operand" "0")
2528                   (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2529   "TARGET_68881"
2530   "f<FP:round>sub%.l %2,%0")
2532 (define_insn "sub<mode>3_floathi_68881"
2533   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2534         (minus:FP (match_operand:FP 1 "general_operand" "0")
2535                   (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2536   "TARGET_68881"
2537   "f<FP:round>sub%.w %2,%0")
2539 (define_insn "sub<mode>3_floatqi_68881"
2540   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2541         (minus:FP (match_operand:FP 1 "general_operand" "0")
2542                   (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2543   "TARGET_68881"
2544   "f<FP:round>sub%.b %2,%0")
2546 (define_insn "sub<mode>3_68881"
2547   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2548         (minus:FP (match_operand:FP 1 "general_operand" "0")
2549                   (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2550   "TARGET_68881"
2552   if (FP_REG_P (operands[2]))
2553     return "f<FP:round>sub%.x %2,%0";
2554   return "f<FP:round>sub%.<FP:prec> %f2,%0";
2557 (define_insn "sub<mode>3_cf"
2558   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2559         (minus:FP (match_operand:FP 1 "general_operand" "0")
2560                   (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2561   "TARGET_COLDFIRE_FPU"
2563   if (FP_REG_P (operands[2]))
2564     return "f<FP:prec>sub%.d %2,%0";
2565   return "f<FP:prec>sub%.<FP:prec> %2,%0";
2568 ;; multiply instructions
2570 (define_insn "mulhi3"
2571   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2572         (mult:HI (match_operand:HI 1 "general_operand" "%0")
2573                  (match_operand:HI 2 "general_src_operand" "dmSn")))]
2574   ""
2576   return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2579 (define_insn "mulhisi3"
2580   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2581         (mult:SI (sign_extend:SI
2582                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
2583                  (sign_extend:SI
2584                   (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2585   ""
2587   return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2590 (define_insn ""
2591   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2592         (mult:SI (sign_extend:SI
2593                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
2594                  (match_operand:SI 2 "const_int_operand" "n")))]
2595   "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2597   return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2600 (define_expand "mulsi3"
2601   [(set (match_operand:SI 0 "nonimmediate_operand" "")
2602         (mult:SI (match_operand:SI 1 "general_operand" "")
2603                  (match_operand:SI 2 "general_operand" "")))]
2604   "TARGET_68020 || TARGET_COLDFIRE"
2605   "")
2607 (define_insn ""
2608   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2609         (mult:SI (match_operand:SI 1 "general_operand" "%0")
2610                  (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2612   "TARGET_68020"
2613   "muls%.l %2,%0")
2615 (define_insn ""
2616   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2617         (mult:SI (match_operand:SI 1 "general_operand" "%0")
2618                  (match_operand:SI 2 "general_operand" "d<Q>")))]
2619   "TARGET_COLDFIRE"
2620   "muls%.l %2,%0")
2622 (define_insn "umulhisi3"
2623   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2624         (mult:SI (zero_extend:SI
2625                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
2626                  (zero_extend:SI
2627                   (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2628   ""
2630   return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2633 (define_insn ""
2634   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2635         (mult:SI (zero_extend:SI
2636                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
2637                  (match_operand:SI 2 "const_int_operand" "n")))]
2638   "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2640   return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2643 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2644 ;; proper matching constraint.  This is because the matching is between
2645 ;; the high-numbered word of the DImode operand[0] and operand[1].
2646 (define_expand "umulsidi3"
2647   [(parallel
2648     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2649           (mult:SI (match_operand:SI 1 "register_operand" "")
2650                    (match_operand:SI 2 "register_operand" "")))
2651      (set (subreg:SI (match_dup 0) 0)
2652           (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2653                                              (zero_extend:DI (match_dup 2)))
2654                                     (const_int 32))))])]
2655   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2656   "")
2658 (define_insn ""
2659   [(set (match_operand:SI 0 "register_operand" "=d")
2660         (mult:SI (match_operand:SI 1 "register_operand" "%0")
2661                   (match_operand:SI 2 "nonimmediate_operand" "dm")))
2662    (set (match_operand:SI 3 "register_operand" "=d")
2663         (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2664                                            (zero_extend:DI (match_dup 2)))
2665                                   (const_int 32))))]
2666   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2667   "mulu%.l %2,%3:%0")
2669 ; Match immediate case.  For 2.4 only match things < 2^31.
2670 ; It's tricky with larger values in these patterns since we need to match
2671 ; values between the two parallel multiplies, between a CONST_DOUBLE and
2672 ; a CONST_INT.
2673 (define_insn ""
2674   [(set (match_operand:SI 0 "register_operand" "=d")
2675         (mult:SI (match_operand:SI 1 "register_operand" "%0")
2676                  (match_operand:SI 2 "const_int_operand" "n")))
2677    (set (match_operand:SI 3 "register_operand" "=d")
2678         (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2679                                            (match_dup 2))
2680                                   (const_int 32))))]
2681   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
2682    && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
2683   "mulu%.l %2,%3:%0")
2685 (define_expand "mulsidi3"
2686   [(parallel
2687     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2688           (mult:SI (match_operand:SI 1 "register_operand" "")
2689                    (match_operand:SI 2 "register_operand" "")))
2690      (set (subreg:SI (match_dup 0) 0)
2691           (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2692                                              (sign_extend:DI (match_dup 2)))
2693                                     (const_int 32))))])]
2694   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2695   "")
2697 (define_insn ""
2698   [(set (match_operand:SI 0 "register_operand" "=d")
2699         (mult:SI (match_operand:SI 1 "register_operand" "%0")
2700                  (match_operand:SI 2 "nonimmediate_operand" "dm")))
2701    (set (match_operand:SI 3 "register_operand" "=d")
2702         (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2703                                            (sign_extend:DI (match_dup 2)))
2704                                   (const_int 32))))]
2705   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2706   "muls%.l %2,%3:%0")
2708 (define_insn ""
2709   [(set (match_operand:SI 0 "register_operand" "=d")
2710         (mult:SI (match_operand:SI 1 "register_operand" "%0")
2711                  (match_operand:SI 2 "const_int_operand" "n")))
2712    (set (match_operand:SI 3 "register_operand" "=d")
2713         (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
2714                                            (match_dup 2))
2715                                   (const_int 32))))]
2716   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2717   "muls%.l %2,%3:%0")
2719 (define_expand "umulsi3_highpart"
2720   [(parallel
2721     [(set (match_operand:SI 0 "register_operand" "")
2722           (truncate:SI
2723            (lshiftrt:DI
2724             (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
2725                      (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
2726             (const_int 32))))
2727      (clobber (match_dup 3))])]
2728   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2730   operands[3] = gen_reg_rtx (SImode);
2732   if (GET_CODE (operands[2]) == CONST_INT)
2733     {
2734       operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
2735                                         0, DImode);
2737       /* We have to adjust the operand order for the matching constraints.  */
2738       emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
2739                                              operands[1], operands[2]));
2740       DONE;
2741     }
2744 (define_insn ""
2745   [(set (match_operand:SI 0 "register_operand" "=d")
2746         (truncate:SI
2747          (lshiftrt:DI
2748           (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2749                    (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2750           (const_int 32))))
2751    (clobber (match_operand:SI 1 "register_operand" "=d"))]
2752   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2753   "mulu%.l %3,%0:%1")
2755 (define_insn "const_umulsi3_highpart"
2756   [(set (match_operand:SI 0 "register_operand" "=d")
2757         (truncate:SI
2758          (lshiftrt:DI
2759           (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
2760                    (match_operand:DI 3 "const_uint32_operand" "n"))
2761           (const_int 32))))
2762    (clobber (match_operand:SI 1 "register_operand" "=d"))]
2763   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2764   "mulu%.l %3,%0:%1")
2766 (define_expand "smulsi3_highpart"
2767   [(parallel
2768     [(set (match_operand:SI 0 "register_operand" "")
2769           (truncate:SI
2770            (lshiftrt:DI
2771             (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
2772                      (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
2773             (const_int 32))))
2774      (clobber (match_dup 3))])]
2775   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2777   operands[3] = gen_reg_rtx (SImode);
2778   if (GET_CODE (operands[2]) == CONST_INT)
2779     {
2780       /* We have to adjust the operand order for the matching constraints.  */
2781       emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
2782                                              operands[1], operands[2]));
2783       DONE;
2784     }
2787 (define_insn ""
2788   [(set (match_operand:SI 0 "register_operand" "=d")
2789         (truncate:SI
2790          (lshiftrt:DI
2791           (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
2792                    (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
2793           (const_int 32))))
2794    (clobber (match_operand:SI 1 "register_operand" "=d"))]
2795   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2796   "muls%.l %3,%0:%1")
2798 (define_insn "const_smulsi3_highpart"
2799   [(set (match_operand:SI 0 "register_operand" "=d")
2800         (truncate:SI
2801          (lshiftrt:DI
2802           (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
2803                    (match_operand:DI 3 "const_sint32_operand" "n"))
2804           (const_int 32))))
2805    (clobber (match_operand:SI 1 "register_operand" "=d"))]
2806   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2807   "muls%.l %3,%0:%1")
2809 (define_expand "mul<mode>3"
2810   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2811         (mult:FP (match_operand:FP 1 "general_operand" "")
2812                  (match_operand:FP 2 "general_operand" "")))]
2813   "TARGET_HARD_FLOAT"
2814   "")
2816 (define_insn "mul<mode>3_floatsi_68881"
2817   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2818         (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2819                  (match_operand:FP 1 "general_operand" "0")))]
2820   "TARGET_68881"
2822   return TARGET_68040
2823          ? "f<FP:round>mul%.l %2,%0"
2824          : "f<FP:round_mul>mul%.l %2,%0";
2827 (define_insn "mul<mode>3_floathi_68881"
2828   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2829         (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2830                  (match_operand:FP 1 "general_operand" "0")))]
2831   "TARGET_68881"
2833   return TARGET_68040
2834          ? "f<FP:round>mul%.w %2,%0"
2835          : "f<FP:round_mul>mul%.w %2,%0";
2838 (define_insn "mul<mode>3_floatqi_68881"
2839   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2840         (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2841                  (match_operand:FP 1 "general_operand" "0")))]
2842   "TARGET_68881"
2844   return TARGET_68040
2845          ? "f<FP:round>mul%.b %2,%0"
2846          : "f<FP:round_mul>mul%.b %2,%0";
2849 (define_insn "muldf_68881"
2850   [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
2851         (mult:DF (match_operand:DF 1 "general_operand" "%0")
2852                  (match_operand:DF 2 "general_operand" "fmG")))]
2853   "TARGET_68881"
2855   if (GET_CODE (operands[2]) == CONST_DOUBLE
2856       && floating_exact_log2 (operands[2]) && !TUNE_68040_60)
2857     {
2858       int i = floating_exact_log2 (operands[2]);
2859       operands[2] = GEN_INT (i);
2860       return "fscale%.l %2,%0";
2861     }
2862   if (REG_P (operands[2]))
2863     return "f%&mul%.x %2,%0";
2864   return "f%&mul%.d %f2,%0";
2867 (define_insn "mulsf_68881"
2868   [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2869         (mult:SF (match_operand:SF 1 "general_operand" "%0")
2870                  (match_operand:SF 2 "general_operand" "fdmF")))]
2871   "TARGET_68881"
2873   if (FP_REG_P (operands[2]))
2874     return (TARGET_68040
2875             ? "fsmul%.x %2,%0"
2876             : "fsglmul%.x %2,%0");
2877   return (TARGET_68040
2878           ? "fsmul%.s %f2,%0"
2879           : "fsglmul%.s %f2,%0");
2882 (define_insn "mulxf3_68881"
2883   [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
2884         (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
2885                  (match_operand:XF 2 "nonimmediate_operand" "fm")))]
2886   "TARGET_68881"
2888   return "fmul%.x %f2,%0";
2891 (define_insn "fmul<mode>3_cf"
2892   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2893         (mult:FP (match_operand:FP 1 "general_operand" "%0")
2894                  (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
2895   "TARGET_COLDFIRE_FPU"
2897   if (FP_REG_P (operands[2]))
2898     return "f<FP:prec>mul%.d %2,%0";
2899   return "f<FP:prec>mul%.<FP:prec> %2,%0";
2902 ;; divide instructions
2904 (define_expand "div<mode>3"
2905   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2906         (div:FP (match_operand:FP 1 "general_operand" "")
2907                 (match_operand:FP 2 "general_operand" "")))]
2908   "TARGET_HARD_FLOAT"
2909   "")
2911 (define_insn "div<mode>3_floatsi_68881"
2912   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2913         (div:FP (match_operand:FP 1 "general_operand" "0")
2914                 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2915   "TARGET_68881"
2917   return TARGET_68040
2918          ? "f<FP:round>div%.l %2,%0"
2919          : "f<FP:round_mul>div%.l %2,%0";
2922 (define_insn "div<mode>3_floathi_68881"
2923   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2924         (div:FP (match_operand:FP 1 "general_operand" "0")
2925                 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2926   "TARGET_68881"
2928   return TARGET_68040
2929          ? "f<FP:round>div%.w %2,%0"
2930          : "f<FP:round_mul>div%.w %2,%0";
2933 (define_insn "div<mode>3_floatqi_68881"
2934   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2935         (div:FP (match_operand:FP 1 "general_operand" "0")
2936                 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2937   "TARGET_68881"
2939   return TARGET_68040
2940          ? "f<FP:round>div%.b %2,%0"
2941          : "f<FP:round_mul>div%.b %2,%0";
2944 (define_insn "div<mode>3_68881"
2945   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2946         (div:FP (match_operand:FP 1 "general_operand" "0")
2947                 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2948   "TARGET_68881"
2950   if (FP_REG_P (operands[2]))
2951     return (TARGET_68040
2952             ? "f<FP:round>div%.x %2,%0"
2953             : "f<FP:round_mul>div%.x %2,%0");
2954   return (TARGET_68040
2955           ? "f<FP:round>div%.<FP:prec> %f2,%0"
2956           : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
2959 (define_insn "div<mode>3_cf"
2960   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2961         (div:FP (match_operand:FP 1 "general_operand" "0")
2962                 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
2963   "TARGET_COLDFIRE_FPU"
2965   if (FP_REG_P (operands[2]))
2966     return "f<FP:prec>div%.d %2,%0";
2967   return "f<FP:prec>div%.<FP:prec> %2,%0";
2970 ;; Remainder instructions.
2972 (define_expand "divmodsi4"
2973   [(parallel
2974     [(set (match_operand:SI 0 "nonimmediate_operand" "")
2975           (div:SI (match_operand:SI 1 "general_operand" "")
2976                   (match_operand:SI 2 "general_src_operand" "")))
2977      (set (match_operand:SI 3 "nonimmediate_operand" "")
2978           (mod:SI (match_dup 1) (match_dup 2)))])]
2979   "TARGET_68020 || TARGET_CF_HWDIV"
2980   "")
2982 (define_insn ""
2983   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2984         (div:SI (match_operand:SI 1 "general_operand" "0")
2985                 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
2986    (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
2987         (mod:SI (match_dup 1) (match_dup 2)))]
2988   "TARGET_CF_HWDIV"
2990   if (find_reg_note (insn, REG_UNUSED, operands[3]))
2991     return "divs%.l %2,%0";
2992   else if (find_reg_note (insn, REG_UNUSED, operands[0]))
2993     return "rems%.l %2,%3:%0";
2994   else
2995     return "rems%.l %2,%3:%0\;divs%.l %2,%0";
2998 (define_insn ""
2999   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3000         (div:SI (match_operand:SI 1 "general_operand" "0")
3001                 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3002    (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3003         (mod:SI (match_dup 1) (match_dup 2)))]
3004   "TARGET_68020"
3006   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3007     return "divs%.l %2,%0";
3008   else
3009     return "divsl%.l %2,%3:%0";
3012 (define_expand "udivmodsi4"
3013   [(parallel
3014     [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3015           (udiv:SI (match_operand:SI 1 "general_operand" "0")
3016                    (match_operand:SI 2 "general_src_operand" "dmSTK")))
3017      (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3018           (umod:SI (match_dup 1) (match_dup 2)))])]
3019   "TARGET_68020 || TARGET_CF_HWDIV"
3020   "")
3022 (define_insn ""
3023   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3024         (udiv:SI (match_operand:SI 1 "general_operand" "0")
3025                  (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3026    (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3027         (umod:SI (match_dup 1) (match_dup 2)))]
3028   "TARGET_CF_HWDIV"
3030   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3031     return "divu%.l %2,%0";
3032   else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3033     return "remu%.l %2,%3:%0";
3034   else
3035     return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3038 (define_insn ""
3039   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3040         (udiv:SI (match_operand:SI 1 "general_operand" "0")
3041                  (match_operand:SI 2 "general_src_operand" "dmSTK")))
3042    (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3043         (umod:SI (match_dup 1) (match_dup 2)))]
3044   "TARGET_68020 && !TARGET_COLDFIRE"
3046   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3047     return "divu%.l %2,%0";
3048   else
3049     return "divul%.l %2,%3:%0";
3052 (define_insn "divmodhi4"
3053   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3054         (div:HI (match_operand:HI 1 "general_operand" "0")
3055                 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3056    (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3057         (mod:HI (match_dup 1) (match_dup 2)))]
3058   "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3060   output_asm_insn (MOTOROLA ?
3061     "ext%.l %0\;divs%.w %2,%0" :
3062     "extl %0\;divs %2,%0",
3063     operands);
3064   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3065     {
3066       CC_STATUS_INIT;
3067       return "move%.l %0,%3\;swap %3";
3068     }
3069   else
3070     return "";
3073 (define_insn "udivmodhi4"
3074   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3075         (udiv:HI (match_operand:HI 1 "general_operand" "0")
3076                  (match_operand:HI 2 "general_src_operand" "dmSKT")))
3077    (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3078         (umod:HI (match_dup 1) (match_dup 2)))]
3079   "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3081   if (TARGET_ISAB)
3082     output_asm_insn (MOTOROLA ?
3083       "mvz%.w %0,%0\;divu%.w %2,%0" :
3084       "mvz%.w %0,%0\;divu %2,%0",
3085       operands);
3086   else
3087     output_asm_insn (MOTOROLA ?
3088       "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3089       "and%.l #0xFFFF,%0\;divu %2,%0",
3090       operands);
3092   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3093     {
3094       CC_STATUS_INIT;
3095       return "move%.l %0,%3\;swap %3";
3096     }
3097   else
3098     return "";
3101 ;; logical-and instructions
3103 ;; "anddi3" is mainly here to help combine().
3104 (define_insn "anddi3"
3105   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3106         (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3107                 (match_operand:DI 2 "general_operand" "dn,don")))]
3108   "!TARGET_COLDFIRE"
3110   CC_STATUS_INIT;
3111   /* We can get CONST_DOUBLE, but also const1_rtx etc.  */
3112   if (CONSTANT_P (operands[2]))
3113     {
3114       rtx hi, lo;
3116       split_double (operands[2], &hi, &lo);
3118       switch (INTVAL (hi))
3119         {
3120           case 0 :
3121             output_asm_insn ("clr%.l %0", operands);
3122             break;
3123           case -1 :
3124             break;
3125           default :
3126             {
3127             rtx xoperands[3];
3129             xoperands[0] = operands[0];
3130             xoperands[2] = hi;
3131             output_asm_insn (output_andsi3 (xoperands), xoperands);
3132             }
3133         }
3134       if (GET_CODE (operands[0]) == REG)
3135         operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3136       else
3137         operands[0] = adjust_address (operands[0], SImode, 4);
3138       switch (INTVAL (lo))
3139         {
3140           case 0 :
3141             output_asm_insn ("clr%.l %0", operands);
3142             break;
3143           case -1 :
3144             break;
3145           default :
3146             {
3147             rtx xoperands[3];
3149             xoperands[0] = operands[0];
3150             xoperands[2] = lo;
3151             output_asm_insn (output_andsi3 (xoperands), xoperands);
3152             }
3153         }
3154       return "";
3155     }
3156   if (GET_CODE (operands[0]) != REG)
3157     {
3158       operands[1] = adjust_address (operands[0], SImode, 4);
3159       return "and%.l %2,%0\;and%.l %R2,%1";
3160     }
3161   if (GET_CODE (operands[2]) != REG)
3162     {
3163       operands[1] = adjust_address (operands[2], SImode, 4);
3164       return "and%.l %2,%0\;and%.l %1,%R0";
3165     }
3166   return "and%.l %2,%0\;and%.l %R2,%R0";
3169 ;; Prevent AND from being made with sp.  This doesn't exist in the machine
3170 ;; and reload will cause inefficient code.  Since sp is a FIXED_REG, we
3171 ;; can't allocate pseudos into it.
3173 (define_expand "andsi3"
3174   [(set (match_operand:SI 0 "not_sp_operand" "")
3175         (and:SI (match_operand:SI 1 "general_operand" "")
3176                 (match_operand:SI 2 "general_src_operand" "")))]
3177   ""
3178   "")
3180 ;; produced by split operations after reload finished
3181 (define_insn "*andsi3_split"
3182   [(set (match_operand:SI 0 "register_operand" "=d")
3183         (and:SI (match_operand:SI 1 "register_operand" "0")
3184                 (match_operand:SI 2 "const_int_operand" "i")))]
3185   "reload_completed && !TARGET_COLDFIRE"
3187   return output_andsi3 (operands);
3190 (define_insn "andsi3_internal"
3191   [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3192         (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3193                 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3194   "!TARGET_COLDFIRE"
3196   return output_andsi3 (operands);
3199 (define_insn "andsi3_5200"
3200   [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3201         (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3202                 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3203   "TARGET_COLDFIRE"
3205   if (TARGET_ISAB
3206       && DATA_REG_P (operands[0])
3207       && GET_CODE (operands[2]) == CONST_INT)
3208     {
3209       if (INTVAL (operands[2]) == 0x000000ff)
3210         return "mvz%.b %0,%0";
3211       else if (INTVAL (operands[2]) == 0x0000ffff)
3212         return "mvz%.w %0,%0";
3213     }
3214   return output_andsi3 (operands);
3217 (define_insn "andhi3"
3218   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3219         (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3220                 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3221   "!TARGET_COLDFIRE"
3222   "and%.w %2,%0")
3224 (define_insn ""
3225   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3226         (and:HI (match_dup 0)
3227                 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3228   "!TARGET_COLDFIRE"
3229   "and%.w %1,%0")
3231 (define_insn ""
3232   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3233         (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3234                 (match_dup 0)))]
3235   "!TARGET_COLDFIRE"
3236   "and%.w %1,%0")
3238 (define_insn "andqi3"
3239   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3240         (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3241                 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3242   "!TARGET_COLDFIRE"
3243   "and%.b %2,%0")
3245 (define_insn ""
3246   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3247         (and:QI (match_dup 0)
3248                 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3249   "!TARGET_COLDFIRE"
3250   "and%.b %1,%0")
3252 (define_insn ""
3253   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3254         (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3255                 (match_dup 0)))]
3256   "!TARGET_COLDFIRE"
3257   "and%.b %1,%0")
3259 ;; inclusive-or instructions
3261 (define_insn "iordi_zext"
3262   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3263     (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3264         (match_operand:DI 2 "general_operand" "0,0")))]
3265   "!TARGET_COLDFIRE"
3267   int byte_mode;
3269   CC_STATUS_INIT;
3270   if (GET_CODE (operands[0]) == REG)
3271     operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3272   else
3273     operands[0] = adjust_address (operands[0], SImode, 4);
3274   if (GET_MODE (operands[1]) == SImode)
3275     return "or%.l %1,%0";
3276   byte_mode = (GET_MODE (operands[1]) == QImode);
3277   if (GET_CODE (operands[0]) == MEM)
3278     operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3279                                   byte_mode ? 3 : 2);
3280   if (byte_mode)
3281     return "or%.b %1,%0";
3282   else
3283     return "or%.w %1,%0";
3286 ;; "iordi3" is mainly here to help combine().
3287 (define_insn "iordi3"
3288   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3289         (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3290                 (match_operand:DI 2 "general_operand" "dn,don")))]
3291   "!TARGET_COLDFIRE"
3293   CC_STATUS_INIT;
3294   /* We can get CONST_DOUBLE, but also const1_rtx etc.  */
3295   if (CONSTANT_P (operands[2]))
3296     {
3297       rtx hi, lo;
3299       split_double (operands[2], &hi, &lo);
3301       switch (INTVAL (hi))
3302         {
3303           case 0 :
3304             break;
3305           case -1 :
3306             /* FIXME : a scratch register would be welcome here if operand[0]
3307                is not a register */
3308             output_asm_insn ("move%.l #-1,%0", operands);
3309             break;
3310           default :
3311             {
3312             rtx xoperands[3];
3314             xoperands[0] = operands[0];
3315             xoperands[2] = hi;
3316             output_asm_insn (output_iorsi3 (xoperands), xoperands);
3317             }
3318         }
3319       if (GET_CODE (operands[0]) == REG)
3320         operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3321       else
3322         operands[0] = adjust_address (operands[0], SImode, 4);
3323       switch (INTVAL (lo))
3324         {
3325           case 0 :
3326             break;
3327           case -1 :
3328             /* FIXME : a scratch register would be welcome here if operand[0]
3329                is not a register */
3330             output_asm_insn ("move%.l #-1,%0", operands);
3331             break;
3332           default :
3333             {
3334             rtx xoperands[3];
3336             xoperands[0] = operands[0];
3337             xoperands[2] = lo;
3338             output_asm_insn (output_iorsi3 (xoperands), xoperands);
3339             }
3340         }
3341       return "";
3342     }
3343   if (GET_CODE (operands[0]) != REG)
3344     {
3345       operands[1] = adjust_address (operands[0], SImode, 4);
3346       return "or%.l %2,%0\;or%.l %R2,%1";
3347     }
3348   if (GET_CODE (operands[2]) != REG)
3349     {
3350       operands[1] = adjust_address (operands[2], SImode, 4);
3351       return "or%.l %2,%0\;or%.l %1,%R0";
3352     }
3353   return "or%.l %2,%0\;or%.l %R2,%R0";
3356 (define_expand "iorsi3"
3357   [(set (match_operand:SI 0 "nonimmediate_operand" "")
3358         (ior:SI (match_operand:SI 1 "general_operand" "")
3359                 (match_operand:SI 2 "general_src_operand" "")))]
3360   ""
3361   "")
3363 (define_insn "iorsi3_internal"
3364   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3365         (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3366                 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3367   "! TARGET_COLDFIRE"
3369   return output_iorsi3 (operands);
3372 (define_insn "iorsi3_5200"
3373   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3374         (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3375                 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3376   "TARGET_COLDFIRE"
3378   return output_iorsi3 (operands);
3381 (define_insn "iorhi3"
3382   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3383         (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3384                 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3385   "!TARGET_COLDFIRE"
3386   "or%.w %2,%0")
3388 (define_insn ""
3389   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3390         (ior:HI (match_dup 0)
3391                 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3392   "!TARGET_COLDFIRE"
3393   "or%.w %1,%0")
3395 (define_insn ""
3396   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3397         (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3398                 (match_dup 0)))]
3399   "!TARGET_COLDFIRE"
3400   "or%.w %1,%0")
3402 (define_insn "iorqi3"
3403   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3404         (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3405                 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3406   "!TARGET_COLDFIRE"
3407   "or%.b %2,%0")
3409 (define_insn ""
3410   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3411         (ior:QI (match_dup 0)
3412                 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3413   "!TARGET_COLDFIRE"
3414   "or%.b %1,%0")
3416 (define_insn ""
3417   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3418         (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3419                 (match_dup 0)))]
3420   "!TARGET_COLDFIRE"
3421   "or%.b %1,%0")
3423 ;; On all 68k models, this makes faster code in a special case.
3424 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3426 (define_insn "iorsi_zexthi_ashl16"
3427   [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3428     (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3429         (ashift:SI (match_operand:SI 2 "general_operand" "or")
3430             (const_int 16))))]
3431   ""
3433   CC_STATUS_INIT;
3434   if (GET_CODE (operands[2]) != REG)
3435       operands[2] = adjust_address (operands[2], HImode, 2);
3436   if (GET_CODE (operands[2]) != REG
3437   || REGNO (operands[2]) != REGNO (operands[0]))
3438     output_asm_insn ("move%.w %2,%0", operands);
3439   return "swap %0\;mov%.w %1,%0";
3442 (define_insn "iorsi_zext"
3443   [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3444     (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3445         (match_operand:SI 2 "general_operand" "0,0")))]
3446   "!TARGET_COLDFIRE"
3448   int byte_mode;
3450   CC_STATUS_INIT;
3451   byte_mode = (GET_MODE (operands[1]) == QImode);
3452   if (GET_CODE (operands[0]) == MEM)
3453     operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3454                                   byte_mode ? 3 : 2);
3455   if (byte_mode)
3456     return "or%.b %1,%0";
3457   else
3458     return "or%.w %1,%0";
3461 ;; xor instructions
3463 ;; "xordi3" is mainly here to help combine().
3464 (define_insn "xordi3"
3465   [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3466         (xor:DI (match_operand:DI 1 "general_operand" "%0")
3467                 (match_operand:DI 2 "general_operand" "dn")))]
3468   "!TARGET_COLDFIRE"
3470   CC_STATUS_INIT;
3471   /* We can get CONST_DOUBLE, but also const1_rtx etc.  */
3473   if (CONSTANT_P (operands[2]))
3474     {
3475       rtx hi, lo;
3477       split_double (operands[2], &hi, &lo);
3479       switch (INTVAL (hi))
3480         {
3481           case 0 :
3482             break;
3483           case -1 :
3484             output_asm_insn ("not%.l %0", operands);
3485             break;
3486           default :
3487             /* FIXME : a scratch register would be welcome here if
3488                -128 <= INTVAL (hi) < -1 */
3489             {
3490             rtx xoperands[3];
3492             xoperands[0] = operands[0];
3493             xoperands[2] = hi;
3494             output_asm_insn (output_xorsi3 (xoperands), xoperands);
3495             }
3496         }
3497       if (GET_CODE (operands[0]) == REG)
3498         operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3499       else
3500         operands[0] = adjust_address (operands[0], SImode, 4);
3501       switch (INTVAL (lo))
3502         {
3503           case 0 :
3504             break;
3505           case -1 :
3506             output_asm_insn ("not%.l %0", operands);
3507             break;
3508           default :
3509             /* FIXME : a scratch register would be welcome here if
3510                -128 <= INTVAL (lo) < -1 */
3511             operands[2] = lo;
3512             /* FIXME : this should be merged with xorsi3 */
3513             {
3514             rtx xoperands[3];
3516             xoperands[0] = operands[0];
3517             xoperands[2] = lo;
3518             output_asm_insn (output_xorsi3 (xoperands), xoperands);
3519             }
3520         }
3521       return "";
3522     }
3523   if (GET_CODE (operands[0]) != REG)
3524     {
3525       operands[1] = adjust_address (operands[0], SImode, 4);
3526       return "eor%.l %2,%0\;eor%.l %R2,%1";
3527     }
3528   if (GET_CODE (operands[2]) != REG)
3529     {
3530       operands[1] = adjust_address (operands[2], SImode, 4);
3531       return "eor%.l %2,%0\;eor%.l %1,%R0";
3532     }
3533   return "eor%.l %2,%0\;eor%.l %R2,%R0";
3536 (define_expand "xorsi3"
3537   [(set (match_operand:SI 0 "nonimmediate_operand" "")
3538         (xor:SI (match_operand:SI 1 "general_operand" "")
3539                 (match_operand:SI 2 "general_operand" "")))]
3540   ""
3541   "")
3543 (define_insn "xorsi3_internal"
3544   [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3545         (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3546                 (match_operand:SI 2 "general_operand" "di,dKT")))]
3548   "!TARGET_COLDFIRE"
3550   return output_xorsi3 (operands);
3553 (define_insn "xorsi3_5200"
3554   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3555         (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3556                 (match_operand:SI 2 "general_operand" "d,Ks")))]
3557   "TARGET_COLDFIRE"
3559   return output_xorsi3 (operands);
3562 (define_insn "xorhi3"
3563   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3564         (xor:HI (match_operand:HI 1 "general_operand" "%0")
3565                 (match_operand:HI 2 "general_operand" "dn")))]
3566   "!TARGET_COLDFIRE"
3567   "eor%.w %2,%0")
3569 (define_insn ""
3570   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3571         (xor:HI (match_dup 0)
3572                 (match_operand:HI 1 "general_operand" "dn")))]
3573   "!TARGET_COLDFIRE"
3574   "eor%.w %1,%0")
3576 (define_insn ""
3577   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3578         (xor:HI (match_operand:HI 1 "general_operand" "dn")
3579                 (match_dup 0)))]
3580   "!TARGET_COLDFIRE"
3581   "eor%.w %1,%0")
3583 (define_insn "xorqi3"
3584   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3585         (xor:QI (match_operand:QI 1 "general_operand" "%0")
3586                 (match_operand:QI 2 "general_operand" "dn")))]
3587   "!TARGET_COLDFIRE"
3588   "eor%.b %2,%0")
3590 (define_insn ""
3591   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3592         (xor:QI (match_dup 0)
3593                 (match_operand:QI 1 "general_operand" "dn")))]
3594   "!TARGET_COLDFIRE"
3595   "eor%.b %1,%0")
3597 (define_insn ""
3598   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3599         (xor:QI (match_operand:QI 1 "general_operand" "dn")
3600                 (match_dup 0)))]
3601   "!TARGET_COLDFIRE"
3602   "eor%.b %1,%0")
3604 ;; negation instructions
3606 (define_expand "negdi2"
3607   [(set (match_operand:DI 0 "nonimmediate_operand" "")
3608         (neg:DI (match_operand:DI 1 "general_operand" "")))]
3609   ""
3611   if (TARGET_COLDFIRE)
3612     emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3613   else
3614     emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3615   DONE;
3618 (define_insn "negdi2_internal"
3619   [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3620         (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3621   "!TARGET_COLDFIRE"
3623   if (which_alternative == 0)
3624     return "neg%.l %0\;negx%.l %0";
3625   if (GET_CODE (operands[0]) == REG)
3626     operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3627   else
3628     operands[1] = adjust_address (operands[0], SImode, 4);
3629   if (ADDRESS_REG_P (operands[0]))
3630     return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3631   else
3632     return "neg%.l %1\;negx%.l %0";
3635 (define_insn "negdi2_5200"
3636   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3637         (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3638   "TARGET_COLDFIRE"
3640   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3641   return "neg%.l %1\;negx%.l %0";
3644 (define_expand "negsi2"
3645   [(set (match_operand:SI 0 "nonimmediate_operand" "")
3646         (neg:SI (match_operand:SI 1 "general_operand" "")))]
3647   ""
3649   if (TARGET_COLDFIRE)
3650     emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3651   else
3652     emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3653   DONE;
3656 (define_insn "negsi2_internal"
3657   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3658         (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3659   "!TARGET_COLDFIRE"
3660   "neg%.l %0")
3662 (define_insn "negsi2_5200"
3663   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3664         (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3665   "TARGET_COLDFIRE"
3666   "neg%.l %0")
3668 (define_insn "neghi2"
3669   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3670         (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3671   "!TARGET_COLDFIRE"
3672   "neg%.w %0")
3674 (define_insn ""
3675   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3676         (neg:HI (match_dup 0)))]
3677   "!TARGET_COLDFIRE"
3678   "neg%.w %0")
3680 (define_insn "negqi2"
3681   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3682         (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3683   "!TARGET_COLDFIRE"
3684   "neg%.b %0")
3686 (define_insn ""
3687   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3688         (neg:QI (match_dup 0)))]
3689   "!TARGET_COLDFIRE"
3690   "neg%.b %0")
3692 ;; If using software floating point, just flip the sign bit.
3694 (define_expand "negsf2"
3695   [(set (match_operand:SF 0 "nonimmediate_operand" "")
3696         (neg:SF (match_operand:SF 1 "general_operand" "")))]
3697   ""
3699   if (!TARGET_HARD_FLOAT)
3700     {
3701       rtx result;
3702       rtx target;
3704       target = operand_subword_force (operands[0], 0, SFmode);
3705       result = expand_binop (SImode, xor_optab,
3706                              operand_subword_force (operands[1], 0, SFmode),
3707                              GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3708       gcc_assert (result);
3710       if (result != target)
3711         emit_move_insn (result, target);
3713       /* Make a place for REG_EQUAL.  */
3714       emit_move_insn (operands[0], operands[0]);
3715       DONE;
3716     }
3719 (define_expand "negdf2"
3720   [(set (match_operand:DF 0 "nonimmediate_operand" "")
3721         (neg:DF (match_operand:DF 1 "general_operand" "")))]
3722   ""
3724   if (!TARGET_HARD_FLOAT)
3725     {
3726       rtx result;
3727       rtx target;
3728       rtx insns;
3730       start_sequence ();
3731       target = operand_subword (operands[0], 0, 1, DFmode);
3732       result = expand_binop (SImode, xor_optab,
3733                              operand_subword_force (operands[1], 0, DFmode),
3734                              GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3735       gcc_assert (result);
3737       if (result != target)
3738         emit_move_insn (result, target);
3740       emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3741                       operand_subword_force (operands[1], 1, DFmode));
3743       insns = get_insns ();
3744       end_sequence ();
3746       emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3747       DONE;
3748     }
3751 (define_expand "negxf2"
3752   [(set (match_operand:XF 0 "nonimmediate_operand" "")
3753         (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
3754   ""
3756   if (!TARGET_68881)
3757     {
3758       rtx result;
3759       rtx target;
3760       rtx insns;
3762       start_sequence ();
3763       target = operand_subword (operands[0], 0, 1, XFmode);
3764       result = expand_binop (SImode, xor_optab,
3765                              operand_subword_force (operands[1], 0, XFmode),
3766                              GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3767       gcc_assert (result);
3769       if (result != target)
3770         emit_move_insn (result, target);
3772       emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
3773                       operand_subword_force (operands[1], 1, XFmode));
3774       emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
3775                       operand_subword_force (operands[1], 2, XFmode));
3777       insns = get_insns ();
3778       end_sequence ();
3780       emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3781       DONE;
3782     }
3785 (define_insn "neg<mode>2_68881"
3786   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3787         (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
3788   "TARGET_68881"
3790   if (DATA_REG_P (operands[0]))
3791     {
3792       operands[1] = GEN_INT (31);
3793       return "bchg %1,%0";
3794     }
3795   if (FP_REG_P (operands[1]))
3796     return "f<FP:round>neg%.x %1,%0";
3797   return "f<FP:round>neg%.<FP:prec> %f1,%0";
3800 (define_insn "neg<mode>2_cf"
3801   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3802         (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
3803   "TARGET_COLDFIRE_FPU"
3805   if (DATA_REG_P (operands[0]))
3806     {
3807       operands[1] = GEN_INT (31);
3808       return "bchg %1,%0";
3809     }
3810   if (FP_REG_P (operands[1]))
3811     return "f<FP:prec>neg%.d %1,%0";
3812   return "f<FP:prec>neg%.<FP:prec> %1,%0";
3815 ;; Sqrt instruction for the 68881
3817 (define_expand "sqrt<mode>2"
3818   [(set (match_operand:FP 0 "nonimmediate_operand" "")
3819         (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
3820   "TARGET_HARD_FLOAT"
3821   "")
3823 (define_insn "sqrt<mode>2_68881"
3824   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3825         (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
3826   "TARGET_68881"
3828   if (FP_REG_P (operands[1]))
3829     return "f<FP:round>sqrt%.x %1,%0";
3830   return "f<FP:round>sqrt%.<FP:prec> %1,%0";
3833 (define_insn "sqrt<mode>2_cf"
3834   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3835         (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
3836   "TARGET_COLDFIRE_FPU"
3838   if (FP_REG_P (operands[1]))
3839     return "f<FP:prec>sqrt%.d %1,%0";
3840   return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
3842 ;; Absolute value instructions
3843 ;; If using software floating point, just zero the sign bit.
3845 (define_expand "abssf2"
3846   [(set (match_operand:SF 0 "nonimmediate_operand" "")
3847         (abs:SF (match_operand:SF 1 "general_operand" "")))]
3848   ""
3850   if (!TARGET_HARD_FLOAT)
3851     {
3852       rtx result;
3853       rtx target;
3855       target = operand_subword_force (operands[0], 0, SFmode);
3856       result = expand_binop (SImode, and_optab,
3857                              operand_subword_force (operands[1], 0, SFmode),
3858                              GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3859       gcc_assert (result);
3861       if (result != target)
3862         emit_move_insn (result, target);
3864       /* Make a place for REG_EQUAL.  */
3865       emit_move_insn (operands[0], operands[0]);
3866       DONE;
3867     }
3870 (define_expand "absdf2"
3871   [(set (match_operand:DF 0 "nonimmediate_operand" "")
3872         (abs:DF (match_operand:DF 1 "general_operand" "")))]
3873   ""
3875   if (!TARGET_HARD_FLOAT)
3876     {
3877       rtx result;
3878       rtx target;
3879       rtx insns;
3881       start_sequence ();
3882       target = operand_subword (operands[0], 0, 1, DFmode);
3883       result = expand_binop (SImode, and_optab,
3884                              operand_subword_force (operands[1], 0, DFmode),
3885                              GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3886       gcc_assert (result);
3888       if (result != target)
3889         emit_move_insn (result, target);
3891       emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
3892                       operand_subword_force (operands[1], 1, DFmode));
3894       insns = get_insns ();
3895       end_sequence ();
3897       emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3898       DONE;
3899     }
3902 (define_expand "absxf2"
3903   [(set (match_operand:XF 0 "nonimmediate_operand" "")
3904         (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
3905   ""
3907   if (!TARGET_68881)
3908     {
3909       rtx result;
3910       rtx target;
3911       rtx insns;
3913       start_sequence ();
3914       target = operand_subword (operands[0], 0, 1, XFmode);
3915       result = expand_binop (SImode, and_optab,
3916                              operand_subword_force (operands[1], 0, XFmode),
3917                              GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
3918       gcc_assert (result);
3920       if (result != target)
3921         emit_move_insn (result, target);
3923       emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
3924                       operand_subword_force (operands[1], 1, XFmode));
3925       emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
3926                       operand_subword_force (operands[1], 2, XFmode));
3928       insns = get_insns ();
3929       end_sequence ();
3931       emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
3932       DONE;
3933     }
3936 (define_insn "abs<mode>2_68881"
3937   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3938         (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
3939   "TARGET_68881"
3941   if (DATA_REG_P (operands[0]))
3942     {
3943       operands[1] = GEN_INT (31);
3944       return "bclr %1,%0";
3945     }
3946   if (FP_REG_P (operands[1]))
3947     return "f<FP:round>abs%.x %1,%0";
3948   return "f<FP:round>abs%.<FP:prec> %f1,%0";
3951 (define_insn "abs<mode>2_cf"
3952   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
3953         (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
3954   "TARGET_COLDFIRE_FPU"
3956   if (DATA_REG_P (operands[0]))
3957     {
3958       operands[1] = GEN_INT (31);
3959       return "bclr %1,%0";
3960     }
3961   if (FP_REG_P (operands[1]))
3962     return "f<FP:prec>abs%.d %1,%0";
3963   return "f<FP:prec>abs%.<FP:prec> %1,%0";
3966 ;; bit indexing instructions
3968 ;; ColdFire ff1 instruction implements clz.
3969 (define_insn "clzsi2"
3970   [(set (match_operand:SI 0 "register_operand" "=d")
3971         (clz:SI (match_operand:SI 1 "register_operand" "0")))]
3972   "TARGET_ISAAPLUS || TARGET_ISAC"
3973   "ff1 %0")
3975 ;; one complement instructions
3977 ;; "one_cmpldi2" is mainly here to help combine().
3978 (define_insn "one_cmpldi2"
3979   [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
3980         (not:DI (match_operand:DI 1 "general_operand" "0")))]
3981   "!TARGET_COLDFIRE"
3983   CC_STATUS_INIT;
3984   if (GET_CODE (operands[0]) == REG)
3985     operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3986   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
3987         || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
3988     operands[1] = operands[0];
3989   else
3990     operands[1] = adjust_address (operands[0], SImode, 4);
3991   return "not%.l %1\;not%.l %0";
3994 (define_expand "one_cmplsi2"
3995   [(set (match_operand:SI 0 "nonimmediate_operand" "")
3996         (not:SI (match_operand:SI 1 "general_operand" "")))]
3997   ""
3999   if (TARGET_COLDFIRE)
4000     emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
4001   else
4002     emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
4003   DONE;
4006 (define_insn "one_cmplsi2_internal"
4007   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4008         (not:SI (match_operand:SI 1 "general_operand" "0")))]
4009   "!TARGET_COLDFIRE"
4010   "not%.l %0")
4012 (define_insn "one_cmplsi2_5200"
4013   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4014         (not:SI (match_operand:SI 1 "general_operand" "0")))]
4015   "TARGET_COLDFIRE"
4016   "not%.l %0")
4018 (define_insn "one_cmplhi2"
4019   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4020         (not:HI (match_operand:HI 1 "general_operand" "0")))]
4021   "!TARGET_COLDFIRE"
4022   "not%.w %0")
4024 (define_insn ""
4025   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4026         (not:HI (match_dup 0)))]
4027   "!TARGET_COLDFIRE"
4028   "not%.w %0")
4030 (define_insn "one_cmplqi2"
4031   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4032         (not:QI (match_operand:QI 1 "general_operand" "0")))]
4033   "!TARGET_COLDFIRE"
4034   "not%.b %0")
4036 (define_insn ""
4037   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4038         (not:QI (match_dup 0)))]
4039   "!TARGET_COLDFIRE"
4040   "not%.b %0")
4042 ;; arithmetic shift instructions
4043 ;; We don't need the shift memory by 1 bit instruction
4045 (define_insn "ashldi_extsi"
4046   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4047     (ashift:DI
4048       (match_operator:DI 2 "extend_operator"
4049         [(match_operand:SI 1 "general_operand" "rm")])
4050       (const_int 32)))]
4051   ""
4053   CC_STATUS_INIT;
4054   if (GET_CODE (operands[0]) == REG)
4055     operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4056   else
4057     operands[2] = adjust_address (operands[0], SImode, 4);
4058   if (ADDRESS_REG_P (operands[0]))
4059     return "move%.l %1,%0\;sub%.l %2,%2";
4060   else
4061     return "move%.l %1,%0\;clr%.l %2";
4064 (define_insn "ashldi_sexthi"
4065   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
4066     (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
4067         (const_int 32)))
4068     (clobber (match_scratch:SI 2 "=a,X"))]
4069   ""
4071   CC_STATUS_INIT;
4072   if (GET_CODE (operands[0]) == MEM)
4073     {
4074     if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4075       return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
4076     else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4077       return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
4078     else
4079       {
4080         operands[3] = adjust_address (operands[0], SImode, 4);
4081         return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
4082       }
4083     }
4084   else if (DATA_REG_P (operands[0]))
4085     return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
4086   else
4087     return "move%.w %1,%0\;sub%.l %R0,%R0";
4090 (define_insn "ashldi_const32"
4091   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm")
4092         (ashift:DI (match_operand:DI 1 "general_operand" "ro")
4093                      (const_int 32)))]
4094   ""
4096   CC_STATUS_INIT;
4097   if (GET_CODE (operands[1]) == REG)
4098     operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4099   else
4100     operands[3] = adjust_address (operands[1], SImode, 4);
4101   if (GET_CODE (operands[0]) == REG)
4102     operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4103   else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4104     return "clr%.l %0\;move%.l %3,%0";
4105   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4106     return "move%.l %3,%0\;clr%.l %0";
4107   else
4108     operands[2] = adjust_address (operands[0], SImode, 4);
4109   if (ADDRESS_REG_P (operands[2]))
4110     return "move%.l %3,%0\;sub%.l %2,%2";
4111   else
4112     return "move%.l %3,%0\;clr%.l %2";
4115 ;; The predicate below must be general_operand, because ashldi3 allows that
4116 (define_insn "ashldi_const"
4117   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4118         (ashift:DI (match_operand:DI 1 "general_operand" "0")
4119                      (match_operand 2 "const_int_operand" "n")))]
4120   "(!TARGET_COLDFIRE
4121     && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4122         || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4123         || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4125   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4126   if (INTVAL (operands[2]) == 1)
4127     return "add%.l %1,%1\;addx%.l %0,%0";
4128   else if (INTVAL (operands[2]) == 8)
4129     return "rol%.l #8,%1\;rol%.l #8,%0\;move%.b %1,%0\;clr%.b %1";
4130   else if (INTVAL (operands[2]) == 16)
4131     return "swap %1\;swap %0\;move%.w %1,%0\;clr%.w %1";
4132   else if (INTVAL (operands[2]) == 48)
4133     return "mov%.l %1,%0\;swap %0\;clr%.l %1\;clr%.w %0";
4134   else if (INTVAL (operands[2]) == 2)
4135     return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
4136   else if (INTVAL (operands[2]) == 3)
4137     return "add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0\;add%.l %1,%1\;addx%.l %0,%0";
4138   else /* 32 < INTVAL (operands[2]) <= 63 */
4139     {
4140       operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4141       output_asm_insn (INTVAL (operands[2]) <= 8 ? "asl%.l %2,%1" :
4142                         "moveq %2,%0\;asl%.l %0,%1", operands);
4143       return "mov%.l %1,%0\;moveq #0,%1";
4144     }
4147 (define_expand "ashldi3"
4148   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4149         (ashift:DI (match_operand:DI 1 "general_operand" "")
4150                      (match_operand 2 "const_int_operand" "")))]
4151   "!TARGET_COLDFIRE"
4152   "
4154   /* ???  This is a named pattern like this is not allowed to FAIL based
4155      on its operands.  */
4156   if (GET_CODE (operands[2]) != CONST_INT
4157       || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4158           && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4159           && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4160     FAIL;
4161 } ")
4163 ;; On most 68k models, this makes faster code in a special case.
4165 (define_insn "ashlsi_16"
4166   [(set (match_operand:SI 0 "register_operand" "=d")
4167         (ashift:SI (match_operand:SI 1 "register_operand" "0")
4168                    (const_int 16)))]
4169   "!TUNE_68060"
4171   CC_STATUS_INIT;
4172   return "swap %0\;clr%.w %0";
4175 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
4176 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4178 ;; On the 68000, this makes faster code in a special case.
4180 (define_insn "ashlsi_17_24"
4181   [(set (match_operand:SI 0 "register_operand" "=d")
4182         (ashift:SI (match_operand:SI 1 "register_operand" "0")
4183                    (match_operand:SI 2 "const_int_operand" "n")))]
4184   "TUNE_68000_10
4185    && INTVAL (operands[2]) > 16
4186    && INTVAL (operands[2]) <= 24"
4188   CC_STATUS_INIT;
4190   operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4191   return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4194 (define_insn "ashlsi3"
4195   [(set (match_operand:SI 0 "register_operand" "=d")
4196         (ashift:SI (match_operand:SI 1 "register_operand" "0")
4197                    (match_operand:SI 2 "general_operand" "dI")))]
4198   ""
4200   if (operands[2] == const1_rtx)
4201     {
4202       cc_status.flags = CC_NO_OVERFLOW;
4203       return "add%.l %0,%0";
4204     }
4205   return "lsl%.l %2,%0";
4208 (define_insn "ashlhi3"
4209   [(set (match_operand:HI 0 "register_operand" "=d")
4210         (ashift:HI (match_operand:HI 1 "register_operand" "0")
4211                    (match_operand:HI 2 "general_operand" "dI")))]
4212   "!TARGET_COLDFIRE"
4213   "lsl%.w %2,%0")
4215 (define_insn ""
4216   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4217         (ashift:HI (match_dup 0)
4218                    (match_operand:HI 1 "general_operand" "dI")))]
4219   "!TARGET_COLDFIRE"
4220   "lsl%.w %1,%0")
4222 (define_insn "ashlqi3"
4223   [(set (match_operand:QI 0 "register_operand" "=d")
4224         (ashift:QI (match_operand:QI 1 "register_operand" "0")
4225                    (match_operand:QI 2 "general_operand" "dI")))]
4226   "!TARGET_COLDFIRE"
4227   "lsl%.b %2,%0")
4229 (define_insn ""
4230   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4231         (ashift:QI (match_dup 0)
4232                    (match_operand:QI 1 "general_operand" "dI")))]
4233   "!TARGET_COLDFIRE"
4234   "lsl%.b %1,%0")
4236 ;; On most 68k models, this makes faster code in a special case.
4238 (define_insn "ashrsi_16"
4239   [(set (match_operand:SI 0 "register_operand" "=d")
4240         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4241                      (const_int 16)))]
4242   "!TUNE_68060"
4243   "swap %0\;ext%.l %0")
4245 ;; On the 68000, this makes faster code in a special case.
4247 (define_insn ""
4248   [(set (match_operand:SI 0 "register_operand" "=d")
4249         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4250                      (match_operand:SI 2 "const_int_operand" "n")))]
4251   "TUNE_68000_10
4252    && INTVAL (operands[2]) > 16
4253    && INTVAL (operands[2]) <= 24"
4255   operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4256   return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4259 (define_insn "subreghi1ashrdi_const32"
4260   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4261     (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4262             (const_int 32)) 6))]
4263   ""
4265   if (GET_CODE (operands[1]) != REG)
4266     operands[1] = adjust_address (operands[1], HImode, 2);
4267   return "move%.w %1,%0";
4270 (define_insn "subregsi1ashrdi_const32"
4271   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4272     (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4273             (const_int 32)) 4))]
4274   ""
4276   return "move%.l %1,%0";
4279 (define_insn "ashrdi_const32"
4280   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o,<")
4281         (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4282                      (const_int 32)))
4283    (clobber (match_scratch:SI 2 "=X,d,d"))]
4284   ""
4286   CC_STATUS_INIT;
4287   if (which_alternative == 0)
4288     {
4289       operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4290       if (TARGET_68020)
4291         return "move%.l %1,%2\;smi %0\;extb%.l %0";
4292       else
4293         return "move%.l %1,%2\;smi %0\;ext%.w %0\;ext%.l %0";
4294     }
4295   else
4296     {
4297       if (which_alternative == 2)
4298         operands[3] = operands[0];
4299       else if (which_alternative == 1)
4300         operands[3] = adjust_address (operands[0], SImode, 4);
4301       if (TARGET_68020)
4302         return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4303       else
4304         return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4305     }
4308 ;; The predicate below must be general_operand, because ashrdi3 allows that
4309 (define_insn "ashrdi_const"
4310   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4311         (ashiftrt:DI (match_operand:DI 1 "general_operand" "0")
4312                      (match_operand 2 "const_int_operand" "n")))
4313    (clobber (match_scratch:SI 3 "=X"))]
4314   "(!TARGET_COLDFIRE 
4315     && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4316         || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4317         || INTVAL (operands[2]) == 31
4318         || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4320   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4321   if (INTVAL (operands[2]) == 63)
4322     return "add%.l %0,%0\;subx%.l %0,%0\;move%.l %0,%1";
4323   CC_STATUS_INIT;
4324   if (INTVAL (operands[2]) == 1)
4325     return "asr%.l #1,%0\;roxr%.l #1,%1";
4326   else if (INTVAL (operands[2]) == 8)
4327     return "move%.b %0,%1\;asr%.l #8,%0\;ror%.l #8,%1";
4328   else if (INTVAL (operands[2]) == 16)
4329     return "move%.w %0,%1\;swap %0\;ext%.l %0\;swap %1";
4330   else if (INTVAL (operands[2]) == 48)
4331     return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4332   else if (INTVAL (operands[2]) == 31)
4333     return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4334   else if (INTVAL (operands[2]) == 2)
4335     return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4336   else if (INTVAL (operands[2]) == 3)
4337     return "asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1\;asr%.l #1,%0\;roxr%.l #1,%1";
4338   else /* 32 < INTVAL (operands[2]) <= 63 */
4339     {
4340       operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4341       output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4342                         "moveq %2,%1\;asr%.l %1,%0", operands);
4343       output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4344       return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4345              TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4346     }
4349 (define_expand "ashrdi3"
4350   [(parallel [(set (match_operand:DI 0 "nonimmediate_operand" "")
4351                    (ashiftrt:DI (match_operand:DI 1 "general_operand" "")
4352                                 (match_operand 2 "const_int_operand" "")))
4353               (clobber (match_scratch:SI 3 ""))])]
4354   "!TARGET_COLDFIRE"
4355   "
4357   /* ???  This is a named pattern like this is not allowed to FAIL based
4358      on its operands.  */
4359   if (GET_CODE (operands[2]) != CONST_INT
4360       || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4361           && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4362           && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4363     FAIL;
4364   operands[3] = gen_rtx_SCRATCH (SImode);
4365 } ")
4367 ;; On all 68k models, this makes faster code in a special case.
4369 (define_insn "ashrsi_31"
4370   [(set (match_operand:SI 0 "register_operand" "=d")
4371         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4372                      (const_int 31)))]
4373   ""
4375   return "add%.l %0,%0\;subx%.l %0,%0";
4378 (define_insn "ashrsi3"
4379   [(set (match_operand:SI 0 "register_operand" "=d")
4380         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4381                      (match_operand:SI 2 "general_operand" "dI")))]
4382   ""
4383   "asr%.l %2,%0")
4385 (define_insn "ashrhi3"
4386   [(set (match_operand:HI 0 "register_operand" "=d")
4387         (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4388                      (match_operand:HI 2 "general_operand" "dI")))]
4389   "!TARGET_COLDFIRE"
4390   "asr%.w %2,%0")
4392 (define_insn ""
4393   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4394         (ashiftrt:HI (match_dup 0)
4395                      (match_operand:HI 1 "general_operand" "dI")))]
4396   "!TARGET_COLDFIRE"
4397   "asr%.w %1,%0")
4399 (define_insn "ashrqi3"
4400   [(set (match_operand:QI 0 "register_operand" "=d")
4401         (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4402                      (match_operand:QI 2 "general_operand" "dI")))]
4403   "!TARGET_COLDFIRE"
4404   "asr%.b %2,%0")
4406 (define_insn ""
4407   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4408         (ashiftrt:QI (match_dup 0)
4409                      (match_operand:QI 1 "general_operand" "dI")))]
4410   "!TARGET_COLDFIRE"
4411   "asr%.b %1,%0")
4413 ;; logical shift instructions
4415 ;; commented out because of reload problems in 950612-1.c
4416 ;;(define_insn ""
4417 ;;        [(set (cc0)
4418 ;;            (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4419 ;;                    (const_int 32)) 4))
4420 ;;        (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4421 ;;            (subreg:SI (lshiftrt:DI (match_dup 0)
4422 ;;                    (const_int 32)) 4))]
4423 ;;  ""
4425 ;;  return "move%.l %0,%1";
4426 ;;})
4428 ;;(define_insn ""
4429 ;;        [(set (cc0)
4430 ;;            (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4431 ;;                    (const_int 32)) 0))
4432 ;;        (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4433 ;;            (lshiftrt:DI (match_dup 0)
4434 ;;                (const_int 32)))]
4435 ;;  ""
4437 ;;  if (GET_CODE (operands[1]) == REG)
4438 ;;    operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4439 ;;  else
4440 ;;    operands[2] = adjust_address (operands[1], SImode, 4);
4441 ;;  return "move%.l %0,%2\;clr%.l %1";
4442 ;;})
4444 (define_insn "subreg1lshrdi_const32"
4445   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4446     (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4447             (const_int 32)) 4))]
4448   ""
4450   return "move%.l %1,%0";
4453 (define_insn "lshrdi_const32"
4454   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro,<,>")
4455         (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,ro,ro")
4456                      (const_int 32)))]
4457   ""
4459   CC_STATUS_INIT;
4460   if (which_alternative == 1)
4461     return "move%.l %1,%0\;clr%.l %0";
4462   if (which_alternative == 2)
4463     return "clr%.l %0\;move%.l %1,%0";
4464   if (GET_CODE (operands[0]) == REG)
4465     operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4466   else
4467     operands[2] = adjust_address (operands[0], SImode, 4);
4468   if (GET_CODE (operands[1]) == REG)
4469     operands[3] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4470   else
4471     operands[3] = adjust_address (operands[1], SImode, 4);
4472   if (ADDRESS_REG_P (operands[0]))
4473     return "move%.l %1,%2\;sub%.l %0,%0";
4474   else
4475     return "move%.l %1,%2\;clr%.l %0";
4478 ;; The predicate below must be general_operand, because lshrdi3 allows that
4479 (define_insn "lshrdi_const"
4480   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4481         (lshiftrt:DI (match_operand:DI 1 "general_operand" "0")
4482                      (match_operand 2 "const_int_operand" "n")))]
4483   "(!TARGET_COLDFIRE
4484     && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4485          || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4486          || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
4488   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4489   if (INTVAL (operands[2]) == 63)
4490     return "add%.l %0,%0\;clr%.l %0\;clr%.l %1\;addx%.l %1,%1";
4491   CC_STATUS_INIT;
4492   if (INTVAL (operands[2]) == 1)
4493     return "lsr%.l #1,%0\;roxr%.l #1,%1";
4494   else if (INTVAL (operands[2]) == 8)
4495     return "move%.b %0,%1\;lsr%.l #8,%0\;ror%.l #8,%1";
4496   else if (INTVAL (operands[2]) == 16)
4497     return "move%.w %0,%1\;clr%.w %0\;swap %1\;swap %0";
4498   else if (INTVAL (operands[2]) == 48)
4499     return "move%.l %0,%1\;clr%.w %1\;clr%.l %0\;swap %1";
4500   else if (INTVAL (operands[2]) == 2)
4501     return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4502   else if (INTVAL (operands[2]) == 3)
4503     return "lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1\;lsr%.l #1,%0\;roxr%.l #1,%1";
4504   else /* 32 < INTVAL (operands[2]) <= 63 */
4505     {
4506       operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4507       output_asm_insn (INTVAL (operands[2]) <= 8 ? "lsr%.l %2,%0" :
4508                         "moveq %2,%1\;lsr%.l %1,%0", operands);
4509       return "mov%.l %0,%1\;moveq #0,%0";
4510     }
4513 (define_expand "lshrdi3"
4514   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4515         (lshiftrt:DI (match_operand:DI 1 "general_operand" "")
4516                      (match_operand 2 "const_int_operand" "")))]
4517   "!TARGET_COLDFIRE"
4519   /* ???  This is a named pattern like this is not allowed to FAIL based
4520      on its operands.  */
4521   if (GET_CODE (operands[2]) != CONST_INT
4522       || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4523           && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4524           && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4525     FAIL;
4528 ;; On all 68k models, this makes faster code in a special case.
4530 (define_insn "lshrsi_31"
4531   [(set (match_operand:SI 0 "register_operand" "=d")
4532         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4533                      (const_int 31)))]
4534   ""
4536   return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
4539 ;; On most 68k models, this makes faster code in a special case.
4541 (define_insn "lshrsi_16"
4542   [(set (match_operand:SI 0 "register_operand" "=d")
4543         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4544                      (const_int 16)))]
4545   "!TUNE_68060"
4547   CC_STATUS_INIT;
4548   return "clr%.w %0\;swap %0";
4551 ;; On the 68000, this makes faster code in a special case.
4553 (define_insn "lshrsi_17_24"
4554   [(set (match_operand:SI 0 "register_operand" "=d")
4555         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4556                      (match_operand:SI 2 "const_int_operand" "n")))]
4557   "TUNE_68000_10
4558    && INTVAL (operands[2]) > 16
4559    && INTVAL (operands[2]) <= 24"
4561   /* I think lsr%.w sets the CC properly.  */
4562   operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4563   return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
4566 (define_insn "lshrsi3"
4567   [(set (match_operand:SI 0 "register_operand" "=d")
4568         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
4569                      (match_operand:SI 2 "general_operand" "dI")))]
4570   ""
4571   "lsr%.l %2,%0")
4573 (define_insn "lshrhi3"
4574   [(set (match_operand:HI 0 "register_operand" "=d")
4575         (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
4576                      (match_operand:HI 2 "general_operand" "dI")))]
4577   "!TARGET_COLDFIRE"
4578   "lsr%.w %2,%0")
4580 (define_insn ""
4581   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4582         (lshiftrt:HI (match_dup 0)
4583                      (match_operand:HI 1 "general_operand" "dI")))]
4584   "!TARGET_COLDFIRE"
4585   "lsr%.w %1,%0")
4587 (define_insn "lshrqi3"
4588   [(set (match_operand:QI 0 "register_operand" "=d")
4589         (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
4590                      (match_operand:QI 2 "general_operand" "dI")))]
4591   "!TARGET_COLDFIRE"
4592   "lsr%.b %2,%0")
4594 (define_insn ""
4595   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4596         (lshiftrt:QI (match_dup 0)
4597                      (match_operand:QI 1 "general_operand" "dI")))]
4598   "!TARGET_COLDFIRE"
4599   "lsr%.b %1,%0")
4601 ;; rotate instructions
4603 (define_insn "rotlsi3"
4604   [(set (match_operand:SI 0 "register_operand" "=d")
4605         (rotate:SI (match_operand:SI 1 "register_operand" "0")
4606                    (match_operand:SI 2 "general_operand" "dINO")))]
4607   "!TARGET_COLDFIRE"
4609   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
4610     return "swap %0";
4611   else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
4612     {
4613       operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4614       return "ror%.l %2,%0";
4615     }
4616   else
4617     return "rol%.l %2,%0";
4620 (define_insn "rotlhi3"
4621   [(set (match_operand:HI 0 "register_operand" "=d")
4622         (rotate:HI (match_operand:HI 1 "register_operand" "0")
4623                    (match_operand:HI 2 "general_operand" "dIP")))]
4624   "!TARGET_COLDFIRE"
4626   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4627     {
4628       operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4629       return "ror%.w %2,%0";
4630     }
4631   else
4632     return "rol%.w %2,%0";
4635 (define_insn ""
4636   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4637         (rotate:HI (match_dup 0)
4638                    (match_operand:HI 1 "general_operand" "dIP")))]
4639   "!TARGET_COLDFIRE"
4641   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
4642     {
4643       operands[2] = GEN_INT (16 - INTVAL (operands[2]));
4644       return "ror%.w %2,%0";
4645     }
4646   else
4647     return "rol%.w %2,%0";
4650 (define_insn "rotlqi3"
4651   [(set (match_operand:QI 0 "register_operand" "=d")
4652         (rotate:QI (match_operand:QI 1 "register_operand" "0")
4653                    (match_operand:QI 2 "general_operand" "dI")))]
4654   "!TARGET_COLDFIRE"
4656   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4657     {
4658       operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4659       return "ror%.b %2,%0";
4660     }
4661   else
4662     return "rol%.b %2,%0";
4665 (define_insn ""
4666   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4667         (rotate:QI (match_dup 0)
4668                    (match_operand:QI 1 "general_operand" "dI")))]
4669   "!TARGET_COLDFIRE"
4671   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
4672     {
4673       operands[2] = GEN_INT (8 - INTVAL (operands[2]));
4674       return "ror%.b %2,%0";
4675     }
4676   else
4677     return "rol%.b %2,%0";
4680 (define_insn "rotrsi3"
4681   [(set (match_operand:SI 0 "register_operand" "=d")
4682         (rotatert:SI (match_operand:SI 1 "register_operand" "0")
4683                      (match_operand:SI 2 "general_operand" "dI")))]
4684   "!TARGET_COLDFIRE"
4685   "ror%.l %2,%0")
4687 (define_insn "rotrhi3"
4688   [(set (match_operand:HI 0 "register_operand" "=d")
4689         (rotatert:HI (match_operand:HI 1 "register_operand" "0")
4690                      (match_operand:HI 2 "general_operand" "dI")))]
4691   "!TARGET_COLDFIRE"
4692   "ror%.w %2,%0")
4694 (define_insn ""
4695   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4696         (rotatert:HI (match_dup 0)
4697                      (match_operand:HI 1 "general_operand" "dI")))]
4698   "!TARGET_COLDFIRE"
4699   "ror%.w %1,%0")
4701 (define_insn "rotrqi3"
4702   [(set (match_operand:QI 0 "register_operand" "=d")
4703         (rotatert:QI (match_operand:QI 1 "register_operand" "0")
4704                      (match_operand:QI 2 "general_operand" "dI")))]
4705   "!TARGET_COLDFIRE"
4706   "ror%.b %2,%0")
4708 (define_insn ""
4709   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4710         (rotatert:QI (match_dup 0)
4711                      (match_operand:QI 1 "general_operand" "dI")))]
4712   "!TARGET_COLDFIRE"
4713   "ror%.b %1,%0")
4716 ;; Bit set/clear in memory byte.
4718 ;; set bit, bit number is int
4719 (define_insn "bsetmemqi"
4720   [(set (match_operand:QI 0 "memory_operand" "+m")
4721         (ior:QI (subreg:QI (ashift:SI (const_int 1)
4722                 (match_operand:SI 1 "general_operand" "d")) 3)
4723         (match_dup 0)))]
4724   ""
4726   CC_STATUS_INIT;
4727   return "bset %1,%0";
4730 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
4731 (define_insn ""
4732   [(set (match_operand:QI 0 "memory_operand" "+m")
4733         (ior:QI (subreg:QI (ashift:SI (const_int 1)
4734             (match_operator:SI 2 "extend_operator"
4735                 [(match_operand 1 "general_operand" "d")])) 3)
4736         (match_dup 0)))]
4737   ""
4739   CC_STATUS_INIT;
4740   return "bset %1,%0";
4743 ;; clear bit, bit number is int
4744 (define_insn "bclrmemqi"
4745   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4746         (const_int 1)
4747         (minus:SI (const_int 7)
4748             (match_operand:SI 1 "general_operand" "d")))
4749     (const_int 0))]
4750   ""
4752   CC_STATUS_INIT;
4753   return "bclr %1,%0";
4756 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
4757 (define_insn ""
4758   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
4759         (const_int 1)
4760         (minus:SI (const_int 7)
4761             (match_operator:SI 2 "extend_operator"
4762                 [(match_operand 1 "general_operand" "d")])))
4763     (const_int 0))]
4764   ""
4766   CC_STATUS_INIT;
4767   return "bclr %1,%0";
4770 ;; Special cases of bit-field insns which we should
4771 ;; recognize in preference to the general case.
4772 ;; These handle aligned 8-bit and 16-bit fields,
4773 ;; which can usually be done with move instructions.
4776 ; Special case for 32-bit field in memory.  This only occurs when 32-bit
4777 ; alignment of structure members is specified.
4779 ; The move is allowed to be odd byte aligned, because that's still faster
4780 ; than an odd byte aligned bit-field instruction.
4782 (define_insn ""
4783   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4784                          (const_int 32)
4785                          (match_operand:SI 1 "const_int_operand" "n"))
4786         (match_operand:SI 2 "general_src_operand" "rmSi"))]
4787   "TARGET_68020 && TARGET_BITFIELD
4788    && (INTVAL (operands[1]) % 8) == 0
4789    && ! mode_dependent_address_p (XEXP (operands[0], 0))"
4791   operands[0]
4792     = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
4794   return "move%.l %2,%0";
4797 (define_insn ""
4798   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
4799                          (match_operand:SI 1 "const_int_operand" "n")
4800                          (match_operand:SI 2 "const_int_operand" "n"))
4801         (match_operand:SI 3 "register_operand" "d"))]
4802   "TARGET_68020 && TARGET_BITFIELD
4803    && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
4804    && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
4805    && (GET_CODE (operands[0]) == REG
4806        || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
4808   if (REG_P (operands[0]))
4809     {
4810       if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
4811         return "bfins %3,%0{%b2:%b1}";
4812     }
4813   else
4814     operands[0] = adjust_address (operands[0],
4815                                   INTVAL (operands[1]) == 8 ? QImode : HImode,
4816                                   INTVAL (operands[2]) / 8);
4818   if (GET_CODE (operands[3]) == MEM)
4819     operands[3] = adjust_address (operands[3],
4820                                   INTVAL (operands[1]) == 8 ? QImode : HImode,
4821                                   (32 - INTVAL (operands[1])) / 8);
4823   if (INTVAL (operands[1]) == 8)
4824     return "move%.b %3,%0";
4825   return "move%.w %3,%0";
4830 ; Special case for 32-bit field in memory.  This only occurs when 32-bit
4831 ; alignment of structure members is specified.
4833 ; The move is allowed to be odd byte aligned, because that's still faster
4834 ; than an odd byte aligned bit-field instruction.
4836 (define_insn ""
4837   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4838         (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4839                          (const_int 32)
4840                          (match_operand:SI 2 "const_int_operand" "n")))]
4841   "TARGET_68020 && TARGET_BITFIELD
4842    && (INTVAL (operands[2]) % 8) == 0
4843    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4845   operands[1]
4846     = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4848   return "move%.l %1,%0";
4851 (define_insn ""
4852   [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
4853         (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
4854                          (match_operand:SI 2 "const_int_operand" "n")
4855                          (match_operand:SI 3 "const_int_operand" "n")))]
4856   "TARGET_68020 && TARGET_BITFIELD
4857    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4858    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4859    && (GET_CODE (operands[1]) == REG
4860        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4862   cc_status.flags |= CC_NOT_NEGATIVE;
4863   if (REG_P (operands[1]))
4864     {
4865       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4866         return "bfextu %1{%b3:%b2},%0";
4867     }
4868   else
4869     operands[1]
4870       = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
4872   output_asm_insn ("clr%.l %0", operands);
4873   if (GET_CODE (operands[0]) == MEM)
4874     operands[0] = adjust_address (operands[0],
4875                                   INTVAL (operands[2]) == 8 ? QImode : HImode,
4876                                   (32 - INTVAL (operands[1])) / 8);
4878   if (INTVAL (operands[2]) == 8)
4879     return "move%.b %1,%0";
4880   return "move%.w %1,%0";
4884 ; Special case for 32-bit field in memory.  This only occurs when 32-bit
4885 ; alignment of structure members is specified.
4887 ; The move is allowed to be odd byte aligned, because that's still faster
4888 ; than an odd byte aligned bit-field instruction.
4890 (define_insn ""
4891   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4892         (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
4893                          (const_int 32)
4894                          (match_operand:SI 2 "const_int_operand" "n")))]
4895   "TARGET_68020 && TARGET_BITFIELD
4896    && (INTVAL (operands[2]) % 8) == 0
4897    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
4899   operands[1]
4900     = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
4902   return "move%.l %1,%0";
4905 (define_insn ""
4906   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4907         (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
4908                          (match_operand:SI 2 "const_int_operand" "n")
4909                          (match_operand:SI 3 "const_int_operand" "n")))]
4910   "TARGET_68020 && TARGET_BITFIELD
4911    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
4912    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
4913    && (GET_CODE (operands[1]) == REG
4914        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
4916   if (REG_P (operands[1]))
4917     {
4918       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
4919         return "bfexts %1{%b3:%b2},%0";
4920     }
4921   else
4922     operands[1]
4923       = adjust_address (operands[1],
4924                         INTVAL (operands[2]) == 8 ? QImode : HImode,
4925                         INTVAL (operands[3]) / 8);
4927   if (INTVAL (operands[2]) == 8)
4928     return "move%.b %1,%0\;extb%.l %0";
4929   return "move%.w %1,%0\;ext%.l %0";
4932 ;; Bit-field instructions, general cases.
4933 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
4934 ;; so that its address is reloaded.
4936 (define_expand "extv"
4937   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4938         (sign_extract:SI (match_operand:SI 1 "general_operand" "")
4939                          (match_operand:SI 2 "general_operand" "")
4940                          (match_operand:SI 3 "general_operand" "")))]
4941   "TARGET_68020 && TARGET_BITFIELD"
4942   "")
4944 (define_insn ""
4945   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4946         (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
4947                          (match_operand:SI 2 "general_operand" "dn")
4948                          (match_operand:SI 3 "general_operand" "dn")))]
4949   "TARGET_68020 && TARGET_BITFIELD"
4950   "bfexts %1{%b3:%b2},%0")
4952 (define_expand "extzv"
4953   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4954         (zero_extract:SI (match_operand:SI 1 "general_operand" "")
4955                          (match_operand:SI 2 "general_operand" "")
4956                          (match_operand:SI 3 "general_operand" "")))]
4957   "TARGET_68020 && TARGET_BITFIELD"
4958   "")
4960 (define_insn ""
4961   [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d")
4962         (zero_extract:SI (match_operand:QI 1 "memory_operand" "o,d")
4963                          (match_operand:SI 2 "general_operand" "dn,dn")
4964                          (match_operand:SI 3 "general_operand" "dn,dn")))]
4965   "TARGET_68020 && TARGET_BITFIELD"
4967   if (GET_CODE (operands[2]) == CONST_INT)
4968     {
4969       if (INTVAL (operands[2]) != 32)
4970         cc_status.flags |= CC_NOT_NEGATIVE;
4971     }
4972   else
4973     {
4974       CC_STATUS_INIT;
4975     }
4976   return "bfextu %1{%b3:%b2},%0";
4979 (define_insn ""
4980   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4981                          (match_operand:SI 1 "general_operand" "dn")
4982                          (match_operand:SI 2 "general_operand" "dn"))
4983         (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
4984                 (match_operand 3 "const_int_operand" "n")))]
4985   "TARGET_68020 && TARGET_BITFIELD
4986    && (INTVAL (operands[3]) == -1
4987        || (GET_CODE (operands[1]) == CONST_INT
4988            && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
4990   CC_STATUS_INIT;
4991   return "bfchg %0{%b2:%b1}";
4994 (define_insn ""
4995   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
4996                          (match_operand:SI 1 "general_operand" "dn")
4997                          (match_operand:SI 2 "general_operand" "dn"))
4998         (const_int 0))]
4999   "TARGET_68020 && TARGET_BITFIELD"
5001   CC_STATUS_INIT;
5002   return "bfclr %0{%b2:%b1}";
5005 (define_insn ""
5006   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5007                          (match_operand:SI 1 "general_operand" "dn")
5008                          (match_operand:SI 2 "general_operand" "dn"))
5009         (const_int -1))]
5010   "TARGET_68020 && TARGET_BITFIELD"
5012   CC_STATUS_INIT;
5013   return "bfset %0{%b2:%b1}";
5016 (define_expand "insv"
5017   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5018                          (match_operand:SI 1 "general_operand" "")
5019                          (match_operand:SI 2 "general_operand" ""))
5020         (match_operand:SI 3 "register_operand" ""))]
5021   "TARGET_68020 && TARGET_BITFIELD"
5022   "")
5024 (define_insn ""
5025   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5026                          (match_operand:SI 1 "general_operand" "dn")
5027                          (match_operand:SI 2 "general_operand" "dn"))
5028         (match_operand:SI 3 "register_operand" "d"))]
5029   "TARGET_68020 && TARGET_BITFIELD"
5030   "bfins %3,%0{%b2:%b1}")
5032 ;; Now recognize bit-field insns that operate on registers
5033 ;; (or at least were intended to do so).
5035 (define_insn ""
5036   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5037         (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5038                          (match_operand:SI 2 "general_operand" "dn")
5039                          (match_operand:SI 3 "general_operand" "dn")))]
5040   "TARGET_68020 && TARGET_BITFIELD"
5041   "bfexts %1{%b3:%b2},%0")
5043 (define_insn ""
5044   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5045         (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5046                          (match_operand:SI 2 "general_operand" "dn")
5047                          (match_operand:SI 3 "general_operand" "dn")))]
5048   "TARGET_68020 && TARGET_BITFIELD"
5050   if (GET_CODE (operands[2]) == CONST_INT)
5051     {
5052       if (INTVAL (operands[2]) != 32)
5053         cc_status.flags |= CC_NOT_NEGATIVE;
5054     }
5055   else
5056     {
5057       CC_STATUS_INIT;
5058     }
5059   return "bfextu %1{%b3:%b2},%0";
5062 (define_insn ""
5063   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5064                          (match_operand:SI 1 "general_operand" "dn")
5065                          (match_operand:SI 2 "general_operand" "dn"))
5066         (const_int 0))]
5067   "TARGET_68020 && TARGET_BITFIELD"
5069   CC_STATUS_INIT;
5070   return "bfclr %0{%b2:%b1}";
5073 (define_insn ""
5074   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5075                          (match_operand:SI 1 "general_operand" "dn")
5076                          (match_operand:SI 2 "general_operand" "dn"))
5077         (const_int -1))]
5078   "TARGET_68020 && TARGET_BITFIELD"
5080   CC_STATUS_INIT;
5081   return "bfset %0{%b2:%b1}";
5084 (define_insn ""
5085   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5086                          (match_operand:SI 1 "general_operand" "dn")
5087                          (match_operand:SI 2 "general_operand" "dn"))
5088         (match_operand:SI 3 "register_operand" "d"))]
5089   "TARGET_68020 && TARGET_BITFIELD"
5091 #if 0
5092   /* These special cases are now recognized by a specific pattern.  */
5093   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5094       && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5095     return "move%.w %3,%0";
5096   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5097       && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5098     return "move%.b %3,%0";
5099 #endif
5100   return "bfins %3,%0{%b2:%b1}";
5103 ;; Special patterns for optimizing bit-field instructions.
5105 (define_insn ""
5106   [(set (cc0)
5107         (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5108                          (match_operand:SI 1 "const_int_operand" "n")
5109                          (match_operand:SI 2 "general_operand" "dn")))]
5110   "TARGET_68020 && TARGET_BITFIELD"
5112   if (operands[1] == const1_rtx
5113       && GET_CODE (operands[2]) == CONST_INT)
5114     {
5115       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5116       return output_btst (operands,
5117                           GEN_INT (width - INTVAL (operands[2])),
5118                           operands[0], insn, 1000);
5119       /* Pass 1000 as SIGNPOS argument so that btst will
5120          not think we are testing the sign bit for an `and'
5121          and assume that nonzero implies a negative result.  */
5122     }
5123   if (INTVAL (operands[1]) != 32)
5124     cc_status.flags = CC_NOT_NEGATIVE;
5125   return "bftst %0{%b2:%b1}";
5129 ;;; now handle the register cases
5130 (define_insn ""
5131   [(set (cc0)
5132         (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5133                          (match_operand:SI 1 "const_int_operand" "n")
5134                          (match_operand:SI 2 "general_operand" "dn")))]
5135   "TARGET_68020 && TARGET_BITFIELD"
5137   if (operands[1] == const1_rtx
5138       && GET_CODE (operands[2]) == CONST_INT)
5139     {
5140       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5141       return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5142                           operands[0], insn, 1000);
5143       /* Pass 1000 as SIGNPOS argument so that btst will
5144          not think we are testing the sign bit for an `and'
5145          and assume that nonzero implies a negative result.  */
5146     }
5147   if (INTVAL (operands[1]) != 32)
5148     cc_status.flags = CC_NOT_NEGATIVE;
5149   return "bftst %0{%b2:%b1}";
5152 (define_insn "scc0_di"
5153   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5154     (match_operator 1 "valid_dbcc_comparison_p"
5155       [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5156   "! TARGET_COLDFIRE"
5158   return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5161 (define_insn "scc0_di_5200"
5162   [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5163     (match_operator 1 "valid_dbcc_comparison_p"
5164       [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5165   "TARGET_COLDFIRE"
5167   return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5170 (define_insn "scc_di"
5171   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5172     (match_operator 1 "valid_dbcc_comparison_p"
5173       [(match_operand:DI 2 "general_operand" "ro,r")
5174        (match_operand:DI 3 "general_operand" "r,ro")]))]
5175   "! TARGET_COLDFIRE"
5177   return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5180 (define_insn "scc_di_5200"
5181   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5182     (match_operator 1 "valid_dbcc_comparison_p"
5183       [(match_operand:DI 2 "general_operand" "ro,r")
5184        (match_operand:DI 3 "general_operand" "r,ro")]))]
5185   "TARGET_COLDFIRE"
5187   return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5190 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5191 ;; memory, but we cannot allow it to be in memory in case the address
5192 ;; needs to be reloaded.
5194 (define_expand "seq"
5195   [(set (match_operand:QI 0 "register_operand" "")
5196         (eq:QI (cc0) (const_int 0)))]
5197   ""
5199   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5200       && m68k_last_compare_had_fp_operands)
5201     {
5202       m68k_last_compare_had_fp_operands = 0;
5203       FAIL;
5204     }
5207 (define_insn ""
5208   [(set (match_operand:QI 0 "register_operand" "=d")
5209         (eq:QI (cc0) (const_int 0)))]
5210   ""
5212   cc_status = cc_prev_status;
5213   OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5216 (define_expand "sne"
5217   [(set (match_operand:QI 0 "register_operand" "")
5218         (ne:QI (cc0) (const_int 0)))]
5219   ""
5221   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5222       && m68k_last_compare_had_fp_operands)
5223     {
5224       m68k_last_compare_had_fp_operands = 0;
5225       FAIL;
5226     }
5229 (define_insn ""
5230   [(set (match_operand:QI 0 "register_operand" "=d")
5231         (ne:QI (cc0) (const_int 0)))]
5232   ""
5234   cc_status = cc_prev_status;
5235   OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5238 (define_expand "sgt"
5239   [(set (match_operand:QI 0 "register_operand" "")
5240         (gt:QI (cc0) (const_int 0)))]
5241   ""
5243   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5244       && m68k_last_compare_had_fp_operands)
5245     {
5246       m68k_last_compare_had_fp_operands = 0;
5247       FAIL;
5248     }
5251 (define_insn ""
5252   [(set (match_operand:QI 0 "register_operand" "=d")
5253         (gt:QI (cc0) (const_int 0)))]
5254   ""
5256   cc_status = cc_prev_status;
5257   OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5260 (define_expand "sgtu"
5261   [(set (match_operand:QI 0 "register_operand" "")
5262         (gtu:QI (cc0) (const_int 0)))]
5263   ""
5264   "")
5266 (define_insn ""
5267   [(set (match_operand:QI 0 "register_operand" "=d")
5268         (gtu:QI (cc0) (const_int 0)))]
5269   ""
5271   cc_status = cc_prev_status;
5272   return "shi %0";
5275 (define_expand "slt"
5276   [(set (match_operand:QI 0 "register_operand" "")
5277         (lt:QI (cc0) (const_int 0)))]
5278   ""
5280   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5281       && m68k_last_compare_had_fp_operands)
5282     {
5283       m68k_last_compare_had_fp_operands = 0;
5284       FAIL;
5285     }
5288 (define_insn ""
5289   [(set (match_operand:QI 0 "register_operand" "=d")
5290         (lt:QI (cc0) (const_int 0)))]
5291   ""
5293    cc_status = cc_prev_status;
5294    OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5297 (define_expand "sltu"
5298   [(set (match_operand:QI 0 "register_operand" "")
5299         (ltu:QI (cc0) (const_int 0)))]
5300   ""
5301   "")
5303 (define_insn ""
5304   [(set (match_operand:QI 0 "register_operand" "=d")
5305         (ltu:QI (cc0) (const_int 0)))]
5306   ""
5308    cc_status = cc_prev_status;
5309    return "scs %0";
5312 (define_expand "sge"
5313   [(set (match_operand:QI 0 "register_operand" "")
5314         (ge:QI (cc0) (const_int 0)))]
5315   ""
5317   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5318       && m68k_last_compare_had_fp_operands)
5319     {
5320       m68k_last_compare_had_fp_operands = 0;
5321       FAIL;
5322     }
5325 (define_insn ""
5326   [(set (match_operand:QI 0 "register_operand" "=d")
5327         (ge:QI (cc0) (const_int 0)))]
5328   ""
5330    cc_status = cc_prev_status;
5331    OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5334 (define_expand "sgeu"
5335   [(set (match_operand:QI 0 "register_operand" "")
5336         (geu:QI (cc0) (const_int 0)))]
5337   ""
5338   "")
5340 (define_insn ""
5341   [(set (match_operand:QI 0 "register_operand" "=d")
5342         (geu:QI (cc0) (const_int 0)))]
5343   ""
5345    cc_status = cc_prev_status;
5346    return "scc %0";
5349 (define_expand "sle"
5350   [(set (match_operand:QI 0 "register_operand" "")
5351         (le:QI (cc0) (const_int 0)))]
5352   ""
5354   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5355       && m68k_last_compare_had_fp_operands)
5356     {
5357       m68k_last_compare_had_fp_operands = 0;
5358       FAIL;
5359     }
5362 (define_insn ""
5363   [(set (match_operand:QI 0 "register_operand" "=d")
5364         (le:QI (cc0) (const_int 0)))]
5365   ""
5367   cc_status = cc_prev_status;
5368   OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5371 (define_expand "sleu"
5372   [(set (match_operand:QI 0 "register_operand" "")
5373         (leu:QI (cc0) (const_int 0)))]
5374   ""
5375   "")
5377 (define_insn ""
5378   [(set (match_operand:QI 0 "register_operand" "=d")
5379         (leu:QI (cc0) (const_int 0)))]
5380   ""
5382    cc_status = cc_prev_status;
5383    return "sls %0";
5386 (define_expand "sordered"
5387   [(set (match_operand:QI 0 "register_operand" "")
5388         (ordered:QI (cc0) (const_int 0)))]
5389   "TARGET_68881 && !TUNE_68060"
5391   gcc_assert (m68k_last_compare_had_fp_operands);
5392   m68k_last_compare_had_fp_operands = 0;
5395 (define_insn "*sordered_1"
5396   [(set (match_operand:QI 0 "register_operand" "=d")
5397         (ordered:QI (cc0) (const_int 0)))]
5398   "TARGET_68881 && !TUNE_68060"
5400   cc_status = cc_prev_status;
5401   return "fsor %0";
5404 (define_expand "sunordered"
5405   [(set (match_operand:QI 0 "register_operand" "")
5406         (unordered:QI (cc0) (const_int 0)))]
5407   "TARGET_68881 && !TUNE_68060"
5409   gcc_assert (m68k_last_compare_had_fp_operands);
5410   m68k_last_compare_had_fp_operands = 0;
5413 (define_insn "*sunordered_1"
5414   [(set (match_operand:QI 0 "register_operand" "=d")
5415         (unordered:QI (cc0) (const_int 0)))]
5416   "TARGET_68881 && !TUNE_68060"
5418   cc_status = cc_prev_status;
5419   return "fsun %0";
5422 (define_expand "suneq"
5423   [(set (match_operand:QI 0 "register_operand" "")
5424         (uneq:QI (cc0) (const_int 0)))]
5425   "TARGET_68881 && !TUNE_68060"
5427   gcc_assert (m68k_last_compare_had_fp_operands);
5428   m68k_last_compare_had_fp_operands = 0;
5431 (define_insn "*suneq_1"
5432   [(set (match_operand:QI 0 "register_operand" "=d")
5433         (uneq:QI (cc0) (const_int 0)))]
5434   "TARGET_68881 && !TUNE_68060"
5436   cc_status = cc_prev_status;
5437   return "fsueq %0";
5440 (define_expand "sunge"
5441   [(set (match_operand:QI 0 "register_operand" "")
5442         (unge:QI (cc0) (const_int 0)))]
5443   "TARGET_68881 && !TUNE_68060"
5445   gcc_assert (m68k_last_compare_had_fp_operands);
5446   m68k_last_compare_had_fp_operands = 0;
5449 (define_insn "*sunge_1"
5450   [(set (match_operand:QI 0 "register_operand" "=d")
5451         (unge:QI (cc0) (const_int 0)))]
5452   "TARGET_68881 && !TUNE_68060"
5454   cc_status = cc_prev_status;
5455   return "fsuge %0";
5458 (define_expand "sungt"
5459   [(set (match_operand:QI 0 "register_operand" "")
5460         (ungt:QI (cc0) (const_int 0)))]
5461   "TARGET_68881 && !TUNE_68060"
5463   gcc_assert (m68k_last_compare_had_fp_operands);
5464   m68k_last_compare_had_fp_operands = 0;
5467 (define_insn "*sungt_1"
5468   [(set (match_operand:QI 0 "register_operand" "=d")
5469         (ungt:QI (cc0) (const_int 0)))]
5470   "TARGET_68881 && !TUNE_68060"
5472   cc_status = cc_prev_status;
5473   return "fsugt %0";
5476 (define_expand "sunle"
5477   [(set (match_operand:QI 0 "register_operand" "")
5478         (unle:QI (cc0) (const_int 0)))]
5479   "TARGET_68881 && !TUNE_68060"
5481   gcc_assert (m68k_last_compare_had_fp_operands);
5482   m68k_last_compare_had_fp_operands = 0;
5485 (define_insn "*sunle_1"
5486   [(set (match_operand:QI 0 "register_operand" "=d")
5487         (unle:QI (cc0) (const_int 0)))]
5488   "TARGET_68881 && !TUNE_68060"
5490   cc_status = cc_prev_status;
5491   return "fsule %0";
5494 (define_expand "sunlt"
5495   [(set (match_operand:QI 0 "register_operand" "")
5496         (unlt:QI (cc0) (const_int 0)))]
5497   "TARGET_68881 && !TUNE_68060"
5499   gcc_assert (m68k_last_compare_had_fp_operands);
5500   m68k_last_compare_had_fp_operands = 0;
5503 (define_insn "*sunlt_1"
5504   [(set (match_operand:QI 0 "register_operand" "=d")
5505         (unlt:QI (cc0) (const_int 0)))]
5506   "TARGET_68881 && !TUNE_68060"
5508   cc_status = cc_prev_status;
5509   return "fsult %0";
5512 (define_expand "sltgt"
5513   [(set (match_operand:QI 0 "register_operand" "")
5514         (ltgt:QI (cc0) (const_int 0)))]
5515   "TARGET_68881 && !TUNE_68060"
5517   gcc_assert (m68k_last_compare_had_fp_operands);
5518   m68k_last_compare_had_fp_operands = 0;
5521 (define_insn "*sltgt_1"
5522   [(set (match_operand:QI 0 "register_operand" "=d")
5523         (ltgt:QI (cc0) (const_int 0)))]
5524   "TARGET_68881 && !TUNE_68060"
5526   cc_status = cc_prev_status;
5527   return "fsogl %0";
5530 (define_insn "*fsogt_1"
5531   [(set (match_operand:QI 0 "register_operand" "=d")
5532         (not:QI (unle:QI (cc0) (const_int 0))))]
5533   "TARGET_68881 && !TUNE_68060"
5535   cc_status = cc_prev_status;
5536   return "fsogt %0";
5539 (define_insn "*fsoge_1"
5540   [(set (match_operand:QI 0 "register_operand" "=d")
5541         (not:QI (unlt:QI (cc0) (const_int 0))))]
5542   "TARGET_68881 && !TUNE_68060"
5544   cc_status = cc_prev_status;
5545   return "fsoge %0";
5548 (define_insn "*fsolt_1"
5549   [(set (match_operand:QI 0 "register_operand" "=d")
5550         (not:QI (unge:QI (cc0) (const_int 0))))]
5551   "TARGET_68881 && !TUNE_68060"
5553   cc_status = cc_prev_status;
5554   return "fsolt %0";
5557 (define_insn "*fsole_1"
5558   [(set (match_operand:QI 0 "register_operand" "=d")
5559         (not:QI (ungt:QI (cc0) (const_int 0))))]
5560   "TARGET_68881 && !TUNE_68060"
5562   cc_status = cc_prev_status;
5563   return "fsole %0";
5566 ;; Basic conditional jump instructions.
5568 (define_insn "beq0_di"
5569   [(set (pc)
5570     (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
5571             (const_int 0))
5572         (label_ref (match_operand 1 "" ","))
5573         (pc)))
5574    (clobber (match_scratch:SI 2 "=d,d"))]
5575   ""
5577   CC_STATUS_INIT;
5578   if (which_alternative == 1)
5579     {
5580       if (MOTOROLA)
5581         return "move%.l %0,%2\;or%.l %0,%2\;jbeq %l1";
5582       else
5583         return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5584     }
5585   if ((cc_prev_status.value1
5586       && rtx_equal_p (cc_prev_status.value1, operands[0]))
5587     || (cc_prev_status.value2
5588       && rtx_equal_p (cc_prev_status.value2, operands[0])))
5589     {
5590       cc_status = cc_prev_status;
5591       return MOTOROLA ? "jbeq %l1" : "jeq %l1";
5592     }
5593   if (GET_CODE (operands[0]) == REG)
5594     operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5595   else
5596     operands[3] = adjust_address (operands[0], SImode, 4);
5597   if (! ADDRESS_REG_P (operands[0]))
5598     {
5599       if (reg_overlap_mentioned_p (operands[2], operands[0]))
5600         {
5601           if (reg_overlap_mentioned_p (operands[2], operands[3]))
5602             {
5603               if (MOTOROLA)
5604                 return "or%.l %0,%2\;jbeq %l1";
5605               else
5606                 return "or%.l %0,%2\;jeq %l1";
5607             }
5608           else
5609             {
5610               if (MOTOROLA)
5611                 return "or%.l %3,%2\;jbeq %l1";
5612               else
5613                 return "or%.l %3,%2\;jeq %l1";
5614             }
5615         }
5616       if (MOTOROLA)
5617         return "move%.l %0,%2\;or%.l %3,%2\;jbeq %l1";
5618       else
5619         return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5620     }
5621   operands[4] = gen_label_rtx();
5622   if (TARGET_68020 || TARGET_COLDFIRE)
5623     {
5624       if (MOTOROLA)
5625         output_asm_insn ("tst%.l %0\;jbne %l4\;tst%.l %3\;jbeq %l1", operands);
5626       else
5627         output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
5628     }
5629   else
5630     {
5631       if (MOTOROLA)
5632         output_asm_insn ("cmp%.w #0,%0\;jbne %l4\;cmp%.w #0,%3\;jbeq %l1", operands);
5633       else
5634         output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
5635     }
5636   (*targetm.asm_out.internal_label) (asm_out_file, "L",
5637                                 CODE_LABEL_NUMBER (operands[4]));
5638   return "";
5641 (define_insn "bne0_di"
5642   [(set (pc)
5643     (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
5644             (const_int 0))
5645         (label_ref (match_operand 1 "" ","))
5646         (pc)))
5647    (clobber (match_scratch:SI 2 "=d,X"))]
5648   ""
5650   if ((cc_prev_status.value1
5651       && rtx_equal_p (cc_prev_status.value1, operands[0]))
5652     || (cc_prev_status.value2
5653       && rtx_equal_p (cc_prev_status.value2, operands[0])))
5654     {
5655       cc_status = cc_prev_status;
5656       return MOTOROLA ? "jbne %l1" : "jne %l1";
5657     }
5658   CC_STATUS_INIT;
5659   if (GET_CODE (operands[0]) == REG)
5660     operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5661   else
5662     operands[3] = adjust_address (operands[0], SImode, 4);
5663   if (!ADDRESS_REG_P (operands[0]))
5664     {
5665       if (reg_overlap_mentioned_p (operands[2], operands[0]))
5666         {
5667           if (reg_overlap_mentioned_p (operands[2], operands[3]))
5668             {
5669               if (MOTOROLA)
5670                 return "or%.l %0,%2\;jbne %l1";
5671               else
5672                 return "or%.l %0,%2\;jne %l1";
5673             }
5674           else
5675             {
5676               if (MOTOROLA)
5677                 return "or%.l %3,%2\;jbne %l1";
5678               else
5679                 return "or%.l %3,%2\;jne %l1";
5680             }
5681         }
5682       if (MOTOROLA)
5683         return "move%.l %0,%2\;or%.l %3,%2\;jbne %l1";
5684       else
5685         return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
5686     }
5687   if (TARGET_68020 || TARGET_COLDFIRE)
5688     {
5689       if (MOTOROLA)
5690         return "tst%.l %0\;jbne %l1\;tst%.l %3\;jbne %l1";
5691       else
5692         return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
5693     }
5694   else
5695     {
5696       if (MOTOROLA)
5697         return "cmp%.w #0,%0\;jbne %l1\;cmp%.w #0,%3\;jbne %l1";
5698       else
5699         return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
5700     }
5703 (define_insn "bge0_di"
5704   [(set (pc)
5705     (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
5706             (const_int 0))
5707         (label_ref (match_operand 1 "" ""))
5708         (pc)))]
5709   ""
5711   if ((cc_prev_status.value1
5712       && rtx_equal_p (cc_prev_status.value1, operands[0]))
5713     || (cc_prev_status.value2
5714       && rtx_equal_p (cc_prev_status.value2, operands[0])))
5715     {
5716       cc_status = cc_prev_status;
5717       if (cc_status.flags & CC_REVERSED)
5718         {
5719           return MOTOROLA ? "jble %l1" : "jle %l1";
5720         }
5721       else
5722         {
5723           return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5724         }
5725     }
5726   CC_STATUS_INIT;
5727   if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5728     output_asm_insn("tst%.l %0", operands);
5729   else
5730     {
5731       /* On an address reg, cmpw may replace cmpl.  */
5732       output_asm_insn("cmp%.w #0,%0", operands);
5733     }
5734   return MOTOROLA ? "jbpl %l1" : "jpl %l1";
5737 (define_insn "blt0_di"
5738   [(set (pc)
5739     (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
5740             (const_int 0))
5741         (label_ref (match_operand 1 "" ""))
5742         (pc)))]
5743   ""
5745   if ((cc_prev_status.value1
5746       && rtx_equal_p (cc_prev_status.value1, operands[0]))
5747     || (cc_prev_status.value2
5748       && rtx_equal_p (cc_prev_status.value2, operands[0])))
5749     {
5750       cc_status = cc_prev_status;
5751       if (cc_status.flags & CC_REVERSED)
5752         {
5753           return MOTOROLA ? "jbgt %l1" : "jgt %l1";
5754         }
5755       else
5756         {
5757           return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5758         }
5759     }
5760   CC_STATUS_INIT;
5761   if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
5762     output_asm_insn("tst%.l %0", operands);
5763   else
5764     {
5765       /* On an address reg, cmpw may replace cmpl.  */
5766       output_asm_insn("cmp%.w #0,%0", operands);
5767     }
5769   return MOTOROLA ? "jbmi %l1" : "jmi %l1";
5772 (define_insn "beq"
5773   [(set (pc)
5774         (if_then_else (eq (cc0)
5775                           (const_int 0))
5776                       (label_ref (match_operand 0 "" ""))
5777                       (pc)))]
5778   ""
5780   if (MOTOROLA)
5781     OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
5782   else
5783     OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
5786 (define_insn "bne"
5787   [(set (pc)
5788         (if_then_else (ne (cc0)
5789                           (const_int 0))
5790                       (label_ref (match_operand 0 "" ""))
5791                       (pc)))]
5792   ""
5794   if (MOTOROLA)
5795     OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
5796   else
5797     OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
5800 (define_insn "bgt"
5801   [(set (pc)
5802         (if_then_else (gt (cc0)
5803                           (const_int 0))
5804                       (label_ref (match_operand 0 "" ""))
5805                       (pc)))]
5806   ""
5808   if (MOTOROLA)
5809     OUTPUT_JUMP ("jbgt %l0", "fbgt %l0", 0);
5810   else
5811     OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
5814 (define_insn "bgtu"
5815   [(set (pc)
5816         (if_then_else (gtu (cc0)
5817                            (const_int 0))
5818                       (label_ref (match_operand 0 "" ""))
5819                       (pc)))]
5820   ""
5822   return MOTOROLA ? "jbhi %l0" : "jhi %l0";
5825 (define_insn "blt"
5826   [(set (pc)
5827         (if_then_else (lt (cc0)
5828                           (const_int 0))
5829                       (label_ref (match_operand 0 "" ""))
5830                       (pc)))]
5831   ""
5833   if (MOTOROLA)
5834     OUTPUT_JUMP ("jblt %l0", "fblt %l0", "jbmi %l0");
5835   else
5836     OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
5839 (define_insn "bltu"
5840   [(set (pc)
5841         (if_then_else (ltu (cc0)
5842                            (const_int 0))
5843                       (label_ref (match_operand 0 "" ""))
5844                       (pc)))]
5845   ""
5847   return MOTOROLA ? "jbcs %l0" : "jcs %l0";
5850 (define_insn "bge"
5851   [(set (pc)
5852         (if_then_else (ge (cc0)
5853                           (const_int 0))
5854                       (label_ref (match_operand 0 "" ""))
5855                       (pc)))]
5856   ""
5858   if (MOTOROLA)
5859     OUTPUT_JUMP ("jbge %l0", "fbge %l0", "jbpl %l0");
5860   else
5861     OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
5864 (define_insn "bgeu"
5865   [(set (pc)
5866         (if_then_else (geu (cc0)
5867                            (const_int 0))
5868                       (label_ref (match_operand 0 "" ""))
5869                       (pc)))]
5870   ""
5872   return MOTOROLA ? "jbcc %l0" : "jcc %l0";
5875 (define_insn "ble"
5876   [(set (pc)
5877         (if_then_else (le (cc0)
5878                           (const_int 0))
5879                       (label_ref (match_operand 0 "" ""))
5880                       (pc)))]
5881   ""
5883   if (MOTOROLA)
5884     OUTPUT_JUMP ("jble %l0", "fble %l0", 0);
5885   else
5886     OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
5889 (define_insn "bleu"
5890   [(set (pc)
5891         (if_then_else (leu (cc0)
5892                            (const_int 0))
5893                       (label_ref (match_operand 0 "" ""))
5894                       (pc)))]
5895   ""
5897   return MOTOROLA ? "jbls %l0" : "jls %l0";
5900 (define_insn "bordered"
5901   [(set (pc)
5902         (if_then_else (ordered (cc0) (const_int 0))
5903                       (label_ref (match_operand 0 "" ""))
5904                       (pc)))]
5905   "TARGET_HARD_FLOAT"
5907   gcc_assert (cc_prev_status.flags & CC_IN_68881);
5908   return MOTOROLA ? "fbor %l0" : "fjor %l0";
5911 (define_insn "bunordered"
5912   [(set (pc)
5913         (if_then_else (unordered (cc0) (const_int 0))
5914                       (label_ref (match_operand 0 "" ""))
5915                       (pc)))]
5916   "TARGET_HARD_FLOAT"
5918   gcc_assert (cc_prev_status.flags & CC_IN_68881);
5919   return MOTOROLA ? "fbun %l0" : "fjun %l0";
5922 (define_insn "buneq"
5923   [(set (pc)
5924         (if_then_else (uneq (cc0) (const_int 0))
5925                       (label_ref (match_operand 0 "" ""))
5926                       (pc)))]
5927   "TARGET_HARD_FLOAT"
5929   gcc_assert (cc_prev_status.flags & CC_IN_68881);
5930   return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
5933 (define_insn "bunge"
5934   [(set (pc)
5935         (if_then_else (unge (cc0) (const_int 0))
5936                       (label_ref (match_operand 0 "" ""))
5937                       (pc)))]
5938   "TARGET_HARD_FLOAT"
5940   gcc_assert (cc_prev_status.flags & CC_IN_68881);
5941   return MOTOROLA ? "fbuge %l0" : "fjuge %l0";
5944 (define_insn "bungt"
5945   [(set (pc)
5946         (if_then_else (ungt (cc0) (const_int 0))
5947                       (label_ref (match_operand 0 "" ""))
5948                       (pc)))]
5949   "TARGET_HARD_FLOAT"
5951   gcc_assert (cc_prev_status.flags & CC_IN_68881);
5952   return MOTOROLA ? "fbugt %l0" : "fjugt %l0";
5955 (define_insn "bunle"
5956   [(set (pc)
5957         (if_then_else (unle (cc0) (const_int 0))
5958                       (label_ref (match_operand 0 "" ""))
5959                       (pc)))]
5960   "TARGET_HARD_FLOAT"
5962   gcc_assert (cc_prev_status.flags & CC_IN_68881);
5963   return MOTOROLA ? "fbule %l0" : "fjule %l0";
5966 (define_insn "bunlt"
5967   [(set (pc)
5968         (if_then_else (unlt (cc0) (const_int 0))
5969                       (label_ref (match_operand 0 "" ""))
5970                       (pc)))]
5971   "TARGET_HARD_FLOAT"
5973   gcc_assert (cc_prev_status.flags & CC_IN_68881);
5974   return MOTOROLA ? "fbult %l0" : "fjult %l0";
5977 (define_insn "bltgt"
5978   [(set (pc)
5979         (if_then_else (ltgt (cc0) (const_int 0))
5980                       (label_ref (match_operand 0 "" ""))
5981                       (pc)))]
5982   "TARGET_HARD_FLOAT"
5984   gcc_assert (cc_prev_status.flags & CC_IN_68881);
5985   return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
5988 ;; Negated conditional jump instructions.
5990 (define_insn ""
5991   [(set (pc)
5992         (if_then_else (eq (cc0)
5993                           (const_int 0))
5994                       (pc)
5995                       (label_ref (match_operand 0 "" ""))))]
5996   ""
5998   if (MOTOROLA)
5999     OUTPUT_JUMP ("jbne %l0", "fbne %l0", "jbne %l0");
6000   else
6001     OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6004 (define_insn ""
6005   [(set (pc)
6006         (if_then_else (ne (cc0)
6007                           (const_int 0))
6008                       (pc)
6009                       (label_ref (match_operand 0 "" ""))))]
6010   ""
6012   if (MOTOROLA)
6013     OUTPUT_JUMP ("jbeq %l0", "fbeq %l0", "jbeq %l0");
6014   else
6015     OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6018 (define_insn ""
6019   [(set (pc)
6020         (if_then_else (gt (cc0)
6021                           (const_int 0))
6022                       (pc)
6023                       (label_ref (match_operand 0 "" ""))))]
6024   ""
6026   if (MOTOROLA)
6027     OUTPUT_JUMP ("jble %l0", "fbngt %l0", 0);
6028   else
6029     OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6032 (define_insn ""
6033   [(set (pc)
6034         (if_then_else (gtu (cc0)
6035                            (const_int 0))
6036                       (pc)
6037                       (label_ref (match_operand 0 "" ""))))]
6038   ""
6040   return MOTOROLA ? "jbls %l0" : "jls %l0";
6043 (define_insn ""
6044   [(set (pc)
6045         (if_then_else (lt (cc0)
6046                           (const_int 0))
6047                       (pc)
6048                       (label_ref (match_operand 0 "" ""))))]
6049   ""
6051   if (MOTOROLA)
6052     OUTPUT_JUMP ("jbge %l0", "fbnlt %l0", "jbpl %l0");
6053   else
6054     OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6057 (define_insn ""
6058   [(set (pc)
6059         (if_then_else (ltu (cc0)
6060                            (const_int 0))
6061                       (pc)
6062                       (label_ref (match_operand 0 "" ""))))]
6063   ""
6065   return MOTOROLA ? "jbcc %l0" : "jcc %l0";
6068 (define_insn ""
6069   [(set (pc)
6070         (if_then_else (ge (cc0)
6071                           (const_int 0))
6072                       (pc)
6073                       (label_ref (match_operand 0 "" ""))))]
6074   ""
6076   if (MOTOROLA)
6077     OUTPUT_JUMP ("jblt %l0", "fbnge %l0", "jbmi %l0");
6078   else
6079     OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6082 (define_insn ""
6083   [(set (pc)
6084         (if_then_else (geu (cc0)
6085                            (const_int 0))
6086                       (pc)
6087                       (label_ref (match_operand 0 "" ""))))]
6088   ""
6090   return MOTOROLA ? "jbcs %l0" : "jcs %l0";
6093 (define_insn ""
6094   [(set (pc)
6095         (if_then_else (le (cc0)
6096                           (const_int 0))
6097                       (pc)
6098                       (label_ref (match_operand 0 "" ""))))]
6099   ""
6101   if (MOTOROLA)
6102     OUTPUT_JUMP ("jbgt %l0", "fbnle %l0", 0);
6103   else
6104     OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6107 (define_insn ""
6108   [(set (pc)
6109         (if_then_else (leu (cc0)
6110                            (const_int 0))
6111                       (pc)
6112                       (label_ref (match_operand 0 "" ""))))]
6113   ""
6115   return MOTOROLA ? "jbhi %l0" : "jhi %l0";
6118 (define_insn "*bordered_rev"
6119   [(set (pc)
6120         (if_then_else (ordered (cc0) (const_int 0))
6121                       (pc)
6122                       (label_ref (match_operand 0 "" ""))))]
6123   "TARGET_HARD_FLOAT"
6125   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6126   return MOTOROLA ? "fbun %l0" : "fjun %l0";
6129 (define_insn "*bunordered_rev"
6130   [(set (pc)
6131         (if_then_else (unordered (cc0) (const_int 0))
6132                       (pc)
6133                       (label_ref (match_operand 0 "" ""))))]
6134   "TARGET_HARD_FLOAT"
6136   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6137   return MOTOROLA ? "fbor %l0" : "fjor %l0";
6140 (define_insn "*buneq_rev"
6141   [(set (pc)
6142         (if_then_else (uneq (cc0) (const_int 0))
6143                       (pc)
6144                       (label_ref (match_operand 0 "" ""))))]
6145   "TARGET_HARD_FLOAT"
6147   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6148   return MOTOROLA ? "fbogl %l0" : "fjogl %l0";
6151 (define_insn "*bunge_rev"
6152   [(set (pc)
6153         (if_then_else (unge (cc0) (const_int 0))
6154                       (pc)
6155                       (label_ref (match_operand 0 "" ""))))]
6156   "TARGET_HARD_FLOAT"
6158   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6159   return MOTOROLA ? "fbolt %l0" : "fjolt %l0";
6162 (define_insn "*bungt_rev"
6163   [(set (pc)
6164         (if_then_else (ungt (cc0) (const_int 0))
6165                       (pc)
6166                       (label_ref (match_operand 0 "" ""))))]
6167   "TARGET_HARD_FLOAT"
6169   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6170   return MOTOROLA ? "fbole %l0" : "fjole %l0";
6173 (define_insn "*bunle_rev"
6174   [(set (pc)
6175         (if_then_else (unle (cc0) (const_int 0))
6176                       (pc)
6177                       (label_ref (match_operand 0 "" ""))))]
6178   "TARGET_HARD_FLOAT"
6180   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6181   return MOTOROLA ? "fbogt %l0" : "fjogt %l0";
6184 (define_insn "*bunlt_rev"
6185   [(set (pc)
6186         (if_then_else (unlt (cc0) (const_int 0))
6187                       (pc)
6188                       (label_ref (match_operand 0 "" ""))))]
6189   "TARGET_HARD_FLOAT"
6191   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6192   return MOTOROLA ? "fboge %l0" : "fjoge %l0";
6195 (define_insn "*bltgt_rev"
6196   [(set (pc)
6197         (if_then_else (ltgt (cc0) (const_int 0))
6198                       (pc)
6199                       (label_ref (match_operand 0 "" ""))))]
6200   "TARGET_HARD_FLOAT"
6202   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6203   return MOTOROLA ? "fbueq %l0" : "fjueq %l0";
6206 ;; Unconditional and other jump instructions
6207 (define_insn "jump"
6208   [(set (pc)
6209         (label_ref (match_operand 0 "" "")))]
6210   ""
6212   return MOTOROLA ? "jbra %l0" : "jra %l0";
6215 (define_expand "tablejump"
6216   [(parallel [(set (pc) (match_operand 0 "" ""))
6217               (use (label_ref (match_operand 1 "" "")))])]
6218   ""
6220 #ifdef CASE_VECTOR_PC_RELATIVE
6221     operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6222                                 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6223 #endif
6226 ;; Jump to variable address from dispatch table of absolute addresses.
6227 (define_insn ""
6228   [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6229    (use (label_ref (match_operand 1 "" "")))]
6230   ""
6232   return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6235 ;; Jump to variable address from dispatch table of relative addresses.
6236 (define_insn ""
6237   [(set (pc)
6238         (plus:SI (pc)
6239                  (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6240    (use (label_ref (match_operand 1 "" "")))]
6241   ""
6243 #ifdef ASM_RETURN_CASE_JUMP
6244   ASM_RETURN_CASE_JUMP;
6245 #else
6246   if (TARGET_COLDFIRE)
6247     {
6248       if (ADDRESS_REG_P (operands[0]))
6249         return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6250       else if (MOTOROLA)
6251         return "ext%.l %0\;jmp (2,pc,%0.l)";
6252       else
6253         return "extl %0\;jmp pc@(2,%0:l)";
6254     }
6255   else
6256     return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6257 #endif
6260 ;; Decrement-and-branch insns.
6261 (define_insn ""
6262   [(set (pc)
6263         (if_then_else
6264          (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6265              (const_int 0))
6266          (label_ref (match_operand 1 "" ""))
6267          (pc)))
6268    (set (match_dup 0)
6269         (plus:HI (match_dup 0)
6270                  (const_int -1)))]
6271   "!TARGET_COLDFIRE"
6273   CC_STATUS_INIT;
6274   if (DATA_REG_P (operands[0]))
6275     return "dbra %0,%l1";
6276   if (GET_CODE (operands[0]) == MEM)
6277     return MOTOROLA ?
6278       "subq%.w #1,%0\;jbcc %l1" :
6279       "subqw #1,%0\;jcc %l1";
6280   return MOTOROLA ?
6281     "subq%.w #1,%0\;cmp%.w #-1,%0\;jbne %l1" :
6282     "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6285 (define_insn ""
6286   [(set (pc)
6287         (if_then_else
6288          (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6289              (const_int 0))
6290          (label_ref (match_operand 1 "" ""))
6291          (pc)))
6292    (set (match_dup 0)
6293         (plus:SI (match_dup 0)
6294                  (const_int -1)))]
6295   "!TARGET_COLDFIRE"
6297   CC_STATUS_INIT;
6298   if (DATA_REG_P (operands[0]))
6299     return MOTOROLA ?
6300       "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6301       "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6302   if (GET_CODE (operands[0]) == MEM)
6303     return MOTOROLA ?
6304       "subq%.l #1,%0\;jbcc %l1" :
6305       "subq%.l #1,%0\;jcc %l1";
6306   return MOTOROLA ?
6307     "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6308     "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6311 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6313 (define_insn ""
6314   [(set (pc)
6315         (if_then_else
6316           (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6317                        (const_int -1))
6318               (const_int 0))
6319           (label_ref (match_operand 1 "" ""))
6320           (pc)))
6321    (set (match_dup 0)
6322         (plus:HI (match_dup 0)
6323                  (const_int -1)))]
6324   "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6326   CC_STATUS_INIT;
6327   if (DATA_REG_P (operands[0]))
6328     return "dbra %0,%l1";
6329   if (GET_CODE (operands[0]) == MEM)
6330     return MOTOROLA ?
6331       "subq%.w #1,%0\;jbcc %l1" :
6332       "subq%.w #1,%0\;jcc %l1";
6333   return MOTOROLA ?
6334     "subq.w #1,%0\;cmp.w #-1,%0\;jbne %l1" :
6335     "subqw #1,%0\;cmpw #-1,%0\;jne %l1";
6338 (define_expand "decrement_and_branch_until_zero"
6339   [(parallel [(set (pc)
6340                    (if_then_else
6341                     (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6342                                  (const_int -1))
6343                         (const_int 0))
6344                     (label_ref (match_operand 1 "" ""))
6345                     (pc)))
6346               (set (match_dup 0)
6347                    (plus:SI (match_dup 0)
6348                             (const_int -1)))])]
6349   ""
6350   "")
6352 (define_insn ""
6353   [(set (pc)
6354         (if_then_else
6355           (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6356                        (const_int -1))
6357               (const_int 0))
6358           (label_ref (match_operand 1 "" ""))
6359           (pc)))
6360    (set (match_dup 0)
6361         (plus:SI (match_dup 0)
6362                  (const_int -1)))]
6363   "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6365   CC_STATUS_INIT;
6366   if (DATA_REG_P (operands[0]))
6367     return MOTOROLA ?
6368       "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jbcc %l1" :
6369       "dbra %0,%l1\;clr%.w %0\;subql #1,%0\;jcc %l1";
6370   if (GET_CODE (operands[0]) == MEM)
6371     return MOTOROLA ?
6372       "subq%.l #1,%0\;jbcc %l1" :
6373       "subql #1,%0\;jcc %l1";
6374   return MOTOROLA ?
6375     "subq.l #1,%0\;cmp.l #-1,%0\;jbne %l1" :
6376     "subql #1,%0\;cmpl #-1,%0\;jne %l1";
6379 ;; Call subroutine with no return value.
6380 (define_expand "call"
6381   [(call (match_operand:QI 0 "memory_operand" "")
6382          (match_operand:SI 1 "general_operand" ""))]
6383   ;; Operand 1 not really used on the m68000.
6384   ""
6386   operands[0] = m68k_legitimize_call_address (operands[0]);
6389 (define_insn "*call"
6390   [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
6391          (match_operand:SI 1 "general_operand" "g,g"))]
6392   ;; Operand 1 not really used on the m68000.
6393   ""
6395   return output_call (operands[0]);
6398 ;; Call subroutine, returning value in operand 0
6399 ;; (which must be a hard register).
6400 (define_expand "call_value"
6401   [(set (match_operand 0 "" "")
6402         (call (match_operand:QI 1 "memory_operand" "")
6403               (match_operand:SI 2 "general_operand" "")))]
6404   ;; Operand 2 not really used on the m68000.
6405   ""
6407   operands[1] = m68k_legitimize_call_address (operands[1]);
6410 (define_insn "*call_value"
6411   [(set (match_operand 0 "" "=rf,rf")
6412         (call (mem:QI (match_operand:SI 1 "call_operand" "a,W"))
6413               (match_operand:SI 2 "general_operand" "g,g")))]
6414   ;; Operand 2 not really used on the m68000.
6415   ""
6417   operands[0] = operands[1];
6418   return output_call (operands[0]);
6421 ;; Call subroutine returning any type.
6423 (define_expand "untyped_call"
6424   [(parallel [(call (match_operand 0 "" "")
6425                     (const_int 0))
6426               (match_operand 1 "" "")
6427               (match_operand 2 "" "")])]
6428   "NEEDS_UNTYPED_CALL"
6430   int i;
6432   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6434   for (i = 0; i < XVECLEN (operands[2], 0); i++)
6435     {
6436       rtx set = XVECEXP (operands[2], 0, i);
6437       emit_move_insn (SET_DEST (set), SET_SRC (set));
6438     }
6440   /* The optimizer does not know that the call sets the function value
6441      registers we stored in the result block.  We avoid problems by
6442      claiming that all hard registers are used and clobbered at this
6443      point.  */
6444   emit_insn (gen_blockage ());
6446   DONE;
6449 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6450 ;; all of memory.  This blocks insns from being moved across this point.
6452 (define_insn "blockage"
6453   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6454   ""
6455   "")
6457 (define_insn "nop"
6458   [(const_int 0)]
6459   ""
6460   "nop")
6462 ;; Used for frameless functions which save no regs and allocate no locals.
6463 (define_insn "return"
6464   [(return)]
6465   "m68k_use_return_insn ()"
6467   if (current_function_pops_args == 0)
6468     return "rts";
6469   operands[0] = GEN_INT (current_function_pops_args);
6470   return "rtd %0";
6473 (define_insn "indirect_jump"
6474   [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
6475   ""
6476   "jmp %a0")
6478 ;; This should not be used unless the add/sub insns can't be.
6480 (define_insn ""
6481   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
6482         (match_operand:QI 1 "address_operand" "p"))]
6483   ""
6485   /* Recognize an insn that refers to a table of offsets.  Such an insn will
6486      need to refer to a label on the insn.  So output one.  Use the
6487      label-number of the table of offsets to generate this label.  This code,
6488      and similar code above, assumes that there will be at most one reference
6489      to each table.  */
6490   if (GET_CODE (operands[1]) == PLUS
6491       && GET_CODE (XEXP (operands[1], 1)) == LABEL_REF
6492       && GET_CODE (XEXP (operands[1], 0)) != PLUS)
6493     {
6494       rtx labelref = XEXP (operands[1], 1);
6495       if (MOTOROLA)
6496         asm_fprintf (asm_out_file, "\\t.set %LLI%d,.+2\\n",
6497                      CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6498       else
6499         (*targetm.asm_out.internal_label) (asm_out_file, "LI",
6500                      CODE_LABEL_NUMBER (XEXP (labelref, 0)));
6501     }
6502   return "lea %a1,%0";
6505 ;; This is the first machine-dependent peephole optimization.
6506 ;; It is useful when a floating value is returned from a function call
6507 ;; and then is moved into an FP register.
6508 ;; But it is mainly intended to test the support for these optimizations.
6510 (define_peephole
6511   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
6512    (set (match_operand:DF 0 "register_operand" "=f")
6513         (match_operand:DF 1 "register_operand" "ad"))]
6514   "FP_REG_P (operands[0]) && ! FP_REG_P (operands[1])"
6516   rtx xoperands[2];
6517   xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6518   output_asm_insn ("move%.l %1,%@", xoperands);
6519   output_asm_insn ("move%.l %1,%-", operands);
6520   return "fmove%.d %+,%0";
6523 ;; Optimize a stack-adjust followed by a push of an argument.
6524 ;; This is said to happen frequently with -msoft-float
6525 ;; when there are consecutive library calls.
6527 (define_peephole
6528   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6529                                  (match_operand:SI 0 "const_int_operand" "n")))
6530    (set (match_operand:SF 1 "push_operand" "=m")
6531         (match_operand:SF 2 "general_operand" "rmfF"))]
6532   "INTVAL (operands[0]) >= 4
6533    && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6535   if (INTVAL (operands[0]) > 4)
6536     {
6537       rtx xoperands[2];
6538       xoperands[0] = stack_pointer_rtx;
6539       xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6540       if (INTVAL (xoperands[1]) <= 8)
6541         {
6542           if (!TARGET_COLDFIRE)
6543             output_asm_insn ("addq%.w %1,%0", xoperands);
6544           else
6545             output_asm_insn ("addq%.l %1,%0", xoperands);
6546         }
6547       else if (TUNE_CPU32 && INTVAL (xoperands[1]) <= 16)
6548         {
6549           xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6550           output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6551         }
6552       else if (INTVAL (xoperands[1]) <= 0x7FFF)
6553         {
6554           if (TUNE_68040)
6555             output_asm_insn ("add%.w %1,%0", xoperands);
6556           else if (MOTOROLA)
6557             output_asm_insn ("lea (%c1,%0),%0", xoperands);
6558           else
6559             output_asm_insn ("lea %0@(%c1),%0", xoperands);
6560         }
6561       else
6562         output_asm_insn ("add%.l %1,%0", xoperands);
6563     }
6564   if (FP_REG_P (operands[2]))
6565     return "fmove%.s %2,%@";
6566   return "move%.l %2,%@";
6569 ;; Speed up stack adjust followed by a fullword fixedpoint push.
6571 (define_peephole
6572   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
6573                                  (match_operand:SI 0 "const_int_operand" "n")))
6574    (set (match_operand:SI 1 "push_operand" "=m")
6575         (match_operand:SI 2 "general_operand" "g"))]
6576   "INTVAL (operands[0]) >= 4
6577    && ! reg_mentioned_p (stack_pointer_rtx, operands[2])"
6579   if (INTVAL (operands[0]) > 4)
6580     {
6581       rtx xoperands[2];
6582       xoperands[0] = stack_pointer_rtx;
6583       xoperands[1] = GEN_INT (INTVAL (operands[0]) - 4);
6584       if (INTVAL (xoperands[1]) <= 8)
6585         {
6586           if (!TARGET_COLDFIRE)
6587             output_asm_insn ("addq%.w %1,%0", xoperands);
6588           else
6589             output_asm_insn ("addq%.l %1,%0", xoperands);
6590         }
6591       else if (TUNE_CPU32 && INTVAL (xoperands[1]) <= 16)
6592         {
6593           xoperands[1] = GEN_INT (INTVAL (xoperands[1]) - 8);
6594           output_asm_insn ("addq%.w #8,%0\;addq%.w %1,%0", xoperands);
6595         }
6596       else if (INTVAL (xoperands[1]) <= 0x7FFF)
6597         {
6598           if (TUNE_68040)
6599             output_asm_insn ("add%.w %1,%0", xoperands);
6600           else if (MOTOROLA)
6601             output_asm_insn ("lea (%c1,%0),%0", xoperands);
6602           else
6603             output_asm_insn ("lea %0@(%c1),%0", xoperands);
6604         }
6605       else
6606         output_asm_insn ("add%.l %1,%0", xoperands);
6607     }
6608   if (operands[2] == const0_rtx)
6609     return "clr%.l %@";
6610   return "move%.l %2,%@";
6613 ;; Speed up pushing a single byte but leaving four bytes of space.
6615 (define_peephole
6616   [(set (mem:QI (pre_dec:SI (reg:SI SP_REG)))
6617         (match_operand:QI 1 "general_operand" "dami"))
6618    (set (reg:SI SP_REG) (minus:SI (reg:SI SP_REG) (const_int 2)))]
6619   "! reg_mentioned_p (stack_pointer_rtx, operands[1])"
6621   rtx xoperands[4];
6623   if (GET_CODE (operands[1]) == REG)
6624     return "move%.l %1,%-";
6626   xoperands[1] = operands[1];
6627   xoperands[2]
6628     = gen_rtx_MEM (QImode, plus_constant (stack_pointer_rtx, 3));
6629   xoperands[3] = stack_pointer_rtx;
6630   if (!TARGET_COLDFIRE)
6631     output_asm_insn ("subq%.w #4,%3\;move%.b %1,%2", xoperands);
6632   else
6633     output_asm_insn ("subq%.l #4,%3\;move%.b %1,%2", xoperands);
6634   return "";
6637 (define_peephole
6638   [(set (match_operand:SI 0 "register_operand" "=d")
6639         (const_int 0))
6640    (set (strict_low_part (subreg:HI (match_dup 0) 2))
6641         (match_operand:HI 1 "general_operand" "rmn"))]
6642   "strict_low_part_peephole_ok (HImode, prev_nonnote_insn (insn), operands[0])"
6644   if (GET_CODE (operands[1]) == CONST_INT)
6645     {
6646       if (operands[1] == const0_rtx
6647           && (DATA_REG_P (operands[0])
6648               || GET_CODE (operands[0]) == MEM)
6649           /* clr insns on 68000 read before writing.  */
6650           && ((TARGET_68010 || TARGET_COLDFIRE)
6651               || !(GET_CODE (operands[0]) == MEM
6652                    && MEM_VOLATILE_P (operands[0]))))
6653         return "clr%.w %0";
6654     }
6655   return "move%.w %1,%0";
6658 ;; dbCC peepholes
6660 ;; Turns
6661 ;;   loop:
6662 ;;           [ ... ]
6663 ;;           jCC label          ; abnormal loop termination
6664 ;;           dbra dN, loop      ; normal loop termination
6666 ;; Into
6667 ;;   loop:
6668 ;;           [ ... ]
6669 ;;           dbCC dN, loop
6670 ;;           jCC label
6672 ;; Which moves the jCC condition outside the inner loop for free.
6675 (define_peephole
6676   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6677                              [(cc0) (const_int 0)])
6678                            (label_ref (match_operand 2 "" ""))
6679                            (pc)))
6680    (parallel
6681     [(set (pc)
6682           (if_then_else
6683             (ne (match_operand:HI 0 "register_operand" "")
6684                 (const_int 0))
6685             (label_ref (match_operand 1 "" ""))
6686             (pc)))
6687      (set (match_dup 0)
6688           (plus:HI (match_dup 0)
6689                    (const_int -1)))])]
6690   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6692   CC_STATUS_INIT;
6693   output_dbcc_and_branch (operands);
6694   return "";
6697 (define_peephole
6698   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6699                              [(cc0) (const_int 0)])
6700                            (label_ref (match_operand 2 "" ""))
6701                            (pc)))
6702    (parallel
6703     [(set (pc)
6704           (if_then_else
6705             (ne (match_operand:SI 0 "register_operand" "")
6706                 (const_int 0))
6707             (label_ref (match_operand 1 "" ""))
6708             (pc)))
6709      (set (match_dup 0)
6710           (plus:SI (match_dup 0)
6711                    (const_int -1)))])]
6712   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6714   CC_STATUS_INIT;
6715   output_dbcc_and_branch (operands);
6716   return "";
6719 (define_peephole
6720   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6721                              [(cc0) (const_int 0)])
6722                            (label_ref (match_operand 2 "" ""))
6723                            (pc)))
6724    (parallel
6725     [(set (pc)
6726           (if_then_else
6727             (ge (plus:HI (match_operand:HI 0 "register_operand" "")
6728                          (const_int -1))
6729                 (const_int 0))
6730             (label_ref (match_operand 1 "" ""))
6731             (pc)))
6732      (set (match_dup 0)
6733           (plus:HI (match_dup 0)
6734                    (const_int -1)))])]
6735   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6737   CC_STATUS_INIT;
6738   output_dbcc_and_branch (operands);
6739   return "";
6742 (define_peephole
6743   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
6744                              [(cc0) (const_int 0)])
6745                            (label_ref (match_operand 2 "" ""))
6746                            (pc)))
6747    (parallel
6748     [(set (pc)
6749           (if_then_else
6750             (ge (plus:SI (match_operand:SI 0 "register_operand" "")
6751                          (const_int -1))
6752                 (const_int 0))
6753             (label_ref (match_operand 1 "" ""))
6754             (pc)))
6755      (set (match_dup 0)
6756           (plus:SI (match_dup 0)
6757                    (const_int -1)))])]
6758   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
6760   CC_STATUS_INIT;
6761   output_dbcc_and_branch (operands);
6762   return "";
6766 (define_insn "extendsfxf2"
6767   [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6768         (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
6769   "TARGET_68881"
6771   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6772     {
6773       if (REGNO (operands[0]) == REGNO (operands[1]))
6774         {
6775           /* Extending float to double in an fp-reg is a no-op.
6776              NOTICE_UPDATE_CC has already assumed that the
6777              cc will be set.  So cancel what it did.  */
6778           cc_status = cc_prev_status;
6779           return "";
6780         }
6781       return "f%$move%.x %1,%0";
6782     }
6783   if (FP_REG_P (operands[0]))
6784     {
6785       if (FP_REG_P (operands[1]))
6786         return "f%$move%.x %1,%0";
6787       else if (ADDRESS_REG_P (operands[1]))
6788         return "move%.l %1,%-\;f%$move%.s %+,%0";
6789       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
6790         return output_move_const_single (operands);
6791       return "f%$move%.s %f1,%0";
6792     }
6793   return "fmove%.x %f1,%0";
6797 (define_insn "extenddfxf2"
6798   [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
6799         (float_extend:XF
6800           (match_operand:DF 1 "general_operand" "f,rmE")))]
6801   "TARGET_68881"
6803   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
6804     {
6805       if (REGNO (operands[0]) == REGNO (operands[1]))
6806         {
6807           /* Extending float to double in an fp-reg is a no-op.
6808              NOTICE_UPDATE_CC has already assumed that the
6809              cc will be set.  So cancel what it did.  */
6810           cc_status = cc_prev_status;
6811           return "";
6812         }
6813       return "fmove%.x %1,%0";
6814     }
6815   if (FP_REG_P (operands[0]))
6816     {
6817       if (REG_P (operands[1]))
6818         {
6819           rtx xoperands[2];
6820           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
6821           output_asm_insn ("move%.l %1,%-", xoperands);
6822           output_asm_insn ("move%.l %1,%-", operands);
6823           return "f%&move%.d %+,%0";
6824         }
6825       if (GET_CODE (operands[1]) == CONST_DOUBLE)
6826         return output_move_const_double (operands);
6827       return "f%&move%.d %f1,%0";
6828     }
6829   return "fmove%.x %f1,%0";
6832 (define_insn "truncxfdf2"
6833   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
6834         (float_truncate:DF
6835           (match_operand:XF 1 "general_operand" "f,f")))]
6836   "TARGET_68881"
6838   if (REG_P (operands[0]))
6839     {
6840       output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
6841       operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6842       return "move%.l %+,%0";
6843     }
6844   return "fmove%.d %f1,%0";
6847 (define_insn "truncxfsf2"
6848   [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
6849         (float_truncate:SF
6850           (match_operand:XF 1 "general_operand" "f")))]
6851   "TARGET_68881"
6852   "fmove%.s %f1,%0")
6854 (define_insn "sin<mode>2"
6855   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
6856         (unspec:FP
6857           [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
6858   "TARGET_68881 && flag_unsafe_math_optimizations"
6860   if (FP_REG_P (operands[1]))
6861     return "fsin%.x %1,%0";
6862   else
6863     return "fsin%.<FP:prec> %1,%0";
6866 (define_insn "cos<mode>2"
6867   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
6868         (unspec:FP
6869           [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
6870   "TARGET_68881 && flag_unsafe_math_optimizations"
6872   if (FP_REG_P (operands[1]))
6873     return "fcos%.x %1,%0";
6874   else
6875     return "fcos%.<FP:prec> %1,%0";
6878 (define_insn "trap"
6879   [(trap_if (const_int -1) (const_int 7))]
6880   ""
6881   "trap #7")
6883 (define_insn "conditional_trap"
6884   [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
6885                             [(cc0) (const_int 0)])
6886             (match_operand:SI 1 "const_int_operand" "I"))]
6887   "TARGET_68020 && ! flags_in_68881 ()"
6889   switch (GET_CODE (operands[0]))
6890   {
6891   case EQ:  return "trapeq";
6892   case NE:  return "trapne";
6893   case GT:  return "trapgt";
6894   case GTU: return "traphi";
6895   case LT:  return "traplt";
6896   case LTU: return "trapcs";
6897   case GE:  return "trapge";
6898   case GEU: return "trapcc";
6899   case LE:  return "traple";
6900   case LEU: return "trapls";
6901   default: gcc_unreachable ();
6902   }