OSDN Git Service

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