1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987-2018 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 3, or (at your option)
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3. If not see
18 ;; <http://www.gnu.org/licenses/>.
20 ;;- Information about MCF5200 port.
22 ;;- The MCF5200 "ColdFire" architecture is a reduced version of the
23 ;;- 68k ISA. Differences include reduced support for byte and word
24 ;;- operands and the removal of BCD, bitfield, rotate, and integer
25 ;;- divide instructions. The TARGET_COLDFIRE flag turns the use of the
26 ;;- removed opcodes and addressing modes off.
30 ;;- instruction definitions
32 ;;- @@The original PO technology requires these to be ordered by speed,
33 ;;- @@ so that assigner will pick the fastest.
35 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
37 ;;- When naming insn's (operand 0 of define_insn) be careful about using
38 ;;- names from other targets machine descriptions.
40 ;;- cpp macro #define NOTICE_UPDATE_CC in file tm.h handles condition code
41 ;;- updates for most instructions.
43 ;;- Operand classes for the register allocator:
44 ;;- 'a' one of the address registers can be used.
45 ;;- 'd' one of the data registers can be used.
46 ;;- 'f' one of the m68881/fpu registers can be used
47 ;;- 'r' either a data or an address register can be used.
49 ;;- Immediate Floating point operator constraints
50 ;;- 'G' a floating point constant that is *NOT* one of the standard
51 ;; 68881 constant values (to force calling output_move_const_double
52 ;; to get it from rom if it is a 68881 constant).
54 ;; See the functions standard_XXX_constant_p in output-m68k.c for more
57 ;;- Immediate integer operand constraints:
59 ;;- 'J' -32768 .. 32767
60 ;;- 'K' all integers EXCEPT -128 .. 127
62 ;;- 'M' all integers EXCEPT -256 .. 255
68 ;;- "%." size separator ("." or "") move%.l d0,d1
69 ;;- "%-" push operand "sp@-" move%.l d0,%-
70 ;;- "%+" pop operand "sp@+" move%.l d0,%+
71 ;;- "%@" top of stack "sp@" move%.l d0,%@
72 ;;- "%!" fpcr register
73 ;;- "%$" single-precision fp specifier ("s" or "") f%$add.x fp0,fp1
74 ;;- "%&" double-precision fp specifier ("d" or "") f%&add.x fp0,fp1
76 ;;- Information about 68040 port.
78 ;;- The 68040 executes all 68030 and 68881/2 instructions, but some must
79 ;;- be emulated in software by the OS. It is faster to avoid these
80 ;;- instructions and issue a library call rather than trapping into
81 ;;- the kernel. The affected instructions are fintrz and fscale. The
82 ;;- TUNE_68040 flag turns the use of the opcodes off.
84 ;;- The '040 also implements a set of new floating-point instructions
85 ;;- which specify the rounding precision in the opcode. This finally
86 ;;- permit the 68k series to be truly IEEE compliant, and solves all
87 ;;- issues of excess precision accumulating in the extended registers.
88 ;;- By default, GCC does not use these instructions, since such code will
89 ;;- not run on an '030. To use these instructions, use the -m68040-only
92 ;;- These new instructions aren't directly in the md. They are brought
93 ;;- into play by defining "%$" and "%&" to expand to "s" and "d" rather
96 ;;- Information about 68060 port.
98 ;;- The 68060 executes all 68030 and 68881/2 instructions, but some must
99 ;;- be emulated in software by the OS. It is faster to avoid these
100 ;;- instructions and issue a library call rather than trapping into
101 ;;- the kernel. The affected instructions are: divs.l <ea>,Dr:Dq;
102 ;;- divu.l <ea>,Dr:Dq; muls.l <ea>,Dr:Dq; mulu.l <ea>,Dr:Dq; and
103 ;;- fscale. The TUNE_68060 flag turns the use of the opcodes off.
105 ;;- Some of these insn's are composites of several m68000 op codes.
106 ;;- The assembler (or final @@??) insures that the appropriate one is
121 ;; UNSPEC_VOLATILE usage:
124 [(UNSPECV_BLOCKAGE 0)
131 ;; Registers by name.
142 (include "predicates.md")
143 (include "constraints.md")
145 ;; ::::::::::::::::::::
149 ;; ::::::::::::::::::::
152 (define_attr "cpu" "cfv1, cfv2, cfv3, cfv4, unknown"
153 (const (symbol_ref "m68k_sched_cpu")))
156 (define_attr "mac" "no, cf_mac, cf_emac"
157 (const (symbol_ref "m68k_sched_mac")))
159 ;; Instruction type for use in scheduling description.
160 ;; _l and _w suffixes indicate size of the operands of instruction.
161 ;; alu - usual arithmetic or logic instruction.
162 ;; aluq - arithmetic or logic instruction which has a quick immediate (the one
163 ;; that is encoded in the instruction word) for its Y operand.
164 ;; alux - Arithmetic instruction that uses carry bit (e.g., addx and subx).
165 ;; bcc - conditional branch.
166 ;; bitr - bit operation that only updates flags.
167 ;; bitrw - bit operation that updates flags and output operand.
168 ;; bra, bsr, clr, cmp, div, ext - corresponding instruction.
169 ;; falu, fbcc, fcmp, fdiv, fmove, fmul, fneg, fsqrt, ftst - corresponding
171 ;; ib - fake instruction to subscribe slots in ColdFire V1,V2,V3 instruction
173 ;; ignore - fake instruction.
174 ;; jmp, jsr, lea, link, mov3q, move, moveq, mul - corresponding instruction.
175 ;; mvsz - mvs or mvz instruction.
176 ;; neg, nop, pea, rts, scc - corresponding instruction.
177 ;; shift - arithmetic or logical shift instruction.
178 ;; trap, tst, unlk - corresponding instruction.
180 "alu_l,aluq_l,alux_l,bcc,bitr,bitrw,bra,bsr,clr,clr_l,cmp,cmp_l,
182 falu,fbcc,fcmp,fdiv,fmove,fmul,fneg,fsqrt,ftst,
184 jmp,jsr,lea,link,mov3q_l,move,move_l,moveq_l,mul_w,mul_l,mvsz,neg_l,nop,
188 (const_string "unknown"))
190 ;; Index of the X or Y operand in recog_data.operand[].
191 ;; Should be used only within opx_type and opy_type.
192 (define_attr "opx" "" (const_int 0))
193 (define_attr "opy" "" (const_int 1))
195 ;; Type of the Y operand.
196 ;; See m68k.c: enum attr_op_type.
197 (define_attr "opy_type"
198 "none,Rn,FPn,mem1,mem234,mem5,mem6,mem7,imm_q,imm_w,imm_l"
199 (cond [(eq_attr "type" "ext,fbcc,ftst,neg_l,bcc,bra,bsr,clr,clr_l,ib,ignore,
200 jmp,jsr,nop,rts,scc,trap,tst,tst_l,
201 unlk,unknown") (const_string "none")
202 (eq_attr "type" "lea,pea")
203 (symbol_ref "m68k_sched_attr_opy_type (insn, 1)")]
204 (symbol_ref "m68k_sched_attr_opy_type (insn, 0)")))
206 ;; Type of the X operand.
207 ;; See m68k.c: enum attr_op_type.
208 (define_attr "opx_type"
209 "none,Rn,FPn,mem1,mem234,mem5,mem6,mem7,imm_q,imm_w,imm_l"
210 (cond [(eq_attr "type" "ib,ignore,nop,rts,trap,unlk,
211 unknown") (const_string "none")
212 (eq_attr "type" "pea") (const_string "mem1")
213 (eq_attr "type" "jmp,jsr")
214 (symbol_ref "m68k_sched_attr_opx_type (insn, 1)")]
215 (symbol_ref "m68k_sched_attr_opx_type (insn, 0)")))
217 ;; Access to the X operand: none, read, write, read/write, unknown.
218 ;; Access to the Y operand is either none (if opy_type is none)
219 ;; or read otherwise.
220 (define_attr "opx_access" "none, r, w, rw"
221 (cond [(eq_attr "type" "ib,ignore,nop,rts,trap,unlk,
222 unknown") (const_string "none")
223 (eq_attr "type" "bcc,bra,bsr,bitr,cmp,cmp_l,fbcc,fcmp,ftst,
224 jmp,jsr,tst,tst_l") (const_string "r")
225 (eq_attr "type" "clr,clr_l,fneg,fmove,lea,
226 mov3q_l,move,move_l,moveq_l,mvsz,
227 pea,scc") (const_string "w")
228 (eq_attr "type" "alu_l,aluq_l,alux_l,bitrw,div_w,div_l,ext,
229 falu,fdiv,fmul,fsqrt,link,mul_w,mul_l,
230 neg_l,shift") (const_string "rw")]
231 ;; Should never be used.
232 (symbol_ref "(gcc_unreachable (), OPX_ACCESS_NONE)")))
234 ;; Memory accesses of the insn.
235 ;; 00 - no memory references
236 ;; 10 - memory is read
237 ;; i0 - indexed memory is read
238 ;; 01 - memory is written
239 ;; 0i - indexed memory is written
240 ;; 11 - memory is read, memory is written
241 ;; i1 - indexed memory is read, memory is written
242 ;; 1i - memory is read, indexed memory is written
243 (define_attr "op_mem" "00, 10, i0, 01, 0i, 11, i1, 1i"
244 (symbol_ref "m68k_sched_attr_op_mem (insn)"))
246 ;; Instruction size in words.
247 (define_attr "size" "1,2,3"
248 (symbol_ref "m68k_sched_attr_size (insn)"))
250 ;; Alternative is OK for ColdFire.
251 (define_attr "ok_for_coldfire" "yes,no" (const_string "yes"))
253 ;; Define 'enabled' attribute.
254 (define_attr "enabled" ""
255 (cond [(and (match_test "TARGET_COLDFIRE")
256 (eq_attr "ok_for_coldfire" "no"))
260 ;; Mode macros for integer operations.
261 (define_mode_iterator I [QI HI SI])
262 (define_mode_attr sz [(QI "%.b") (HI "%.w") (SI "%.l")])
264 ;; Mode macros for floating point operations.
265 ;; Valid floating point modes
266 (define_mode_iterator FP [SF DF (XF "TARGET_68881")])
267 ;; Mnemonic infix to round result
268 (define_mode_attr round [(SF "%$") (DF "%&") (XF "")])
269 ;; Mnemonic infix to round result for mul or div instruction
270 (define_mode_attr round_mul [(SF "sgl") (DF "%&") (XF "")])
271 ;; Suffix specifying source operand format
272 (define_mode_attr prec [(SF "s") (DF "d") (XF "x")])
273 ;; Allowable D registers
274 (define_mode_attr dreg [(SF "d") (DF "") (XF "")])
275 ;; Allowable 68881 constant constraints
276 (define_mode_attr const [(SF "F") (DF "G") (XF "")])
279 (define_insn_and_split "*movdf_internal"
280 [(set (match_operand:DF 0 "push_operand" "=m, m")
281 (match_operand:DF 1 "general_operand" "f, ro<>E"))]
286 "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 1)"
289 m68k_emit_move_double (operands);
292 [(set_attr "type" "fmove,*")])
294 (define_insn_and_split "pushdi"
295 [(set (match_operand:DI 0 "push_operand" "=m")
296 (match_operand:DI 1 "general_operand" "ro<>Fi"))]
299 "&& reload_completed"
302 m68k_emit_move_double (operands);
306 ;; We don't want to allow a constant operand for test insns because
307 ;; (set (cc0) (const_int foo)) has no mode information. Such insns will
308 ;; be folded while optimizing anyway.
312 (compare (match_operand:DI 0 "nonimmediate_operand" "am,d")
314 (clobber (match_scratch:SI 1 "=X,d"))
315 (clobber (match_scratch:DI 2 "=d,X"))]
318 if (which_alternative == 0)
322 xoperands[0] = operands[2];
323 xoperands[1] = operands[0];
324 output_move_double (xoperands);
325 cc_status.flags |= CC_REVERSED; /*|*/
326 return "neg%.l %R2\;negx%.l %2";
328 if (find_reg_note (insn, REG_DEAD, operands[0]))
330 cc_status.flags |= CC_REVERSED; /*|*/
331 return "neg%.l %R0\;negx%.l %0";
335 'sub' clears %1, and also clears the X cc bit
336 'tst' sets the Z cc bit according to the low part of the DImode operand
337 'subx %1' (i.e. subx #0) acts as a (non-existent) tstx on the high part.
339 return "sub%.l %1,%1\;tst%.l %R0\;subx%.l %1,%0";
342 ;; If you think that the 68020 does not support tstl a0,
343 ;; reread page B-167 of the 68020 manual more carefully.
344 (define_insn "*tstsi_internal_68020_cf"
346 (compare (match_operand:SI 0 "nonimmediate_operand" "rm")
348 "TARGET_68020 || TARGET_COLDFIRE"
350 [(set_attr "type" "tst_l")])
352 ;; On an address reg, cmpw may replace cmpl.
353 (define_insn "*tstsi_internal"
355 (compare (match_operand:SI 0 "nonimmediate_operand" "dm,r")
357 "!(TARGET_68020 || TARGET_COLDFIRE)"
361 [(set_attr "type" "tst_l,cmp")])
363 ;; This can't use an address register, because comparisons
364 ;; with address registers as second operand always test the whole word.
365 (define_insn "*tsthi_internal"
367 (compare (match_operand:HI 0 "nonimmediate_operand" "dm")
371 [(set_attr "type" "tst")])
373 (define_insn "*tstqi_internal"
375 (compare (match_operand:QI 0 "nonimmediate_operand" "dm")
379 [(set_attr "type" "tst")])
381 (define_insn "tst<mode>_68881"
383 (compare (match_operand:FP 0 "general_operand" "f<FP:dreg>m")
384 (match_operand:FP 1 "const0_operand" "H")))]
387 cc_status.flags = CC_IN_68881;
388 if (FP_REG_P (operands[0]))
390 return "ftst%.<FP:prec> %0";
392 [(set_attr "type" "ftst")])
394 (define_insn "tst<mode>_cf"
396 (compare (match_operand:FP 0 "general_operand" "f<FP:dreg><Q>U")
397 (match_operand:FP 1 "const0_operand" "H")))]
398 "TARGET_COLDFIRE_FPU"
400 cc_status.flags = CC_IN_68881;
401 if (FP_REG_P (operands[0]))
403 return "ftst%.<FP:prec> %0";
405 [(set_attr "type" "ftst")])
408 ;; compare instructions.
410 (define_insn "*cmpdi_internal"
412 (compare (match_operand:DI 1 "nonimmediate_operand" "0,d")
413 (match_operand:DI 2 "general_operand" "d,0")))
414 (clobber (match_scratch:DI 0 "=d,d"))]
417 if (rtx_equal_p (operands[0], operands[1]))
418 return "sub%.l %R2,%R0\;subx%.l %2,%0";
421 cc_status.flags |= CC_REVERSED; /*|*/
422 return "sub%.l %R1,%R0\;subx%.l %1,%0";
428 (compare (match_operand:DI 0 "nonimmediate_operand")
429 (match_operand:DI 1 "general_operand")))
430 (clobber (match_scratch:DI 2))]
435 (define_expand "cbranchdi4"
437 (if_then_else (match_operator 0 "ordered_comparison_operator"
438 [(match_operand:DI 1 "nonimmediate_operand")
439 (match_operand:DI 2 "general_operand")])
440 (label_ref (match_operand 3 ""))
444 if (operands[2] == const0_rtx)
445 emit_insn (gen_tstdi (operands[1]));
447 emit_insn (gen_cmpdi (operands[1], operands[2]));
448 operands[1] = cc0_rtx;
449 operands[2] = const0_rtx;
452 (define_expand "cstoredi4"
453 [(set (match_operand:QI 0 "register_operand")
454 (match_operator:QI 1 "ordered_comparison_operator"
455 [(match_operand:DI 2 "nonimmediate_operand")
456 (match_operand:DI 3 "general_operand")]))]
459 if (operands[3] == const0_rtx)
460 emit_insn (gen_tstdi (operands[2]));
462 emit_insn (gen_cmpdi (operands[2], operands[3]));
463 operands[2] = cc0_rtx;
464 operands[3] = const0_rtx;
468 (define_expand "cbranchsi4"
470 (compare (match_operand:SI 1 "nonimmediate_operand" "")
471 (match_operand:SI 2 "general_operand" "")))
473 (if_then_else (match_operator 0 "ordered_comparison_operator"
474 [(cc0) (const_int 0)])
475 (label_ref (match_operand 3 ""))
480 (define_expand "cstoresi4"
482 (compare (match_operand:SI 2 "nonimmediate_operand" "")
483 (match_operand:SI 3 "general_operand" "")))
484 (set (match_operand:QI 0 "register_operand")
485 (match_operator:QI 1 "ordered_comparison_operator"
486 [(cc0) (const_int 0)]))]
491 ;; A composite of the cmp, cmpa, cmpi & cmpm m68000 op codes.
493 ;; In theory we ought to be able to use some 'S' constraints and
494 ;; operand predicates that allow PC-rel addressing modes in the
495 ;; comparison patterns and expanders below. But we would have to be
496 ;; cognizant of the fact that PC-rel addresses are not allowed for
497 ;; both operands and determining whether or not we emit the operands in
498 ;; order or reversed is not trivial to do just based on the constraints
499 ;; and operand predicates. So to be safe, just don't allow the PC-rel
500 ;; versions in the various comparison expanders, patterns, for comparisons.
503 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mr,ma,>")
504 (match_operand:SI 1 "general_operand" "mr,ma,KTr,Ksr,>")))]
507 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
508 return "cmpm%.l %1,%0";
509 if (REG_P (operands[1])
510 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
512 cc_status.flags |= CC_REVERSED; /*|*/
513 return "cmp%.l %d0,%d1";
515 if (ADDRESS_REG_P (operands[0])
516 && GET_CODE (operands[1]) == CONST_INT
517 && INTVAL (operands[1]) < 0x8000
518 && INTVAL (operands[1]) >= -0x8000)
519 return "cmp%.w %1,%0";
520 return "cmp%.l %d1,%d0";
523 (define_insn "*cmpsi_cf"
525 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
526 (match_operand:SI 1 "general_operand" "r,mrKs")))]
529 if (REG_P (operands[1])
530 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
532 cc_status.flags |= CC_REVERSED; /*|*/
533 return "cmp%.l %d0,%d1";
535 return "cmp%.l %d1,%d0";
537 [(set_attr "type" "cmp_l")])
539 (define_expand "cbranchhi4"
541 (compare (match_operand:HI 1 "nonimmediate_operand" "")
542 (match_operand:HI 2 "m68k_subword_comparison_operand" "")))
544 (if_then_else (match_operator 0 "ordered_comparison_operator"
545 [(cc0) (const_int 0)])
546 (label_ref (match_operand 3 ""))
551 (define_expand "cstorehi4"
553 (compare (match_operand:HI 2 "nonimmediate_operand" "")
554 (match_operand:HI 3 "m68k_subword_comparison_operand" "")))
555 (set (match_operand:QI 0 "register_operand")
556 (match_operator:QI 1 "ordered_comparison_operator"
557 [(cc0) (const_int 0)]))]
563 (compare (match_operand:HI 0 "nonimmediate_operand" "rnm,d,n,m,>")
564 (match_operand:HI 1 "general_operand" "d,rnm,m,n,>")))]
567 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
568 return "cmpm%.w %1,%0";
569 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
570 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
572 cc_status.flags |= CC_REVERSED; /*|*/
573 return "cmp%.w %d0,%d1";
575 return "cmp%.w %d1,%d0";
578 (define_expand "cbranchqi4"
580 (compare (match_operand:QI 1 "nonimmediate_operand" "")
581 (match_operand:QI 2 "m68k_subword_comparison_operand" "")))
583 (if_then_else (match_operator 0 "ordered_comparison_operator"
584 [(cc0) (const_int 0)])
585 (label_ref (match_operand 3 ""))
590 (define_expand "cstoreqi4"
592 (compare (match_operand:QI 2 "nonimmediate_operand" "")
593 (match_operand:QI 3 "m68k_subword_comparison_operand" "")))
594 (set (match_operand:QI 0 "register_operand")
595 (match_operator:QI 1 "ordered_comparison_operator"
596 [(cc0) (const_int 0)]))]
602 (compare (match_operand:QI 0 "nonimmediate_operand" "dn,dm,>")
603 (match_operand:QI 1 "general_operand" "dm,nd,>")))]
606 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
607 return "cmpm%.b %1,%0";
608 if (REG_P (operands[1])
609 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
611 cc_status.flags |= CC_REVERSED; /*|*/
612 return "cmp%.b %d0,%d1";
614 return "cmp%.b %d1,%d0";
617 (define_expand "cbranch<mode>4"
619 (compare (match_operand:FP 1 "register_operand" "")
620 (match_operand:FP 2 "fp_src_operand" "")))
622 (if_then_else (match_operator 0 "comparison_operator"
623 [(cc0) (const_int 0)])
624 (label_ref (match_operand 3 ""))
629 (define_expand "cstore<mode>4"
631 (compare (match_operand:FP 2 "register_operand" "")
632 (match_operand:FP 3 "fp_src_operand" "")))
633 (set (match_operand:QI 0 "register_operand")
634 (match_operator:QI 1 "m68k_cstore_comparison_operator"
635 [(cc0) (const_int 0)]))]
636 "TARGET_HARD_FLOAT && !(TUNE_68060 || TARGET_COLDFIRE_FPU)"
637 "if (TARGET_COLDFIRE && operands[2] != const0_rtx)
640 (define_insn "*cmp<mode>_68881"
642 (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg>mF")
643 (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg>mF,f")))]
645 && (register_operand (operands[0], <MODE>mode)
646 || register_operand (operands[1], <MODE>mode))"
649 fcmp%.<FP:prec> %f1,%0
650 fcmp%.<FP:prec> %0,%f1"
651 [(set_attr "type" "fcmp")])
653 (define_insn "*cmp<mode>_cf"
655 (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg><Q>U")
656 (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg><Q>U,f")))]
658 && (register_operand (operands[0], <MODE>mode)
659 || register_operand (operands[1], <MODE>mode))"
662 fcmp%.<FP:prec> %f1,%0
663 fcmp%.<FP:prec> %0,%f1"
664 [(set_attr "type" "fcmp")])
666 ;; Recognizers for btst instructions.
668 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
669 ;; specified as a constant, so we must disable all patterns that may extract
670 ;; from a MEM at a constant bit position if we can't use this as a constraint.
675 (compare (zero_extract:SI (match_operand:QI 0 "memory_src_operand" "oS")
677 (minus:SI (const_int 7)
678 (match_operand:SI 1 "general_operand" "di")))
682 return output_btst (operands, operands[1], operands[0], insn, 7);
685 ;; This is the same as the above pattern except for the constraints. The 'i'
691 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
693 (minus:SI (const_int 7)
694 (match_operand:SI 1 "general_operand" "d")))
698 return output_btst (operands, operands[1], operands[0], insn, 7);
704 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
706 (minus:SI (const_int 31)
707 (match_operand:SI 1 "general_operand" "di")))
709 "!(CONST_INT_P (operands[1]) && !IN_RANGE (INTVAL (operands[1]), 0, 31))"
711 return output_btst (operands, operands[1], operands[0], insn, 31);
714 ;; The following two patterns are like the previous two
715 ;; except that they use the fact that bit-number operands
716 ;; are automatically masked to 3 or 5 bits.
721 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
723 (minus:SI (const_int 7)
725 (match_operand:SI 1 "register_operand" "d")
730 return output_btst (operands, operands[1], operands[0], insn, 7);
736 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
738 (minus:SI (const_int 31)
740 (match_operand:SI 1 "register_operand" "d")
745 return output_btst (operands, operands[1], operands[0], insn, 31);
748 ;; Nonoffsettable mem refs are ok in this one pattern
749 ;; since we don't try to adjust them.
753 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "m")
755 (match_operand:SI 1 "const_int_operand" "n"))
757 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
759 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
760 return output_btst (operands, operands[1], operands[0], insn, 7);
766 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "do")
768 (match_operand:SI 1 "const_int_operand" "n"))
771 && !(REG_P (operands[0]) && !IN_RANGE (INTVAL (operands[1]), 0, 31))"
773 if (GET_CODE (operands[0]) == MEM)
775 operands[0] = adjust_address (operands[0], QImode,
776 INTVAL (operands[1]) / 8);
777 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
778 return output_btst (operands, operands[1], operands[0], insn, 7);
780 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
781 return output_btst (operands, operands[1], operands[0], insn, 31);
784 ;; This is the same as the above pattern except for the constraints.
785 ;; The 'o' has been replaced with 'Q'.
790 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "dQ")
792 (match_operand:SI 1 "const_int_operand" "n"))
795 && !(REG_P (operands[0]) && !IN_RANGE (INTVAL (operands[1]), 0, 31))"
797 if (GET_CODE (operands[0]) == MEM)
799 operands[0] = adjust_address (operands[0], QImode,
800 INTVAL (operands[1]) / 8);
801 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
802 return output_btst (operands, operands[1], operands[0], insn, 7);
804 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
805 return output_btst (operands, operands[1], operands[0], insn, 31);
811 ;; A special case in which it is not desirable
812 ;; to reload the constant into a data register.
813 (define_insn "pushexthisi_const"
814 [(set (match_operand:SI 0 "push_operand" "=m,m,m")
815 (match_operand:SI 1 "const_int_operand" "C0,R,J"))]
816 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
821 [(set_attr "type" "clr_l,mov3q_l,pea")])
824 ;(define_insn "swapsi"
825 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
826 ; (match_operand:SI 1 "general_operand" "+r"))
827 ; (set (match_dup 1) (match_dup 0))]
831 ;; Special case of fullword move when source is zero for 68000_10.
832 ;; moveq is faster on the 68000.
833 (define_insn "*movsi_const0_68000_10"
834 [(set (match_operand:SI 0 "movsi_const0_operand" "=d,a,g")
841 [(set_attr "type" "moveq_l,alu_l,clr_l")
842 (set_attr "opy" "*,0,*")])
844 ;; Special case of fullword move when source is zero for 68040_60.
845 ;; On the '040, 'subl an,an' takes 2 clocks while lea takes only 1
846 (define_insn "*movsi_const0_68040_60"
847 [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
851 if (which_alternative == 0)
852 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
853 else if (which_alternative == 1)
861 [(set_attr "type" "lea,clr_l")])
863 ;; Special case of fullword move when source is zero.
864 (define_insn "*movsi_const0"
865 [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
867 "!(TUNE_68000_10 || TUNE_68040_60)"
871 [(set_attr "type" "alu_l,clr_l")
872 (set_attr "opy" "0,*")])
874 ;; General case of fullword move.
876 ;; This is the main "hook" for PIC code. When generating
877 ;; PIC, movsi is responsible for determining when the source address
878 ;; needs PIC relocation and appropriately calling legitimize_pic_address
879 ;; to perform the actual relocation.
881 ;; In both the PIC and non-PIC cases the patterns generated will
882 ;; matched by the next define_insn.
883 (define_expand "movsi"
884 [(set (match_operand:SI 0 "" "")
885 (match_operand:SI 1 "" ""))]
888 rtx tmp, base, offset;
890 /* Recognize the case where operand[1] is a reference to thread-local
891 data and load its address to a register. */
892 if (!TARGET_PCREL && m68k_tls_reference_p (operands[1], false))
894 rtx tmp = operands[1];
897 if (GET_CODE (tmp) == CONST && GET_CODE (XEXP (tmp, 0)) == PLUS)
899 addend = XEXP (XEXP (tmp, 0), 1);
900 tmp = XEXP (XEXP (tmp, 0), 0);
903 gcc_assert (GET_CODE (tmp) == SYMBOL_REF);
904 gcc_assert (SYMBOL_REF_TLS_MODEL (tmp) != 0);
906 tmp = m68k_legitimize_tls_address (tmp);
914 reg = gen_reg_rtx (Pmode);
915 emit_move_insn (reg, tmp);
919 tmp = gen_rtx_PLUS (SImode, tmp, addend);
924 else if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
926 /* The source is an address which requires PIC relocation.
927 Call legitimize_pic_address with the source, mode, and a relocation
928 register (a new pseudo, or the final destination if reload_in_progress
929 is set). Then fall through normally */
930 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
931 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
933 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
935 /* Don't allow writes to memory except via a register;
936 the m68k doesn't consider PC-relative addresses to be writable. */
937 if (symbolic_operand (operands[0], SImode))
938 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
939 else if (GET_CODE (operands[0]) == MEM
940 && symbolic_operand (XEXP (operands[0], 0), SImode))
941 operands[0] = gen_rtx_MEM (SImode,
942 force_reg (SImode, XEXP (operands[0], 0)));
944 if (M68K_OFFSETS_MUST_BE_WITHIN_SECTIONS_P)
946 split_const (operands[1], &base, &offset);
947 if (GET_CODE (base) == SYMBOL_REF
948 && !offset_within_block_p (base, INTVAL (offset)))
950 tmp = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (SImode);
951 emit_move_insn (tmp, base);
952 emit_insn (gen_addsi3 (operands[0], tmp, offset));
958 ;; General case of fullword move.
959 (define_insn "*movsi_m68k"
960 ;; Notes: make sure no alternative allows g vs g.
961 ;; We don't allow f-regs since fixed point cannot go in them.
962 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
963 (match_operand:SI 1 "general_src_operand" "damSnT,n,i"))]
964 "!TARGET_COLDFIRE && reload_completed"
966 return output_move_simode (operands);
969 ;; Before reload is completed the register constraints
970 ;; force integer constants in range for a moveq to be reloaded
971 ;; if they are headed for memory.
972 (define_insn "*movsi_m68k2"
973 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
974 (match_operand:SI 1 "general_src_operand" "damSKT,n,i"))]
978 return output_move_simode (operands);
981 ;; ColdFire move instructions can have at most one operand of mode >= 6.
982 (define_insn "*movsi_cf"
983 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d, d, d, d, d, a,Ap, a, r<Q>,g, U")
984 (match_operand:SI 1 "general_operand" " R,CQ,CW,CZ,CS,Ci,J,J Cs,Cs, g, Rr<Q>,U"))]
987 switch (which_alternative)
990 return "mov3q%.l %1,%0";
993 return "moveq %1,%0";
997 unsigned u = INTVAL (operands[1]);
999 operands[1] = GEN_INT ((u << 16) | (u >> 16)); /*|*/
1000 return "moveq %1,%0\n\tswap %0";
1004 return "mvz%.w %1,%0";
1007 return "mvs%.w %1,%0";
1010 return "move%.l %1,%0";
1013 return "move%.w %1,%0";
1019 return "lea %a1,%0";
1024 return "move%.l %1,%0";
1031 [(set_attr "type" "mov3q_l,moveq_l,*,mvsz,mvsz,move_l,move,pea,lea,move_l,move_l,move_l")])
1033 ;; Special case of fullword move, where we need to get a non-GOT PIC
1034 ;; reference into an address register.
1036 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
1037 (match_operand:SI 1 "pcrel_address" ""))]
1040 if (push_operand (operands[0], SImode))
1042 return "lea %a1,%0";
1045 (define_expand "movhi"
1046 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1047 (match_operand:HI 1 "general_operand" ""))]
1052 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
1053 (match_operand:HI 1 "general_src_operand" "gS"))]
1055 "* return output_move_himode (operands);")
1058 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
1059 (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
1061 "* return output_move_himode (operands);")
1063 (define_expand "movstricthi"
1064 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1065 (match_operand:HI 1 "general_src_operand" ""))]
1070 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
1071 (match_operand:HI 1 "general_src_operand" "rmSn"))]
1073 "* return output_move_stricthi (operands);")
1076 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
1077 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
1079 "* return output_move_stricthi (operands);")
1081 (define_expand "movqi"
1082 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1083 (match_operand:QI 1 "general_src_operand" ""))]
1088 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
1089 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
1091 "* return output_move_qimode (operands);")
1094 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
1095 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
1097 "* return output_move_qimode (operands);")
1099 (define_expand "movstrictqi"
1100 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1101 (match_operand:QI 1 "general_src_operand" ""))]
1106 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
1107 (match_operand:QI 1 "general_src_operand" "dmSn"))]
1109 "* return output_move_strictqi (operands);")
1111 (define_insn "*movstrictqi_cf"
1112 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d, Ac, d,m"))
1113 (match_operand:QI 1 "general_src_operand" "C0,C0, dmn,d"))]
1120 [(set_attr "type" "clr,clr,move,move")])
1122 (define_expand "pushqi1"
1123 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
1124 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
1125 (match_operand:QI 0 "general_operand" ""))]
1129 (define_expand "reload_insf"
1130 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1131 (match_operand:SF 1 "general_operand" "mf"))
1132 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1133 "TARGET_COLDFIRE_FPU"
1135 if (emit_move_sequence (operands, SFmode, operands[2]))
1138 /* We don't want the clobber emitted, so handle this ourselves. */
1139 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1143 (define_expand "reload_outsf"
1144 [(set (match_operand:SF 0 "general_operand" "")
1145 (match_operand:SF 1 "register_operand" "f"))
1146 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1147 "TARGET_COLDFIRE_FPU"
1149 if (emit_move_sequence (operands, SFmode, operands[2]))
1152 /* We don't want the clobber emitted, so handle this ourselves. */
1153 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1157 (define_expand "movsf"
1158 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1159 (match_operand:SF 1 "general_operand" ""))]
1164 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
1165 (match_operand:SF 1 "general_operand" "rmfF"))]
1168 if (FP_REG_P (operands[0]))
1170 if (FP_REG_P (operands[1]))
1171 return "f%$move%.x %1,%0";
1172 else if (ADDRESS_REG_P (operands[1]))
1173 return "move%.l %1,%-\;f%$move%.s %+,%0";
1174 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
1175 return output_move_const_single (operands);
1176 return "f%$move%.s %f1,%0";
1178 if (FP_REG_P (operands[1]))
1180 if (ADDRESS_REG_P (operands[0]))
1181 return "fmove%.s %1,%-\;move%.l %+,%0";
1182 return "fmove%.s %f1,%0";
1184 if (operands[1] == CONST0_RTX (SFmode)
1185 /* clr insns on 68000 read before writing. */
1186 && ((TARGET_68010 || TARGET_COLDFIRE)
1187 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
1189 if (ADDRESS_REG_P (operands[0]))
1191 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
1193 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
1195 return "sub%.l %0,%0";
1197 /* moveq is faster on the 68000. */
1198 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
1199 return "moveq #0,%0";
1202 return "move%.l %1,%0";
1205 (define_insn "movsf_cf_soft"
1206 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>,g,U")
1207 (match_operand:SF 1 "general_operand" "g,r<Q>,U"))]
1208 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1210 [(set_attr "type" "move_l")])
1212 ;; SFmode MEMs are restricted to modes 2-4 if TARGET_COLDFIRE_FPU.
1213 ;; The move instructions can handle all combinations.
1214 (define_insn "movsf_cf_hard"
1215 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f, f,mr,f,r<Q>,f
1217 (match_operand:SF 1 "general_operand" " f, r<Q>U,f,rm,F,F, m
1219 "TARGET_COLDFIRE_FPU"
1221 if (which_alternative == 4 || which_alternative == 5) {
1224 REAL_VALUE_TO_TARGET_SINGLE (*CONST_DOUBLE_REAL_VALUE (operands[1]), l);
1225 xoperands[0] = operands[0];
1226 xoperands[1] = GEN_INT (l);
1227 if (which_alternative == 5) {
1229 if (ADDRESS_REG_P (xoperands[0]))
1230 output_asm_insn ("sub%.l %0,%0", xoperands);
1232 output_asm_insn ("clr%.l %0", xoperands);
1234 if (GET_CODE (operands[0]) == MEM
1235 && symbolic_operand (XEXP (operands[0], 0), SImode))
1236 output_asm_insn ("move%.l %1,%-;move%.l %+,%0", xoperands);
1238 output_asm_insn ("move%.l %1,%0", xoperands);
1242 output_asm_insn ("move%.l %1,%-;fsmove%.s %+,%0", xoperands);
1244 output_asm_insn ("clr%.l %-;fsmove%.s %+,%0", xoperands);
1247 if (FP_REG_P (operands[0]))
1249 if (ADDRESS_REG_P (operands[1]))
1250 return "move%.l %1,%-;fsmove%.s %+,%0";
1251 if (FP_REG_P (operands[1]))
1252 return "fsmove%.d %1,%0";
1253 return "fsmove%.s %f1,%0";
1255 if (FP_REG_P (operands[1]))
1257 if (ADDRESS_REG_P (operands[0]))
1258 return "fmove%.s %1,%-;move%.l %+,%0";
1259 return "fmove%.s %f1,%0";
1261 if (operands[1] == CONST0_RTX (SFmode))
1263 if (ADDRESS_REG_P (operands[0]))
1264 return "sub%.l %0,%0";
1267 return "move%.l %1,%0";
1270 (define_expand "reload_indf"
1271 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1272 (match_operand:DF 1 "general_operand" "mf"))
1273 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1274 "TARGET_COLDFIRE_FPU"
1276 if (emit_move_sequence (operands, DFmode, operands[2]))
1279 /* We don't want the clobber emitted, so handle this ourselves. */
1280 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1284 (define_expand "reload_outdf"
1285 [(set (match_operand:DF 0 "general_operand" "")
1286 (match_operand:DF 1 "register_operand" "f"))
1287 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1288 "TARGET_COLDFIRE_FPU"
1290 if (emit_move_sequence (operands, DFmode, operands[2]))
1293 /* We don't want the clobber emitted, so handle this ourselves. */
1294 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1298 (define_expand "movdf"
1299 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1300 (match_operand:DF 1 "general_operand" ""))]
1303 if (TARGET_COLDFIRE_FPU)
1304 if (emit_move_sequence (operands, DFmode, 0))
1309 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
1310 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
1311 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
1312 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
1315 if (FP_REG_P (operands[0]))
1317 if (FP_REG_P (operands[1]))
1318 return "f%&move%.x %1,%0";
1319 if (REG_P (operands[1]))
1322 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1323 output_asm_insn ("move%.l %1,%-", xoperands);
1324 output_asm_insn ("move%.l %1,%-", operands);
1325 return "f%&move%.d %+,%0";
1327 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1328 return output_move_const_double (operands);
1329 return "f%&move%.d %f1,%0";
1331 else if (FP_REG_P (operands[1]))
1333 if (REG_P (operands[0]))
1335 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1336 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1337 return "move%.l %+,%0";
1340 return "fmove%.d %f1,%0";
1342 return output_move_double (operands);
1345 (define_insn_and_split "movdf_cf_soft"
1346 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
1347 (match_operand:DF 1 "general_operand" "g,r"))]
1348 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1350 "&& reload_completed"
1353 m68k_emit_move_double (operands);
1357 (define_insn "movdf_cf_hard"
1358 [(set (match_operand:DF 0 "nonimmediate_operand" "=f, <Q>U,r,f,r,r,m,f")
1359 (match_operand:DF 1 "general_operand" " f<Q>U,f, f,r,r,m,r,E"))]
1360 "TARGET_COLDFIRE_FPU"
1365 switch (which_alternative)
1368 return "fdmove%.d %1,%0";
1370 return "fmove%.d %1,%0";
1372 return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1374 return "move%.l %R1,%-;move%.l %1,%-;fdmove%.d %+,%0";
1375 case 4: case 5: case 6:
1376 return output_move_double (operands);
1378 REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (operands[1]), l);
1379 xoperands[0] = operands[0];
1380 xoperands[1] = GEN_INT (l[0]);
1381 xoperands[2] = GEN_INT (l[1]);
1382 if (operands[1] == CONST0_RTX (DFmode))
1383 output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1387 output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1390 output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1396 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1397 ;; allowed. Most but not all have predicates and constraint that disallow
1398 ;; constants. Most but not all have output templates that handle constants.
1399 ;; See also TARGET_LEGITIMATE_CONSTANT_P.
1401 (define_expand "movxf"
1402 [(set (match_operand:XF 0 "nonimmediate_operand" "")
1403 (match_operand:XF 1 "general_operand" ""))]
1406 /* We can't rewrite operands during reload. */
1407 if (! reload_in_progress)
1409 if (CONSTANT_P (operands[1]))
1411 operands[1] = force_const_mem (XFmode, operands[1]);
1412 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1413 operands[1] = adjust_address (operands[1], XFmode, 0);
1415 if (flag_pic && TARGET_PCREL)
1417 /* Don't allow writes to memory except via a register; the
1418 m68k doesn't consider PC-relative addresses to be writable. */
1419 if (GET_CODE (operands[0]) == MEM
1420 && symbolic_operand (XEXP (operands[0], 0), SImode))
1421 operands[0] = gen_rtx_MEM (XFmode,
1422 force_reg (SImode, XEXP (operands[0], 0)));
1428 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1429 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1432 if (FP_REG_P (operands[0]))
1434 if (FP_REG_P (operands[1]))
1435 return "fmove%.x %1,%0";
1436 if (REG_P (operands[1]))
1439 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1440 output_asm_insn ("move%.l %1,%-", xoperands);
1441 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1442 output_asm_insn ("move%.l %1,%-", xoperands);
1443 output_asm_insn ("move%.l %1,%-", operands);
1444 return "fmove%.x %+,%0";
1446 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1447 return "fmove%.x %1,%0";
1448 return "fmove%.x %f1,%0";
1450 if (FP_REG_P (operands[1]))
1452 if (REG_P (operands[0]))
1454 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1455 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1456 output_asm_insn ("move%.l %+,%0", operands);
1457 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1458 return "move%.l %+,%0";
1460 /* Must be memory destination. */
1461 return "fmove%.x %f1,%0";
1463 return output_move_double (operands);
1467 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1468 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1469 "! TARGET_68881 && ! TARGET_COLDFIRE"
1471 if (FP_REG_P (operands[0]))
1473 if (FP_REG_P (operands[1]))
1474 return "fmove%.x %1,%0";
1475 if (REG_P (operands[1]))
1478 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1479 output_asm_insn ("move%.l %1,%-", xoperands);
1480 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1481 output_asm_insn ("move%.l %1,%-", xoperands);
1482 output_asm_insn ("move%.l %1,%-", operands);
1483 return "fmove%.x %+,%0";
1485 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1486 return "fmove%.x %1,%0";
1487 return "fmove%.x %f1,%0";
1489 if (FP_REG_P (operands[1]))
1491 if (REG_P (operands[0]))
1493 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1494 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1495 output_asm_insn ("move%.l %+,%0", operands);
1496 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1497 return "move%.l %+,%0";
1500 return "fmove%.x %f1,%0";
1502 return output_move_double (operands);
1506 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1507 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1508 "! TARGET_68881 && TARGET_COLDFIRE"
1509 "* return output_move_double (operands);")
1511 (define_expand "movdi"
1512 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1513 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1514 (match_operand:DI 1 "general_operand" ""))]
1518 ;; movdi can apply to fp regs in some cases
1520 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1521 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1522 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1523 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1524 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1525 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1526 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1529 if (FP_REG_P (operands[0]))
1531 if (FP_REG_P (operands[1]))
1532 return "fmove%.x %1,%0";
1533 if (REG_P (operands[1]))
1536 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1537 output_asm_insn ("move%.l %1,%-", xoperands);
1538 output_asm_insn ("move%.l %1,%-", operands);
1539 return "fmove%.d %+,%0";
1541 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1542 return output_move_const_double (operands);
1543 return "fmove%.d %f1,%0";
1545 else if (FP_REG_P (operands[1]))
1547 if (REG_P (operands[0]))
1549 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1550 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1551 return "move%.l %+,%0";
1554 return "fmove%.d %f1,%0";
1556 return output_move_double (operands);
1560 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1561 (match_operand:DI 1 "general_operand" "g,r"))]
1563 "* return output_move_double (operands);")
1565 ;; Thus goes after the move instructions
1566 ;; because the move instructions are better (require no spilling)
1567 ;; when they can apply. It goes before the add/sub insns
1568 ;; so we will prefer it to them.
1570 (define_insn "pushasi"
1571 [(set (match_operand:SI 0 "push_operand" "=m")
1572 (match_operand:SI 1 "address_operand" "p"))]
1575 [(set_attr "type" "pea")])
1577 ;; truncation instructions
1578 (define_insn "truncsiqi2"
1579 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1581 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1584 if (GET_CODE (operands[0]) == REG)
1586 /* Must clear condition codes, since the move.l bases them on
1587 the entire 32 bits, not just the desired 8 bits. */
1589 return "move%.l %1,%0";
1591 if (GET_CODE (operands[1]) == MEM)
1592 operands[1] = adjust_address (operands[1], QImode, 3);
1593 return "move%.b %1,%0";
1596 (define_insn "trunchiqi2"
1597 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1599 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1602 if (GET_CODE (operands[0]) == REG
1603 && (GET_CODE (operands[1]) == MEM
1604 || GET_CODE (operands[1]) == CONST_INT))
1606 /* Must clear condition codes, since the move.w bases them on
1607 the entire 16 bits, not just the desired 8 bits. */
1609 return "move%.w %1,%0";
1611 if (GET_CODE (operands[0]) == REG)
1613 /* Must clear condition codes, since the move.l bases them on
1614 the entire 32 bits, not just the desired 8 bits. */
1616 return "move%.l %1,%0";
1618 if (GET_CODE (operands[1]) == MEM)
1619 operands[1] = adjust_address (operands[1], QImode, 1);
1620 return "move%.b %1,%0";
1623 (define_insn "truncsihi2"
1624 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1626 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1629 if (GET_CODE (operands[0]) == REG)
1631 /* Must clear condition codes, since the move.l bases them on
1632 the entire 32 bits, not just the desired 8 bits. */
1634 return "move%.l %1,%0";
1636 if (GET_CODE (operands[1]) == MEM)
1637 operands[1] = adjust_address (operands[1], QImode, 2);
1638 return "move%.w %1,%0";
1641 ;; zero extension instructions
1643 ;; two special patterns to match various post_inc/pre_dec patterns
1644 (define_insn_and_split "*zero_extend_inc"
1645 [(set (match_operand 0 "post_inc_operand" "")
1646 (zero_extend (match_operand 1 "register_operand" "")))]
1647 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1648 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1649 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1657 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1660 (define_insn_and_split "*zero_extend_dec"
1661 [(set (match_operand 0 "pre_dec_operand" "")
1662 (zero_extend (match_operand 1 "register_operand" "")))]
1663 "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1664 GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1665 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1666 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1674 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1677 (define_insn_and_split "zero_extendqidi2"
1678 [(set (match_operand:DI 0 "register_operand" "")
1679 (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1684 (zero_extend:SI (match_dup 1)))
1688 operands[2] = gen_lowpart (SImode, operands[0]);
1689 operands[3] = gen_highpart (SImode, operands[0]);
1692 (define_insn_and_split "zero_extendhidi2"
1693 [(set (match_operand:DI 0 "register_operand" "")
1694 (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1699 (zero_extend:SI (match_dup 1)))
1703 operands[2] = gen_lowpart (SImode, operands[0]);
1704 operands[3] = gen_highpart (SImode, operands[0]);
1707 (define_expand "zero_extendsidi2"
1708 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1709 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1712 if (GET_CODE (operands[0]) == MEM
1713 && GET_CODE (operands[1]) == MEM)
1714 operands[1] = force_reg (SImode, operands[1]);
1717 (define_insn_and_split "*zero_extendsidi2"
1718 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1719 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1720 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1728 operands[2] = gen_lowpart (SImode, operands[0]);
1729 operands[3] = gen_highpart (SImode, operands[0]);
1732 (define_insn "*zero_extendhisi2_cf"
1733 [(set (match_operand:SI 0 "register_operand" "=d")
1734 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1737 [(set_attr "type" "mvsz")])
1739 (define_insn "zero_extendhisi2"
1740 [(set (match_operand:SI 0 "register_operand" "=d")
1741 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1745 (define_expand "zero_extendqihi2"
1746 [(set (match_operand:HI 0 "register_operand" "")
1747 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1751 (define_insn "*zero_extendqihi2"
1752 [(set (match_operand:HI 0 "register_operand" "=d")
1753 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1757 (define_insn "*zero_extendqisi2_cfv4"
1758 [(set (match_operand:SI 0 "register_operand" "=d")
1759 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1762 [(set_attr "type" "mvsz")])
1764 (define_insn "zero_extendqisi2"
1765 [(set (match_operand:SI 0 "register_operand" "=d")
1766 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1770 ;; these two pattern split everything else which isn't matched by
1771 ;; something else above
1773 [(set (match_operand 0 "register_operand" "")
1774 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1777 && reg_mentioned_p (operands[0], operands[1])"
1778 [(set (strict_low_part (match_dup 2))
1781 (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1783 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1784 operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1785 operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1789 [(set (match_operand 0 "register_operand" "")
1790 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1791 "!ISA_HAS_MVS_MVZ && reload_completed"
1794 (set (strict_low_part (match_dup 2))
1797 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1800 ;; sign extension instructions
1802 (define_insn "extendqidi2"
1803 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1804 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1808 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1809 if (ISA_HAS_MVS_MVZ)
1810 return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1811 if (TARGET_68020 || TARGET_COLDFIRE)
1813 if (ADDRESS_REG_P (operands[1]))
1814 return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1816 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1820 if (ADDRESS_REG_P (operands[1]))
1821 return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1823 return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1827 (define_insn "extendhidi2"
1828 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1830 (match_operand:HI 1 "general_src_operand" "rmS")))]
1834 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1835 if (ISA_HAS_MVS_MVZ)
1836 return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1837 if (TARGET_68020 || TARGET_COLDFIRE)
1838 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1840 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1843 (define_insn "extendsidi2"
1844 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o,o,<")
1846 (match_operand:SI 1 "nonimmediate_src_operand" "rm,rm,r<Q>,rm")))
1847 (clobber (match_scratch:SI 2 "=X,d,d,d"))]
1852 if (which_alternative == 0)
1853 /* Handle alternative 0. */
1855 if (TARGET_68020 || TARGET_COLDFIRE)
1856 return "move%.l %1,%R0\;smi %0\;extb%.l %0";
1858 return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
1861 /* Handle alternatives 1, 2 and 3. We don't need to adjust address by 4
1862 in alternative 3 because autodecrement will do that for us. */
1863 operands[3] = adjust_address (operands[0], SImode,
1864 which_alternative == 3 ? 0 : 4);
1865 operands[0] = adjust_address (operands[0], SImode, 0);
1867 if (TARGET_68020 || TARGET_COLDFIRE)
1868 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
1870 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
1872 [(set_attr "ok_for_coldfire" "yes,no,yes,yes")])
1874 ;; Special case when one can avoid register clobbering, copy and test
1875 ;; Maybe there is a way to make that the general case, by forcing the
1876 ;; result of the SI tree to be in the lower register of the DI target
1878 ;; Don't allow memory for operand 1 as that would require an earlyclobber
1879 ;; which results in worse code
1880 (define_insn "extendplussidi"
1881 [(set (match_operand:DI 0 "register_operand" "=d")
1882 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rn")
1883 (match_operand:SI 2 "general_operand" "rmn"))))]
1887 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1888 if (GET_CODE (operands[1]) == CONST_INT
1889 && (unsigned) INTVAL (operands[1]) > 8)
1891 rtx tmp = operands[1];
1893 operands[1] = operands[2];
1896 if (GET_CODE (operands[1]) == REG
1897 && REGNO (operands[1]) == REGNO (operands[3]))
1898 output_asm_insn ("add%.l %2,%3", operands);
1900 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1901 if (TARGET_68020 || TARGET_COLDFIRE)
1902 return "smi %0\;extb%.l %0";
1904 return "smi %0\;ext%.w %0\;ext%.l %0";
1907 (define_expand "extendhisi2"
1908 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1910 (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1914 (define_insn "*cfv4_extendhisi2"
1915 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1917 (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1920 [(set_attr "type" "mvsz")])
1922 (define_insn "*68k_extendhisi2"
1923 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1925 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1930 [(set_attr "type" "ext,move")])
1932 (define_insn "extendqihi2"
1933 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1934 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1937 [(set_attr "type" "ext")])
1939 (define_expand "extendqisi2"
1940 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1941 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1942 "TARGET_68020 || TARGET_COLDFIRE"
1945 (define_insn "*cfv4_extendqisi2"
1946 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1947 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1950 [(set_attr "type" "mvsz")])
1952 (define_insn "*68k_extendqisi2"
1953 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1954 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1955 "TARGET_68020 || (TARGET_COLDFIRE && !ISA_HAS_MVS_MVZ)"
1957 [(set_attr "type" "ext")])
1959 ;; Conversions between float and double.
1961 (define_expand "extendsfdf2"
1962 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1964 (match_operand:SF 1 "general_operand" "")))]
1969 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1971 (match_operand:SF 1 "general_operand" "f,dmF")))]
1974 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1976 if (REGNO (operands[0]) == REGNO (operands[1]))
1978 /* Extending float to double in an fp-reg is a no-op.
1979 NOTICE_UPDATE_CC has already assumed that the
1980 cc will be set. So cancel what it did. */
1981 cc_status = cc_prev_status;
1984 return "f%&move%.x %1,%0";
1986 if (FP_REG_P (operands[0]))
1987 return "f%&move%.s %f1,%0";
1988 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1990 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1991 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1992 return "move%.l %+,%0";
1994 return "fmove%.d %f1,%0";
1997 (define_insn "extendsfdf2_cf"
1998 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
2000 (match_operand:SF 1 "general_operand" "f,<Q>U")))]
2001 "TARGET_COLDFIRE_FPU"
2003 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
2005 if (REGNO (operands[0]) == REGNO (operands[1]))
2007 /* Extending float to double in an fp-reg is a no-op.
2008 NOTICE_UPDATE_CC has already assumed that the
2009 cc will be set. So cancel what it did. */
2010 cc_status = cc_prev_status;
2013 return "fdmove%.d %1,%0";
2015 return "fdmove%.s %f1,%0";
2018 ;; This cannot output into an f-reg because there is no way to be
2019 ;; sure of truncating in that case.
2020 (define_expand "truncdfsf2"
2021 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2023 (match_operand:DF 1 "general_operand" "")))]
2027 ;; On the '040 we can truncate in a register accurately and easily.
2029 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2031 (match_operand:DF 1 "general_operand" "fmG")))]
2032 "TARGET_68881 && TARGET_68040"
2034 if (FP_REG_P (operands[1]))
2035 return "f%$move%.x %1,%0";
2036 return "f%$move%.d %f1,%0";
2039 (define_insn "truncdfsf2_cf"
2040 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
2042 (match_operand:DF 1 "general_operand" "<Q>U,f")))]
2043 "TARGET_COLDFIRE_FPU"
2047 [(set_attr "type" "fmove")])
2049 (define_insn "*truncdfsf2_68881"
2050 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
2052 (match_operand:DF 1 "general_operand" "f")))]
2055 [(set_attr "type" "fmove")])
2057 ;; Conversion between fixed point and floating point.
2058 ;; Note that among the fix-to-float insns
2059 ;; the ones that start with SImode come first.
2060 ;; That is so that an operand that is a CONST_INT
2061 ;; (and therefore lacks a specific machine mode).
2062 ;; will be recognized as SImode (which is always valid)
2063 ;; rather than as QImode or HImode.
2065 (define_expand "floatsi<mode>2"
2066 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2067 (float:FP (match_operand:SI 1 "general_operand" "")))]
2071 (define_insn "floatsi<mode>2_68881"
2072 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2073 (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
2075 "f<FP:round>move%.l %1,%0"
2076 [(set_attr "type" "fmove")])
2078 (define_insn "floatsi<mode>2_cf"
2079 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2080 (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
2081 "TARGET_COLDFIRE_FPU"
2082 "f<FP:prec>move%.l %1,%0"
2083 [(set_attr "type" "fmove")])
2086 (define_expand "floathi<mode>2"
2087 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2088 (float:FP (match_operand:HI 1 "general_operand" "")))]
2092 (define_insn "floathi<mode>2_68881"
2093 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2094 (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
2097 [(set_attr "type" "fmove")])
2099 (define_insn "floathi<mode>2_cf"
2100 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2101 (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
2102 "TARGET_COLDFIRE_FPU"
2104 [(set_attr "type" "fmove")])
2107 (define_expand "floatqi<mode>2"
2108 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2109 (float:FP (match_operand:QI 1 "general_operand" "")))]
2113 (define_insn "floatqi<mode>2_68881"
2114 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2115 (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
2118 [(set_attr "type" "fmove")])
2120 (define_insn "floatqi<mode>2_cf"
2121 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2122 (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
2123 "TARGET_COLDFIRE_FPU"
2125 [(set_attr "type" "fmove")])
2128 ;; New routines to convert floating-point values to integers
2129 ;; to be used on the '040. These should be faster than trapping
2130 ;; into the kernel to emulate fintrz. They should also be faster
2131 ;; than calling the subroutines fixsfsi or fixdfsi.
2133 (define_insn "fix_truncdfsi2"
2134 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2135 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2136 (clobber (match_scratch:SI 2 "=d"))
2137 (clobber (match_scratch:SI 3 "=d"))]
2138 "TARGET_68881 && TUNE_68040"
2141 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,%!";
2144 (define_insn "fix_truncdfhi2"
2145 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2146 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2147 (clobber (match_scratch:SI 2 "=d"))
2148 (clobber (match_scratch:SI 3 "=d"))]
2149 "TARGET_68881 && TUNE_68040"
2152 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,%!";
2155 (define_insn "fix_truncdfqi2"
2156 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2157 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2158 (clobber (match_scratch:SI 2 "=d"))
2159 (clobber (match_scratch:SI 3 "=d"))]
2160 "TARGET_68881 && TUNE_68040"
2163 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,%!";
2166 ;; Convert a float to a float whose value is an integer.
2167 ;; This is the first stage of converting it to an integer type.
2169 (define_expand "ftrunc<mode>2"
2170 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2171 (fix:FP (match_operand:FP 1 "general_operand" "")))]
2172 "TARGET_HARD_FLOAT && !TUNE_68040"
2175 (define_insn "ftrunc<mode>2_68881"
2176 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2177 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
2178 "TARGET_68881 && !TUNE_68040"
2180 if (FP_REG_P (operands[1]))
2181 return "fintrz%.x %f1,%0";
2182 return "fintrz%.<FP:prec> %f1,%0";
2184 [(set_attr "type" "falu")])
2186 (define_insn "ftrunc<mode>2_cf"
2187 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2188 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
2189 "TARGET_COLDFIRE_FPU"
2191 if (FP_REG_P (operands[1]))
2192 return "fintrz%.d %f1,%0";
2193 return "fintrz%.<FP:prec> %f1,%0";
2195 [(set_attr "type" "falu")])
2197 ;; Convert a float whose value is an integer
2198 ;; to an actual integer. Second stage of converting float to integer type.
2199 (define_expand "fix<mode>qi2"
2200 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2201 (fix:QI (match_operand:FP 1 "general_operand" "")))]
2205 (define_insn "fix<mode>qi2_68881"
2206 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2207 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2210 [(set_attr "type" "fmove")])
2212 (define_insn "fix<mode>qi2_cf"
2213 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
2214 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2215 "TARGET_COLDFIRE_FPU"
2217 [(set_attr "type" "fmove")])
2219 (define_expand "fix<mode>hi2"
2220 [(set (match_operand:HI 0 "nonimmediate_operand" "")
2221 (fix:HI (match_operand:FP 1 "general_operand" "")))]
2225 (define_insn "fix<mode>hi2_68881"
2226 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2227 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2230 [(set_attr "type" "fmove")])
2232 (define_insn "fix<mode>hi2_cf"
2233 [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
2234 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2235 "TARGET_COLDFIRE_FPU"
2237 [(set_attr "type" "fmove")])
2239 (define_expand "fix<mode>si2"
2240 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2241 (fix:SI (match_operand:FP 1 "general_operand" "")))]
2245 (define_insn "fix<mode>si2_68881"
2246 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2247 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2250 [(set_attr "type" "fmove")])
2252 (define_insn "fix<mode>si2_cf"
2253 [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
2254 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2255 "TARGET_COLDFIRE_FPU"
2257 [(set_attr "type" "fmove")])
2262 (define_insn "adddi_lshrdi_63"
2263 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
2264 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
2267 (clobber (match_scratch:SI 2 "=d"))]
2270 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2271 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
2273 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
2274 if (GET_CODE (operands[1]) == REG)
2275 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2276 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
2277 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2278 operands[4] = operands[1];
2280 operands[4] = adjust_address (operands[1], SImode, 4);
2281 if (GET_CODE (operands[1]) == MEM
2282 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2283 output_asm_insn ("move%.l %4,%3", operands);
2284 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
2285 if (TARGET_68020 || TARGET_COLDFIRE)
2286 output_asm_insn ("extb%.l %2", operands);
2288 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
2289 if (GET_CODE (operands[1]) != MEM
2290 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
2291 output_asm_insn ("move%.l %4,%3", operands);
2292 return "sub%.l %2,%3\;subx%.l %2,%0";
2295 (define_insn "adddi_sexthishl32"
2296 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2297 (plus:DI (ashift:DI (sign_extend:DI
2298 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
2300 (match_operand:DI 2 "general_operand" "0,0,0,0")))
2301 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2305 if (ADDRESS_REG_P (operands[0]))
2306 return "add%.w %1,%0";
2307 else if (ADDRESS_REG_P (operands[3]))
2308 return "move%.w %1,%3\;add%.l %3,%0";
2310 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
2313 (define_insn "*adddi_dilshr32"
2314 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
2315 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
2317 (match_operand:DI 2 "general_operand" "0,0")))]
2321 if (GET_CODE (operands[0]) == REG)
2322 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2324 operands[2] = adjust_address (operands[0], SImode, 4);
2325 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
2328 (define_insn "*adddi_dilshr32_cf"
2329 [(set (match_operand:DI 0 "register_operand" "=d")
2330 (plus:DI (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
2332 (match_operand:DI 2 "register_operand" "0")))]
2336 return "add%.l %1,%R0\;negx%.l %0\;neg%.l %0";
2339 (define_insn "adddi_dishl32"
2340 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
2341 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
2342 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2343 ;; (const_int 32))))]
2344 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
2346 (match_operand:DI 2 "general_operand" "0,0")))]
2350 if (GET_CODE (operands[1]) == REG)
2351 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2353 operands[1] = adjust_address (operands[1], SImode, 4);
2354 return "add%.l %1,%0";
2356 [(set_attr "type" "alu_l")])
2358 (define_insn "adddi3"
2359 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2360 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0")
2361 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2362 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2365 if (DATA_REG_P (operands[0]))
2367 if (DATA_REG_P (operands[2]))
2368 return "add%.l %R2,%R0\;addx%.l %2,%0";
2369 else if (GET_CODE (operands[2]) == MEM
2370 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2371 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
2377 if (GET_CODE (operands[2]) == REG)
2379 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2382 else if (CONSTANT_P (operands[2]))
2383 split_double (operands[2], &high, &low);
2386 low = adjust_address (operands[2], SImode, 4);
2390 operands[1] = low, operands[2] = high;
2391 xoperands[0] = operands[3];
2392 if (GET_CODE (operands[1]) == CONST_INT
2393 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2394 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2396 xoperands[1] = operands[2];
2398 output_asm_insn (output_move_simode (xoperands), xoperands);
2399 if (GET_CODE (operands[1]) == CONST_INT)
2401 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2402 return "addq%.l %1,%R0\;addx%.l %3,%0";
2403 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2405 operands[1] = GEN_INT (-INTVAL (operands[1]));
2406 return "subq%.l %1,%R0\;subx%.l %3,%0";
2409 return "add%.l %1,%R0\;addx%.l %3,%0";
2414 gcc_assert (GET_CODE (operands[0]) == MEM);
2416 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2418 operands[1] = gen_rtx_MEM (SImode,
2419 plus_constant (Pmode,
2420 XEXP(operands[0], 0), -8));
2421 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2423 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2425 operands[1] = XEXP(operands[0], 0);
2426 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2430 operands[1] = adjust_address (operands[0], SImode, 4);
2431 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2436 (define_insn "addsi_lshrsi_31"
2437 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,dm,d<Q>")
2438 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm,r<Q>,rm")
2443 operands[2] = operands[0];
2444 operands[3] = gen_label_rtx();
2445 if (GET_CODE (operands[0]) == MEM)
2447 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2448 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2449 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2450 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2452 output_asm_insn ("move%.l %1,%0", operands);
2453 output_asm_insn ("jpl %l3", operands);
2454 output_asm_insn ("addq%.l #1,%2", operands);
2455 (*targetm.asm_out.internal_label) (asm_out_file, "L",
2456 CODE_LABEL_NUMBER (operands[3]));
2459 [(set_attr "ok_for_coldfire" "no,yes,yes")])
2461 (define_expand "addsi3"
2462 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2463 (plus:SI (match_operand:SI 1 "general_operand" "")
2464 (match_operand:SI 2 "general_src_operand" "")))]
2468 ;; Note that the middle two alternatives are near-duplicates
2469 ;; in order to handle insns generated by reload.
2470 ;; This is needed since they are not themselves reloaded,
2471 ;; so commutativity won't apply to them.
2472 (define_insn "*addsi3_internal"
2473 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2474 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2475 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2479 "* return output_addsi3 (operands);")
2481 (define_insn_and_split "*addsi3_5200"
2482 [(set (match_operand:SI 0 "nonimmediate_operand" "=mr,mr,a, m,r, ?a, ?a,?a,?a")
2483 (plus:SI (match_operand:SI 1 "general_operand" "%0, 0, 0, 0,0, a, a, r, a")
2484 (match_operand:SI 2 "general_src_operand" " I, L, JCu,d,mrKi,Cj, r, a, JCu")))]
2487 switch (which_alternative)
2490 return "addq%.l %2,%0";
2493 operands[2] = GEN_INT (- INTVAL (operands[2]));
2494 return "subq%.l %2,%0";
2498 return "add%.l %2,%0";
2501 /* move%.l %2,%0\n\tadd%.l %1,%0 */
2505 return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0";
2508 return MOTOROLA ? "lea (%2,%1.l),%0" : "lea %2@(0,%1:l),%0";
2512 return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
2519 "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 5) && !operands_match_p (operands[0], operands[1])"
2523 (plus:SI (match_dup 0)
2526 [(set_attr "type" "aluq_l,aluq_l,lea, alu_l,alu_l,*,lea, lea, lea")
2527 (set_attr "opy" "2, 2, *, 2, 2, *,*, *, *")
2528 (set_attr "opy_type" "*, *, mem5,*, *, *,mem6,mem6,mem5")])
2531 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2532 (plus:SI (match_operand:SI 1 "general_operand" "0")
2534 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2538 (define_insn "addhi3"
2539 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2540 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2541 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2544 if (GET_CODE (operands[2]) == CONST_INT)
2546 /* If the constant would be a negative number when interpreted as
2547 HImode, make it negative. This is usually, but not always, done
2548 elsewhere in the compiler. First check for constants out of range,
2549 which could confuse us. */
2551 if (INTVAL (operands[2]) >= 32768)
2552 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2554 if (INTVAL (operands[2]) > 0
2555 && INTVAL (operands[2]) <= 8)
2556 return "addq%.w %2,%0";
2557 if (INTVAL (operands[2]) < 0
2558 && INTVAL (operands[2]) >= -8)
2560 operands[2] = GEN_INT (- INTVAL (operands[2]));
2561 return "subq%.w %2,%0";
2563 /* On the CPU32 it is faster to use two addqw instructions to
2564 add a small integer (8 < N <= 16) to a register.
2565 Likewise for subqw. */
2566 if (TUNE_CPU32 && REG_P (operands[0]))
2568 if (INTVAL (operands[2]) > 8
2569 && INTVAL (operands[2]) <= 16)
2571 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2572 return "addq%.w #8,%0\;addq%.w %2,%0";
2574 if (INTVAL (operands[2]) < -8
2575 && INTVAL (operands[2]) >= -16)
2577 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2578 return "subq%.w #8,%0\;subq%.w %2,%0";
2581 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2582 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2584 return "add%.w %2,%0";
2587 ;; These insns must use MATCH_DUP instead of the more expected
2588 ;; use of a matching constraint because the "output" here is also
2589 ;; an input, so you can't use the matching constraint. That also means
2590 ;; that you can't use the "%", so you need patterns with the matched
2591 ;; operand in both positions.
2594 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2595 (plus:HI (match_dup 0)
2596 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2599 if (GET_CODE (operands[1]) == CONST_INT)
2601 /* If the constant would be a negative number when interpreted as
2602 HImode, make it negative. This is usually, but not always, done
2603 elsewhere in the compiler. First check for constants out of range,
2604 which could confuse us. */
2606 if (INTVAL (operands[1]) >= 32768)
2607 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2609 if (INTVAL (operands[1]) > 0
2610 && INTVAL (operands[1]) <= 8)
2611 return "addq%.w %1,%0";
2612 if (INTVAL (operands[1]) < 0
2613 && INTVAL (operands[1]) >= -8)
2615 operands[1] = GEN_INT (- INTVAL (operands[1]));
2616 return "subq%.w %1,%0";
2618 /* On the CPU32 it is faster to use two addqw instructions to
2619 add a small integer (8 < N <= 16) to a register.
2620 Likewise for subqw. */
2621 if (TUNE_CPU32 && REG_P (operands[0]))
2623 if (INTVAL (operands[1]) > 8
2624 && INTVAL (operands[1]) <= 16)
2626 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2627 return "addq%.w #8,%0\;addq%.w %1,%0";
2629 if (INTVAL (operands[1]) < -8
2630 && INTVAL (operands[1]) >= -16)
2632 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2633 return "subq%.w #8,%0\;subq%.w %1,%0";
2636 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2637 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2639 return "add%.w %1,%0";
2643 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2644 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2648 if (GET_CODE (operands[1]) == CONST_INT)
2650 /* If the constant would be a negative number when interpreted as
2651 HImode, make it negative. This is usually, but not always, done
2652 elsewhere in the compiler. First check for constants out of range,
2653 which could confuse us. */
2655 if (INTVAL (operands[1]) >= 32768)
2656 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2658 if (INTVAL (operands[1]) > 0
2659 && INTVAL (operands[1]) <= 8)
2660 return "addq%.w %1,%0";
2661 if (INTVAL (operands[1]) < 0
2662 && INTVAL (operands[1]) >= -8)
2664 operands[1] = GEN_INT (- INTVAL (operands[1]));
2665 return "subq%.w %1,%0";
2667 /* On the CPU32 it is faster to use two addqw instructions to
2668 add a small integer (8 < N <= 16) to a register.
2669 Likewise for subqw. */
2670 if (TUNE_CPU32 && REG_P (operands[0]))
2672 if (INTVAL (operands[1]) > 8
2673 && INTVAL (operands[1]) <= 16)
2675 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2676 return "addq%.w #8,%0\;addq%.w %1,%0";
2678 if (INTVAL (operands[1]) < -8
2679 && INTVAL (operands[1]) >= -16)
2681 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2682 return "subq%.w #8,%0\;subq%.w %1,%0";
2685 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2686 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2688 return "add%.w %1,%0";
2691 (define_insn "addqi3"
2692 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2693 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2694 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2697 if (GET_CODE (operands[2]) == CONST_INT)
2699 if (INTVAL (operands[2]) >= 128)
2700 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2702 if (INTVAL (operands[2]) > 0
2703 && INTVAL (operands[2]) <= 8)
2704 return "addq%.b %2,%0";
2705 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2707 operands[2] = GEN_INT (- INTVAL (operands[2]));
2708 return "subq%.b %2,%0";
2711 return "add%.b %2,%0";
2715 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2716 (plus:QI (match_dup 0)
2717 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2720 if (GET_CODE (operands[1]) == CONST_INT)
2722 if (INTVAL (operands[1]) >= 128)
2723 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2725 if (INTVAL (operands[1]) > 0
2726 && INTVAL (operands[1]) <= 8)
2727 return "addq%.b %1,%0";
2728 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2730 operands[1] = GEN_INT (- INTVAL (operands[1]));
2731 return "subq%.b %1,%0";
2734 return "add%.b %1,%0";
2738 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2739 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2743 if (GET_CODE (operands[1]) == CONST_INT)
2745 if (INTVAL (operands[1]) >= 128)
2746 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2748 if (INTVAL (operands[1]) > 0
2749 && INTVAL (operands[1]) <= 8)
2750 return "addq%.b %1,%0";
2751 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2753 operands[1] = GEN_INT (- INTVAL (operands[1]));
2754 return "subq%.b %1,%0";
2757 return "add%.b %1,%0";
2760 (define_expand "add<mode>3"
2761 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2762 (plus:FP (match_operand:FP 1 "general_operand" "")
2763 (match_operand:FP 2 "general_operand" "")))]
2767 (define_insn "add<mode>3_floatsi_68881"
2768 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2769 (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2770 (match_operand:FP 1 "general_operand" "0")))]
2772 "f<FP:round>add%.l %2,%0"
2773 [(set_attr "type" "falu")
2774 (set_attr "opy" "2")])
2776 (define_insn "add<mode>3_floathi_68881"
2777 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2778 (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2779 (match_operand:FP 1 "general_operand" "0")))]
2781 "f<FP:round>add%.w %2,%0"
2782 [(set_attr "type" "falu")
2783 (set_attr "opy" "2")])
2785 (define_insn "add<mode>3_floatqi_68881"
2786 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2787 (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2788 (match_operand:FP 1 "general_operand" "0")))]
2790 "f<FP:round>add%.b %2,%0"
2791 [(set_attr "type" "falu")
2792 (set_attr "opy" "2")])
2794 (define_insn "add<mode>3_68881"
2795 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2796 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2797 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2800 if (FP_REG_P (operands[2]))
2801 return "f<FP:round>add%.x %2,%0";
2802 return "f<FP:round>add%.<FP:prec> %f2,%0";
2804 [(set_attr "type" "falu")
2805 (set_attr "opy" "2")])
2807 (define_insn "add<mode>3_cf"
2808 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2809 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2810 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2811 "TARGET_COLDFIRE_FPU"
2813 if (FP_REG_P (operands[2]))
2814 return "f<FP:prec>add%.d %2,%0";
2815 return "f<FP:prec>add%.<FP:prec> %2,%0";
2817 [(set_attr "type" "falu")
2818 (set_attr "opy" "2")])
2820 ;; subtract instructions
2822 (define_insn "subdi_sexthishl32"
2823 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2824 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2825 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2827 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2831 if (ADDRESS_REG_P (operands[0]))
2832 return "sub%.w %2,%0";
2833 else if (ADDRESS_REG_P (operands[3]))
2834 return "move%.w %2,%3\;sub%.l %3,%0";
2836 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2839 (define_insn "subdi_dishl32"
2840 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2841 (minus:DI (match_dup 0)
2842 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2847 if (GET_CODE (operands[1]) == REG)
2848 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2850 operands[1] = adjust_address (operands[1], SImode, 4);
2851 return "sub%.l %1,%0";
2853 [(set_attr "type" "alu_l")])
2855 (define_insn "subdi3"
2856 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2857 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2858 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2859 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2862 if (DATA_REG_P (operands[0]))
2864 if (DATA_REG_P (operands[2]))
2865 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2866 else if (GET_CODE (operands[2]) == MEM
2867 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2869 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2876 if (GET_CODE (operands[2]) == REG)
2878 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2881 else if (CONSTANT_P (operands[2]))
2882 split_double (operands[2], &high, &low);
2885 low = adjust_address (operands[2], SImode, 4);
2889 operands[1] = low, operands[2] = high;
2890 xoperands[0] = operands[3];
2891 if (GET_CODE (operands[1]) == CONST_INT
2892 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2893 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2895 xoperands[1] = operands[2];
2897 output_asm_insn (output_move_simode (xoperands), xoperands);
2898 if (GET_CODE (operands[1]) == CONST_INT)
2900 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2901 return "subq%.l %1,%R0\;subx%.l %3,%0";
2902 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2904 operands[1] = GEN_INT (-INTVAL (operands[1]));
2905 return "addq%.l %1,%R0\;addx%.l %3,%0";
2908 return "sub%.l %1,%R0\;subx%.l %3,%0";
2913 gcc_assert (GET_CODE (operands[0]) == MEM);
2915 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2918 = gen_rtx_MEM (SImode, plus_constant (Pmode,
2919 XEXP (operands[0], 0), -8));
2920 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2922 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2924 operands[1] = XEXP(operands[0], 0);
2925 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2929 operands[1] = adjust_address (operands[0], SImode, 4);
2930 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2935 (define_insn "subsi3"
2936 [(set (match_operand:SI 0 "nonimmediate_operand" "=mda,m,d,a")
2937 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0,0")
2938 (match_operand:SI 2 "general_src_operand" "I,dT,mSrT,mSrs")))]
2945 [(set_attr "type" "aluq_l,alu_l,alu_l,alu_l")
2946 (set_attr "opy" "2")])
2949 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2950 (minus:SI (match_operand:SI 1 "general_operand" "0")
2952 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2956 (define_insn "subhi3"
2957 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2958 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2959 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2964 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2965 (minus:HI (match_dup 0)
2966 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2970 (define_insn "subqi3"
2971 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2972 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2973 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2978 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2979 (minus:QI (match_dup 0)
2980 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2984 (define_expand "sub<mode>3"
2985 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2986 (minus:FP (match_operand:FP 1 "general_operand" "")
2987 (match_operand:FP 2 "general_operand" "")))]
2991 (define_insn "sub<mode>3_floatsi_68881"
2992 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2993 (minus:FP (match_operand:FP 1 "general_operand" "0")
2994 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2996 "f<FP:round>sub%.l %2,%0"
2997 [(set_attr "type" "falu")
2998 (set_attr "opy" "2")])
3000 (define_insn "sub<mode>3_floathi_68881"
3001 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3002 (minus:FP (match_operand:FP 1 "general_operand" "0")
3003 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
3005 "f<FP:round>sub%.w %2,%0"
3006 [(set_attr "type" "falu")
3007 (set_attr "opy" "2")])
3009 (define_insn "sub<mode>3_floatqi_68881"
3010 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3011 (minus:FP (match_operand:FP 1 "general_operand" "0")
3012 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3014 "f<FP:round>sub%.b %2,%0"
3015 [(set_attr "type" "falu")
3016 (set_attr "opy" "2")])
3018 (define_insn "sub<mode>3_68881"
3019 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3020 (minus:FP (match_operand:FP 1 "general_operand" "0")
3021 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3024 if (FP_REG_P (operands[2]))
3025 return "f<FP:round>sub%.x %2,%0";
3026 return "f<FP:round>sub%.<FP:prec> %f2,%0";
3028 [(set_attr "type" "falu")
3029 (set_attr "opy" "2")])
3031 (define_insn "sub<mode>3_cf"
3032 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3033 (minus:FP (match_operand:FP 1 "general_operand" "0")
3034 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
3035 "TARGET_COLDFIRE_FPU"
3037 if (FP_REG_P (operands[2]))
3038 return "f<FP:prec>sub%.d %2,%0";
3039 return "f<FP:prec>sub%.<FP:prec> %2,%0";
3041 [(set_attr "type" "falu")
3042 (set_attr "opy" "2")])
3044 ;; multiply instructions
3046 (define_insn "mulhi3"
3047 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3048 (mult:HI (match_operand:HI 1 "general_operand" "%0")
3049 (match_operand:HI 2 "general_src_operand" "dmSn")))]
3052 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3054 [(set_attr "type" "mul_w")
3055 (set_attr "opy" "2")])
3057 (define_insn "mulhisi3"
3058 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3059 (mult:SI (sign_extend:SI
3060 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3062 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3065 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3067 [(set_attr "type" "mul_w")
3068 (set_attr "opy" "2")])
3070 (define_insn "*mulhisisi3_s"
3071 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3072 (mult:SI (sign_extend:SI
3073 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3074 (match_operand:SI 2 "const_int_operand" "n")))]
3075 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
3077 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3079 [(set_attr "type" "mul_w")
3080 (set_attr "opy" "2")])
3082 (define_expand "mulsi3"
3083 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3084 (mult:SI (match_operand:SI 1 "general_operand" "")
3085 (match_operand:SI 2 "general_operand" "")))]
3086 "TARGET_68020 || TARGET_COLDFIRE"
3089 (define_insn "*mulsi3_68020"
3090 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3091 (mult:SI (match_operand:SI 1 "general_operand" "%0")
3092 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
3096 [(set_attr "type" "mul_l")
3097 (set_attr "opy" "2")])
3099 (define_insn "*mulsi3_cf"
3100 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3101 (mult:SI (match_operand:SI 1 "general_operand" "%0")
3102 (match_operand:SI 2 "general_operand" "d<Q>")))]
3105 [(set_attr "type" "mul_l")
3106 (set_attr "opy" "2")])
3108 (define_insn "umulhisi3"
3109 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3110 (mult:SI (zero_extend:SI
3111 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3113 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3116 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3118 [(set_attr "type" "mul_w")
3119 (set_attr "opy" "2")])
3121 (define_insn "*mulhisisi3_z"
3122 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3123 (mult:SI (zero_extend:SI
3124 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3125 (match_operand:SI 2 "const_int_operand" "n")))]
3126 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
3128 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3130 [(set_attr "type" "mul_w")
3131 (set_attr "opy" "2")])
3133 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
3134 ;; proper matching constraint. This is because the matching is between
3135 ;; the high-numbered word of the DImode operand[0] and operand[1].
3136 (define_expand "umulsidi3"
3138 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3139 (mult:SI (match_operand:SI 1 "register_operand" "")
3140 (match_operand:SI 2 "register_operand" "")))
3141 (set (subreg:SI (match_dup 0) 0)
3142 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3143 (zero_extend:DI (match_dup 2)))
3144 (const_int 32))))])]
3145 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3149 [(set (match_operand:SI 0 "register_operand" "=d")
3150 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3151 (match_operand:SI 2 "nonimmediate_operand" "dm")))
3152 (set (match_operand:SI 3 "register_operand" "=d")
3153 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3154 (zero_extend:DI (match_dup 2)))
3156 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3159 ; Match immediate case. For 2.4 only match things < 2^31.
3160 ; It's tricky with larger values in these patterns since we need to match
3161 ; values between the two parallel multiplies, between a CONST_DOUBLE and
3164 [(set (match_operand:SI 0 "register_operand" "=d")
3165 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3166 (match_operand:SI 2 "const_int_operand" "n")))
3167 (set (match_operand:SI 3 "register_operand" "=d")
3168 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3171 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
3172 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
3175 (define_expand "mulsidi3"
3177 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3178 (mult:SI (match_operand:SI 1 "register_operand" "")
3179 (match_operand:SI 2 "register_operand" "")))
3180 (set (subreg:SI (match_dup 0) 0)
3181 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3182 (sign_extend:DI (match_dup 2)))
3183 (const_int 32))))])]
3184 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3188 [(set (match_operand:SI 0 "register_operand" "=d")
3189 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3190 (match_operand:SI 2 "nonimmediate_operand" "dm")))
3191 (set (match_operand:SI 3 "register_operand" "=d")
3192 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3193 (sign_extend:DI (match_dup 2)))
3195 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3199 [(set (match_operand:SI 0 "register_operand" "=d")
3200 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3201 (match_operand:SI 2 "const_int_operand" "n")))
3202 (set (match_operand:SI 3 "register_operand" "=d")
3203 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3206 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3209 (define_expand "umulsi3_highpart"
3211 [(set (match_operand:SI 0 "register_operand" "")
3214 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
3215 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
3217 (clobber (match_dup 3))])]
3218 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3220 operands[3] = gen_reg_rtx (SImode);
3222 if (GET_CODE (operands[2]) == CONST_INT)
3224 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
3227 /* We have to adjust the operand order for the matching constraints. */
3228 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
3229 operands[1], operands[2]));
3235 [(set (match_operand:SI 0 "register_operand" "=d")
3238 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3239 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3241 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3242 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3245 (define_insn "const_umulsi3_highpart"
3246 [(set (match_operand:SI 0 "register_operand" "=d")
3249 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
3250 (match_operand:DI 3 "const_uint32_operand" "n"))
3252 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3253 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3256 (define_expand "smulsi3_highpart"
3258 [(set (match_operand:SI 0 "register_operand" "")
3261 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
3262 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
3264 (clobber (match_dup 3))])]
3265 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3267 operands[3] = gen_reg_rtx (SImode);
3268 if (GET_CODE (operands[2]) == CONST_INT)
3270 /* We have to adjust the operand order for the matching constraints. */
3271 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
3272 operands[1], operands[2]));
3278 [(set (match_operand:SI 0 "register_operand" "=d")
3281 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3282 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3284 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3285 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3288 (define_insn "const_smulsi3_highpart"
3289 [(set (match_operand:SI 0 "register_operand" "=d")
3292 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
3293 (match_operand:DI 3 "const_sint32_operand" "n"))
3295 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3296 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3299 (define_expand "mul<mode>3"
3300 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3301 (mult:FP (match_operand:FP 1 "general_operand" "")
3302 (match_operand:FP 2 "general_operand" "")))]
3306 (define_insn "mul<mode>3_floatsi_68881"
3307 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3308 (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
3309 (match_operand:FP 1 "general_operand" "0")))]
3313 ? "f<FP:round>mul%.l %2,%0"
3314 : "f<FP:round_mul>mul%.l %2,%0";
3316 [(set_attr "type" "fmul")
3317 (set_attr "opy" "2")])
3319 (define_insn "mul<mode>3_floathi_68881"
3320 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3321 (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
3322 (match_operand:FP 1 "general_operand" "0")))]
3326 ? "f<FP:round>mul%.w %2,%0"
3327 : "f<FP:round_mul>mul%.w %2,%0";
3329 [(set_attr "type" "fmul")
3330 (set_attr "opy" "2")])
3332 (define_insn "mul<mode>3_floatqi_68881"
3333 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3334 (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
3335 (match_operand:FP 1 "general_operand" "0")))]
3339 ? "f<FP:round>mul%.b %2,%0"
3340 : "f<FP:round_mul>mul%.b %2,%0";
3342 [(set_attr "type" "fmul")
3343 (set_attr "opy" "2")])
3345 (define_insn "muldf_68881"
3346 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3347 (mult:DF (match_operand:DF 1 "general_operand" "%0")
3348 (match_operand:DF 2 "general_operand" "fmG")))]
3351 if (GET_CODE (operands[2]) == CONST_DOUBLE
3352 && floating_exact_log2 (operands[2]) && !TUNE_68040_60)
3354 int i = floating_exact_log2 (operands[2]);
3355 operands[2] = GEN_INT (i);
3356 return "fscale%.l %2,%0";
3358 if (REG_P (operands[2]))
3359 return "f%&mul%.x %2,%0";
3360 return "f%&mul%.d %f2,%0";
3363 (define_insn "mulsf_68881"
3364 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3365 (mult:SF (match_operand:SF 1 "general_operand" "%0")
3366 (match_operand:SF 2 "general_operand" "fdmF")))]
3369 if (FP_REG_P (operands[2]))
3370 return (TARGET_68040
3372 : "fsglmul%.x %2,%0");
3373 return (TARGET_68040
3375 : "fsglmul%.s %f2,%0");
3378 (define_insn "mulxf3_68881"
3379 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
3380 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
3381 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
3384 return "fmul%.x %f2,%0";
3387 (define_insn "fmul<mode>3_cf"
3388 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3389 (mult:FP (match_operand:FP 1 "general_operand" "%0")
3390 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3391 "TARGET_COLDFIRE_FPU"
3393 if (FP_REG_P (operands[2]))
3394 return "f<FP:prec>mul%.d %2,%0";
3395 return "f<FP:prec>mul%.<FP:prec> %2,%0";
3397 [(set_attr "type" "fmul")
3398 (set_attr "opy" "2")])
3400 ;; divide instructions
3402 (define_expand "div<mode>3"
3403 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3404 (div:FP (match_operand:FP 1 "general_operand" "")
3405 (match_operand:FP 2 "general_operand" "")))]
3409 (define_insn "div<mode>3_floatsi_68881"
3410 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3411 (div:FP (match_operand:FP 1 "general_operand" "0")
3412 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
3416 ? "f<FP:round>div%.l %2,%0"
3417 : "f<FP:round_mul>div%.l %2,%0";
3420 (define_insn "div<mode>3_floathi_68881"
3421 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3422 (div:FP (match_operand:FP 1 "general_operand" "0")
3423 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
3427 ? "f<FP:round>div%.w %2,%0"
3428 : "f<FP:round_mul>div%.w %2,%0";
3431 (define_insn "div<mode>3_floatqi_68881"
3432 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3433 (div:FP (match_operand:FP 1 "general_operand" "0")
3434 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3438 ? "f<FP:round>div%.b %2,%0"
3439 : "f<FP:round_mul>div%.b %2,%0";
3442 (define_insn "div<mode>3_68881"
3443 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3444 (div:FP (match_operand:FP 1 "general_operand" "0")
3445 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3448 if (FP_REG_P (operands[2]))
3449 return (TARGET_68040
3450 ? "f<FP:round>div%.x %2,%0"
3451 : "f<FP:round_mul>div%.x %2,%0");
3452 return (TARGET_68040
3453 ? "f<FP:round>div%.<FP:prec> %f2,%0"
3454 : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
3457 (define_insn "div<mode>3_cf"
3458 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3459 (div:FP (match_operand:FP 1 "general_operand" "0")
3460 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3461 "TARGET_COLDFIRE_FPU"
3463 if (FP_REG_P (operands[2]))
3464 return "f<FP:prec>div%.d %2,%0";
3465 return "f<FP:prec>div%.<FP:prec> %2,%0";
3467 [(set_attr "type" "fdiv")
3468 (set_attr "opy" "2")])
3470 ;; Remainder instructions.
3472 (define_expand "divmodsi4"
3474 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3475 (div:SI (match_operand:SI 1 "general_operand" "")
3476 (match_operand:SI 2 "general_src_operand" "")))
3477 (set (match_operand:SI 3 "nonimmediate_operand" "")
3478 (mod:SI (match_dup 1) (match_dup 2)))])]
3479 "TARGET_68020 || TARGET_CF_HWDIV"
3483 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3484 (div:SI (match_operand:SI 1 "general_operand" "0")
3485 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3486 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3487 (mod:SI (match_dup 1) (match_dup 2)))]
3490 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3491 return "divs%.l %2,%0";
3492 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3493 return "rems%.l %2,%3:%0";
3495 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
3497 [(set_attr "type" "div_l")
3498 (set_attr "opy" "2")])
3501 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3502 (div:SI (match_operand:SI 1 "general_operand" "0")
3503 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3504 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3505 (mod:SI (match_dup 1) (match_dup 2)))]
3508 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3509 return "divs%.l %2,%0";
3511 return "divsl%.l %2,%3:%0";
3514 (define_expand "udivmodsi4"
3516 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3517 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3518 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3519 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3520 (umod:SI (match_dup 1) (match_dup 2)))])]
3521 "TARGET_68020 || TARGET_CF_HWDIV"
3525 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3526 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3527 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3528 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3529 (umod:SI (match_dup 1) (match_dup 2)))]
3532 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3533 return "divu%.l %2,%0";
3534 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3535 return "remu%.l %2,%3:%0";
3537 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3539 [(set_attr "type" "div_l")
3540 (set_attr "opy" "2")])
3543 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3544 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3545 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3546 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3547 (umod:SI (match_dup 1) (match_dup 2)))]
3548 "TARGET_68020 && !TARGET_COLDFIRE"
3550 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3551 return "divu%.l %2,%0";
3553 return "divul%.l %2,%3:%0";
3556 (define_insn "divmodhi4"
3557 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3558 (div:HI (match_operand:HI 1 "general_operand" "0")
3559 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3560 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3561 (mod:HI (match_dup 1) (match_dup 2)))]
3562 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3564 output_asm_insn (MOTOROLA ?
3565 "ext%.l %0\;divs%.w %2,%0" :
3566 "extl %0\;divs %2,%0",
3568 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3571 return "move%.l %0,%3\;swap %3";
3577 (define_insn "udivmodhi4"
3578 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3579 (udiv:HI (match_operand:HI 1 "general_operand" "0")
3580 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3581 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3582 (umod:HI (match_dup 1) (match_dup 2)))]
3583 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3585 if (ISA_HAS_MVS_MVZ)
3586 output_asm_insn (MOTOROLA ?
3587 "mvz%.w %0,%0\;divu%.w %2,%0" :
3588 "mvz%.w %0,%0\;divu %2,%0",
3591 output_asm_insn (MOTOROLA ?
3592 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3593 "and%.l #0xFFFF,%0\;divu %2,%0",
3596 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3599 return "move%.l %0,%3\;swap %3";
3605 ;; logical-and instructions
3607 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3608 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3609 ;; can't allocate pseudos into it.
3611 (define_expand "andsi3"
3612 [(set (match_operand:SI 0 "not_sp_operand" "")
3613 (and:SI (match_operand:SI 1 "general_operand" "")
3614 (match_operand:SI 2 "general_src_operand" "")))]
3618 ;; produced by split operations after reload finished
3619 (define_insn "*andsi3_split"
3620 [(set (match_operand:SI 0 "register_operand" "=d")
3621 (and:SI (match_operand:SI 1 "register_operand" "0")
3622 (match_operand:SI 2 "const_int_operand" "i")))]
3623 "reload_completed && !TARGET_COLDFIRE"
3625 return output_andsi3 (operands);
3628 (define_insn "andsi3_internal"
3629 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3630 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3631 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3634 return output_andsi3 (operands);
3637 (define_insn "andsi3_5200"
3638 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3639 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3640 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3644 && DATA_REG_P (operands[0])
3645 && GET_CODE (operands[2]) == CONST_INT)
3647 if (INTVAL (operands[2]) == 0x000000ff)
3648 return "mvz%.b %0,%0";
3649 else if (INTVAL (operands[2]) == 0x0000ffff)
3650 return "mvz%.w %0,%0";
3652 return output_andsi3 (operands);
3655 (define_insn "andhi3"
3656 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3657 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3658 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3663 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3664 (and:HI (match_dup 0)
3665 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3670 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3671 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3676 (define_insn "andqi3"
3677 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3678 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3679 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3684 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3685 (and:QI (match_dup 0)
3686 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3691 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3692 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3697 ;; inclusive-or instructions
3699 (define_insn "iordi_zext"
3700 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3701 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3702 (match_operand:DI 2 "general_operand" "0,0")))]
3708 if (GET_CODE (operands[0]) == REG)
3709 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3711 operands[0] = adjust_address (operands[0], SImode, 4);
3712 if (GET_MODE (operands[1]) == SImode)
3713 return "or%.l %1,%0";
3714 byte_mode = (GET_MODE (operands[1]) == QImode);
3715 if (GET_CODE (operands[0]) == MEM)
3716 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3719 return "or%.b %1,%0";
3721 return "or%.w %1,%0";
3724 (define_expand "iorsi3"
3725 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3726 (ior:SI (match_operand:SI 1 "general_operand" "")
3727 (match_operand:SI 2 "general_src_operand" "")))]
3731 (define_insn "iorsi3_internal"
3732 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3733 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3734 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3737 return output_iorsi3 (operands);
3740 (define_insn "iorsi3_5200"
3741 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3742 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3743 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3746 return output_iorsi3 (operands);
3749 (define_insn "iorhi3"
3750 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3751 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3752 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3757 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3758 (ior:HI (match_dup 0)
3759 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3764 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3765 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3770 (define_insn "iorqi3"
3771 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3772 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3773 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3778 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3779 (ior:QI (match_dup 0)
3780 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3785 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3786 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3791 ;; On all 68k models, this makes faster code in a special case.
3792 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3794 (define_insn "iorsi_zexthi_ashl16"
3795 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3796 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3797 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3802 if (GET_CODE (operands[2]) != REG)
3803 operands[2] = adjust_address (operands[2], HImode, 2);
3804 if (GET_CODE (operands[2]) != REG
3805 || REGNO (operands[2]) != REGNO (operands[0]))
3806 output_asm_insn ("move%.w %2,%0", operands);
3807 return "swap %0\;mov%.w %1,%0";
3810 (define_insn "iorsi_zext"
3811 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3812 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3813 (match_operand:SI 2 "general_operand" "0,0")))]
3819 byte_mode = (GET_MODE (operands[1]) == QImode);
3820 if (GET_CODE (operands[0]) == MEM)
3821 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3824 return "or%.b %1,%0";
3826 return "or%.w %1,%0";
3831 (define_expand "xorsi3"
3832 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3833 (xor:SI (match_operand:SI 1 "general_operand" "")
3834 (match_operand:SI 2 "general_operand" "")))]
3838 (define_insn "xorsi3_internal"
3839 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,o,m")
3840 (xor:SI (match_operand:SI 1 "general_operand" "%0, 0,0")
3841 (match_operand:SI 2 "general_operand" "di,dK,dKT")))]
3845 return output_xorsi3 (operands);
3848 (define_insn "xorsi3_5200"
3849 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3850 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3851 (match_operand:SI 2 "general_operand" "d,Ks")))]
3854 return output_xorsi3 (operands);
3857 (define_insn "xorhi3"
3858 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3859 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3860 (match_operand:HI 2 "general_operand" "dn")))]
3865 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3866 (xor:HI (match_dup 0)
3867 (match_operand:HI 1 "general_operand" "dn")))]
3872 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3873 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3878 (define_insn "xorqi3"
3879 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3880 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3881 (match_operand:QI 2 "general_operand" "dn")))]
3886 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3887 (xor:QI (match_dup 0)
3888 (match_operand:QI 1 "general_operand" "dn")))]
3893 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3894 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3899 ;; negation instructions
3901 (define_expand "negdi2"
3902 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3903 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3906 if (TARGET_COLDFIRE)
3907 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3909 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3913 (define_insn "negdi2_internal"
3914 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3915 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3918 if (which_alternative == 0)
3919 return "neg%.l %0\;negx%.l %0";
3920 if (GET_CODE (operands[0]) == REG)
3921 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3923 operands[1] = adjust_address (operands[0], SImode, 4);
3924 if (ADDRESS_REG_P (operands[0]))
3925 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3927 return "neg%.l %1\;negx%.l %0";
3930 (define_insn "negdi2_5200"
3931 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3932 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3935 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3936 return "neg%.l %1\;negx%.l %0";
3939 (define_expand "negsi2"
3940 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3941 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3944 if (TARGET_COLDFIRE)
3945 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3947 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3951 (define_insn "negsi2_internal"
3952 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3953 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3956 [(set_attr "type" "neg_l")])
3958 (define_insn "negsi2_5200"
3959 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3960 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3963 [(set_attr "type" "neg_l")])
3965 (define_insn "neghi2"
3966 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3967 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3972 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3973 (neg:HI (match_dup 0)))]
3977 (define_insn "negqi2"
3978 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3979 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3984 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3985 (neg:QI (match_dup 0)))]
3989 ;; If using software floating point, just flip the sign bit.
3991 (define_expand "negsf2"
3992 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3993 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3996 if (!TARGET_HARD_FLOAT)
4001 target = operand_subword_force (operands[0], 0, SFmode);
4002 result = expand_binop (SImode, xor_optab,
4003 operand_subword_force (operands[1], 0, SFmode),
4004 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4005 gcc_assert (result);
4007 if (result != target)
4008 emit_move_insn (result, target);
4010 /* Make a place for REG_EQUAL. */
4011 emit_move_insn (operands[0], operands[0]);
4016 (define_expand "negdf2"
4017 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4018 (neg:DF (match_operand:DF 1 "general_operand" "")))]
4021 if (!TARGET_HARD_FLOAT)
4028 target = operand_subword (operands[0], 0, 1, DFmode);
4029 result = expand_binop (SImode, xor_optab,
4030 operand_subword_force (operands[1], 0, DFmode),
4031 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4032 gcc_assert (result);
4034 if (result != target)
4035 emit_move_insn (result, target);
4037 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4038 operand_subword_force (operands[1], 1, DFmode));
4040 insns = get_insns ();
4048 (define_expand "negxf2"
4049 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4050 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4060 target = operand_subword (operands[0], 0, 1, XFmode);
4061 result = expand_binop (SImode, xor_optab,
4062 operand_subword_force (operands[1], 0, XFmode),
4063 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4064 gcc_assert (result);
4066 if (result != target)
4067 emit_move_insn (result, target);
4069 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4070 operand_subword_force (operands[1], 1, XFmode));
4071 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4072 operand_subword_force (operands[1], 2, XFmode));
4074 insns = get_insns ();
4082 (define_insn "neg<mode>2_68881"
4083 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4084 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4087 if (DATA_REG_P (operands[0]))
4089 operands[1] = GEN_INT (31);
4090 return "bchg %1,%0";
4092 if (FP_REG_P (operands[1]))
4093 return "f<FP:round>neg%.x %1,%0";
4094 return "f<FP:round>neg%.<FP:prec> %f1,%0";
4097 (define_insn "neg<mode>2_cf"
4098 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4099 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4100 "TARGET_COLDFIRE_FPU"
4102 if (DATA_REG_P (operands[0]))
4104 operands[1] = GEN_INT (31);
4105 return "bchg %1,%0";
4107 if (FP_REG_P (operands[1]))
4108 return "f<FP:prec>neg%.d %1,%0";
4109 return "f<FP:prec>neg%.<FP:prec> %1,%0";
4112 ;; Sqrt instruction for the 68881
4114 (define_expand "sqrt<mode>2"
4115 [(set (match_operand:FP 0 "nonimmediate_operand" "")
4116 (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
4120 (define_insn "sqrt<mode>2_68881"
4121 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4122 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
4125 if (FP_REG_P (operands[1]))
4126 return "f<FP:round>sqrt%.x %1,%0";
4127 return "f<FP:round>sqrt%.<FP:prec> %1,%0";
4129 [(set_attr "type" "fsqrt")])
4131 (define_insn "sqrt<mode>2_cf"
4132 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4133 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
4134 "TARGET_COLDFIRE_FPU"
4136 if (FP_REG_P (operands[1]))
4137 return "f<FP:prec>sqrt%.d %1,%0";
4138 return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
4140 [(set_attr "type" "fsqrt")])
4141 ;; Absolute value instructions
4142 ;; If using software floating point, just zero the sign bit.
4144 (define_expand "abssf2"
4145 [(set (match_operand:SF 0 "nonimmediate_operand" "")
4146 (abs:SF (match_operand:SF 1 "general_operand" "")))]
4149 if (!TARGET_HARD_FLOAT)
4154 target = operand_subword_force (operands[0], 0, SFmode);
4155 result = expand_binop (SImode, and_optab,
4156 operand_subword_force (operands[1], 0, SFmode),
4157 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4158 gcc_assert (result);
4160 if (result != target)
4161 emit_move_insn (result, target);
4163 /* Make a place for REG_EQUAL. */
4164 emit_move_insn (operands[0], operands[0]);
4169 (define_expand "absdf2"
4170 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4171 (abs:DF (match_operand:DF 1 "general_operand" "")))]
4174 if (!TARGET_HARD_FLOAT)
4181 target = operand_subword (operands[0], 0, 1, DFmode);
4182 result = expand_binop (SImode, and_optab,
4183 operand_subword_force (operands[1], 0, DFmode),
4184 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4185 gcc_assert (result);
4187 if (result != target)
4188 emit_move_insn (result, target);
4190 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4191 operand_subword_force (operands[1], 1, DFmode));
4193 insns = get_insns ();
4201 (define_expand "absxf2"
4202 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4203 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4213 target = operand_subword (operands[0], 0, 1, XFmode);
4214 result = expand_binop (SImode, and_optab,
4215 operand_subword_force (operands[1], 0, XFmode),
4216 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4217 gcc_assert (result);
4219 if (result != target)
4220 emit_move_insn (result, target);
4222 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4223 operand_subword_force (operands[1], 1, XFmode));
4224 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4225 operand_subword_force (operands[1], 2, XFmode));
4227 insns = get_insns ();
4235 (define_insn "abs<mode>2_68881"
4236 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4237 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4240 if (DATA_REG_P (operands[0]))
4242 operands[1] = GEN_INT (31);
4243 return "bclr %1,%0";
4245 if (FP_REG_P (operands[1]))
4246 return "f<FP:round>abs%.x %1,%0";
4247 return "f<FP:round>abs%.<FP:prec> %f1,%0";
4250 (define_insn "abs<mode>2_cf"
4251 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4252 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4253 "TARGET_COLDFIRE_FPU"
4255 if (DATA_REG_P (operands[0]))
4257 operands[1] = GEN_INT (31);
4258 return "bclr %1,%0";
4260 if (FP_REG_P (operands[1]))
4261 return "f<FP:prec>abs%.d %1,%0";
4262 return "f<FP:prec>abs%.<FP:prec> %1,%0";
4264 [(set_attr "type" "bitrw,fneg")])
4266 ;; bit indexing instructions
4268 (define_expand "clzsi2"
4269 [(set (match_operand:SI 0 "register_operand" "")
4270 (clz:SI (match_operand:SI 1 "general_operand" "")))]
4271 "ISA_HAS_FF1 || (TARGET_68020 && TARGET_BITFIELD)"
4274 operands[1] = force_reg (SImode, operands[1]);
4277 (define_insn "*clzsi2_68k"
4278 [(set (match_operand:SI 0 "register_operand" "=d")
4279 (clz:SI (match_operand:SI 1 "general_operand" "do")))]
4280 "TARGET_68020 && TARGET_BITFIELD"
4283 return "bfffo %1{#0:#0},%0";
4286 ;; ColdFire ff1 instruction implements clz.
4287 (define_insn "*clzsi2_cf"
4288 [(set (match_operand:SI 0 "register_operand" "=d")
4289 (clz:SI (match_operand:SI 1 "register_operand" "0")))]
4295 [(set_attr "type" "ext")])
4297 ;; one complement instructions
4299 (define_expand "one_cmplsi2"
4300 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4301 (not:SI (match_operand:SI 1 "general_operand" "")))]
4304 if (TARGET_COLDFIRE)
4305 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
4307 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
4311 (define_insn "one_cmplsi2_internal"
4312 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4313 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4317 (define_insn "one_cmplsi2_5200"
4318 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4319 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4322 [(set_attr "type" "neg_l")])
4324 (define_insn "one_cmplhi2"
4325 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4326 (not:HI (match_operand:HI 1 "general_operand" "0")))]
4331 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4332 (not:HI (match_dup 0)))]
4336 (define_insn "one_cmplqi2"
4337 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4338 (not:QI (match_operand:QI 1 "general_operand" "0")))]
4343 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4344 (not:QI (match_dup 0)))]
4348 ;; arithmetic shift instructions
4349 ;; We don't need the shift memory by 1 bit instruction
4350 (define_insn_and_split "ashldi_extsi"
4351 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4353 (match_operator:DI 2 "extend_operator"
4354 [(match_operand:SI 1 "general_operand" "rm")])
4358 "&& reload_completed"
4359 [(set (match_dup 3) (match_dup 1))
4360 (set (match_dup 2) (const_int 0))]
4361 "split_di(operands, 1, operands + 2, operands + 3);")
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:SI 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);
4687 return "asr%.l #1,%0\;roxr%.l #1,%1";
4691 [(set (match_operand:DI 0 "register_operand" "")
4692 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4694 "reload_completed && !TARGET_COLDFIRE"
4696 (ashiftrt:DI (match_dup 1) (const_int 1)))
4698 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4702 [(set (match_operand:DI 0 "register_operand" "")
4703 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4705 "reload_completed && !TARGET_COLDFIRE"
4707 (ashiftrt:DI (match_dup 1) (const_int 2)))
4709 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4713 [(set (match_operand:DI 0 "register_operand" "")
4714 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4716 "reload_completed && !TARGET_COLDFIRE"
4717 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4718 (subreg:QI (match_dup 0) 3))
4720 (ashiftrt:SI (match_dup 2) (const_int 8)))
4722 (rotatert:SI (match_dup 3) (const_int 8)))]
4724 operands[2] = gen_highpart (SImode, operands[0]);
4725 operands[3] = gen_lowpart (SImode, operands[0]);
4729 [(set (match_operand:DI 0 "register_operand" "")
4730 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4732 "reload_completed && !TARGET_COLDFIRE"
4733 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4734 (subreg:HI (match_dup 0) 2))
4736 (rotate:SI (match_dup 2) (const_int 16)))
4738 (rotate:SI (match_dup 3) (const_int 16)))
4740 (sign_extend:SI (subreg:HI (match_dup 2) 2)))]
4742 operands[2] = gen_highpart (SImode, operands[0]);
4743 operands[3] = gen_lowpart (SImode, operands[0]);
4746 (define_insn "*ashrdi_const32"
4747 [(set (match_operand:DI 0 "register_operand" "=d")
4748 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro")
4754 return "move%.l %1,%R0\;smi %0\;extb%.l %0";
4756 return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
4759 (define_insn "*ashrdi_const32_mem"
4760 [(set (match_operand:DI 0 "memory_operand" "=o,<")
4761 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro,ro")
4763 (clobber (match_scratch:SI 2 "=d,d"))]
4767 operands[3] = adjust_address (operands[0], SImode,
4768 which_alternative == 0 ? 4 : 0);
4769 operands[0] = adjust_address (operands[0], SImode, 0);
4770 if (TARGET_68020 || TARGET_COLDFIRE)
4771 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4773 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4777 [(set (match_operand:DI 0 "register_operand" "")
4778 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4780 "reload_completed && !TARGET_COLDFIRE"
4782 (ashiftrt:SI (match_dup 3) (const_int 31)))
4785 "split_di(operands, 1, operands + 2, operands + 3);")
4787 ;; The predicate below must be general_operand, because ashrdi3 allows that
4788 (define_insn "ashrdi_const"
4789 [(set (match_operand:DI 0 "register_operand" "=d")
4790 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4791 (match_operand 2 "const_int_operand" "n")))]
4793 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4794 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4795 || INTVAL (operands[2]) == 31
4796 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4798 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4800 if (INTVAL (operands[2]) == 48)
4801 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4802 if (INTVAL (operands[2]) == 31)
4803 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4804 if (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)
4806 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4807 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4808 "moveq %2,%1\;asr%.l %1,%0", operands);
4809 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4810 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4811 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4816 (define_expand "ashrdi3"
4817 [(set (match_operand:DI 0 "register_operand" "")
4818 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4819 (match_operand:SI 2 "const_int_operand" "")))]
4822 /* ??? This is a named pattern like this is not allowed to FAIL based
4824 if (GET_CODE (operands[2]) != CONST_INT
4825 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4826 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4827 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4831 ;; On all 68k models, this makes faster code in a special case.
4833 (define_insn "ashrsi_31"
4834 [(set (match_operand:SI 0 "register_operand" "=d")
4835 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4839 return "add%.l %0,%0\;subx%.l %0,%0";
4842 (define_insn "ashrsi3"
4843 [(set (match_operand:SI 0 "register_operand" "=d")
4844 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4845 (match_operand:SI 2 "general_operand" "dI")))]
4848 [(set_attr "type" "shift")
4849 (set_attr "opy" "2")])
4851 (define_insn "ashrhi3"
4852 [(set (match_operand:HI 0 "register_operand" "=d")
4853 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4854 (match_operand:HI 2 "general_operand" "dI")))]
4859 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4860 (ashiftrt:HI (match_dup 0)
4861 (match_operand:HI 1 "general_operand" "dI")))]
4865 (define_insn "ashrqi3"
4866 [(set (match_operand:QI 0 "register_operand" "=d")
4867 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4868 (match_operand:QI 2 "general_operand" "dI")))]
4873 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4874 (ashiftrt:QI (match_dup 0)
4875 (match_operand:QI 1 "general_operand" "dI")))]
4879 ;; logical shift instructions
4881 ;; commented out because of reload problems in 950612-1.c
4884 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4885 ;; (const_int 32)) 4))
4886 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4887 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4888 ;; (const_int 32)) 4))]
4891 ;; return "move%.l %0,%1";
4896 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4897 ;; (const_int 32)) 0))
4898 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4899 ;; (lshiftrt:DI (match_dup 0)
4900 ;; (const_int 32)))]
4903 ;; if (GET_CODE (operands[1]) == REG)
4904 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4906 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4907 ;; return "move%.l %0,%2\;clr%.l %1";
4910 (define_insn "subreg1lshrdi_const32"
4911 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4912 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4913 (const_int 32)) 4))]
4916 [(set_attr "type" "move_l")])
4918 (define_insn "*lshrdi3_const1"
4919 [(set (match_operand:DI 0 "register_operand" "=d")
4920 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
4925 return "lsr%.l #1,%0\;roxr%.l #1,%R0";
4929 [(set (match_operand:DI 0 "register_operand" "")
4930 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4932 "reload_completed && !TARGET_COLDFIRE"
4934 (lshiftrt:DI (match_dup 1) (const_int 1)))
4936 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4940 [(set (match_operand:DI 0 "register_operand" "")
4941 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4943 "reload_completed && !TARGET_COLDFIRE"
4945 (lshiftrt:DI (match_dup 1) (const_int 2)))
4947 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4951 [(set (match_operand:DI 0 "register_operand" "")
4952 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4954 "reload_completed && !TARGET_COLDFIRE"
4955 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4956 (subreg:QI (match_dup 0) 3))
4958 (lshiftrt:SI (match_dup 2) (const_int 8)))
4960 (rotatert:SI (match_dup 3) (const_int 8)))]
4962 operands[2] = gen_highpart (SImode, operands[0]);
4963 operands[3] = gen_lowpart (SImode, operands[0]);
4967 [(set (match_operand:DI 0 "register_operand" "")
4968 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4970 "reload_completed && !TARGET_COLDFIRE"
4971 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4972 (subreg:HI (match_dup 0) 2))
4973 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4976 (rotate:SI (match_dup 3) (const_int 16)))
4978 (rotate:SI (match_dup 2) (const_int 16)))]
4980 operands[2] = gen_highpart (SImode, operands[0]);
4981 operands[3] = gen_lowpart (SImode, operands[0]);
4985 [(set (match_operand:DI 0 "pre_dec_operand" "")
4986 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
4989 [(set (match_dup 0) (match_dup 1))
4990 (set (match_dup 0) (const_int 0))]
4992 operands[0] = adjust_address(operands[0], SImode, 0);
4993 operands[1] = gen_highpart(SImode, operands[1]);
4997 [(set (match_operand:DI 0 "post_inc_operand" "")
4998 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5001 [(set (match_dup 0) (const_int 0))
5002 (set (match_dup 0) (match_dup 1))]
5004 operands[0] = adjust_address(operands[0], SImode, 0);
5005 operands[1] = gen_highpart(SImode, operands[1]);
5009 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5010 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5013 [(set (match_dup 2) (match_dup 5))
5014 (set (match_dup 4) (const_int 0))]
5015 "split_di(operands, 2, operands + 2, operands + 4);")
5017 (define_insn "*lshrdi_const32"
5018 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
5019 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
5025 [(set (match_operand:DI 0 "register_operand" "")
5026 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5027 (match_operand 2 "const_int_operand" "")))]
5028 "reload_completed && !TARGET_COLDFIRE
5029 && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
5030 [(set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 2)))
5031 (set (match_dup 4) (match_dup 3))
5032 (set (match_dup 3) (const_int 0))]
5034 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5035 operands[3] = gen_highpart (SImode, operands[0]);
5036 operands[4] = gen_lowpart (SImode, operands[0]);
5040 [(set (match_operand:DI 0 "register_operand" "")
5041 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5044 [(set (match_dup 3) (match_dup 2))
5045 (set (strict_low_part (subreg:HI (match_dup 0) 6))
5047 (set (match_dup 2) (const_int 0))
5049 (rotate:SI (match_dup 3) (const_int 16)))]
5051 operands[2] = gen_highpart (SImode, operands[0]);
5052 operands[3] = gen_lowpart (SImode, operands[0]);
5056 [(set (match_operand:DI 0 "register_operand" "")
5057 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5058 (match_operand 2 "const_int_operand" "")))]
5059 "reload_completed && !TARGET_COLDFIRE
5060 && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 62"
5061 [(set (match_dup 4) (match_dup 2))
5062 (set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 4)))
5063 (set (match_dup 4) (match_dup 3))
5064 (set (match_dup 3) (const_int 0))]
5066 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5067 operands[3] = gen_highpart (SImode, operands[0]);
5068 operands[4] = gen_lowpart (SImode, operands[0]);
5071 (define_insn "*lshrdi_const63"
5072 [(set (match_operand:DI 0 "register_operand" "=d")
5073 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5076 "add%.l %0,%0\;clr%.l %0\;clr%.l %R1\;addx%.l %R1,%R1")
5078 (define_insn "*lshrdi3_const"
5079 [(set (match_operand:DI 0 "register_operand" "=d")
5080 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5081 (match_operand 2 "const_int_operand" "n")))]
5083 && ((INTVAL (operands[2]) >= 2 && INTVAL (operands[2]) <= 3)
5084 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
5085 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
5088 (define_expand "lshrdi3"
5089 [(set (match_operand:DI 0 "register_operand" "")
5090 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5091 (match_operand:SI 2 "const_int_operand" "")))]
5094 /* ??? This is a named pattern like this is not allowed to FAIL based
5096 if (GET_CODE (operands[2]) != CONST_INT
5097 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
5098 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
5099 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
5103 ;; On all 68k models, this makes faster code in a special case.
5105 (define_insn "lshrsi_31"
5106 [(set (match_operand:SI 0 "register_operand" "=d")
5107 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5111 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
5114 ;; On most 68k models, this makes faster code in a special case.
5116 (define_insn "lshrsi_16"
5117 [(set (match_operand:SI 0 "register_operand" "=d")
5118 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5123 return "clr%.w %0\;swap %0";
5126 ;; On the 68000, this makes faster code in a special case.
5128 (define_insn "lshrsi_17_24"
5129 [(set (match_operand:SI 0 "register_operand" "=d")
5130 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5131 (match_operand:SI 2 "const_int_operand" "n")))]
5133 && INTVAL (operands[2]) > 16
5134 && INTVAL (operands[2]) <= 24"
5136 /* I think lsr%.w sets the CC properly. */
5137 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
5138 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
5141 (define_insn "lshrsi3"
5142 [(set (match_operand:SI 0 "register_operand" "=d")
5143 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5144 (match_operand:SI 2 "general_operand" "dI")))]
5147 [(set_attr "type" "shift")
5148 (set_attr "opy" "2")])
5150 (define_insn "lshrhi3"
5151 [(set (match_operand:HI 0 "register_operand" "=d")
5152 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
5153 (match_operand:HI 2 "general_operand" "dI")))]
5158 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5159 (lshiftrt:HI (match_dup 0)
5160 (match_operand:HI 1 "general_operand" "dI")))]
5164 (define_insn "lshrqi3"
5165 [(set (match_operand:QI 0 "register_operand" "=d")
5166 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
5167 (match_operand:QI 2 "general_operand" "dI")))]
5172 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5173 (lshiftrt:QI (match_dup 0)
5174 (match_operand:QI 1 "general_operand" "dI")))]
5178 ;; rotate instructions
5180 (define_insn "rotlsi_16"
5181 [(set (match_operand:SI 0 "register_operand" "=d")
5182 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5186 [(set_attr "type" "shift")])
5188 (define_insn "rotlsi3"
5189 [(set (match_operand:SI 0 "register_operand" "=d")
5190 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5191 (match_operand:SI 2 "general_operand" "dINO")))]
5194 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
5196 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
5198 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
5199 return "ror%.l %2,%0";
5202 return "rol%.l %2,%0";
5205 (define_insn "rotlhi3"
5206 [(set (match_operand:HI 0 "register_operand" "=d")
5207 (rotate:HI (match_operand:HI 1 "register_operand" "0")
5208 (match_operand:HI 2 "general_operand" "dIP")))]
5211 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5213 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5214 return "ror%.w %2,%0";
5217 return "rol%.w %2,%0";
5220 (define_insn "*rotlhi3_lowpart"
5221 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5222 (rotate:HI (match_dup 0)
5223 (match_operand:HI 1 "general_operand" "dIP")))]
5226 if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) >= 8)
5228 operands[1] = GEN_INT (16 - INTVAL (operands[1]));
5229 return "ror%.w %1,%0";
5232 return "rol%.w %1,%0";
5235 (define_insn "rotlqi3"
5236 [(set (match_operand:QI 0 "register_operand" "=d")
5237 (rotate:QI (match_operand:QI 1 "register_operand" "0")
5238 (match_operand:QI 2 "general_operand" "dI")))]
5241 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5243 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5244 return "ror%.b %2,%0";
5247 return "rol%.b %2,%0";
5250 (define_insn "*rotlqi3_lowpart"
5251 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5252 (rotate:QI (match_dup 0)
5253 (match_operand:QI 1 "general_operand" "dI")))]
5256 if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) >= 4)
5258 operands[1] = GEN_INT (8 - INTVAL (operands[1]));
5259 return "ror%.b %1,%0";
5262 return "rol%.b %1,%0";
5265 (define_insn "rotrsi3"
5266 [(set (match_operand:SI 0 "register_operand" "=d")
5267 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
5268 (match_operand:SI 2 "general_operand" "dI")))]
5272 (define_insn "rotrhi3"
5273 [(set (match_operand:HI 0 "register_operand" "=d")
5274 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
5275 (match_operand:HI 2 "general_operand" "dI")))]
5279 (define_insn "rotrhi_lowpart"
5280 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5281 (rotatert:HI (match_dup 0)
5282 (match_operand:HI 1 "general_operand" "dI")))]
5286 (define_insn "rotrqi3"
5287 [(set (match_operand:QI 0 "register_operand" "=d")
5288 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
5289 (match_operand:QI 2 "general_operand" "dI")))]
5294 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5295 (rotatert:QI (match_dup 0)
5296 (match_operand:QI 1 "general_operand" "dI")))]
5300 (define_expand "bswapsi2"
5301 [(set (match_operand:SI 0 "register_operand")
5302 (bswap:SI (match_operand:SI 1 "register_operand")))]
5305 rtx x = operands[0];
5306 emit_move_insn (x, operands[1]);
5307 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5308 emit_insn (gen_rotlsi3 (x, x, GEN_INT (16)));
5309 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5314 ;; Bit set/clear in memory byte.
5316 ;; set bit, bit number is int
5317 (define_insn "bsetmemqi"
5318 [(set (match_operand:QI 0 "memory_operand" "+m")
5319 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5320 (match_operand:SI 1 "general_operand" "d")) 3)
5325 return "bset %1,%0";
5327 [(set_attr "type" "bitrw")])
5329 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
5330 (define_insn "*bsetmemqi_ext"
5331 [(set (match_operand:QI 0 "memory_operand" "+m")
5332 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5333 (match_operator:SI 2 "extend_operator"
5334 [(match_operand 1 "general_operand" "d")])) 3)
5339 return "bset %1,%0";
5341 [(set_attr "type" "bitrw")])
5343 (define_insn "*bsetdreg"
5344 [(set (match_operand:SI 0 "register_operand" "=d")
5345 (ior:SI (ashift:SI (const_int 1)
5346 (and:SI (match_operand:SI 1 "register_operand" "d")
5348 (match_operand:SI 2 "register_operand" "0")))]
5352 return "bset %1,%0";
5354 [(set_attr "type" "bitrw")])
5356 (define_insn "*bchgdreg"
5357 [(set (match_operand:SI 0 "register_operand" "=d")
5358 (xor:SI (ashift:SI (const_int 1)
5359 (and:SI (match_operand:SI 1 "register_operand" "d")
5361 (match_operand:SI 2 "register_operand" "0")))]
5365 return "bchg %1,%0";
5367 [(set_attr "type" "bitrw")])
5369 (define_insn "*bclrdreg"
5370 [(set (match_operand:SI 0 "register_operand" "=d")
5371 (and:SI (rotate:SI (const_int -2)
5372 (and:SI (match_operand:SI 1 "register_operand" "d")
5374 (match_operand:SI 2 "register_operand" "0")))]
5378 return "bclr %1,%0";
5380 [(set_attr "type" "bitrw")])
5382 ;; clear bit, bit number is int
5383 (define_insn "bclrmemqi"
5384 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5386 (minus:SI (const_int 7)
5387 (match_operand:SI 1 "general_operand" "d")))
5392 return "bclr %1,%0";
5394 [(set_attr "type" "bitrw")])
5396 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
5397 (define_insn "*bclrmemqi_ext"
5398 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5400 (minus:SI (const_int 7)
5401 (match_operator:SI 2 "extend_operator"
5402 [(match_operand 1 "general_operand" "d")])))
5407 return "bclr %1,%0";
5409 [(set_attr "type" "bitrw")])
5411 ;; Special cases of bit-field insns which we should
5412 ;; recognize in preference to the general case.
5413 ;; These handle aligned 8-bit and 16-bit fields,
5414 ;; which can usually be done with move instructions.
5417 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5418 ; alignment of structure members is specified.
5420 ; The move is allowed to be odd byte aligned, because that's still faster
5421 ; than an odd byte aligned bit-field instruction.
5423 (define_insn "*insv_32_mem"
5424 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5426 (match_operand:SI 1 "const_int_operand" "n"))
5427 (match_operand:SI 2 "general_src_operand" "rmSi"))]
5428 "TARGET_68020 && TARGET_BITFIELD
5429 && (INTVAL (operands[1]) % 8) == 0
5430 && ! mode_dependent_address_p (XEXP (operands[0], 0),
5431 MEM_ADDR_SPACE (operands[0]))"
5434 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
5436 return "move%.l %2,%0";
5439 (define_insn "*insv_8_16_reg"
5440 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5441 (match_operand:SI 1 "const_int_operand" "n")
5442 (match_operand:SI 2 "const_int_operand" "n"))
5443 (match_operand:SI 3 "register_operand" "d"))]
5444 "TARGET_68020 && TARGET_BITFIELD
5445 && IN_RANGE (INTVAL (operands[2]), 0, 31)
5446 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
5447 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0"
5449 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
5450 return "bfins %3,%0{%b2:%b1}";
5452 if (INTVAL (operands[1]) == 8)
5453 return "move%.b %3,%0";
5454 return "move%.w %3,%0";
5459 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5460 ; alignment of structure members is specified.
5462 ; The move is allowed to be odd byte aligned, because that's still faster
5463 ; than an odd byte aligned bit-field instruction.
5465 (define_insn "*extzv_32_mem"
5466 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5467 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5469 (match_operand:SI 2 "const_int_operand" "n")))]
5470 "TARGET_68020 && TARGET_BITFIELD
5471 && (INTVAL (operands[2]) % 8) == 0
5472 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5473 MEM_ADDR_SPACE (operands[1]))"
5476 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5478 return "move%.l %1,%0";
5481 (define_insn "*extzv_8_16_reg"
5482 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
5483 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5484 (match_operand:SI 2 "const_int_operand" "n")
5485 (match_operand:SI 3 "const_int_operand" "n")))]
5486 "TARGET_68020 && TARGET_BITFIELD
5487 && IN_RANGE (INTVAL (operands[3]), 0, 31)
5488 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5489 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5491 cc_status.flags |= CC_NOT_NEGATIVE;
5492 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5493 return "bfextu %1{%b3:%b2},%0";
5495 output_asm_insn ("clr%.l %0", operands);
5496 if (INTVAL (operands[2]) == 8)
5497 return "move%.b %1,%0";
5498 return "move%.w %1,%0";
5502 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5503 ; alignment of structure members is specified.
5505 ; The move is allowed to be odd byte aligned, because that's still faster
5506 ; than an odd byte aligned bit-field instruction.
5508 (define_insn "*extv_32_mem"
5509 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5510 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5512 (match_operand:SI 2 "const_int_operand" "n")))]
5513 "TARGET_68020 && TARGET_BITFIELD
5514 && (INTVAL (operands[2]) % 8) == 0
5515 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5516 MEM_ADDR_SPACE (operands[1]))"
5519 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5521 return "move%.l %1,%0";
5524 (define_insn "*extv_8_16_reg"
5525 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5526 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5527 (match_operand:SI 2 "const_int_operand" "n")
5528 (match_operand:SI 3 "const_int_operand" "n")))]
5529 "TARGET_68020 && TARGET_BITFIELD
5530 && IN_RANGE (INTVAL (operands[3]), 0, 31)
5531 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5532 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5534 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5535 return "bfexts %1{%b3:%b2},%0";
5537 if (INTVAL (operands[2]) == 8)
5538 return "move%.b %1,%0\;extb%.l %0";
5539 return "move%.w %1,%0\;ext%.l %0";
5542 ;; Bit-field instructions, general cases.
5543 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
5544 ;; so that its address is reloaded.
5546 (define_expand "extv"
5547 [(set (match_operand:SI 0 "register_operand" "")
5548 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
5549 (match_operand:SI 2 "const_int_operand" "")
5550 (match_operand:SI 3 "const_int_operand" "")))]
5551 "TARGET_68020 && TARGET_BITFIELD"
5554 (define_insn "*extv_bfexts_mem"
5555 [(set (match_operand:SI 0 "register_operand" "=d")
5556 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
5557 (match_operand:SI 2 "nonmemory_operand" "dn")
5558 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5559 "TARGET_68020 && TARGET_BITFIELD"
5560 "bfexts %1{%b3:%b2},%0")
5562 (define_expand "extzv"
5563 [(set (match_operand:SI 0 "register_operand" "")
5564 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
5565 (match_operand:SI 2 "const_int_operand" "")
5566 (match_operand:SI 3 "const_int_operand" "")))]
5567 "TARGET_68020 && TARGET_BITFIELD"
5570 (define_insn "*extzv_bfextu_mem"
5571 [(set (match_operand:SI 0 "register_operand" "=d")
5572 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o")
5573 (match_operand:SI 2 "nonmemory_operand" "dn")
5574 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5575 "TARGET_68020 && TARGET_BITFIELD"
5577 if (GET_CODE (operands[2]) == CONST_INT)
5579 if (INTVAL (operands[2]) != 32)
5580 cc_status.flags |= CC_NOT_NEGATIVE;
5586 return "bfextu %1{%b3:%b2},%0";
5589 (define_insn "*insv_bfchg_mem"
5590 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5591 (match_operand:SI 1 "nonmemory_operand" "dn")
5592 (match_operand:SI 2 "nonmemory_operand" "dn"))
5593 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
5594 (match_operand 3 "const_int_operand" "n")))]
5595 "TARGET_68020 && TARGET_BITFIELD
5596 && (INTVAL (operands[3]) == -1
5597 || (GET_CODE (operands[1]) == CONST_INT
5598 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
5601 return "bfchg %0{%b2:%b1}";
5604 (define_insn "*insv_bfclr_mem"
5605 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5606 (match_operand:SI 1 "nonmemory_operand" "dn")
5607 (match_operand:SI 2 "nonmemory_operand" "dn"))
5609 "TARGET_68020 && TARGET_BITFIELD"
5612 return "bfclr %0{%b2:%b1}";
5615 (define_insn "*insv_bfset_mem"
5616 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5617 (match_operand:SI 1 "general_operand" "dn")
5618 (match_operand:SI 2 "general_operand" "dn"))
5620 "TARGET_68020 && TARGET_BITFIELD"
5623 return "bfset %0{%b2:%b1}";
5626 (define_expand "insv"
5627 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5628 (match_operand:SI 1 "const_int_operand" "")
5629 (match_operand:SI 2 "const_int_operand" ""))
5630 (match_operand:SI 3 "reg_or_pow2_m1_operand" ""))]
5631 "TARGET_68020 && TARGET_BITFIELD"
5634 /* Special case initializing a field to all ones. */
5635 if (GET_CODE (operands[3]) == CONST_INT)
5637 if (exact_log2 (INTVAL (operands[3]) + 1) != INTVAL (operands[1]))
5638 operands[3] = force_reg (SImode, operands[3]);
5640 operands[3] = constm1_rtx;
5645 (define_insn "*insv_bfins_mem"
5646 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5647 (match_operand:SI 1 "nonmemory_operand" "dn")
5648 (match_operand:SI 2 "nonmemory_operand" "dn"))
5649 (match_operand:SI 3 "register_operand" "d"))]
5650 "TARGET_68020 && TARGET_BITFIELD"
5651 "bfins %3,%0{%b2:%b1}")
5653 ;; Now recognize bit-field insns that operate on registers
5654 ;; (or at least were intended to do so).
5656 (define_insn "*extv_bfexts_reg"
5657 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5658 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5659 (match_operand:SI 2 "const_int_operand" "n")
5660 (match_operand:SI 3 "const_int_operand" "n")))]
5661 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[3]), 0, 31)"
5662 "bfexts %1{%b3:%b2},%0")
5664 (define_insn "*extv_bfextu_reg"
5665 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5666 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5667 (match_operand:SI 2 "const_int_operand" "n")
5668 (match_operand:SI 3 "const_int_operand" "n")))]
5669 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[3]), 0, 31)"
5671 if (GET_CODE (operands[2]) == CONST_INT)
5673 if (INTVAL (operands[2]) != 32)
5674 cc_status.flags |= CC_NOT_NEGATIVE;
5680 return "bfextu %1{%b3:%b2},%0";
5683 (define_insn "*insv_bfclr_reg"
5684 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5685 (match_operand:SI 1 "const_int_operand" "n")
5686 (match_operand:SI 2 "const_int_operand" "n"))
5688 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[2]), 0, 31)"
5691 return "bfclr %0{%b2:%b1}";
5694 (define_insn "*insv_bfset_reg"
5695 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5696 (match_operand:SI 1 "const_int_operand" "n")
5697 (match_operand:SI 2 "const_int_operand" "n"))
5699 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[2]), 0, 31)"
5702 return "bfset %0{%b2:%b1}";
5705 (define_insn "*insv_bfins_reg"
5706 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5707 (match_operand:SI 1 "const_int_operand" "n")
5708 (match_operand:SI 2 "const_int_operand" "n"))
5709 (match_operand:SI 3 "register_operand" "d"))]
5710 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[2]), 0, 31)"
5713 /* These special cases are now recognized by a specific pattern. */
5714 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5715 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5716 return "move%.w %3,%0";
5717 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5718 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5719 return "move%.b %3,%0";
5721 return "bfins %3,%0{%b2:%b1}";
5724 ;; Special patterns for optimizing bit-field instructions.
5726 (define_insn "*tst_bftst_mem"
5728 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5729 (match_operand:SI 1 "const_int_operand" "n")
5730 (match_operand:SI 2 "general_operand" "dn"))
5732 "TARGET_68020 && TARGET_BITFIELD"
5734 if (operands[1] == const1_rtx
5735 && GET_CODE (operands[2]) == CONST_INT)
5737 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5738 return output_btst (operands,
5739 GEN_INT (width - INTVAL (operands[2])),
5740 operands[0], insn, 1000);
5741 /* Pass 1000 as SIGNPOS argument so that btst will
5742 not think we are testing the sign bit for an `and'
5743 and assume that nonzero implies a negative result. */
5745 if (INTVAL (operands[1]) != 32)
5746 cc_status.flags = CC_NOT_NEGATIVE;
5747 return "bftst %0{%b2:%b1}";
5751 ;;; now handle the register cases
5752 (define_insn "*tst_bftst_reg"
5754 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5755 (match_operand:SI 1 "const_int_operand" "n")
5756 (match_operand:SI 2 "general_operand" "dn"))
5758 "TARGET_68020 && TARGET_BITFIELD
5759 && !(CONST_INT_P (operands[2]) && !IN_RANGE (INTVAL (operands[2]), 0, 31))"
5761 if (operands[1] == const1_rtx
5762 && GET_CODE (operands[2]) == CONST_INT)
5764 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5765 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5766 operands[0], insn, 1000);
5767 /* Pass 1000 as SIGNPOS argument so that btst will
5768 not think we are testing the sign bit for an `and'
5769 and assume that nonzero implies a negative result. */
5771 if (INTVAL (operands[1]) != 32)
5772 cc_status.flags = CC_NOT_NEGATIVE;
5773 return "bftst %0{%b2:%b1}";
5776 (define_insn "scc0_di"
5777 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5778 (match_operator 1 "ordered_comparison_operator"
5779 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5782 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5785 (define_insn "scc0_di_5200"
5786 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5787 (match_operator 1 "ordered_comparison_operator"
5788 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5791 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5794 (define_insn "scc_di"
5795 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5796 (match_operator 1 "ordered_comparison_operator"
5797 [(match_operand:DI 2 "general_operand" "ro,r")
5798 (match_operand:DI 3 "general_operand" "r,ro")]))]
5801 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5804 (define_insn "scc_di_5200"
5805 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5806 (match_operator 1 "ordered_comparison_operator"
5807 [(match_operand:DI 2 "general_operand" "ro,r")
5808 (match_operand:DI 3 "general_operand" "r,ro")]))]
5811 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5814 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5815 ;; memory, but we cannot allow it to be in memory in case the address
5816 ;; needs to be reloaded.
5819 [(set (match_operand:QI 0 "register_operand" "=d")
5820 (eq:QI (cc0) (const_int 0)))]
5823 cc_status = cc_prev_status;
5824 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5828 [(set (match_operand:QI 0 "register_operand" "=d")
5829 (ne:QI (cc0) (const_int 0)))]
5832 cc_status = cc_prev_status;
5833 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5837 [(set (match_operand:QI 0 "register_operand" "=d")
5838 (gt:QI (cc0) (const_int 0)))]
5841 cc_status = cc_prev_status;
5842 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5846 [(set (match_operand:QI 0 "register_operand" "=d")
5847 (gtu:QI (cc0) (const_int 0)))]
5850 cc_status = cc_prev_status;
5855 [(set (match_operand:QI 0 "register_operand" "=d")
5856 (lt:QI (cc0) (const_int 0)))]
5859 cc_status = cc_prev_status;
5860 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5864 [(set (match_operand:QI 0 "register_operand" "=d")
5865 (ltu:QI (cc0) (const_int 0)))]
5868 cc_status = cc_prev_status;
5873 [(set (match_operand:QI 0 "register_operand" "=d")
5874 (ge:QI (cc0) (const_int 0)))]
5877 cc_status = cc_prev_status;
5878 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5882 [(set (match_operand:QI 0 "register_operand" "=d")
5883 (geu:QI (cc0) (const_int 0)))]
5886 cc_status = cc_prev_status;
5889 [(set_attr "type" "scc")])
5892 [(set (match_operand:QI 0 "register_operand" "=d")
5893 (le:QI (cc0) (const_int 0)))]
5896 cc_status = cc_prev_status;
5897 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5901 [(set (match_operand:QI 0 "register_operand" "=d")
5902 (leu:QI (cc0) (const_int 0)))]
5905 cc_status = cc_prev_status;
5908 [(set_attr "type" "scc")])
5910 (define_insn "*sordered_1"
5911 [(set (match_operand:QI 0 "register_operand" "=d")
5912 (ordered:QI (cc0) (const_int 0)))]
5913 "TARGET_68881 && !TUNE_68060"
5915 cc_status = cc_prev_status;
5919 (define_insn "*sunordered_1"
5920 [(set (match_operand:QI 0 "register_operand" "=d")
5921 (unordered:QI (cc0) (const_int 0)))]
5922 "TARGET_68881 && !TUNE_68060"
5924 cc_status = cc_prev_status;
5928 (define_insn "*suneq_1"
5929 [(set (match_operand:QI 0 "register_operand" "=d")
5930 (uneq:QI (cc0) (const_int 0)))]
5931 "TARGET_68881 && !TUNE_68060"
5933 cc_status = cc_prev_status;
5937 (define_insn "*sunge_1"
5938 [(set (match_operand:QI 0 "register_operand" "=d")
5939 (unge:QI (cc0) (const_int 0)))]
5940 "TARGET_68881 && !TUNE_68060"
5942 cc_status = cc_prev_status;
5946 (define_insn "*sungt_1"
5947 [(set (match_operand:QI 0 "register_operand" "=d")
5948 (ungt:QI (cc0) (const_int 0)))]
5949 "TARGET_68881 && !TUNE_68060"
5951 cc_status = cc_prev_status;
5955 (define_insn "*sunle_1"
5956 [(set (match_operand:QI 0 "register_operand" "=d")
5957 (unle:QI (cc0) (const_int 0)))]
5958 "TARGET_68881 && !TUNE_68060"
5960 cc_status = cc_prev_status;
5964 (define_insn "*sunlt_1"
5965 [(set (match_operand:QI 0 "register_operand" "=d")
5966 (unlt:QI (cc0) (const_int 0)))]
5967 "TARGET_68881 && !TUNE_68060"
5969 cc_status = cc_prev_status;
5973 (define_insn "*sltgt_1"
5974 [(set (match_operand:QI 0 "register_operand" "=d")
5975 (ltgt:QI (cc0) (const_int 0)))]
5976 "TARGET_68881 && !TUNE_68060"
5978 cc_status = cc_prev_status;
5982 (define_insn "*fsogt_1"
5983 [(set (match_operand:QI 0 "register_operand" "=d")
5984 (not:QI (unle:QI (cc0) (const_int 0))))]
5985 "TARGET_68881 && !TUNE_68060"
5987 cc_status = cc_prev_status;
5991 (define_insn "*fsoge_1"
5992 [(set (match_operand:QI 0 "register_operand" "=d")
5993 (not:QI (unlt:QI (cc0) (const_int 0))))]
5994 "TARGET_68881 && !TUNE_68060"
5996 cc_status = cc_prev_status;
6000 (define_insn "*fsolt_1"
6001 [(set (match_operand:QI 0 "register_operand" "=d")
6002 (not:QI (unge:QI (cc0) (const_int 0))))]
6003 "TARGET_68881 && !TUNE_68060"
6005 cc_status = cc_prev_status;
6009 (define_insn "*fsole_1"
6010 [(set (match_operand:QI 0 "register_operand" "=d")
6011 (not:QI (ungt:QI (cc0) (const_int 0))))]
6012 "TARGET_68881 && !TUNE_68060"
6014 cc_status = cc_prev_status;
6018 ;; Basic conditional jump instructions.
6020 (define_insn "beq0_di"
6022 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*a,o,<>")
6024 (label_ref (match_operand 1 "" ",,"))
6026 (clobber (match_scratch:SI 2 "=d,&d,d"))]
6030 if (which_alternative == 2)
6031 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
6032 if ((cc_prev_status.value1
6033 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6034 || (cc_prev_status.value2
6035 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6037 cc_status = cc_prev_status;
6040 if (GET_CODE (operands[0]) == REG)
6041 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6043 operands[3] = adjust_address (operands[0], SImode, 4);
6044 if (! ADDRESS_REG_P (operands[0]))
6046 if (reg_overlap_mentioned_p (operands[2], operands[0]))
6048 if (reg_overlap_mentioned_p (operands[2], operands[3]))
6049 return "or%.l %0,%2\;jeq %l1";
6051 return "or%.l %3,%2\;jeq %l1";
6053 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
6055 operands[4] = gen_label_rtx();
6056 if (TARGET_68020 || TARGET_COLDFIRE)
6057 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
6059 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
6060 (*targetm.asm_out.internal_label) (asm_out_file, "L",
6061 CODE_LABEL_NUMBER (operands[4]));
6065 (define_insn "bne0_di"
6067 (if_then_else (ne (match_operand:DI 0 "general_operand" "d,o,*a")
6069 (label_ref (match_operand 1 "" ",,"))
6071 (clobber (match_scratch:SI 2 "=d,&d,X"))]
6074 if ((cc_prev_status.value1
6075 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6076 || (cc_prev_status.value2
6077 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6079 cc_status = cc_prev_status;
6083 if (GET_CODE (operands[0]) == REG)
6084 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6086 operands[3] = adjust_address (operands[0], SImode, 4);
6087 if (!ADDRESS_REG_P (operands[0]))
6089 if (reg_overlap_mentioned_p (operands[2], operands[0]))
6091 if (reg_overlap_mentioned_p (operands[2], operands[3]))
6092 return "or%.l %0,%2\;jne %l1";
6094 return "or%.l %3,%2\;jne %l1";
6096 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
6098 if (TARGET_68020 || TARGET_COLDFIRE)
6099 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
6101 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
6104 (define_insn "bge0_di"
6106 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
6108 (label_ref (match_operand 1 "" ""))
6112 if ((cc_prev_status.value1
6113 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6114 || (cc_prev_status.value2
6115 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6117 cc_status = cc_prev_status;
6118 return cc_status.flags & CC_REVERSED ? "jle %l1" : "jpl %l1";
6121 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6122 output_asm_insn("tst%.l %0", operands);
6125 /* On an address reg, cmpw may replace cmpl. */
6126 output_asm_insn("cmp%.w #0,%0", operands);
6131 (define_insn "blt0_di"
6133 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
6135 (label_ref (match_operand 1 "" ""))
6139 if ((cc_prev_status.value1
6140 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6141 || (cc_prev_status.value2
6142 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6144 cc_status = cc_prev_status;
6145 return cc_status.flags & CC_REVERSED ? "jgt %l1" : "jmi %l1";
6148 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6149 output_asm_insn("tst%.l %0", operands);
6152 /* On an address reg, cmpw may replace cmpl. */
6153 output_asm_insn("cmp%.w #0,%0", operands);
6160 (if_then_else (eq (cc0)
6162 (label_ref (match_operand 0 "" ""))
6166 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6168 [(set_attr "type" "bcc")])
6172 (if_then_else (ne (cc0)
6174 (label_ref (match_operand 0 "" ""))
6178 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6180 [(set_attr "type" "bcc")])
6184 (if_then_else (gt (cc0)
6186 (label_ref (match_operand 0 "" ""))
6190 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6192 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6196 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
6198 [(set_attr "type" "bcc")])
6202 (if_then_else (gtu (cc0)
6204 (label_ref (match_operand 0 "" ""))
6208 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6210 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6216 [(set_attr "type" "bcc")])
6220 (if_then_else (lt (cc0)
6222 (label_ref (match_operand 0 "" ""))
6226 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6228 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6232 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
6234 [(set_attr "type" "bcc")])
6238 (if_then_else (ltu (cc0)
6240 (label_ref (match_operand 0 "" ""))
6244 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6246 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6252 [(set_attr "type" "bcc")])
6256 (if_then_else (ge (cc0)
6258 (label_ref (match_operand 0 "" ""))
6262 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6264 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6268 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
6273 (if_then_else (geu (cc0)
6275 (label_ref (match_operand 0 "" ""))
6279 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6281 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6287 [(set_attr "type" "bcc")])
6291 (if_then_else (le (cc0)
6293 (label_ref (match_operand 0 "" ""))
6297 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6299 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6303 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
6305 [(set_attr "type" "bcc")])
6309 (if_then_else (leu (cc0)
6311 (label_ref (match_operand 0 "" ""))
6315 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6317 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6323 [(set_attr "type" "bcc")])
6325 (define_insn "bordered"
6327 (if_then_else (ordered (cc0) (const_int 0))
6328 (label_ref (match_operand 0 "" ""))
6332 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6335 [(set_attr "type" "fbcc")])
6337 (define_insn "bunordered"
6339 (if_then_else (unordered (cc0) (const_int 0))
6340 (label_ref (match_operand 0 "" ""))
6344 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6347 [(set_attr "type" "fbcc")])
6349 (define_insn "buneq"
6351 (if_then_else (uneq (cc0) (const_int 0))
6352 (label_ref (match_operand 0 "" ""))
6356 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6359 [(set_attr "type" "fbcc")])
6361 (define_insn "bunge"
6363 (if_then_else (unge (cc0) (const_int 0))
6364 (label_ref (match_operand 0 "" ""))
6368 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6371 [(set_attr "type" "fbcc")])
6373 (define_insn "bungt"
6375 (if_then_else (ungt (cc0) (const_int 0))
6376 (label_ref (match_operand 0 "" ""))
6380 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6383 [(set_attr "type" "fbcc")])
6385 (define_insn "bunle"
6387 (if_then_else (unle (cc0) (const_int 0))
6388 (label_ref (match_operand 0 "" ""))
6392 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6395 [(set_attr "type" "fbcc")])
6397 (define_insn "bunlt"
6399 (if_then_else (unlt (cc0) (const_int 0))
6400 (label_ref (match_operand 0 "" ""))
6404 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6407 [(set_attr "type" "fbcc")])
6409 (define_insn "bltgt"
6411 (if_then_else (ltgt (cc0) (const_int 0))
6412 (label_ref (match_operand 0 "" ""))
6416 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6419 [(set_attr "type" "fbcc")])
6421 ;; Negated conditional jump instructions.
6423 (define_insn "*beq_rev"
6425 (if_then_else (eq (cc0)
6428 (label_ref (match_operand 0 "" ""))))]
6431 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6433 [(set_attr "type" "bcc")])
6435 (define_insn "*bne_rev"
6437 (if_then_else (ne (cc0)
6440 (label_ref (match_operand 0 "" ""))))]
6443 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6445 [(set_attr "type" "bcc")])
6447 (define_insn "*bgt_rev"
6449 (if_then_else (gt (cc0)
6452 (label_ref (match_operand 0 "" ""))))]
6455 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6457 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6461 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6463 [(set_attr "type" "bcc")])
6465 (define_insn "*bgtu_rev"
6467 (if_then_else (gtu (cc0)
6470 (label_ref (match_operand 0 "" ""))))]
6473 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6475 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6481 [(set_attr "type" "bcc")])
6483 (define_insn "*blt_rev"
6485 (if_then_else (lt (cc0)
6488 (label_ref (match_operand 0 "" ""))))]
6491 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6493 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6497 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6499 [(set_attr "type" "bcc")])
6501 (define_insn "*bltu_rev"
6503 (if_then_else (ltu (cc0)
6506 (label_ref (match_operand 0 "" ""))))]
6509 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6511 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6517 [(set_attr "type" "bcc")])
6519 (define_insn "*bge_rev"
6521 (if_then_else (ge (cc0)
6524 (label_ref (match_operand 0 "" ""))))]
6527 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6529 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6533 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6535 [(set_attr "type" "bcc")])
6537 (define_insn "*bgeu_rev"
6539 (if_then_else (geu (cc0)
6542 (label_ref (match_operand 0 "" ""))))]
6545 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6547 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6553 [(set_attr "type" "bcc")])
6555 (define_insn "*ble_rev"
6557 (if_then_else (le (cc0)
6560 (label_ref (match_operand 0 "" ""))))]
6563 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6565 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6569 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6571 [(set_attr "type" "bcc")])
6573 (define_insn "*bleu_rev"
6575 (if_then_else (leu (cc0)
6578 (label_ref (match_operand 0 "" ""))))]
6581 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6583 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6589 [(set_attr "type" "bcc")])
6591 (define_insn "*bordered_rev"
6593 (if_then_else (ordered (cc0) (const_int 0))
6595 (label_ref (match_operand 0 "" ""))))]
6598 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6601 [(set_attr "type" "fbcc")])
6603 (define_insn "*bunordered_rev"
6605 (if_then_else (unordered (cc0) (const_int 0))
6607 (label_ref (match_operand 0 "" ""))))]
6610 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6613 [(set_attr "type" "fbcc")])
6615 (define_insn "*buneq_rev"
6617 (if_then_else (uneq (cc0) (const_int 0))
6619 (label_ref (match_operand 0 "" ""))))]
6622 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6625 [(set_attr "type" "fbcc")])
6627 (define_insn "*bunge_rev"
6629 (if_then_else (unge (cc0) (const_int 0))
6631 (label_ref (match_operand 0 "" ""))))]
6634 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6637 [(set_attr "type" "fbcc")])
6639 (define_insn "*bungt_rev"
6641 (if_then_else (ungt (cc0) (const_int 0))
6643 (label_ref (match_operand 0 "" ""))))]
6646 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6649 [(set_attr "type" "fbcc")])
6651 (define_insn "*bunle_rev"
6653 (if_then_else (unle (cc0) (const_int 0))
6655 (label_ref (match_operand 0 "" ""))))]
6658 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6661 [(set_attr "type" "fbcc")])
6663 (define_insn "*bunlt_rev"
6665 (if_then_else (unlt (cc0) (const_int 0))
6667 (label_ref (match_operand 0 "" ""))))]
6670 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6673 [(set_attr "type" "fbcc")])
6675 (define_insn "*bltgt_rev"
6677 (if_then_else (ltgt (cc0) (const_int 0))
6679 (label_ref (match_operand 0 "" ""))))]
6682 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6685 [(set_attr "type" "fbcc")])
6687 ;; Unconditional and other jump instructions
6690 (label_ref (match_operand 0 "" "")))]
6693 [(set_attr "type" "bra")])
6695 (define_expand "tablejump"
6696 [(parallel [(set (pc) (match_operand 0 "" ""))
6697 (use (label_ref (match_operand 1 "" "")))])]
6700 #if CASE_VECTOR_PC_RELATIVE
6701 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6702 TARGET_LONG_JUMP_TABLE_OFFSETS
6704 : gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6708 ;; Jump to variable address from dispatch table of absolute addresses.
6709 (define_insn "*tablejump_internal"
6710 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6711 (use (label_ref (match_operand 1 "" "")))]
6714 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6716 [(set_attr "type" "jmp")])
6718 ;; Jump to variable address from dispatch table of relative addresses.
6719 (define_insn "*tablejump_pcrel_si"
6722 (match_operand:SI 0 "register_operand" "r")))
6723 (use (label_ref (match_operand 1 "" "")))]
6724 "TARGET_LONG_JUMP_TABLE_OFFSETS"
6726 #ifdef ASM_RETURN_CASE_JUMP
6727 ASM_RETURN_CASE_JUMP;
6729 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6733 (define_insn "*tablejump_pcrel_hi"
6736 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6737 (use (label_ref (match_operand 1 "" "")))]
6738 "!TARGET_LONG_JUMP_TABLE_OFFSETS"
6740 #ifdef ASM_RETURN_CASE_JUMP
6741 ASM_RETURN_CASE_JUMP;
6743 if (TARGET_COLDFIRE)
6745 if (ADDRESS_REG_P (operands[0]))
6746 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6748 return "ext%.l %0\;jmp (2,pc,%0.l)";
6750 return "extl %0\;jmp pc@(2,%0:l)";
6753 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6757 ;; Decrement-and-branch insns.
6758 (define_insn "*dbne_hi"
6761 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6763 (label_ref (match_operand 1 "" ""))
6766 (plus:HI (match_dup 0)
6771 if (DATA_REG_P (operands[0]))
6772 return "dbra %0,%l1";
6773 if (GET_CODE (operands[0]) == MEM)
6774 return "subq%.w #1,%0\;jcc %l1";
6775 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6778 (define_insn "*dbne_si"
6781 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6783 (label_ref (match_operand 1 "" ""))
6786 (plus:SI (match_dup 0)
6791 if (DATA_REG_P (operands[0]))
6792 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6793 if (GET_CODE (operands[0]) == MEM)
6794 return "subq%.l #1,%0\;jcc %l1";
6795 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6798 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6800 (define_insn "*dbge_hi"
6803 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6806 (label_ref (match_operand 1 "" ""))
6809 (plus:HI (match_dup 0)
6811 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6814 if (DATA_REG_P (operands[0]))
6815 return "dbra %0,%l1";
6816 if (GET_CODE (operands[0]) == MEM)
6817 return "subq%.w #1,%0\;jcc %l1";
6818 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6821 (define_expand "decrement_and_branch_until_zero"
6822 [(parallel [(set (pc)
6824 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6827 (label_ref (match_operand 1 "" ""))
6830 (plus:SI (match_dup 0)
6835 (define_insn "*dbge_si"
6838 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6841 (label_ref (match_operand 1 "" ""))
6844 (plus:SI (match_dup 0)
6846 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6849 if (DATA_REG_P (operands[0]))
6850 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6851 if (GET_CODE (operands[0]) == MEM)
6852 return "subq%.l #1,%0\;jcc %l1";
6853 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6856 (define_expand "sibcall"
6857 [(call (match_operand:QI 0 "memory_operand" "")
6858 (match_operand:SI 1 "general_operand" ""))]
6861 operands[0] = m68k_legitimize_sibcall_address (operands[0]);
6864 (define_insn "*sibcall"
6865 [(call (mem:QI (match_operand:SI 0 "sibcall_operand" ""))
6866 (match_operand:SI 1 "general_operand" ""))]
6867 "SIBLING_CALL_P (insn)"
6869 return output_sibcall (operands[0]);
6872 (define_expand "sibcall_value"
6873 [(set (match_operand 0 "" "")
6874 (call (match_operand:QI 1 "memory_operand" "")
6875 (match_operand:SI 2 "general_operand" "")))]
6878 operands[1] = m68k_legitimize_sibcall_address (operands[1]);
6881 (define_insn "*sibcall_value"
6882 [(set (match_operand 0 "" "=rf,rf")
6883 (call (mem:QI (match_operand:SI 1 "sibcall_operand" ""))
6884 (match_operand:SI 2 "general_operand" "")))]
6885 "SIBLING_CALL_P (insn)"
6887 operands[0] = operands[1];
6888 return output_sibcall (operands[0]);
6891 ;; Call subroutine with no return value.
6892 (define_expand "call"
6893 [(call (match_operand:QI 0 "memory_operand" "")
6894 (match_operand:SI 1 "general_operand" ""))]
6895 ;; Operand 1 not really used on the m68000.
6898 operands[0] = m68k_legitimize_call_address (operands[0]);
6901 (define_insn "*call"
6902 [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
6903 (match_operand:SI 1 "general_operand" "g,g"))]
6904 ;; Operand 1 not really used on the m68000.
6905 "!SIBLING_CALL_P (insn)"
6907 return output_call (operands[0]);
6909 [(set_attr "type" "jsr")])
6911 ;; Call subroutine, returning value in operand 0
6912 ;; (which must be a hard register).
6913 (define_expand "call_value"
6914 [(set (match_operand 0 "" "")
6915 (call (match_operand:QI 1 "memory_operand" "")
6916 (match_operand:SI 2 "general_operand" "")))]
6917 ;; Operand 2 not really used on the m68000.
6920 operands[1] = m68k_legitimize_call_address (operands[1]);
6923 (define_insn "*non_symbolic_call_value"
6924 [(set (match_operand 0 "" "=rf,rf")
6925 (call (mem:QI (match_operand:SI 1 "non_symbolic_call_operand" "a,W"))
6926 (match_operand:SI 2 "general_operand" "g,g")))]
6927 ;; Operand 2 not really used on the m68000.
6928 "!SIBLING_CALL_P (insn)"
6930 [(set_attr "type" "jsr")
6931 (set_attr "opx" "1")])
6933 (define_insn "*symbolic_call_value_jsr"
6934 [(set (match_operand 0 "" "=rf,rf")
6935 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6936 (match_operand:SI 2 "general_operand" "g,g")))]
6937 ;; Operand 2 not really used on the m68000.
6938 "!SIBLING_CALL_P (insn) && m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_JSR"
6940 operands[0] = operands[1];
6941 return m68k_symbolic_call;
6943 [(set_attr "type" "jsr")
6944 (set_attr "opx" "1")])
6946 (define_insn "*symbolic_call_value_bsr"
6947 [(set (match_operand 0 "" "=rf,rf")
6948 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6949 (match_operand:SI 2 "general_operand" "g,g")))]
6950 ;; Operand 2 not really used on the m68000.
6951 "!SIBLING_CALL_P (insn)
6952 && (m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_C
6953 || m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_P)"
6955 operands[0] = operands[1];
6956 return m68k_symbolic_call;
6958 [(set_attr "type" "bsr")
6959 (set_attr "opx" "1")])
6961 ;; Call subroutine returning any type.
6963 (define_expand "untyped_call"
6964 [(parallel [(call (match_operand 0 "" "")
6966 (match_operand 1 "" "")
6967 (match_operand 2 "" "")])]
6968 "NEEDS_UNTYPED_CALL"
6972 emit_call_insn (gen_call (operands[0], const0_rtx));
6974 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6976 rtx set = XVECEXP (operands[2], 0, i);
6977 emit_move_insn (SET_DEST (set), SET_SRC (set));
6980 /* The optimizer does not know that the call sets the function value
6981 registers we stored in the result block. We avoid problems by
6982 claiming that all hard registers are used and clobbered at this
6984 emit_insn (gen_blockage ());
6989 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6990 ;; all of memory. This blocks insns from being moved across this point.
6992 (define_insn "blockage"
6993 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
7001 [(set_attr "type" "nop")])
7003 (define_expand "prologue"
7007 m68k_expand_prologue ();
7011 (define_expand "epilogue"
7015 m68k_expand_epilogue (false);
7019 (define_expand "sibcall_epilogue"
7023 m68k_expand_epilogue (true);
7027 ;; Used for frameless functions which save no regs and allocate no locals.
7028 (define_expand "return"
7030 "m68k_use_return_insn ()"
7033 (define_insn "*return"
7037 switch (m68k_get_function_kind (current_function_decl))
7039 case m68k_fk_interrupt_handler:
7042 case m68k_fk_interrupt_thread:
7046 if (crtl->args.pops_args)
7048 operands[0] = GEN_INT (crtl->args.pops_args);
7055 [(set_attr "type" "rts")])
7057 (define_insn "*m68k_store_multiple"
7058 [(match_parallel 0 "" [(match_operand 1 "")])]
7059 "m68k_movem_pattern_p (operands[0], NULL, 0, true)"
7061 return m68k_output_movem (operands, operands[0], 0, true);
7064 (define_insn "*m68k_store_multiple_automod"
7065 [(match_parallel 0 ""
7066 [(set (match_operand:SI 1 "register_operand" "=a")
7067 (plus:SI (match_operand:SI 2 "register_operand" "1")
7068 (match_operand:SI 3 "const_int_operand")))])]
7069 "m68k_movem_pattern_p (operands[0], operands[1], INTVAL (operands[3]), true)"
7071 return m68k_output_movem (operands, operands[0], INTVAL (operands[3]), true);
7074 (define_insn "*m68k_load_multiple"
7075 [(match_parallel 0 "" [(match_operand 1 "")])]
7076 "m68k_movem_pattern_p (operands[0], NULL, 0, false)"
7078 return m68k_output_movem (operands, operands[0], 0, false);
7081 (define_insn "*m68k_load_multiple_automod"
7082 [(match_parallel 0 ""
7083 [(set (match_operand:SI 1 "register_operand" "=a")
7084 (plus:SI (match_operand:SI 2 "register_operand" "1")
7085 (match_operand:SI 3 "const_int_operand")))])]
7086 "m68k_movem_pattern_p (operands[0], operands[1],
7087 INTVAL (operands[3]), false)"
7089 return m68k_output_movem (operands, operands[0],
7090 INTVAL (operands[3]), false);
7093 (define_expand "link"
7095 [(set (match_operand:SI 0 "register_operand")
7096 (plus:SI (reg:SI SP_REG) (const_int -4)))
7099 (set (reg:SI SP_REG)
7100 (plus:SI (reg:SI SP_REG)
7101 (match_operand:SI 1 "const_int_operand")))])]
7102 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7104 operands[2] = gen_frame_mem (SImode,
7105 plus_constant (Pmode, stack_pointer_rtx, -4));
7108 (define_insn "*link"
7109 [(set (match_operand:SI 0 "register_operand" "+r")
7110 (plus:SI (reg:SI SP_REG) (const_int -4)))
7111 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
7113 (set (reg:SI SP_REG)
7114 (plus:SI (reg:SI SP_REG)
7115 (match_operand:SI 1 "const_int_operand")))]
7116 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7118 operands[1] = GEN_INT (INTVAL (operands[1]) + 4);
7120 return "link %0,%1";
7121 else if (INTVAL (operands[1]) >= -0x8000)
7122 return "link.w %0,%1";
7124 return "link.l %0,%1";
7126 [(set_attr "type" "link")])
7128 (define_expand "unlink"
7130 [(set (match_operand:SI 0 "register_operand")
7132 (set (reg:SI SP_REG)
7133 (plus:SI (match_dup 0)
7137 operands[1] = gen_frame_mem (SImode, copy_rtx (operands[0]));
7140 (define_insn "*unlink"
7141 [(set (match_operand:SI 0 "register_operand" "+r")
7142 (mem:SI (match_dup 0)))
7143 (set (reg:SI SP_REG)
7144 (plus:SI (match_dup 0)
7148 [(set_attr "type" "unlk")])
7150 (define_insn "load_got"
7151 [(set (match_operand:SI 0 "register_operand" "=a")
7152 (unspec:SI [(const_int 0)] UNSPEC_GOT))]
7155 if (TARGET_ID_SHARED_LIBRARY)
7157 operands[1] = gen_rtx_REG (Pmode, PIC_REG);
7158 return MOTOROLA ? "move.l %?(%1),%0" : "movel %1@(%?), %0";
7162 if (TARGET_COLDFIRE)
7163 /* Load the full 32-bit PC-relative offset of
7164 _GLOBAL_OFFSET_TABLE_ into the PIC register, then use it to
7165 calculate the absolute value. The offset and "lea"
7166 operation word together occupy 6 bytes. */
7167 return ("move.l #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t"
7168 "lea (-6, %%pc, %0), %0");
7170 return "lea (%%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %0";
7173 return ("movel #_GLOBAL_OFFSET_TABLE_, %0\n\t"
7174 "lea %%pc@(0,%0:l),%0");
7177 (define_insn "indirect_jump"
7178 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
7181 [(set_attr "type" "jmp")])
7183 ;; This should not be used unless the add/sub insns can't be.
7186 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
7187 (match_operand:QI 1 "address_operand" "p"))]
7191 ;; This is the first machine-dependent peephole optimization.
7192 ;; It is useful when a floating value is returned from a function call
7193 ;; and then is moved into an FP register.
7194 ;; But it is mainly intended to test the support for these optimizations.
7197 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7198 (set (match_operand:DF 0 "register_operand" "")
7199 (match_operand:DF 1 "register_operand" ""))]
7200 "FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
7201 [(set (mem:SI (reg:SI SP_REG)) (match_dup 1))
7202 (set (mem:SI (pre_dec:SI (reg:SI SP_REG))) (match_dup 2))
7203 (set (match_dup 0) (mem:DF (post_inc:SI (reg:SI SP_REG))))]
7204 "split_di(operands + 1, 1, operands + 1, operands + 2);")
7206 ;; Optimize a stack-adjust followed by a push of an argument.
7207 ;; This is said to happen frequently with -msoft-float
7208 ;; when there are consecutive library calls.
7211 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7212 (set (match_operand:SF 0 "push_operand" "")
7213 (match_operand:SF 1 "general_operand" ""))]
7214 "!reg_mentioned_p (stack_pointer_rtx, operands[0])"
7215 [(set (match_dup 0) (match_dup 1))]
7216 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7219 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7220 (match_operand:SI 0 "const_int_operand" "")))
7221 (set (match_operand:SF 1 "push_operand" "")
7222 (match_operand:SF 2 "general_operand" ""))]
7223 "INTVAL (operands[0]) > 4
7224 && !reg_mentioned_p (stack_pointer_rtx, operands[2])"
7225 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7226 (set (match_dup 1) (match_dup 2))]
7228 operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7229 operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7232 ;; Speed up stack adjust followed by a fullword fixedpoint push.
7233 ;; Constant operands need special care, as replacing a "pea X.w" with
7234 ;; "move.l #X,(%sp)" is often not a win.
7236 ;; Already done by the previous csa pass, left as reference.
7238 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7239 (set (match_operand:SI 0 "push_operand" "")
7240 (match_operand:SI 1 "general_operand" ""))]
7241 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7242 [(set (match_dup 0) (match_dup 1))]
7243 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7245 ;; Try to use moveq, after stack push has been changed into a simple move.
7247 [(match_scratch:SI 2 "d")
7248 (set (match_operand:SI 0 "memory_operand" "")
7249 (match_operand:SI 1 "const_int_operand" ""))]
7250 "GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
7251 && INTVAL (operands[1]) != 0
7252 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7253 && !valid_mov3q_const (INTVAL (operands[1]))"
7254 [(set (match_dup 2) (match_dup 1))
7255 (set (match_dup 0) (match_dup 2))])
7257 ;; This sequence adds an instruction, but is two bytes shorter.
7259 [(match_scratch:SI 2 "d")
7260 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 12)))
7261 (set (match_operand:SI 0 "push_operand" "")
7262 (match_operand:SI 1 "const_int_operand" ""))]
7263 "INTVAL (operands[1]) != 0
7264 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7265 && !valid_mov3q_const (INTVAL (operands[1]))"
7266 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 8)))
7267 (set (match_dup 2) (match_dup 1))
7268 (set (match_dup 0) (match_dup 2))]
7269 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7271 ;; Changing pea X.w into a move.l is no real win here.
7273 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7274 (match_operand:SI 0 "const_int_operand" "")))
7275 (set (match_operand:SI 1 "push_operand" "")
7276 (match_operand:SI 2 "general_operand" ""))]
7277 "INTVAL (operands[0]) > 4
7278 && !reg_mentioned_p (stack_pointer_rtx, operands[2])
7279 && !(CONST_INT_P (operands[2]) && INTVAL (operands[2]) != 0
7280 && IN_RANGE (INTVAL (operands[2]), -0x8000, 0x7fff)
7281 && !valid_mov3q_const (INTVAL (operands[2])))"
7282 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7283 (set (match_dup 1) (match_dup 2))]
7285 operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7286 operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7289 ;; Speed up pushing a single byte/two bytes but leaving four bytes of space
7290 ;; (which differs slightly between m680x0 and ColdFire).
7293 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
7294 (set (match_operand:QI 0 "memory_operand" "")
7295 (match_operand:QI 1 "register_operand" ""))]
7296 "!reg_mentioned_p (stack_pointer_rtx, operands[1])
7297 && GET_CODE (XEXP (operands[0], 0)) == PLUS
7298 && rtx_equal_p (XEXP (XEXP (operands[0], 0), 0), stack_pointer_rtx)
7299 && CONST_INT_P (XEXP (XEXP (operands[0], 0), 1))
7300 && INTVAL (XEXP (XEXP (operands[0], 0), 1)) == 3"
7301 [(set (match_dup 0) (match_dup 1))]
7303 rtx addr = gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx);
7304 operands[0] = adjust_automodify_address (operands[0], SImode, addr, -3);
7305 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7309 [(set (match_operand:QI 0 "push_operand" "")
7310 (match_operand:QI 1 "register_operand" ""))
7311 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -3)))]
7312 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7313 [(set (match_dup 0) (match_dup 1))]
7315 operands[0] = adjust_automodify_address (operands[0], SImode,
7316 XEXP (operands[0], 0), -3);
7317 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7321 [(set (match_operand:HI 0 "push_operand" "")
7322 (match_operand:HI 1 "register_operand" ""))
7323 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))]
7324 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7325 [(set (match_dup 0) (match_dup 1))]
7327 operands[0] = adjust_automodify_address (operands[0], SImode,
7328 XEXP (operands[0], 0), -2);
7329 operands[1] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
7332 ;; Optimize a series of strict_low_part assignments
7335 [(set (match_operand:SI 0 "register_operand" "")
7337 (set (strict_low_part (match_operand:HI 1 "register_operand" ""))
7338 (match_operand:HI 2 "general_operand" ""))]
7339 "REGNO (operands[0]) == REGNO (operands[1])
7340 && strict_low_part_peephole_ok (HImode, insn, operands[0])"
7341 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7345 [(set (match_operand:SI 0 "register_operand" "")
7347 (set (strict_low_part (match_operand:QI 1 "register_operand" ""))
7348 (match_operand:QI 2 "general_operand" ""))]
7349 "REGNO (operands[0]) == REGNO (operands[1])
7350 && strict_low_part_peephole_ok (QImode, insn, operands[0])"
7351 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7359 ;; jCC label ; abnormal loop termination
7360 ;; dbra dN, loop ; normal loop termination
7368 ;; Which moves the jCC condition outside the inner loop for free.
7372 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7373 [(cc0) (const_int 0)])
7374 (label_ref (match_operand 2 "" ""))
7379 (ne (match_operand:HI 0 "register_operand" "")
7381 (label_ref (match_operand 1 "" ""))
7384 (plus:HI (match_dup 0)
7386 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7389 output_dbcc_and_branch (operands);
7394 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7395 [(cc0) (const_int 0)])
7396 (label_ref (match_operand 2 "" ""))
7401 (ne (match_operand:SI 0 "register_operand" "")
7403 (label_ref (match_operand 1 "" ""))
7406 (plus:SI (match_dup 0)
7408 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7411 output_dbcc_and_branch (operands);
7416 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7417 [(cc0) (const_int 0)])
7418 (label_ref (match_operand 2 "" ""))
7423 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
7426 (label_ref (match_operand 1 "" ""))
7429 (plus:HI (match_dup 0)
7431 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7434 output_dbcc_and_branch (operands);
7439 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7440 [(cc0) (const_int 0)])
7441 (label_ref (match_operand 2 "" ""))
7446 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
7449 (label_ref (match_operand 1 "" ""))
7452 (plus:SI (match_dup 0)
7454 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7457 output_dbcc_and_branch (operands);
7462 (define_insn "extendsfxf2"
7463 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7464 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
7467 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7469 if (REGNO (operands[0]) == REGNO (operands[1]))
7471 /* Extending float to double in an fp-reg is a no-op.
7472 NOTICE_UPDATE_CC has already assumed that the
7473 cc will be set. So cancel what it did. */
7474 cc_status = cc_prev_status;
7477 return "f%$move%.x %1,%0";
7479 if (FP_REG_P (operands[0]))
7481 if (FP_REG_P (operands[1]))
7482 return "f%$move%.x %1,%0";
7483 else if (ADDRESS_REG_P (operands[1]))
7484 return "move%.l %1,%-\;f%$move%.s %+,%0";
7485 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
7486 return output_move_const_single (operands);
7487 return "f%$move%.s %f1,%0";
7489 return "fmove%.x %f1,%0";
7493 (define_insn "extenddfxf2"
7494 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7496 (match_operand:DF 1 "general_operand" "f,rmE")))]
7499 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7501 if (REGNO (operands[0]) == REGNO (operands[1]))
7503 /* Extending float to double in an fp-reg is a no-op.
7504 NOTICE_UPDATE_CC has already assumed that the
7505 cc will be set. So cancel what it did. */
7506 cc_status = cc_prev_status;
7509 return "fmove%.x %1,%0";
7511 if (FP_REG_P (operands[0]))
7513 if (REG_P (operands[1]))
7516 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
7517 output_asm_insn ("move%.l %1,%-", xoperands);
7518 output_asm_insn ("move%.l %1,%-", operands);
7519 return "f%&move%.d %+,%0";
7521 if (GET_CODE (operands[1]) == CONST_DOUBLE)
7522 return output_move_const_double (operands);
7523 return "f%&move%.d %f1,%0";
7525 return "fmove%.x %f1,%0";
7528 (define_insn "truncxfdf2"
7529 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
7531 (match_operand:XF 1 "general_operand" "f,f")))]
7534 if (REG_P (operands[0]))
7536 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
7537 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
7538 return "move%.l %+,%0";
7540 return "fmove%.d %f1,%0";
7543 (define_insn "truncxfsf2"
7544 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
7546 (match_operand:XF 1 "general_operand" "f")))]
7550 (define_insn "sin<mode>2"
7551 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7553 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
7554 "TARGET_68881 && flag_unsafe_math_optimizations"
7556 if (FP_REG_P (operands[1]))
7557 return "fsin%.x %1,%0";
7559 return "fsin%.<FP:prec> %1,%0";
7562 (define_insn "cos<mode>2"
7563 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7565 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
7566 "TARGET_68881 && flag_unsafe_math_optimizations"
7568 if (FP_REG_P (operands[1]))
7569 return "fcos%.x %1,%0";
7571 return "fcos%.<FP:prec> %1,%0";
7574 ;; Unconditional traps are assumed to have (const_int 1) for the condition.
7576 [(trap_if (const_int 1) (const_int 7))]
7579 [(set_attr "type" "trap")])
7581 (define_expand "ctrapdi4"
7582 [(trap_if (match_operator 0 "ordered_comparison_operator"
7583 [(cc0) (const_int 0)])
7584 (match_operand:SI 3 "const1_operand" ""))]
7587 if (operands[2] == const0_rtx)
7588 emit_insn (gen_tstdi (operands[1]));
7590 emit_insn (gen_cmpdi (operands[1], operands[2]));
7591 operands[1] = cc0_rtx;
7592 operands[2] = const0_rtx;
7595 (define_expand "ctrapsi4"
7597 (compare (match_operand:SI 1 "nonimmediate_operand" "")
7598 (match_operand:SI 2 "general_operand" "")))
7599 (trap_if (match_operator 0 "ordered_comparison_operator"
7600 [(cc0) (const_int 0)])
7601 (match_operand:SI 3 "const1_operand" ""))]
7605 (define_expand "ctraphi4"
7607 (compare (match_operand:HI 1 "nonimmediate_src_operand" "")
7608 (match_operand:HI 2 "general_src_operand" "")))
7609 (trap_if (match_operator 0 "ordered_comparison_operator"
7610 [(cc0) (const_int 0)])
7611 (match_operand:SI 3 "const1_operand" ""))]
7615 (define_expand "ctrapqi4"
7617 (compare (match_operand:QI 1 "nonimmediate_src_operand" "")
7618 (match_operand:QI 2 "general_src_operand" "")))
7619 (trap_if (match_operator 0 "ordered_comparison_operator"
7620 [(cc0) (const_int 0)])
7621 (match_operand:SI 3 "const1_operand" ""))]
7625 (define_insn "*conditional_trap"
7626 [(trap_if (match_operator 0 "ordered_comparison_operator"
7627 [(cc0) (const_int 0)])
7628 (match_operand:SI 1 "const1_operand" "I"))]
7629 "TARGET_68020 && ! flags_in_68881 ()"
7631 switch (GET_CODE (operands[0]))
7633 case EQ: return "trapeq";
7634 case NE: return "trapne";
7635 case GT: return "trapgt";
7636 case GTU: return "traphi";
7637 case LT: return "traplt";
7638 case LTU: return "trapcs";
7639 case GE: return "trapge";
7640 case GEU: return "trapcc";
7641 case LE: return "traple";
7642 case LEU: return "trapls";
7643 default: gcc_unreachable ();
7647 ;; These are to prevent the scheduler from moving stores to the frame
7648 ;; before the stack adjustment.
7649 (define_insn "stack_tie"
7650 [(set (mem:BLK (scratch))
7651 (unspec:BLK [(match_operand:SI 0 "register_operand" "r")
7652 (match_operand:SI 1 "register_operand" "r")]
7656 [(set_attr "type" "ignore")])
7658 ;; Instruction that subscribes one word in ColdFire instruction buffer.
7659 ;; This instruction is used within scheduler only and should not appear
7660 ;; in the instruction stream.
7662 [(unspec [(const_int 0)] UNSPEC_IB)]
7665 [(set_attr "type" "ib")])
7672 ;; move.l 4(%a0),%a0
7673 ;; clr.b (%a0,%a1.l)
7680 ;; The latter is smaller. It is faster on all models except m68060.
7683 [(set (match_operand:SI 0 "register_operand" "")
7684 (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "")
7685 (match_operand:SI 2 "const_int_operand" ""))))
7686 (set (mem:QI (plus:SI (match_operand:SI 3 "register_operand" "")
7687 (match_operand:SI 4 "register_operand" "")))
7689 "(optimize_size || !TUNE_68060)
7690 && (operands[0] == operands[3] || operands[0] == operands[4])
7691 && ADDRESS_REG_P (operands[1])
7692 && ADDRESS_REG_P ((operands[0] == operands[3]) ? operands[4] : operands[3])
7693 && peep2_reg_dead_p (2, operands[3])
7694 && peep2_reg_dead_p (2, operands[4])"
7696 (plus:SI (match_dup 5)
7697 (mem:SI (plus:SI (match_dup 1)
7699 (set (mem:QI (match_dup 5))
7701 "operands[5] = (operands[0] == operands[3]) ? operands[4] : operands[3];")
7709 ;; addq/subq -const,dY
7713 ;; dX and dY must both be dead at the end of the sequence and the constant
7714 ;; must be valid for addq/subq.
7716 ;; Essentially we're making it trivial for final to realize the comparison
7719 ;; Testing has shown a variant where the operands are reversed in the
7720 ;; comparison never hits, so I have not included that variant.
7724 [(set (match_operand:SI 0 "register_operand" "")
7725 (match_operand:SI 1 "addq_subq_operand" ""))
7726 (set (cc0) (compare (match_operand:SI 2 "register_operand" "")
7728 (set (pc) (if_then_else (match_operator 5 "equality_comparison_operator"
7729 [(cc0) (const_int 0)])
7730 (match_operand 3 "pc_or_label_operand")
7731 (match_operand 4 "pc_or_label_operand")))]
7732 "peep2_reg_dead_p (2, operands[0])
7733 && peep2_reg_dead_p (2, operands[2])
7734 && (operands[3] == pc_rtx || operands[4] == pc_rtx)
7735 && DATA_REG_P (operands[2])
7736 && !rtx_equal_p (operands[0], operands[2])"
7737 [(set (match_dup 2) (plus:SI (match_dup 2) (match_dup 6)))
7738 (set (cc0) (compare (match_dup 2) (const_int 0)))
7739 (set (pc) (if_then_else (match_op_dup 5 [(cc0) (const_int 0)])
7742 "operands[6] = GEN_INT (-INTVAL (operands[1]));")
7745 [(set (match_operand:SI 0 "register_operand" "")
7746 (match_operand:SI 1 "pow2_m1_operand" ""))
7747 (set (cc0) (compare (match_operand:SI 2 "register_operand" "")
7748 (match_operand:SI 3 "register_operand" "")))
7749 (set (pc) (if_then_else (gtu (cc0) (const_int 0))
7750 (match_operand 4 "pc_or_label_operand")
7751 (match_operand 5 "pc_or_label_operand")))]
7752 "INTVAL (operands[1]) <= 255
7753 && operands[0] == operands[3]
7754 && peep2_reg_dead_p (2, operands[0])
7755 && peep2_reg_dead_p (2, operands[2])
7756 && (operands[4] == pc_rtx || operands[5] == pc_rtx)
7757 && (optimize_size || TUNE_68040_60)
7758 && DATA_REG_P (operands[2])"
7759 [(set (match_dup 7) (lshiftrt:SI (match_dup 7) (match_dup 6)))
7760 (set (cc0) (compare (match_dup 7) (const_int 0)))
7761 (set (pc) (if_then_else (ne (cc0) (const_int 0))
7762 (match_dup 4) (match_dup 5)))]
7765 operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
7766 operands[7] = operands[2];
7770 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
7771 (match_operand:SI 1 "pow2_m1_operand" "")))
7772 (set (pc) (if_then_else (gtu (cc0) (const_int 0))
7773 (match_operand 2 "pc_or_label_operand")
7774 (match_operand 3 "pc_or_label_operand")))]
7775 "INTVAL (operands[1]) <= 255
7776 && peep2_reg_dead_p (1, operands[0])
7777 && (operands[2] == pc_rtx || operands[3] == pc_rtx)
7778 && (optimize_size || TUNE_68040_60)
7779 && DATA_REG_P (operands[0])"
7780 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 4)))
7781 (set (cc0) (compare (match_dup 0) (const_int 0)))
7782 (set (pc) (if_then_else (ne (cc0) (const_int 0))
7783 (match_dup 2) (match_dup 3)))]
7784 "{ operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1)); }")
7787 [(set (match_operand:SI 0 "register_operand" "")
7788 (match_operand:SI 1 "pow2_m1_operand" ""))
7789 (set (cc0) (compare (match_operand:SI 2 "register_operand" "")
7790 (match_operand:SI 3 "register_operand" "")))
7791 (set (pc) (if_then_else (leu (cc0) (const_int 0))
7792 (match_operand 4 "pc_or_label_operand")
7793 (match_operand 5 "pc_or_label_operand")))]
7794 "INTVAL (operands[1]) <= 255
7795 && operands[0] == operands[3]
7796 && peep2_reg_dead_p (2, operands[0])
7797 && peep2_reg_dead_p (2, operands[2])
7798 && (operands[4] == pc_rtx || operands[5] == pc_rtx)
7799 && (optimize_size || TUNE_68040_60)
7800 && DATA_REG_P (operands[2])"
7801 [(set (match_dup 7) (lshiftrt:SI (match_dup 7) (match_dup 6)))
7802 (set (cc0) (compare (match_dup 7) (const_int 0)))
7803 (set (pc) (if_then_else (eq (cc0) (const_int 0))
7804 (match_dup 4) (match_dup 5)))]
7807 operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
7808 operands[7] = operands[2];
7811 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
7812 (match_operand:SI 1 "pow2_m1_operand" "")))
7813 (set (pc) (if_then_else (leu (cc0) (const_int 0))
7814 (match_operand 2 "pc_or_label_operand")
7815 (match_operand 3 "pc_or_label_operand")))]
7816 "INTVAL (operands[1]) <= 255
7817 && peep2_reg_dead_p (1, operands[0])
7818 && (operands[2] == pc_rtx || operands[3] == pc_rtx)
7819 && (optimize_size || TUNE_68040_60)
7820 && DATA_REG_P (operands[0])"
7821 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 4)))
7822 (set (cc0) (compare (match_dup 0) (const_int 0)))
7823 (set (pc) (if_then_else (eq (cc0) (const_int 0))
7824 (match_dup 2) (match_dup 3)))]
7825 "{ operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1)); }")
7827 ;; When optimizing for size or for the original 68000 or 68010, we can
7828 ;; improve some relational tests against 65536 (which get canonicalized
7829 ;; internally against 65535).
7830 ;; The rotate in the output pattern will turn into a swap.
7832 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
7834 (set (pc) (if_then_else (match_operator 1 "swap_peephole_relational_operator"
7835 [(cc0) (const_int 0)])
7836 (match_operand 2 "pc_or_label_operand")
7837 (match_operand 3 "pc_or_label_operand")))]
7838 "peep2_reg_dead_p (1, operands[0])
7839 && (operands[2] == pc_rtx || operands[3] == pc_rtx)
7840 && (optimize_size || TUNE_68000_10)
7841 && DATA_REG_P (operands[0])"
7842 [(set (match_dup 0) (rotate:SI (match_dup 0) (const_int 16)))
7843 (set (cc0) (compare (subreg:HI (match_dup 0) 2) (const_int 0)))
7844 (set (pc) (if_then_else (match_op_dup 1 [(cc0) (const_int 0)])
7845 (match_dup 2) (match_dup 3)))]