OSDN Git Service

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