OSDN Git Service

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