OSDN Git Service

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