1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987-2017 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);
4686 return "asr%.l #1,%0\;roxr%.l #1,%1";
4690 [(set (match_operand:DI 0 "register_operand" "")
4691 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4693 "reload_completed && !TARGET_COLDFIRE"
4695 (ashiftrt:DI (match_dup 1) (const_int 1)))
4697 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4701 [(set (match_operand:DI 0 "register_operand" "")
4702 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4704 "reload_completed && !TARGET_COLDFIRE"
4706 (ashiftrt:DI (match_dup 1) (const_int 2)))
4708 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4712 [(set (match_operand:DI 0 "register_operand" "")
4713 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4715 "reload_completed && !TARGET_COLDFIRE"
4716 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4717 (subreg:QI (match_dup 0) 3))
4719 (ashiftrt:SI (match_dup 2) (const_int 8)))
4721 (rotatert:SI (match_dup 3) (const_int 8)))]
4723 operands[2] = gen_highpart (SImode, operands[0]);
4724 operands[3] = gen_lowpart (SImode, operands[0]);
4728 [(set (match_operand:DI 0 "register_operand" "")
4729 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4731 "reload_completed && !TARGET_COLDFIRE"
4732 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4733 (subreg:HI (match_dup 0) 2))
4735 (rotate:SI (match_dup 2) (const_int 16)))
4737 (rotate:SI (match_dup 3) (const_int 16)))
4739 (sign_extend:SI (subreg:HI (match_dup 2) 2)))]
4741 operands[2] = gen_highpart (SImode, operands[0]);
4742 operands[3] = gen_lowpart (SImode, operands[0]);
4745 (define_insn "*ashrdi_const32"
4746 [(set (match_operand:DI 0 "register_operand" "=d")
4747 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro")
4753 return "move%.l %1,%R0\;smi %0\;extb%.l %0";
4755 return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
4758 (define_insn "*ashrdi_const32_mem"
4759 [(set (match_operand:DI 0 "memory_operand" "=o,<")
4760 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro,ro")
4762 (clobber (match_scratch:SI 2 "=d,d"))]
4766 operands[3] = adjust_address (operands[0], SImode,
4767 which_alternative == 0 ? 4 : 0);
4768 operands[0] = adjust_address (operands[0], SImode, 0);
4769 if (TARGET_68020 || TARGET_COLDFIRE)
4770 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4772 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4776 [(set (match_operand:DI 0 "register_operand" "")
4777 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4779 "reload_completed && !TARGET_COLDFIRE"
4781 (ashiftrt:SI (match_dup 3) (const_int 31)))
4784 "split_di(operands, 1, operands + 2, operands + 3);")
4786 ;; The predicate below must be general_operand, because ashrdi3 allows that
4787 (define_insn "ashrdi_const"
4788 [(set (match_operand:DI 0 "register_operand" "=d")
4789 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4790 (match_operand 2 "const_int_operand" "n")))]
4792 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4793 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4794 || INTVAL (operands[2]) == 31
4795 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4797 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4799 if (INTVAL (operands[2]) == 48)
4800 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4801 if (INTVAL (operands[2]) == 31)
4802 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4803 if (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)
4805 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4806 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4807 "moveq %2,%1\;asr%.l %1,%0", operands);
4808 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4809 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4810 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4815 (define_expand "ashrdi3"
4816 [(set (match_operand:DI 0 "register_operand" "")
4817 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4818 (match_operand:SI 2 "const_int_operand" "")))]
4821 /* ??? This is a named pattern like this is not allowed to FAIL based
4823 if (GET_CODE (operands[2]) != CONST_INT
4824 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4825 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4826 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4830 ;; On all 68k models, this makes faster code in a special case.
4832 (define_insn "ashrsi_31"
4833 [(set (match_operand:SI 0 "register_operand" "=d")
4834 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4838 return "add%.l %0,%0\;subx%.l %0,%0";
4841 (define_insn "ashrsi3"
4842 [(set (match_operand:SI 0 "register_operand" "=d")
4843 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4844 (match_operand:SI 2 "general_operand" "dI")))]
4847 [(set_attr "type" "shift")
4848 (set_attr "opy" "2")])
4850 (define_insn "ashrhi3"
4851 [(set (match_operand:HI 0 "register_operand" "=d")
4852 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4853 (match_operand:HI 2 "general_operand" "dI")))]
4858 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4859 (ashiftrt:HI (match_dup 0)
4860 (match_operand:HI 1 "general_operand" "dI")))]
4864 (define_insn "ashrqi3"
4865 [(set (match_operand:QI 0 "register_operand" "=d")
4866 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4867 (match_operand:QI 2 "general_operand" "dI")))]
4872 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4873 (ashiftrt:QI (match_dup 0)
4874 (match_operand:QI 1 "general_operand" "dI")))]
4878 ;; logical shift instructions
4880 ;; commented out because of reload problems in 950612-1.c
4883 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4884 ;; (const_int 32)) 4))
4885 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4886 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4887 ;; (const_int 32)) 4))]
4890 ;; return "move%.l %0,%1";
4895 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4896 ;; (const_int 32)) 0))
4897 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4898 ;; (lshiftrt:DI (match_dup 0)
4899 ;; (const_int 32)))]
4902 ;; if (GET_CODE (operands[1]) == REG)
4903 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4905 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4906 ;; return "move%.l %0,%2\;clr%.l %1";
4909 (define_insn "subreg1lshrdi_const32"
4910 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4911 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4912 (const_int 32)) 4))]
4915 [(set_attr "type" "move_l")])
4917 (define_insn "*lshrdi3_const1"
4918 [(set (match_operand:DI 0 "register_operand" "=d")
4919 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
4922 "lsr%.l #1,%0\;roxr%.l #1,%R0")
4925 [(set (match_operand:DI 0 "register_operand" "")
4926 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4928 "reload_completed && !TARGET_COLDFIRE"
4930 (lshiftrt:DI (match_dup 1) (const_int 1)))
4932 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4936 [(set (match_operand:DI 0 "register_operand" "")
4937 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4939 "reload_completed && !TARGET_COLDFIRE"
4941 (lshiftrt:DI (match_dup 1) (const_int 2)))
4943 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4947 [(set (match_operand:DI 0 "register_operand" "")
4948 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4950 "reload_completed && !TARGET_COLDFIRE"
4951 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4952 (subreg:QI (match_dup 0) 3))
4954 (lshiftrt:SI (match_dup 2) (const_int 8)))
4956 (rotatert:SI (match_dup 3) (const_int 8)))]
4958 operands[2] = gen_highpart (SImode, operands[0]);
4959 operands[3] = gen_lowpart (SImode, operands[0]);
4963 [(set (match_operand:DI 0 "register_operand" "")
4964 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4966 "reload_completed && !TARGET_COLDFIRE"
4967 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4968 (subreg:HI (match_dup 0) 2))
4969 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4972 (rotate:SI (match_dup 3) (const_int 16)))
4974 (rotate:SI (match_dup 2) (const_int 16)))]
4976 operands[2] = gen_highpart (SImode, operands[0]);
4977 operands[3] = gen_lowpart (SImode, operands[0]);
4981 [(set (match_operand:DI 0 "pre_dec_operand" "")
4982 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
4985 [(set (match_dup 0) (match_dup 1))
4986 (set (match_dup 0) (const_int 0))]
4988 operands[0] = adjust_address(operands[0], SImode, 0);
4989 operands[1] = gen_highpart(SImode, operands[1]);
4993 [(set (match_operand:DI 0 "post_inc_operand" "")
4994 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
4997 [(set (match_dup 0) (const_int 0))
4998 (set (match_dup 0) (match_dup 1))]
5000 operands[0] = adjust_address(operands[0], SImode, 0);
5001 operands[1] = gen_highpart(SImode, operands[1]);
5005 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5006 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5009 [(set (match_dup 2) (match_dup 5))
5010 (set (match_dup 4) (const_int 0))]
5011 "split_di(operands, 2, operands + 2, operands + 4);")
5013 (define_insn "*lshrdi_const32"
5014 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
5015 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
5021 [(set (match_operand:DI 0 "register_operand" "")
5022 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5023 (match_operand 2 "const_int_operand" "")))]
5024 "reload_completed && !TARGET_COLDFIRE
5025 && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
5026 [(set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 2)))
5027 (set (match_dup 4) (match_dup 3))
5028 (set (match_dup 3) (const_int 0))]
5030 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5031 operands[3] = gen_highpart (SImode, operands[0]);
5032 operands[4] = gen_lowpart (SImode, operands[0]);
5036 [(set (match_operand:DI 0 "register_operand" "")
5037 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5040 [(set (match_dup 3) (match_dup 2))
5041 (set (strict_low_part (subreg:HI (match_dup 0) 6))
5043 (set (match_dup 2) (const_int 0))
5045 (rotate:SI (match_dup 3) (const_int 16)))]
5047 operands[2] = gen_highpart (SImode, operands[0]);
5048 operands[3] = gen_lowpart (SImode, operands[0]);
5052 [(set (match_operand:DI 0 "register_operand" "")
5053 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5054 (match_operand 2 "const_int_operand" "")))]
5055 "reload_completed && !TARGET_COLDFIRE
5056 && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 62"
5057 [(set (match_dup 4) (match_dup 2))
5058 (set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 4)))
5059 (set (match_dup 4) (match_dup 3))
5060 (set (match_dup 3) (const_int 0))]
5062 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5063 operands[3] = gen_highpart (SImode, operands[0]);
5064 operands[4] = gen_lowpart (SImode, operands[0]);
5067 (define_insn "*lshrdi_const63"
5068 [(set (match_operand:DI 0 "register_operand" "=d")
5069 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5072 "add%.l %0,%0\;clr%.l %0\;clr%.l %R1\;addx%.l %R1,%R1")
5074 (define_insn "*lshrdi3_const"
5075 [(set (match_operand:DI 0 "register_operand" "=d")
5076 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5077 (match_operand 2 "const_int_operand" "n")))]
5079 && ((INTVAL (operands[2]) >= 2 && INTVAL (operands[2]) <= 3)
5080 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
5081 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
5084 (define_expand "lshrdi3"
5085 [(set (match_operand:DI 0 "register_operand" "")
5086 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5087 (match_operand:SI 2 "const_int_operand" "")))]
5090 /* ??? This is a named pattern like this is not allowed to FAIL based
5092 if (GET_CODE (operands[2]) != CONST_INT
5093 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
5094 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
5095 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
5099 ;; On all 68k models, this makes faster code in a special case.
5101 (define_insn "lshrsi_31"
5102 [(set (match_operand:SI 0 "register_operand" "=d")
5103 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5107 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
5110 ;; On most 68k models, this makes faster code in a special case.
5112 (define_insn "lshrsi_16"
5113 [(set (match_operand:SI 0 "register_operand" "=d")
5114 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5119 return "clr%.w %0\;swap %0";
5122 ;; On the 68000, this makes faster code in a special case.
5124 (define_insn "lshrsi_17_24"
5125 [(set (match_operand:SI 0 "register_operand" "=d")
5126 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5127 (match_operand:SI 2 "const_int_operand" "n")))]
5129 && INTVAL (operands[2]) > 16
5130 && INTVAL (operands[2]) <= 24"
5132 /* I think lsr%.w sets the CC properly. */
5133 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
5134 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
5137 (define_insn "lshrsi3"
5138 [(set (match_operand:SI 0 "register_operand" "=d")
5139 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5140 (match_operand:SI 2 "general_operand" "dI")))]
5143 [(set_attr "type" "shift")
5144 (set_attr "opy" "2")])
5146 (define_insn "lshrhi3"
5147 [(set (match_operand:HI 0 "register_operand" "=d")
5148 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
5149 (match_operand:HI 2 "general_operand" "dI")))]
5154 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5155 (lshiftrt:HI (match_dup 0)
5156 (match_operand:HI 1 "general_operand" "dI")))]
5160 (define_insn "lshrqi3"
5161 [(set (match_operand:QI 0 "register_operand" "=d")
5162 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
5163 (match_operand:QI 2 "general_operand" "dI")))]
5168 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5169 (lshiftrt:QI (match_dup 0)
5170 (match_operand:QI 1 "general_operand" "dI")))]
5174 ;; rotate instructions
5176 (define_insn "rotlsi_16"
5177 [(set (match_operand:SI 0 "register_operand" "=d")
5178 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5182 [(set_attr "type" "shift")])
5184 (define_insn "rotlsi3"
5185 [(set (match_operand:SI 0 "register_operand" "=d")
5186 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5187 (match_operand:SI 2 "general_operand" "dINO")))]
5190 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
5192 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
5194 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
5195 return "ror%.l %2,%0";
5198 return "rol%.l %2,%0";
5201 (define_insn "rotlhi3"
5202 [(set (match_operand:HI 0 "register_operand" "=d")
5203 (rotate:HI (match_operand:HI 1 "register_operand" "0")
5204 (match_operand:HI 2 "general_operand" "dIP")))]
5207 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5209 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5210 return "ror%.w %2,%0";
5213 return "rol%.w %2,%0";
5216 (define_insn "*rotlhi3_lowpart"
5217 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5218 (rotate:HI (match_dup 0)
5219 (match_operand:HI 1 "general_operand" "dIP")))]
5222 if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) >= 8)
5224 operands[1] = GEN_INT (16 - INTVAL (operands[1]));
5225 return "ror%.w %1,%0";
5228 return "rol%.w %1,%0";
5231 (define_insn "rotlqi3"
5232 [(set (match_operand:QI 0 "register_operand" "=d")
5233 (rotate:QI (match_operand:QI 1 "register_operand" "0")
5234 (match_operand:QI 2 "general_operand" "dI")))]
5237 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5239 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5240 return "ror%.b %2,%0";
5243 return "rol%.b %2,%0";
5246 (define_insn "*rotlqi3_lowpart"
5247 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5248 (rotate:QI (match_dup 0)
5249 (match_operand:QI 1 "general_operand" "dI")))]
5252 if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) >= 4)
5254 operands[1] = GEN_INT (8 - INTVAL (operands[1]));
5255 return "ror%.b %1,%0";
5258 return "rol%.b %1,%0";
5261 (define_insn "rotrsi3"
5262 [(set (match_operand:SI 0 "register_operand" "=d")
5263 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
5264 (match_operand:SI 2 "general_operand" "dI")))]
5268 (define_insn "rotrhi3"
5269 [(set (match_operand:HI 0 "register_operand" "=d")
5270 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
5271 (match_operand:HI 2 "general_operand" "dI")))]
5275 (define_insn "rotrhi_lowpart"
5276 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5277 (rotatert:HI (match_dup 0)
5278 (match_operand:HI 1 "general_operand" "dI")))]
5282 (define_insn "rotrqi3"
5283 [(set (match_operand:QI 0 "register_operand" "=d")
5284 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
5285 (match_operand:QI 2 "general_operand" "dI")))]
5290 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5291 (rotatert:QI (match_dup 0)
5292 (match_operand:QI 1 "general_operand" "dI")))]
5296 (define_expand "bswapsi2"
5297 [(set (match_operand:SI 0 "register_operand")
5298 (bswap:SI (match_operand:SI 1 "register_operand")))]
5301 rtx x = operands[0];
5302 emit_move_insn (x, operands[1]);
5303 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5304 emit_insn (gen_rotlsi3 (x, x, GEN_INT (16)));
5305 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5310 ;; Bit set/clear in memory byte.
5312 ;; set bit, bit number is int
5313 (define_insn "bsetmemqi"
5314 [(set (match_operand:QI 0 "memory_operand" "+m")
5315 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5316 (match_operand:SI 1 "general_operand" "d")) 3)
5321 return "bset %1,%0";
5323 [(set_attr "type" "bitrw")])
5325 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
5326 (define_insn "*bsetmemqi_ext"
5327 [(set (match_operand:QI 0 "memory_operand" "+m")
5328 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5329 (match_operator:SI 2 "extend_operator"
5330 [(match_operand 1 "general_operand" "d")])) 3)
5335 return "bset %1,%0";
5337 [(set_attr "type" "bitrw")])
5339 (define_insn "*bsetdreg"
5340 [(set (match_operand:SI 0 "register_operand" "=d")
5341 (ior:SI (ashift:SI (const_int 1)
5342 (and:SI (match_operand:SI 1 "register_operand" "d")
5344 (match_operand:SI 2 "register_operand" "0")))]
5348 return "bset %1,%0";
5350 [(set_attr "type" "bitrw")])
5352 (define_insn "*bchgdreg"
5353 [(set (match_operand:SI 0 "register_operand" "=d")
5354 (xor:SI (ashift:SI (const_int 1)
5355 (and:SI (match_operand:SI 1 "register_operand" "d")
5357 (match_operand:SI 2 "register_operand" "0")))]
5361 return "bchg %1,%0";
5363 [(set_attr "type" "bitrw")])
5365 (define_insn "*bclrdreg"
5366 [(set (match_operand:SI 0 "register_operand" "=d")
5367 (and:SI (rotate:SI (const_int -2)
5368 (and:SI (match_operand:SI 1 "register_operand" "d")
5370 (match_operand:SI 2 "register_operand" "0")))]
5374 return "bclr %1,%0";
5376 [(set_attr "type" "bitrw")])
5378 ;; clear bit, bit number is int
5379 (define_insn "bclrmemqi"
5380 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5382 (minus:SI (const_int 7)
5383 (match_operand:SI 1 "general_operand" "d")))
5388 return "bclr %1,%0";
5390 [(set_attr "type" "bitrw")])
5392 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
5393 (define_insn "*bclrmemqi_ext"
5394 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5396 (minus:SI (const_int 7)
5397 (match_operator:SI 2 "extend_operator"
5398 [(match_operand 1 "general_operand" "d")])))
5403 return "bclr %1,%0";
5405 [(set_attr "type" "bitrw")])
5407 ;; Special cases of bit-field insns which we should
5408 ;; recognize in preference to the general case.
5409 ;; These handle aligned 8-bit and 16-bit fields,
5410 ;; which can usually be done with move instructions.
5413 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5414 ; alignment of structure members is specified.
5416 ; The move is allowed to be odd byte aligned, because that's still faster
5417 ; than an odd byte aligned bit-field instruction.
5419 (define_insn "*insv_32_mem"
5420 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5422 (match_operand:SI 1 "const_int_operand" "n"))
5423 (match_operand:SI 2 "general_src_operand" "rmSi"))]
5424 "TARGET_68020 && TARGET_BITFIELD
5425 && (INTVAL (operands[1]) % 8) == 0
5426 && ! mode_dependent_address_p (XEXP (operands[0], 0),
5427 MEM_ADDR_SPACE (operands[0]))"
5430 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
5432 return "move%.l %2,%0";
5435 (define_insn "*insv_8_16_reg"
5436 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5437 (match_operand:SI 1 "const_int_operand" "n")
5438 (match_operand:SI 2 "const_int_operand" "n"))
5439 (match_operand:SI 3 "register_operand" "d"))]
5440 "TARGET_68020 && TARGET_BITFIELD
5441 && IN_RANGE (INTVAL (operands[2]), 0, 31)
5442 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
5443 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0"
5445 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
5446 return "bfins %3,%0{%b2:%b1}";
5448 if (INTVAL (operands[1]) == 8)
5449 return "move%.b %3,%0";
5450 return "move%.w %3,%0";
5455 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5456 ; alignment of structure members is specified.
5458 ; The move is allowed to be odd byte aligned, because that's still faster
5459 ; than an odd byte aligned bit-field instruction.
5461 (define_insn "*extzv_32_mem"
5462 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5463 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5465 (match_operand:SI 2 "const_int_operand" "n")))]
5466 "TARGET_68020 && TARGET_BITFIELD
5467 && (INTVAL (operands[2]) % 8) == 0
5468 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5469 MEM_ADDR_SPACE (operands[1]))"
5472 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5474 return "move%.l %1,%0";
5477 (define_insn "*extzv_8_16_reg"
5478 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
5479 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5480 (match_operand:SI 2 "const_int_operand" "n")
5481 (match_operand:SI 3 "const_int_operand" "n")))]
5482 "TARGET_68020 && TARGET_BITFIELD
5483 && IN_RANGE (INTVAL (operands[3]), 0, 31)
5484 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5485 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5487 cc_status.flags |= CC_NOT_NEGATIVE;
5488 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5489 return "bfextu %1{%b3:%b2},%0";
5491 output_asm_insn ("clr%.l %0", operands);
5492 if (INTVAL (operands[2]) == 8)
5493 return "move%.b %1,%0";
5494 return "move%.w %1,%0";
5498 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5499 ; alignment of structure members is specified.
5501 ; The move is allowed to be odd byte aligned, because that's still faster
5502 ; than an odd byte aligned bit-field instruction.
5504 (define_insn "*extv_32_mem"
5505 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5506 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5508 (match_operand:SI 2 "const_int_operand" "n")))]
5509 "TARGET_68020 && TARGET_BITFIELD
5510 && (INTVAL (operands[2]) % 8) == 0
5511 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5512 MEM_ADDR_SPACE (operands[1]))"
5515 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5517 return "move%.l %1,%0";
5520 (define_insn "*extv_8_16_reg"
5521 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5522 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5523 (match_operand:SI 2 "const_int_operand" "n")
5524 (match_operand:SI 3 "const_int_operand" "n")))]
5525 "TARGET_68020 && TARGET_BITFIELD
5526 && IN_RANGE (INTVAL (operands[3]), 0, 31)
5527 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5528 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5530 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5531 return "bfexts %1{%b3:%b2},%0";
5533 if (INTVAL (operands[2]) == 8)
5534 return "move%.b %1,%0\;extb%.l %0";
5535 return "move%.w %1,%0\;ext%.l %0";
5538 ;; Bit-field instructions, general cases.
5539 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
5540 ;; so that its address is reloaded.
5542 (define_expand "extv"
5543 [(set (match_operand:SI 0 "register_operand" "")
5544 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
5545 (match_operand:SI 2 "const_int_operand" "")
5546 (match_operand:SI 3 "const_int_operand" "")))]
5547 "TARGET_68020 && TARGET_BITFIELD"
5550 (define_insn "*extv_bfexts_mem"
5551 [(set (match_operand:SI 0 "register_operand" "=d")
5552 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
5553 (match_operand:SI 2 "nonmemory_operand" "dn")
5554 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5555 "TARGET_68020 && TARGET_BITFIELD"
5556 "bfexts %1{%b3:%b2},%0")
5558 (define_expand "extzv"
5559 [(set (match_operand:SI 0 "register_operand" "")
5560 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
5561 (match_operand:SI 2 "const_int_operand" "")
5562 (match_operand:SI 3 "const_int_operand" "")))]
5563 "TARGET_68020 && TARGET_BITFIELD"
5566 (define_insn "*extzv_bfextu_mem"
5567 [(set (match_operand:SI 0 "register_operand" "=d")
5568 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o")
5569 (match_operand:SI 2 "nonmemory_operand" "dn")
5570 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5571 "TARGET_68020 && TARGET_BITFIELD"
5573 if (GET_CODE (operands[2]) == CONST_INT)
5575 if (INTVAL (operands[2]) != 32)
5576 cc_status.flags |= CC_NOT_NEGATIVE;
5582 return "bfextu %1{%b3:%b2},%0";
5585 (define_insn "*insv_bfchg_mem"
5586 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5587 (match_operand:SI 1 "nonmemory_operand" "dn")
5588 (match_operand:SI 2 "nonmemory_operand" "dn"))
5589 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
5590 (match_operand 3 "const_int_operand" "n")))]
5591 "TARGET_68020 && TARGET_BITFIELD
5592 && (INTVAL (operands[3]) == -1
5593 || (GET_CODE (operands[1]) == CONST_INT
5594 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
5597 return "bfchg %0{%b2:%b1}";
5600 (define_insn "*insv_bfclr_mem"
5601 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5602 (match_operand:SI 1 "nonmemory_operand" "dn")
5603 (match_operand:SI 2 "nonmemory_operand" "dn"))
5605 "TARGET_68020 && TARGET_BITFIELD"
5608 return "bfclr %0{%b2:%b1}";
5611 (define_insn "*insv_bfset_mem"
5612 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5613 (match_operand:SI 1 "general_operand" "dn")
5614 (match_operand:SI 2 "general_operand" "dn"))
5616 "TARGET_68020 && TARGET_BITFIELD"
5619 return "bfset %0{%b2:%b1}";
5622 (define_expand "insv"
5623 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5624 (match_operand:SI 1 "const_int_operand" "")
5625 (match_operand:SI 2 "const_int_operand" ""))
5626 (match_operand:SI 3 "reg_or_pow2_m1_operand" ""))]
5627 "TARGET_68020 && TARGET_BITFIELD"
5630 /* Special case initializing a field to all ones. */
5631 if (GET_CODE (operands[3]) == CONST_INT)
5633 if (exact_log2 (INTVAL (operands[3]) + 1) != INTVAL (operands[1]))
5634 operands[3] = force_reg (SImode, operands[3]);
5636 operands[3] = constm1_rtx;
5641 (define_insn "*insv_bfins_mem"
5642 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5643 (match_operand:SI 1 "nonmemory_operand" "dn")
5644 (match_operand:SI 2 "nonmemory_operand" "dn"))
5645 (match_operand:SI 3 "register_operand" "d"))]
5646 "TARGET_68020 && TARGET_BITFIELD"
5647 "bfins %3,%0{%b2:%b1}")
5649 ;; Now recognize bit-field insns that operate on registers
5650 ;; (or at least were intended to do so).
5652 (define_insn "*extv_bfexts_reg"
5653 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5654 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5655 (match_operand:SI 2 "const_int_operand" "n")
5656 (match_operand:SI 3 "const_int_operand" "n")))]
5657 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[3]), 0, 31)"
5658 "bfexts %1{%b3:%b2},%0")
5660 (define_insn "*extv_bfextu_reg"
5661 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5662 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5663 (match_operand:SI 2 "const_int_operand" "n")
5664 (match_operand:SI 3 "const_int_operand" "n")))]
5665 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[3]), 0, 31)"
5667 if (GET_CODE (operands[2]) == CONST_INT)
5669 if (INTVAL (operands[2]) != 32)
5670 cc_status.flags |= CC_NOT_NEGATIVE;
5676 return "bfextu %1{%b3:%b2},%0";
5679 (define_insn "*insv_bfclr_reg"
5680 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5681 (match_operand:SI 1 "const_int_operand" "n")
5682 (match_operand:SI 2 "const_int_operand" "n"))
5684 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[2]), 0, 31)"
5687 return "bfclr %0{%b2:%b1}";
5690 (define_insn "*insv_bfset_reg"
5691 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5692 (match_operand:SI 1 "const_int_operand" "n")
5693 (match_operand:SI 2 "const_int_operand" "n"))
5695 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[2]), 0, 31)"
5698 return "bfset %0{%b2:%b1}";
5701 (define_insn "*insv_bfins_reg"
5702 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5703 (match_operand:SI 1 "const_int_operand" "n")
5704 (match_operand:SI 2 "const_int_operand" "n"))
5705 (match_operand:SI 3 "register_operand" "d"))]
5706 "TARGET_68020 && TARGET_BITFIELD && IN_RANGE (INTVAL (operands[2]), 0, 31)"
5709 /* These special cases are now recognized by a specific pattern. */
5710 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5711 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5712 return "move%.w %3,%0";
5713 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5714 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5715 return "move%.b %3,%0";
5717 return "bfins %3,%0{%b2:%b1}";
5720 ;; Special patterns for optimizing bit-field instructions.
5722 (define_insn "*tst_bftst_mem"
5724 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5725 (match_operand:SI 1 "const_int_operand" "n")
5726 (match_operand:SI 2 "general_operand" "dn"))
5728 "TARGET_68020 && TARGET_BITFIELD"
5730 if (operands[1] == const1_rtx
5731 && GET_CODE (operands[2]) == CONST_INT)
5733 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5734 return output_btst (operands,
5735 GEN_INT (width - INTVAL (operands[2])),
5736 operands[0], insn, 1000);
5737 /* Pass 1000 as SIGNPOS argument so that btst will
5738 not think we are testing the sign bit for an `and'
5739 and assume that nonzero implies a negative result. */
5741 if (INTVAL (operands[1]) != 32)
5742 cc_status.flags = CC_NOT_NEGATIVE;
5743 return "bftst %0{%b2:%b1}";
5747 ;;; now handle the register cases
5748 (define_insn "*tst_bftst_reg"
5750 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5751 (match_operand:SI 1 "const_int_operand" "n")
5752 (match_operand:SI 2 "general_operand" "dn"))
5754 "TARGET_68020 && TARGET_BITFIELD
5755 && !(CONST_INT_P (operands[2]) && !IN_RANGE (INTVAL (operands[2]), 0, 31))"
5757 if (operands[1] == const1_rtx
5758 && GET_CODE (operands[2]) == CONST_INT)
5760 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5761 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5762 operands[0], insn, 1000);
5763 /* Pass 1000 as SIGNPOS argument so that btst will
5764 not think we are testing the sign bit for an `and'
5765 and assume that nonzero implies a negative result. */
5767 if (INTVAL (operands[1]) != 32)
5768 cc_status.flags = CC_NOT_NEGATIVE;
5769 return "bftst %0{%b2:%b1}";
5772 (define_insn "scc0_di"
5773 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5774 (match_operator 1 "ordered_comparison_operator"
5775 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5778 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5781 (define_insn "scc0_di_5200"
5782 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5783 (match_operator 1 "ordered_comparison_operator"
5784 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5787 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5790 (define_insn "scc_di"
5791 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5792 (match_operator 1 "ordered_comparison_operator"
5793 [(match_operand:DI 2 "general_operand" "ro,r")
5794 (match_operand:DI 3 "general_operand" "r,ro")]))]
5797 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5800 (define_insn "scc_di_5200"
5801 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5802 (match_operator 1 "ordered_comparison_operator"
5803 [(match_operand:DI 2 "general_operand" "ro,r")
5804 (match_operand:DI 3 "general_operand" "r,ro")]))]
5807 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5810 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5811 ;; memory, but we cannot allow it to be in memory in case the address
5812 ;; needs to be reloaded.
5815 [(set (match_operand:QI 0 "register_operand" "=d")
5816 (eq:QI (cc0) (const_int 0)))]
5819 cc_status = cc_prev_status;
5820 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5824 [(set (match_operand:QI 0 "register_operand" "=d")
5825 (ne:QI (cc0) (const_int 0)))]
5828 cc_status = cc_prev_status;
5829 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5833 [(set (match_operand:QI 0 "register_operand" "=d")
5834 (gt:QI (cc0) (const_int 0)))]
5837 cc_status = cc_prev_status;
5838 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5842 [(set (match_operand:QI 0 "register_operand" "=d")
5843 (gtu:QI (cc0) (const_int 0)))]
5846 cc_status = cc_prev_status;
5851 [(set (match_operand:QI 0 "register_operand" "=d")
5852 (lt:QI (cc0) (const_int 0)))]
5855 cc_status = cc_prev_status;
5856 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5860 [(set (match_operand:QI 0 "register_operand" "=d")
5861 (ltu:QI (cc0) (const_int 0)))]
5864 cc_status = cc_prev_status;
5869 [(set (match_operand:QI 0 "register_operand" "=d")
5870 (ge:QI (cc0) (const_int 0)))]
5873 cc_status = cc_prev_status;
5874 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5878 [(set (match_operand:QI 0 "register_operand" "=d")
5879 (geu:QI (cc0) (const_int 0)))]
5882 cc_status = cc_prev_status;
5885 [(set_attr "type" "scc")])
5888 [(set (match_operand:QI 0 "register_operand" "=d")
5889 (le:QI (cc0) (const_int 0)))]
5892 cc_status = cc_prev_status;
5893 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5897 [(set (match_operand:QI 0 "register_operand" "=d")
5898 (leu:QI (cc0) (const_int 0)))]
5901 cc_status = cc_prev_status;
5904 [(set_attr "type" "scc")])
5906 (define_insn "*sordered_1"
5907 [(set (match_operand:QI 0 "register_operand" "=d")
5908 (ordered:QI (cc0) (const_int 0)))]
5909 "TARGET_68881 && !TUNE_68060"
5911 cc_status = cc_prev_status;
5915 (define_insn "*sunordered_1"
5916 [(set (match_operand:QI 0 "register_operand" "=d")
5917 (unordered:QI (cc0) (const_int 0)))]
5918 "TARGET_68881 && !TUNE_68060"
5920 cc_status = cc_prev_status;
5924 (define_insn "*suneq_1"
5925 [(set (match_operand:QI 0 "register_operand" "=d")
5926 (uneq:QI (cc0) (const_int 0)))]
5927 "TARGET_68881 && !TUNE_68060"
5929 cc_status = cc_prev_status;
5933 (define_insn "*sunge_1"
5934 [(set (match_operand:QI 0 "register_operand" "=d")
5935 (unge:QI (cc0) (const_int 0)))]
5936 "TARGET_68881 && !TUNE_68060"
5938 cc_status = cc_prev_status;
5942 (define_insn "*sungt_1"
5943 [(set (match_operand:QI 0 "register_operand" "=d")
5944 (ungt:QI (cc0) (const_int 0)))]
5945 "TARGET_68881 && !TUNE_68060"
5947 cc_status = cc_prev_status;
5951 (define_insn "*sunle_1"
5952 [(set (match_operand:QI 0 "register_operand" "=d")
5953 (unle:QI (cc0) (const_int 0)))]
5954 "TARGET_68881 && !TUNE_68060"
5956 cc_status = cc_prev_status;
5960 (define_insn "*sunlt_1"
5961 [(set (match_operand:QI 0 "register_operand" "=d")
5962 (unlt:QI (cc0) (const_int 0)))]
5963 "TARGET_68881 && !TUNE_68060"
5965 cc_status = cc_prev_status;
5969 (define_insn "*sltgt_1"
5970 [(set (match_operand:QI 0 "register_operand" "=d")
5971 (ltgt:QI (cc0) (const_int 0)))]
5972 "TARGET_68881 && !TUNE_68060"
5974 cc_status = cc_prev_status;
5978 (define_insn "*fsogt_1"
5979 [(set (match_operand:QI 0 "register_operand" "=d")
5980 (not:QI (unle:QI (cc0) (const_int 0))))]
5981 "TARGET_68881 && !TUNE_68060"
5983 cc_status = cc_prev_status;
5987 (define_insn "*fsoge_1"
5988 [(set (match_operand:QI 0 "register_operand" "=d")
5989 (not:QI (unlt:QI (cc0) (const_int 0))))]
5990 "TARGET_68881 && !TUNE_68060"
5992 cc_status = cc_prev_status;
5996 (define_insn "*fsolt_1"
5997 [(set (match_operand:QI 0 "register_operand" "=d")
5998 (not:QI (unge:QI (cc0) (const_int 0))))]
5999 "TARGET_68881 && !TUNE_68060"
6001 cc_status = cc_prev_status;
6005 (define_insn "*fsole_1"
6006 [(set (match_operand:QI 0 "register_operand" "=d")
6007 (not:QI (ungt:QI (cc0) (const_int 0))))]
6008 "TARGET_68881 && !TUNE_68060"
6010 cc_status = cc_prev_status;
6014 ;; Basic conditional jump instructions.
6016 (define_insn "beq0_di"
6018 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*a,o,<>")
6020 (label_ref (match_operand 1 "" ",,"))
6022 (clobber (match_scratch:SI 2 "=d,&d,d"))]
6026 if (which_alternative == 2)
6027 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
6028 if ((cc_prev_status.value1
6029 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6030 || (cc_prev_status.value2
6031 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6033 cc_status = cc_prev_status;
6036 if (GET_CODE (operands[0]) == REG)
6037 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6039 operands[3] = adjust_address (operands[0], SImode, 4);
6040 if (! ADDRESS_REG_P (operands[0]))
6042 if (reg_overlap_mentioned_p (operands[2], operands[0]))
6044 if (reg_overlap_mentioned_p (operands[2], operands[3]))
6045 return "or%.l %0,%2\;jeq %l1";
6047 return "or%.l %3,%2\;jeq %l1";
6049 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
6051 operands[4] = gen_label_rtx();
6052 if (TARGET_68020 || TARGET_COLDFIRE)
6053 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
6055 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
6056 (*targetm.asm_out.internal_label) (asm_out_file, "L",
6057 CODE_LABEL_NUMBER (operands[4]));
6061 (define_insn "bne0_di"
6063 (if_then_else (ne (match_operand:DI 0 "general_operand" "d,o,*a")
6065 (label_ref (match_operand 1 "" ",,"))
6067 (clobber (match_scratch:SI 2 "=d,&d,X"))]
6070 if ((cc_prev_status.value1
6071 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6072 || (cc_prev_status.value2
6073 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6075 cc_status = cc_prev_status;
6079 if (GET_CODE (operands[0]) == REG)
6080 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6082 operands[3] = adjust_address (operands[0], SImode, 4);
6083 if (!ADDRESS_REG_P (operands[0]))
6085 if (reg_overlap_mentioned_p (operands[2], operands[0]))
6087 if (reg_overlap_mentioned_p (operands[2], operands[3]))
6088 return "or%.l %0,%2\;jne %l1";
6090 return "or%.l %3,%2\;jne %l1";
6092 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
6094 if (TARGET_68020 || TARGET_COLDFIRE)
6095 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
6097 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
6100 (define_insn "bge0_di"
6102 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
6104 (label_ref (match_operand 1 "" ""))
6108 if ((cc_prev_status.value1
6109 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6110 || (cc_prev_status.value2
6111 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6113 cc_status = cc_prev_status;
6114 return cc_status.flags & CC_REVERSED ? "jle %l1" : "jpl %l1";
6117 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6118 output_asm_insn("tst%.l %0", operands);
6121 /* On an address reg, cmpw may replace cmpl. */
6122 output_asm_insn("cmp%.w #0,%0", operands);
6127 (define_insn "blt0_di"
6129 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
6131 (label_ref (match_operand 1 "" ""))
6135 if ((cc_prev_status.value1
6136 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6137 || (cc_prev_status.value2
6138 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6140 cc_status = cc_prev_status;
6141 return cc_status.flags & CC_REVERSED ? "jgt %l1" : "jmi %l1";
6144 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6145 output_asm_insn("tst%.l %0", operands);
6148 /* On an address reg, cmpw may replace cmpl. */
6149 output_asm_insn("cmp%.w #0,%0", operands);
6156 (if_then_else (eq (cc0)
6158 (label_ref (match_operand 0 "" ""))
6162 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6164 [(set_attr "type" "bcc")])
6168 (if_then_else (ne (cc0)
6170 (label_ref (match_operand 0 "" ""))
6174 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6176 [(set_attr "type" "bcc")])
6180 (if_then_else (gt (cc0)
6182 (label_ref (match_operand 0 "" ""))
6186 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6188 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6192 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
6194 [(set_attr "type" "bcc")])
6198 (if_then_else (gtu (cc0)
6200 (label_ref (match_operand 0 "" ""))
6204 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6206 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6212 [(set_attr "type" "bcc")])
6216 (if_then_else (lt (cc0)
6218 (label_ref (match_operand 0 "" ""))
6222 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6224 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6228 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
6230 [(set_attr "type" "bcc")])
6234 (if_then_else (ltu (cc0)
6236 (label_ref (match_operand 0 "" ""))
6240 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6242 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6248 [(set_attr "type" "bcc")])
6252 (if_then_else (ge (cc0)
6254 (label_ref (match_operand 0 "" ""))
6258 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6260 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6264 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
6269 (if_then_else (geu (cc0)
6271 (label_ref (match_operand 0 "" ""))
6275 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6277 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6283 [(set_attr "type" "bcc")])
6287 (if_then_else (le (cc0)
6289 (label_ref (match_operand 0 "" ""))
6293 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6295 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6299 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
6301 [(set_attr "type" "bcc")])
6305 (if_then_else (leu (cc0)
6307 (label_ref (match_operand 0 "" ""))
6311 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6313 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6319 [(set_attr "type" "bcc")])
6321 (define_insn "bordered"
6323 (if_then_else (ordered (cc0) (const_int 0))
6324 (label_ref (match_operand 0 "" ""))
6328 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6331 [(set_attr "type" "fbcc")])
6333 (define_insn "bunordered"
6335 (if_then_else (unordered (cc0) (const_int 0))
6336 (label_ref (match_operand 0 "" ""))
6340 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6343 [(set_attr "type" "fbcc")])
6345 (define_insn "buneq"
6347 (if_then_else (uneq (cc0) (const_int 0))
6348 (label_ref (match_operand 0 "" ""))
6352 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6355 [(set_attr "type" "fbcc")])
6357 (define_insn "bunge"
6359 (if_then_else (unge (cc0) (const_int 0))
6360 (label_ref (match_operand 0 "" ""))
6364 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6367 [(set_attr "type" "fbcc")])
6369 (define_insn "bungt"
6371 (if_then_else (ungt (cc0) (const_int 0))
6372 (label_ref (match_operand 0 "" ""))
6376 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6379 [(set_attr "type" "fbcc")])
6381 (define_insn "bunle"
6383 (if_then_else (unle (cc0) (const_int 0))
6384 (label_ref (match_operand 0 "" ""))
6388 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6391 [(set_attr "type" "fbcc")])
6393 (define_insn "bunlt"
6395 (if_then_else (unlt (cc0) (const_int 0))
6396 (label_ref (match_operand 0 "" ""))
6400 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6403 [(set_attr "type" "fbcc")])
6405 (define_insn "bltgt"
6407 (if_then_else (ltgt (cc0) (const_int 0))
6408 (label_ref (match_operand 0 "" ""))
6412 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6415 [(set_attr "type" "fbcc")])
6417 ;; Negated conditional jump instructions.
6419 (define_insn "*beq_rev"
6421 (if_then_else (eq (cc0)
6424 (label_ref (match_operand 0 "" ""))))]
6427 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6429 [(set_attr "type" "bcc")])
6431 (define_insn "*bne_rev"
6433 (if_then_else (ne (cc0)
6436 (label_ref (match_operand 0 "" ""))))]
6439 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6441 [(set_attr "type" "bcc")])
6443 (define_insn "*bgt_rev"
6445 (if_then_else (gt (cc0)
6448 (label_ref (match_operand 0 "" ""))))]
6451 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6453 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6457 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6459 [(set_attr "type" "bcc")])
6461 (define_insn "*bgtu_rev"
6463 (if_then_else (gtu (cc0)
6466 (label_ref (match_operand 0 "" ""))))]
6469 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6471 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6477 [(set_attr "type" "bcc")])
6479 (define_insn "*blt_rev"
6481 (if_then_else (lt (cc0)
6484 (label_ref (match_operand 0 "" ""))))]
6487 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6489 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6493 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6495 [(set_attr "type" "bcc")])
6497 (define_insn "*bltu_rev"
6499 (if_then_else (ltu (cc0)
6502 (label_ref (match_operand 0 "" ""))))]
6505 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6507 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6513 [(set_attr "type" "bcc")])
6515 (define_insn "*bge_rev"
6517 (if_then_else (ge (cc0)
6520 (label_ref (match_operand 0 "" ""))))]
6523 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6525 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6529 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6531 [(set_attr "type" "bcc")])
6533 (define_insn "*bgeu_rev"
6535 (if_then_else (geu (cc0)
6538 (label_ref (match_operand 0 "" ""))))]
6541 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6543 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6549 [(set_attr "type" "bcc")])
6551 (define_insn "*ble_rev"
6553 (if_then_else (le (cc0)
6556 (label_ref (match_operand 0 "" ""))))]
6559 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6561 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6565 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6567 [(set_attr "type" "bcc")])
6569 (define_insn "*bleu_rev"
6571 (if_then_else (leu (cc0)
6574 (label_ref (match_operand 0 "" ""))))]
6577 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6579 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6585 [(set_attr "type" "bcc")])
6587 (define_insn "*bordered_rev"
6589 (if_then_else (ordered (cc0) (const_int 0))
6591 (label_ref (match_operand 0 "" ""))))]
6594 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6597 [(set_attr "type" "fbcc")])
6599 (define_insn "*bunordered_rev"
6601 (if_then_else (unordered (cc0) (const_int 0))
6603 (label_ref (match_operand 0 "" ""))))]
6606 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6609 [(set_attr "type" "fbcc")])
6611 (define_insn "*buneq_rev"
6613 (if_then_else (uneq (cc0) (const_int 0))
6615 (label_ref (match_operand 0 "" ""))))]
6618 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6621 [(set_attr "type" "fbcc")])
6623 (define_insn "*bunge_rev"
6625 (if_then_else (unge (cc0) (const_int 0))
6627 (label_ref (match_operand 0 "" ""))))]
6630 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6633 [(set_attr "type" "fbcc")])
6635 (define_insn "*bungt_rev"
6637 (if_then_else (ungt (cc0) (const_int 0))
6639 (label_ref (match_operand 0 "" ""))))]
6642 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6645 [(set_attr "type" "fbcc")])
6647 (define_insn "*bunle_rev"
6649 (if_then_else (unle (cc0) (const_int 0))
6651 (label_ref (match_operand 0 "" ""))))]
6654 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6657 [(set_attr "type" "fbcc")])
6659 (define_insn "*bunlt_rev"
6661 (if_then_else (unlt (cc0) (const_int 0))
6663 (label_ref (match_operand 0 "" ""))))]
6666 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6669 [(set_attr "type" "fbcc")])
6671 (define_insn "*bltgt_rev"
6673 (if_then_else (ltgt (cc0) (const_int 0))
6675 (label_ref (match_operand 0 "" ""))))]
6678 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6681 [(set_attr "type" "fbcc")])
6683 ;; Unconditional and other jump instructions
6686 (label_ref (match_operand 0 "" "")))]
6689 [(set_attr "type" "bra")])
6691 (define_expand "tablejump"
6692 [(parallel [(set (pc) (match_operand 0 "" ""))
6693 (use (label_ref (match_operand 1 "" "")))])]
6696 #if CASE_VECTOR_PC_RELATIVE
6697 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6698 TARGET_LONG_JUMP_TABLE_OFFSETS
6700 : gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6704 ;; Jump to variable address from dispatch table of absolute addresses.
6705 (define_insn "*tablejump_internal"
6706 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6707 (use (label_ref (match_operand 1 "" "")))]
6710 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6712 [(set_attr "type" "jmp")])
6714 ;; Jump to variable address from dispatch table of relative addresses.
6715 (define_insn "*tablejump_pcrel_si"
6718 (match_operand:SI 0 "register_operand" "r")))
6719 (use (label_ref (match_operand 1 "" "")))]
6720 "TARGET_LONG_JUMP_TABLE_OFFSETS"
6722 #ifdef ASM_RETURN_CASE_JUMP
6723 ASM_RETURN_CASE_JUMP;
6725 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6729 (define_insn "*tablejump_pcrel_hi"
6732 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6733 (use (label_ref (match_operand 1 "" "")))]
6734 "!TARGET_LONG_JUMP_TABLE_OFFSETS"
6736 #ifdef ASM_RETURN_CASE_JUMP
6737 ASM_RETURN_CASE_JUMP;
6739 if (TARGET_COLDFIRE)
6741 if (ADDRESS_REG_P (operands[0]))
6742 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6744 return "ext%.l %0\;jmp (2,pc,%0.l)";
6746 return "extl %0\;jmp pc@(2,%0:l)";
6749 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6753 ;; Decrement-and-branch insns.
6754 (define_insn "*dbne_hi"
6757 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6759 (label_ref (match_operand 1 "" ""))
6762 (plus:HI (match_dup 0)
6767 if (DATA_REG_P (operands[0]))
6768 return "dbra %0,%l1";
6769 if (GET_CODE (operands[0]) == MEM)
6770 return "subq%.w #1,%0\;jcc %l1";
6771 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6774 (define_insn "*dbne_si"
6777 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6779 (label_ref (match_operand 1 "" ""))
6782 (plus:SI (match_dup 0)
6787 if (DATA_REG_P (operands[0]))
6788 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6789 if (GET_CODE (operands[0]) == MEM)
6790 return "subq%.l #1,%0\;jcc %l1";
6791 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6794 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6796 (define_insn "*dbge_hi"
6799 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6802 (label_ref (match_operand 1 "" ""))
6805 (plus:HI (match_dup 0)
6807 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6810 if (DATA_REG_P (operands[0]))
6811 return "dbra %0,%l1";
6812 if (GET_CODE (operands[0]) == MEM)
6813 return "subq%.w #1,%0\;jcc %l1";
6814 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6817 (define_expand "decrement_and_branch_until_zero"
6818 [(parallel [(set (pc)
6820 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6823 (label_ref (match_operand 1 "" ""))
6826 (plus:SI (match_dup 0)
6831 (define_insn "*dbge_si"
6834 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6837 (label_ref (match_operand 1 "" ""))
6840 (plus:SI (match_dup 0)
6842 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6845 if (DATA_REG_P (operands[0]))
6846 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6847 if (GET_CODE (operands[0]) == MEM)
6848 return "subq%.l #1,%0\;jcc %l1";
6849 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6852 (define_expand "sibcall"
6853 [(call (match_operand:QI 0 "memory_operand" "")
6854 (match_operand:SI 1 "general_operand" ""))]
6857 operands[0] = m68k_legitimize_sibcall_address (operands[0]);
6860 (define_insn "*sibcall"
6861 [(call (mem:QI (match_operand:SI 0 "sibcall_operand" ""))
6862 (match_operand:SI 1 "general_operand" ""))]
6863 "SIBLING_CALL_P (insn)"
6865 return output_sibcall (operands[0]);
6868 (define_expand "sibcall_value"
6869 [(set (match_operand 0 "" "")
6870 (call (match_operand:QI 1 "memory_operand" "")
6871 (match_operand:SI 2 "general_operand" "")))]
6874 operands[1] = m68k_legitimize_sibcall_address (operands[1]);
6877 (define_insn "*sibcall_value"
6878 [(set (match_operand 0 "" "=rf,rf")
6879 (call (mem:QI (match_operand:SI 1 "sibcall_operand" ""))
6880 (match_operand:SI 2 "general_operand" "")))]
6881 "SIBLING_CALL_P (insn)"
6883 operands[0] = operands[1];
6884 return output_sibcall (operands[0]);
6887 ;; Call subroutine with no return value.
6888 (define_expand "call"
6889 [(call (match_operand:QI 0 "memory_operand" "")
6890 (match_operand:SI 1 "general_operand" ""))]
6891 ;; Operand 1 not really used on the m68000.
6894 operands[0] = m68k_legitimize_call_address (operands[0]);
6897 (define_insn "*call"
6898 [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
6899 (match_operand:SI 1 "general_operand" "g,g"))]
6900 ;; Operand 1 not really used on the m68000.
6901 "!SIBLING_CALL_P (insn)"
6903 return output_call (operands[0]);
6905 [(set_attr "type" "jsr")])
6907 ;; Call subroutine, returning value in operand 0
6908 ;; (which must be a hard register).
6909 (define_expand "call_value"
6910 [(set (match_operand 0 "" "")
6911 (call (match_operand:QI 1 "memory_operand" "")
6912 (match_operand:SI 2 "general_operand" "")))]
6913 ;; Operand 2 not really used on the m68000.
6916 operands[1] = m68k_legitimize_call_address (operands[1]);
6919 (define_insn "*non_symbolic_call_value"
6920 [(set (match_operand 0 "" "=rf,rf")
6921 (call (mem:QI (match_operand:SI 1 "non_symbolic_call_operand" "a,W"))
6922 (match_operand:SI 2 "general_operand" "g,g")))]
6923 ;; Operand 2 not really used on the m68000.
6924 "!SIBLING_CALL_P (insn)"
6926 [(set_attr "type" "jsr")
6927 (set_attr "opx" "1")])
6929 (define_insn "*symbolic_call_value_jsr"
6930 [(set (match_operand 0 "" "=rf,rf")
6931 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6932 (match_operand:SI 2 "general_operand" "g,g")))]
6933 ;; Operand 2 not really used on the m68000.
6934 "!SIBLING_CALL_P (insn) && m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_JSR"
6936 operands[0] = operands[1];
6937 return m68k_symbolic_call;
6939 [(set_attr "type" "jsr")
6940 (set_attr "opx" "1")])
6942 (define_insn "*symbolic_call_value_bsr"
6943 [(set (match_operand 0 "" "=rf,rf")
6944 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6945 (match_operand:SI 2 "general_operand" "g,g")))]
6946 ;; Operand 2 not really used on the m68000.
6947 "!SIBLING_CALL_P (insn)
6948 && (m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_C
6949 || m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_P)"
6951 operands[0] = operands[1];
6952 return m68k_symbolic_call;
6954 [(set_attr "type" "bsr")
6955 (set_attr "opx" "1")])
6957 ;; Call subroutine returning any type.
6959 (define_expand "untyped_call"
6960 [(parallel [(call (match_operand 0 "" "")
6962 (match_operand 1 "" "")
6963 (match_operand 2 "" "")])]
6964 "NEEDS_UNTYPED_CALL"
6968 emit_call_insn (gen_call (operands[0], const0_rtx));
6970 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6972 rtx set = XVECEXP (operands[2], 0, i);
6973 emit_move_insn (SET_DEST (set), SET_SRC (set));
6976 /* The optimizer does not know that the call sets the function value
6977 registers we stored in the result block. We avoid problems by
6978 claiming that all hard registers are used and clobbered at this
6980 emit_insn (gen_blockage ());
6985 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6986 ;; all of memory. This blocks insns from being moved across this point.
6988 (define_insn "blockage"
6989 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6997 [(set_attr "type" "nop")])
6999 (define_expand "prologue"
7003 m68k_expand_prologue ();
7007 (define_expand "epilogue"
7011 m68k_expand_epilogue (false);
7015 (define_expand "sibcall_epilogue"
7019 m68k_expand_epilogue (true);
7023 ;; Used for frameless functions which save no regs and allocate no locals.
7024 (define_expand "return"
7026 "m68k_use_return_insn ()"
7029 (define_insn "*return"
7033 switch (m68k_get_function_kind (current_function_decl))
7035 case m68k_fk_interrupt_handler:
7038 case m68k_fk_interrupt_thread:
7042 if (crtl->args.pops_args)
7044 operands[0] = GEN_INT (crtl->args.pops_args);
7051 [(set_attr "type" "rts")])
7053 (define_insn "*m68k_store_multiple"
7054 [(match_parallel 0 "" [(match_operand 1 "")])]
7055 "m68k_movem_pattern_p (operands[0], NULL, 0, true)"
7057 return m68k_output_movem (operands, operands[0], 0, true);
7060 (define_insn "*m68k_store_multiple_automod"
7061 [(match_parallel 0 ""
7062 [(set (match_operand:SI 1 "register_operand" "=a")
7063 (plus:SI (match_operand:SI 2 "register_operand" "1")
7064 (match_operand:SI 3 "const_int_operand")))])]
7065 "m68k_movem_pattern_p (operands[0], operands[1], INTVAL (operands[3]), true)"
7067 return m68k_output_movem (operands, operands[0], INTVAL (operands[3]), true);
7070 (define_insn "*m68k_load_multiple"
7071 [(match_parallel 0 "" [(match_operand 1 "")])]
7072 "m68k_movem_pattern_p (operands[0], NULL, 0, false)"
7074 return m68k_output_movem (operands, operands[0], 0, false);
7077 (define_insn "*m68k_load_multiple_automod"
7078 [(match_parallel 0 ""
7079 [(set (match_operand:SI 1 "register_operand" "=a")
7080 (plus:SI (match_operand:SI 2 "register_operand" "1")
7081 (match_operand:SI 3 "const_int_operand")))])]
7082 "m68k_movem_pattern_p (operands[0], operands[1],
7083 INTVAL (operands[3]), false)"
7085 return m68k_output_movem (operands, operands[0],
7086 INTVAL (operands[3]), false);
7089 (define_expand "link"
7091 [(set (match_operand:SI 0 "register_operand")
7092 (plus:SI (reg:SI SP_REG) (const_int -4)))
7095 (set (reg:SI SP_REG)
7096 (plus:SI (reg:SI SP_REG)
7097 (match_operand:SI 1 "const_int_operand")))])]
7098 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7100 operands[2] = gen_frame_mem (SImode,
7101 plus_constant (Pmode, stack_pointer_rtx, -4));
7104 (define_insn "*link"
7105 [(set (match_operand:SI 0 "register_operand" "+r")
7106 (plus:SI (reg:SI SP_REG) (const_int -4)))
7107 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
7109 (set (reg:SI SP_REG)
7110 (plus:SI (reg:SI SP_REG)
7111 (match_operand:SI 1 "const_int_operand")))]
7112 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7114 operands[1] = GEN_INT (INTVAL (operands[1]) + 4);
7116 return "link %0,%1";
7117 else if (INTVAL (operands[1]) >= -0x8000)
7118 return "link.w %0,%1";
7120 return "link.l %0,%1";
7122 [(set_attr "type" "link")])
7124 (define_expand "unlink"
7126 [(set (match_operand:SI 0 "register_operand")
7128 (set (reg:SI SP_REG)
7129 (plus:SI (match_dup 0)
7133 operands[1] = gen_frame_mem (SImode, copy_rtx (operands[0]));
7136 (define_insn "*unlink"
7137 [(set (match_operand:SI 0 "register_operand" "+r")
7138 (mem:SI (match_dup 0)))
7139 (set (reg:SI SP_REG)
7140 (plus:SI (match_dup 0)
7144 [(set_attr "type" "unlk")])
7146 (define_insn "load_got"
7147 [(set (match_operand:SI 0 "register_operand" "=a")
7148 (unspec:SI [(const_int 0)] UNSPEC_GOT))]
7151 if (TARGET_ID_SHARED_LIBRARY)
7153 operands[1] = gen_rtx_REG (Pmode, PIC_REG);
7154 return MOTOROLA ? "move.l %?(%1),%0" : "movel %1@(%?), %0";
7158 if (TARGET_COLDFIRE)
7159 /* Load the full 32-bit PC-relative offset of
7160 _GLOBAL_OFFSET_TABLE_ into the PIC register, then use it to
7161 calculate the absolute value. The offset and "lea"
7162 operation word together occupy 6 bytes. */
7163 return ("move.l #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t"
7164 "lea (-6, %%pc, %0), %0");
7166 return "lea (%%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %0";
7169 return ("movel #_GLOBAL_OFFSET_TABLE_, %0\n\t"
7170 "lea %%pc@(0,%0:l),%0");
7173 (define_insn "indirect_jump"
7174 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
7177 [(set_attr "type" "jmp")])
7179 ;; This should not be used unless the add/sub insns can't be.
7182 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
7183 (match_operand:QI 1 "address_operand" "p"))]
7187 ;; This is the first machine-dependent peephole optimization.
7188 ;; It is useful when a floating value is returned from a function call
7189 ;; and then is moved into an FP register.
7190 ;; But it is mainly intended to test the support for these optimizations.
7193 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7194 (set (match_operand:DF 0 "register_operand" "")
7195 (match_operand:DF 1 "register_operand" ""))]
7196 "FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
7197 [(set (mem:SI (reg:SI SP_REG)) (match_dup 1))
7198 (set (mem:SI (pre_dec:SI (reg:SI SP_REG))) (match_dup 2))
7199 (set (match_dup 0) (mem:DF (post_inc:SI (reg:SI SP_REG))))]
7200 "split_di(operands + 1, 1, operands + 1, operands + 2);")
7202 ;; Optimize a stack-adjust followed by a push of an argument.
7203 ;; This is said to happen frequently with -msoft-float
7204 ;; when there are consecutive library calls.
7207 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7208 (set (match_operand:SF 0 "push_operand" "")
7209 (match_operand:SF 1 "general_operand" ""))]
7210 "!reg_mentioned_p (stack_pointer_rtx, operands[0])"
7211 [(set (match_dup 0) (match_dup 1))]
7212 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7215 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7216 (match_operand:SI 0 "const_int_operand" "")))
7217 (set (match_operand:SF 1 "push_operand" "")
7218 (match_operand:SF 2 "general_operand" ""))]
7219 "INTVAL (operands[0]) > 4
7220 && !reg_mentioned_p (stack_pointer_rtx, operands[2])"
7221 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7222 (set (match_dup 1) (match_dup 2))]
7224 operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7225 operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7228 ;; Speed up stack adjust followed by a fullword fixedpoint push.
7229 ;; Constant operands need special care, as replacing a "pea X.w" with
7230 ;; "move.l #X,(%sp)" is often not a win.
7232 ;; Already done by the previous csa pass, left as reference.
7234 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7235 (set (match_operand:SI 0 "push_operand" "")
7236 (match_operand:SI 1 "general_operand" ""))]
7237 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7238 [(set (match_dup 0) (match_dup 1))]
7239 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7241 ;; Try to use moveq, after stack push has been changed into a simple move.
7243 [(match_scratch:SI 2 "d")
7244 (set (match_operand:SI 0 "memory_operand" "")
7245 (match_operand:SI 1 "const_int_operand" ""))]
7246 "GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
7247 && INTVAL (operands[1]) != 0
7248 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7249 && !valid_mov3q_const (INTVAL (operands[1]))"
7250 [(set (match_dup 2) (match_dup 1))
7251 (set (match_dup 0) (match_dup 2))])
7253 ;; This sequence adds an instruction, but is two bytes shorter.
7255 [(match_scratch:SI 2 "d")
7256 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 12)))
7257 (set (match_operand:SI 0 "push_operand" "")
7258 (match_operand:SI 1 "const_int_operand" ""))]
7259 "INTVAL (operands[1]) != 0
7260 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7261 && !valid_mov3q_const (INTVAL (operands[1]))"
7262 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 8)))
7263 (set (match_dup 2) (match_dup 1))
7264 (set (match_dup 0) (match_dup 2))]
7265 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7267 ;; Changing pea X.w into a move.l is no real win here.
7269 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7270 (match_operand:SI 0 "const_int_operand" "")))
7271 (set (match_operand:SI 1 "push_operand" "")
7272 (match_operand:SI 2 "general_operand" ""))]
7273 "INTVAL (operands[0]) > 4
7274 && !reg_mentioned_p (stack_pointer_rtx, operands[2])
7275 && !(CONST_INT_P (operands[2]) && INTVAL (operands[2]) != 0
7276 && IN_RANGE (INTVAL (operands[2]), -0x8000, 0x7fff)
7277 && !valid_mov3q_const (INTVAL (operands[2])))"
7278 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7279 (set (match_dup 1) (match_dup 2))]
7281 operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7282 operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7285 ;; Speed up pushing a single byte/two bytes but leaving four bytes of space
7286 ;; (which differs slightly between m680x0 and ColdFire).
7289 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
7290 (set (match_operand:QI 0 "memory_operand" "")
7291 (match_operand:QI 1 "register_operand" ""))]
7292 "!reg_mentioned_p (stack_pointer_rtx, operands[1])
7293 && GET_CODE (XEXP (operands[0], 0)) == PLUS
7294 && rtx_equal_p (XEXP (XEXP (operands[0], 0), 0), stack_pointer_rtx)
7295 && CONST_INT_P (XEXP (XEXP (operands[0], 0), 1))
7296 && INTVAL (XEXP (XEXP (operands[0], 0), 1)) == 3"
7297 [(set (match_dup 0) (match_dup 1))]
7299 rtx addr = gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx);
7300 operands[0] = adjust_automodify_address (operands[0], SImode, addr, -3);
7301 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7305 [(set (match_operand:QI 0 "push_operand" "")
7306 (match_operand:QI 1 "register_operand" ""))
7307 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -3)))]
7308 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7309 [(set (match_dup 0) (match_dup 1))]
7311 operands[0] = adjust_automodify_address (operands[0], SImode,
7312 XEXP (operands[0], 0), -3);
7313 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7317 [(set (match_operand:HI 0 "push_operand" "")
7318 (match_operand:HI 1 "register_operand" ""))
7319 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))]
7320 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7321 [(set (match_dup 0) (match_dup 1))]
7323 operands[0] = adjust_automodify_address (operands[0], SImode,
7324 XEXP (operands[0], 0), -2);
7325 operands[1] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
7328 ;; Optimize a series of strict_low_part assignments
7331 [(set (match_operand:SI 0 "register_operand" "")
7333 (set (strict_low_part (match_operand:HI 1 "register_operand" ""))
7334 (match_operand:HI 2 "general_operand" ""))]
7335 "REGNO (operands[0]) == REGNO (operands[1])
7336 && strict_low_part_peephole_ok (HImode, insn, operands[0])"
7337 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7341 [(set (match_operand:SI 0 "register_operand" "")
7343 (set (strict_low_part (match_operand:QI 1 "register_operand" ""))
7344 (match_operand:QI 2 "general_operand" ""))]
7345 "REGNO (operands[0]) == REGNO (operands[1])
7346 && strict_low_part_peephole_ok (QImode, insn, operands[0])"
7347 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7355 ;; jCC label ; abnormal loop termination
7356 ;; dbra dN, loop ; normal loop termination
7364 ;; Which moves the jCC condition outside the inner loop for free.
7368 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7369 [(cc0) (const_int 0)])
7370 (label_ref (match_operand 2 "" ""))
7375 (ne (match_operand:HI 0 "register_operand" "")
7377 (label_ref (match_operand 1 "" ""))
7380 (plus:HI (match_dup 0)
7382 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7385 output_dbcc_and_branch (operands);
7390 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7391 [(cc0) (const_int 0)])
7392 (label_ref (match_operand 2 "" ""))
7397 (ne (match_operand:SI 0 "register_operand" "")
7399 (label_ref (match_operand 1 "" ""))
7402 (plus:SI (match_dup 0)
7404 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7407 output_dbcc_and_branch (operands);
7412 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7413 [(cc0) (const_int 0)])
7414 (label_ref (match_operand 2 "" ""))
7419 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
7422 (label_ref (match_operand 1 "" ""))
7425 (plus:HI (match_dup 0)
7427 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7430 output_dbcc_and_branch (operands);
7435 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7436 [(cc0) (const_int 0)])
7437 (label_ref (match_operand 2 "" ""))
7442 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
7445 (label_ref (match_operand 1 "" ""))
7448 (plus:SI (match_dup 0)
7450 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7453 output_dbcc_and_branch (operands);
7458 (define_insn "extendsfxf2"
7459 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7460 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
7463 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7465 if (REGNO (operands[0]) == REGNO (operands[1]))
7467 /* Extending float to double in an fp-reg is a no-op.
7468 NOTICE_UPDATE_CC has already assumed that the
7469 cc will be set. So cancel what it did. */
7470 cc_status = cc_prev_status;
7473 return "f%$move%.x %1,%0";
7475 if (FP_REG_P (operands[0]))
7477 if (FP_REG_P (operands[1]))
7478 return "f%$move%.x %1,%0";
7479 else if (ADDRESS_REG_P (operands[1]))
7480 return "move%.l %1,%-\;f%$move%.s %+,%0";
7481 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
7482 return output_move_const_single (operands);
7483 return "f%$move%.s %f1,%0";
7485 return "fmove%.x %f1,%0";
7489 (define_insn "extenddfxf2"
7490 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7492 (match_operand:DF 1 "general_operand" "f,rmE")))]
7495 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7497 if (REGNO (operands[0]) == REGNO (operands[1]))
7499 /* Extending float to double in an fp-reg is a no-op.
7500 NOTICE_UPDATE_CC has already assumed that the
7501 cc will be set. So cancel what it did. */
7502 cc_status = cc_prev_status;
7505 return "fmove%.x %1,%0";
7507 if (FP_REG_P (operands[0]))
7509 if (REG_P (operands[1]))
7512 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
7513 output_asm_insn ("move%.l %1,%-", xoperands);
7514 output_asm_insn ("move%.l %1,%-", operands);
7515 return "f%&move%.d %+,%0";
7517 if (GET_CODE (operands[1]) == CONST_DOUBLE)
7518 return output_move_const_double (operands);
7519 return "f%&move%.d %f1,%0";
7521 return "fmove%.x %f1,%0";
7524 (define_insn "truncxfdf2"
7525 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
7527 (match_operand:XF 1 "general_operand" "f,f")))]
7530 if (REG_P (operands[0]))
7532 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
7533 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
7534 return "move%.l %+,%0";
7536 return "fmove%.d %f1,%0";
7539 (define_insn "truncxfsf2"
7540 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
7542 (match_operand:XF 1 "general_operand" "f")))]
7546 (define_insn "sin<mode>2"
7547 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7549 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
7550 "TARGET_68881 && flag_unsafe_math_optimizations"
7552 if (FP_REG_P (operands[1]))
7553 return "fsin%.x %1,%0";
7555 return "fsin%.<FP:prec> %1,%0";
7558 (define_insn "cos<mode>2"
7559 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7561 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
7562 "TARGET_68881 && flag_unsafe_math_optimizations"
7564 if (FP_REG_P (operands[1]))
7565 return "fcos%.x %1,%0";
7567 return "fcos%.<FP:prec> %1,%0";
7570 ;; Unconditional traps are assumed to have (const_int 1) for the condition.
7572 [(trap_if (const_int 1) (const_int 7))]
7575 [(set_attr "type" "trap")])
7577 (define_expand "ctrapdi4"
7578 [(trap_if (match_operator 0 "ordered_comparison_operator"
7579 [(cc0) (const_int 0)])
7580 (match_operand:SI 3 "const1_operand" ""))]
7583 if (operands[2] == const0_rtx)
7584 emit_insn (gen_tstdi (operands[1]));
7586 emit_insn (gen_cmpdi (operands[1], operands[2]));
7587 operands[1] = cc0_rtx;
7588 operands[2] = const0_rtx;
7591 (define_expand "ctrapsi4"
7593 (compare (match_operand:SI 1 "nonimmediate_operand" "")
7594 (match_operand:SI 2 "general_operand" "")))
7595 (trap_if (match_operator 0 "ordered_comparison_operator"
7596 [(cc0) (const_int 0)])
7597 (match_operand:SI 3 "const1_operand" ""))]
7601 (define_expand "ctraphi4"
7603 (compare (match_operand:HI 1 "nonimmediate_src_operand" "")
7604 (match_operand:HI 2 "general_src_operand" "")))
7605 (trap_if (match_operator 0 "ordered_comparison_operator"
7606 [(cc0) (const_int 0)])
7607 (match_operand:SI 3 "const1_operand" ""))]
7611 (define_expand "ctrapqi4"
7613 (compare (match_operand:QI 1 "nonimmediate_src_operand" "")
7614 (match_operand:QI 2 "general_src_operand" "")))
7615 (trap_if (match_operator 0 "ordered_comparison_operator"
7616 [(cc0) (const_int 0)])
7617 (match_operand:SI 3 "const1_operand" ""))]
7621 (define_insn "*conditional_trap"
7622 [(trap_if (match_operator 0 "ordered_comparison_operator"
7623 [(cc0) (const_int 0)])
7624 (match_operand:SI 1 "const1_operand" "I"))]
7625 "TARGET_68020 && ! flags_in_68881 ()"
7627 switch (GET_CODE (operands[0]))
7629 case EQ: return "trapeq";
7630 case NE: return "trapne";
7631 case GT: return "trapgt";
7632 case GTU: return "traphi";
7633 case LT: return "traplt";
7634 case LTU: return "trapcs";
7635 case GE: return "trapge";
7636 case GEU: return "trapcc";
7637 case LE: return "traple";
7638 case LEU: return "trapls";
7639 default: gcc_unreachable ();
7643 ;; These are to prevent the scheduler from moving stores to the frame
7644 ;; before the stack adjustment.
7645 (define_insn "stack_tie"
7646 [(set (mem:BLK (scratch))
7647 (unspec:BLK [(match_operand:SI 0 "register_operand" "r")
7648 (match_operand:SI 1 "register_operand" "r")]
7652 [(set_attr "type" "ignore")])
7654 ;; Instruction that subscribes one word in ColdFire instruction buffer.
7655 ;; This instruction is used within scheduler only and should not appear
7656 ;; in the instruction stream.
7658 [(unspec [(const_int 0)] UNSPEC_IB)]
7661 [(set_attr "type" "ib")])
7668 ;; move.l 4(%a0),%a0
7669 ;; clr.b (%a0,%a1.l)
7676 ;; The latter is smaller. It is faster on all models except m68060.
7679 [(set (match_operand:SI 0 "register_operand" "")
7680 (mem:SI (plus:SI (match_operand:SI 1 "register_operand" "")
7681 (match_operand:SI 2 "const_int_operand" ""))))
7682 (set (mem:QI (plus:SI (match_operand:SI 3 "register_operand" "")
7683 (match_operand:SI 4 "register_operand" "")))
7685 "(optimize_size || !TUNE_68060)
7686 && (operands[0] == operands[3] || operands[0] == operands[4])
7687 && ADDRESS_REG_P (operands[1])
7688 && ADDRESS_REG_P ((operands[0] == operands[3]) ? operands[4] : operands[3])
7689 && peep2_reg_dead_p (2, operands[3])
7690 && peep2_reg_dead_p (2, operands[4])"
7692 (plus:SI (match_dup 5)
7693 (mem:SI (plus:SI (match_dup 1)
7695 (set (mem:QI (match_dup 5))
7697 "operands[5] = (operands[0] == operands[3]) ? operands[4] : operands[3];")
7705 ;; addq/subq -const,dY
7709 ;; dX and dY must both be dead at the end of the sequence and the constant
7710 ;; must be valid for addq/subq.
7712 ;; Essentially we're making it trivial for final to realize the comparison
7715 ;; Testing has shown a variant where the operands are reversed in the
7716 ;; comparison never hits, so I have not included that variant.
7720 [(set (match_operand:SI 0 "register_operand" "")
7721 (match_operand:SI 1 "addq_subq_operand" ""))
7722 (set (cc0) (compare (match_operand:SI 2 "register_operand" "")
7724 (set (pc) (if_then_else (match_operator 5 "equality_comparison_operator"
7725 [(cc0) (const_int 0)])
7726 (match_operand 3 "pc_or_label_operand")
7727 (match_operand 4 "pc_or_label_operand")))]
7728 "peep2_reg_dead_p (2, operands[0])
7729 && peep2_reg_dead_p (2, operands[2])
7730 && (operands[3] == pc_rtx || operands[4] == pc_rtx)
7731 && DATA_REG_P (operands[2])"
7732 [(set (match_dup 2) (plus:SI (match_dup 2) (match_dup 6)))
7733 (set (cc0) (compare (match_dup 2) (const_int 0)))
7734 (set (pc) (if_then_else (match_op_dup 5 [(cc0) (const_int 0)])
7737 "operands[6] = GEN_INT (-INTVAL (operands[1]));")
7740 [(set (match_operand:SI 0 "register_operand" "")
7741 (match_operand:SI 1 "pow2_m1_operand" ""))
7742 (set (cc0) (compare (match_operand:SI 2 "register_operand" "")
7743 (match_operand:SI 3 "register_operand" "")))
7744 (set (pc) (if_then_else (gtu (cc0) (const_int 0))
7745 (match_operand 4 "pc_or_label_operand")
7746 (match_operand 5 "pc_or_label_operand")))]
7747 "INTVAL (operands[1]) <= 255
7748 && operands[0] == operands[3]
7749 && peep2_reg_dead_p (2, operands[0])
7750 && peep2_reg_dead_p (2, operands[2])
7751 && (operands[4] == pc_rtx || operands[5] == pc_rtx)
7752 && (optimize_size || TUNE_68040_60)
7753 && DATA_REG_P (operands[2])"
7754 [(set (match_dup 7) (lshiftrt:SI (match_dup 7) (match_dup 6)))
7755 (set (cc0) (compare (match_dup 7) (const_int 0)))
7756 (set (pc) (if_then_else (ne (cc0) (const_int 0))
7757 (match_dup 4) (match_dup 5)))]
7760 operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
7761 operands[7] = operands[2];
7765 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
7766 (match_operand:SI 1 "pow2_m1_operand" "")))
7767 (set (pc) (if_then_else (gtu (cc0) (const_int 0))
7768 (match_operand 2 "pc_or_label_operand")
7769 (match_operand 3 "pc_or_label_operand")))]
7770 "INTVAL (operands[1]) <= 255
7771 && peep2_reg_dead_p (1, operands[0])
7772 && (operands[2] == pc_rtx || operands[3] == pc_rtx)
7773 && (optimize_size || TUNE_68040_60)
7774 && DATA_REG_P (operands[0])"
7775 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 4)))
7776 (set (cc0) (compare (match_dup 0) (const_int 0)))
7777 (set (pc) (if_then_else (ne (cc0) (const_int 0))
7778 (match_dup 2) (match_dup 3)))]
7779 "{ operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1)); }")
7782 [(set (match_operand:SI 0 "register_operand" "")
7783 (match_operand:SI 1 "pow2_m1_operand" ""))
7784 (set (cc0) (compare (match_operand:SI 2 "register_operand" "")
7785 (match_operand:SI 3 "register_operand" "")))
7786 (set (pc) (if_then_else (leu (cc0) (const_int 0))
7787 (match_operand 4 "pc_or_label_operand")
7788 (match_operand 5 "pc_or_label_operand")))]
7789 "INTVAL (operands[1]) <= 255
7790 && operands[0] == operands[3]
7791 && peep2_reg_dead_p (2, operands[0])
7792 && peep2_reg_dead_p (2, operands[2])
7793 && (operands[4] == pc_rtx || operands[5] == pc_rtx)
7794 && (optimize_size || TUNE_68040_60)
7795 && DATA_REG_P (operands[2])"
7796 [(set (match_dup 7) (lshiftrt:SI (match_dup 7) (match_dup 6)))
7797 (set (cc0) (compare (match_dup 7) (const_int 0)))
7798 (set (pc) (if_then_else (eq (cc0) (const_int 0))
7799 (match_dup 4) (match_dup 5)))]
7802 operands[6] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
7803 operands[7] = operands[2];
7806 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
7807 (match_operand:SI 1 "pow2_m1_operand" "")))
7808 (set (pc) (if_then_else (leu (cc0) (const_int 0))
7809 (match_operand 2 "pc_or_label_operand")
7810 (match_operand 3 "pc_or_label_operand")))]
7811 "INTVAL (operands[1]) <= 255
7812 && peep2_reg_dead_p (1, operands[0])
7813 && (operands[2] == pc_rtx || operands[3] == pc_rtx)
7814 && (optimize_size || TUNE_68040_60)
7815 && DATA_REG_P (operands[0])"
7816 [(set (match_dup 0) (lshiftrt:SI (match_dup 0) (match_dup 4)))
7817 (set (cc0) (compare (match_dup 0) (const_int 0)))
7818 (set (pc) (if_then_else (eq (cc0) (const_int 0))
7819 (match_dup 2) (match_dup 3)))]
7820 "{ operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1)); }")
7822 ;; When optimizing for size or for the original 68000 or 68010, we can
7823 ;; improve some relational tests against 65536 (which get canonicalized
7824 ;; internally against 65535).
7825 ;; The rotate in the output pattern will turn into a swap.
7827 [(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
7829 (set (pc) (if_then_else (match_operator 1 "swap_peephole_relational_operator"
7830 [(cc0) (const_int 0)])
7831 (match_operand 2 "pc_or_label_operand")
7832 (match_operand 3 "pc_or_label_operand")))]
7833 "peep2_reg_dead_p (1, operands[0])
7834 && (operands[2] == pc_rtx || operands[3] == pc_rtx)
7835 && (optimize_size || TUNE_68000_10)
7836 && DATA_REG_P (operands[0])"
7837 [(set (match_dup 0) (rotate:SI (match_dup 0) (const_int 16)))
7838 (set (cc0) (compare (subreg:HI (match_dup 0) 2) (const_int 0)))
7839 (set (pc) (if_then_else (match_op_dup 1 [(cc0) (const_int 0)])
7840 (match_dup 2) (match_dup 3)))]