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, 2009, 2012
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)
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.
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
59 ;;- Immediate integer operand constraints:
61 ;;- 'J' -32768 .. 32767
62 ;;- 'K' all integers EXCEPT -128 .. 127
64 ;;- 'M' all integers EXCEPT -256 .. 255
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
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
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
123 ;; UNSPEC_VOLATILE usage:
126 [(UNSPECV_BLOCKAGE 0)
133 ;; Registers by name.
144 (include "predicates.md")
145 (include "constraints.md")
147 ;; ::::::::::::::::::::
151 ;; ::::::::::::::::::::
154 (define_attr "cpu" "cfv1, cfv2, cfv3, cfv4, unknown"
155 (const (symbol_ref "m68k_sched_cpu")))
158 (define_attr "mac" "no, cf_mac, cf_emac"
159 (const (symbol_ref "m68k_sched_mac")))
161 ;; Instruction type for use in scheduling description.
162 ;; _l and _w suffixes indicate size of the operands of instruction.
163 ;; alu - usual arithmetic or logic instruction.
164 ;; aluq - arithmetic or logic instruction which has a quick immediate (the one
165 ;; that is encoded in the instruction word) for its Y operand.
166 ;; alux - Arithmetic instruction that uses carry bit (e.g., addx and subx).
167 ;; bcc - conditional branch.
168 ;; bitr - bit operation that only updates flags.
169 ;; bitrw - bit operation that updates flags and output operand.
170 ;; bra, bsr, clr, cmp, div, ext - corresponding instruction.
171 ;; falu, fbcc, fcmp, fdiv, fmove, fmul, fneg, fsqrt, ftst - corresponding
173 ;; ib - fake instruction to subscribe slots in ColdFire V1,V2,V3 instruction
175 ;; ignore - fake instruction.
176 ;; jmp, jsr, lea, link, mov3q, move, moveq, mul - corresponding instruction.
177 ;; mvsz - mvs or mvz instruction.
178 ;; neg, nop, pea, rts, scc - corresponding instruction.
179 ;; shift - arithmetic or logical shift instruction.
180 ;; trap, tst, unlk - corresponding instruction.
182 "alu_l,aluq_l,alux_l,bcc,bitr,bitrw,bra,bsr,clr,clr_l,cmp,cmp_l,
184 falu,fbcc,fcmp,fdiv,fmove,fmul,fneg,fsqrt,ftst,
186 jmp,jsr,lea,link,mov3q_l,move,move_l,moveq_l,mul_w,mul_l,mvsz,neg_l,nop,
190 (const_string "unknown"))
192 ;; Index of the X or Y operand in recog_data.operand[].
193 ;; Should be used only within opx_type and opy_type.
194 (define_attr "opx" "" (const_int 0))
195 (define_attr "opy" "" (const_int 1))
197 ;; Type of the Y operand.
198 ;; See m68k.c: enum attr_op_type.
199 (define_attr "opy_type"
200 "none,Rn,FPn,mem1,mem234,mem5,mem6,mem7,imm_q,imm_w,imm_l"
201 (cond [(eq_attr "type" "ext,fbcc,ftst,neg_l,bcc,bra,bsr,clr,clr_l,ib,ignore,
202 jmp,jsr,nop,rts,scc,trap,tst,tst_l,
203 unlk,unknown") (const_string "none")
204 (eq_attr "type" "lea,pea")
205 (symbol_ref "m68k_sched_attr_opy_type (insn, 1)")]
206 (symbol_ref "m68k_sched_attr_opy_type (insn, 0)")))
208 ;; Type of the X operand.
209 ;; See m68k.c: enum attr_op_type.
210 (define_attr "opx_type"
211 "none,Rn,FPn,mem1,mem234,mem5,mem6,mem7,imm_q,imm_w,imm_l"
212 (cond [(eq_attr "type" "ib,ignore,nop,rts,trap,unlk,
213 unknown") (const_string "none")
214 (eq_attr "type" "pea") (const_string "mem1")
215 (eq_attr "type" "jmp,jsr")
216 (symbol_ref "m68k_sched_attr_opx_type (insn, 1)")]
217 (symbol_ref "m68k_sched_attr_opx_type (insn, 0)")))
219 ;; Access to the X operand: none, read, write, read/write, unknown.
220 ;; Access to the Y operand is either none (if opy_type is none)
221 ;; or read otherwise.
222 (define_attr "opx_access" "none, r, w, rw"
223 (cond [(eq_attr "type" "ib,ignore,nop,rts,trap,unlk,
224 unknown") (const_string "none")
225 (eq_attr "type" "bcc,bra,bsr,bitr,cmp,cmp_l,fbcc,fcmp,ftst,
226 jmp,jsr,tst,tst_l") (const_string "r")
227 (eq_attr "type" "clr,clr_l,fneg,fmove,lea,
228 mov3q_l,move,move_l,moveq_l,mvsz,
229 pea,scc") (const_string "w")
230 (eq_attr "type" "alu_l,aluq_l,alux_l,bitrw,div_w,div_l,ext,
231 falu,fdiv,fmul,fsqrt,link,mul_w,mul_l,
232 neg_l,shift") (const_string "rw")]
233 ;; Should never be used.
234 (symbol_ref "(gcc_unreachable (), OPX_ACCESS_NONE)")))
236 ;; Memory accesses of the insn.
237 ;; 00 - no memory references
238 ;; 10 - memory is read
239 ;; i0 - indexed memory is read
240 ;; 01 - memory is written
241 ;; 0i - indexed memory is written
242 ;; 11 - memory is read, memory is written
243 ;; i1 - indexed memory is read, memory is written
244 ;; 1i - memory is read, indexed memory is written
245 (define_attr "op_mem" "00, 10, i0, 01, 0i, 11, i1, 1i"
246 (symbol_ref "m68k_sched_attr_op_mem (insn)"))
248 ;; Instruction size in words.
249 (define_attr "size" "1,2,3"
250 (symbol_ref "m68k_sched_attr_size (insn)"))
252 ;; Alternative is OK for ColdFire.
253 (define_attr "ok_for_coldfire" "yes,no" (const_string "yes"))
255 ;; Define 'enabled' attribute.
256 (define_attr "enabled" ""
257 (cond [(and (match_test "TARGET_COLDFIRE")
258 (eq_attr "ok_for_coldfire" "no"))
262 ;; Mode macros for integer operations.
263 (define_mode_iterator I [QI HI SI])
264 (define_mode_attr sz [(QI "%.b") (HI "%.w") (SI "%.l")])
266 ;; Mode macros for floating point operations.
267 ;; Valid floating point modes
268 (define_mode_iterator FP [SF DF (XF "TARGET_68881")])
269 ;; Mnemonic infix to round result
270 (define_mode_attr round [(SF "%$") (DF "%&") (XF "")])
271 ;; Mnemonic infix to round result for mul or div instruction
272 (define_mode_attr round_mul [(SF "sgl") (DF "%&") (XF "")])
273 ;; Suffix specifying source operand format
274 (define_mode_attr prec [(SF "s") (DF "d") (XF "x")])
275 ;; Allowable D registers
276 (define_mode_attr dreg [(SF "d") (DF "") (XF "")])
277 ;; Allowable 68881 constant constraints
278 (define_mode_attr const [(SF "F") (DF "G") (XF "")])
281 (define_insn_and_split "*movdf_internal"
282 [(set (match_operand:DF 0 "push_operand" "=m, m")
283 (match_operand:DF 1 "general_operand" "f, ro<>E"))]
288 "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 1)"
291 m68k_emit_move_double (operands);
294 [(set_attr "type" "fmove,*")])
296 (define_insn_and_split "pushdi"
297 [(set (match_operand:DI 0 "push_operand" "=m")
298 (match_operand:DI 1 "general_operand" "ro<>Fi"))]
301 "&& reload_completed"
304 m68k_emit_move_double (operands);
308 ;; We don't want to allow a constant operand for test insns because
309 ;; (set (cc0) (const_int foo)) has no mode information. Such insns will
310 ;; be folded while optimizing anyway.
314 (compare (match_operand:DI 0 "nonimmediate_operand" "am,d")
316 (clobber (match_scratch:SI 1 "=X,d"))
317 (clobber (match_scratch:DI 2 "=d,X"))]
320 if (which_alternative == 0)
324 xoperands[0] = operands[2];
325 xoperands[1] = operands[0];
326 output_move_double (xoperands);
327 cc_status.flags |= CC_REVERSED; /*|*/
328 return "neg%.l %R2\;negx%.l %2";
330 if (find_reg_note (insn, REG_DEAD, operands[0]))
332 cc_status.flags |= CC_REVERSED; /*|*/
333 return "neg%.l %R0\;negx%.l %0";
337 'sub' clears %1, and also clears the X cc bit
338 'tst' sets the Z cc bit according to the low part of the DImode operand
339 'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part.
341 return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
344 ;; If you think that the 68020 does not support tstl a0,
345 ;; reread page B-167 of the 68020 manual more carefully.
346 (define_insn "*tstsi_internal_68020_cf"
348 (compare (match_operand:SI 0 "nonimmediate_operand" "rm")
350 "TARGET_68020 || TARGET_COLDFIRE"
352 [(set_attr "type" "tst_l")])
354 ;; On an address reg, cmpw may replace cmpl.
355 (define_insn "*tstsi_internal"
357 (compare (match_operand:SI 0 "nonimmediate_operand" "dm,r")
359 "!(TARGET_68020 || TARGET_COLDFIRE)"
363 [(set_attr "type" "tst_l,cmp")])
365 ;; This can't use an address register, because comparisons
366 ;; with address registers as second operand always test the whole word.
367 (define_insn "*tsthi_internal"
369 (compare (match_operand:HI 0 "nonimmediate_operand" "dm")
373 [(set_attr "type" "tst")])
375 (define_insn "*tstqi_internal"
377 (compare (match_operand:QI 0 "nonimmediate_operand" "dm")
381 [(set_attr "type" "tst")])
383 (define_insn "tst<mode>_68881"
385 (compare (match_operand:FP 0 "general_operand" "f<FP:dreg>m")
386 (match_operand:FP 1 "const0_operand" "H")))]
389 cc_status.flags = CC_IN_68881;
390 if (FP_REG_P (operands[0]))
392 return "ftst%.<FP:prec> %0";
394 [(set_attr "type" "ftst")])
396 (define_insn "tst<mode>_cf"
398 (compare (match_operand:FP 0 "general_operand" "f<FP:dreg><Q>U")
399 (match_operand:FP 1 "const0_operand" "H")))]
400 "TARGET_COLDFIRE_FPU"
402 cc_status.flags = CC_IN_68881;
403 if (FP_REG_P (operands[0]))
405 return "ftst%.<FP:prec> %0";
407 [(set_attr "type" "ftst")])
410 ;; compare instructions.
412 (define_insn "*cmpdi_internal"
414 (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
415 (match_operand:DI 2 "general_operand" "d,0")))
416 (clobber (match_scratch:DI 0 "=d,d"))]
419 if (rtx_equal_p (operands[0], operands[1]))
420 return "sub%.l %R2,%R0\;subx%.l %2,%0";
423 cc_status.flags |= CC_REVERSED; /*|*/
424 return "sub%.l %R1,%R0\;subx%.l %1,%0";
430 (compare (match_operand:DI 0 "nonimmediate_operand")
431 (match_operand:DI 1 "general_operand")))
432 (clobber (match_scratch:DI 2))]
437 (define_expand "cbranchdi4"
439 (if_then_else (match_operator 0 "ordered_comparison_operator"
440 [(match_operand:DI 1 "nonimmediate_operand")
441 (match_operand:DI 2 "general_operand")])
442 (label_ref (match_operand 3 ""))
446 if (operands[2] == const0_rtx)
447 emit_insn (gen_tstdi (operands[1]));
449 emit_insn (gen_cmpdi (operands[1], operands[2]));
450 operands[1] = cc0_rtx;
451 operands[2] = const0_rtx;
454 (define_expand "cstoredi4"
455 [(set (match_operand:QI 0 "register_operand")
456 (match_operator:QI 1 "ordered_comparison_operator"
457 [(match_operand:DI 2 "nonimmediate_operand")
458 (match_operand:DI 3 "general_operand")]))]
461 if (operands[3] == const0_rtx)
462 emit_insn (gen_tstdi (operands[2]));
464 emit_insn (gen_cmpdi (operands[2], operands[3]));
465 operands[2] = cc0_rtx;
466 operands[3] = const0_rtx;
470 (define_expand "cbranchsi4"
472 (compare (match_operand:SI 1 "nonimmediate_operand" "")
473 (match_operand:SI 2 "general_operand" "")))
475 (if_then_else (match_operator 0 "ordered_comparison_operator"
476 [(cc0) (const_int 0)])
477 (label_ref (match_operand 3 ""))
482 (define_expand "cstoresi4"
484 (compare (match_operand:SI 2 "nonimmediate_operand" "")
485 (match_operand:SI 3 "general_operand" "")))
486 (set (match_operand:QI 0 "register_operand")
487 (match_operator:QI 1 "ordered_comparison_operator"
488 [(cc0) (const_int 0)]))]
493 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
496 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
497 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
500 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
501 return "cmpm%.l %1,%0";
502 if (REG_P (operands[1])
503 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
505 cc_status.flags |= CC_REVERSED; /*|*/
506 return "cmp%.l %d0,%d1";
508 if (ADDRESS_REG_P (operands[0])
509 && GET_CODE (operands[1]) == CONST_INT
510 && INTVAL (operands[1]) < 0x8000
511 && INTVAL (operands[1]) >= -0x8000)
512 return "cmp%.w %1,%0";
513 return "cmp%.l %d1,%d0";
516 (define_insn "*cmpsi_cf"
518 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
519 (match_operand:SI 1 "general_operand" "r,mrKs")))]
522 if (REG_P (operands[1])
523 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
525 cc_status.flags |= CC_REVERSED; /*|*/
526 return "cmp%.l %d0,%d1";
528 return "cmp%.l %d1,%d0";
530 [(set_attr "type" "cmp_l")])
532 (define_expand "cbranchhi4"
534 (compare (match_operand:HI 1 "nonimmediate_src_operand" "")
535 (match_operand:HI 2 "m68k_subword_comparison_operand" "")))
537 (if_then_else (match_operator 0 "ordered_comparison_operator"
538 [(cc0) (const_int 0)])
539 (label_ref (match_operand 3 ""))
544 (define_expand "cstorehi4"
546 (compare (match_operand:HI 2 "nonimmediate_operand" "")
547 (match_operand:HI 3 "m68k_subword_comparison_operand" "")))
548 (set (match_operand:QI 0 "register_operand")
549 (match_operator:QI 1 "ordered_comparison_operator"
550 [(cc0) (const_int 0)]))]
556 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
557 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
560 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
561 return "cmpm%.w %1,%0";
562 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
563 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
565 cc_status.flags |= CC_REVERSED; /*|*/
566 return "cmp%.w %d0,%d1";
568 return "cmp%.w %d1,%d0";
571 (define_expand "cbranchqi4"
573 (compare (match_operand:QI 1 "nonimmediate_src_operand" "")
574 (match_operand:QI 2 "m68k_subword_comparison_operand" "")))
576 (if_then_else (match_operator 0 "ordered_comparison_operator"
577 [(cc0) (const_int 0)])
578 (label_ref (match_operand 3 ""))
583 (define_expand "cstoreqi4"
585 (compare (match_operand:QI 2 "nonimmediate_src_operand" "")
586 (match_operand:QI 3 "m68k_subword_comparison_operand" "")))
587 (set (match_operand:QI 0 "register_operand")
588 (match_operator:QI 1 "ordered_comparison_operator"
589 [(cc0) (const_int 0)]))]
595 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
596 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
599 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
600 return "cmpm%.b %1,%0";
601 if (REG_P (operands[1])
602 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
604 cc_status.flags |= CC_REVERSED; /*|*/
605 return "cmp%.b %d0,%d1";
607 return "cmp%.b %d1,%d0";
610 (define_expand "cbranch<mode>4"
612 (compare (match_operand:FP 1 "register_operand" "")
613 (match_operand:FP 2 "fp_src_operand" "")))
615 (if_then_else (match_operator 0 "comparison_operator"
616 [(cc0) (const_int 0)])
617 (label_ref (match_operand 3 ""))
622 (define_expand "cstore<mode>4"
624 (compare (match_operand:FP 2 "register_operand" "")
625 (match_operand:FP 3 "fp_src_operand" "")))
626 (set (match_operand:QI 0 "register_operand")
627 (match_operator:QI 1 "m68k_cstore_comparison_operator"
628 [(cc0) (const_int 0)]))]
629 "TARGET_HARD_FLOAT && !(TUNE_68060 || TARGET_COLDFIRE_FPU)"
630 "if (TARGET_COLDFIRE && operands[2] != const0_rtx)
633 (define_insn "*cmp<mode>_68881"
635 (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg>mF")
636 (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg>mF,f")))]
638 && (register_operand (operands[0], <MODE>mode)
639 || register_operand (operands[1], <MODE>mode))"
642 fcmp%.<FP:prec> %f1,%0
643 fcmp%.<FP:prec> %0,%f1"
644 [(set_attr "type" "fcmp")])
646 (define_insn "*cmp<mode>_cf"
648 (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg><Q>U")
649 (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg><Q>U,f")))]
651 && (register_operand (operands[0], <MODE>mode)
652 || register_operand (operands[1], <MODE>mode))"
655 fcmp%.<FP:prec> %f1,%0
656 fcmp%.<FP:prec> %0,%f1"
657 [(set_attr "type" "fcmp")])
659 ;; Recognizers for btst instructions.
661 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
662 ;; specified as a constant, so we must disable all patterns that may extract
663 ;; from a MEM at a constant bit position if we can't use this as a constraint.
668 (compare (zero_extract:SI (match_operand:QI 0 "memory_src_operand" "oS")
670 (minus:SI (const_int 7)
671 (match_operand:SI 1 "general_operand" "di")))
675 return output_btst (operands, operands[1], operands[0], insn, 7);
678 ;; This is the same as the above pattern except for the constraints. The 'i'
684 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
686 (minus:SI (const_int 7)
687 (match_operand:SI 1 "general_operand" "d")))
691 return output_btst (operands, operands[1], operands[0], insn, 7);
697 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
699 (minus:SI (const_int 31)
700 (match_operand:SI 1 "general_operand" "di")))
704 return output_btst (operands, operands[1], operands[0], insn, 31);
707 ;; The following two patterns are like the previous two
708 ;; except that they use the fact that bit-number operands
709 ;; are automatically masked to 3 or 5 bits.
714 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
716 (minus:SI (const_int 7)
718 (match_operand:SI 1 "register_operand" "d")
723 return output_btst (operands, operands[1], operands[0], insn, 7);
729 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
731 (minus:SI (const_int 31)
733 (match_operand:SI 1 "register_operand" "d")
738 return output_btst (operands, operands[1], operands[0], insn, 31);
741 ;; Nonoffsettable mem refs are ok in this one pattern
742 ;; since we don't try to adjust them.
746 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "m")
748 (match_operand:SI 1 "const_int_operand" "n"))
750 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
752 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
753 return output_btst (operands, operands[1], operands[0], insn, 7);
759 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "do")
761 (match_operand:SI 1 "const_int_operand" "n"))
765 if (GET_CODE (operands[0]) == MEM)
767 operands[0] = adjust_address (operands[0], QImode,
768 INTVAL (operands[1]) / 8);
769 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
770 return output_btst (operands, operands[1], operands[0], insn, 7);
772 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
773 return output_btst (operands, operands[1], operands[0], insn, 31);
776 ;; This is the same as the above pattern except for the constraints.
777 ;; The 'o' has been replaced with 'Q'.
782 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "dQ")
784 (match_operand:SI 1 "const_int_operand" "n"))
788 if (GET_CODE (operands[0]) == MEM)
790 operands[0] = adjust_address (operands[0], QImode,
791 INTVAL (operands[1]) / 8);
792 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
793 return output_btst (operands, operands[1], operands[0], insn, 7);
795 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
796 return output_btst (operands, operands[1], operands[0], insn, 31);
802 ;; A special case in which it is not desirable
803 ;; to reload the constant into a data register.
804 (define_insn "pushexthisi_const"
805 [(set (match_operand:SI 0 "push_operand" "=m,m,m")
806 (match_operand:SI 1 "const_int_operand" "C0,R,J"))]
807 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
812 [(set_attr "type" "clr_l,mov3q_l,pea")])
815 ;(define_insn "swapsi"
816 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
817 ; (match_operand:SI 1 "general_operand" "+r"))
818 ; (set (match_dup 1) (match_dup 0))]
822 ;; Special case of fullword move when source is zero for 68000_10.
823 ;; moveq is faster on the 68000.
824 (define_insn "*movsi_const0_68000_10"
825 [(set (match_operand:SI 0 "movsi_const0_operand" "=d,a,g")
832 [(set_attr "type" "moveq_l,alu_l,clr_l")
833 (set_attr "opy" "*,0,*")])
835 ;; Special case of fullword move when source is zero for 68040_60.
836 ;; On the '040, 'subl an,an' takes 2 clocks while lea takes only 1
837 (define_insn "*movsi_const0_68040_60"
838 [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
842 if (which_alternative == 0)
843 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
844 else if (which_alternative == 1)
852 [(set_attr "type" "lea,clr_l")])
854 ;; Special case of fullword move when source is zero.
855 (define_insn "*movsi_const0"
856 [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
858 "!(TUNE_68000_10 || TUNE_68040_60)"
862 [(set_attr "type" "alu_l,clr_l")
863 (set_attr "opy" "0,*")])
865 ;; General case of fullword move.
867 ;; This is the main "hook" for PIC code. When generating
868 ;; PIC, movsi is responsible for determining when the source address
869 ;; needs PIC relocation and appropriately calling legitimize_pic_address
870 ;; to perform the actual relocation.
872 ;; In both the PIC and non-PIC cases the patterns generated will
873 ;; matched by the next define_insn.
874 (define_expand "movsi"
875 [(set (match_operand:SI 0 "" "")
876 (match_operand:SI 1 "" ""))]
879 rtx tmp, base, offset;
881 /* Recognize the case where operand[1] is a reference to thread-local
882 data and load its address to a register. */
883 if (!TARGET_PCREL && m68k_tls_reference_p (operands[1], false))
885 rtx tmp = operands[1];
888 if (GET_CODE (tmp) == CONST && GET_CODE (XEXP (tmp, 0)) == PLUS)
890 addend = XEXP (XEXP (tmp, 0), 1);
891 tmp = XEXP (XEXP (tmp, 0), 0);
894 gcc_assert (GET_CODE (tmp) == SYMBOL_REF);
895 gcc_assert (SYMBOL_REF_TLS_MODEL (tmp) != 0);
897 tmp = m68k_legitimize_tls_address (tmp);
905 reg = gen_reg_rtx (Pmode);
906 emit_move_insn (reg, tmp);
910 tmp = gen_rtx_PLUS (SImode, tmp, addend);
915 else if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
917 /* The source is an address which requires PIC relocation.
918 Call legitimize_pic_address with the source, mode, and a relocation
919 register (a new pseudo, or the final destination if reload_in_progress
920 is set). Then fall through normally */
921 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
922 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
924 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
926 /* Don't allow writes to memory except via a register;
927 the m68k doesn't consider PC-relative addresses to be writable. */
928 if (symbolic_operand (operands[0], SImode))
929 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
930 else if (GET_CODE (operands[0]) == MEM
931 && symbolic_operand (XEXP (operands[0], 0), SImode))
932 operands[0] = gen_rtx_MEM (SImode,
933 force_reg (SImode, XEXP (operands[0], 0)));
935 if (M68K_OFFSETS_MUST_BE_WITHIN_SECTIONS_P)
937 split_const (operands[1], &base, &offset);
938 if (GET_CODE (base) == SYMBOL_REF
939 && !offset_within_block_p (base, INTVAL (offset)))
941 tmp = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (SImode);
942 emit_move_insn (tmp, base);
943 emit_insn (gen_addsi3 (operands[0], tmp, offset));
949 ;; General case of fullword move.
950 (define_insn "*movsi_m68k"
951 ;; Notes: make sure no alternative allows g vs g.
952 ;; We don't allow f-regs since fixed point cannot go in them.
953 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
954 (match_operand:SI 1 "general_src_operand" "damSnT,n,i"))]
955 "!TARGET_COLDFIRE && reload_completed"
957 return output_move_simode (operands);
960 ;; Before reload is completed the register constraints
961 ;; force integer constants in range for a moveq to be reloaded
962 ;; if they are headed for memory.
963 (define_insn "*movsi_m68k2"
964 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
965 (match_operand:SI 1 "general_src_operand" "damSKT,n,i"))]
969 return output_move_simode (operands);
972 ;; ColdFire move instructions can have at most one operand of mode >= 6.
973 (define_insn "*movsi_cf"
974 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d, d, d, d, d, a,Ap, a, r<Q>,g, U")
975 (match_operand:SI 1 "general_operand" " R,CQ,CW,CZ,CS,Ci,J,J Cs,Cs, g, Rr<Q>,U"))]
978 switch (which_alternative)
981 return "mov3q%.l %1,%0";
984 return "moveq %1,%0";
988 unsigned u = INTVAL (operands[1]);
990 operands[1] = GEN_INT ((u << 16) | (u >> 16)); /*|*/
991 return "moveq %1,%0\n\tswap %0";
995 return "mvz%.w %1,%0";
998 return "mvs%.w %1,%0";
1001 return "move%.l %1,%0";
1004 return "move%.w %1,%0";
1010 return "lea %a1,%0";
1015 return "move%.l %1,%0";
1022 [(set_attr "type" "mov3q_l,moveq_l,*,mvsz,mvsz,move_l,move,pea,lea,move_l,move_l,move_l")])
1024 ;; Special case of fullword move, where we need to get a non-GOT PIC
1025 ;; reference into an address register.
1027 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
1028 (match_operand:SI 1 "pcrel_address" ""))]
1031 if (push_operand (operands[0], SImode))
1033 return "lea %a1,%0";
1036 (define_expand "movhi"
1037 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1038 (match_operand:HI 1 "general_operand" ""))]
1043 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
1044 (match_operand:HI 1 "general_src_operand" "gS"))]
1046 "* return output_move_himode (operands);")
1049 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
1050 (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
1052 "* return output_move_himode (operands);")
1054 (define_expand "movstricthi"
1055 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1056 (match_operand:HI 1 "general_src_operand" ""))]
1061 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
1062 (match_operand:HI 1 "general_src_operand" "rmSn"))]
1064 "* return output_move_stricthi (operands);")
1067 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
1068 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
1070 "* return output_move_stricthi (operands);")
1072 (define_expand "movqi"
1073 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1074 (match_operand:QI 1 "general_src_operand" ""))]
1079 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
1080 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
1082 "* return output_move_qimode (operands);")
1085 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
1086 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
1088 "* return output_move_qimode (operands);")
1090 (define_expand "movstrictqi"
1091 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1092 (match_operand:QI 1 "general_src_operand" ""))]
1097 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
1098 (match_operand:QI 1 "general_src_operand" "dmSn"))]
1100 "* return output_move_strictqi (operands);")
1102 (define_insn "*movstrictqi_cf"
1103 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d, Ac, d,m"))
1104 (match_operand:QI 1 "general_src_operand" "C0,C0, dmn,d"))]
1111 [(set_attr "type" "clr,clr,move,move")])
1113 (define_expand "pushqi1"
1114 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
1115 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
1116 (match_operand:QI 0 "general_operand" ""))]
1120 (define_expand "reload_insf"
1121 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1122 (match_operand:SF 1 "general_operand" "mf"))
1123 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1124 "TARGET_COLDFIRE_FPU"
1126 if (emit_move_sequence (operands, SFmode, operands[2]))
1129 /* We don't want the clobber emitted, so handle this ourselves. */
1130 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1134 (define_expand "reload_outsf"
1135 [(set (match_operand:SF 0 "general_operand" "")
1136 (match_operand:SF 1 "register_operand" "f"))
1137 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1138 "TARGET_COLDFIRE_FPU"
1140 if (emit_move_sequence (operands, SFmode, operands[2]))
1143 /* We don't want the clobber emitted, so handle this ourselves. */
1144 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1148 (define_expand "movsf"
1149 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1150 (match_operand:SF 1 "general_operand" ""))]
1155 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
1156 (match_operand:SF 1 "general_operand" "rmfF"))]
1159 if (FP_REG_P (operands[0]))
1161 if (FP_REG_P (operands[1]))
1162 return "f%$move%.x %1,%0";
1163 else if (ADDRESS_REG_P (operands[1]))
1164 return "move%.l %1,%-\;f%$move%.s %+,%0";
1165 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
1166 return output_move_const_single (operands);
1167 return "f%$move%.s %f1,%0";
1169 if (FP_REG_P (operands[1]))
1171 if (ADDRESS_REG_P (operands[0]))
1172 return "fmove%.s %1,%-\;move%.l %+,%0";
1173 return "fmove%.s %f1,%0";
1175 if (operands[1] == CONST0_RTX (SFmode)
1176 /* clr insns on 68000 read before writing. */
1177 && ((TARGET_68010 || TARGET_COLDFIRE)
1178 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
1180 if (ADDRESS_REG_P (operands[0]))
1182 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
1184 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
1186 return "sub%.l %0,%0";
1188 /* moveq is faster on the 68000. */
1189 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
1190 return "moveq #0,%0";
1193 return "move%.l %1,%0";
1196 (define_insn "movsf_cf_soft"
1197 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>,g,U")
1198 (match_operand:SF 1 "general_operand" "g,r<Q>,U"))]
1199 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1201 [(set_attr "type" "move_l")])
1203 ;; SFmode MEMs are restricted to modes 2-4 if TARGET_COLDFIRE_FPU.
1204 ;; The move instructions can handle all combinations.
1205 (define_insn "movsf_cf_hard"
1206 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f, f,mr,f,r<Q>,f
1208 (match_operand:SF 1 "general_operand" " f, r<Q>U,f,rm,F,F, m
1210 "TARGET_COLDFIRE_FPU"
1212 if (which_alternative == 4 || which_alternative == 5) {
1216 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1217 REAL_VALUE_TO_TARGET_SINGLE (r, l);
1218 xoperands[0] = operands[0];
1219 xoperands[1] = GEN_INT (l);
1220 if (which_alternative == 5) {
1222 if (ADDRESS_REG_P (xoperands[0]))
1223 output_asm_insn ("sub%.l %0,%0", xoperands);
1225 output_asm_insn ("clr%.l %0", xoperands);
1227 if (GET_CODE (operands[0]) == MEM
1228 && symbolic_operand (XEXP (operands[0], 0), SImode))
1229 output_asm_insn ("move%.l %1,%-;move%.l %+,%0", xoperands);
1231 output_asm_insn ("move%.l %1,%0", xoperands);
1235 output_asm_insn ("move%.l %1,%-;fsmove%.s %+,%0", xoperands);
1237 output_asm_insn ("clr%.l %-;fsmove%.s %+,%0", xoperands);
1240 if (FP_REG_P (operands[0]))
1242 if (ADDRESS_REG_P (operands[1]))
1243 return "move%.l %1,%-;fsmove%.s %+,%0";
1244 if (FP_REG_P (operands[1]))
1245 return "fsmove%.d %1,%0";
1246 return "fsmove%.s %f1,%0";
1248 if (FP_REG_P (operands[1]))
1250 if (ADDRESS_REG_P (operands[0]))
1251 return "fmove%.s %1,%-;move%.l %+,%0";
1252 return "fmove%.s %f1,%0";
1254 if (operands[1] == CONST0_RTX (SFmode))
1256 if (ADDRESS_REG_P (operands[0]))
1257 return "sub%.l %0,%0";
1260 return "move%.l %1,%0";
1263 (define_expand "reload_indf"
1264 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1265 (match_operand:DF 1 "general_operand" "mf"))
1266 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1267 "TARGET_COLDFIRE_FPU"
1269 if (emit_move_sequence (operands, DFmode, operands[2]))
1272 /* We don't want the clobber emitted, so handle this ourselves. */
1273 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1277 (define_expand "reload_outdf"
1278 [(set (match_operand:DF 0 "general_operand" "")
1279 (match_operand:DF 1 "register_operand" "f"))
1280 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1281 "TARGET_COLDFIRE_FPU"
1283 if (emit_move_sequence (operands, DFmode, operands[2]))
1286 /* We don't want the clobber emitted, so handle this ourselves. */
1287 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1291 (define_expand "movdf"
1292 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1293 (match_operand:DF 1 "general_operand" ""))]
1296 if (TARGET_COLDFIRE_FPU)
1297 if (emit_move_sequence (operands, DFmode, 0))
1302 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
1303 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
1304 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
1305 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
1308 if (FP_REG_P (operands[0]))
1310 if (FP_REG_P (operands[1]))
1311 return "f%&move%.x %1,%0";
1312 if (REG_P (operands[1]))
1315 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1316 output_asm_insn ("move%.l %1,%-", xoperands);
1317 output_asm_insn ("move%.l %1,%-", operands);
1318 return "f%&move%.d %+,%0";
1320 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1321 return output_move_const_double (operands);
1322 return "f%&move%.d %f1,%0";
1324 else if (FP_REG_P (operands[1]))
1326 if (REG_P (operands[0]))
1328 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1329 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1330 return "move%.l %+,%0";
1333 return "fmove%.d %f1,%0";
1335 return output_move_double (operands);
1338 (define_insn_and_split "movdf_cf_soft"
1339 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
1340 (match_operand:DF 1 "general_operand" "g,r"))]
1341 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1343 "&& reload_completed"
1346 m68k_emit_move_double (operands);
1350 (define_insn "movdf_cf_hard"
1351 [(set (match_operand:DF 0 "nonimmediate_operand" "=f, <Q>U,r,f,r,r,m,f")
1352 (match_operand:DF 1 "general_operand" " f<Q>U,f, f,r,r,m,r,E"))]
1353 "TARGET_COLDFIRE_FPU"
1359 switch (which_alternative)
1362 return "fdmove%.d %1,%0";
1364 return "fmove%.d %1,%0";
1366 return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1368 return "move%.l %R1,%-;move%.l %1,%-;fdmove%.d %+,%0";
1369 case 4: case 5: case 6:
1370 return output_move_double (operands);
1372 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1373 REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1374 xoperands[0] = operands[0];
1375 xoperands[1] = GEN_INT (l[0]);
1376 xoperands[2] = GEN_INT (l[1]);
1377 if (operands[1] == CONST0_RTX (DFmode))
1378 output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1382 output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1385 output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1391 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1392 ;; allowed. Most but not all have predicates and constraint that disallow
1393 ;; constants. Most but not all have output templates that handle constants.
1394 ;; See also TARGET_LEGITIMATE_CONSTANT_P.
1396 (define_expand "movxf"
1397 [(set (match_operand:XF 0 "nonimmediate_operand" "")
1398 (match_operand:XF 1 "general_operand" ""))]
1401 /* We can't rewrite operands during reload. */
1402 if (! reload_in_progress)
1404 if (CONSTANT_P (operands[1]))
1406 operands[1] = force_const_mem (XFmode, operands[1]);
1407 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1408 operands[1] = adjust_address (operands[1], XFmode, 0);
1410 if (flag_pic && TARGET_PCREL)
1412 /* Don't allow writes to memory except via a register; the
1413 m68k doesn't consider PC-relative addresses to be writable. */
1414 if (GET_CODE (operands[0]) == MEM
1415 && symbolic_operand (XEXP (operands[0], 0), SImode))
1416 operands[0] = gen_rtx_MEM (XFmode,
1417 force_reg (SImode, XEXP (operands[0], 0)));
1423 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1424 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1427 if (FP_REG_P (operands[0]))
1429 if (FP_REG_P (operands[1]))
1430 return "fmove%.x %1,%0";
1431 if (REG_P (operands[1]))
1434 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1435 output_asm_insn ("move%.l %1,%-", xoperands);
1436 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1437 output_asm_insn ("move%.l %1,%-", xoperands);
1438 output_asm_insn ("move%.l %1,%-", operands);
1439 return "fmove%.x %+,%0";
1441 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1442 return "fmove%.x %1,%0";
1443 return "fmove%.x %f1,%0";
1445 if (FP_REG_P (operands[1]))
1447 if (REG_P (operands[0]))
1449 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1450 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1451 output_asm_insn ("move%.l %+,%0", operands);
1452 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1453 return "move%.l %+,%0";
1455 /* Must be memory destination. */
1456 return "fmove%.x %f1,%0";
1458 return output_move_double (operands);
1462 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1463 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1464 "! TARGET_68881 && ! TARGET_COLDFIRE"
1466 if (FP_REG_P (operands[0]))
1468 if (FP_REG_P (operands[1]))
1469 return "fmove%.x %1,%0";
1470 if (REG_P (operands[1]))
1473 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1474 output_asm_insn ("move%.l %1,%-", xoperands);
1475 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1476 output_asm_insn ("move%.l %1,%-", xoperands);
1477 output_asm_insn ("move%.l %1,%-", operands);
1478 return "fmove%.x %+,%0";
1480 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1481 return "fmove%.x %1,%0";
1482 return "fmove%.x %f1,%0";
1484 if (FP_REG_P (operands[1]))
1486 if (REG_P (operands[0]))
1488 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1489 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1490 output_asm_insn ("move%.l %+,%0", operands);
1491 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1492 return "move%.l %+,%0";
1495 return "fmove%.x %f1,%0";
1497 return output_move_double (operands);
1501 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1502 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1503 "! TARGET_68881 && TARGET_COLDFIRE"
1504 "* return output_move_double (operands);")
1506 (define_expand "movdi"
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" "")
1509 (match_operand:DI 1 "general_operand" ""))]
1513 ;; movdi can apply to fp regs in some cases
1515 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1516 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1517 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1518 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1519 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1520 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1521 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1524 if (FP_REG_P (operands[0]))
1526 if (FP_REG_P (operands[1]))
1527 return "fmove%.x %1,%0";
1528 if (REG_P (operands[1]))
1531 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1532 output_asm_insn ("move%.l %1,%-", xoperands);
1533 output_asm_insn ("move%.l %1,%-", operands);
1534 return "fmove%.d %+,%0";
1536 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1537 return output_move_const_double (operands);
1538 return "fmove%.d %f1,%0";
1540 else if (FP_REG_P (operands[1]))
1542 if (REG_P (operands[0]))
1544 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1545 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1546 return "move%.l %+,%0";
1549 return "fmove%.d %f1,%0";
1551 return output_move_double (operands);
1555 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1556 (match_operand:DI 1 "general_operand" "g,r"))]
1558 "* return output_move_double (operands);")
1560 ;; Thus goes after the move instructions
1561 ;; because the move instructions are better (require no spilling)
1562 ;; when they can apply. It goes before the add/sub insns
1563 ;; so we will prefer it to them.
1565 (define_insn "pushasi"
1566 [(set (match_operand:SI 0 "push_operand" "=m")
1567 (match_operand:SI 1 "address_operand" "p"))]
1570 [(set_attr "type" "pea")])
1572 ;; truncation instructions
1573 (define_insn "truncsiqi2"
1574 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1576 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1579 if (GET_CODE (operands[0]) == REG)
1581 /* Must clear condition codes, since the move.l bases them on
1582 the entire 32 bits, not just the desired 8 bits. */
1584 return "move%.l %1,%0";
1586 if (GET_CODE (operands[1]) == MEM)
1587 operands[1] = adjust_address (operands[1], QImode, 3);
1588 return "move%.b %1,%0";
1591 (define_insn "trunchiqi2"
1592 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1594 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1597 if (GET_CODE (operands[0]) == REG
1598 && (GET_CODE (operands[1]) == MEM
1599 || GET_CODE (operands[1]) == CONST_INT))
1601 /* Must clear condition codes, since the move.w bases them on
1602 the entire 16 bits, not just the desired 8 bits. */
1604 return "move%.w %1,%0";
1606 if (GET_CODE (operands[0]) == REG)
1608 /* Must clear condition codes, since the move.l bases them on
1609 the entire 32 bits, not just the desired 8 bits. */
1611 return "move%.l %1,%0";
1613 if (GET_CODE (operands[1]) == MEM)
1614 operands[1] = adjust_address (operands[1], QImode, 1);
1615 return "move%.b %1,%0";
1618 (define_insn "truncsihi2"
1619 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1621 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1624 if (GET_CODE (operands[0]) == REG)
1626 /* Must clear condition codes, since the move.l bases them on
1627 the entire 32 bits, not just the desired 8 bits. */
1629 return "move%.l %1,%0";
1631 if (GET_CODE (operands[1]) == MEM)
1632 operands[1] = adjust_address (operands[1], QImode, 2);
1633 return "move%.w %1,%0";
1636 ;; zero extension instructions
1638 ;; two special patterns to match various post_inc/pre_dec patterns
1639 (define_insn_and_split "*zero_extend_inc"
1640 [(set (match_operand 0 "post_inc_operand" "")
1641 (zero_extend (match_operand 1 "register_operand" "")))]
1642 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1643 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1644 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1652 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1655 (define_insn_and_split "*zero_extend_dec"
1656 [(set (match_operand 0 "pre_dec_operand" "")
1657 (zero_extend (match_operand 1 "register_operand" "")))]
1658 "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1659 GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1660 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1661 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1669 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1672 (define_insn_and_split "zero_extendqidi2"
1673 [(set (match_operand:DI 0 "register_operand" "")
1674 (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1679 (zero_extend:SI (match_dup 1)))
1683 operands[2] = gen_lowpart (SImode, operands[0]);
1684 operands[3] = gen_highpart (SImode, operands[0]);
1687 (define_insn_and_split "zero_extendhidi2"
1688 [(set (match_operand:DI 0 "register_operand" "")
1689 (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1694 (zero_extend:SI (match_dup 1)))
1698 operands[2] = gen_lowpart (SImode, operands[0]);
1699 operands[3] = gen_highpart (SImode, operands[0]);
1702 (define_expand "zero_extendsidi2"
1703 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1704 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1707 if (GET_CODE (operands[0]) == MEM
1708 && GET_CODE (operands[1]) == MEM)
1709 operands[1] = force_reg (SImode, operands[1]);
1712 (define_insn_and_split "*zero_extendsidi2"
1713 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1714 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1715 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1723 operands[2] = gen_lowpart (SImode, operands[0]);
1724 operands[3] = gen_highpart (SImode, operands[0]);
1727 (define_insn "*zero_extendhisi2_cf"
1728 [(set (match_operand:SI 0 "register_operand" "=d")
1729 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1732 [(set_attr "type" "mvsz")])
1734 (define_insn "zero_extendhisi2"
1735 [(set (match_operand:SI 0 "register_operand" "=d")
1736 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1740 (define_expand "zero_extendqihi2"
1741 [(set (match_operand:HI 0 "register_operand" "")
1742 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1746 (define_insn "*zero_extendqihi2"
1747 [(set (match_operand:HI 0 "register_operand" "=d")
1748 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1752 (define_insn "*zero_extendqisi2_cfv4"
1753 [(set (match_operand:SI 0 "register_operand" "=d")
1754 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1757 [(set_attr "type" "mvsz")])
1759 (define_insn "zero_extendqisi2"
1760 [(set (match_operand:SI 0 "register_operand" "=d")
1761 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1765 ;; these two pattern split everything else which isn't matched by
1766 ;; something else above
1768 [(set (match_operand 0 "register_operand" "")
1769 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1772 && reg_mentioned_p (operands[0], operands[1])"
1773 [(set (strict_low_part (match_dup 2))
1776 (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1778 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1779 operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1780 operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1784 [(set (match_operand 0 "register_operand" "")
1785 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1786 "!ISA_HAS_MVS_MVZ && reload_completed"
1789 (set (strict_low_part (match_dup 2))
1792 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1795 ;; sign extension instructions
1797 (define_insn "extendqidi2"
1798 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1799 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1803 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1804 if (ISA_HAS_MVS_MVZ)
1805 return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1806 if (TARGET_68020 || TARGET_COLDFIRE)
1808 if (ADDRESS_REG_P (operands[1]))
1809 return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1811 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1815 if (ADDRESS_REG_P (operands[1]))
1816 return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1818 return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1822 (define_insn "extendhidi2"
1823 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1825 (match_operand:HI 1 "general_src_operand" "rmS")))]
1829 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1830 if (ISA_HAS_MVS_MVZ)
1831 return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1832 if (TARGET_68020 || TARGET_COLDFIRE)
1833 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1835 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1838 (define_insn "extendsidi2"
1839 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o,o,<")
1841 (match_operand:SI 1 "nonimmediate_src_operand" "rm,rm,r<Q>,rm")))
1842 (clobber (match_scratch:SI 2 "=X,d,d,d"))]
1847 if (which_alternative == 0)
1848 /* Handle alternative 0. */
1850 if (TARGET_68020 || TARGET_COLDFIRE)
1851 return "move%.l %1,%R0\;smi %0\;extb%.l %0";
1853 return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
1856 /* Handle alternatives 1, 2 and 3. We don't need to adjust address by 4
1857 in alternative 3 because autodecrement will do that for us. */
1858 operands[3] = adjust_address (operands[0], SImode,
1859 which_alternative == 3 ? 0 : 4);
1860 operands[0] = adjust_address (operands[0], SImode, 0);
1862 if (TARGET_68020 || TARGET_COLDFIRE)
1863 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
1865 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
1867 [(set_attr "ok_for_coldfire" "yes,no,yes,yes")])
1869 ;; Special case when one can avoid register clobbering, copy and test
1870 ;; Maybe there is a way to make that the general case, by forcing the
1871 ;; result of the SI tree to be in the lower register of the DI target
1873 (define_insn "extendplussidi"
1874 [(set (match_operand:DI 0 "register_operand" "=d")
1875 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rmn")
1876 (match_operand:SI 2 "general_operand" "rmn"))))]
1880 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1881 if (GET_CODE (operands[1]) == CONST_INT
1882 && (unsigned) INTVAL (operands[1]) > 8)
1884 rtx tmp = operands[1];
1886 operands[1] = operands[2];
1889 if (GET_CODE (operands[1]) == REG
1890 && REGNO (operands[1]) == REGNO (operands[3]))
1891 output_asm_insn ("add%.l %2,%3", operands);
1893 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1894 if (TARGET_68020 || TARGET_COLDFIRE)
1895 return "smi %0\;extb%.l %0";
1897 return "smi %0\;ext%.w %0\;ext%.l %0";
1900 (define_expand "extendhisi2"
1901 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1903 (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1907 (define_insn "*cfv4_extendhisi2"
1908 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1910 (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1913 [(set_attr "type" "mvsz")])
1915 (define_insn "*68k_extendhisi2"
1916 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1918 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1923 [(set_attr "type" "ext,move")])
1925 (define_insn "extendqihi2"
1926 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1927 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1930 [(set_attr "type" "ext")])
1932 (define_expand "extendqisi2"
1933 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1934 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1935 "TARGET_68020 || TARGET_COLDFIRE"
1938 (define_insn "*cfv4_extendqisi2"
1939 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1940 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1943 [(set_attr "type" "mvsz")])
1945 (define_insn "*68k_extendqisi2"
1946 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1947 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1948 "TARGET_68020 || (TARGET_COLDFIRE && !ISA_HAS_MVS_MVZ)"
1950 [(set_attr "type" "ext")])
1952 ;; Conversions between float and double.
1954 (define_expand "extendsfdf2"
1955 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1957 (match_operand:SF 1 "general_operand" "")))]
1962 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1964 (match_operand:SF 1 "general_operand" "f,dmF")))]
1967 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1969 if (REGNO (operands[0]) == REGNO (operands[1]))
1971 /* Extending float to double in an fp-reg is a no-op.
1972 NOTICE_UPDATE_CC has already assumed that the
1973 cc will be set. So cancel what it did. */
1974 cc_status = cc_prev_status;
1977 return "f%&move%.x %1,%0";
1979 if (FP_REG_P (operands[0]))
1980 return "f%&move%.s %f1,%0";
1981 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1983 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1984 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1985 return "move%.l %+,%0";
1987 return "fmove%.d %f1,%0";
1990 (define_insn "extendsfdf2_cf"
1991 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
1993 (match_operand:SF 1 "general_operand" "f,<Q>U")))]
1994 "TARGET_COLDFIRE_FPU"
1996 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1998 if (REGNO (operands[0]) == REGNO (operands[1]))
2000 /* Extending float to double in an fp-reg is a no-op.
2001 NOTICE_UPDATE_CC has already assumed that the
2002 cc will be set. So cancel what it did. */
2003 cc_status = cc_prev_status;
2006 return "fdmove%.d %1,%0";
2008 return "fdmove%.s %f1,%0";
2011 ;; This cannot output into an f-reg because there is no way to be
2012 ;; sure of truncating in that case.
2013 (define_expand "truncdfsf2"
2014 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2016 (match_operand:DF 1 "general_operand" "")))]
2020 ;; On the '040 we can truncate in a register accurately and easily.
2022 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2024 (match_operand:DF 1 "general_operand" "fmG")))]
2025 "TARGET_68881 && TARGET_68040"
2027 if (FP_REG_P (operands[1]))
2028 return "f%$move%.x %1,%0";
2029 return "f%$move%.d %f1,%0";
2032 (define_insn "truncdfsf2_cf"
2033 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
2035 (match_operand:DF 1 "general_operand" "<Q>U,f")))]
2036 "TARGET_COLDFIRE_FPU"
2040 [(set_attr "type" "fmove")])
2042 (define_insn "*truncdfsf2_68881"
2043 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
2045 (match_operand:DF 1 "general_operand" "f")))]
2048 [(set_attr "type" "fmove")])
2050 ;; Conversion between fixed point and floating point.
2051 ;; Note that among the fix-to-float insns
2052 ;; the ones that start with SImode come first.
2053 ;; That is so that an operand that is a CONST_INT
2054 ;; (and therefore lacks a specific machine mode).
2055 ;; will be recognized as SImode (which is always valid)
2056 ;; rather than as QImode or HImode.
2058 (define_expand "floatsi<mode>2"
2059 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2060 (float:FP (match_operand:SI 1 "general_operand" "")))]
2064 (define_insn "floatsi<mode>2_68881"
2065 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2066 (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
2068 "f<FP:round>move%.l %1,%0"
2069 [(set_attr "type" "fmove")])
2071 (define_insn "floatsi<mode>2_cf"
2072 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2073 (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
2074 "TARGET_COLDFIRE_FPU"
2075 "f<FP:prec>move%.l %1,%0"
2076 [(set_attr "type" "fmove")])
2079 (define_expand "floathi<mode>2"
2080 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2081 (float:FP (match_operand:HI 1 "general_operand" "")))]
2085 (define_insn "floathi<mode>2_68881"
2086 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2087 (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
2090 [(set_attr "type" "fmove")])
2092 (define_insn "floathi<mode>2_cf"
2093 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2094 (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
2095 "TARGET_COLDFIRE_FPU"
2097 [(set_attr "type" "fmove")])
2100 (define_expand "floatqi<mode>2"
2101 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2102 (float:FP (match_operand:QI 1 "general_operand" "")))]
2106 (define_insn "floatqi<mode>2_68881"
2107 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2108 (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
2111 [(set_attr "type" "fmove")])
2113 (define_insn "floatqi<mode>2_cf"
2114 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2115 (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
2116 "TARGET_COLDFIRE_FPU"
2118 [(set_attr "type" "fmove")])
2121 ;; New routines to convert floating-point values to integers
2122 ;; to be used on the '040. These should be faster than trapping
2123 ;; into the kernel to emulate fintrz. They should also be faster
2124 ;; than calling the subroutines fixsfsi or fixdfsi.
2126 (define_insn "fix_truncdfsi2"
2127 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2128 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2129 (clobber (match_scratch:SI 2 "=d"))
2130 (clobber (match_scratch:SI 3 "=d"))]
2131 "TARGET_68881 && TUNE_68040"
2134 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,%!";
2137 (define_insn "fix_truncdfhi2"
2138 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2139 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2140 (clobber (match_scratch:SI 2 "=d"))
2141 (clobber (match_scratch:SI 3 "=d"))]
2142 "TARGET_68881 && TUNE_68040"
2145 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,%!";
2148 (define_insn "fix_truncdfqi2"
2149 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2150 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2151 (clobber (match_scratch:SI 2 "=d"))
2152 (clobber (match_scratch:SI 3 "=d"))]
2153 "TARGET_68881 && TUNE_68040"
2156 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,%!";
2159 ;; Convert a float to a float whose value is an integer.
2160 ;; This is the first stage of converting it to an integer type.
2162 (define_expand "ftrunc<mode>2"
2163 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2164 (fix:FP (match_operand:FP 1 "general_operand" "")))]
2165 "TARGET_HARD_FLOAT && !TUNE_68040"
2168 (define_insn "ftrunc<mode>2_68881"
2169 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2170 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
2171 "TARGET_68881 && !TUNE_68040"
2173 if (FP_REG_P (operands[1]))
2174 return "fintrz%.x %f1,%0";
2175 return "fintrz%.<FP:prec> %f1,%0";
2177 [(set_attr "type" "falu")])
2179 (define_insn "ftrunc<mode>2_cf"
2180 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2181 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
2182 "TARGET_COLDFIRE_FPU"
2184 if (FP_REG_P (operands[1]))
2185 return "fintrz%.d %f1,%0";
2186 return "fintrz%.<FP:prec> %f1,%0";
2188 [(set_attr "type" "falu")])
2190 ;; Convert a float whose value is an integer
2191 ;; to an actual integer. Second stage of converting float to integer type.
2192 (define_expand "fix<mode>qi2"
2193 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2194 (fix:QI (match_operand:FP 1 "general_operand" "")))]
2198 (define_insn "fix<mode>qi2_68881"
2199 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2200 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2203 [(set_attr "type" "fmove")])
2205 (define_insn "fix<mode>qi2_cf"
2206 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
2207 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2208 "TARGET_COLDFIRE_FPU"
2210 [(set_attr "type" "fmove")])
2212 (define_expand "fix<mode>hi2"
2213 [(set (match_operand:HI 0 "nonimmediate_operand" "")
2214 (fix:HI (match_operand:FP 1 "general_operand" "")))]
2218 (define_insn "fix<mode>hi2_68881"
2219 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2220 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2223 [(set_attr "type" "fmove")])
2225 (define_insn "fix<mode>hi2_cf"
2226 [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
2227 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2228 "TARGET_COLDFIRE_FPU"
2230 [(set_attr "type" "fmove")])
2232 (define_expand "fix<mode>si2"
2233 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2234 (fix:SI (match_operand:FP 1 "general_operand" "")))]
2238 (define_insn "fix<mode>si2_68881"
2239 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2240 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2243 [(set_attr "type" "fmove")])
2245 (define_insn "fix<mode>si2_cf"
2246 [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
2247 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2248 "TARGET_COLDFIRE_FPU"
2250 [(set_attr "type" "fmove")])
2255 (define_insn "adddi_lshrdi_63"
2256 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
2257 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
2260 (clobber (match_scratch:SI 2 "=d"))]
2263 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2264 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
2266 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
2267 if (GET_CODE (operands[1]) == REG)
2268 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2269 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
2270 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2271 operands[4] = operands[1];
2273 operands[4] = adjust_address (operands[1], SImode, 4);
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 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
2278 if (TARGET_68020 || TARGET_COLDFIRE)
2279 output_asm_insn ("extb%.l %2", operands);
2281 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
2282 if (GET_CODE (operands[1]) != MEM
2283 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
2284 output_asm_insn ("move%.l %4,%3", operands);
2285 return "sub%.l %2,%3\;subx%.l %2,%0";
2288 (define_insn "adddi_sexthishl32"
2289 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2290 (plus:DI (ashift:DI (sign_extend:DI
2291 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
2293 (match_operand:DI 2 "general_operand" "0,0,0,0")))
2294 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2298 if (ADDRESS_REG_P (operands[0]))
2299 return "add%.w %1,%0";
2300 else if (ADDRESS_REG_P (operands[3]))
2301 return "move%.w %1,%3\;add%.l %3,%0";
2303 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
2306 (define_insn "*adddi_dilshr32"
2307 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
2308 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
2310 (match_operand:DI 2 "general_operand" "0,0")))]
2314 if (GET_CODE (operands[0]) == REG)
2315 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2317 operands[2] = adjust_address (operands[0], SImode, 4);
2318 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
2321 (define_insn "*adddi_dilshr32_cf"
2322 [(set (match_operand:DI 0 "register_operand" "=d")
2323 (plus:DI (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
2325 (match_operand:DI 2 "register_operand" "0")))]
2329 return "add%.l %1,%R0\;negx%.l %0\;neg%.l %0";
2332 (define_insn "adddi_dishl32"
2333 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
2334 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
2335 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2336 ;; (const_int 32))))]
2337 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
2339 (match_operand:DI 2 "general_operand" "0,0")))]
2343 if (GET_CODE (operands[1]) == REG)
2344 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2346 operands[1] = adjust_address (operands[1], SImode, 4);
2347 return "add%.l %1,%0";
2349 [(set_attr "type" "alu_l")])
2351 (define_insn "adddi3"
2352 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2353 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0")
2354 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2355 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2358 if (DATA_REG_P (operands[0]))
2360 if (DATA_REG_P (operands[2]))
2361 return "add%.l %R2,%R0\;addx%.l %2,%0";
2362 else if (GET_CODE (operands[2]) == MEM
2363 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2364 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
2370 if (GET_CODE (operands[2]) == REG)
2372 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2375 else if (CONSTANT_P (operands[2]))
2376 split_double (operands[2], &high, &low);
2379 low = adjust_address (operands[2], SImode, 4);
2383 operands[1] = low, operands[2] = high;
2384 xoperands[0] = operands[3];
2385 if (GET_CODE (operands[1]) == CONST_INT
2386 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2387 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2389 xoperands[1] = operands[2];
2391 output_asm_insn (output_move_simode (xoperands), xoperands);
2392 if (GET_CODE (operands[1]) == CONST_INT)
2394 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2395 return "addq%.l %1,%R0\;addx%.l %3,%0";
2396 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2398 operands[1] = GEN_INT (-INTVAL (operands[1]));
2399 return "subq%.l %1,%R0\;subx%.l %3,%0";
2402 return "add%.l %1,%R0\;addx%.l %3,%0";
2407 gcc_assert (GET_CODE (operands[0]) == MEM);
2409 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2411 operands[1] = gen_rtx_MEM (SImode,
2412 plus_constant (Pmode,
2413 XEXP(operands[0], 0), -8));
2414 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2416 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2418 operands[1] = XEXP(operands[0], 0);
2419 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2423 operands[1] = adjust_address (operands[0], SImode, 4);
2424 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2429 (define_insn "addsi_lshrsi_31"
2430 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,dm,d<Q>")
2431 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm,r<Q>,rm")
2436 operands[2] = operands[0];
2437 operands[3] = gen_label_rtx();
2438 if (GET_CODE (operands[0]) == MEM)
2440 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2441 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2442 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2443 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2445 output_asm_insn ("move%.l %1,%0", operands);
2446 output_asm_insn ("jpl %l3", operands);
2447 output_asm_insn ("addq%.l #1,%2", operands);
2448 (*targetm.asm_out.internal_label) (asm_out_file, "L",
2449 CODE_LABEL_NUMBER (operands[3]));
2452 [(set_attr "ok_for_coldfire" "no,yes,yes")])
2454 (define_expand "addsi3"
2455 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2456 (plus:SI (match_operand:SI 1 "general_operand" "")
2457 (match_operand:SI 2 "general_src_operand" "")))]
2461 ;; Note that the middle two alternatives are near-duplicates
2462 ;; in order to handle insns generated by reload.
2463 ;; This is needed since they are not themselves reloaded,
2464 ;; so commutativity won't apply to them.
2465 (define_insn "*addsi3_internal"
2466 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2467 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2468 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2472 "* return output_addsi3 (operands);")
2474 (define_insn_and_split "*addsi3_5200"
2475 [(set (match_operand:SI 0 "nonimmediate_operand" "=mr,mr,a, m,r, ?a, ?a,?a,?a")
2476 (plus:SI (match_operand:SI 1 "general_operand" "%0, 0, 0, 0,0, a, a, r, a")
2477 (match_operand:SI 2 "general_src_operand" " I, L, JCu,d,mrKi,Cj, r, a, JCu")))]
2480 switch (which_alternative)
2483 return "addq%.l %2,%0";
2486 operands[2] = GEN_INT (- INTVAL (operands[2]));
2487 return "subq%.l %2,%0";
2491 return "add%.l %2,%0";
2494 /* move%.l %2,%0\n\tadd%.l %1,%0 */
2498 return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0";
2501 return MOTOROLA ? "lea (%2,%1.l),%0" : "lea %2@(0,%1:l),%0";
2505 return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
2512 "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 5) && !operands_match_p (operands[0], operands[1])"
2516 (plus:SI (match_dup 0)
2519 [(set_attr "type" "aluq_l,aluq_l,lea, alu_l,alu_l,*,lea, lea, lea")
2520 (set_attr "opy" "2, 2, *, 2, 2, *,*, *, *")
2521 (set_attr "opy_type" "*, *, mem5,*, *, *,mem6,mem6,mem5")])
2524 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2525 (plus:SI (match_operand:SI 1 "general_operand" "0")
2527 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2531 (define_insn "addhi3"
2532 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2533 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2534 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2537 if (GET_CODE (operands[2]) == CONST_INT)
2539 /* If the constant would be a negative number when interpreted as
2540 HImode, make it negative. This is usually, but not always, done
2541 elsewhere in the compiler. First check for constants out of range,
2542 which could confuse us. */
2544 if (INTVAL (operands[2]) >= 32768)
2545 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2547 if (INTVAL (operands[2]) > 0
2548 && INTVAL (operands[2]) <= 8)
2549 return "addq%.w %2,%0";
2550 if (INTVAL (operands[2]) < 0
2551 && INTVAL (operands[2]) >= -8)
2553 operands[2] = GEN_INT (- INTVAL (operands[2]));
2554 return "subq%.w %2,%0";
2556 /* On the CPU32 it is faster to use two addqw instructions to
2557 add a small integer (8 < N <= 16) to a register.
2558 Likewise for subqw. */
2559 if (TUNE_CPU32 && REG_P (operands[0]))
2561 if (INTVAL (operands[2]) > 8
2562 && INTVAL (operands[2]) <= 16)
2564 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2565 return "addq%.w #8,%0\;addq%.w %2,%0";
2567 if (INTVAL (operands[2]) < -8
2568 && INTVAL (operands[2]) >= -16)
2570 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2571 return "subq%.w #8,%0\;subq%.w %2,%0";
2574 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2575 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2577 return "add%.w %2,%0";
2580 ;; These insns must use MATCH_DUP instead of the more expected
2581 ;; use of a matching constraint because the "output" here is also
2582 ;; an input, so you can't use the matching constraint. That also means
2583 ;; that you can't use the "%", so you need patterns with the matched
2584 ;; operand in both positions.
2587 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2588 (plus:HI (match_dup 0)
2589 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2592 if (GET_CODE (operands[1]) == CONST_INT)
2594 /* If the constant would be a negative number when interpreted as
2595 HImode, make it negative. This is usually, but not always, done
2596 elsewhere in the compiler. First check for constants out of range,
2597 which could confuse us. */
2599 if (INTVAL (operands[1]) >= 32768)
2600 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2602 if (INTVAL (operands[1]) > 0
2603 && INTVAL (operands[1]) <= 8)
2604 return "addq%.w %1,%0";
2605 if (INTVAL (operands[1]) < 0
2606 && INTVAL (operands[1]) >= -8)
2608 operands[1] = GEN_INT (- INTVAL (operands[1]));
2609 return "subq%.w %1,%0";
2611 /* On the CPU32 it is faster to use two addqw instructions to
2612 add a small integer (8 < N <= 16) to a register.
2613 Likewise for subqw. */
2614 if (TUNE_CPU32 && REG_P (operands[0]))
2616 if (INTVAL (operands[1]) > 8
2617 && INTVAL (operands[1]) <= 16)
2619 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2620 return "addq%.w #8,%0\;addq%.w %1,%0";
2622 if (INTVAL (operands[1]) < -8
2623 && INTVAL (operands[1]) >= -16)
2625 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2626 return "subq%.w #8,%0\;subq%.w %1,%0";
2629 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2630 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2632 return "add%.w %1,%0";
2636 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2637 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2641 if (GET_CODE (operands[1]) == CONST_INT)
2643 /* If the constant would be a negative number when interpreted as
2644 HImode, make it negative. This is usually, but not always, done
2645 elsewhere in the compiler. First check for constants out of range,
2646 which could confuse us. */
2648 if (INTVAL (operands[1]) >= 32768)
2649 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2651 if (INTVAL (operands[1]) > 0
2652 && INTVAL (operands[1]) <= 8)
2653 return "addq%.w %1,%0";
2654 if (INTVAL (operands[1]) < 0
2655 && INTVAL (operands[1]) >= -8)
2657 operands[1] = GEN_INT (- INTVAL (operands[1]));
2658 return "subq%.w %1,%0";
2660 /* On the CPU32 it is faster to use two addqw instructions to
2661 add a small integer (8 < N <= 16) to a register.
2662 Likewise for subqw. */
2663 if (TUNE_CPU32 && REG_P (operands[0]))
2665 if (INTVAL (operands[1]) > 8
2666 && INTVAL (operands[1]) <= 16)
2668 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2669 return "addq%.w #8,%0\;addq%.w %1,%0";
2671 if (INTVAL (operands[1]) < -8
2672 && INTVAL (operands[1]) >= -16)
2674 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2675 return "subq%.w #8,%0\;subq%.w %1,%0";
2678 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2679 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2681 return "add%.w %1,%0";
2684 (define_insn "addqi3"
2685 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2686 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2687 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2690 if (GET_CODE (operands[2]) == CONST_INT)
2692 if (INTVAL (operands[2]) >= 128)
2693 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2695 if (INTVAL (operands[2]) > 0
2696 && INTVAL (operands[2]) <= 8)
2697 return "addq%.b %2,%0";
2698 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2700 operands[2] = GEN_INT (- INTVAL (operands[2]));
2701 return "subq%.b %2,%0";
2704 return "add%.b %2,%0";
2708 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2709 (plus:QI (match_dup 0)
2710 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2713 if (GET_CODE (operands[1]) == CONST_INT)
2715 if (INTVAL (operands[1]) >= 128)
2716 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2718 if (INTVAL (operands[1]) > 0
2719 && INTVAL (operands[1]) <= 8)
2720 return "addq%.b %1,%0";
2721 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2723 operands[1] = GEN_INT (- INTVAL (operands[1]));
2724 return "subq%.b %1,%0";
2727 return "add%.b %1,%0";
2731 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2732 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2736 if (GET_CODE (operands[1]) == CONST_INT)
2738 if (INTVAL (operands[1]) >= 128)
2739 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2741 if (INTVAL (operands[1]) > 0
2742 && INTVAL (operands[1]) <= 8)
2743 return "addq%.b %1,%0";
2744 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2746 operands[1] = GEN_INT (- INTVAL (operands[1]));
2747 return "subq%.b %1,%0";
2750 return "add%.b %1,%0";
2753 (define_expand "add<mode>3"
2754 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2755 (plus:FP (match_operand:FP 1 "general_operand" "")
2756 (match_operand:FP 2 "general_operand" "")))]
2760 (define_insn "add<mode>3_floatsi_68881"
2761 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2762 (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2763 (match_operand:FP 1 "general_operand" "0")))]
2765 "f<FP:round>add%.l %2,%0"
2766 [(set_attr "type" "falu")
2767 (set_attr "opy" "2")])
2769 (define_insn "add<mode>3_floathi_68881"
2770 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2771 (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2772 (match_operand:FP 1 "general_operand" "0")))]
2774 "f<FP:round>add%.w %2,%0"
2775 [(set_attr "type" "falu")
2776 (set_attr "opy" "2")])
2778 (define_insn "add<mode>3_floatqi_68881"
2779 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2780 (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2781 (match_operand:FP 1 "general_operand" "0")))]
2783 "f<FP:round>add%.b %2,%0"
2784 [(set_attr "type" "falu")
2785 (set_attr "opy" "2")])
2787 (define_insn "add<mode>3_68881"
2788 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2789 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2790 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2793 if (FP_REG_P (operands[2]))
2794 return "f<FP:round>add%.x %2,%0";
2795 return "f<FP:round>add%.<FP:prec> %f2,%0";
2797 [(set_attr "type" "falu")
2798 (set_attr "opy" "2")])
2800 (define_insn "add<mode>3_cf"
2801 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2802 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2803 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2804 "TARGET_COLDFIRE_FPU"
2806 if (FP_REG_P (operands[2]))
2807 return "f<FP:prec>add%.d %2,%0";
2808 return "f<FP:prec>add%.<FP:prec> %2,%0";
2810 [(set_attr "type" "falu")
2811 (set_attr "opy" "2")])
2813 ;; subtract instructions
2815 (define_insn "subdi_sexthishl32"
2816 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2817 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2818 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2820 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2824 if (ADDRESS_REG_P (operands[0]))
2825 return "sub%.w %2,%0";
2826 else if (ADDRESS_REG_P (operands[3]))
2827 return "move%.w %2,%3\;sub%.l %3,%0";
2829 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2832 (define_insn "subdi_dishl32"
2833 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2834 (minus:DI (match_dup 0)
2835 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2840 if (GET_CODE (operands[1]) == REG)
2841 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2843 operands[1] = adjust_address (operands[1], SImode, 4);
2844 return "sub%.l %1,%0";
2846 [(set_attr "type" "alu_l")])
2848 (define_insn "subdi3"
2849 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2850 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2851 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2852 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2855 if (DATA_REG_P (operands[0]))
2857 if (DATA_REG_P (operands[2]))
2858 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2859 else if (GET_CODE (operands[2]) == MEM
2860 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2862 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2869 if (GET_CODE (operands[2]) == REG)
2871 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2874 else if (CONSTANT_P (operands[2]))
2875 split_double (operands[2], &high, &low);
2878 low = adjust_address (operands[2], SImode, 4);
2882 operands[1] = low, operands[2] = high;
2883 xoperands[0] = operands[3];
2884 if (GET_CODE (operands[1]) == CONST_INT
2885 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2886 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2888 xoperands[1] = operands[2];
2890 output_asm_insn (output_move_simode (xoperands), xoperands);
2891 if (GET_CODE (operands[1]) == CONST_INT)
2893 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2894 return "subq%.l %1,%R0\;subx%.l %3,%0";
2895 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2897 operands[1] = GEN_INT (-INTVAL (operands[1]));
2898 return "addq%.l %1,%R0\;addx%.l %3,%0";
2901 return "sub%.l %1,%R0\;subx%.l %3,%0";
2906 gcc_assert (GET_CODE (operands[0]) == MEM);
2908 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2911 = gen_rtx_MEM (SImode, plus_constant (Pmode,
2912 XEXP (operands[0], 0), -8));
2913 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2915 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2917 operands[1] = XEXP(operands[0], 0);
2918 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2922 operands[1] = adjust_address (operands[0], SImode, 4);
2923 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2928 (define_insn "subsi3"
2929 [(set (match_operand:SI 0 "nonimmediate_operand" "=mda,m,d,a")
2930 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0,0")
2931 (match_operand:SI 2 "general_src_operand" "I,dT,mSrT,mSrs")))]
2938 [(set_attr "type" "aluq_l,alu_l,alu_l,alu_l")
2939 (set_attr "opy" "2")])
2942 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2943 (minus:SI (match_operand:SI 1 "general_operand" "0")
2945 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2949 (define_insn "subhi3"
2950 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2951 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2952 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2957 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2958 (minus:HI (match_dup 0)
2959 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2963 (define_insn "subqi3"
2964 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2965 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2966 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2971 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2972 (minus:QI (match_dup 0)
2973 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2977 (define_expand "sub<mode>3"
2978 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2979 (minus:FP (match_operand:FP 1 "general_operand" "")
2980 (match_operand:FP 2 "general_operand" "")))]
2984 (define_insn "sub<mode>3_floatsi_68881"
2985 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2986 (minus:FP (match_operand:FP 1 "general_operand" "0")
2987 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2989 "f<FP:round>sub%.l %2,%0"
2990 [(set_attr "type" "falu")
2991 (set_attr "opy" "2")])
2993 (define_insn "sub<mode>3_floathi_68881"
2994 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2995 (minus:FP (match_operand:FP 1 "general_operand" "0")
2996 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2998 "f<FP:round>sub%.w %2,%0"
2999 [(set_attr "type" "falu")
3000 (set_attr "opy" "2")])
3002 (define_insn "sub<mode>3_floatqi_68881"
3003 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3004 (minus:FP (match_operand:FP 1 "general_operand" "0")
3005 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3007 "f<FP:round>sub%.b %2,%0"
3008 [(set_attr "type" "falu")
3009 (set_attr "opy" "2")])
3011 (define_insn "sub<mode>3_68881"
3012 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3013 (minus:FP (match_operand:FP 1 "general_operand" "0")
3014 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3017 if (FP_REG_P (operands[2]))
3018 return "f<FP:round>sub%.x %2,%0";
3019 return "f<FP:round>sub%.<FP:prec> %f2,%0";
3021 [(set_attr "type" "falu")
3022 (set_attr "opy" "2")])
3024 (define_insn "sub<mode>3_cf"
3025 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3026 (minus:FP (match_operand:FP 1 "general_operand" "0")
3027 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
3028 "TARGET_COLDFIRE_FPU"
3030 if (FP_REG_P (operands[2]))
3031 return "f<FP:prec>sub%.d %2,%0";
3032 return "f<FP:prec>sub%.<FP:prec> %2,%0";
3034 [(set_attr "type" "falu")
3035 (set_attr "opy" "2")])
3037 ;; multiply instructions
3039 (define_insn "mulhi3"
3040 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3041 (mult:HI (match_operand:HI 1 "general_operand" "%0")
3042 (match_operand:HI 2 "general_src_operand" "dmSn")))]
3045 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3047 [(set_attr "type" "mul_w")
3048 (set_attr "opy" "2")])
3050 (define_insn "mulhisi3"
3051 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3052 (mult:SI (sign_extend:SI
3053 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3055 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3058 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3060 [(set_attr "type" "mul_w")
3061 (set_attr "opy" "2")])
3063 (define_insn "*mulhisisi3_s"
3064 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3065 (mult:SI (sign_extend:SI
3066 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3067 (match_operand:SI 2 "const_int_operand" "n")))]
3068 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
3070 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3072 [(set_attr "type" "mul_w")
3073 (set_attr "opy" "2")])
3075 (define_expand "mulsi3"
3076 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3077 (mult:SI (match_operand:SI 1 "general_operand" "")
3078 (match_operand:SI 2 "general_operand" "")))]
3079 "TARGET_68020 || TARGET_COLDFIRE"
3082 (define_insn "*mulsi3_68020"
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_src_operand" "dmSTK")))]
3089 [(set_attr "type" "mul_l")
3090 (set_attr "opy" "2")])
3092 (define_insn "*mulsi3_cf"
3093 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3094 (mult:SI (match_operand:SI 1 "general_operand" "%0")
3095 (match_operand:SI 2 "general_operand" "d<Q>")))]
3098 [(set_attr "type" "mul_l")
3099 (set_attr "opy" "2")])
3101 (define_insn "umulhisi3"
3102 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3103 (mult:SI (zero_extend:SI
3104 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3106 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3109 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3111 [(set_attr "type" "mul_w")
3112 (set_attr "opy" "2")])
3114 (define_insn "*mulhisisi3_z"
3115 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3116 (mult:SI (zero_extend:SI
3117 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3118 (match_operand:SI 2 "const_int_operand" "n")))]
3119 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
3121 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3123 [(set_attr "type" "mul_w")
3124 (set_attr "opy" "2")])
3126 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
3127 ;; proper matching constraint. This is because the matching is between
3128 ;; the high-numbered word of the DImode operand[0] and operand[1].
3129 (define_expand "umulsidi3"
3131 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3132 (mult:SI (match_operand:SI 1 "register_operand" "")
3133 (match_operand:SI 2 "register_operand" "")))
3134 (set (subreg:SI (match_dup 0) 0)
3135 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3136 (zero_extend:DI (match_dup 2)))
3137 (const_int 32))))])]
3138 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3142 [(set (match_operand:SI 0 "register_operand" "=d")
3143 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3144 (match_operand:SI 2 "nonimmediate_operand" "dm")))
3145 (set (match_operand:SI 3 "register_operand" "=d")
3146 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3147 (zero_extend:DI (match_dup 2)))
3149 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3152 ; Match immediate case. For 2.4 only match things < 2^31.
3153 ; It's tricky with larger values in these patterns since we need to match
3154 ; values between the two parallel multiplies, between a CONST_DOUBLE and
3157 [(set (match_operand:SI 0 "register_operand" "=d")
3158 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3159 (match_operand:SI 2 "const_int_operand" "n")))
3160 (set (match_operand:SI 3 "register_operand" "=d")
3161 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3164 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
3165 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
3168 (define_expand "mulsidi3"
3170 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3171 (mult:SI (match_operand:SI 1 "register_operand" "")
3172 (match_operand:SI 2 "register_operand" "")))
3173 (set (subreg:SI (match_dup 0) 0)
3174 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3175 (sign_extend:DI (match_dup 2)))
3176 (const_int 32))))])]
3177 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3181 [(set (match_operand:SI 0 "register_operand" "=d")
3182 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3183 (match_operand:SI 2 "nonimmediate_operand" "dm")))
3184 (set (match_operand:SI 3 "register_operand" "=d")
3185 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3186 (sign_extend:DI (match_dup 2)))
3188 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3192 [(set (match_operand:SI 0 "register_operand" "=d")
3193 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3194 (match_operand:SI 2 "const_int_operand" "n")))
3195 (set (match_operand:SI 3 "register_operand" "=d")
3196 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3199 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3202 (define_expand "umulsi3_highpart"
3204 [(set (match_operand:SI 0 "register_operand" "")
3207 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
3208 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
3210 (clobber (match_dup 3))])]
3211 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3213 operands[3] = gen_reg_rtx (SImode);
3215 if (GET_CODE (operands[2]) == CONST_INT)
3217 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
3220 /* We have to adjust the operand order for the matching constraints. */
3221 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
3222 operands[1], operands[2]));
3228 [(set (match_operand:SI 0 "register_operand" "=d")
3231 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3232 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3234 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3235 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3238 (define_insn "const_umulsi3_highpart"
3239 [(set (match_operand:SI 0 "register_operand" "=d")
3242 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
3243 (match_operand:DI 3 "const_uint32_operand" "n"))
3245 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3246 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3249 (define_expand "smulsi3_highpart"
3251 [(set (match_operand:SI 0 "register_operand" "")
3254 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
3255 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
3257 (clobber (match_dup 3))])]
3258 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3260 operands[3] = gen_reg_rtx (SImode);
3261 if (GET_CODE (operands[2]) == CONST_INT)
3263 /* We have to adjust the operand order for the matching constraints. */
3264 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
3265 operands[1], operands[2]));
3271 [(set (match_operand:SI 0 "register_operand" "=d")
3274 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3275 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3277 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3278 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3281 (define_insn "const_smulsi3_highpart"
3282 [(set (match_operand:SI 0 "register_operand" "=d")
3285 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
3286 (match_operand:DI 3 "const_sint32_operand" "n"))
3288 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3289 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3292 (define_expand "mul<mode>3"
3293 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3294 (mult:FP (match_operand:FP 1 "general_operand" "")
3295 (match_operand:FP 2 "general_operand" "")))]
3299 (define_insn "mul<mode>3_floatsi_68881"
3300 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3301 (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
3302 (match_operand:FP 1 "general_operand" "0")))]
3306 ? "f<FP:round>mul%.l %2,%0"
3307 : "f<FP:round_mul>mul%.l %2,%0";
3309 [(set_attr "type" "fmul")
3310 (set_attr "opy" "2")])
3312 (define_insn "mul<mode>3_floathi_68881"
3313 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3314 (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
3315 (match_operand:FP 1 "general_operand" "0")))]
3319 ? "f<FP:round>mul%.w %2,%0"
3320 : "f<FP:round_mul>mul%.w %2,%0";
3322 [(set_attr "type" "fmul")
3323 (set_attr "opy" "2")])
3325 (define_insn "mul<mode>3_floatqi_68881"
3326 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3327 (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
3328 (match_operand:FP 1 "general_operand" "0")))]
3332 ? "f<FP:round>mul%.b %2,%0"
3333 : "f<FP:round_mul>mul%.b %2,%0";
3335 [(set_attr "type" "fmul")
3336 (set_attr "opy" "2")])
3338 (define_insn "muldf_68881"
3339 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3340 (mult:DF (match_operand:DF 1 "general_operand" "%0")
3341 (match_operand:DF 2 "general_operand" "fmG")))]
3344 if (GET_CODE (operands[2]) == CONST_DOUBLE
3345 && floating_exact_log2 (operands[2]) && !TUNE_68040_60)
3347 int i = floating_exact_log2 (operands[2]);
3348 operands[2] = GEN_INT (i);
3349 return "fscale%.l %2,%0";
3351 if (REG_P (operands[2]))
3352 return "f%&mul%.x %2,%0";
3353 return "f%&mul%.d %f2,%0";
3356 (define_insn "mulsf_68881"
3357 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3358 (mult:SF (match_operand:SF 1 "general_operand" "%0")
3359 (match_operand:SF 2 "general_operand" "fdmF")))]
3362 if (FP_REG_P (operands[2]))
3363 return (TARGET_68040
3365 : "fsglmul%.x %2,%0");
3366 return (TARGET_68040
3368 : "fsglmul%.s %f2,%0");
3371 (define_insn "mulxf3_68881"
3372 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
3373 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
3374 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
3377 return "fmul%.x %f2,%0";
3380 (define_insn "fmul<mode>3_cf"
3381 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3382 (mult:FP (match_operand:FP 1 "general_operand" "%0")
3383 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3384 "TARGET_COLDFIRE_FPU"
3386 if (FP_REG_P (operands[2]))
3387 return "f<FP:prec>mul%.d %2,%0";
3388 return "f<FP:prec>mul%.<FP:prec> %2,%0";
3390 [(set_attr "type" "fmul")
3391 (set_attr "opy" "2")])
3393 ;; divide instructions
3395 (define_expand "div<mode>3"
3396 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3397 (div:FP (match_operand:FP 1 "general_operand" "")
3398 (match_operand:FP 2 "general_operand" "")))]
3402 (define_insn "div<mode>3_floatsi_68881"
3403 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3404 (div:FP (match_operand:FP 1 "general_operand" "0")
3405 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
3409 ? "f<FP:round>div%.l %2,%0"
3410 : "f<FP:round_mul>div%.l %2,%0";
3413 (define_insn "div<mode>3_floathi_68881"
3414 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3415 (div:FP (match_operand:FP 1 "general_operand" "0")
3416 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
3420 ? "f<FP:round>div%.w %2,%0"
3421 : "f<FP:round_mul>div%.w %2,%0";
3424 (define_insn "div<mode>3_floatqi_68881"
3425 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3426 (div:FP (match_operand:FP 1 "general_operand" "0")
3427 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3431 ? "f<FP:round>div%.b %2,%0"
3432 : "f<FP:round_mul>div%.b %2,%0";
3435 (define_insn "div<mode>3_68881"
3436 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3437 (div:FP (match_operand:FP 1 "general_operand" "0")
3438 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3441 if (FP_REG_P (operands[2]))
3442 return (TARGET_68040
3443 ? "f<FP:round>div%.x %2,%0"
3444 : "f<FP:round_mul>div%.x %2,%0");
3445 return (TARGET_68040
3446 ? "f<FP:round>div%.<FP:prec> %f2,%0"
3447 : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
3450 (define_insn "div<mode>3_cf"
3451 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3452 (div:FP (match_operand:FP 1 "general_operand" "0")
3453 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3454 "TARGET_COLDFIRE_FPU"
3456 if (FP_REG_P (operands[2]))
3457 return "f<FP:prec>div%.d %2,%0";
3458 return "f<FP:prec>div%.<FP:prec> %2,%0";
3460 [(set_attr "type" "fdiv")
3461 (set_attr "opy" "2")])
3463 ;; Remainder instructions.
3465 (define_expand "divmodsi4"
3467 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3468 (div:SI (match_operand:SI 1 "general_operand" "")
3469 (match_operand:SI 2 "general_src_operand" "")))
3470 (set (match_operand:SI 3 "nonimmediate_operand" "")
3471 (mod:SI (match_dup 1) (match_dup 2)))])]
3472 "TARGET_68020 || TARGET_CF_HWDIV"
3476 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3477 (div:SI (match_operand:SI 1 "general_operand" "0")
3478 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3479 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3480 (mod:SI (match_dup 1) (match_dup 2)))]
3483 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3484 return "divs%.l %2,%0";
3485 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3486 return "rems%.l %2,%3:%0";
3488 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
3490 [(set_attr "type" "div_l")
3491 (set_attr "opy" "2")])
3494 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3495 (div:SI (match_operand:SI 1 "general_operand" "0")
3496 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3497 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3498 (mod:SI (match_dup 1) (match_dup 2)))]
3501 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3502 return "divs%.l %2,%0";
3504 return "divsl%.l %2,%3:%0";
3507 (define_expand "udivmodsi4"
3509 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3510 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3511 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3512 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3513 (umod:SI (match_dup 1) (match_dup 2)))])]
3514 "TARGET_68020 || TARGET_CF_HWDIV"
3518 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3519 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3520 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3521 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3522 (umod:SI (match_dup 1) (match_dup 2)))]
3525 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3526 return "divu%.l %2,%0";
3527 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3528 return "remu%.l %2,%3:%0";
3530 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3532 [(set_attr "type" "div_l")
3533 (set_attr "opy" "2")])
3536 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3537 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3538 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3539 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3540 (umod:SI (match_dup 1) (match_dup 2)))]
3541 "TARGET_68020 && !TARGET_COLDFIRE"
3543 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3544 return "divu%.l %2,%0";
3546 return "divul%.l %2,%3:%0";
3549 (define_insn "divmodhi4"
3550 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3551 (div:HI (match_operand:HI 1 "general_operand" "0")
3552 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3553 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3554 (mod:HI (match_dup 1) (match_dup 2)))]
3555 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3557 output_asm_insn (MOTOROLA ?
3558 "ext%.l %0\;divs%.w %2,%0" :
3559 "extl %0\;divs %2,%0",
3561 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3564 return "move%.l %0,%3\;swap %3";
3570 (define_insn "udivmodhi4"
3571 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3572 (udiv:HI (match_operand:HI 1 "general_operand" "0")
3573 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3574 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3575 (umod:HI (match_dup 1) (match_dup 2)))]
3576 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3578 if (ISA_HAS_MVS_MVZ)
3579 output_asm_insn (MOTOROLA ?
3580 "mvz%.w %0,%0\;divu%.w %2,%0" :
3581 "mvz%.w %0,%0\;divu %2,%0",
3584 output_asm_insn (MOTOROLA ?
3585 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3586 "and%.l #0xFFFF,%0\;divu %2,%0",
3589 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3592 return "move%.l %0,%3\;swap %3";
3598 ;; logical-and instructions
3600 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3601 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3602 ;; can't allocate pseudos into it.
3604 (define_expand "andsi3"
3605 [(set (match_operand:SI 0 "not_sp_operand" "")
3606 (and:SI (match_operand:SI 1 "general_operand" "")
3607 (match_operand:SI 2 "general_src_operand" "")))]
3611 ;; produced by split operations after reload finished
3612 (define_insn "*andsi3_split"
3613 [(set (match_operand:SI 0 "register_operand" "=d")
3614 (and:SI (match_operand:SI 1 "register_operand" "0")
3615 (match_operand:SI 2 "const_int_operand" "i")))]
3616 "reload_completed && !TARGET_COLDFIRE"
3618 return output_andsi3 (operands);
3621 (define_insn "andsi3_internal"
3622 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3623 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3624 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3627 return output_andsi3 (operands);
3630 (define_insn "andsi3_5200"
3631 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3632 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3633 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3637 && DATA_REG_P (operands[0])
3638 && GET_CODE (operands[2]) == CONST_INT)
3640 if (INTVAL (operands[2]) == 0x000000ff)
3641 return "mvz%.b %0,%0";
3642 else if (INTVAL (operands[2]) == 0x0000ffff)
3643 return "mvz%.w %0,%0";
3645 return output_andsi3 (operands);
3648 (define_insn "andhi3"
3649 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3650 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3651 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3656 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3657 (and:HI (match_dup 0)
3658 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3663 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3664 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3669 (define_insn "andqi3"
3670 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3671 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3672 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3677 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3678 (and:QI (match_dup 0)
3679 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3684 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3685 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3690 ;; inclusive-or instructions
3692 (define_insn "iordi_zext"
3693 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3694 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3695 (match_operand:DI 2 "general_operand" "0,0")))]
3701 if (GET_CODE (operands[0]) == REG)
3702 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3704 operands[0] = adjust_address (operands[0], SImode, 4);
3705 if (GET_MODE (operands[1]) == SImode)
3706 return "or%.l %1,%0";
3707 byte_mode = (GET_MODE (operands[1]) == QImode);
3708 if (GET_CODE (operands[0]) == MEM)
3709 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3712 return "or%.b %1,%0";
3714 return "or%.w %1,%0";
3717 (define_expand "iorsi3"
3718 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3719 (ior:SI (match_operand:SI 1 "general_operand" "")
3720 (match_operand:SI 2 "general_src_operand" "")))]
3724 (define_insn "iorsi3_internal"
3725 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3726 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3727 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3730 return output_iorsi3 (operands);
3733 (define_insn "iorsi3_5200"
3734 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3735 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3736 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3739 return output_iorsi3 (operands);
3742 (define_insn "iorhi3"
3743 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3744 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3745 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3750 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3751 (ior:HI (match_dup 0)
3752 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3757 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3758 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3763 (define_insn "iorqi3"
3764 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3765 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3766 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3771 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3772 (ior:QI (match_dup 0)
3773 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3778 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3779 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3784 ;; On all 68k models, this makes faster code in a special case.
3785 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3787 (define_insn "iorsi_zexthi_ashl16"
3788 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3789 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3790 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3795 if (GET_CODE (operands[2]) != REG)
3796 operands[2] = adjust_address (operands[2], HImode, 2);
3797 if (GET_CODE (operands[2]) != REG
3798 || REGNO (operands[2]) != REGNO (operands[0]))
3799 output_asm_insn ("move%.w %2,%0", operands);
3800 return "swap %0\;mov%.w %1,%0";
3803 (define_insn "iorsi_zext"
3804 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3805 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3806 (match_operand:SI 2 "general_operand" "0,0")))]
3812 byte_mode = (GET_MODE (operands[1]) == QImode);
3813 if (GET_CODE (operands[0]) == MEM)
3814 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3817 return "or%.b %1,%0";
3819 return "or%.w %1,%0";
3824 (define_expand "xorsi3"
3825 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3826 (xor:SI (match_operand:SI 1 "general_operand" "")
3827 (match_operand:SI 2 "general_operand" "")))]
3831 (define_insn "xorsi3_internal"
3832 [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3833 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3834 (match_operand:SI 2 "general_operand" "di,dKT")))]
3838 return output_xorsi3 (operands);
3841 (define_insn "xorsi3_5200"
3842 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3843 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3844 (match_operand:SI 2 "general_operand" "d,Ks")))]
3847 return output_xorsi3 (operands);
3850 (define_insn "xorhi3"
3851 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3852 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3853 (match_operand:HI 2 "general_operand" "dn")))]
3858 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3859 (xor:HI (match_dup 0)
3860 (match_operand:HI 1 "general_operand" "dn")))]
3865 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3866 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3871 (define_insn "xorqi3"
3872 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3873 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3874 (match_operand:QI 2 "general_operand" "dn")))]
3879 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3880 (xor:QI (match_dup 0)
3881 (match_operand:QI 1 "general_operand" "dn")))]
3886 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3887 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3892 ;; negation instructions
3894 (define_expand "negdi2"
3895 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3896 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3899 if (TARGET_COLDFIRE)
3900 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3902 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3906 (define_insn "negdi2_internal"
3907 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3908 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3911 if (which_alternative == 0)
3912 return "neg%.l %0\;negx%.l %0";
3913 if (GET_CODE (operands[0]) == REG)
3914 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3916 operands[1] = adjust_address (operands[0], SImode, 4);
3917 if (ADDRESS_REG_P (operands[0]))
3918 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3920 return "neg%.l %1\;negx%.l %0";
3923 (define_insn "negdi2_5200"
3924 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3925 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3928 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3929 return "neg%.l %1\;negx%.l %0";
3932 (define_expand "negsi2"
3933 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3934 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3937 if (TARGET_COLDFIRE)
3938 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3940 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3944 (define_insn "negsi2_internal"
3945 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3946 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3949 [(set_attr "type" "neg_l")])
3951 (define_insn "negsi2_5200"
3952 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3953 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3956 [(set_attr "type" "neg_l")])
3958 (define_insn "neghi2"
3959 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3960 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3965 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3966 (neg:HI (match_dup 0)))]
3970 (define_insn "negqi2"
3971 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3972 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3977 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3978 (neg:QI (match_dup 0)))]
3982 ;; If using software floating point, just flip the sign bit.
3984 (define_expand "negsf2"
3985 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3986 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3989 if (!TARGET_HARD_FLOAT)
3994 target = operand_subword_force (operands[0], 0, SFmode);
3995 result = expand_binop (SImode, xor_optab,
3996 operand_subword_force (operands[1], 0, SFmode),
3997 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3998 gcc_assert (result);
4000 if (result != target)
4001 emit_move_insn (result, target);
4003 /* Make a place for REG_EQUAL. */
4004 emit_move_insn (operands[0], operands[0]);
4009 (define_expand "negdf2"
4010 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4011 (neg:DF (match_operand:DF 1 "general_operand" "")))]
4014 if (!TARGET_HARD_FLOAT)
4021 target = operand_subword (operands[0], 0, 1, DFmode);
4022 result = expand_binop (SImode, xor_optab,
4023 operand_subword_force (operands[1], 0, DFmode),
4024 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4025 gcc_assert (result);
4027 if (result != target)
4028 emit_move_insn (result, target);
4030 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4031 operand_subword_force (operands[1], 1, DFmode));
4033 insns = get_insns ();
4041 (define_expand "negxf2"
4042 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4043 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4053 target = operand_subword (operands[0], 0, 1, XFmode);
4054 result = expand_binop (SImode, xor_optab,
4055 operand_subword_force (operands[1], 0, XFmode),
4056 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4057 gcc_assert (result);
4059 if (result != target)
4060 emit_move_insn (result, target);
4062 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4063 operand_subword_force (operands[1], 1, XFmode));
4064 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4065 operand_subword_force (operands[1], 2, XFmode));
4067 insns = get_insns ();
4075 (define_insn "neg<mode>2_68881"
4076 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4077 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4080 if (DATA_REG_P (operands[0]))
4082 operands[1] = GEN_INT (31);
4083 return "bchg %1,%0";
4085 if (FP_REG_P (operands[1]))
4086 return "f<FP:round>neg%.x %1,%0";
4087 return "f<FP:round>neg%.<FP:prec> %f1,%0";
4090 (define_insn "neg<mode>2_cf"
4091 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4092 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4093 "TARGET_COLDFIRE_FPU"
4095 if (DATA_REG_P (operands[0]))
4097 operands[1] = GEN_INT (31);
4098 return "bchg %1,%0";
4100 if (FP_REG_P (operands[1]))
4101 return "f<FP:prec>neg%.d %1,%0";
4102 return "f<FP:prec>neg%.<FP:prec> %1,%0";
4105 ;; Sqrt instruction for the 68881
4107 (define_expand "sqrt<mode>2"
4108 [(set (match_operand:FP 0 "nonimmediate_operand" "")
4109 (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
4113 (define_insn "sqrt<mode>2_68881"
4114 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4115 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
4118 if (FP_REG_P (operands[1]))
4119 return "f<FP:round>sqrt%.x %1,%0";
4120 return "f<FP:round>sqrt%.<FP:prec> %1,%0";
4122 [(set_attr "type" "fsqrt")])
4124 (define_insn "sqrt<mode>2_cf"
4125 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4126 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
4127 "TARGET_COLDFIRE_FPU"
4129 if (FP_REG_P (operands[1]))
4130 return "f<FP:prec>sqrt%.d %1,%0";
4131 return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
4133 [(set_attr "type" "fsqrt")])
4134 ;; Absolute value instructions
4135 ;; If using software floating point, just zero the sign bit.
4137 (define_expand "abssf2"
4138 [(set (match_operand:SF 0 "nonimmediate_operand" "")
4139 (abs:SF (match_operand:SF 1 "general_operand" "")))]
4142 if (!TARGET_HARD_FLOAT)
4147 target = operand_subword_force (operands[0], 0, SFmode);
4148 result = expand_binop (SImode, and_optab,
4149 operand_subword_force (operands[1], 0, SFmode),
4150 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4151 gcc_assert (result);
4153 if (result != target)
4154 emit_move_insn (result, target);
4156 /* Make a place for REG_EQUAL. */
4157 emit_move_insn (operands[0], operands[0]);
4162 (define_expand "absdf2"
4163 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4164 (abs:DF (match_operand:DF 1 "general_operand" "")))]
4167 if (!TARGET_HARD_FLOAT)
4174 target = operand_subword (operands[0], 0, 1, DFmode);
4175 result = expand_binop (SImode, and_optab,
4176 operand_subword_force (operands[1], 0, DFmode),
4177 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4178 gcc_assert (result);
4180 if (result != target)
4181 emit_move_insn (result, target);
4183 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4184 operand_subword_force (operands[1], 1, DFmode));
4186 insns = get_insns ();
4194 (define_expand "absxf2"
4195 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4196 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4206 target = operand_subword (operands[0], 0, 1, XFmode);
4207 result = expand_binop (SImode, and_optab,
4208 operand_subword_force (operands[1], 0, XFmode),
4209 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4210 gcc_assert (result);
4212 if (result != target)
4213 emit_move_insn (result, target);
4215 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4216 operand_subword_force (operands[1], 1, XFmode));
4217 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4218 operand_subword_force (operands[1], 2, XFmode));
4220 insns = get_insns ();
4228 (define_insn "abs<mode>2_68881"
4229 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4230 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4233 if (DATA_REG_P (operands[0]))
4235 operands[1] = GEN_INT (31);
4236 return "bclr %1,%0";
4238 if (FP_REG_P (operands[1]))
4239 return "f<FP:round>abs%.x %1,%0";
4240 return "f<FP:round>abs%.<FP:prec> %f1,%0";
4243 (define_insn "abs<mode>2_cf"
4244 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4245 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4246 "TARGET_COLDFIRE_FPU"
4248 if (DATA_REG_P (operands[0]))
4250 operands[1] = GEN_INT (31);
4251 return "bclr %1,%0";
4253 if (FP_REG_P (operands[1]))
4254 return "f<FP:prec>abs%.d %1,%0";
4255 return "f<FP:prec>abs%.<FP:prec> %1,%0";
4257 [(set_attr "type" "bitrw,fneg")])
4259 ;; bit indexing instructions
4261 (define_expand "clzsi2"
4262 [(set (match_operand:SI 0 "register_operand" "")
4263 (clz:SI (match_operand:SI 1 "general_operand" "")))]
4264 "ISA_HAS_FF1 || (TARGET_68020 && TARGET_BITFIELD)"
4267 operands[1] = force_reg (SImode, operands[1]);
4270 (define_insn "*clzsi2_68k"
4271 [(set (match_operand:SI 0 "register_operand" "=d")
4272 (clz:SI (match_operand:SI 1 "general_operand" "do")))]
4273 "TARGET_68020 && TARGET_BITFIELD"
4276 return "bfffo %1{#0:#0},%0";
4279 ;; ColdFire ff1 instruction implements clz.
4280 (define_insn "*clzsi2_cf"
4281 [(set (match_operand:SI 0 "register_operand" "=d")
4282 (clz:SI (match_operand:SI 1 "register_operand" "0")))]
4288 [(set_attr "type" "ext")])
4290 ;; one complement instructions
4292 (define_expand "one_cmplsi2"
4293 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4294 (not:SI (match_operand:SI 1 "general_operand" "")))]
4297 if (TARGET_COLDFIRE)
4298 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
4300 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
4304 (define_insn "one_cmplsi2_internal"
4305 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4306 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4310 (define_insn "one_cmplsi2_5200"
4311 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4312 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4315 [(set_attr "type" "neg_l")])
4317 (define_insn "one_cmplhi2"
4318 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4319 (not:HI (match_operand:HI 1 "general_operand" "0")))]
4324 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4325 (not:HI (match_dup 0)))]
4329 (define_insn "one_cmplqi2"
4330 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4331 (not:QI (match_operand:QI 1 "general_operand" "0")))]
4336 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4337 (not:QI (match_dup 0)))]
4341 ;; arithmetic shift instructions
4342 ;; We don't need the shift memory by 1 bit instruction
4344 (define_insn "ashldi_extsi"
4345 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4347 (match_operator:DI 2 "extend_operator"
4348 [(match_operand:SI 1 "general_operand" "rm")])
4353 if (GET_CODE (operands[0]) == REG)
4354 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4356 operands[2] = adjust_address (operands[0], SImode, 4);
4357 if (ADDRESS_REG_P (operands[0]))
4358 return "move%.l %1,%0\;sub%.l %2,%2";
4360 return "move%.l %1,%0\;clr%.l %2";
4363 (define_insn "ashldi_sexthi"
4364 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
4365 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
4367 (clobber (match_scratch:SI 2 "=a,X"))]
4371 if (GET_CODE (operands[0]) == MEM)
4373 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4374 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
4375 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4376 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
4379 operands[3] = adjust_address (operands[0], SImode, 4);
4380 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
4383 else if (DATA_REG_P (operands[0]))
4384 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
4386 return "move%.w %1,%0\;sub%.l %R0,%R0";
4389 (define_insn "*ashldi3_const1"
4390 [(set (match_operand:DI 0 "register_operand" "=d")
4391 (ashift:DI (match_operand:DI 1 "register_operand" "0")
4394 "add%.l %R0,%R0\;addx%.l %0,%0")
4397 [(set (match_operand:DI 0 "register_operand" "")
4398 (ashift:DI (match_operand:DI 1 "register_operand" "")
4400 "reload_completed && !TARGET_COLDFIRE"
4402 (ashift:DI (match_dup 1) (const_int 1)))
4404 (ashift:DI (match_dup 0) (const_int 1)))]
4408 [(set (match_operand:DI 0 "register_operand" "")
4409 (ashift:DI (match_operand:DI 1 "register_operand" "")
4411 "reload_completed && !TARGET_COLDFIRE"
4413 (ashift:DI (match_dup 1) (const_int 2)))
4415 (ashift:DI (match_dup 0) (const_int 1)))]
4419 [(set (match_operand:DI 0 "register_operand" "")
4420 (ashift:DI (match_operand:DI 1 "register_operand" "")
4422 "reload_completed && !TARGET_COLDFIRE"
4424 (rotate:SI (match_dup 2) (const_int 8)))
4426 (rotate:SI (match_dup 3) (const_int 8)))
4427 (set (strict_low_part (subreg:QI (match_dup 0) 3))
4428 (subreg:QI (match_dup 0) 7))
4429 (set (strict_low_part (subreg:QI (match_dup 0) 7))
4432 operands[2] = gen_highpart (SImode, operands[0]);
4433 operands[3] = gen_lowpart (SImode, operands[0]);
4437 [(set (match_operand:DI 0 "register_operand" "")
4438 (ashift:DI (match_operand:DI 1 "register_operand" "")
4440 "reload_completed && !TARGET_COLDFIRE"
4442 (rotate:SI (match_dup 2) (const_int 16)))
4444 (rotate:SI (match_dup 3) (const_int 16)))
4445 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4446 (subreg:HI (match_dup 0) 6))
4447 (set (strict_low_part (subreg:HI (match_dup 0) 6))
4450 operands[2] = gen_highpart (SImode, operands[0]);
4451 operands[3] = gen_lowpart (SImode, operands[0]);
4455 [(set (match_operand:DI 0 "pre_dec_operand" "")
4456 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4459 [(set (match_dup 0) (const_int 0))
4460 (set (match_dup 0) (match_dup 1))]
4462 operands[0] = adjust_address(operands[0], SImode, 0);
4463 operands[1] = gen_lowpart(SImode, operands[1]);
4467 [(set (match_operand:DI 0 "post_inc_operand" "")
4468 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4471 [(set (match_dup 0) (match_dup 1))
4472 (set (match_dup 0) (const_int 0))]
4474 operands[0] = adjust_address(operands[0], SImode, 0);
4475 operands[1] = gen_lowpart(SImode, operands[1]);
4478 (define_insn_and_split "*ashldi3_const32"
4479 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
4480 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
4484 "&& reload_completed"
4485 [(set (match_dup 4) (match_dup 3))
4486 (set (match_dup 2) (const_int 0))]
4487 "split_di(operands, 2, operands + 2, operands + 4);")
4490 [(set (match_operand:DI 0 "register_operand" "")
4491 (ashift:DI (match_operand:DI 1 "register_operand" "")
4492 (match_operand 2 "const_int_operand" "")))]
4493 "reload_completed && !TARGET_COLDFIRE
4494 && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
4495 [(set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 2)))
4496 (set (match_dup 3) (match_dup 4))
4497 (set (match_dup 4) (const_int 0))]
4499 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4500 operands[3] = gen_highpart (SImode, operands[0]);
4501 operands[4] = gen_lowpart (SImode, operands[0]);
4505 [(set (match_operand:DI 0 "register_operand" "")
4506 (ashift:DI (match_operand:DI 1 "register_operand" "")
4508 "reload_completed && !TARGET_COLDFIRE"
4509 [(set (match_dup 2) (match_dup 3))
4511 (rotate:SI (match_dup 2) (const_int 16)))
4512 (set (match_dup 3) (const_int 0))
4513 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4516 operands[2] = gen_highpart (SImode, operands[0]);
4517 operands[3] = gen_lowpart (SImode, operands[0]);
4521 [(set (match_operand:DI 0 "register_operand" "")
4522 (ashift:DI (match_operand:DI 1 "register_operand" "")
4523 (match_operand 2 "const_int_operand" "")))]
4524 "reload_completed && !TARGET_COLDFIRE
4525 && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 63"
4526 [(set (match_dup 3) (match_dup 2))
4527 (set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 3)))
4528 (set (match_dup 3) (match_dup 4))
4529 (set (match_dup 4) (const_int 0))]
4531 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4532 operands[3] = gen_highpart (SImode, operands[0]);
4533 operands[4] = gen_lowpart (SImode, operands[0]);
4536 (define_insn "*ashldi3"
4537 [(set (match_operand:DI 0 "register_operand" "=d")
4538 (ashift:DI (match_operand:DI 1 "register_operand" "0")
4539 (match_operand 2 "const_int_operand" "n")))]
4541 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4542 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4543 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4546 (define_expand "ashldi3"
4547 [(set (match_operand:DI 0 "register_operand" "")
4548 (ashift:DI (match_operand:DI 1 "register_operand" "")
4549 (match_operand 2 "const_int_operand" "")))]
4552 /* ??? This is a named pattern like this is not allowed to FAIL based
4554 if (GET_CODE (operands[2]) != CONST_INT
4555 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4556 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4557 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4561 ;; On most 68k models, this makes faster code in a special case.
4563 (define_insn "ashlsi_16"
4564 [(set (match_operand:SI 0 "register_operand" "=d")
4565 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4570 return "swap %0\;clr%.w %0";
4573 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
4574 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4576 ;; On the 68000, this makes faster code in a special case.
4578 (define_insn "ashlsi_17_24"
4579 [(set (match_operand:SI 0 "register_operand" "=d")
4580 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4581 (match_operand:SI 2 "const_int_operand" "n")))]
4583 && INTVAL (operands[2]) > 16
4584 && INTVAL (operands[2]) <= 24"
4588 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4589 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4592 (define_insn "ashlsi3"
4593 [(set (match_operand:SI 0 "register_operand" "=d")
4594 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4595 (match_operand:SI 2 "general_operand" "dI")))]
4598 if (operands[2] == const1_rtx)
4600 cc_status.flags = CC_NO_OVERFLOW;
4601 return "add%.l %0,%0";
4603 return "lsl%.l %2,%0";
4606 (define_insn "ashlhi3"
4607 [(set (match_operand:HI 0 "register_operand" "=d")
4608 (ashift:HI (match_operand:HI 1 "register_operand" "0")
4609 (match_operand:HI 2 "general_operand" "dI")))]
4614 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4615 (ashift:HI (match_dup 0)
4616 (match_operand:HI 1 "general_operand" "dI")))]
4620 (define_insn "ashlqi3"
4621 [(set (match_operand:QI 0 "register_operand" "=d")
4622 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4623 (match_operand:QI 2 "general_operand" "dI")))]
4628 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4629 (ashift:QI (match_dup 0)
4630 (match_operand:QI 1 "general_operand" "dI")))]
4634 ;; On most 68k models, this makes faster code in a special case.
4636 (define_insn "ashrsi_16"
4637 [(set (match_operand:SI 0 "register_operand" "=d")
4638 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4641 "swap %0\;ext%.l %0")
4643 ;; On the 68000, this makes faster code in a special case.
4646 [(set (match_operand:SI 0 "register_operand" "=d")
4647 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4648 (match_operand:SI 2 "const_int_operand" "n")))]
4650 && INTVAL (operands[2]) > 16
4651 && INTVAL (operands[2]) <= 24"
4653 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4654 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4657 (define_insn "subreghi1ashrdi_const32"
4658 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4659 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4660 (const_int 32)) 6))]
4663 if (GET_CODE (operands[1]) != REG)
4664 operands[1] = adjust_address (operands[1], HImode, 2);
4665 return "move%.w %1,%0";
4667 [(set_attr "type" "move")])
4669 (define_insn "subregsi1ashrdi_const32"
4670 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4671 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4672 (const_int 32)) 4))]
4675 return "move%.l %1,%0";
4677 [(set_attr "type" "move_l")])
4679 (define_insn "*ashrdi3_const1"
4680 [(set (match_operand:DI 0 "register_operand" "=d")
4681 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4685 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4686 return "asr%.l #1,%0\;roxr%.l #1,%1";
4690 [(set (match_operand:DI 0 "register_operand" "")
4691 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4693 "reload_completed && !TARGET_COLDFIRE"
4695 (ashiftrt:DI (match_dup 1) (const_int 1)))
4697 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4701 [(set (match_operand:DI 0 "register_operand" "")
4702 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4704 "reload_completed && !TARGET_COLDFIRE"
4706 (ashiftrt:DI (match_dup 1) (const_int 2)))
4708 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4712 [(set (match_operand:DI 0 "register_operand" "")
4713 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4715 "reload_completed && !TARGET_COLDFIRE"
4716 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4717 (subreg:QI (match_dup 0) 3))
4719 (ashiftrt:SI (match_dup 2) (const_int 8)))
4721 (rotatert:SI (match_dup 3) (const_int 8)))]
4723 operands[2] = gen_highpart (SImode, operands[0]);
4724 operands[3] = gen_lowpart (SImode, operands[0]);
4728 [(set (match_operand:DI 0 "register_operand" "")
4729 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4731 "reload_completed && !TARGET_COLDFIRE"
4732 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4733 (subreg:HI (match_dup 0) 2))
4735 (rotate:SI (match_dup 2) (const_int 16)))
4737 (rotate:SI (match_dup 3) (const_int 16)))
4739 (sign_extend:SI (subreg:HI (match_dup 2) 2)))]
4741 operands[2] = gen_highpart (SImode, operands[0]);
4742 operands[3] = gen_lowpart (SImode, operands[0]);
4745 (define_insn "*ashrdi_const32"
4746 [(set (match_operand:DI 0 "register_operand" "=d")
4747 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro")
4753 return "move%.l %1,%R0\;smi %0\;extb%.l %0";
4755 return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
4758 (define_insn "*ashrdi_const32_mem"
4759 [(set (match_operand:DI 0 "memory_operand" "=o,<")
4760 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro,ro")
4762 (clobber (match_scratch:SI 2 "=d,d"))]
4766 operands[3] = adjust_address (operands[0], SImode,
4767 which_alternative == 0 ? 4 : 0);
4768 operands[0] = adjust_address (operands[0], SImode, 0);
4769 if (TARGET_68020 || TARGET_COLDFIRE)
4770 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4772 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4776 [(set (match_operand:DI 0 "register_operand" "")
4777 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4779 "reload_completed && !TARGET_COLDFIRE"
4781 (ashiftrt:SI (match_dup 3) (const_int 31)))
4784 "split_di(operands, 1, operands + 2, operands + 3);")
4786 ;; The predicate below must be general_operand, because ashrdi3 allows that
4787 (define_insn "ashrdi_const"
4788 [(set (match_operand:DI 0 "register_operand" "=d")
4789 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4790 (match_operand 2 "const_int_operand" "n")))]
4792 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4793 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4794 || INTVAL (operands[2]) == 31
4795 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4797 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4799 if (INTVAL (operands[2]) == 48)
4800 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4801 if (INTVAL (operands[2]) == 31)
4802 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4803 if (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)
4805 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4806 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4807 "moveq %2,%1\;asr%.l %1,%0", operands);
4808 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4809 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4810 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4815 (define_expand "ashrdi3"
4816 [(set (match_operand:DI 0 "register_operand" "")
4817 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4818 (match_operand 2 "const_int_operand" "")))]
4821 /* ??? This is a named pattern like this is not allowed to FAIL based
4823 if (GET_CODE (operands[2]) != CONST_INT
4824 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4825 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4826 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4830 ;; On all 68k models, this makes faster code in a special case.
4832 (define_insn "ashrsi_31"
4833 [(set (match_operand:SI 0 "register_operand" "=d")
4834 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4838 return "add%.l %0,%0\;subx%.l %0,%0";
4841 (define_insn "ashrsi3"
4842 [(set (match_operand:SI 0 "register_operand" "=d")
4843 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4844 (match_operand:SI 2 "general_operand" "dI")))]
4847 [(set_attr "type" "shift")
4848 (set_attr "opy" "2")])
4850 (define_insn "ashrhi3"
4851 [(set (match_operand:HI 0 "register_operand" "=d")
4852 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4853 (match_operand:HI 2 "general_operand" "dI")))]
4858 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4859 (ashiftrt:HI (match_dup 0)
4860 (match_operand:HI 1 "general_operand" "dI")))]
4864 (define_insn "ashrqi3"
4865 [(set (match_operand:QI 0 "register_operand" "=d")
4866 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4867 (match_operand:QI 2 "general_operand" "dI")))]
4872 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4873 (ashiftrt:QI (match_dup 0)
4874 (match_operand:QI 1 "general_operand" "dI")))]
4878 ;; logical shift instructions
4880 ;; commented out because of reload problems in 950612-1.c
4883 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4884 ;; (const_int 32)) 4))
4885 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4886 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4887 ;; (const_int 32)) 4))]
4890 ;; return "move%.l %0,%1";
4895 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4896 ;; (const_int 32)) 0))
4897 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4898 ;; (lshiftrt:DI (match_dup 0)
4899 ;; (const_int 32)))]
4902 ;; if (GET_CODE (operands[1]) == REG)
4903 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4905 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4906 ;; return "move%.l %0,%2\;clr%.l %1";
4909 (define_insn "subreg1lshrdi_const32"
4910 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4911 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4912 (const_int 32)) 4))]
4915 [(set_attr "type" "move_l")])
4917 (define_insn "*lshrdi3_const1"
4918 [(set (match_operand:DI 0 "register_operand" "=d")
4919 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
4922 "lsr%.l #1,%0\;roxr%.l #1,%R0")
4925 [(set (match_operand:DI 0 "register_operand" "")
4926 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4928 "reload_completed && !TARGET_COLDFIRE"
4930 (lshiftrt:DI (match_dup 1) (const_int 1)))
4932 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4936 [(set (match_operand:DI 0 "register_operand" "")
4937 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4939 "reload_completed && !TARGET_COLDFIRE"
4941 (lshiftrt:DI (match_dup 1) (const_int 2)))
4943 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4947 [(set (match_operand:DI 0 "register_operand" "")
4948 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4950 "reload_completed && !TARGET_COLDFIRE"
4951 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4952 (subreg:QI (match_dup 0) 3))
4954 (lshiftrt:SI (match_dup 2) (const_int 8)))
4956 (rotatert:SI (match_dup 3) (const_int 8)))]
4958 operands[2] = gen_highpart (SImode, operands[0]);
4959 operands[3] = gen_lowpart (SImode, operands[0]);
4963 [(set (match_operand:DI 0 "register_operand" "")
4964 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4966 "reload_completed && !TARGET_COLDFIRE"
4967 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4968 (subreg:HI (match_dup 0) 2))
4969 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4972 (rotate:SI (match_dup 3) (const_int 16)))
4974 (rotate:SI (match_dup 2) (const_int 16)))]
4976 operands[2] = gen_highpart (SImode, operands[0]);
4977 operands[3] = gen_lowpart (SImode, operands[0]);
4981 [(set (match_operand:DI 0 "pre_dec_operand" "")
4982 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
4985 [(set (match_dup 0) (match_dup 1))
4986 (set (match_dup 0) (const_int 0))]
4988 operands[0] = adjust_address(operands[0], SImode, 0);
4989 operands[1] = gen_highpart(SImode, operands[1]);
4993 [(set (match_operand:DI 0 "post_inc_operand" "")
4994 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
4997 [(set (match_dup 0) (const_int 0))
4998 (set (match_dup 0) (match_dup 1))]
5000 operands[0] = adjust_address(operands[0], SImode, 0);
5001 operands[1] = gen_highpart(SImode, operands[1]);
5005 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5006 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5009 [(set (match_dup 2) (match_dup 5))
5010 (set (match_dup 4) (const_int 0))]
5011 "split_di(operands, 2, operands + 2, operands + 4);")
5013 (define_insn "*lshrdi_const32"
5014 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
5015 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
5021 [(set (match_operand:DI 0 "register_operand" "")
5022 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5023 (match_operand 2 "const_int_operand" "")))]
5024 "reload_completed && !TARGET_COLDFIRE
5025 && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
5026 [(set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 2)))
5027 (set (match_dup 4) (match_dup 3))
5028 (set (match_dup 3) (const_int 0))]
5030 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5031 operands[3] = gen_highpart (SImode, operands[0]);
5032 operands[4] = gen_lowpart (SImode, operands[0]);
5036 [(set (match_operand:DI 0 "register_operand" "")
5037 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5040 [(set (match_dup 3) (match_dup 2))
5041 (set (strict_low_part (subreg:HI (match_dup 0) 6))
5043 (set (match_dup 2) (const_int 0))
5045 (rotate:SI (match_dup 3) (const_int 16)))]
5047 operands[2] = gen_highpart (SImode, operands[0]);
5048 operands[3] = gen_lowpart (SImode, operands[0]);
5052 [(set (match_operand:DI 0 "register_operand" "")
5053 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5054 (match_operand 2 "const_int_operand" "")))]
5055 "reload_completed && !TARGET_COLDFIRE
5056 && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 62"
5057 [(set (match_dup 4) (match_dup 2))
5058 (set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 4)))
5059 (set (match_dup 4) (match_dup 3))
5060 (set (match_dup 3) (const_int 0))]
5062 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5063 operands[3] = gen_highpart (SImode, operands[0]);
5064 operands[4] = gen_lowpart (SImode, operands[0]);
5067 (define_insn "*lshrdi_const63"
5068 [(set (match_operand:DI 0 "register_operand" "=d")
5069 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5072 "add%.l %0,%0\;clr%.l %0\;clr%.l %R1\;addx%.l %R1,%R1")
5074 (define_insn "*lshrdi3_const"
5075 [(set (match_operand:DI 0 "register_operand" "=d")
5076 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5077 (match_operand 2 "const_int_operand" "n")))]
5079 && ((INTVAL (operands[2]) >= 2 && INTVAL (operands[2]) <= 3)
5080 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
5081 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
5084 (define_expand "lshrdi3"
5085 [(set (match_operand:DI 0 "register_operand" "")
5086 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5087 (match_operand 2 "const_int_operand" "")))]
5090 /* ??? This is a named pattern like this is not allowed to FAIL based
5092 if (GET_CODE (operands[2]) != CONST_INT
5093 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
5094 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
5095 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
5099 ;; On all 68k models, this makes faster code in a special case.
5101 (define_insn "lshrsi_31"
5102 [(set (match_operand:SI 0 "register_operand" "=d")
5103 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5107 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
5110 ;; On most 68k models, this makes faster code in a special case.
5112 (define_insn "lshrsi_16"
5113 [(set (match_operand:SI 0 "register_operand" "=d")
5114 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5119 return "clr%.w %0\;swap %0";
5122 ;; On the 68000, this makes faster code in a special case.
5124 (define_insn "lshrsi_17_24"
5125 [(set (match_operand:SI 0 "register_operand" "=d")
5126 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5127 (match_operand:SI 2 "const_int_operand" "n")))]
5129 && INTVAL (operands[2]) > 16
5130 && INTVAL (operands[2]) <= 24"
5132 /* I think lsr%.w sets the CC properly. */
5133 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
5134 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
5137 (define_insn "lshrsi3"
5138 [(set (match_operand:SI 0 "register_operand" "=d")
5139 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5140 (match_operand:SI 2 "general_operand" "dI")))]
5143 [(set_attr "type" "shift")
5144 (set_attr "opy" "2")])
5146 (define_insn "lshrhi3"
5147 [(set (match_operand:HI 0 "register_operand" "=d")
5148 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
5149 (match_operand:HI 2 "general_operand" "dI")))]
5154 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5155 (lshiftrt:HI (match_dup 0)
5156 (match_operand:HI 1 "general_operand" "dI")))]
5160 (define_insn "lshrqi3"
5161 [(set (match_operand:QI 0 "register_operand" "=d")
5162 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
5163 (match_operand:QI 2 "general_operand" "dI")))]
5168 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5169 (lshiftrt:QI (match_dup 0)
5170 (match_operand:QI 1 "general_operand" "dI")))]
5174 ;; rotate instructions
5176 (define_insn "rotlsi_16"
5177 [(set (match_operand:SI 0 "register_operand" "=d")
5178 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5182 [(set_attr "type" "shift")])
5184 (define_insn "rotlsi3"
5185 [(set (match_operand:SI 0 "register_operand" "=d")
5186 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5187 (match_operand:SI 2 "general_operand" "dINO")))]
5190 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
5192 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
5194 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
5195 return "ror%.l %2,%0";
5198 return "rol%.l %2,%0";
5201 (define_insn "rotlhi3"
5202 [(set (match_operand:HI 0 "register_operand" "=d")
5203 (rotate:HI (match_operand:HI 1 "register_operand" "0")
5204 (match_operand:HI 2 "general_operand" "dIP")))]
5207 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5209 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5210 return "ror%.w %2,%0";
5213 return "rol%.w %2,%0";
5217 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5218 (rotate:HI (match_dup 0)
5219 (match_operand:HI 1 "general_operand" "dIP")))]
5222 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5224 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5225 return "ror%.w %2,%0";
5228 return "rol%.w %2,%0";
5231 (define_insn "rotlqi3"
5232 [(set (match_operand:QI 0 "register_operand" "=d")
5233 (rotate:QI (match_operand:QI 1 "register_operand" "0")
5234 (match_operand:QI 2 "general_operand" "dI")))]
5237 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5239 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5240 return "ror%.b %2,%0";
5243 return "rol%.b %2,%0";
5247 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5248 (rotate:QI (match_dup 0)
5249 (match_operand:QI 1 "general_operand" "dI")))]
5252 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5254 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5255 return "ror%.b %2,%0";
5258 return "rol%.b %2,%0";
5261 (define_insn "rotrsi3"
5262 [(set (match_operand:SI 0 "register_operand" "=d")
5263 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
5264 (match_operand:SI 2 "general_operand" "dI")))]
5268 (define_insn "rotrhi3"
5269 [(set (match_operand:HI 0 "register_operand" "=d")
5270 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
5271 (match_operand:HI 2 "general_operand" "dI")))]
5275 (define_insn "rotrhi_lowpart"
5276 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5277 (rotatert:HI (match_dup 0)
5278 (match_operand:HI 1 "general_operand" "dI")))]
5282 (define_insn "rotrqi3"
5283 [(set (match_operand:QI 0 "register_operand" "=d")
5284 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
5285 (match_operand:QI 2 "general_operand" "dI")))]
5290 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5291 (rotatert:QI (match_dup 0)
5292 (match_operand:QI 1 "general_operand" "dI")))]
5296 (define_expand "bswapsi2"
5297 [(set (match_operand:SI 0 "register_operand")
5298 (bswap:SI (match_operand:SI 1 "register_operand")))]
5301 rtx x = operands[0];
5302 emit_move_insn (x, operands[1]);
5303 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5304 emit_insn (gen_rotlsi3 (x, x, GEN_INT (16)));
5305 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5310 ;; Bit set/clear in memory byte.
5312 ;; set bit, bit number is int
5313 (define_insn "bsetmemqi"
5314 [(set (match_operand:QI 0 "memory_operand" "+m")
5315 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5316 (match_operand:SI 1 "general_operand" "d")) 3)
5321 return "bset %1,%0";
5323 [(set_attr "type" "bitrw")])
5325 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
5326 (define_insn "*bsetmemqi_ext"
5327 [(set (match_operand:QI 0 "memory_operand" "+m")
5328 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5329 (match_operator:SI 2 "extend_operator"
5330 [(match_operand 1 "general_operand" "d")])) 3)
5335 return "bset %1,%0";
5337 [(set_attr "type" "bitrw")])
5339 ;; clear bit, bit number is int
5340 (define_insn "bclrmemqi"
5341 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5343 (minus:SI (const_int 7)
5344 (match_operand:SI 1 "general_operand" "d")))
5349 return "bclr %1,%0";
5351 [(set_attr "type" "bitrw")])
5353 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
5354 (define_insn "*bclrmemqi_ext"
5355 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5357 (minus:SI (const_int 7)
5358 (match_operator:SI 2 "extend_operator"
5359 [(match_operand 1 "general_operand" "d")])))
5364 return "bclr %1,%0";
5366 [(set_attr "type" "bitrw")])
5368 ;; Special cases of bit-field insns which we should
5369 ;; recognize in preference to the general case.
5370 ;; These handle aligned 8-bit and 16-bit fields,
5371 ;; which can usually be done with move instructions.
5374 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5375 ; alignment of structure members is specified.
5377 ; The move is allowed to be odd byte aligned, because that's still faster
5378 ; than an odd byte aligned bit-field instruction.
5380 (define_insn "*insv_32_mem"
5381 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5383 (match_operand:SI 1 "const_int_operand" "n"))
5384 (match_operand:SI 2 "general_src_operand" "rmSi"))]
5385 "TARGET_68020 && TARGET_BITFIELD
5386 && (INTVAL (operands[1]) % 8) == 0
5387 && ! mode_dependent_address_p (XEXP (operands[0], 0),
5388 MEM_ADDR_SPACE (operands[0]))"
5391 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
5393 return "move%.l %2,%0";
5396 (define_insn "*insv_8_16_reg"
5397 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5398 (match_operand:SI 1 "const_int_operand" "n")
5399 (match_operand:SI 2 "const_int_operand" "n"))
5400 (match_operand:SI 3 "register_operand" "d"))]
5401 "TARGET_68020 && TARGET_BITFIELD
5402 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
5403 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0"
5405 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
5406 return "bfins %3,%0{%b2:%b1}";
5408 if (INTVAL (operands[1]) == 8)
5409 return "move%.b %3,%0";
5410 return "move%.w %3,%0";
5415 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5416 ; alignment of structure members is specified.
5418 ; The move is allowed to be odd byte aligned, because that's still faster
5419 ; than an odd byte aligned bit-field instruction.
5421 (define_insn "*extzv_32_mem"
5422 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5423 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5425 (match_operand:SI 2 "const_int_operand" "n")))]
5426 "TARGET_68020 && TARGET_BITFIELD
5427 && (INTVAL (operands[2]) % 8) == 0
5428 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5429 MEM_ADDR_SPACE (operands[1]))"
5432 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5434 return "move%.l %1,%0";
5437 (define_insn "*extzv_8_16_reg"
5438 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
5439 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5440 (match_operand:SI 2 "const_int_operand" "n")
5441 (match_operand:SI 3 "const_int_operand" "n")))]
5442 "TARGET_68020 && TARGET_BITFIELD
5443 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5444 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5446 cc_status.flags |= CC_NOT_NEGATIVE;
5447 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5448 return "bfextu %1{%b3:%b2},%0";
5450 output_asm_insn ("clr%.l %0", operands);
5451 if (INTVAL (operands[2]) == 8)
5452 return "move%.b %1,%0";
5453 return "move%.w %1,%0";
5457 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5458 ; alignment of structure members is specified.
5460 ; The move is allowed to be odd byte aligned, because that's still faster
5461 ; than an odd byte aligned bit-field instruction.
5463 (define_insn "*extv_32_mem"
5464 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5465 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5467 (match_operand:SI 2 "const_int_operand" "n")))]
5468 "TARGET_68020 && TARGET_BITFIELD
5469 && (INTVAL (operands[2]) % 8) == 0
5470 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5471 MEM_ADDR_SPACE (operands[1]))"
5474 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5476 return "move%.l %1,%0";
5479 (define_insn "*extv_8_16_reg"
5480 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5481 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5482 (match_operand:SI 2 "const_int_operand" "n")
5483 (match_operand:SI 3 "const_int_operand" "n")))]
5484 "TARGET_68020 && TARGET_BITFIELD
5485 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5486 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5488 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5489 return "bfexts %1{%b3:%b2},%0";
5491 if (INTVAL (operands[2]) == 8)
5492 return "move%.b %1,%0\;extb%.l %0";
5493 return "move%.w %1,%0\;ext%.l %0";
5496 ;; Bit-field instructions, general cases.
5497 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
5498 ;; so that its address is reloaded.
5500 (define_expand "extv"
5501 [(set (match_operand:SI 0 "register_operand" "")
5502 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
5503 (match_operand:SI 2 "const_int_operand" "")
5504 (match_operand:SI 3 "const_int_operand" "")))]
5505 "TARGET_68020 && TARGET_BITFIELD"
5508 (define_insn "*extv_bfexts_mem"
5509 [(set (match_operand:SI 0 "register_operand" "=d")
5510 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
5511 (match_operand:SI 2 "nonmemory_operand" "dn")
5512 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5513 "TARGET_68020 && TARGET_BITFIELD"
5514 "bfexts %1{%b3:%b2},%0")
5516 (define_expand "extzv"
5517 [(set (match_operand:SI 0 "register_operand" "")
5518 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
5519 (match_operand:SI 2 "const_int_operand" "")
5520 (match_operand:SI 3 "const_int_operand" "")))]
5521 "TARGET_68020 && TARGET_BITFIELD"
5524 (define_insn "*extzv_bfextu_mem"
5525 [(set (match_operand:SI 0 "register_operand" "=d")
5526 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o")
5527 (match_operand:SI 2 "nonmemory_operand" "dn")
5528 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5529 "TARGET_68020 && TARGET_BITFIELD"
5531 if (GET_CODE (operands[2]) == CONST_INT)
5533 if (INTVAL (operands[2]) != 32)
5534 cc_status.flags |= CC_NOT_NEGATIVE;
5540 return "bfextu %1{%b3:%b2},%0";
5543 (define_insn "*insv_bfchg_mem"
5544 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5545 (match_operand:SI 1 "nonmemory_operand" "dn")
5546 (match_operand:SI 2 "nonmemory_operand" "dn"))
5547 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
5548 (match_operand 3 "const_int_operand" "n")))]
5549 "TARGET_68020 && TARGET_BITFIELD
5550 && (INTVAL (operands[3]) == -1
5551 || (GET_CODE (operands[1]) == CONST_INT
5552 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
5555 return "bfchg %0{%b2:%b1}";
5558 (define_insn "*insv_bfclr_mem"
5559 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5560 (match_operand:SI 1 "nonmemory_operand" "dn")
5561 (match_operand:SI 2 "nonmemory_operand" "dn"))
5563 "TARGET_68020 && TARGET_BITFIELD"
5566 return "bfclr %0{%b2:%b1}";
5569 (define_insn "*insv_bfset_mem"
5570 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5571 (match_operand:SI 1 "general_operand" "dn")
5572 (match_operand:SI 2 "general_operand" "dn"))
5574 "TARGET_68020 && TARGET_BITFIELD"
5577 return "bfset %0{%b2:%b1}";
5580 (define_expand "insv"
5581 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5582 (match_operand:SI 1 "const_int_operand" "")
5583 (match_operand:SI 2 "const_int_operand" ""))
5584 (match_operand:SI 3 "register_operand" ""))]
5585 "TARGET_68020 && TARGET_BITFIELD"
5588 (define_insn "*insv_bfins_mem"
5589 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5590 (match_operand:SI 1 "nonmemory_operand" "dn")
5591 (match_operand:SI 2 "nonmemory_operand" "dn"))
5592 (match_operand:SI 3 "register_operand" "d"))]
5593 "TARGET_68020 && TARGET_BITFIELD"
5594 "bfins %3,%0{%b2:%b1}")
5596 ;; Now recognize bit-field insns that operate on registers
5597 ;; (or at least were intended to do so).
5599 (define_insn "*extv_bfexts_reg"
5600 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5601 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5602 (match_operand:SI 2 "const_int_operand" "n")
5603 (match_operand:SI 3 "const_int_operand" "n")))]
5604 "TARGET_68020 && TARGET_BITFIELD"
5605 "bfexts %1{%b3:%b2},%0")
5607 (define_insn "*extv_bfextu_reg"
5608 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5609 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5610 (match_operand:SI 2 "const_int_operand" "n")
5611 (match_operand:SI 3 "const_int_operand" "n")))]
5612 "TARGET_68020 && TARGET_BITFIELD"
5614 if (GET_CODE (operands[2]) == CONST_INT)
5616 if (INTVAL (operands[2]) != 32)
5617 cc_status.flags |= CC_NOT_NEGATIVE;
5623 return "bfextu %1{%b3:%b2},%0";
5626 (define_insn "*insv_bfclr_reg"
5627 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5628 (match_operand:SI 1 "const_int_operand" "n")
5629 (match_operand:SI 2 "const_int_operand" "n"))
5631 "TARGET_68020 && TARGET_BITFIELD"
5634 return "bfclr %0{%b2:%b1}";
5637 (define_insn "*insv_bfset_reg"
5638 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5639 (match_operand:SI 1 "const_int_operand" "n")
5640 (match_operand:SI 2 "const_int_operand" "n"))
5642 "TARGET_68020 && TARGET_BITFIELD"
5645 return "bfset %0{%b2:%b1}";
5648 (define_insn "*insv_bfins_reg"
5649 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5650 (match_operand:SI 1 "const_int_operand" "n")
5651 (match_operand:SI 2 "const_int_operand" "n"))
5652 (match_operand:SI 3 "register_operand" "d"))]
5653 "TARGET_68020 && TARGET_BITFIELD"
5656 /* These special cases are now recognized by a specific pattern. */
5657 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5658 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5659 return "move%.w %3,%0";
5660 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5661 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5662 return "move%.b %3,%0";
5664 return "bfins %3,%0{%b2:%b1}";
5667 ;; Special patterns for optimizing bit-field instructions.
5669 (define_insn "*tst_bftst_mem"
5671 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5672 (match_operand:SI 1 "const_int_operand" "n")
5673 (match_operand:SI 2 "general_operand" "dn"))
5675 "TARGET_68020 && TARGET_BITFIELD"
5677 if (operands[1] == const1_rtx
5678 && GET_CODE (operands[2]) == CONST_INT)
5680 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5681 return output_btst (operands,
5682 GEN_INT (width - INTVAL (operands[2])),
5683 operands[0], insn, 1000);
5684 /* Pass 1000 as SIGNPOS argument so that btst will
5685 not think we are testing the sign bit for an `and'
5686 and assume that nonzero implies a negative result. */
5688 if (INTVAL (operands[1]) != 32)
5689 cc_status.flags = CC_NOT_NEGATIVE;
5690 return "bftst %0{%b2:%b1}";
5694 ;;; now handle the register cases
5695 (define_insn "*tst_bftst_reg"
5697 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5698 (match_operand:SI 1 "const_int_operand" "n")
5699 (match_operand:SI 2 "general_operand" "dn"))
5701 "TARGET_68020 && TARGET_BITFIELD"
5703 if (operands[1] == const1_rtx
5704 && GET_CODE (operands[2]) == CONST_INT)
5706 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5707 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5708 operands[0], insn, 1000);
5709 /* Pass 1000 as SIGNPOS argument so that btst will
5710 not think we are testing the sign bit for an `and'
5711 and assume that nonzero implies a negative result. */
5713 if (INTVAL (operands[1]) != 32)
5714 cc_status.flags = CC_NOT_NEGATIVE;
5715 return "bftst %0{%b2:%b1}";
5718 (define_insn "scc0_di"
5719 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5720 (match_operator 1 "ordered_comparison_operator"
5721 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5724 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5727 (define_insn "scc0_di_5200"
5728 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5729 (match_operator 1 "ordered_comparison_operator"
5730 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5733 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5736 (define_insn "scc_di"
5737 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5738 (match_operator 1 "ordered_comparison_operator"
5739 [(match_operand:DI 2 "general_operand" "ro,r")
5740 (match_operand:DI 3 "general_operand" "r,ro")]))]
5743 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5746 (define_insn "scc_di_5200"
5747 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5748 (match_operator 1 "ordered_comparison_operator"
5749 [(match_operand:DI 2 "general_operand" "ro,r")
5750 (match_operand:DI 3 "general_operand" "r,ro")]))]
5753 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5756 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5757 ;; memory, but we cannot allow it to be in memory in case the address
5758 ;; needs to be reloaded.
5761 [(set (match_operand:QI 0 "register_operand" "=d")
5762 (eq:QI (cc0) (const_int 0)))]
5765 cc_status = cc_prev_status;
5766 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5770 [(set (match_operand:QI 0 "register_operand" "=d")
5771 (ne:QI (cc0) (const_int 0)))]
5774 cc_status = cc_prev_status;
5775 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5779 [(set (match_operand:QI 0 "register_operand" "=d")
5780 (gt:QI (cc0) (const_int 0)))]
5783 cc_status = cc_prev_status;
5784 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5788 [(set (match_operand:QI 0 "register_operand" "=d")
5789 (gtu:QI (cc0) (const_int 0)))]
5792 cc_status = cc_prev_status;
5797 [(set (match_operand:QI 0 "register_operand" "=d")
5798 (lt:QI (cc0) (const_int 0)))]
5801 cc_status = cc_prev_status;
5802 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5806 [(set (match_operand:QI 0 "register_operand" "=d")
5807 (ltu:QI (cc0) (const_int 0)))]
5810 cc_status = cc_prev_status;
5815 [(set (match_operand:QI 0 "register_operand" "=d")
5816 (ge:QI (cc0) (const_int 0)))]
5819 cc_status = cc_prev_status;
5820 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5824 [(set (match_operand:QI 0 "register_operand" "=d")
5825 (geu:QI (cc0) (const_int 0)))]
5828 cc_status = cc_prev_status;
5831 [(set_attr "type" "scc")])
5834 [(set (match_operand:QI 0 "register_operand" "=d")
5835 (le:QI (cc0) (const_int 0)))]
5838 cc_status = cc_prev_status;
5839 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5843 [(set (match_operand:QI 0 "register_operand" "=d")
5844 (leu:QI (cc0) (const_int 0)))]
5847 cc_status = cc_prev_status;
5850 [(set_attr "type" "scc")])
5852 (define_insn "*sordered_1"
5853 [(set (match_operand:QI 0 "register_operand" "=d")
5854 (ordered:QI (cc0) (const_int 0)))]
5855 "TARGET_68881 && !TUNE_68060"
5857 cc_status = cc_prev_status;
5861 (define_insn "*sunordered_1"
5862 [(set (match_operand:QI 0 "register_operand" "=d")
5863 (unordered:QI (cc0) (const_int 0)))]
5864 "TARGET_68881 && !TUNE_68060"
5866 cc_status = cc_prev_status;
5870 (define_insn "*suneq_1"
5871 [(set (match_operand:QI 0 "register_operand" "=d")
5872 (uneq:QI (cc0) (const_int 0)))]
5873 "TARGET_68881 && !TUNE_68060"
5875 cc_status = cc_prev_status;
5879 (define_insn "*sunge_1"
5880 [(set (match_operand:QI 0 "register_operand" "=d")
5881 (unge:QI (cc0) (const_int 0)))]
5882 "TARGET_68881 && !TUNE_68060"
5884 cc_status = cc_prev_status;
5888 (define_insn "*sungt_1"
5889 [(set (match_operand:QI 0 "register_operand" "=d")
5890 (ungt:QI (cc0) (const_int 0)))]
5891 "TARGET_68881 && !TUNE_68060"
5893 cc_status = cc_prev_status;
5897 (define_insn "*sunle_1"
5898 [(set (match_operand:QI 0 "register_operand" "=d")
5899 (unle:QI (cc0) (const_int 0)))]
5900 "TARGET_68881 && !TUNE_68060"
5902 cc_status = cc_prev_status;
5906 (define_insn "*sunlt_1"
5907 [(set (match_operand:QI 0 "register_operand" "=d")
5908 (unlt:QI (cc0) (const_int 0)))]
5909 "TARGET_68881 && !TUNE_68060"
5911 cc_status = cc_prev_status;
5915 (define_insn "*sltgt_1"
5916 [(set (match_operand:QI 0 "register_operand" "=d")
5917 (ltgt:QI (cc0) (const_int 0)))]
5918 "TARGET_68881 && !TUNE_68060"
5920 cc_status = cc_prev_status;
5924 (define_insn "*fsogt_1"
5925 [(set (match_operand:QI 0 "register_operand" "=d")
5926 (not:QI (unle:QI (cc0) (const_int 0))))]
5927 "TARGET_68881 && !TUNE_68060"
5929 cc_status = cc_prev_status;
5933 (define_insn "*fsoge_1"
5934 [(set (match_operand:QI 0 "register_operand" "=d")
5935 (not:QI (unlt:QI (cc0) (const_int 0))))]
5936 "TARGET_68881 && !TUNE_68060"
5938 cc_status = cc_prev_status;
5942 (define_insn "*fsolt_1"
5943 [(set (match_operand:QI 0 "register_operand" "=d")
5944 (not:QI (unge:QI (cc0) (const_int 0))))]
5945 "TARGET_68881 && !TUNE_68060"
5947 cc_status = cc_prev_status;
5951 (define_insn "*fsole_1"
5952 [(set (match_operand:QI 0 "register_operand" "=d")
5953 (not:QI (ungt:QI (cc0) (const_int 0))))]
5954 "TARGET_68881 && !TUNE_68060"
5956 cc_status = cc_prev_status;
5960 ;; Basic conditional jump instructions.
5962 (define_insn "beq0_di"
5964 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*ao,<>")
5966 (label_ref (match_operand 1 "" ","))
5968 (clobber (match_scratch:SI 2 "=d,d"))]
5972 if (which_alternative == 1)
5973 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5974 if ((cc_prev_status.value1
5975 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5976 || (cc_prev_status.value2
5977 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5979 cc_status = cc_prev_status;
5982 if (GET_CODE (operands[0]) == REG)
5983 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5985 operands[3] = adjust_address (operands[0], SImode, 4);
5986 if (! ADDRESS_REG_P (operands[0]))
5988 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5990 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5991 return "or%.l %0,%2\;jeq %l1";
5993 return "or%.l %3,%2\;jeq %l1";
5995 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5997 operands[4] = gen_label_rtx();
5998 if (TARGET_68020 || TARGET_COLDFIRE)
5999 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
6001 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
6002 (*targetm.asm_out.internal_label) (asm_out_file, "L",
6003 CODE_LABEL_NUMBER (operands[4]));
6007 (define_insn "bne0_di"
6009 (if_then_else (ne (match_operand:DI 0 "general_operand" "do,*a")
6011 (label_ref (match_operand 1 "" ","))
6013 (clobber (match_scratch:SI 2 "=d,X"))]
6016 if ((cc_prev_status.value1
6017 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6018 || (cc_prev_status.value2
6019 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6021 cc_status = cc_prev_status;
6025 if (GET_CODE (operands[0]) == REG)
6026 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6028 operands[3] = adjust_address (operands[0], SImode, 4);
6029 if (!ADDRESS_REG_P (operands[0]))
6031 if (reg_overlap_mentioned_p (operands[2], operands[0]))
6033 if (reg_overlap_mentioned_p (operands[2], operands[3]))
6034 return "or%.l %0,%2\;jne %l1";
6036 return "or%.l %3,%2\;jne %l1";
6038 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
6040 if (TARGET_68020 || TARGET_COLDFIRE)
6041 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
6043 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
6046 (define_insn "bge0_di"
6048 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
6050 (label_ref (match_operand 1 "" ""))
6054 if ((cc_prev_status.value1
6055 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6056 || (cc_prev_status.value2
6057 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6059 cc_status = cc_prev_status;
6060 return cc_status.flags & CC_REVERSED ? "jle %l1" : "jpl %l1";
6063 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6064 output_asm_insn("tst%.l %0", operands);
6067 /* On an address reg, cmpw may replace cmpl. */
6068 output_asm_insn("cmp%.w #0,%0", operands);
6073 (define_insn "blt0_di"
6075 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
6077 (label_ref (match_operand 1 "" ""))
6081 if ((cc_prev_status.value1
6082 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6083 || (cc_prev_status.value2
6084 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6086 cc_status = cc_prev_status;
6087 return cc_status.flags & CC_REVERSED ? "jgt %l1" : "jmi %l1";
6090 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6091 output_asm_insn("tst%.l %0", operands);
6094 /* On an address reg, cmpw may replace cmpl. */
6095 output_asm_insn("cmp%.w #0,%0", operands);
6102 (if_then_else (eq (cc0)
6104 (label_ref (match_operand 0 "" ""))
6108 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6110 [(set_attr "type" "bcc")])
6114 (if_then_else (ne (cc0)
6116 (label_ref (match_operand 0 "" ""))
6120 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6122 [(set_attr "type" "bcc")])
6126 (if_then_else (gt (cc0)
6128 (label_ref (match_operand 0 "" ""))
6132 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6134 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6138 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
6140 [(set_attr "type" "bcc")])
6144 (if_then_else (gtu (cc0)
6146 (label_ref (match_operand 0 "" ""))
6150 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6152 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6158 [(set_attr "type" "bcc")])
6162 (if_then_else (lt (cc0)
6164 (label_ref (match_operand 0 "" ""))
6168 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6170 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6174 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
6176 [(set_attr "type" "bcc")])
6180 (if_then_else (ltu (cc0)
6182 (label_ref (match_operand 0 "" ""))
6186 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6188 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6194 [(set_attr "type" "bcc")])
6198 (if_then_else (ge (cc0)
6200 (label_ref (match_operand 0 "" ""))
6204 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6206 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6210 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
6215 (if_then_else (geu (cc0)
6217 (label_ref (match_operand 0 "" ""))
6221 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6223 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6229 [(set_attr "type" "bcc")])
6233 (if_then_else (le (cc0)
6235 (label_ref (match_operand 0 "" ""))
6239 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6241 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6245 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
6247 [(set_attr "type" "bcc")])
6251 (if_then_else (leu (cc0)
6253 (label_ref (match_operand 0 "" ""))
6257 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6259 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6265 [(set_attr "type" "bcc")])
6267 (define_insn "bordered"
6269 (if_then_else (ordered (cc0) (const_int 0))
6270 (label_ref (match_operand 0 "" ""))
6274 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6277 [(set_attr "type" "fbcc")])
6279 (define_insn "bunordered"
6281 (if_then_else (unordered (cc0) (const_int 0))
6282 (label_ref (match_operand 0 "" ""))
6286 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6289 [(set_attr "type" "fbcc")])
6291 (define_insn "buneq"
6293 (if_then_else (uneq (cc0) (const_int 0))
6294 (label_ref (match_operand 0 "" ""))
6298 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6301 [(set_attr "type" "fbcc")])
6303 (define_insn "bunge"
6305 (if_then_else (unge (cc0) (const_int 0))
6306 (label_ref (match_operand 0 "" ""))
6310 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6313 [(set_attr "type" "fbcc")])
6315 (define_insn "bungt"
6317 (if_then_else (ungt (cc0) (const_int 0))
6318 (label_ref (match_operand 0 "" ""))
6322 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6325 [(set_attr "type" "fbcc")])
6327 (define_insn "bunle"
6329 (if_then_else (unle (cc0) (const_int 0))
6330 (label_ref (match_operand 0 "" ""))
6334 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6337 [(set_attr "type" "fbcc")])
6339 (define_insn "bunlt"
6341 (if_then_else (unlt (cc0) (const_int 0))
6342 (label_ref (match_operand 0 "" ""))
6346 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6349 [(set_attr "type" "fbcc")])
6351 (define_insn "bltgt"
6353 (if_then_else (ltgt (cc0) (const_int 0))
6354 (label_ref (match_operand 0 "" ""))
6358 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6361 [(set_attr "type" "fbcc")])
6363 ;; Negated conditional jump instructions.
6365 (define_insn "*beq_rev"
6367 (if_then_else (eq (cc0)
6370 (label_ref (match_operand 0 "" ""))))]
6373 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6375 [(set_attr "type" "bcc")])
6377 (define_insn "*bne_rev"
6379 (if_then_else (ne (cc0)
6382 (label_ref (match_operand 0 "" ""))))]
6385 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6387 [(set_attr "type" "bcc")])
6389 (define_insn "*bgt_rev"
6391 (if_then_else (gt (cc0)
6394 (label_ref (match_operand 0 "" ""))))]
6397 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6399 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6403 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6405 [(set_attr "type" "bcc")])
6407 (define_insn "*bgtu_rev"
6409 (if_then_else (gtu (cc0)
6412 (label_ref (match_operand 0 "" ""))))]
6415 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6417 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6423 [(set_attr "type" "bcc")])
6425 (define_insn "*blt_rev"
6427 (if_then_else (lt (cc0)
6430 (label_ref (match_operand 0 "" ""))))]
6433 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6435 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6439 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6441 [(set_attr "type" "bcc")])
6443 (define_insn "*bltu_rev"
6445 (if_then_else (ltu (cc0)
6448 (label_ref (match_operand 0 "" ""))))]
6451 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6453 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6459 [(set_attr "type" "bcc")])
6461 (define_insn "*bge_rev"
6463 (if_then_else (ge (cc0)
6466 (label_ref (match_operand 0 "" ""))))]
6469 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6471 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6475 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6477 [(set_attr "type" "bcc")])
6479 (define_insn "*bgeu_rev"
6481 (if_then_else (geu (cc0)
6484 (label_ref (match_operand 0 "" ""))))]
6487 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6489 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6495 [(set_attr "type" "bcc")])
6497 (define_insn "*ble_rev"
6499 (if_then_else (le (cc0)
6502 (label_ref (match_operand 0 "" ""))))]
6505 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6507 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6511 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6513 [(set_attr "type" "bcc")])
6515 (define_insn "*bleu_rev"
6517 (if_then_else (leu (cc0)
6520 (label_ref (match_operand 0 "" ""))))]
6523 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6525 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6531 [(set_attr "type" "bcc")])
6533 (define_insn "*bordered_rev"
6535 (if_then_else (ordered (cc0) (const_int 0))
6537 (label_ref (match_operand 0 "" ""))))]
6540 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6543 [(set_attr "type" "fbcc")])
6545 (define_insn "*bunordered_rev"
6547 (if_then_else (unordered (cc0) (const_int 0))
6549 (label_ref (match_operand 0 "" ""))))]
6552 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6555 [(set_attr "type" "fbcc")])
6557 (define_insn "*buneq_rev"
6559 (if_then_else (uneq (cc0) (const_int 0))
6561 (label_ref (match_operand 0 "" ""))))]
6564 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6567 [(set_attr "type" "fbcc")])
6569 (define_insn "*bunge_rev"
6571 (if_then_else (unge (cc0) (const_int 0))
6573 (label_ref (match_operand 0 "" ""))))]
6576 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6579 [(set_attr "type" "fbcc")])
6581 (define_insn "*bungt_rev"
6583 (if_then_else (ungt (cc0) (const_int 0))
6585 (label_ref (match_operand 0 "" ""))))]
6588 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6591 [(set_attr "type" "fbcc")])
6593 (define_insn "*bunle_rev"
6595 (if_then_else (unle (cc0) (const_int 0))
6597 (label_ref (match_operand 0 "" ""))))]
6600 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6603 [(set_attr "type" "fbcc")])
6605 (define_insn "*bunlt_rev"
6607 (if_then_else (unlt (cc0) (const_int 0))
6609 (label_ref (match_operand 0 "" ""))))]
6612 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6615 [(set_attr "type" "fbcc")])
6617 (define_insn "*bltgt_rev"
6619 (if_then_else (ltgt (cc0) (const_int 0))
6621 (label_ref (match_operand 0 "" ""))))]
6624 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6627 [(set_attr "type" "fbcc")])
6629 ;; Unconditional and other jump instructions
6632 (label_ref (match_operand 0 "" "")))]
6635 [(set_attr "type" "bra")])
6637 (define_expand "tablejump"
6638 [(parallel [(set (pc) (match_operand 0 "" ""))
6639 (use (label_ref (match_operand 1 "" "")))])]
6642 #if CASE_VECTOR_PC_RELATIVE
6643 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6644 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6648 ;; Jump to variable address from dispatch table of absolute addresses.
6649 (define_insn "*tablejump_internal"
6650 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6651 (use (label_ref (match_operand 1 "" "")))]
6654 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6656 [(set_attr "type" "jmp")])
6658 ;; Jump to variable address from dispatch table of relative addresses.
6662 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6663 (use (label_ref (match_operand 1 "" "")))]
6666 #ifdef ASM_RETURN_CASE_JUMP
6667 ASM_RETURN_CASE_JUMP;
6669 if (TARGET_COLDFIRE)
6671 if (ADDRESS_REG_P (operands[0]))
6672 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6674 return "ext%.l %0\;jmp (2,pc,%0.l)";
6676 return "extl %0\;jmp pc@(2,%0:l)";
6679 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6683 ;; Decrement-and-branch insns.
6684 (define_insn "*dbne_hi"
6687 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6689 (label_ref (match_operand 1 "" ""))
6692 (plus:HI (match_dup 0)
6697 if (DATA_REG_P (operands[0]))
6698 return "dbra %0,%l1";
6699 if (GET_CODE (operands[0]) == MEM)
6700 return "subq%.w #1,%0\;jcc %l1";
6701 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6704 (define_insn "*dbne_si"
6707 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6709 (label_ref (match_operand 1 "" ""))
6712 (plus:SI (match_dup 0)
6717 if (DATA_REG_P (operands[0]))
6718 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6719 if (GET_CODE (operands[0]) == MEM)
6720 return "subq%.l #1,%0\;jcc %l1";
6721 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6724 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6726 (define_insn "*dbge_hi"
6729 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6732 (label_ref (match_operand 1 "" ""))
6735 (plus:HI (match_dup 0)
6737 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6740 if (DATA_REG_P (operands[0]))
6741 return "dbra %0,%l1";
6742 if (GET_CODE (operands[0]) == MEM)
6743 return "subq%.w #1,%0\;jcc %l1";
6744 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6747 (define_expand "decrement_and_branch_until_zero"
6748 [(parallel [(set (pc)
6750 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6753 (label_ref (match_operand 1 "" ""))
6756 (plus:SI (match_dup 0)
6761 (define_insn "*dbge_si"
6764 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6767 (label_ref (match_operand 1 "" ""))
6770 (plus:SI (match_dup 0)
6772 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6775 if (DATA_REG_P (operands[0]))
6776 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6777 if (GET_CODE (operands[0]) == MEM)
6778 return "subq%.l #1,%0\;jcc %l1";
6779 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6782 (define_expand "sibcall"
6783 [(call (match_operand:QI 0 "memory_operand" "")
6784 (match_operand:SI 1 "general_operand" ""))]
6787 operands[0] = m68k_legitimize_sibcall_address (operands[0]);
6790 (define_insn "*sibcall"
6791 [(call (mem:QI (match_operand:SI 0 "sibcall_operand" ""))
6792 (match_operand:SI 1 "general_operand" ""))]
6793 "SIBLING_CALL_P (insn)"
6795 return output_sibcall (operands[0]);
6798 (define_expand "sibcall_value"
6799 [(set (match_operand 0 "" "")
6800 (call (match_operand:QI 1 "memory_operand" "")
6801 (match_operand:SI 2 "general_operand" "")))]
6804 operands[1] = m68k_legitimize_sibcall_address (operands[1]);
6807 (define_insn "*sibcall_value"
6808 [(set (match_operand 0 "" "=rf,rf")
6809 (call (mem:QI (match_operand:SI 1 "sibcall_operand" ""))
6810 (match_operand:SI 2 "general_operand" "")))]
6811 "SIBLING_CALL_P (insn)"
6813 operands[0] = operands[1];
6814 return output_sibcall (operands[0]);
6817 ;; Call subroutine with no return value.
6818 (define_expand "call"
6819 [(call (match_operand:QI 0 "memory_operand" "")
6820 (match_operand:SI 1 "general_operand" ""))]
6821 ;; Operand 1 not really used on the m68000.
6824 operands[0] = m68k_legitimize_call_address (operands[0]);
6827 (define_insn "*call"
6828 [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
6829 (match_operand:SI 1 "general_operand" "g,g"))]
6830 ;; Operand 1 not really used on the m68000.
6831 "!SIBLING_CALL_P (insn)"
6833 return output_call (operands[0]);
6835 [(set_attr "type" "jsr")])
6837 ;; Call subroutine, returning value in operand 0
6838 ;; (which must be a hard register).
6839 (define_expand "call_value"
6840 [(set (match_operand 0 "" "")
6841 (call (match_operand:QI 1 "memory_operand" "")
6842 (match_operand:SI 2 "general_operand" "")))]
6843 ;; Operand 2 not really used on the m68000.
6846 operands[1] = m68k_legitimize_call_address (operands[1]);
6849 (define_insn "*non_symbolic_call_value"
6850 [(set (match_operand 0 "" "=rf,rf")
6851 (call (mem:QI (match_operand:SI 1 "non_symbolic_call_operand" "a,W"))
6852 (match_operand:SI 2 "general_operand" "g,g")))]
6853 ;; Operand 2 not really used on the m68000.
6854 "!SIBLING_CALL_P (insn)"
6856 [(set_attr "type" "jsr")
6857 (set_attr "opx" "1")])
6859 (define_insn "*symbolic_call_value_jsr"
6860 [(set (match_operand 0 "" "=rf,rf")
6861 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6862 (match_operand:SI 2 "general_operand" "g,g")))]
6863 ;; Operand 2 not really used on the m68000.
6864 "!SIBLING_CALL_P (insn) && m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_JSR"
6866 operands[0] = operands[1];
6867 return m68k_symbolic_call;
6869 [(set_attr "type" "jsr")
6870 (set_attr "opx" "1")])
6872 (define_insn "*symbolic_call_value_bsr"
6873 [(set (match_operand 0 "" "=rf,rf")
6874 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6875 (match_operand:SI 2 "general_operand" "g,g")))]
6876 ;; Operand 2 not really used on the m68000.
6877 "!SIBLING_CALL_P (insn)
6878 && (m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_C
6879 || m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_P)"
6881 operands[0] = operands[1];
6882 return m68k_symbolic_call;
6884 [(set_attr "type" "bsr")
6885 (set_attr "opx" "1")])
6887 ;; Call subroutine returning any type.
6889 (define_expand "untyped_call"
6890 [(parallel [(call (match_operand 0 "" "")
6892 (match_operand 1 "" "")
6893 (match_operand 2 "" "")])]
6894 "NEEDS_UNTYPED_CALL"
6898 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6900 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6902 rtx set = XVECEXP (operands[2], 0, i);
6903 emit_move_insn (SET_DEST (set), SET_SRC (set));
6906 /* The optimizer does not know that the call sets the function value
6907 registers we stored in the result block. We avoid problems by
6908 claiming that all hard registers are used and clobbered at this
6910 emit_insn (gen_blockage ());
6915 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6916 ;; all of memory. This blocks insns from being moved across this point.
6918 (define_insn "blockage"
6919 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6927 [(set_attr "type" "nop")])
6929 (define_expand "prologue"
6933 m68k_expand_prologue ();
6937 (define_expand "epilogue"
6941 m68k_expand_epilogue (false);
6945 (define_expand "sibcall_epilogue"
6949 m68k_expand_epilogue (true);
6953 ;; Used for frameless functions which save no regs and allocate no locals.
6954 (define_expand "return"
6956 "m68k_use_return_insn ()"
6959 (define_insn "*return"
6963 switch (m68k_get_function_kind (current_function_decl))
6965 case m68k_fk_interrupt_handler:
6968 case m68k_fk_interrupt_thread:
6972 if (crtl->args.pops_args)
6974 operands[0] = GEN_INT (crtl->args.pops_args);
6981 [(set_attr "type" "rts")])
6983 (define_insn "*m68k_store_multiple"
6984 [(match_parallel 0 "" [(match_operand 1 "")])]
6985 "m68k_movem_pattern_p (operands[0], NULL, 0, true)"
6987 return m68k_output_movem (operands, operands[0], 0, true);
6990 (define_insn "*m68k_store_multiple_automod"
6991 [(match_parallel 0 ""
6992 [(set (match_operand:SI 1 "register_operand" "=a")
6993 (plus:SI (match_operand:SI 2 "register_operand" "1")
6994 (match_operand:SI 3 "const_int_operand")))])]
6995 "m68k_movem_pattern_p (operands[0], operands[1], INTVAL (operands[3]), true)"
6997 return m68k_output_movem (operands, operands[0], INTVAL (operands[3]), true);
7000 (define_insn "*m68k_load_multiple"
7001 [(match_parallel 0 "" [(match_operand 1 "")])]
7002 "m68k_movem_pattern_p (operands[0], NULL, 0, false)"
7004 return m68k_output_movem (operands, operands[0], 0, false);
7007 (define_insn "*m68k_load_multiple_automod"
7008 [(match_parallel 0 ""
7009 [(set (match_operand:SI 1 "register_operand" "=a")
7010 (plus:SI (match_operand:SI 2 "register_operand" "1")
7011 (match_operand:SI 3 "const_int_operand")))])]
7012 "m68k_movem_pattern_p (operands[0], operands[1],
7013 INTVAL (operands[3]), false)"
7015 return m68k_output_movem (operands, operands[0],
7016 INTVAL (operands[3]), false);
7019 (define_expand "link"
7021 [(set (match_operand:SI 0 "register_operand")
7022 (plus:SI (reg:SI SP_REG) (const_int -4)))
7025 (set (reg:SI SP_REG)
7026 (plus:SI (reg:SI SP_REG)
7027 (match_operand:SI 1 "const_int_operand")))])]
7028 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7030 operands[2] = gen_frame_mem (SImode,
7031 plus_constant (Pmode, stack_pointer_rtx, -4));
7034 (define_insn "*link"
7035 [(set (match_operand:SI 0 "register_operand" "+r")
7036 (plus:SI (reg:SI SP_REG) (const_int -4)))
7037 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
7039 (set (reg:SI SP_REG)
7040 (plus:SI (reg:SI SP_REG)
7041 (match_operand:SI 1 "const_int_operand")))]
7042 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7044 operands[1] = GEN_INT (INTVAL (operands[1]) + 4);
7046 return "link %0,%1";
7047 else if (INTVAL (operands[1]) >= -0x8000)
7048 return "link.w %0,%1";
7050 return "link.l %0,%1";
7052 [(set_attr "type" "link")])
7054 (define_expand "unlink"
7056 [(set (match_operand:SI 0 "register_operand")
7058 (set (reg:SI SP_REG)
7059 (plus:SI (match_dup 0)
7063 operands[1] = gen_frame_mem (SImode, copy_rtx (operands[0]));
7066 (define_insn "*unlink"
7067 [(set (match_operand:SI 0 "register_operand" "+r")
7068 (mem:SI (match_dup 0)))
7069 (set (reg:SI SP_REG)
7070 (plus:SI (match_dup 0)
7074 [(set_attr "type" "unlk")])
7076 (define_insn "load_got"
7077 [(set (match_operand:SI 0 "register_operand" "=a")
7078 (unspec:SI [(const_int 0)] UNSPEC_GOT))]
7081 if (TARGET_ID_SHARED_LIBRARY)
7083 operands[1] = gen_rtx_REG (Pmode, PIC_REG);
7084 return MOTOROLA ? "move.l %?(%1),%0" : "movel %1@(%?), %0";
7088 if (TARGET_COLDFIRE)
7089 /* Load the full 32-bit PC-relative offset of
7090 _GLOBAL_OFFSET_TABLE_ into the PIC register, then use it to
7091 calculate the absolute value. The offset and "lea"
7092 operation word together occupy 6 bytes. */
7093 return ("move.l #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t"
7094 "lea (-6, %%pc, %0), %0");
7096 return "lea (%%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %0";
7099 return ("movel #_GLOBAL_OFFSET_TABLE_, %0\n\t"
7100 "lea %%pc@(0,%0:l),%0");
7103 (define_insn "indirect_jump"
7104 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
7107 [(set_attr "type" "jmp")])
7109 ;; This should not be used unless the add/sub insns can't be.
7112 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
7113 (match_operand:QI 1 "address_operand" "p"))]
7117 ;; This is the first machine-dependent peephole optimization.
7118 ;; It is useful when a floating value is returned from a function call
7119 ;; and then is moved into an FP register.
7120 ;; But it is mainly intended to test the support for these optimizations.
7123 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7124 (set (match_operand:DF 0 "register_operand" "")
7125 (match_operand:DF 1 "register_operand" ""))]
7126 "FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
7127 [(set (mem:SI (reg:SI SP_REG)) (match_dup 1))
7128 (set (mem:SI (pre_dec:SI (reg:SI SP_REG))) (match_dup 2))
7129 (set (match_dup 0) (mem:DF (post_inc:SI (reg:SI SP_REG))))]
7130 "split_di(operands + 1, 1, operands + 1, operands + 2);")
7132 ;; Optimize a stack-adjust followed by a push of an argument.
7133 ;; This is said to happen frequently with -msoft-float
7134 ;; when there are consecutive library calls.
7137 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7138 (set (match_operand:SF 0 "push_operand" "")
7139 (match_operand:SF 1 "general_operand" ""))]
7140 "!reg_mentioned_p (stack_pointer_rtx, operands[0])"
7141 [(set (match_dup 0) (match_dup 1))]
7142 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7145 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7146 (match_operand:SI 0 "const_int_operand" "")))
7147 (set (match_operand:SF 1 "push_operand" "")
7148 (match_operand:SF 2 "general_operand" ""))]
7149 "INTVAL (operands[0]) > 4
7150 && !reg_mentioned_p (stack_pointer_rtx, operands[2])"
7151 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7152 (set (match_dup 1) (match_dup 2))]
7154 operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7155 operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7158 ;; Speed up stack adjust followed by a fullword fixedpoint push.
7159 ;; Constant operands need special care, as replacing a "pea X.w" with
7160 ;; "move.l #X,(%sp)" is often not a win.
7162 ;; Already done by the previous csa pass, left as reference.
7164 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7165 (set (match_operand:SI 0 "push_operand" "")
7166 (match_operand:SI 1 "general_operand" ""))]
7167 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7168 [(set (match_dup 0) (match_dup 1))]
7169 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7171 ;; Try to use moveq, after stack push has been changed into a simple move.
7173 [(match_scratch:SI 2 "d")
7174 (set (match_operand:SI 0 "memory_operand" "")
7175 (match_operand:SI 1 "const_int_operand" ""))]
7176 "GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
7177 && INTVAL (operands[1]) != 0
7178 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7179 && !valid_mov3q_const (INTVAL (operands[1]))"
7180 [(set (match_dup 2) (match_dup 1))
7181 (set (match_dup 0) (match_dup 2))])
7183 ;; This sequence adds an instruction, but is two bytes shorter.
7185 [(match_scratch:SI 2 "d")
7186 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 12)))
7187 (set (match_operand:SI 0 "push_operand" "")
7188 (match_operand:SI 1 "const_int_operand" ""))]
7189 "INTVAL (operands[1]) != 0
7190 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7191 && !valid_mov3q_const (INTVAL (operands[1]))"
7192 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 8)))
7193 (set (match_dup 2) (match_dup 1))
7194 (set (match_dup 0) (match_dup 2))]
7195 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7197 ;; Changing pea X.w into a move.l is no real win here.
7199 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7200 (match_operand:SI 0 "const_int_operand" "")))
7201 (set (match_operand:SI 1 "push_operand" "")
7202 (match_operand:SI 2 "general_operand" ""))]
7203 "INTVAL (operands[0]) > 4
7204 && !reg_mentioned_p (stack_pointer_rtx, operands[2])
7205 && !(CONST_INT_P (operands[2]) && INTVAL (operands[2]) != 0
7206 && IN_RANGE (INTVAL (operands[2]), -0x8000, 0x7fff)
7207 && !valid_mov3q_const (INTVAL (operands[2])))"
7208 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7209 (set (match_dup 1) (match_dup 2))]
7211 operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7212 operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7215 ;; Speed up pushing a single byte/two bytes but leaving four bytes of space
7216 ;; (which differs slightly between m680x0 and ColdFire).
7219 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
7220 (set (match_operand:QI 0 "memory_operand" "")
7221 (match_operand:QI 1 "register_operand" ""))]
7222 "!reg_mentioned_p (stack_pointer_rtx, operands[1])
7223 && GET_CODE (XEXP (operands[0], 0)) == PLUS
7224 && rtx_equal_p (XEXP (XEXP (operands[0], 0), 0), stack_pointer_rtx)
7225 && CONST_INT_P (XEXP (XEXP (operands[0], 0), 1))
7226 && INTVAL (XEXP (XEXP (operands[0], 0), 1)) == 3"
7227 [(set (match_dup 0) (match_dup 1))]
7229 rtx addr = gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx);
7230 operands[0] = adjust_automodify_address (operands[0], SImode, addr, -3);
7231 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7235 [(set (match_operand:QI 0 "push_operand" "")
7236 (match_operand:QI 1 "register_operand" ""))
7237 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -3)))]
7238 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7239 [(set (match_dup 0) (match_dup 1))]
7241 operands[0] = adjust_automodify_address (operands[0], SImode,
7242 XEXP (operands[0], 0), -3);
7243 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7247 [(set (match_operand:HI 0 "push_operand" "")
7248 (match_operand:HI 1 "register_operand" ""))
7249 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))]
7250 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7251 [(set (match_dup 0) (match_dup 1))]
7253 operands[0] = adjust_automodify_address (operands[0], SImode,
7254 XEXP (operands[0], 0), -2);
7255 operands[1] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
7258 ;; Optimize a series of strict_low_part assignments
7261 [(set (match_operand:SI 0 "register_operand" "")
7263 (set (strict_low_part (match_operand:HI 1 "register_operand" ""))
7264 (match_operand:HI 2 "general_operand" ""))]
7265 "REGNO (operands[0]) == REGNO (operands[1])
7266 && strict_low_part_peephole_ok (HImode, insn, operands[0])"
7267 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7271 [(set (match_operand:SI 0 "register_operand" "")
7273 (set (strict_low_part (match_operand:QI 1 "register_operand" ""))
7274 (match_operand:QI 2 "general_operand" ""))]
7275 "REGNO (operands[0]) == REGNO (operands[1])
7276 && strict_low_part_peephole_ok (QImode, insn, operands[0])"
7277 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7285 ;; jCC label ; abnormal loop termination
7286 ;; dbra dN, loop ; normal loop termination
7294 ;; Which moves the jCC condition outside the inner loop for free.
7298 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7299 [(cc0) (const_int 0)])
7300 (label_ref (match_operand 2 "" ""))
7305 (ne (match_operand:HI 0 "register_operand" "")
7307 (label_ref (match_operand 1 "" ""))
7310 (plus:HI (match_dup 0)
7312 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7315 output_dbcc_and_branch (operands);
7320 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7321 [(cc0) (const_int 0)])
7322 (label_ref (match_operand 2 "" ""))
7327 (ne (match_operand:SI 0 "register_operand" "")
7329 (label_ref (match_operand 1 "" ""))
7332 (plus:SI (match_dup 0)
7334 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7337 output_dbcc_and_branch (operands);
7342 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7343 [(cc0) (const_int 0)])
7344 (label_ref (match_operand 2 "" ""))
7349 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
7352 (label_ref (match_operand 1 "" ""))
7355 (plus:HI (match_dup 0)
7357 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7360 output_dbcc_and_branch (operands);
7365 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7366 [(cc0) (const_int 0)])
7367 (label_ref (match_operand 2 "" ""))
7372 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
7375 (label_ref (match_operand 1 "" ""))
7378 (plus:SI (match_dup 0)
7380 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7383 output_dbcc_and_branch (operands);
7388 (define_insn "extendsfxf2"
7389 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7390 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
7393 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7395 if (REGNO (operands[0]) == REGNO (operands[1]))
7397 /* Extending float to double in an fp-reg is a no-op.
7398 NOTICE_UPDATE_CC has already assumed that the
7399 cc will be set. So cancel what it did. */
7400 cc_status = cc_prev_status;
7403 return "f%$move%.x %1,%0";
7405 if (FP_REG_P (operands[0]))
7407 if (FP_REG_P (operands[1]))
7408 return "f%$move%.x %1,%0";
7409 else if (ADDRESS_REG_P (operands[1]))
7410 return "move%.l %1,%-\;f%$move%.s %+,%0";
7411 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
7412 return output_move_const_single (operands);
7413 return "f%$move%.s %f1,%0";
7415 return "fmove%.x %f1,%0";
7419 (define_insn "extenddfxf2"
7420 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7422 (match_operand:DF 1 "general_operand" "f,rmE")))]
7425 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7427 if (REGNO (operands[0]) == REGNO (operands[1]))
7429 /* Extending float to double in an fp-reg is a no-op.
7430 NOTICE_UPDATE_CC has already assumed that the
7431 cc will be set. So cancel what it did. */
7432 cc_status = cc_prev_status;
7435 return "fmove%.x %1,%0";
7437 if (FP_REG_P (operands[0]))
7439 if (REG_P (operands[1]))
7442 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
7443 output_asm_insn ("move%.l %1,%-", xoperands);
7444 output_asm_insn ("move%.l %1,%-", operands);
7445 return "f%&move%.d %+,%0";
7447 if (GET_CODE (operands[1]) == CONST_DOUBLE)
7448 return output_move_const_double (operands);
7449 return "f%&move%.d %f1,%0";
7451 return "fmove%.x %f1,%0";
7454 (define_insn "truncxfdf2"
7455 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
7457 (match_operand:XF 1 "general_operand" "f,f")))]
7460 if (REG_P (operands[0]))
7462 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
7463 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
7464 return "move%.l %+,%0";
7466 return "fmove%.d %f1,%0";
7469 (define_insn "truncxfsf2"
7470 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
7472 (match_operand:XF 1 "general_operand" "f")))]
7476 (define_insn "sin<mode>2"
7477 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7479 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
7480 "TARGET_68881 && flag_unsafe_math_optimizations"
7482 if (FP_REG_P (operands[1]))
7483 return "fsin%.x %1,%0";
7485 return "fsin%.<FP:prec> %1,%0";
7488 (define_insn "cos<mode>2"
7489 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7491 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
7492 "TARGET_68881 && flag_unsafe_math_optimizations"
7494 if (FP_REG_P (operands[1]))
7495 return "fcos%.x %1,%0";
7497 return "fcos%.<FP:prec> %1,%0";
7500 ;; Unconditional traps are assumed to have (const_int 1) for the condition.
7502 [(trap_if (const_int 1) (const_int 7))]
7505 [(set_attr "type" "trap")])
7507 (define_expand "ctrapdi4"
7508 [(trap_if (match_operator 0 "ordered_comparison_operator"
7509 [(cc0) (const_int 0)])
7510 (match_operand:SI 3 "const1_operand" ""))]
7513 if (operands[2] == const0_rtx)
7514 emit_insn (gen_tstdi (operands[1]));
7516 emit_insn (gen_cmpdi (operands[1], operands[2]));
7517 operands[1] = cc0_rtx;
7518 operands[2] = const0_rtx;
7521 (define_expand "ctrapsi4"
7523 (compare (match_operand:SI 1 "nonimmediate_operand" "")
7524 (match_operand:SI 2 "general_operand" "")))
7525 (trap_if (match_operator 0 "ordered_comparison_operator"
7526 [(cc0) (const_int 0)])
7527 (match_operand:SI 3 "const1_operand" ""))]
7531 (define_expand "ctraphi4"
7533 (compare (match_operand:HI 1 "nonimmediate_src_operand" "")
7534 (match_operand:HI 2 "general_src_operand" "")))
7535 (trap_if (match_operator 0 "ordered_comparison_operator"
7536 [(cc0) (const_int 0)])
7537 (match_operand:SI 3 "const1_operand" ""))]
7541 (define_expand "ctrapqi4"
7543 (compare (match_operand:QI 1 "nonimmediate_src_operand" "")
7544 (match_operand:QI 2 "general_src_operand" "")))
7545 (trap_if (match_operator 0 "ordered_comparison_operator"
7546 [(cc0) (const_int 0)])
7547 (match_operand:SI 3 "const1_operand" ""))]
7551 (define_insn "*conditional_trap"
7552 [(trap_if (match_operator 0 "ordered_comparison_operator"
7553 [(cc0) (const_int 0)])
7554 (match_operand:SI 1 "const1_operand" "I"))]
7555 "TARGET_68020 && ! flags_in_68881 ()"
7557 switch (GET_CODE (operands[0]))
7559 case EQ: return "trapeq";
7560 case NE: return "trapne";
7561 case GT: return "trapgt";
7562 case GTU: return "traphi";
7563 case LT: return "traplt";
7564 case LTU: return "trapcs";
7565 case GE: return "trapge";
7566 case GEU: return "trapcc";
7567 case LE: return "traple";
7568 case LEU: return "trapls";
7569 default: gcc_unreachable ();
7573 ;; These are to prevent the scheduler from moving stores to the frame
7574 ;; before the stack adjustment.
7575 (define_insn "stack_tie"
7576 [(set (mem:BLK (scratch))
7577 (unspec:BLK [(match_operand:SI 0 "register_operand" "r")
7578 (match_operand:SI 1 "register_operand" "r")]
7582 [(set_attr "type" "ignore")])
7584 ;; Instruction that subscribes one word in ColdFire instruction buffer.
7585 ;; This instruction is used within scheduler only and should not appear
7586 ;; in the instruction stream.
7588 [(unspec [(const_int 0)] UNSPEC_IB)]
7591 [(set_attr "type" "ib")])