2009-07-17 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / gcc / config / m68k / m68k.md
blob037bb372cc996b38386012be0a6ec3a4b98b2de9
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, 2008
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    (UNSPEC_RELOC16 6)
120    (UNSPEC_RELOC32 7)
121   ])
123 ;; UNSPEC_VOLATILE usage:
125 (define_constants
126   [(UNSPECV_BLOCKAGE    0)
127   ])
129 ;; Registers by name.
130 (define_constants
131   [(D0_REG              0)
132    (A0_REG              8)
133    (A1_REG              9)
134    (PIC_REG             13)
135    (A6_REG              14)
136    (SP_REG              15)
137    (FP0_REG             16)
138   ])
140 (include "predicates.md")
141 (include "constraints.md")
143 ;; ::::::::::::::::::::
144 ;; ::
145 ;; :: Attributes
146 ;; ::
147 ;; ::::::::::::::::::::
149 ;; Processor type.
150 (define_attr "cpu" "cfv1, cfv2, cfv3, cfv4, unknown"
151   (const (symbol_ref "m68k_sched_cpu")))
153 ;; MAC type.
154 (define_attr "mac" "no, cf_mac, cf_emac"
155   (const (symbol_ref "m68k_sched_mac")))
157 ;; Instruction type for use in scheduling description.
158 ;; _l and _w suffixes indicate size of the operands of instruction.
159 ;; alu - usual arithmetic or logic instruction.
160 ;; aluq - arithmetic or logic instruction which has a quick immediate (the one
161 ;;        that is encoded in the instruction word) for its Y operand.
162 ;; alux - Arithmetic instruction that uses carry bit (e.g., addx and subx).
163 ;; bcc - conditional branch.
164 ;; bitr - bit operation that only updates flags.
165 ;; bitrw - bit operation that updates flags and output operand.
166 ;; bra, bsr, clr, cmp, div, ext - corresponding instruction.
167 ;; falu, fbcc, fcmp, fdiv, fmove, fmul, fneg, fsqrt, ftst - corresponding
168 ;;                                                          instruction.
169 ;; ib - fake instruction to subscribe slots in ColdFire V1,V2,V3 instruction
170 ;;      buffer.
171 ;; ignore - fake instruction.
172 ;; jmp, jsr, lea, link, mov3q, move, moveq, mul - corresponding instruction.
173 ;; mvsz - mvs or mvz instruction.
174 ;; neg, nop, pea, rts, scc - corresponding instruction.
175 ;; shift - arithmetic or logical shift instruction.
176 ;; trap, tst, unlk - corresponding instruction.
177 (define_attr "type"
178   "alu_l,aluq_l,alux_l,bcc,bitr,bitrw,bra,bsr,clr,clr_l,cmp,cmp_l,
179    div_w,div_l,ext,
180    falu,fbcc,fcmp,fdiv,fmove,fmul,fneg,fsqrt,ftst,
181    ib,ignore,
182    jmp,jsr,lea,link,mov3q_l,move,move_l,moveq_l,mul_w,mul_l,mvsz,neg_l,nop,
183    pea,rts,scc,shift,
184    trap,tst,tst_l,unlk,
185    unknown"
186   (const_string "unknown"))
188 ;; Index of the X or Y operand in recog_data.operand[].
189 ;; Should be used only within opx_type and opy_type.
190 (define_attr "opx" "" (const_int 0))
191 (define_attr "opy" "" (const_int 1))
193 ;; Type of the Y operand.
194 ;; See m68k.c: enum attr_op_type.
195 (define_attr "opy_type"
196   "none,Rn,FPn,mem1,mem234,mem5,mem6,mem7,imm_q,imm_w,imm_l"
197   (cond [(eq_attr "type" "ext,fbcc,ftst,neg_l,bcc,bra,bsr,clr,clr_l,ib,ignore,
198                           jmp,jsr,nop,rts,scc,trap,tst,tst_l,
199                           unlk,unknown") (const_string "none")
200          (eq_attr "type" "lea,pea")
201          (symbol_ref "m68k_sched_attr_opy_type (insn, 1)")]
202         (symbol_ref "m68k_sched_attr_opy_type (insn, 0)")))
204 ;; Type of the X operand.
205 ;; See m68k.c: enum attr_op_type.
206 (define_attr "opx_type"
207   "none,Rn,FPn,mem1,mem234,mem5,mem6,mem7,imm_q,imm_w,imm_l"
208   (cond [(eq_attr "type" "ib,ignore,nop,rts,trap,unlk,
209                           unknown") (const_string "none")
210          (eq_attr "type" "pea") (const_string "mem1")
211          (eq_attr "type" "jmp,jsr")
212          (symbol_ref "m68k_sched_attr_opx_type (insn, 1)")]
213         (symbol_ref "m68k_sched_attr_opx_type (insn, 0)")))
215 ;; Access to the X operand: none, read, write, read/write, unknown.
216 ;; Access to the Y operand is either none (if opy_type is none)
217 ;; or read otherwise.
218 (define_attr "opx_access" "none, r, w, rw"
219   (cond [(eq_attr "type" "ib,ignore,nop,rts,trap,unlk,
220                           unknown") (const_string "none")
221          (eq_attr "type" "bcc,bra,bsr,bitr,cmp,cmp_l,fbcc,fcmp,ftst,
222                           jmp,jsr,tst,tst_l") (const_string "r")
223          (eq_attr "type" "clr,clr_l,fneg,fmove,lea,
224                           mov3q_l,move,move_l,moveq_l,mvsz,
225                           pea,scc") (const_string "w")
226          (eq_attr "type" "alu_l,aluq_l,alux_l,bitrw,div_w,div_l,ext,
227                           falu,fdiv,fmul,fsqrt,link,mul_w,mul_l,
228                           neg_l,shift") (const_string "rw")]
229         ;; Should never be used.
230         (symbol_ref "(gcc_unreachable (), OPX_ACCESS_NONE)")))
232 ;; Memory accesses of the insn.
233 ;; 00 - no memory references
234 ;; 10 - memory is read
235 ;; i0 - indexed memory is read
236 ;; 01 - memory is written
237 ;; 0i - indexed memory is written
238 ;; 11 - memory is read, memory is written
239 ;; i1 - indexed memory is read, memory is written
240 ;; 1i - memory is read, indexed memory is written
241 (define_attr "op_mem" "00, 10, i0, 01, 0i, 11, i1, 1i"
242   (symbol_ref "m68k_sched_attr_op_mem (insn)"))
244 ;; Instruction size in words.
245 (define_attr "size" "1,2,3"
246   (symbol_ref "m68k_sched_attr_size (insn)"))
248 ;; Alternative is OK for ColdFire.
249 (define_attr "ok_for_coldfire" "yes,no" (const_string "yes"))
251 ;; Define 'enabled' attribute.
252 (define_attr "enabled" ""
253   (cond [(and (ne (symbol_ref "TARGET_COLDFIRE") (const_int 0))
254               (eq_attr "ok_for_coldfire" "no"))
255          (const_int 0)]
256         (const_int 1)))
258 ;; Mode macros for floating point operations.
259 ;; Valid floating point modes
260 (define_mode_iterator FP [SF DF (XF "TARGET_68881")])
261 ;; Mnemonic infix to round result
262 (define_mode_attr round [(SF "%$") (DF "%&") (XF "")])
263 ;; Mnemonic infix to round result for mul or div instruction
264 (define_mode_attr round_mul [(SF "sgl") (DF "%&") (XF "")])
265 ;; Suffix specifying source operand format
266 (define_mode_attr prec [(SF "s") (DF "d") (XF "x")])
267 ;; Allowable D registers
268 (define_mode_attr dreg [(SF "d") (DF "") (XF "")])
269 ;; Allowable 68881 constant constraints
270 (define_mode_attr const [(SF "F") (DF "G") (XF "")])
273 (define_insn_and_split "*movdf_internal"
274   [(set (match_operand:DF 0 "push_operand"   "=m, m")
275         (match_operand:DF 1 "general_operand" "f, ro<>E"))]
276   ""
277   "@
278    fmove%.d %f1,%0
279    #"
280   "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 1)"
281   [(const_int 0)]
283   m68k_emit_move_double (operands);
284   DONE;
286   [(set_attr "type" "fmove,*")])
288 (define_insn_and_split "pushdi"
289   [(set (match_operand:DI 0 "push_operand" "=m")
290         (match_operand:DI 1 "general_operand" "ro<>Fi"))]
291   ""
292   "#"
293   "&& reload_completed"
294   [(const_int 0)]
296   m68k_emit_move_double (operands);
297   DONE;
300 ;; We don't want to allow a constant operand for test insns because
301 ;; (set (cc0) (const_int foo)) has no mode information.  Such insns will
302 ;; be folded while optimizing anyway.
304 (define_insn "tstdi"
305   [(set (cc0)
306         (compare (match_operand:DI 0 "nonimmediate_operand" "am,d")
307                  (const_int 0)))
308    (clobber (match_scratch:SI 1 "=X,d"))
309    (clobber (match_scratch:DI 2 "=d,X"))]
310   ""
312   if (which_alternative == 0)
313     {
314       rtx xoperands[2];
316       xoperands[0] = operands[2];
317       xoperands[1] = operands[0];
318       output_move_double (xoperands);
319       cc_status.flags |= CC_REVERSED; /*|*/
320       return "neg%.l %R2\;negx%.l %2";
321     }
322   if (find_reg_note (insn, REG_DEAD, operands[0]))
323     {
324       cc_status.flags |= CC_REVERSED; /*|*/
325       return "neg%.l %R0\;negx%.l %0";
326     }
327   else
328     /*
329        'sub' clears %1, and also clears the X cc bit
330        'tst' sets the Z cc bit according to the low part of the DImode operand
331        'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part.
332     */
333     return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
336 ;; If you think that the 68020 does not support tstl a0,
337 ;; reread page B-167 of the 68020 manual more carefully.
338 (define_insn "*tstsi_internal_68020_cf"
339   [(set (cc0)
340         (compare (match_operand:SI 0 "nonimmediate_operand" "rm")
341                  (const_int 0)))]
342   "TARGET_68020 || TARGET_COLDFIRE"
343   "tst%.l %0"
344   [(set_attr "type" "tst_l")])
346 ;; On an address reg, cmpw may replace cmpl.
347 (define_insn "*tstsi_internal"
348   [(set (cc0)
349         (compare (match_operand:SI 0 "nonimmediate_operand" "dm,r")
350                  (const_int 0)))]
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_insn "*tsthi_internal"
360   [(set (cc0)
361         (compare (match_operand:HI 0 "nonimmediate_operand" "dm")
362                  (const_int 0)))]
363   ""
364   "tst%.w %0"
365   [(set_attr "type" "tst")])
367 (define_insn "*tstqi_internal"
368   [(set (cc0)
369         (compare (match_operand:QI 0 "nonimmediate_operand" "dm")
370                  (const_int 0)))]
371   ""
372   "tst%.b %0"
373   [(set_attr "type" "tst")])
375 (define_insn "tst<mode>_68881"
376   [(set (cc0)
377         (compare (match_operand:FP 0 "general_operand" "f<FP:dreg>m")
378                  (match_operand:FP 1 "const0_operand" "H")))]
379   "TARGET_68881"
381   cc_status.flags = CC_IN_68881;
382   if (FP_REG_P (operands[0]))
383     return "ftst%.x %0";
384   return "ftst%.<FP:prec> %0";
386   [(set_attr "type" "ftst")])
388 (define_insn "tst<mode>_cf"
389   [(set (cc0)
390         (compare (match_operand:FP 0 "general_operand" "f<FP:dreg><Q>U")
391                  (match_operand:FP 1 "const0_operand" "H")))]
392   "TARGET_COLDFIRE_FPU"
394   cc_status.flags = CC_IN_68881;
395   if (FP_REG_P (operands[0]))
396     return "ftst%.d %0";
397   return "ftst%.<FP:prec> %0";
399   [(set_attr "type" "ftst")])
402 ;; compare instructions.
404 (define_insn "*cmpdi_internal"
405  [(set (cc0)
406        (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
407                 (match_operand:DI 2 "general_operand" "d,0")))
408   (clobber (match_scratch:DI 0 "=d,d"))]
409   ""
411   if (rtx_equal_p (operands[0], operands[1]))
412     return "sub%.l %R2,%R0\;subx%.l %2,%0";
413   else
414     {
415       cc_status.flags |= CC_REVERSED; /*|*/
416       return "sub%.l %R1,%R0\;subx%.l %1,%0";
417     }
420 (define_insn "cmpdi"
421  [(set (cc0)
422        (compare (match_operand:DI 0 "nonimmediate_operand")
423                 (match_operand:DI 1 "general_operand")))
424   (clobber (match_scratch:DI 2))]
425   ""
426   "")
429 (define_expand "cbranchdi4"
430   [(set (pc)
431         (if_then_else (match_operator 0 "ordered_comparison_operator"
432                        [(match_operand:DI 1 "nonimmediate_operand")
433                         (match_operand:DI 2 "general_operand")])
434                       (label_ref (match_operand 3 ""))
435                       (pc)))]
436   ""
438   if (operands[2] == const0_rtx)
439     emit_insn (gen_tstdi (operands[1]));
440   else
441     emit_insn (gen_cmpdi (operands[1], operands[2]));
442   operands[1] = cc0_rtx;
443   operands[2] = const0_rtx;
446 (define_expand "cstoredi4"
447   [(set (match_operand:QI 0 "register_operand")
448         (match_operator:QI 1 "ordered_comparison_operator"
449          [(match_operand:DI 2 "nonimmediate_operand")
450           (match_operand:DI 3 "general_operand")]))]
451   ""
453   if (operands[3] == const0_rtx)
454     emit_insn (gen_tstdi (operands[2]));
455   else
456     emit_insn (gen_cmpdi (operands[2], operands[3]));
457   operands[2] = cc0_rtx;
458   operands[3] = const0_rtx;
462 (define_expand "cbranchsi4"
463   [(set (cc0)
464         (compare (match_operand:SI 1 "nonimmediate_operand" "")
465                  (match_operand:SI 2 "general_operand" "")))
466    (set (pc)
467         (if_then_else (match_operator 0 "ordered_comparison_operator"
468                        [(cc0) (const_int 0)])
469                       (label_ref (match_operand 3 ""))
470                       (pc)))]
471   ""
472   "")
474 (define_expand "cstoresi4"
475   [(set (cc0)
476         (compare (match_operand:SI 2 "nonimmediate_operand" "")
477                  (match_operand:SI 3 "general_operand" "")))
478    (set (match_operand:QI 0 "register_operand")
479         (match_operator:QI 1 "ordered_comparison_operator"
480          [(cc0) (const_int 0)]))]
481   ""
482   "")
485 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
486 (define_insn ""
487   [(set (cc0)
488         (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
489                  (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
490   "!TARGET_COLDFIRE"
492   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
493     return "cmpm%.l %1,%0";
494   if (REG_P (operands[1])
495       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
496     {
497       cc_status.flags |= CC_REVERSED; /*|*/
498       return "cmp%.l %d0,%d1";
499     }
500   if (ADDRESS_REG_P (operands[0])
501       && GET_CODE (operands[1]) == CONST_INT
502       && INTVAL (operands[1]) < 0x8000
503       && INTVAL (operands[1]) >= -0x8000)
504     return "cmp%.w %1,%0";
505   return "cmp%.l %d1,%d0";
508 (define_insn "*cmpsi_cf"
509   [(set (cc0)
510         (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
511                  (match_operand:SI 1 "general_operand" "r,mrKs")))]
512   "TARGET_COLDFIRE"
514   if (REG_P (operands[1])
515       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
516     {
517       cc_status.flags |= CC_REVERSED; /*|*/
518       return "cmp%.l %d0,%d1";
519     }
520   return "cmp%.l %d1,%d0";
522   [(set_attr "type" "cmp_l")])
524 (define_expand "cbranchhi4"
525   [(set (cc0)
526         (compare (match_operand:HI 1 "nonimmediate_src_operand" "")
527                  (match_operand:HI 2 "m68k_subword_comparison_operand" "")))
528    (set (pc)
529         (if_then_else (match_operator 0 "ordered_comparison_operator"
530                        [(cc0) (const_int 0)])
531                       (label_ref (match_operand 3 ""))
532                       (pc)))]
533   ""
534   "")
536 (define_expand "cstorehi4"
537   [(set (cc0)
538         (compare (match_operand:HI 2 "nonimmediate_operand" "")
539                  (match_operand:HI 3 "m68k_subword_comparison_operand" "")))
540    (set (match_operand:QI 0 "register_operand")
541         (match_operator:QI 1 "ordered_comparison_operator"
542          [(cc0) (const_int 0)]))]
543   ""
544   "")
546 (define_insn ""
547   [(set (cc0)
548         (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
549                  (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
550   "!TARGET_COLDFIRE"
552   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
553     return "cmpm%.w %1,%0";
554   if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
555       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
556     {
557       cc_status.flags |= CC_REVERSED; /*|*/
558       return "cmp%.w %d0,%d1";
559     }
560   return "cmp%.w %d1,%d0";
563 (define_expand "cbranchqi4"
564   [(set (cc0)
565         (compare (match_operand:QI 1 "nonimmediate_src_operand" "")
566                  (match_operand:QI 2 "m68k_subword_comparison_operand" "")))
567    (set (pc)
568         (if_then_else (match_operator 0 "ordered_comparison_operator"
569                        [(cc0) (const_int 0)])
570                       (label_ref (match_operand 3 ""))
571                       (pc)))]
572   ""
573   "")
575 (define_expand "cstoreqi4"
576   [(set (cc0)
577         (compare (match_operand:QI 2 "nonimmediate_src_operand" "")
578                  (match_operand:QI 3 "m68k_subword_comparison_operand" "")))
579    (set (match_operand:QI 0 "register_operand")
580         (match_operator:QI 1 "ordered_comparison_operator"
581          [(cc0) (const_int 0)]))]
582   ""
583   "")
585 (define_insn ""
586   [(set (cc0)
587         (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
588                  (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
589   "!TARGET_COLDFIRE"
591   if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
592     return "cmpm%.b %1,%0";
593   if (REG_P (operands[1])
594       || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
595     {
596       cc_status.flags |= CC_REVERSED; /*|*/
597       return "cmp%.b %d0,%d1";
598     }
599   return "cmp%.b %d1,%d0";
602 (define_expand "cbranch<mode>4"
603   [(set (cc0)
604         (compare (match_operand:FP 1 "register_operand" "")
605                  (match_operand:FP 2 "fp_src_operand" "")))
606    (set (pc)
607         (if_then_else (match_operator 0 "comparison_operator"
608                        [(cc0) (const_int 0)])
609                       (label_ref (match_operand 3 ""))
610                       (pc)))]
611   "TARGET_HARD_FLOAT"
612   "")
614 (define_expand "cstore<mode>4"
615   [(set (cc0)
616         (compare (match_operand:FP 2 "register_operand" "")
617                  (match_operand:FP 3 "fp_src_operand" "")))
618    (set (match_operand:QI 0 "register_operand")
619         (match_operator:QI 1 "m68k_cstore_comparison_operator"
620          [(cc0) (const_int 0)]))]
621   "TARGET_HARD_FLOAT && !(TUNE_68060 || TARGET_COLDFIRE_FPU)"
622   "if (TARGET_COLDFIRE && operands[2] != const0_rtx)
623      FAIL;")
625 (define_insn "*cmp<mode>_68881"
626   [(set (cc0)
627         (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg>mF")
628                  (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg>mF,f")))]
629   "TARGET_68881
630    && (register_operand (operands[0], <MODE>mode)
631        || register_operand (operands[1], <MODE>mode))"
632   "@
633    fcmp%.x %1,%0
634    fcmp%.<FP:prec> %f1,%0
635    fcmp%.<FP:prec> %0,%f1"
636   [(set_attr "type" "fcmp")])
638 (define_insn "*cmp<mode>_cf"
639   [(set (cc0)
640         (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg><Q>U")
641                  (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg><Q>U,f")))]
642   "TARGET_COLDFIRE_FPU
643    && (register_operand (operands[0], <MODE>mode)
644        || register_operand (operands[1], <MODE>mode))"
645   "@
646    fcmp%.d %1,%0
647    fcmp%.<FP:prec> %f1,%0
648    fcmp%.<FP:prec> %0,%f1"
649   [(set_attr "type" "fcmp")])
651 ;; Recognizers for btst instructions.
653 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
654 ;; specified as a constant, so we must disable all patterns that may extract
655 ;; from a MEM at a constant bit position if we can't use this as a constraint.
657 (define_insn ""
658   [(set
659     (cc0)
660     (compare (zero_extract:SI (match_operand:QI 0 "memory_src_operand" "oS")
661                                (const_int 1)
662                                (minus:SI (const_int 7)
663                                          (match_operand:SI 1 "general_operand" "di")))
664              (const_int 0)))]
665   "!TARGET_COLDFIRE"
667   return output_btst (operands, operands[1], operands[0], insn, 7);
670 ;; This is the same as the above pattern except for the constraints.  The 'i'
671 ;; has been deleted.
673 (define_insn ""
674   [(set
675     (cc0)
676     (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
677                                (const_int 1)
678                                (minus:SI (const_int 7)
679                                          (match_operand:SI 1 "general_operand" "d")))
680              (const_int 0)))]
681   "TARGET_COLDFIRE"
683   return output_btst (operands, operands[1], operands[0], insn, 7);
686 (define_insn ""
687   [(set
688     (cc0)
689     (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
690                                (const_int 1)
691                                (minus:SI (const_int 31)
692                                          (match_operand:SI 1 "general_operand" "di")))
693              (const_int 0)))]
694   ""
696   return output_btst (operands, operands[1], operands[0], insn, 31);
699 ;; The following two patterns are like the previous two
700 ;; except that they use the fact that bit-number operands
701 ;; are automatically masked to 3 or 5 bits.
703 (define_insn ""
704   [(set
705     (cc0)
706     (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
707                                (const_int 1)
708                                (minus:SI (const_int 7)
709                                          (and:SI
710                                           (match_operand:SI 1 "register_operand" "d")
711                                           (const_int 7))))
712              (const_int 0)))]
713   ""
715   return output_btst (operands, operands[1], operands[0], insn, 7);
718 (define_insn ""
719   [(set
720     (cc0)
721     (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
722                                (const_int 1)
723                                (minus:SI (const_int 31)
724                                          (and:SI
725                                           (match_operand:SI 1 "register_operand" "d")
726                                           (const_int 31))))
727              (const_int 0)))]
728   ""
730   return output_btst (operands, operands[1], operands[0], insn, 31);
733 ;; Nonoffsettable mem refs are ok in this one pattern
734 ;; since we don't try to adjust them.
735 (define_insn ""
736   [(set
737     (cc0)
738     (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "m")
739                               (const_int 1)
740                               (match_operand:SI 1 "const_int_operand" "n"))
741              (const_int 0)))]
742   "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
744   operands[1] = GEN_INT (7 - INTVAL (operands[1]));
745   return output_btst (operands, operands[1], operands[0], insn, 7);
748 (define_insn ""
749   [(set
750     (cc0)
751     (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "do")
752                               (const_int 1)
753                             (match_operand:SI 1 "const_int_operand" "n"))
754              (const_int 0)))]
755   "!TARGET_COLDFIRE"
757   if (GET_CODE (operands[0]) == MEM)
758     {
759       operands[0] = adjust_address (operands[0], QImode,
760                                     INTVAL (operands[1]) / 8);
761       operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
762       return output_btst (operands, operands[1], operands[0], insn, 7);
763     }
764   operands[1] = GEN_INT (31 - INTVAL (operands[1]));
765   return output_btst (operands, operands[1], operands[0], insn, 31);
768 ;; This is the same as the above pattern except for the constraints.
769 ;; The 'o' has been replaced with 'Q'.
771 (define_insn ""
772   [(set
773     (cc0)
774     (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "dQ")
775                               (const_int 1)
776                               (match_operand:SI 1 "const_int_operand" "n"))
777              (const_int 0)))]
778   "TARGET_COLDFIRE"
780   if (GET_CODE (operands[0]) == MEM)
781     {
782       operands[0] = adjust_address (operands[0], QImode,
783                                     INTVAL (operands[1]) / 8);
784       operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
785       return output_btst (operands, operands[1], operands[0], insn, 7);
786     }
787   operands[1] = GEN_INT (31 - INTVAL (operands[1]));
788   return output_btst (operands, operands[1], operands[0], insn, 31);
792 ;; move instructions
794 ;; A special case in which it is not desirable
795 ;; to reload the constant into a data register.
796 (define_insn "pushexthisi_const"
797   [(set (match_operand:SI 0 "push_operand" "=m,m,m")
798         (match_operand:SI 1 "const_int_operand" "C0,R,J"))]
799   "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
800   "@
801    clr%.l %0
802    mov3q%.l %1,%-
803    pea %a1"
804   [(set_attr "type" "clr_l,mov3q_l,pea")])
806 ;This is never used.
807 ;(define_insn "swapsi"
808 ;  [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
809 ;       (match_operand:SI 1 "general_operand" "+r"))
810 ;   (set (match_dup 1) (match_dup 0))]
811 ;  ""
812 ;  "exg %1,%0")
814 ;; Special case of fullword move when source is zero for 68000_10.
815 ;; moveq is faster on the 68000.
816 (define_insn "*movsi_const0_68000_10"
817   [(set (match_operand:SI 0 "movsi_const0_operand" "=d,a,g")
818         (const_int 0))]
819   "TUNE_68000_10"
820   "@
821    moveq #0,%0
822    sub%.l %0,%0
823    clr%.l %0"
824   [(set_attr "type" "moveq_l,alu_l,clr_l")
825    (set_attr "opy" "*,0,*")])
827 ;; Special case of fullword move when source is zero for 68040_60.
828 ;; On the '040, 'subl an,an' takes 2 clocks while lea takes only 1
829 (define_insn "*movsi_const0_68040_60"
830   [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
831         (const_int 0))]
832   "TUNE_68040_60"
834   if (which_alternative == 0)
835     return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
836   else if (which_alternative == 1)
837     return "clr%.l %0";
838   else
839     {
840       gcc_unreachable ();
841       return "";
842     }
844   [(set_attr "type" "lea,clr_l")])
846 ;; Special case of fullword move when source is zero.
847 (define_insn "*movsi_const0"
848   [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
849         (const_int 0))]
850   "!(TUNE_68000_10 || TUNE_68040_60)"
851   "@
852    sub%.l %0,%0
853    clr%.l %0"
854   [(set_attr "type" "alu_l,clr_l")
855    (set_attr "opy" "0,*")])
857 ;; General case of fullword move.
859 ;; This is the main "hook" for PIC code.  When generating
860 ;; PIC, movsi is responsible for determining when the source address
861 ;; needs PIC relocation and appropriately calling legitimize_pic_address
862 ;; to perform the actual relocation.
864 ;; In both the PIC and non-PIC cases the patterns generated will
865 ;; matched by the next define_insn.
866 (define_expand "movsi"
867   [(set (match_operand:SI 0 "" "")
868         (match_operand:SI 1 "" ""))]
869   ""
871   rtx tmp, base, offset;
873   /* Recognize the case where operand[1] is a reference to thread-local
874      data and load its address to a register.  */
875   if (!TARGET_PCREL && m68k_tls_reference_p (operands[1], false))
876     {
877       rtx tmp = operands[1];
878       rtx addend = NULL;
880       if (GET_CODE (tmp) == CONST && GET_CODE (XEXP (tmp, 0)) == PLUS)
881         {
882           addend = XEXP (XEXP (tmp, 0), 1);
883           tmp = XEXP (XEXP (tmp, 0), 0);
884         }
886       gcc_assert (GET_CODE (tmp) == SYMBOL_REF);
887       gcc_assert (SYMBOL_REF_TLS_MODEL (tmp) != 0);
889       tmp = m68k_legitimize_tls_address (tmp);
891       if (addend)
892         {
893           if (!REG_P (tmp))
894             {
895               rtx reg;
897               reg = gen_reg_rtx (Pmode);
898               emit_move_insn (reg, tmp);
899               tmp = reg;
900             }
902           tmp = gen_rtx_PLUS (SImode, tmp, addend);
903         }
905       operands[1] = tmp;
906     }
907   else if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
908     {
909       /* The source is an address which requires PIC relocation.
910          Call legitimize_pic_address with the source, mode, and a relocation
911          register (a new pseudo, or the final destination if reload_in_progress
912          is set).   Then fall through normally */
913       rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
914       operands[1] = legitimize_pic_address (operands[1], SImode, temp);
915     }
916   else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
917     {
918       /* Don't allow writes to memory except via a register;
919          the m68k doesn't consider PC-relative addresses to be writable.  */
920       if (symbolic_operand (operands[0], SImode))
921         operands[0] = force_reg (SImode, XEXP (operands[0], 0));
922       else if (GET_CODE (operands[0]) == MEM
923                && symbolic_operand (XEXP (operands[0], 0), SImode))
924         operands[0] = gen_rtx_MEM (SImode,
925                                force_reg (SImode, XEXP (operands[0], 0)));
926     }
927   if (M68K_OFFSETS_MUST_BE_WITHIN_SECTIONS_P)
928     {
929       split_const (operands[1], &base, &offset);
930       if (GET_CODE (base) == SYMBOL_REF
931           && !offset_within_block_p (base, INTVAL (offset)))
932         {
933           tmp = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (SImode);
934           emit_move_insn (tmp, base);
935           emit_insn (gen_addsi3 (operands[0], tmp, offset));
936           DONE;
937         }
938     }
941 ;; General case of fullword move.
942 (define_insn "*movsi_m68k"
943   ;; Notes: make sure no alternative allows g vs g.
944   ;; We don't allow f-regs since fixed point cannot go in them.
945   [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
946         (match_operand:SI 1 "general_src_operand" "damSnT,n,i"))]
947   "!TARGET_COLDFIRE && reload_completed"
949   return output_move_simode (operands);
952 ;; Before reload is completed the register constraints
953 ;; force integer constants in range for a moveq to be reloaded
954 ;; if they are headed for memory.
955 (define_insn "*movsi_m68k2"
956   [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
957         (match_operand:SI 1 "general_src_operand" "damSKT,n,i"))]
959   "!TARGET_COLDFIRE"
961   return output_move_simode (operands);
964 ;; ColdFire move instructions can have at most one operand of mode >= 6.
965 (define_insn "*movsi_cf"
966   [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d, d, d, d, d, a,Ap,  a,  r<Q>,g,    U")
967         (match_operand:SI 1 "general_operand"      " R,CQ,CW,CZ,CS,Ci,J,J Cs,Cs, g,   Rr<Q>,U"))]
968   "TARGET_COLDFIRE"
970   switch (which_alternative)
971     {
972     case 0:
973       return "mov3q%.l %1,%0";
975     case 1:
976       return "moveq %1,%0";
978     case 2:
979       {
980         unsigned u = INTVAL (operands[1]);
982         operands[1] = GEN_INT ((u << 16) | (u >> 16));  /*|*/
983         return "moveq %1,%0\n\tswap %0";
984       }
986     case 3:
987       return "mvz%.w %1,%0";
989     case 4:
990       return "mvs%.w %1,%0";
992     case 5:
993       return "move%.l %1,%0";
995     case 6:
996       return "move%.w %1,%0";
998     case 7:
999       return "pea %a1";
1001     case 8:
1002       return "lea %a1,%0";
1004     case 9:
1005     case 10:
1006     case 11:
1007       return "move%.l %1,%0";
1009     default:
1010       gcc_unreachable ();
1011       return "";
1012     }
1014   [(set_attr "type" "mov3q_l,moveq_l,*,mvsz,mvsz,move_l,move,pea,lea,move_l,move_l,move_l")])
1016 ;; Special case of fullword move, where we need to get a non-GOT PIC
1017 ;; reference into an address register.
1018 (define_insn ""
1019   [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
1020         (match_operand:SI 1 "pcrel_address" ""))]
1021   "TARGET_PCREL"
1023   if (push_operand (operands[0], SImode))
1024     return "pea %a1";
1025   return "lea %a1,%0";
1028 (define_expand "movhi"
1029   [(set (match_operand:HI 0 "nonimmediate_operand" "")
1030         (match_operand:HI 1 "general_operand" ""))]
1031   ""
1032   "")
1034 (define_insn ""
1035   [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
1036         (match_operand:HI 1 "general_src_operand" "gS"))]
1037   "!TARGET_COLDFIRE"
1038   "* return output_move_himode (operands);")
1040 (define_insn ""
1041   [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
1042         (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
1043   "TARGET_COLDFIRE"
1044   "* return output_move_himode (operands);")
1046 (define_expand "movstricthi"
1047   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1048         (match_operand:HI 1 "general_src_operand" ""))]
1049   ""
1050   "")
1052 (define_insn ""
1053   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
1054         (match_operand:HI 1 "general_src_operand" "rmSn"))]
1055   "!TARGET_COLDFIRE"
1056   "* return output_move_stricthi (operands);")
1058 (define_insn ""
1059   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
1060         (match_operand:HI 1 "general_src_operand" "rmn,r"))]
1061   "TARGET_COLDFIRE"
1062   "* return output_move_stricthi (operands);")
1064 (define_expand "movqi"
1065   [(set (match_operand:QI 0 "nonimmediate_operand" "")
1066         (match_operand:QI 1 "general_src_operand" ""))]
1067   ""
1068   "")
1070 (define_insn ""
1071   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
1072         (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
1073   "!TARGET_COLDFIRE"
1074   "* return output_move_qimode (operands);")
1076 (define_insn ""
1077   [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
1078         (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
1079   "TARGET_COLDFIRE"
1080   "* return output_move_qimode (operands);")
1082 (define_expand "movstrictqi"
1083   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1084         (match_operand:QI 1 "general_src_operand" ""))]
1085   ""
1086   "")
1088 (define_insn ""
1089   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
1090         (match_operand:QI 1 "general_src_operand" "dmSn"))]
1091   "!TARGET_COLDFIRE"
1092   "* return output_move_strictqi (operands);")
1094 (define_insn "*movstrictqi_cf"
1095   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d, Ac, d,m"))
1096         (match_operand:QI 1 "general_src_operand"                    "C0,C0, dmn,d"))]
1097   "TARGET_COLDFIRE"
1098   "@
1099    clr%.b %0
1100    clr%.b %0
1101    move%.b %1,%0
1102    move%.b %1,%0"
1103   [(set_attr "type" "clr,clr,move,move")])
1105 (define_expand "pushqi1"
1106   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
1107    (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
1108         (match_operand:QI 0 "general_operand" ""))]
1109   "!TARGET_COLDFIRE"
1110   "")
1112 (define_expand "reload_insf"
1113   [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1114         (match_operand:SF 1 "general_operand" "mf"))
1115    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1116   "TARGET_COLDFIRE_FPU"
1118   if (emit_move_sequence (operands, SFmode, operands[2]))
1119     DONE;
1121   /* We don't want the clobber emitted, so handle this ourselves. */
1122   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1123   DONE;
1126 (define_expand "reload_outsf"
1127   [(set (match_operand:SF 0 "general_operand" "")
1128         (match_operand:SF 1 "register_operand" "f"))
1129    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1130   "TARGET_COLDFIRE_FPU"
1132   if (emit_move_sequence (operands, SFmode, operands[2]))
1133     DONE;
1135   /* We don't want the clobber emitted, so handle this ourselves. */
1136   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1137   DONE;
1140 (define_expand "movsf"
1141   [(set (match_operand:SF 0 "nonimmediate_operand" "")
1142         (match_operand:SF 1 "general_operand" ""))]
1143   ""
1144   "")
1146 (define_insn ""
1147   [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
1148         (match_operand:SF 1 "general_operand" "rmfF"))]
1149   "!TARGET_COLDFIRE"
1151   if (FP_REG_P (operands[0]))
1152     {
1153       if (FP_REG_P (operands[1]))
1154         return "f%$move%.x %1,%0";
1155       else if (ADDRESS_REG_P (operands[1]))
1156         return "move%.l %1,%-\;f%$move%.s %+,%0";
1157       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
1158         return output_move_const_single (operands);
1159       return "f%$move%.s %f1,%0";
1160     }
1161   if (FP_REG_P (operands[1]))
1162     {
1163       if (ADDRESS_REG_P (operands[0]))
1164         return "fmove%.s %1,%-\;move%.l %+,%0";
1165       return "fmove%.s %f1,%0";
1166     }
1167   if (operands[1] == CONST0_RTX (SFmode)
1168       /* clr insns on 68000 read before writing.  */
1169       && ((TARGET_68010 || TARGET_COLDFIRE)
1170           || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
1171     {
1172       if (ADDRESS_REG_P (operands[0]))
1173         {
1174           /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
1175           if (TUNE_68040_60)
1176             return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
1177           else
1178             return "sub%.l %0,%0";
1179         }
1180       /* moveq is faster on the 68000.  */
1181       if (DATA_REG_P (operands[0]) && TUNE_68000_10)
1182         return "moveq #0,%0";
1183       return "clr%.l %0";
1184     }
1185   return "move%.l %1,%0";
1188 (define_insn "movsf_cf_soft"
1189   [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>,g,U")
1190         (match_operand:SF 1 "general_operand" "g,r<Q>,U"))]
1191   "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1192   "move%.l %1,%0"
1193   [(set_attr "type" "move_l")])
1195 ;; SFmode MEMs are restricted to modes 2-4 if TARGET_COLDFIRE_FPU.
1196 ;; The move instructions can handle all combinations.
1197 (define_insn "movsf_cf_hard"
1198   [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f,    f,mr,f,r<Q>,f
1199 ,m")
1200         (match_operand:SF 1 "general_operand"      " f,     r<Q>U,f,rm,F,F,   m
1201 ,f"))]
1202   "TARGET_COLDFIRE_FPU"
1204   if (which_alternative == 4 || which_alternative == 5) {
1205     rtx xoperands[2];
1206     REAL_VALUE_TYPE r;
1207     long l;
1208     REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1209     REAL_VALUE_TO_TARGET_SINGLE (r, l);
1210     xoperands[0] = operands[0];
1211     xoperands[1] = GEN_INT (l);
1212     if (which_alternative == 5) {
1213       if (l == 0) {
1214         if (ADDRESS_REG_P (xoperands[0]))
1215           output_asm_insn ("sub%.l %0,%0", xoperands);
1216         else
1217           output_asm_insn ("clr%.l %0", xoperands);
1218       } else
1219         if (GET_CODE (operands[0]) == MEM
1220             && symbolic_operand (XEXP (operands[0], 0), SImode))
1221           output_asm_insn ("move%.l %1,%-;move%.l %+,%0", xoperands);
1222         else
1223           output_asm_insn ("move%.l %1,%0", xoperands);
1224       return "";
1225     }
1226     if (l != 0)
1227       output_asm_insn ("move%.l %1,%-;fsmove%.s %+,%0", xoperands);
1228     else
1229       output_asm_insn ("clr%.l %-;fsmove%.s %+,%0", xoperands);
1230     return "";
1231   }
1232   if (FP_REG_P (operands[0]))
1233     {
1234       if (ADDRESS_REG_P (operands[1]))
1235         return "move%.l %1,%-;fsmove%.s %+,%0";
1236       if (FP_REG_P (operands[1]))
1237         return "fsmove%.d %1,%0";
1238       return "fsmove%.s %f1,%0";
1239     }
1240   if (FP_REG_P (operands[1]))
1241     {
1242       if (ADDRESS_REG_P (operands[0]))
1243         return "fmove%.s %1,%-;move%.l %+,%0";
1244       return "fmove%.s %f1,%0";
1245     }
1246   if (operands[1] == CONST0_RTX (SFmode))
1247     {
1248       if (ADDRESS_REG_P (operands[0]))
1249         return "sub%.l %0,%0";
1250       return "clr%.l %0";
1251     }
1252   return "move%.l %1,%0";
1255 (define_expand "reload_indf"
1256   [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1257         (match_operand:DF 1 "general_operand" "mf"))
1258    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1259   "TARGET_COLDFIRE_FPU"
1261   if (emit_move_sequence (operands, DFmode, operands[2]))
1262     DONE;
1264   /* We don't want the clobber emitted, so handle this ourselves. */
1265   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1266   DONE;
1269 (define_expand "reload_outdf"
1270   [(set (match_operand:DF 0 "general_operand" "")
1271         (match_operand:DF 1 "register_operand" "f"))
1272    (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1273   "TARGET_COLDFIRE_FPU"
1275   if (emit_move_sequence (operands, DFmode, operands[2]))
1276     DONE;
1278   /* We don't want the clobber emitted, so handle this ourselves. */
1279   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1280   DONE;
1283 (define_expand "movdf"
1284   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1285         (match_operand:DF 1 "general_operand" ""))]
1286   ""
1288   if (TARGET_COLDFIRE_FPU)
1289     if (emit_move_sequence (operands, DFmode, 0))
1290       DONE;
1293 (define_insn ""
1294   [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
1295         (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
1296 ;  [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
1297 ;       (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
1298   "!TARGET_COLDFIRE"
1300   if (FP_REG_P (operands[0]))
1301     {
1302       if (FP_REG_P (operands[1]))
1303         return "f%&move%.x %1,%0";
1304       if (REG_P (operands[1]))
1305         {
1306           rtx xoperands[2];
1307           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1308           output_asm_insn ("move%.l %1,%-", xoperands);
1309           output_asm_insn ("move%.l %1,%-", operands);
1310           return "f%&move%.d %+,%0";
1311         }
1312       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1313         return output_move_const_double (operands);
1314       return "f%&move%.d %f1,%0";
1315     }
1316   else if (FP_REG_P (operands[1]))
1317     {
1318       if (REG_P (operands[0]))
1319         {
1320           output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1321           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1322           return "move%.l %+,%0";
1323         }
1324       else
1325         return "fmove%.d %f1,%0";
1326     }
1327   return output_move_double (operands);
1330 (define_insn_and_split "movdf_cf_soft"
1331   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
1332         (match_operand:DF 1 "general_operand" "g,r"))]
1333   "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1334   "#"
1335   "&& reload_completed"
1336   [(const_int 0)]
1338   m68k_emit_move_double (operands);
1339   DONE;
1342 (define_insn "movdf_cf_hard"
1343   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,    <Q>U,r,f,r,r,m,f")
1344         (match_operand:DF 1 "general_operand"      " f<Q>U,f,   f,r,r,m,r,E"))]
1345   "TARGET_COLDFIRE_FPU"
1347   rtx xoperands[3];
1348   REAL_VALUE_TYPE r;
1349   long l[2];
1351   switch (which_alternative)
1352     {
1353     default:
1354       return "fdmove%.d %1,%0";
1355     case 1:
1356       return "fmove%.d %1,%0";
1357     case 2:
1358       return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1359     case 3:
1360       return "move%.l %R1,%-;move%.l %1,%-;fdmove%.d %+,%0";
1361     case 4: case 5: case 6:
1362       return output_move_double (operands);
1363     case 7:
1364       REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1365       REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1366       xoperands[0] = operands[0];
1367       xoperands[1] = GEN_INT (l[0]);
1368       xoperands[2] = GEN_INT (l[1]);
1369       if (operands[1] == CONST0_RTX (DFmode))
1370         output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1371                         xoperands);
1372       else
1373         if (l[1] == 0)
1374           output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1375                           xoperands);
1376         else
1377           output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1378                           xoperands);
1379       return "";
1380     }
1383 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1384 ;; allowed.  Most but not all have predicates and constraint that disallow
1385 ;; constants.  Most but not all have output templates that handle constants.
1386 ;; See also LEGITIMATE_CONSTANT_P.
1388 (define_expand "movxf"
1389   [(set (match_operand:XF 0 "nonimmediate_operand" "")
1390         (match_operand:XF 1 "general_operand" ""))]
1391   ""
1393   /* We can't rewrite operands during reload.  */
1394   if (! reload_in_progress)
1395     {
1396       if (CONSTANT_P (operands[1]))
1397         {
1398           operands[1] = force_const_mem (XFmode, operands[1]);
1399           if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1400             operands[1] = adjust_address (operands[1], XFmode, 0);
1401         }
1402       if (flag_pic && TARGET_PCREL)
1403         {
1404           /* Don't allow writes to memory except via a register; the
1405              m68k doesn't consider PC-relative addresses to be writable.  */
1406           if (GET_CODE (operands[0]) == MEM
1407               && symbolic_operand (XEXP (operands[0], 0), SImode))
1408             operands[0] = gen_rtx_MEM (XFmode,
1409                                    force_reg (SImode, XEXP (operands[0], 0)));
1410         }
1411     }
1414 (define_insn ""
1415   [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1416         (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1417   "TARGET_68881"
1419   if (FP_REG_P (operands[0]))
1420     {
1421       if (FP_REG_P (operands[1]))
1422         return "fmove%.x %1,%0";
1423       if (REG_P (operands[1]))
1424         {
1425           rtx xoperands[2];
1426           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1427           output_asm_insn ("move%.l %1,%-", xoperands);
1428           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1429           output_asm_insn ("move%.l %1,%-", xoperands);
1430           output_asm_insn ("move%.l %1,%-", operands);
1431           return "fmove%.x %+,%0";
1432         }
1433       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1434         return "fmove%.x %1,%0";
1435       return "fmove%.x %f1,%0";
1436     }
1437   if (FP_REG_P (operands[1]))
1438     {
1439       if (REG_P (operands[0]))
1440         {
1441           output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1442           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1443           output_asm_insn ("move%.l %+,%0", operands);
1444           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1445           return "move%.l %+,%0";
1446         }
1447       /* Must be memory destination.  */
1448       return "fmove%.x %f1,%0";
1449     }
1450   return output_move_double (operands);
1453 (define_insn ""
1454   [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1455         (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1456   "! TARGET_68881 && ! TARGET_COLDFIRE"
1458   if (FP_REG_P (operands[0]))
1459     {
1460       if (FP_REG_P (operands[1]))
1461         return "fmove%.x %1,%0";
1462       if (REG_P (operands[1]))
1463         {
1464           rtx xoperands[2];
1465           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1466           output_asm_insn ("move%.l %1,%-", xoperands);
1467           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1468           output_asm_insn ("move%.l %1,%-", xoperands);
1469           output_asm_insn ("move%.l %1,%-", operands);
1470           return "fmove%.x %+,%0";
1471         }
1472       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1473         return "fmove%.x %1,%0";
1474       return "fmove%.x %f1,%0";
1475     }
1476   if (FP_REG_P (operands[1]))
1477     {
1478       if (REG_P (operands[0]))
1479         {
1480           output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1481           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1482           output_asm_insn ("move%.l %+,%0", operands);
1483           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1484           return "move%.l %+,%0";
1485         }
1486       else
1487         return "fmove%.x %f1,%0";
1488     }
1489   return output_move_double (operands);
1492 (define_insn ""
1493   [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1494         (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1495   "! TARGET_68881 && TARGET_COLDFIRE"
1496   "* return output_move_double (operands);")
1498 (define_expand "movdi"
1499   ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1500   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1501         (match_operand:DI 1 "general_operand" ""))]
1502   ""
1503   "")
1505 ;; movdi can apply to fp regs in some cases
1506 (define_insn ""
1507   ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1508   [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1509         (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1510 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1511 ;       (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1512 ;  [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1513 ;       (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1514   "!TARGET_COLDFIRE"
1516   if (FP_REG_P (operands[0]))
1517     {
1518       if (FP_REG_P (operands[1]))
1519         return "fmove%.x %1,%0";
1520       if (REG_P (operands[1]))
1521         {
1522           rtx xoperands[2];
1523           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1524           output_asm_insn ("move%.l %1,%-", xoperands);
1525           output_asm_insn ("move%.l %1,%-", operands);
1526           return "fmove%.d %+,%0";
1527         }
1528       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1529         return output_move_const_double (operands);
1530       return "fmove%.d %f1,%0";
1531     }
1532   else if (FP_REG_P (operands[1]))
1533     {
1534       if (REG_P (operands[0]))
1535         {
1536           output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1537           operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1538           return "move%.l %+,%0";
1539         }
1540       else
1541         return "fmove%.d %f1,%0";
1542     }
1543   return output_move_double (operands);
1546 (define_insn ""
1547   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1548         (match_operand:DI 1 "general_operand" "g,r"))]
1549   "TARGET_COLDFIRE"
1550   "* return output_move_double (operands);")
1552 ;; Thus goes after the move instructions
1553 ;; because the move instructions are better (require no spilling)
1554 ;; when they can apply.  It goes before the add/sub insns
1555 ;; so we will prefer it to them.
1557 (define_insn "pushasi"
1558   [(set (match_operand:SI 0 "push_operand" "=m")
1559         (match_operand:SI 1 "address_operand" "p"))]
1560   ""
1561   "pea %a1"
1562   [(set_attr "type" "pea")])
1564 ;; truncation instructions
1565 (define_insn "truncsiqi2"
1566   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1567         (truncate:QI
1568          (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1569   ""
1571   if (GET_CODE (operands[0]) == REG)
1572     {
1573       /* Must clear condition codes, since the move.l bases them on
1574          the entire 32 bits, not just the desired 8 bits.  */
1575       CC_STATUS_INIT;
1576       return "move%.l %1,%0";
1577     }
1578   if (GET_CODE (operands[1]) == MEM)
1579     operands[1] = adjust_address (operands[1], QImode, 3);
1580   return "move%.b %1,%0";
1583 (define_insn "trunchiqi2"
1584   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1585         (truncate:QI
1586          (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1587   ""
1589   if (GET_CODE (operands[0]) == REG
1590       && (GET_CODE (operands[1]) == MEM
1591           || GET_CODE (operands[1]) == CONST_INT))
1592     {
1593       /* Must clear condition codes, since the move.w bases them on
1594          the entire 16 bits, not just the desired 8 bits.  */
1595       CC_STATUS_INIT;
1596       return "move%.w %1,%0";
1597     }
1598   if (GET_CODE (operands[0]) == REG)
1599     {
1600       /* Must clear condition codes, since the move.l bases them on
1601          the entire 32 bits, not just the desired 8 bits.  */
1602       CC_STATUS_INIT;
1603       return "move%.l %1,%0";
1604     }
1605   if (GET_CODE (operands[1]) == MEM)
1606     operands[1] = adjust_address (operands[1], QImode, 1);
1607   return "move%.b %1,%0";
1610 (define_insn "truncsihi2"
1611   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1612         (truncate:HI
1613          (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1614   ""
1616   if (GET_CODE (operands[0]) == REG)
1617     {
1618       /* Must clear condition codes, since the move.l bases them on
1619          the entire 32 bits, not just the desired 8 bits.  */
1620       CC_STATUS_INIT;
1621       return "move%.l %1,%0";
1622     }
1623   if (GET_CODE (operands[1]) == MEM)
1624     operands[1] = adjust_address (operands[1], QImode, 2);
1625   return "move%.w %1,%0";
1628 ;; zero extension instructions
1630 ;; two special patterns to match various post_inc/pre_dec patterns
1631 (define_insn_and_split "*zero_extend_inc"
1632   [(set (match_operand 0 "post_inc_operand" "")
1633         (zero_extend (match_operand 1 "register_operand" "")))]
1634   "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1635    GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1636    GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1637   "#"
1638   ""
1639   [(set (match_dup 0)
1640         (const_int 0))
1641    (set (match_dup 0)
1642         (match_dup 1))]
1644   operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1647 (define_insn_and_split "*zero_extend_dec"
1648   [(set (match_operand 0 "pre_dec_operand" "")
1649         (zero_extend (match_operand 1 "register_operand" "")))]
1650   "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1651    GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1652    GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1653    GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1654   "#"
1655   ""
1656   [(set (match_dup 0)
1657         (match_dup 1))
1658    (set (match_dup 0)
1659         (const_int 0))]
1661   operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1664 (define_insn_and_split "zero_extendqidi2"
1665   [(set (match_operand:DI 0 "register_operand" "")
1666         (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1667   ""
1668   "#"
1669   ""
1670   [(set (match_dup 2)
1671         (zero_extend:SI (match_dup 1)))
1672    (set (match_dup 3)
1673         (const_int 0))]
1675   operands[2] = gen_lowpart (SImode, operands[0]);
1676   operands[3] = gen_highpart (SImode, operands[0]);
1679 (define_insn_and_split "zero_extendhidi2"
1680   [(set (match_operand:DI 0 "register_operand" "")
1681         (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1682   ""
1683   "#"
1684   ""
1685   [(set (match_dup 2)
1686         (zero_extend:SI (match_dup 1)))
1687    (set (match_dup 3)
1688         (const_int 0))]
1690   operands[2] = gen_lowpart (SImode, operands[0]);
1691   operands[3] = gen_highpart (SImode, operands[0]);
1694 (define_expand "zero_extendsidi2"
1695   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1696         (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1697   ""
1699   if (GET_CODE (operands[0]) == MEM
1700       && GET_CODE (operands[1]) == MEM)
1701     operands[1] = force_reg (SImode, operands[1]);
1704 (define_insn_and_split "*zero_extendsidi2"
1705   [(set (match_operand:DI 0 "nonimmediate_operand" "")
1706         (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1707   "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1708   "#"
1709   ""
1710   [(set (match_dup 2)
1711         (match_dup 1))
1712    (set (match_dup 3)
1713         (const_int 0))]
1715   operands[2] = gen_lowpart (SImode, operands[0]);
1716   operands[3] = gen_highpart (SImode, operands[0]);
1719 (define_insn "*zero_extendhisi2_cf"
1720   [(set (match_operand:SI 0 "register_operand" "=d")
1721         (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1722   "ISA_HAS_MVS_MVZ"
1723   "mvz%.w %1,%0"
1724   [(set_attr "type" "mvsz")])
1726 (define_insn "zero_extendhisi2"
1727   [(set (match_operand:SI 0 "register_operand" "=d")
1728         (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1729   ""
1730   "#")
1732 (define_expand "zero_extendqihi2"
1733   [(set (match_operand:HI 0 "register_operand" "")
1734         (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1735   "!TARGET_COLDFIRE"
1736   "")
1738 (define_insn "*zero_extendqihi2"
1739   [(set (match_operand:HI 0 "register_operand" "=d")
1740         (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1741   "!TARGET_COLDFIRE"
1742   "#")
1744 (define_insn "*zero_extendqisi2_cfv4"
1745   [(set (match_operand:SI 0 "register_operand" "=d")
1746         (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1747   "ISA_HAS_MVS_MVZ"
1748   "mvz%.b %1,%0"
1749   [(set_attr "type" "mvsz")])
1751 (define_insn "zero_extendqisi2"
1752   [(set (match_operand:SI 0 "register_operand" "=d")
1753         (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1754   ""
1755   "#")
1757 ;; these two pattern split everything else which isn't matched by
1758 ;; something else above
1759 (define_split
1760   [(set (match_operand 0 "register_operand" "")
1761         (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1762   "!ISA_HAS_MVS_MVZ
1763    && reload_completed
1764    && reg_mentioned_p (operands[0], operands[1])"
1765   [(set (strict_low_part (match_dup 2))
1766         (match_dup 1))
1767    (set (match_dup 0)
1768         (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1770   operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1771   operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1772   operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1775 (define_split
1776   [(set (match_operand 0 "register_operand" "")
1777         (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1778   "!ISA_HAS_MVS_MVZ && reload_completed"
1779   [(set (match_dup 0)
1780         (const_int 0))
1781    (set (strict_low_part (match_dup 2))
1782         (match_dup 1))]
1784   operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1787 ;; sign extension instructions
1789 (define_insn "extendqidi2"
1790   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1791         (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1792   ""
1794   CC_STATUS_INIT;
1795   operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1796   if (ISA_HAS_MVS_MVZ)
1797     return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1798   if (TARGET_68020 || TARGET_COLDFIRE)
1799     {
1800       if (ADDRESS_REG_P (operands[1]))
1801         return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1802       else
1803         return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1804     }
1805   else
1806     {
1807       if (ADDRESS_REG_P (operands[1]))
1808         return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1809       else
1810         return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1811     }
1814 (define_insn "extendhidi2"
1815   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1816         (sign_extend:DI
1817          (match_operand:HI 1 "general_src_operand" "rmS")))]
1818   ""
1820   CC_STATUS_INIT;
1821   operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1822   if (ISA_HAS_MVS_MVZ)
1823     return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1824   if (TARGET_68020 || TARGET_COLDFIRE)
1825     return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1826   else
1827     return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1830 (define_insn "extendsidi2"
1831   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o,o,<")
1832         (sign_extend:DI
1833          (match_operand:SI 1 "nonimmediate_src_operand" "rm,rm,r<Q>,rm")))
1834    (clobber (match_scratch:SI 2 "=X,d,d,d"))]
1835   ""
1837   CC_STATUS_INIT;
1839   if (which_alternative == 0)
1840     /* Handle alternative 0.  */
1841     {
1842       if (TARGET_68020 || TARGET_COLDFIRE)
1843         return "move%.l %1,%R0\;smi %0\;extb%.l %0";
1844       else
1845         return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
1846     }
1848   /* Handle alternatives 1, 2 and 3.  We don't need to adjust address by 4
1849      in alternative 3 because autodecrement will do that for us.  */
1850   operands[3] = adjust_address (operands[0], SImode,
1851                                 which_alternative == 3 ? 0 : 4);
1852   operands[0] = adjust_address (operands[0], SImode, 0);
1854   if (TARGET_68020 || TARGET_COLDFIRE)
1855     return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
1856   else
1857     return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
1859   [(set_attr "ok_for_coldfire" "yes,no,yes,yes")])
1861 ;; Special case when one can avoid register clobbering, copy and test
1862 ;; Maybe there is a way to make that the general case, by forcing the
1863 ;; result of the SI tree to be in the lower register of the DI target
1865 (define_insn "extendplussidi"
1866   [(set (match_operand:DI 0 "register_operand" "=d")
1867     (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1868             (match_operand:SI 2 "general_operand" "rmn"))))]
1869   ""
1871   CC_STATUS_INIT;
1872   operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1873   if (GET_CODE (operands[1]) == CONST_INT
1874   && (unsigned) INTVAL (operands[1]) > 8)
1875     {
1876       rtx tmp = operands[1];
1878       operands[1] = operands[2];
1879       operands[2] = tmp;
1880     }
1881   if (GET_CODE (operands[1]) == REG
1882       && REGNO (operands[1]) == REGNO (operands[3]))
1883     output_asm_insn ("add%.l %2,%3", operands);
1884   else
1885     output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1886   if (TARGET_68020 || TARGET_COLDFIRE)
1887     return "smi %0\;extb%.l %0";
1888   else
1889     return "smi %0\;ext%.w %0\;ext%.l %0";
1892 (define_expand "extendhisi2"
1893   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1894         (sign_extend:SI
1895          (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1896   ""
1897   "")
1899 (define_insn "*cfv4_extendhisi2"
1900   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1901         (sign_extend:SI
1902          (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1903   "ISA_HAS_MVS_MVZ"
1904   "mvs%.w %1,%0"
1905   [(set_attr "type" "mvsz")])
1907 (define_insn "*68k_extendhisi2"
1908   [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1909         (sign_extend:SI
1910          (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1911   "!ISA_HAS_MVS_MVZ"
1912   "@
1913    ext%.l %0
1914    move%.w %1,%0"
1915   [(set_attr "type" "ext,move")])
1917 (define_insn "extendqihi2"
1918   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1919         (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1920   ""
1921   "ext%.w %0"
1922   [(set_attr "type" "ext")])
1924 (define_expand "extendqisi2"
1925   [(set (match_operand:SI 0 "nonimmediate_operand" "")
1926         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1927   "TARGET_68020 || TARGET_COLDFIRE"
1928   "")
1930 (define_insn "*cfv4_extendqisi2"
1931   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1932         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1933   "ISA_HAS_MVS_MVZ"
1934   "mvs%.b %1,%0"
1935   [(set_attr "type" "mvsz")])
1937 (define_insn "*68k_extendqisi2"
1938   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1939         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1940   "TARGET_68020 || (TARGET_COLDFIRE && !ISA_HAS_MVS_MVZ)"
1941   "extb%.l %0"
1942   [(set_attr "type" "ext")])
1944 ;; Conversions between float and double.
1946 (define_expand "extendsfdf2"
1947   [(set (match_operand:DF 0 "nonimmediate_operand" "")
1948         (float_extend:DF
1949          (match_operand:SF 1 "general_operand" "")))]
1950   "TARGET_HARD_FLOAT"
1951   "")
1953 (define_insn ""
1954   [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1955         (float_extend:DF
1956           (match_operand:SF 1 "general_operand" "f,dmF")))]
1957   "TARGET_68881"
1959   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1960     {
1961       if (REGNO (operands[0]) == REGNO (operands[1]))
1962         {
1963           /* Extending float to double in an fp-reg is a no-op.
1964              NOTICE_UPDATE_CC has already assumed that the
1965              cc will be set.  So cancel what it did.  */
1966           cc_status = cc_prev_status;
1967           return "";
1968         }
1969       return "f%&move%.x %1,%0";
1970     }
1971   if (FP_REG_P (operands[0]))
1972     return "f%&move%.s %f1,%0";
1973   if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1974     {
1975       output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1976       operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1977       return "move%.l %+,%0";
1978     }
1979   return "fmove%.d %f1,%0";
1982 (define_insn "extendsfdf2_cf"
1983   [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
1984         (float_extend:DF
1985          (match_operand:SF 1 "general_operand" "f,<Q>U")))]
1986   "TARGET_COLDFIRE_FPU"
1988   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1989     {
1990       if (REGNO (operands[0]) == REGNO (operands[1]))
1991         {
1992           /* Extending float to double in an fp-reg is a no-op.
1993              NOTICE_UPDATE_CC has already assumed that the
1994              cc will be set.  So cancel what it did.  */
1995           cc_status = cc_prev_status;
1996           return "";
1997         }
1998       return "fdmove%.d %1,%0";
1999     }
2000   return "fdmove%.s %f1,%0";
2003 ;; This cannot output into an f-reg because there is no way to be
2004 ;; sure of truncating in that case.
2005 (define_expand "truncdfsf2"
2006   [(set (match_operand:SF 0 "nonimmediate_operand" "")
2007         (float_truncate:SF
2008           (match_operand:DF 1 "general_operand" "")))]
2009   "TARGET_HARD_FLOAT"
2010   "")
2012 ;; On the '040 we can truncate in a register accurately and easily.
2013 (define_insn ""
2014   [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2015         (float_truncate:SF
2016           (match_operand:DF 1 "general_operand" "fmG")))]
2017   "TARGET_68881 && TARGET_68040"
2019   if (FP_REG_P (operands[1]))
2020     return "f%$move%.x %1,%0";
2021   return "f%$move%.d %f1,%0";
2024 (define_insn "truncdfsf2_cf"
2025   [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
2026         (float_truncate:SF
2027           (match_operand:DF 1 "general_operand" "<Q>U,f")))]
2028   "TARGET_COLDFIRE_FPU"
2029   "@
2030   fsmove%.d %1,%0
2031   fmove%.s %1,%0"
2032   [(set_attr "type" "fmove")])
2034 (define_insn "*truncdfsf2_68881"
2035   [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
2036         (float_truncate:SF
2037           (match_operand:DF 1 "general_operand" "f")))]
2038   "TARGET_68881"
2039   "fmove%.s %f1,%0"
2040   [(set_attr "type" "fmove")])
2042 ;; Conversion between fixed point and floating point.
2043 ;; Note that among the fix-to-float insns
2044 ;; the ones that start with SImode come first.
2045 ;; That is so that an operand that is a CONST_INT
2046 ;; (and therefore lacks a specific machine mode).
2047 ;; will be recognized as SImode (which is always valid)
2048 ;; rather than as QImode or HImode.
2050 (define_expand "floatsi<mode>2"
2051   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2052         (float:FP (match_operand:SI 1 "general_operand" "")))]
2053   "TARGET_HARD_FLOAT"
2054   "")
2056 (define_insn "floatsi<mode>2_68881"
2057   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2058         (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
2059   "TARGET_68881"
2060   "f<FP:round>move%.l %1,%0"
2061   [(set_attr "type" "fmove")])
2063 (define_insn "floatsi<mode>2_cf"
2064   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2065         (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
2066   "TARGET_COLDFIRE_FPU"
2067   "f<FP:prec>move%.l %1,%0"
2068   [(set_attr "type" "fmove")])
2071 (define_expand "floathi<mode>2"
2072   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2073         (float:FP (match_operand:HI 1 "general_operand" "")))]
2074   "TARGET_HARD_FLOAT"
2075   "")
2077 (define_insn "floathi<mode>2_68881"
2078   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2079         (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
2080   "TARGET_68881"
2081   "fmove%.w %1,%0"
2082   [(set_attr "type" "fmove")])
2084 (define_insn "floathi<mode>2_cf"
2085   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2086         (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
2087   "TARGET_COLDFIRE_FPU"
2088   "fmove%.w %1,%0"
2089   [(set_attr "type" "fmove")])
2092 (define_expand "floatqi<mode>2"
2093   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2094         (float:FP (match_operand:QI 1 "general_operand" "")))]
2095   "TARGET_HARD_FLOAT"
2096   "")
2098 (define_insn "floatqi<mode>2_68881"
2099   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2100         (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
2101   "TARGET_68881"
2102   "fmove%.b %1,%0"
2103   [(set_attr "type" "fmove")])
2105 (define_insn "floatqi<mode>2_cf"
2106   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2107         (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
2108   "TARGET_COLDFIRE_FPU"
2109   "fmove%.b %1,%0"
2110   [(set_attr "type" "fmove")])
2113 ;; New routines to convert floating-point values to integers
2114 ;; to be used on the '040.  These should be faster than trapping
2115 ;; into the kernel to emulate fintrz.  They should also be faster
2116 ;; than calling the subroutines fixsfsi or fixdfsi.
2118 (define_insn "fix_truncdfsi2"
2119   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2120         (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2121    (clobber (match_scratch:SI 2 "=d"))
2122    (clobber (match_scratch:SI 3 "=d"))]
2123   "TARGET_68881 && TUNE_68040"
2125   CC_STATUS_INIT;
2126   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,%!";
2129 (define_insn "fix_truncdfhi2"
2130   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2131         (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2132    (clobber (match_scratch:SI 2 "=d"))
2133    (clobber (match_scratch:SI 3 "=d"))]
2134   "TARGET_68881 && TUNE_68040"
2136   CC_STATUS_INIT;
2137   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,%!";
2140 (define_insn "fix_truncdfqi2"
2141   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2142         (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2143    (clobber (match_scratch:SI 2 "=d"))
2144    (clobber (match_scratch:SI 3 "=d"))]
2145   "TARGET_68881 && TUNE_68040"
2147   CC_STATUS_INIT;
2148   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,%!";
2151 ;; Convert a float to a float whose value is an integer.
2152 ;; This is the first stage of converting it to an integer type.
2154 (define_expand "ftrunc<mode>2"
2155   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2156         (fix:FP (match_operand:FP 1 "general_operand" "")))]
2157   "TARGET_HARD_FLOAT && !TUNE_68040"
2158   "")
2160 (define_insn "ftrunc<mode>2_68881"
2161   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2162         (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
2163   "TARGET_68881 && !TUNE_68040"
2165   if (FP_REG_P (operands[1]))
2166     return "fintrz%.x %f1,%0";
2167   return "fintrz%.<FP:prec> %f1,%0";
2169   [(set_attr "type" "falu")])
2171 (define_insn "ftrunc<mode>2_cf"
2172   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2173         (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
2174   "TARGET_COLDFIRE_FPU"
2176   if (FP_REG_P (operands[1]))
2177     return "fintrz%.d %f1,%0";
2178   return "fintrz%.<FP:prec> %f1,%0";
2180   [(set_attr "type" "falu")])
2182 ;; Convert a float whose value is an integer
2183 ;; to an actual integer.  Second stage of converting float to integer type.
2184 (define_expand "fix<mode>qi2"
2185   [(set (match_operand:QI 0 "nonimmediate_operand" "")
2186         (fix:QI (match_operand:FP 1 "general_operand" "")))]
2187   "TARGET_HARD_FLOAT"
2188   "")
2190 (define_insn "fix<mode>qi2_68881"
2191   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2192         (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2193   "TARGET_68881"
2194   "fmove%.b %1,%0"
2195   [(set_attr "type" "fmove")])
2197 (define_insn "fix<mode>qi2_cf"
2198   [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
2199         (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2200   "TARGET_COLDFIRE_FPU"
2201   "fmove%.b %1,%0"
2202   [(set_attr "type" "fmove")])
2204 (define_expand "fix<mode>hi2"
2205   [(set (match_operand:HI 0 "nonimmediate_operand" "")
2206         (fix:HI (match_operand:FP 1 "general_operand" "")))]
2207   "TARGET_HARD_FLOAT"
2208   "")
2210 (define_insn "fix<mode>hi2_68881"
2211   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2212         (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2213   "TARGET_68881"
2214   "fmove%.w %1,%0"
2215   [(set_attr "type" "fmove")])
2217 (define_insn "fix<mode>hi2_cf"
2218   [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
2219         (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2220   "TARGET_COLDFIRE_FPU"
2221   "fmove%.w %1,%0"
2222   [(set_attr "type" "fmove")])
2224 (define_expand "fix<mode>si2"
2225   [(set (match_operand:SI 0 "nonimmediate_operand" "")
2226         (fix:SI (match_operand:FP 1 "general_operand" "")))]
2227   "TARGET_HARD_FLOAT"
2228   "")
2230 (define_insn "fix<mode>si2_68881"
2231   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2232         (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2233   "TARGET_68881"
2234   "fmove%.l %1,%0"
2235   [(set_attr "type" "fmove")])
2237 (define_insn "fix<mode>si2_cf"
2238   [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
2239         (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2240   "TARGET_COLDFIRE_FPU"
2241   "fmove%.l %1,%0"
2242   [(set_attr "type" "fmove")])
2245 ;; add instructions
2247 (define_insn "adddi_lshrdi_63"
2248   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
2249     (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
2250             (const_int 63))
2251         (match_dup 1)))
2252    (clobber (match_scratch:SI 2 "=d"))]
2253   ""
2255   operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2256   if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
2257     return
2258     "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
2259   if (GET_CODE (operands[1]) == REG)
2260     operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2261   else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
2262         || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2263     operands[4] = operands[1];
2264   else
2265     operands[4] = adjust_address (operands[1], SImode, 4);
2266   if (GET_CODE (operands[1]) == MEM
2267    && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2268     output_asm_insn ("move%.l %4,%3", operands);
2269   output_asm_insn ("move%.l %1,%0\;smi %2", operands);
2270   if (TARGET_68020 || TARGET_COLDFIRE)
2271     output_asm_insn ("extb%.l %2", operands);
2272   else
2273     output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
2274   if (GET_CODE (operands[1]) != MEM
2275    || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
2276     output_asm_insn ("move%.l %4,%3", operands);
2277   return "sub%.l %2,%3\;subx%.l %2,%0";
2280 (define_insn "adddi_sexthishl32"
2281   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2282     (plus:DI (ashift:DI (sign_extend:DI
2283           (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
2284             (const_int 32))
2285         (match_operand:DI 2 "general_operand" "0,0,0,0")))
2286    (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2287   "!TARGET_COLDFIRE"
2289   CC_STATUS_INIT;
2290   if (ADDRESS_REG_P (operands[0]))
2291     return "add%.w %1,%0";
2292   else if (ADDRESS_REG_P (operands[3]))
2293     return "move%.w %1,%3\;add%.l %3,%0";
2294   else
2295     return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
2298 (define_insn "*adddi_dilshr32"
2299   [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
2300         (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
2301                               (const_int 32))
2302                  (match_operand:DI 2 "general_operand" "0,0")))]
2303   "!TARGET_COLDFIRE"
2305   CC_STATUS_INIT;
2306   if (GET_CODE (operands[0]) == REG)
2307     operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2308   else
2309     operands[2] = adjust_address (operands[0], SImode, 4);
2310   return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
2313 (define_insn "*adddi_dilshr32_cf"
2314   [(set (match_operand:DI 0 "register_operand" "=d")
2315         (plus:DI (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
2316                               (const_int 32))
2317                  (match_operand:DI 2 "register_operand" "0")))]
2318   "TARGET_COLDFIRE"
2320   CC_STATUS_INIT;
2321   return "add%.l %1,%R0\;negx%.l %0\;neg%.l %0";
2324 (define_insn "adddi_dishl32"
2325   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
2326 ;;    (plus:DI (match_operand:DI 2 "general_operand" "%0")
2327 ;;      (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2328 ;;            (const_int 32))))]
2329     (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
2330             (const_int 32))
2331         (match_operand:DI 2 "general_operand" "0,0")))]
2332   ""
2334   CC_STATUS_INIT;
2335   if (GET_CODE (operands[1]) == REG)
2336     operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2337   else
2338     operands[1] = adjust_address (operands[1], SImode, 4);
2339   return "add%.l %1,%0";
2341   [(set_attr "type" "alu_l")])
2343 (define_insn "adddi3"
2344   [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2345         (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0")
2346                  (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2347    (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2348   ""
2350   if (DATA_REG_P (operands[0]))
2351     {
2352       if (DATA_REG_P (operands[2]))
2353         return "add%.l %R2,%R0\;addx%.l %2,%0";
2354       else if (GET_CODE (operands[2]) == MEM
2355           && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2356         return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
2357       else
2358         {
2359           rtx high, low;
2360           rtx xoperands[2];
2362           if (GET_CODE (operands[2]) == REG)
2363             {
2364               low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2365               high = operands[2];
2366             }
2367           else if (CONSTANT_P (operands[2]))
2368             split_double (operands[2], &high, &low);
2369           else
2370             {
2371               low = adjust_address (operands[2], SImode, 4);
2372               high = operands[2];
2373             }
2375           operands[1] = low, operands[2] = high;
2376           xoperands[0] = operands[3];
2377           if (GET_CODE (operands[1]) == CONST_INT
2378               && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2379             xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2380           else
2381             xoperands[1] = operands[2];
2383           output_asm_insn (output_move_simode (xoperands), xoperands);
2384           if (GET_CODE (operands[1]) == CONST_INT)
2385             {
2386               if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2387                 return "addq%.l %1,%R0\;addx%.l %3,%0";
2388               else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2389                 {
2390                   operands[1] = GEN_INT (-INTVAL (operands[1]));
2391                   return "subq%.l %1,%R0\;subx%.l %3,%0";
2392                 }
2393             }
2394           return "add%.l %1,%R0\;addx%.l %3,%0";
2395         }
2396     }
2397   else
2398     {
2399       gcc_assert (GET_CODE (operands[0]) == MEM);
2400       CC_STATUS_INIT;
2401       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2402         {
2403           operands[1] = gen_rtx_MEM (SImode,
2404                                      plus_constant (XEXP(operands[0], 0), -8));
2405           return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2406         }
2407       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2408         {
2409           operands[1] = XEXP(operands[0], 0);
2410           return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2411         }
2412       else
2413         {
2414           operands[1] = adjust_address (operands[0], SImode, 4);
2415           return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2416         }
2417     }
2420 (define_insn "addsi_lshrsi_31"
2421   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,dm,d<Q>")
2422     (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm,r<Q>,rm")
2423             (const_int 31))
2424         (match_dup 1)))]
2425   ""
2427   operands[2] = operands[0];
2428   operands[3] = gen_label_rtx();
2429   if (GET_CODE (operands[0]) == MEM)
2430     {
2431       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2432         operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2433       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2434         operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2435     }
2436   output_asm_insn ("move%.l %1,%0", operands);
2437   output_asm_insn ("jpl %l3", operands);
2438   output_asm_insn ("addq%.l #1,%2", operands);
2439   (*targetm.asm_out.internal_label) (asm_out_file, "L",
2440                                 CODE_LABEL_NUMBER (operands[3]));
2441   return "";
2443   [(set_attr "ok_for_coldfire" "no,yes,yes")])
2445 (define_expand "addsi3"
2446   [(set (match_operand:SI 0 "nonimmediate_operand" "")
2447         (plus:SI (match_operand:SI 1 "general_operand" "")
2448                  (match_operand:SI 2 "general_src_operand" "")))]
2449   ""
2450   "")
2452 ;; Note that the middle two alternatives are near-duplicates
2453 ;; in order to handle insns generated by reload.
2454 ;; This is needed since they are not themselves reloaded,
2455 ;; so commutativity won't apply to them.
2456 (define_insn "*addsi3_internal"
2457   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2458         (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2459                  (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2462   "! TARGET_COLDFIRE"
2463   "* return output_addsi3 (operands);")
2465 (define_insn_and_split "*addsi3_5200"
2466   [(set (match_operand:SI 0 "nonimmediate_operand"         "=mr,mr,a,  m,r,  ?a, ?a,?a,?a")
2467         (plus:SI (match_operand:SI 1 "general_operand"     "%0, 0, 0,  0,0,   a,  a, r, a")
2468                  (match_operand:SI 2 "general_src_operand" " I, L, JCu,d,mrKi,Cj, r, a, JCu")))]
2469   "TARGET_COLDFIRE"
2471   switch (which_alternative)
2472     {
2473     case 0:
2474       return "addq%.l %2,%0";
2476     case 1:
2477       operands[2] = GEN_INT (- INTVAL (operands[2]));
2478       return "subq%.l %2,%0";
2480     case 3:
2481     case 4:
2482       return "add%.l %2,%0";
2484     case 5:
2485       /* move%.l %2,%0\n\tadd%.l %1,%0 */
2486       return "#";
2488     case 6:
2489       return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0";
2491     case 7:
2492       return MOTOROLA ? "lea (%2,%1.l),%0" : "lea %2@(0,%1:l),%0";
2494     case 2:
2495     case 8:
2496       return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
2498     default:
2499       gcc_unreachable ();
2500       return "";
2501     }
2503   "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 5) && !operands_match_p (operands[0], operands[1])"
2504   [(set (match_dup 0)
2505         (match_dup 2))
2506    (set (match_dup 0)
2507         (plus:SI (match_dup 0)
2508                  (match_dup 1)))]
2509   ""
2510   [(set_attr "type"     "aluq_l,aluq_l,lea, alu_l,alu_l,*,lea, lea, lea")
2511    (set_attr "opy"      "2,     2,     *,   2,    2,    *,*,   *,   *")
2512    (set_attr "opy_type" "*,     *,     mem5,*,    *,    *,mem6,mem6,mem5")])
2514 (define_insn ""
2515   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2516         (plus:SI (match_operand:SI 1 "general_operand" "0")
2517                  (sign_extend:SI
2518                   (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2519   "!TARGET_COLDFIRE"
2520   "add%.w %2,%0")
2522 (define_insn "addhi3"
2523   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2524         (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2525                  (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2526   "!TARGET_COLDFIRE"
2528   if (GET_CODE (operands[2]) == CONST_INT)
2529     {
2530       /* If the constant would be a negative number when interpreted as
2531          HImode, make it negative.  This is usually, but not always, done
2532          elsewhere in the compiler.  First check for constants out of range,
2533          which could confuse us.  */
2535       if (INTVAL (operands[2]) >= 32768)
2536         operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2538       if (INTVAL (operands[2]) > 0
2539           && INTVAL (operands[2]) <= 8)
2540         return "addq%.w %2,%0";
2541       if (INTVAL (operands[2]) < 0
2542           && INTVAL (operands[2]) >= -8)
2543         {
2544           operands[2] = GEN_INT (- INTVAL (operands[2]));
2545           return "subq%.w %2,%0";
2546         }
2547       /* On the CPU32 it is faster to use two addqw instructions to
2548          add a small integer (8 < N <= 16) to a register.  
2549          Likewise for subqw.  */
2550       if (TUNE_CPU32 && REG_P (operands[0]))
2551         {
2552           if (INTVAL (operands[2]) > 8
2553               && INTVAL (operands[2]) <= 16)
2554             {
2555               operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2556               return "addq%.w #8,%0\;addq%.w %2,%0";
2557             }
2558           if (INTVAL (operands[2]) < -8
2559               && INTVAL (operands[2]) >= -16)
2560             {
2561               operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2562               return "subq%.w #8,%0\;subq%.w %2,%0";
2563             }
2564         }
2565       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2566         return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2567     }
2568   return "add%.w %2,%0";
2571 ;; These insns must use MATCH_DUP instead of the more expected
2572 ;; use of a matching constraint because the "output" here is also
2573 ;; an input, so you can't use the matching constraint.  That also means
2574 ;; that you can't use the "%", so you need patterns with the matched
2575 ;; operand in both positions.
2577 (define_insn ""
2578   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2579         (plus:HI (match_dup 0)
2580                  (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2581   "!TARGET_COLDFIRE"
2583   if (GET_CODE (operands[1]) == CONST_INT)
2584     {
2585       /* If the constant would be a negative number when interpreted as
2586          HImode, make it negative.  This is usually, but not always, done
2587          elsewhere in the compiler.  First check for constants out of range,
2588          which could confuse us.  */
2590       if (INTVAL (operands[1]) >= 32768)
2591         operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2593       if (INTVAL (operands[1]) > 0
2594           && INTVAL (operands[1]) <= 8)
2595         return "addq%.w %1,%0";
2596       if (INTVAL (operands[1]) < 0
2597           && INTVAL (operands[1]) >= -8)
2598         {
2599           operands[1] = GEN_INT (- INTVAL (operands[1]));
2600           return "subq%.w %1,%0";
2601         }
2602       /* On the CPU32 it is faster to use two addqw instructions to
2603          add a small integer (8 < N <= 16) to a register. 
2604          Likewise for subqw.  */
2605       if (TUNE_CPU32 && REG_P (operands[0]))
2606         {
2607           if (INTVAL (operands[1]) > 8
2608               && INTVAL (operands[1]) <= 16)
2609             {
2610               operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2611               return "addq%.w #8,%0\;addq%.w %1,%0";
2612             }
2613           if (INTVAL (operands[1]) < -8
2614               && INTVAL (operands[1]) >= -16)
2615             {
2616               operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2617               return "subq%.w #8,%0\;subq%.w %1,%0";
2618             }
2619         }
2620       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2621         return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2622     }
2623   return "add%.w %1,%0";
2626 (define_insn ""
2627   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2628         (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2629                  (match_dup 0)))]
2630   "!TARGET_COLDFIRE"
2632   if (GET_CODE (operands[1]) == CONST_INT)
2633     {
2634       /* If the constant would be a negative number when interpreted as
2635          HImode, make it negative.  This is usually, but not always, done
2636          elsewhere in the compiler.  First check for constants out of range,
2637          which could confuse us.  */
2639       if (INTVAL (operands[1]) >= 32768)
2640         operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2642       if (INTVAL (operands[1]) > 0
2643           && INTVAL (operands[1]) <= 8)
2644         return "addq%.w %1,%0";
2645       if (INTVAL (operands[1]) < 0
2646           && INTVAL (operands[1]) >= -8)
2647         {
2648           operands[1] = GEN_INT (- INTVAL (operands[1]));
2649           return "subq%.w %1,%0";
2650         }
2651       /* On the CPU32 it is faster to use two addqw instructions to
2652          add a small integer (8 < N <= 16) to a register.
2653          Likewise for subqw.  */
2654       if (TUNE_CPU32 && REG_P (operands[0]))
2655         {
2656           if (INTVAL (operands[1]) > 8
2657               && INTVAL (operands[1]) <= 16)
2658             {
2659               operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2660               return "addq%.w #8,%0\;addq%.w %1,%0";
2661             }
2662           if (INTVAL (operands[1]) < -8
2663               && INTVAL (operands[1]) >= -16)
2664             {
2665               operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2666               return "subq%.w #8,%0\;subq%.w %1,%0";
2667             }
2668         }
2669       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2670         return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2671     }
2672   return "add%.w %1,%0";
2675 (define_insn "addqi3"
2676   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2677         (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2678                  (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2679   "!TARGET_COLDFIRE"
2681   if (GET_CODE (operands[2]) == CONST_INT)
2682     {
2683       if (INTVAL (operands[2]) >= 128)
2684         operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2686       if (INTVAL (operands[2]) > 0
2687           && INTVAL (operands[2]) <= 8)
2688         return "addq%.b %2,%0";
2689       if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2690        {
2691          operands[2] = GEN_INT (- INTVAL (operands[2]));
2692          return "subq%.b %2,%0";
2693        }
2694     }
2695   return "add%.b %2,%0";
2698 (define_insn ""
2699   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2700         (plus:QI (match_dup 0)
2701                  (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2702   "!TARGET_COLDFIRE"
2704   if (GET_CODE (operands[1]) == CONST_INT)
2705     {
2706       if (INTVAL (operands[1]) >= 128)
2707         operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2709       if (INTVAL (operands[1]) > 0
2710           && INTVAL (operands[1]) <= 8)
2711         return "addq%.b %1,%0";
2712       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2713        {
2714          operands[1] = GEN_INT (- INTVAL (operands[1]));
2715          return "subq%.b %1,%0";
2716        }
2717     }
2718   return "add%.b %1,%0";
2721 (define_insn ""
2722   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2723         (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2724                  (match_dup 0)))]
2725   "!TARGET_COLDFIRE"
2727   if (GET_CODE (operands[1]) == CONST_INT)
2728     {
2729       if (INTVAL (operands[1]) >= 128)
2730         operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2732       if (INTVAL (operands[1]) > 0
2733           && INTVAL (operands[1]) <= 8)
2734         return "addq%.b %1,%0";
2735       if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2736        {
2737          operands[1] = GEN_INT (- INTVAL (operands[1]));
2738          return "subq%.b %1,%0";
2739        }
2740     }
2741   return "add%.b %1,%0";
2744 (define_expand "add<mode>3"
2745   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2746         (plus:FP (match_operand:FP 1 "general_operand" "")
2747                  (match_operand:FP 2 "general_operand" "")))]
2748   "TARGET_HARD_FLOAT"
2749   "")
2751 (define_insn "add<mode>3_floatsi_68881"
2752   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2753         (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2754                  (match_operand:FP 1 "general_operand" "0")))]
2755   "TARGET_68881"
2756   "f<FP:round>add%.l %2,%0"
2757   [(set_attr "type" "falu")
2758    (set_attr "opy" "2")])
2760 (define_insn "add<mode>3_floathi_68881"
2761   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2762         (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2763                  (match_operand:FP 1 "general_operand" "0")))]
2764   "TARGET_68881"
2765   "f<FP:round>add%.w %2,%0"
2766   [(set_attr "type" "falu")
2767    (set_attr "opy" "2")])
2769 (define_insn "add<mode>3_floatqi_68881"
2770   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2771         (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2772                  (match_operand:FP 1 "general_operand" "0")))]
2773   "TARGET_68881"
2774   "f<FP:round>add%.b %2,%0"
2775   [(set_attr "type" "falu")
2776    (set_attr "opy" "2")])
2778 (define_insn "add<mode>3_68881"
2779   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2780         (plus:FP (match_operand:FP 1 "general_operand" "%0")
2781                  (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2782   "TARGET_68881"
2784   if (FP_REG_P (operands[2]))
2785     return "f<FP:round>add%.x %2,%0";
2786   return "f<FP:round>add%.<FP:prec> %f2,%0";
2788   [(set_attr "type" "falu")
2789    (set_attr "opy" "2")])
2791 (define_insn "add<mode>3_cf"
2792   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2793         (plus:FP (match_operand:FP 1 "general_operand" "%0")
2794                  (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2795   "TARGET_COLDFIRE_FPU"
2797   if (FP_REG_P (operands[2]))
2798     return "f<FP:prec>add%.d %2,%0";
2799   return "f<FP:prec>add%.<FP:prec> %2,%0";
2801   [(set_attr "type" "falu")
2802    (set_attr "opy" "2")])
2804 ;; subtract instructions
2806 (define_insn "subdi_sexthishl32"
2807   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2808     (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2809         (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2810             (const_int 32))))
2811    (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2812   "!TARGET_COLDFIRE"
2814   CC_STATUS_INIT;
2815   if (ADDRESS_REG_P (operands[0]))
2816     return "sub%.w %2,%0";
2817   else if (ADDRESS_REG_P (operands[3]))
2818     return "move%.w %2,%3\;sub%.l %3,%0";
2819   else
2820     return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2823 (define_insn "subdi_dishl32"
2824   [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2825     (minus:DI (match_dup 0)
2826         (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2827             (const_int 32))))]
2828   ""
2830   CC_STATUS_INIT;
2831   if (GET_CODE (operands[1]) == REG)
2832     operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2833   else
2834     operands[1] = adjust_address (operands[1], SImode, 4);
2835   return "sub%.l %1,%0";
2837   [(set_attr "type" "alu_l")])
2839 (define_insn "subdi3"
2840   [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2841         (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2842                  (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2843    (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2844   ""
2846   if (DATA_REG_P (operands[0]))
2847     {
2848       if (DATA_REG_P (operands[2]))
2849         return "sub%.l %R2,%R0\;subx%.l %2,%0";
2850       else if (GET_CODE (operands[2]) == MEM
2851           && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2852         {
2853           return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2854         }
2855       else
2856         {
2857           rtx high, low;
2858           rtx xoperands[2];
2860           if (GET_CODE (operands[2]) == REG)
2861             {
2862               low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2863               high = operands[2];
2864             }
2865           else if (CONSTANT_P (operands[2]))
2866             split_double (operands[2], &high, &low);
2867           else
2868             {
2869               low = adjust_address (operands[2], SImode, 4);
2870               high = operands[2];
2871             }
2873           operands[1] = low, operands[2] = high;
2874           xoperands[0] = operands[3];
2875           if (GET_CODE (operands[1]) == CONST_INT
2876               && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2877             xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2878           else
2879             xoperands[1] = operands[2];
2881           output_asm_insn (output_move_simode (xoperands), xoperands);
2882           if (GET_CODE (operands[1]) == CONST_INT)
2883             {
2884               if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2885                 return "subq%.l %1,%R0\;subx%.l %3,%0";
2886               else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2887                 {
2888                   operands[1] = GEN_INT (-INTVAL (operands[1]));
2889                   return "addq%.l %1,%R0\;addx%.l %3,%0";
2890                 }
2891             }
2892           return "sub%.l %1,%R0\;subx%.l %3,%0";
2893         }
2894     }
2895   else
2896     {
2897       gcc_assert (GET_CODE (operands[0]) == MEM);
2898       CC_STATUS_INIT;
2899       if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2900         {
2901           operands[1]
2902             = gen_rtx_MEM (SImode, plus_constant (XEXP (operands[0], 0), -8));
2903           return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2904         }
2905       else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2906         {
2907           operands[1] = XEXP(operands[0], 0);
2908           return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2909         }
2910       else
2911         {
2912           operands[1] = adjust_address (operands[0], SImode, 4);
2913           return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2914         }
2915     }
2918 (define_insn "subsi3"
2919   [(set (match_operand:SI 0 "nonimmediate_operand" "=mda,m,d,a")
2920         (minus:SI (match_operand:SI 1 "general_operand" "0,0,0,0")
2921                   (match_operand:SI 2 "general_src_operand" "I,dT,mSrT,mSrs")))]
2922   ""
2923   "@
2924    subq%.l %2, %0
2925    sub%.l %2,%0
2926    sub%.l %2,%0
2927    sub%.l %2,%0"
2928   [(set_attr "type" "aluq_l,alu_l,alu_l,alu_l")
2929    (set_attr "opy" "2")])
2931 (define_insn ""
2932   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2933         (minus:SI (match_operand:SI 1 "general_operand" "0")
2934                   (sign_extend:SI
2935                    (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2936   "!TARGET_COLDFIRE"
2937   "sub%.w %2,%0")
2939 (define_insn "subhi3"
2940   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2941         (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2942                   (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2943   "!TARGET_COLDFIRE"
2944   "sub%.w %2,%0")
2946 (define_insn ""
2947   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2948         (minus:HI (match_dup 0)
2949                   (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2950   "!TARGET_COLDFIRE"
2951   "sub%.w %1,%0")
2953 (define_insn "subqi3"
2954   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2955         (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2956                   (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2957   "!TARGET_COLDFIRE"
2958   "sub%.b %2,%0")
2960 (define_insn ""
2961   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2962         (minus:QI (match_dup 0)
2963                   (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2964   "!TARGET_COLDFIRE"
2965   "sub%.b %1,%0")
2967 (define_expand "sub<mode>3"
2968   [(set (match_operand:FP 0 "nonimmediate_operand" "")
2969         (minus:FP (match_operand:FP 1 "general_operand" "")
2970                   (match_operand:FP 2 "general_operand" "")))]
2971   "TARGET_HARD_FLOAT"
2972   "")
2974 (define_insn "sub<mode>3_floatsi_68881"
2975   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2976         (minus:FP (match_operand:FP 1 "general_operand" "0")
2977                   (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2978   "TARGET_68881"
2979   "f<FP:round>sub%.l %2,%0"
2980   [(set_attr "type" "falu")
2981    (set_attr "opy" "2")])
2983 (define_insn "sub<mode>3_floathi_68881"
2984   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2985         (minus:FP (match_operand:FP 1 "general_operand" "0")
2986                   (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2987   "TARGET_68881"
2988   "f<FP:round>sub%.w %2,%0"
2989   [(set_attr "type" "falu")
2990    (set_attr "opy" "2")])
2992 (define_insn "sub<mode>3_floatqi_68881"
2993   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2994         (minus:FP (match_operand:FP 1 "general_operand" "0")
2995                   (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
2996   "TARGET_68881"
2997   "f<FP:round>sub%.b %2,%0"
2998   [(set_attr "type" "falu")
2999    (set_attr "opy" "2")])
3001 (define_insn "sub<mode>3_68881"
3002   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3003         (minus:FP (match_operand:FP 1 "general_operand" "0")
3004                   (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3005   "TARGET_68881"
3007   if (FP_REG_P (operands[2]))
3008     return "f<FP:round>sub%.x %2,%0";
3009   return "f<FP:round>sub%.<FP:prec> %f2,%0";
3011   [(set_attr "type" "falu")
3012    (set_attr "opy" "2")])
3014 (define_insn "sub<mode>3_cf"
3015   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3016         (minus:FP (match_operand:FP 1 "general_operand" "0")
3017                   (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
3018   "TARGET_COLDFIRE_FPU"
3020   if (FP_REG_P (operands[2]))
3021     return "f<FP:prec>sub%.d %2,%0";
3022   return "f<FP:prec>sub%.<FP:prec> %2,%0";
3024   [(set_attr "type" "falu")
3025    (set_attr "opy" "2")])
3027 ;; multiply instructions
3029 (define_insn "mulhi3"
3030   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3031         (mult:HI (match_operand:HI 1 "general_operand" "%0")
3032                  (match_operand:HI 2 "general_src_operand" "dmSn")))]
3033   ""
3035   return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3037   [(set_attr "type" "mul_w")
3038    (set_attr "opy" "2")])
3040 (define_insn "mulhisi3"
3041   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3042         (mult:SI (sign_extend:SI
3043                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
3044                  (sign_extend:SI
3045                   (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3046   ""
3048   return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3050   [(set_attr "type" "mul_w")
3051    (set_attr "opy" "2")])
3053 (define_insn "*mulhisisi3_s"
3054   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3055         (mult:SI (sign_extend:SI
3056                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
3057                  (match_operand:SI 2 "const_int_operand" "n")))]
3058   "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
3060   return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3062   [(set_attr "type" "mul_w")
3063    (set_attr "opy" "2")])
3065 (define_expand "mulsi3"
3066   [(set (match_operand:SI 0 "nonimmediate_operand" "")
3067         (mult:SI (match_operand:SI 1 "general_operand" "")
3068                  (match_operand:SI 2 "general_operand" "")))]
3069   "TARGET_68020 || TARGET_COLDFIRE"
3070   "")
3072 (define_insn "*mulsi3_68020"
3073   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3074         (mult:SI (match_operand:SI 1 "general_operand" "%0")
3075                  (match_operand:SI 2 "general_src_operand" "dmSTK")))]
3077   "TARGET_68020"
3078   "muls%.l %2,%0"
3079   [(set_attr "type" "mul_l")
3080    (set_attr "opy" "2")])
3082 (define_insn "*mulsi3_cf"
3083   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3084         (mult:SI (match_operand:SI 1 "general_operand" "%0")
3085                  (match_operand:SI 2 "general_operand" "d<Q>")))]
3086   "TARGET_COLDFIRE"
3087   "muls%.l %2,%0"
3088   [(set_attr "type" "mul_l")
3089    (set_attr "opy" "2")])
3091 (define_insn "umulhisi3"
3092   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3093         (mult:SI (zero_extend:SI
3094                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
3095                  (zero_extend:SI
3096                   (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3097   ""
3099   return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3101   [(set_attr "type" "mul_w")
3102    (set_attr "opy" "2")])
3104 (define_insn "*mulhisisi3_z"
3105   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3106         (mult:SI (zero_extend:SI
3107                   (match_operand:HI 1 "nonimmediate_operand" "%0"))
3108                  (match_operand:SI 2 "const_int_operand" "n")))]
3109   "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
3111   return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3113   [(set_attr "type" "mul_w")
3114    (set_attr "opy" "2")])
3116 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
3117 ;; proper matching constraint.  This is because the matching is between
3118 ;; the high-numbered word of the DImode operand[0] and operand[1].
3119 (define_expand "umulsidi3"
3120   [(parallel
3121     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3122           (mult:SI (match_operand:SI 1 "register_operand" "")
3123                    (match_operand:SI 2 "register_operand" "")))
3124      (set (subreg:SI (match_dup 0) 0)
3125           (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3126                                              (zero_extend:DI (match_dup 2)))
3127                                     (const_int 32))))])]
3128   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3129   "")
3131 (define_insn ""
3132   [(set (match_operand:SI 0 "register_operand" "=d")
3133         (mult:SI (match_operand:SI 1 "register_operand" "%0")
3134                   (match_operand:SI 2 "nonimmediate_operand" "dm")))
3135    (set (match_operand:SI 3 "register_operand" "=d")
3136         (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3137                                            (zero_extend:DI (match_dup 2)))
3138                                   (const_int 32))))]
3139   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3140   "mulu%.l %2,%3:%0")
3142 ; Match immediate case.  For 2.4 only match things < 2^31.
3143 ; It's tricky with larger values in these patterns since we need to match
3144 ; values between the two parallel multiplies, between a CONST_DOUBLE and
3145 ; a CONST_INT.
3146 (define_insn ""
3147   [(set (match_operand:SI 0 "register_operand" "=d")
3148         (mult:SI (match_operand:SI 1 "register_operand" "%0")
3149                  (match_operand:SI 2 "const_int_operand" "n")))
3150    (set (match_operand:SI 3 "register_operand" "=d")
3151         (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3152                                            (match_dup 2))
3153                                   (const_int 32))))]
3154   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
3155    && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
3156   "mulu%.l %2,%3:%0")
3158 (define_expand "mulsidi3"
3159   [(parallel
3160     [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3161           (mult:SI (match_operand:SI 1 "register_operand" "")
3162                    (match_operand:SI 2 "register_operand" "")))
3163      (set (subreg:SI (match_dup 0) 0)
3164           (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3165                                              (sign_extend:DI (match_dup 2)))
3166                                     (const_int 32))))])]
3167   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3168   "")
3170 (define_insn ""
3171   [(set (match_operand:SI 0 "register_operand" "=d")
3172         (mult:SI (match_operand:SI 1 "register_operand" "%0")
3173                  (match_operand:SI 2 "nonimmediate_operand" "dm")))
3174    (set (match_operand:SI 3 "register_operand" "=d")
3175         (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3176                                            (sign_extend:DI (match_dup 2)))
3177                                   (const_int 32))))]
3178   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3179   "muls%.l %2,%3:%0")
3181 (define_insn ""
3182   [(set (match_operand:SI 0 "register_operand" "=d")
3183         (mult:SI (match_operand:SI 1 "register_operand" "%0")
3184                  (match_operand:SI 2 "const_int_operand" "n")))
3185    (set (match_operand:SI 3 "register_operand" "=d")
3186         (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3187                                            (match_dup 2))
3188                                   (const_int 32))))]
3189   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3190   "muls%.l %2,%3:%0")
3192 (define_expand "umulsi3_highpart"
3193   [(parallel
3194     [(set (match_operand:SI 0 "register_operand" "")
3195           (truncate:SI
3196            (lshiftrt:DI
3197             (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
3198                      (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
3199             (const_int 32))))
3200      (clobber (match_dup 3))])]
3201   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3203   operands[3] = gen_reg_rtx (SImode);
3205   if (GET_CODE (operands[2]) == CONST_INT)
3206     {
3207       operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
3208                                         0, DImode);
3210       /* We have to adjust the operand order for the matching constraints.  */
3211       emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
3212                                              operands[1], operands[2]));
3213       DONE;
3214     }
3217 (define_insn ""
3218   [(set (match_operand:SI 0 "register_operand" "=d")
3219         (truncate:SI
3220          (lshiftrt:DI
3221           (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3222                    (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3223           (const_int 32))))
3224    (clobber (match_operand:SI 1 "register_operand" "=d"))]
3225   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3226   "mulu%.l %3,%0:%1")
3228 (define_insn "const_umulsi3_highpart"
3229   [(set (match_operand:SI 0 "register_operand" "=d")
3230         (truncate:SI
3231          (lshiftrt:DI
3232           (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
3233                    (match_operand:DI 3 "const_uint32_operand" "n"))
3234           (const_int 32))))
3235    (clobber (match_operand:SI 1 "register_operand" "=d"))]
3236   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3237   "mulu%.l %3,%0:%1")
3239 (define_expand "smulsi3_highpart"
3240   [(parallel
3241     [(set (match_operand:SI 0 "register_operand" "")
3242           (truncate:SI
3243            (lshiftrt:DI
3244             (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
3245                      (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
3246             (const_int 32))))
3247      (clobber (match_dup 3))])]
3248   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3250   operands[3] = gen_reg_rtx (SImode);
3251   if (GET_CODE (operands[2]) == CONST_INT)
3252     {
3253       /* We have to adjust the operand order for the matching constraints.  */
3254       emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
3255                                              operands[1], operands[2]));
3256       DONE;
3257     }
3260 (define_insn ""
3261   [(set (match_operand:SI 0 "register_operand" "=d")
3262         (truncate:SI
3263          (lshiftrt:DI
3264           (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3265                    (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3266           (const_int 32))))
3267    (clobber (match_operand:SI 1 "register_operand" "=d"))]
3268   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3269   "muls%.l %3,%0:%1")
3271 (define_insn "const_smulsi3_highpart"
3272   [(set (match_operand:SI 0 "register_operand" "=d")
3273         (truncate:SI
3274          (lshiftrt:DI
3275           (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
3276                    (match_operand:DI 3 "const_sint32_operand" "n"))
3277           (const_int 32))))
3278    (clobber (match_operand:SI 1 "register_operand" "=d"))]
3279   "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3280   "muls%.l %3,%0:%1")
3282 (define_expand "mul<mode>3"
3283   [(set (match_operand:FP 0 "nonimmediate_operand" "")
3284         (mult:FP (match_operand:FP 1 "general_operand" "")
3285                  (match_operand:FP 2 "general_operand" "")))]
3286   "TARGET_HARD_FLOAT"
3287   "")
3289 (define_insn "mul<mode>3_floatsi_68881"
3290   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3291         (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
3292                  (match_operand:FP 1 "general_operand" "0")))]
3293   "TARGET_68881"
3295   return TARGET_68040
3296          ? "f<FP:round>mul%.l %2,%0"
3297          : "f<FP:round_mul>mul%.l %2,%0";
3299   [(set_attr "type" "fmul")
3300    (set_attr "opy" "2")])
3302 (define_insn "mul<mode>3_floathi_68881"
3303   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3304         (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
3305                  (match_operand:FP 1 "general_operand" "0")))]
3306   "TARGET_68881"
3308   return TARGET_68040
3309          ? "f<FP:round>mul%.w %2,%0"
3310          : "f<FP:round_mul>mul%.w %2,%0";
3312   [(set_attr "type" "fmul")
3313    (set_attr "opy" "2")])
3315 (define_insn "mul<mode>3_floatqi_68881"
3316   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3317         (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
3318                  (match_operand:FP 1 "general_operand" "0")))]
3319   "TARGET_68881"
3321   return TARGET_68040
3322          ? "f<FP:round>mul%.b %2,%0"
3323          : "f<FP:round_mul>mul%.b %2,%0";
3325   [(set_attr "type" "fmul")
3326    (set_attr "opy" "2")])
3328 (define_insn "muldf_68881"
3329   [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3330         (mult:DF (match_operand:DF 1 "general_operand" "%0")
3331                  (match_operand:DF 2 "general_operand" "fmG")))]
3332   "TARGET_68881"
3334   if (GET_CODE (operands[2]) == CONST_DOUBLE
3335       && floating_exact_log2 (operands[2]) && !TUNE_68040_60)
3336     {
3337       int i = floating_exact_log2 (operands[2]);
3338       operands[2] = GEN_INT (i);
3339       return "fscale%.l %2,%0";
3340     }
3341   if (REG_P (operands[2]))
3342     return "f%&mul%.x %2,%0";
3343   return "f%&mul%.d %f2,%0";
3346 (define_insn "mulsf_68881"
3347   [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3348         (mult:SF (match_operand:SF 1 "general_operand" "%0")
3349                  (match_operand:SF 2 "general_operand" "fdmF")))]
3350   "TARGET_68881"
3352   if (FP_REG_P (operands[2]))
3353     return (TARGET_68040
3354             ? "fsmul%.x %2,%0"
3355             : "fsglmul%.x %2,%0");
3356   return (TARGET_68040
3357           ? "fsmul%.s %f2,%0"
3358           : "fsglmul%.s %f2,%0");
3361 (define_insn "mulxf3_68881"
3362   [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
3363         (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
3364                  (match_operand:XF 2 "nonimmediate_operand" "fm")))]
3365   "TARGET_68881"
3367   return "fmul%.x %f2,%0";
3370 (define_insn "fmul<mode>3_cf"
3371   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3372         (mult:FP (match_operand:FP 1 "general_operand" "%0")
3373                  (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3374   "TARGET_COLDFIRE_FPU"
3376   if (FP_REG_P (operands[2]))
3377     return "f<FP:prec>mul%.d %2,%0";
3378   return "f<FP:prec>mul%.<FP:prec> %2,%0";
3380   [(set_attr "type" "fmul")
3381    (set_attr "opy" "2")])
3383 ;; divide instructions
3385 (define_expand "div<mode>3"
3386   [(set (match_operand:FP 0 "nonimmediate_operand" "")
3387         (div:FP (match_operand:FP 1 "general_operand" "")
3388                 (match_operand:FP 2 "general_operand" "")))]
3389   "TARGET_HARD_FLOAT"
3390   "")
3392 (define_insn "div<mode>3_floatsi_68881"
3393   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3394         (div:FP (match_operand:FP 1 "general_operand" "0")
3395                 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
3396   "TARGET_68881"
3398   return TARGET_68040
3399          ? "f<FP:round>div%.l %2,%0"
3400          : "f<FP:round_mul>div%.l %2,%0";
3403 (define_insn "div<mode>3_floathi_68881"
3404   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3405         (div:FP (match_operand:FP 1 "general_operand" "0")
3406                 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
3407   "TARGET_68881"
3409   return TARGET_68040
3410          ? "f<FP:round>div%.w %2,%0"
3411          : "f<FP:round_mul>div%.w %2,%0";
3414 (define_insn "div<mode>3_floatqi_68881"
3415   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3416         (div:FP (match_operand:FP 1 "general_operand" "0")
3417                 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3418   "TARGET_68881"
3420   return TARGET_68040
3421          ? "f<FP:round>div%.b %2,%0"
3422          : "f<FP:round_mul>div%.b %2,%0";
3425 (define_insn "div<mode>3_68881"
3426   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3427         (div:FP (match_operand:FP 1 "general_operand" "0")
3428                 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3429   "TARGET_68881"
3431   if (FP_REG_P (operands[2]))
3432     return (TARGET_68040
3433             ? "f<FP:round>div%.x %2,%0"
3434             : "f<FP:round_mul>div%.x %2,%0");
3435   return (TARGET_68040
3436           ? "f<FP:round>div%.<FP:prec> %f2,%0"
3437           : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
3440 (define_insn "div<mode>3_cf"
3441   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3442         (div:FP (match_operand:FP 1 "general_operand" "0")
3443                 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3444   "TARGET_COLDFIRE_FPU"
3446   if (FP_REG_P (operands[2]))
3447     return "f<FP:prec>div%.d %2,%0";
3448   return "f<FP:prec>div%.<FP:prec> %2,%0";
3450   [(set_attr "type" "fdiv")
3451    (set_attr "opy" "2")])
3453 ;; Remainder instructions.
3455 (define_expand "divmodsi4"
3456   [(parallel
3457     [(set (match_operand:SI 0 "nonimmediate_operand" "")
3458           (div:SI (match_operand:SI 1 "general_operand" "")
3459                   (match_operand:SI 2 "general_src_operand" "")))
3460      (set (match_operand:SI 3 "nonimmediate_operand" "")
3461           (mod:SI (match_dup 1) (match_dup 2)))])]
3462   "TARGET_68020 || TARGET_CF_HWDIV"
3463   "")
3465 (define_insn ""
3466   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3467         (div:SI (match_operand:SI 1 "general_operand" "0")
3468                 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3469    (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3470         (mod:SI (match_dup 1) (match_dup 2)))]
3471   "TARGET_CF_HWDIV"
3473   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3474     return "divs%.l %2,%0";
3475   else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3476     return "rems%.l %2,%3:%0";
3477   else
3478     return "rems%.l %2,%3:%0\;divs%.l %2,%0";
3480   [(set_attr "type" "div_l")
3481    (set_attr "opy" "2")])
3483 (define_insn ""
3484   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3485         (div:SI (match_operand:SI 1 "general_operand" "0")
3486                 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3487    (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3488         (mod:SI (match_dup 1) (match_dup 2)))]
3489   "TARGET_68020"
3491   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3492     return "divs%.l %2,%0";
3493   else
3494     return "divsl%.l %2,%3:%0";
3497 (define_expand "udivmodsi4"
3498   [(parallel
3499     [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3500           (udiv:SI (match_operand:SI 1 "general_operand" "0")
3501                    (match_operand:SI 2 "general_src_operand" "dmSTK")))
3502      (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3503           (umod:SI (match_dup 1) (match_dup 2)))])]
3504   "TARGET_68020 || TARGET_CF_HWDIV"
3505   "")
3507 (define_insn ""
3508   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3509         (udiv:SI (match_operand:SI 1 "general_operand" "0")
3510                  (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3511    (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3512         (umod:SI (match_dup 1) (match_dup 2)))]
3513   "TARGET_CF_HWDIV"
3515   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3516     return "divu%.l %2,%0";
3517   else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3518     return "remu%.l %2,%3:%0";
3519   else
3520     return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3522   [(set_attr "type" "div_l")
3523    (set_attr "opy" "2")])
3525 (define_insn ""
3526   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3527         (udiv:SI (match_operand:SI 1 "general_operand" "0")
3528                  (match_operand:SI 2 "general_src_operand" "dmSTK")))
3529    (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3530         (umod:SI (match_dup 1) (match_dup 2)))]
3531   "TARGET_68020 && !TARGET_COLDFIRE"
3533   if (find_reg_note (insn, REG_UNUSED, operands[3]))
3534     return "divu%.l %2,%0";
3535   else
3536     return "divul%.l %2,%3:%0";
3539 (define_insn "divmodhi4"
3540   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3541         (div:HI (match_operand:HI 1 "general_operand" "0")
3542                 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3543    (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3544         (mod:HI (match_dup 1) (match_dup 2)))]
3545   "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3547   output_asm_insn (MOTOROLA ?
3548     "ext%.l %0\;divs%.w %2,%0" :
3549     "extl %0\;divs %2,%0",
3550     operands);
3551   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3552     {
3553       CC_STATUS_INIT;
3554       return "move%.l %0,%3\;swap %3";
3555     }
3556   else
3557     return "";
3560 (define_insn "udivmodhi4"
3561   [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3562         (udiv:HI (match_operand:HI 1 "general_operand" "0")
3563                  (match_operand:HI 2 "general_src_operand" "dmSKT")))
3564    (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3565         (umod:HI (match_dup 1) (match_dup 2)))]
3566   "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3568   if (ISA_HAS_MVS_MVZ)
3569     output_asm_insn (MOTOROLA ?
3570       "mvz%.w %0,%0\;divu%.w %2,%0" :
3571       "mvz%.w %0,%0\;divu %2,%0",
3572       operands);
3573   else
3574     output_asm_insn (MOTOROLA ?
3575       "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3576       "and%.l #0xFFFF,%0\;divu %2,%0",
3577       operands);
3579   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3580     {
3581       CC_STATUS_INIT;
3582       return "move%.l %0,%3\;swap %3";
3583     }
3584   else
3585     return "";
3588 ;; logical-and instructions
3590 ;; "anddi3" is mainly here to help combine().
3591 (define_insn "anddi3"
3592   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3593         (and:DI (match_operand:DI 1 "general_operand" "%0,0")
3594                 (match_operand:DI 2 "general_operand" "dn,don")))]
3595   "!TARGET_COLDFIRE"
3597   CC_STATUS_INIT;
3598   /* We can get CONST_DOUBLE, but also const1_rtx etc.  */
3599   if (CONSTANT_P (operands[2]))
3600     {
3601       rtx hi, lo;
3603       split_double (operands[2], &hi, &lo);
3605       switch (INTVAL (hi))
3606         {
3607           case 0 :
3608             output_asm_insn ("clr%.l %0", operands);
3609             break;
3610           case -1 :
3611             break;
3612           default :
3613             {
3614             rtx xoperands[3];
3616             xoperands[0] = operands[0];
3617             xoperands[2] = hi;
3618             output_asm_insn (output_andsi3 (xoperands), xoperands);
3619             }
3620         }
3621       if (GET_CODE (operands[0]) == REG)
3622         operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3623       else
3624         operands[0] = adjust_address (operands[0], SImode, 4);
3625       switch (INTVAL (lo))
3626         {
3627           case 0 :
3628             output_asm_insn ("clr%.l %0", operands);
3629             break;
3630           case -1 :
3631             break;
3632           default :
3633             {
3634             rtx xoperands[3];
3636             xoperands[0] = operands[0];
3637             xoperands[2] = lo;
3638             output_asm_insn (output_andsi3 (xoperands), xoperands);
3639             }
3640         }
3641       return "";
3642     }
3643   if (GET_CODE (operands[0]) != REG)
3644     {
3645       operands[1] = adjust_address (operands[0], SImode, 4);
3646       return "and%.l %2,%0\;and%.l %R2,%1";
3647     }
3648   if (GET_CODE (operands[2]) != REG)
3649     {
3650       operands[1] = adjust_address (operands[2], SImode, 4);
3651       return "and%.l %2,%0\;and%.l %1,%R0";
3652     }
3653   return "and%.l %2,%0\;and%.l %R2,%R0";
3656 ;; Prevent AND from being made with sp.  This doesn't exist in the machine
3657 ;; and reload will cause inefficient code.  Since sp is a FIXED_REG, we
3658 ;; can't allocate pseudos into it.
3660 (define_expand "andsi3"
3661   [(set (match_operand:SI 0 "not_sp_operand" "")
3662         (and:SI (match_operand:SI 1 "general_operand" "")
3663                 (match_operand:SI 2 "general_src_operand" "")))]
3664   ""
3665   "")
3667 ;; produced by split operations after reload finished
3668 (define_insn "*andsi3_split"
3669   [(set (match_operand:SI 0 "register_operand" "=d")
3670         (and:SI (match_operand:SI 1 "register_operand" "0")
3671                 (match_operand:SI 2 "const_int_operand" "i")))]
3672   "reload_completed && !TARGET_COLDFIRE"
3674   return output_andsi3 (operands);
3677 (define_insn "andsi3_internal"
3678   [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3679         (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3680                 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3681   "!TARGET_COLDFIRE"
3683   return output_andsi3 (operands);
3686 (define_insn "andsi3_5200"
3687   [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3688         (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3689                 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3690   "TARGET_COLDFIRE"
3692   if (ISA_HAS_MVS_MVZ
3693       && DATA_REG_P (operands[0])
3694       && GET_CODE (operands[2]) == CONST_INT)
3695     {
3696       if (INTVAL (operands[2]) == 0x000000ff)
3697         return "mvz%.b %0,%0";
3698       else if (INTVAL (operands[2]) == 0x0000ffff)
3699         return "mvz%.w %0,%0";
3700     }
3701   return output_andsi3 (operands);
3704 (define_insn "andhi3"
3705   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3706         (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3707                 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3708   "!TARGET_COLDFIRE"
3709   "and%.w %2,%0")
3711 (define_insn ""
3712   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3713         (and:HI (match_dup 0)
3714                 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3715   "!TARGET_COLDFIRE"
3716   "and%.w %1,%0")
3718 (define_insn ""
3719   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3720         (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3721                 (match_dup 0)))]
3722   "!TARGET_COLDFIRE"
3723   "and%.w %1,%0")
3725 (define_insn "andqi3"
3726   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3727         (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3728                 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3729   "!TARGET_COLDFIRE"
3730   "and%.b %2,%0")
3732 (define_insn ""
3733   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3734         (and:QI (match_dup 0)
3735                 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3736   "!TARGET_COLDFIRE"
3737   "and%.b %1,%0")
3739 (define_insn ""
3740   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3741         (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3742                 (match_dup 0)))]
3743   "!TARGET_COLDFIRE"
3744   "and%.b %1,%0")
3746 ;; inclusive-or instructions
3748 (define_insn "iordi_zext"
3749   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3750     (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3751         (match_operand:DI 2 "general_operand" "0,0")))]
3752   "!TARGET_COLDFIRE"
3754   int byte_mode;
3756   CC_STATUS_INIT;
3757   if (GET_CODE (operands[0]) == REG)
3758     operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3759   else
3760     operands[0] = adjust_address (operands[0], SImode, 4);
3761   if (GET_MODE (operands[1]) == SImode)
3762     return "or%.l %1,%0";
3763   byte_mode = (GET_MODE (operands[1]) == QImode);
3764   if (GET_CODE (operands[0]) == MEM)
3765     operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3766                                   byte_mode ? 3 : 2);
3767   if (byte_mode)
3768     return "or%.b %1,%0";
3769   else
3770     return "or%.w %1,%0";
3773 ;; "iordi3" is mainly here to help combine().
3774 (define_insn "iordi3"
3775   [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3776         (ior:DI (match_operand:DI 1 "general_operand" "%0,0")
3777                 (match_operand:DI 2 "general_operand" "dn,don")))]
3778   "!TARGET_COLDFIRE"
3780   CC_STATUS_INIT;
3781   /* We can get CONST_DOUBLE, but also const1_rtx etc.  */
3782   if (CONSTANT_P (operands[2]))
3783     {
3784       rtx hi, lo;
3786       split_double (operands[2], &hi, &lo);
3788       switch (INTVAL (hi))
3789         {
3790           case 0 :
3791             break;
3792           case -1 :
3793             /* FIXME : a scratch register would be welcome here if operand[0]
3794                is not a register */
3795             output_asm_insn ("move%.l #-1,%0", operands);
3796             break;
3797           default :
3798             {
3799             rtx xoperands[3];
3801             xoperands[0] = operands[0];
3802             xoperands[2] = hi;
3803             output_asm_insn (output_iorsi3 (xoperands), xoperands);
3804             }
3805         }
3806       if (GET_CODE (operands[0]) == REG)
3807         operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3808       else
3809         operands[0] = adjust_address (operands[0], SImode, 4);
3810       switch (INTVAL (lo))
3811         {
3812           case 0 :
3813             break;
3814           case -1 :
3815             /* FIXME : a scratch register would be welcome here if operand[0]
3816                is not a register */
3817             output_asm_insn ("move%.l #-1,%0", operands);
3818             break;
3819           default :
3820             {
3821             rtx xoperands[3];
3823             xoperands[0] = operands[0];
3824             xoperands[2] = lo;
3825             output_asm_insn (output_iorsi3 (xoperands), xoperands);
3826             }
3827         }
3828       return "";
3829     }
3830   if (GET_CODE (operands[0]) != REG)
3831     {
3832       operands[1] = adjust_address (operands[0], SImode, 4);
3833       return "or%.l %2,%0\;or%.l %R2,%1";
3834     }
3835   if (GET_CODE (operands[2]) != REG)
3836     {
3837       operands[1] = adjust_address (operands[2], SImode, 4);
3838       return "or%.l %2,%0\;or%.l %1,%R0";
3839     }
3840   return "or%.l %2,%0\;or%.l %R2,%R0";
3843 (define_expand "iorsi3"
3844   [(set (match_operand:SI 0 "nonimmediate_operand" "")
3845         (ior:SI (match_operand:SI 1 "general_operand" "")
3846                 (match_operand:SI 2 "general_src_operand" "")))]
3847   ""
3848   "")
3850 (define_insn "iorsi3_internal"
3851   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3852         (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3853                 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3854   "! TARGET_COLDFIRE"
3856   return output_iorsi3 (operands);
3859 (define_insn "iorsi3_5200"
3860   [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3861         (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3862                 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3863   "TARGET_COLDFIRE"
3865   return output_iorsi3 (operands);
3868 (define_insn "iorhi3"
3869   [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3870         (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3871                 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3872   "!TARGET_COLDFIRE"
3873   "or%.w %2,%0")
3875 (define_insn ""
3876   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3877         (ior:HI (match_dup 0)
3878                 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3879   "!TARGET_COLDFIRE"
3880   "or%.w %1,%0")
3882 (define_insn ""
3883   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3884         (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3885                 (match_dup 0)))]
3886   "!TARGET_COLDFIRE"
3887   "or%.w %1,%0")
3889 (define_insn "iorqi3"
3890   [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3891         (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3892                 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3893   "!TARGET_COLDFIRE"
3894   "or%.b %2,%0")
3896 (define_insn ""
3897   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3898         (ior:QI (match_dup 0)
3899                 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3900   "!TARGET_COLDFIRE"
3901   "or%.b %1,%0")
3903 (define_insn ""
3904   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3905         (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3906                 (match_dup 0)))]
3907   "!TARGET_COLDFIRE"
3908   "or%.b %1,%0")
3910 ;; On all 68k models, this makes faster code in a special case.
3911 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3913 (define_insn "iorsi_zexthi_ashl16"
3914   [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3915     (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3916         (ashift:SI (match_operand:SI 2 "general_operand" "or")
3917             (const_int 16))))]
3918   ""
3920   CC_STATUS_INIT;
3921   if (GET_CODE (operands[2]) != REG)
3922       operands[2] = adjust_address (operands[2], HImode, 2);
3923   if (GET_CODE (operands[2]) != REG
3924   || REGNO (operands[2]) != REGNO (operands[0]))
3925     output_asm_insn ("move%.w %2,%0", operands);
3926   return "swap %0\;mov%.w %1,%0";
3929 (define_insn "iorsi_zext"
3930   [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3931     (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3932         (match_operand:SI 2 "general_operand" "0,0")))]
3933   "!TARGET_COLDFIRE"
3935   int byte_mode;
3937   CC_STATUS_INIT;
3938   byte_mode = (GET_MODE (operands[1]) == QImode);
3939   if (GET_CODE (operands[0]) == MEM)
3940     operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3941                                   byte_mode ? 3 : 2);
3942   if (byte_mode)
3943     return "or%.b %1,%0";
3944   else
3945     return "or%.w %1,%0";
3948 ;; xor instructions
3950 ;; "xordi3" is mainly here to help combine().
3951 (define_insn "xordi3"
3952   [(set (match_operand:DI 0 "nonimmediate_operand" "=od")
3953         (xor:DI (match_operand:DI 1 "general_operand" "%0")
3954                 (match_operand:DI 2 "general_operand" "dn")))]
3955   "!TARGET_COLDFIRE"
3957   CC_STATUS_INIT;
3958   /* We can get CONST_DOUBLE, but also const1_rtx etc.  */
3960   if (CONSTANT_P (operands[2]))
3961     {
3962       rtx hi, lo;
3964       split_double (operands[2], &hi, &lo);
3966       switch (INTVAL (hi))
3967         {
3968           case 0 :
3969             break;
3970           case -1 :
3971             output_asm_insn ("not%.l %0", operands);
3972             break;
3973           default :
3974             /* FIXME : a scratch register would be welcome here if
3975                -128 <= INTVAL (hi) < -1 */
3976             {
3977             rtx xoperands[3];
3979             xoperands[0] = operands[0];
3980             xoperands[2] = hi;
3981             output_asm_insn (output_xorsi3 (xoperands), xoperands);
3982             }
3983         }
3984       if (GET_CODE (operands[0]) == REG)
3985         operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3986       else
3987         operands[0] = adjust_address (operands[0], SImode, 4);
3988       switch (INTVAL (lo))
3989         {
3990           case 0 :
3991             break;
3992           case -1 :
3993             output_asm_insn ("not%.l %0", operands);
3994             break;
3995           default :
3996             /* FIXME : a scratch register would be welcome here if
3997                -128 <= INTVAL (lo) < -1 */
3998             operands[2] = lo;
3999             /* FIXME : this should be merged with xorsi3 */
4000             {
4001             rtx xoperands[3];
4003             xoperands[0] = operands[0];
4004             xoperands[2] = lo;
4005             output_asm_insn (output_xorsi3 (xoperands), xoperands);
4006             }
4007         }
4008       return "";
4009     }
4010   if (GET_CODE (operands[0]) != REG)
4011     {
4012       operands[1] = adjust_address (operands[0], SImode, 4);
4013       return "eor%.l %2,%0\;eor%.l %R2,%1";
4014     }
4015   if (GET_CODE (operands[2]) != REG)
4016     {
4017       operands[1] = adjust_address (operands[2], SImode, 4);
4018       return "eor%.l %2,%0\;eor%.l %1,%R0";
4019     }
4020   return "eor%.l %2,%0\;eor%.l %R2,%R0";
4023 (define_expand "xorsi3"
4024   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4025         (xor:SI (match_operand:SI 1 "general_operand" "")
4026                 (match_operand:SI 2 "general_operand" "")))]
4027   ""
4028   "")
4030 (define_insn "xorsi3_internal"
4031   [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
4032         (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
4033                 (match_operand:SI 2 "general_operand" "di,dKT")))]
4035   "!TARGET_COLDFIRE"
4037   return output_xorsi3 (operands);
4040 (define_insn "xorsi3_5200"
4041   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
4042         (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
4043                 (match_operand:SI 2 "general_operand" "d,Ks")))]
4044   "TARGET_COLDFIRE"
4046   return output_xorsi3 (operands);
4049 (define_insn "xorhi3"
4050   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4051         (xor:HI (match_operand:HI 1 "general_operand" "%0")
4052                 (match_operand:HI 2 "general_operand" "dn")))]
4053   "!TARGET_COLDFIRE"
4054   "eor%.w %2,%0")
4056 (define_insn ""
4057   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4058         (xor:HI (match_dup 0)
4059                 (match_operand:HI 1 "general_operand" "dn")))]
4060   "!TARGET_COLDFIRE"
4061   "eor%.w %1,%0")
4063 (define_insn ""
4064   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4065         (xor:HI (match_operand:HI 1 "general_operand" "dn")
4066                 (match_dup 0)))]
4067   "!TARGET_COLDFIRE"
4068   "eor%.w %1,%0")
4070 (define_insn "xorqi3"
4071   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4072         (xor:QI (match_operand:QI 1 "general_operand" "%0")
4073                 (match_operand:QI 2 "general_operand" "dn")))]
4074   "!TARGET_COLDFIRE"
4075   "eor%.b %2,%0")
4077 (define_insn ""
4078   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4079         (xor:QI (match_dup 0)
4080                 (match_operand:QI 1 "general_operand" "dn")))]
4081   "!TARGET_COLDFIRE"
4082   "eor%.b %1,%0")
4084 (define_insn ""
4085   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4086         (xor:QI (match_operand:QI 1 "general_operand" "dn")
4087                 (match_dup 0)))]
4088   "!TARGET_COLDFIRE"
4089   "eor%.b %1,%0")
4091 ;; negation instructions
4093 (define_expand "negdi2"
4094   [(set (match_operand:DI 0 "nonimmediate_operand" "")
4095         (neg:DI (match_operand:DI 1 "general_operand" "")))]
4096   ""
4098   if (TARGET_COLDFIRE)
4099     emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
4100   else
4101     emit_insn (gen_negdi2_internal (operands[0], operands[1]));
4102   DONE;
4105 (define_insn "negdi2_internal"
4106   [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
4107         (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
4108   "!TARGET_COLDFIRE"
4110   if (which_alternative == 0)
4111     return "neg%.l %0\;negx%.l %0";
4112   if (GET_CODE (operands[0]) == REG)
4113     operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4114   else
4115     operands[1] = adjust_address (operands[0], SImode, 4);
4116   if (ADDRESS_REG_P (operands[0]))
4117     return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
4118   else
4119     return "neg%.l %1\;negx%.l %0";
4122 (define_insn "negdi2_5200"
4123   [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
4124         (neg:DI (match_operand:DI 1 "general_operand" "0")))]
4125   "TARGET_COLDFIRE"
4127   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4128   return "neg%.l %1\;negx%.l %0";
4131 (define_expand "negsi2"
4132   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4133         (neg:SI (match_operand:SI 1 "general_operand" "")))]
4134   ""
4136   if (TARGET_COLDFIRE)
4137     emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
4138   else
4139     emit_insn (gen_negsi2_internal (operands[0], operands[1]));
4140   DONE;
4143 (define_insn "negsi2_internal"
4144   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4145         (neg:SI (match_operand:SI 1 "general_operand" "0")))]
4146   "!TARGET_COLDFIRE"
4147   "neg%.l %0"
4148   [(set_attr "type" "neg_l")])
4150 (define_insn "negsi2_5200"
4151   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4152         (neg:SI (match_operand:SI 1 "general_operand" "0")))]
4153   "TARGET_COLDFIRE"
4154   "neg%.l %0"
4155   [(set_attr "type" "neg_l")])
4157 (define_insn "neghi2"
4158   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4159         (neg:HI (match_operand:HI 1 "general_operand" "0")))]
4160   "!TARGET_COLDFIRE"
4161   "neg%.w %0")
4163 (define_insn ""
4164   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4165         (neg:HI (match_dup 0)))]
4166   "!TARGET_COLDFIRE"
4167   "neg%.w %0")
4169 (define_insn "negqi2"
4170   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4171         (neg:QI (match_operand:QI 1 "general_operand" "0")))]
4172   "!TARGET_COLDFIRE"
4173   "neg%.b %0")
4175 (define_insn ""
4176   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4177         (neg:QI (match_dup 0)))]
4178   "!TARGET_COLDFIRE"
4179   "neg%.b %0")
4181 ;; If using software floating point, just flip the sign bit.
4183 (define_expand "negsf2"
4184   [(set (match_operand:SF 0 "nonimmediate_operand" "")
4185         (neg:SF (match_operand:SF 1 "general_operand" "")))]
4186   ""
4188   if (!TARGET_HARD_FLOAT)
4189     {
4190       rtx result;
4191       rtx target;
4193       target = operand_subword_force (operands[0], 0, SFmode);
4194       result = expand_binop (SImode, xor_optab,
4195                              operand_subword_force (operands[1], 0, SFmode),
4196                              GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4197       gcc_assert (result);
4199       if (result != target)
4200         emit_move_insn (result, target);
4202       /* Make a place for REG_EQUAL.  */
4203       emit_move_insn (operands[0], operands[0]);
4204       DONE;
4205     }
4208 (define_expand "negdf2"
4209   [(set (match_operand:DF 0 "nonimmediate_operand" "")
4210         (neg:DF (match_operand:DF 1 "general_operand" "")))]
4211   ""
4213   if (!TARGET_HARD_FLOAT)
4214     {
4215       rtx result;
4216       rtx target;
4217       rtx insns;
4219       start_sequence ();
4220       target = operand_subword (operands[0], 0, 1, DFmode);
4221       result = expand_binop (SImode, xor_optab,
4222                              operand_subword_force (operands[1], 0, DFmode),
4223                              GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4224       gcc_assert (result);
4226       if (result != target)
4227         emit_move_insn (result, target);
4229       emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4230                       operand_subword_force (operands[1], 1, DFmode));
4232       insns = get_insns ();
4233       end_sequence ();
4235       emit_insn (insns);
4236       DONE;
4237     }
4240 (define_expand "negxf2"
4241   [(set (match_operand:XF 0 "nonimmediate_operand" "")
4242         (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4243   ""
4245   if (!TARGET_68881)
4246     {
4247       rtx result;
4248       rtx target;
4249       rtx insns;
4251       start_sequence ();
4252       target = operand_subword (operands[0], 0, 1, XFmode);
4253       result = expand_binop (SImode, xor_optab,
4254                              operand_subword_force (operands[1], 0, XFmode),
4255                              GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4256       gcc_assert (result);
4258       if (result != target)
4259         emit_move_insn (result, target);
4261       emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4262                       operand_subword_force (operands[1], 1, XFmode));
4263       emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4264                       operand_subword_force (operands[1], 2, XFmode));
4266       insns = get_insns ();
4267       end_sequence ();
4269       emit_insn (insns);
4270       DONE;
4271     }
4274 (define_insn "neg<mode>2_68881"
4275   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4276         (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4277   "TARGET_68881"
4279   if (DATA_REG_P (operands[0]))
4280     {
4281       operands[1] = GEN_INT (31);
4282       return "bchg %1,%0";
4283     }
4284   if (FP_REG_P (operands[1]))
4285     return "f<FP:round>neg%.x %1,%0";
4286   return "f<FP:round>neg%.<FP:prec> %f1,%0";
4289 (define_insn "neg<mode>2_cf"
4290   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4291         (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4292   "TARGET_COLDFIRE_FPU"
4294   if (DATA_REG_P (operands[0]))
4295     {
4296       operands[1] = GEN_INT (31);
4297       return "bchg %1,%0";
4298     }
4299   if (FP_REG_P (operands[1]))
4300     return "f<FP:prec>neg%.d %1,%0";
4301   return "f<FP:prec>neg%.<FP:prec> %1,%0";
4304 ;; Sqrt instruction for the 68881
4306 (define_expand "sqrt<mode>2"
4307   [(set (match_operand:FP 0 "nonimmediate_operand" "")
4308         (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
4309   "TARGET_HARD_FLOAT"
4310   "")
4312 (define_insn "sqrt<mode>2_68881"
4313   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4314         (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
4315   "TARGET_68881"
4317   if (FP_REG_P (operands[1]))
4318     return "f<FP:round>sqrt%.x %1,%0";
4319   return "f<FP:round>sqrt%.<FP:prec> %1,%0";
4321   [(set_attr "type" "fsqrt")])
4323 (define_insn "sqrt<mode>2_cf"
4324   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4325         (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
4326   "TARGET_COLDFIRE_FPU"
4328   if (FP_REG_P (operands[1]))
4329     return "f<FP:prec>sqrt%.d %1,%0";
4330   return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
4332   [(set_attr "type" "fsqrt")])
4333 ;; Absolute value instructions
4334 ;; If using software floating point, just zero the sign bit.
4336 (define_expand "abssf2"
4337   [(set (match_operand:SF 0 "nonimmediate_operand" "")
4338         (abs:SF (match_operand:SF 1 "general_operand" "")))]
4339   ""
4341   if (!TARGET_HARD_FLOAT)
4342     {
4343       rtx result;
4344       rtx target;
4346       target = operand_subword_force (operands[0], 0, SFmode);
4347       result = expand_binop (SImode, and_optab,
4348                              operand_subword_force (operands[1], 0, SFmode),
4349                              GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4350       gcc_assert (result);
4352       if (result != target)
4353         emit_move_insn (result, target);
4355       /* Make a place for REG_EQUAL.  */
4356       emit_move_insn (operands[0], operands[0]);
4357       DONE;
4358     }
4361 (define_expand "absdf2"
4362   [(set (match_operand:DF 0 "nonimmediate_operand" "")
4363         (abs:DF (match_operand:DF 1 "general_operand" "")))]
4364   ""
4366   if (!TARGET_HARD_FLOAT)
4367     {
4368       rtx result;
4369       rtx target;
4370       rtx insns;
4372       start_sequence ();
4373       target = operand_subword (operands[0], 0, 1, DFmode);
4374       result = expand_binop (SImode, and_optab,
4375                              operand_subword_force (operands[1], 0, DFmode),
4376                              GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4377       gcc_assert (result);
4379       if (result != target)
4380         emit_move_insn (result, target);
4382       emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4383                       operand_subword_force (operands[1], 1, DFmode));
4385       insns = get_insns ();
4386       end_sequence ();
4388       emit_insn (insns);
4389       DONE;
4390     }
4393 (define_expand "absxf2"
4394   [(set (match_operand:XF 0 "nonimmediate_operand" "")
4395         (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4396   ""
4398   if (!TARGET_68881)
4399     {
4400       rtx result;
4401       rtx target;
4402       rtx insns;
4404       start_sequence ();
4405       target = operand_subword (operands[0], 0, 1, XFmode);
4406       result = expand_binop (SImode, and_optab,
4407                              operand_subword_force (operands[1], 0, XFmode),
4408                              GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4409       gcc_assert (result);
4411       if (result != target)
4412         emit_move_insn (result, target);
4414       emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4415                       operand_subword_force (operands[1], 1, XFmode));
4416       emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4417                       operand_subword_force (operands[1], 2, XFmode));
4419       insns = get_insns ();
4420       end_sequence ();
4422       emit_insn (insns);
4423       DONE;
4424     }
4427 (define_insn "abs<mode>2_68881"
4428   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4429         (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4430   "TARGET_68881"
4432   if (DATA_REG_P (operands[0]))
4433     {
4434       operands[1] = GEN_INT (31);
4435       return "bclr %1,%0";
4436     }
4437   if (FP_REG_P (operands[1]))
4438     return "f<FP:round>abs%.x %1,%0";
4439   return "f<FP:round>abs%.<FP:prec> %f1,%0";
4442 (define_insn "abs<mode>2_cf"
4443   [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4444         (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4445   "TARGET_COLDFIRE_FPU"
4447   if (DATA_REG_P (operands[0]))
4448     {
4449       operands[1] = GEN_INT (31);
4450       return "bclr %1,%0";
4451     }
4452   if (FP_REG_P (operands[1]))
4453     return "f<FP:prec>abs%.d %1,%0";
4454   return "f<FP:prec>abs%.<FP:prec> %1,%0";
4456   [(set_attr "type" "bitrw,fneg")])
4458 ;; bit indexing instructions
4460 ;; ColdFire ff1 instruction implements clz.
4461 (define_insn "clzsi2"
4462   [(set (match_operand:SI 0 "register_operand" "=d")
4463         (clz:SI (match_operand:SI 1 "register_operand" "0")))]
4464   "ISA_HAS_FF1"
4465   "ff1 %0"
4466   [(set_attr "type" "ext")])
4468 ;; one complement instructions
4470 ;; "one_cmpldi2" is mainly here to help combine().
4471 (define_insn "one_cmpldi2"
4472   [(set (match_operand:DI 0 "nonimmediate_operand" "=dm")
4473         (not:DI (match_operand:DI 1 "general_operand" "0")))]
4474   "!TARGET_COLDFIRE"
4476   CC_STATUS_INIT;
4477   if (GET_CODE (operands[0]) == REG)
4478     operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4479   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC
4480         || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4481     operands[1] = operands[0];
4482   else
4483     operands[1] = adjust_address (operands[0], SImode, 4);
4484   return "not%.l %1\;not%.l %0";
4487 (define_expand "one_cmplsi2"
4488   [(set (match_operand:SI 0 "nonimmediate_operand" "")
4489         (not:SI (match_operand:SI 1 "general_operand" "")))]
4490   ""
4492   if (TARGET_COLDFIRE)
4493     emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
4494   else
4495     emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
4496   DONE;
4499 (define_insn "one_cmplsi2_internal"
4500   [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4501         (not:SI (match_operand:SI 1 "general_operand" "0")))]
4502   "!TARGET_COLDFIRE"
4503   "not%.l %0")
4505 (define_insn "one_cmplsi2_5200"
4506   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4507         (not:SI (match_operand:SI 1 "general_operand" "0")))]
4508   "TARGET_COLDFIRE"
4509   "not%.l %0"
4510   [(set_attr "type" "neg_l")])
4512 (define_insn "one_cmplhi2"
4513   [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4514         (not:HI (match_operand:HI 1 "general_operand" "0")))]
4515   "!TARGET_COLDFIRE"
4516   "not%.w %0")
4518 (define_insn ""
4519   [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4520         (not:HI (match_dup 0)))]
4521   "!TARGET_COLDFIRE"
4522   "not%.w %0")
4524 (define_insn "one_cmplqi2"
4525   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4526         (not:QI (match_operand:QI 1 "general_operand" "0")))]
4527   "!TARGET_COLDFIRE"
4528   "not%.b %0")
4530 (define_insn ""
4531   [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4532         (not:QI (match_dup 0)))]
4533   "!TARGET_COLDFIRE"
4534   "not%.b %0")
4536 ;; arithmetic shift instructions
4537 ;; We don't need the shift memory by 1 bit instruction
4539 (define_insn "ashldi_extsi"
4540   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4541     (ashift:DI
4542       (match_operator:DI 2 "extend_operator"
4543         [(match_operand:SI 1 "general_operand" "rm")])
4544       (const_int 32)))]
4545   ""
4547   CC_STATUS_INIT;
4548   if (GET_CODE (operands[0]) == REG)
4549     operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4550   else
4551     operands[2] = adjust_address (operands[0], SImode, 4);
4552   if (ADDRESS_REG_P (operands[0]))
4553     return "move%.l %1,%0\;sub%.l %2,%2";
4554   else
4555     return "move%.l %1,%0\;clr%.l %2";
4558 (define_insn "ashldi_sexthi"
4559   [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
4560     (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
4561         (const_int 32)))
4562     (clobber (match_scratch:SI 2 "=a,X"))]
4563   ""
4565   CC_STATUS_INIT;
4566   if (GET_CODE (operands[0]) == MEM)
4567     {
4568     if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4569       return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
4570     else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4571       return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
4572     else
4573       {
4574         operands[3] = adjust_address (operands[0], SImode, 4);
4575         return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
4576       }
4577     }
4578   else if (DATA_REG_P (operands[0]))
4579     return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
4580   else
4581     return "move%.w %1,%0\;sub%.l %R0,%R0";
4584 (define_insn "*ashldi3_const1"
4585   [(set (match_operand:DI 0 "register_operand" "=d")
4586         (ashift:DI (match_operand:DI 1 "register_operand" "0")
4587                    (const_int 1)))]
4588   "!TARGET_COLDFIRE"
4589   "add%.l %R0,%R0\;addx%.l %0,%0")
4591 (define_split
4592   [(set (match_operand:DI 0 "register_operand" "")
4593         (ashift:DI (match_operand:DI 1 "register_operand" "")
4594                    (const_int 2)))]
4595   "reload_completed && !TARGET_COLDFIRE"
4596   [(set (match_dup 0)
4597         (ashift:DI (match_dup 1) (const_int 1)))
4598    (set (match_dup 0)
4599         (ashift:DI (match_dup 0) (const_int 1)))]
4600   "")
4602 (define_split
4603   [(set (match_operand:DI 0 "register_operand" "")
4604         (ashift:DI (match_operand:DI 1 "register_operand" "")
4605                    (const_int 3)))]
4606   "reload_completed && !TARGET_COLDFIRE"
4607   [(set (match_dup 0)
4608         (ashift:DI (match_dup 1) (const_int 2)))
4609    (set (match_dup 0)
4610         (ashift:DI (match_dup 0) (const_int 1)))]
4611   "")
4613 (define_split
4614   [(set (match_operand:DI 0 "register_operand" "")
4615         (ashift:DI (match_operand:DI 1 "register_operand" "")
4616                    (const_int 8)))]
4617   "reload_completed && !TARGET_COLDFIRE"
4618   [(set (match_dup 2)
4619         (rotate:SI (match_dup 2) (const_int 8)))
4620    (set (match_dup 3)
4621         (rotate:SI (match_dup 3) (const_int 8)))
4622    (set (strict_low_part (subreg:QI (match_dup 0) 3))
4623         (subreg:QI (match_dup 0) 7))
4624    (set (strict_low_part (subreg:QI (match_dup 0) 7))
4625         (const_int 0))]
4627   operands[2] = gen_highpart (SImode, operands[0]);
4628   operands[3] = gen_lowpart (SImode, operands[0]);
4631 (define_split
4632   [(set (match_operand:DI 0 "register_operand" "")
4633         (ashift:DI (match_operand:DI 1 "register_operand" "")
4634                    (const_int 16)))]
4635   "reload_completed && !TARGET_COLDFIRE"
4636   [(set (match_dup 2)
4637         (rotate:SI (match_dup 2) (const_int 16)))
4638    (set (match_dup 3)
4639         (rotate:SI (match_dup 3) (const_int 16)))
4640    (set (strict_low_part (subreg:HI (match_dup 0) 2))
4641         (subreg:HI (match_dup 0) 6))
4642    (set (strict_low_part (subreg:HI (match_dup 0) 6))
4643         (const_int 0))]
4645   operands[2] = gen_highpart (SImode, operands[0]);
4646   operands[3] = gen_lowpart (SImode, operands[0]);
4649 (define_split
4650   [(set (match_operand:DI 0 "pre_dec_operand" "")
4651         (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4652                    (const_int 32)))]
4653   "reload_completed"
4654   [(set (match_dup 0) (const_int 0))
4655    (set (match_dup 0) (match_dup 1))]
4657   operands[0] = adjust_address(operands[0], SImode, 0);
4658   operands[1] = gen_lowpart(SImode, operands[1]);
4661 (define_split
4662   [(set (match_operand:DI 0 "post_inc_operand" "")
4663         (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4664                    (const_int 32)))]
4665   "reload_completed"
4666   [(set (match_dup 0) (match_dup 1))
4667    (set (match_dup 0) (const_int 0))]
4669   operands[0] = adjust_address(operands[0], SImode, 0);
4670   operands[1] = gen_lowpart(SImode, operands[1]);
4673 (define_insn_and_split "*ashldi3_const32"
4674   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
4675         (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
4676                    (const_int 32)))]
4677   ""
4678   "#"
4679   "&& reload_completed"
4680   [(set (match_dup 4) (match_dup 3))
4681    (set (match_dup 2) (const_int 0))]
4682   "split_di(operands, 2, operands + 2, operands + 4);")
4684 (define_split
4685   [(set (match_operand:DI 0 "register_operand" "")
4686         (ashift:DI (match_operand:DI 1 "register_operand" "")
4687                    (match_operand 2 "const_int_operand" "")))]
4688   "reload_completed && !TARGET_COLDFIRE
4689    && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
4690   [(set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 2)))
4691    (set (match_dup 3) (match_dup 4))
4692    (set (match_dup 4) (const_int 0))]
4694   operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4695   operands[3] = gen_highpart (SImode, operands[0]);
4696   operands[4] = gen_lowpart (SImode, operands[0]);
4699 (define_split
4700   [(set (match_operand:DI 0 "register_operand" "")
4701         (ashift:DI (match_operand:DI 1 "register_operand" "")
4702                    (const_int 48)))]
4703   "reload_completed && !TARGET_COLDFIRE"
4704   [(set (match_dup 2) (match_dup 3))
4705    (set (match_dup 2)
4706         (rotate:SI (match_dup 2) (const_int 16)))
4707    (set (match_dup 3) (const_int 0))
4708    (set (strict_low_part (subreg:HI (match_dup 0) 2))
4709         (const_int 0))]
4711   operands[2] = gen_highpart (SImode, operands[0]);
4712   operands[3] = gen_lowpart (SImode, operands[0]);
4715 (define_split
4716   [(set (match_operand:DI 0 "register_operand" "")
4717         (ashift:DI (match_operand:DI 1 "register_operand" "")
4718                    (match_operand 2 "const_int_operand" "")))]
4719   "reload_completed && !TARGET_COLDFIRE
4720    && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 63"
4721   [(set (match_dup 3) (match_dup 2))
4722    (set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 3)))
4723    (set (match_dup 3) (match_dup 4))
4724    (set (match_dup 4) (const_int 0))]
4726   operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4727   operands[3] = gen_highpart (SImode, operands[0]);
4728   operands[4] = gen_lowpart (SImode, operands[0]);
4731 (define_insn "*ashldi3"
4732   [(set (match_operand:DI 0 "register_operand" "=d")
4733         (ashift:DI (match_operand:DI 1 "register_operand" "0")
4734                    (match_operand 2 "const_int_operand" "n")))]
4735   "!TARGET_COLDFIRE
4736     && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4737         || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4738         || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4739   "#")
4741 (define_expand "ashldi3"
4742   [(set (match_operand:DI 0 "register_operand" "")
4743         (ashift:DI (match_operand:DI 1 "register_operand" "")
4744                    (match_operand 2 "const_int_operand" "")))]
4745   "!TARGET_COLDFIRE"
4747   /* ???  This is a named pattern like this is not allowed to FAIL based
4748      on its operands.  */
4749   if (GET_CODE (operands[2]) != CONST_INT
4750       || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4751           && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4752           && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4753     FAIL;
4756 ;; On most 68k models, this makes faster code in a special case.
4758 (define_insn "ashlsi_16"
4759   [(set (match_operand:SI 0 "register_operand" "=d")
4760         (ashift:SI (match_operand:SI 1 "register_operand" "0")
4761                    (const_int 16)))]
4762   "!TUNE_68060"
4764   CC_STATUS_INIT;
4765   return "swap %0\;clr%.w %0";
4768 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
4769 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4771 ;; On the 68000, this makes faster code in a special case.
4773 (define_insn "ashlsi_17_24"
4774   [(set (match_operand:SI 0 "register_operand" "=d")
4775         (ashift:SI (match_operand:SI 1 "register_operand" "0")
4776                    (match_operand:SI 2 "const_int_operand" "n")))]
4777   "TUNE_68000_10
4778    && INTVAL (operands[2]) > 16
4779    && INTVAL (operands[2]) <= 24"
4781   CC_STATUS_INIT;
4783   operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4784   return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4787 (define_insn "ashlsi3"
4788   [(set (match_operand:SI 0 "register_operand" "=d")
4789         (ashift:SI (match_operand:SI 1 "register_operand" "0")
4790                    (match_operand:SI 2 "general_operand" "dI")))]
4791   ""
4793   if (operands[2] == const1_rtx)
4794     {
4795       cc_status.flags = CC_NO_OVERFLOW;
4796       return "add%.l %0,%0";
4797     }
4798   return "lsl%.l %2,%0";
4801 (define_insn "ashlhi3"
4802   [(set (match_operand:HI 0 "register_operand" "=d")
4803         (ashift:HI (match_operand:HI 1 "register_operand" "0")
4804                    (match_operand:HI 2 "general_operand" "dI")))]
4805   "!TARGET_COLDFIRE"
4806   "lsl%.w %2,%0")
4808 (define_insn ""
4809   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4810         (ashift:HI (match_dup 0)
4811                    (match_operand:HI 1 "general_operand" "dI")))]
4812   "!TARGET_COLDFIRE"
4813   "lsl%.w %1,%0")
4815 (define_insn "ashlqi3"
4816   [(set (match_operand:QI 0 "register_operand" "=d")
4817         (ashift:QI (match_operand:QI 1 "register_operand" "0")
4818                    (match_operand:QI 2 "general_operand" "dI")))]
4819   "!TARGET_COLDFIRE"
4820   "lsl%.b %2,%0")
4822 (define_insn ""
4823   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4824         (ashift:QI (match_dup 0)
4825                    (match_operand:QI 1 "general_operand" "dI")))]
4826   "!TARGET_COLDFIRE"
4827   "lsl%.b %1,%0")
4829 ;; On most 68k models, this makes faster code in a special case.
4831 (define_insn "ashrsi_16"
4832   [(set (match_operand:SI 0 "register_operand" "=d")
4833         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4834                      (const_int 16)))]
4835   "!TUNE_68060"
4836   "swap %0\;ext%.l %0")
4838 ;; On the 68000, this makes faster code in a special case.
4840 (define_insn ""
4841   [(set (match_operand:SI 0 "register_operand" "=d")
4842         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4843                      (match_operand:SI 2 "const_int_operand" "n")))]
4844   "TUNE_68000_10
4845    && INTVAL (operands[2]) > 16
4846    && INTVAL (operands[2]) <= 24"
4848   operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4849   return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4852 (define_insn "subreghi1ashrdi_const32"
4853   [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4854     (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4855             (const_int 32)) 6))]
4856   ""
4858   if (GET_CODE (operands[1]) != REG)
4859     operands[1] = adjust_address (operands[1], HImode, 2);
4860   return "move%.w %1,%0";
4862   [(set_attr "type" "move")])
4864 (define_insn "subregsi1ashrdi_const32"
4865   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4866     (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4867             (const_int 32)) 4))]
4868   ""
4870   return "move%.l %1,%0";
4872   [(set_attr "type" "move_l")])
4874 (define_insn "*ashrdi3_const1"
4875   [(set (match_operand:DI 0 "register_operand" "=d")
4876         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4877                      (const_int 1)))]
4878   "!TARGET_COLDFIRE"
4880   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4881   return "asr%.l #1,%0\;roxr%.l #1,%1";
4884 (define_split
4885   [(set (match_operand:DI 0 "register_operand" "")
4886         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4887                      (const_int 2)))]
4888   "reload_completed && !TARGET_COLDFIRE"
4889   [(set (match_dup 0)
4890         (ashiftrt:DI (match_dup 1) (const_int 1)))
4891    (set (match_dup 0)
4892         (ashiftrt:DI (match_dup 0) (const_int 1)))]
4893   "")
4895 (define_split
4896   [(set (match_operand:DI 0 "register_operand" "")
4897         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4898                      (const_int 3)))]
4899   "reload_completed && !TARGET_COLDFIRE"
4900   [(set (match_dup 0)
4901         (ashiftrt:DI (match_dup 1) (const_int 2)))
4902    (set (match_dup 0)
4903         (ashiftrt:DI (match_dup 0) (const_int 1)))]
4904   "")
4906 (define_split
4907   [(set (match_operand:DI 0 "register_operand" "")
4908         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4909                      (const_int 8)))]
4910   "reload_completed && !TARGET_COLDFIRE"
4911   [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4912         (subreg:QI (match_dup 0) 3))
4913    (set (match_dup 2)
4914         (ashiftrt:SI (match_dup 2) (const_int 8)))
4915    (set (match_dup 3)
4916         (rotatert:SI (match_dup 3) (const_int 8)))]
4918   operands[2] = gen_highpart (SImode, operands[0]);
4919   operands[3] = gen_lowpart (SImode, operands[0]);
4922 (define_split
4923   [(set (match_operand:DI 0 "register_operand" "")
4924         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4925                      (const_int 16)))]
4926   "reload_completed && !TARGET_COLDFIRE"
4927   [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4928         (subreg:HI (match_dup 0) 2))
4929    (set (match_dup 2)
4930         (rotate:SI (match_dup 2) (const_int 16)))
4931    (set (match_dup 3)
4932         (rotate:SI (match_dup 3) (const_int 16)))
4933    (set (match_dup 2)
4934         (sign_extend:SI (subreg:HI (match_dup 2) 2)))]
4936   operands[2] = gen_highpart (SImode, operands[0]);
4937   operands[3] = gen_lowpart (SImode, operands[0]);
4940 (define_insn "*ashrdi_const32"
4941   [(set (match_operand:DI 0 "register_operand" "=d")
4942         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro")
4943                      (const_int 32)))]
4944   ""
4946   CC_STATUS_INIT;
4947   if (TARGET_68020)
4948     return "move%.l %1,%R0\;smi %0\;extb%.l %0";
4949   else
4950     return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
4953 (define_insn "*ashrdi_const32_mem"
4954   [(set (match_operand:DI 0 "memory_operand" "=o,<")
4955         (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro,ro")
4956                      (const_int 32)))
4957    (clobber (match_scratch:SI 2 "=d,d"))]
4958   ""
4960   CC_STATUS_INIT;
4961   operands[3] = adjust_address (operands[0], SImode,
4962                                 which_alternative == 0 ? 4 : 0);
4963   operands[0] = adjust_address (operands[0], SImode, 0);
4964   if (TARGET_68020 || TARGET_COLDFIRE)
4965     return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4966   else
4967     return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4970 (define_split
4971   [(set (match_operand:DI 0 "register_operand" "")
4972         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4973                      (const_int 63)))]
4974   "reload_completed && !TARGET_COLDFIRE"
4975   [(set (match_dup 3)
4976         (ashiftrt:SI (match_dup 3) (const_int 31)))
4977    (set (match_dup 2)
4978         (match_dup 3))]
4979   "split_di(operands, 1, operands + 2, operands + 3);")
4981 ;; The predicate below must be general_operand, because ashrdi3 allows that
4982 (define_insn "ashrdi_const"
4983   [(set (match_operand:DI 0 "register_operand" "=d")
4984         (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4985                      (match_operand 2 "const_int_operand" "n")))]
4986   "!TARGET_COLDFIRE
4987     && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4988         || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4989         || INTVAL (operands[2]) == 31
4990         || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4992   operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4993   CC_STATUS_INIT;
4994   if (INTVAL (operands[2]) == 48)
4995     return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4996   if (INTVAL (operands[2]) == 31)
4997     return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4998   if (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)
4999     {
5000       operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5001       output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
5002                         "moveq %2,%1\;asr%.l %1,%0", operands);
5003       output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
5004       return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
5005              TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
5006     }
5007   return "#";
5010 (define_expand "ashrdi3"
5011   [(set (match_operand:DI 0 "register_operand" "")
5012         (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
5013                      (match_operand 2 "const_int_operand" "")))]
5014   "!TARGET_COLDFIRE"
5016   /* ???  This is a named pattern like this is not allowed to FAIL based
5017      on its operands.  */
5018   if (GET_CODE (operands[2]) != CONST_INT
5019       || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
5020           && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
5021           && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
5022     FAIL;
5025 ;; On all 68k models, this makes faster code in a special case.
5027 (define_insn "ashrsi_31"
5028   [(set (match_operand:SI 0 "register_operand" "=d")
5029         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
5030                      (const_int 31)))]
5031   ""
5033   return "add%.l %0,%0\;subx%.l %0,%0";
5036 (define_insn "ashrsi3"
5037   [(set (match_operand:SI 0 "register_operand" "=d")
5038         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
5039                      (match_operand:SI 2 "general_operand" "dI")))]
5040   ""
5041   "asr%.l %2,%0"
5042   [(set_attr "type" "shift")
5043    (set_attr "opy" "2")])
5045 (define_insn "ashrhi3"
5046   [(set (match_operand:HI 0 "register_operand" "=d")
5047         (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
5048                      (match_operand:HI 2 "general_operand" "dI")))]
5049   "!TARGET_COLDFIRE"
5050   "asr%.w %2,%0")
5052 (define_insn ""
5053   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5054         (ashiftrt:HI (match_dup 0)
5055                      (match_operand:HI 1 "general_operand" "dI")))]
5056   "!TARGET_COLDFIRE"
5057   "asr%.w %1,%0")
5059 (define_insn "ashrqi3"
5060   [(set (match_operand:QI 0 "register_operand" "=d")
5061         (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
5062                      (match_operand:QI 2 "general_operand" "dI")))]
5063   "!TARGET_COLDFIRE"
5064   "asr%.b %2,%0")
5066 (define_insn ""
5067   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5068         (ashiftrt:QI (match_dup 0)
5069                      (match_operand:QI 1 "general_operand" "dI")))]
5070   "!TARGET_COLDFIRE"
5071   "asr%.b %1,%0")
5073 ;; logical shift instructions
5075 ;; commented out because of reload problems in 950612-1.c
5076 ;;(define_insn ""
5077 ;;        [(set (cc0)
5078 ;;            (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
5079 ;;                    (const_int 32)) 4))
5080 ;;        (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
5081 ;;            (subreg:SI (lshiftrt:DI (match_dup 0)
5082 ;;                    (const_int 32)) 4))]
5083 ;;  ""
5085 ;;  return "move%.l %0,%1";
5086 ;;})
5088 ;;(define_insn ""
5089 ;;        [(set (cc0)
5090 ;;            (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
5091 ;;                    (const_int 32)) 0))
5092 ;;        (set (match_operand:DI 1 "nonimmediate_operand" "=do")
5093 ;;            (lshiftrt:DI (match_dup 0)
5094 ;;                (const_int 32)))]
5095 ;;  ""
5097 ;;  if (GET_CODE (operands[1]) == REG)
5098 ;;    operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
5099 ;;  else
5100 ;;    operands[2] = adjust_address (operands[1], SImode, 4);
5101 ;;  return "move%.l %0,%2\;clr%.l %1";
5102 ;;})
5104 (define_insn "subreg1lshrdi_const32"
5105   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5106     (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
5107             (const_int 32)) 4))]
5108   ""
5109   "move%.l %1,%0"
5110   [(set_attr "type" "move_l")])
5112 (define_insn "*lshrdi3_const1"
5113   [(set (match_operand:DI 0 "register_operand" "=d")
5114         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5115                      (const_int 1)))]
5116   "!TARGET_COLDFIRE"
5117   "lsr%.l #1,%0\;roxr%.l #1,%R0")
5119 (define_split
5120   [(set (match_operand:DI 0 "register_operand" "")
5121         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5122                      (const_int 2)))]
5123   "reload_completed && !TARGET_COLDFIRE"
5124   [(set (match_dup 0)
5125         (lshiftrt:DI (match_dup 1) (const_int 1)))
5126    (set (match_dup 0)
5127         (lshiftrt:DI (match_dup 0) (const_int 1)))]
5128   "")
5130 (define_split
5131   [(set (match_operand:DI 0 "register_operand" "")
5132         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5133                      (const_int 3)))]
5134   "reload_completed && !TARGET_COLDFIRE"
5135   [(set (match_dup 0)
5136         (lshiftrt:DI (match_dup 1) (const_int 2)))
5137    (set (match_dup 0)
5138         (lshiftrt:DI (match_dup 0) (const_int 1)))]
5139   "")
5141 (define_split
5142   [(set (match_operand:DI 0 "register_operand" "")
5143         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5144                      (const_int 8)))]
5145   "reload_completed && !TARGET_COLDFIRE"
5146   [(set (strict_low_part (subreg:QI (match_dup 0) 7))
5147         (subreg:QI (match_dup 0) 3))
5148    (set (match_dup 2)
5149         (lshiftrt:SI (match_dup 2) (const_int 8)))
5150    (set (match_dup 3)
5151         (rotatert:SI (match_dup 3) (const_int 8)))]
5153   operands[2] = gen_highpart (SImode, operands[0]);
5154   operands[3] = gen_lowpart (SImode, operands[0]);
5157 (define_split
5158   [(set (match_operand:DI 0 "register_operand" "")
5159         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5160                      (const_int 16)))]
5161   "reload_completed && !TARGET_COLDFIRE"
5162   [(set (strict_low_part (subreg:HI (match_dup 0) 6))
5163         (subreg:HI (match_dup 0) 2))
5164    (set (strict_low_part (subreg:HI (match_dup 0) 2))
5165         (const_int 0))
5166    (set (match_dup 3)
5167         (rotate:SI (match_dup 3) (const_int 16)))
5168    (set (match_dup 2)
5169         (rotate:SI (match_dup 2) (const_int 16)))]
5171   operands[2] = gen_highpart (SImode, operands[0]);
5172   operands[3] = gen_lowpart (SImode, operands[0]);
5175 (define_split
5176   [(set (match_operand:DI 0 "pre_dec_operand" "")
5177         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5178                      (const_int 32)))]
5179   "reload_completed"
5180   [(set (match_dup 0) (match_dup 1))
5181    (set (match_dup 0) (const_int 0))]
5183   operands[0] = adjust_address(operands[0], SImode, 0);
5184   operands[1] = gen_highpart(SImode, operands[1]);
5187 (define_split
5188   [(set (match_operand:DI 0 "post_inc_operand" "")
5189         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5190                      (const_int 32)))]
5191   "reload_completed"
5192   [(set (match_dup 0) (const_int 0))
5193    (set (match_dup 0) (match_dup 1))]
5195   operands[0] = adjust_address(operands[0], SImode, 0);
5196   operands[1] = gen_highpart(SImode, operands[1]);
5199 (define_split
5200   [(set (match_operand:DI 0 "nonimmediate_operand" "")
5201         (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5202                      (const_int 32)))]
5203   "reload_completed"
5204   [(set (match_dup 2) (match_dup 5))
5205    (set (match_dup 4) (const_int 0))]
5206   "split_di(operands, 2, operands + 2, operands + 4);")
5208 (define_insn "*lshrdi_const32"
5209   [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
5210         (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
5211                      (const_int 32)))]
5212   ""
5213   "#")
5215 (define_split
5216   [(set (match_operand:DI 0 "register_operand" "")
5217         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5218                      (match_operand 2 "const_int_operand" "")))]
5219   "reload_completed && !TARGET_COLDFIRE
5220    && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
5221   [(set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 2)))
5222    (set (match_dup 4) (match_dup 3))
5223    (set (match_dup 3) (const_int 0))]
5225   operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5226   operands[3] = gen_highpart (SImode, operands[0]);
5227   operands[4] = gen_lowpart (SImode, operands[0]);
5230 (define_split
5231   [(set (match_operand:DI 0 "register_operand" "")
5232         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5233                      (const_int 48)))]
5234   "reload_completed"
5235   [(set (match_dup 3) (match_dup 2))
5236    (set (strict_low_part (subreg:HI (match_dup 0) 6))
5237         (const_int 0))
5238    (set (match_dup 2) (const_int 0))
5239    (set (match_dup 3)
5240         (rotate:SI (match_dup 3) (const_int 16)))]
5242   operands[2] = gen_highpart (SImode, operands[0]);
5243   operands[3] = gen_lowpart (SImode, operands[0]);
5246 (define_split
5247   [(set (match_operand:DI 0 "register_operand" "")
5248         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5249                      (match_operand 2 "const_int_operand" "")))]
5250   "reload_completed && !TARGET_COLDFIRE
5251    && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 62"
5252   [(set (match_dup 4) (match_dup 2))
5253    (set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 4)))
5254    (set (match_dup 4) (match_dup 3))
5255    (set (match_dup 3) (const_int 0))]
5257   operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5258   operands[3] = gen_highpart (SImode, operands[0]);
5259   operands[4] = gen_lowpart (SImode, operands[0]);
5262 (define_insn "*lshrdi_const63"
5263   [(set (match_operand:DI 0 "register_operand" "=d")
5264         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5265                      (const_int 63)))]
5266   ""
5267   "add%.l %0,%0\;clr%.l %0\;clr%.l %R1\;addx%.l %R1,%R1")
5269 (define_insn "*lshrdi3_const"
5270   [(set (match_operand:DI 0 "register_operand" "=d")
5271         (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5272                      (match_operand 2 "const_int_operand" "n")))]
5273   "(!TARGET_COLDFIRE
5274     && ((INTVAL (operands[2]) >= 2 && INTVAL (operands[2]) <= 3)
5275          || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
5276          || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
5277   "#")
5279 (define_expand "lshrdi3"
5280   [(set (match_operand:DI 0 "register_operand" "")
5281         (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5282                      (match_operand 2 "const_int_operand" "")))]
5283   "!TARGET_COLDFIRE"
5285   /* ???  This is a named pattern like this is not allowed to FAIL based
5286      on its operands.  */
5287   if (GET_CODE (operands[2]) != CONST_INT
5288       || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
5289           && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
5290           && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
5291     FAIL;
5294 ;; On all 68k models, this makes faster code in a special case.
5296 (define_insn "lshrsi_31"
5297   [(set (match_operand:SI 0 "register_operand" "=d")
5298         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5299                      (const_int 31)))]
5300   ""
5302   return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
5305 ;; On most 68k models, this makes faster code in a special case.
5307 (define_insn "lshrsi_16"
5308   [(set (match_operand:SI 0 "register_operand" "=d")
5309         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5310                      (const_int 16)))]
5311   "!TUNE_68060"
5313   CC_STATUS_INIT;
5314   return "clr%.w %0\;swap %0";
5317 ;; On the 68000, this makes faster code in a special case.
5319 (define_insn "lshrsi_17_24"
5320   [(set (match_operand:SI 0 "register_operand" "=d")
5321         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5322                      (match_operand:SI 2 "const_int_operand" "n")))]
5323   "TUNE_68000_10
5324    && INTVAL (operands[2]) > 16
5325    && INTVAL (operands[2]) <= 24"
5327   /* I think lsr%.w sets the CC properly.  */
5328   operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
5329   return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
5332 (define_insn "lshrsi3"
5333   [(set (match_operand:SI 0 "register_operand" "=d")
5334         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5335                      (match_operand:SI 2 "general_operand" "dI")))]
5336   ""
5337   "lsr%.l %2,%0"
5338   [(set_attr "type" "shift")
5339    (set_attr "opy" "2")])
5341 (define_insn "lshrhi3"
5342   [(set (match_operand:HI 0 "register_operand" "=d")
5343         (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
5344                      (match_operand:HI 2 "general_operand" "dI")))]
5345   "!TARGET_COLDFIRE"
5346   "lsr%.w %2,%0")
5348 (define_insn ""
5349   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5350         (lshiftrt:HI (match_dup 0)
5351                      (match_operand:HI 1 "general_operand" "dI")))]
5352   "!TARGET_COLDFIRE"
5353   "lsr%.w %1,%0")
5355 (define_insn "lshrqi3"
5356   [(set (match_operand:QI 0 "register_operand" "=d")
5357         (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
5358                      (match_operand:QI 2 "general_operand" "dI")))]
5359   "!TARGET_COLDFIRE"
5360   "lsr%.b %2,%0")
5362 (define_insn ""
5363   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5364         (lshiftrt:QI (match_dup 0)
5365                      (match_operand:QI 1 "general_operand" "dI")))]
5366   "!TARGET_COLDFIRE"
5367   "lsr%.b %1,%0")
5369 ;; rotate instructions
5371 (define_insn "rotlsi3"
5372   [(set (match_operand:SI 0 "register_operand" "=d")
5373         (rotate:SI (match_operand:SI 1 "register_operand" "0")
5374                    (match_operand:SI 2 "general_operand" "dINO")))]
5375   "!TARGET_COLDFIRE"
5377   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
5378     return "swap %0";
5379   else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
5380     {
5381       operands[2] = GEN_INT (32 - INTVAL (operands[2]));
5382       return "ror%.l %2,%0";
5383     }
5384   else
5385     return "rol%.l %2,%0";
5388 (define_insn "rotlhi3"
5389   [(set (match_operand:HI 0 "register_operand" "=d")
5390         (rotate:HI (match_operand:HI 1 "register_operand" "0")
5391                    (match_operand:HI 2 "general_operand" "dIP")))]
5392   "!TARGET_COLDFIRE"
5394   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5395     {
5396       operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5397       return "ror%.w %2,%0";
5398     }
5399   else
5400     return "rol%.w %2,%0";
5403 (define_insn ""
5404   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5405         (rotate:HI (match_dup 0)
5406                    (match_operand:HI 1 "general_operand" "dIP")))]
5407   "!TARGET_COLDFIRE"
5409   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5410     {
5411       operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5412       return "ror%.w %2,%0";
5413     }
5414   else
5415     return "rol%.w %2,%0";
5418 (define_insn "rotlqi3"
5419   [(set (match_operand:QI 0 "register_operand" "=d")
5420         (rotate:QI (match_operand:QI 1 "register_operand" "0")
5421                    (match_operand:QI 2 "general_operand" "dI")))]
5422   "!TARGET_COLDFIRE"
5424   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5425     {
5426       operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5427       return "ror%.b %2,%0";
5428     }
5429   else
5430     return "rol%.b %2,%0";
5433 (define_insn ""
5434   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5435         (rotate:QI (match_dup 0)
5436                    (match_operand:QI 1 "general_operand" "dI")))]
5437   "!TARGET_COLDFIRE"
5439   if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5440     {
5441       operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5442       return "ror%.b %2,%0";
5443     }
5444   else
5445     return "rol%.b %2,%0";
5448 (define_insn "rotrsi3"
5449   [(set (match_operand:SI 0 "register_operand" "=d")
5450         (rotatert:SI (match_operand:SI 1 "register_operand" "0")
5451                      (match_operand:SI 2 "general_operand" "dI")))]
5452   "!TARGET_COLDFIRE"
5453   "ror%.l %2,%0")
5455 (define_insn "rotrhi3"
5456   [(set (match_operand:HI 0 "register_operand" "=d")
5457         (rotatert:HI (match_operand:HI 1 "register_operand" "0")
5458                      (match_operand:HI 2 "general_operand" "dI")))]
5459   "!TARGET_COLDFIRE"
5460   "ror%.w %2,%0")
5462 (define_insn ""
5463   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5464         (rotatert:HI (match_dup 0)
5465                      (match_operand:HI 1 "general_operand" "dI")))]
5466   "!TARGET_COLDFIRE"
5467   "ror%.w %1,%0")
5469 (define_insn "rotrqi3"
5470   [(set (match_operand:QI 0 "register_operand" "=d")
5471         (rotatert:QI (match_operand:QI 1 "register_operand" "0")
5472                      (match_operand:QI 2 "general_operand" "dI")))]
5473   "!TARGET_COLDFIRE"
5474   "ror%.b %2,%0")
5476 (define_insn ""
5477   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5478         (rotatert:QI (match_dup 0)
5479                      (match_operand:QI 1 "general_operand" "dI")))]
5480   "!TARGET_COLDFIRE"
5481   "ror%.b %1,%0")
5484 ;; Bit set/clear in memory byte.
5486 ;; set bit, bit number is int
5487 (define_insn "bsetmemqi"
5488   [(set (match_operand:QI 0 "memory_operand" "+m")
5489         (ior:QI (subreg:QI (ashift:SI (const_int 1)
5490                 (match_operand:SI 1 "general_operand" "d")) 3)
5491         (match_dup 0)))]
5492   ""
5494   CC_STATUS_INIT;
5495   return "bset %1,%0";
5497   [(set_attr "type" "bitrw")])
5499 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
5500 (define_insn "*bsetmemqi_ext"
5501   [(set (match_operand:QI 0 "memory_operand" "+m")
5502         (ior:QI (subreg:QI (ashift:SI (const_int 1)
5503             (match_operator:SI 2 "extend_operator"
5504                 [(match_operand 1 "general_operand" "d")])) 3)
5505         (match_dup 0)))]
5506   ""
5508   CC_STATUS_INIT;
5509   return "bset %1,%0";
5511   [(set_attr "type" "bitrw")])
5513 ;; clear bit, bit number is int
5514 (define_insn "bclrmemqi"
5515   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5516         (const_int 1)
5517         (minus:SI (const_int 7)
5518             (match_operand:SI 1 "general_operand" "d")))
5519     (const_int 0))]
5520   ""
5522   CC_STATUS_INIT;
5523   return "bclr %1,%0";
5525   [(set_attr "type" "bitrw")])
5527 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
5528 (define_insn "*bclrmemqi_ext"
5529   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5530         (const_int 1)
5531         (minus:SI (const_int 7)
5532             (match_operator:SI 2 "extend_operator"
5533                 [(match_operand 1 "general_operand" "d")])))
5534     (const_int 0))]
5535   ""
5537   CC_STATUS_INIT;
5538   return "bclr %1,%0";
5540   [(set_attr "type" "bitrw")])
5542 ;; Special cases of bit-field insns which we should
5543 ;; recognize in preference to the general case.
5544 ;; These handle aligned 8-bit and 16-bit fields,
5545 ;; which can usually be done with move instructions.
5548 ; Special case for 32-bit field in memory.  This only occurs when 32-bit
5549 ; alignment of structure members is specified.
5551 ; The move is allowed to be odd byte aligned, because that's still faster
5552 ; than an odd byte aligned bit-field instruction.
5554 (define_insn ""
5555   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5556                          (const_int 32)
5557                          (match_operand:SI 1 "const_int_operand" "n"))
5558         (match_operand:SI 2 "general_src_operand" "rmSi"))]
5559   "TARGET_68020 && TARGET_BITFIELD
5560    && (INTVAL (operands[1]) % 8) == 0
5561    && ! mode_dependent_address_p (XEXP (operands[0], 0))"
5563   operands[0]
5564     = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
5566   return "move%.l %2,%0";
5569 (define_insn ""
5570   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+do")
5571                          (match_operand:SI 1 "const_int_operand" "n")
5572                          (match_operand:SI 2 "const_int_operand" "n"))
5573         (match_operand:SI 3 "register_operand" "d"))]
5574   "TARGET_68020 && TARGET_BITFIELD
5575    && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
5576    && INTVAL (operands[2]) % INTVAL (operands[1]) == 0
5577    && (GET_CODE (operands[0]) == REG
5578        || ! mode_dependent_address_p (XEXP (operands[0], 0)))"
5580   if (REG_P (operands[0]))
5581     {
5582       if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
5583         return "bfins %3,%0{%b2:%b1}";
5584     }
5585   else
5586     operands[0] = adjust_address (operands[0],
5587                                   INTVAL (operands[1]) == 8 ? QImode : HImode,
5588                                   INTVAL (operands[2]) / 8);
5590   if (GET_CODE (operands[3]) == MEM)
5591     operands[3] = adjust_address (operands[3],
5592                                   INTVAL (operands[1]) == 8 ? QImode : HImode,
5593                                   (32 - INTVAL (operands[1])) / 8);
5595   if (INTVAL (operands[1]) == 8)
5596     return "move%.b %3,%0";
5597   return "move%.w %3,%0";
5602 ; Special case for 32-bit field in memory.  This only occurs when 32-bit
5603 ; alignment of structure members is specified.
5605 ; The move is allowed to be odd byte aligned, because that's still faster
5606 ; than an odd byte aligned bit-field instruction.
5608 (define_insn ""
5609   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5610         (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5611                          (const_int 32)
5612                          (match_operand:SI 2 "const_int_operand" "n")))]
5613   "TARGET_68020 && TARGET_BITFIELD
5614    && (INTVAL (operands[2]) % 8) == 0
5615    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
5617   operands[1]
5618     = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5620   return "move%.l %1,%0";
5623 (define_insn ""
5624   [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
5625         (zero_extract:SI (match_operand:SI 1 "register_operand" "do")
5626                          (match_operand:SI 2 "const_int_operand" "n")
5627                          (match_operand:SI 3 "const_int_operand" "n")))]
5628   "TARGET_68020 && TARGET_BITFIELD
5629    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5630    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
5631    && (GET_CODE (operands[1]) == REG
5632        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
5634   cc_status.flags |= CC_NOT_NEGATIVE;
5635   if (REG_P (operands[1]))
5636     {
5637       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5638         return "bfextu %1{%b3:%b2},%0";
5639     }
5640   else
5641     operands[1]
5642       = adjust_address (operands[1], SImode, INTVAL (operands[3]) / 8);
5644   output_asm_insn ("clr%.l %0", operands);
5645   if (GET_CODE (operands[0]) == MEM)
5646     operands[0] = adjust_address (operands[0],
5647                                   INTVAL (operands[2]) == 8 ? QImode : HImode,
5648                                   (32 - INTVAL (operands[1])) / 8);
5650   if (INTVAL (operands[2]) == 8)
5651     return "move%.b %1,%0";
5652   return "move%.w %1,%0";
5656 ; Special case for 32-bit field in memory.  This only occurs when 32-bit
5657 ; alignment of structure members is specified.
5659 ; The move is allowed to be odd byte aligned, because that's still faster
5660 ; than an odd byte aligned bit-field instruction.
5662 (define_insn ""
5663   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5664         (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5665                          (const_int 32)
5666                          (match_operand:SI 2 "const_int_operand" "n")))]
5667   "TARGET_68020 && TARGET_BITFIELD
5668    && (INTVAL (operands[2]) % 8) == 0
5669    && ! mode_dependent_address_p (XEXP (operands[1], 0))"
5671   operands[1]
5672     = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5674   return "move%.l %1,%0";
5677 (define_insn ""
5678   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5679         (sign_extract:SI (match_operand:SI 1 "register_operand" "do")
5680                          (match_operand:SI 2 "const_int_operand" "n")
5681                          (match_operand:SI 3 "const_int_operand" "n")))]
5682   "TARGET_68020 && TARGET_BITFIELD
5683    && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5684    && INTVAL (operands[3]) % INTVAL (operands[2]) == 0
5685    && (GET_CODE (operands[1]) == REG
5686        || ! mode_dependent_address_p (XEXP (operands[1], 0)))"
5688   if (REG_P (operands[1]))
5689     {
5690       if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5691         return "bfexts %1{%b3:%b2},%0";
5692     }
5693   else
5694     operands[1]
5695       = adjust_address (operands[1],
5696                         INTVAL (operands[2]) == 8 ? QImode : HImode,
5697                         INTVAL (operands[3]) / 8);
5699   if (INTVAL (operands[2]) == 8)
5700     return "move%.b %1,%0\;extb%.l %0";
5701   return "move%.w %1,%0\;ext%.l %0";
5704 ;; Bit-field instructions, general cases.
5705 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
5706 ;; so that its address is reloaded.
5708 (define_expand "extv"
5709   [(set (match_operand:SI 0 "register_operand" "")
5710         (sign_extract:SI (match_operand:SI 1 "general_operand" "")
5711                          (match_operand:SI 2 "const_int_operand" "")
5712                          (match_operand:SI 3 "const_int_operand" "")))]
5713   "TARGET_68020 && TARGET_BITFIELD"
5714   "")
5716 (define_insn ""
5717   [(set (match_operand:SI 0 "register_operand" "=d")
5718         (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
5719                          (match_operand:SI 2 "nonmemory_operand" "dn")
5720                          (match_operand:SI 3 "nonmemory_operand" "dn")))]
5721   "TARGET_68020 && TARGET_BITFIELD"
5722   "bfexts %1{%b3:%b2},%0")
5724 (define_expand "extzv"
5725   [(set (match_operand:SI 0 "register_operand" "")
5726         (zero_extract:SI (match_operand:SI 1 "general_operand" "")
5727                          (match_operand:SI 2 "const_int_operand" "")
5728                          (match_operand:SI 3 "const_int_operand" "")))]
5729   "TARGET_68020 && TARGET_BITFIELD"
5730   "")
5732 (define_insn ""
5733   [(set (match_operand:SI 0 "register_operand" "=d")
5734         (zero_extract:SI (match_operand:QI 1 "memory_operand" "o")
5735                          (match_operand:SI 2 "nonmemory_operand" "dn")
5736                          (match_operand:SI 3 "nonmemory_operand" "dn")))]
5737   "TARGET_68020 && TARGET_BITFIELD"
5739   if (GET_CODE (operands[2]) == CONST_INT)
5740     {
5741       if (INTVAL (operands[2]) != 32)
5742         cc_status.flags |= CC_NOT_NEGATIVE;
5743     }
5744   else
5745     {
5746       CC_STATUS_INIT;
5747     }
5748   return "bfextu %1{%b3:%b2},%0";
5751 (define_insn ""
5752   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5753                          (match_operand:SI 1 "nonmemory_operand" "dn")
5754                          (match_operand:SI 2 "nonmemory_operand" "dn"))
5755         (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
5756                 (match_operand 3 "const_int_operand" "n")))]
5757   "TARGET_68020 && TARGET_BITFIELD
5758    && (INTVAL (operands[3]) == -1
5759        || (GET_CODE (operands[1]) == CONST_INT
5760            && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
5762   CC_STATUS_INIT;
5763   return "bfchg %0{%b2:%b1}";
5766 (define_insn ""
5767   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5768                          (match_operand:SI 1 "nonmemory_operand" "dn")
5769                          (match_operand:SI 2 "nonmemory_operand" "dn"))
5770         (const_int 0))]
5771   "TARGET_68020 && TARGET_BITFIELD"
5773   CC_STATUS_INIT;
5774   return "bfclr %0{%b2:%b1}";
5777 (define_insn ""
5778   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5779                          (match_operand:SI 1 "general_operand" "dn")
5780                          (match_operand:SI 2 "general_operand" "dn"))
5781         (const_int -1))]
5782   "TARGET_68020 && TARGET_BITFIELD"
5784   CC_STATUS_INIT;
5785   return "bfset %0{%b2:%b1}";
5788 (define_expand "insv"
5789   [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5790                          (match_operand:SI 1 "const_int_operand" "")
5791                          (match_operand:SI 2 "const_int_operand" ""))
5792         (match_operand:SI 3 "register_operand" ""))]
5793   "TARGET_68020 && TARGET_BITFIELD"
5794   "")
5796 (define_insn ""
5797   [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5798                          (match_operand:SI 1 "nonmemory_operand" "dn")
5799                          (match_operand:SI 2 "nonmemory_operand" "dn"))
5800         (match_operand:SI 3 "register_operand" "d"))]
5801   "TARGET_68020 && TARGET_BITFIELD"
5802   "bfins %3,%0{%b2:%b1}")
5804 ;; Now recognize bit-field insns that operate on registers
5805 ;; (or at least were intended to do so).
5807 (define_insn ""
5808   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5809         (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5810                          (match_operand:SI 2 "const_int_operand" "n")
5811                          (match_operand:SI 3 "const_int_operand" "n")))]
5812   "TARGET_68020 && TARGET_BITFIELD"
5813   "bfexts %1{%b3:%b2},%0")
5815 (define_insn ""
5816   [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5817         (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5818                          (match_operand:SI 2 "const_int_operand" "n")
5819                          (match_operand:SI 3 "const_int_operand" "n")))]
5820   "TARGET_68020 && TARGET_BITFIELD"
5822   if (GET_CODE (operands[2]) == CONST_INT)
5823     {
5824       if (INTVAL (operands[2]) != 32)
5825         cc_status.flags |= CC_NOT_NEGATIVE;
5826     }
5827   else
5828     {
5829       CC_STATUS_INIT;
5830     }
5831   return "bfextu %1{%b3:%b2},%0";
5834 (define_insn ""
5835   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5836                          (match_operand:SI 1 "const_int_operand" "n")
5837                          (match_operand:SI 2 "const_int_operand" "n"))
5838         (const_int 0))]
5839   "TARGET_68020 && TARGET_BITFIELD"
5841   CC_STATUS_INIT;
5842   return "bfclr %0{%b2:%b1}";
5845 (define_insn ""
5846   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5847                          (match_operand:SI 1 "const_int_operand" "n")
5848                          (match_operand:SI 2 "const_int_operand" "n"))
5849         (const_int -1))]
5850   "TARGET_68020 && TARGET_BITFIELD"
5852   CC_STATUS_INIT;
5853   return "bfset %0{%b2:%b1}";
5856 (define_insn ""
5857   [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5858                          (match_operand:SI 1 "const_int_operand" "n")
5859                          (match_operand:SI 2 "const_int_operand" "n"))
5860         (match_operand:SI 3 "register_operand" "d"))]
5861   "TARGET_68020 && TARGET_BITFIELD"
5863 #if 0
5864   /* These special cases are now recognized by a specific pattern.  */
5865   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5866       && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5867     return "move%.w %3,%0";
5868   if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5869       && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5870     return "move%.b %3,%0";
5871 #endif
5872   return "bfins %3,%0{%b2:%b1}";
5875 ;; Special patterns for optimizing bit-field instructions.
5877 (define_insn ""
5878   [(set (cc0)
5879         (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5880                                   (match_operand:SI 1 "const_int_operand" "n")
5881                                   (match_operand:SI 2 "general_operand" "dn"))
5882                  (const_int 0)))]
5883   "TARGET_68020 && TARGET_BITFIELD"
5885   if (operands[1] == const1_rtx
5886       && GET_CODE (operands[2]) == CONST_INT)
5887     {
5888       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5889       return output_btst (operands,
5890                           GEN_INT (width - INTVAL (operands[2])),
5891                           operands[0], insn, 1000);
5892       /* Pass 1000 as SIGNPOS argument so that btst will
5893          not think we are testing the sign bit for an `and'
5894          and assume that nonzero implies a negative result.  */
5895     }
5896   if (INTVAL (operands[1]) != 32)
5897     cc_status.flags = CC_NOT_NEGATIVE;
5898   return "bftst %0{%b2:%b1}";
5902 ;;; now handle the register cases
5903 (define_insn ""
5904   [(set (cc0)
5905         (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5906                                   (match_operand:SI 1 "const_int_operand" "n")
5907                                   (match_operand:SI 2 "general_operand" "dn"))
5908                  (const_int 0)))]
5909   "TARGET_68020 && TARGET_BITFIELD"
5911   if (operands[1] == const1_rtx
5912       && GET_CODE (operands[2]) == CONST_INT)
5913     {
5914       int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5915       return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5916                           operands[0], insn, 1000);
5917       /* Pass 1000 as SIGNPOS argument so that btst will
5918          not think we are testing the sign bit for an `and'
5919          and assume that nonzero implies a negative result.  */
5920     }
5921   if (INTVAL (operands[1]) != 32)
5922     cc_status.flags = CC_NOT_NEGATIVE;
5923   return "bftst %0{%b2:%b1}";
5926 (define_insn "scc0_di"
5927   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5928     (match_operator 1 "ordered_comparison_operator"
5929       [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5930   "! TARGET_COLDFIRE"
5932   return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5935 (define_insn "scc0_di_5200"
5936   [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5937     (match_operator 1 "ordered_comparison_operator"
5938       [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5939   "TARGET_COLDFIRE"
5941   return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5944 (define_insn "scc_di"
5945   [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5946     (match_operator 1 "ordered_comparison_operator"
5947       [(match_operand:DI 2 "general_operand" "ro,r")
5948        (match_operand:DI 3 "general_operand" "r,ro")]))]
5949   "! TARGET_COLDFIRE"
5951   return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5954 (define_insn "scc_di_5200"
5955   [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5956     (match_operator 1 "ordered_comparison_operator"
5957       [(match_operand:DI 2 "general_operand" "ro,r")
5958        (match_operand:DI 3 "general_operand" "r,ro")]))]
5959   "TARGET_COLDFIRE"
5961   return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5964 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5965 ;; memory, but we cannot allow it to be in memory in case the address
5966 ;; needs to be reloaded.
5968 (define_insn ""
5969   [(set (match_operand:QI 0 "register_operand" "=d")
5970         (eq:QI (cc0) (const_int 0)))]
5971   ""
5973   cc_status = cc_prev_status;
5974   OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5977 (define_insn ""
5978   [(set (match_operand:QI 0 "register_operand" "=d")
5979         (ne:QI (cc0) (const_int 0)))]
5980   ""
5982   cc_status = cc_prev_status;
5983   OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5986 (define_insn ""
5987   [(set (match_operand:QI 0 "register_operand" "=d")
5988         (gt:QI (cc0) (const_int 0)))]
5989   ""
5991   cc_status = cc_prev_status;
5992   OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5995 (define_insn ""
5996   [(set (match_operand:QI 0 "register_operand" "=d")
5997         (gtu:QI (cc0) (const_int 0)))]
5998   ""
6000   cc_status = cc_prev_status;
6001   return "shi %0";
6004 (define_insn ""
6005   [(set (match_operand:QI 0 "register_operand" "=d")
6006         (lt:QI (cc0) (const_int 0)))]
6007   ""
6009    cc_status = cc_prev_status;
6010    OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
6013 (define_insn ""
6014   [(set (match_operand:QI 0 "register_operand" "=d")
6015         (ltu:QI (cc0) (const_int 0)))]
6016   ""
6018    cc_status = cc_prev_status;
6019    return "scs %0";
6022 (define_insn ""
6023   [(set (match_operand:QI 0 "register_operand" "=d")
6024         (ge:QI (cc0) (const_int 0)))]
6025   ""
6027    cc_status = cc_prev_status;
6028    OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
6031 (define_insn "*scc"
6032   [(set (match_operand:QI 0 "register_operand" "=d")
6033         (geu:QI (cc0) (const_int 0)))]
6034   ""
6036    cc_status = cc_prev_status;
6037    return "scc %0";
6039   [(set_attr "type" "scc")])
6041 (define_insn ""
6042   [(set (match_operand:QI 0 "register_operand" "=d")
6043         (le:QI (cc0) (const_int 0)))]
6044   ""
6046   cc_status = cc_prev_status;
6047   OUTPUT_JUMP ("sle %0", "fsle %0", 0);
6050 (define_insn "*sls"
6051   [(set (match_operand:QI 0 "register_operand" "=d")
6052         (leu:QI (cc0) (const_int 0)))]
6053   ""
6055    cc_status = cc_prev_status;
6056    return "sls %0";
6058   [(set_attr "type" "scc")])
6060 (define_insn "*sordered_1"
6061   [(set (match_operand:QI 0 "register_operand" "=d")
6062         (ordered:QI (cc0) (const_int 0)))]
6063   "TARGET_68881 && !TUNE_68060"
6065   cc_status = cc_prev_status;
6066   return "fsor %0";
6069 (define_insn "*sunordered_1"
6070   [(set (match_operand:QI 0 "register_operand" "=d")
6071         (unordered:QI (cc0) (const_int 0)))]
6072   "TARGET_68881 && !TUNE_68060"
6074   cc_status = cc_prev_status;
6075   return "fsun %0";
6078 (define_insn "*suneq_1"
6079   [(set (match_operand:QI 0 "register_operand" "=d")
6080         (uneq:QI (cc0) (const_int 0)))]
6081   "TARGET_68881 && !TUNE_68060"
6083   cc_status = cc_prev_status;
6084   return "fsueq %0";
6087 (define_insn "*sunge_1"
6088   [(set (match_operand:QI 0 "register_operand" "=d")
6089         (unge:QI (cc0) (const_int 0)))]
6090   "TARGET_68881 && !TUNE_68060"
6092   cc_status = cc_prev_status;
6093   return "fsuge %0";
6096 (define_insn "*sungt_1"
6097   [(set (match_operand:QI 0 "register_operand" "=d")
6098         (ungt:QI (cc0) (const_int 0)))]
6099   "TARGET_68881 && !TUNE_68060"
6101   cc_status = cc_prev_status;
6102   return "fsugt %0";
6105 (define_insn "*sunle_1"
6106   [(set (match_operand:QI 0 "register_operand" "=d")
6107         (unle:QI (cc0) (const_int 0)))]
6108   "TARGET_68881 && !TUNE_68060"
6110   cc_status = cc_prev_status;
6111   return "fsule %0";
6114 (define_insn "*sunlt_1"
6115   [(set (match_operand:QI 0 "register_operand" "=d")
6116         (unlt:QI (cc0) (const_int 0)))]
6117   "TARGET_68881 && !TUNE_68060"
6119   cc_status = cc_prev_status;
6120   return "fsult %0";
6123 (define_insn "*sltgt_1"
6124   [(set (match_operand:QI 0 "register_operand" "=d")
6125         (ltgt:QI (cc0) (const_int 0)))]
6126   "TARGET_68881 && !TUNE_68060"
6128   cc_status = cc_prev_status;
6129   return "fsogl %0";
6132 (define_insn "*fsogt_1"
6133   [(set (match_operand:QI 0 "register_operand" "=d")
6134         (not:QI (unle:QI (cc0) (const_int 0))))]
6135   "TARGET_68881 && !TUNE_68060"
6137   cc_status = cc_prev_status;
6138   return "fsogt %0";
6141 (define_insn "*fsoge_1"
6142   [(set (match_operand:QI 0 "register_operand" "=d")
6143         (not:QI (unlt:QI (cc0) (const_int 0))))]
6144   "TARGET_68881 && !TUNE_68060"
6146   cc_status = cc_prev_status;
6147   return "fsoge %0";
6150 (define_insn "*fsolt_1"
6151   [(set (match_operand:QI 0 "register_operand" "=d")
6152         (not:QI (unge:QI (cc0) (const_int 0))))]
6153   "TARGET_68881 && !TUNE_68060"
6155   cc_status = cc_prev_status;
6156   return "fsolt %0";
6159 (define_insn "*fsole_1"
6160   [(set (match_operand:QI 0 "register_operand" "=d")
6161         (not:QI (ungt:QI (cc0) (const_int 0))))]
6162   "TARGET_68881 && !TUNE_68060"
6164   cc_status = cc_prev_status;
6165   return "fsole %0";
6168 ;; Basic conditional jump instructions.
6170 (define_insn "beq0_di"
6171   [(set (pc)
6172     (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
6173             (const_int 0))
6174         (label_ref (match_operand 1 "" ","))
6175         (pc)))
6176    (clobber (match_scratch:SI 2 "=d,d"))]
6177   ""
6179   CC_STATUS_INIT;
6180   if (which_alternative == 1)
6181     return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
6182   if ((cc_prev_status.value1
6183       && rtx_equal_p (cc_prev_status.value1, operands[0]))
6184     || (cc_prev_status.value2
6185       && rtx_equal_p (cc_prev_status.value2, operands[0])))
6186     {
6187       cc_status = cc_prev_status;
6188       return "jeq %l1";
6189     }
6190   if (GET_CODE (operands[0]) == REG)
6191     operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6192   else
6193     operands[3] = adjust_address (operands[0], SImode, 4);
6194   if (! ADDRESS_REG_P (operands[0]))
6195     {
6196       if (reg_overlap_mentioned_p (operands[2], operands[0]))
6197         {
6198           if (reg_overlap_mentioned_p (operands[2], operands[3]))
6199             return "or%.l %0,%2\;jeq %l1";
6200           else
6201             return "or%.l %3,%2\;jeq %l1";
6202         }
6203       return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
6204     }
6205   operands[4] = gen_label_rtx();
6206   if (TARGET_68020 || TARGET_COLDFIRE)
6207     output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
6208   else
6209     output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
6210   (*targetm.asm_out.internal_label) (asm_out_file, "L",
6211                                 CODE_LABEL_NUMBER (operands[4]));
6212   return "";
6215 (define_insn "bne0_di"
6216   [(set (pc)
6217     (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
6218             (const_int 0))
6219         (label_ref (match_operand 1 "" ","))
6220         (pc)))
6221    (clobber (match_scratch:SI 2 "=d,X"))]
6222   ""
6224   if ((cc_prev_status.value1
6225       && rtx_equal_p (cc_prev_status.value1, operands[0]))
6226     || (cc_prev_status.value2
6227       && rtx_equal_p (cc_prev_status.value2, operands[0])))
6228     {
6229       cc_status = cc_prev_status;
6230       return "jne %l1";
6231     }
6232   CC_STATUS_INIT;
6233   if (GET_CODE (operands[0]) == REG)
6234     operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6235   else
6236     operands[3] = adjust_address (operands[0], SImode, 4);
6237   if (!ADDRESS_REG_P (operands[0]))
6238     {
6239       if (reg_overlap_mentioned_p (operands[2], operands[0]))
6240         {
6241           if (reg_overlap_mentioned_p (operands[2], operands[3]))
6242             return "or%.l %0,%2\;jne %l1";
6243           else
6244             return "or%.l %3,%2\;jne %l1";
6245         }
6246       return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
6247     }
6248   if (TARGET_68020 || TARGET_COLDFIRE)
6249     return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
6250   else
6251     return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
6254 (define_insn "bge0_di"
6255   [(set (pc)
6256     (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
6257             (const_int 0))
6258         (label_ref (match_operand 1 "" ""))
6259         (pc)))]
6260   ""
6262   if ((cc_prev_status.value1
6263       && rtx_equal_p (cc_prev_status.value1, operands[0]))
6264     || (cc_prev_status.value2
6265       && rtx_equal_p (cc_prev_status.value2, operands[0])))
6266     {
6267       cc_status = cc_prev_status;
6268       return cc_status.flags & CC_REVERSED ? "jle %l1" : "jpl %l1";
6269     }
6270   CC_STATUS_INIT;
6271   if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6272     output_asm_insn("tst%.l %0", operands);
6273   else
6274     {
6275       /* On an address reg, cmpw may replace cmpl.  */
6276       output_asm_insn("cmp%.w #0,%0", operands);
6277     }
6278   return "jpl %l1";
6281 (define_insn "blt0_di"
6282   [(set (pc)
6283     (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
6284             (const_int 0))
6285         (label_ref (match_operand 1 "" ""))
6286         (pc)))]
6287   ""
6289   if ((cc_prev_status.value1
6290       && rtx_equal_p (cc_prev_status.value1, operands[0]))
6291     || (cc_prev_status.value2
6292       && rtx_equal_p (cc_prev_status.value2, operands[0])))
6293     {
6294       cc_status = cc_prev_status;
6295       return cc_status.flags & CC_REVERSED ? "jgt %l1" : "jmi %l1";
6296     }
6297   CC_STATUS_INIT;
6298   if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6299     output_asm_insn("tst%.l %0", operands);
6300   else
6301     {
6302       /* On an address reg, cmpw may replace cmpl.  */
6303       output_asm_insn("cmp%.w #0,%0", operands);
6304     }
6305   return "jmi %l1";
6308 (define_insn "beq"
6309   [(set (pc)
6310         (if_then_else (eq (cc0)
6311                           (const_int 0))
6312                       (label_ref (match_operand 0 "" ""))
6313                       (pc)))]
6314   ""
6316   OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6318   [(set (attr "type") (symbol_ref "m68k_sched_branch_type (insn)"))])
6320 (define_insn "bne"
6321   [(set (pc)
6322         (if_then_else (ne (cc0)
6323                           (const_int 0))
6324                       (label_ref (match_operand 0 "" ""))
6325                       (pc)))]
6326   ""
6328   OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6330   [(set (attr "type") (symbol_ref "m68k_sched_branch_type (insn)"))])
6332 (define_insn "bgt"
6333   [(set (pc)
6334         (if_then_else (gt (cc0)
6335                           (const_int 0))
6336                       (label_ref (match_operand 0 "" ""))
6337                       (pc)))]
6338   ""
6340   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6341     {
6342       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6343       return 0;
6344     }
6346   OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
6348   [(set (attr "type") (symbol_ref "m68k_sched_branch_type (insn)"))])
6350 (define_insn "bgtu"
6351   [(set (pc)
6352         (if_then_else (gtu (cc0)
6353                            (const_int 0))
6354                       (label_ref (match_operand 0 "" ""))
6355                       (pc)))]
6356   ""
6358   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6359     {
6360       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6361       return 0;
6362     }
6364   return "jhi %l0";
6366   [(set_attr "type" "bcc")])
6368 (define_insn "blt"
6369   [(set (pc)
6370         (if_then_else (lt (cc0)
6371                           (const_int 0))
6372                       (label_ref (match_operand 0 "" ""))
6373                       (pc)))]
6374   ""
6376   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6377     {
6378       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6379       return 0;
6380     }
6382   OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
6384   [(set (attr "type") (symbol_ref "m68k_sched_branch_type (insn)"))])
6386 (define_insn "bltu"
6387   [(set (pc)
6388         (if_then_else (ltu (cc0)
6389                            (const_int 0))
6390                       (label_ref (match_operand 0 "" ""))
6391                       (pc)))]
6392   ""
6394   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6395     {
6396       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6397       return 0;
6398     }
6400   return "jcs %l0";
6402   [(set_attr "type" "bcc")])
6404 (define_insn "bge"
6405   [(set (pc)
6406         (if_then_else (ge (cc0)
6407                           (const_int 0))
6408                       (label_ref (match_operand 0 "" ""))
6409                       (pc)))]
6410   ""
6412   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6413     {
6414       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6415       return 0;
6416     }
6418   OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
6421 (define_insn "bgeu"
6422   [(set (pc)
6423         (if_then_else (geu (cc0)
6424                            (const_int 0))
6425                       (label_ref (match_operand 0 "" ""))
6426                       (pc)))]
6427   ""
6429   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6430     {
6431       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6432       return 0;
6433     }
6435   return "jcc %l0";
6437   [(set_attr "type" "bcc")])
6439 (define_insn "ble"
6440   [(set (pc)
6441         (if_then_else (le (cc0)
6442                           (const_int 0))
6443                       (label_ref (match_operand 0 "" ""))
6444                       (pc)))]
6445   ""
6447   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6448     {
6449       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6450       return 0;
6451     }
6453   OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
6455   [(set_attr "type" "bcc")])
6457 (define_insn "bleu"
6458   [(set (pc)
6459         (if_then_else (leu (cc0)
6460                            (const_int 0))
6461                       (label_ref (match_operand 0 "" ""))
6462                       (pc)))]
6463   ""
6465   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6466     {
6467       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6468       return 0;
6469     }
6471   return "jls %l0";
6473   [(set_attr "type" "bcc")])
6475 (define_insn "bordered"
6476   [(set (pc)
6477         (if_then_else (ordered (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 "fjor %l0";
6485   [(set_attr "type" "fbcc")])
6487 (define_insn "bunordered"
6488   [(set (pc)
6489         (if_then_else (unordered (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 "fjun %l0";
6497   [(set_attr "type" "fbcc")])
6499 (define_insn "buneq"
6500   [(set (pc)
6501         (if_then_else (uneq (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 "fjueq %l0";
6509   [(set_attr "type" "fbcc")])
6511 (define_insn "bunge"
6512   [(set (pc)
6513         (if_then_else (unge (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 "fjuge %l0";
6521   [(set_attr "type" "fbcc")])
6523 (define_insn "bungt"
6524   [(set (pc)
6525         (if_then_else (ungt (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 "fjugt %l0";
6533   [(set_attr "type" "fbcc")])
6535 (define_insn "bunle"
6536   [(set (pc)
6537         (if_then_else (unle (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 "fjule %l0";
6545   [(set_attr "type" "fbcc")])
6547 (define_insn "bunlt"
6548   [(set (pc)
6549         (if_then_else (unlt (cc0) (const_int 0))
6550                       (label_ref (match_operand 0 "" ""))
6551                       (pc)))]
6552   "TARGET_HARD_FLOAT"
6554   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6555   return "fjult %l0";
6557   [(set_attr "type" "fbcc")])
6559 (define_insn "bltgt"
6560   [(set (pc)
6561         (if_then_else (ltgt (cc0) (const_int 0))
6562                       (label_ref (match_operand 0 "" ""))
6563                       (pc)))]
6564   "TARGET_HARD_FLOAT"
6566   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6567   return "fjogl %l0";
6569   [(set_attr "type" "fbcc")])
6571 ;; Negated conditional jump instructions.
6573 (define_insn "*beq_rev"
6574   [(set (pc)
6575         (if_then_else (eq (cc0)
6576                           (const_int 0))
6577                       (pc)
6578                       (label_ref (match_operand 0 "" ""))))]
6579   ""
6581   OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6583   [(set_attr "type" "bcc")])
6585 (define_insn "*bne_rev"
6586   [(set (pc)
6587         (if_then_else (ne (cc0)
6588                           (const_int 0))
6589                       (pc)
6590                       (label_ref (match_operand 0 "" ""))))]
6591   ""
6593   OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6595   [(set_attr "type" "bcc")])
6597 (define_insn "*bgt_rev"
6598   [(set (pc)
6599         (if_then_else (gt (cc0)
6600                           (const_int 0))
6601                       (pc)
6602                       (label_ref (match_operand 0 "" ""))))]
6603   ""
6605   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6606     {
6607       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6608       return 0;
6609     }
6611   OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6613   [(set_attr "type" "bcc")])
6615 (define_insn "*bgtu_rev"
6616   [(set (pc)
6617         (if_then_else (gtu (cc0)
6618                            (const_int 0))
6619                       (pc)
6620                       (label_ref (match_operand 0 "" ""))))]
6621   ""
6623   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6624     {
6625       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6626       return 0;
6627     }
6629   return "jls %l0";
6631   [(set_attr "type" "bcc")])
6633 (define_insn "*blt_rev"
6634   [(set (pc)
6635         (if_then_else (lt (cc0)
6636                           (const_int 0))
6637                       (pc)
6638                       (label_ref (match_operand 0 "" ""))))]
6639   ""
6641   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6642     {
6643       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6644       return 0;
6645     }
6647   OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6649   [(set_attr "type" "bcc")])
6651 (define_insn "*bltu_rev"
6652   [(set (pc)
6653         (if_then_else (ltu (cc0)
6654                            (const_int 0))
6655                       (pc)
6656                       (label_ref (match_operand 0 "" ""))))]
6657   ""
6659   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6660     {
6661       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6662       return 0;
6663     }
6665   return "jcc %l0";
6667   [(set_attr "type" "bcc")])
6669 (define_insn "*bge_rev"
6670   [(set (pc)
6671         (if_then_else (ge (cc0)
6672                           (const_int 0))
6673                       (pc)
6674                       (label_ref (match_operand 0 "" ""))))]
6675   ""
6677   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6678     {
6679       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6680       return 0;
6681     }
6683   OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6685   [(set_attr "type" "bcc")])
6687 (define_insn "*bgeu_rev"
6688   [(set (pc)
6689         (if_then_else (geu (cc0)
6690                            (const_int 0))
6691                       (pc)
6692                       (label_ref (match_operand 0 "" ""))))]
6693   ""
6695   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6696     {
6697       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6698       return 0;
6699     }
6701   return "jcs %l0";
6703   [(set_attr "type" "bcc")])
6705 (define_insn "*ble_rev"
6706   [(set (pc)
6707         (if_then_else (le (cc0)
6708                           (const_int 0))
6709                       (pc)
6710                       (label_ref (match_operand 0 "" ""))))]
6711   ""
6713   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6714     {
6715       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6716       return 0;
6717     }
6719   OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6721   [(set_attr "type" "bcc")])
6723 (define_insn "*bleu_rev"
6724   [(set (pc)
6725         (if_then_else (leu (cc0)
6726                            (const_int 0))
6727                       (pc)
6728                       (label_ref (match_operand 0 "" ""))))]
6729   ""
6731   if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6732     {
6733       cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6734       return 0;
6735     }
6737   return "jhi %l0";
6739   [(set_attr "type" "bcc")])
6741 (define_insn "*bordered_rev"
6742   [(set (pc)
6743         (if_then_else (ordered (cc0) (const_int 0))
6744                       (pc)
6745                       (label_ref (match_operand 0 "" ""))))]
6746   "TARGET_HARD_FLOAT"
6748   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6749   return "fjun %l0";
6751   [(set_attr "type" "fbcc")])
6753 (define_insn "*bunordered_rev"
6754   [(set (pc)
6755         (if_then_else (unordered (cc0) (const_int 0))
6756                       (pc)
6757                       (label_ref (match_operand 0 "" ""))))]
6758   "TARGET_HARD_FLOAT"
6760   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6761   return "fjor %l0";
6763   [(set_attr "type" "fbcc")])
6765 (define_insn "*buneq_rev"
6766   [(set (pc)
6767         (if_then_else (uneq (cc0) (const_int 0))
6768                       (pc)
6769                       (label_ref (match_operand 0 "" ""))))]
6770   "TARGET_HARD_FLOAT"
6772   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6773   return "fjogl %l0";
6775   [(set_attr "type" "fbcc")])
6777 (define_insn "*bunge_rev"
6778   [(set (pc)
6779         (if_then_else (unge (cc0) (const_int 0))
6780                       (pc)
6781                       (label_ref (match_operand 0 "" ""))))]
6782   "TARGET_HARD_FLOAT"
6784   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6785   return "fjolt %l0";
6787   [(set_attr "type" "fbcc")])
6789 (define_insn "*bungt_rev"
6790   [(set (pc)
6791         (if_then_else (ungt (cc0) (const_int 0))
6792                       (pc)
6793                       (label_ref (match_operand 0 "" ""))))]
6794   "TARGET_HARD_FLOAT"
6796   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6797   return "fjole %l0";
6799   [(set_attr "type" "fbcc")])
6801 (define_insn "*bunle_rev"
6802   [(set (pc)
6803         (if_then_else (unle (cc0) (const_int 0))
6804                       (pc)
6805                       (label_ref (match_operand 0 "" ""))))]
6806   "TARGET_HARD_FLOAT"
6808   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6809   return "fjogt %l0";
6811   [(set_attr "type" "fbcc")])
6813 (define_insn "*bunlt_rev"
6814   [(set (pc)
6815         (if_then_else (unlt (cc0) (const_int 0))
6816                       (pc)
6817                       (label_ref (match_operand 0 "" ""))))]
6818   "TARGET_HARD_FLOAT"
6820   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6821   return "fjoge %l0";
6823   [(set_attr "type" "fbcc")])
6825 (define_insn "*bltgt_rev"
6826   [(set (pc)
6827         (if_then_else (ltgt (cc0) (const_int 0))
6828                       (pc)
6829                       (label_ref (match_operand 0 "" ""))))]
6830   "TARGET_HARD_FLOAT"
6832   gcc_assert (cc_prev_status.flags & CC_IN_68881);
6833   return "fjueq %l0";
6835   [(set_attr "type" "fbcc")])
6837 ;; Unconditional and other jump instructions
6838 (define_insn "jump"
6839   [(set (pc)
6840         (label_ref (match_operand 0 "" "")))]
6841   ""
6842   "jra %l0"
6843   [(set_attr "type" "bra")])
6845 (define_expand "tablejump"
6846   [(parallel [(set (pc) (match_operand 0 "" ""))
6847               (use (label_ref (match_operand 1 "" "")))])]
6848   ""
6850 #ifdef CASE_VECTOR_PC_RELATIVE
6851     operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6852                                 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6853 #endif
6856 ;; Jump to variable address from dispatch table of absolute addresses.
6857 (define_insn "*tablejump_internal"
6858   [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6859    (use (label_ref (match_operand 1 "" "")))]
6860   ""
6862   return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6864   [(set_attr "type" "jmp")])
6866 ;; Jump to variable address from dispatch table of relative addresses.
6867 (define_insn ""
6868   [(set (pc)
6869         (plus:SI (pc)
6870                  (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6871    (use (label_ref (match_operand 1 "" "")))]
6872   ""
6874 #ifdef ASM_RETURN_CASE_JUMP
6875   ASM_RETURN_CASE_JUMP;
6876 #else
6877   if (TARGET_COLDFIRE)
6878     {
6879       if (ADDRESS_REG_P (operands[0]))
6880         return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6881       else if (MOTOROLA)
6882         return "ext%.l %0\;jmp (2,pc,%0.l)";
6883       else
6884         return "extl %0\;jmp pc@(2,%0:l)";
6885     }
6886   else
6887     return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6888 #endif
6891 ;; Decrement-and-branch insns.
6892 (define_insn "*dbne_hi"
6893   [(set (pc)
6894         (if_then_else
6895          (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6896              (const_int 0))
6897          (label_ref (match_operand 1 "" ""))
6898          (pc)))
6899    (set (match_dup 0)
6900         (plus:HI (match_dup 0)
6901                  (const_int -1)))]
6902   "!TARGET_COLDFIRE"
6904   CC_STATUS_INIT;
6905   if (DATA_REG_P (operands[0]))
6906     return "dbra %0,%l1";
6907   if (GET_CODE (operands[0]) == MEM)
6908     return "subq%.w #1,%0\;jcc %l1";
6909   return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6912 (define_insn "*dbne_si"
6913   [(set (pc)
6914         (if_then_else
6915          (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6916              (const_int 0))
6917          (label_ref (match_operand 1 "" ""))
6918          (pc)))
6919    (set (match_dup 0)
6920         (plus:SI (match_dup 0)
6921                  (const_int -1)))]
6922   "!TARGET_COLDFIRE"
6924   CC_STATUS_INIT;
6925   if (DATA_REG_P (operands[0]))
6926     return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6927   if (GET_CODE (operands[0]) == MEM)
6928     return "subq%.l #1,%0\;jcc %l1";
6929   return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6932 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6934 (define_insn "*dbge_hi"
6935   [(set (pc)
6936         (if_then_else
6937           (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6938                        (const_int -1))
6939               (const_int 0))
6940           (label_ref (match_operand 1 "" ""))
6941           (pc)))
6942    (set (match_dup 0)
6943         (plus:HI (match_dup 0)
6944                  (const_int -1)))]
6945   "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6947   CC_STATUS_INIT;
6948   if (DATA_REG_P (operands[0]))
6949     return "dbra %0,%l1";
6950   if (GET_CODE (operands[0]) == MEM)
6951     return "subq%.w #1,%0\;jcc %l1";
6952   return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6955 (define_expand "decrement_and_branch_until_zero"
6956   [(parallel [(set (pc)
6957                    (if_then_else
6958                     (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6959                                  (const_int -1))
6960                         (const_int 0))
6961                     (label_ref (match_operand 1 "" ""))
6962                     (pc)))
6963               (set (match_dup 0)
6964                    (plus:SI (match_dup 0)
6965                             (const_int -1)))])]
6966   ""
6967   "")
6969 (define_insn "*dbge_si"
6970   [(set (pc)
6971         (if_then_else
6972           (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6973                        (const_int -1))
6974               (const_int 0))
6975           (label_ref (match_operand 1 "" ""))
6976           (pc)))
6977    (set (match_dup 0)
6978         (plus:SI (match_dup 0)
6979                  (const_int -1)))]
6980   "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6982   CC_STATUS_INIT;
6983   if (DATA_REG_P (operands[0]))
6984     return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6985   if (GET_CODE (operands[0]) == MEM)
6986     return "subq%.l #1,%0\;jcc %l1";
6987   return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6990 (define_expand "sibcall"
6991   [(call (match_operand:QI 0 "memory_operand" "")
6992          (match_operand:SI 1 "general_operand" ""))]
6993   ""
6995   operands[0] = m68k_legitimize_sibcall_address (operands[0]);
6998 (define_insn "*sibcall"
6999   [(call (mem:QI (match_operand:SI 0 "sibcall_operand" ""))
7000          (match_operand:SI 1 "general_operand" ""))]
7001   "SIBLING_CALL_P (insn)"
7003   return output_sibcall (operands[0]);
7006 (define_expand "sibcall_value"
7007   [(set (match_operand 0 "" "")
7008         (call (match_operand:QI 1 "memory_operand" "")
7009               (match_operand:SI 2 "general_operand" "")))]
7010   ""
7012   operands[1] = m68k_legitimize_sibcall_address (operands[1]);
7015 (define_insn "*sibcall_value"
7016   [(set (match_operand 0 "" "=rf,rf")
7017         (call (mem:QI (match_operand:SI 1 "sibcall_operand" ""))
7018               (match_operand:SI 2 "general_operand" "")))]
7019   "SIBLING_CALL_P (insn)"
7021   operands[0] = operands[1];
7022   return output_sibcall (operands[0]);
7025 ;; Call subroutine with no return value.
7026 (define_expand "call"
7027   [(call (match_operand:QI 0 "memory_operand" "")
7028          (match_operand:SI 1 "general_operand" ""))]
7029   ;; Operand 1 not really used on the m68000.
7030   ""
7032   operands[0] = m68k_legitimize_call_address (operands[0]);
7035 (define_insn "*call"
7036   [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
7037          (match_operand:SI 1 "general_operand" "g,g"))]
7038   ;; Operand 1 not really used on the m68000.
7039   "!SIBLING_CALL_P (insn)"
7041   return output_call (operands[0]);
7043   [(set_attr "type" "jsr")])
7045 ;; Call subroutine, returning value in operand 0
7046 ;; (which must be a hard register).
7047 (define_expand "call_value"
7048   [(set (match_operand 0 "" "")
7049         (call (match_operand:QI 1 "memory_operand" "")
7050               (match_operand:SI 2 "general_operand" "")))]
7051   ;; Operand 2 not really used on the m68000.
7052   ""
7054   operands[1] = m68k_legitimize_call_address (operands[1]);
7057 (define_insn "*non_symbolic_call_value"
7058   [(set (match_operand 0 "" "=rf,rf")
7059         (call (mem:QI (match_operand:SI 1 "non_symbolic_call_operand" "a,W"))
7060               (match_operand:SI 2 "general_operand" "g,g")))]
7061   ;; Operand 2 not really used on the m68000.
7062   "!SIBLING_CALL_P (insn)"
7063   "jsr %a1"
7064   [(set_attr "type" "jsr")
7065    (set_attr "opx" "1")])
7067 (define_insn "*symbolic_call_value_jsr"
7068   [(set (match_operand 0 "" "=rf,rf")
7069         (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
7070               (match_operand:SI 2 "general_operand" "g,g")))]
7071   ;; Operand 2 not really used on the m68000.
7072   "!SIBLING_CALL_P (insn) && m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_JSR"
7074   operands[0] = operands[1];
7075   return m68k_symbolic_call;
7077   [(set_attr "type" "jsr")
7078    (set_attr "opx" "1")])
7080 (define_insn "*symbolic_call_value_bsr"
7081   [(set (match_operand 0 "" "=rf,rf")
7082         (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
7083               (match_operand:SI 2 "general_operand" "g,g")))]
7084   ;; Operand 2 not really used on the m68000.
7085   "!SIBLING_CALL_P (insn)
7086    && (m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_C
7087        || m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_P)"
7089   operands[0] = operands[1];
7090   return m68k_symbolic_call;
7092   [(set_attr "type" "bsr")
7093    (set_attr "opx" "1")])
7095 ;; Call subroutine returning any type.
7097 (define_expand "untyped_call"
7098   [(parallel [(call (match_operand 0 "" "")
7099                     (const_int 0))
7100               (match_operand 1 "" "")
7101               (match_operand 2 "" "")])]
7102   "NEEDS_UNTYPED_CALL"
7104   int i;
7106   emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
7108   for (i = 0; i < XVECLEN (operands[2], 0); i++)
7109     {
7110       rtx set = XVECEXP (operands[2], 0, i);
7111       emit_move_insn (SET_DEST (set), SET_SRC (set));
7112     }
7114   /* The optimizer does not know that the call sets the function value
7115      registers we stored in the result block.  We avoid problems by
7116      claiming that all hard registers are used and clobbered at this
7117      point.  */
7118   emit_insn (gen_blockage ());
7120   DONE;
7123 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
7124 ;; all of memory.  This blocks insns from being moved across this point.
7126 (define_insn "blockage"
7127   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
7128   ""
7129   "")
7131 (define_insn "nop"
7132   [(const_int 0)]
7133   ""
7134   "nop"
7135   [(set_attr "type" "nop")])
7137 (define_expand "prologue"
7138   [(const_int 0)]
7139   ""
7141   m68k_expand_prologue ();
7142   DONE;
7145 (define_expand "epilogue"
7146   [(return)]
7147   ""
7149   m68k_expand_epilogue (false);
7150   DONE;
7153 (define_expand "sibcall_epilogue"
7154   [(return)]
7155   ""
7157   m68k_expand_epilogue (true);
7158   DONE;
7161 ;; Used for frameless functions which save no regs and allocate no locals.
7162 (define_expand "return"
7163   [(return)]
7164   "m68k_use_return_insn ()"
7165   "")
7167 (define_insn "*return"
7168   [(return)]
7169   ""
7171   switch (m68k_get_function_kind (current_function_decl))
7172     {
7173     case m68k_fk_interrupt_handler:
7174       return "rte";
7176     case m68k_fk_interrupt_thread:
7177       return "sleep";
7179     default:
7180       if (crtl->args.pops_args)
7181         {
7182           operands[0] = GEN_INT (crtl->args.pops_args);
7183           return "rtd %0";
7184         }
7185       else
7186         return "rts";
7187     }
7189   [(set_attr "type" "rts")])
7191 (define_insn "*m68k_store_multiple"
7192   [(match_parallel 0 "" [(match_operand 1 "")])]
7193   "m68k_movem_pattern_p (operands[0], NULL, 0, true)"
7195   return m68k_output_movem (operands, operands[0], 0, true);
7198 (define_insn "*m68k_store_multiple_automod"
7199   [(match_parallel 0 ""
7200      [(set (match_operand:SI 1 "register_operand" "=a")
7201            (plus:SI (match_operand:SI 2 "register_operand" "1")
7202                     (match_operand:SI 3 "const_int_operand")))])]
7203   "m68k_movem_pattern_p (operands[0], operands[1], INTVAL (operands[3]), true)"
7205   return m68k_output_movem (operands, operands[0], INTVAL (operands[3]), true);
7208 (define_insn "*m68k_load_multiple"
7209   [(match_parallel 0 "" [(match_operand 1 "")])]
7210   "m68k_movem_pattern_p (operands[0], NULL, 0, false)"
7212   return m68k_output_movem (operands, operands[0], 0, false);
7215 (define_insn "*m68k_load_multiple_automod"
7216   [(match_parallel 0 ""
7217      [(set (match_operand:SI 1 "register_operand" "=a")
7218            (plus:SI (match_operand:SI 2 "register_operand" "1")
7219                     (match_operand:SI 3 "const_int_operand")))])]
7220   "m68k_movem_pattern_p (operands[0], operands[1],
7221                          INTVAL (operands[3]), false)"
7223   return m68k_output_movem (operands, operands[0],
7224                             INTVAL (operands[3]), false);
7227 (define_expand "link"
7228   [(parallel
7229        [(set (match_operand:SI 0 "register_operand")
7230              (plus:SI (reg:SI SP_REG) (const_int -4)))
7231         (set (match_dup 2)
7232              (match_dup 0))
7233         (set (reg:SI SP_REG)
7234              (plus:SI (reg:SI SP_REG)
7235                       (match_operand:SI 1 "const_int_operand")))])]
7236   "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7238   operands[2] = gen_frame_mem (SImode, plus_constant (stack_pointer_rtx, -4));
7241 (define_insn "*link"
7242   [(set (match_operand:SI 0 "register_operand" "+r")
7243         (plus:SI (reg:SI SP_REG) (const_int -4)))
7244    (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
7245         (match_dup 0))
7246    (set (reg:SI SP_REG)
7247         (plus:SI (reg:SI SP_REG)
7248                  (match_operand:SI 1 "const_int_operand")))]
7249   "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7251   operands[1] = GEN_INT (INTVAL (operands[1]) + 4);
7252   if (!MOTOROLA)
7253     return "link %0,%1";
7254   else if (INTVAL (operands[1]) >= -0x8000)
7255     return "link.w %0,%1";
7256   else
7257     return "link.l %0,%1";
7259   [(set_attr "type" "link")])
7261 (define_expand "unlink"
7262   [(parallel
7263       [(set (match_operand:SI 0 "register_operand")
7264             (match_dup 1))
7265        (set (reg:SI SP_REG)
7266             (plus:SI (match_dup 0)
7267                      (const_int 4)))])]
7268   ""
7270   operands[1] = gen_frame_mem (SImode, copy_rtx (operands[0]));
7273 (define_insn "*unlink"
7274   [(set (match_operand:SI 0 "register_operand" "+r")
7275         (mem:SI (match_dup 0)))
7276    (set (reg:SI SP_REG)
7277         (plus:SI (match_dup 0)
7278                  (const_int 4)))]
7279   ""
7280   "unlk %0"
7281   [(set_attr "type" "unlk")])
7283 (define_insn "load_got"
7284   [(set (match_operand:SI 0 "register_operand" "=a")
7285         (unspec:SI [(const_int 0)] UNSPEC_GOT))]
7286   ""
7288   if (TARGET_ID_SHARED_LIBRARY)
7289     {
7290       operands[1] = gen_rtx_REG (Pmode, PIC_REG);
7291       return MOTOROLA ? "move.l %?(%1),%0" : "movel %1@(%?), %0";
7292     }
7293   else if (MOTOROLA)
7294     {
7295       if (TARGET_COLDFIRE)
7296         /* Load the full 32-bit PC-relative offset of
7297            _GLOBAL_OFFSET_TABLE_ into the PIC register, then use it to
7298            calculate the absolute value.  The offset and "lea"
7299            operation word together occupy 6 bytes.  */
7300         return ("move.l #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t"
7301                 "lea (-6, %%pc, %0), %0");
7302       else
7303         return "lea (%%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %0";
7304     }
7305   else
7306     return ("movel #_GLOBAL_OFFSET_TABLE_, %0\n\t"
7307             "lea %%pc@(0,%0:l),%0");
7310 (define_insn "indirect_jump"
7311   [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
7312   ""
7313   "jmp %a0"
7314   [(set_attr "type" "jmp")])
7316 ;; This should not be used unless the add/sub insns can't be.
7318 (define_insn "*lea"
7319   [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
7320         (match_operand:QI 1 "address_operand" "p"))]
7321   ""
7322   "lea %a1,%0")
7324 ;; This is the first machine-dependent peephole optimization.
7325 ;; It is useful when a floating value is returned from a function call
7326 ;; and then is moved into an FP register.
7327 ;; But it is mainly intended to test the support for these optimizations.
7329 (define_peephole2
7330   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7331    (set (match_operand:DF 0 "register_operand" "")
7332         (match_operand:DF 1 "register_operand" ""))]
7333   "FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
7334   [(set (mem:SI (reg:SI SP_REG)) (match_dup 1))
7335    (set (mem:SI (pre_dec:SI (reg:SI SP_REG))) (match_dup 2))
7336    (set (match_dup 0) (mem:DF (post_inc:SI (reg:SI SP_REG))))]
7337   "split_di(operands + 1, 1, operands + 1, operands + 2);")
7339 ;; Optimize a stack-adjust followed by a push of an argument.
7340 ;; This is said to happen frequently with -msoft-float
7341 ;; when there are consecutive library calls.
7343 (define_peephole2
7344   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7345    (set (match_operand:SF 0 "push_operand" "")
7346         (match_operand:SF 1 "general_operand" ""))]
7347   "!reg_mentioned_p (stack_pointer_rtx, operands[0])"
7348   [(set (match_dup 0) (match_dup 1))]
7349   "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7351 (define_peephole2
7352   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7353                                  (match_operand:SI 0 "const_int_operand" "")))
7354    (set (match_operand:SF 1 "push_operand" "")
7355         (match_operand:SF 2 "general_operand" ""))]
7356   "INTVAL (operands[0]) > 4
7357    && !reg_mentioned_p (stack_pointer_rtx, operands[2])"
7358   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7359    (set (match_dup 1) (match_dup 2))]
7361   operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7362   operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7365 ;; Speed up stack adjust followed by a fullword fixedpoint push.
7366 ;; Constant operands need special care, as replacing a "pea X.w" with
7367 ;; "move.l #X,(%sp)" is often not a win.
7369 ;; Already done by the previous csa pass, left as reference.
7370 (define_peephole2
7371   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7372    (set (match_operand:SI 0 "push_operand" "")
7373         (match_operand:SI 1 "general_operand" ""))]
7374   "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7375   [(set (match_dup 0) (match_dup 1))]
7376   "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7378 ;; Try to use moveq, after stack push has been changed into a simple move.
7379 (define_peephole2
7380   [(match_scratch:SI 2 "d")
7381    (set (match_operand:SI 0 "memory_operand" "")
7382         (match_operand:SI 1 "const_int_operand" ""))]
7383   "GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
7384    && INTVAL (operands[1]) != 0
7385    && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7386    && !valid_mov3q_const (INTVAL (operands[1]))"
7387   [(set (match_dup 2) (match_dup 1))
7388    (set (match_dup 0) (match_dup 2))])
7390 ;; This sequence adds an instruction, but is two bytes shorter.
7391 (define_peephole2
7392   [(match_scratch:SI 2 "d")
7393    (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 12)))
7394    (set (match_operand:SI 0 "push_operand" "")
7395         (match_operand:SI 1 "const_int_operand" ""))]
7396   "INTVAL (operands[1]) != 0
7397    && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7398    && !valid_mov3q_const (INTVAL (operands[1]))"
7399   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 8)))
7400    (set (match_dup 2) (match_dup 1))
7401    (set (match_dup 0) (match_dup 2))]
7402   "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7404 ;; Changing pea X.w into a move.l is no real win here.
7405 (define_peephole2
7406   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7407                                  (match_operand:SI 0 "const_int_operand" "")))
7408    (set (match_operand:SI 1 "push_operand" "")
7409         (match_operand:SI 2 "general_operand" ""))]
7410   "INTVAL (operands[0]) > 4
7411    && !reg_mentioned_p (stack_pointer_rtx, operands[2])
7412    && !(CONST_INT_P (operands[2]) && INTVAL (operands[2]) != 0
7413         && IN_RANGE (INTVAL (operands[2]), -0x8000, 0x7fff)
7414         && !valid_mov3q_const (INTVAL (operands[2])))"
7415   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7416    (set (match_dup 1) (match_dup 2))]
7418   operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7419   operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7422 ;; Speed up pushing a single byte/two bytes but leaving four bytes of space
7423 ;; (which differs slightly between m680x0 and ColdFire).
7425 (define_peephole2
7426   [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
7427    (set (match_operand:QI 0 "memory_operand" "")
7428         (match_operand:QI 1 "register_operand" ""))]
7429   "!reg_mentioned_p (stack_pointer_rtx, operands[1])
7430    && GET_CODE (XEXP (operands[0], 0)) == PLUS
7431    && rtx_equal_p (XEXP (XEXP (operands[0], 0), 0), stack_pointer_rtx)
7432    && CONST_INT_P (XEXP (XEXP (operands[0], 0), 1))
7433    && INTVAL (XEXP (XEXP (operands[0], 0), 1)) == 3"
7434   [(set (match_dup 0) (match_dup 1))]
7436   rtx addr = gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx);
7437   operands[0] = adjust_automodify_address (operands[0], SImode, addr, -3);
7438   operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7441 (define_peephole2
7442   [(set (match_operand:QI 0 "push_operand" "")
7443         (match_operand:QI 1 "register_operand" ""))
7444    (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -3)))]
7445   "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7446   [(set (match_dup 0) (match_dup 1))]
7448   operands[0] = adjust_automodify_address (operands[0], SImode,
7449                                            XEXP (operands[0], 0), -3);
7450   operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7453 (define_peephole2
7454   [(set (match_operand:HI 0 "push_operand" "")
7455         (match_operand:HI 1 "register_operand" ""))
7456    (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))]
7457   "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7458   [(set (match_dup 0) (match_dup 1))]
7460   operands[0] = adjust_automodify_address (operands[0], SImode,
7461                                            XEXP (operands[0], 0), -2);
7462   operands[1] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
7465 ;; Optimize a series of strict_low_part assignments
7467 (define_peephole2
7468   [(set (match_operand:SI 0 "register_operand" "")
7469         (const_int 0))
7470    (set (strict_low_part (match_operand:HI 1 "register_operand" ""))
7471         (match_operand:HI 2 "general_operand" ""))]
7472   "REGNO (operands[0]) == REGNO (operands[1])
7473    && strict_low_part_peephole_ok (HImode, insn, operands[0])"
7474   [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7475   "")
7477 (define_peephole2
7478   [(set (match_operand:SI 0 "register_operand" "")
7479         (const_int 0))
7480    (set (strict_low_part (match_operand:QI 1 "register_operand" ""))
7481         (match_operand:QI 2 "general_operand" ""))]
7482   "REGNO (operands[0]) == REGNO (operands[1])
7483    && strict_low_part_peephole_ok (QImode, insn, operands[0])"
7484   [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7485   "")
7487 ;; dbCC peepholes
7489 ;; Turns
7490 ;;   loop:
7491 ;;           [ ... ]
7492 ;;           jCC label          ; abnormal loop termination
7493 ;;           dbra dN, loop      ; normal loop termination
7495 ;; Into
7496 ;;   loop:
7497 ;;           [ ... ]
7498 ;;           dbCC dN, loop
7499 ;;           jCC label
7501 ;; Which moves the jCC condition outside the inner loop for free.
7504 (define_peephole
7505   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7506                              [(cc0) (const_int 0)])
7507                            (label_ref (match_operand 2 "" ""))
7508                            (pc)))
7509    (parallel
7510     [(set (pc)
7511           (if_then_else
7512             (ne (match_operand:HI 0 "register_operand" "")
7513                 (const_int 0))
7514             (label_ref (match_operand 1 "" ""))
7515             (pc)))
7516      (set (match_dup 0)
7517           (plus:HI (match_dup 0)
7518                    (const_int -1)))])]
7519   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7521   CC_STATUS_INIT;
7522   output_dbcc_and_branch (operands);
7523   return "";
7526 (define_peephole
7527   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7528                              [(cc0) (const_int 0)])
7529                            (label_ref (match_operand 2 "" ""))
7530                            (pc)))
7531    (parallel
7532     [(set (pc)
7533           (if_then_else
7534             (ne (match_operand:SI 0 "register_operand" "")
7535                 (const_int 0))
7536             (label_ref (match_operand 1 "" ""))
7537             (pc)))
7538      (set (match_dup 0)
7539           (plus:SI (match_dup 0)
7540                    (const_int -1)))])]
7541   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7543   CC_STATUS_INIT;
7544   output_dbcc_and_branch (operands);
7545   return "";
7548 (define_peephole
7549   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7550                              [(cc0) (const_int 0)])
7551                            (label_ref (match_operand 2 "" ""))
7552                            (pc)))
7553    (parallel
7554     [(set (pc)
7555           (if_then_else
7556             (ge (plus:HI (match_operand:HI 0 "register_operand" "")
7557                          (const_int -1))
7558                 (const_int 0))
7559             (label_ref (match_operand 1 "" ""))
7560             (pc)))
7561      (set (match_dup 0)
7562           (plus:HI (match_dup 0)
7563                    (const_int -1)))])]
7564   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7566   CC_STATUS_INIT;
7567   output_dbcc_and_branch (operands);
7568   return "";
7571 (define_peephole
7572   [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7573                              [(cc0) (const_int 0)])
7574                            (label_ref (match_operand 2 "" ""))
7575                            (pc)))
7576    (parallel
7577     [(set (pc)
7578           (if_then_else
7579             (ge (plus:SI (match_operand:SI 0 "register_operand" "")
7580                          (const_int -1))
7581                 (const_int 0))
7582             (label_ref (match_operand 1 "" ""))
7583             (pc)))
7584      (set (match_dup 0)
7585           (plus:SI (match_dup 0)
7586                    (const_int -1)))])]
7587   "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7589   CC_STATUS_INIT;
7590   output_dbcc_and_branch (operands);
7591   return "";
7595 (define_insn "extendsfxf2"
7596   [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7597         (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
7598   "TARGET_68881"
7600   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7601     {
7602       if (REGNO (operands[0]) == REGNO (operands[1]))
7603         {
7604           /* Extending float to double in an fp-reg is a no-op.
7605              NOTICE_UPDATE_CC has already assumed that the
7606              cc will be set.  So cancel what it did.  */
7607           cc_status = cc_prev_status;
7608           return "";
7609         }
7610       return "f%$move%.x %1,%0";
7611     }
7612   if (FP_REG_P (operands[0]))
7613     {
7614       if (FP_REG_P (operands[1]))
7615         return "f%$move%.x %1,%0";
7616       else if (ADDRESS_REG_P (operands[1]))
7617         return "move%.l %1,%-\;f%$move%.s %+,%0";
7618       else if (GET_CODE (operands[1]) == CONST_DOUBLE)
7619         return output_move_const_single (operands);
7620       return "f%$move%.s %f1,%0";
7621     }
7622   return "fmove%.x %f1,%0";
7626 (define_insn "extenddfxf2"
7627   [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7628         (float_extend:XF
7629           (match_operand:DF 1 "general_operand" "f,rmE")))]
7630   "TARGET_68881"
7632   if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7633     {
7634       if (REGNO (operands[0]) == REGNO (operands[1]))
7635         {
7636           /* Extending float to double in an fp-reg is a no-op.
7637              NOTICE_UPDATE_CC has already assumed that the
7638              cc will be set.  So cancel what it did.  */
7639           cc_status = cc_prev_status;
7640           return "";
7641         }
7642       return "fmove%.x %1,%0";
7643     }
7644   if (FP_REG_P (operands[0]))
7645     {
7646       if (REG_P (operands[1]))
7647         {
7648           rtx xoperands[2];
7649           xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
7650           output_asm_insn ("move%.l %1,%-", xoperands);
7651           output_asm_insn ("move%.l %1,%-", operands);
7652           return "f%&move%.d %+,%0";
7653         }
7654       if (GET_CODE (operands[1]) == CONST_DOUBLE)
7655         return output_move_const_double (operands);
7656       return "f%&move%.d %f1,%0";
7657     }
7658   return "fmove%.x %f1,%0";
7661 (define_insn "truncxfdf2"
7662   [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
7663         (float_truncate:DF
7664           (match_operand:XF 1 "general_operand" "f,f")))]
7665   "TARGET_68881"
7667   if (REG_P (operands[0]))
7668     {
7669       output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
7670       operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
7671       return "move%.l %+,%0";
7672     }
7673   return "fmove%.d %f1,%0";
7676 (define_insn "truncxfsf2"
7677   [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
7678         (float_truncate:SF
7679           (match_operand:XF 1 "general_operand" "f")))]
7680   "TARGET_68881"
7681   "fmove%.s %f1,%0")
7683 (define_insn "sin<mode>2"
7684   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7685         (unspec:FP
7686           [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
7687   "TARGET_68881 && flag_unsafe_math_optimizations"
7689   if (FP_REG_P (operands[1]))
7690     return "fsin%.x %1,%0";
7691   else
7692     return "fsin%.<FP:prec> %1,%0";
7695 (define_insn "cos<mode>2"
7696   [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7697         (unspec:FP
7698           [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
7699   "TARGET_68881 && flag_unsafe_math_optimizations"
7701   if (FP_REG_P (operands[1]))
7702     return "fcos%.x %1,%0";
7703   else
7704     return "fcos%.<FP:prec> %1,%0";
7707 ;; Unconditional traps are assumed to have (const_int 1) for the condition.
7708 (define_insn "trap"
7709   [(trap_if (const_int 1) (const_int 7))]
7710   ""
7711   "trap #7"
7712   [(set_attr "type" "trap")])
7714 (define_expand "ctrapdi4"
7715   [(trap_if (match_operator 0 "ordered_comparison_operator"
7716                             [(cc0) (const_int 0)])
7717             (match_operand:SI 3 "const1_operand" ""))]
7718   "TARGET_68020"
7720   if (operands[2] == const0_rtx)
7721     emit_insn (gen_tstdi (operands[1]));
7722   else
7723     emit_insn (gen_cmpdi (operands[1], operands[2]));
7724   operands[1] = cc0_rtx;
7725   operands[2] = const0_rtx;
7728 (define_expand "ctrapsi4"
7729   [(set (cc0)
7730         (compare (match_operand:SI 1 "nonimmediate_operand" "")
7731                  (match_operand:SI 2 "general_operand" "")))
7732    (trap_if (match_operator 0 "ordered_comparison_operator"
7733                             [(cc0) (const_int 0)])
7734             (match_operand:SI 3 "const1_operand" ""))]
7735   "TARGET_68020"
7736   "")
7738 (define_expand "ctraphi4"
7739   [(set (cc0)
7740         (compare (match_operand:HI 1 "nonimmediate_src_operand" "")
7741                  (match_operand:HI 2 "general_src_operand" "")))
7742    (trap_if (match_operator 0 "ordered_comparison_operator"
7743                             [(cc0) (const_int 0)])
7744             (match_operand:SI 3 "const1_operand" ""))]
7745   "TARGET_68020"
7746   "")
7748 (define_expand "ctrapqi4"
7749   [(set (cc0)
7750         (compare (match_operand:QI 1 "nonimmediate_src_operand" "")
7751                  (match_operand:QI 2 "general_src_operand" "")))
7752    (trap_if (match_operator 0 "ordered_comparison_operator"
7753                             [(cc0) (const_int 0)])
7754             (match_operand:SI 3 "const1_operand" ""))]
7755   "TARGET_68020"
7756   "")
7758 (define_insn "*conditional_trap"
7759   [(trap_if (match_operator 0 "ordered_comparison_operator"
7760                             [(cc0) (const_int 0)])
7761             (match_operand:SI 1 "const1_operand" "I"))]
7762   "TARGET_68020 && ! flags_in_68881 ()"
7764   switch (GET_CODE (operands[0]))
7765   {
7766   case EQ:  return "trapeq";
7767   case NE:  return "trapne";
7768   case GT:  return "trapgt";
7769   case GTU: return "traphi";
7770   case LT:  return "traplt";
7771   case LTU: return "trapcs";
7772   case GE:  return "trapge";
7773   case GEU: return "trapcc";
7774   case LE:  return "traple";
7775   case LEU: return "trapls";
7776   default: gcc_unreachable ();
7777   }
7780 ;; These are to prevent the scheduler from moving stores to the frame
7781 ;; before the stack adjustment.
7782 (define_insn "stack_tie"
7783   [(set (mem:BLK (scratch))
7784         (unspec:BLK [(match_operand:SI 0 "register_operand" "r")
7785                      (match_operand:SI 1 "register_operand" "r")]
7786                     UNSPEC_TIE))]
7787   ""
7788   ""
7789   [(set_attr "type" "ignore")])
7791 ;; Instruction that subscribes one word in ColdFire instruction buffer.
7792 ;; This instruction is used within scheduler only and should not appear
7793 ;; in the instruction stream.
7794 (define_insn "ib"
7795   [(unspec [(const_int 0)] UNSPEC_IB)]
7796   ""
7797   "#"
7798   [(set_attr "type" "ib")])
7800 (include "cf.md")