1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987-2015 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")))
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"))
772 if (GET_CODE (operands[0]) == MEM)
774 operands[0] = adjust_address (operands[0], QImode,
775 INTVAL (operands[1]) / 8);
776 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
777 return output_btst (operands, operands[1], operands[0], insn, 7);
779 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
780 return output_btst (operands, operands[1], operands[0], insn, 31);
783 ;; This is the same as the above pattern except for the constraints.
784 ;; The 'o' has been replaced with 'Q'.
789 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "dQ")
791 (match_operand:SI 1 "const_int_operand" "n"))
795 if (GET_CODE (operands[0]) == MEM)
797 operands[0] = adjust_address (operands[0], QImode,
798 INTVAL (operands[1]) / 8);
799 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
800 return output_btst (operands, operands[1], operands[0], insn, 7);
802 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
803 return output_btst (operands, operands[1], operands[0], insn, 31);
809 ;; A special case in which it is not desirable
810 ;; to reload the constant into a data register.
811 (define_insn "pushexthisi_const"
812 [(set (match_operand:SI 0 "push_operand" "=m,m,m")
813 (match_operand:SI 1 "const_int_operand" "C0,R,J"))]
814 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
819 [(set_attr "type" "clr_l,mov3q_l,pea")])
822 ;(define_insn "swapsi"
823 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
824 ; (match_operand:SI 1 "general_operand" "+r"))
825 ; (set (match_dup 1) (match_dup 0))]
829 ;; Special case of fullword move when source is zero for 68000_10.
830 ;; moveq is faster on the 68000.
831 (define_insn "*movsi_const0_68000_10"
832 [(set (match_operand:SI 0 "movsi_const0_operand" "=d,a,g")
839 [(set_attr "type" "moveq_l,alu_l,clr_l")
840 (set_attr "opy" "*,0,*")])
842 ;; Special case of fullword move when source is zero for 68040_60.
843 ;; On the '040, 'subl an,an' takes 2 clocks while lea takes only 1
844 (define_insn "*movsi_const0_68040_60"
845 [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
849 if (which_alternative == 0)
850 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
851 else if (which_alternative == 1)
859 [(set_attr "type" "lea,clr_l")])
861 ;; Special case of fullword move when source is zero.
862 (define_insn "*movsi_const0"
863 [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
865 "!(TUNE_68000_10 || TUNE_68040_60)"
869 [(set_attr "type" "alu_l,clr_l")
870 (set_attr "opy" "0,*")])
872 ;; General case of fullword move.
874 ;; This is the main "hook" for PIC code. When generating
875 ;; PIC, movsi is responsible for determining when the source address
876 ;; needs PIC relocation and appropriately calling legitimize_pic_address
877 ;; to perform the actual relocation.
879 ;; In both the PIC and non-PIC cases the patterns generated will
880 ;; matched by the next define_insn.
881 (define_expand "movsi"
882 [(set (match_operand:SI 0 "" "")
883 (match_operand:SI 1 "" ""))]
886 rtx tmp, base, offset;
888 /* Recognize the case where operand[1] is a reference to thread-local
889 data and load its address to a register. */
890 if (!TARGET_PCREL && m68k_tls_reference_p (operands[1], false))
892 rtx tmp = operands[1];
895 if (GET_CODE (tmp) == CONST && GET_CODE (XEXP (tmp, 0)) == PLUS)
897 addend = XEXP (XEXP (tmp, 0), 1);
898 tmp = XEXP (XEXP (tmp, 0), 0);
901 gcc_assert (GET_CODE (tmp) == SYMBOL_REF);
902 gcc_assert (SYMBOL_REF_TLS_MODEL (tmp) != 0);
904 tmp = m68k_legitimize_tls_address (tmp);
912 reg = gen_reg_rtx (Pmode);
913 emit_move_insn (reg, tmp);
917 tmp = gen_rtx_PLUS (SImode, tmp, addend);
922 else if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
924 /* The source is an address which requires PIC relocation.
925 Call legitimize_pic_address with the source, mode, and a relocation
926 register (a new pseudo, or the final destination if reload_in_progress
927 is set). Then fall through normally */
928 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
929 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
931 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
933 /* Don't allow writes to memory except via a register;
934 the m68k doesn't consider PC-relative addresses to be writable. */
935 if (symbolic_operand (operands[0], SImode))
936 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
937 else if (GET_CODE (operands[0]) == MEM
938 && symbolic_operand (XEXP (operands[0], 0), SImode))
939 operands[0] = gen_rtx_MEM (SImode,
940 force_reg (SImode, XEXP (operands[0], 0)));
942 if (M68K_OFFSETS_MUST_BE_WITHIN_SECTIONS_P)
944 split_const (operands[1], &base, &offset);
945 if (GET_CODE (base) == SYMBOL_REF
946 && !offset_within_block_p (base, INTVAL (offset)))
948 tmp = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (SImode);
949 emit_move_insn (tmp, base);
950 emit_insn (gen_addsi3 (operands[0], tmp, offset));
956 ;; General case of fullword move.
957 (define_insn "*movsi_m68k"
958 ;; Notes: make sure no alternative allows g vs g.
959 ;; We don't allow f-regs since fixed point cannot go in them.
960 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
961 (match_operand:SI 1 "general_src_operand" "damSnT,n,i"))]
962 "!TARGET_COLDFIRE && reload_completed"
964 return output_move_simode (operands);
967 ;; Before reload is completed the register constraints
968 ;; force integer constants in range for a moveq to be reloaded
969 ;; if they are headed for memory.
970 (define_insn "*movsi_m68k2"
971 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
972 (match_operand:SI 1 "general_src_operand" "damSKT,n,i"))]
976 return output_move_simode (operands);
979 ;; ColdFire move instructions can have at most one operand of mode >= 6.
980 (define_insn "*movsi_cf"
981 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d, d, d, d, d, a,Ap, a, r<Q>,g, U")
982 (match_operand:SI 1 "general_operand" " R,CQ,CW,CZ,CS,Ci,J,J Cs,Cs, g, Rr<Q>,U"))]
985 switch (which_alternative)
988 return "mov3q%.l %1,%0";
991 return "moveq %1,%0";
995 unsigned u = INTVAL (operands[1]);
997 operands[1] = GEN_INT ((u << 16) | (u >> 16)); /*|*/
998 return "moveq %1,%0\n\tswap %0";
1002 return "mvz%.w %1,%0";
1005 return "mvs%.w %1,%0";
1008 return "move%.l %1,%0";
1011 return "move%.w %1,%0";
1017 return "lea %a1,%0";
1022 return "move%.l %1,%0";
1029 [(set_attr "type" "mov3q_l,moveq_l,*,mvsz,mvsz,move_l,move,pea,lea,move_l,move_l,move_l")])
1031 ;; Special case of fullword move, where we need to get a non-GOT PIC
1032 ;; reference into an address register.
1034 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
1035 (match_operand:SI 1 "pcrel_address" ""))]
1038 if (push_operand (operands[0], SImode))
1040 return "lea %a1,%0";
1043 (define_expand "movhi"
1044 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1045 (match_operand:HI 1 "general_operand" ""))]
1050 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
1051 (match_operand:HI 1 "general_src_operand" "gS"))]
1053 "* return output_move_himode (operands);")
1056 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
1057 (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
1059 "* return output_move_himode (operands);")
1061 (define_expand "movstricthi"
1062 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1063 (match_operand:HI 1 "general_src_operand" ""))]
1068 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
1069 (match_operand:HI 1 "general_src_operand" "rmSn"))]
1071 "* return output_move_stricthi (operands);")
1074 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
1075 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
1077 "* return output_move_stricthi (operands);")
1079 (define_expand "movqi"
1080 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1081 (match_operand:QI 1 "general_src_operand" ""))]
1086 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
1087 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
1089 "* return output_move_qimode (operands);")
1092 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
1093 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
1095 "* return output_move_qimode (operands);")
1097 (define_expand "movstrictqi"
1098 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1099 (match_operand:QI 1 "general_src_operand" ""))]
1104 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
1105 (match_operand:QI 1 "general_src_operand" "dmSn"))]
1107 "* return output_move_strictqi (operands);")
1109 (define_insn "*movstrictqi_cf"
1110 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d, Ac, d,m"))
1111 (match_operand:QI 1 "general_src_operand" "C0,C0, dmn,d"))]
1118 [(set_attr "type" "clr,clr,move,move")])
1120 (define_expand "pushqi1"
1121 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
1122 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
1123 (match_operand:QI 0 "general_operand" ""))]
1127 (define_expand "reload_insf"
1128 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1129 (match_operand:SF 1 "general_operand" "mf"))
1130 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1131 "TARGET_COLDFIRE_FPU"
1133 if (emit_move_sequence (operands, SFmode, operands[2]))
1136 /* We don't want the clobber emitted, so handle this ourselves. */
1137 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1141 (define_expand "reload_outsf"
1142 [(set (match_operand:SF 0 "general_operand" "")
1143 (match_operand:SF 1 "register_operand" "f"))
1144 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1145 "TARGET_COLDFIRE_FPU"
1147 if (emit_move_sequence (operands, SFmode, operands[2]))
1150 /* We don't want the clobber emitted, so handle this ourselves. */
1151 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1155 (define_expand "movsf"
1156 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1157 (match_operand:SF 1 "general_operand" ""))]
1162 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
1163 (match_operand:SF 1 "general_operand" "rmfF"))]
1166 if (FP_REG_P (operands[0]))
1168 if (FP_REG_P (operands[1]))
1169 return "f%$move%.x %1,%0";
1170 else if (ADDRESS_REG_P (operands[1]))
1171 return "move%.l %1,%-\;f%$move%.s %+,%0";
1172 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
1173 return output_move_const_single (operands);
1174 return "f%$move%.s %f1,%0";
1176 if (FP_REG_P (operands[1]))
1178 if (ADDRESS_REG_P (operands[0]))
1179 return "fmove%.s %1,%-\;move%.l %+,%0";
1180 return "fmove%.s %f1,%0";
1182 if (operands[1] == CONST0_RTX (SFmode)
1183 /* clr insns on 68000 read before writing. */
1184 && ((TARGET_68010 || TARGET_COLDFIRE)
1185 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
1187 if (ADDRESS_REG_P (operands[0]))
1189 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
1191 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
1193 return "sub%.l %0,%0";
1195 /* moveq is faster on the 68000. */
1196 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
1197 return "moveq #0,%0";
1200 return "move%.l %1,%0";
1203 (define_insn "movsf_cf_soft"
1204 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>,g,U")
1205 (match_operand:SF 1 "general_operand" "g,r<Q>,U"))]
1206 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1208 [(set_attr "type" "move_l")])
1210 ;; SFmode MEMs are restricted to modes 2-4 if TARGET_COLDFIRE_FPU.
1211 ;; The move instructions can handle all combinations.
1212 (define_insn "movsf_cf_hard"
1213 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f, f,mr,f,r<Q>,f
1215 (match_operand:SF 1 "general_operand" " f, r<Q>U,f,rm,F,F, m
1217 "TARGET_COLDFIRE_FPU"
1219 if (which_alternative == 4 || which_alternative == 5) {
1223 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1224 REAL_VALUE_TO_TARGET_SINGLE (r, 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"
1366 switch (which_alternative)
1369 return "fdmove%.d %1,%0";
1371 return "fmove%.d %1,%0";
1373 return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1375 return "move%.l %R1,%-;move%.l %1,%-;fdmove%.d %+,%0";
1376 case 4: case 5: case 6:
1377 return output_move_double (operands);
1379 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1380 REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1381 xoperands[0] = operands[0];
1382 xoperands[1] = GEN_INT (l[0]);
1383 xoperands[2] = GEN_INT (l[1]);
1384 if (operands[1] == CONST0_RTX (DFmode))
1385 output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1389 output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1392 output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1398 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1399 ;; allowed. Most but not all have predicates and constraint that disallow
1400 ;; constants. Most but not all have output templates that handle constants.
1401 ;; See also TARGET_LEGITIMATE_CONSTANT_P.
1403 (define_expand "movxf"
1404 [(set (match_operand:XF 0 "nonimmediate_operand" "")
1405 (match_operand:XF 1 "general_operand" ""))]
1408 /* We can't rewrite operands during reload. */
1409 if (! reload_in_progress)
1411 if (CONSTANT_P (operands[1]))
1413 operands[1] = force_const_mem (XFmode, operands[1]);
1414 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1415 operands[1] = adjust_address (operands[1], XFmode, 0);
1417 if (flag_pic && TARGET_PCREL)
1419 /* Don't allow writes to memory except via a register; the
1420 m68k doesn't consider PC-relative addresses to be writable. */
1421 if (GET_CODE (operands[0]) == MEM
1422 && symbolic_operand (XEXP (operands[0], 0), SImode))
1423 operands[0] = gen_rtx_MEM (XFmode,
1424 force_reg (SImode, XEXP (operands[0], 0)));
1430 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1431 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1434 if (FP_REG_P (operands[0]))
1436 if (FP_REG_P (operands[1]))
1437 return "fmove%.x %1,%0";
1438 if (REG_P (operands[1]))
1441 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1442 output_asm_insn ("move%.l %1,%-", xoperands);
1443 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1444 output_asm_insn ("move%.l %1,%-", xoperands);
1445 output_asm_insn ("move%.l %1,%-", operands);
1446 return "fmove%.x %+,%0";
1448 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1449 return "fmove%.x %1,%0";
1450 return "fmove%.x %f1,%0";
1452 if (FP_REG_P (operands[1]))
1454 if (REG_P (operands[0]))
1456 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1457 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1458 output_asm_insn ("move%.l %+,%0", operands);
1459 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1460 return "move%.l %+,%0";
1462 /* Must be memory destination. */
1463 return "fmove%.x %f1,%0";
1465 return output_move_double (operands);
1469 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1470 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1471 "! TARGET_68881 && ! TARGET_COLDFIRE"
1473 if (FP_REG_P (operands[0]))
1475 if (FP_REG_P (operands[1]))
1476 return "fmove%.x %1,%0";
1477 if (REG_P (operands[1]))
1480 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1481 output_asm_insn ("move%.l %1,%-", xoperands);
1482 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1483 output_asm_insn ("move%.l %1,%-", xoperands);
1484 output_asm_insn ("move%.l %1,%-", operands);
1485 return "fmove%.x %+,%0";
1487 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1488 return "fmove%.x %1,%0";
1489 return "fmove%.x %f1,%0";
1491 if (FP_REG_P (operands[1]))
1493 if (REG_P (operands[0]))
1495 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1496 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1497 output_asm_insn ("move%.l %+,%0", operands);
1498 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1499 return "move%.l %+,%0";
1502 return "fmove%.x %f1,%0";
1504 return output_move_double (operands);
1508 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1509 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1510 "! TARGET_68881 && TARGET_COLDFIRE"
1511 "* return output_move_double (operands);")
1513 (define_expand "movdi"
1514 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1515 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1516 (match_operand:DI 1 "general_operand" ""))]
1520 ;; movdi can apply to fp regs in some cases
1522 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1523 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1524 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1525 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1526 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1527 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1528 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1531 if (FP_REG_P (operands[0]))
1533 if (FP_REG_P (operands[1]))
1534 return "fmove%.x %1,%0";
1535 if (REG_P (operands[1]))
1538 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1539 output_asm_insn ("move%.l %1,%-", xoperands);
1540 output_asm_insn ("move%.l %1,%-", operands);
1541 return "fmove%.d %+,%0";
1543 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1544 return output_move_const_double (operands);
1545 return "fmove%.d %f1,%0";
1547 else if (FP_REG_P (operands[1]))
1549 if (REG_P (operands[0]))
1551 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1552 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1553 return "move%.l %+,%0";
1556 return "fmove%.d %f1,%0";
1558 return output_move_double (operands);
1562 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1563 (match_operand:DI 1 "general_operand" "g,r"))]
1565 "* return output_move_double (operands);")
1567 ;; Thus goes after the move instructions
1568 ;; because the move instructions are better (require no spilling)
1569 ;; when they can apply. It goes before the add/sub insns
1570 ;; so we will prefer it to them.
1572 (define_insn "pushasi"
1573 [(set (match_operand:SI 0 "push_operand" "=m")
1574 (match_operand:SI 1 "address_operand" "p"))]
1577 [(set_attr "type" "pea")])
1579 ;; truncation instructions
1580 (define_insn "truncsiqi2"
1581 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1583 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1586 if (GET_CODE (operands[0]) == REG)
1588 /* Must clear condition codes, since the move.l bases them on
1589 the entire 32 bits, not just the desired 8 bits. */
1591 return "move%.l %1,%0";
1593 if (GET_CODE (operands[1]) == MEM)
1594 operands[1] = adjust_address (operands[1], QImode, 3);
1595 return "move%.b %1,%0";
1598 (define_insn "trunchiqi2"
1599 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1601 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1604 if (GET_CODE (operands[0]) == REG
1605 && (GET_CODE (operands[1]) == MEM
1606 || GET_CODE (operands[1]) == CONST_INT))
1608 /* Must clear condition codes, since the move.w bases them on
1609 the entire 16 bits, not just the desired 8 bits. */
1611 return "move%.w %1,%0";
1613 if (GET_CODE (operands[0]) == REG)
1615 /* Must clear condition codes, since the move.l bases them on
1616 the entire 32 bits, not just the desired 8 bits. */
1618 return "move%.l %1,%0";
1620 if (GET_CODE (operands[1]) == MEM)
1621 operands[1] = adjust_address (operands[1], QImode, 1);
1622 return "move%.b %1,%0";
1625 (define_insn "truncsihi2"
1626 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1628 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1631 if (GET_CODE (operands[0]) == REG)
1633 /* Must clear condition codes, since the move.l bases them on
1634 the entire 32 bits, not just the desired 8 bits. */
1636 return "move%.l %1,%0";
1638 if (GET_CODE (operands[1]) == MEM)
1639 operands[1] = adjust_address (operands[1], QImode, 2);
1640 return "move%.w %1,%0";
1643 ;; zero extension instructions
1645 ;; two special patterns to match various post_inc/pre_dec patterns
1646 (define_insn_and_split "*zero_extend_inc"
1647 [(set (match_operand 0 "post_inc_operand" "")
1648 (zero_extend (match_operand 1 "register_operand" "")))]
1649 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1650 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1651 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1659 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1662 (define_insn_and_split "*zero_extend_dec"
1663 [(set (match_operand 0 "pre_dec_operand" "")
1664 (zero_extend (match_operand 1 "register_operand" "")))]
1665 "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1666 GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1667 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1668 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1676 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1679 (define_insn_and_split "zero_extendqidi2"
1680 [(set (match_operand:DI 0 "register_operand" "")
1681 (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1686 (zero_extend:SI (match_dup 1)))
1690 operands[2] = gen_lowpart (SImode, operands[0]);
1691 operands[3] = gen_highpart (SImode, operands[0]);
1694 (define_insn_and_split "zero_extendhidi2"
1695 [(set (match_operand:DI 0 "register_operand" "")
1696 (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1701 (zero_extend:SI (match_dup 1)))
1705 operands[2] = gen_lowpart (SImode, operands[0]);
1706 operands[3] = gen_highpart (SImode, operands[0]);
1709 (define_expand "zero_extendsidi2"
1710 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1711 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1714 if (GET_CODE (operands[0]) == MEM
1715 && GET_CODE (operands[1]) == MEM)
1716 operands[1] = force_reg (SImode, operands[1]);
1719 (define_insn_and_split "*zero_extendsidi2"
1720 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1721 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1722 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1730 operands[2] = gen_lowpart (SImode, operands[0]);
1731 operands[3] = gen_highpart (SImode, operands[0]);
1734 (define_insn "*zero_extendhisi2_cf"
1735 [(set (match_operand:SI 0 "register_operand" "=d")
1736 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1739 [(set_attr "type" "mvsz")])
1741 (define_insn "zero_extendhisi2"
1742 [(set (match_operand:SI 0 "register_operand" "=d")
1743 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1747 (define_expand "zero_extendqihi2"
1748 [(set (match_operand:HI 0 "register_operand" "")
1749 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1753 (define_insn "*zero_extendqihi2"
1754 [(set (match_operand:HI 0 "register_operand" "=d")
1755 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1759 (define_insn "*zero_extendqisi2_cfv4"
1760 [(set (match_operand:SI 0 "register_operand" "=d")
1761 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1764 [(set_attr "type" "mvsz")])
1766 (define_insn "zero_extendqisi2"
1767 [(set (match_operand:SI 0 "register_operand" "=d")
1768 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1772 ;; these two pattern split everything else which isn't matched by
1773 ;; something else above
1775 [(set (match_operand 0 "register_operand" "")
1776 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1779 && reg_mentioned_p (operands[0], operands[1])"
1780 [(set (strict_low_part (match_dup 2))
1783 (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1785 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1786 operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1787 operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1791 [(set (match_operand 0 "register_operand" "")
1792 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1793 "!ISA_HAS_MVS_MVZ && reload_completed"
1796 (set (strict_low_part (match_dup 2))
1799 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1802 ;; sign extension instructions
1804 (define_insn "extendqidi2"
1805 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1806 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1810 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1811 if (ISA_HAS_MVS_MVZ)
1812 return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1813 if (TARGET_68020 || TARGET_COLDFIRE)
1815 if (ADDRESS_REG_P (operands[1]))
1816 return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1818 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1822 if (ADDRESS_REG_P (operands[1]))
1823 return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1825 return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1829 (define_insn "extendhidi2"
1830 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1832 (match_operand:HI 1 "general_src_operand" "rmS")))]
1836 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1837 if (ISA_HAS_MVS_MVZ)
1838 return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1839 if (TARGET_68020 || TARGET_COLDFIRE)
1840 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1842 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1845 (define_insn "extendsidi2"
1846 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o,o,<")
1848 (match_operand:SI 1 "nonimmediate_src_operand" "rm,rm,r<Q>,rm")))
1849 (clobber (match_scratch:SI 2 "=X,d,d,d"))]
1854 if (which_alternative == 0)
1855 /* Handle alternative 0. */
1857 if (TARGET_68020 || TARGET_COLDFIRE)
1858 return "move%.l %1,%R0\;smi %0\;extb%.l %0";
1860 return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
1863 /* Handle alternatives 1, 2 and 3. We don't need to adjust address by 4
1864 in alternative 3 because autodecrement will do that for us. */
1865 operands[3] = adjust_address (operands[0], SImode,
1866 which_alternative == 3 ? 0 : 4);
1867 operands[0] = adjust_address (operands[0], SImode, 0);
1869 if (TARGET_68020 || TARGET_COLDFIRE)
1870 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
1872 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
1874 [(set_attr "ok_for_coldfire" "yes,no,yes,yes")])
1876 ;; Special case when one can avoid register clobbering, copy and test
1877 ;; Maybe there is a way to make that the general case, by forcing the
1878 ;; result of the SI tree to be in the lower register of the DI target
1880 ;; Don't allow memory for operand 1 as that would require an earlyclobber
1881 ;; which results in worse code
1882 (define_insn "extendplussidi"
1883 [(set (match_operand:DI 0 "register_operand" "=d")
1884 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rn")
1885 (match_operand:SI 2 "general_operand" "rmn"))))]
1889 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1890 if (GET_CODE (operands[1]) == CONST_INT
1891 && (unsigned) INTVAL (operands[1]) > 8)
1893 rtx tmp = operands[1];
1895 operands[1] = operands[2];
1898 if (GET_CODE (operands[1]) == REG
1899 && REGNO (operands[1]) == REGNO (operands[3]))
1900 output_asm_insn ("add%.l %2,%3", operands);
1902 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1903 if (TARGET_68020 || TARGET_COLDFIRE)
1904 return "smi %0\;extb%.l %0";
1906 return "smi %0\;ext%.w %0\;ext%.l %0";
1909 (define_expand "extendhisi2"
1910 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1912 (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1916 (define_insn "*cfv4_extendhisi2"
1917 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1919 (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1922 [(set_attr "type" "mvsz")])
1924 (define_insn "*68k_extendhisi2"
1925 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1927 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1932 [(set_attr "type" "ext,move")])
1934 (define_insn "extendqihi2"
1935 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1936 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1939 [(set_attr "type" "ext")])
1941 (define_expand "extendqisi2"
1942 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1943 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1944 "TARGET_68020 || TARGET_COLDFIRE"
1947 (define_insn "*cfv4_extendqisi2"
1948 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1949 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1952 [(set_attr "type" "mvsz")])
1954 (define_insn "*68k_extendqisi2"
1955 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1956 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1957 "TARGET_68020 || (TARGET_COLDFIRE && !ISA_HAS_MVS_MVZ)"
1959 [(set_attr "type" "ext")])
1961 ;; Conversions between float and double.
1963 (define_expand "extendsfdf2"
1964 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1966 (match_operand:SF 1 "general_operand" "")))]
1971 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1973 (match_operand:SF 1 "general_operand" "f,dmF")))]
1976 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1978 if (REGNO (operands[0]) == REGNO (operands[1]))
1980 /* Extending float to double in an fp-reg is a no-op.
1981 NOTICE_UPDATE_CC has already assumed that the
1982 cc will be set. So cancel what it did. */
1983 cc_status = cc_prev_status;
1986 return "f%&move%.x %1,%0";
1988 if (FP_REG_P (operands[0]))
1989 return "f%&move%.s %f1,%0";
1990 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1992 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1993 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1994 return "move%.l %+,%0";
1996 return "fmove%.d %f1,%0";
1999 (define_insn "extendsfdf2_cf"
2000 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
2002 (match_operand:SF 1 "general_operand" "f,<Q>U")))]
2003 "TARGET_COLDFIRE_FPU"
2005 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
2007 if (REGNO (operands[0]) == REGNO (operands[1]))
2009 /* Extending float to double in an fp-reg is a no-op.
2010 NOTICE_UPDATE_CC has already assumed that the
2011 cc will be set. So cancel what it did. */
2012 cc_status = cc_prev_status;
2015 return "fdmove%.d %1,%0";
2017 return "fdmove%.s %f1,%0";
2020 ;; This cannot output into an f-reg because there is no way to be
2021 ;; sure of truncating in that case.
2022 (define_expand "truncdfsf2"
2023 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2025 (match_operand:DF 1 "general_operand" "")))]
2029 ;; On the '040 we can truncate in a register accurately and easily.
2031 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2033 (match_operand:DF 1 "general_operand" "fmG")))]
2034 "TARGET_68881 && TARGET_68040"
2036 if (FP_REG_P (operands[1]))
2037 return "f%$move%.x %1,%0";
2038 return "f%$move%.d %f1,%0";
2041 (define_insn "truncdfsf2_cf"
2042 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
2044 (match_operand:DF 1 "general_operand" "<Q>U,f")))]
2045 "TARGET_COLDFIRE_FPU"
2049 [(set_attr "type" "fmove")])
2051 (define_insn "*truncdfsf2_68881"
2052 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
2054 (match_operand:DF 1 "general_operand" "f")))]
2057 [(set_attr "type" "fmove")])
2059 ;; Conversion between fixed point and floating point.
2060 ;; Note that among the fix-to-float insns
2061 ;; the ones that start with SImode come first.
2062 ;; That is so that an operand that is a CONST_INT
2063 ;; (and therefore lacks a specific machine mode).
2064 ;; will be recognized as SImode (which is always valid)
2065 ;; rather than as QImode or HImode.
2067 (define_expand "floatsi<mode>2"
2068 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2069 (float:FP (match_operand:SI 1 "general_operand" "")))]
2073 (define_insn "floatsi<mode>2_68881"
2074 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2075 (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
2077 "f<FP:round>move%.l %1,%0"
2078 [(set_attr "type" "fmove")])
2080 (define_insn "floatsi<mode>2_cf"
2081 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2082 (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
2083 "TARGET_COLDFIRE_FPU"
2084 "f<FP:prec>move%.l %1,%0"
2085 [(set_attr "type" "fmove")])
2088 (define_expand "floathi<mode>2"
2089 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2090 (float:FP (match_operand:HI 1 "general_operand" "")))]
2094 (define_insn "floathi<mode>2_68881"
2095 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2096 (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
2099 [(set_attr "type" "fmove")])
2101 (define_insn "floathi<mode>2_cf"
2102 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2103 (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
2104 "TARGET_COLDFIRE_FPU"
2106 [(set_attr "type" "fmove")])
2109 (define_expand "floatqi<mode>2"
2110 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2111 (float:FP (match_operand:QI 1 "general_operand" "")))]
2115 (define_insn "floatqi<mode>2_68881"
2116 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2117 (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
2120 [(set_attr "type" "fmove")])
2122 (define_insn "floatqi<mode>2_cf"
2123 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2124 (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
2125 "TARGET_COLDFIRE_FPU"
2127 [(set_attr "type" "fmove")])
2130 ;; New routines to convert floating-point values to integers
2131 ;; to be used on the '040. These should be faster than trapping
2132 ;; into the kernel to emulate fintrz. They should also be faster
2133 ;; than calling the subroutines fixsfsi or fixdfsi.
2135 (define_insn "fix_truncdfsi2"
2136 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2137 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2138 (clobber (match_scratch:SI 2 "=d"))
2139 (clobber (match_scratch:SI 3 "=d"))]
2140 "TARGET_68881 && TUNE_68040"
2143 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,%!";
2146 (define_insn "fix_truncdfhi2"
2147 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2148 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2149 (clobber (match_scratch:SI 2 "=d"))
2150 (clobber (match_scratch:SI 3 "=d"))]
2151 "TARGET_68881 && TUNE_68040"
2154 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,%!";
2157 (define_insn "fix_truncdfqi2"
2158 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2159 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2160 (clobber (match_scratch:SI 2 "=d"))
2161 (clobber (match_scratch:SI 3 "=d"))]
2162 "TARGET_68881 && TUNE_68040"
2165 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,%!";
2168 ;; Convert a float to a float whose value is an integer.
2169 ;; This is the first stage of converting it to an integer type.
2171 (define_expand "ftrunc<mode>2"
2172 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2173 (fix:FP (match_operand:FP 1 "general_operand" "")))]
2174 "TARGET_HARD_FLOAT && !TUNE_68040"
2177 (define_insn "ftrunc<mode>2_68881"
2178 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2179 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
2180 "TARGET_68881 && !TUNE_68040"
2182 if (FP_REG_P (operands[1]))
2183 return "fintrz%.x %f1,%0";
2184 return "fintrz%.<FP:prec> %f1,%0";
2186 [(set_attr "type" "falu")])
2188 (define_insn "ftrunc<mode>2_cf"
2189 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2190 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
2191 "TARGET_COLDFIRE_FPU"
2193 if (FP_REG_P (operands[1]))
2194 return "fintrz%.d %f1,%0";
2195 return "fintrz%.<FP:prec> %f1,%0";
2197 [(set_attr "type" "falu")])
2199 ;; Convert a float whose value is an integer
2200 ;; to an actual integer. Second stage of converting float to integer type.
2201 (define_expand "fix<mode>qi2"
2202 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2203 (fix:QI (match_operand:FP 1 "general_operand" "")))]
2207 (define_insn "fix<mode>qi2_68881"
2208 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2209 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2212 [(set_attr "type" "fmove")])
2214 (define_insn "fix<mode>qi2_cf"
2215 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
2216 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2217 "TARGET_COLDFIRE_FPU"
2219 [(set_attr "type" "fmove")])
2221 (define_expand "fix<mode>hi2"
2222 [(set (match_operand:HI 0 "nonimmediate_operand" "")
2223 (fix:HI (match_operand:FP 1 "general_operand" "")))]
2227 (define_insn "fix<mode>hi2_68881"
2228 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2229 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2232 [(set_attr "type" "fmove")])
2234 (define_insn "fix<mode>hi2_cf"
2235 [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
2236 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2237 "TARGET_COLDFIRE_FPU"
2239 [(set_attr "type" "fmove")])
2241 (define_expand "fix<mode>si2"
2242 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2243 (fix:SI (match_operand:FP 1 "general_operand" "")))]
2247 (define_insn "fix<mode>si2_68881"
2248 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2249 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2252 [(set_attr "type" "fmove")])
2254 (define_insn "fix<mode>si2_cf"
2255 [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
2256 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2257 "TARGET_COLDFIRE_FPU"
2259 [(set_attr "type" "fmove")])
2264 (define_insn "adddi_lshrdi_63"
2265 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
2266 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
2269 (clobber (match_scratch:SI 2 "=d"))]
2272 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2273 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
2275 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
2276 if (GET_CODE (operands[1]) == REG)
2277 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2278 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
2279 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2280 operands[4] = operands[1];
2282 operands[4] = adjust_address (operands[1], SImode, 4);
2283 if (GET_CODE (operands[1]) == MEM
2284 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2285 output_asm_insn ("move%.l %4,%3", operands);
2286 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
2287 if (TARGET_68020 || TARGET_COLDFIRE)
2288 output_asm_insn ("extb%.l %2", operands);
2290 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
2291 if (GET_CODE (operands[1]) != MEM
2292 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
2293 output_asm_insn ("move%.l %4,%3", operands);
2294 return "sub%.l %2,%3\;subx%.l %2,%0";
2297 (define_insn "adddi_sexthishl32"
2298 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2299 (plus:DI (ashift:DI (sign_extend:DI
2300 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
2302 (match_operand:DI 2 "general_operand" "0,0,0,0")))
2303 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2307 if (ADDRESS_REG_P (operands[0]))
2308 return "add%.w %1,%0";
2309 else if (ADDRESS_REG_P (operands[3]))
2310 return "move%.w %1,%3\;add%.l %3,%0";
2312 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
2315 (define_insn "*adddi_dilshr32"
2316 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
2317 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
2319 (match_operand:DI 2 "general_operand" "0,0")))]
2323 if (GET_CODE (operands[0]) == REG)
2324 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2326 operands[2] = adjust_address (operands[0], SImode, 4);
2327 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
2330 (define_insn "*adddi_dilshr32_cf"
2331 [(set (match_operand:DI 0 "register_operand" "=d")
2332 (plus:DI (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
2334 (match_operand:DI 2 "register_operand" "0")))]
2338 return "add%.l %1,%R0\;negx%.l %0\;neg%.l %0";
2341 (define_insn "adddi_dishl32"
2342 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
2343 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
2344 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2345 ;; (const_int 32))))]
2346 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
2348 (match_operand:DI 2 "general_operand" "0,0")))]
2352 if (GET_CODE (operands[1]) == REG)
2353 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2355 operands[1] = adjust_address (operands[1], SImode, 4);
2356 return "add%.l %1,%0";
2358 [(set_attr "type" "alu_l")])
2360 (define_insn "adddi3"
2361 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2362 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0")
2363 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2364 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2367 if (DATA_REG_P (operands[0]))
2369 if (DATA_REG_P (operands[2]))
2370 return "add%.l %R2,%R0\;addx%.l %2,%0";
2371 else if (GET_CODE (operands[2]) == MEM
2372 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2373 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
2379 if (GET_CODE (operands[2]) == REG)
2381 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2384 else if (CONSTANT_P (operands[2]))
2385 split_double (operands[2], &high, &low);
2388 low = adjust_address (operands[2], SImode, 4);
2392 operands[1] = low, operands[2] = high;
2393 xoperands[0] = operands[3];
2394 if (GET_CODE (operands[1]) == CONST_INT
2395 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2396 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2398 xoperands[1] = operands[2];
2400 output_asm_insn (output_move_simode (xoperands), xoperands);
2401 if (GET_CODE (operands[1]) == CONST_INT)
2403 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2404 return "addq%.l %1,%R0\;addx%.l %3,%0";
2405 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2407 operands[1] = GEN_INT (-INTVAL (operands[1]));
2408 return "subq%.l %1,%R0\;subx%.l %3,%0";
2411 return "add%.l %1,%R0\;addx%.l %3,%0";
2416 gcc_assert (GET_CODE (operands[0]) == MEM);
2418 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2420 operands[1] = gen_rtx_MEM (SImode,
2421 plus_constant (Pmode,
2422 XEXP(operands[0], 0), -8));
2423 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2425 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2427 operands[1] = XEXP(operands[0], 0);
2428 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2432 operands[1] = adjust_address (operands[0], SImode, 4);
2433 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2438 (define_insn "addsi_lshrsi_31"
2439 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,dm,d<Q>")
2440 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm,r<Q>,rm")
2445 operands[2] = operands[0];
2446 operands[3] = gen_label_rtx();
2447 if (GET_CODE (operands[0]) == MEM)
2449 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2450 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2451 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2452 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2454 output_asm_insn ("move%.l %1,%0", operands);
2455 output_asm_insn ("jpl %l3", operands);
2456 output_asm_insn ("addq%.l #1,%2", operands);
2457 (*targetm.asm_out.internal_label) (asm_out_file, "L",
2458 CODE_LABEL_NUMBER (operands[3]));
2461 [(set_attr "ok_for_coldfire" "no,yes,yes")])
2463 (define_expand "addsi3"
2464 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2465 (plus:SI (match_operand:SI 1 "general_operand" "")
2466 (match_operand:SI 2 "general_src_operand" "")))]
2470 ;; Note that the middle two alternatives are near-duplicates
2471 ;; in order to handle insns generated by reload.
2472 ;; This is needed since they are not themselves reloaded,
2473 ;; so commutativity won't apply to them.
2474 (define_insn "*addsi3_internal"
2475 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2476 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2477 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2481 "* return output_addsi3 (operands);")
2483 (define_insn_and_split "*addsi3_5200"
2484 [(set (match_operand:SI 0 "nonimmediate_operand" "=mr,mr,a, m,r, ?a, ?a,?a,?a")
2485 (plus:SI (match_operand:SI 1 "general_operand" "%0, 0, 0, 0,0, a, a, r, a")
2486 (match_operand:SI 2 "general_src_operand" " I, L, JCu,d,mrKi,Cj, r, a, JCu")))]
2489 switch (which_alternative)
2492 return "addq%.l %2,%0";
2495 operands[2] = GEN_INT (- INTVAL (operands[2]));
2496 return "subq%.l %2,%0";
2500 return "add%.l %2,%0";
2503 /* move%.l %2,%0\n\tadd%.l %1,%0 */
2507 return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0";
2510 return MOTOROLA ? "lea (%2,%1.l),%0" : "lea %2@(0,%1:l),%0";
2514 return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
2521 "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 5) && !operands_match_p (operands[0], operands[1])"
2525 (plus:SI (match_dup 0)
2528 [(set_attr "type" "aluq_l,aluq_l,lea, alu_l,alu_l,*,lea, lea, lea")
2529 (set_attr "opy" "2, 2, *, 2, 2, *,*, *, *")
2530 (set_attr "opy_type" "*, *, mem5,*, *, *,mem6,mem6,mem5")])
2533 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2534 (plus:SI (match_operand:SI 1 "general_operand" "0")
2536 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2540 (define_insn "addhi3"
2541 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2542 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2543 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2546 if (GET_CODE (operands[2]) == CONST_INT)
2548 /* If the constant would be a negative number when interpreted as
2549 HImode, make it negative. This is usually, but not always, done
2550 elsewhere in the compiler. First check for constants out of range,
2551 which could confuse us. */
2553 if (INTVAL (operands[2]) >= 32768)
2554 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2556 if (INTVAL (operands[2]) > 0
2557 && INTVAL (operands[2]) <= 8)
2558 return "addq%.w %2,%0";
2559 if (INTVAL (operands[2]) < 0
2560 && INTVAL (operands[2]) >= -8)
2562 operands[2] = GEN_INT (- INTVAL (operands[2]));
2563 return "subq%.w %2,%0";
2565 /* On the CPU32 it is faster to use two addqw instructions to
2566 add a small integer (8 < N <= 16) to a register.
2567 Likewise for subqw. */
2568 if (TUNE_CPU32 && REG_P (operands[0]))
2570 if (INTVAL (operands[2]) > 8
2571 && INTVAL (operands[2]) <= 16)
2573 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2574 return "addq%.w #8,%0\;addq%.w %2,%0";
2576 if (INTVAL (operands[2]) < -8
2577 && INTVAL (operands[2]) >= -16)
2579 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2580 return "subq%.w #8,%0\;subq%.w %2,%0";
2583 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2584 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2586 return "add%.w %2,%0";
2589 ;; These insns must use MATCH_DUP instead of the more expected
2590 ;; use of a matching constraint because the "output" here is also
2591 ;; an input, so you can't use the matching constraint. That also means
2592 ;; that you can't use the "%", so you need patterns with the matched
2593 ;; operand in both positions.
2596 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2597 (plus:HI (match_dup 0)
2598 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2601 if (GET_CODE (operands[1]) == CONST_INT)
2603 /* If the constant would be a negative number when interpreted as
2604 HImode, make it negative. This is usually, but not always, done
2605 elsewhere in the compiler. First check for constants out of range,
2606 which could confuse us. */
2608 if (INTVAL (operands[1]) >= 32768)
2609 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2611 if (INTVAL (operands[1]) > 0
2612 && INTVAL (operands[1]) <= 8)
2613 return "addq%.w %1,%0";
2614 if (INTVAL (operands[1]) < 0
2615 && INTVAL (operands[1]) >= -8)
2617 operands[1] = GEN_INT (- INTVAL (operands[1]));
2618 return "subq%.w %1,%0";
2620 /* On the CPU32 it is faster to use two addqw instructions to
2621 add a small integer (8 < N <= 16) to a register.
2622 Likewise for subqw. */
2623 if (TUNE_CPU32 && REG_P (operands[0]))
2625 if (INTVAL (operands[1]) > 8
2626 && INTVAL (operands[1]) <= 16)
2628 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2629 return "addq%.w #8,%0\;addq%.w %1,%0";
2631 if (INTVAL (operands[1]) < -8
2632 && INTVAL (operands[1]) >= -16)
2634 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2635 return "subq%.w #8,%0\;subq%.w %1,%0";
2638 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2639 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2641 return "add%.w %1,%0";
2645 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2646 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2650 if (GET_CODE (operands[1]) == CONST_INT)
2652 /* If the constant would be a negative number when interpreted as
2653 HImode, make it negative. This is usually, but not always, done
2654 elsewhere in the compiler. First check for constants out of range,
2655 which could confuse us. */
2657 if (INTVAL (operands[1]) >= 32768)
2658 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2660 if (INTVAL (operands[1]) > 0
2661 && INTVAL (operands[1]) <= 8)
2662 return "addq%.w %1,%0";
2663 if (INTVAL (operands[1]) < 0
2664 && INTVAL (operands[1]) >= -8)
2666 operands[1] = GEN_INT (- INTVAL (operands[1]));
2667 return "subq%.w %1,%0";
2669 /* On the CPU32 it is faster to use two addqw instructions to
2670 add a small integer (8 < N <= 16) to a register.
2671 Likewise for subqw. */
2672 if (TUNE_CPU32 && REG_P (operands[0]))
2674 if (INTVAL (operands[1]) > 8
2675 && INTVAL (operands[1]) <= 16)
2677 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2678 return "addq%.w #8,%0\;addq%.w %1,%0";
2680 if (INTVAL (operands[1]) < -8
2681 && INTVAL (operands[1]) >= -16)
2683 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2684 return "subq%.w #8,%0\;subq%.w %1,%0";
2687 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2688 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2690 return "add%.w %1,%0";
2693 (define_insn "addqi3"
2694 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2695 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2696 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2699 if (GET_CODE (operands[2]) == CONST_INT)
2701 if (INTVAL (operands[2]) >= 128)
2702 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2704 if (INTVAL (operands[2]) > 0
2705 && INTVAL (operands[2]) <= 8)
2706 return "addq%.b %2,%0";
2707 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2709 operands[2] = GEN_INT (- INTVAL (operands[2]));
2710 return "subq%.b %2,%0";
2713 return "add%.b %2,%0";
2717 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2718 (plus:QI (match_dup 0)
2719 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2722 if (GET_CODE (operands[1]) == CONST_INT)
2724 if (INTVAL (operands[1]) >= 128)
2725 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2727 if (INTVAL (operands[1]) > 0
2728 && INTVAL (operands[1]) <= 8)
2729 return "addq%.b %1,%0";
2730 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2732 operands[1] = GEN_INT (- INTVAL (operands[1]));
2733 return "subq%.b %1,%0";
2736 return "add%.b %1,%0";
2740 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2741 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2745 if (GET_CODE (operands[1]) == CONST_INT)
2747 if (INTVAL (operands[1]) >= 128)
2748 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2750 if (INTVAL (operands[1]) > 0
2751 && INTVAL (operands[1]) <= 8)
2752 return "addq%.b %1,%0";
2753 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2755 operands[1] = GEN_INT (- INTVAL (operands[1]));
2756 return "subq%.b %1,%0";
2759 return "add%.b %1,%0";
2762 (define_expand "add<mode>3"
2763 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2764 (plus:FP (match_operand:FP 1 "general_operand" "")
2765 (match_operand:FP 2 "general_operand" "")))]
2769 (define_insn "add<mode>3_floatsi_68881"
2770 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2771 (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2772 (match_operand:FP 1 "general_operand" "0")))]
2774 "f<FP:round>add%.l %2,%0"
2775 [(set_attr "type" "falu")
2776 (set_attr "opy" "2")])
2778 (define_insn "add<mode>3_floathi_68881"
2779 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2780 (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2781 (match_operand:FP 1 "general_operand" "0")))]
2783 "f<FP:round>add%.w %2,%0"
2784 [(set_attr "type" "falu")
2785 (set_attr "opy" "2")])
2787 (define_insn "add<mode>3_floatqi_68881"
2788 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2789 (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2790 (match_operand:FP 1 "general_operand" "0")))]
2792 "f<FP:round>add%.b %2,%0"
2793 [(set_attr "type" "falu")
2794 (set_attr "opy" "2")])
2796 (define_insn "add<mode>3_68881"
2797 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2798 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2799 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2802 if (FP_REG_P (operands[2]))
2803 return "f<FP:round>add%.x %2,%0";
2804 return "f<FP:round>add%.<FP:prec> %f2,%0";
2806 [(set_attr "type" "falu")
2807 (set_attr "opy" "2")])
2809 (define_insn "add<mode>3_cf"
2810 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2811 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2812 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2813 "TARGET_COLDFIRE_FPU"
2815 if (FP_REG_P (operands[2]))
2816 return "f<FP:prec>add%.d %2,%0";
2817 return "f<FP:prec>add%.<FP:prec> %2,%0";
2819 [(set_attr "type" "falu")
2820 (set_attr "opy" "2")])
2822 ;; subtract instructions
2824 (define_insn "subdi_sexthishl32"
2825 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2826 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2827 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2829 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2833 if (ADDRESS_REG_P (operands[0]))
2834 return "sub%.w %2,%0";
2835 else if (ADDRESS_REG_P (operands[3]))
2836 return "move%.w %2,%3\;sub%.l %3,%0";
2838 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2841 (define_insn "subdi_dishl32"
2842 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2843 (minus:DI (match_dup 0)
2844 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2849 if (GET_CODE (operands[1]) == REG)
2850 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2852 operands[1] = adjust_address (operands[1], SImode, 4);
2853 return "sub%.l %1,%0";
2855 [(set_attr "type" "alu_l")])
2857 (define_insn "subdi3"
2858 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2859 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2860 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2861 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2864 if (DATA_REG_P (operands[0]))
2866 if (DATA_REG_P (operands[2]))
2867 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2868 else if (GET_CODE (operands[2]) == MEM
2869 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2871 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2878 if (GET_CODE (operands[2]) == REG)
2880 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2883 else if (CONSTANT_P (operands[2]))
2884 split_double (operands[2], &high, &low);
2887 low = adjust_address (operands[2], SImode, 4);
2891 operands[1] = low, operands[2] = high;
2892 xoperands[0] = operands[3];
2893 if (GET_CODE (operands[1]) == CONST_INT
2894 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2895 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2897 xoperands[1] = operands[2];
2899 output_asm_insn (output_move_simode (xoperands), xoperands);
2900 if (GET_CODE (operands[1]) == CONST_INT)
2902 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2903 return "subq%.l %1,%R0\;subx%.l %3,%0";
2904 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2906 operands[1] = GEN_INT (-INTVAL (operands[1]));
2907 return "addq%.l %1,%R0\;addx%.l %3,%0";
2910 return "sub%.l %1,%R0\;subx%.l %3,%0";
2915 gcc_assert (GET_CODE (operands[0]) == MEM);
2917 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2920 = gen_rtx_MEM (SImode, plus_constant (Pmode,
2921 XEXP (operands[0], 0), -8));
2922 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2924 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2926 operands[1] = XEXP(operands[0], 0);
2927 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2931 operands[1] = adjust_address (operands[0], SImode, 4);
2932 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2937 (define_insn "subsi3"
2938 [(set (match_operand:SI 0 "nonimmediate_operand" "=mda,m,d,a")
2939 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0,0")
2940 (match_operand:SI 2 "general_src_operand" "I,dT,mSrT,mSrs")))]
2947 [(set_attr "type" "aluq_l,alu_l,alu_l,alu_l")
2948 (set_attr "opy" "2")])
2951 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2952 (minus:SI (match_operand:SI 1 "general_operand" "0")
2954 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2958 (define_insn "subhi3"
2959 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2960 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2961 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2966 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2967 (minus:HI (match_dup 0)
2968 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2972 (define_insn "subqi3"
2973 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2974 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2975 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2980 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2981 (minus:QI (match_dup 0)
2982 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2986 (define_expand "sub<mode>3"
2987 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2988 (minus:FP (match_operand:FP 1 "general_operand" "")
2989 (match_operand:FP 2 "general_operand" "")))]
2993 (define_insn "sub<mode>3_floatsi_68881"
2994 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2995 (minus:FP (match_operand:FP 1 "general_operand" "0")
2996 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2998 "f<FP:round>sub%.l %2,%0"
2999 [(set_attr "type" "falu")
3000 (set_attr "opy" "2")])
3002 (define_insn "sub<mode>3_floathi_68881"
3003 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3004 (minus:FP (match_operand:FP 1 "general_operand" "0")
3005 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
3007 "f<FP:round>sub%.w %2,%0"
3008 [(set_attr "type" "falu")
3009 (set_attr "opy" "2")])
3011 (define_insn "sub<mode>3_floatqi_68881"
3012 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3013 (minus:FP (match_operand:FP 1 "general_operand" "0")
3014 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3016 "f<FP:round>sub%.b %2,%0"
3017 [(set_attr "type" "falu")
3018 (set_attr "opy" "2")])
3020 (define_insn "sub<mode>3_68881"
3021 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3022 (minus:FP (match_operand:FP 1 "general_operand" "0")
3023 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3026 if (FP_REG_P (operands[2]))
3027 return "f<FP:round>sub%.x %2,%0";
3028 return "f<FP:round>sub%.<FP:prec> %f2,%0";
3030 [(set_attr "type" "falu")
3031 (set_attr "opy" "2")])
3033 (define_insn "sub<mode>3_cf"
3034 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3035 (minus:FP (match_operand:FP 1 "general_operand" "0")
3036 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
3037 "TARGET_COLDFIRE_FPU"
3039 if (FP_REG_P (operands[2]))
3040 return "f<FP:prec>sub%.d %2,%0";
3041 return "f<FP:prec>sub%.<FP:prec> %2,%0";
3043 [(set_attr "type" "falu")
3044 (set_attr "opy" "2")])
3046 ;; multiply instructions
3048 (define_insn "mulhi3"
3049 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3050 (mult:HI (match_operand:HI 1 "general_operand" "%0")
3051 (match_operand:HI 2 "general_src_operand" "dmSn")))]
3054 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3056 [(set_attr "type" "mul_w")
3057 (set_attr "opy" "2")])
3059 (define_insn "mulhisi3"
3060 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3061 (mult:SI (sign_extend:SI
3062 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3064 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3067 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3069 [(set_attr "type" "mul_w")
3070 (set_attr "opy" "2")])
3072 (define_insn "*mulhisisi3_s"
3073 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3074 (mult:SI (sign_extend:SI
3075 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3076 (match_operand:SI 2 "const_int_operand" "n")))]
3077 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
3079 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3081 [(set_attr "type" "mul_w")
3082 (set_attr "opy" "2")])
3084 (define_expand "mulsi3"
3085 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3086 (mult:SI (match_operand:SI 1 "general_operand" "")
3087 (match_operand:SI 2 "general_operand" "")))]
3088 "TARGET_68020 || TARGET_COLDFIRE"
3091 (define_insn "*mulsi3_68020"
3092 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3093 (mult:SI (match_operand:SI 1 "general_operand" "%0")
3094 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
3098 [(set_attr "type" "mul_l")
3099 (set_attr "opy" "2")])
3101 (define_insn "*mulsi3_cf"
3102 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3103 (mult:SI (match_operand:SI 1 "general_operand" "%0")
3104 (match_operand:SI 2 "general_operand" "d<Q>")))]
3107 [(set_attr "type" "mul_l")
3108 (set_attr "opy" "2")])
3110 (define_insn "umulhisi3"
3111 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3112 (mult:SI (zero_extend:SI
3113 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3115 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3118 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3120 [(set_attr "type" "mul_w")
3121 (set_attr "opy" "2")])
3123 (define_insn "*mulhisisi3_z"
3124 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3125 (mult:SI (zero_extend:SI
3126 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3127 (match_operand:SI 2 "const_int_operand" "n")))]
3128 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
3130 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3132 [(set_attr "type" "mul_w")
3133 (set_attr "opy" "2")])
3135 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
3136 ;; proper matching constraint. This is because the matching is between
3137 ;; the high-numbered word of the DImode operand[0] and operand[1].
3138 (define_expand "umulsidi3"
3140 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3141 (mult:SI (match_operand:SI 1 "register_operand" "")
3142 (match_operand:SI 2 "register_operand" "")))
3143 (set (subreg:SI (match_dup 0) 0)
3144 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3145 (zero_extend:DI (match_dup 2)))
3146 (const_int 32))))])]
3147 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3151 [(set (match_operand:SI 0 "register_operand" "=d")
3152 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3153 (match_operand:SI 2 "nonimmediate_operand" "dm")))
3154 (set (match_operand:SI 3 "register_operand" "=d")
3155 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3156 (zero_extend:DI (match_dup 2)))
3158 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3161 ; Match immediate case. For 2.4 only match things < 2^31.
3162 ; It's tricky with larger values in these patterns since we need to match
3163 ; values between the two parallel multiplies, between a CONST_DOUBLE and
3166 [(set (match_operand:SI 0 "register_operand" "=d")
3167 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3168 (match_operand:SI 2 "const_int_operand" "n")))
3169 (set (match_operand:SI 3 "register_operand" "=d")
3170 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3173 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
3174 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
3177 (define_expand "mulsidi3"
3179 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3180 (mult:SI (match_operand:SI 1 "register_operand" "")
3181 (match_operand:SI 2 "register_operand" "")))
3182 (set (subreg:SI (match_dup 0) 0)
3183 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3184 (sign_extend:DI (match_dup 2)))
3185 (const_int 32))))])]
3186 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3190 [(set (match_operand:SI 0 "register_operand" "=d")
3191 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3192 (match_operand:SI 2 "nonimmediate_operand" "dm")))
3193 (set (match_operand:SI 3 "register_operand" "=d")
3194 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3195 (sign_extend:DI (match_dup 2)))
3197 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3201 [(set (match_operand:SI 0 "register_operand" "=d")
3202 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3203 (match_operand:SI 2 "const_int_operand" "n")))
3204 (set (match_operand:SI 3 "register_operand" "=d")
3205 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3208 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3211 (define_expand "umulsi3_highpart"
3213 [(set (match_operand:SI 0 "register_operand" "")
3216 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
3217 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
3219 (clobber (match_dup 3))])]
3220 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3222 operands[3] = gen_reg_rtx (SImode);
3224 if (GET_CODE (operands[2]) == CONST_INT)
3226 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
3229 /* We have to adjust the operand order for the matching constraints. */
3230 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
3231 operands[1], operands[2]));
3237 [(set (match_operand:SI 0 "register_operand" "=d")
3240 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3241 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3243 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3244 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3247 (define_insn "const_umulsi3_highpart"
3248 [(set (match_operand:SI 0 "register_operand" "=d")
3251 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
3252 (match_operand:DI 3 "const_uint32_operand" "n"))
3254 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3255 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3258 (define_expand "smulsi3_highpart"
3260 [(set (match_operand:SI 0 "register_operand" "")
3263 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
3264 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
3266 (clobber (match_dup 3))])]
3267 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3269 operands[3] = gen_reg_rtx (SImode);
3270 if (GET_CODE (operands[2]) == CONST_INT)
3272 /* We have to adjust the operand order for the matching constraints. */
3273 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
3274 operands[1], operands[2]));
3280 [(set (match_operand:SI 0 "register_operand" "=d")
3283 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3284 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3286 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3287 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3290 (define_insn "const_smulsi3_highpart"
3291 [(set (match_operand:SI 0 "register_operand" "=d")
3294 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
3295 (match_operand:DI 3 "const_sint32_operand" "n"))
3297 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3298 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3301 (define_expand "mul<mode>3"
3302 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3303 (mult:FP (match_operand:FP 1 "general_operand" "")
3304 (match_operand:FP 2 "general_operand" "")))]
3308 (define_insn "mul<mode>3_floatsi_68881"
3309 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3310 (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
3311 (match_operand:FP 1 "general_operand" "0")))]
3315 ? "f<FP:round>mul%.l %2,%0"
3316 : "f<FP:round_mul>mul%.l %2,%0";
3318 [(set_attr "type" "fmul")
3319 (set_attr "opy" "2")])
3321 (define_insn "mul<mode>3_floathi_68881"
3322 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3323 (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
3324 (match_operand:FP 1 "general_operand" "0")))]
3328 ? "f<FP:round>mul%.w %2,%0"
3329 : "f<FP:round_mul>mul%.w %2,%0";
3331 [(set_attr "type" "fmul")
3332 (set_attr "opy" "2")])
3334 (define_insn "mul<mode>3_floatqi_68881"
3335 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3336 (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
3337 (match_operand:FP 1 "general_operand" "0")))]
3341 ? "f<FP:round>mul%.b %2,%0"
3342 : "f<FP:round_mul>mul%.b %2,%0";
3344 [(set_attr "type" "fmul")
3345 (set_attr "opy" "2")])
3347 (define_insn "muldf_68881"
3348 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3349 (mult:DF (match_operand:DF 1 "general_operand" "%0")
3350 (match_operand:DF 2 "general_operand" "fmG")))]
3353 if (GET_CODE (operands[2]) == CONST_DOUBLE
3354 && floating_exact_log2 (operands[2]) && !TUNE_68040_60)
3356 int i = floating_exact_log2 (operands[2]);
3357 operands[2] = GEN_INT (i);
3358 return "fscale%.l %2,%0";
3360 if (REG_P (operands[2]))
3361 return "f%&mul%.x %2,%0";
3362 return "f%&mul%.d %f2,%0";
3365 (define_insn "mulsf_68881"
3366 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3367 (mult:SF (match_operand:SF 1 "general_operand" "%0")
3368 (match_operand:SF 2 "general_operand" "fdmF")))]
3371 if (FP_REG_P (operands[2]))
3372 return (TARGET_68040
3374 : "fsglmul%.x %2,%0");
3375 return (TARGET_68040
3377 : "fsglmul%.s %f2,%0");
3380 (define_insn "mulxf3_68881"
3381 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
3382 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
3383 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
3386 return "fmul%.x %f2,%0";
3389 (define_insn "fmul<mode>3_cf"
3390 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3391 (mult:FP (match_operand:FP 1 "general_operand" "%0")
3392 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3393 "TARGET_COLDFIRE_FPU"
3395 if (FP_REG_P (operands[2]))
3396 return "f<FP:prec>mul%.d %2,%0";
3397 return "f<FP:prec>mul%.<FP:prec> %2,%0";
3399 [(set_attr "type" "fmul")
3400 (set_attr "opy" "2")])
3402 ;; divide instructions
3404 (define_expand "div<mode>3"
3405 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3406 (div:FP (match_operand:FP 1 "general_operand" "")
3407 (match_operand:FP 2 "general_operand" "")))]
3411 (define_insn "div<mode>3_floatsi_68881"
3412 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3413 (div:FP (match_operand:FP 1 "general_operand" "0")
3414 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
3418 ? "f<FP:round>div%.l %2,%0"
3419 : "f<FP:round_mul>div%.l %2,%0";
3422 (define_insn "div<mode>3_floathi_68881"
3423 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3424 (div:FP (match_operand:FP 1 "general_operand" "0")
3425 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
3429 ? "f<FP:round>div%.w %2,%0"
3430 : "f<FP:round_mul>div%.w %2,%0";
3433 (define_insn "div<mode>3_floatqi_68881"
3434 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3435 (div:FP (match_operand:FP 1 "general_operand" "0")
3436 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3440 ? "f<FP:round>div%.b %2,%0"
3441 : "f<FP:round_mul>div%.b %2,%0";
3444 (define_insn "div<mode>3_68881"
3445 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3446 (div:FP (match_operand:FP 1 "general_operand" "0")
3447 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3450 if (FP_REG_P (operands[2]))
3451 return (TARGET_68040
3452 ? "f<FP:round>div%.x %2,%0"
3453 : "f<FP:round_mul>div%.x %2,%0");
3454 return (TARGET_68040
3455 ? "f<FP:round>div%.<FP:prec> %f2,%0"
3456 : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
3459 (define_insn "div<mode>3_cf"
3460 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3461 (div:FP (match_operand:FP 1 "general_operand" "0")
3462 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3463 "TARGET_COLDFIRE_FPU"
3465 if (FP_REG_P (operands[2]))
3466 return "f<FP:prec>div%.d %2,%0";
3467 return "f<FP:prec>div%.<FP:prec> %2,%0";
3469 [(set_attr "type" "fdiv")
3470 (set_attr "opy" "2")])
3472 ;; Remainder instructions.
3474 (define_expand "divmodsi4"
3476 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3477 (div:SI (match_operand:SI 1 "general_operand" "")
3478 (match_operand:SI 2 "general_src_operand" "")))
3479 (set (match_operand:SI 3 "nonimmediate_operand" "")
3480 (mod:SI (match_dup 1) (match_dup 2)))])]
3481 "TARGET_68020 || TARGET_CF_HWDIV"
3485 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3486 (div:SI (match_operand:SI 1 "general_operand" "0")
3487 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3488 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3489 (mod:SI (match_dup 1) (match_dup 2)))]
3492 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3493 return "divs%.l %2,%0";
3494 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3495 return "rems%.l %2,%3:%0";
3497 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
3499 [(set_attr "type" "div_l")
3500 (set_attr "opy" "2")])
3503 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3504 (div:SI (match_operand:SI 1 "general_operand" "0")
3505 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3506 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3507 (mod:SI (match_dup 1) (match_dup 2)))]
3510 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3511 return "divs%.l %2,%0";
3513 return "divsl%.l %2,%3:%0";
3516 (define_expand "udivmodsi4"
3518 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3519 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3520 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3521 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3522 (umod:SI (match_dup 1) (match_dup 2)))])]
3523 "TARGET_68020 || TARGET_CF_HWDIV"
3527 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3528 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3529 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3530 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3531 (umod:SI (match_dup 1) (match_dup 2)))]
3534 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3535 return "divu%.l %2,%0";
3536 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3537 return "remu%.l %2,%3:%0";
3539 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3541 [(set_attr "type" "div_l")
3542 (set_attr "opy" "2")])
3545 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3546 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3547 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3548 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3549 (umod:SI (match_dup 1) (match_dup 2)))]
3550 "TARGET_68020 && !TARGET_COLDFIRE"
3552 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3553 return "divu%.l %2,%0";
3555 return "divul%.l %2,%3:%0";
3558 (define_insn "divmodhi4"
3559 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3560 (div:HI (match_operand:HI 1 "general_operand" "0")
3561 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3562 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3563 (mod:HI (match_dup 1) (match_dup 2)))]
3564 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3566 output_asm_insn (MOTOROLA ?
3567 "ext%.l %0\;divs%.w %2,%0" :
3568 "extl %0\;divs %2,%0",
3570 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3573 return "move%.l %0,%3\;swap %3";
3579 (define_insn "udivmodhi4"
3580 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3581 (udiv:HI (match_operand:HI 1 "general_operand" "0")
3582 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3583 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3584 (umod:HI (match_dup 1) (match_dup 2)))]
3585 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3587 if (ISA_HAS_MVS_MVZ)
3588 output_asm_insn (MOTOROLA ?
3589 "mvz%.w %0,%0\;divu%.w %2,%0" :
3590 "mvz%.w %0,%0\;divu %2,%0",
3593 output_asm_insn (MOTOROLA ?
3594 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3595 "and%.l #0xFFFF,%0\;divu %2,%0",
3598 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3601 return "move%.l %0,%3\;swap %3";
3607 ;; logical-and instructions
3609 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3610 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3611 ;; can't allocate pseudos into it.
3613 (define_expand "andsi3"
3614 [(set (match_operand:SI 0 "not_sp_operand" "")
3615 (and:SI (match_operand:SI 1 "general_operand" "")
3616 (match_operand:SI 2 "general_src_operand" "")))]
3620 ;; produced by split operations after reload finished
3621 (define_insn "*andsi3_split"
3622 [(set (match_operand:SI 0 "register_operand" "=d")
3623 (and:SI (match_operand:SI 1 "register_operand" "0")
3624 (match_operand:SI 2 "const_int_operand" "i")))]
3625 "reload_completed && !TARGET_COLDFIRE"
3627 return output_andsi3 (operands);
3630 (define_insn "andsi3_internal"
3631 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3632 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3633 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3636 return output_andsi3 (operands);
3639 (define_insn "andsi3_5200"
3640 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3641 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3642 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3646 && DATA_REG_P (operands[0])
3647 && GET_CODE (operands[2]) == CONST_INT)
3649 if (INTVAL (operands[2]) == 0x000000ff)
3650 return "mvz%.b %0,%0";
3651 else if (INTVAL (operands[2]) == 0x0000ffff)
3652 return "mvz%.w %0,%0";
3654 return output_andsi3 (operands);
3657 (define_insn "andhi3"
3658 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3659 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3660 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3665 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3666 (and:HI (match_dup 0)
3667 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3672 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3673 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3678 (define_insn "andqi3"
3679 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3680 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3681 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3686 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3687 (and:QI (match_dup 0)
3688 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3693 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3694 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3699 ;; inclusive-or instructions
3701 (define_insn "iordi_zext"
3702 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3703 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3704 (match_operand:DI 2 "general_operand" "0,0")))]
3710 if (GET_CODE (operands[0]) == REG)
3711 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3713 operands[0] = adjust_address (operands[0], SImode, 4);
3714 if (GET_MODE (operands[1]) == SImode)
3715 return "or%.l %1,%0";
3716 byte_mode = (GET_MODE (operands[1]) == QImode);
3717 if (GET_CODE (operands[0]) == MEM)
3718 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3721 return "or%.b %1,%0";
3723 return "or%.w %1,%0";
3726 (define_expand "iorsi3"
3727 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3728 (ior:SI (match_operand:SI 1 "general_operand" "")
3729 (match_operand:SI 2 "general_src_operand" "")))]
3733 (define_insn "iorsi3_internal"
3734 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3735 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3736 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3739 return output_iorsi3 (operands);
3742 (define_insn "iorsi3_5200"
3743 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3744 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3745 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3748 return output_iorsi3 (operands);
3751 (define_insn "iorhi3"
3752 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3753 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3754 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3759 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3760 (ior:HI (match_dup 0)
3761 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3766 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3767 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3772 (define_insn "iorqi3"
3773 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3774 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3775 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3780 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3781 (ior:QI (match_dup 0)
3782 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3787 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3788 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3793 ;; On all 68k models, this makes faster code in a special case.
3794 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3796 (define_insn "iorsi_zexthi_ashl16"
3797 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3798 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3799 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3804 if (GET_CODE (operands[2]) != REG)
3805 operands[2] = adjust_address (operands[2], HImode, 2);
3806 if (GET_CODE (operands[2]) != REG
3807 || REGNO (operands[2]) != REGNO (operands[0]))
3808 output_asm_insn ("move%.w %2,%0", operands);
3809 return "swap %0\;mov%.w %1,%0";
3812 (define_insn "iorsi_zext"
3813 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3814 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3815 (match_operand:SI 2 "general_operand" "0,0")))]
3821 byte_mode = (GET_MODE (operands[1]) == QImode);
3822 if (GET_CODE (operands[0]) == MEM)
3823 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3826 return "or%.b %1,%0";
3828 return "or%.w %1,%0";
3833 (define_expand "xorsi3"
3834 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3835 (xor:SI (match_operand:SI 1 "general_operand" "")
3836 (match_operand:SI 2 "general_operand" "")))]
3840 (define_insn "xorsi3_internal"
3841 [(set (match_operand:SI 0 "nonimmediate_operand" "=d,o,m")
3842 (xor:SI (match_operand:SI 1 "general_operand" "%0, 0,0")
3843 (match_operand:SI 2 "general_operand" "di,dK,dKT")))]
3847 return output_xorsi3 (operands);
3850 (define_insn "xorsi3_5200"
3851 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3852 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3853 (match_operand:SI 2 "general_operand" "d,Ks")))]
3856 return output_xorsi3 (operands);
3859 (define_insn "xorhi3"
3860 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3861 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3862 (match_operand:HI 2 "general_operand" "dn")))]
3867 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3868 (xor:HI (match_dup 0)
3869 (match_operand:HI 1 "general_operand" "dn")))]
3874 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3875 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3880 (define_insn "xorqi3"
3881 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3882 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3883 (match_operand:QI 2 "general_operand" "dn")))]
3888 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3889 (xor:QI (match_dup 0)
3890 (match_operand:QI 1 "general_operand" "dn")))]
3895 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3896 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3901 ;; negation instructions
3903 (define_expand "negdi2"
3904 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3905 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3908 if (TARGET_COLDFIRE)
3909 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3911 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3915 (define_insn "negdi2_internal"
3916 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3917 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3920 if (which_alternative == 0)
3921 return "neg%.l %0\;negx%.l %0";
3922 if (GET_CODE (operands[0]) == REG)
3923 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3925 operands[1] = adjust_address (operands[0], SImode, 4);
3926 if (ADDRESS_REG_P (operands[0]))
3927 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3929 return "neg%.l %1\;negx%.l %0";
3932 (define_insn "negdi2_5200"
3933 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3934 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3937 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3938 return "neg%.l %1\;negx%.l %0";
3941 (define_expand "negsi2"
3942 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3943 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3946 if (TARGET_COLDFIRE)
3947 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3949 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3953 (define_insn "negsi2_internal"
3954 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3955 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3958 [(set_attr "type" "neg_l")])
3960 (define_insn "negsi2_5200"
3961 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3962 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3965 [(set_attr "type" "neg_l")])
3967 (define_insn "neghi2"
3968 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3969 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3974 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3975 (neg:HI (match_dup 0)))]
3979 (define_insn "negqi2"
3980 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3981 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3986 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3987 (neg:QI (match_dup 0)))]
3991 ;; If using software floating point, just flip the sign bit.
3993 (define_expand "negsf2"
3994 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3995 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3998 if (!TARGET_HARD_FLOAT)
4003 target = operand_subword_force (operands[0], 0, SFmode);
4004 result = expand_binop (SImode, xor_optab,
4005 operand_subword_force (operands[1], 0, SFmode),
4006 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4007 gcc_assert (result);
4009 if (result != target)
4010 emit_move_insn (result, target);
4012 /* Make a place for REG_EQUAL. */
4013 emit_move_insn (operands[0], operands[0]);
4018 (define_expand "negdf2"
4019 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4020 (neg:DF (match_operand:DF 1 "general_operand" "")))]
4023 if (!TARGET_HARD_FLOAT)
4030 target = operand_subword (operands[0], 0, 1, DFmode);
4031 result = expand_binop (SImode, xor_optab,
4032 operand_subword_force (operands[1], 0, DFmode),
4033 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4034 gcc_assert (result);
4036 if (result != target)
4037 emit_move_insn (result, target);
4039 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4040 operand_subword_force (operands[1], 1, DFmode));
4042 insns = get_insns ();
4050 (define_expand "negxf2"
4051 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4052 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4062 target = operand_subword (operands[0], 0, 1, XFmode);
4063 result = expand_binop (SImode, xor_optab,
4064 operand_subword_force (operands[1], 0, XFmode),
4065 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4066 gcc_assert (result);
4068 if (result != target)
4069 emit_move_insn (result, target);
4071 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4072 operand_subword_force (operands[1], 1, XFmode));
4073 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4074 operand_subword_force (operands[1], 2, XFmode));
4076 insns = get_insns ();
4084 (define_insn "neg<mode>2_68881"
4085 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4086 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4089 if (DATA_REG_P (operands[0]))
4091 operands[1] = GEN_INT (31);
4092 return "bchg %1,%0";
4094 if (FP_REG_P (operands[1]))
4095 return "f<FP:round>neg%.x %1,%0";
4096 return "f<FP:round>neg%.<FP:prec> %f1,%0";
4099 (define_insn "neg<mode>2_cf"
4100 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4101 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4102 "TARGET_COLDFIRE_FPU"
4104 if (DATA_REG_P (operands[0]))
4106 operands[1] = GEN_INT (31);
4107 return "bchg %1,%0";
4109 if (FP_REG_P (operands[1]))
4110 return "f<FP:prec>neg%.d %1,%0";
4111 return "f<FP:prec>neg%.<FP:prec> %1,%0";
4114 ;; Sqrt instruction for the 68881
4116 (define_expand "sqrt<mode>2"
4117 [(set (match_operand:FP 0 "nonimmediate_operand" "")
4118 (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
4122 (define_insn "sqrt<mode>2_68881"
4123 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4124 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
4127 if (FP_REG_P (operands[1]))
4128 return "f<FP:round>sqrt%.x %1,%0";
4129 return "f<FP:round>sqrt%.<FP:prec> %1,%0";
4131 [(set_attr "type" "fsqrt")])
4133 (define_insn "sqrt<mode>2_cf"
4134 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4135 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
4136 "TARGET_COLDFIRE_FPU"
4138 if (FP_REG_P (operands[1]))
4139 return "f<FP:prec>sqrt%.d %1,%0";
4140 return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
4142 [(set_attr "type" "fsqrt")])
4143 ;; Absolute value instructions
4144 ;; If using software floating point, just zero the sign bit.
4146 (define_expand "abssf2"
4147 [(set (match_operand:SF 0 "nonimmediate_operand" "")
4148 (abs:SF (match_operand:SF 1 "general_operand" "")))]
4151 if (!TARGET_HARD_FLOAT)
4156 target = operand_subword_force (operands[0], 0, SFmode);
4157 result = expand_binop (SImode, and_optab,
4158 operand_subword_force (operands[1], 0, SFmode),
4159 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4160 gcc_assert (result);
4162 if (result != target)
4163 emit_move_insn (result, target);
4165 /* Make a place for REG_EQUAL. */
4166 emit_move_insn (operands[0], operands[0]);
4171 (define_expand "absdf2"
4172 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4173 (abs:DF (match_operand:DF 1 "general_operand" "")))]
4176 if (!TARGET_HARD_FLOAT)
4183 target = operand_subword (operands[0], 0, 1, DFmode);
4184 result = expand_binop (SImode, and_optab,
4185 operand_subword_force (operands[1], 0, DFmode),
4186 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4187 gcc_assert (result);
4189 if (result != target)
4190 emit_move_insn (result, target);
4192 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4193 operand_subword_force (operands[1], 1, DFmode));
4195 insns = get_insns ();
4203 (define_expand "absxf2"
4204 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4205 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4215 target = operand_subword (operands[0], 0, 1, XFmode);
4216 result = expand_binop (SImode, and_optab,
4217 operand_subword_force (operands[1], 0, XFmode),
4218 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4219 gcc_assert (result);
4221 if (result != target)
4222 emit_move_insn (result, target);
4224 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4225 operand_subword_force (operands[1], 1, XFmode));
4226 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4227 operand_subword_force (operands[1], 2, XFmode));
4229 insns = get_insns ();
4237 (define_insn "abs<mode>2_68881"
4238 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4239 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4242 if (DATA_REG_P (operands[0]))
4244 operands[1] = GEN_INT (31);
4245 return "bclr %1,%0";
4247 if (FP_REG_P (operands[1]))
4248 return "f<FP:round>abs%.x %1,%0";
4249 return "f<FP:round>abs%.<FP:prec> %f1,%0";
4252 (define_insn "abs<mode>2_cf"
4253 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4254 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4255 "TARGET_COLDFIRE_FPU"
4257 if (DATA_REG_P (operands[0]))
4259 operands[1] = GEN_INT (31);
4260 return "bclr %1,%0";
4262 if (FP_REG_P (operands[1]))
4263 return "f<FP:prec>abs%.d %1,%0";
4264 return "f<FP:prec>abs%.<FP:prec> %1,%0";
4266 [(set_attr "type" "bitrw,fneg")])
4268 ;; bit indexing instructions
4270 (define_expand "clzsi2"
4271 [(set (match_operand:SI 0 "register_operand" "")
4272 (clz:SI (match_operand:SI 1 "general_operand" "")))]
4273 "ISA_HAS_FF1 || (TARGET_68020 && TARGET_BITFIELD)"
4276 operands[1] = force_reg (SImode, operands[1]);
4279 (define_insn "*clzsi2_68k"
4280 [(set (match_operand:SI 0 "register_operand" "=d")
4281 (clz:SI (match_operand:SI 1 "general_operand" "do")))]
4282 "TARGET_68020 && TARGET_BITFIELD"
4285 return "bfffo %1{#0:#0},%0";
4288 ;; ColdFire ff1 instruction implements clz.
4289 (define_insn "*clzsi2_cf"
4290 [(set (match_operand:SI 0 "register_operand" "=d")
4291 (clz:SI (match_operand:SI 1 "register_operand" "0")))]
4297 [(set_attr "type" "ext")])
4299 ;; one complement instructions
4301 (define_expand "one_cmplsi2"
4302 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4303 (not:SI (match_operand:SI 1 "general_operand" "")))]
4306 if (TARGET_COLDFIRE)
4307 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
4309 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
4313 (define_insn "one_cmplsi2_internal"
4314 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4315 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4319 (define_insn "one_cmplsi2_5200"
4320 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4321 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4324 [(set_attr "type" "neg_l")])
4326 (define_insn "one_cmplhi2"
4327 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4328 (not:HI (match_operand:HI 1 "general_operand" "0")))]
4333 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4334 (not:HI (match_dup 0)))]
4338 (define_insn "one_cmplqi2"
4339 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4340 (not:QI (match_operand:QI 1 "general_operand" "0")))]
4345 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4346 (not:QI (match_dup 0)))]
4350 ;; arithmetic shift instructions
4351 ;; We don't need the shift memory by 1 bit instruction
4352 (define_insn_and_split "ashldi_extsi"
4353 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4355 (match_operator:DI 2 "extend_operator"
4356 [(match_operand:SI 1 "general_operand" "rm")])
4360 "&& reload_completed"
4361 [(set (match_dup 3) (match_dup 1))
4362 (set (match_dup 2) (const_int 0))]
4363 "split_di(operands, 1, operands + 2, operands + 3);")
4365 (define_insn "ashldi_sexthi"
4366 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
4367 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
4369 (clobber (match_scratch:SI 2 "=a,X"))]
4373 if (GET_CODE (operands[0]) == MEM)
4375 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4376 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
4377 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4378 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
4381 operands[3] = adjust_address (operands[0], SImode, 4);
4382 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
4385 else if (DATA_REG_P (operands[0]))
4386 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
4388 return "move%.w %1,%0\;sub%.l %R0,%R0";
4391 (define_insn "*ashldi3_const1"
4392 [(set (match_operand:DI 0 "register_operand" "=d")
4393 (ashift:DI (match_operand:DI 1 "register_operand" "0")
4396 "add%.l %R0,%R0\;addx%.l %0,%0")
4399 [(set (match_operand:DI 0 "register_operand" "")
4400 (ashift:DI (match_operand:DI 1 "register_operand" "")
4402 "reload_completed && !TARGET_COLDFIRE"
4404 (ashift:DI (match_dup 1) (const_int 1)))
4406 (ashift:DI (match_dup 0) (const_int 1)))]
4410 [(set (match_operand:DI 0 "register_operand" "")
4411 (ashift:DI (match_operand:DI 1 "register_operand" "")
4413 "reload_completed && !TARGET_COLDFIRE"
4415 (ashift:DI (match_dup 1) (const_int 2)))
4417 (ashift:DI (match_dup 0) (const_int 1)))]
4421 [(set (match_operand:DI 0 "register_operand" "")
4422 (ashift:DI (match_operand:DI 1 "register_operand" "")
4424 "reload_completed && !TARGET_COLDFIRE"
4426 (rotate:SI (match_dup 2) (const_int 8)))
4428 (rotate:SI (match_dup 3) (const_int 8)))
4429 (set (strict_low_part (subreg:QI (match_dup 0) 3))
4430 (subreg:QI (match_dup 0) 7))
4431 (set (strict_low_part (subreg:QI (match_dup 0) 7))
4434 operands[2] = gen_highpart (SImode, operands[0]);
4435 operands[3] = gen_lowpart (SImode, operands[0]);
4439 [(set (match_operand:DI 0 "register_operand" "")
4440 (ashift:DI (match_operand:DI 1 "register_operand" "")
4442 "reload_completed && !TARGET_COLDFIRE"
4444 (rotate:SI (match_dup 2) (const_int 16)))
4446 (rotate:SI (match_dup 3) (const_int 16)))
4447 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4448 (subreg:HI (match_dup 0) 6))
4449 (set (strict_low_part (subreg:HI (match_dup 0) 6))
4452 operands[2] = gen_highpart (SImode, operands[0]);
4453 operands[3] = gen_lowpart (SImode, operands[0]);
4457 [(set (match_operand:DI 0 "pre_dec_operand" "")
4458 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4461 [(set (match_dup 0) (const_int 0))
4462 (set (match_dup 0) (match_dup 1))]
4464 operands[0] = adjust_address(operands[0], SImode, 0);
4465 operands[1] = gen_lowpart(SImode, operands[1]);
4469 [(set (match_operand:DI 0 "post_inc_operand" "")
4470 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4473 [(set (match_dup 0) (match_dup 1))
4474 (set (match_dup 0) (const_int 0))]
4476 operands[0] = adjust_address(operands[0], SImode, 0);
4477 operands[1] = gen_lowpart(SImode, operands[1]);
4480 (define_insn_and_split "*ashldi3_const32"
4481 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
4482 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
4486 "&& reload_completed"
4487 [(set (match_dup 4) (match_dup 3))
4488 (set (match_dup 2) (const_int 0))]
4489 "split_di(operands, 2, operands + 2, operands + 4);")
4492 [(set (match_operand:DI 0 "register_operand" "")
4493 (ashift:DI (match_operand:DI 1 "register_operand" "")
4494 (match_operand 2 "const_int_operand" "")))]
4495 "reload_completed && !TARGET_COLDFIRE
4496 && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
4497 [(set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 2)))
4498 (set (match_dup 3) (match_dup 4))
4499 (set (match_dup 4) (const_int 0))]
4501 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4502 operands[3] = gen_highpart (SImode, operands[0]);
4503 operands[4] = gen_lowpart (SImode, operands[0]);
4507 [(set (match_operand:DI 0 "register_operand" "")
4508 (ashift:DI (match_operand:DI 1 "register_operand" "")
4510 "reload_completed && !TARGET_COLDFIRE"
4511 [(set (match_dup 2) (match_dup 3))
4513 (rotate:SI (match_dup 2) (const_int 16)))
4514 (set (match_dup 3) (const_int 0))
4515 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4518 operands[2] = gen_highpart (SImode, operands[0]);
4519 operands[3] = gen_lowpart (SImode, operands[0]);
4523 [(set (match_operand:DI 0 "register_operand" "")
4524 (ashift:DI (match_operand:DI 1 "register_operand" "")
4525 (match_operand 2 "const_int_operand" "")))]
4526 "reload_completed && !TARGET_COLDFIRE
4527 && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 63"
4528 [(set (match_dup 3) (match_dup 2))
4529 (set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 3)))
4530 (set (match_dup 3) (match_dup 4))
4531 (set (match_dup 4) (const_int 0))]
4533 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4534 operands[3] = gen_highpart (SImode, operands[0]);
4535 operands[4] = gen_lowpart (SImode, operands[0]);
4538 (define_insn "*ashldi3"
4539 [(set (match_operand:DI 0 "register_operand" "=d")
4540 (ashift:DI (match_operand:DI 1 "register_operand" "0")
4541 (match_operand 2 "const_int_operand" "n")))]
4543 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4544 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4545 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4548 (define_expand "ashldi3"
4549 [(set (match_operand:DI 0 "register_operand" "")
4550 (ashift:DI (match_operand:DI 1 "register_operand" "")
4551 (match_operand 2 "const_int_operand" "")))]
4554 /* ??? This is a named pattern like this is not allowed to FAIL based
4556 if (GET_CODE (operands[2]) != CONST_INT
4557 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4558 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4559 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4563 ;; On most 68k models, this makes faster code in a special case.
4565 (define_insn "ashlsi_16"
4566 [(set (match_operand:SI 0 "register_operand" "=d")
4567 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4572 return "swap %0\;clr%.w %0";
4575 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
4576 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4578 ;; On the 68000, this makes faster code in a special case.
4580 (define_insn "ashlsi_17_24"
4581 [(set (match_operand:SI 0 "register_operand" "=d")
4582 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4583 (match_operand:SI 2 "const_int_operand" "n")))]
4585 && INTVAL (operands[2]) > 16
4586 && INTVAL (operands[2]) <= 24"
4590 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4591 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4594 (define_insn "ashlsi3"
4595 [(set (match_operand:SI 0 "register_operand" "=d")
4596 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4597 (match_operand:SI 2 "general_operand" "dI")))]
4600 if (operands[2] == const1_rtx)
4602 cc_status.flags = CC_NO_OVERFLOW;
4603 return "add%.l %0,%0";
4605 return "lsl%.l %2,%0";
4608 (define_insn "ashlhi3"
4609 [(set (match_operand:HI 0 "register_operand" "=d")
4610 (ashift:HI (match_operand:HI 1 "register_operand" "0")
4611 (match_operand:HI 2 "general_operand" "dI")))]
4616 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4617 (ashift:HI (match_dup 0)
4618 (match_operand:HI 1 "general_operand" "dI")))]
4622 (define_insn "ashlqi3"
4623 [(set (match_operand:QI 0 "register_operand" "=d")
4624 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4625 (match_operand:QI 2 "general_operand" "dI")))]
4630 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4631 (ashift:QI (match_dup 0)
4632 (match_operand:QI 1 "general_operand" "dI")))]
4636 ;; On most 68k models, this makes faster code in a special case.
4638 (define_insn "ashrsi_16"
4639 [(set (match_operand:SI 0 "register_operand" "=d")
4640 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4643 "swap %0\;ext%.l %0")
4645 ;; On the 68000, this makes faster code in a special case.
4648 [(set (match_operand:SI 0 "register_operand" "=d")
4649 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4650 (match_operand:SI 2 "const_int_operand" "n")))]
4652 && INTVAL (operands[2]) > 16
4653 && INTVAL (operands[2]) <= 24"
4655 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4656 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4659 (define_insn "subreghi1ashrdi_const32"
4660 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4661 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4662 (const_int 32)) 6))]
4665 if (GET_CODE (operands[1]) != REG)
4666 operands[1] = adjust_address (operands[1], HImode, 2);
4667 return "move%.w %1,%0";
4669 [(set_attr "type" "move")])
4671 (define_insn "subregsi1ashrdi_const32"
4672 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4673 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4674 (const_int 32)) 4))]
4677 return "move%.l %1,%0";
4679 [(set_attr "type" "move_l")])
4681 (define_insn "*ashrdi3_const1"
4682 [(set (match_operand:DI 0 "register_operand" "=d")
4683 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4687 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4688 return "asr%.l #1,%0\;roxr%.l #1,%1";
4692 [(set (match_operand:DI 0 "register_operand" "")
4693 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4695 "reload_completed && !TARGET_COLDFIRE"
4697 (ashiftrt:DI (match_dup 1) (const_int 1)))
4699 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4703 [(set (match_operand:DI 0 "register_operand" "")
4704 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4706 "reload_completed && !TARGET_COLDFIRE"
4708 (ashiftrt:DI (match_dup 1) (const_int 2)))
4710 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4714 [(set (match_operand:DI 0 "register_operand" "")
4715 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4717 "reload_completed && !TARGET_COLDFIRE"
4718 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4719 (subreg:QI (match_dup 0) 3))
4721 (ashiftrt:SI (match_dup 2) (const_int 8)))
4723 (rotatert:SI (match_dup 3) (const_int 8)))]
4725 operands[2] = gen_highpart (SImode, operands[0]);
4726 operands[3] = gen_lowpart (SImode, operands[0]);
4730 [(set (match_operand:DI 0 "register_operand" "")
4731 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4733 "reload_completed && !TARGET_COLDFIRE"
4734 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4735 (subreg:HI (match_dup 0) 2))
4737 (rotate:SI (match_dup 2) (const_int 16)))
4739 (rotate:SI (match_dup 3) (const_int 16)))
4741 (sign_extend:SI (subreg:HI (match_dup 2) 2)))]
4743 operands[2] = gen_highpart (SImode, operands[0]);
4744 operands[3] = gen_lowpart (SImode, operands[0]);
4747 (define_insn "*ashrdi_const32"
4748 [(set (match_operand:DI 0 "register_operand" "=d")
4749 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro")
4755 return "move%.l %1,%R0\;smi %0\;extb%.l %0";
4757 return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
4760 (define_insn "*ashrdi_const32_mem"
4761 [(set (match_operand:DI 0 "memory_operand" "=o,<")
4762 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro,ro")
4764 (clobber (match_scratch:SI 2 "=d,d"))]
4768 operands[3] = adjust_address (operands[0], SImode,
4769 which_alternative == 0 ? 4 : 0);
4770 operands[0] = adjust_address (operands[0], SImode, 0);
4771 if (TARGET_68020 || TARGET_COLDFIRE)
4772 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4774 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4778 [(set (match_operand:DI 0 "register_operand" "")
4779 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4781 "reload_completed && !TARGET_COLDFIRE"
4783 (ashiftrt:SI (match_dup 3) (const_int 31)))
4786 "split_di(operands, 1, operands + 2, operands + 3);")
4788 ;; The predicate below must be general_operand, because ashrdi3 allows that
4789 (define_insn "ashrdi_const"
4790 [(set (match_operand:DI 0 "register_operand" "=d")
4791 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4792 (match_operand 2 "const_int_operand" "n")))]
4794 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4795 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4796 || INTVAL (operands[2]) == 31
4797 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4799 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4801 if (INTVAL (operands[2]) == 48)
4802 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4803 if (INTVAL (operands[2]) == 31)
4804 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4805 if (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)
4807 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4808 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4809 "moveq %2,%1\;asr%.l %1,%0", operands);
4810 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4811 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4812 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4817 (define_expand "ashrdi3"
4818 [(set (match_operand:DI 0 "register_operand" "")
4819 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4820 (match_operand 2 "const_int_operand" "")))]
4823 /* ??? This is a named pattern like this is not allowed to FAIL based
4825 if (GET_CODE (operands[2]) != CONST_INT
4826 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4827 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4828 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4832 ;; On all 68k models, this makes faster code in a special case.
4834 (define_insn "ashrsi_31"
4835 [(set (match_operand:SI 0 "register_operand" "=d")
4836 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4840 return "add%.l %0,%0\;subx%.l %0,%0";
4843 (define_insn "ashrsi3"
4844 [(set (match_operand:SI 0 "register_operand" "=d")
4845 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4846 (match_operand:SI 2 "general_operand" "dI")))]
4849 [(set_attr "type" "shift")
4850 (set_attr "opy" "2")])
4852 (define_insn "ashrhi3"
4853 [(set (match_operand:HI 0 "register_operand" "=d")
4854 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4855 (match_operand:HI 2 "general_operand" "dI")))]
4860 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4861 (ashiftrt:HI (match_dup 0)
4862 (match_operand:HI 1 "general_operand" "dI")))]
4866 (define_insn "ashrqi3"
4867 [(set (match_operand:QI 0 "register_operand" "=d")
4868 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4869 (match_operand:QI 2 "general_operand" "dI")))]
4874 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4875 (ashiftrt:QI (match_dup 0)
4876 (match_operand:QI 1 "general_operand" "dI")))]
4880 ;; logical shift instructions
4882 ;; commented out because of reload problems in 950612-1.c
4885 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4886 ;; (const_int 32)) 4))
4887 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4888 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4889 ;; (const_int 32)) 4))]
4892 ;; return "move%.l %0,%1";
4897 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4898 ;; (const_int 32)) 0))
4899 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4900 ;; (lshiftrt:DI (match_dup 0)
4901 ;; (const_int 32)))]
4904 ;; if (GET_CODE (operands[1]) == REG)
4905 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4907 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4908 ;; return "move%.l %0,%2\;clr%.l %1";
4911 (define_insn "subreg1lshrdi_const32"
4912 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4913 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4914 (const_int 32)) 4))]
4917 [(set_attr "type" "move_l")])
4919 (define_insn "*lshrdi3_const1"
4920 [(set (match_operand:DI 0 "register_operand" "=d")
4921 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
4924 "lsr%.l #1,%0\;roxr%.l #1,%R0")
4927 [(set (match_operand:DI 0 "register_operand" "")
4928 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4930 "reload_completed && !TARGET_COLDFIRE"
4932 (lshiftrt:DI (match_dup 1) (const_int 1)))
4934 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4938 [(set (match_operand:DI 0 "register_operand" "")
4939 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4941 "reload_completed && !TARGET_COLDFIRE"
4943 (lshiftrt:DI (match_dup 1) (const_int 2)))
4945 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4949 [(set (match_operand:DI 0 "register_operand" "")
4950 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4952 "reload_completed && !TARGET_COLDFIRE"
4953 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4954 (subreg:QI (match_dup 0) 3))
4956 (lshiftrt:SI (match_dup 2) (const_int 8)))
4958 (rotatert:SI (match_dup 3) (const_int 8)))]
4960 operands[2] = gen_highpart (SImode, operands[0]);
4961 operands[3] = gen_lowpart (SImode, operands[0]);
4965 [(set (match_operand:DI 0 "register_operand" "")
4966 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4968 "reload_completed && !TARGET_COLDFIRE"
4969 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4970 (subreg:HI (match_dup 0) 2))
4971 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4974 (rotate:SI (match_dup 3) (const_int 16)))
4976 (rotate:SI (match_dup 2) (const_int 16)))]
4978 operands[2] = gen_highpart (SImode, operands[0]);
4979 operands[3] = gen_lowpart (SImode, operands[0]);
4983 [(set (match_operand:DI 0 "pre_dec_operand" "")
4984 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
4987 [(set (match_dup 0) (match_dup 1))
4988 (set (match_dup 0) (const_int 0))]
4990 operands[0] = adjust_address(operands[0], SImode, 0);
4991 operands[1] = gen_highpart(SImode, operands[1]);
4995 [(set (match_operand:DI 0 "post_inc_operand" "")
4996 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
4999 [(set (match_dup 0) (const_int 0))
5000 (set (match_dup 0) (match_dup 1))]
5002 operands[0] = adjust_address(operands[0], SImode, 0);
5003 operands[1] = gen_highpart(SImode, operands[1]);
5007 [(set (match_operand:DI 0 "nonimmediate_operand" "")
5008 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5011 [(set (match_dup 2) (match_dup 5))
5012 (set (match_dup 4) (const_int 0))]
5013 "split_di(operands, 2, operands + 2, operands + 4);")
5015 (define_insn "*lshrdi_const32"
5016 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
5017 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
5023 [(set (match_operand:DI 0 "register_operand" "")
5024 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5025 (match_operand 2 "const_int_operand" "")))]
5026 "reload_completed && !TARGET_COLDFIRE
5027 && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
5028 [(set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 2)))
5029 (set (match_dup 4) (match_dup 3))
5030 (set (match_dup 3) (const_int 0))]
5032 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5033 operands[3] = gen_highpart (SImode, operands[0]);
5034 operands[4] = gen_lowpart (SImode, operands[0]);
5038 [(set (match_operand:DI 0 "register_operand" "")
5039 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5042 [(set (match_dup 3) (match_dup 2))
5043 (set (strict_low_part (subreg:HI (match_dup 0) 6))
5045 (set (match_dup 2) (const_int 0))
5047 (rotate:SI (match_dup 3) (const_int 16)))]
5049 operands[2] = gen_highpart (SImode, operands[0]);
5050 operands[3] = gen_lowpart (SImode, operands[0]);
5054 [(set (match_operand:DI 0 "register_operand" "")
5055 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5056 (match_operand 2 "const_int_operand" "")))]
5057 "reload_completed && !TARGET_COLDFIRE
5058 && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 62"
5059 [(set (match_dup 4) (match_dup 2))
5060 (set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 4)))
5061 (set (match_dup 4) (match_dup 3))
5062 (set (match_dup 3) (const_int 0))]
5064 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5065 operands[3] = gen_highpart (SImode, operands[0]);
5066 operands[4] = gen_lowpart (SImode, operands[0]);
5069 (define_insn "*lshrdi_const63"
5070 [(set (match_operand:DI 0 "register_operand" "=d")
5071 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5074 "add%.l %0,%0\;clr%.l %0\;clr%.l %R1\;addx%.l %R1,%R1")
5076 (define_insn "*lshrdi3_const"
5077 [(set (match_operand:DI 0 "register_operand" "=d")
5078 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5079 (match_operand 2 "const_int_operand" "n")))]
5081 && ((INTVAL (operands[2]) >= 2 && INTVAL (operands[2]) <= 3)
5082 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
5083 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
5086 (define_expand "lshrdi3"
5087 [(set (match_operand:DI 0 "register_operand" "")
5088 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5089 (match_operand 2 "const_int_operand" "")))]
5092 /* ??? This is a named pattern like this is not allowed to FAIL based
5094 if (GET_CODE (operands[2]) != CONST_INT
5095 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
5096 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
5097 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
5101 ;; On all 68k models, this makes faster code in a special case.
5103 (define_insn "lshrsi_31"
5104 [(set (match_operand:SI 0 "register_operand" "=d")
5105 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5109 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
5112 ;; On most 68k models, this makes faster code in a special case.
5114 (define_insn "lshrsi_16"
5115 [(set (match_operand:SI 0 "register_operand" "=d")
5116 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5121 return "clr%.w %0\;swap %0";
5124 ;; On the 68000, this makes faster code in a special case.
5126 (define_insn "lshrsi_17_24"
5127 [(set (match_operand:SI 0 "register_operand" "=d")
5128 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5129 (match_operand:SI 2 "const_int_operand" "n")))]
5131 && INTVAL (operands[2]) > 16
5132 && INTVAL (operands[2]) <= 24"
5134 /* I think lsr%.w sets the CC properly. */
5135 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
5136 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
5139 (define_insn "lshrsi3"
5140 [(set (match_operand:SI 0 "register_operand" "=d")
5141 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5142 (match_operand:SI 2 "general_operand" "dI")))]
5145 [(set_attr "type" "shift")
5146 (set_attr "opy" "2")])
5148 (define_insn "lshrhi3"
5149 [(set (match_operand:HI 0 "register_operand" "=d")
5150 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
5151 (match_operand:HI 2 "general_operand" "dI")))]
5156 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5157 (lshiftrt:HI (match_dup 0)
5158 (match_operand:HI 1 "general_operand" "dI")))]
5162 (define_insn "lshrqi3"
5163 [(set (match_operand:QI 0 "register_operand" "=d")
5164 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
5165 (match_operand:QI 2 "general_operand" "dI")))]
5170 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5171 (lshiftrt:QI (match_dup 0)
5172 (match_operand:QI 1 "general_operand" "dI")))]
5176 ;; rotate instructions
5178 (define_insn "rotlsi_16"
5179 [(set (match_operand:SI 0 "register_operand" "=d")
5180 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5184 [(set_attr "type" "shift")])
5186 (define_insn "rotlsi3"
5187 [(set (match_operand:SI 0 "register_operand" "=d")
5188 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5189 (match_operand:SI 2 "general_operand" "dINO")))]
5192 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
5194 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
5196 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
5197 return "ror%.l %2,%0";
5200 return "rol%.l %2,%0";
5203 (define_insn "rotlhi3"
5204 [(set (match_operand:HI 0 "register_operand" "=d")
5205 (rotate:HI (match_operand:HI 1 "register_operand" "0")
5206 (match_operand:HI 2 "general_operand" "dIP")))]
5209 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5211 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5212 return "ror%.w %2,%0";
5215 return "rol%.w %2,%0";
5218 (define_insn "*rotlhi3_lowpart"
5219 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5220 (rotate:HI (match_dup 0)
5221 (match_operand:HI 1 "general_operand" "dIP")))]
5224 if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) >= 8)
5226 operands[1] = GEN_INT (16 - INTVAL (operands[1]));
5227 return "ror%.w %1,%0";
5230 return "rol%.w %1,%0";
5233 (define_insn "rotlqi3"
5234 [(set (match_operand:QI 0 "register_operand" "=d")
5235 (rotate:QI (match_operand:QI 1 "register_operand" "0")
5236 (match_operand:QI 2 "general_operand" "dI")))]
5239 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5241 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5242 return "ror%.b %2,%0";
5245 return "rol%.b %2,%0";
5248 (define_insn "*rotlqi3_lowpart"
5249 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5250 (rotate:QI (match_dup 0)
5251 (match_operand:QI 1 "general_operand" "dI")))]
5254 if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) >= 4)
5256 operands[1] = GEN_INT (8 - INTVAL (operands[1]));
5257 return "ror%.b %1,%0";
5260 return "rol%.b %1,%0";
5263 (define_insn "rotrsi3"
5264 [(set (match_operand:SI 0 "register_operand" "=d")
5265 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
5266 (match_operand:SI 2 "general_operand" "dI")))]
5270 (define_insn "rotrhi3"
5271 [(set (match_operand:HI 0 "register_operand" "=d")
5272 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
5273 (match_operand:HI 2 "general_operand" "dI")))]
5277 (define_insn "rotrhi_lowpart"
5278 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5279 (rotatert:HI (match_dup 0)
5280 (match_operand:HI 1 "general_operand" "dI")))]
5284 (define_insn "rotrqi3"
5285 [(set (match_operand:QI 0 "register_operand" "=d")
5286 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
5287 (match_operand:QI 2 "general_operand" "dI")))]
5292 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5293 (rotatert:QI (match_dup 0)
5294 (match_operand:QI 1 "general_operand" "dI")))]
5298 (define_expand "bswapsi2"
5299 [(set (match_operand:SI 0 "register_operand")
5300 (bswap:SI (match_operand:SI 1 "register_operand")))]
5303 rtx x = operands[0];
5304 emit_move_insn (x, operands[1]);
5305 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5306 emit_insn (gen_rotlsi3 (x, x, GEN_INT (16)));
5307 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5312 ;; Bit set/clear in memory byte.
5314 ;; set bit, bit number is int
5315 (define_insn "bsetmemqi"
5316 [(set (match_operand:QI 0 "memory_operand" "+m")
5317 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5318 (match_operand:SI 1 "general_operand" "d")) 3)
5323 return "bset %1,%0";
5325 [(set_attr "type" "bitrw")])
5327 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
5328 (define_insn "*bsetmemqi_ext"
5329 [(set (match_operand:QI 0 "memory_operand" "+m")
5330 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5331 (match_operator:SI 2 "extend_operator"
5332 [(match_operand 1 "general_operand" "d")])) 3)
5337 return "bset %1,%0";
5339 [(set_attr "type" "bitrw")])
5341 ;; clear bit, bit number is int
5342 (define_insn "bclrmemqi"
5343 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5345 (minus:SI (const_int 7)
5346 (match_operand:SI 1 "general_operand" "d")))
5351 return "bclr %1,%0";
5353 [(set_attr "type" "bitrw")])
5355 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
5356 (define_insn "*bclrmemqi_ext"
5357 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5359 (minus:SI (const_int 7)
5360 (match_operator:SI 2 "extend_operator"
5361 [(match_operand 1 "general_operand" "d")])))
5366 return "bclr %1,%0";
5368 [(set_attr "type" "bitrw")])
5370 ;; Special cases of bit-field insns which we should
5371 ;; recognize in preference to the general case.
5372 ;; These handle aligned 8-bit and 16-bit fields,
5373 ;; which can usually be done with move instructions.
5376 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5377 ; alignment of structure members is specified.
5379 ; The move is allowed to be odd byte aligned, because that's still faster
5380 ; than an odd byte aligned bit-field instruction.
5382 (define_insn "*insv_32_mem"
5383 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5385 (match_operand:SI 1 "const_int_operand" "n"))
5386 (match_operand:SI 2 "general_src_operand" "rmSi"))]
5387 "TARGET_68020 && TARGET_BITFIELD
5388 && (INTVAL (operands[1]) % 8) == 0
5389 && ! mode_dependent_address_p (XEXP (operands[0], 0),
5390 MEM_ADDR_SPACE (operands[0]))"
5393 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
5395 return "move%.l %2,%0";
5398 (define_insn "*insv_8_16_reg"
5399 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5400 (match_operand:SI 1 "const_int_operand" "n")
5401 (match_operand:SI 2 "const_int_operand" "n"))
5402 (match_operand:SI 3 "register_operand" "d"))]
5403 "TARGET_68020 && TARGET_BITFIELD
5404 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
5405 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0"
5407 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
5408 return "bfins %3,%0{%b2:%b1}";
5410 if (INTVAL (operands[1]) == 8)
5411 return "move%.b %3,%0";
5412 return "move%.w %3,%0";
5417 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5418 ; alignment of structure members is specified.
5420 ; The move is allowed to be odd byte aligned, because that's still faster
5421 ; than an odd byte aligned bit-field instruction.
5423 (define_insn "*extzv_32_mem"
5424 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5425 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5427 (match_operand:SI 2 "const_int_operand" "n")))]
5428 "TARGET_68020 && TARGET_BITFIELD
5429 && (INTVAL (operands[2]) % 8) == 0
5430 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5431 MEM_ADDR_SPACE (operands[1]))"
5434 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5436 return "move%.l %1,%0";
5439 (define_insn "*extzv_8_16_reg"
5440 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
5441 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5442 (match_operand:SI 2 "const_int_operand" "n")
5443 (match_operand:SI 3 "const_int_operand" "n")))]
5444 "TARGET_68020 && TARGET_BITFIELD
5445 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5446 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5448 cc_status.flags |= CC_NOT_NEGATIVE;
5449 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5450 return "bfextu %1{%b3:%b2},%0";
5452 output_asm_insn ("clr%.l %0", operands);
5453 if (INTVAL (operands[2]) == 8)
5454 return "move%.b %1,%0";
5455 return "move%.w %1,%0";
5459 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5460 ; alignment of structure members is specified.
5462 ; The move is allowed to be odd byte aligned, because that's still faster
5463 ; than an odd byte aligned bit-field instruction.
5465 (define_insn "*extv_32_mem"
5466 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5467 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5469 (match_operand:SI 2 "const_int_operand" "n")))]
5470 "TARGET_68020 && TARGET_BITFIELD
5471 && (INTVAL (operands[2]) % 8) == 0
5472 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5473 MEM_ADDR_SPACE (operands[1]))"
5476 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5478 return "move%.l %1,%0";
5481 (define_insn "*extv_8_16_reg"
5482 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5483 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5484 (match_operand:SI 2 "const_int_operand" "n")
5485 (match_operand:SI 3 "const_int_operand" "n")))]
5486 "TARGET_68020 && TARGET_BITFIELD
5487 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5488 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5490 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5491 return "bfexts %1{%b3:%b2},%0";
5493 if (INTVAL (operands[2]) == 8)
5494 return "move%.b %1,%0\;extb%.l %0";
5495 return "move%.w %1,%0\;ext%.l %0";
5498 ;; Bit-field instructions, general cases.
5499 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
5500 ;; so that its address is reloaded.
5502 (define_expand "extv"
5503 [(set (match_operand:SI 0 "register_operand" "")
5504 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
5505 (match_operand:SI 2 "const_int_operand" "")
5506 (match_operand:SI 3 "const_int_operand" "")))]
5507 "TARGET_68020 && TARGET_BITFIELD"
5510 (define_insn "*extv_bfexts_mem"
5511 [(set (match_operand:SI 0 "register_operand" "=d")
5512 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
5513 (match_operand:SI 2 "nonmemory_operand" "dn")
5514 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5515 "TARGET_68020 && TARGET_BITFIELD"
5516 "bfexts %1{%b3:%b2},%0")
5518 (define_expand "extzv"
5519 [(set (match_operand:SI 0 "register_operand" "")
5520 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
5521 (match_operand:SI 2 "const_int_operand" "")
5522 (match_operand:SI 3 "const_int_operand" "")))]
5523 "TARGET_68020 && TARGET_BITFIELD"
5526 (define_insn "*extzv_bfextu_mem"
5527 [(set (match_operand:SI 0 "register_operand" "=d")
5528 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o")
5529 (match_operand:SI 2 "nonmemory_operand" "dn")
5530 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5531 "TARGET_68020 && TARGET_BITFIELD"
5533 if (GET_CODE (operands[2]) == CONST_INT)
5535 if (INTVAL (operands[2]) != 32)
5536 cc_status.flags |= CC_NOT_NEGATIVE;
5542 return "bfextu %1{%b3:%b2},%0";
5545 (define_insn "*insv_bfchg_mem"
5546 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5547 (match_operand:SI 1 "nonmemory_operand" "dn")
5548 (match_operand:SI 2 "nonmemory_operand" "dn"))
5549 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
5550 (match_operand 3 "const_int_operand" "n")))]
5551 "TARGET_68020 && TARGET_BITFIELD
5552 && (INTVAL (operands[3]) == -1
5553 || (GET_CODE (operands[1]) == CONST_INT
5554 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
5557 return "bfchg %0{%b2:%b1}";
5560 (define_insn "*insv_bfclr_mem"
5561 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5562 (match_operand:SI 1 "nonmemory_operand" "dn")
5563 (match_operand:SI 2 "nonmemory_operand" "dn"))
5565 "TARGET_68020 && TARGET_BITFIELD"
5568 return "bfclr %0{%b2:%b1}";
5571 (define_insn "*insv_bfset_mem"
5572 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5573 (match_operand:SI 1 "general_operand" "dn")
5574 (match_operand:SI 2 "general_operand" "dn"))
5576 "TARGET_68020 && TARGET_BITFIELD"
5579 return "bfset %0{%b2:%b1}";
5582 (define_expand "insv"
5583 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5584 (match_operand:SI 1 "const_int_operand" "")
5585 (match_operand:SI 2 "const_int_operand" ""))
5586 (match_operand:SI 3 "reg_or_pow2_m1_operand" ""))]
5587 "TARGET_68020 && TARGET_BITFIELD"
5590 /* Special case initializing a field to all ones. */
5591 if (GET_CODE (operands[3]) == CONST_INT)
5593 if (exact_log2 (INTVAL (operands[3]) + 1) != INTVAL (operands[1]))
5594 operands[3] = force_reg (SImode, operands[3]);
5596 operands[3] = constm1_rtx;
5601 (define_insn "*insv_bfins_mem"
5602 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5603 (match_operand:SI 1 "nonmemory_operand" "dn")
5604 (match_operand:SI 2 "nonmemory_operand" "dn"))
5605 (match_operand:SI 3 "register_operand" "d"))]
5606 "TARGET_68020 && TARGET_BITFIELD"
5607 "bfins %3,%0{%b2:%b1}")
5609 ;; Now recognize bit-field insns that operate on registers
5610 ;; (or at least were intended to do so).
5612 (define_insn "*extv_bfexts_reg"
5613 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5614 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5615 (match_operand:SI 2 "const_int_operand" "n")
5616 (match_operand:SI 3 "const_int_operand" "n")))]
5617 "TARGET_68020 && TARGET_BITFIELD"
5618 "bfexts %1{%b3:%b2},%0")
5620 (define_insn "*extv_bfextu_reg"
5621 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5622 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5623 (match_operand:SI 2 "const_int_operand" "n")
5624 (match_operand:SI 3 "const_int_operand" "n")))]
5625 "TARGET_68020 && TARGET_BITFIELD"
5627 if (GET_CODE (operands[2]) == CONST_INT)
5629 if (INTVAL (operands[2]) != 32)
5630 cc_status.flags |= CC_NOT_NEGATIVE;
5636 return "bfextu %1{%b3:%b2},%0";
5639 (define_insn "*insv_bfclr_reg"
5640 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5641 (match_operand:SI 1 "const_int_operand" "n")
5642 (match_operand:SI 2 "const_int_operand" "n"))
5644 "TARGET_68020 && TARGET_BITFIELD"
5647 return "bfclr %0{%b2:%b1}";
5650 (define_insn "*insv_bfset_reg"
5651 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5652 (match_operand:SI 1 "const_int_operand" "n")
5653 (match_operand:SI 2 "const_int_operand" "n"))
5655 "TARGET_68020 && TARGET_BITFIELD"
5658 return "bfset %0{%b2:%b1}";
5661 (define_insn "*insv_bfins_reg"
5662 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5663 (match_operand:SI 1 "const_int_operand" "n")
5664 (match_operand:SI 2 "const_int_operand" "n"))
5665 (match_operand:SI 3 "register_operand" "d"))]
5666 "TARGET_68020 && TARGET_BITFIELD"
5669 /* These special cases are now recognized by a specific pattern. */
5670 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5671 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5672 return "move%.w %3,%0";
5673 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5674 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5675 return "move%.b %3,%0";
5677 return "bfins %3,%0{%b2:%b1}";
5680 ;; Special patterns for optimizing bit-field instructions.
5682 (define_insn "*tst_bftst_mem"
5684 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5685 (match_operand:SI 1 "const_int_operand" "n")
5686 (match_operand:SI 2 "general_operand" "dn"))
5688 "TARGET_68020 && TARGET_BITFIELD"
5690 if (operands[1] == const1_rtx
5691 && GET_CODE (operands[2]) == CONST_INT)
5693 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5694 return output_btst (operands,
5695 GEN_INT (width - INTVAL (operands[2])),
5696 operands[0], insn, 1000);
5697 /* Pass 1000 as SIGNPOS argument so that btst will
5698 not think we are testing the sign bit for an `and'
5699 and assume that nonzero implies a negative result. */
5701 if (INTVAL (operands[1]) != 32)
5702 cc_status.flags = CC_NOT_NEGATIVE;
5703 return "bftst %0{%b2:%b1}";
5707 ;;; now handle the register cases
5708 (define_insn "*tst_bftst_reg"
5710 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5711 (match_operand:SI 1 "const_int_operand" "n")
5712 (match_operand:SI 2 "general_operand" "dn"))
5714 "TARGET_68020 && TARGET_BITFIELD"
5716 if (operands[1] == const1_rtx
5717 && GET_CODE (operands[2]) == CONST_INT)
5719 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5720 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5721 operands[0], insn, 1000);
5722 /* Pass 1000 as SIGNPOS argument so that btst will
5723 not think we are testing the sign bit for an `and'
5724 and assume that nonzero implies a negative result. */
5726 if (INTVAL (operands[1]) != 32)
5727 cc_status.flags = CC_NOT_NEGATIVE;
5728 return "bftst %0{%b2:%b1}";
5731 (define_insn "scc0_di"
5732 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5733 (match_operator 1 "ordered_comparison_operator"
5734 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5737 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5740 (define_insn "scc0_di_5200"
5741 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5742 (match_operator 1 "ordered_comparison_operator"
5743 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5746 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5749 (define_insn "scc_di"
5750 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5751 (match_operator 1 "ordered_comparison_operator"
5752 [(match_operand:DI 2 "general_operand" "ro,r")
5753 (match_operand:DI 3 "general_operand" "r,ro")]))]
5756 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5759 (define_insn "scc_di_5200"
5760 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5761 (match_operator 1 "ordered_comparison_operator"
5762 [(match_operand:DI 2 "general_operand" "ro,r")
5763 (match_operand:DI 3 "general_operand" "r,ro")]))]
5766 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5769 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5770 ;; memory, but we cannot allow it to be in memory in case the address
5771 ;; needs to be reloaded.
5774 [(set (match_operand:QI 0 "register_operand" "=d")
5775 (eq:QI (cc0) (const_int 0)))]
5778 cc_status = cc_prev_status;
5779 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5783 [(set (match_operand:QI 0 "register_operand" "=d")
5784 (ne:QI (cc0) (const_int 0)))]
5787 cc_status = cc_prev_status;
5788 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5792 [(set (match_operand:QI 0 "register_operand" "=d")
5793 (gt:QI (cc0) (const_int 0)))]
5796 cc_status = cc_prev_status;
5797 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5801 [(set (match_operand:QI 0 "register_operand" "=d")
5802 (gtu:QI (cc0) (const_int 0)))]
5805 cc_status = cc_prev_status;
5810 [(set (match_operand:QI 0 "register_operand" "=d")
5811 (lt:QI (cc0) (const_int 0)))]
5814 cc_status = cc_prev_status;
5815 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5819 [(set (match_operand:QI 0 "register_operand" "=d")
5820 (ltu:QI (cc0) (const_int 0)))]
5823 cc_status = cc_prev_status;
5828 [(set (match_operand:QI 0 "register_operand" "=d")
5829 (ge:QI (cc0) (const_int 0)))]
5832 cc_status = cc_prev_status;
5833 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5837 [(set (match_operand:QI 0 "register_operand" "=d")
5838 (geu:QI (cc0) (const_int 0)))]
5841 cc_status = cc_prev_status;
5844 [(set_attr "type" "scc")])
5847 [(set (match_operand:QI 0 "register_operand" "=d")
5848 (le:QI (cc0) (const_int 0)))]
5851 cc_status = cc_prev_status;
5852 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5856 [(set (match_operand:QI 0 "register_operand" "=d")
5857 (leu:QI (cc0) (const_int 0)))]
5860 cc_status = cc_prev_status;
5863 [(set_attr "type" "scc")])
5865 (define_insn "*sordered_1"
5866 [(set (match_operand:QI 0 "register_operand" "=d")
5867 (ordered:QI (cc0) (const_int 0)))]
5868 "TARGET_68881 && !TUNE_68060"
5870 cc_status = cc_prev_status;
5874 (define_insn "*sunordered_1"
5875 [(set (match_operand:QI 0 "register_operand" "=d")
5876 (unordered:QI (cc0) (const_int 0)))]
5877 "TARGET_68881 && !TUNE_68060"
5879 cc_status = cc_prev_status;
5883 (define_insn "*suneq_1"
5884 [(set (match_operand:QI 0 "register_operand" "=d")
5885 (uneq:QI (cc0) (const_int 0)))]
5886 "TARGET_68881 && !TUNE_68060"
5888 cc_status = cc_prev_status;
5892 (define_insn "*sunge_1"
5893 [(set (match_operand:QI 0 "register_operand" "=d")
5894 (unge:QI (cc0) (const_int 0)))]
5895 "TARGET_68881 && !TUNE_68060"
5897 cc_status = cc_prev_status;
5901 (define_insn "*sungt_1"
5902 [(set (match_operand:QI 0 "register_operand" "=d")
5903 (ungt:QI (cc0) (const_int 0)))]
5904 "TARGET_68881 && !TUNE_68060"
5906 cc_status = cc_prev_status;
5910 (define_insn "*sunle_1"
5911 [(set (match_operand:QI 0 "register_operand" "=d")
5912 (unle:QI (cc0) (const_int 0)))]
5913 "TARGET_68881 && !TUNE_68060"
5915 cc_status = cc_prev_status;
5919 (define_insn "*sunlt_1"
5920 [(set (match_operand:QI 0 "register_operand" "=d")
5921 (unlt:QI (cc0) (const_int 0)))]
5922 "TARGET_68881 && !TUNE_68060"
5924 cc_status = cc_prev_status;
5928 (define_insn "*sltgt_1"
5929 [(set (match_operand:QI 0 "register_operand" "=d")
5930 (ltgt:QI (cc0) (const_int 0)))]
5931 "TARGET_68881 && !TUNE_68060"
5933 cc_status = cc_prev_status;
5937 (define_insn "*fsogt_1"
5938 [(set (match_operand:QI 0 "register_operand" "=d")
5939 (not:QI (unle:QI (cc0) (const_int 0))))]
5940 "TARGET_68881 && !TUNE_68060"
5942 cc_status = cc_prev_status;
5946 (define_insn "*fsoge_1"
5947 [(set (match_operand:QI 0 "register_operand" "=d")
5948 (not:QI (unlt:QI (cc0) (const_int 0))))]
5949 "TARGET_68881 && !TUNE_68060"
5951 cc_status = cc_prev_status;
5955 (define_insn "*fsolt_1"
5956 [(set (match_operand:QI 0 "register_operand" "=d")
5957 (not:QI (unge:QI (cc0) (const_int 0))))]
5958 "TARGET_68881 && !TUNE_68060"
5960 cc_status = cc_prev_status;
5964 (define_insn "*fsole_1"
5965 [(set (match_operand:QI 0 "register_operand" "=d")
5966 (not:QI (ungt:QI (cc0) (const_int 0))))]
5967 "TARGET_68881 && !TUNE_68060"
5969 cc_status = cc_prev_status;
5973 ;; Basic conditional jump instructions.
5975 (define_insn "beq0_di"
5977 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*a,o,<>")
5979 (label_ref (match_operand 1 "" ",,"))
5981 (clobber (match_scratch:SI 2 "=d,&d,d"))]
5985 if (which_alternative == 2)
5986 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5987 if ((cc_prev_status.value1
5988 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5989 || (cc_prev_status.value2
5990 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5992 cc_status = cc_prev_status;
5995 if (GET_CODE (operands[0]) == REG)
5996 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5998 operands[3] = adjust_address (operands[0], SImode, 4);
5999 if (! ADDRESS_REG_P (operands[0]))
6001 if (reg_overlap_mentioned_p (operands[2], operands[0]))
6003 if (reg_overlap_mentioned_p (operands[2], operands[3]))
6004 return "or%.l %0,%2\;jeq %l1";
6006 return "or%.l %3,%2\;jeq %l1";
6008 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
6010 operands[4] = gen_label_rtx();
6011 if (TARGET_68020 || TARGET_COLDFIRE)
6012 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
6014 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
6015 (*targetm.asm_out.internal_label) (asm_out_file, "L",
6016 CODE_LABEL_NUMBER (operands[4]));
6020 (define_insn "bne0_di"
6022 (if_then_else (ne (match_operand:DI 0 "general_operand" "d,o,*a")
6024 (label_ref (match_operand 1 "" ",,"))
6026 (clobber (match_scratch:SI 2 "=d,&d,X"))]
6029 if ((cc_prev_status.value1
6030 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6031 || (cc_prev_status.value2
6032 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6034 cc_status = cc_prev_status;
6038 if (GET_CODE (operands[0]) == REG)
6039 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6041 operands[3] = adjust_address (operands[0], SImode, 4);
6042 if (!ADDRESS_REG_P (operands[0]))
6044 if (reg_overlap_mentioned_p (operands[2], operands[0]))
6046 if (reg_overlap_mentioned_p (operands[2], operands[3]))
6047 return "or%.l %0,%2\;jne %l1";
6049 return "or%.l %3,%2\;jne %l1";
6051 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
6053 if (TARGET_68020 || TARGET_COLDFIRE)
6054 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
6056 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
6059 (define_insn "bge0_di"
6061 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
6063 (label_ref (match_operand 1 "" ""))
6067 if ((cc_prev_status.value1
6068 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6069 || (cc_prev_status.value2
6070 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6072 cc_status = cc_prev_status;
6073 return cc_status.flags & CC_REVERSED ? "jle %l1" : "jpl %l1";
6076 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6077 output_asm_insn("tst%.l %0", operands);
6080 /* On an address reg, cmpw may replace cmpl. */
6081 output_asm_insn("cmp%.w #0,%0", operands);
6086 (define_insn "blt0_di"
6088 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
6090 (label_ref (match_operand 1 "" ""))
6094 if ((cc_prev_status.value1
6095 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6096 || (cc_prev_status.value2
6097 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6099 cc_status = cc_prev_status;
6100 return cc_status.flags & CC_REVERSED ? "jgt %l1" : "jmi %l1";
6103 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6104 output_asm_insn("tst%.l %0", operands);
6107 /* On an address reg, cmpw may replace cmpl. */
6108 output_asm_insn("cmp%.w #0,%0", operands);
6115 (if_then_else (eq (cc0)
6117 (label_ref (match_operand 0 "" ""))
6121 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6123 [(set_attr "type" "bcc")])
6127 (if_then_else (ne (cc0)
6129 (label_ref (match_operand 0 "" ""))
6133 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6135 [(set_attr "type" "bcc")])
6139 (if_then_else (gt (cc0)
6141 (label_ref (match_operand 0 "" ""))
6145 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6147 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6151 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
6153 [(set_attr "type" "bcc")])
6157 (if_then_else (gtu (cc0)
6159 (label_ref (match_operand 0 "" ""))
6163 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6165 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6171 [(set_attr "type" "bcc")])
6175 (if_then_else (lt (cc0)
6177 (label_ref (match_operand 0 "" ""))
6181 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6183 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6187 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
6189 [(set_attr "type" "bcc")])
6193 (if_then_else (ltu (cc0)
6195 (label_ref (match_operand 0 "" ""))
6199 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6201 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6207 [(set_attr "type" "bcc")])
6211 (if_then_else (ge (cc0)
6213 (label_ref (match_operand 0 "" ""))
6217 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6219 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6223 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
6228 (if_then_else (geu (cc0)
6230 (label_ref (match_operand 0 "" ""))
6234 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6236 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6242 [(set_attr "type" "bcc")])
6246 (if_then_else (le (cc0)
6248 (label_ref (match_operand 0 "" ""))
6252 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6254 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6258 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
6260 [(set_attr "type" "bcc")])
6264 (if_then_else (leu (cc0)
6266 (label_ref (match_operand 0 "" ""))
6270 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6272 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6278 [(set_attr "type" "bcc")])
6280 (define_insn "bordered"
6282 (if_then_else (ordered (cc0) (const_int 0))
6283 (label_ref (match_operand 0 "" ""))
6287 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6290 [(set_attr "type" "fbcc")])
6292 (define_insn "bunordered"
6294 (if_then_else (unordered (cc0) (const_int 0))
6295 (label_ref (match_operand 0 "" ""))
6299 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6302 [(set_attr "type" "fbcc")])
6304 (define_insn "buneq"
6306 (if_then_else (uneq (cc0) (const_int 0))
6307 (label_ref (match_operand 0 "" ""))
6311 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6314 [(set_attr "type" "fbcc")])
6316 (define_insn "bunge"
6318 (if_then_else (unge (cc0) (const_int 0))
6319 (label_ref (match_operand 0 "" ""))
6323 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6326 [(set_attr "type" "fbcc")])
6328 (define_insn "bungt"
6330 (if_then_else (ungt (cc0) (const_int 0))
6331 (label_ref (match_operand 0 "" ""))
6335 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6338 [(set_attr "type" "fbcc")])
6340 (define_insn "bunle"
6342 (if_then_else (unle (cc0) (const_int 0))
6343 (label_ref (match_operand 0 "" ""))
6347 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6350 [(set_attr "type" "fbcc")])
6352 (define_insn "bunlt"
6354 (if_then_else (unlt (cc0) (const_int 0))
6355 (label_ref (match_operand 0 "" ""))
6359 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6362 [(set_attr "type" "fbcc")])
6364 (define_insn "bltgt"
6366 (if_then_else (ltgt (cc0) (const_int 0))
6367 (label_ref (match_operand 0 "" ""))
6371 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6374 [(set_attr "type" "fbcc")])
6376 ;; Negated conditional jump instructions.
6378 (define_insn "*beq_rev"
6380 (if_then_else (eq (cc0)
6383 (label_ref (match_operand 0 "" ""))))]
6386 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6388 [(set_attr "type" "bcc")])
6390 (define_insn "*bne_rev"
6392 (if_then_else (ne (cc0)
6395 (label_ref (match_operand 0 "" ""))))]
6398 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6400 [(set_attr "type" "bcc")])
6402 (define_insn "*bgt_rev"
6404 (if_then_else (gt (cc0)
6407 (label_ref (match_operand 0 "" ""))))]
6410 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6412 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6416 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6418 [(set_attr "type" "bcc")])
6420 (define_insn "*bgtu_rev"
6422 (if_then_else (gtu (cc0)
6425 (label_ref (match_operand 0 "" ""))))]
6428 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6430 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6436 [(set_attr "type" "bcc")])
6438 (define_insn "*blt_rev"
6440 (if_then_else (lt (cc0)
6443 (label_ref (match_operand 0 "" ""))))]
6446 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6448 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6452 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6454 [(set_attr "type" "bcc")])
6456 (define_insn "*bltu_rev"
6458 (if_then_else (ltu (cc0)
6461 (label_ref (match_operand 0 "" ""))))]
6464 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6466 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6472 [(set_attr "type" "bcc")])
6474 (define_insn "*bge_rev"
6476 (if_then_else (ge (cc0)
6479 (label_ref (match_operand 0 "" ""))))]
6482 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6484 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6488 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6490 [(set_attr "type" "bcc")])
6492 (define_insn "*bgeu_rev"
6494 (if_then_else (geu (cc0)
6497 (label_ref (match_operand 0 "" ""))))]
6500 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6502 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6508 [(set_attr "type" "bcc")])
6510 (define_insn "*ble_rev"
6512 (if_then_else (le (cc0)
6515 (label_ref (match_operand 0 "" ""))))]
6518 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6520 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6524 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6526 [(set_attr "type" "bcc")])
6528 (define_insn "*bleu_rev"
6530 (if_then_else (leu (cc0)
6533 (label_ref (match_operand 0 "" ""))))]
6536 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6538 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6544 [(set_attr "type" "bcc")])
6546 (define_insn "*bordered_rev"
6548 (if_then_else (ordered (cc0) (const_int 0))
6550 (label_ref (match_operand 0 "" ""))))]
6553 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6556 [(set_attr "type" "fbcc")])
6558 (define_insn "*bunordered_rev"
6560 (if_then_else (unordered (cc0) (const_int 0))
6562 (label_ref (match_operand 0 "" ""))))]
6565 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6568 [(set_attr "type" "fbcc")])
6570 (define_insn "*buneq_rev"
6572 (if_then_else (uneq (cc0) (const_int 0))
6574 (label_ref (match_operand 0 "" ""))))]
6577 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6580 [(set_attr "type" "fbcc")])
6582 (define_insn "*bunge_rev"
6584 (if_then_else (unge (cc0) (const_int 0))
6586 (label_ref (match_operand 0 "" ""))))]
6589 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6592 [(set_attr "type" "fbcc")])
6594 (define_insn "*bungt_rev"
6596 (if_then_else (ungt (cc0) (const_int 0))
6598 (label_ref (match_operand 0 "" ""))))]
6601 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6604 [(set_attr "type" "fbcc")])
6606 (define_insn "*bunle_rev"
6608 (if_then_else (unle (cc0) (const_int 0))
6610 (label_ref (match_operand 0 "" ""))))]
6613 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6616 [(set_attr "type" "fbcc")])
6618 (define_insn "*bunlt_rev"
6620 (if_then_else (unlt (cc0) (const_int 0))
6622 (label_ref (match_operand 0 "" ""))))]
6625 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6628 [(set_attr "type" "fbcc")])
6630 (define_insn "*bltgt_rev"
6632 (if_then_else (ltgt (cc0) (const_int 0))
6634 (label_ref (match_operand 0 "" ""))))]
6637 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6640 [(set_attr "type" "fbcc")])
6642 ;; Unconditional and other jump instructions
6645 (label_ref (match_operand 0 "" "")))]
6648 [(set_attr "type" "bra")])
6650 (define_expand "tablejump"
6651 [(parallel [(set (pc) (match_operand 0 "" ""))
6652 (use (label_ref (match_operand 1 "" "")))])]
6655 #if CASE_VECTOR_PC_RELATIVE
6656 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6657 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6661 ;; Jump to variable address from dispatch table of absolute addresses.
6662 (define_insn "*tablejump_internal"
6663 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6664 (use (label_ref (match_operand 1 "" "")))]
6667 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6669 [(set_attr "type" "jmp")])
6671 ;; Jump to variable address from dispatch table of relative addresses.
6675 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6676 (use (label_ref (match_operand 1 "" "")))]
6679 #ifdef ASM_RETURN_CASE_JUMP
6680 ASM_RETURN_CASE_JUMP;
6682 if (TARGET_COLDFIRE)
6684 if (ADDRESS_REG_P (operands[0]))
6685 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6687 return "ext%.l %0\;jmp (2,pc,%0.l)";
6689 return "extl %0\;jmp pc@(2,%0:l)";
6692 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6696 ;; Decrement-and-branch insns.
6697 (define_insn "*dbne_hi"
6700 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6702 (label_ref (match_operand 1 "" ""))
6705 (plus:HI (match_dup 0)
6710 if (DATA_REG_P (operands[0]))
6711 return "dbra %0,%l1";
6712 if (GET_CODE (operands[0]) == MEM)
6713 return "subq%.w #1,%0\;jcc %l1";
6714 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6717 (define_insn "*dbne_si"
6720 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6722 (label_ref (match_operand 1 "" ""))
6725 (plus:SI (match_dup 0)
6730 if (DATA_REG_P (operands[0]))
6731 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6732 if (GET_CODE (operands[0]) == MEM)
6733 return "subq%.l #1,%0\;jcc %l1";
6734 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6737 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6739 (define_insn "*dbge_hi"
6742 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6745 (label_ref (match_operand 1 "" ""))
6748 (plus:HI (match_dup 0)
6750 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6753 if (DATA_REG_P (operands[0]))
6754 return "dbra %0,%l1";
6755 if (GET_CODE (operands[0]) == MEM)
6756 return "subq%.w #1,%0\;jcc %l1";
6757 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6760 (define_expand "decrement_and_branch_until_zero"
6761 [(parallel [(set (pc)
6763 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6766 (label_ref (match_operand 1 "" ""))
6769 (plus:SI (match_dup 0)
6774 (define_insn "*dbge_si"
6777 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6780 (label_ref (match_operand 1 "" ""))
6783 (plus:SI (match_dup 0)
6785 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6788 if (DATA_REG_P (operands[0]))
6789 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6790 if (GET_CODE (operands[0]) == MEM)
6791 return "subq%.l #1,%0\;jcc %l1";
6792 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6795 (define_expand "sibcall"
6796 [(call (match_operand:QI 0 "memory_operand" "")
6797 (match_operand:SI 1 "general_operand" ""))]
6800 operands[0] = m68k_legitimize_sibcall_address (operands[0]);
6803 (define_insn "*sibcall"
6804 [(call (mem:QI (match_operand:SI 0 "sibcall_operand" ""))
6805 (match_operand:SI 1 "general_operand" ""))]
6806 "SIBLING_CALL_P (insn)"
6808 return output_sibcall (operands[0]);
6811 (define_expand "sibcall_value"
6812 [(set (match_operand 0 "" "")
6813 (call (match_operand:QI 1 "memory_operand" "")
6814 (match_operand:SI 2 "general_operand" "")))]
6817 operands[1] = m68k_legitimize_sibcall_address (operands[1]);
6820 (define_insn "*sibcall_value"
6821 [(set (match_operand 0 "" "=rf,rf")
6822 (call (mem:QI (match_operand:SI 1 "sibcall_operand" ""))
6823 (match_operand:SI 2 "general_operand" "")))]
6824 "SIBLING_CALL_P (insn)"
6826 operands[0] = operands[1];
6827 return output_sibcall (operands[0]);
6830 ;; Call subroutine with no return value.
6831 (define_expand "call"
6832 [(call (match_operand:QI 0 "memory_operand" "")
6833 (match_operand:SI 1 "general_operand" ""))]
6834 ;; Operand 1 not really used on the m68000.
6837 operands[0] = m68k_legitimize_call_address (operands[0]);
6840 (define_insn "*call"
6841 [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
6842 (match_operand:SI 1 "general_operand" "g,g"))]
6843 ;; Operand 1 not really used on the m68000.
6844 "!SIBLING_CALL_P (insn)"
6846 return output_call (operands[0]);
6848 [(set_attr "type" "jsr")])
6850 ;; Call subroutine, returning value in operand 0
6851 ;; (which must be a hard register).
6852 (define_expand "call_value"
6853 [(set (match_operand 0 "" "")
6854 (call (match_operand:QI 1 "memory_operand" "")
6855 (match_operand:SI 2 "general_operand" "")))]
6856 ;; Operand 2 not really used on the m68000.
6859 operands[1] = m68k_legitimize_call_address (operands[1]);
6862 (define_insn "*non_symbolic_call_value"
6863 [(set (match_operand 0 "" "=rf,rf")
6864 (call (mem:QI (match_operand:SI 1 "non_symbolic_call_operand" "a,W"))
6865 (match_operand:SI 2 "general_operand" "g,g")))]
6866 ;; Operand 2 not really used on the m68000.
6867 "!SIBLING_CALL_P (insn)"
6869 [(set_attr "type" "jsr")
6870 (set_attr "opx" "1")])
6872 (define_insn "*symbolic_call_value_jsr"
6873 [(set (match_operand 0 "" "=rf,rf")
6874 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6875 (match_operand:SI 2 "general_operand" "g,g")))]
6876 ;; Operand 2 not really used on the m68000.
6877 "!SIBLING_CALL_P (insn) && m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_JSR"
6879 operands[0] = operands[1];
6880 return m68k_symbolic_call;
6882 [(set_attr "type" "jsr")
6883 (set_attr "opx" "1")])
6885 (define_insn "*symbolic_call_value_bsr"
6886 [(set (match_operand 0 "" "=rf,rf")
6887 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6888 (match_operand:SI 2 "general_operand" "g,g")))]
6889 ;; Operand 2 not really used on the m68000.
6890 "!SIBLING_CALL_P (insn)
6891 && (m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_C
6892 || m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_P)"
6894 operands[0] = operands[1];
6895 return m68k_symbolic_call;
6897 [(set_attr "type" "bsr")
6898 (set_attr "opx" "1")])
6900 ;; Call subroutine returning any type.
6902 (define_expand "untyped_call"
6903 [(parallel [(call (match_operand 0 "" "")
6905 (match_operand 1 "" "")
6906 (match_operand 2 "" "")])]
6907 "NEEDS_UNTYPED_CALL"
6911 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6913 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6915 rtx set = XVECEXP (operands[2], 0, i);
6916 emit_move_insn (SET_DEST (set), SET_SRC (set));
6919 /* The optimizer does not know that the call sets the function value
6920 registers we stored in the result block. We avoid problems by
6921 claiming that all hard registers are used and clobbered at this
6923 emit_insn (gen_blockage ());
6928 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6929 ;; all of memory. This blocks insns from being moved across this point.
6931 (define_insn "blockage"
6932 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6940 [(set_attr "type" "nop")])
6942 (define_expand "prologue"
6946 m68k_expand_prologue ();
6950 (define_expand "epilogue"
6954 m68k_expand_epilogue (false);
6958 (define_expand "sibcall_epilogue"
6962 m68k_expand_epilogue (true);
6966 ;; Used for frameless functions which save no regs and allocate no locals.
6967 (define_expand "return"
6969 "m68k_use_return_insn ()"
6972 (define_insn "*return"
6976 switch (m68k_get_function_kind (current_function_decl))
6978 case m68k_fk_interrupt_handler:
6981 case m68k_fk_interrupt_thread:
6985 if (crtl->args.pops_args)
6987 operands[0] = GEN_INT (crtl->args.pops_args);
6994 [(set_attr "type" "rts")])
6996 (define_insn "*m68k_store_multiple"
6997 [(match_parallel 0 "" [(match_operand 1 "")])]
6998 "m68k_movem_pattern_p (operands[0], NULL, 0, true)"
7000 return m68k_output_movem (operands, operands[0], 0, true);
7003 (define_insn "*m68k_store_multiple_automod"
7004 [(match_parallel 0 ""
7005 [(set (match_operand:SI 1 "register_operand" "=a")
7006 (plus:SI (match_operand:SI 2 "register_operand" "1")
7007 (match_operand:SI 3 "const_int_operand")))])]
7008 "m68k_movem_pattern_p (operands[0], operands[1], INTVAL (operands[3]), true)"
7010 return m68k_output_movem (operands, operands[0], INTVAL (operands[3]), true);
7013 (define_insn "*m68k_load_multiple"
7014 [(match_parallel 0 "" [(match_operand 1 "")])]
7015 "m68k_movem_pattern_p (operands[0], NULL, 0, false)"
7017 return m68k_output_movem (operands, operands[0], 0, false);
7020 (define_insn "*m68k_load_multiple_automod"
7021 [(match_parallel 0 ""
7022 [(set (match_operand:SI 1 "register_operand" "=a")
7023 (plus:SI (match_operand:SI 2 "register_operand" "1")
7024 (match_operand:SI 3 "const_int_operand")))])]
7025 "m68k_movem_pattern_p (operands[0], operands[1],
7026 INTVAL (operands[3]), false)"
7028 return m68k_output_movem (operands, operands[0],
7029 INTVAL (operands[3]), false);
7032 (define_expand "link"
7034 [(set (match_operand:SI 0 "register_operand")
7035 (plus:SI (reg:SI SP_REG) (const_int -4)))
7038 (set (reg:SI SP_REG)
7039 (plus:SI (reg:SI SP_REG)
7040 (match_operand:SI 1 "const_int_operand")))])]
7041 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7043 operands[2] = gen_frame_mem (SImode,
7044 plus_constant (Pmode, stack_pointer_rtx, -4));
7047 (define_insn "*link"
7048 [(set (match_operand:SI 0 "register_operand" "+r")
7049 (plus:SI (reg:SI SP_REG) (const_int -4)))
7050 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
7052 (set (reg:SI SP_REG)
7053 (plus:SI (reg:SI SP_REG)
7054 (match_operand:SI 1 "const_int_operand")))]
7055 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7057 operands[1] = GEN_INT (INTVAL (operands[1]) + 4);
7059 return "link %0,%1";
7060 else if (INTVAL (operands[1]) >= -0x8000)
7061 return "link.w %0,%1";
7063 return "link.l %0,%1";
7065 [(set_attr "type" "link")])
7067 (define_expand "unlink"
7069 [(set (match_operand:SI 0 "register_operand")
7071 (set (reg:SI SP_REG)
7072 (plus:SI (match_dup 0)
7076 operands[1] = gen_frame_mem (SImode, copy_rtx (operands[0]));
7079 (define_insn "*unlink"
7080 [(set (match_operand:SI 0 "register_operand" "+r")
7081 (mem:SI (match_dup 0)))
7082 (set (reg:SI SP_REG)
7083 (plus:SI (match_dup 0)
7087 [(set_attr "type" "unlk")])
7089 (define_insn "load_got"
7090 [(set (match_operand:SI 0 "register_operand" "=a")
7091 (unspec:SI [(const_int 0)] UNSPEC_GOT))]
7094 if (TARGET_ID_SHARED_LIBRARY)
7096 operands[1] = gen_rtx_REG (Pmode, PIC_REG);
7097 return MOTOROLA ? "move.l %?(%1),%0" : "movel %1@(%?), %0";
7101 if (TARGET_COLDFIRE)
7102 /* Load the full 32-bit PC-relative offset of
7103 _GLOBAL_OFFSET_TABLE_ into the PIC register, then use it to
7104 calculate the absolute value. The offset and "lea"
7105 operation word together occupy 6 bytes. */
7106 return ("move.l #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t"
7107 "lea (-6, %%pc, %0), %0");
7109 return "lea (%%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %0";
7112 return ("movel #_GLOBAL_OFFSET_TABLE_, %0\n\t"
7113 "lea %%pc@(0,%0:l),%0");
7116 (define_insn "indirect_jump"
7117 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
7120 [(set_attr "type" "jmp")])
7122 ;; This should not be used unless the add/sub insns can't be.
7125 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
7126 (match_operand:QI 1 "address_operand" "p"))]
7130 ;; This is the first machine-dependent peephole optimization.
7131 ;; It is useful when a floating value is returned from a function call
7132 ;; and then is moved into an FP register.
7133 ;; But it is mainly intended to test the support for these optimizations.
7136 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7137 (set (match_operand:DF 0 "register_operand" "")
7138 (match_operand:DF 1 "register_operand" ""))]
7139 "FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
7140 [(set (mem:SI (reg:SI SP_REG)) (match_dup 1))
7141 (set (mem:SI (pre_dec:SI (reg:SI SP_REG))) (match_dup 2))
7142 (set (match_dup 0) (mem:DF (post_inc:SI (reg:SI SP_REG))))]
7143 "split_di(operands + 1, 1, operands + 1, operands + 2);")
7145 ;; Optimize a stack-adjust followed by a push of an argument.
7146 ;; This is said to happen frequently with -msoft-float
7147 ;; when there are consecutive library calls.
7150 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7151 (set (match_operand:SF 0 "push_operand" "")
7152 (match_operand:SF 1 "general_operand" ""))]
7153 "!reg_mentioned_p (stack_pointer_rtx, operands[0])"
7154 [(set (match_dup 0) (match_dup 1))]
7155 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7158 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7159 (match_operand:SI 0 "const_int_operand" "")))
7160 (set (match_operand:SF 1 "push_operand" "")
7161 (match_operand:SF 2 "general_operand" ""))]
7162 "INTVAL (operands[0]) > 4
7163 && !reg_mentioned_p (stack_pointer_rtx, operands[2])"
7164 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7165 (set (match_dup 1) (match_dup 2))]
7167 operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7168 operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7171 ;; Speed up stack adjust followed by a fullword fixedpoint push.
7172 ;; Constant operands need special care, as replacing a "pea X.w" with
7173 ;; "move.l #X,(%sp)" is often not a win.
7175 ;; Already done by the previous csa pass, left as reference.
7177 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7178 (set (match_operand:SI 0 "push_operand" "")
7179 (match_operand:SI 1 "general_operand" ""))]
7180 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7181 [(set (match_dup 0) (match_dup 1))]
7182 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7184 ;; Try to use moveq, after stack push has been changed into a simple move.
7186 [(match_scratch:SI 2 "d")
7187 (set (match_operand:SI 0 "memory_operand" "")
7188 (match_operand:SI 1 "const_int_operand" ""))]
7189 "GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
7190 && INTVAL (operands[1]) != 0
7191 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7192 && !valid_mov3q_const (INTVAL (operands[1]))"
7193 [(set (match_dup 2) (match_dup 1))
7194 (set (match_dup 0) (match_dup 2))])
7196 ;; This sequence adds an instruction, but is two bytes shorter.
7198 [(match_scratch:SI 2 "d")
7199 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 12)))
7200 (set (match_operand:SI 0 "push_operand" "")
7201 (match_operand:SI 1 "const_int_operand" ""))]
7202 "INTVAL (operands[1]) != 0
7203 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7204 && !valid_mov3q_const (INTVAL (operands[1]))"
7205 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 8)))
7206 (set (match_dup 2) (match_dup 1))
7207 (set (match_dup 0) (match_dup 2))]
7208 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7210 ;; Changing pea X.w into a move.l is no real win here.
7212 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7213 (match_operand:SI 0 "const_int_operand" "")))
7214 (set (match_operand:SI 1 "push_operand" "")
7215 (match_operand:SI 2 "general_operand" ""))]
7216 "INTVAL (operands[0]) > 4
7217 && !reg_mentioned_p (stack_pointer_rtx, operands[2])
7218 && !(CONST_INT_P (operands[2]) && INTVAL (operands[2]) != 0
7219 && IN_RANGE (INTVAL (operands[2]), -0x8000, 0x7fff)
7220 && !valid_mov3q_const (INTVAL (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 pushing a single byte/two bytes but leaving four bytes of space
7229 ;; (which differs slightly between m680x0 and ColdFire).
7232 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
7233 (set (match_operand:QI 0 "memory_operand" "")
7234 (match_operand:QI 1 "register_operand" ""))]
7235 "!reg_mentioned_p (stack_pointer_rtx, operands[1])
7236 && GET_CODE (XEXP (operands[0], 0)) == PLUS
7237 && rtx_equal_p (XEXP (XEXP (operands[0], 0), 0), stack_pointer_rtx)
7238 && CONST_INT_P (XEXP (XEXP (operands[0], 0), 1))
7239 && INTVAL (XEXP (XEXP (operands[0], 0), 1)) == 3"
7240 [(set (match_dup 0) (match_dup 1))]
7242 rtx addr = gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx);
7243 operands[0] = adjust_automodify_address (operands[0], SImode, addr, -3);
7244 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7248 [(set (match_operand:QI 0 "push_operand" "")
7249 (match_operand:QI 1 "register_operand" ""))
7250 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -3)))]
7251 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7252 [(set (match_dup 0) (match_dup 1))]
7254 operands[0] = adjust_automodify_address (operands[0], SImode,
7255 XEXP (operands[0], 0), -3);
7256 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7260 [(set (match_operand:HI 0 "push_operand" "")
7261 (match_operand:HI 1 "register_operand" ""))
7262 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))]
7263 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7264 [(set (match_dup 0) (match_dup 1))]
7266 operands[0] = adjust_automodify_address (operands[0], SImode,
7267 XEXP (operands[0], 0), -2);
7268 operands[1] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
7271 ;; Optimize a series of strict_low_part assignments
7274 [(set (match_operand:SI 0 "register_operand" "")
7276 (set (strict_low_part (match_operand:HI 1 "register_operand" ""))
7277 (match_operand:HI 2 "general_operand" ""))]
7278 "REGNO (operands[0]) == REGNO (operands[1])
7279 && strict_low_part_peephole_ok (HImode, insn, operands[0])"
7280 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7284 [(set (match_operand:SI 0 "register_operand" "")
7286 (set (strict_low_part (match_operand:QI 1 "register_operand" ""))
7287 (match_operand:QI 2 "general_operand" ""))]
7288 "REGNO (operands[0]) == REGNO (operands[1])
7289 && strict_low_part_peephole_ok (QImode, insn, operands[0])"
7290 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7298 ;; jCC label ; abnormal loop termination
7299 ;; dbra dN, loop ; normal loop termination
7307 ;; Which moves the jCC condition outside the inner loop for free.
7311 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7312 [(cc0) (const_int 0)])
7313 (label_ref (match_operand 2 "" ""))
7318 (ne (match_operand:HI 0 "register_operand" "")
7320 (label_ref (match_operand 1 "" ""))
7323 (plus:HI (match_dup 0)
7325 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7328 output_dbcc_and_branch (operands);
7333 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7334 [(cc0) (const_int 0)])
7335 (label_ref (match_operand 2 "" ""))
7340 (ne (match_operand:SI 0 "register_operand" "")
7342 (label_ref (match_operand 1 "" ""))
7345 (plus:SI (match_dup 0)
7347 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7350 output_dbcc_and_branch (operands);
7355 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7356 [(cc0) (const_int 0)])
7357 (label_ref (match_operand 2 "" ""))
7362 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
7365 (label_ref (match_operand 1 "" ""))
7368 (plus:HI (match_dup 0)
7370 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7373 output_dbcc_and_branch (operands);
7378 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7379 [(cc0) (const_int 0)])
7380 (label_ref (match_operand 2 "" ""))
7385 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
7388 (label_ref (match_operand 1 "" ""))
7391 (plus:SI (match_dup 0)
7393 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7396 output_dbcc_and_branch (operands);
7401 (define_insn "extendsfxf2"
7402 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7403 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
7406 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7408 if (REGNO (operands[0]) == REGNO (operands[1]))
7410 /* Extending float to double in an fp-reg is a no-op.
7411 NOTICE_UPDATE_CC has already assumed that the
7412 cc will be set. So cancel what it did. */
7413 cc_status = cc_prev_status;
7416 return "f%$move%.x %1,%0";
7418 if (FP_REG_P (operands[0]))
7420 if (FP_REG_P (operands[1]))
7421 return "f%$move%.x %1,%0";
7422 else if (ADDRESS_REG_P (operands[1]))
7423 return "move%.l %1,%-\;f%$move%.s %+,%0";
7424 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
7425 return output_move_const_single (operands);
7426 return "f%$move%.s %f1,%0";
7428 return "fmove%.x %f1,%0";
7432 (define_insn "extenddfxf2"
7433 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7435 (match_operand:DF 1 "general_operand" "f,rmE")))]
7438 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7440 if (REGNO (operands[0]) == REGNO (operands[1]))
7442 /* Extending float to double in an fp-reg is a no-op.
7443 NOTICE_UPDATE_CC has already assumed that the
7444 cc will be set. So cancel what it did. */
7445 cc_status = cc_prev_status;
7448 return "fmove%.x %1,%0";
7450 if (FP_REG_P (operands[0]))
7452 if (REG_P (operands[1]))
7455 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
7456 output_asm_insn ("move%.l %1,%-", xoperands);
7457 output_asm_insn ("move%.l %1,%-", operands);
7458 return "f%&move%.d %+,%0";
7460 if (GET_CODE (operands[1]) == CONST_DOUBLE)
7461 return output_move_const_double (operands);
7462 return "f%&move%.d %f1,%0";
7464 return "fmove%.x %f1,%0";
7467 (define_insn "truncxfdf2"
7468 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
7470 (match_operand:XF 1 "general_operand" "f,f")))]
7473 if (REG_P (operands[0]))
7475 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
7476 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
7477 return "move%.l %+,%0";
7479 return "fmove%.d %f1,%0";
7482 (define_insn "truncxfsf2"
7483 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
7485 (match_operand:XF 1 "general_operand" "f")))]
7489 (define_insn "sin<mode>2"
7490 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7492 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
7493 "TARGET_68881 && flag_unsafe_math_optimizations"
7495 if (FP_REG_P (operands[1]))
7496 return "fsin%.x %1,%0";
7498 return "fsin%.<FP:prec> %1,%0";
7501 (define_insn "cos<mode>2"
7502 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7504 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
7505 "TARGET_68881 && flag_unsafe_math_optimizations"
7507 if (FP_REG_P (operands[1]))
7508 return "fcos%.x %1,%0";
7510 return "fcos%.<FP:prec> %1,%0";
7513 ;; Unconditional traps are assumed to have (const_int 1) for the condition.
7515 [(trap_if (const_int 1) (const_int 7))]
7518 [(set_attr "type" "trap")])
7520 (define_expand "ctrapdi4"
7521 [(trap_if (match_operator 0 "ordered_comparison_operator"
7522 [(cc0) (const_int 0)])
7523 (match_operand:SI 3 "const1_operand" ""))]
7526 if (operands[2] == const0_rtx)
7527 emit_insn (gen_tstdi (operands[1]));
7529 emit_insn (gen_cmpdi (operands[1], operands[2]));
7530 operands[1] = cc0_rtx;
7531 operands[2] = const0_rtx;
7534 (define_expand "ctrapsi4"
7536 (compare (match_operand:SI 1 "nonimmediate_operand" "")
7537 (match_operand:SI 2 "general_operand" "")))
7538 (trap_if (match_operator 0 "ordered_comparison_operator"
7539 [(cc0) (const_int 0)])
7540 (match_operand:SI 3 "const1_operand" ""))]
7544 (define_expand "ctraphi4"
7546 (compare (match_operand:HI 1 "nonimmediate_src_operand" "")
7547 (match_operand:HI 2 "general_src_operand" "")))
7548 (trap_if (match_operator 0 "ordered_comparison_operator"
7549 [(cc0) (const_int 0)])
7550 (match_operand:SI 3 "const1_operand" ""))]
7554 (define_expand "ctrapqi4"
7556 (compare (match_operand:QI 1 "nonimmediate_src_operand" "")
7557 (match_operand:QI 2 "general_src_operand" "")))
7558 (trap_if (match_operator 0 "ordered_comparison_operator"
7559 [(cc0) (const_int 0)])
7560 (match_operand:SI 3 "const1_operand" ""))]
7564 (define_insn "*conditional_trap"
7565 [(trap_if (match_operator 0 "ordered_comparison_operator"
7566 [(cc0) (const_int 0)])
7567 (match_operand:SI 1 "const1_operand" "I"))]
7568 "TARGET_68020 && ! flags_in_68881 ()"
7570 switch (GET_CODE (operands[0]))
7572 case EQ: return "trapeq";
7573 case NE: return "trapne";
7574 case GT: return "trapgt";
7575 case GTU: return "traphi";
7576 case LT: return "traplt";
7577 case LTU: return "trapcs";
7578 case GE: return "trapge";
7579 case GEU: return "trapcc";
7580 case LE: return "traple";
7581 case LEU: return "trapls";
7582 default: gcc_unreachable ();
7586 ;; These are to prevent the scheduler from moving stores to the frame
7587 ;; before the stack adjustment.
7588 (define_insn "stack_tie"
7589 [(set (mem:BLK (scratch))
7590 (unspec:BLK [(match_operand:SI 0 "register_operand" "r")
7591 (match_operand:SI 1 "register_operand" "r")]
7595 [(set_attr "type" "ignore")])
7597 ;; Instruction that subscribes one word in ColdFire instruction buffer.
7598 ;; This instruction is used within scheduler only and should not appear
7599 ;; in the instruction stream.
7601 [(unspec [(const_int 0)] UNSPEC_IB)]
7604 [(set_attr "type" "ib")])