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