2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / config / m68k / m68k.md
blob56c459e68b0c5dd359ff2f2b428a26fb74bc4dc0
1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;;  Copyright (C) 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
3 ;;  2002, 2003, 2004, 2005, 2006, 2007
4 ;;  Free Software Foundation, Inc.
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; any later version.
13 ;; GCC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3.  If not see
20 ;; <http://www.gnu.org/licenses/>.
22 ;;- Information about MCF5200 port.
24 ;;- The MCF5200 "ColdFire" architecture is a reduced version of the
25 ;;- 68k ISA.  Differences include reduced support for byte and word
26 ;;- operands and the removal of BCD, bitfield, rotate, and integer
27 ;;- divide instructions.  The TARGET_COLDFIRE flag turns the use of the
28 ;;- removed opcodes and addressing modes off.
29 ;;- 
32 ;;- instruction definitions
34 ;;- @@The original PO technology requires these to be ordered by speed,
35 ;;- @@    so that assigner will pick the fastest.
37 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
39 ;;- When naming insn's (operand 0 of define_insn) be careful about using
40 ;;- names from other targets machine descriptions.
42 ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
43 ;;- updates for most instructions.
45 ;;- Operand classes for the register allocator:
46 ;;- 'a' one of the address registers can be used.
47 ;;- 'd' one of the data registers can be used.
48 ;;- 'f' one of the m68881/fpu registers can be used
49 ;;- 'r' either a data or an address register can be used.
51 ;;- Immediate Floating point operator constraints
52 ;;- 'G' a floating point constant that is *NOT* one of the standard
53 ;;   68881 constant values (to force calling output_move_const_double
54 ;;   to get it from rom if it is a 68881 constant).
56 ;;   See the functions standard_XXX_constant_p in output-m68k.c for more
57 ;; info.
59 ;;- Immediate integer operand constraints:
60 ;;- 'I'  1 .. 8
61 ;;- 'J'  -32768 .. 32767
62 ;;- 'K'  all integers EXCEPT -128 .. 127
63 ;;- 'L'  -8 .. -1
64 ;;- 'M'  all integers EXCEPT -256 .. 255
65 ;;- 'N'  24 .. 31
66 ;;- 'O'  16
67 ;;- 'P'  8 .. 15
69 ;;- Assembler specs:
70 ;;- "%."    size separator ("." or "")                  move%.l d0,d1
71 ;;- "%-"    push operand "sp@-"                         move%.l d0,%-
72 ;;- "%+"    pop operand "sp@+"                          move%.l d0,%+
73 ;;- "%@"    top of stack "sp@"                          move%.l d0,%@
74 ;;- "%!"    fpcr register
75 ;;- "%$"    single-precision fp specifier ("s" or "")   f%$add.x fp0,fp1
76 ;;- "%&"    double-precision fp specifier ("d" or "")   f%&add.x fp0,fp1
78 ;;- Information about 68040 port.
80 ;;- The 68040 executes all 68030 and 68881/2 instructions, but some must
81 ;;- be emulated in software by the OS.  It is faster to avoid these
82 ;;- instructions and issue a library call rather than trapping into
83 ;;- the kernel.  The affected instructions are fintrz and fscale.  The
84 ;;- TUNE_68040 flag turns the use of the opcodes off.
86 ;;- The '040 also implements a set of new floating-point instructions
87 ;;- which specify the rounding precision in the opcode.  This finally
88 ;;- permit the 68k series to be truly IEEE compliant, and solves all
89 ;;- issues of excess precision accumulating in the extended registers.
90 ;;- By default, GCC does not use these instructions, since such code will
91 ;;- not run on an '030.  To use these instructions, use the -m68040-only
92 ;;- switch.
94 ;;- These new instructions aren't directly in the md.  They are brought
95 ;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather
96 ;;- than "".
98 ;;- Information about 68060 port.
100 ;;- The 68060 executes all 68030 and 68881/2 instructions, but some must
101 ;;- be emulated in software by the OS.  It is faster to avoid these
102 ;;- instructions and issue a library call rather than trapping into
103 ;;- the kernel.  The affected instructions are: divs.l <ea>,Dr:Dq;
104 ;;- divu.l <ea>,Dr:Dq; muls.l <ea>,Dr:Dq; mulu.l <ea>,Dr:Dq; and
105 ;;- fscale.  The TUNE_68060 flag turns the use of the opcodes off.
107 ;;- Some of these insn's are composites of several m68000 op codes.
108 ;;- The assembler (or final @@??) insures that the appropriate one is
109 ;;- selected.
111 ;; UNSPEC usage:
113 (define_constants
114   [(UNSPEC_SIN 1)
115    (UNSPEC_COS 2)
116    (UNSPEC_GOT 3)
117    (UNSPEC_IB 4)
118    (UNSPEC_TIE 5)
119   ])
121 ;; UNSPEC_VOLATILE usage:
123 (define_constants
124   [(UNSPECV_BLOCKAGE    0)
125   ])
127 ;; Registers by name.
128 (define_constants
129   [(D0_REG              0)
130    (A0_REG              8)
131    (A1_REG              9)
132    (PIC_REG             13)
133    (A6_REG              14)
134    (SP_REG              15)
135    (FP0_REG             16)
136   ])
138 (include "predicates.md")
139 (include "constraints.md")
141 ;; ::::::::::::::::::::
142 ;; ::
143 ;; :: Attributes
144 ;; ::
145 ;; ::::::::::::::::::::
147 ;; Processor type.
148 (define_attr "cpu" "cfv1, cfv2, cfv3, cfv4, unknown"
149   (const (symbol_ref "m68k_sched_cpu")))
151 ;; MAC type.
152 (define_attr "mac" "no, cf_mac, cf_emac"
153   (const (symbol_ref "m68k_sched_mac")))
155 ;; Instruction type for use in scheduling description.
156 ;; _l and _w suffixes indicate size of the operands of instruction.
157 ;; alu - usual arithmetic or logic instruction.
158 ;; aluq - arithmetic or logic instruction which has a quick immediate (the one
159 ;;        that is encoded in the instruction word) for its Y operand.
160 ;; alux - Arithmetic instruction that uses carry bit (e.g., addx and subx).
161 ;; bcc - conditional branch.
162 ;; bitr - bit operation that only updates flags.
163 ;; bitrw - bit operation that updates flags and output operand.
164 ;; bra, bsr, clr, cmp, div, ext - corresponding instruction.
165 ;; falu, fbcc, fcmp, fdiv, fmove, fmul, fneg, fsqrt, ftst - corresponding
166 ;;                                                          instruction.
167 ;; ib - fake instruction to subscribe slots in ColdFire V1,V2,V3 instruction
168 ;;      buffer.
169 ;; ignore - fake instruction.
170 ;; jmp, jsr, lea, link, mov3q, move, moveq, mul - corresponding instruction.
171 ;; mvsz - mvs or mvz instruction.
172 ;; neg, nop, pea, rts, scc - corresponding instruction.
173 ;; shift - arithmetic or logical shift instruction.
174 ;; trap, tst, unlk - corresponding instruction.
175 (define_attr "type"
176   "alu_l,aluq_l,alux_l,bcc,bitr,bitrw,bra,bsr,clr,clr_l,cmp,cmp_l,
177    div_w,div_l,ext,
178    falu,fbcc,fcmp,fdiv,fmove,fmul,fneg,fsqrt,ftst,
179    ib,ignore,
180    jmp,jsr,lea,link,mov3q_l,move,move_l,moveq_l,mul_w,mul_l,mvsz,neg_l,nop,
181    pea,rts,scc,shift,
182    trap,tst,tst_l,unlk,
183    unknown"
184   (const_string "unknown"))
186 ;; Index of the X or Y operand in recog_data.operand[].
187 ;; Should be used only within opx_type and opy_type.
188 (define_attr "opx" "" (const_int 0))
189 (define_attr "opy" "" (const_int 1))
191 ;; Type of the Y operand.
192 ;; See m68k.c: enum attr_op_type.
193 (define_attr "opy_type"
194   "none,Rn,FPn,mem1,mem234,mem5,mem6,mem7,imm_q,imm_w,imm_l"
195   (cond [(eq_attr "type" "ext,fbcc,ftst,neg_l,bcc,bra,bsr,clr,clr_l,ib,ignore,
196                           jmp,jsr,nop,rts,scc,trap,tst,tst_l,
197                           unlk,unknown") (const_string "none")
198          (eq_attr "type" "lea,pea")
199          (symbol_ref "m68k_sched_attr_opy_type (insn, 1)")]
200         (symbol_ref "m68k_sched_attr_opy_type (insn, 0)")))
202 ;; Type of the X operand.
203 ;; See m68k.c: enum attr_op_type.
204 (define_attr "opx_type"
205   "none,Rn,FPn,mem1,mem234,mem5,mem6,mem7,imm_q,imm_w,imm_l"
206   (cond [(eq_attr "type" "ib,ignore,nop,rts,trap,unlk,
207                           unknown") (const_string "none")
208          (eq_attr "type" "pea") (const_string "mem1")
209          (eq_attr "type" "jmp,jsr")
210          (symbol_ref "m68k_sched_attr_opx_type (insn, 1)")]
211         (symbol_ref "m68k_sched_attr_opx_type (insn, 0)")))
213 ;; Access to the X operand: none, read, write, read/write, unknown.
214 ;; Access to the Y operand is either none (if opy_type is none)
215 ;; or read otherwise.
216 (define_attr "opx_access" "none, r, w, rw"
217   (cond [(eq_attr "type" "ib,ignore,nop,rts,trap,unlk,
218                           unknown") (const_string "none")
219          (eq_attr "type" "bcc,bra,bsr,bitr,cmp,cmp_l,fbcc,fcmp,ftst,
220                           jmp,jsr,tst,tst_l") (const_string "r")
221          (eq_attr "type" "clr,clr_l,fneg,fmove,lea,
222                           mov3q_l,move,move_l,moveq_l,mvsz,
223                           pea,scc") (const_string "w")
224          (eq_attr "type" "alu_l,aluq_l,alux_l,bitrw,div_w,div_l,ext,
225                           falu,fdiv,fmul,fsqrt,link,mul_w,mul_l,
226                           neg_l,shift") (const_string "rw")]
227         ;; Should never be used.
228         (symbol_ref "(gcc_unreachable (), OPX_ACCESS_NONE)")))
230 ;; Memory accesses of the insn.
231 ;; 00 - no memory references
232 ;; 10 - memory is read
233 ;; i0 - indexed memory is read
234 ;; 01 - memory is written
235 ;; 0i - indexed memory is written
236 ;; 11 - memory is read, memory is written
237 ;; i1 - indexed memory is read, memory is written
238 ;; 1i - memory is read, indexed memory is written
239 (define_attr "op_mem" "00, 10, i0, 01, 0i, 11, i1, 1i"
240   (symbol_ref "m68k_sched_attr_op_mem (insn)"))
242 ;; Instruction size in words.
243 (define_attr "size" "1,2,3"
244   (symbol_ref "m68k_sched_attr_size (insn)"))
247 ;; Mode macros for floating point operations.
248 ;; Valid floating point modes
249 (define_mode_iterator FP [SF DF (XF "TARGET_68881")])
250 ;; Mnemonic infix to round result
251 (define_mode_attr round [(SF "%$") (DF "%&") (XF "")])
252 ;; Mnemonic infix to round result for mul or div instruction
253 (define_mode_attr round_mul [(SF "sgl") (DF "%&") (XF "")])
254 ;; Suffix specifying source operand format
255 (define_mode_attr prec [(SF "s") (DF "d") (XF "x")])
256 ;; Allowable D registers
257 (define_mode_attr dreg [(SF "d") (DF "") (XF "")])
258 ;; Allowable 68881 constant constraints
259 (define_mode_attr const [(SF "F") (DF "G") (XF "")])
262 (define_insn_and_split "*movdf_internal"
263   [(set (match_operand:DF 0 "push_operand"   "=m, m")
264         (match_operand:DF 1 "general_operand" "f, ro<>E"))]
265   ""
266   "@
267    fmove%.d %f1,%0
268    #"
269   "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 1)"
270   [(const_int 0)]
272   m68k_emit_move_double (operands);
273   DONE;
275   [(set_attr "type" "fmove,*")])
277 (define_insn_and_split "pushdi"
278   [(set (match_operand:DI 0 "push_operand" "=m")
279         (match_operand:DI 1 "general_operand" "ro<>Fi"))]
280   ""
281   "#"
282   "&& reload_completed"
283   [(const_int 0)]
285   m68k_emit_move_double (operands);
286   DONE;
289 ;; We don't want to allow a constant operand for test insns because
290 ;; (set (cc0) (const_int foo)) has no mode information.  Such insns will
291 ;; be folded while optimizing anyway.
293 (define_expand "tstdi"
294   [(parallel [(set (cc0)
295                    (match_operand:DI 0 "nonimmediate_operand" ""))
296               (clobber (match_scratch:SI 1 ""))
297               (clobber (match_scratch:DI 2 ""))])]
298   ""
299   "m68k_last_compare_had_fp_operands = 0;")
301 (define_insn ""
302   [(set (cc0)
303         (match_operand:DI 0 "nonimmediate_operand" "am,d"))
304    (clobber (match_scratch:SI 1 "=X,d"))
305    (clobber (match_scratch:DI 2 "=d,X"))]
306   ""
308   if (which_alternative == 0)
309     {
310       rtx xoperands[2];
312       xoperands[0] = operands[2];
313       xoperands[1] = operands[0];
314       output_move_double (xoperands);
315       cc_status.flags |= CC_REVERSED; /*|*/
316       return "neg%.l %R2\;negx%.l %2";
317     }
318   if (find_reg_note (insn, REG_DEAD, operands[0]))
319     {
320       cc_status.flags |= CC_REVERSED; /*|*/
321       return "neg%.l %R0\;negx%.l %0";
322     }
323   else
324     /*
325        'sub' clears %1, and also clears the X cc bit
326        'tst' sets the Z cc bit according to the low part of the DImode operand
327        'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part.
328     */
329     return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
332 (define_expand "tstsi"
333   [(set (cc0)
334         (match_operand:SI 0 "nonimmediate_operand" ""))]
335   ""
336   "m68k_last_compare_had_fp_operands = 0;")
338 ;; If you think that the 68020 does not support tstl a0,
339 ;; reread page B-167 of the 68020 manual more carefully.
340 (define_insn "*tstsi_internal_68020_cf"
341   [(set (cc0)
342         (match_operand:SI 0 "nonimmediate_operand" "rm"))]
343   "TARGET_68020 || TARGET_COLDFIRE"
344   "tst%.l %0"
345   [(set_attr "type" "tst_l")])
347 ;; On an address reg, cmpw may replace cmpl.
348 (define_insn "*tstsi_internal"
349   [(set (cc0)
350         (match_operand:SI 0 "nonimmediate_operand" "dm,r"))]
351   "!(TARGET_68020 || TARGET_COLDFIRE)"
352   "@
353    tst%.l %0
354    cmp%.w #0,%0"
355   [(set_attr "type" "tst_l,cmp")])
357 ;; This can't use an address register, because comparisons
358 ;; with address registers as second operand always test the whole word.
359 (define_expand "tsthi"
360   [(set (cc0)
361         (match_operand:HI 0 "nonimmediate_operand" ""))]
362   ""
363   "m68k_last_compare_had_fp_operands = 0;")
365 (define_insn "*tsthi_internal"
366   [(set (cc0)
367         (match_operand:HI 0 "nonimmediate_operand" "dm"))]
368   ""
369   "tst%.w %0"
370   [(set_attr "type" "tst")])
372 (define_expand "tstqi"
373   [(set (cc0)
374         (match_operand:QI 0 "nonimmediate_operand" ""))]
375   ""
376   "m68k_last_compare_had_fp_operands = 0;")
378 (define_insn "*tstqi_internal"
379   [(set (cc0)
380         (match_operand:QI 0 "nonimmediate_operand" "dm"))]
381   ""
382   "tst%.b %0"
383   [(set_attr "type" "tst")])
385 (define_expand "tst<mode>"
386   [(set (cc0)
387         (match_operand:FP 0 "general_operand" ""))]
388   "TARGET_HARD_FLOAT"
390   m68k_last_compare_had_fp_operands = 1;
393 (define_insn "tst<mode>_68881"
394   [(set (cc0)
395         (match_operand:FP 0 "general_operand" "f<FP:dreg>m"))]
396   "TARGET_68881"
398   cc_status.flags = CC_IN_68881;
399   if (FP_REG_P (operands[0]))
400     return "ftst%.x %0";
401   return "ftst%.<FP:prec> %0";
403   [(set_attr "type" "ftst")])
405 (define_insn "tst<mode>_cf"
406   [(set (cc0)
407         (match_operand:FP 0 "general_operand" "f<FP:dreg><Q>U"))]
408   "TARGET_COLDFIRE_FPU"
410   cc_status.flags = CC_IN_68881;
411   if (FP_REG_P (operands[0]))
412     return "ftst%.d %0";
413   return "ftst%.<FP:prec> %0";
415   [(set_attr "type" "ftst")])
418 ;; compare instructions.
420 (define_expand "cmpdi"
421   [(parallel
422     [(set (cc0)
423           (compare (match_operand:DI 0 "nonimmediate_operand" "")
424                    (match_operand:DI 1 "general_operand" "")))
425      (clobber (match_dup 2))])]
426   ""
427   "m68k_last_compare_had_fp_operands = 0; operands[2] = gen_reg_rtx (DImode);")
429 (define_insn ""
430   [(set (cc0)
431         (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
432                  (match_operand:DI 2 "general_operand" "d,0")))
433    (clobber (match_operand:DI 0 "register_operand" "=d,d"))]
434   ""
436   if (rtx_equal_p (operands[0], operands[1]))
437     return "sub%.l %R2,%R0\;subx%.l %2,%0";
438   else
439     {
440       cc_status.flags |= CC_REVERSED; /*|*/
441       return "sub%.l %R1,%R0\;subx%.l %1,%0";
442     }
445 (define_expand "cmpsi"
446   [(set (cc0)
447         (compare (match_operand:SI 0 "nonimmediate_operand" "")
448                  (match_operand:SI 1 "general_operand" "")))]
449   ""
451   m68k_last_compare_had_fp_operands = 0;
454 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
455 (define_insn ""
456   [(set (cc0)
457         (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
458                  (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
459   "!TARGET_COLDFIRE"
461   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
462     return "cmpm%.l %1,%0";
463   if (REG_P (operands[1])
464       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
465     {
466       cc_status.flags |= CC_REVERSED; /*|*/
467       return "cmp%.l %d0,%d1";
468     }
469   if (ADDRESS_REG_P (operands[0])
470       && GET_CODE (operands[1]) == CONST_INT
471       && INTVAL (operands[1]) < 0x8000
472       && INTVAL (operands[1]) >= -0x8000)
473     return "cmp%.w %1,%0";
474   return "cmp%.l %d1,%d0";
477 (define_insn "*cmpsi_cf"
478   [(set (cc0)
479         (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
480                  (match_operand:SI 1 "general_operand" "r,mrKs")))]
481   "TARGET_COLDFIRE"
483   if (REG_P (operands[1])
484       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
485     {
486       cc_status.flags |= CC_REVERSED; /*|*/
487       return "cmp%.l %d0,%d1";
488     }
489   return "cmp%.l %d1,%d0";
491   [(set_attr "type" "cmp_l")])
493 (define_expand "cmphi"
494   [(set (cc0)
495         (compare (match_operand:HI 0 "nonimmediate_src_operand" "")
496                  (match_operand:HI 1 "general_src_operand" "")))]
497   "!TARGET_COLDFIRE"
498   "m68k_last_compare_had_fp_operands = 0;")
500 (define_insn ""
501   [(set (cc0)
502         (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
503                  (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
504   "!TARGET_COLDFIRE"
506   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
507     return "cmpm%.w %1,%0";
508   if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
509       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
510     {
511       cc_status.flags |= CC_REVERSED; /*|*/
512       return "cmp%.w %d0,%d1";
513     }
514   return "cmp%.w %d1,%d0";
517 (define_expand "cmpqi"
518   [(set (cc0)
519         (compare (match_operand:QI 0 "nonimmediate_src_operand" "")
520                  (match_operand:QI 1 "general_src_operand" "")))]
521   "!TARGET_COLDFIRE"
522   "m68k_last_compare_had_fp_operands = 0;")
524 (define_insn ""
525   [(set (cc0)
526         (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
527                  (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
528   "!TARGET_COLDFIRE"
530   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
531     return "cmpm%.b %1,%0";
532   if (REG_P (operands[1])
533       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
534     {
535       cc_status.flags |= CC_REVERSED; /*|*/
536       return "cmp%.b %d0,%d1";
537     }
538   return "cmp%.b %d1,%d0";
541 (define_expand "cmp<mode>"
542   [(set (cc0)
543         (compare (match_operand:FP 0 "register_operand" "")
544                  (match_operand:FP 1 "fp_src_operand" "")))]
545   "TARGET_HARD_FLOAT"
546   "m68k_last_compare_had_fp_operands = 1;")
548 (define_insn "*cmp<mode>_68881"
549   [(set (cc0)
550         (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg>mF")
551                  (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg>mF,f")))]
552   "TARGET_68881
553    && (register_operand (operands[0], <MODE>mode)
554        || register_operand (operands[1], <MODE>mode))"
555   "@
556    fcmp%.x %1,%0
557    fcmp%.<FP:prec> %f1,%0
558    fcmp%.<FP:prec> %0,%f1"
559   [(set_attr "type" "fcmp")])
561 (define_insn "*cmp<mode>_cf"
562   [(set (cc0)
563         (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg><Q>U")
564                  (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg><Q>U,f")))]
565   "TARGET_COLDFIRE_FPU
566    && (register_operand (operands[0], <MODE>mode)
567        || register_operand (operands[1], <MODE>mode))"
568   "@
569    fcmp%.d %1,%0
570    fcmp%.<FP:prec> %f1,%0
571    fcmp%.<FP:prec> %0,%f1"
572   [(set_attr "type" "fcmp")])
574 ;; Recognizers for btst instructions.
576 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
577 ;; specified as a constant, so we must disable all patterns that may extract
578 ;; from a MEM at a constant bit position if we can't use this as a constraint.
580 (define_insn ""
581   [(set (cc0) (zero_extract (match_operand:QI 0 "memory_src_operand" "oS")
582                             (const_int 1)
583                             (minus:SI (const_int 7)
584                                       (match_operand:SI 1 "general_operand" "di"))))]
585   "!TARGET_COLDFIRE"
587   return output_btst (operands, operands[1], operands[0], insn, 7);
590 ;; This is the same as the above pattern except for the constraints.  The 'i'
591 ;; has been deleted.
593 (define_insn ""
594   [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
595                             (const_int 1)
596                             (minus:SI (const_int 7)
597                                       (match_operand:SI 1 "general_operand" "d"))))]
598   "TARGET_COLDFIRE"
600   return output_btst (operands, operands[1], operands[0], insn, 7);
603 (define_insn ""
604   [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
605                             (const_int 1)
606                             (minus:SI (const_int 31)
607                                       (match_operand:SI 1 "general_operand" "di"))))]
608   ""
610   return output_btst (operands, operands[1], operands[0], insn, 31);
613 ;; The following two patterns are like the previous two
614 ;; except that they use the fact that bit-number operands
615 ;; are automatically masked to 3 or 5 bits.
617 (define_insn ""
618   [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "o")
619                             (const_int 1)
620                             (minus:SI (const_int 7)
621                                       (and:SI
622                                        (match_operand:SI 1 "register_operand" "d")
623                                        (const_int 7)))))]
624   ""
626   return output_btst (operands, operands[1], operands[0], insn, 7);
629 (define_insn ""
630   [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "d")
631                             (const_int 1)
632                             (minus:SI (const_int 31)
633                                       (and:SI
634                                        (match_operand:SI 1 "register_operand" "d")
635                                        (const_int 31)))))]
636   ""
638   return output_btst (operands, operands[1], operands[0], insn, 31);
641 ;; Nonoffsettable mem refs are ok in this one pattern
642 ;; since we don't try to adjust them.
643 (define_insn ""
644   [(set (cc0) (zero_extract (match_operand:QI 0 "memory_operand" "m")
645                             (const_int 1)
646                             (match_operand:SI 1 "const_int_operand" "n")))]
647   "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
649   operands[1] = GEN_INT (7 - INTVAL (operands[1]));
650   return output_btst (operands, operands[1], operands[0], insn, 7);
653 (define_insn ""
654   [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "do")
655                             (const_int 1)
656                             (match_operand:SI 1 "const_int_operand" "n")))]
657   "!TARGET_COLDFIRE"
659   if (GET_CODE (operands[0]) == MEM)
660     {
661       operands[0] = adjust_address (operands[0], QImode,
662                                     INTVAL (operands[1]) / 8);
663       operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
664       return output_btst (operands, operands[1], operands[0], insn, 7);
665     }
666   operands[1] = GEN_INT (31 - INTVAL (operands[1]));
667   return output_btst (operands, operands[1], operands[0], insn, 31);
670 ;; This is the same as the above pattern except for the constraints.
671 ;; The 'o' has been replaced with 'Q'.
673 (define_insn ""
674   [(set (cc0) (zero_extract (match_operand:SI 0 "register_operand" "dQ")
675                             (const_int 1)
676                             (match_operand:SI 1 "const_int_operand" "n")))]
677   "TARGET_COLDFIRE"
679   if (GET_CODE (operands[0]) == MEM)
680     {
681       operands[0] = adjust_address (operands[0], QImode,
682                                     INTVAL (operands[1]) / 8);
683       operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
684       return output_btst (operands, operands[1], operands[0], insn, 7);
685     }
686   operands[1] = GEN_INT (31 - INTVAL (operands[1]));
687   return output_btst (operands, operands[1], operands[0], insn, 31);
691 ;; move instructions
693 ;; A special case in which it is not desirable
694 ;; to reload the constant into a data register.
695 (define_insn "pushexthisi_const"
696   [(set (match_operand:SI 0 "push_operand" "=m,m,m")
697         (match_operand:SI 1 "const_int_operand" "C0,R,J"))]
698   "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
699   "@
700    clr%.l %0
701    mov3q%.l %1,%-
702    pea %a1"
703   [(set_attr "type" "clr_l,mov3q_l,pea")])
705 ;This is never used.
706 ;(define_insn "swapsi"
707 ;  [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
708 ;       (match_operand:SI 1 "general_operand" "+r"))
709 ;   (set (match_dup 1) (match_dup 0))]
710 ;  ""
711 ;  "exg %1,%0")
713 ;; Special case of fullword move when source is zero for 68000_10.
714 ;; moveq is faster on the 68000.
715 (define_insn "*movsi_const0_68000_10"
716   [(set (match_operand:SI 0 "movsi_const0_operand" "=d,a,g")
717         (const_int 0))]
718   "TUNE_68000_10"
719   "@
720    moveq #0,%0
721    sub%.l %0,%0
722    clr%.l %0"
723   [(set_attr "type" "moveq_l,alu_l,clr_l")
724    (set_attr "opy" "*,0,*")])
726 ;; Special case of fullword move when source is zero for 68040_60.
727 ;; On the '040, 'subl an,an' takes 2 clocks while lea takes only 1
728 (define_insn "*movsi_const0_68040_60"
729   [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
730         (const_int 0))]
731   "TUNE_68040_60"
733   if (which_alternative == 0)
734     return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
735   else if (which_alternative == 1)
736     return "clr%.l %0";
737   else
738     {
739       gcc_unreachable ();
740       return "";
741     }
743   [(set_attr "type" "lea,clr_l")])
745 ;; Special case of fullword move when source is zero.
746 (define_insn "*movsi_const0"
747   [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
748         (const_int 0))]
749   "!(TUNE_68000_10 || TUNE_68040_60)"
750   "@
751    sub%.l %0,%0
752    clr%.l %0"
753   [(set_attr "type" "alu_l,clr_l")
754    (set_attr "opy" "0,*")])
756 ;; General case of fullword move.
758 ;; This is the main "hook" for PIC code.  When generating
759 ;; PIC, movsi is responsible for determining when the source address
760 ;; needs PIC relocation and appropriately calling legitimize_pic_address
761 ;; to perform the actual relocation.
763 ;; In both the PIC and non-PIC cases the patterns generated will
764 ;; matched by the next define_insn.
765 (define_expand "movsi"
766   [(set (match_operand:SI 0 "" "")
767         (match_operand:SI 1 "" ""))]
768   ""
770   rtx tmp, base, offset;
772   if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
773     {
774       /* The source is an address which requires PIC relocation.
775          Call legitimize_pic_address with the source, mode, and a relocation
776          register (a new pseudo, or the final destination if reload_in_progress
777          is set).   Then fall through normally */
778       rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
779       operands[1] = legitimize_pic_address (operands[1], SImode, temp);
780     }
781   else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
782     {
783       /* Don't allow writes to memory except via a register;
784          the m68k doesn't consider PC-relative addresses to be writable.  */
785       if (symbolic_operand (operands[0], SImode))
786         operands[0] = force_reg (SImode, XEXP (operands[0], 0));
787       else if (GET_CODE (operands[0]) == MEM
788                && symbolic_operand (XEXP (operands[0], 0), SImode))
789         operands[0] = gen_rtx_MEM (SImode,
790                                force_reg (SImode, XEXP (operands[0], 0)));
791     }
792   if (M68K_OFFSETS_MUST_BE_WITHIN_SECTIONS_P)
793     {
794       split_const (operands[1], &base, &offset);
795       if (GET_CODE (base) == SYMBOL_REF
796           && !offset_within_block_p (base, INTVAL (offset)))
797         {
798           tmp = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (SImode);
799           emit_move_insn (tmp, base);
800           emit_insn (gen_addsi3 (operands[0], tmp, offset));
801           DONE;
802         }
803     }
806 ;; General case of fullword move.
807 (define_insn "*movsi_m68k"
808   ;; Notes: make sure no alternative allows g vs g.
809   ;; We don't allow f-regs since fixed point cannot go in them.
810   [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
811         (match_operand:SI 1 "general_src_operand" "damSnT,n,i"))]
812   "!TARGET_COLDFIRE && reload_completed"
814   return output_move_simode (operands);
817 ;; Before reload is completed the register constraints
818 ;; force integer constants in range for a moveq to be reloaded
819 ;; if they are headed for memory.
820 (define_insn "*movsi_m68k2"
821   [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
822         (match_operand:SI 1 "general_src_operand" "damSKT,n,i"))]
824   "!TARGET_COLDFIRE"
826   return output_move_simode (operands);
829 ;; ColdFire move instructions can have at most one operand of mode >= 6.
830 (define_insn "*movsi_cf"
831   [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d, d, d, d, d, a,Ap,  a,  r<Q>,g,    U")
832         (match_operand:SI 1 "general_operand"      " R,CQ,CW,CZ,CS,Ci,J,J Cs,Cs, g,   Rr<Q>,U"))]
833   "TARGET_COLDFIRE"
835   switch (which_alternative)
836     {
837     case 0:
838       return "mov3q%.l %1,%0";
840     case 1:
841       return "moveq %1,%0";
843     case 2:
844       {
845         unsigned u = INTVAL (operands[1]);
847         operands[1] = GEN_INT ((u << 16) | (u >> 16));  /*|*/
848         return "moveq %1,%0\n\tswap %0";
849       }
851     case 3:
852       return "mvz%.w %1,%0";
854     case 4:
855       return "mvs%.w %1,%0";
857     case 5:
858       return "move%.l %1,%0";
860     case 6:
861       return "move%.w %1,%0";
863     case 7:
864       return "pea %a1";
866     case 8:
867       return "lea %a1,%0";
869     case 9:
870     case 10:
871     case 11:
872       return "move%.l %1,%0";
874     default:
875       gcc_unreachable ();
876       return "";
877     }
879   [(set_attr "type" "mov3q_l,moveq_l,*,mvsz,mvsz,move_l,move,pea,lea,move_l,move_l,move_l")])
881 ;; Special case of fullword move, where we need to get a non-GOT PIC
882 ;; reference into an address register.
883 (define_insn ""
884   [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
885         (match_operand:SI 1 "pcrel_address" ""))]
886   "TARGET_PCREL"
888   if (push_operand (operands[0], SImode))
889     return "pea %a1";
890   return "lea %a1,%0";
893 (define_expand "movhi"
894   [(set (match_operand:HI 0 "nonimmediate_operand" "")
895         (match_operand:HI 1 "general_operand" ""))]
896   ""
897   "")
899 (define_insn ""
900   [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
901         (match_operand:HI 1 "general_src_operand" "gS"))]
902   "!TARGET_COLDFIRE"
903   "* return output_move_himode (operands);")
905 (define_insn ""
906   [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
907         (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
908   "TARGET_COLDFIRE"
909   "* return output_move_himode (operands);")
911 (define_expand "movstricthi"
912   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
913         (match_operand:HI 1 "general_src_operand" ""))]
914   ""
915   "")
917 (define_insn ""
918   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
919         (match_operand:HI 1 "general_src_operand" "rmSn"))]
920   "!TARGET_COLDFIRE"
921   "* return output_move_stricthi (operands);")
923 (define_insn ""
924   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
925         (match_operand:HI 1 "general_src_operand" "rmn,r"))]
926   "TARGET_COLDFIRE"
927   "* return output_move_stricthi (operands);")
929 (define_expand "movqi"
930   [(set (match_operand:QI 0 "nonimmediate_operand" "")
931         (match_operand:QI 1 "general_src_operand" ""))]
932   ""
933   "")
935 (define_insn ""
936   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
937         (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
938   "!TARGET_COLDFIRE"
939   "* return output_move_qimode (operands);")
941 (define_insn ""
942   [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
943         (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
944   "TARGET_COLDFIRE"
945   "* return output_move_qimode (operands);")
947 (define_expand "movstrictqi"
948   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
949         (match_operand:QI 1 "general_src_operand" ""))]
950   ""
951   "")
953 (define_insn ""
954   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
955         (match_operand:QI 1 "general_src_operand" "dmSn"))]
956   "!TARGET_COLDFIRE"
957   "* return output_move_strictqi (operands);")
959 (define_insn "*movstrictqi_cf"
960   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d, Ac, d,m"))
961         (match_operand:QI 1 "general_src_operand"                    "C0,C0, dmn,d"))]
962   "TARGET_COLDFIRE"
963   "@
964    clr%.b %0
965    clr%.b %0
966    move%.b %1,%0
967    move%.b %1,%0"
968   [(set_attr "type" "clr,clr,move,move")])
970 (define_expand "pushqi1"
971   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
972    (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
973         (match_operand:QI 0 "general_operand" ""))]
974   "!TARGET_COLDFIRE"
975   "")
977 (define_expand "reload_insf"
978   [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
979         (match_operand:SF 1 "general_operand" "mf"))
980    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
981   "TARGET_COLDFIRE_FPU"
983   if (emit_move_sequence (operands, SFmode, operands[2]))
984     DONE;
986   /* We don't want the clobber emitted, so handle this ourselves. */
987   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
988   DONE;
991 (define_expand "reload_outsf"
992   [(set (match_operand:SF 0 "general_operand" "")
993         (match_operand:SF 1 "register_operand" "f"))
994    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
995   "TARGET_COLDFIRE_FPU"
997   if (emit_move_sequence (operands, SFmode, operands[2]))
998     DONE;
1000   /* We don't want the clobber emitted, so handle this ourselves. */
1001   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1002   DONE;
1005 (define_expand "movsf"
1006   [(set (match_operand:SF 0 "nonimmediate_operand" "")
1007         (match_operand:SF 1 "general_operand" ""))]
1008   ""
1009   "")
1011 (define_insn ""
1012   [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
1013         (match_operand:SF 1 "general_operand" "rmfF"))]
1014   "!TARGET_COLDFIRE"
1016   if (FP_REG_P (operands[0]))
1017     {
1018       if (FP_REG_P (operands[1]))
1019         return "f%$move%.x %1,%0";
1020       else if (ADDRESS_REG_P (operands[1]))
1021         return "move%.l %1,%-\;f%$move%.s %+,%0";
1022       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
1023         return output_move_const_single (operands);
1024       return "f%$move%.s %f1,%0";
1025     }
1026   if (FP_REG_P (operands[1]))
1027     {
1028       if (ADDRESS_REG_P (operands[0]))
1029         return "fmove%.s %1,%-\;move%.l %+,%0";
1030       return "fmove%.s %f1,%0";
1031     }
1032   if (operands[1] == CONST0_RTX (SFmode)
1033       /* clr insns on 68000 read before writing.  */
1034       && ((TARGET_68010 || TARGET_COLDFIRE)
1035           || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
1036     {
1037       if (ADDRESS_REG_P (operands[0]))
1038         {
1039           /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
1040           if (TUNE_68040_60)
1041             return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
1042           else
1043             return "sub%.l %0,%0";
1044         }
1045       /* moveq is faster on the 68000.  */
1046       if (DATA_REG_P (operands[0]) && TUNE_68000_10)
1047         return "moveq #0,%0";
1048       return "clr%.l %0";
1049     }
1050   return "move%.l %1,%0";
1053 (define_insn "movsf_cf_soft"
1054   [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>,g,U")
1055         (match_operand:SF 1 "general_operand" "g,r<Q>,U"))]
1056   "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1057   "move%.l %1,%0"
1058   [(set_attr "type" "move_l")])
1060 ;; SFmode MEMs are restricted to modes 2-4 if TARGET_COLDFIRE_FPU.
1061 ;; The move instructions can handle all combinations.
1062 (define_insn "movsf_cf_hard"
1063   [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f,    f,mr,f,r<Q>,f
1064 ,m")
1065         (match_operand:SF 1 "general_operand"      " f,     r<Q>U,f,rm,F,F,   m
1066 ,f"))]
1067   "TARGET_COLDFIRE_FPU"
1069   if (which_alternative == 4 || which_alternative == 5) {
1070     rtx xoperands[2];
1071     REAL_VALUE_TYPE r;
1072     long l;
1073     REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1074     REAL_VALUE_TO_TARGET_SINGLE (r, l);
1075     xoperands[0] = operands[0];
1076     xoperands[1] = GEN_INT (l);
1077     if (which_alternative == 5) {
1078       if (l == 0) {
1079         if (ADDRESS_REG_P (xoperands[0]))
1080           output_asm_insn ("sub%.l %0,%0", xoperands);
1081         else
1082           output_asm_insn ("clr%.l %0", xoperands);
1083       } else
1084         if (GET_CODE (operands[0]) == MEM
1085             && symbolic_operand (XEXP (operands[0], 0), SImode))
1086           output_asm_insn ("move%.l %1,%-;move%.l %+,%0", xoperands);
1087         else
1088           output_asm_insn ("move%.l %1,%0", xoperands);
1089       return "";
1090     }
1091     if (l != 0)
1092       output_asm_insn ("move%.l %1,%-;fsmove%.s %+,%0", xoperands);
1093     else
1094       output_asm_insn ("clr%.l %-;fsmove%.s %+,%0", xoperands);
1095     return "";
1096   }
1097   if (FP_REG_P (operands[0]))
1098     {
1099       if (ADDRESS_REG_P (operands[1]))
1100         return "move%.l %1,%-;fsmove%.s %+,%0";
1101       if (FP_REG_P (operands[1]))
1102         return "fsmove%.d %1,%0";
1103       return "fsmove%.s %f1,%0";
1104     }
1105   if (FP_REG_P (operands[1]))
1106     {
1107       if (ADDRESS_REG_P (operands[0]))
1108         return "fmove%.s %1,%-;move%.l %+,%0";
1109       return "fmove%.s %f1,%0";
1110     }
1111   if (operands[1] == CONST0_RTX (SFmode))
1112     {
1113       if (ADDRESS_REG_P (operands[0]))
1114         return "sub%.l %0,%0";
1115       return "clr%.l %0";
1116     }
1117   return "move%.l %1,%0";
1120 (define_expand "reload_indf"
1121   [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1122         (match_operand:DF 1 "general_operand" "mf"))
1123    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1124   "TARGET_COLDFIRE_FPU"
1126   if (emit_move_sequence (operands, DFmode, operands[2]))
1127     DONE;
1129   /* We don't want the clobber emitted, so handle this ourselves. */
1130   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1131   DONE;
1134 (define_expand "reload_outdf"
1135   [(set (match_operand:DF 0 "general_operand" "")
1136         (match_operand:DF 1 "register_operand" "f"))
1137    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1138   "TARGET_COLDFIRE_FPU"
1140   if (emit_move_sequence (operands, DFmode, operands[2]))
1141     DONE;
1143   /* We don't want the clobber emitted, so handle this ourselves. */
1144   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1145   DONE;
1148 (define_expand "movdf"
1149   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1150         (match_operand:DF 1 "general_operand" ""))]
1151   ""
1153   if (TARGET_COLDFIRE_FPU)
1154     if (emit_move_sequence (operands, DFmode, 0))
1155       DONE;
1158 (define_insn ""
1159   [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
1160         (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
1161 ;  [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
1162 ;       (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
1163   "!TARGET_COLDFIRE"
1165   if (FP_REG_P (operands[0]))
1166     {
1167       if (FP_REG_P (operands[1]))
1168         return "f%&move%.x %1,%0";
1169       if (REG_P (operands[1]))
1170         {
1171           rtx xoperands[2];
1172           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1173           output_asm_insn ("move%.l %1,%-", xoperands);
1174           output_asm_insn ("move%.l %1,%-", operands);
1175           return "f%&move%.d %+,%0";
1176         }
1177       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1178         return output_move_const_double (operands);
1179       return "f%&move%.d %f1,%0";
1180     }
1181   else if (FP_REG_P (operands[1]))
1182     {
1183       if (REG_P (operands[0]))
1184         {
1185           output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1186           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1187           return "move%.l %+,%0";
1188         }
1189       else
1190         return "fmove%.d %f1,%0";
1191     }
1192   return output_move_double (operands);
1195 (define_insn_and_split "movdf_cf_soft"
1196   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
1197         (match_operand:DF 1 "general_operand" "g,r"))]
1198   "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1199   "#"
1200   "&& reload_completed"
1201   [(const_int 0)]
1203   m68k_emit_move_double (operands);
1204   DONE;
1207 (define_insn "movdf_cf_hard"
1208   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,    <Q>U,r,f,r,r,m,f")
1209         (match_operand:DF 1 "general_operand"      " f<Q>U,f,   f,r,r,m,r,E"))]
1210   "TARGET_COLDFIRE_FPU"
1212   rtx xoperands[3];
1213   REAL_VALUE_TYPE r;
1214   long l[2];
1216   switch (which_alternative)
1217     {
1218     default:
1219       return "fdmove%.d %1,%0";
1220     case 1:
1221       return "fmove%.d %1,%0";
1222     case 2:
1223       return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1224     case 3:
1225       return "move%.l %R1,%-;move%.l %1,%-;fdmove%.d %+,%0";
1226     case 4: case 5: case 6:
1227       return output_move_double (operands);
1228     case 7:
1229       REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1230       REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1231       xoperands[0] = operands[0];
1232       xoperands[1] = GEN_INT (l[0]);
1233       xoperands[2] = GEN_INT (l[1]);
1234       if (operands[1] == CONST0_RTX (DFmode))
1235         output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1236                         xoperands);
1237       else
1238         if (l[1] == 0)
1239           output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1240                           xoperands);
1241         else
1242           output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1243                           xoperands);
1244       return "";
1245     }
1248 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1249 ;; allowed.  Most but not all have predicates and constraint that disallow
1250 ;; constants.  Most but not all have output templates that handle constants.
1251 ;; See also LEGITIMATE_CONSTANT_P.
1253 (define_expand "movxf"
1254   [(set (match_operand:XF 0 "nonimmediate_operand" "")
1255         (match_operand:XF 1 "general_operand" ""))]
1256   ""
1258   /* We can't rewrite operands during reload.  */
1259   if (! reload_in_progress)
1260     {
1261       if (CONSTANT_P (operands[1]))
1262         {
1263           operands[1] = force_const_mem (XFmode, operands[1]);
1264           if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1265             operands[1] = adjust_address (operands[1], XFmode, 0);
1266         }
1267       if (flag_pic && TARGET_PCREL)
1268         {
1269           /* Don't allow writes to memory except via a register; the
1270              m68k doesn't consider PC-relative addresses to be writable.  */
1271           if (GET_CODE (operands[0]) == MEM
1272               && symbolic_operand (XEXP (operands[0], 0), SImode))
1273             operands[0] = gen_rtx_MEM (XFmode,
1274                                    force_reg (SImode, XEXP (operands[0], 0)));
1275         }
1276     }
1279 (define_insn ""
1280   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1281         (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1282   "TARGET_68881"
1284   if (FP_REG_P (operands[0]))
1285     {
1286       if (FP_REG_P (operands[1]))
1287         return "fmove%.x %1,%0";
1288       if (REG_P (operands[1]))
1289         {
1290           rtx xoperands[2];
1291           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1292           output_asm_insn ("move%.l %1,%-", xoperands);
1293           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1294           output_asm_insn ("move%.l %1,%-", xoperands);
1295           output_asm_insn ("move%.l %1,%-", operands);
1296           return "fmove%.x %+,%0";
1297         }
1298       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1299         return "fmove%.x %1,%0";
1300       return "fmove%.x %f1,%0";
1301     }
1302   if (FP_REG_P (operands[1]))
1303     {
1304       if (REG_P (operands[0]))
1305         {
1306           output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1307           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1308           output_asm_insn ("move%.l %+,%0", operands);
1309           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1310           return "move%.l %+,%0";
1311         }
1312       /* Must be memory destination.  */
1313       return "fmove%.x %f1,%0";
1314     }
1315   return output_move_double (operands);
1318 (define_insn ""
1319   [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1320         (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1321   "! TARGET_68881 && ! TARGET_COLDFIRE"
1323   if (FP_REG_P (operands[0]))
1324     {
1325       if (FP_REG_P (operands[1]))
1326         return "fmove%.x %1,%0";
1327       if (REG_P (operands[1]))
1328         {
1329           rtx xoperands[2];
1330           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1331           output_asm_insn ("move%.l %1,%-", xoperands);
1332           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1333           output_asm_insn ("move%.l %1,%-", xoperands);
1334           output_asm_insn ("move%.l %1,%-", operands);
1335           return "fmove%.x %+,%0";
1336         }
1337       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1338         return "fmove%.x %1,%0";
1339       return "fmove%.x %f1,%0";
1340     }
1341   if (FP_REG_P (operands[1]))
1342     {
1343       if (REG_P (operands[0]))
1344         {
1345           output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1346           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1347           output_asm_insn ("move%.l %+,%0", operands);
1348           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1349           return "move%.l %+,%0";
1350         }
1351       else
1352         return "fmove%.x %f1,%0";
1353     }
1354   return output_move_double (operands);
1357 (define_insn ""
1358   [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1359         (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1360   "! TARGET_68881 && TARGET_COLDFIRE"
1361   "* return output_move_double (operands);")
1363 (define_expand "movdi"
1364   ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1365   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1366         (match_operand:DI 1 "general_operand" ""))]
1367   ""
1368   "")
1370 ;; movdi can apply to fp regs in some cases
1371 (define_insn ""
1372   ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1373   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1374         (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1375 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1376 ;       (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1377 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1378 ;       (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1379   "!TARGET_COLDFIRE"
1381   if (FP_REG_P (operands[0]))
1382     {
1383       if (FP_REG_P (operands[1]))
1384         return "fmove%.x %1,%0";
1385       if (REG_P (operands[1]))
1386         {
1387           rtx xoperands[2];
1388           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1389           output_asm_insn ("move%.l %1,%-", xoperands);
1390           output_asm_insn ("move%.l %1,%-", operands);
1391           return "fmove%.d %+,%0";
1392         }
1393       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1394         return output_move_const_double (operands);
1395       return "fmove%.d %f1,%0";
1396     }
1397   else if (FP_REG_P (operands[1]))
1398     {
1399       if (REG_P (operands[0]))
1400         {
1401           output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1402           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1403           return "move%.l %+,%0";
1404         }
1405       else
1406         return "fmove%.d %f1,%0";
1407     }
1408   return output_move_double (operands);
1411 (define_insn ""
1412   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1413         (match_operand:DI 1 "general_operand" "g,r"))]
1414   "TARGET_COLDFIRE"
1415   "* return output_move_double (operands);")
1417 ;; Thus goes after the move instructions
1418 ;; because the move instructions are better (require no spilling)
1419 ;; when they can apply.  It goes before the add/sub insns
1420 ;; so we will prefer it to them.
1422 (define_insn "pushasi"
1423   [(set (match_operand:SI 0 "push_operand" "=m")
1424         (match_operand:SI 1 "address_operand" "p"))]
1425   ""
1426   "pea %a1"
1427   [(set_attr "type" "pea")])
1429 ;; truncation instructions
1430 (define_insn "truncsiqi2"
1431   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1432         (truncate:QI
1433          (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1434   ""
1436   if (GET_CODE (operands[0]) == REG)
1437     {
1438       /* Must clear condition codes, since the move.l bases them on
1439          the entire 32 bits, not just the desired 8 bits.  */
1440       CC_STATUS_INIT;
1441       return "move%.l %1,%0";
1442     }
1443   if (GET_CODE (operands[1]) == MEM)
1444     operands[1] = adjust_address (operands[1], QImode, 3);
1445   return "move%.b %1,%0";
1448 (define_insn "trunchiqi2"
1449   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1450         (truncate:QI
1451          (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1452   ""
1454   if (GET_CODE (operands[0]) == REG
1455       && (GET_CODE (operands[1]) == MEM
1456           || GET_CODE (operands[1]) == CONST_INT))
1457     {
1458       /* Must clear condition codes, since the move.w bases them on
1459          the entire 16 bits, not just the desired 8 bits.  */
1460       CC_STATUS_INIT;
1461       return "move%.w %1,%0";
1462     }
1463   if (GET_CODE (operands[0]) == REG)
1464     {
1465       /* Must clear condition codes, since the move.l bases them on
1466          the entire 32 bits, not just the desired 8 bits.  */
1467       CC_STATUS_INIT;
1468       return "move%.l %1,%0";
1469     }
1470   if (GET_CODE (operands[1]) == MEM)
1471     operands[1] = adjust_address (operands[1], QImode, 1);
1472   return "move%.b %1,%0";
1475 (define_insn "truncsihi2"
1476   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1477         (truncate:HI
1478          (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1479   ""
1481   if (GET_CODE (operands[0]) == REG)
1482     {
1483       /* Must clear condition codes, since the move.l bases them on
1484          the entire 32 bits, not just the desired 8 bits.  */
1485       CC_STATUS_INIT;
1486       return "move%.l %1,%0";
1487     }
1488   if (GET_CODE (operands[1]) == MEM)
1489     operands[1] = adjust_address (operands[1], QImode, 2);
1490   return "move%.w %1,%0";
1493 ;; zero extension instructions
1495 ;; two special patterns to match various post_inc/pre_dec patterns
1496 (define_insn_and_split "*zero_extend_inc"
1497   [(set (match_operand 0 "post_inc_operand" "")
1498         (zero_extend (match_operand 1 "register_operand" "")))]
1499   "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1500    GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1501    GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1502   "#"
1503   ""
1504   [(set (match_dup 0)
1505         (const_int 0))
1506    (set (match_dup 0)
1507         (match_dup 1))]
1509   operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1512 (define_insn_and_split "*zero_extend_dec"
1513   [(set (match_operand 0 "pre_dec_operand" "")
1514         (zero_extend (match_operand 1 "register_operand" "")))]
1515   "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1516    GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1517    GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1518    GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1519   "#"
1520   ""
1521   [(set (match_dup 0)
1522         (match_dup 1))
1523    (set (match_dup 0)
1524         (const_int 0))]
1526   operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1529 (define_insn_and_split "zero_extendqidi2"
1530   [(set (match_operand:DI 0 "register_operand" "")
1531         (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1532   ""
1533   "#"
1534   ""
1535   [(set (match_dup 2)
1536         (zero_extend:SI (match_dup 1)))
1537    (set (match_dup 3)
1538         (const_int 0))]
1540   operands[2] = gen_lowpart (SImode, operands[0]);
1541   operands[3] = gen_highpart (SImode, operands[0]);
1544 (define_insn_and_split "zero_extendhidi2"
1545   [(set (match_operand:DI 0 "register_operand" "")
1546         (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1547   ""
1548   "#"
1549   ""
1550   [(set (match_dup 2)
1551         (zero_extend:SI (match_dup 1)))
1552    (set (match_dup 3)
1553         (const_int 0))]
1555   operands[2] = gen_lowpart (SImode, operands[0]);
1556   operands[3] = gen_highpart (SImode, operands[0]);
1559 (define_expand "zero_extendsidi2"
1560   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1561         (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1562   ""
1564   if (GET_CODE (operands[0]) == MEM
1565       && GET_CODE (operands[1]) == MEM)
1566     operands[1] = force_reg (SImode, operands[1]);
1569 (define_insn_and_split "*zero_extendsidi2"
1570   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1571         (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1572   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1573   "#"
1574   ""
1575   [(set (match_dup 2)
1576         (match_dup 1))
1577    (set (match_dup 3)
1578         (const_int 0))]
1580   operands[2] = gen_lowpart (SImode, operands[0]);
1581   operands[3] = gen_highpart (SImode, operands[0]);
1584 (define_insn "*zero_extendhisi2_cf"
1585   [(set (match_operand:SI 0 "register_operand" "=d")
1586         (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1587   "ISA_HAS_MVS_MVZ"
1588   "mvz%.w %1,%0"
1589   [(set_attr "type" "mvsz")])
1591 (define_insn "zero_extendhisi2"
1592   [(set (match_operand:SI 0 "register_operand" "=d")
1593         (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1594   ""
1595   "#")
1597 (define_expand "zero_extendqihi2"
1598   [(set (match_operand:HI 0 "register_operand" "")
1599         (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1600   "!TARGET_COLDFIRE"
1601   "")
1603 (define_insn "*zero_extendqihi2"
1604   [(set (match_operand:HI 0 "register_operand" "=d")
1605         (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1606   "!TARGET_COLDFIRE"
1607   "#")
1609 (define_insn "*zero_extendqisi2_cfv4"
1610   [(set (match_operand:SI 0 "register_operand" "=d")
1611         (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1612   "ISA_HAS_MVS_MVZ"
1613   "mvz%.b %1,%0"
1614   [(set_attr "type" "mvsz")])
1616 (define_insn "zero_extendqisi2"
1617   [(set (match_operand:SI 0 "register_operand" "=d")
1618         (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1619   ""
1620   "#")
1622 ;; these two pattern split everything else which isn't matched by
1623 ;; something else above
1624 (define_split
1625   [(set (match_operand 0 "register_operand" "")
1626         (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1627   "!ISA_HAS_MVS_MVZ
1628    && reload_completed
1629    && reg_mentioned_p (operands[0], operands[1])"
1630   [(set (strict_low_part (match_dup 2))
1631         (match_dup 1))
1632    (set (match_dup 0)
1633         (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1635   operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1636   operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1637   operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1640 (define_split
1641   [(set (match_operand 0 "register_operand" "")
1642         (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1643   "!ISA_HAS_MVS_MVZ && reload_completed"
1644   [(set (match_dup 0)
1645         (const_int 0))
1646    (set (strict_low_part (match_dup 2))
1647         (match_dup 1))]
1649   operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1652 ;; sign extension instructions
1654 (define_insn "extendqidi2"
1655   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1656         (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1657   ""
1659   CC_STATUS_INIT;
1660   operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1661   if (ISA_HAS_MVS_MVZ)
1662     return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1663   if (TARGET_68020 || TARGET_COLDFIRE)
1664     {
1665       if (ADDRESS_REG_P (operands[1]))
1666         return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1667       else
1668         return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1669     }
1670   else
1671     {
1672       if (ADDRESS_REG_P (operands[1]))
1673         return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1674       else
1675         return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1676     }
1679 (define_insn "extendhidi2"
1680   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1681         (sign_extend:DI
1682          (match_operand:HI 1 "general_src_operand" "rmS")))]
1683   ""
1685   CC_STATUS_INIT;
1686   operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1687   if (ISA_HAS_MVS_MVZ)
1688     return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1689   if (TARGET_68020 || TARGET_COLDFIRE)
1690     return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1691   else
1692     return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1695 (define_insn "extendsidi2"
1696   [(set (match_operand:DI 0 "register_operand" "=d")
1697         (sign_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "rm")))]
1698   ""
1700   CC_STATUS_INIT;
1701   if (TARGET_68020 || TARGET_COLDFIRE)
1702     return "move%.l %1,%R0\;smi %0\;extb%.l %0";
1703   else
1704     return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
1707 (define_insn "*extendsidi2_mem"
1708   [(set (match_operand:DI 0 "memory_operand" "=o,<")
1709         (sign_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "rm,rm")))
1710    (clobber (match_scratch:SI 2 "=d,d"))]
1711    ""
1713   CC_STATUS_INIT;
1714   operands[3] = adjust_address (operands[0], SImode,
1715                                 which_alternative == 0 ? 4 : 0);
1716   operands[0] = adjust_address (operands[0], SImode, 0);
1717   if (TARGET_68020 || TARGET_COLDFIRE)
1718     return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
1719   else
1720     return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
1723 ;; Special case when one can avoid register clobbering, copy and test
1724 ;; Maybe there is a way to make that the general case, by forcing the
1725 ;; result of the SI tree to be in the lower register of the DI target
1727 (define_insn "extendplussidi"
1728   [(set (match_operand:DI 0 "register_operand" "=d")
1729     (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1730             (match_operand:SI 2 "general_operand" "rmn"))))]
1731   ""
1733   CC_STATUS_INIT;
1734   operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1735   if (GET_CODE (operands[1]) == CONST_INT
1736   && (unsigned) INTVAL (operands[1]) > 8)
1737     {
1738       rtx tmp = operands[1];
1740       operands[1] = operands[2];
1741       operands[2] = tmp;
1742     }
1743   if (GET_CODE (operands[1]) == REG
1744       && REGNO (operands[1]) == REGNO (operands[3]))
1745     output_asm_insn ("add%.l %2,%3", operands);
1746   else
1747     output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1748   if (TARGET_68020 || TARGET_COLDFIRE)
1749     return "smi %0\;extb%.l %0";
1750   else
1751     return "smi %0\;ext%.w %0\;ext%.l %0";
1754 (define_expand "extendhisi2"
1755   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1756         (sign_extend:SI
1757          (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1758   ""
1759   "")
1761 (define_insn "*cfv4_extendhisi2"
1762   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1763         (sign_extend:SI
1764          (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1765   "ISA_HAS_MVS_MVZ"
1766   "mvs%.w %1,%0"
1767   [(set_attr "type" "mvsz")])
1769 (define_insn "*68k_extendhisi2"
1770   [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1771         (sign_extend:SI
1772          (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1773   "!ISA_HAS_MVS_MVZ"
1774   "@
1775    ext%.l %0
1776    move%.w %1,%0"
1777   [(set_attr "type" "ext,move")])
1779 (define_insn "extendqihi2"
1780   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1781         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1782   ""
1783   "ext%.w %0"
1784   [(set_attr "type" "ext")])
1786 (define_expand "extendqisi2"
1787   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1788         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1789   "TARGET_68020 || TARGET_COLDFIRE"
1790   "")
1792 (define_insn "*cfv4_extendqisi2"
1793   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1794         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1795   "ISA_HAS_MVS_MVZ"
1796   "mvs%.b %1,%0"
1797   [(set_attr "type" "mvsz")])
1799 (define_insn "*68k_extendqisi2"
1800   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1801         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1802   "TARGET_68020 || (TARGET_COLDFIRE && !ISA_HAS_MVS_MVZ)"
1803   "extb%.l %0"
1804   [(set_attr "type" "ext")])
1806 ;; Conversions between float and double.
1808 (define_expand "extendsfdf2"
1809   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1810         (float_extend:DF
1811          (match_operand:SF 1 "general_operand" "")))]
1812   "TARGET_HARD_FLOAT"
1813   "")
1815 (define_insn ""
1816   [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1817         (float_extend:DF
1818           (match_operand:SF 1 "general_operand" "f,dmF")))]
1819   "TARGET_68881"
1821   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1822     {
1823       if (REGNO (operands[0]) == REGNO (operands[1]))
1824         {
1825           /* Extending float to double in an fp-reg is a no-op.
1826              NOTICE_UPDATE_CC has already assumed that the
1827              cc will be set.  So cancel what it did.  */
1828           cc_status = cc_prev_status;
1829           return "";
1830         }
1831       return "f%&move%.x %1,%0";
1832     }
1833   if (FP_REG_P (operands[0]))
1834     return "f%&move%.s %f1,%0";
1835   if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1836     {
1837       output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1838       operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1839       return "move%.l %+,%0";
1840     }
1841   return "fmove%.d %f1,%0";
1844 (define_insn "extendsfdf2_cf"
1845   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
1846         (float_extend:DF
1847          (match_operand:SF 1 "general_operand" "f,<Q>U")))]
1848   "TARGET_COLDFIRE_FPU"
1850   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1851     {
1852       if (REGNO (operands[0]) == REGNO (operands[1]))
1853         {
1854           /* Extending float to double in an fp-reg is a no-op.
1855              NOTICE_UPDATE_CC has already assumed that the
1856              cc will be set.  So cancel what it did.  */
1857           cc_status = cc_prev_status;
1858           return "";
1859         }
1860       return "fdmove%.d %1,%0";
1861     }
1862   return "fdmove%.s %f1,%0";
1865 ;; This cannot output into an f-reg because there is no way to be
1866 ;; sure of truncating in that case.
1867 (define_expand "truncdfsf2"
1868   [(set (match_operand:SF 0 "nonimmediate_operand" "")
1869         (float_truncate:SF
1870           (match_operand:DF 1 "general_operand" "")))]
1871   "TARGET_HARD_FLOAT"
1872   "")
1874 ;; On the '040 we can truncate in a register accurately and easily.
1875 (define_insn ""
1876   [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1877         (float_truncate:SF
1878           (match_operand:DF 1 "general_operand" "fmG")))]
1879   "TARGET_68881 && TARGET_68040"
1881   if (FP_REG_P (operands[1]))
1882     return "f%$move%.x %1,%0";
1883   return "f%$move%.d %f1,%0";
1886 (define_insn "truncdfsf2_cf"
1887   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
1888         (float_truncate:SF
1889           (match_operand:DF 1 "general_operand" "<Q>U,f")))]
1890   "TARGET_COLDFIRE_FPU"
1891   "@
1892   fsmove%.d %1,%0
1893   fmove%.s %1,%0"
1894   [(set_attr "type" "fmove")])
1896 (define_insn "*truncdfsf2_68881"
1897   [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
1898         (float_truncate:SF
1899           (match_operand:DF 1 "general_operand" "f")))]
1900   "TARGET_68881"
1901   "fmove%.s %f1,%0"
1902   [(set_attr "type" "fmove")])
1904 ;; Conversion between fixed point and floating point.
1905 ;; Note that among the fix-to-float insns
1906 ;; the ones that start with SImode come first.
1907 ;; That is so that an operand that is a CONST_INT
1908 ;; (and therefore lacks a specific machine mode).
1909 ;; will be recognized as SImode (which is always valid)
1910 ;; rather than as QImode or HImode.
1912 (define_expand "floatsi<mode>2"
1913   [(set (match_operand:FP 0 "nonimmediate_operand" "")
1914         (float:FP (match_operand:SI 1 "general_operand" "")))]
1915   "TARGET_HARD_FLOAT"
1916   "")
1918 (define_insn "floatsi<mode>2_68881"
1919   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1920         (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
1921   "TARGET_68881"
1922   "f<FP:round>move%.l %1,%0"
1923   [(set_attr "type" "fmove")])
1925 (define_insn "floatsi<mode>2_cf"
1926   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1927         (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
1928   "TARGET_COLDFIRE_FPU"
1929   "f<FP:prec>move%.l %1,%0"
1930   [(set_attr "type" "fmove")])
1933 (define_expand "floathi<mode>2"
1934   [(set (match_operand:FP 0 "nonimmediate_operand" "")
1935         (float:FP (match_operand:HI 1 "general_operand" "")))]
1936   "TARGET_HARD_FLOAT"
1937   "")
1939 (define_insn "floathi<mode>2_68881"
1940   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1941         (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
1942   "TARGET_68881"
1943   "fmove%.w %1,%0"
1944   [(set_attr "type" "fmove")])
1946 (define_insn "floathi<mode>2_cf"
1947   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1948         (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
1949   "TARGET_COLDFIRE_FPU"
1950   "fmove%.w %1,%0"
1951   [(set_attr "type" "fmove")])
1954 (define_expand "floatqi<mode>2"
1955   [(set (match_operand:FP 0 "nonimmediate_operand" "")
1956         (float:FP (match_operand:QI 1 "general_operand" "")))]
1957   "TARGET_HARD_FLOAT"
1958   "")
1960 (define_insn "floatqi<mode>2_68881"
1961   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1962         (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
1963   "TARGET_68881"
1964   "fmove%.b %1,%0"
1965   [(set_attr "type" "fmove")])
1967 (define_insn "floatqi<mode>2_cf"
1968   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
1969         (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
1970   "TARGET_COLDFIRE_FPU"
1971   "fmove%.b %1,%0"
1972   [(set_attr "type" "fmove")])
1975 ;; New routines to convert floating-point values to integers
1976 ;; to be used on the '040.  These should be faster than trapping
1977 ;; into the kernel to emulate fintrz.  They should also be faster
1978 ;; than calling the subroutines fixsfsi or fixdfsi.
1980 (define_insn "fix_truncdfsi2"
1981   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
1982         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1983    (clobber (match_scratch:SI 2 "=d"))
1984    (clobber (match_scratch:SI 3 "=d"))]
1985   "TARGET_68881 && TUNE_68040"
1987   CC_STATUS_INIT;
1988   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,%!";
1991 (define_insn "fix_truncdfhi2"
1992   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
1993         (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
1994    (clobber (match_scratch:SI 2 "=d"))
1995    (clobber (match_scratch:SI 3 "=d"))]
1996   "TARGET_68881 && TUNE_68040"
1998   CC_STATUS_INIT;
1999   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,%!";
2002 (define_insn "fix_truncdfqi2"
2003   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2004         (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2005    (clobber (match_scratch:SI 2 "=d"))
2006    (clobber (match_scratch:SI 3 "=d"))]
2007   "TARGET_68881 && TUNE_68040"
2009   CC_STATUS_INIT;
2010   return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.b %1,%0\;fmovem%.l %2,%!";
2013 ;; Convert a float to a float whose value is an integer.
2014 ;; This is the first stage of converting it to an integer type.
2016 (define_expand "ftrunc<mode>2"
2017   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2018         (fix:FP (match_operand:FP 1 "general_operand" "")))]
2019   "TARGET_HARD_FLOAT && !TUNE_68040"
2020   "")
2022 (define_insn "ftrunc<mode>2_68881"
2023   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2024         (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
2025   "TARGET_68881 && !TUNE_68040"
2027   if (FP_REG_P (operands[1]))
2028     return "fintrz%.x %f1,%0";
2029   return "fintrz%.<FP:prec> %f1,%0";
2031   [(set_attr "type" "falu")])
2033 (define_insn "ftrunc<mode>2_cf"
2034   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2035         (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
2036   "TARGET_COLDFIRE_FPU"
2038   if (FP_REG_P (operands[1]))
2039     return "fintrz%.d %f1,%0";
2040   return "fintrz%.<FP:prec> %f1,%0";
2042   [(set_attr "type" "falu")])
2044 ;; Convert a float whose value is an integer
2045 ;; to an actual integer.  Second stage of converting float to integer type.
2046 (define_expand "fix<mode>qi2"
2047   [(set (match_operand:QI 0 "nonimmediate_operand" "")
2048         (fix:QI (match_operand:FP 1 "general_operand" "")))]
2049   "TARGET_HARD_FLOAT"
2050   "")
2052 (define_insn "fix<mode>qi2_68881"
2053   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2054         (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2055   "TARGET_68881"
2056   "fmove%.b %1,%0"
2057   [(set_attr "type" "fmove")])
2059 (define_insn "fix<mode>qi2_cf"
2060   [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
2061         (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2062   "TARGET_COLDFIRE_FPU"
2063   "fmove%.b %1,%0"
2064   [(set_attr "type" "fmove")])
2066 (define_expand "fix<mode>hi2"
2067   [(set (match_operand:HI 0 "nonimmediate_operand" "")
2068         (fix:HI (match_operand:FP 1 "general_operand" "")))]
2069   "TARGET_HARD_FLOAT"
2070   "")
2072 (define_insn "fix<mode>hi2_68881"
2073   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2074         (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2075   "TARGET_68881"
2076   "fmove%.w %1,%0"
2077   [(set_attr "type" "fmove")])
2079 (define_insn "fix<mode>hi2_cf"
2080   [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
2081         (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2082   "TARGET_COLDFIRE_FPU"
2083   "fmove%.w %1,%0"
2084   [(set_attr "type" "fmove")])
2086 (define_expand "fix<mode>si2"
2087   [(set (match_operand:SI 0 "nonimmediate_operand" "")
2088         (fix:SI (match_operand:FP 1 "general_operand" "")))]
2089   "TARGET_HARD_FLOAT"
2090   "")
2092 (define_insn "fix<mode>si2_68881"
2093   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2094         (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2095   "TARGET_68881"
2096   "fmove%.l %1,%0"
2097   [(set_attr "type" "fmove")])
2099 (define_insn "fix<mode>si2_cf"
2100   [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
2101         (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2102   "TARGET_COLDFIRE_FPU"
2103   "fmove%.l %1,%0"
2104   [(set_attr "type" "fmove")])
2107 ;; add instructions
2109 (define_insn "adddi_lshrdi_63"
2110   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
2111     (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
2112             (const_int 63))
2113         (match_dup 1)))
2114    (clobber (match_scratch:SI 2 "=d"))]
2115   ""
2117   operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2118   if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
2119     return
2120     "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
2121   if (GET_CODE (operands[1]) == REG)
2122     operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2123   else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
2124         || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2125     operands[4] = operands[1];
2126   else
2127     operands[4] = adjust_address (operands[1], SImode, 4);
2128   if (GET_CODE (operands[1]) == MEM
2129    && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2130     output_asm_insn ("move%.l %4,%3", operands);
2131   output_asm_insn ("move%.l %1,%0\;smi %2", operands);
2132   if (TARGET_68020 || TARGET_COLDFIRE)
2133     output_asm_insn ("extb%.l %2", operands);
2134   else
2135     output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
2136   if (GET_CODE (operands[1]) != MEM
2137    || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
2138     output_asm_insn ("move%.l %4,%3", operands);
2139   return "sub%.l %2,%3\;subx%.l %2,%0";
2142 (define_insn "adddi_sexthishl32"
2143   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2144     (plus:DI (ashift:DI (sign_extend:DI
2145           (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
2146             (const_int 32))
2147         (match_operand:DI 2 "general_operand" "0,0,0,0")))
2148    (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2149   "!TARGET_COLDFIRE"
2151   CC_STATUS_INIT;
2152   if (ADDRESS_REG_P (operands[0]))
2153     return "add%.w %1,%0";
2154   else if (ADDRESS_REG_P (operands[3]))
2155     return "move%.w %1,%3\;add%.l %3,%0";
2156   else
2157     return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
2160 (define_insn "*adddi_dilshr32"
2161   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
2162         (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
2163                               (const_int 32))
2164                  (match_operand:DI 2 "general_operand" "0,0")))]
2165   "!TARGET_COLDFIRE"
2167   CC_STATUS_INIT;
2168   if (GET_CODE (operands[0]) == REG)
2169     operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2170   else
2171     operands[2] = adjust_address (operands[0], SImode, 4);
2172   return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
2175 (define_insn "*adddi_dilshr32_cf"
2176   [(set (match_operand:DI 0 "register_operand" "=d")
2177         (plus:DI (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
2178                               (const_int 32))
2179                  (match_operand:DI 2 "register_operand" "0")))]
2180   "TARGET_COLDFIRE"
2182   CC_STATUS_INIT;
2183   return "add%.l %1,%R0\;negx%.l %0\;neg%.l %0";
2186 (define_insn "adddi_dishl32"
2187   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
2188 ;;    (plus:DI (match_operand:DI 2 "general_operand" "%0")
2189 ;;      (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2190 ;;            (const_int 32))))]
2191     (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
2192             (const_int 32))
2193         (match_operand:DI 2 "general_operand" "0,0")))]
2194   ""
2196   CC_STATUS_INIT;
2197   if (GET_CODE (operands[1]) == REG)
2198     operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2199   else
2200     operands[1] = adjust_address (operands[1], SImode, 4);
2201   return "add%.l %1,%0";
2203   [(set_attr "type" "alu_l")])
2205 (define_insn "adddi3"
2206   [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2207         (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0")
2208                  (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2209    (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2210   ""
2212   if (DATA_REG_P (operands[0]))
2213     {
2214       if (DATA_REG_P (operands[2]))
2215         return "add%.l %R2,%R0\;addx%.l %2,%0";
2216       else if (GET_CODE (operands[2]) == MEM
2217           && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2218         return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
2219       else
2220         {
2221           rtx high, low;
2222           rtx xoperands[2];
2224           if (GET_CODE (operands[2]) == REG)
2225             {
2226               low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2227               high = operands[2];
2228             }
2229           else if (CONSTANT_P (operands[2]))
2230             split_double (operands[2], &high, &low);
2231           else
2232             {
2233               low = adjust_address (operands[2], SImode, 4);
2234               high = operands[2];
2235             }
2237           operands[1] = low, operands[2] = high;
2238           xoperands[0] = operands[3];
2239           if (GET_CODE (operands[1]) == CONST_INT
2240               && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2241             xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2242           else
2243             xoperands[1] = operands[2];
2245           output_asm_insn (output_move_simode (xoperands), xoperands);
2246           if (GET_CODE (operands[1]) == CONST_INT)
2247             {
2248               if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2249                 return "addq%.l %1,%R0\;addx%.l %3,%0";
2250               else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2251                 {
2252                   operands[1] = GEN_INT (-INTVAL (operands[1]));
2253                   return "subq%.l %1,%R0\;subx%.l %3,%0";
2254                 }
2255             }
2256           return "add%.l %1,%R0\;addx%.l %3,%0";
2257         }
2258     }
2259   else
2260     {
2261       gcc_assert (GET_CODE (operands[0]) == MEM);
2262       CC_STATUS_INIT;
2263       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2264         {
2265           operands[1] = gen_rtx_MEM (SImode,
2266                                      plus_constant (XEXP(operands[0], 0), -8));
2267           return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2268         }
2269       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2270         {
2271           operands[1] = XEXP(operands[0], 0);
2272           return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2273         }
2274       else
2275         {
2276           operands[1] = adjust_address (operands[0], SImode, 4);
2277           return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2278         }
2279     }
2282 (define_insn "addsi_lshrsi_31"
2283   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2284     (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm")
2285             (const_int 31))
2286         (match_dup 1)))]
2287   ""
2289   operands[2] = operands[0];
2290   operands[3] = gen_label_rtx();
2291   if (GET_CODE (operands[0]) == MEM)
2292     {
2293       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2294         operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2295       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2296         operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2297     }
2298   output_asm_insn ("move%.l %1,%0", operands);
2299   output_asm_insn ("jpl %l3", operands);
2300   output_asm_insn ("addq%.l #1,%2", operands);
2301   (*targetm.asm_out.internal_label) (asm_out_file, "L",
2302                                 CODE_LABEL_NUMBER (operands[3]));
2303   return "";
2306 (define_expand "addsi3"
2307   [(set (match_operand:SI 0 "nonimmediate_operand" "")
2308         (plus:SI (match_operand:SI 1 "general_operand" "")
2309                  (match_operand:SI 2 "general_src_operand" "")))]
2310   ""
2311   "")
2313 ;; Note that the middle two alternatives are near-duplicates
2314 ;; in order to handle insns generated by reload.
2315 ;; This is needed since they are not themselves reloaded,
2316 ;; so commutativity won't apply to them.
2317 (define_insn "*addsi3_internal"
2318   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2319         (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2320                  (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2323   "! TARGET_COLDFIRE"
2324   "* return output_addsi3 (operands);")
2326 (define_insn_and_split "*addsi3_5200"
2327   [(set (match_operand:SI 0 "nonimmediate_operand"         "=mr,mr,m,r,  ?a,?a,?a,?a")
2328         (plus:SI (match_operand:SI 1 "general_operand"     "%0, 0, 0,0,   a, a, r, a")
2329                  (match_operand:SI 2 "general_src_operand" " I, L, d,mrKi,Cj,r, a, J")))]
2330   "TARGET_COLDFIRE"
2332   switch (which_alternative)
2333     {
2334     case 0:
2335       return "addq%.l %2,%0";
2337     case 1:
2338       operands[2] = GEN_INT (- INTVAL (operands[2]));
2339       return "subq%.l %2,%0";
2341     case 2:
2342     case 3:
2343       return "add%.l %2,%0";
2345     case 4:
2346       /* move%.l %2,%0\n\tadd%.l %1,%0 */
2347       return "#";
2349     case 5:
2350       return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0";
2352     case 6:
2353       return MOTOROLA ? "lea (%2,%1.l),%0" : "lea %2@(0,%1:l),%0";
2355     case 7:
2356       return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
2358     default:
2359       gcc_unreachable ();
2360       return "";
2361     }
2363   "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 4) && !operands_match_p (operands[0], operands[1])"
2364   [(set (match_dup 0)
2365         (match_dup 2))
2366    (set (match_dup 0)
2367         (plus:SI (match_dup 0)
2368                  (match_dup 1)))]
2369   ""
2370   [(set_attr "type" "aluq_l,aluq_l,alu_l,alu_l,*,lea,lea,lea")
2371    (set_attr "opy" "2,2,2,2,*,*,*,*")
2372    (set_attr "opy_type" "*,*,*,*,*,mem6,mem6,mem5")])
2374 (define_insn ""
2375   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2376         (plus:SI (match_operand:SI 1 "general_operand" "0")
2377                  (sign_extend:SI
2378                   (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2379   "!TARGET_COLDFIRE"
2380   "add%.w %2,%0")
2382 (define_insn "addhi3"
2383   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2384         (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2385                  (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2386   "!TARGET_COLDFIRE"
2388   if (GET_CODE (operands[2]) == CONST_INT)
2389     {
2390       /* If the constant would be a negative number when interpreted as
2391          HImode, make it negative.  This is usually, but not always, done
2392          elsewhere in the compiler.  First check for constants out of range,
2393          which could confuse us.  */
2395       if (INTVAL (operands[2]) >= 32768)
2396         operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2398       if (INTVAL (operands[2]) > 0
2399           && INTVAL (operands[2]) <= 8)
2400         return "addq%.w %2,%0";
2401       if (INTVAL (operands[2]) < 0
2402           && INTVAL (operands[2]) >= -8)
2403         {
2404           operands[2] = GEN_INT (- INTVAL (operands[2]));
2405           return "subq%.w %2,%0";
2406         }
2407       /* On the CPU32 it is faster to use two addqw instructions to
2408          add a small integer (8 < N <= 16) to a register.  
2409          Likewise for subqw.  */
2410       if (TUNE_CPU32 && REG_P (operands[0]))
2411         {
2412           if (INTVAL (operands[2]) > 8
2413               && INTVAL (operands[2]) <= 16)
2414             {
2415               operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2416               return "addq%.w #8,%0\;addq%.w %2,%0";
2417             }
2418           if (INTVAL (operands[2]) < -8
2419               && INTVAL (operands[2]) >= -16)
2420             {
2421               operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2422               return "subq%.w #8,%0\;subq%.w %2,%0";
2423             }
2424         }
2425       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2426         return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2427     }
2428   return "add%.w %2,%0";
2431 ;; These insns must use MATCH_DUP instead of the more expected
2432 ;; use of a matching constraint because the "output" here is also
2433 ;; an input, so you can't use the matching constraint.  That also means
2434 ;; that you can't use the "%", so you need patterns with the matched
2435 ;; operand in both positions.
2437 (define_insn ""
2438   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2439         (plus:HI (match_dup 0)
2440                  (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2441   "!TARGET_COLDFIRE"
2443   if (GET_CODE (operands[1]) == CONST_INT)
2444     {
2445       /* If the constant would be a negative number when interpreted as
2446          HImode, make it negative.  This is usually, but not always, done
2447          elsewhere in the compiler.  First check for constants out of range,
2448          which could confuse us.  */
2450       if (INTVAL (operands[1]) >= 32768)
2451         operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2453       if (INTVAL (operands[1]) > 0
2454           && INTVAL (operands[1]) <= 8)
2455         return "addq%.w %1,%0";
2456       if (INTVAL (operands[1]) < 0
2457           && INTVAL (operands[1]) >= -8)
2458         {
2459           operands[1] = GEN_INT (- INTVAL (operands[1]));
2460           return "subq%.w %1,%0";
2461         }
2462       /* On the CPU32 it is faster to use two addqw instructions to
2463          add a small integer (8 < N <= 16) to a register. 
2464          Likewise for subqw.  */
2465       if (TUNE_CPU32 && REG_P (operands[0]))
2466         {
2467           if (INTVAL (operands[1]) > 8
2468               && INTVAL (operands[1]) <= 16)
2469             {
2470               operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2471               return "addq%.w #8,%0\;addq%.w %1,%0";
2472             }
2473           if (INTVAL (operands[1]) < -8
2474               && INTVAL (operands[1]) >= -16)
2475             {
2476               operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2477               return "subq%.w #8,%0\;subq%.w %1,%0";
2478             }
2479         }
2480       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2481         return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2482     }
2483   return "add%.w %1,%0";
2486 (define_insn ""
2487   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2488         (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2489                  (match_dup 0)))]
2490   "!TARGET_COLDFIRE"
2492   if (GET_CODE (operands[1]) == CONST_INT)
2493     {
2494       /* If the constant would be a negative number when interpreted as
2495          HImode, make it negative.  This is usually, but not always, done
2496          elsewhere in the compiler.  First check for constants out of range,
2497          which could confuse us.  */
2499       if (INTVAL (operands[1]) >= 32768)
2500         operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2502       if (INTVAL (operands[1]) > 0
2503           && INTVAL (operands[1]) <= 8)
2504         return "addq%.w %1,%0";
2505       if (INTVAL (operands[1]) < 0
2506           && INTVAL (operands[1]) >= -8)
2507         {
2508           operands[1] = GEN_INT (- INTVAL (operands[1]));
2509           return "subq%.w %1,%0";
2510         }
2511       /* On the CPU32 it is faster to use two addqw instructions to
2512          add a small integer (8 < N <= 16) to a register.
2513          Likewise for subqw.  */
2514       if (TUNE_CPU32 && REG_P (operands[0]))
2515         {
2516           if (INTVAL (operands[1]) > 8
2517               && INTVAL (operands[1]) <= 16)
2518             {
2519               operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2520               return "addq%.w #8,%0\;addq%.w %1,%0";
2521             }
2522           if (INTVAL (operands[1]) < -8
2523               && INTVAL (operands[1]) >= -16)
2524             {
2525               operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2526               return "subq%.w #8,%0\;subq%.w %1,%0";
2527             }
2528         }
2529       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2530         return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2531     }
2532   return "add%.w %1,%0";
2535 (define_insn "addqi3"
2536   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2537         (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2538                  (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2539   "!TARGET_COLDFIRE"
2541   if (GET_CODE (operands[2]) == CONST_INT)
2542     {
2543       if (INTVAL (operands[2]) >= 128)
2544         operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2546       if (INTVAL (operands[2]) > 0
2547           && INTVAL (operands[2]) <= 8)
2548         return "addq%.b %2,%0";
2549       if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2550        {
2551          operands[2] = GEN_INT (- INTVAL (operands[2]));
2552          return "subq%.b %2,%0";
2553        }
2554     }
2555   return "add%.b %2,%0";
2558 (define_insn ""
2559   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2560         (plus:QI (match_dup 0)
2561                  (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2562   "!TARGET_COLDFIRE"
2564   if (GET_CODE (operands[1]) == CONST_INT)
2565     {
2566       if (INTVAL (operands[1]) >= 128)
2567         operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2569       if (INTVAL (operands[1]) > 0
2570           && INTVAL (operands[1]) <= 8)
2571         return "addq%.b %1,%0";
2572       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2573        {
2574          operands[1] = GEN_INT (- INTVAL (operands[1]));
2575          return "subq%.b %1,%0";
2576        }
2577     }
2578   return "add%.b %1,%0";
2581 (define_insn ""
2582   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2583         (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2584                  (match_dup 0)))]
2585   "!TARGET_COLDFIRE"
2587   if (GET_CODE (operands[1]) == CONST_INT)
2588     {
2589       if (INTVAL (operands[1]) >= 128)
2590         operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2592       if (INTVAL (operands[1]) > 0
2593           && INTVAL (operands[1]) <= 8)
2594         return "addq%.b %1,%0";
2595       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2596        {
2597          operands[1] = GEN_INT (- INTVAL (operands[1]));
2598          return "subq%.b %1,%0";
2599        }
2600     }
2601   return "add%.b %1,%0";
2604 (define_expand "add<mode>3"
2605   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2606         (plus:FP (match_operand:FP 1 "general_operand" "")
2607                  (match_operand:FP 2 "general_operand" "")))]
2608   "TARGET_HARD_FLOAT"
2609   "")
2611 (define_insn "add<mode>3_floatsi_68881"
2612   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2613         (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2614                  (match_operand:FP 1 "general_operand" "0")))]
2615   "TARGET_68881"
2616   "f<FP:round>add%.l %2,%0"
2617   [(set_attr "type" "falu")
2618    (set_attr "opy" "2")])
2620 (define_insn "add<mode>3_floathi_68881"
2621   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2622         (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2623                  (match_operand:FP 1 "general_operand" "0")))]
2624   "TARGET_68881"
2625   "f<FP:round>add%.w %2,%0"
2626   [(set_attr "type" "falu")
2627    (set_attr "opy" "2")])
2629 (define_insn "add<mode>3_floatqi_68881"
2630   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2631         (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2632                  (match_operand:FP 1 "general_operand" "0")))]
2633   "TARGET_68881"
2634   "f<FP:round>add%.b %2,%0"
2635   [(set_attr "type" "falu")
2636    (set_attr "opy" "2")])
2638 (define_insn "add<mode>3_68881"
2639   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2640         (plus:FP (match_operand:FP 1 "general_operand" "%0")
2641                  (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2642   "TARGET_68881"
2644   if (FP_REG_P (operands[2]))
2645     return "f<FP:round>add%.x %2,%0";
2646   return "f<FP:round>add%.<FP:prec> %f2,%0";
2648   [(set_attr "type" "falu")
2649    (set_attr "opy" "2")])
2651 (define_insn "add<mode>3_cf"
2652   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2653         (plus:FP (match_operand:FP 1 "general_operand" "%0")
2654                  (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2655   "TARGET_COLDFIRE_FPU"
2657   if (FP_REG_P (operands[2]))
2658     return "f<FP:prec>add%.d %2,%0";
2659   return "f<FP:prec>add%.<FP:prec> %2,%0";
2661   [(set_attr "type" "falu")
2662    (set_attr "opy" "2")])
2664 ;; subtract instructions
2666 (define_insn "subdi_sexthishl32"
2667   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2668     (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2669         (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2670             (const_int 32))))
2671    (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2672   "!TARGET_COLDFIRE"
2674   CC_STATUS_INIT;
2675   if (ADDRESS_REG_P (operands[0]))
2676     return "sub%.w %2,%0";
2677   else if (ADDRESS_REG_P (operands[3]))
2678     return "move%.w %2,%3\;sub%.l %3,%0";
2679   else
2680     return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2683 (define_insn "subdi_dishl32"
2684   [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2685     (minus:DI (match_dup 0)
2686         (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2687             (const_int 32))))]
2688   ""
2690   CC_STATUS_INIT;
2691   if (GET_CODE (operands[1]) == REG)
2692     operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2693   else
2694     operands[1] = adjust_address (operands[1], SImode, 4);
2695   return "sub%.l %1,%0";
2697   [(set_attr "type" "alu_l")])
2699 (define_insn "subdi3"
2700   [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2701         (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2702                  (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2703    (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2704   ""
2706   if (DATA_REG_P (operands[0]))
2707     {
2708       if (DATA_REG_P (operands[2]))
2709         return "sub%.l %R2,%R0\;subx%.l %2,%0";
2710       else if (GET_CODE (operands[2]) == MEM
2711           && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2712         {
2713           return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2714         }
2715       else
2716         {
2717           rtx high, low;
2718           rtx xoperands[2];
2720           if (GET_CODE (operands[2]) == REG)
2721             {
2722               low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2723               high = operands[2];
2724             }
2725           else if (CONSTANT_P (operands[2]))
2726             split_double (operands[2], &high, &low);
2727           else
2728             {
2729               low = adjust_address (operands[2], SImode, 4);
2730               high = operands[2];
2731             }
2733           operands[1] = low, operands[2] = high;
2734           xoperands[0] = operands[3];
2735           if (GET_CODE (operands[1]) == CONST_INT
2736               && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2737             xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2738           else
2739             xoperands[1] = operands[2];
2741           output_asm_insn (output_move_simode (xoperands), xoperands);
2742           if (GET_CODE (operands[1]) == CONST_INT)
2743             {
2744               if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2745                 return "subq%.l %1,%R0\;subx%.l %3,%0";
2746               else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2747                 {
2748                   operands[1] = GEN_INT (-INTVAL (operands[1]));
2749                   return "addq%.l %1,%R0\;addx%.l %3,%0";
2750                 }
2751             }
2752           return "sub%.l %1,%R0\;subx%.l %3,%0";
2753         }
2754     }
2755   else
2756     {
2757       gcc_assert (GET_CODE (operands[0]) == MEM);
2758       CC_STATUS_INIT;
2759       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2760         {
2761           operands[1]
2762             = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2763           return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2764         }
2765       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2766         {
2767           operands[1] = XEXP(operands[0], 0);
2768           return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2769         }
2770       else
2771         {
2772           operands[1] = adjust_address (operands[0], SImode, 4);
2773           return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2774         }
2775     }
2778 (define_insn "subsi3"
2779   [(set (match_operand:SI 0 "nonimmediate_operand" "=mda,m,d,a")
2780         (minus:SI (match_operand:SI 1 "general_operand" "0,0,0,0")
2781                   (match_operand:SI 2 "general_src_operand" "I,dT,mSrT,mSrs")))]
2782   ""
2783   "@
2784    subq%.l %2, %0
2785    sub%.l %2,%0
2786    sub%.l %2,%0
2787    sub%.l %2,%0"
2788   [(set_attr "type" "aluq_l,alu_l,alu_l,alu_l")
2789    (set_attr "opy" "2")])
2791 (define_insn ""
2792   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2793         (minus:SI (match_operand:SI 1 "general_operand" "0")
2794                   (sign_extend:SI
2795                    (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2796   "!TARGET_COLDFIRE"
2797   "sub%.w %2,%0")
2799 (define_insn "subhi3"
2800   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2801         (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2802                   (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2803   "!TARGET_COLDFIRE"
2804   "sub%.w %2,%0")
2806 (define_insn ""
2807   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2808         (minus:HI (match_dup 0)
2809                   (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2810   "!TARGET_COLDFIRE"
2811   "sub%.w %1,%0")
2813 (define_insn "subqi3"
2814   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2815         (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2816                   (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2817   "!TARGET_COLDFIRE"
2818   "sub%.b %2,%0")
2820 (define_insn ""
2821   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2822         (minus:QI (match_dup 0)
2823                   (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2824   "!TARGET_COLDFIRE"
2825   "sub%.b %1,%0")
2827 (define_expand "sub<mode>3"
2828   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2829         (minus:FP (match_operand:FP 1 "general_operand" "")
2830                   (match_operand:FP 2 "general_operand" "")))]
2831   "TARGET_HARD_FLOAT"
2832   "")
2834 (define_insn "sub<mode>3_floatsi_68881"
2835   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2836         (minus:FP (match_operand:FP 1 "general_operand" "0")
2837                   (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2838   "TARGET_68881"
2839   "f<FP:round>sub%.l %2,%0"
2840   [(set_attr "type" "falu")
2841    (set_attr "opy" "2")])
2843 (define_insn "sub<mode>3_floathi_68881"
2844   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2845         (minus:FP (match_operand:FP 1 "general_operand" "0")
2846                   (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2847   "TARGET_68881"
2848   "f<FP:round>sub%.w %2,%0"
2849   [(set_attr "type" "falu")
2850    (set_attr "opy" "2")])
2852 (define_insn "sub<mode>3_floatqi_68881"
2853   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2854         (minus:FP (match_operand:FP 1 "general_operand" "0")
2855                   (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2856   "TARGET_68881"
2857   "f<FP:round>sub%.b %2,%0"
2858   [(set_attr "type" "falu")
2859    (set_attr "opy" "2")])
2861 (define_insn "sub<mode>3_68881"
2862   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2863         (minus:FP (match_operand:FP 1 "general_operand" "0")
2864                   (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2865   "TARGET_68881"
2867   if (FP_REG_P (operands[2]))
2868     return "f<FP:round>sub%.x %2,%0";
2869   return "f<FP:round>sub%.<FP:prec> %f2,%0";
2871   [(set_attr "type" "falu")
2872    (set_attr "opy" "2")])
2874 (define_insn "sub<mode>3_cf"
2875   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2876         (minus:FP (match_operand:FP 1 "general_operand" "0")
2877                   (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2878   "TARGET_COLDFIRE_FPU"
2880   if (FP_REG_P (operands[2]))
2881     return "f<FP:prec>sub%.d %2,%0";
2882   return "f<FP:prec>sub%.<FP:prec> %2,%0";
2884   [(set_attr "type" "falu")
2885    (set_attr "opy" "2")])
2887 ;; multiply instructions
2889 (define_insn "mulhi3"
2890   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
2891         (mult:HI (match_operand:HI 1 "general_operand" "%0")
2892                  (match_operand:HI 2 "general_src_operand" "dmSn")))]
2893   ""
2895   return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2897   [(set_attr "type" "mul_w")
2898    (set_attr "opy" "2")])
2900 (define_insn "mulhisi3"
2901   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2902         (mult:SI (sign_extend:SI
2903                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
2904                  (sign_extend:SI
2905                   (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
2906   ""
2908   return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2910   [(set_attr "type" "mul_w")
2911    (set_attr "opy" "2")])
2913 (define_insn "*mulhisisi3_s"
2914   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2915         (mult:SI (sign_extend:SI
2916                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
2917                  (match_operand:SI 2 "const_int_operand" "n")))]
2918   "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
2920   return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
2922   [(set_attr "type" "mul_w")
2923    (set_attr "opy" "2")])
2925 (define_expand "mulsi3"
2926   [(set (match_operand:SI 0 "nonimmediate_operand" "")
2927         (mult:SI (match_operand:SI 1 "general_operand" "")
2928                  (match_operand:SI 2 "general_operand" "")))]
2929   "TARGET_68020 || TARGET_COLDFIRE"
2930   "")
2932 (define_insn "*mulsi3_68020"
2933   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2934         (mult:SI (match_operand:SI 1 "general_operand" "%0")
2935                  (match_operand:SI 2 "general_src_operand" "dmSTK")))]
2937   "TARGET_68020"
2938   "muls%.l %2,%0"
2939   [(set_attr "type" "mul_l")
2940    (set_attr "opy" "2")])
2942 (define_insn "*mulsi3_cf"
2943   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2944         (mult:SI (match_operand:SI 1 "general_operand" "%0")
2945                  (match_operand:SI 2 "general_operand" "d<Q>")))]
2946   "TARGET_COLDFIRE"
2947   "muls%.l %2,%0"
2948   [(set_attr "type" "mul_l")
2949    (set_attr "opy" "2")])
2951 (define_insn "umulhisi3"
2952   [(set (match_operand:SI 0 "nonimmediate_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_src_operand" "dmS"))))]
2957   ""
2959   return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2961   [(set_attr "type" "mul_w")
2962    (set_attr "opy" "2")])
2964 (define_insn "*mulhisisi3_z"
2965   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
2966         (mult:SI (zero_extend:SI
2967                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
2968                  (match_operand:SI 2 "const_int_operand" "n")))]
2969   "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
2971   return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
2973   [(set_attr "type" "mul_w")
2974    (set_attr "opy" "2")])
2976 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
2977 ;; proper matching constraint.  This is because the matching is between
2978 ;; the high-numbered word of the DImode operand[0] and operand[1].
2979 (define_expand "umulsidi3"
2980   [(parallel
2981     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
2982           (mult:SI (match_operand:SI 1 "register_operand" "")
2983                    (match_operand:SI 2 "register_operand" "")))
2984      (set (subreg:SI (match_dup 0) 0)
2985           (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2986                                              (zero_extend:DI (match_dup 2)))
2987                                     (const_int 32))))])]
2988   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
2989   "")
2991 (define_insn ""
2992   [(set (match_operand:SI 0 "register_operand" "=d")
2993         (mult:SI (match_operand:SI 1 "register_operand" "%0")
2994                   (match_operand:SI 2 "nonimmediate_operand" "dm")))
2995    (set (match_operand:SI 3 "register_operand" "=d")
2996         (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
2997                                            (zero_extend:DI (match_dup 2)))
2998                                   (const_int 32))))]
2999   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3000   "mulu%.l %2,%3:%0")
3002 ; Match immediate case.  For 2.4 only match things < 2^31.
3003 ; It's tricky with larger values in these patterns since we need to match
3004 ; values between the two parallel multiplies, between a CONST_DOUBLE and
3005 ; a CONST_INT.
3006 (define_insn ""
3007   [(set (match_operand:SI 0 "register_operand" "=d")
3008         (mult:SI (match_operand:SI 1 "register_operand" "%0")
3009                  (match_operand:SI 2 "const_int_operand" "n")))
3010    (set (match_operand:SI 3 "register_operand" "=d")
3011         (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3012                                            (match_dup 2))
3013                                   (const_int 32))))]
3014   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
3015    && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
3016   "mulu%.l %2,%3:%0")
3018 (define_expand "mulsidi3"
3019   [(parallel
3020     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3021           (mult:SI (match_operand:SI 1 "register_operand" "")
3022                    (match_operand:SI 2 "register_operand" "")))
3023      (set (subreg:SI (match_dup 0) 0)
3024           (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3025                                              (sign_extend:DI (match_dup 2)))
3026                                     (const_int 32))))])]
3027   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3028   "")
3030 (define_insn ""
3031   [(set (match_operand:SI 0 "register_operand" "=d")
3032         (mult:SI (match_operand:SI 1 "register_operand" "%0")
3033                  (match_operand:SI 2 "nonimmediate_operand" "dm")))
3034    (set (match_operand:SI 3 "register_operand" "=d")
3035         (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3036                                            (sign_extend:DI (match_dup 2)))
3037                                   (const_int 32))))]
3038   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3039   "muls%.l %2,%3:%0")
3041 (define_insn ""
3042   [(set (match_operand:SI 0 "register_operand" "=d")
3043         (mult:SI (match_operand:SI 1 "register_operand" "%0")
3044                  (match_operand:SI 2 "const_int_operand" "n")))
3045    (set (match_operand:SI 3 "register_operand" "=d")
3046         (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3047                                            (match_dup 2))
3048                                   (const_int 32))))]
3049   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3050   "muls%.l %2,%3:%0")
3052 (define_expand "umulsi3_highpart"
3053   [(parallel
3054     [(set (match_operand:SI 0 "register_operand" "")
3055           (truncate:SI
3056            (lshiftrt:DI
3057             (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
3058                      (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
3059             (const_int 32))))
3060      (clobber (match_dup 3))])]
3061   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3063   operands[3] = gen_reg_rtx (SImode);
3065   if (GET_CODE (operands[2]) == CONST_INT)
3066     {
3067       operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
3068                                         0, DImode);
3070       /* We have to adjust the operand order for the matching constraints.  */
3071       emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
3072                                              operands[1], operands[2]));
3073       DONE;
3074     }
3077 (define_insn ""
3078   [(set (match_operand:SI 0 "register_operand" "=d")
3079         (truncate:SI
3080          (lshiftrt:DI
3081           (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3082                    (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3083           (const_int 32))))
3084    (clobber (match_operand:SI 1 "register_operand" "=d"))]
3085   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3086   "mulu%.l %3,%0:%1")
3088 (define_insn "const_umulsi3_highpart"
3089   [(set (match_operand:SI 0 "register_operand" "=d")
3090         (truncate:SI
3091          (lshiftrt:DI
3092           (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
3093                    (match_operand:DI 3 "const_uint32_operand" "n"))
3094           (const_int 32))))
3095    (clobber (match_operand:SI 1 "register_operand" "=d"))]
3096   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3097   "mulu%.l %3,%0:%1")
3099 (define_expand "smulsi3_highpart"
3100   [(parallel
3101     [(set (match_operand:SI 0 "register_operand" "")
3102           (truncate:SI
3103            (lshiftrt:DI
3104             (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
3105                      (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
3106             (const_int 32))))
3107      (clobber (match_dup 3))])]
3108   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3110   operands[3] = gen_reg_rtx (SImode);
3111   if (GET_CODE (operands[2]) == CONST_INT)
3112     {
3113       /* We have to adjust the operand order for the matching constraints.  */
3114       emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
3115                                              operands[1], operands[2]));
3116       DONE;
3117     }
3120 (define_insn ""
3121   [(set (match_operand:SI 0 "register_operand" "=d")
3122         (truncate:SI
3123          (lshiftrt:DI
3124           (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3125                    (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3126           (const_int 32))))
3127    (clobber (match_operand:SI 1 "register_operand" "=d"))]
3128   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3129   "muls%.l %3,%0:%1")
3131 (define_insn "const_smulsi3_highpart"
3132   [(set (match_operand:SI 0 "register_operand" "=d")
3133         (truncate:SI
3134          (lshiftrt:DI
3135           (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
3136                    (match_operand:DI 3 "const_sint32_operand" "n"))
3137           (const_int 32))))
3138    (clobber (match_operand:SI 1 "register_operand" "=d"))]
3139   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3140   "muls%.l %3,%0:%1")
3142 (define_expand "mul<mode>3"
3143   [(set (match_operand:FP 0 "nonimmediate_operand" "")
3144         (mult:FP (match_operand:FP 1 "general_operand" "")
3145                  (match_operand:FP 2 "general_operand" "")))]
3146   "TARGET_HARD_FLOAT"
3147   "")
3149 (define_insn "mul<mode>3_floatsi_68881"
3150   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3151         (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
3152                  (match_operand:FP 1 "general_operand" "0")))]
3153   "TARGET_68881"
3155   return TARGET_68040
3156          ? "f<FP:round>mul%.l %2,%0"
3157          : "f<FP:round_mul>mul%.l %2,%0";
3159   [(set_attr "type" "fmul")
3160    (set_attr "opy" "2")])
3162 (define_insn "mul<mode>3_floathi_68881"
3163   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3164         (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
3165                  (match_operand:FP 1 "general_operand" "0")))]
3166   "TARGET_68881"
3168   return TARGET_68040
3169          ? "f<FP:round>mul%.w %2,%0"
3170          : "f<FP:round_mul>mul%.w %2,%0";
3172   [(set_attr "type" "fmul")
3173    (set_attr "opy" "2")])
3175 (define_insn "mul<mode>3_floatqi_68881"
3176   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3177         (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
3178                  (match_operand:FP 1 "general_operand" "0")))]
3179   "TARGET_68881"
3181   return TARGET_68040
3182          ? "f<FP:round>mul%.b %2,%0"
3183          : "f<FP:round_mul>mul%.b %2,%0";
3185   [(set_attr "type" "fmul")
3186    (set_attr "opy" "2")])
3188 (define_insn "muldf_68881"
3189   [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3190         (mult:DF (match_operand:DF 1 "general_operand" "%0")
3191                  (match_operand:DF 2 "general_operand" "fmG")))]
3192   "TARGET_68881"
3194   if (GET_CODE (operands[2]) == CONST_DOUBLE
3195       && floating_exact_log2 (operands[2]) && !TUNE_68040_60)
3196     {
3197       int i = floating_exact_log2 (operands[2]);
3198       operands[2] = GEN_INT (i);
3199       return "fscale%.l %2,%0";
3200     }
3201   if (REG_P (operands[2]))
3202     return "f%&mul%.x %2,%0";
3203   return "f%&mul%.d %f2,%0";
3206 (define_insn "mulsf_68881"
3207   [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3208         (mult:SF (match_operand:SF 1 "general_operand" "%0")
3209                  (match_operand:SF 2 "general_operand" "fdmF")))]
3210   "TARGET_68881"
3212   if (FP_REG_P (operands[2]))
3213     return (TARGET_68040
3214             ? "fsmul%.x %2,%0"
3215             : "fsglmul%.x %2,%0");
3216   return (TARGET_68040
3217           ? "fsmul%.s %f2,%0"
3218           : "fsglmul%.s %f2,%0");
3221 (define_insn "mulxf3_68881"
3222   [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
3223         (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
3224                  (match_operand:XF 2 "nonimmediate_operand" "fm")))]
3225   "TARGET_68881"
3227   return "fmul%.x %f2,%0";
3230 (define_insn "fmul<mode>3_cf"
3231   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3232         (mult:FP (match_operand:FP 1 "general_operand" "%0")
3233                  (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3234   "TARGET_COLDFIRE_FPU"
3236   if (FP_REG_P (operands[2]))
3237     return "f<FP:prec>mul%.d %2,%0";
3238   return "f<FP:prec>mul%.<FP:prec> %2,%0";
3240   [(set_attr "type" "fmul")
3241    (set_attr "opy" "2")])
3243 ;; divide instructions
3245 (define_expand "div<mode>3"
3246   [(set (match_operand:FP 0 "nonimmediate_operand" "")
3247         (div:FP (match_operand:FP 1 "general_operand" "")
3248                 (match_operand:FP 2 "general_operand" "")))]
3249   "TARGET_HARD_FLOAT"
3250   "")
3252 (define_insn "div<mode>3_floatsi_68881"
3253   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3254         (div:FP (match_operand:FP 1 "general_operand" "0")
3255                 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
3256   "TARGET_68881"
3258   return TARGET_68040
3259          ? "f<FP:round>div%.l %2,%0"
3260          : "f<FP:round_mul>div%.l %2,%0";
3263 (define_insn "div<mode>3_floathi_68881"
3264   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3265         (div:FP (match_operand:FP 1 "general_operand" "0")
3266                 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
3267   "TARGET_68881"
3269   return TARGET_68040
3270          ? "f<FP:round>div%.w %2,%0"
3271          : "f<FP:round_mul>div%.w %2,%0";
3274 (define_insn "div<mode>3_floatqi_68881"
3275   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3276         (div:FP (match_operand:FP 1 "general_operand" "0")
3277                 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3278   "TARGET_68881"
3280   return TARGET_68040
3281          ? "f<FP:round>div%.b %2,%0"
3282          : "f<FP:round_mul>div%.b %2,%0";
3285 (define_insn "div<mode>3_68881"
3286   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3287         (div:FP (match_operand:FP 1 "general_operand" "0")
3288                 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3289   "TARGET_68881"
3291   if (FP_REG_P (operands[2]))
3292     return (TARGET_68040
3293             ? "f<FP:round>div%.x %2,%0"
3294             : "f<FP:round_mul>div%.x %2,%0");
3295   return (TARGET_68040
3296           ? "f<FP:round>div%.<FP:prec> %f2,%0"
3297           : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
3300 (define_insn "div<mode>3_cf"
3301   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3302         (div:FP (match_operand:FP 1 "general_operand" "0")
3303                 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3304   "TARGET_COLDFIRE_FPU"
3306   if (FP_REG_P (operands[2]))
3307     return "f<FP:prec>div%.d %2,%0";
3308   return "f<FP:prec>div%.<FP:prec> %2,%0";
3310   [(set_attr "type" "fdiv")
3311    (set_attr "opy" "2")])
3313 ;; Remainder instructions.
3315 (define_expand "divmodsi4"
3316   [(parallel
3317     [(set (match_operand:SI 0 "nonimmediate_operand" "")
3318           (div:SI (match_operand:SI 1 "general_operand" "")
3319                   (match_operand:SI 2 "general_src_operand" "")))
3320      (set (match_operand:SI 3 "nonimmediate_operand" "")
3321           (mod:SI (match_dup 1) (match_dup 2)))])]
3322   "TARGET_68020 || TARGET_CF_HWDIV"
3323   "")
3325 (define_insn ""
3326   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3327         (div:SI (match_operand:SI 1 "general_operand" "0")
3328                 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3329    (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3330         (mod:SI (match_dup 1) (match_dup 2)))]
3331   "TARGET_CF_HWDIV"
3333   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3334     return "divs%.l %2,%0";
3335   else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3336     return "rems%.l %2,%3:%0";
3337   else
3338     return "rems%.l %2,%3:%0\;divs%.l %2,%0";
3340   [(set_attr "type" "div_l")
3341    (set_attr "opy" "2")])
3343 (define_insn ""
3344   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3345         (div:SI (match_operand:SI 1 "general_operand" "0")
3346                 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3347    (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3348         (mod:SI (match_dup 1) (match_dup 2)))]
3349   "TARGET_68020"
3351   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3352     return "divs%.l %2,%0";
3353   else
3354     return "divsl%.l %2,%3:%0";
3357 (define_expand "udivmodsi4"
3358   [(parallel
3359     [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3360           (udiv:SI (match_operand:SI 1 "general_operand" "0")
3361                    (match_operand:SI 2 "general_src_operand" "dmSTK")))
3362      (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3363           (umod:SI (match_dup 1) (match_dup 2)))])]
3364   "TARGET_68020 || TARGET_CF_HWDIV"
3365   "")
3367 (define_insn ""
3368   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3369         (udiv:SI (match_operand:SI 1 "general_operand" "0")
3370                  (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3371    (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3372         (umod:SI (match_dup 1) (match_dup 2)))]
3373   "TARGET_CF_HWDIV"
3375   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3376     return "divu%.l %2,%0";
3377   else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3378     return "remu%.l %2,%3:%0";
3379   else
3380     return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3382   [(set_attr "type" "div_l")
3383    (set_attr "opy" "2")])
3385 (define_insn ""
3386   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3387         (udiv:SI (match_operand:SI 1 "general_operand" "0")
3388                  (match_operand:SI 2 "general_src_operand" "dmSTK")))
3389    (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3390         (umod:SI (match_dup 1) (match_dup 2)))]
3391   "TARGET_68020 && !TARGET_COLDFIRE"
3393   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3394     return "divu%.l %2,%0";
3395   else
3396     return "divul%.l %2,%3:%0";
3399 (define_insn "divmodhi4"
3400   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3401         (div:HI (match_operand:HI 1 "general_operand" "0")
3402                 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3403    (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3404         (mod:HI (match_dup 1) (match_dup 2)))]
3405   "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3407   output_asm_insn (MOTOROLA ?
3408     "ext%.l %0\;divs%.w %2,%0" :
3409     "extl %0\;divs %2,%0",
3410     operands);
3411   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3412     {
3413       CC_STATUS_INIT;
3414       return "move%.l %0,%3\;swap %3";
3415     }
3416   else
3417     return "";
3420 (define_insn "udivmodhi4"
3421   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3422         (udiv:HI (match_operand:HI 1 "general_operand" "0")
3423                  (match_operand:HI 2 "general_src_operand" "dmSKT")))
3424    (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3425         (umod:HI (match_dup 1) (match_dup 2)))]
3426   "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3428   if (ISA_HAS_MVS_MVZ)
3429     output_asm_insn (MOTOROLA ?
3430       "mvz%.w %0,%0\;divu%.w %2,%0" :
3431       "mvz%.w %0,%0\;divu %2,%0",
3432       operands);
3433   else
3434     output_asm_insn (MOTOROLA ?
3435       "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3436       "and%.l #0xFFFF,%0\;divu %2,%0",
3437       operands);
3439   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3440     {
3441       CC_STATUS_INIT;
3442       return "move%.l %0,%3\;swap %3";
3443     }
3444   else
3445     return "";
3448 ;; logical-and instructions
3450 ;; "anddi3" is mainly here to help combine().
3451 (define_insn "anddi3"
3452   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3453         (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3454                 (match_operand:DI 2 "general_operand" "dn,don")))]
3455   "!TARGET_COLDFIRE"
3457   CC_STATUS_INIT;
3458   /* We can get CONST_DOUBLE, but also const1_rtx etc.  */
3459   if (CONSTANT_P (operands[2]))
3460     {
3461       rtx hi, lo;
3463       split_double (operands[2], &hi, &lo);
3465       switch (INTVAL (hi))
3466         {
3467           case 0 :
3468             output_asm_insn ("clr%.l %0", operands);
3469             break;
3470           case -1 :
3471             break;
3472           default :
3473             {
3474             rtx xoperands[3];
3476             xoperands[0] = operands[0];
3477             xoperands[2] = hi;
3478             output_asm_insn (output_andsi3 (xoperands), xoperands);
3479             }
3480         }
3481       if (GET_CODE (operands[0]) == REG)
3482         operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3483       else
3484         operands[0] = adjust_address (operands[0], SImode, 4);
3485       switch (INTVAL (lo))
3486         {
3487           case 0 :
3488             output_asm_insn ("clr%.l %0", operands);
3489             break;
3490           case -1 :
3491             break;
3492           default :
3493             {
3494             rtx xoperands[3];
3496             xoperands[0] = operands[0];
3497             xoperands[2] = lo;
3498             output_asm_insn (output_andsi3 (xoperands), xoperands);
3499             }
3500         }
3501       return "";
3502     }
3503   if (GET_CODE (operands[0]) != REG)
3504     {
3505       operands[1] = adjust_address (operands[0], SImode, 4);
3506       return "and%.l %2,%0\;and%.l %R2,%1";
3507     }
3508   if (GET_CODE (operands[2]) != REG)
3509     {
3510       operands[1] = adjust_address (operands[2], SImode, 4);
3511       return "and%.l %2,%0\;and%.l %1,%R0";
3512     }
3513   return "and%.l %2,%0\;and%.l %R2,%R0";
3516 ;; Prevent AND from being made with sp.  This doesn't exist in the machine
3517 ;; and reload will cause inefficient code.  Since sp is a FIXED_REG, we
3518 ;; can't allocate pseudos into it.
3520 (define_expand "andsi3"
3521   [(set (match_operand:SI 0 "not_sp_operand" "")
3522         (and:SI (match_operand:SI 1 "general_operand" "")
3523                 (match_operand:SI 2 "general_src_operand" "")))]
3524   ""
3525   "")
3527 ;; produced by split operations after reload finished
3528 (define_insn "*andsi3_split"
3529   [(set (match_operand:SI 0 "register_operand" "=d")
3530         (and:SI (match_operand:SI 1 "register_operand" "0")
3531                 (match_operand:SI 2 "const_int_operand" "i")))]
3532   "reload_completed && !TARGET_COLDFIRE"
3534   return output_andsi3 (operands);
3537 (define_insn "andsi3_internal"
3538   [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3539         (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3540                 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3541   "!TARGET_COLDFIRE"
3543   return output_andsi3 (operands);
3546 (define_insn "andsi3_5200"
3547   [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3548         (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3549                 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3550   "TARGET_COLDFIRE"
3552   if (ISA_HAS_MVS_MVZ
3553       && DATA_REG_P (operands[0])
3554       && GET_CODE (operands[2]) == CONST_INT)
3555     {
3556       if (INTVAL (operands[2]) == 0x000000ff)
3557         return "mvz%.b %0,%0";
3558       else if (INTVAL (operands[2]) == 0x0000ffff)
3559         return "mvz%.w %0,%0";
3560     }
3561   return output_andsi3 (operands);
3564 (define_insn "andhi3"
3565   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3566         (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3567                 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3568   "!TARGET_COLDFIRE"
3569   "and%.w %2,%0")
3571 (define_insn ""
3572   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3573         (and:HI (match_dup 0)
3574                 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3575   "!TARGET_COLDFIRE"
3576   "and%.w %1,%0")
3578 (define_insn ""
3579   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3580         (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3581                 (match_dup 0)))]
3582   "!TARGET_COLDFIRE"
3583   "and%.w %1,%0")
3585 (define_insn "andqi3"
3586   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3587         (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3588                 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3589   "!TARGET_COLDFIRE"
3590   "and%.b %2,%0")
3592 (define_insn ""
3593   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3594         (and:QI (match_dup 0)
3595                 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3596   "!TARGET_COLDFIRE"
3597   "and%.b %1,%0")
3599 (define_insn ""
3600   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3601         (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3602                 (match_dup 0)))]
3603   "!TARGET_COLDFIRE"
3604   "and%.b %1,%0")
3606 ;; inclusive-or instructions
3608 (define_insn "iordi_zext"
3609   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3610     (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3611         (match_operand:DI 2 "general_operand" "0,0")))]
3612   "!TARGET_COLDFIRE"
3614   int byte_mode;
3616   CC_STATUS_INIT;
3617   if (GET_CODE (operands[0]) == REG)
3618     operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3619   else
3620     operands[0] = adjust_address (operands[0], SImode, 4);
3621   if (GET_MODE (operands[1]) == SImode)
3622     return "or%.l %1,%0";
3623   byte_mode = (GET_MODE (operands[1]) == QImode);
3624   if (GET_CODE (operands[0]) == MEM)
3625     operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3626                                   byte_mode ? 3 : 2);
3627   if (byte_mode)
3628     return "or%.b %1,%0";
3629   else
3630     return "or%.w %1,%0";
3633 ;; "iordi3" is mainly here to help combine().
3634 (define_insn "iordi3"
3635   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3636         (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3637                 (match_operand:DI 2 "general_operand" "dn,don")))]
3638   "!TARGET_COLDFIRE"
3640   CC_STATUS_INIT;
3641   /* We can get CONST_DOUBLE, but also const1_rtx etc.  */
3642   if (CONSTANT_P (operands[2]))
3643     {
3644       rtx hi, lo;
3646       split_double (operands[2], &hi, &lo);
3648       switch (INTVAL (hi))
3649         {
3650           case 0 :
3651             break;
3652           case -1 :
3653             /* FIXME : a scratch register would be welcome here if operand[0]
3654                is not a register */
3655             output_asm_insn ("move%.l #-1,%0", operands);
3656             break;
3657           default :
3658             {
3659             rtx xoperands[3];
3661             xoperands[0] = operands[0];
3662             xoperands[2] = hi;
3663             output_asm_insn (output_iorsi3 (xoperands), xoperands);
3664             }
3665         }
3666       if (GET_CODE (operands[0]) == REG)
3667         operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3668       else
3669         operands[0] = adjust_address (operands[0], SImode, 4);
3670       switch (INTVAL (lo))
3671         {
3672           case 0 :
3673             break;
3674           case -1 :
3675             /* FIXME : a scratch register would be welcome here if operand[0]
3676                is not a register */
3677             output_asm_insn ("move%.l #-1,%0", operands);
3678             break;
3679           default :
3680             {
3681             rtx xoperands[3];
3683             xoperands[0] = operands[0];
3684             xoperands[2] = lo;
3685             output_asm_insn (output_iorsi3 (xoperands), xoperands);
3686             }
3687         }
3688       return "";
3689     }
3690   if (GET_CODE (operands[0]) != REG)
3691     {
3692       operands[1] = adjust_address (operands[0], SImode, 4);
3693       return "or%.l %2,%0\;or%.l %R2,%1";
3694     }
3695   if (GET_CODE (operands[2]) != REG)
3696     {
3697       operands[1] = adjust_address (operands[2], SImode, 4);
3698       return "or%.l %2,%0\;or%.l %1,%R0";
3699     }
3700   return "or%.l %2,%0\;or%.l %R2,%R0";
3703 (define_expand "iorsi3"
3704   [(set (match_operand:SI 0 "nonimmediate_operand" "")
3705         (ior:SI (match_operand:SI 1 "general_operand" "")
3706                 (match_operand:SI 2 "general_src_operand" "")))]
3707   ""
3708   "")
3710 (define_insn "iorsi3_internal"
3711   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3712         (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3713                 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3714   "! TARGET_COLDFIRE"
3716   return output_iorsi3 (operands);
3719 (define_insn "iorsi3_5200"
3720   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3721         (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3722                 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3723   "TARGET_COLDFIRE"
3725   return output_iorsi3 (operands);
3728 (define_insn "iorhi3"
3729   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3730         (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3731                 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3732   "!TARGET_COLDFIRE"
3733   "or%.w %2,%0")
3735 (define_insn ""
3736   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3737         (ior:HI (match_dup 0)
3738                 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3739   "!TARGET_COLDFIRE"
3740   "or%.w %1,%0")
3742 (define_insn ""
3743   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3744         (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3745                 (match_dup 0)))]
3746   "!TARGET_COLDFIRE"
3747   "or%.w %1,%0")
3749 (define_insn "iorqi3"
3750   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3751         (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3752                 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3753   "!TARGET_COLDFIRE"
3754   "or%.b %2,%0")
3756 (define_insn ""
3757   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3758         (ior:QI (match_dup 0)
3759                 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3760   "!TARGET_COLDFIRE"
3761   "or%.b %1,%0")
3763 (define_insn ""
3764   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3765         (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3766                 (match_dup 0)))]
3767   "!TARGET_COLDFIRE"
3768   "or%.b %1,%0")
3770 ;; On all 68k models, this makes faster code in a special case.
3771 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3773 (define_insn "iorsi_zexthi_ashl16"
3774   [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3775     (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3776         (ashift:SI (match_operand:SI 2 "general_operand" "or")
3777             (const_int 16))))]
3778   ""
3780   CC_STATUS_INIT;
3781   if (GET_CODE (operands[2]) != REG)
3782       operands[2] = adjust_address (operands[2], HImode, 2);
3783   if (GET_CODE (operands[2]) != REG
3784   || REGNO (operands[2]) != REGNO (operands[0]))
3785     output_asm_insn ("move%.w %2,%0", operands);
3786   return "swap %0\;mov%.w %1,%0";
3789 (define_insn "iorsi_zext"
3790   [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3791     (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3792         (match_operand:SI 2 "general_operand" "0,0")))]
3793   "!TARGET_COLDFIRE"
3795   int byte_mode;
3797   CC_STATUS_INIT;
3798   byte_mode = (GET_MODE (operands[1]) == QImode);
3799   if (GET_CODE (operands[0]) == MEM)
3800     operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3801                                   byte_mode ? 3 : 2);
3802   if (byte_mode)
3803     return "or%.b %1,%0";
3804   else
3805     return "or%.w %1,%0";
3808 ;; xor instructions
3810 ;; "xordi3" is mainly here to help combine().
3811 (define_insn "xordi3"
3812   [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3813         (xor:DI (match_operand:DI 1 "general_operand" "%0")
3814                 (match_operand:DI 2 "general_operand" "dn")))]
3815   "!TARGET_COLDFIRE"
3817   CC_STATUS_INIT;
3818   /* We can get CONST_DOUBLE, but also const1_rtx etc.  */
3820   if (CONSTANT_P (operands[2]))
3821     {
3822       rtx hi, lo;
3824       split_double (operands[2], &hi, &lo);
3826       switch (INTVAL (hi))
3827         {
3828           case 0 :
3829             break;
3830           case -1 :
3831             output_asm_insn ("not%.l %0", operands);
3832             break;
3833           default :
3834             /* FIXME : a scratch register would be welcome here if
3835                -128 <= INTVAL (hi) < -1 */
3836             {
3837             rtx xoperands[3];
3839             xoperands[0] = operands[0];
3840             xoperands[2] = hi;
3841             output_asm_insn (output_xorsi3 (xoperands), xoperands);
3842             }
3843         }
3844       if (GET_CODE (operands[0]) == REG)
3845         operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3846       else
3847         operands[0] = adjust_address (operands[0], SImode, 4);
3848       switch (INTVAL (lo))
3849         {
3850           case 0 :
3851             break;
3852           case -1 :
3853             output_asm_insn ("not%.l %0", operands);
3854             break;
3855           default :
3856             /* FIXME : a scratch register would be welcome here if
3857                -128 <= INTVAL (lo) < -1 */
3858             operands[2] = lo;
3859             /* FIXME : this should be merged with xorsi3 */
3860             {
3861             rtx xoperands[3];
3863             xoperands[0] = operands[0];
3864             xoperands[2] = lo;
3865             output_asm_insn (output_xorsi3 (xoperands), xoperands);
3866             }
3867         }
3868       return "";
3869     }
3870   if (GET_CODE (operands[0]) != REG)
3871     {
3872       operands[1] = adjust_address (operands[0], SImode, 4);
3873       return "eor%.l %2,%0\;eor%.l %R2,%1";
3874     }
3875   if (GET_CODE (operands[2]) != REG)
3876     {
3877       operands[1] = adjust_address (operands[2], SImode, 4);
3878       return "eor%.l %2,%0\;eor%.l %1,%R0";
3879     }
3880   return "eor%.l %2,%0\;eor%.l %R2,%R0";
3883 (define_expand "xorsi3"
3884   [(set (match_operand:SI 0 "nonimmediate_operand" "")
3885         (xor:SI (match_operand:SI 1 "general_operand" "")
3886                 (match_operand:SI 2 "general_operand" "")))]
3887   ""
3888   "")
3890 (define_insn "xorsi3_internal"
3891   [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3892         (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3893                 (match_operand:SI 2 "general_operand" "di,dKT")))]
3895   "!TARGET_COLDFIRE"
3897   return output_xorsi3 (operands);
3900 (define_insn "xorsi3_5200"
3901   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3902         (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3903                 (match_operand:SI 2 "general_operand" "d,Ks")))]
3904   "TARGET_COLDFIRE"
3906   return output_xorsi3 (operands);
3909 (define_insn "xorhi3"
3910   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3911         (xor:HI (match_operand:HI 1 "general_operand" "%0")
3912                 (match_operand:HI 2 "general_operand" "dn")))]
3913   "!TARGET_COLDFIRE"
3914   "eor%.w %2,%0")
3916 (define_insn ""
3917   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3918         (xor:HI (match_dup 0)
3919                 (match_operand:HI 1 "general_operand" "dn")))]
3920   "!TARGET_COLDFIRE"
3921   "eor%.w %1,%0")
3923 (define_insn ""
3924   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3925         (xor:HI (match_operand:HI 1 "general_operand" "dn")
3926                 (match_dup 0)))]
3927   "!TARGET_COLDFIRE"
3928   "eor%.w %1,%0")
3930 (define_insn "xorqi3"
3931   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3932         (xor:QI (match_operand:QI 1 "general_operand" "%0")
3933                 (match_operand:QI 2 "general_operand" "dn")))]
3934   "!TARGET_COLDFIRE"
3935   "eor%.b %2,%0")
3937 (define_insn ""
3938   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3939         (xor:QI (match_dup 0)
3940                 (match_operand:QI 1 "general_operand" "dn")))]
3941   "!TARGET_COLDFIRE"
3942   "eor%.b %1,%0")
3944 (define_insn ""
3945   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3946         (xor:QI (match_operand:QI 1 "general_operand" "dn")
3947                 (match_dup 0)))]
3948   "!TARGET_COLDFIRE"
3949   "eor%.b %1,%0")
3951 ;; negation instructions
3953 (define_expand "negdi2"
3954   [(set (match_operand:DI 0 "nonimmediate_operand" "")
3955         (neg:DI (match_operand:DI 1 "general_operand" "")))]
3956   ""
3958   if (TARGET_COLDFIRE)
3959     emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3960   else
3961     emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3962   DONE;
3965 (define_insn "negdi2_internal"
3966   [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3967         (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3968   "!TARGET_COLDFIRE"
3970   if (which_alternative == 0)
3971     return "neg%.l %0\;negx%.l %0";
3972   if (GET_CODE (operands[0]) == REG)
3973     operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3974   else
3975     operands[1] = adjust_address (operands[0], SImode, 4);
3976   if (ADDRESS_REG_P (operands[0]))
3977     return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3978   else
3979     return "neg%.l %1\;negx%.l %0";
3982 (define_insn "negdi2_5200"
3983   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3984         (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3985   "TARGET_COLDFIRE"
3987   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3988   return "neg%.l %1\;negx%.l %0";
3991 (define_expand "negsi2"
3992   [(set (match_operand:SI 0 "nonimmediate_operand" "")
3993         (neg:SI (match_operand:SI 1 "general_operand" "")))]
3994   ""
3996   if (TARGET_COLDFIRE)
3997     emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3998   else
3999     emit_insn (gen_negsi2_internal (operands[0], operands[1]));
4000   DONE;
4003 (define_insn "negsi2_internal"
4004   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4005         (neg:SI (match_operand:SI 1 "general_operand" "0")))]
4006   "!TARGET_COLDFIRE"
4007   "neg%.l %0"
4008   [(set_attr "type" "neg_l")])
4010 (define_insn "negsi2_5200"
4011   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4012         (neg:SI (match_operand:SI 1 "general_operand" "0")))]
4013   "TARGET_COLDFIRE"
4014   "neg%.l %0"
4015   [(set_attr "type" "neg_l")])
4017 (define_insn "neghi2"
4018   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4019         (neg:HI (match_operand:HI 1 "general_operand" "0")))]
4020   "!TARGET_COLDFIRE"
4021   "neg%.w %0")
4023 (define_insn ""
4024   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4025         (neg:HI (match_dup 0)))]
4026   "!TARGET_COLDFIRE"
4027   "neg%.w %0")
4029 (define_insn "negqi2"
4030   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4031         (neg:QI (match_operand:QI 1 "general_operand" "0")))]
4032   "!TARGET_COLDFIRE"
4033   "neg%.b %0")
4035 (define_insn ""
4036   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4037         (neg:QI (match_dup 0)))]
4038   "!TARGET_COLDFIRE"
4039   "neg%.b %0")
4041 ;; If using software floating point, just flip the sign bit.
4043 (define_expand "negsf2"
4044   [(set (match_operand:SF 0 "nonimmediate_operand" "")
4045         (neg:SF (match_operand:SF 1 "general_operand" "")))]
4046   ""
4048   if (!TARGET_HARD_FLOAT)
4049     {
4050       rtx result;
4051       rtx target;
4053       target = operand_subword_force (operands[0], 0, SFmode);
4054       result = expand_binop (SImode, xor_optab,
4055                              operand_subword_force (operands[1], 0, SFmode),
4056                              GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4057       gcc_assert (result);
4059       if (result != target)
4060         emit_move_insn (result, target);
4062       /* Make a place for REG_EQUAL.  */
4063       emit_move_insn (operands[0], operands[0]);
4064       DONE;
4065     }
4068 (define_expand "negdf2"
4069   [(set (match_operand:DF 0 "nonimmediate_operand" "")
4070         (neg:DF (match_operand:DF 1 "general_operand" "")))]
4071   ""
4073   if (!TARGET_HARD_FLOAT)
4074     {
4075       rtx result;
4076       rtx target;
4077       rtx insns;
4079       start_sequence ();
4080       target = operand_subword (operands[0], 0, 1, DFmode);
4081       result = expand_binop (SImode, xor_optab,
4082                              operand_subword_force (operands[1], 0, DFmode),
4083                              GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4084       gcc_assert (result);
4086       if (result != target)
4087         emit_move_insn (result, target);
4089       emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4090                       operand_subword_force (operands[1], 1, DFmode));
4092       insns = get_insns ();
4093       end_sequence ();
4095       emit_insn (insns);
4096       DONE;
4097     }
4100 (define_expand "negxf2"
4101   [(set (match_operand:XF 0 "nonimmediate_operand" "")
4102         (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4103   ""
4105   if (!TARGET_68881)
4106     {
4107       rtx result;
4108       rtx target;
4109       rtx insns;
4111       start_sequence ();
4112       target = operand_subword (operands[0], 0, 1, XFmode);
4113       result = expand_binop (SImode, xor_optab,
4114                              operand_subword_force (operands[1], 0, XFmode),
4115                              GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4116       gcc_assert (result);
4118       if (result != target)
4119         emit_move_insn (result, target);
4121       emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4122                       operand_subword_force (operands[1], 1, XFmode));
4123       emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4124                       operand_subword_force (operands[1], 2, XFmode));
4126       insns = get_insns ();
4127       end_sequence ();
4129       emit_insn (insns);
4130       DONE;
4131     }
4134 (define_insn "neg<mode>2_68881"
4135   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4136         (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4137   "TARGET_68881"
4139   if (DATA_REG_P (operands[0]))
4140     {
4141       operands[1] = GEN_INT (31);
4142       return "bchg %1,%0";
4143     }
4144   if (FP_REG_P (operands[1]))
4145     return "f<FP:round>neg%.x %1,%0";
4146   return "f<FP:round>neg%.<FP:prec> %f1,%0";
4149 (define_insn "neg<mode>2_cf"
4150   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4151         (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4152   "TARGET_COLDFIRE_FPU"
4154   if (DATA_REG_P (operands[0]))
4155     {
4156       operands[1] = GEN_INT (31);
4157       return "bchg %1,%0";
4158     }
4159   if (FP_REG_P (operands[1]))
4160     return "f<FP:prec>neg%.d %1,%0";
4161   return "f<FP:prec>neg%.<FP:prec> %1,%0";
4164 ;; Sqrt instruction for the 68881
4166 (define_expand "sqrt<mode>2"
4167   [(set (match_operand:FP 0 "nonimmediate_operand" "")
4168         (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
4169   "TARGET_HARD_FLOAT"
4170   "")
4172 (define_insn "sqrt<mode>2_68881"
4173   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4174         (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
4175   "TARGET_68881"
4177   if (FP_REG_P (operands[1]))
4178     return "f<FP:round>sqrt%.x %1,%0";
4179   return "f<FP:round>sqrt%.<FP:prec> %1,%0";
4181   [(set_attr "type" "fsqrt")])
4183 (define_insn "sqrt<mode>2_cf"
4184   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4185         (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
4186   "TARGET_COLDFIRE_FPU"
4188   if (FP_REG_P (operands[1]))
4189     return "f<FP:prec>sqrt%.d %1,%0";
4190   return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
4192   [(set_attr "type" "fsqrt")])
4193 ;; Absolute value instructions
4194 ;; If using software floating point, just zero the sign bit.
4196 (define_expand "abssf2"
4197   [(set (match_operand:SF 0 "nonimmediate_operand" "")
4198         (abs:SF (match_operand:SF 1 "general_operand" "")))]
4199   ""
4201   if (!TARGET_HARD_FLOAT)
4202     {
4203       rtx result;
4204       rtx target;
4206       target = operand_subword_force (operands[0], 0, SFmode);
4207       result = expand_binop (SImode, and_optab,
4208                              operand_subword_force (operands[1], 0, SFmode),
4209                              GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4210       gcc_assert (result);
4212       if (result != target)
4213         emit_move_insn (result, target);
4215       /* Make a place for REG_EQUAL.  */
4216       emit_move_insn (operands[0], operands[0]);
4217       DONE;
4218     }
4221 (define_expand "absdf2"
4222   [(set (match_operand:DF 0 "nonimmediate_operand" "")
4223         (abs:DF (match_operand:DF 1 "general_operand" "")))]
4224   ""
4226   if (!TARGET_HARD_FLOAT)
4227     {
4228       rtx result;
4229       rtx target;
4230       rtx insns;
4232       start_sequence ();
4233       target = operand_subword (operands[0], 0, 1, DFmode);
4234       result = expand_binop (SImode, and_optab,
4235                              operand_subword_force (operands[1], 0, DFmode),
4236                              GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4237       gcc_assert (result);
4239       if (result != target)
4240         emit_move_insn (result, target);
4242       emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4243                       operand_subword_force (operands[1], 1, DFmode));
4245       insns = get_insns ();
4246       end_sequence ();
4248       emit_insn (insns);
4249       DONE;
4250     }
4253 (define_expand "absxf2"
4254   [(set (match_operand:XF 0 "nonimmediate_operand" "")
4255         (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4256   ""
4258   if (!TARGET_68881)
4259     {
4260       rtx result;
4261       rtx target;
4262       rtx insns;
4264       start_sequence ();
4265       target = operand_subword (operands[0], 0, 1, XFmode);
4266       result = expand_binop (SImode, and_optab,
4267                              operand_subword_force (operands[1], 0, XFmode),
4268                              GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4269       gcc_assert (result);
4271       if (result != target)
4272         emit_move_insn (result, target);
4274       emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4275                       operand_subword_force (operands[1], 1, XFmode));
4276       emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4277                       operand_subword_force (operands[1], 2, XFmode));
4279       insns = get_insns ();
4280       end_sequence ();
4282       emit_insn (insns);
4283       DONE;
4284     }
4287 (define_insn "abs<mode>2_68881"
4288   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4289         (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4290   "TARGET_68881"
4292   if (DATA_REG_P (operands[0]))
4293     {
4294       operands[1] = GEN_INT (31);
4295       return "bclr %1,%0";
4296     }
4297   if (FP_REG_P (operands[1]))
4298     return "f<FP:round>abs%.x %1,%0";
4299   return "f<FP:round>abs%.<FP:prec> %f1,%0";
4302 (define_insn "abs<mode>2_cf"
4303   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4304         (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4305   "TARGET_COLDFIRE_FPU"
4307   if (DATA_REG_P (operands[0]))
4308     {
4309       operands[1] = GEN_INT (31);
4310       return "bclr %1,%0";
4311     }
4312   if (FP_REG_P (operands[1]))
4313     return "f<FP:prec>abs%.d %1,%0";
4314   return "f<FP:prec>abs%.<FP:prec> %1,%0";
4316   [(set_attr "type" "bitrw,fneg")])
4318 ;; bit indexing instructions
4320 ;; ColdFire ff1 instruction implements clz.
4321 (define_insn "clzsi2"
4322   [(set (match_operand:SI 0 "register_operand" "=d")
4323         (clz:SI (match_operand:SI 1 "register_operand" "0")))]
4324   "ISA_HAS_FF1"
4325   "ff1 %0"
4326   [(set_attr "type" "ext")])
4328 ;; one complement instructions
4330 ;; "one_cmpldi2" is mainly here to help combine().
4331 (define_insn "one_cmpldi2"
4332   [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
4333         (not:DI (match_operand:DI 1 "general_operand" "0")))]
4334   "!TARGET_COLDFIRE"
4336   CC_STATUS_INIT;
4337   if (GET_CODE (operands[0]) == REG)
4338     operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4339   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
4340         || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4341     operands[1] = operands[0];
4342   else
4343     operands[1] = adjust_address (operands[0], SImode, 4);
4344   return "not%.l %1\;not%.l %0";
4347 (define_expand "one_cmplsi2"
4348   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4349         (not:SI (match_operand:SI 1 "general_operand" "")))]
4350   ""
4352   if (TARGET_COLDFIRE)
4353     emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
4354   else
4355     emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
4356   DONE;
4359 (define_insn "one_cmplsi2_internal"
4360   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4361         (not:SI (match_operand:SI 1 "general_operand" "0")))]
4362   "!TARGET_COLDFIRE"
4363   "not%.l %0")
4365 (define_insn "one_cmplsi2_5200"
4366   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4367         (not:SI (match_operand:SI 1 "general_operand" "0")))]
4368   "TARGET_COLDFIRE"
4369   "not%.l %0"
4370   [(set_attr "type" "neg_l")])
4372 (define_insn "one_cmplhi2"
4373   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4374         (not:HI (match_operand:HI 1 "general_operand" "0")))]
4375   "!TARGET_COLDFIRE"
4376   "not%.w %0")
4378 (define_insn ""
4379   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4380         (not:HI (match_dup 0)))]
4381   "!TARGET_COLDFIRE"
4382   "not%.w %0")
4384 (define_insn "one_cmplqi2"
4385   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4386         (not:QI (match_operand:QI 1 "general_operand" "0")))]
4387   "!TARGET_COLDFIRE"
4388   "not%.b %0")
4390 (define_insn ""
4391   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4392         (not:QI (match_dup 0)))]
4393   "!TARGET_COLDFIRE"
4394   "not%.b %0")
4396 ;; arithmetic shift instructions
4397 ;; We don't need the shift memory by 1 bit instruction
4399 (define_insn "ashldi_extsi"
4400   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4401     (ashift:DI
4402       (match_operator:DI 2 "extend_operator"
4403         [(match_operand:SI 1 "general_operand" "rm")])
4404       (const_int 32)))]
4405   ""
4407   CC_STATUS_INIT;
4408   if (GET_CODE (operands[0]) == REG)
4409     operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4410   else
4411     operands[2] = adjust_address (operands[0], SImode, 4);
4412   if (ADDRESS_REG_P (operands[0]))
4413     return "move%.l %1,%0\;sub%.l %2,%2";
4414   else
4415     return "move%.l %1,%0\;clr%.l %2";
4418 (define_insn "ashldi_sexthi"
4419   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
4420     (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
4421         (const_int 32)))
4422     (clobber (match_scratch:SI 2 "=a,X"))]
4423   ""
4425   CC_STATUS_INIT;
4426   if (GET_CODE (operands[0]) == MEM)
4427     {
4428     if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4429       return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
4430     else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4431       return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
4432     else
4433       {
4434         operands[3] = adjust_address (operands[0], SImode, 4);
4435         return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
4436       }
4437     }
4438   else if (DATA_REG_P (operands[0]))
4439     return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
4440   else
4441     return "move%.w %1,%0\;sub%.l %R0,%R0";
4444 (define_insn "*ashldi3_const1"
4445   [(set (match_operand:DI 0 "register_operand" "=d")
4446         (ashift:DI (match_operand:DI 1 "register_operand" "0")
4447                    (const_int 1)))]
4448   "!TARGET_COLDFIRE"
4449   "add%.l %R0,%R0\;addx%.l %0,%0")
4451 (define_split
4452   [(set (match_operand:DI 0 "register_operand" "")
4453         (ashift:DI (match_operand:DI 1 "register_operand" "")
4454                    (const_int 2)))]
4455   "reload_completed && !TARGET_COLDFIRE"
4456   [(set (match_dup 0)
4457         (ashift:DI (match_dup 1) (const_int 1)))
4458    (set (match_dup 0)
4459         (ashift:DI (match_dup 0) (const_int 1)))]
4460   "")
4462 (define_split
4463   [(set (match_operand:DI 0 "register_operand" "")
4464         (ashift:DI (match_operand:DI 1 "register_operand" "")
4465                    (const_int 3)))]
4466   "reload_completed && !TARGET_COLDFIRE"
4467   [(set (match_dup 0)
4468         (ashift:DI (match_dup 1) (const_int 2)))
4469    (set (match_dup 0)
4470         (ashift:DI (match_dup 0) (const_int 1)))]
4471   "")
4473 (define_split
4474   [(set (match_operand:DI 0 "register_operand" "")
4475         (ashift:DI (match_operand:DI 1 "register_operand" "")
4476                    (const_int 8)))]
4477   "reload_completed && !TARGET_COLDFIRE"
4478   [(set (match_dup 2)
4479         (rotate:SI (match_dup 2) (const_int 8)))
4480    (set (match_dup 3)
4481         (rotate:SI (match_dup 3) (const_int 8)))
4482    (set (strict_low_part (subreg:QI (match_dup 0) 3))
4483         (subreg:QI (match_dup 0) 7))
4484    (set (strict_low_part (subreg:QI (match_dup 0) 7))
4485         (const_int 0))]
4487   operands[2] = gen_highpart (SImode, operands[0]);
4488   operands[3] = gen_lowpart (SImode, operands[0]);
4491 (define_split
4492   [(set (match_operand:DI 0 "register_operand" "")
4493         (ashift:DI (match_operand:DI 1 "register_operand" "")
4494                    (const_int 16)))]
4495   "reload_completed && !TARGET_COLDFIRE"
4496   [(set (match_dup 2)
4497         (rotate:SI (match_dup 2) (const_int 16)))
4498    (set (match_dup 3)
4499         (rotate:SI (match_dup 3) (const_int 16)))
4500    (set (strict_low_part (subreg:HI (match_dup 0) 2))
4501         (subreg:HI (match_dup 0) 6))
4502    (set (strict_low_part (subreg:HI (match_dup 0) 6))
4503         (const_int 0))]
4505   operands[2] = gen_highpart (SImode, operands[0]);
4506   operands[3] = gen_lowpart (SImode, operands[0]);
4509 (define_split
4510   [(set (match_operand:DI 0 "pre_dec_operand" "")
4511         (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4512                    (const_int 32)))]
4513   "reload_completed"
4514   [(set (match_dup 0) (const_int 0))
4515    (set (match_dup 0) (match_dup 1))]
4517   operands[0] = adjust_address(operands[0], SImode, 0);
4518   operands[1] = gen_lowpart(SImode, operands[1]);
4521 (define_split
4522   [(set (match_operand:DI 0 "post_inc_operand" "")
4523         (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4524                    (const_int 32)))]
4525   "reload_completed"
4526   [(set (match_dup 0) (match_dup 1))
4527    (set (match_dup 0) (const_int 0))]
4529   operands[0] = adjust_address(operands[0], SImode, 0);
4530   operands[1] = gen_lowpart(SImode, operands[1]);
4533 (define_insn_and_split "*ashldi3_const32"
4534   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
4535         (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
4536                    (const_int 32)))]
4537   ""
4538   "#"
4539   "&& reload_completed"
4540   [(set (match_dup 4) (match_dup 3))
4541    (set (match_dup 2) (const_int 0))]
4542   "split_di(operands, 2, operands + 2, operands + 4);")
4544 (define_split
4545   [(set (match_operand:DI 0 "register_operand" "")
4546         (ashift:DI (match_operand:DI 1 "register_operand" "")
4547                    (match_operand 2 "const_int_operand" "")))]
4548   "reload_completed && !TARGET_COLDFIRE
4549    && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
4550   [(set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 2)))
4551    (set (match_dup 3) (match_dup 4))
4552    (set (match_dup 4) (const_int 0))]
4554   operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4555   operands[3] = gen_highpart (SImode, operands[0]);
4556   operands[4] = gen_lowpart (SImode, operands[0]);
4559 (define_split
4560   [(set (match_operand:DI 0 "register_operand" "")
4561         (ashift:DI (match_operand:DI 1 "register_operand" "")
4562                    (const_int 48)))]
4563   "reload_completed && !TARGET_COLDFIRE"
4564   [(set (match_dup 2) (match_dup 3))
4565    (set (match_dup 2)
4566         (rotate:SI (match_dup 2) (const_int 16)))
4567    (set (match_dup 3) (const_int 0))
4568    (set (strict_low_part (subreg:HI (match_dup 0) 2))
4569         (const_int 0))]
4571   operands[2] = gen_highpart (SImode, operands[0]);
4572   operands[3] = gen_lowpart (SImode, operands[0]);
4575 (define_split
4576   [(set (match_operand:DI 0 "register_operand" "")
4577         (ashift:DI (match_operand:DI 1 "register_operand" "")
4578                    (match_operand 2 "const_int_operand" "")))]
4579   "reload_completed && !TARGET_COLDFIRE
4580    && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 63"
4581   [(set (match_dup 3) (match_dup 2))
4582    (set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 3)))
4583    (set (match_dup 3) (match_dup 4))
4584    (set (match_dup 4) (const_int 0))]
4586   operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4587   operands[3] = gen_highpart (SImode, operands[0]);
4588   operands[4] = gen_lowpart (SImode, operands[0]);
4591 (define_insn "*ashldi3"
4592   [(set (match_operand:DI 0 "register_operand" "=d")
4593         (ashift:DI (match_operand:DI 1 "register_operand" "0")
4594                    (match_operand 2 "const_int_operand" "n")))]
4595   "!TARGET_COLDFIRE
4596     && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4597         || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4598         || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4599   "#")
4601 (define_expand "ashldi3"
4602   [(set (match_operand:DI 0 "register_operand" "")
4603         (ashift:DI (match_operand:DI 1 "register_operand" "")
4604                    (match_operand 2 "const_int_operand" "")))]
4605   "!TARGET_COLDFIRE"
4607   /* ???  This is a named pattern like this is not allowed to FAIL based
4608      on its operands.  */
4609   if (GET_CODE (operands[2]) != CONST_INT
4610       || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4611           && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4612           && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4613     FAIL;
4616 ;; On most 68k models, this makes faster code in a special case.
4618 (define_insn "ashlsi_16"
4619   [(set (match_operand:SI 0 "register_operand" "=d")
4620         (ashift:SI (match_operand:SI 1 "register_operand" "0")
4621                    (const_int 16)))]
4622   "!TUNE_68060"
4624   CC_STATUS_INIT;
4625   return "swap %0\;clr%.w %0";
4628 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
4629 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4631 ;; On the 68000, this makes faster code in a special case.
4633 (define_insn "ashlsi_17_24"
4634   [(set (match_operand:SI 0 "register_operand" "=d")
4635         (ashift:SI (match_operand:SI 1 "register_operand" "0")
4636                    (match_operand:SI 2 "const_int_operand" "n")))]
4637   "TUNE_68000_10
4638    && INTVAL (operands[2]) > 16
4639    && INTVAL (operands[2]) <= 24"
4641   CC_STATUS_INIT;
4643   operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4644   return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4647 (define_insn "ashlsi3"
4648   [(set (match_operand:SI 0 "register_operand" "=d")
4649         (ashift:SI (match_operand:SI 1 "register_operand" "0")
4650                    (match_operand:SI 2 "general_operand" "dI")))]
4651   ""
4653   if (operands[2] == const1_rtx)
4654     {
4655       cc_status.flags = CC_NO_OVERFLOW;
4656       return "add%.l %0,%0";
4657     }
4658   return "lsl%.l %2,%0";
4661 (define_insn "ashlhi3"
4662   [(set (match_operand:HI 0 "register_operand" "=d")
4663         (ashift:HI (match_operand:HI 1 "register_operand" "0")
4664                    (match_operand:HI 2 "general_operand" "dI")))]
4665   "!TARGET_COLDFIRE"
4666   "lsl%.w %2,%0")
4668 (define_insn ""
4669   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4670         (ashift:HI (match_dup 0)
4671                    (match_operand:HI 1 "general_operand" "dI")))]
4672   "!TARGET_COLDFIRE"
4673   "lsl%.w %1,%0")
4675 (define_insn "ashlqi3"
4676   [(set (match_operand:QI 0 "register_operand" "=d")
4677         (ashift:QI (match_operand:QI 1 "register_operand" "0")
4678                    (match_operand:QI 2 "general_operand" "dI")))]
4679   "!TARGET_COLDFIRE"
4680   "lsl%.b %2,%0")
4682 (define_insn ""
4683   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4684         (ashift:QI (match_dup 0)
4685                    (match_operand:QI 1 "general_operand" "dI")))]
4686   "!TARGET_COLDFIRE"
4687   "lsl%.b %1,%0")
4689 ;; On most 68k models, this makes faster code in a special case.
4691 (define_insn "ashrsi_16"
4692   [(set (match_operand:SI 0 "register_operand" "=d")
4693         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4694                      (const_int 16)))]
4695   "!TUNE_68060"
4696   "swap %0\;ext%.l %0")
4698 ;; On the 68000, this makes faster code in a special case.
4700 (define_insn ""
4701   [(set (match_operand:SI 0 "register_operand" "=d")
4702         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4703                      (match_operand:SI 2 "const_int_operand" "n")))]
4704   "TUNE_68000_10
4705    && INTVAL (operands[2]) > 16
4706    && INTVAL (operands[2]) <= 24"
4708   operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4709   return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4712 (define_insn "subreghi1ashrdi_const32"
4713   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4714     (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4715             (const_int 32)) 6))]
4716   ""
4718   if (GET_CODE (operands[1]) != REG)
4719     operands[1] = adjust_address (operands[1], HImode, 2);
4720   return "move%.w %1,%0";
4722   [(set_attr "type" "move")])
4724 (define_insn "subregsi1ashrdi_const32"
4725   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4726     (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4727             (const_int 32)) 4))]
4728   ""
4730   return "move%.l %1,%0";
4732   [(set_attr "type" "move_l")])
4734 (define_insn "*ashrdi3_const1"
4735   [(set (match_operand:DI 0 "register_operand" "=d")
4736         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4737                      (const_int 1)))]
4738   "!TARGET_COLDFIRE"
4740   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4741   return "asr%.l #1,%0\;roxr%.l #1,%1";
4744 (define_split
4745   [(set (match_operand:DI 0 "register_operand" "")
4746         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4747                      (const_int 2)))]
4748   "reload_completed && !TARGET_COLDFIRE"
4749   [(set (match_dup 0)
4750         (ashiftrt:DI (match_dup 1) (const_int 1)))
4751    (set (match_dup 0)
4752         (ashiftrt:DI (match_dup 0) (const_int 1)))]
4753   "")
4755 (define_split
4756   [(set (match_operand:DI 0 "register_operand" "")
4757         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4758                      (const_int 3)))]
4759   "reload_completed && !TARGET_COLDFIRE"
4760   [(set (match_dup 0)
4761         (ashiftrt:DI (match_dup 1) (const_int 2)))
4762    (set (match_dup 0)
4763         (ashiftrt:DI (match_dup 0) (const_int 1)))]
4764   "")
4766 (define_split
4767   [(set (match_operand:DI 0 "register_operand" "")
4768         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4769                      (const_int 8)))]
4770   "reload_completed && !TARGET_COLDFIRE"
4771   [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4772         (subreg:QI (match_dup 0) 3))
4773    (set (match_dup 2)
4774         (ashiftrt:SI (match_dup 2) (const_int 8)))
4775    (set (match_dup 3)
4776         (rotatert:SI (match_dup 3) (const_int 8)))]
4778   operands[2] = gen_highpart (SImode, operands[0]);
4779   operands[3] = gen_lowpart (SImode, operands[0]);
4782 (define_split
4783   [(set (match_operand:DI 0 "register_operand" "")
4784         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4785                      (const_int 16)))]
4786   "reload_completed && !TARGET_COLDFIRE"
4787   [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4788         (subreg:HI (match_dup 0) 2))
4789    (set (match_dup 2)
4790         (rotate:SI (match_dup 2) (const_int 16)))
4791    (set (match_dup 3)
4792         (rotate:SI (match_dup 3) (const_int 16)))
4793    (set (match_dup 2)
4794         (sign_extend:SI (subreg:HI (match_dup 2) 2)))]
4796   operands[2] = gen_highpart (SImode, operands[0]);
4797   operands[3] = gen_lowpart (SImode, operands[0]);
4800 (define_insn "*ashrdi_const32"
4801   [(set (match_operand:DI 0 "register_operand" "=d")
4802         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro")
4803                      (const_int 32)))]
4804   ""
4806   CC_STATUS_INIT;
4807   if (TARGET_68020)
4808     return "move%.l %1,%R0\;smi %0\;extb%.l %0";
4809   else
4810     return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
4813 (define_insn "*ashrdi_const32_mem"
4814   [(set (match_operand:DI 0 "memory_operand" "=o,<")
4815         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro,ro")
4816                      (const_int 32)))
4817    (clobber (match_scratch:SI 2 "=d,d"))]
4818   ""
4820   CC_STATUS_INIT;
4821   operands[3] = adjust_address (operands[0], SImode,
4822                                 which_alternative == 0 ? 4 : 0);
4823   operands[0] = adjust_address (operands[0], SImode, 0);
4824   if (TARGET_68020 || TARGET_COLDFIRE)
4825     return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4826   else
4827     return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4830 (define_split
4831   [(set (match_operand:DI 0 "register_operand" "")
4832         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4833                      (const_int 63)))]
4834   "reload_completed && !TARGET_COLDFIRE"
4835   [(set (match_dup 3)
4836         (ashiftrt:SI (match_dup 3) (const_int 31)))
4837    (set (match_dup 2)
4838         (match_dup 3))]
4839   "split_di(operands, 1, operands + 2, operands + 3);")
4841 ;; The predicate below must be general_operand, because ashrdi3 allows that
4842 (define_insn "ashrdi_const"
4843   [(set (match_operand:DI 0 "register_operand" "=d")
4844         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4845                      (match_operand 2 "const_int_operand" "n")))]
4846   "!TARGET_COLDFIRE
4847     && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4848         || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4849         || INTVAL (operands[2]) == 31
4850         || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4852   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4853   CC_STATUS_INIT;
4854   if (INTVAL (operands[2]) == 48)
4855     return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4856   if (INTVAL (operands[2]) == 31)
4857     return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4858   if (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)
4859     {
4860       operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4861       output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4862                         "moveq %2,%1\;asr%.l %1,%0", operands);
4863       output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4864       return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4865              TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4866     }
4867   return "#";
4870 (define_expand "ashrdi3"
4871   [(set (match_operand:DI 0 "register_operand" "")
4872         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4873                      (match_operand 2 "const_int_operand" "")))]
4874   "!TARGET_COLDFIRE"
4876   /* ???  This is a named pattern like this is not allowed to FAIL based
4877      on its operands.  */
4878   if (GET_CODE (operands[2]) != CONST_INT
4879       || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4880           && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4881           && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4882     FAIL;
4885 ;; On all 68k models, this makes faster code in a special case.
4887 (define_insn "ashrsi_31"
4888   [(set (match_operand:SI 0 "register_operand" "=d")
4889         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4890                      (const_int 31)))]
4891   ""
4893   return "add%.l %0,%0\;subx%.l %0,%0";
4896 (define_insn "ashrsi3"
4897   [(set (match_operand:SI 0 "register_operand" "=d")
4898         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4899                      (match_operand:SI 2 "general_operand" "dI")))]
4900   ""
4901   "asr%.l %2,%0"
4902   [(set_attr "type" "shift")
4903    (set_attr "opy" "2")])
4905 (define_insn "ashrhi3"
4906   [(set (match_operand:HI 0 "register_operand" "=d")
4907         (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4908                      (match_operand:HI 2 "general_operand" "dI")))]
4909   "!TARGET_COLDFIRE"
4910   "asr%.w %2,%0")
4912 (define_insn ""
4913   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4914         (ashiftrt:HI (match_dup 0)
4915                      (match_operand:HI 1 "general_operand" "dI")))]
4916   "!TARGET_COLDFIRE"
4917   "asr%.w %1,%0")
4919 (define_insn "ashrqi3"
4920   [(set (match_operand:QI 0 "register_operand" "=d")
4921         (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4922                      (match_operand:QI 2 "general_operand" "dI")))]
4923   "!TARGET_COLDFIRE"
4924   "asr%.b %2,%0")
4926 (define_insn ""
4927   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4928         (ashiftrt:QI (match_dup 0)
4929                      (match_operand:QI 1 "general_operand" "dI")))]
4930   "!TARGET_COLDFIRE"
4931   "asr%.b %1,%0")
4933 ;; logical shift instructions
4935 ;; commented out because of reload problems in 950612-1.c
4936 ;;(define_insn ""
4937 ;;        [(set (cc0)
4938 ;;            (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4939 ;;                    (const_int 32)) 4))
4940 ;;        (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4941 ;;            (subreg:SI (lshiftrt:DI (match_dup 0)
4942 ;;                    (const_int 32)) 4))]
4943 ;;  ""
4945 ;;  return "move%.l %0,%1";
4946 ;;})
4948 ;;(define_insn ""
4949 ;;        [(set (cc0)
4950 ;;            (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4951 ;;                    (const_int 32)) 0))
4952 ;;        (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4953 ;;            (lshiftrt:DI (match_dup 0)
4954 ;;                (const_int 32)))]
4955 ;;  ""
4957 ;;  if (GET_CODE (operands[1]) == REG)
4958 ;;    operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4959 ;;  else
4960 ;;    operands[2] = adjust_address (operands[1], SImode, 4);
4961 ;;  return "move%.l %0,%2\;clr%.l %1";
4962 ;;})
4964 (define_insn "subreg1lshrdi_const32"
4965   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4966     (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4967             (const_int 32)) 4))]
4968   ""
4969   "move%.l %1,%0"
4970   [(set_attr "type" "move_l")])
4972 (define_insn "*lshrdi3_const1"
4973   [(set (match_operand:DI 0 "register_operand" "=d")
4974         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
4975                      (const_int 1)))]
4976   "!TARGET_COLDFIRE"
4977   "lsr%.l #1,%0\;roxr%.l #1,%R0")
4979 (define_split
4980   [(set (match_operand:DI 0 "register_operand" "")
4981         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4982                      (const_int 2)))]
4983   "reload_completed && !TARGET_COLDFIRE"
4984   [(set (match_dup 0)
4985         (lshiftrt:DI (match_dup 1) (const_int 1)))
4986    (set (match_dup 0)
4987         (lshiftrt:DI (match_dup 0) (const_int 1)))]
4988   "")
4990 (define_split
4991   [(set (match_operand:DI 0 "register_operand" "")
4992         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4993                      (const_int 3)))]
4994   "reload_completed && !TARGET_COLDFIRE"
4995   [(set (match_dup 0)
4996         (lshiftrt:DI (match_dup 1) (const_int 2)))
4997    (set (match_dup 0)
4998         (lshiftrt:DI (match_dup 0) (const_int 1)))]
4999   "")
5001 (define_split
5002   [(set (match_operand:DI 0 "register_operand" "")
5003         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5004                      (const_int 8)))]
5005   "reload_completed && !TARGET_COLDFIRE"
5006   [(set (strict_low_part (subreg:QI (match_dup 0) 7))
5007         (subreg:QI (match_dup 0) 3))
5008    (set (match_dup 2)
5009         (lshiftrt:SI (match_dup 2) (const_int 8)))
5010    (set (match_dup 3)
5011         (rotatert:SI (match_dup 3) (const_int 8)))]
5013   operands[2] = gen_highpart (SImode, operands[0]);
5014   operands[3] = gen_lowpart (SImode, operands[0]);
5017 (define_split
5018   [(set (match_operand:DI 0 "register_operand" "")
5019         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5020                      (const_int 16)))]
5021   "reload_completed && !TARGET_COLDFIRE"
5022   [(set (strict_low_part (subreg:HI (match_dup 0) 6))
5023         (subreg:HI (match_dup 0) 2))
5024    (set (strict_low_part (subreg:HI (match_dup 0) 2))
5025         (const_int 0))
5026    (set (match_dup 3)
5027         (rotate:SI (match_dup 3) (const_int 16)))
5028    (set (match_dup 2)
5029         (rotate:SI (match_dup 2) (const_int 16)))]
5031   operands[2] = gen_highpart (SImode, operands[0]);
5032   operands[3] = gen_lowpart (SImode, operands[0]);
5035 (define_split
5036   [(set (match_operand:DI 0 "pre_dec_operand" "")
5037         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5038                      (const_int 32)))]
5039   "reload_completed"
5040   [(set (match_dup 0) (match_dup 1))
5041    (set (match_dup 0) (const_int 0))]
5043   operands[0] = adjust_address(operands[0], SImode, 0);
5044   operands[1] = gen_highpart(SImode, operands[1]);
5047 (define_split
5048   [(set (match_operand:DI 0 "post_inc_operand" "")
5049         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5050                      (const_int 32)))]
5051   "reload_completed"
5052   [(set (match_dup 0) (const_int 0))
5053    (set (match_dup 0) (match_dup 1))]
5055   operands[0] = adjust_address(operands[0], SImode, 0);
5056   operands[1] = gen_highpart(SImode, operands[1]);
5059 (define_split
5060   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5061         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5062                      (const_int 32)))]
5063   "reload_completed"
5064   [(set (match_dup 2) (match_dup 5))
5065    (set (match_dup 4) (const_int 0))]
5066   "split_di(operands, 2, operands + 2, operands + 4);")
5068 (define_insn "*lshrdi_const32"
5069   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
5070         (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
5071                      (const_int 32)))]
5072   ""
5073   "#")
5075 (define_split
5076   [(set (match_operand:DI 0 "register_operand" "")
5077         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5078                      (match_operand 2 "const_int_operand" "")))]
5079   "reload_completed && !TARGET_COLDFIRE
5080    && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
5081   [(set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 2)))
5082    (set (match_dup 4) (match_dup 3))
5083    (set (match_dup 3) (const_int 0))]
5085   operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5086   operands[3] = gen_highpart (SImode, operands[0]);
5087   operands[4] = gen_lowpart (SImode, operands[0]);
5090 (define_split
5091   [(set (match_operand:DI 0 "register_operand" "")
5092         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5093                      (const_int 48)))]
5094   "reload_completed"
5095   [(set (match_dup 3) (match_dup 2))
5096    (set (strict_low_part (subreg:HI (match_dup 0) 6))
5097         (const_int 0))
5098    (set (match_dup 2) (const_int 0))
5099    (set (match_dup 3)
5100         (rotate:SI (match_dup 3) (const_int 16)))]
5102   operands[2] = gen_highpart (SImode, operands[0]);
5103   operands[3] = gen_lowpart (SImode, operands[0]);
5106 (define_split
5107   [(set (match_operand:DI 0 "register_operand" "")
5108         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5109                      (match_operand 2 "const_int_operand" "")))]
5110   "reload_completed && !TARGET_COLDFIRE
5111    && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 62"
5112   [(set (match_dup 4) (match_dup 2))
5113    (set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 4)))
5114    (set (match_dup 4) (match_dup 3))
5115    (set (match_dup 3) (const_int 0))]
5117   operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5118   operands[3] = gen_highpart (SImode, operands[0]);
5119   operands[4] = gen_lowpart (SImode, operands[0]);
5122 (define_insn "*lshrdi_const63"
5123   [(set (match_operand:DI 0 "register_operand" "=d")
5124         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5125                      (const_int 63)))]
5126   ""
5127   "add%.l %0,%0\;clr%.l %0\;clr%.l %R1\;addx%.l %R1,%R1")
5129 (define_insn "*lshrdi3_const"
5130   [(set (match_operand:DI 0 "register_operand" "=d")
5131         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5132                      (match_operand 2 "const_int_operand" "n")))]
5133   "(!TARGET_COLDFIRE
5134     && ((INTVAL (operands[2]) >= 2 && INTVAL (operands[2]) <= 3)
5135          || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
5136          || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
5137   "#")
5139 (define_expand "lshrdi3"
5140   [(set (match_operand:DI 0 "register_operand" "")
5141         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5142                      (match_operand 2 "const_int_operand" "")))]
5143   "!TARGET_COLDFIRE"
5145   /* ???  This is a named pattern like this is not allowed to FAIL based
5146      on its operands.  */
5147   if (GET_CODE (operands[2]) != CONST_INT
5148       || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
5149           && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
5150           && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
5151     FAIL;
5154 ;; On all 68k models, this makes faster code in a special case.
5156 (define_insn "lshrsi_31"
5157   [(set (match_operand:SI 0 "register_operand" "=d")
5158         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5159                      (const_int 31)))]
5160   ""
5162   return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
5165 ;; On most 68k models, this makes faster code in a special case.
5167 (define_insn "lshrsi_16"
5168   [(set (match_operand:SI 0 "register_operand" "=d")
5169         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5170                      (const_int 16)))]
5171   "!TUNE_68060"
5173   CC_STATUS_INIT;
5174   return "clr%.w %0\;swap %0";
5177 ;; On the 68000, this makes faster code in a special case.
5179 (define_insn "lshrsi_17_24"
5180   [(set (match_operand:SI 0 "register_operand" "=d")
5181         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5182                      (match_operand:SI 2 "const_int_operand" "n")))]
5183   "TUNE_68000_10
5184    && INTVAL (operands[2]) > 16
5185    && INTVAL (operands[2]) <= 24"
5187   /* I think lsr%.w sets the CC properly.  */
5188   operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
5189   return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
5192 (define_insn "lshrsi3"
5193   [(set (match_operand:SI 0 "register_operand" "=d")
5194         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5195                      (match_operand:SI 2 "general_operand" "dI")))]
5196   ""
5197   "lsr%.l %2,%0"
5198   [(set_attr "type" "shift")
5199    (set_attr "opy" "2")])
5201 (define_insn "lshrhi3"
5202   [(set (match_operand:HI 0 "register_operand" "=d")
5203         (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
5204                      (match_operand:HI 2 "general_operand" "dI")))]
5205   "!TARGET_COLDFIRE"
5206   "lsr%.w %2,%0")
5208 (define_insn ""
5209   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5210         (lshiftrt:HI (match_dup 0)
5211                      (match_operand:HI 1 "general_operand" "dI")))]
5212   "!TARGET_COLDFIRE"
5213   "lsr%.w %1,%0")
5215 (define_insn "lshrqi3"
5216   [(set (match_operand:QI 0 "register_operand" "=d")
5217         (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
5218                      (match_operand:QI 2 "general_operand" "dI")))]
5219   "!TARGET_COLDFIRE"
5220   "lsr%.b %2,%0")
5222 (define_insn ""
5223   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5224         (lshiftrt:QI (match_dup 0)
5225                      (match_operand:QI 1 "general_operand" "dI")))]
5226   "!TARGET_COLDFIRE"
5227   "lsr%.b %1,%0")
5229 ;; rotate instructions
5231 (define_insn "rotlsi3"
5232   [(set (match_operand:SI 0 "register_operand" "=d")
5233         (rotate:SI (match_operand:SI 1 "register_operand" "0")
5234                    (match_operand:SI 2 "general_operand" "dINO")))]
5235   "!TARGET_COLDFIRE"
5237   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
5238     return "swap %0";
5239   else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
5240     {
5241       operands[2] = GEN_INT (32 - INTVAL (operands[2]));
5242       return "ror%.l %2,%0";
5243     }
5244   else
5245     return "rol%.l %2,%0";
5248 (define_insn "rotlhi3"
5249   [(set (match_operand:HI 0 "register_operand" "=d")
5250         (rotate:HI (match_operand:HI 1 "register_operand" "0")
5251                    (match_operand:HI 2 "general_operand" "dIP")))]
5252   "!TARGET_COLDFIRE"
5254   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5255     {
5256       operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5257       return "ror%.w %2,%0";
5258     }
5259   else
5260     return "rol%.w %2,%0";
5263 (define_insn ""
5264   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5265         (rotate:HI (match_dup 0)
5266                    (match_operand:HI 1 "general_operand" "dIP")))]
5267   "!TARGET_COLDFIRE"
5269   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5270     {
5271       operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5272       return "ror%.w %2,%0";
5273     }
5274   else
5275     return "rol%.w %2,%0";
5278 (define_insn "rotlqi3"
5279   [(set (match_operand:QI 0 "register_operand" "=d")
5280         (rotate:QI (match_operand:QI 1 "register_operand" "0")
5281                    (match_operand:QI 2 "general_operand" "dI")))]
5282   "!TARGET_COLDFIRE"
5284   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5285     {
5286       operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5287       return "ror%.b %2,%0";
5288     }
5289   else
5290     return "rol%.b %2,%0";
5293 (define_insn ""
5294   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5295         (rotate:QI (match_dup 0)
5296                    (match_operand:QI 1 "general_operand" "dI")))]
5297   "!TARGET_COLDFIRE"
5299   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5300     {
5301       operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5302       return "ror%.b %2,%0";
5303     }
5304   else
5305     return "rol%.b %2,%0";
5308 (define_insn "rotrsi3"
5309   [(set (match_operand:SI 0 "register_operand" "=d")
5310         (rotatert:SI (match_operand:SI 1 "register_operand" "0")
5311                      (match_operand:SI 2 "general_operand" "dI")))]
5312   "!TARGET_COLDFIRE"
5313   "ror%.l %2,%0")
5315 (define_insn "rotrhi3"
5316   [(set (match_operand:HI 0 "register_operand" "=d")
5317         (rotatert:HI (match_operand:HI 1 "register_operand" "0")
5318                      (match_operand:HI 2 "general_operand" "dI")))]
5319   "!TARGET_COLDFIRE"
5320   "ror%.w %2,%0")
5322 (define_insn ""
5323   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5324         (rotatert:HI (match_dup 0)
5325                      (match_operand:HI 1 "general_operand" "dI")))]
5326   "!TARGET_COLDFIRE"
5327   "ror%.w %1,%0")
5329 (define_insn "rotrqi3"
5330   [(set (match_operand:QI 0 "register_operand" "=d")
5331         (rotatert:QI (match_operand:QI 1 "register_operand" "0")
5332                      (match_operand:QI 2 "general_operand" "dI")))]
5333   "!TARGET_COLDFIRE"
5334   "ror%.b %2,%0")
5336 (define_insn ""
5337   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5338         (rotatert:QI (match_dup 0)
5339                      (match_operand:QI 1 "general_operand" "dI")))]
5340   "!TARGET_COLDFIRE"
5341   "ror%.b %1,%0")
5344 ;; Bit set/clear in memory byte.
5346 ;; set bit, bit number is int
5347 (define_insn "bsetmemqi"
5348   [(set (match_operand:QI 0 "memory_operand" "+m")
5349         (ior:QI (subreg:QI (ashift:SI (const_int 1)
5350                 (match_operand:SI 1 "general_operand" "d")) 3)
5351         (match_dup 0)))]
5352   ""
5354   CC_STATUS_INIT;
5355   return "bset %1,%0";
5357   [(set_attr "type" "bitrw")])
5359 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
5360 (define_insn "*bsetmemqi_ext"
5361   [(set (match_operand:QI 0 "memory_operand" "+m")
5362         (ior:QI (subreg:QI (ashift:SI (const_int 1)
5363             (match_operator:SI 2 "extend_operator"
5364                 [(match_operand 1 "general_operand" "d")])) 3)
5365         (match_dup 0)))]
5366   ""
5368   CC_STATUS_INIT;
5369   return "bset %1,%0";
5371   [(set_attr "type" "bitrw")])
5373 ;; clear bit, bit number is int
5374 (define_insn "bclrmemqi"
5375   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5376         (const_int 1)
5377         (minus:SI (const_int 7)
5378             (match_operand:SI 1 "general_operand" "d")))
5379     (const_int 0))]
5380   ""
5382   CC_STATUS_INIT;
5383   return "bclr %1,%0";
5385   [(set_attr "type" "bitrw")])
5387 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
5388 (define_insn "*bclrmemqi_ext"
5389   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5390         (const_int 1)
5391         (minus:SI (const_int 7)
5392             (match_operator:SI 2 "extend_operator"
5393                 [(match_operand 1 "general_operand" "d")])))
5394     (const_int 0))]
5395   ""
5397   CC_STATUS_INIT;
5398   return "bclr %1,%0";
5400   [(set_attr "type" "bitrw")])
5402 ;; Special cases of bit-field insns which we should
5403 ;; recognize in preference to the general case.
5404 ;; These handle aligned 8-bit and 16-bit fields,
5405 ;; which can usually be done with move instructions.
5408 ; Special case for 32-bit field in memory.  This only occurs when 32-bit
5409 ; alignment of structure members is specified.
5411 ; The move is allowed to be odd byte aligned, because that's still faster
5412 ; than an odd byte aligned bit-field instruction.
5414 (define_insn ""
5415   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5416                          (const_int 32)
5417                          (match_operand:SI 1 "const_int_operand" "n"))
5418         (match_operand:SI 2 "general_src_operand" "rmSi"))]
5419   "TARGET_68020 && TARGET_BITFIELD
5420    && (INTVAL (operands[1]) % 8) == 0
5421    && ! mode_dependent_address_p (XEXP (operands[0], 0))"
5423   operands[0]
5424     = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
5426   return "move%.l %2,%0";
5429 (define_insn ""
5430   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
5431                          (match_operand:SI 1 "const_int_operand" "n")
5432                          (match_operand:SI 2 "const_int_operand" "n"))
5433         (match_operand:SI 3 "register_operand" "d"))]
5434   "TARGET_68020 && TARGET_BITFIELD
5435    && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
5436    && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
5437    && (GET_CODE (operands[0]) == REG
5438        || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
5440   if (REG_P (operands[0]))
5441     {
5442       if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
5443         return "bfins %3,%0{%b2:%b1}";
5444     }
5445   else
5446     operands[0] = adjust_address (operands[0],
5447                                   INTVAL (operands[1]) == 8 ? QImode : HImode,
5448                                   INTVAL (operands[2]) / 8);
5450   if (GET_CODE (operands[3]) == MEM)
5451     operands[3] = adjust_address (operands[3],
5452                                   INTVAL (operands[1]) == 8 ? QImode : HImode,
5453                                   (32 - INTVAL (operands[1])) / 8);
5455   if (INTVAL (operands[1]) == 8)
5456     return "move%.b %3,%0";
5457   return "move%.w %3,%0";
5462 ; Special case for 32-bit field in memory.  This only occurs when 32-bit
5463 ; alignment of structure members is specified.
5465 ; The move is allowed to be odd byte aligned, because that's still faster
5466 ; than an odd byte aligned bit-field instruction.
5468 (define_insn ""
5469   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5470         (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5471                          (const_int 32)
5472                          (match_operand:SI 2 "const_int_operand" "n")))]
5473   "TARGET_68020 && TARGET_BITFIELD
5474    && (INTVAL (operands[2]) % 8) == 0
5475    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
5477   operands[1]
5478     = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5480   return "move%.l %1,%0";
5483 (define_insn ""
5484   [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
5485         (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
5486                          (match_operand:SI 2 "const_int_operand" "n")
5487                          (match_operand:SI 3 "const_int_operand" "n")))]
5488   "TARGET_68020 && TARGET_BITFIELD
5489    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5490    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
5491    && (GET_CODE (operands[1]) == REG
5492        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
5494   cc_status.flags |= CC_NOT_NEGATIVE;
5495   if (REG_P (operands[1]))
5496     {
5497       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5498         return "bfextu %1{%b3:%b2},%0";
5499     }
5500   else
5501     operands[1]
5502       = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
5504   output_asm_insn ("clr%.l %0", operands);
5505   if (GET_CODE (operands[0]) == MEM)
5506     operands[0] = adjust_address (operands[0],
5507                                   INTVAL (operands[2]) == 8 ? QImode : HImode,
5508                                   (32 - INTVAL (operands[1])) / 8);
5510   if (INTVAL (operands[2]) == 8)
5511     return "move%.b %1,%0";
5512   return "move%.w %1,%0";
5516 ; Special case for 32-bit field in memory.  This only occurs when 32-bit
5517 ; alignment of structure members is specified.
5519 ; The move is allowed to be odd byte aligned, because that's still faster
5520 ; than an odd byte aligned bit-field instruction.
5522 (define_insn ""
5523   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5524         (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5525                          (const_int 32)
5526                          (match_operand:SI 2 "const_int_operand" "n")))]
5527   "TARGET_68020 && TARGET_BITFIELD
5528    && (INTVAL (operands[2]) % 8) == 0
5529    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
5531   operands[1]
5532     = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5534   return "move%.l %1,%0";
5537 (define_insn ""
5538   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5539         (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
5540                          (match_operand:SI 2 "const_int_operand" "n")
5541                          (match_operand:SI 3 "const_int_operand" "n")))]
5542   "TARGET_68020 && TARGET_BITFIELD
5543    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5544    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
5545    && (GET_CODE (operands[1]) == REG
5546        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
5548   if (REG_P (operands[1]))
5549     {
5550       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5551         return "bfexts %1{%b3:%b2},%0";
5552     }
5553   else
5554     operands[1]
5555       = adjust_address (operands[1],
5556                         INTVAL (operands[2]) == 8 ? QImode : HImode,
5557                         INTVAL (operands[3]) / 8);
5559   if (INTVAL (operands[2]) == 8)
5560     return "move%.b %1,%0\;extb%.l %0";
5561   return "move%.w %1,%0\;ext%.l %0";
5564 ;; Bit-field instructions, general cases.
5565 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
5566 ;; so that its address is reloaded.
5568 (define_expand "extv"
5569   [(set (match_operand:SI 0 "register_operand" "")
5570         (sign_extract:SI (match_operand:SI 1 "general_operand" "")
5571                          (match_operand:SI 2 "const_int_operand" "")
5572                          (match_operand:SI 3 "const_int_operand" "")))]
5573   "TARGET_68020 && TARGET_BITFIELD"
5574   "")
5576 (define_insn ""
5577   [(set (match_operand:SI 0 "register_operand" "=d")
5578         (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
5579                          (match_operand:SI 2 "nonmemory_operand" "dn")
5580                          (match_operand:SI 3 "nonmemory_operand" "dn")))]
5581   "TARGET_68020 && TARGET_BITFIELD"
5582   "bfexts %1{%b3:%b2},%0")
5584 (define_expand "extzv"
5585   [(set (match_operand:SI 0 "register_operand" "")
5586         (zero_extract:SI (match_operand:SI 1 "general_operand" "")
5587                          (match_operand:SI 2 "const_int_operand" "")
5588                          (match_operand:SI 3 "const_int_operand" "")))]
5589   "TARGET_68020 && TARGET_BITFIELD"
5590   "")
5592 (define_insn ""
5593   [(set (match_operand:SI 0 "register_operand" "=d")
5594         (zero_extract:SI (match_operand:QI 1 "memory_operand" "o")
5595                          (match_operand:SI 2 "nonmemory_operand" "dn")
5596                          (match_operand:SI 3 "nonmemory_operand" "dn")))]
5597   "TARGET_68020 && TARGET_BITFIELD"
5599   if (GET_CODE (operands[2]) == CONST_INT)
5600     {
5601       if (INTVAL (operands[2]) != 32)
5602         cc_status.flags |= CC_NOT_NEGATIVE;
5603     }
5604   else
5605     {
5606       CC_STATUS_INIT;
5607     }
5608   return "bfextu %1{%b3:%b2},%0";
5611 (define_insn ""
5612   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5613                          (match_operand:SI 1 "nonmemory_operand" "dn")
5614                          (match_operand:SI 2 "nonmemory_operand" "dn"))
5615         (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
5616                 (match_operand 3 "const_int_operand" "n")))]
5617   "TARGET_68020 && TARGET_BITFIELD
5618    && (INTVAL (operands[3]) == -1
5619        || (GET_CODE (operands[1]) == CONST_INT
5620            && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
5622   CC_STATUS_INIT;
5623   return "bfchg %0{%b2:%b1}";
5626 (define_insn ""
5627   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5628                          (match_operand:SI 1 "nonmemory_operand" "dn")
5629                          (match_operand:SI 2 "nonmemory_operand" "dn"))
5630         (const_int 0))]
5631   "TARGET_68020 && TARGET_BITFIELD"
5633   CC_STATUS_INIT;
5634   return "bfclr %0{%b2:%b1}";
5637 (define_insn ""
5638   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5639                          (match_operand:SI 1 "general_operand" "dn")
5640                          (match_operand:SI 2 "general_operand" "dn"))
5641         (const_int -1))]
5642   "TARGET_68020 && TARGET_BITFIELD"
5644   CC_STATUS_INIT;
5645   return "bfset %0{%b2:%b1}";
5648 (define_expand "insv"
5649   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5650                          (match_operand:SI 1 "const_int_operand" "")
5651                          (match_operand:SI 2 "const_int_operand" ""))
5652         (match_operand:SI 3 "register_operand" ""))]
5653   "TARGET_68020 && TARGET_BITFIELD"
5654   "")
5656 (define_insn ""
5657   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5658                          (match_operand:SI 1 "nonmemory_operand" "dn")
5659                          (match_operand:SI 2 "nonmemory_operand" "dn"))
5660         (match_operand:SI 3 "register_operand" "d"))]
5661   "TARGET_68020 && TARGET_BITFIELD"
5662   "bfins %3,%0{%b2:%b1}")
5664 ;; Now recognize bit-field insns that operate on registers
5665 ;; (or at least were intended to do so).
5667 (define_insn ""
5668   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5669         (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5670                          (match_operand:SI 2 "const_int_operand" "n")
5671                          (match_operand:SI 3 "const_int_operand" "n")))]
5672   "TARGET_68020 && TARGET_BITFIELD"
5673   "bfexts %1{%b3:%b2},%0")
5675 (define_insn ""
5676   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5677         (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5678                          (match_operand:SI 2 "const_int_operand" "n")
5679                          (match_operand:SI 3 "const_int_operand" "n")))]
5680   "TARGET_68020 && TARGET_BITFIELD"
5682   if (GET_CODE (operands[2]) == CONST_INT)
5683     {
5684       if (INTVAL (operands[2]) != 32)
5685         cc_status.flags |= CC_NOT_NEGATIVE;
5686     }
5687   else
5688     {
5689       CC_STATUS_INIT;
5690     }
5691   return "bfextu %1{%b3:%b2},%0";
5694 (define_insn ""
5695   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5696                          (match_operand:SI 1 "const_int_operand" "n")
5697                          (match_operand:SI 2 "const_int_operand" "n"))
5698         (const_int 0))]
5699   "TARGET_68020 && TARGET_BITFIELD"
5701   CC_STATUS_INIT;
5702   return "bfclr %0{%b2:%b1}";
5705 (define_insn ""
5706   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5707                          (match_operand:SI 1 "const_int_operand" "n")
5708                          (match_operand:SI 2 "const_int_operand" "n"))
5709         (const_int -1))]
5710   "TARGET_68020 && TARGET_BITFIELD"
5712   CC_STATUS_INIT;
5713   return "bfset %0{%b2:%b1}";
5716 (define_insn ""
5717   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5718                          (match_operand:SI 1 "const_int_operand" "n")
5719                          (match_operand:SI 2 "const_int_operand" "n"))
5720         (match_operand:SI 3 "register_operand" "d"))]
5721   "TARGET_68020 && TARGET_BITFIELD"
5723 #if 0
5724   /* These special cases are now recognized by a specific pattern.  */
5725   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5726       && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5727     return "move%.w %3,%0";
5728   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5729       && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5730     return "move%.b %3,%0";
5731 #endif
5732   return "bfins %3,%0{%b2:%b1}";
5735 ;; Special patterns for optimizing bit-field instructions.
5737 (define_insn ""
5738   [(set (cc0)
5739         (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5740                          (match_operand:SI 1 "const_int_operand" "n")
5741                          (match_operand:SI 2 "general_operand" "dn")))]
5742   "TARGET_68020 && TARGET_BITFIELD"
5744   if (operands[1] == const1_rtx
5745       && GET_CODE (operands[2]) == CONST_INT)
5746     {
5747       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5748       return output_btst (operands,
5749                           GEN_INT (width - INTVAL (operands[2])),
5750                           operands[0], insn, 1000);
5751       /* Pass 1000 as SIGNPOS argument so that btst will
5752          not think we are testing the sign bit for an `and'
5753          and assume that nonzero implies a negative result.  */
5754     }
5755   if (INTVAL (operands[1]) != 32)
5756     cc_status.flags = CC_NOT_NEGATIVE;
5757   return "bftst %0{%b2:%b1}";
5761 ;;; now handle the register cases
5762 (define_insn ""
5763   [(set (cc0)
5764         (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5765                          (match_operand:SI 1 "const_int_operand" "n")
5766                          (match_operand:SI 2 "general_operand" "dn")))]
5767   "TARGET_68020 && TARGET_BITFIELD"
5769   if (operands[1] == const1_rtx
5770       && GET_CODE (operands[2]) == CONST_INT)
5771     {
5772       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5773       return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5774                           operands[0], insn, 1000);
5775       /* Pass 1000 as SIGNPOS argument so that btst will
5776          not think we are testing the sign bit for an `and'
5777          and assume that nonzero implies a negative result.  */
5778     }
5779   if (INTVAL (operands[1]) != 32)
5780     cc_status.flags = CC_NOT_NEGATIVE;
5781   return "bftst %0{%b2:%b1}";
5784 (define_insn "scc0_di"
5785   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5786     (match_operator 1 "valid_dbcc_comparison_p"
5787       [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5788   "! TARGET_COLDFIRE"
5790   return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5793 (define_insn "scc0_di_5200"
5794   [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5795     (match_operator 1 "valid_dbcc_comparison_p"
5796       [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5797   "TARGET_COLDFIRE"
5799   return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5802 (define_insn "scc_di"
5803   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5804     (match_operator 1 "valid_dbcc_comparison_p"
5805       [(match_operand:DI 2 "general_operand" "ro,r")
5806        (match_operand:DI 3 "general_operand" "r,ro")]))]
5807   "! TARGET_COLDFIRE"
5809   return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5812 (define_insn "scc_di_5200"
5813   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5814     (match_operator 1 "valid_dbcc_comparison_p"
5815       [(match_operand:DI 2 "general_operand" "ro,r")
5816        (match_operand:DI 3 "general_operand" "r,ro")]))]
5817   "TARGET_COLDFIRE"
5819   return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5822 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5823 ;; memory, but we cannot allow it to be in memory in case the address
5824 ;; needs to be reloaded.
5826 (define_expand "seq"
5827   [(set (match_operand:QI 0 "register_operand" "")
5828         (eq:QI (cc0) (const_int 0)))]
5829   ""
5831   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5832       && m68k_last_compare_had_fp_operands)
5833     {
5834       m68k_last_compare_had_fp_operands = 0;
5835       FAIL;
5836     }
5839 (define_insn ""
5840   [(set (match_operand:QI 0 "register_operand" "=d")
5841         (eq:QI (cc0) (const_int 0)))]
5842   ""
5844   cc_status = cc_prev_status;
5845   OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5848 (define_expand "sne"
5849   [(set (match_operand:QI 0 "register_operand" "")
5850         (ne:QI (cc0) (const_int 0)))]
5851   ""
5853   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5854       && m68k_last_compare_had_fp_operands)
5855     {
5856       m68k_last_compare_had_fp_operands = 0;
5857       FAIL;
5858     }
5861 (define_insn ""
5862   [(set (match_operand:QI 0 "register_operand" "=d")
5863         (ne:QI (cc0) (const_int 0)))]
5864   ""
5866   cc_status = cc_prev_status;
5867   OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5870 (define_expand "sgt"
5871   [(set (match_operand:QI 0 "register_operand" "")
5872         (gt:QI (cc0) (const_int 0)))]
5873   ""
5875   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5876       && m68k_last_compare_had_fp_operands)
5877     {
5878       m68k_last_compare_had_fp_operands = 0;
5879       FAIL;
5880     }
5883 (define_insn ""
5884   [(set (match_operand:QI 0 "register_operand" "=d")
5885         (gt:QI (cc0) (const_int 0)))]
5886   ""
5888   cc_status = cc_prev_status;
5889   OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5892 (define_expand "sgtu"
5893   [(set (match_operand:QI 0 "register_operand" "")
5894         (gtu:QI (cc0) (const_int 0)))]
5895   ""
5896   "")
5898 (define_insn ""
5899   [(set (match_operand:QI 0 "register_operand" "=d")
5900         (gtu:QI (cc0) (const_int 0)))]
5901   ""
5903   cc_status = cc_prev_status;
5904   return "shi %0";
5907 (define_expand "slt"
5908   [(set (match_operand:QI 0 "register_operand" "")
5909         (lt:QI (cc0) (const_int 0)))]
5910   ""
5912   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5913       && m68k_last_compare_had_fp_operands)
5914     {
5915       m68k_last_compare_had_fp_operands = 0;
5916       FAIL;
5917     }
5920 (define_insn ""
5921   [(set (match_operand:QI 0 "register_operand" "=d")
5922         (lt:QI (cc0) (const_int 0)))]
5923   ""
5925    cc_status = cc_prev_status;
5926    OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5929 (define_expand "sltu"
5930   [(set (match_operand:QI 0 "register_operand" "")
5931         (ltu:QI (cc0) (const_int 0)))]
5932   ""
5933   "")
5935 (define_insn ""
5936   [(set (match_operand:QI 0 "register_operand" "=d")
5937         (ltu:QI (cc0) (const_int 0)))]
5938   ""
5940    cc_status = cc_prev_status;
5941    return "scs %0";
5944 (define_expand "sge"
5945   [(set (match_operand:QI 0 "register_operand" "")
5946         (ge:QI (cc0) (const_int 0)))]
5947   ""
5949   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5950       && m68k_last_compare_had_fp_operands)
5951     {
5952       m68k_last_compare_had_fp_operands = 0;
5953       FAIL;
5954     }
5957 (define_insn ""
5958   [(set (match_operand:QI 0 "register_operand" "=d")
5959         (ge:QI (cc0) (const_int 0)))]
5960   ""
5962    cc_status = cc_prev_status;
5963    OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5966 (define_expand "sgeu"
5967   [(set (match_operand:QI 0 "register_operand" "")
5968         (geu:QI (cc0) (const_int 0)))]
5969   ""
5970   "")
5972 (define_insn "*scc"
5973   [(set (match_operand:QI 0 "register_operand" "=d")
5974         (geu:QI (cc0) (const_int 0)))]
5975   ""
5977    cc_status = cc_prev_status;
5978    return "scc %0";
5980   [(set_attr "type" "scc")])
5982 (define_expand "sle"
5983   [(set (match_operand:QI 0 "register_operand" "")
5984         (le:QI (cc0) (const_int 0)))]
5985   ""
5987   if ((TUNE_68060 || TARGET_COLDFIRE_FPU)
5988       && m68k_last_compare_had_fp_operands)
5989     {
5990       m68k_last_compare_had_fp_operands = 0;
5991       FAIL;
5992     }
5995 (define_insn ""
5996   [(set (match_operand:QI 0 "register_operand" "=d")
5997         (le:QI (cc0) (const_int 0)))]
5998   ""
6000   cc_status = cc_prev_status;
6001   OUTPUT_JUMP ("sle %0", "fsle %0", 0);
6004 (define_expand "sleu"
6005   [(set (match_operand:QI 0 "register_operand" "")
6006         (leu:QI (cc0) (const_int 0)))]
6007   ""
6008   "")
6010 (define_insn "*sls"
6011   [(set (match_operand:QI 0 "register_operand" "=d")
6012         (leu:QI (cc0) (const_int 0)))]
6013   ""
6015    cc_status = cc_prev_status;
6016    return "sls %0";
6018   [(set_attr "type" "scc")])
6020 (define_expand "sordered"
6021   [(set (match_operand:QI 0 "register_operand" "")
6022         (ordered:QI (cc0) (const_int 0)))]
6023   "TARGET_68881 && !TUNE_68060"
6025   gcc_assert (m68k_last_compare_had_fp_operands);
6026   m68k_last_compare_had_fp_operands = 0;
6029 (define_insn "*sordered_1"
6030   [(set (match_operand:QI 0 "register_operand" "=d")
6031         (ordered:QI (cc0) (const_int 0)))]
6032   "TARGET_68881 && !TUNE_68060"
6034   cc_status = cc_prev_status;
6035   return "fsor %0";
6038 (define_expand "sunordered"
6039   [(set (match_operand:QI 0 "register_operand" "")
6040         (unordered:QI (cc0) (const_int 0)))]
6041   "TARGET_68881 && !TUNE_68060"
6043   gcc_assert (m68k_last_compare_had_fp_operands);
6044   m68k_last_compare_had_fp_operands = 0;
6047 (define_insn "*sunordered_1"
6048   [(set (match_operand:QI 0 "register_operand" "=d")
6049         (unordered:QI (cc0) (const_int 0)))]
6050   "TARGET_68881 && !TUNE_68060"
6052   cc_status = cc_prev_status;
6053   return "fsun %0";
6056 (define_expand "suneq"
6057   [(set (match_operand:QI 0 "register_operand" "")
6058         (uneq:QI (cc0) (const_int 0)))]
6059   "TARGET_68881 && !TUNE_68060"
6061   gcc_assert (m68k_last_compare_had_fp_operands);
6062   m68k_last_compare_had_fp_operands = 0;
6065 (define_insn "*suneq_1"
6066   [(set (match_operand:QI 0 "register_operand" "=d")
6067         (uneq:QI (cc0) (const_int 0)))]
6068   "TARGET_68881 && !TUNE_68060"
6070   cc_status = cc_prev_status;
6071   return "fsueq %0";
6074 (define_expand "sunge"
6075   [(set (match_operand:QI 0 "register_operand" "")
6076         (unge:QI (cc0) (const_int 0)))]
6077   "TARGET_68881 && !TUNE_68060"
6079   gcc_assert (m68k_last_compare_had_fp_operands);
6080   m68k_last_compare_had_fp_operands = 0;
6083 (define_insn "*sunge_1"
6084   [(set (match_operand:QI 0 "register_operand" "=d")
6085         (unge:QI (cc0) (const_int 0)))]
6086   "TARGET_68881 && !TUNE_68060"
6088   cc_status = cc_prev_status;
6089   return "fsuge %0";
6092 (define_expand "sungt"
6093   [(set (match_operand:QI 0 "register_operand" "")
6094         (ungt:QI (cc0) (const_int 0)))]
6095   "TARGET_68881 && !TUNE_68060"
6097   gcc_assert (m68k_last_compare_had_fp_operands);
6098   m68k_last_compare_had_fp_operands = 0;
6101 (define_insn "*sungt_1"
6102   [(set (match_operand:QI 0 "register_operand" "=d")
6103         (ungt:QI (cc0) (const_int 0)))]
6104   "TARGET_68881 && !TUNE_68060"
6106   cc_status = cc_prev_status;
6107   return "fsugt %0";
6110 (define_expand "sunle"
6111   [(set (match_operand:QI 0 "register_operand" "")
6112         (unle:QI (cc0) (const_int 0)))]
6113   "TARGET_68881 && !TUNE_68060"
6115   gcc_assert (m68k_last_compare_had_fp_operands);
6116   m68k_last_compare_had_fp_operands = 0;
6119 (define_insn "*sunle_1"
6120   [(set (match_operand:QI 0 "register_operand" "=d")
6121         (unle:QI (cc0) (const_int 0)))]
6122   "TARGET_68881 && !TUNE_68060"
6124   cc_status = cc_prev_status;
6125   return "fsule %0";
6128 (define_expand "sunlt"
6129   [(set (match_operand:QI 0 "register_operand" "")
6130         (unlt:QI (cc0) (const_int 0)))]
6131   "TARGET_68881 && !TUNE_68060"
6133   gcc_assert (m68k_last_compare_had_fp_operands);
6134   m68k_last_compare_had_fp_operands = 0;
6137 (define_insn "*sunlt_1"
6138   [(set (match_operand:QI 0 "register_operand" "=d")
6139         (unlt:QI (cc0) (const_int 0)))]
6140   "TARGET_68881 && !TUNE_68060"
6142   cc_status = cc_prev_status;
6143   return "fsult %0";
6146 (define_expand "sltgt"
6147   [(set (match_operand:QI 0 "register_operand" "")
6148         (ltgt:QI (cc0) (const_int 0)))]
6149   "TARGET_68881 && !TUNE_68060"
6151   gcc_assert (m68k_last_compare_had_fp_operands);
6152   m68k_last_compare_had_fp_operands = 0;
6155 (define_insn "*sltgt_1"
6156   [(set (match_operand:QI 0 "register_operand" "=d")
6157         (ltgt:QI (cc0) (const_int 0)))]
6158   "TARGET_68881 && !TUNE_68060"
6160   cc_status = cc_prev_status;
6161   return "fsogl %0";
6164 (define_insn "*fsogt_1"
6165   [(set (match_operand:QI 0 "register_operand" "=d")
6166         (not:QI (unle:QI (cc0) (const_int 0))))]
6167   "TARGET_68881 && !TUNE_68060"
6169   cc_status = cc_prev_status;
6170   return "fsogt %0";
6173 (define_insn "*fsoge_1"
6174   [(set (match_operand:QI 0 "register_operand" "=d")
6175         (not:QI (unlt:QI (cc0) (const_int 0))))]
6176   "TARGET_68881 && !TUNE_68060"
6178   cc_status = cc_prev_status;
6179   return "fsoge %0";
6182 (define_insn "*fsolt_1"
6183   [(set (match_operand:QI 0 "register_operand" "=d")
6184         (not:QI (unge:QI (cc0) (const_int 0))))]
6185   "TARGET_68881 && !TUNE_68060"
6187   cc_status = cc_prev_status;
6188   return "fsolt %0";
6191 (define_insn "*fsole_1"
6192   [(set (match_operand:QI 0 "register_operand" "=d")
6193         (not:QI (ungt:QI (cc0) (const_int 0))))]
6194   "TARGET_68881 && !TUNE_68060"
6196   cc_status = cc_prev_status;
6197   return "fsole %0";
6200 ;; Basic conditional jump instructions.
6202 (define_insn "beq0_di"
6203   [(set (pc)
6204     (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
6205             (const_int 0))
6206         (label_ref (match_operand 1 "" ","))
6207         (pc)))
6208    (clobber (match_scratch:SI 2 "=d,d"))]
6209   ""
6211   CC_STATUS_INIT;
6212   if (which_alternative == 1)
6213     return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
6214   if ((cc_prev_status.value1
6215       && rtx_equal_p (cc_prev_status.value1, operands[0]))
6216     || (cc_prev_status.value2
6217       && rtx_equal_p (cc_prev_status.value2, operands[0])))
6218     {
6219       cc_status = cc_prev_status;
6220       return "jeq %l1";
6221     }
6222   if (GET_CODE (operands[0]) == REG)
6223     operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6224   else
6225     operands[3] = adjust_address (operands[0], SImode, 4);
6226   if (! ADDRESS_REG_P (operands[0]))
6227     {
6228       if (reg_overlap_mentioned_p (operands[2], operands[0]))
6229         {
6230           if (reg_overlap_mentioned_p (operands[2], operands[3]))
6231             return "or%.l %0,%2\;jeq %l1";
6232           else
6233             return "or%.l %3,%2\;jeq %l1";
6234         }
6235       return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
6236     }
6237   operands[4] = gen_label_rtx();
6238   if (TARGET_68020 || TARGET_COLDFIRE)
6239     output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
6240   else
6241     output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
6242   (*targetm.asm_out.internal_label) (asm_out_file, "L",
6243                                 CODE_LABEL_NUMBER (operands[4]));
6244   return "";
6247 (define_insn "bne0_di"
6248   [(set (pc)
6249     (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
6250             (const_int 0))
6251         (label_ref (match_operand 1 "" ","))
6252         (pc)))
6253    (clobber (match_scratch:SI 2 "=d,X"))]
6254   ""
6256   if ((cc_prev_status.value1
6257       && rtx_equal_p (cc_prev_status.value1, operands[0]))
6258     || (cc_prev_status.value2
6259       && rtx_equal_p (cc_prev_status.value2, operands[0])))
6260     {
6261       cc_status = cc_prev_status;
6262       return "jne %l1";
6263     }
6264   CC_STATUS_INIT;
6265   if (GET_CODE (operands[0]) == REG)
6266     operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6267   else
6268     operands[3] = adjust_address (operands[0], SImode, 4);
6269   if (!ADDRESS_REG_P (operands[0]))
6270     {
6271       if (reg_overlap_mentioned_p (operands[2], operands[0]))
6272         {
6273           if (reg_overlap_mentioned_p (operands[2], operands[3]))
6274             return "or%.l %0,%2\;jne %l1";
6275           else
6276             return "or%.l %3,%2\;jne %l1";
6277         }
6278       return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
6279     }
6280   if (TARGET_68020 || TARGET_COLDFIRE)
6281     return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
6282   else
6283     return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
6286 (define_insn "bge0_di"
6287   [(set (pc)
6288     (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
6289             (const_int 0))
6290         (label_ref (match_operand 1 "" ""))
6291         (pc)))]
6292   ""
6294   if ((cc_prev_status.value1
6295       && rtx_equal_p (cc_prev_status.value1, operands[0]))
6296     || (cc_prev_status.value2
6297       && rtx_equal_p (cc_prev_status.value2, operands[0])))
6298     {
6299       cc_status = cc_prev_status;
6300       return cc_status.flags & CC_REVERSED ? "jle %l1" : "jpl %l1";
6301     }
6302   CC_STATUS_INIT;
6303   if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6304     output_asm_insn("tst%.l %0", operands);
6305   else
6306     {
6307       /* On an address reg, cmpw may replace cmpl.  */
6308       output_asm_insn("cmp%.w #0,%0", operands);
6309     }
6310   return "jpl %l1";
6313 (define_insn "blt0_di"
6314   [(set (pc)
6315     (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
6316             (const_int 0))
6317         (label_ref (match_operand 1 "" ""))
6318         (pc)))]
6319   ""
6321   if ((cc_prev_status.value1
6322       && rtx_equal_p (cc_prev_status.value1, operands[0]))
6323     || (cc_prev_status.value2
6324       && rtx_equal_p (cc_prev_status.value2, operands[0])))
6325     {
6326       cc_status = cc_prev_status;
6327       return cc_status.flags & CC_REVERSED ? "jgt %l1" : "jmi %l1";
6328     }
6329   CC_STATUS_INIT;
6330   if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6331     output_asm_insn("tst%.l %0", operands);
6332   else
6333     {
6334       /* On an address reg, cmpw may replace cmpl.  */
6335       output_asm_insn("cmp%.w #0,%0", operands);
6336     }
6337   return "jmi %l1";
6340 (define_insn "beq"
6341   [(set (pc)
6342         (if_then_else (eq (cc0)
6343                           (const_int 0))
6344                       (label_ref (match_operand 0 "" ""))
6345                       (pc)))]
6346   ""
6348   OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6350   [(set (attr "type") (symbol_ref "m68k_sched_branch_type (insn)"))])
6352 (define_insn "bne"
6353   [(set (pc)
6354         (if_then_else (ne (cc0)
6355                           (const_int 0))
6356                       (label_ref (match_operand 0 "" ""))
6357                       (pc)))]
6358   ""
6360   OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6362   [(set (attr "type") (symbol_ref "m68k_sched_branch_type (insn)"))])
6364 (define_insn "bgt"
6365   [(set (pc)
6366         (if_then_else (gt (cc0)
6367                           (const_int 0))
6368                       (label_ref (match_operand 0 "" ""))
6369                       (pc)))]
6370   ""
6372   OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
6374   [(set (attr "type") (symbol_ref "m68k_sched_branch_type (insn)"))])
6376 (define_insn "bgtu"
6377   [(set (pc)
6378         (if_then_else (gtu (cc0)
6379                            (const_int 0))
6380                       (label_ref (match_operand 0 "" ""))
6381                       (pc)))]
6382   ""
6383   "jhi %l0"
6384   [(set_attr "type" "bcc")])
6386 (define_insn "blt"
6387   [(set (pc)
6388         (if_then_else (lt (cc0)
6389                           (const_int 0))
6390                       (label_ref (match_operand 0 "" ""))
6391                       (pc)))]
6392   ""
6394   OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
6396   [(set (attr "type") (symbol_ref "m68k_sched_branch_type (insn)"))])
6398 (define_insn "bltu"
6399   [(set (pc)
6400         (if_then_else (ltu (cc0)
6401                            (const_int 0))
6402                       (label_ref (match_operand 0 "" ""))
6403                       (pc)))]
6404   ""
6405   "jcs %l0"
6406   [(set_attr "type" "bcc")])
6408 (define_insn "bge"
6409   [(set (pc)
6410         (if_then_else (ge (cc0)
6411                           (const_int 0))
6412                       (label_ref (match_operand 0 "" ""))
6413                       (pc)))]
6414   ""
6416   OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
6419 (define_insn "bgeu"
6420   [(set (pc)
6421         (if_then_else (geu (cc0)
6422                            (const_int 0))
6423                       (label_ref (match_operand 0 "" ""))
6424                       (pc)))]
6425   ""
6426   "jcc %l0"
6427   [(set_attr "type" "bcc")])
6429 (define_insn "ble"
6430   [(set (pc)
6431         (if_then_else (le (cc0)
6432                           (const_int 0))
6433                       (label_ref (match_operand 0 "" ""))
6434                       (pc)))]
6435   ""
6437   OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
6439   [(set_attr "type" "bcc")])
6441 (define_insn "bleu"
6442   [(set (pc)
6443         (if_then_else (leu (cc0)
6444                            (const_int 0))
6445                       (label_ref (match_operand 0 "" ""))
6446                       (pc)))]
6447   ""
6448   "jls %l0"
6449   [(set_attr "type" "bcc")])
6451 (define_insn "bordered"
6452   [(set (pc)
6453         (if_then_else (ordered (cc0) (const_int 0))
6454                       (label_ref (match_operand 0 "" ""))
6455                       (pc)))]
6456   "TARGET_HARD_FLOAT"
6458   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6459   return "fjor %l0";
6461   [(set_attr "type" "fbcc")])
6463 (define_insn "bunordered"
6464   [(set (pc)
6465         (if_then_else (unordered (cc0) (const_int 0))
6466                       (label_ref (match_operand 0 "" ""))
6467                       (pc)))]
6468   "TARGET_HARD_FLOAT"
6470   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6471   return "fjun %l0";
6473   [(set_attr "type" "fbcc")])
6475 (define_insn "buneq"
6476   [(set (pc)
6477         (if_then_else (uneq (cc0) (const_int 0))
6478                       (label_ref (match_operand 0 "" ""))
6479                       (pc)))]
6480   "TARGET_HARD_FLOAT"
6482   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6483   return "fjueq %l0";
6485   [(set_attr "type" "fbcc")])
6487 (define_insn "bunge"
6488   [(set (pc)
6489         (if_then_else (unge (cc0) (const_int 0))
6490                       (label_ref (match_operand 0 "" ""))
6491                       (pc)))]
6492   "TARGET_HARD_FLOAT"
6494   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6495   return "fjuge %l0";
6497   [(set_attr "type" "fbcc")])
6499 (define_insn "bungt"
6500   [(set (pc)
6501         (if_then_else (ungt (cc0) (const_int 0))
6502                       (label_ref (match_operand 0 "" ""))
6503                       (pc)))]
6504   "TARGET_HARD_FLOAT"
6506   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6507   return "fjugt %l0";
6509   [(set_attr "type" "fbcc")])
6511 (define_insn "bunle"
6512   [(set (pc)
6513         (if_then_else (unle (cc0) (const_int 0))
6514                       (label_ref (match_operand 0 "" ""))
6515                       (pc)))]
6516   "TARGET_HARD_FLOAT"
6518   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6519   return "fjule %l0";
6521   [(set_attr "type" "fbcc")])
6523 (define_insn "bunlt"
6524   [(set (pc)
6525         (if_then_else (unlt (cc0) (const_int 0))
6526                       (label_ref (match_operand 0 "" ""))
6527                       (pc)))]
6528   "TARGET_HARD_FLOAT"
6530   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6531   return "fjult %l0";
6533   [(set_attr "type" "fbcc")])
6535 (define_insn "bltgt"
6536   [(set (pc)
6537         (if_then_else (ltgt (cc0) (const_int 0))
6538                       (label_ref (match_operand 0 "" ""))
6539                       (pc)))]
6540   "TARGET_HARD_FLOAT"
6542   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6543   return "fjogl %l0";
6545   [(set_attr "type" "fbcc")])
6547 ;; Negated conditional jump instructions.
6549 (define_insn "*beq_rev"
6550   [(set (pc)
6551         (if_then_else (eq (cc0)
6552                           (const_int 0))
6553                       (pc)
6554                       (label_ref (match_operand 0 "" ""))))]
6555   ""
6557   OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6559   [(set_attr "type" "bcc")])
6561 (define_insn "*bne_rev"
6562   [(set (pc)
6563         (if_then_else (ne (cc0)
6564                           (const_int 0))
6565                       (pc)
6566                       (label_ref (match_operand 0 "" ""))))]
6567   ""
6569   OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6571   [(set_attr "type" "bcc")])
6573 (define_insn "*bgt_rev"
6574   [(set (pc)
6575         (if_then_else (gt (cc0)
6576                           (const_int 0))
6577                       (pc)
6578                       (label_ref (match_operand 0 "" ""))))]
6579   ""
6581   OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6583   [(set_attr "type" "bcc")])
6585 (define_insn "*bgtu_rev"
6586   [(set (pc)
6587         (if_then_else (gtu (cc0)
6588                            (const_int 0))
6589                       (pc)
6590                       (label_ref (match_operand 0 "" ""))))]
6591   ""
6592   "jls %l0"
6593   [(set_attr "type" "bcc")])
6595 (define_insn "*blt_rev"
6596   [(set (pc)
6597         (if_then_else (lt (cc0)
6598                           (const_int 0))
6599                       (pc)
6600                       (label_ref (match_operand 0 "" ""))))]
6601   ""
6603   OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6605   [(set_attr "type" "bcc")])
6607 (define_insn "*bltu_rev"
6608   [(set (pc)
6609         (if_then_else (ltu (cc0)
6610                            (const_int 0))
6611                       (pc)
6612                       (label_ref (match_operand 0 "" ""))))]
6613   ""
6614   "jcc %l0"
6615   [(set_attr "type" "bcc")])
6617 (define_insn "*bge_rev"
6618   [(set (pc)
6619         (if_then_else (ge (cc0)
6620                           (const_int 0))
6621                       (pc)
6622                       (label_ref (match_operand 0 "" ""))))]
6623   ""
6625   OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6627   [(set_attr "type" "bcc")])
6629 (define_insn "*bgeu_rev"
6630   [(set (pc)
6631         (if_then_else (geu (cc0)
6632                            (const_int 0))
6633                       (pc)
6634                       (label_ref (match_operand 0 "" ""))))]
6635   ""
6636   "jcs %l0"
6637   [(set_attr "type" "bcc")])
6639 (define_insn "*ble_rev"
6640   [(set (pc)
6641         (if_then_else (le (cc0)
6642                           (const_int 0))
6643                       (pc)
6644                       (label_ref (match_operand 0 "" ""))))]
6645   ""
6647   OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6649   [(set_attr "type" "bcc")])
6651 (define_insn "*bleu_rev"
6652   [(set (pc)
6653         (if_then_else (leu (cc0)
6654                            (const_int 0))
6655                       (pc)
6656                       (label_ref (match_operand 0 "" ""))))]
6657   ""
6658   "jhi %l0"
6659   [(set_attr "type" "bcc")])
6661 (define_insn "*bordered_rev"
6662   [(set (pc)
6663         (if_then_else (ordered (cc0) (const_int 0))
6664                       (pc)
6665                       (label_ref (match_operand 0 "" ""))))]
6666   "TARGET_HARD_FLOAT"
6668   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6669   return "fjun %l0";
6671   [(set_attr "type" "fbcc")])
6673 (define_insn "*bunordered_rev"
6674   [(set (pc)
6675         (if_then_else (unordered (cc0) (const_int 0))
6676                       (pc)
6677                       (label_ref (match_operand 0 "" ""))))]
6678   "TARGET_HARD_FLOAT"
6680   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6681   return "fjor %l0";
6683   [(set_attr "type" "fbcc")])
6685 (define_insn "*buneq_rev"
6686   [(set (pc)
6687         (if_then_else (uneq (cc0) (const_int 0))
6688                       (pc)
6689                       (label_ref (match_operand 0 "" ""))))]
6690   "TARGET_HARD_FLOAT"
6692   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6693   return "fjogl %l0";
6695   [(set_attr "type" "fbcc")])
6697 (define_insn "*bunge_rev"
6698   [(set (pc)
6699         (if_then_else (unge (cc0) (const_int 0))
6700                       (pc)
6701                       (label_ref (match_operand 0 "" ""))))]
6702   "TARGET_HARD_FLOAT"
6704   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6705   return "fjolt %l0";
6707   [(set_attr "type" "fbcc")])
6709 (define_insn "*bungt_rev"
6710   [(set (pc)
6711         (if_then_else (ungt (cc0) (const_int 0))
6712                       (pc)
6713                       (label_ref (match_operand 0 "" ""))))]
6714   "TARGET_HARD_FLOAT"
6716   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6717   return "fjole %l0";
6719   [(set_attr "type" "fbcc")])
6721 (define_insn "*bunle_rev"
6722   [(set (pc)
6723         (if_then_else (unle (cc0) (const_int 0))
6724                       (pc)
6725                       (label_ref (match_operand 0 "" ""))))]
6726   "TARGET_HARD_FLOAT"
6728   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6729   return "fjogt %l0";
6731   [(set_attr "type" "fbcc")])
6733 (define_insn "*bunlt_rev"
6734   [(set (pc)
6735         (if_then_else (unlt (cc0) (const_int 0))
6736                       (pc)
6737                       (label_ref (match_operand 0 "" ""))))]
6738   "TARGET_HARD_FLOAT"
6740   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6741   return "fjoge %l0";
6743   [(set_attr "type" "fbcc")])
6745 (define_insn "*bltgt_rev"
6746   [(set (pc)
6747         (if_then_else (ltgt (cc0) (const_int 0))
6748                       (pc)
6749                       (label_ref (match_operand 0 "" ""))))]
6750   "TARGET_HARD_FLOAT"
6752   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6753   return "fjueq %l0";
6755   [(set_attr "type" "fbcc")])
6757 ;; Unconditional and other jump instructions
6758 (define_insn "jump"
6759   [(set (pc)
6760         (label_ref (match_operand 0 "" "")))]
6761   ""
6762   "jra %l0"
6763   [(set_attr "type" "bra")])
6765 (define_expand "tablejump"
6766   [(parallel [(set (pc) (match_operand 0 "" ""))
6767               (use (label_ref (match_operand 1 "" "")))])]
6768   ""
6770 #ifdef CASE_VECTOR_PC_RELATIVE
6771     operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6772                                 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6773 #endif
6776 ;; Jump to variable address from dispatch table of absolute addresses.
6777 (define_insn "*tablejump_internal"
6778   [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6779    (use (label_ref (match_operand 1 "" "")))]
6780   ""
6782   return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6784   [(set_attr "type" "jmp")])
6786 ;; Jump to variable address from dispatch table of relative addresses.
6787 (define_insn ""
6788   [(set (pc)
6789         (plus:SI (pc)
6790                  (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6791    (use (label_ref (match_operand 1 "" "")))]
6792   ""
6794 #ifdef ASM_RETURN_CASE_JUMP
6795   ASM_RETURN_CASE_JUMP;
6796 #else
6797   if (TARGET_COLDFIRE)
6798     {
6799       if (ADDRESS_REG_P (operands[0]))
6800         return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6801       else if (MOTOROLA)
6802         return "ext%.l %0\;jmp (2,pc,%0.l)";
6803       else
6804         return "extl %0\;jmp pc@(2,%0:l)";
6805     }
6806   else
6807     return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6808 #endif
6811 ;; Decrement-and-branch insns.
6812 (define_insn "*dbne_hi"
6813   [(set (pc)
6814         (if_then_else
6815          (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6816              (const_int 0))
6817          (label_ref (match_operand 1 "" ""))
6818          (pc)))
6819    (set (match_dup 0)
6820         (plus:HI (match_dup 0)
6821                  (const_int -1)))]
6822   "!TARGET_COLDFIRE"
6824   CC_STATUS_INIT;
6825   if (DATA_REG_P (operands[0]))
6826     return "dbra %0,%l1";
6827   if (GET_CODE (operands[0]) == MEM)
6828     return "subq%.w #1,%0\;jcc %l1";
6829   return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6832 (define_insn "*dbne_si"
6833   [(set (pc)
6834         (if_then_else
6835          (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6836              (const_int 0))
6837          (label_ref (match_operand 1 "" ""))
6838          (pc)))
6839    (set (match_dup 0)
6840         (plus:SI (match_dup 0)
6841                  (const_int -1)))]
6842   "!TARGET_COLDFIRE"
6844   CC_STATUS_INIT;
6845   if (DATA_REG_P (operands[0]))
6846     return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6847   if (GET_CODE (operands[0]) == MEM)
6848     return "subq%.l #1,%0\;jcc %l1";
6849   return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6852 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6854 (define_insn "*dbge_hi"
6855   [(set (pc)
6856         (if_then_else
6857           (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6858                        (const_int -1))
6859               (const_int 0))
6860           (label_ref (match_operand 1 "" ""))
6861           (pc)))
6862    (set (match_dup 0)
6863         (plus:HI (match_dup 0)
6864                  (const_int -1)))]
6865   "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6867   CC_STATUS_INIT;
6868   if (DATA_REG_P (operands[0]))
6869     return "dbra %0,%l1";
6870   if (GET_CODE (operands[0]) == MEM)
6871     return "subq%.w #1,%0\;jcc %l1";
6872   return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6875 (define_expand "decrement_and_branch_until_zero"
6876   [(parallel [(set (pc)
6877                    (if_then_else
6878                     (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6879                                  (const_int -1))
6880                         (const_int 0))
6881                     (label_ref (match_operand 1 "" ""))
6882                     (pc)))
6883               (set (match_dup 0)
6884                    (plus:SI (match_dup 0)
6885                             (const_int -1)))])]
6886   ""
6887   "")
6889 (define_insn "*dbge_si"
6890   [(set (pc)
6891         (if_then_else
6892           (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6893                        (const_int -1))
6894               (const_int 0))
6895           (label_ref (match_operand 1 "" ""))
6896           (pc)))
6897    (set (match_dup 0)
6898         (plus:SI (match_dup 0)
6899                  (const_int -1)))]
6900   "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6902   CC_STATUS_INIT;
6903   if (DATA_REG_P (operands[0]))
6904     return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6905   if (GET_CODE (operands[0]) == MEM)
6906     return "subq%.l #1,%0\;jcc %l1";
6907   return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6910 (define_expand "sibcall"
6911   [(call (match_operand:QI 0 "memory_operand" "")
6912          (match_operand:SI 1 "general_operand" ""))]
6913   ""
6915   operands[0] = m68k_legitimize_sibcall_address (operands[0]);
6918 (define_insn "*sibcall"
6919   [(call (mem:QI (match_operand:SI 0 "sibcall_operand" ""))
6920          (match_operand:SI 1 "general_operand" ""))]
6921   "SIBLING_CALL_P (insn)"
6923   return output_sibcall (operands[0]);
6926 (define_expand "sibcall_value"
6927   [(set (match_operand 0 "" "")
6928         (call (match_operand:QI 1 "memory_operand" "")
6929               (match_operand:SI 2 "general_operand" "")))]
6930   ""
6932   operands[1] = m68k_legitimize_sibcall_address (operands[1]);
6935 (define_insn "*sibcall_value"
6936   [(set (match_operand 0 "" "=rf,rf")
6937         (call (mem:QI (match_operand:SI 1 "sibcall_operand" ""))
6938               (match_operand:SI 2 "general_operand" "")))]
6939   "SIBLING_CALL_P (insn)"
6941   operands[0] = operands[1];
6942   return output_sibcall (operands[0]);
6945 ;; Call subroutine with no return value.
6946 (define_expand "call"
6947   [(call (match_operand:QI 0 "memory_operand" "")
6948          (match_operand:SI 1 "general_operand" ""))]
6949   ;; Operand 1 not really used on the m68000.
6950   ""
6952   operands[0] = m68k_legitimize_call_address (operands[0]);
6955 (define_insn "*call"
6956   [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
6957          (match_operand:SI 1 "general_operand" "g,g"))]
6958   ;; Operand 1 not really used on the m68000.
6959   "!SIBLING_CALL_P (insn)"
6961   return output_call (operands[0]);
6963   [(set_attr "type" "jsr")])
6965 ;; Call subroutine, returning value in operand 0
6966 ;; (which must be a hard register).
6967 (define_expand "call_value"
6968   [(set (match_operand 0 "" "")
6969         (call (match_operand:QI 1 "memory_operand" "")
6970               (match_operand:SI 2 "general_operand" "")))]
6971   ;; Operand 2 not really used on the m68000.
6972   ""
6974   operands[1] = m68k_legitimize_call_address (operands[1]);
6977 (define_insn "*non_symbolic_call_value"
6978   [(set (match_operand 0 "" "=rf,rf")
6979         (call (mem:QI (match_operand:SI 1 "non_symbolic_call_operand" "a,W"))
6980               (match_operand:SI 2 "general_operand" "g,g")))]
6981   ;; Operand 2 not really used on the m68000.
6982   "!SIBLING_CALL_P (insn)"
6983   "jsr %a1"
6984   [(set_attr "type" "jsr")
6985    (set_attr "opx" "1")])
6987 (define_insn "*symbolic_call_value_jsr"
6988   [(set (match_operand 0 "" "=rf,rf")
6989         (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6990               (match_operand:SI 2 "general_operand" "g,g")))]
6991   ;; Operand 2 not really used on the m68000.
6992   "!SIBLING_CALL_P (insn) && m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_JSR"
6994   operands[0] = operands[1];
6995   return m68k_symbolic_call;
6997   [(set_attr "type" "jsr")
6998    (set_attr "opx" "1")])
7000 (define_insn "*symbolic_call_value_bsr"
7001   [(set (match_operand 0 "" "=rf,rf")
7002         (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
7003               (match_operand:SI 2 "general_operand" "g,g")))]
7004   ;; Operand 2 not really used on the m68000.
7005   "!SIBLING_CALL_P (insn)
7006    && (m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_C
7007        || m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_P)"
7009   operands[0] = operands[1];
7010   return m68k_symbolic_call;
7012   [(set_attr "type" "bsr")
7013    (set_attr "opx" "1")])
7015 ;; Call subroutine returning any type.
7017 (define_expand "untyped_call"
7018   [(parallel [(call (match_operand 0 "" "")
7019                     (const_int 0))
7020               (match_operand 1 "" "")
7021               (match_operand 2 "" "")])]
7022   "NEEDS_UNTYPED_CALL"
7024   int i;
7026   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
7028   for (i = 0; i < XVECLEN (operands[2], 0); i++)
7029     {
7030       rtx set = XVECEXP (operands[2], 0, i);
7031       emit_move_insn (SET_DEST (set), SET_SRC (set));
7032     }
7034   /* The optimizer does not know that the call sets the function value
7035      registers we stored in the result block.  We avoid problems by
7036      claiming that all hard registers are used and clobbered at this
7037      point.  */
7038   emit_insn (gen_blockage ());
7040   DONE;
7043 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7044 ;; all of memory.  This blocks insns from being moved across this point.
7046 (define_insn "blockage"
7047   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
7048   ""
7049   "")
7051 (define_insn "nop"
7052   [(const_int 0)]
7053   ""
7054   "nop"
7055   [(set_attr "type" "nop")])
7057 (define_expand "prologue"
7058   [(const_int 0)]
7059   ""
7061   m68k_expand_prologue ();
7062   DONE;
7065 (define_expand "epilogue"
7066   [(return)]
7067   ""
7069   m68k_expand_epilogue (false);
7070   DONE;
7073 (define_expand "sibcall_epilogue"
7074   [(return)]
7075   ""
7077   m68k_expand_epilogue (true);
7078   DONE;
7081 ;; Used for frameless functions which save no regs and allocate no locals.
7082 (define_expand "return"
7083   [(return)]
7084   "m68k_use_return_insn ()"
7085   "")
7087 (define_insn "*return"
7088   [(return)]
7089   ""
7091   switch (m68k_get_function_kind (current_function_decl))
7092     {
7093     case m68k_fk_interrupt_handler:
7094       return "rte";
7096     case m68k_fk_interrupt_thread:
7097       return "sleep";
7099     default:
7100       if (crtl->args.pops_args)
7101         {
7102           operands[0] = GEN_INT (crtl->args.pops_args);
7103           return "rtd %0";
7104         }
7105       else
7106         return "rts";
7107     }
7109   [(set_attr "type" "rts")])
7111 (define_insn "*m68k_store_multiple"
7112   [(match_parallel 0 "" [(match_operand 1 "")])]
7113   "m68k_movem_pattern_p (operands[0], NULL, 0, true)"
7115   return m68k_output_movem (operands, operands[0], 0, true);
7118 (define_insn "*m68k_store_multiple_automod"
7119   [(match_parallel 0 ""
7120      [(set (match_operand:SI 1 "register_operand" "=a")
7121            (plus:SI (match_operand:SI 2 "register_operand" "1")
7122                     (match_operand:SI 3 "const_int_operand")))])]
7123   "m68k_movem_pattern_p (operands[0], operands[1], INTVAL (operands[3]), true)"
7125   return m68k_output_movem (operands, operands[0], INTVAL (operands[3]), true);
7128 (define_insn "*m68k_load_multiple"
7129   [(match_parallel 0 "" [(match_operand 1 "")])]
7130   "m68k_movem_pattern_p (operands[0], NULL, 0, false)"
7132   return m68k_output_movem (operands, operands[0], 0, false);
7135 (define_insn "*m68k_load_multiple_automod"
7136   [(match_parallel 0 ""
7137      [(set (match_operand:SI 1 "register_operand" "=a")
7138            (plus:SI (match_operand:SI 2 "register_operand" "1")
7139                     (match_operand:SI 3 "const_int_operand")))])]
7140   "m68k_movem_pattern_p (operands[0], operands[1],
7141                          INTVAL (operands[3]), false)"
7143   return m68k_output_movem (operands, operands[0],
7144                             INTVAL (operands[3]), false);
7147 (define_expand "link"
7148   [(parallel
7149        [(set (match_operand:SI 0 "register_operand")
7150              (plus:SI (reg:SI SP_REG) (const_int -4)))
7151         (set (match_dup 2)
7152              (match_dup 0))
7153         (set (reg:SI SP_REG)
7154              (plus:SI (reg:SI SP_REG)
7155                       (match_operand:SI 1 "const_int_operand")))])]
7156   "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7158   operands[2] = gen_frame_mem (SImode, plus_constant (stack_pointer_rtx, -4));
7161 (define_insn "*link"
7162   [(set (match_operand:SI 0 "register_operand" "+r")
7163         (plus:SI (reg:SI SP_REG) (const_int -4)))
7164    (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
7165         (match_dup 0))
7166    (set (reg:SI SP_REG)
7167         (plus:SI (reg:SI SP_REG)
7168                  (match_operand:SI 1 "const_int_operand")))]
7169   "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7171   operands[1] = GEN_INT (INTVAL (operands[1]) + 4);
7172   if (!MOTOROLA)
7173     return "link %0,%1";
7174   else if (INTVAL (operands[1]) >= -0x8000)
7175     return "link.w %0,%1";
7176   else
7177     return "link.l %0,%1";
7179   [(set_attr "type" "link")])
7181 (define_expand "unlink"
7182   [(parallel
7183       [(set (match_operand:SI 0 "register_operand")
7184             (match_dup 1))
7185        (set (reg:SI SP_REG)
7186             (plus:SI (match_dup 0)
7187                      (const_int 4)))])]
7188   ""
7190   operands[1] = gen_frame_mem (SImode, copy_rtx (operands[0]));
7193 (define_insn "*unlink"
7194   [(set (match_operand:SI 0 "register_operand" "+r")
7195         (mem:SI (match_dup 0)))
7196    (set (reg:SI SP_REG)
7197         (plus:SI (match_dup 0)
7198                  (const_int 4)))]
7199   ""
7200   "unlk %0"
7201   [(set_attr "type" "unlk")])
7203 (define_insn "load_got"
7204   [(set (match_operand:SI 0 "register_operand" "=a")
7205         (unspec:SI [(const_int 0)] UNSPEC_GOT))]
7206   ""
7208   if (TARGET_ID_SHARED_LIBRARY)
7209     {
7210       operands[1] = gen_rtx_REG (Pmode, PIC_REG);
7211       return MOTOROLA ? "move.l %?(%1),%0" : "movel %1@(%?), %0";
7212     }
7213   else if (MOTOROLA)
7214     {
7215       if (TARGET_COLDFIRE)
7216         /* Load the full 32-bit PC-relative offset of
7217            _GLOBAL_OFFSET_TABLE_ into the PIC register, then use it to
7218            calculate the absolute value.  The offset and "lea"
7219            operation word together occupy 6 bytes.  */
7220         return ("move.l #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t"
7221                 "lea (-6, %%pc, %0), %0");
7222       else
7223         return "lea (%%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %0";
7224     }
7225   else
7226     return ("movel #_GLOBAL_OFFSET_TABLE_, %0\n\t"
7227             "lea %%pc@(0,%0:l),%0");
7230 (define_insn "indirect_jump"
7231   [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
7232   ""
7233   "jmp %a0"
7234   [(set_attr "type" "jmp")])
7236 ;; This should not be used unless the add/sub insns can't be.
7238 (define_insn "*lea"
7239   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
7240         (match_operand:QI 1 "address_operand" "p"))]
7241   ""
7242   "lea %a1,%0")
7244 ;; This is the first machine-dependent peephole optimization.
7245 ;; It is useful when a floating value is returned from a function call
7246 ;; and then is moved into an FP register.
7247 ;; But it is mainly intended to test the support for these optimizations.
7249 (define_peephole2
7250   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7251    (set (match_operand:DF 0 "register_operand" "")
7252         (match_operand:DF 1 "register_operand" ""))]
7253   "FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
7254   [(set (mem:SI (reg:SI SP_REG)) (match_dup 1))
7255    (set (mem:SI (pre_dec:SI (reg:SI SP_REG))) (match_dup 2))
7256    (set (match_dup 0) (mem:DF (post_inc:SI (reg:SI SP_REG))))]
7257   "split_di(operands + 1, 1, operands + 1, operands + 2);")
7259 ;; Optimize a stack-adjust followed by a push of an argument.
7260 ;; This is said to happen frequently with -msoft-float
7261 ;; when there are consecutive library calls.
7263 (define_peephole2
7264   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7265    (set (match_operand:SF 0 "push_operand" "")
7266         (match_operand:SF 1 "general_operand" ""))]
7267   "!reg_mentioned_p (stack_pointer_rtx, operands[0])"
7268   [(set (match_dup 0) (match_dup 1))]
7269   "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7271 (define_peephole2
7272   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7273                                  (match_operand:SI 0 "const_int_operand" "")))
7274    (set (match_operand:SF 1 "push_operand" "")
7275         (match_operand:SF 2 "general_operand" ""))]
7276   "INTVAL (operands[0]) > 4
7277    && !reg_mentioned_p (stack_pointer_rtx, operands[2])"
7278   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7279    (set (match_dup 1) (match_dup 2))]
7281   operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7282   operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7285 ;; Speed up stack adjust followed by a fullword fixedpoint push.
7286 ;; Constant operands need special care, as replacing a "pea X.w" with
7287 ;; "move.l #X,(%sp)" is often not a win.
7289 ;; Already done by the previous csa pass, left as reference.
7290 (define_peephole2
7291   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7292    (set (match_operand:SI 0 "push_operand" "")
7293         (match_operand:SI 1 "general_operand" ""))]
7294   "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7295   [(set (match_dup 0) (match_dup 1))]
7296   "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7298 ;; Try to use moveq, after stack push has been changed into a simple move.
7299 (define_peephole2
7300   [(match_scratch:SI 2 "d")
7301    (set (match_operand:SI 0 "memory_operand" "")
7302         (match_operand:SI 1 "const_int_operand" ""))]
7303   "GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
7304    && INTVAL (operands[1]) != 0
7305    && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7306    && !valid_mov3q_const (INTVAL (operands[1]))"
7307   [(set (match_dup 2) (match_dup 1))
7308    (set (match_dup 0) (match_dup 2))])
7310 ;; This sequence adds an instruction, but is two bytes shorter.
7311 (define_peephole2
7312   [(match_scratch:SI 2 "d")
7313    (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 12)))
7314    (set (match_operand:SI 0 "push_operand" "")
7315         (match_operand:SI 1 "const_int_operand" ""))]
7316   "INTVAL (operands[1]) != 0
7317    && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7318    && !valid_mov3q_const (INTVAL (operands[1]))"
7319   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 8)))
7320    (set (match_dup 2) (match_dup 1))
7321    (set (match_dup 0) (match_dup 2))]
7322   "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7324 ;; Changing pea X.w into a move.l is no real win here.
7325 (define_peephole2
7326   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7327                                  (match_operand:SI 0 "const_int_operand" "")))
7328    (set (match_operand:SI 1 "push_operand" "")
7329         (match_operand:SI 2 "general_operand" ""))]
7330   "INTVAL (operands[0]) > 4
7331    && !reg_mentioned_p (stack_pointer_rtx, operands[2])
7332    && !(CONST_INT_P (operands[2]) && INTVAL (operands[2]) != 0
7333         && IN_RANGE (INTVAL (operands[2]), -0x8000, 0x7fff)
7334         && !valid_mov3q_const (INTVAL (operands[2])))"
7335   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7336    (set (match_dup 1) (match_dup 2))]
7338   operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7339   operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7342 ;; Speed up pushing a single byte/two bytes but leaving four bytes of space
7343 ;; (which differs slightly between m680x0 and ColdFire).
7345 (define_peephole2
7346   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
7347    (set (match_operand:QI 0 "memory_operand" "")
7348         (match_operand:QI 1 "register_operand" ""))]
7349   "!reg_mentioned_p (stack_pointer_rtx, operands[1])
7350    && GET_CODE (XEXP (operands[0], 0)) == PLUS
7351    && rtx_equal_p (XEXP (XEXP (operands[0], 0), 0), stack_pointer_rtx)
7352    && CONST_INT_P (XEXP (XEXP (operands[0], 0), 1))
7353    && INTVAL (XEXP (XEXP (operands[0], 0), 1)) == 3"
7354   [(set (match_dup 0) (match_dup 1))]
7356   rtx addr = gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx);
7357   operands[0] = adjust_automodify_address (operands[0], SImode, addr, -3);
7358   operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7361 (define_peephole2
7362   [(set (match_operand:QI 0 "push_operand" "")
7363         (match_operand:QI 1 "register_operand" ""))
7364    (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -3)))]
7365   "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7366   [(set (match_dup 0) (match_dup 1))]
7368   operands[0] = adjust_automodify_address (operands[0], SImode,
7369                                            XEXP (operands[0], 0), -3);
7370   operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7373 (define_peephole2
7374   [(set (match_operand:HI 0 "push_operand" "")
7375         (match_operand:HI 1 "register_operand" ""))
7376    (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))]
7377   "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7378   [(set (match_dup 0) (match_dup 1))]
7380   operands[0] = adjust_automodify_address (operands[0], SImode,
7381                                            XEXP (operands[0], 0), -2);
7382   operands[1] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
7385 ;; Optimize a series of strict_low_part assignments
7387 (define_peephole2
7388   [(set (match_operand:SI 0 "register_operand" "")
7389         (const_int 0))
7390    (set (strict_low_part (match_operand:HI 1 "register_operand" ""))
7391         (match_operand:HI 2 "general_operand" ""))]
7392   "REGNO (operands[0]) == REGNO (operands[1])
7393    && strict_low_part_peephole_ok (HImode, insn, operands[0])"
7394   [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7395   "")
7397 (define_peephole2
7398   [(set (match_operand:SI 0 "register_operand" "")
7399         (const_int 0))
7400    (set (strict_low_part (match_operand:QI 1 "register_operand" ""))
7401         (match_operand:QI 2 "general_operand" ""))]
7402   "REGNO (operands[0]) == REGNO (operands[1])
7403    && strict_low_part_peephole_ok (QImode, insn, operands[0])"
7404   [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7405   "")
7407 ;; dbCC peepholes
7409 ;; Turns
7410 ;;   loop:
7411 ;;           [ ... ]
7412 ;;           jCC label          ; abnormal loop termination
7413 ;;           dbra dN, loop      ; normal loop termination
7415 ;; Into
7416 ;;   loop:
7417 ;;           [ ... ]
7418 ;;           dbCC dN, loop
7419 ;;           jCC label
7421 ;; Which moves the jCC condition outside the inner loop for free.
7424 (define_peephole
7425   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7426                              [(cc0) (const_int 0)])
7427                            (label_ref (match_operand 2 "" ""))
7428                            (pc)))
7429    (parallel
7430     [(set (pc)
7431           (if_then_else
7432             (ne (match_operand:HI 0 "register_operand" "")
7433                 (const_int 0))
7434             (label_ref (match_operand 1 "" ""))
7435             (pc)))
7436      (set (match_dup 0)
7437           (plus:HI (match_dup 0)
7438                    (const_int -1)))])]
7439   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7441   CC_STATUS_INIT;
7442   output_dbcc_and_branch (operands);
7443   return "";
7446 (define_peephole
7447   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7448                              [(cc0) (const_int 0)])
7449                            (label_ref (match_operand 2 "" ""))
7450                            (pc)))
7451    (parallel
7452     [(set (pc)
7453           (if_then_else
7454             (ne (match_operand:SI 0 "register_operand" "")
7455                 (const_int 0))
7456             (label_ref (match_operand 1 "" ""))
7457             (pc)))
7458      (set (match_dup 0)
7459           (plus:SI (match_dup 0)
7460                    (const_int -1)))])]
7461   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7463   CC_STATUS_INIT;
7464   output_dbcc_and_branch (operands);
7465   return "";
7468 (define_peephole
7469   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7470                              [(cc0) (const_int 0)])
7471                            (label_ref (match_operand 2 "" ""))
7472                            (pc)))
7473    (parallel
7474     [(set (pc)
7475           (if_then_else
7476             (ge (plus:HI (match_operand:HI 0 "register_operand" "")
7477                          (const_int -1))
7478                 (const_int 0))
7479             (label_ref (match_operand 1 "" ""))
7480             (pc)))
7481      (set (match_dup 0)
7482           (plus:HI (match_dup 0)
7483                    (const_int -1)))])]
7484   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7486   CC_STATUS_INIT;
7487   output_dbcc_and_branch (operands);
7488   return "";
7491 (define_peephole
7492   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7493                              [(cc0) (const_int 0)])
7494                            (label_ref (match_operand 2 "" ""))
7495                            (pc)))
7496    (parallel
7497     [(set (pc)
7498           (if_then_else
7499             (ge (plus:SI (match_operand:SI 0 "register_operand" "")
7500                          (const_int -1))
7501                 (const_int 0))
7502             (label_ref (match_operand 1 "" ""))
7503             (pc)))
7504      (set (match_dup 0)
7505           (plus:SI (match_dup 0)
7506                    (const_int -1)))])]
7507   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7509   CC_STATUS_INIT;
7510   output_dbcc_and_branch (operands);
7511   return "";
7515 (define_insn "extendsfxf2"
7516   [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7517         (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
7518   "TARGET_68881"
7520   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7521     {
7522       if (REGNO (operands[0]) == REGNO (operands[1]))
7523         {
7524           /* Extending float to double in an fp-reg is a no-op.
7525              NOTICE_UPDATE_CC has already assumed that the
7526              cc will be set.  So cancel what it did.  */
7527           cc_status = cc_prev_status;
7528           return "";
7529         }
7530       return "f%$move%.x %1,%0";
7531     }
7532   if (FP_REG_P (operands[0]))
7533     {
7534       if (FP_REG_P (operands[1]))
7535         return "f%$move%.x %1,%0";
7536       else if (ADDRESS_REG_P (operands[1]))
7537         return "move%.l %1,%-\;f%$move%.s %+,%0";
7538       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
7539         return output_move_const_single (operands);
7540       return "f%$move%.s %f1,%0";
7541     }
7542   return "fmove%.x %f1,%0";
7546 (define_insn "extenddfxf2"
7547   [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7548         (float_extend:XF
7549           (match_operand:DF 1 "general_operand" "f,rmE")))]
7550   "TARGET_68881"
7552   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7553     {
7554       if (REGNO (operands[0]) == REGNO (operands[1]))
7555         {
7556           /* Extending float to double in an fp-reg is a no-op.
7557              NOTICE_UPDATE_CC has already assumed that the
7558              cc will be set.  So cancel what it did.  */
7559           cc_status = cc_prev_status;
7560           return "";
7561         }
7562       return "fmove%.x %1,%0";
7563     }
7564   if (FP_REG_P (operands[0]))
7565     {
7566       if (REG_P (operands[1]))
7567         {
7568           rtx xoperands[2];
7569           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
7570           output_asm_insn ("move%.l %1,%-", xoperands);
7571           output_asm_insn ("move%.l %1,%-", operands);
7572           return "f%&move%.d %+,%0";
7573         }
7574       if (GET_CODE (operands[1]) == CONST_DOUBLE)
7575         return output_move_const_double (operands);
7576       return "f%&move%.d %f1,%0";
7577     }
7578   return "fmove%.x %f1,%0";
7581 (define_insn "truncxfdf2"
7582   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
7583         (float_truncate:DF
7584           (match_operand:XF 1 "general_operand" "f,f")))]
7585   "TARGET_68881"
7587   if (REG_P (operands[0]))
7588     {
7589       output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
7590       operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
7591       return "move%.l %+,%0";
7592     }
7593   return "fmove%.d %f1,%0";
7596 (define_insn "truncxfsf2"
7597   [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
7598         (float_truncate:SF
7599           (match_operand:XF 1 "general_operand" "f")))]
7600   "TARGET_68881"
7601   "fmove%.s %f1,%0")
7603 (define_insn "sin<mode>2"
7604   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7605         (unspec:FP
7606           [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
7607   "TARGET_68881 && flag_unsafe_math_optimizations"
7609   if (FP_REG_P (operands[1]))
7610     return "fsin%.x %1,%0";
7611   else
7612     return "fsin%.<FP:prec> %1,%0";
7615 (define_insn "cos<mode>2"
7616   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7617         (unspec:FP
7618           [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
7619   "TARGET_68881 && flag_unsafe_math_optimizations"
7621   if (FP_REG_P (operands[1]))
7622     return "fcos%.x %1,%0";
7623   else
7624     return "fcos%.<FP:prec> %1,%0";
7627 ;; Unconditional traps are assumed to have (const_int 1) for the condition.
7628 (define_insn "trap"
7629   [(trap_if (const_int 1) (const_int 7))]
7630   ""
7631   "trap #7"
7632   [(set_attr "type" "trap")])
7634 (define_expand "conditional_trap"
7635   [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
7636                             [(cc0) (const_int 0)])
7637             (match_operand:SI 1 "const_int_operand" "I"))]
7638   "TARGET_68020"
7640   if (m68k_last_compare_had_fp_operands)
7641     {
7642       m68k_last_compare_had_fp_operands = 0;
7643       FAIL;
7644     }
7647 (define_insn "*conditional_trap"
7648   [(trap_if (match_operator 0 "valid_dbcc_comparison_p"
7649                             [(cc0) (const_int 0)])
7650             (match_operand:SI 1 "const_int_operand" "I"))]
7651   "TARGET_68020 && ! flags_in_68881 ()"
7653   switch (GET_CODE (operands[0]))
7654   {
7655   case EQ:  return "trapeq";
7656   case NE:  return "trapne";
7657   case GT:  return "trapgt";
7658   case GTU: return "traphi";
7659   case LT:  return "traplt";
7660   case LTU: return "trapcs";
7661   case GE:  return "trapge";
7662   case GEU: return "trapcc";
7663   case LE:  return "traple";
7664   case LEU: return "trapls";
7665   default: gcc_unreachable ();
7666   }
7669 ;; These are to prevent the scheduler from moving stores to the frame
7670 ;; before the stack adjustment.
7671 (define_insn "stack_tie"
7672   [(set (mem:BLK (scratch))
7673         (unspec:BLK [(match_operand:SI 0 "register_operand" "r")
7674                      (match_operand:SI 1 "register_operand" "r")]
7675                     UNSPEC_TIE))]
7676   ""
7677   ""
7678   [(set_attr "type" "ignore")])
7680 ;; Instruction that subscribes one word in ColdFire instruction buffer.
7681 ;; This instruction is used within scheduler only and should not appear
7682 ;; in the instruction stream.
7683 (define_insn "ib"
7684   [(unspec [(const_int 0)] UNSPEC_IB)]
7685   ""
7686   "#"
7687   [(set_attr "type" "ib")])
7689 (include "cf.md")