OSDN Git Service

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