OSDN Git Service

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