OSDN Git Service

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