OSDN Git Service

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