1 ;;- Machine description for GNU compiler, Motorola 68000 Version
2 ;; Copyright (C) 1987-2014 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.
494 (compare (match_operand:SI 0 "nonimmediate_operand" "rKT,rKs,mSr,mSa,>")
495 (match_operand:SI 1 "general_src_operand" "mSr,mSa,KTr,Ksr,>")))]
498 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
499 return "cmpm%.l %1,%0";
500 if (REG_P (operands[1])
501 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
503 cc_status.flags |= CC_REVERSED; /*|*/
504 return "cmp%.l %d0,%d1";
506 if (ADDRESS_REG_P (operands[0])
507 && GET_CODE (operands[1]) == CONST_INT
508 && INTVAL (operands[1]) < 0x8000
509 && INTVAL (operands[1]) >= -0x8000)
510 return "cmp%.w %1,%0";
511 return "cmp%.l %d1,%d0";
514 (define_insn "*cmpsi_cf"
516 (compare (match_operand:SI 0 "nonimmediate_operand" "mrKs,r")
517 (match_operand:SI 1 "general_operand" "r,mrKs")))]
520 if (REG_P (operands[1])
521 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
523 cc_status.flags |= CC_REVERSED; /*|*/
524 return "cmp%.l %d0,%d1";
526 return "cmp%.l %d1,%d0";
528 [(set_attr "type" "cmp_l")])
530 (define_expand "cbranchhi4"
532 (compare (match_operand:HI 1 "nonimmediate_src_operand" "")
533 (match_operand:HI 2 "m68k_subword_comparison_operand" "")))
535 (if_then_else (match_operator 0 "ordered_comparison_operator"
536 [(cc0) (const_int 0)])
537 (label_ref (match_operand 3 ""))
542 (define_expand "cstorehi4"
544 (compare (match_operand:HI 2 "nonimmediate_operand" "")
545 (match_operand:HI 3 "m68k_subword_comparison_operand" "")))
546 (set (match_operand:QI 0 "register_operand")
547 (match_operator:QI 1 "ordered_comparison_operator"
548 [(cc0) (const_int 0)]))]
554 (compare (match_operand:HI 0 "nonimmediate_src_operand" "rnmS,d,n,mS,>")
555 (match_operand:HI 1 "general_src_operand" "d,rnmS,mS,n,>")))]
558 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
559 return "cmpm%.w %1,%0";
560 if ((REG_P (operands[1]) && !ADDRESS_REG_P (operands[1]))
561 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
563 cc_status.flags |= CC_REVERSED; /*|*/
564 return "cmp%.w %d0,%d1";
566 return "cmp%.w %d1,%d0";
569 (define_expand "cbranchqi4"
571 (compare (match_operand:QI 1 "nonimmediate_src_operand" "")
572 (match_operand:QI 2 "m68k_subword_comparison_operand" "")))
574 (if_then_else (match_operator 0 "ordered_comparison_operator"
575 [(cc0) (const_int 0)])
576 (label_ref (match_operand 3 ""))
581 (define_expand "cstoreqi4"
583 (compare (match_operand:QI 2 "nonimmediate_src_operand" "")
584 (match_operand:QI 3 "m68k_subword_comparison_operand" "")))
585 (set (match_operand:QI 0 "register_operand")
586 (match_operator:QI 1 "ordered_comparison_operator"
587 [(cc0) (const_int 0)]))]
593 (compare (match_operand:QI 0 "nonimmediate_src_operand" "dn,dmS,>")
594 (match_operand:QI 1 "general_src_operand" "dmS,nd,>")))]
597 if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM)
598 return "cmpm%.b %1,%0";
599 if (REG_P (operands[1])
600 || (!REG_P (operands[0]) && GET_CODE (operands[0]) != MEM))
602 cc_status.flags |= CC_REVERSED; /*|*/
603 return "cmp%.b %d0,%d1";
605 return "cmp%.b %d1,%d0";
608 (define_expand "cbranch<mode>4"
610 (compare (match_operand:FP 1 "register_operand" "")
611 (match_operand:FP 2 "fp_src_operand" "")))
613 (if_then_else (match_operator 0 "comparison_operator"
614 [(cc0) (const_int 0)])
615 (label_ref (match_operand 3 ""))
620 (define_expand "cstore<mode>4"
622 (compare (match_operand:FP 2 "register_operand" "")
623 (match_operand:FP 3 "fp_src_operand" "")))
624 (set (match_operand:QI 0 "register_operand")
625 (match_operator:QI 1 "m68k_cstore_comparison_operator"
626 [(cc0) (const_int 0)]))]
627 "TARGET_HARD_FLOAT && !(TUNE_68060 || TARGET_COLDFIRE_FPU)"
628 "if (TARGET_COLDFIRE && operands[2] != const0_rtx)
631 (define_insn "*cmp<mode>_68881"
633 (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg>mF")
634 (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg>mF,f")))]
636 && (register_operand (operands[0], <MODE>mode)
637 || register_operand (operands[1], <MODE>mode))"
640 fcmp%.<FP:prec> %f1,%0
641 fcmp%.<FP:prec> %0,%f1"
642 [(set_attr "type" "fcmp")])
644 (define_insn "*cmp<mode>_cf"
646 (compare (match_operand:FP 0 "fp_src_operand" "f,f,<FP:dreg><Q>U")
647 (match_operand:FP 1 "fp_src_operand" "f,<FP:dreg><Q>U,f")))]
649 && (register_operand (operands[0], <MODE>mode)
650 || register_operand (operands[1], <MODE>mode))"
653 fcmp%.<FP:prec> %f1,%0
654 fcmp%.<FP:prec> %0,%f1"
655 [(set_attr "type" "fcmp")])
657 ;; Recognizers for btst instructions.
659 ;; ColdFire/5200 only allows "<Q>" type addresses when the bit position is
660 ;; specified as a constant, so we must disable all patterns that may extract
661 ;; from a MEM at a constant bit position if we can't use this as a constraint.
666 (compare (zero_extract:SI (match_operand:QI 0 "memory_src_operand" "oS")
668 (minus:SI (const_int 7)
669 (match_operand:SI 1 "general_operand" "di")))
673 return output_btst (operands, operands[1], operands[0], insn, 7);
676 ;; This is the same as the above pattern except for the constraints. The 'i'
682 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
684 (minus:SI (const_int 7)
685 (match_operand:SI 1 "general_operand" "d")))
689 return output_btst (operands, operands[1], operands[0], insn, 7);
695 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
697 (minus:SI (const_int 31)
698 (match_operand:SI 1 "general_operand" "di")))
702 return output_btst (operands, operands[1], operands[0], insn, 31);
705 ;; The following two patterns are like the previous two
706 ;; except that they use the fact that bit-number operands
707 ;; are automatically masked to 3 or 5 bits.
712 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
714 (minus:SI (const_int 7)
716 (match_operand:SI 1 "register_operand" "d")
721 return output_btst (operands, operands[1], operands[0], insn, 7);
727 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
729 (minus:SI (const_int 31)
731 (match_operand:SI 1 "register_operand" "d")
736 return output_btst (operands, operands[1], operands[0], insn, 31);
739 ;; Nonoffsettable mem refs are ok in this one pattern
740 ;; since we don't try to adjust them.
744 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "m")
746 (match_operand:SI 1 "const_int_operand" "n"))
748 "(unsigned) INTVAL (operands[1]) < 8 && !TARGET_COLDFIRE"
750 operands[1] = GEN_INT (7 - INTVAL (operands[1]));
751 return output_btst (operands, operands[1], operands[0], insn, 7);
757 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "do")
759 (match_operand:SI 1 "const_int_operand" "n"))
763 if (GET_CODE (operands[0]) == MEM)
765 operands[0] = adjust_address (operands[0], QImode,
766 INTVAL (operands[1]) / 8);
767 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
768 return output_btst (operands, operands[1], operands[0], insn, 7);
770 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
771 return output_btst (operands, operands[1], operands[0], insn, 31);
774 ;; This is the same as the above pattern except for the constraints.
775 ;; The 'o' has been replaced with 'Q'.
780 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "dQ")
782 (match_operand:SI 1 "const_int_operand" "n"))
786 if (GET_CODE (operands[0]) == MEM)
788 operands[0] = adjust_address (operands[0], QImode,
789 INTVAL (operands[1]) / 8);
790 operands[1] = GEN_INT (7 - INTVAL (operands[1]) % 8);
791 return output_btst (operands, operands[1], operands[0], insn, 7);
793 operands[1] = GEN_INT (31 - INTVAL (operands[1]));
794 return output_btst (operands, operands[1], operands[0], insn, 31);
800 ;; A special case in which it is not desirable
801 ;; to reload the constant into a data register.
802 (define_insn "pushexthisi_const"
803 [(set (match_operand:SI 0 "push_operand" "=m,m,m")
804 (match_operand:SI 1 "const_int_operand" "C0,R,J"))]
805 "INTVAL (operands[1]) >= -0x8000 && INTVAL (operands[1]) < 0x8000"
810 [(set_attr "type" "clr_l,mov3q_l,pea")])
813 ;(define_insn "swapsi"
814 ; [(set (match_operand:SI 0 "nonimmediate_operand" "+r")
815 ; (match_operand:SI 1 "general_operand" "+r"))
816 ; (set (match_dup 1) (match_dup 0))]
820 ;; Special case of fullword move when source is zero for 68000_10.
821 ;; moveq is faster on the 68000.
822 (define_insn "*movsi_const0_68000_10"
823 [(set (match_operand:SI 0 "movsi_const0_operand" "=d,a,g")
830 [(set_attr "type" "moveq_l,alu_l,clr_l")
831 (set_attr "opy" "*,0,*")])
833 ;; Special case of fullword move when source is zero for 68040_60.
834 ;; On the '040, 'subl an,an' takes 2 clocks while lea takes only 1
835 (define_insn "*movsi_const0_68040_60"
836 [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
840 if (which_alternative == 0)
841 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
842 else if (which_alternative == 1)
850 [(set_attr "type" "lea,clr_l")])
852 ;; Special case of fullword move when source is zero.
853 (define_insn "*movsi_const0"
854 [(set (match_operand:SI 0 "movsi_const0_operand" "=a,g")
856 "!(TUNE_68000_10 || TUNE_68040_60)"
860 [(set_attr "type" "alu_l,clr_l")
861 (set_attr "opy" "0,*")])
863 ;; General case of fullword move.
865 ;; This is the main "hook" for PIC code. When generating
866 ;; PIC, movsi is responsible for determining when the source address
867 ;; needs PIC relocation and appropriately calling legitimize_pic_address
868 ;; to perform the actual relocation.
870 ;; In both the PIC and non-PIC cases the patterns generated will
871 ;; matched by the next define_insn.
872 (define_expand "movsi"
873 [(set (match_operand:SI 0 "" "")
874 (match_operand:SI 1 "" ""))]
877 rtx tmp, base, offset;
879 /* Recognize the case where operand[1] is a reference to thread-local
880 data and load its address to a register. */
881 if (!TARGET_PCREL && m68k_tls_reference_p (operands[1], false))
883 rtx tmp = operands[1];
886 if (GET_CODE (tmp) == CONST && GET_CODE (XEXP (tmp, 0)) == PLUS)
888 addend = XEXP (XEXP (tmp, 0), 1);
889 tmp = XEXP (XEXP (tmp, 0), 0);
892 gcc_assert (GET_CODE (tmp) == SYMBOL_REF);
893 gcc_assert (SYMBOL_REF_TLS_MODEL (tmp) != 0);
895 tmp = m68k_legitimize_tls_address (tmp);
903 reg = gen_reg_rtx (Pmode);
904 emit_move_insn (reg, tmp);
908 tmp = gen_rtx_PLUS (SImode, tmp, addend);
913 else if (flag_pic && !TARGET_PCREL && symbolic_operand (operands[1], SImode))
915 /* The source is an address which requires PIC relocation.
916 Call legitimize_pic_address with the source, mode, and a relocation
917 register (a new pseudo, or the final destination if reload_in_progress
918 is set). Then fall through normally */
919 rtx temp = reload_in_progress ? operands[0] : gen_reg_rtx (Pmode);
920 operands[1] = legitimize_pic_address (operands[1], SImode, temp);
922 else if (flag_pic && TARGET_PCREL && ! reload_in_progress)
924 /* Don't allow writes to memory except via a register;
925 the m68k doesn't consider PC-relative addresses to be writable. */
926 if (symbolic_operand (operands[0], SImode))
927 operands[0] = force_reg (SImode, XEXP (operands[0], 0));
928 else if (GET_CODE (operands[0]) == MEM
929 && symbolic_operand (XEXP (operands[0], 0), SImode))
930 operands[0] = gen_rtx_MEM (SImode,
931 force_reg (SImode, XEXP (operands[0], 0)));
933 if (M68K_OFFSETS_MUST_BE_WITHIN_SECTIONS_P)
935 split_const (operands[1], &base, &offset);
936 if (GET_CODE (base) == SYMBOL_REF
937 && !offset_within_block_p (base, INTVAL (offset)))
939 tmp = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (SImode);
940 emit_move_insn (tmp, base);
941 emit_insn (gen_addsi3 (operands[0], tmp, offset));
947 ;; General case of fullword move.
948 (define_insn "*movsi_m68k"
949 ;; Notes: make sure no alternative allows g vs g.
950 ;; We don't allow f-regs since fixed point cannot go in them.
951 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
952 (match_operand:SI 1 "general_src_operand" "damSnT,n,i"))]
953 "!TARGET_COLDFIRE && reload_completed"
955 return output_move_simode (operands);
958 ;; Before reload is completed the register constraints
959 ;; force integer constants in range for a moveq to be reloaded
960 ;; if they are headed for memory.
961 (define_insn "*movsi_m68k2"
962 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d,a<")
963 (match_operand:SI 1 "general_src_operand" "damSKT,n,i"))]
967 return output_move_simode (operands);
970 ;; ColdFire move instructions can have at most one operand of mode >= 6.
971 (define_insn "*movsi_cf"
972 [(set (match_operand:SI 0 "nonimmediate_operand" "=g,d, d, d, d, d, a,Ap, a, r<Q>,g, U")
973 (match_operand:SI 1 "general_operand" " R,CQ,CW,CZ,CS,Ci,J,J Cs,Cs, g, Rr<Q>,U"))]
976 switch (which_alternative)
979 return "mov3q%.l %1,%0";
982 return "moveq %1,%0";
986 unsigned u = INTVAL (operands[1]);
988 operands[1] = GEN_INT ((u << 16) | (u >> 16)); /*|*/
989 return "moveq %1,%0\n\tswap %0";
993 return "mvz%.w %1,%0";
996 return "mvs%.w %1,%0";
999 return "move%.l %1,%0";
1002 return "move%.w %1,%0";
1008 return "lea %a1,%0";
1013 return "move%.l %1,%0";
1020 [(set_attr "type" "mov3q_l,moveq_l,*,mvsz,mvsz,move_l,move,pea,lea,move_l,move_l,move_l")])
1022 ;; Special case of fullword move, where we need to get a non-GOT PIC
1023 ;; reference into an address register.
1025 [(set (match_operand:SI 0 "nonimmediate_operand" "=a<")
1026 (match_operand:SI 1 "pcrel_address" ""))]
1029 if (push_operand (operands[0], SImode))
1031 return "lea %a1,%0";
1034 (define_expand "movhi"
1035 [(set (match_operand:HI 0 "nonimmediate_operand" "")
1036 (match_operand:HI 1 "general_operand" ""))]
1041 [(set (match_operand:HI 0 "nonimmediate_operand" "=g")
1042 (match_operand:HI 1 "general_src_operand" "gS"))]
1044 "* return output_move_himode (operands);")
1047 [(set (match_operand:HI 0 "nonimmediate_operand" "=r<Q>,g,U")
1048 (match_operand:HI 1 "general_operand" "g,r<Q>,U"))]
1050 "* return output_move_himode (operands);")
1052 (define_expand "movstricthi"
1053 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" ""))
1054 (match_operand:HI 1 "general_src_operand" ""))]
1059 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
1060 (match_operand:HI 1 "general_src_operand" "rmSn"))]
1062 "* return output_move_stricthi (operands);")
1065 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+d,m"))
1066 (match_operand:HI 1 "general_src_operand" "rmn,r"))]
1068 "* return output_move_stricthi (operands);")
1070 (define_expand "movqi"
1071 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1072 (match_operand:QI 1 "general_src_operand" ""))]
1077 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,*a,m")
1078 (match_operand:QI 1 "general_src_operand" "dmSi*a,di*a,dmSi"))]
1080 "* return output_move_qimode (operands);")
1083 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>,dm,U,d*a")
1084 (match_operand:QI 1 "general_src_operand" "dmi,d<Q>,U,di*a"))]
1086 "* return output_move_qimode (operands);")
1088 (define_expand "movstrictqi"
1089 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" ""))
1090 (match_operand:QI 1 "general_src_operand" ""))]
1095 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
1096 (match_operand:QI 1 "general_src_operand" "dmSn"))]
1098 "* return output_move_strictqi (operands);")
1100 (define_insn "*movstrictqi_cf"
1101 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+d, Ac, d,m"))
1102 (match_operand:QI 1 "general_src_operand" "C0,C0, dmn,d"))]
1109 [(set_attr "type" "clr,clr,move,move")])
1111 (define_expand "pushqi1"
1112 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))
1113 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int 1)))
1114 (match_operand:QI 0 "general_operand" ""))]
1118 (define_expand "reload_insf"
1119 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
1120 (match_operand:SF 1 "general_operand" "mf"))
1121 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1122 "TARGET_COLDFIRE_FPU"
1124 if (emit_move_sequence (operands, SFmode, operands[2]))
1127 /* We don't want the clobber emitted, so handle this ourselves. */
1128 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1132 (define_expand "reload_outsf"
1133 [(set (match_operand:SF 0 "general_operand" "")
1134 (match_operand:SF 1 "register_operand" "f"))
1135 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1136 "TARGET_COLDFIRE_FPU"
1138 if (emit_move_sequence (operands, SFmode, operands[2]))
1141 /* We don't want the clobber emitted, so handle this ourselves. */
1142 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1146 (define_expand "movsf"
1147 [(set (match_operand:SF 0 "nonimmediate_operand" "")
1148 (match_operand:SF 1 "general_operand" ""))]
1153 [(set (match_operand:SF 0 "nonimmediate_operand" "=rmf")
1154 (match_operand:SF 1 "general_operand" "rmfF"))]
1157 if (FP_REG_P (operands[0]))
1159 if (FP_REG_P (operands[1]))
1160 return "f%$move%.x %1,%0";
1161 else if (ADDRESS_REG_P (operands[1]))
1162 return "move%.l %1,%-\;f%$move%.s %+,%0";
1163 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
1164 return output_move_const_single (operands);
1165 return "f%$move%.s %f1,%0";
1167 if (FP_REG_P (operands[1]))
1169 if (ADDRESS_REG_P (operands[0]))
1170 return "fmove%.s %1,%-\;move%.l %+,%0";
1171 return "fmove%.s %f1,%0";
1173 if (operands[1] == CONST0_RTX (SFmode)
1174 /* clr insns on 68000 read before writing. */
1175 && ((TARGET_68010 || TARGET_COLDFIRE)
1176 || !(GET_CODE (operands[0]) == MEM && MEM_VOLATILE_P (operands[0]))))
1178 if (ADDRESS_REG_P (operands[0]))
1180 /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
1182 return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
1184 return "sub%.l %0,%0";
1186 /* moveq is faster on the 68000. */
1187 if (DATA_REG_P (operands[0]) && TUNE_68000_10)
1188 return "moveq #0,%0";
1191 return "move%.l %1,%0";
1194 (define_insn "movsf_cf_soft"
1195 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>,g,U")
1196 (match_operand:SF 1 "general_operand" "g,r<Q>,U"))]
1197 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1199 [(set_attr "type" "move_l")])
1201 ;; SFmode MEMs are restricted to modes 2-4 if TARGET_COLDFIRE_FPU.
1202 ;; The move instructions can handle all combinations.
1203 (define_insn "movsf_cf_hard"
1204 [(set (match_operand:SF 0 "nonimmediate_operand" "=r<Q>U, f, f,mr,f,r<Q>,f
1206 (match_operand:SF 1 "general_operand" " f, r<Q>U,f,rm,F,F, m
1208 "TARGET_COLDFIRE_FPU"
1210 if (which_alternative == 4 || which_alternative == 5) {
1214 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1215 REAL_VALUE_TO_TARGET_SINGLE (r, l);
1216 xoperands[0] = operands[0];
1217 xoperands[1] = GEN_INT (l);
1218 if (which_alternative == 5) {
1220 if (ADDRESS_REG_P (xoperands[0]))
1221 output_asm_insn ("sub%.l %0,%0", xoperands);
1223 output_asm_insn ("clr%.l %0", xoperands);
1225 if (GET_CODE (operands[0]) == MEM
1226 && symbolic_operand (XEXP (operands[0], 0), SImode))
1227 output_asm_insn ("move%.l %1,%-;move%.l %+,%0", xoperands);
1229 output_asm_insn ("move%.l %1,%0", xoperands);
1233 output_asm_insn ("move%.l %1,%-;fsmove%.s %+,%0", xoperands);
1235 output_asm_insn ("clr%.l %-;fsmove%.s %+,%0", xoperands);
1238 if (FP_REG_P (operands[0]))
1240 if (ADDRESS_REG_P (operands[1]))
1241 return "move%.l %1,%-;fsmove%.s %+,%0";
1242 if (FP_REG_P (operands[1]))
1243 return "fsmove%.d %1,%0";
1244 return "fsmove%.s %f1,%0";
1246 if (FP_REG_P (operands[1]))
1248 if (ADDRESS_REG_P (operands[0]))
1249 return "fmove%.s %1,%-;move%.l %+,%0";
1250 return "fmove%.s %f1,%0";
1252 if (operands[1] == CONST0_RTX (SFmode))
1254 if (ADDRESS_REG_P (operands[0]))
1255 return "sub%.l %0,%0";
1258 return "move%.l %1,%0";
1261 (define_expand "reload_indf"
1262 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
1263 (match_operand:DF 1 "general_operand" "mf"))
1264 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1265 "TARGET_COLDFIRE_FPU"
1267 if (emit_move_sequence (operands, DFmode, operands[2]))
1270 /* We don't want the clobber emitted, so handle this ourselves. */
1271 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1275 (define_expand "reload_outdf"
1276 [(set (match_operand:DF 0 "general_operand" "")
1277 (match_operand:DF 1 "register_operand" "f"))
1278 (clobber (match_operand:SI 2 "register_operand" "=&a"))]
1279 "TARGET_COLDFIRE_FPU"
1281 if (emit_move_sequence (operands, DFmode, operands[2]))
1284 /* We don't want the clobber emitted, so handle this ourselves. */
1285 emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
1289 (define_expand "movdf"
1290 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1291 (match_operand:DF 1 "general_operand" ""))]
1294 if (TARGET_COLDFIRE_FPU)
1295 if (emit_move_sequence (operands, DFmode, 0))
1300 [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,rf,rf,&rof<>")
1301 (match_operand:DF 1 "general_operand" "*rf,m,0,*rofE<>"))]
1302 ; [(set (match_operand:DF 0 "nonimmediate_operand" "=rm,&rf,&rof<>")
1303 ; (match_operand:DF 1 "general_operand" "rf,m,rofF<>"))]
1306 if (FP_REG_P (operands[0]))
1308 if (FP_REG_P (operands[1]))
1309 return "f%&move%.x %1,%0";
1310 if (REG_P (operands[1]))
1313 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1314 output_asm_insn ("move%.l %1,%-", xoperands);
1315 output_asm_insn ("move%.l %1,%-", operands);
1316 return "f%&move%.d %+,%0";
1318 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1319 return output_move_const_double (operands);
1320 return "f%&move%.d %f1,%0";
1322 else if (FP_REG_P (operands[1]))
1324 if (REG_P (operands[0]))
1326 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1327 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1328 return "move%.l %+,%0";
1331 return "fmove%.d %f1,%0";
1333 return output_move_double (operands);
1336 (define_insn_and_split "movdf_cf_soft"
1337 [(set (match_operand:DF 0 "nonimmediate_operand" "=r,g")
1338 (match_operand:DF 1 "general_operand" "g,r"))]
1339 "TARGET_COLDFIRE && !TARGET_COLDFIRE_FPU"
1341 "&& reload_completed"
1344 m68k_emit_move_double (operands);
1348 (define_insn "movdf_cf_hard"
1349 [(set (match_operand:DF 0 "nonimmediate_operand" "=f, <Q>U,r,f,r,r,m,f")
1350 (match_operand:DF 1 "general_operand" " f<Q>U,f, f,r,r,m,r,E"))]
1351 "TARGET_COLDFIRE_FPU"
1357 switch (which_alternative)
1360 return "fdmove%.d %1,%0";
1362 return "fmove%.d %1,%0";
1364 return "fmove%.d %1,%-;move%.l %+,%0;move%.l %+,%R0";
1366 return "move%.l %R1,%-;move%.l %1,%-;fdmove%.d %+,%0";
1367 case 4: case 5: case 6:
1368 return output_move_double (operands);
1370 REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
1371 REAL_VALUE_TO_TARGET_DOUBLE (r, l);
1372 xoperands[0] = operands[0];
1373 xoperands[1] = GEN_INT (l[0]);
1374 xoperands[2] = GEN_INT (l[1]);
1375 if (operands[1] == CONST0_RTX (DFmode))
1376 output_asm_insn ("clr%.l %-;clr%.l %-;fdmove%.d %+,%0",
1380 output_asm_insn ("clr%.l %-;move%.l %1,%-;fdmove%.d %+,%0",
1383 output_asm_insn ("move%.l %2,%-;move%.l %1,%-;fdmove%.d %+,%0",
1389 ;; ??? The XFmode patterns are schizophrenic about whether constants are
1390 ;; allowed. Most but not all have predicates and constraint that disallow
1391 ;; constants. Most but not all have output templates that handle constants.
1392 ;; See also TARGET_LEGITIMATE_CONSTANT_P.
1394 (define_expand "movxf"
1395 [(set (match_operand:XF 0 "nonimmediate_operand" "")
1396 (match_operand:XF 1 "general_operand" ""))]
1399 /* We can't rewrite operands during reload. */
1400 if (! reload_in_progress)
1402 if (CONSTANT_P (operands[1]))
1404 operands[1] = force_const_mem (XFmode, operands[1]);
1405 if (! memory_address_p (XFmode, XEXP (operands[1], 0)))
1406 operands[1] = adjust_address (operands[1], XFmode, 0);
1408 if (flag_pic && TARGET_PCREL)
1410 /* Don't allow writes to memory except via a register; the
1411 m68k doesn't consider PC-relative addresses to be writable. */
1412 if (GET_CODE (operands[0]) == MEM
1413 && symbolic_operand (XEXP (operands[0], 0), SImode))
1414 operands[0] = gen_rtx_MEM (XFmode,
1415 force_reg (SImode, XEXP (operands[0], 0)));
1421 [(set (match_operand:XF 0 "nonimmediate_operand" "=f,m,f,!r,!f,!r,m,!r")
1422 (match_operand:XF 1 "nonimmediate_operand" "m,f,f,f,r,!r,!r,m"))]
1425 if (FP_REG_P (operands[0]))
1427 if (FP_REG_P (operands[1]))
1428 return "fmove%.x %1,%0";
1429 if (REG_P (operands[1]))
1432 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1433 output_asm_insn ("move%.l %1,%-", xoperands);
1434 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1435 output_asm_insn ("move%.l %1,%-", xoperands);
1436 output_asm_insn ("move%.l %1,%-", operands);
1437 return "fmove%.x %+,%0";
1439 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1440 return "fmove%.x %1,%0";
1441 return "fmove%.x %f1,%0";
1443 if (FP_REG_P (operands[1]))
1445 if (REG_P (operands[0]))
1447 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1448 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1449 output_asm_insn ("move%.l %+,%0", operands);
1450 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1451 return "move%.l %+,%0";
1453 /* Must be memory destination. */
1454 return "fmove%.x %f1,%0";
1456 return output_move_double (operands);
1460 [(set (match_operand:XF 0 "nonimmediate_operand" "=rm,rf,&rof<>")
1461 (match_operand:XF 1 "nonimmediate_operand" "rf,m,rof<>"))]
1462 "! TARGET_68881 && ! TARGET_COLDFIRE"
1464 if (FP_REG_P (operands[0]))
1466 if (FP_REG_P (operands[1]))
1467 return "fmove%.x %1,%0";
1468 if (REG_P (operands[1]))
1471 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 2);
1472 output_asm_insn ("move%.l %1,%-", xoperands);
1473 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1474 output_asm_insn ("move%.l %1,%-", xoperands);
1475 output_asm_insn ("move%.l %1,%-", operands);
1476 return "fmove%.x %+,%0";
1478 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1479 return "fmove%.x %1,%0";
1480 return "fmove%.x %f1,%0";
1482 if (FP_REG_P (operands[1]))
1484 if (REG_P (operands[0]))
1486 output_asm_insn ("fmove%.x %f1,%-\;move%.l %+,%0", operands);
1487 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1488 output_asm_insn ("move%.l %+,%0", operands);
1489 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1490 return "move%.l %+,%0";
1493 return "fmove%.x %f1,%0";
1495 return output_move_double (operands);
1499 [(set (match_operand:XF 0 "nonimmediate_operand" "=r,g")
1500 (match_operand:XF 1 "nonimmediate_operand" "g,r"))]
1501 "! TARGET_68881 && TARGET_COLDFIRE"
1502 "* return output_move_double (operands);")
1504 (define_expand "movdi"
1505 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1506 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1507 (match_operand:DI 1 "general_operand" ""))]
1511 ;; movdi can apply to fp regs in some cases
1513 ;; Let's see if it really still needs to handle fp regs, and, if so, why.
1514 [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,r,&ro<>")
1515 (match_operand:DI 1 "general_operand" "rF,m,roi<>F"))]
1516 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&r,&ro<>,!&rm,!&f")
1517 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF"))]
1518 ; [(set (match_operand:DI 0 "nonimmediate_operand" "=rm,&rf,&ro<>,!&rm,!&f")
1519 ; (match_operand:DI 1 "general_operand" "r,m,roi<>,fF,rfF"))]
1522 if (FP_REG_P (operands[0]))
1524 if (FP_REG_P (operands[1]))
1525 return "fmove%.x %1,%0";
1526 if (REG_P (operands[1]))
1529 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
1530 output_asm_insn ("move%.l %1,%-", xoperands);
1531 output_asm_insn ("move%.l %1,%-", operands);
1532 return "fmove%.d %+,%0";
1534 if (GET_CODE (operands[1]) == CONST_DOUBLE)
1535 return output_move_const_double (operands);
1536 return "fmove%.d %f1,%0";
1538 else if (FP_REG_P (operands[1]))
1540 if (REG_P (operands[0]))
1542 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1543 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1544 return "move%.l %+,%0";
1547 return "fmove%.d %f1,%0";
1549 return output_move_double (operands);
1553 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,g")
1554 (match_operand:DI 1 "general_operand" "g,r"))]
1556 "* return output_move_double (operands);")
1558 ;; Thus goes after the move instructions
1559 ;; because the move instructions are better (require no spilling)
1560 ;; when they can apply. It goes before the add/sub insns
1561 ;; so we will prefer it to them.
1563 (define_insn "pushasi"
1564 [(set (match_operand:SI 0 "push_operand" "=m")
1565 (match_operand:SI 1 "address_operand" "p"))]
1568 [(set_attr "type" "pea")])
1570 ;; truncation instructions
1571 (define_insn "truncsiqi2"
1572 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1574 (match_operand:SI 1 "general_src_operand" "doJS,i")))]
1577 if (GET_CODE (operands[0]) == REG)
1579 /* Must clear condition codes, since the move.l bases them on
1580 the entire 32 bits, not just the desired 8 bits. */
1582 return "move%.l %1,%0";
1584 if (GET_CODE (operands[1]) == MEM)
1585 operands[1] = adjust_address (operands[1], QImode, 3);
1586 return "move%.b %1,%0";
1589 (define_insn "trunchiqi2"
1590 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,d")
1592 (match_operand:HI 1 "general_src_operand" "doJS,i")))]
1595 if (GET_CODE (operands[0]) == REG
1596 && (GET_CODE (operands[1]) == MEM
1597 || GET_CODE (operands[1]) == CONST_INT))
1599 /* Must clear condition codes, since the move.w bases them on
1600 the entire 16 bits, not just the desired 8 bits. */
1602 return "move%.w %1,%0";
1604 if (GET_CODE (operands[0]) == REG)
1606 /* Must clear condition codes, since the move.l bases them on
1607 the entire 32 bits, not just the desired 8 bits. */
1609 return "move%.l %1,%0";
1611 if (GET_CODE (operands[1]) == MEM)
1612 operands[1] = adjust_address (operands[1], QImode, 1);
1613 return "move%.b %1,%0";
1616 (define_insn "truncsihi2"
1617 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm,d")
1619 (match_operand:SI 1 "general_src_operand" "roJS,i")))]
1622 if (GET_CODE (operands[0]) == REG)
1624 /* Must clear condition codes, since the move.l bases them on
1625 the entire 32 bits, not just the desired 8 bits. */
1627 return "move%.l %1,%0";
1629 if (GET_CODE (operands[1]) == MEM)
1630 operands[1] = adjust_address (operands[1], QImode, 2);
1631 return "move%.w %1,%0";
1634 ;; zero extension instructions
1636 ;; two special patterns to match various post_inc/pre_dec patterns
1637 (define_insn_and_split "*zero_extend_inc"
1638 [(set (match_operand 0 "post_inc_operand" "")
1639 (zero_extend (match_operand 1 "register_operand" "")))]
1640 "GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1641 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1642 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1650 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1653 (define_insn_and_split "*zero_extend_dec"
1654 [(set (match_operand 0 "pre_dec_operand" "")
1655 (zero_extend (match_operand 1 "register_operand" "")))]
1656 "(GET_MODE (operands[0]) != HImode || XEXP (XEXP (operands[0], 0), 0) != stack_pointer_rtx) &&
1657 GET_MODE_CLASS (GET_MODE (operands[0])) == MODE_INT &&
1658 GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_INT &&
1659 GET_MODE_SIZE (GET_MODE (operands[0])) == GET_MODE_SIZE (GET_MODE (operands[1])) * 2"
1667 operands[0] = adjust_address (operands[0], GET_MODE (operands[1]), 0);
1670 (define_insn_and_split "zero_extendqidi2"
1671 [(set (match_operand:DI 0 "register_operand" "")
1672 (zero_extend:DI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1677 (zero_extend:SI (match_dup 1)))
1681 operands[2] = gen_lowpart (SImode, operands[0]);
1682 operands[3] = gen_highpart (SImode, operands[0]);
1685 (define_insn_and_split "zero_extendhidi2"
1686 [(set (match_operand:DI 0 "register_operand" "")
1687 (zero_extend:DI (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1692 (zero_extend:SI (match_dup 1)))
1696 operands[2] = gen_lowpart (SImode, operands[0]);
1697 operands[3] = gen_highpart (SImode, operands[0]);
1700 (define_expand "zero_extendsidi2"
1701 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1702 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1705 if (GET_CODE (operands[0]) == MEM
1706 && GET_CODE (operands[1]) == MEM)
1707 operands[1] = force_reg (SImode, operands[1]);
1710 (define_insn_and_split "*zero_extendsidi2"
1711 [(set (match_operand:DI 0 "nonimmediate_operand" "")
1712 (zero_extend:DI (match_operand:SI 1 "nonimmediate_src_operand" "")))]
1713 "GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != MEM"
1721 operands[2] = gen_lowpart (SImode, operands[0]);
1722 operands[3] = gen_highpart (SImode, operands[0]);
1725 (define_insn "*zero_extendhisi2_cf"
1726 [(set (match_operand:SI 0 "register_operand" "=d")
1727 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1730 [(set_attr "type" "mvsz")])
1732 (define_insn "zero_extendhisi2"
1733 [(set (match_operand:SI 0 "register_operand" "=d")
1734 (zero_extend:SI (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1738 (define_expand "zero_extendqihi2"
1739 [(set (match_operand:HI 0 "register_operand" "")
1740 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "")))]
1744 (define_insn "*zero_extendqihi2"
1745 [(set (match_operand:HI 0 "register_operand" "=d")
1746 (zero_extend:HI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1750 (define_insn "*zero_extendqisi2_cfv4"
1751 [(set (match_operand:SI 0 "register_operand" "=d")
1752 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1755 [(set_attr "type" "mvsz")])
1757 (define_insn "zero_extendqisi2"
1758 [(set (match_operand:SI 0 "register_operand" "=d")
1759 (zero_extend:SI (match_operand:QI 1 "nonimmediate_src_operand" "dmS")))]
1763 ;; these two pattern split everything else which isn't matched by
1764 ;; something else above
1766 [(set (match_operand 0 "register_operand" "")
1767 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1770 && reg_mentioned_p (operands[0], operands[1])"
1771 [(set (strict_low_part (match_dup 2))
1774 (match_op_dup 4 [(match_dup 0) (match_dup 3)]))]
1776 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1777 operands[3] = GEN_INT (GET_MODE_MASK (GET_MODE (operands[1])));
1778 operands[4] = gen_rtx_AND (GET_MODE (operands[0]), operands[0], operands[3]);
1782 [(set (match_operand 0 "register_operand" "")
1783 (zero_extend (match_operand 1 "nonimmediate_src_operand" "")))]
1784 "!ISA_HAS_MVS_MVZ && reload_completed"
1787 (set (strict_low_part (match_dup 2))
1790 operands[2] = gen_lowpart (GET_MODE (operands[1]), operands[0]);
1793 ;; sign extension instructions
1795 (define_insn "extendqidi2"
1796 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1797 (sign_extend:DI (match_operand:QI 1 "general_src_operand" "rmS")))]
1801 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1802 if (ISA_HAS_MVS_MVZ)
1803 return "mvs%.b %1,%2\;smi %0\;extb%.l %0";
1804 if (TARGET_68020 || TARGET_COLDFIRE)
1806 if (ADDRESS_REG_P (operands[1]))
1807 return "move%.w %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1809 return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
1813 if (ADDRESS_REG_P (operands[1]))
1814 return "move%.w %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1816 return "move%.b %1,%2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0\;smi %0";
1820 (define_insn "extendhidi2"
1821 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
1823 (match_operand:HI 1 "general_src_operand" "rmS")))]
1827 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1828 if (ISA_HAS_MVS_MVZ)
1829 return "mvs%.w %1,%2\;smi %0\;extb%.l %0";
1830 if (TARGET_68020 || TARGET_COLDFIRE)
1831 return "move%.w %1,%2\;ext%.l %2\;smi %0\;extb%.l %0";
1833 return "move%.w %1,%2\;ext%.l %2\;smi %0\;ext%.w %0\;ext%.l %0";
1836 (define_insn "extendsidi2"
1837 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o,o,<")
1839 (match_operand:SI 1 "nonimmediate_src_operand" "rm,rm,r<Q>,rm")))
1840 (clobber (match_scratch:SI 2 "=X,d,d,d"))]
1845 if (which_alternative == 0)
1846 /* Handle alternative 0. */
1848 if (TARGET_68020 || TARGET_COLDFIRE)
1849 return "move%.l %1,%R0\;smi %0\;extb%.l %0";
1851 return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
1854 /* Handle alternatives 1, 2 and 3. We don't need to adjust address by 4
1855 in alternative 3 because autodecrement will do that for us. */
1856 operands[3] = adjust_address (operands[0], SImode,
1857 which_alternative == 3 ? 0 : 4);
1858 operands[0] = adjust_address (operands[0], SImode, 0);
1860 if (TARGET_68020 || TARGET_COLDFIRE)
1861 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
1863 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
1865 [(set_attr "ok_for_coldfire" "yes,no,yes,yes")])
1867 ;; Special case when one can avoid register clobbering, copy and test
1868 ;; Maybe there is a way to make that the general case, by forcing the
1869 ;; result of the SI tree to be in the lower register of the DI target
1871 ;; Don't allow memory for operand 1 as that would require an earlyclobber
1872 ;; which results in worse code
1873 (define_insn "extendplussidi"
1874 [(set (match_operand:DI 0 "register_operand" "=d")
1875 (sign_extend:DI (plus:SI (match_operand:SI 1 "general_operand" "%rn")
1876 (match_operand:SI 2 "general_operand" "rmn"))))]
1880 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1881 if (GET_CODE (operands[1]) == CONST_INT
1882 && (unsigned) INTVAL (operands[1]) > 8)
1884 rtx tmp = operands[1];
1886 operands[1] = operands[2];
1889 if (GET_CODE (operands[1]) == REG
1890 && REGNO (operands[1]) == REGNO (operands[3]))
1891 output_asm_insn ("add%.l %2,%3", operands);
1893 output_asm_insn ("move%.l %2,%3\;add%.l %1,%3", operands);
1894 if (TARGET_68020 || TARGET_COLDFIRE)
1895 return "smi %0\;extb%.l %0";
1897 return "smi %0\;ext%.w %0\;ext%.l %0";
1900 (define_expand "extendhisi2"
1901 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1903 (match_operand:HI 1 "nonimmediate_src_operand" "")))]
1907 (define_insn "*cfv4_extendhisi2"
1908 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1910 (match_operand:HI 1 "nonimmediate_src_operand" "rmS")))]
1913 [(set_attr "type" "mvsz")])
1915 (define_insn "*68k_extendhisi2"
1916 [(set (match_operand:SI 0 "nonimmediate_operand" "=*d,a")
1918 (match_operand:HI 1 "nonimmediate_src_operand" "0,rmS")))]
1923 [(set_attr "type" "ext,move")])
1925 (define_insn "extendqihi2"
1926 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
1927 (sign_extend:HI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1930 [(set_attr "type" "ext")])
1932 (define_expand "extendqisi2"
1933 [(set (match_operand:SI 0 "nonimmediate_operand" "")
1934 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "")))]
1935 "TARGET_68020 || TARGET_COLDFIRE"
1938 (define_insn "*cfv4_extendqisi2"
1939 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1940 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "rms")))]
1943 [(set_attr "type" "mvsz")])
1945 (define_insn "*68k_extendqisi2"
1946 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
1947 (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "0")))]
1948 "TARGET_68020 || (TARGET_COLDFIRE && !ISA_HAS_MVS_MVZ)"
1950 [(set_attr "type" "ext")])
1952 ;; Conversions between float and double.
1954 (define_expand "extendsfdf2"
1955 [(set (match_operand:DF 0 "nonimmediate_operand" "")
1957 (match_operand:SF 1 "general_operand" "")))]
1962 [(set (match_operand:DF 0 "nonimmediate_operand" "=*fdm,f")
1964 (match_operand:SF 1 "general_operand" "f,dmF")))]
1967 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1969 if (REGNO (operands[0]) == REGNO (operands[1]))
1971 /* Extending float to double in an fp-reg is a no-op.
1972 NOTICE_UPDATE_CC has already assumed that the
1973 cc will be set. So cancel what it did. */
1974 cc_status = cc_prev_status;
1977 return "f%&move%.x %1,%0";
1979 if (FP_REG_P (operands[0]))
1980 return "f%&move%.s %f1,%0";
1981 if (DATA_REG_P (operands[0]) && FP_REG_P (operands[1]))
1983 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
1984 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
1985 return "move%.l %+,%0";
1987 return "fmove%.d %f1,%0";
1990 (define_insn "extendsfdf2_cf"
1991 [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f")
1993 (match_operand:SF 1 "general_operand" "f,<Q>U")))]
1994 "TARGET_COLDFIRE_FPU"
1996 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
1998 if (REGNO (operands[0]) == REGNO (operands[1]))
2000 /* Extending float to double in an fp-reg is a no-op.
2001 NOTICE_UPDATE_CC has already assumed that the
2002 cc will be set. So cancel what it did. */
2003 cc_status = cc_prev_status;
2006 return "fdmove%.d %1,%0";
2008 return "fdmove%.s %f1,%0";
2011 ;; This cannot output into an f-reg because there is no way to be
2012 ;; sure of truncating in that case.
2013 (define_expand "truncdfsf2"
2014 [(set (match_operand:SF 0 "nonimmediate_operand" "")
2016 (match_operand:DF 1 "general_operand" "")))]
2020 ;; On the '040 we can truncate in a register accurately and easily.
2022 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
2024 (match_operand:DF 1 "general_operand" "fmG")))]
2025 "TARGET_68881 && TARGET_68040"
2027 if (FP_REG_P (operands[1]))
2028 return "f%$move%.x %1,%0";
2029 return "f%$move%.d %f1,%0";
2032 (define_insn "truncdfsf2_cf"
2033 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,d<Q>U")
2035 (match_operand:DF 1 "general_operand" "<Q>U,f")))]
2036 "TARGET_COLDFIRE_FPU"
2040 [(set_attr "type" "fmove")])
2042 (define_insn "*truncdfsf2_68881"
2043 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
2045 (match_operand:DF 1 "general_operand" "f")))]
2048 [(set_attr "type" "fmove")])
2050 ;; Conversion between fixed point and floating point.
2051 ;; Note that among the fix-to-float insns
2052 ;; the ones that start with SImode come first.
2053 ;; That is so that an operand that is a CONST_INT
2054 ;; (and therefore lacks a specific machine mode).
2055 ;; will be recognized as SImode (which is always valid)
2056 ;; rather than as QImode or HImode.
2058 (define_expand "floatsi<mode>2"
2059 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2060 (float:FP (match_operand:SI 1 "general_operand" "")))]
2064 (define_insn "floatsi<mode>2_68881"
2065 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2066 (float:FP (match_operand:SI 1 "general_operand" "dmi")))]
2068 "f<FP:round>move%.l %1,%0"
2069 [(set_attr "type" "fmove")])
2071 (define_insn "floatsi<mode>2_cf"
2072 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2073 (float:FP (match_operand:SI 1 "general_operand" "d<Q>U")))]
2074 "TARGET_COLDFIRE_FPU"
2075 "f<FP:prec>move%.l %1,%0"
2076 [(set_attr "type" "fmove")])
2079 (define_expand "floathi<mode>2"
2080 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2081 (float:FP (match_operand:HI 1 "general_operand" "")))]
2085 (define_insn "floathi<mode>2_68881"
2086 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2087 (float:FP (match_operand:HI 1 "general_operand" "dmn")))]
2090 [(set_attr "type" "fmove")])
2092 (define_insn "floathi<mode>2_cf"
2093 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2094 (float:FP (match_operand:HI 1 "general_operand" "d<Q>U")))]
2095 "TARGET_COLDFIRE_FPU"
2097 [(set_attr "type" "fmove")])
2100 (define_expand "floatqi<mode>2"
2101 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2102 (float:FP (match_operand:QI 1 "general_operand" "")))]
2106 (define_insn "floatqi<mode>2_68881"
2107 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2108 (float:FP (match_operand:QI 1 "general_operand" "dmn")))]
2111 [(set_attr "type" "fmove")])
2113 (define_insn "floatqi<mode>2_cf"
2114 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2115 (float:FP (match_operand:QI 1 "general_operand" "d<Q>U")))]
2116 "TARGET_COLDFIRE_FPU"
2118 [(set_attr "type" "fmove")])
2121 ;; New routines to convert floating-point values to integers
2122 ;; to be used on the '040. These should be faster than trapping
2123 ;; into the kernel to emulate fintrz. They should also be faster
2124 ;; than calling the subroutines fixsfsi or fixdfsi.
2126 (define_insn "fix_truncdfsi2"
2127 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2128 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2129 (clobber (match_scratch:SI 2 "=d"))
2130 (clobber (match_scratch:SI 3 "=d"))]
2131 "TARGET_68881 && TUNE_68040"
2134 return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.l %1,%0\;fmovem%.l %2,%!";
2137 (define_insn "fix_truncdfhi2"
2138 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2139 (fix:HI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2140 (clobber (match_scratch:SI 2 "=d"))
2141 (clobber (match_scratch:SI 3 "=d"))]
2142 "TARGET_68881 && TUNE_68040"
2145 return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.w %1,%0\;fmovem%.l %2,%!";
2148 (define_insn "fix_truncdfqi2"
2149 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2150 (fix:QI (fix:DF (match_operand:DF 1 "register_operand" "f"))))
2151 (clobber (match_scratch:SI 2 "=d"))
2152 (clobber (match_scratch:SI 3 "=d"))]
2153 "TARGET_68881 && TUNE_68040"
2156 return "fmovem%.l %!,%2\;moveq #16,%3\;or%.l %2,%3\;and%.w #-33,%3\;fmovem%.l %3,%!\;fmove%.b %1,%0\;fmovem%.l %2,%!";
2159 ;; Convert a float to a float whose value is an integer.
2160 ;; This is the first stage of converting it to an integer type.
2162 (define_expand "ftrunc<mode>2"
2163 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2164 (fix:FP (match_operand:FP 1 "general_operand" "")))]
2165 "TARGET_HARD_FLOAT && !TUNE_68040"
2168 (define_insn "ftrunc<mode>2_68881"
2169 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2170 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
2171 "TARGET_68881 && !TUNE_68040"
2173 if (FP_REG_P (operands[1]))
2174 return "fintrz%.x %f1,%0";
2175 return "fintrz%.<FP:prec> %f1,%0";
2177 [(set_attr "type" "falu")])
2179 (define_insn "ftrunc<mode>2_cf"
2180 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2181 (fix:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
2182 "TARGET_COLDFIRE_FPU"
2184 if (FP_REG_P (operands[1]))
2185 return "fintrz%.d %f1,%0";
2186 return "fintrz%.<FP:prec> %f1,%0";
2188 [(set_attr "type" "falu")])
2190 ;; Convert a float whose value is an integer
2191 ;; to an actual integer. Second stage of converting float to integer type.
2192 (define_expand "fix<mode>qi2"
2193 [(set (match_operand:QI 0 "nonimmediate_operand" "")
2194 (fix:QI (match_operand:FP 1 "general_operand" "")))]
2198 (define_insn "fix<mode>qi2_68881"
2199 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
2200 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2203 [(set_attr "type" "fmove")])
2205 (define_insn "fix<mode>qi2_cf"
2206 [(set (match_operand:QI 0 "nonimmediate_operand" "=d<Q>U")
2207 (fix:QI (match_operand:FP 1 "general_operand" "f")))]
2208 "TARGET_COLDFIRE_FPU"
2210 [(set_attr "type" "fmove")])
2212 (define_expand "fix<mode>hi2"
2213 [(set (match_operand:HI 0 "nonimmediate_operand" "")
2214 (fix:HI (match_operand:FP 1 "general_operand" "")))]
2218 (define_insn "fix<mode>hi2_68881"
2219 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
2220 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2223 [(set_attr "type" "fmove")])
2225 (define_insn "fix<mode>hi2_cf"
2226 [(set (match_operand:HI 0 "nonimmediate_operand" "=d<Q>U")
2227 (fix:HI (match_operand:FP 1 "general_operand" "f")))]
2228 "TARGET_COLDFIRE_FPU"
2230 [(set_attr "type" "fmove")])
2232 (define_expand "fix<mode>si2"
2233 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2234 (fix:SI (match_operand:FP 1 "general_operand" "")))]
2238 (define_insn "fix<mode>si2_68881"
2239 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
2240 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2243 [(set_attr "type" "fmove")])
2245 (define_insn "fix<mode>si2_cf"
2246 [(set (match_operand:SI 0 "nonimmediate_operand" "=d<Q>U")
2247 (fix:SI (match_operand:FP 1 "general_operand" "f")))]
2248 "TARGET_COLDFIRE_FPU"
2250 [(set_attr "type" "fmove")])
2255 (define_insn "adddi_lshrdi_63"
2256 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
2257 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "rm")
2260 (clobber (match_scratch:SI 2 "=d"))]
2263 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2264 if (REG_P (operands[1]) && REGNO (operands[1]) == REGNO (operands[0]))
2266 "move%.l %1,%2\;add%.l %2,%2\;subx%.l %2,%2\;sub%.l %2,%3\;subx%.l %2,%0";
2267 if (GET_CODE (operands[1]) == REG)
2268 operands[4] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2269 else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC
2270 || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2271 operands[4] = operands[1];
2273 operands[4] = adjust_address (operands[1], SImode, 4);
2274 if (GET_CODE (operands[1]) == MEM
2275 && GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
2276 output_asm_insn ("move%.l %4,%3", operands);
2277 output_asm_insn ("move%.l %1,%0\;smi %2", operands);
2278 if (TARGET_68020 || TARGET_COLDFIRE)
2279 output_asm_insn ("extb%.l %2", operands);
2281 output_asm_insn ("ext%.w %2\;ext%.l %2", operands);
2282 if (GET_CODE (operands[1]) != MEM
2283 || GET_CODE (XEXP (operands[1], 0)) != PRE_DEC)
2284 output_asm_insn ("move%.l %4,%3", operands);
2285 return "sub%.l %2,%3\;subx%.l %2,%0";
2288 (define_insn "adddi_sexthishl32"
2289 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2290 (plus:DI (ashift:DI (sign_extend:DI
2291 (match_operand:HI 1 "general_operand" "rm,rm,rm,rm"))
2293 (match_operand:DI 2 "general_operand" "0,0,0,0")))
2294 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2298 if (ADDRESS_REG_P (operands[0]))
2299 return "add%.w %1,%0";
2300 else if (ADDRESS_REG_P (operands[3]))
2301 return "move%.w %1,%3\;add%.l %3,%0";
2303 return "move%.w %1,%3\;ext%.l %3\;add%.l %3,%0";
2306 (define_insn "*adddi_dilshr32"
2307 [(set (match_operand:DI 0 "nonimmediate_operand" "=d,o")
2308 (plus:DI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro,d")
2310 (match_operand:DI 2 "general_operand" "0,0")))]
2314 if (GET_CODE (operands[0]) == REG)
2315 operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
2317 operands[2] = adjust_address (operands[0], SImode, 4);
2318 return "add%.l %1,%2\;negx%.l %0\;neg%.l %0";
2321 (define_insn "*adddi_dilshr32_cf"
2322 [(set (match_operand:DI 0 "register_operand" "=d")
2323 (plus:DI (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
2325 (match_operand:DI 2 "register_operand" "0")))]
2329 return "add%.l %1,%R0\;negx%.l %0\;neg%.l %0";
2332 (define_insn "adddi_dishl32"
2333 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,o")
2334 ;; (plus:DI (match_operand:DI 2 "general_operand" "%0")
2335 ;; (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2336 ;; (const_int 32))))]
2337 (plus:DI (ashift:DI (match_operand:DI 1 "general_operand" "ro,d")
2339 (match_operand:DI 2 "general_operand" "0,0")))]
2343 if (GET_CODE (operands[1]) == REG)
2344 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2346 operands[1] = adjust_address (operands[1], SImode, 4);
2347 return "add%.l %1,%0";
2349 [(set_attr "type" "alu_l")])
2351 (define_insn "adddi3"
2352 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2353 (plus:DI (match_operand:DI 1 "general_operand" "%0,0,0,0")
2354 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2355 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2358 if (DATA_REG_P (operands[0]))
2360 if (DATA_REG_P (operands[2]))
2361 return "add%.l %R2,%R0\;addx%.l %2,%0";
2362 else if (GET_CODE (operands[2]) == MEM
2363 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2364 return "move%.l %2,%3\;add%.l %2,%R0\;addx%.l %3,%0";
2370 if (GET_CODE (operands[2]) == REG)
2372 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2375 else if (CONSTANT_P (operands[2]))
2376 split_double (operands[2], &high, &low);
2379 low = adjust_address (operands[2], SImode, 4);
2383 operands[1] = low, operands[2] = high;
2384 xoperands[0] = operands[3];
2385 if (GET_CODE (operands[1]) == CONST_INT
2386 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2387 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2389 xoperands[1] = operands[2];
2391 output_asm_insn (output_move_simode (xoperands), xoperands);
2392 if (GET_CODE (operands[1]) == CONST_INT)
2394 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2395 return "addq%.l %1,%R0\;addx%.l %3,%0";
2396 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2398 operands[1] = GEN_INT (-INTVAL (operands[1]));
2399 return "subq%.l %1,%R0\;subx%.l %3,%0";
2402 return "add%.l %1,%R0\;addx%.l %3,%0";
2407 gcc_assert (GET_CODE (operands[0]) == MEM);
2409 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2411 operands[1] = gen_rtx_MEM (SImode,
2412 plus_constant (Pmode,
2413 XEXP(operands[0], 0), -8));
2414 return "move%.l %0,%3\;add%.l %R2,%0\;addx%.l %2,%3\;move%.l %3,%1";
2416 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2418 operands[1] = XEXP(operands[0], 0);
2419 return "add%.l %R2,%0\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%1";
2423 operands[1] = adjust_address (operands[0], SImode, 4);
2424 return "add%.l %R2,%1\;move%.l %0,%3\;addx%.l %2,%3\;move%.l %3,%0";
2429 (define_insn "addsi_lshrsi_31"
2430 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,dm,d<Q>")
2431 (plus:SI (lshiftrt:SI (match_operand:SI 1 "general_operand" "rm,r<Q>,rm")
2436 operands[2] = operands[0];
2437 operands[3] = gen_label_rtx();
2438 if (GET_CODE (operands[0]) == MEM)
2440 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2441 operands[0] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2442 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2443 operands[2] = gen_rtx_MEM (SImode, XEXP (XEXP (operands[0], 0), 0));
2445 output_asm_insn ("move%.l %1,%0", operands);
2446 output_asm_insn ("jpl %l3", operands);
2447 output_asm_insn ("addq%.l #1,%2", operands);
2448 (*targetm.asm_out.internal_label) (asm_out_file, "L",
2449 CODE_LABEL_NUMBER (operands[3]));
2452 [(set_attr "ok_for_coldfire" "no,yes,yes")])
2454 (define_expand "addsi3"
2455 [(set (match_operand:SI 0 "nonimmediate_operand" "")
2456 (plus:SI (match_operand:SI 1 "general_operand" "")
2457 (match_operand:SI 2 "general_src_operand" "")))]
2461 ;; Note that the middle two alternatives are near-duplicates
2462 ;; in order to handle insns generated by reload.
2463 ;; This is needed since they are not themselves reloaded,
2464 ;; so commutativity won't apply to them.
2465 (define_insn "*addsi3_internal"
2466 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,?a,?a,d,a")
2467 (plus:SI (match_operand:SI 1 "general_operand" "%0,a,rJK,0,0")
2468 (match_operand:SI 2 "general_src_operand" "dIKLT,rJK,a,mSrIKLT,mSrIKLs")))]
2472 "* return output_addsi3 (operands);")
2474 (define_insn_and_split "*addsi3_5200"
2475 [(set (match_operand:SI 0 "nonimmediate_operand" "=mr,mr,a, m,r, ?a, ?a,?a,?a")
2476 (plus:SI (match_operand:SI 1 "general_operand" "%0, 0, 0, 0,0, a, a, r, a")
2477 (match_operand:SI 2 "general_src_operand" " I, L, JCu,d,mrKi,Cj, r, a, JCu")))]
2480 switch (which_alternative)
2483 return "addq%.l %2,%0";
2486 operands[2] = GEN_INT (- INTVAL (operands[2]));
2487 return "subq%.l %2,%0";
2491 return "add%.l %2,%0";
2494 /* move%.l %2,%0\n\tadd%.l %1,%0 */
2498 return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0";
2501 return MOTOROLA ? "lea (%2,%1.l),%0" : "lea %2@(0,%1:l),%0";
2505 return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
2512 "&& reload_completed && (extract_constrain_insn_cached (insn), which_alternative == 5) && !operands_match_p (operands[0], operands[1])"
2516 (plus:SI (match_dup 0)
2519 [(set_attr "type" "aluq_l,aluq_l,lea, alu_l,alu_l,*,lea, lea, lea")
2520 (set_attr "opy" "2, 2, *, 2, 2, *,*, *, *")
2521 (set_attr "opy_type" "*, *, mem5,*, *, *,mem6,mem6,mem5")])
2524 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2525 (plus:SI (match_operand:SI 1 "general_operand" "0")
2527 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2531 (define_insn "addhi3"
2532 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2533 (plus:HI (match_operand:HI 1 "general_operand" "%0,0")
2534 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2537 if (GET_CODE (operands[2]) == CONST_INT)
2539 /* If the constant would be a negative number when interpreted as
2540 HImode, make it negative. This is usually, but not always, done
2541 elsewhere in the compiler. First check for constants out of range,
2542 which could confuse us. */
2544 if (INTVAL (operands[2]) >= 32768)
2545 operands[2] = GEN_INT (INTVAL (operands[2]) - 65536);
2547 if (INTVAL (operands[2]) > 0
2548 && INTVAL (operands[2]) <= 8)
2549 return "addq%.w %2,%0";
2550 if (INTVAL (operands[2]) < 0
2551 && INTVAL (operands[2]) >= -8)
2553 operands[2] = GEN_INT (- INTVAL (operands[2]));
2554 return "subq%.w %2,%0";
2556 /* On the CPU32 it is faster to use two addqw instructions to
2557 add a small integer (8 < N <= 16) to a register.
2558 Likewise for subqw. */
2559 if (TUNE_CPU32 && REG_P (operands[0]))
2561 if (INTVAL (operands[2]) > 8
2562 && INTVAL (operands[2]) <= 16)
2564 operands[2] = GEN_INT (INTVAL (operands[2]) - 8);
2565 return "addq%.w #8,%0\;addq%.w %2,%0";
2567 if (INTVAL (operands[2]) < -8
2568 && INTVAL (operands[2]) >= -16)
2570 operands[2] = GEN_INT (- INTVAL (operands[2]) - 8);
2571 return "subq%.w #8,%0\;subq%.w %2,%0";
2574 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2575 return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
2577 return "add%.w %2,%0";
2580 ;; These insns must use MATCH_DUP instead of the more expected
2581 ;; use of a matching constraint because the "output" here is also
2582 ;; an input, so you can't use the matching constraint. That also means
2583 ;; that you can't use the "%", so you need patterns with the matched
2584 ;; operand in both positions.
2587 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2588 (plus:HI (match_dup 0)
2589 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2592 if (GET_CODE (operands[1]) == CONST_INT)
2594 /* If the constant would be a negative number when interpreted as
2595 HImode, make it negative. This is usually, but not always, done
2596 elsewhere in the compiler. First check for constants out of range,
2597 which could confuse us. */
2599 if (INTVAL (operands[1]) >= 32768)
2600 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2602 if (INTVAL (operands[1]) > 0
2603 && INTVAL (operands[1]) <= 8)
2604 return "addq%.w %1,%0";
2605 if (INTVAL (operands[1]) < 0
2606 && INTVAL (operands[1]) >= -8)
2608 operands[1] = GEN_INT (- INTVAL (operands[1]));
2609 return "subq%.w %1,%0";
2611 /* On the CPU32 it is faster to use two addqw instructions to
2612 add a small integer (8 < N <= 16) to a register.
2613 Likewise for subqw. */
2614 if (TUNE_CPU32 && REG_P (operands[0]))
2616 if (INTVAL (operands[1]) > 8
2617 && INTVAL (operands[1]) <= 16)
2619 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2620 return "addq%.w #8,%0\;addq%.w %1,%0";
2622 if (INTVAL (operands[1]) < -8
2623 && INTVAL (operands[1]) >= -16)
2625 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2626 return "subq%.w #8,%0\;subq%.w %1,%0";
2629 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2630 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2632 return "add%.w %1,%0";
2636 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2637 (plus:HI (match_operand:HI 1 "general_src_operand" "dn,rmSn")
2641 if (GET_CODE (operands[1]) == CONST_INT)
2643 /* If the constant would be a negative number when interpreted as
2644 HImode, make it negative. This is usually, but not always, done
2645 elsewhere in the compiler. First check for constants out of range,
2646 which could confuse us. */
2648 if (INTVAL (operands[1]) >= 32768)
2649 operands[1] = GEN_INT (INTVAL (operands[1]) - 65536);
2651 if (INTVAL (operands[1]) > 0
2652 && INTVAL (operands[1]) <= 8)
2653 return "addq%.w %1,%0";
2654 if (INTVAL (operands[1]) < 0
2655 && INTVAL (operands[1]) >= -8)
2657 operands[1] = GEN_INT (- INTVAL (operands[1]));
2658 return "subq%.w %1,%0";
2660 /* On the CPU32 it is faster to use two addqw instructions to
2661 add a small integer (8 < N <= 16) to a register.
2662 Likewise for subqw. */
2663 if (TUNE_CPU32 && REG_P (operands[0]))
2665 if (INTVAL (operands[1]) > 8
2666 && INTVAL (operands[1]) <= 16)
2668 operands[1] = GEN_INT (INTVAL (operands[1]) - 8);
2669 return "addq%.w #8,%0\;addq%.w %1,%0";
2671 if (INTVAL (operands[1]) < -8
2672 && INTVAL (operands[1]) >= -16)
2674 operands[1] = GEN_INT (- INTVAL (operands[1]) - 8);
2675 return "subq%.w #8,%0\;subq%.w %1,%0";
2678 if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
2679 return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
2681 return "add%.w %1,%0";
2684 (define_insn "addqi3"
2685 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2686 (plus:QI (match_operand:QI 1 "general_operand" "%0,0")
2687 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2690 if (GET_CODE (operands[2]) == CONST_INT)
2692 if (INTVAL (operands[2]) >= 128)
2693 operands[2] = GEN_INT (INTVAL (operands[2]) - 256);
2695 if (INTVAL (operands[2]) > 0
2696 && INTVAL (operands[2]) <= 8)
2697 return "addq%.b %2,%0";
2698 if (INTVAL (operands[2]) < 0 && INTVAL (operands[2]) >= -8)
2700 operands[2] = GEN_INT (- INTVAL (operands[2]));
2701 return "subq%.b %2,%0";
2704 return "add%.b %2,%0";
2708 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2709 (plus:QI (match_dup 0)
2710 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2713 if (GET_CODE (operands[1]) == CONST_INT)
2715 if (INTVAL (operands[1]) >= 128)
2716 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2718 if (INTVAL (operands[1]) > 0
2719 && INTVAL (operands[1]) <= 8)
2720 return "addq%.b %1,%0";
2721 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2723 operands[1] = GEN_INT (- INTVAL (operands[1]));
2724 return "subq%.b %1,%0";
2727 return "add%.b %1,%0";
2731 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2732 (plus:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
2736 if (GET_CODE (operands[1]) == CONST_INT)
2738 if (INTVAL (operands[1]) >= 128)
2739 operands[1] = GEN_INT (INTVAL (operands[1]) - 256);
2741 if (INTVAL (operands[1]) > 0
2742 && INTVAL (operands[1]) <= 8)
2743 return "addq%.b %1,%0";
2744 if (INTVAL (operands[1]) < 0 && INTVAL (operands[1]) >= -8)
2746 operands[1] = GEN_INT (- INTVAL (operands[1]));
2747 return "subq%.b %1,%0";
2750 return "add%.b %1,%0";
2753 (define_expand "add<mode>3"
2754 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2755 (plus:FP (match_operand:FP 1 "general_operand" "")
2756 (match_operand:FP 2 "general_operand" "")))]
2760 (define_insn "add<mode>3_floatsi_68881"
2761 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2762 (plus:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
2763 (match_operand:FP 1 "general_operand" "0")))]
2765 "f<FP:round>add%.l %2,%0"
2766 [(set_attr "type" "falu")
2767 (set_attr "opy" "2")])
2769 (define_insn "add<mode>3_floathi_68881"
2770 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2771 (plus:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
2772 (match_operand:FP 1 "general_operand" "0")))]
2774 "f<FP:round>add%.w %2,%0"
2775 [(set_attr "type" "falu")
2776 (set_attr "opy" "2")])
2778 (define_insn "add<mode>3_floatqi_68881"
2779 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2780 (plus:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
2781 (match_operand:FP 1 "general_operand" "0")))]
2783 "f<FP:round>add%.b %2,%0"
2784 [(set_attr "type" "falu")
2785 (set_attr "opy" "2")])
2787 (define_insn "add<mode>3_68881"
2788 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2789 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2790 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
2793 if (FP_REG_P (operands[2]))
2794 return "f<FP:round>add%.x %2,%0";
2795 return "f<FP:round>add%.<FP:prec> %f2,%0";
2797 [(set_attr "type" "falu")
2798 (set_attr "opy" "2")])
2800 (define_insn "add<mode>3_cf"
2801 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2802 (plus:FP (match_operand:FP 1 "general_operand" "%0")
2803 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
2804 "TARGET_COLDFIRE_FPU"
2806 if (FP_REG_P (operands[2]))
2807 return "f<FP:prec>add%.d %2,%0";
2808 return "f<FP:prec>add%.<FP:prec> %2,%0";
2810 [(set_attr "type" "falu")
2811 (set_attr "opy" "2")])
2813 ;; subtract instructions
2815 (define_insn "subdi_sexthishl32"
2816 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,a,*d,*d")
2817 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2818 (ashift:DI (sign_extend:DI (match_operand:HI 2 "general_operand" "rm,rm,rm,rm"))
2820 (clobber (match_scratch:SI 3 "=&d,X,a,?d"))]
2824 if (ADDRESS_REG_P (operands[0]))
2825 return "sub%.w %2,%0";
2826 else if (ADDRESS_REG_P (operands[3]))
2827 return "move%.w %2,%3\;sub%.l %3,%0";
2829 return "move%.w %2,%3\;ext%.l %3\;sub%.l %3,%0";
2832 (define_insn "subdi_dishl32"
2833 [(set (match_operand:DI 0 "nonimmediate_operand" "+ro")
2834 (minus:DI (match_dup 0)
2835 (ashift:DI (match_operand:DI 1 "general_operand" "ro")
2840 if (GET_CODE (operands[1]) == REG)
2841 operands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
2843 operands[1] = adjust_address (operands[1], SImode, 4);
2844 return "sub%.l %1,%0";
2846 [(set_attr "type" "alu_l")])
2848 (define_insn "subdi3"
2849 [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,d,d,d")
2850 (minus:DI (match_operand:DI 1 "general_operand" "0,0,0,0")
2851 (match_operand:DI 2 "general_operand" "d,no>,d,a")))
2852 (clobber (match_scratch:SI 3 "=&d,&d,X,&d"))]
2855 if (DATA_REG_P (operands[0]))
2857 if (DATA_REG_P (operands[2]))
2858 return "sub%.l %R2,%R0\;subx%.l %2,%0";
2859 else if (GET_CODE (operands[2]) == MEM
2860 && GET_CODE (XEXP (operands[2], 0)) == POST_INC)
2862 return "move%.l %2,%3\;sub%.l %2,%R0\;subx%.l %3,%0";
2869 if (GET_CODE (operands[2]) == REG)
2871 low = gen_rtx_REG (SImode, REGNO (operands[2]) + 1);
2874 else if (CONSTANT_P (operands[2]))
2875 split_double (operands[2], &high, &low);
2878 low = adjust_address (operands[2], SImode, 4);
2882 operands[1] = low, operands[2] = high;
2883 xoperands[0] = operands[3];
2884 if (GET_CODE (operands[1]) == CONST_INT
2885 && INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2886 xoperands[1] = GEN_INT (-INTVAL (operands[2]) - 1);
2888 xoperands[1] = operands[2];
2890 output_asm_insn (output_move_simode (xoperands), xoperands);
2891 if (GET_CODE (operands[1]) == CONST_INT)
2893 if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) <= 8)
2894 return "subq%.l %1,%R0\;subx%.l %3,%0";
2895 else if (INTVAL (operands[1]) >= -8 && INTVAL (operands[1]) < 0)
2897 operands[1] = GEN_INT (-INTVAL (operands[1]));
2898 return "addq%.l %1,%R0\;addx%.l %3,%0";
2901 return "sub%.l %1,%R0\;subx%.l %3,%0";
2906 gcc_assert (GET_CODE (operands[0]) == MEM);
2908 if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
2911 = gen_rtx_MEM (SImode, plus_constant (Pmode,
2912 XEXP (operands[0], 0), -8));
2913 return "move%.l %0,%3\;sub%.l %R2,%0\;subx%.l %2,%3\;move%.l %3,%1";
2915 else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
2917 operands[1] = XEXP(operands[0], 0);
2918 return "sub%.l %R2,%0\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%1";
2922 operands[1] = adjust_address (operands[0], SImode, 4);
2923 return "sub%.l %R2,%1\;move%.l %0,%3\;subx%.l %2,%3\;move%.l %3,%0";
2928 (define_insn "subsi3"
2929 [(set (match_operand:SI 0 "nonimmediate_operand" "=mda,m,d,a")
2930 (minus:SI (match_operand:SI 1 "general_operand" "0,0,0,0")
2931 (match_operand:SI 2 "general_src_operand" "I,dT,mSrT,mSrs")))]
2938 [(set_attr "type" "aluq_l,alu_l,alu_l,alu_l")
2939 (set_attr "opy" "2")])
2942 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
2943 (minus:SI (match_operand:SI 1 "general_operand" "0")
2945 (match_operand:HI 2 "nonimmediate_src_operand" "rmS"))))]
2949 (define_insn "subhi3"
2950 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r")
2951 (minus:HI (match_operand:HI 1 "general_operand" "0,0")
2952 (match_operand:HI 2 "general_src_operand" "dn,rmSn")))]
2957 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
2958 (minus:HI (match_dup 0)
2959 (match_operand:HI 1 "general_src_operand" "dn,rmSn")))]
2963 (define_insn "subqi3"
2964 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
2965 (minus:QI (match_operand:QI 1 "general_operand" "0,0")
2966 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
2971 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
2972 (minus:QI (match_dup 0)
2973 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
2977 (define_expand "sub<mode>3"
2978 [(set (match_operand:FP 0 "nonimmediate_operand" "")
2979 (minus:FP (match_operand:FP 1 "general_operand" "")
2980 (match_operand:FP 2 "general_operand" "")))]
2984 (define_insn "sub<mode>3_floatsi_68881"
2985 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2986 (minus:FP (match_operand:FP 1 "general_operand" "0")
2987 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
2989 "f<FP:round>sub%.l %2,%0"
2990 [(set_attr "type" "falu")
2991 (set_attr "opy" "2")])
2993 (define_insn "sub<mode>3_floathi_68881"
2994 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
2995 (minus:FP (match_operand:FP 1 "general_operand" "0")
2996 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
2998 "f<FP:round>sub%.w %2,%0"
2999 [(set_attr "type" "falu")
3000 (set_attr "opy" "2")])
3002 (define_insn "sub<mode>3_floatqi_68881"
3003 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3004 (minus:FP (match_operand:FP 1 "general_operand" "0")
3005 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3007 "f<FP:round>sub%.b %2,%0"
3008 [(set_attr "type" "falu")
3009 (set_attr "opy" "2")])
3011 (define_insn "sub<mode>3_68881"
3012 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3013 (minus:FP (match_operand:FP 1 "general_operand" "0")
3014 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3017 if (FP_REG_P (operands[2]))
3018 return "f<FP:round>sub%.x %2,%0";
3019 return "f<FP:round>sub%.<FP:prec> %f2,%0";
3021 [(set_attr "type" "falu")
3022 (set_attr "opy" "2")])
3024 (define_insn "sub<mode>3_cf"
3025 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3026 (minus:FP (match_operand:FP 1 "general_operand" "0")
3027 (match_operand:FP 2 "general_operand" "f<FP:dreg><Q>U")))]
3028 "TARGET_COLDFIRE_FPU"
3030 if (FP_REG_P (operands[2]))
3031 return "f<FP:prec>sub%.d %2,%0";
3032 return "f<FP:prec>sub%.<FP:prec> %2,%0";
3034 [(set_attr "type" "falu")
3035 (set_attr "opy" "2")])
3037 ;; multiply instructions
3039 (define_insn "mulhi3"
3040 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3041 (mult:HI (match_operand:HI 1 "general_operand" "%0")
3042 (match_operand:HI 2 "general_src_operand" "dmSn")))]
3045 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3047 [(set_attr "type" "mul_w")
3048 (set_attr "opy" "2")])
3050 (define_insn "mulhisi3"
3051 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3052 (mult:SI (sign_extend:SI
3053 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3055 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3058 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3060 [(set_attr "type" "mul_w")
3061 (set_attr "opy" "2")])
3063 (define_insn "*mulhisisi3_s"
3064 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3065 (mult:SI (sign_extend:SI
3066 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3067 (match_operand:SI 2 "const_int_operand" "n")))]
3068 "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
3070 return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
3072 [(set_attr "type" "mul_w")
3073 (set_attr "opy" "2")])
3075 (define_expand "mulsi3"
3076 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3077 (mult:SI (match_operand:SI 1 "general_operand" "")
3078 (match_operand:SI 2 "general_operand" "")))]
3079 "TARGET_68020 || TARGET_COLDFIRE"
3082 (define_insn "*mulsi3_68020"
3083 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3084 (mult:SI (match_operand:SI 1 "general_operand" "%0")
3085 (match_operand:SI 2 "general_src_operand" "dmSTK")))]
3089 [(set_attr "type" "mul_l")
3090 (set_attr "opy" "2")])
3092 (define_insn "*mulsi3_cf"
3093 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3094 (mult:SI (match_operand:SI 1 "general_operand" "%0")
3095 (match_operand:SI 2 "general_operand" "d<Q>")))]
3098 [(set_attr "type" "mul_l")
3099 (set_attr "opy" "2")])
3101 (define_insn "umulhisi3"
3102 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3103 (mult:SI (zero_extend:SI
3104 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3106 (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
3109 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3111 [(set_attr "type" "mul_w")
3112 (set_attr "opy" "2")])
3114 (define_insn "*mulhisisi3_z"
3115 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3116 (mult:SI (zero_extend:SI
3117 (match_operand:HI 1 "nonimmediate_operand" "%0"))
3118 (match_operand:SI 2 "const_int_operand" "n")))]
3119 "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
3121 return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
3123 [(set_attr "type" "mul_w")
3124 (set_attr "opy" "2")])
3126 ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the
3127 ;; proper matching constraint. This is because the matching is between
3128 ;; the high-numbered word of the DImode operand[0] and operand[1].
3129 (define_expand "umulsidi3"
3131 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3132 (mult:SI (match_operand:SI 1 "register_operand" "")
3133 (match_operand:SI 2 "register_operand" "")))
3134 (set (subreg:SI (match_dup 0) 0)
3135 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3136 (zero_extend:DI (match_dup 2)))
3137 (const_int 32))))])]
3138 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3142 [(set (match_operand:SI 0 "register_operand" "=d")
3143 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3144 (match_operand:SI 2 "nonimmediate_operand" "dm")))
3145 (set (match_operand:SI 3 "register_operand" "=d")
3146 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3147 (zero_extend:DI (match_dup 2)))
3149 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3152 ; Match immediate case. For 2.4 only match things < 2^31.
3153 ; It's tricky with larger values in these patterns since we need to match
3154 ; values between the two parallel multiplies, between a CONST_DOUBLE and
3157 [(set (match_operand:SI 0 "register_operand" "=d")
3158 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3159 (match_operand:SI 2 "const_int_operand" "n")))
3160 (set (match_operand:SI 3 "register_operand" "=d")
3161 (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
3164 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE
3165 && (unsigned) INTVAL (operands[2]) <= 0x7fffffff"
3168 (define_expand "mulsidi3"
3170 [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4)
3171 (mult:SI (match_operand:SI 1 "register_operand" "")
3172 (match_operand:SI 2 "register_operand" "")))
3173 (set (subreg:SI (match_dup 0) 0)
3174 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3175 (sign_extend:DI (match_dup 2)))
3176 (const_int 32))))])]
3177 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3181 [(set (match_operand:SI 0 "register_operand" "=d")
3182 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3183 (match_operand:SI 2 "nonimmediate_operand" "dm")))
3184 (set (match_operand:SI 3 "register_operand" "=d")
3185 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3186 (sign_extend:DI (match_dup 2)))
3188 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3192 [(set (match_operand:SI 0 "register_operand" "=d")
3193 (mult:SI (match_operand:SI 1 "register_operand" "%0")
3194 (match_operand:SI 2 "const_int_operand" "n")))
3195 (set (match_operand:SI 3 "register_operand" "=d")
3196 (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
3199 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3202 (define_expand "umulsi3_highpart"
3204 [(set (match_operand:SI 0 "register_operand" "")
3207 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" ""))
3208 (zero_extend:DI (match_operand:SI 2 "general_operand" "")))
3210 (clobber (match_dup 3))])]
3211 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3213 operands[3] = gen_reg_rtx (SImode);
3215 if (GET_CODE (operands[2]) == CONST_INT)
3217 operands[2] = immed_double_const (INTVAL (operands[2]) & 0xffffffff,
3220 /* We have to adjust the operand order for the matching constraints. */
3221 emit_insn (gen_const_umulsi3_highpart (operands[0], operands[3],
3222 operands[1], operands[2]));
3228 [(set (match_operand:SI 0 "register_operand" "=d")
3231 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3232 (zero_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3234 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3235 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3238 (define_insn "const_umulsi3_highpart"
3239 [(set (match_operand:SI 0 "register_operand" "=d")
3242 (mult:DI (zero_extend:DI (match_operand:SI 2 "register_operand" "1"))
3243 (match_operand:DI 3 "const_uint32_operand" "n"))
3245 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3246 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3249 (define_expand "smulsi3_highpart"
3251 [(set (match_operand:SI 0 "register_operand" "")
3254 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" ""))
3255 (sign_extend:DI (match_operand:SI 2 "general_operand" "")))
3257 (clobber (match_dup 3))])]
3258 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3260 operands[3] = gen_reg_rtx (SImode);
3261 if (GET_CODE (operands[2]) == CONST_INT)
3263 /* We have to adjust the operand order for the matching constraints. */
3264 emit_insn (gen_const_smulsi3_highpart (operands[0], operands[3],
3265 operands[1], operands[2]));
3271 [(set (match_operand:SI 0 "register_operand" "=d")
3274 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "%1"))
3275 (sign_extend:DI (match_operand:SI 3 "nonimmediate_operand" "dm")))
3277 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3278 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3281 (define_insn "const_smulsi3_highpart"
3282 [(set (match_operand:SI 0 "register_operand" "=d")
3285 (mult:DI (sign_extend:DI (match_operand:SI 2 "register_operand" "1"))
3286 (match_operand:DI 3 "const_sint32_operand" "n"))
3288 (clobber (match_operand:SI 1 "register_operand" "=d"))]
3289 "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE"
3292 (define_expand "mul<mode>3"
3293 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3294 (mult:FP (match_operand:FP 1 "general_operand" "")
3295 (match_operand:FP 2 "general_operand" "")))]
3299 (define_insn "mul<mode>3_floatsi_68881"
3300 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3301 (mult:FP (float:FP (match_operand:SI 2 "general_operand" "dmi"))
3302 (match_operand:FP 1 "general_operand" "0")))]
3306 ? "f<FP:round>mul%.l %2,%0"
3307 : "f<FP:round_mul>mul%.l %2,%0";
3309 [(set_attr "type" "fmul")
3310 (set_attr "opy" "2")])
3312 (define_insn "mul<mode>3_floathi_68881"
3313 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3314 (mult:FP (float:FP (match_operand:HI 2 "general_operand" "dmn"))
3315 (match_operand:FP 1 "general_operand" "0")))]
3319 ? "f<FP:round>mul%.w %2,%0"
3320 : "f<FP:round_mul>mul%.w %2,%0";
3322 [(set_attr "type" "fmul")
3323 (set_attr "opy" "2")])
3325 (define_insn "mul<mode>3_floatqi_68881"
3326 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3327 (mult:FP (float:FP (match_operand:QI 2 "general_operand" "dmn"))
3328 (match_operand:FP 1 "general_operand" "0")))]
3332 ? "f<FP:round>mul%.b %2,%0"
3333 : "f<FP:round_mul>mul%.b %2,%0";
3335 [(set_attr "type" "fmul")
3336 (set_attr "opy" "2")])
3338 (define_insn "muldf_68881"
3339 [(set (match_operand:DF 0 "nonimmediate_operand" "=f")
3340 (mult:DF (match_operand:DF 1 "general_operand" "%0")
3341 (match_operand:DF 2 "general_operand" "fmG")))]
3344 if (GET_CODE (operands[2]) == CONST_DOUBLE
3345 && floating_exact_log2 (operands[2]) && !TUNE_68040_60)
3347 int i = floating_exact_log2 (operands[2]);
3348 operands[2] = GEN_INT (i);
3349 return "fscale%.l %2,%0";
3351 if (REG_P (operands[2]))
3352 return "f%&mul%.x %2,%0";
3353 return "f%&mul%.d %f2,%0";
3356 (define_insn "mulsf_68881"
3357 [(set (match_operand:SF 0 "nonimmediate_operand" "=f")
3358 (mult:SF (match_operand:SF 1 "general_operand" "%0")
3359 (match_operand:SF 2 "general_operand" "fdmF")))]
3362 if (FP_REG_P (operands[2]))
3363 return (TARGET_68040
3365 : "fsglmul%.x %2,%0");
3366 return (TARGET_68040
3368 : "fsglmul%.s %f2,%0");
3371 (define_insn "mulxf3_68881"
3372 [(set (match_operand:XF 0 "nonimmediate_operand" "=f")
3373 (mult:XF (match_operand:XF 1 "nonimmediate_operand" "%0")
3374 (match_operand:XF 2 "nonimmediate_operand" "fm")))]
3377 return "fmul%.x %f2,%0";
3380 (define_insn "fmul<mode>3_cf"
3381 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3382 (mult:FP (match_operand:FP 1 "general_operand" "%0")
3383 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3384 "TARGET_COLDFIRE_FPU"
3386 if (FP_REG_P (operands[2]))
3387 return "f<FP:prec>mul%.d %2,%0";
3388 return "f<FP:prec>mul%.<FP:prec> %2,%0";
3390 [(set_attr "type" "fmul")
3391 (set_attr "opy" "2")])
3393 ;; divide instructions
3395 (define_expand "div<mode>3"
3396 [(set (match_operand:FP 0 "nonimmediate_operand" "")
3397 (div:FP (match_operand:FP 1 "general_operand" "")
3398 (match_operand:FP 2 "general_operand" "")))]
3402 (define_insn "div<mode>3_floatsi_68881"
3403 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3404 (div:FP (match_operand:FP 1 "general_operand" "0")
3405 (float:FP (match_operand:SI 2 "general_operand" "dmi"))))]
3409 ? "f<FP:round>div%.l %2,%0"
3410 : "f<FP:round_mul>div%.l %2,%0";
3413 (define_insn "div<mode>3_floathi_68881"
3414 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3415 (div:FP (match_operand:FP 1 "general_operand" "0")
3416 (float:FP (match_operand:HI 2 "general_operand" "dmn"))))]
3420 ? "f<FP:round>div%.w %2,%0"
3421 : "f<FP:round_mul>div%.w %2,%0";
3424 (define_insn "div<mode>3_floatqi_68881"
3425 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3426 (div:FP (match_operand:FP 1 "general_operand" "0")
3427 (float:FP (match_operand:QI 2 "general_operand" "dmn"))))]
3431 ? "f<FP:round>div%.b %2,%0"
3432 : "f<FP:round_mul>div%.b %2,%0";
3435 (define_insn "div<mode>3_68881"
3436 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3437 (div:FP (match_operand:FP 1 "general_operand" "0")
3438 (match_operand:FP 2 "general_operand" "f<FP:dreg>m<FP:const>")))]
3441 if (FP_REG_P (operands[2]))
3442 return (TARGET_68040
3443 ? "f<FP:round>div%.x %2,%0"
3444 : "f<FP:round_mul>div%.x %2,%0");
3445 return (TARGET_68040
3446 ? "f<FP:round>div%.<FP:prec> %f2,%0"
3447 : "f<FP:round_mul>div%.<FP:prec> %f2,%0");
3450 (define_insn "div<mode>3_cf"
3451 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
3452 (div:FP (match_operand:FP 1 "general_operand" "0")
3453 (match_operand:FP 2 "general_operand" "f<Q>U<FP:dreg>")))]
3454 "TARGET_COLDFIRE_FPU"
3456 if (FP_REG_P (operands[2]))
3457 return "f<FP:prec>div%.d %2,%0";
3458 return "f<FP:prec>div%.<FP:prec> %2,%0";
3460 [(set_attr "type" "fdiv")
3461 (set_attr "opy" "2")])
3463 ;; Remainder instructions.
3465 (define_expand "divmodsi4"
3467 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3468 (div:SI (match_operand:SI 1 "general_operand" "")
3469 (match_operand:SI 2 "general_src_operand" "")))
3470 (set (match_operand:SI 3 "nonimmediate_operand" "")
3471 (mod:SI (match_dup 1) (match_dup 2)))])]
3472 "TARGET_68020 || TARGET_CF_HWDIV"
3476 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3477 (div:SI (match_operand:SI 1 "general_operand" "0")
3478 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3479 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3480 (mod:SI (match_dup 1) (match_dup 2)))]
3483 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3484 return "divs%.l %2,%0";
3485 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3486 return "rems%.l %2,%3:%0";
3488 return "rems%.l %2,%3:%0\;divs%.l %2,%0";
3490 [(set_attr "type" "div_l")
3491 (set_attr "opy" "2")])
3494 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3495 (div:SI (match_operand:SI 1 "general_operand" "0")
3496 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3497 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3498 (mod:SI (match_dup 1) (match_dup 2)))]
3501 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3502 return "divs%.l %2,%0";
3504 return "divsl%.l %2,%3:%0";
3507 (define_expand "udivmodsi4"
3509 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3510 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3511 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3512 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3513 (umod:SI (match_dup 1) (match_dup 2)))])]
3514 "TARGET_68020 || TARGET_CF_HWDIV"
3518 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3519 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3520 (match_operand:SI 2 "general_src_operand" "d<Q>U")))
3521 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
3522 (umod:SI (match_dup 1) (match_dup 2)))]
3525 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3526 return "divu%.l %2,%0";
3527 else if (find_reg_note (insn, REG_UNUSED, operands[0]))
3528 return "remu%.l %2,%3:%0";
3530 return "remu%.l %2,%3:%0\;divu%.l %2,%0";
3532 [(set_attr "type" "div_l")
3533 (set_attr "opy" "2")])
3536 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3537 (udiv:SI (match_operand:SI 1 "general_operand" "0")
3538 (match_operand:SI 2 "general_src_operand" "dmSTK")))
3539 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
3540 (umod:SI (match_dup 1) (match_dup 2)))]
3541 "TARGET_68020 && !TARGET_COLDFIRE"
3543 if (find_reg_note (insn, REG_UNUSED, operands[3]))
3544 return "divu%.l %2,%0";
3546 return "divul%.l %2,%3:%0";
3549 (define_insn "divmodhi4"
3550 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3551 (div:HI (match_operand:HI 1 "general_operand" "0")
3552 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3553 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3554 (mod:HI (match_dup 1) (match_dup 2)))]
3555 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3557 output_asm_insn (MOTOROLA ?
3558 "ext%.l %0\;divs%.w %2,%0" :
3559 "extl %0\;divs %2,%0",
3561 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3564 return "move%.l %0,%3\;swap %3";
3570 (define_insn "udivmodhi4"
3571 [(set (match_operand:HI 0 "nonimmediate_operand" "=d")
3572 (udiv:HI (match_operand:HI 1 "general_operand" "0")
3573 (match_operand:HI 2 "general_src_operand" "dmSKT")))
3574 (set (match_operand:HI 3 "nonimmediate_operand" "=d")
3575 (umod:HI (match_dup 1) (match_dup 2)))]
3576 "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
3578 if (ISA_HAS_MVS_MVZ)
3579 output_asm_insn (MOTOROLA ?
3580 "mvz%.w %0,%0\;divu%.w %2,%0" :
3581 "mvz%.w %0,%0\;divu %2,%0",
3584 output_asm_insn (MOTOROLA ?
3585 "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
3586 "and%.l #0xFFFF,%0\;divu %2,%0",
3589 if (!find_reg_note(insn, REG_UNUSED, operands[3]))
3592 return "move%.l %0,%3\;swap %3";
3598 ;; logical-and instructions
3600 ;; Prevent AND from being made with sp. This doesn't exist in the machine
3601 ;; and reload will cause inefficient code. Since sp is a FIXED_REG, we
3602 ;; can't allocate pseudos into it.
3604 (define_expand "andsi3"
3605 [(set (match_operand:SI 0 "not_sp_operand" "")
3606 (and:SI (match_operand:SI 1 "general_operand" "")
3607 (match_operand:SI 2 "general_src_operand" "")))]
3611 ;; produced by split operations after reload finished
3612 (define_insn "*andsi3_split"
3613 [(set (match_operand:SI 0 "register_operand" "=d")
3614 (and:SI (match_operand:SI 1 "register_operand" "0")
3615 (match_operand:SI 2 "const_int_operand" "i")))]
3616 "reload_completed && !TARGET_COLDFIRE"
3618 return output_andsi3 (operands);
3621 (define_insn "andsi3_internal"
3622 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3623 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3624 (match_operand:SI 2 "general_src_operand" "dKT,dmSM")))]
3627 return output_andsi3 (operands);
3630 (define_insn "andsi3_5200"
3631 [(set (match_operand:SI 0 "not_sp_operand" "=m,d")
3632 (and:SI (match_operand:SI 1 "general_operand" "%0,0")
3633 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3637 && DATA_REG_P (operands[0])
3638 && GET_CODE (operands[2]) == CONST_INT)
3640 if (INTVAL (operands[2]) == 0x000000ff)
3641 return "mvz%.b %0,%0";
3642 else if (INTVAL (operands[2]) == 0x0000ffff)
3643 return "mvz%.w %0,%0";
3645 return output_andsi3 (operands);
3648 (define_insn "andhi3"
3649 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3650 (and:HI (match_operand:HI 1 "general_operand" "%0,0")
3651 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3656 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3657 (and:HI (match_dup 0)
3658 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3663 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3664 (and:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3669 (define_insn "andqi3"
3670 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3671 (and:QI (match_operand:QI 1 "general_operand" "%0,0")
3672 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3677 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3678 (and:QI (match_dup 0)
3679 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3684 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3685 (and:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3690 ;; inclusive-or instructions
3692 (define_insn "iordi_zext"
3693 [(set (match_operand:DI 0 "nonimmediate_operand" "=o,d")
3694 (ior:DI (zero_extend:DI (match_operand 1 "general_operand" "dn,dmn"))
3695 (match_operand:DI 2 "general_operand" "0,0")))]
3701 if (GET_CODE (operands[0]) == REG)
3702 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3704 operands[0] = adjust_address (operands[0], SImode, 4);
3705 if (GET_MODE (operands[1]) == SImode)
3706 return "or%.l %1,%0";
3707 byte_mode = (GET_MODE (operands[1]) == QImode);
3708 if (GET_CODE (operands[0]) == MEM)
3709 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3712 return "or%.b %1,%0";
3714 return "or%.w %1,%0";
3717 (define_expand "iorsi3"
3718 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3719 (ior:SI (match_operand:SI 1 "general_operand" "")
3720 (match_operand:SI 2 "general_src_operand" "")))]
3724 (define_insn "iorsi3_internal"
3725 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3726 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3727 (match_operand:SI 2 "general_src_operand" "dKT,dmSMT")))]
3730 return output_iorsi3 (operands);
3733 (define_insn "iorsi3_5200"
3734 [(set (match_operand:SI 0 "nonimmediate_operand" "=m,d")
3735 (ior:SI (match_operand:SI 1 "general_operand" "%0,0")
3736 (match_operand:SI 2 "general_src_operand" "d,dmsK")))]
3739 return output_iorsi3 (operands);
3742 (define_insn "iorhi3"
3743 [(set (match_operand:HI 0 "nonimmediate_operand" "=m,d")
3744 (ior:HI (match_operand:HI 1 "general_operand" "%0,0")
3745 (match_operand:HI 2 "general_src_operand" "dn,dmSn")))]
3750 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3751 (ior:HI (match_dup 0)
3752 (match_operand:HI 1 "general_src_operand" "dn,dmSn")))]
3757 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+m,d"))
3758 (ior:HI (match_operand:HI 1 "general_src_operand" "dn,dmSn")
3763 (define_insn "iorqi3"
3764 [(set (match_operand:QI 0 "nonimmediate_operand" "=m,d")
3765 (ior:QI (match_operand:QI 1 "general_operand" "%0,0")
3766 (match_operand:QI 2 "general_src_operand" "dn,dmSn")))]
3771 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3772 (ior:QI (match_dup 0)
3773 (match_operand:QI 1 "general_src_operand" "dn,dmSn")))]
3778 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+m,d"))
3779 (ior:QI (match_operand:QI 1 "general_src_operand" "dn,dmSn")
3784 ;; On all 68k models, this makes faster code in a special case.
3785 ;; See also ashlsi_16, ashrsi_16 and lshrsi_16.
3787 (define_insn "iorsi_zexthi_ashl16"
3788 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
3789 (ior:SI (zero_extend:SI (match_operand:HI 1 "general_operand" "rmn"))
3790 (ashift:SI (match_operand:SI 2 "general_operand" "or")
3795 if (GET_CODE (operands[2]) != REG)
3796 operands[2] = adjust_address (operands[2], HImode, 2);
3797 if (GET_CODE (operands[2]) != REG
3798 || REGNO (operands[2]) != REGNO (operands[0]))
3799 output_asm_insn ("move%.w %2,%0", operands);
3800 return "swap %0\;mov%.w %1,%0";
3803 (define_insn "iorsi_zext"
3804 [(set (match_operand:SI 0 "nonimmediate_operand" "=o,d")
3805 (ior:SI (zero_extend:SI (match_operand 1 "general_operand" "dn,dmn"))
3806 (match_operand:SI 2 "general_operand" "0,0")))]
3812 byte_mode = (GET_MODE (operands[1]) == QImode);
3813 if (GET_CODE (operands[0]) == MEM)
3814 operands[0] = adjust_address (operands[0], byte_mode ? QImode : HImode,
3817 return "or%.b %1,%0";
3819 return "or%.w %1,%0";
3824 (define_expand "xorsi3"
3825 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3826 (xor:SI (match_operand:SI 1 "general_operand" "")
3827 (match_operand:SI 2 "general_operand" "")))]
3831 (define_insn "xorsi3_internal"
3832 [(set (match_operand:SI 0 "nonimmediate_operand" "=do,m")
3833 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3834 (match_operand:SI 2 "general_operand" "di,dKT")))]
3838 return output_xorsi3 (operands);
3841 (define_insn "xorsi3_5200"
3842 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm,d")
3843 (xor:SI (match_operand:SI 1 "general_operand" "%0,0")
3844 (match_operand:SI 2 "general_operand" "d,Ks")))]
3847 return output_xorsi3 (operands);
3850 (define_insn "xorhi3"
3851 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3852 (xor:HI (match_operand:HI 1 "general_operand" "%0")
3853 (match_operand:HI 2 "general_operand" "dn")))]
3858 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3859 (xor:HI (match_dup 0)
3860 (match_operand:HI 1 "general_operand" "dn")))]
3865 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3866 (xor:HI (match_operand:HI 1 "general_operand" "dn")
3871 (define_insn "xorqi3"
3872 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3873 (xor:QI (match_operand:QI 1 "general_operand" "%0")
3874 (match_operand:QI 2 "general_operand" "dn")))]
3879 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3880 (xor:QI (match_dup 0)
3881 (match_operand:QI 1 "general_operand" "dn")))]
3886 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3887 (xor:QI (match_operand:QI 1 "general_operand" "dn")
3892 ;; negation instructions
3894 (define_expand "negdi2"
3895 [(set (match_operand:DI 0 "nonimmediate_operand" "")
3896 (neg:DI (match_operand:DI 1 "general_operand" "")))]
3899 if (TARGET_COLDFIRE)
3900 emit_insn (gen_negdi2_5200 (operands[0], operands[1]));
3902 emit_insn (gen_negdi2_internal (operands[0], operands[1]));
3906 (define_insn "negdi2_internal"
3907 [(set (match_operand:DI 0 "nonimmediate_operand" "=<,do,!*a")
3908 (neg:DI (match_operand:DI 1 "general_operand" "0,0,0")))]
3911 if (which_alternative == 0)
3912 return "neg%.l %0\;negx%.l %0";
3913 if (GET_CODE (operands[0]) == REG)
3914 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3916 operands[1] = adjust_address (operands[0], SImode, 4);
3917 if (ADDRESS_REG_P (operands[0]))
3918 return "exg %/d0,%1\;neg%.l %/d0\;exg %/d0,%1\;exg %/d0,%0\;negx%.l %/d0\;exg %/d0,%0";
3920 return "neg%.l %1\;negx%.l %0";
3923 (define_insn "negdi2_5200"
3924 [(set (match_operand:DI 0 "nonimmediate_operand" "=d")
3925 (neg:DI (match_operand:DI 1 "general_operand" "0")))]
3928 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
3929 return "neg%.l %1\;negx%.l %0";
3932 (define_expand "negsi2"
3933 [(set (match_operand:SI 0 "nonimmediate_operand" "")
3934 (neg:SI (match_operand:SI 1 "general_operand" "")))]
3937 if (TARGET_COLDFIRE)
3938 emit_insn (gen_negsi2_5200 (operands[0], operands[1]));
3940 emit_insn (gen_negsi2_internal (operands[0], operands[1]));
3944 (define_insn "negsi2_internal"
3945 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
3946 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3949 [(set_attr "type" "neg_l")])
3951 (define_insn "negsi2_5200"
3952 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
3953 (neg:SI (match_operand:SI 1 "general_operand" "0")))]
3956 [(set_attr "type" "neg_l")])
3958 (define_insn "neghi2"
3959 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
3960 (neg:HI (match_operand:HI 1 "general_operand" "0")))]
3965 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
3966 (neg:HI (match_dup 0)))]
3970 (define_insn "negqi2"
3971 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
3972 (neg:QI (match_operand:QI 1 "general_operand" "0")))]
3977 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
3978 (neg:QI (match_dup 0)))]
3982 ;; If using software floating point, just flip the sign bit.
3984 (define_expand "negsf2"
3985 [(set (match_operand:SF 0 "nonimmediate_operand" "")
3986 (neg:SF (match_operand:SF 1 "general_operand" "")))]
3989 if (!TARGET_HARD_FLOAT)
3994 target = operand_subword_force (operands[0], 0, SFmode);
3995 result = expand_binop (SImode, xor_optab,
3996 operand_subword_force (operands[1], 0, SFmode),
3997 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
3998 gcc_assert (result);
4000 if (result != target)
4001 emit_move_insn (result, target);
4003 /* Make a place for REG_EQUAL. */
4004 emit_move_insn (operands[0], operands[0]);
4009 (define_expand "negdf2"
4010 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4011 (neg:DF (match_operand:DF 1 "general_operand" "")))]
4014 if (!TARGET_HARD_FLOAT)
4021 target = operand_subword (operands[0], 0, 1, DFmode);
4022 result = expand_binop (SImode, xor_optab,
4023 operand_subword_force (operands[1], 0, DFmode),
4024 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4025 gcc_assert (result);
4027 if (result != target)
4028 emit_move_insn (result, target);
4030 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4031 operand_subword_force (operands[1], 1, DFmode));
4033 insns = get_insns ();
4041 (define_expand "negxf2"
4042 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4043 (neg:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4053 target = operand_subword (operands[0], 0, 1, XFmode);
4054 result = expand_binop (SImode, xor_optab,
4055 operand_subword_force (operands[1], 0, XFmode),
4056 GEN_INT (-2147483647 - 1), target, 0, OPTAB_WIDEN);
4057 gcc_assert (result);
4059 if (result != target)
4060 emit_move_insn (result, target);
4062 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4063 operand_subword_force (operands[1], 1, XFmode));
4064 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4065 operand_subword_force (operands[1], 2, XFmode));
4067 insns = get_insns ();
4075 (define_insn "neg<mode>2_68881"
4076 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4077 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4080 if (DATA_REG_P (operands[0]))
4082 operands[1] = GEN_INT (31);
4083 return "bchg %1,%0";
4085 if (FP_REG_P (operands[1]))
4086 return "f<FP:round>neg%.x %1,%0";
4087 return "f<FP:round>neg%.<FP:prec> %f1,%0";
4090 (define_insn "neg<mode>2_cf"
4091 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4092 (neg:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4093 "TARGET_COLDFIRE_FPU"
4095 if (DATA_REG_P (operands[0]))
4097 operands[1] = GEN_INT (31);
4098 return "bchg %1,%0";
4100 if (FP_REG_P (operands[1]))
4101 return "f<FP:prec>neg%.d %1,%0";
4102 return "f<FP:prec>neg%.<FP:prec> %1,%0";
4105 ;; Sqrt instruction for the 68881
4107 (define_expand "sqrt<mode>2"
4108 [(set (match_operand:FP 0 "nonimmediate_operand" "")
4109 (sqrt:FP (match_operand:FP 1 "general_operand" "")))]
4113 (define_insn "sqrt<mode>2_68881"
4114 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4115 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m")))]
4118 if (FP_REG_P (operands[1]))
4119 return "f<FP:round>sqrt%.x %1,%0";
4120 return "f<FP:round>sqrt%.<FP:prec> %1,%0";
4122 [(set_attr "type" "fsqrt")])
4124 (define_insn "sqrt<mode>2_cf"
4125 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
4126 (sqrt:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U")))]
4127 "TARGET_COLDFIRE_FPU"
4129 if (FP_REG_P (operands[1]))
4130 return "f<FP:prec>sqrt%.d %1,%0";
4131 return "f<FP:prec>sqrt%.<FP:prec> %1,%0";
4133 [(set_attr "type" "fsqrt")])
4134 ;; Absolute value instructions
4135 ;; If using software floating point, just zero the sign bit.
4137 (define_expand "abssf2"
4138 [(set (match_operand:SF 0 "nonimmediate_operand" "")
4139 (abs:SF (match_operand:SF 1 "general_operand" "")))]
4142 if (!TARGET_HARD_FLOAT)
4147 target = operand_subword_force (operands[0], 0, SFmode);
4148 result = expand_binop (SImode, and_optab,
4149 operand_subword_force (operands[1], 0, SFmode),
4150 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4151 gcc_assert (result);
4153 if (result != target)
4154 emit_move_insn (result, target);
4156 /* Make a place for REG_EQUAL. */
4157 emit_move_insn (operands[0], operands[0]);
4162 (define_expand "absdf2"
4163 [(set (match_operand:DF 0 "nonimmediate_operand" "")
4164 (abs:DF (match_operand:DF 1 "general_operand" "")))]
4167 if (!TARGET_HARD_FLOAT)
4174 target = operand_subword (operands[0], 0, 1, DFmode);
4175 result = expand_binop (SImode, and_optab,
4176 operand_subword_force (operands[1], 0, DFmode),
4177 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4178 gcc_assert (result);
4180 if (result != target)
4181 emit_move_insn (result, target);
4183 emit_move_insn (operand_subword (operands[0], 1, 1, DFmode),
4184 operand_subword_force (operands[1], 1, DFmode));
4186 insns = get_insns ();
4194 (define_expand "absxf2"
4195 [(set (match_operand:XF 0 "nonimmediate_operand" "")
4196 (abs:XF (match_operand:XF 1 "nonimmediate_operand" "")))]
4206 target = operand_subword (operands[0], 0, 1, XFmode);
4207 result = expand_binop (SImode, and_optab,
4208 operand_subword_force (operands[1], 0, XFmode),
4209 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
4210 gcc_assert (result);
4212 if (result != target)
4213 emit_move_insn (result, target);
4215 emit_move_insn (operand_subword (operands[0], 1, 1, XFmode),
4216 operand_subword_force (operands[1], 1, XFmode));
4217 emit_move_insn (operand_subword (operands[0], 2, 1, XFmode),
4218 operand_subword_force (operands[1], 2, XFmode));
4220 insns = get_insns ();
4228 (define_insn "abs<mode>2_68881"
4229 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4230 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg>m<FP:const>,0")))]
4233 if (DATA_REG_P (operands[0]))
4235 operands[1] = GEN_INT (31);
4236 return "bclr %1,%0";
4238 if (FP_REG_P (operands[1]))
4239 return "f<FP:round>abs%.x %1,%0";
4240 return "f<FP:round>abs%.<FP:prec> %f1,%0";
4243 (define_insn "abs<mode>2_cf"
4244 [(set (match_operand:FP 0 "nonimmediate_operand" "=f,d")
4245 (abs:FP (match_operand:FP 1 "general_operand" "f<FP:dreg><Q>U,0")))]
4246 "TARGET_COLDFIRE_FPU"
4248 if (DATA_REG_P (operands[0]))
4250 operands[1] = GEN_INT (31);
4251 return "bclr %1,%0";
4253 if (FP_REG_P (operands[1]))
4254 return "f<FP:prec>abs%.d %1,%0";
4255 return "f<FP:prec>abs%.<FP:prec> %1,%0";
4257 [(set_attr "type" "bitrw,fneg")])
4259 ;; bit indexing instructions
4261 (define_expand "clzsi2"
4262 [(set (match_operand:SI 0 "register_operand" "")
4263 (clz:SI (match_operand:SI 1 "general_operand" "")))]
4264 "ISA_HAS_FF1 || (TARGET_68020 && TARGET_BITFIELD)"
4267 operands[1] = force_reg (SImode, operands[1]);
4270 (define_insn "*clzsi2_68k"
4271 [(set (match_operand:SI 0 "register_operand" "=d")
4272 (clz:SI (match_operand:SI 1 "general_operand" "do")))]
4273 "TARGET_68020 && TARGET_BITFIELD"
4276 return "bfffo %1{#0:#0},%0";
4279 ;; ColdFire ff1 instruction implements clz.
4280 (define_insn "*clzsi2_cf"
4281 [(set (match_operand:SI 0 "register_operand" "=d")
4282 (clz:SI (match_operand:SI 1 "register_operand" "0")))]
4288 [(set_attr "type" "ext")])
4290 ;; one complement instructions
4292 (define_expand "one_cmplsi2"
4293 [(set (match_operand:SI 0 "nonimmediate_operand" "")
4294 (not:SI (match_operand:SI 1 "general_operand" "")))]
4297 if (TARGET_COLDFIRE)
4298 emit_insn (gen_one_cmplsi2_5200 (operands[0], operands[1]));
4300 emit_insn (gen_one_cmplsi2_internal (operands[0], operands[1]));
4304 (define_insn "one_cmplsi2_internal"
4305 [(set (match_operand:SI 0 "nonimmediate_operand" "=dm")
4306 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4310 (define_insn "one_cmplsi2_5200"
4311 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
4312 (not:SI (match_operand:SI 1 "general_operand" "0")))]
4315 [(set_attr "type" "neg_l")])
4317 (define_insn "one_cmplhi2"
4318 [(set (match_operand:HI 0 "nonimmediate_operand" "=dm")
4319 (not:HI (match_operand:HI 1 "general_operand" "0")))]
4324 [(set (strict_low_part (match_operand:HI 0 "nonimmediate_operand" "+dm"))
4325 (not:HI (match_dup 0)))]
4329 (define_insn "one_cmplqi2"
4330 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
4331 (not:QI (match_operand:QI 1 "general_operand" "0")))]
4336 [(set (strict_low_part (match_operand:QI 0 "nonimmediate_operand" "+dm"))
4337 (not:QI (match_dup 0)))]
4341 ;; arithmetic shift instructions
4342 ;; We don't need the shift memory by 1 bit instruction
4343 (define_insn_and_split "ashldi_extsi"
4344 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro")
4346 (match_operator:DI 2 "extend_operator"
4347 [(match_operand:SI 1 "general_operand" "rm")])
4351 "&& reload_completed"
4352 [(set (match_dup 3) (match_dup 1))
4353 (set (match_dup 2) (const_int 0))]
4354 "split_di(operands, 1, operands + 2, operands + 3);")
4356 (define_insn "ashldi_sexthi"
4357 [(set (match_operand:DI 0 "nonimmediate_operand" "=m,a*d")
4358 (ashift:DI (sign_extend:DI (match_operand:HI 1 "general_operand" "rm,rm"))
4360 (clobber (match_scratch:SI 2 "=a,X"))]
4364 if (GET_CODE (operands[0]) == MEM)
4366 if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
4367 return "clr%.l %0\;move%.w %1,%2\;move%.l %2,%0";
4368 else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
4369 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %0";
4372 operands[3] = adjust_address (operands[0], SImode, 4);
4373 return "move%.w %1,%2\;move%.l %2,%0\;clr%.l %3";
4376 else if (DATA_REG_P (operands[0]))
4377 return "move%.w %1,%0\;ext%.l %0\;clr%.l %R0";
4379 return "move%.w %1,%0\;sub%.l %R0,%R0";
4382 (define_insn "*ashldi3_const1"
4383 [(set (match_operand:DI 0 "register_operand" "=d")
4384 (ashift:DI (match_operand:DI 1 "register_operand" "0")
4387 "add%.l %R0,%R0\;addx%.l %0,%0")
4390 [(set (match_operand:DI 0 "register_operand" "")
4391 (ashift:DI (match_operand:DI 1 "register_operand" "")
4393 "reload_completed && !TARGET_COLDFIRE"
4395 (ashift:DI (match_dup 1) (const_int 1)))
4397 (ashift:DI (match_dup 0) (const_int 1)))]
4401 [(set (match_operand:DI 0 "register_operand" "")
4402 (ashift:DI (match_operand:DI 1 "register_operand" "")
4404 "reload_completed && !TARGET_COLDFIRE"
4406 (ashift:DI (match_dup 1) (const_int 2)))
4408 (ashift:DI (match_dup 0) (const_int 1)))]
4412 [(set (match_operand:DI 0 "register_operand" "")
4413 (ashift:DI (match_operand:DI 1 "register_operand" "")
4415 "reload_completed && !TARGET_COLDFIRE"
4417 (rotate:SI (match_dup 2) (const_int 8)))
4419 (rotate:SI (match_dup 3) (const_int 8)))
4420 (set (strict_low_part (subreg:QI (match_dup 0) 3))
4421 (subreg:QI (match_dup 0) 7))
4422 (set (strict_low_part (subreg:QI (match_dup 0) 7))
4425 operands[2] = gen_highpart (SImode, operands[0]);
4426 operands[3] = gen_lowpart (SImode, operands[0]);
4430 [(set (match_operand:DI 0 "register_operand" "")
4431 (ashift:DI (match_operand:DI 1 "register_operand" "")
4433 "reload_completed && !TARGET_COLDFIRE"
4435 (rotate:SI (match_dup 2) (const_int 16)))
4437 (rotate:SI (match_dup 3) (const_int 16)))
4438 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4439 (subreg:HI (match_dup 0) 6))
4440 (set (strict_low_part (subreg:HI (match_dup 0) 6))
4443 operands[2] = gen_highpart (SImode, operands[0]);
4444 operands[3] = gen_lowpart (SImode, operands[0]);
4448 [(set (match_operand:DI 0 "pre_dec_operand" "")
4449 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4452 [(set (match_dup 0) (const_int 0))
4453 (set (match_dup 0) (match_dup 1))]
4455 operands[0] = adjust_address(operands[0], SImode, 0);
4456 operands[1] = gen_lowpart(SImode, operands[1]);
4460 [(set (match_operand:DI 0 "post_inc_operand" "")
4461 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "")
4464 [(set (match_dup 0) (match_dup 1))
4465 (set (match_dup 0) (const_int 0))]
4467 operands[0] = adjust_address(operands[0], SImode, 0);
4468 operands[1] = gen_lowpart(SImode, operands[1]);
4471 (define_insn_and_split "*ashldi3_const32"
4472 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
4473 (ashift:DI (match_operand:DI 1 "nonimmediate_operand" "ro")
4477 "&& reload_completed"
4478 [(set (match_dup 4) (match_dup 3))
4479 (set (match_dup 2) (const_int 0))]
4480 "split_di(operands, 2, operands + 2, operands + 4);")
4483 [(set (match_operand:DI 0 "register_operand" "")
4484 (ashift:DI (match_operand:DI 1 "register_operand" "")
4485 (match_operand 2 "const_int_operand" "")))]
4486 "reload_completed && !TARGET_COLDFIRE
4487 && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
4488 [(set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 2)))
4489 (set (match_dup 3) (match_dup 4))
4490 (set (match_dup 4) (const_int 0))]
4492 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4493 operands[3] = gen_highpart (SImode, operands[0]);
4494 operands[4] = gen_lowpart (SImode, operands[0]);
4498 [(set (match_operand:DI 0 "register_operand" "")
4499 (ashift:DI (match_operand:DI 1 "register_operand" "")
4501 "reload_completed && !TARGET_COLDFIRE"
4502 [(set (match_dup 2) (match_dup 3))
4504 (rotate:SI (match_dup 2) (const_int 16)))
4505 (set (match_dup 3) (const_int 0))
4506 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4509 operands[2] = gen_highpart (SImode, operands[0]);
4510 operands[3] = gen_lowpart (SImode, operands[0]);
4514 [(set (match_operand:DI 0 "register_operand" "")
4515 (ashift:DI (match_operand:DI 1 "register_operand" "")
4516 (match_operand 2 "const_int_operand" "")))]
4517 "reload_completed && !TARGET_COLDFIRE
4518 && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 63"
4519 [(set (match_dup 3) (match_dup 2))
4520 (set (match_dup 4) (ashift:SI (match_dup 4) (match_dup 3)))
4521 (set (match_dup 3) (match_dup 4))
4522 (set (match_dup 4) (const_int 0))]
4524 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4525 operands[3] = gen_highpart (SImode, operands[0]);
4526 operands[4] = gen_lowpart (SImode, operands[0]);
4529 (define_insn "*ashldi3"
4530 [(set (match_operand:DI 0 "register_operand" "=d")
4531 (ashift:DI (match_operand:DI 1 "register_operand" "0")
4532 (match_operand 2 "const_int_operand" "n")))]
4534 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4535 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4536 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4539 (define_expand "ashldi3"
4540 [(set (match_operand:DI 0 "register_operand" "")
4541 (ashift:DI (match_operand:DI 1 "register_operand" "")
4542 (match_operand 2 "const_int_operand" "")))]
4545 /* ??? This is a named pattern like this is not allowed to FAIL based
4547 if (GET_CODE (operands[2]) != CONST_INT
4548 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4549 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4550 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
4554 ;; On most 68k models, this makes faster code in a special case.
4556 (define_insn "ashlsi_16"
4557 [(set (match_operand:SI 0 "register_operand" "=d")
4558 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4563 return "swap %0\;clr%.w %0";
4566 ;; ashift patterns : use lsl instead of asl, because lsl always clears the
4567 ;; overflow bit, so we must not set CC_NO_OVERFLOW.
4569 ;; On the 68000, this makes faster code in a special case.
4571 (define_insn "ashlsi_17_24"
4572 [(set (match_operand:SI 0 "register_operand" "=d")
4573 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4574 (match_operand:SI 2 "const_int_operand" "n")))]
4576 && INTVAL (operands[2]) > 16
4577 && INTVAL (operands[2]) <= 24"
4581 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4582 return "lsl%.w %2,%0\;swap %0\;clr%.w %0";
4585 (define_insn "ashlsi3"
4586 [(set (match_operand:SI 0 "register_operand" "=d")
4587 (ashift:SI (match_operand:SI 1 "register_operand" "0")
4588 (match_operand:SI 2 "general_operand" "dI")))]
4591 if (operands[2] == const1_rtx)
4593 cc_status.flags = CC_NO_OVERFLOW;
4594 return "add%.l %0,%0";
4596 return "lsl%.l %2,%0";
4599 (define_insn "ashlhi3"
4600 [(set (match_operand:HI 0 "register_operand" "=d")
4601 (ashift:HI (match_operand:HI 1 "register_operand" "0")
4602 (match_operand:HI 2 "general_operand" "dI")))]
4607 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4608 (ashift:HI (match_dup 0)
4609 (match_operand:HI 1 "general_operand" "dI")))]
4613 (define_insn "ashlqi3"
4614 [(set (match_operand:QI 0 "register_operand" "=d")
4615 (ashift:QI (match_operand:QI 1 "register_operand" "0")
4616 (match_operand:QI 2 "general_operand" "dI")))]
4621 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4622 (ashift:QI (match_dup 0)
4623 (match_operand:QI 1 "general_operand" "dI")))]
4627 ;; On most 68k models, this makes faster code in a special case.
4629 (define_insn "ashrsi_16"
4630 [(set (match_operand:SI 0 "register_operand" "=d")
4631 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4634 "swap %0\;ext%.l %0")
4636 ;; On the 68000, this makes faster code in a special case.
4639 [(set (match_operand:SI 0 "register_operand" "=d")
4640 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4641 (match_operand:SI 2 "const_int_operand" "n")))]
4643 && INTVAL (operands[2]) > 16
4644 && INTVAL (operands[2]) <= 24"
4646 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
4647 return "swap %0\;asr%.w %2,%0\;ext%.l %0";
4650 (define_insn "subreghi1ashrdi_const32"
4651 [(set (match_operand:HI 0 "nonimmediate_operand" "=rm")
4652 (subreg:HI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4653 (const_int 32)) 6))]
4656 if (GET_CODE (operands[1]) != REG)
4657 operands[1] = adjust_address (operands[1], HImode, 2);
4658 return "move%.w %1,%0";
4660 [(set_attr "type" "move")])
4662 (define_insn "subregsi1ashrdi_const32"
4663 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4664 (subreg:SI (ashiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4665 (const_int 32)) 4))]
4668 return "move%.l %1,%0";
4670 [(set_attr "type" "move_l")])
4672 (define_insn "*ashrdi3_const1"
4673 [(set (match_operand:DI 0 "register_operand" "=d")
4674 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4678 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4679 return "asr%.l #1,%0\;roxr%.l #1,%1";
4683 [(set (match_operand:DI 0 "register_operand" "")
4684 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4686 "reload_completed && !TARGET_COLDFIRE"
4688 (ashiftrt:DI (match_dup 1) (const_int 1)))
4690 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4694 [(set (match_operand:DI 0 "register_operand" "")
4695 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4697 "reload_completed && !TARGET_COLDFIRE"
4699 (ashiftrt:DI (match_dup 1) (const_int 2)))
4701 (ashiftrt:DI (match_dup 0) (const_int 1)))]
4705 [(set (match_operand:DI 0 "register_operand" "")
4706 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4708 "reload_completed && !TARGET_COLDFIRE"
4709 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4710 (subreg:QI (match_dup 0) 3))
4712 (ashiftrt:SI (match_dup 2) (const_int 8)))
4714 (rotatert:SI (match_dup 3) (const_int 8)))]
4716 operands[2] = gen_highpart (SImode, operands[0]);
4717 operands[3] = gen_lowpart (SImode, operands[0]);
4721 [(set (match_operand:DI 0 "register_operand" "")
4722 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4724 "reload_completed && !TARGET_COLDFIRE"
4725 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4726 (subreg:HI (match_dup 0) 2))
4728 (rotate:SI (match_dup 2) (const_int 16)))
4730 (rotate:SI (match_dup 3) (const_int 16)))
4732 (sign_extend:SI (subreg:HI (match_dup 2) 2)))]
4734 operands[2] = gen_highpart (SImode, operands[0]);
4735 operands[3] = gen_lowpart (SImode, operands[0]);
4738 (define_insn "*ashrdi_const32"
4739 [(set (match_operand:DI 0 "register_operand" "=d")
4740 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro")
4746 return "move%.l %1,%R0\;smi %0\;extb%.l %0";
4748 return "move%.l %1,%R0\;smi %0\;ext%.w %0\;ext%.l %0";
4751 (define_insn "*ashrdi_const32_mem"
4752 [(set (match_operand:DI 0 "memory_operand" "=o,<")
4753 (ashiftrt:DI (match_operand:DI 1 "nonimmediate_src_operand" "ro,ro")
4755 (clobber (match_scratch:SI 2 "=d,d"))]
4759 operands[3] = adjust_address (operands[0], SImode,
4760 which_alternative == 0 ? 4 : 0);
4761 operands[0] = adjust_address (operands[0], SImode, 0);
4762 if (TARGET_68020 || TARGET_COLDFIRE)
4763 return "move%.l %1,%3\;smi %2\;extb%.l %2\;move%.l %2,%0";
4765 return "move%.l %1,%3\;smi %2\;ext%.w %2\;ext%.l %2\;move%.l %2,%0";
4769 [(set (match_operand:DI 0 "register_operand" "")
4770 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4772 "reload_completed && !TARGET_COLDFIRE"
4774 (ashiftrt:SI (match_dup 3) (const_int 31)))
4777 "split_di(operands, 1, operands + 2, operands + 3);")
4779 ;; The predicate below must be general_operand, because ashrdi3 allows that
4780 (define_insn "ashrdi_const"
4781 [(set (match_operand:DI 0 "register_operand" "=d")
4782 (ashiftrt:DI (match_operand:DI 1 "register_operand" "0")
4783 (match_operand 2 "const_int_operand" "n")))]
4785 && ((INTVAL (operands[2]) >= 1 && INTVAL (operands[2]) <= 3)
4786 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
4787 || INTVAL (operands[2]) == 31
4788 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63))"
4790 operands[1] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
4792 if (INTVAL (operands[2]) == 48)
4793 return "swap %0\;ext%.l %0\;move%.l %0,%1\;smi %0\;ext%.w %0";
4794 if (INTVAL (operands[2]) == 31)
4795 return "add%.l %1,%1\;addx%.l %0,%0\;move%.l %0,%1\;subx%.l %0,%0";
4796 if (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)
4798 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
4799 output_asm_insn (INTVAL (operands[2]) <= 8 ? "asr%.l %2,%0" :
4800 "moveq %2,%1\;asr%.l %1,%0", operands);
4801 output_asm_insn ("mov%.l %0,%1\;smi %0", operands);
4802 return INTVAL (operands[2]) >= 15 ? "ext%.w %d0" :
4803 TARGET_68020 ? "extb%.l %0" : "ext%.w %0\;ext%.l %0";
4808 (define_expand "ashrdi3"
4809 [(set (match_operand:DI 0 "register_operand" "")
4810 (ashiftrt:DI (match_operand:DI 1 "register_operand" "")
4811 (match_operand 2 "const_int_operand" "")))]
4814 /* ??? This is a named pattern like this is not allowed to FAIL based
4816 if (GET_CODE (operands[2]) != CONST_INT
4817 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
4818 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
4819 && (INTVAL (operands[2]) < 31 || INTVAL (operands[2]) > 63)))
4823 ;; On all 68k models, this makes faster code in a special case.
4825 (define_insn "ashrsi_31"
4826 [(set (match_operand:SI 0 "register_operand" "=d")
4827 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4831 return "add%.l %0,%0\;subx%.l %0,%0";
4834 (define_insn "ashrsi3"
4835 [(set (match_operand:SI 0 "register_operand" "=d")
4836 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
4837 (match_operand:SI 2 "general_operand" "dI")))]
4840 [(set_attr "type" "shift")
4841 (set_attr "opy" "2")])
4843 (define_insn "ashrhi3"
4844 [(set (match_operand:HI 0 "register_operand" "=d")
4845 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
4846 (match_operand:HI 2 "general_operand" "dI")))]
4851 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
4852 (ashiftrt:HI (match_dup 0)
4853 (match_operand:HI 1 "general_operand" "dI")))]
4857 (define_insn "ashrqi3"
4858 [(set (match_operand:QI 0 "register_operand" "=d")
4859 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
4860 (match_operand:QI 2 "general_operand" "dI")))]
4865 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
4866 (ashiftrt:QI (match_dup 0)
4867 (match_operand:QI 1 "general_operand" "dI")))]
4871 ;; logical shift instructions
4873 ;; commented out because of reload problems in 950612-1.c
4876 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4877 ;; (const_int 32)) 4))
4878 ;; (set (match_operand:SI 1 "nonimmediate_operand" "=dm")
4879 ;; (subreg:SI (lshiftrt:DI (match_dup 0)
4880 ;; (const_int 32)) 4))]
4883 ;; return "move%.l %0,%1";
4888 ;; (subreg:SI (lshiftrt:DI (match_operand:DI 0 "general_operand" "ro")
4889 ;; (const_int 32)) 0))
4890 ;; (set (match_operand:DI 1 "nonimmediate_operand" "=do")
4891 ;; (lshiftrt:DI (match_dup 0)
4892 ;; (const_int 32)))]
4895 ;; if (GET_CODE (operands[1]) == REG)
4896 ;; operands[2] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
4898 ;; operands[2] = adjust_address (operands[1], SImode, 4);
4899 ;; return "move%.l %0,%2\;clr%.l %1";
4902 (define_insn "subreg1lshrdi_const32"
4903 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
4904 (subreg:SI (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
4905 (const_int 32)) 4))]
4908 [(set_attr "type" "move_l")])
4910 (define_insn "*lshrdi3_const1"
4911 [(set (match_operand:DI 0 "register_operand" "=d")
4912 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
4915 "lsr%.l #1,%0\;roxr%.l #1,%R0")
4918 [(set (match_operand:DI 0 "register_operand" "")
4919 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4921 "reload_completed && !TARGET_COLDFIRE"
4923 (lshiftrt:DI (match_dup 1) (const_int 1)))
4925 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4929 [(set (match_operand:DI 0 "register_operand" "")
4930 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4932 "reload_completed && !TARGET_COLDFIRE"
4934 (lshiftrt:DI (match_dup 1) (const_int 2)))
4936 (lshiftrt:DI (match_dup 0) (const_int 1)))]
4940 [(set (match_operand:DI 0 "register_operand" "")
4941 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4943 "reload_completed && !TARGET_COLDFIRE"
4944 [(set (strict_low_part (subreg:QI (match_dup 0) 7))
4945 (subreg:QI (match_dup 0) 3))
4947 (lshiftrt:SI (match_dup 2) (const_int 8)))
4949 (rotatert:SI (match_dup 3) (const_int 8)))]
4951 operands[2] = gen_highpart (SImode, operands[0]);
4952 operands[3] = gen_lowpart (SImode, operands[0]);
4956 [(set (match_operand:DI 0 "register_operand" "")
4957 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
4959 "reload_completed && !TARGET_COLDFIRE"
4960 [(set (strict_low_part (subreg:HI (match_dup 0) 6))
4961 (subreg:HI (match_dup 0) 2))
4962 (set (strict_low_part (subreg:HI (match_dup 0) 2))
4965 (rotate:SI (match_dup 3) (const_int 16)))
4967 (rotate:SI (match_dup 2) (const_int 16)))]
4969 operands[2] = gen_highpart (SImode, operands[0]);
4970 operands[3] = gen_lowpart (SImode, operands[0]);
4974 [(set (match_operand:DI 0 "pre_dec_operand" "")
4975 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
4978 [(set (match_dup 0) (match_dup 1))
4979 (set (match_dup 0) (const_int 0))]
4981 operands[0] = adjust_address(operands[0], SImode, 0);
4982 operands[1] = gen_highpart(SImode, operands[1]);
4986 [(set (match_operand:DI 0 "post_inc_operand" "")
4987 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
4990 [(set (match_dup 0) (const_int 0))
4991 (set (match_dup 0) (match_dup 1))]
4993 operands[0] = adjust_address(operands[0], SImode, 0);
4994 operands[1] = gen_highpart(SImode, operands[1]);
4998 [(set (match_operand:DI 0 "nonimmediate_operand" "")
4999 (lshiftrt:DI (match_operand:DI 1 "nonimmediate_operand" "")
5002 [(set (match_dup 2) (match_dup 5))
5003 (set (match_dup 4) (const_int 0))]
5004 "split_di(operands, 2, operands + 2, operands + 4);")
5006 (define_insn "*lshrdi_const32"
5007 [(set (match_operand:DI 0 "nonimmediate_operand" "=ro<>")
5008 (lshiftrt:DI (match_operand:DI 1 "general_operand" "ro")
5014 [(set (match_operand:DI 0 "register_operand" "")
5015 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5016 (match_operand 2 "const_int_operand" "")))]
5017 "reload_completed && !TARGET_COLDFIRE
5018 && INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 40"
5019 [(set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 2)))
5020 (set (match_dup 4) (match_dup 3))
5021 (set (match_dup 3) (const_int 0))]
5023 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5024 operands[3] = gen_highpart (SImode, operands[0]);
5025 operands[4] = gen_lowpart (SImode, operands[0]);
5029 [(set (match_operand:DI 0 "register_operand" "")
5030 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5033 [(set (match_dup 3) (match_dup 2))
5034 (set (strict_low_part (subreg:HI (match_dup 0) 6))
5036 (set (match_dup 2) (const_int 0))
5038 (rotate:SI (match_dup 3) (const_int 16)))]
5040 operands[2] = gen_highpart (SImode, operands[0]);
5041 operands[3] = gen_lowpart (SImode, operands[0]);
5045 [(set (match_operand:DI 0 "register_operand" "")
5046 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5047 (match_operand 2 "const_int_operand" "")))]
5048 "reload_completed && !TARGET_COLDFIRE
5049 && INTVAL (operands[2]) > 40 && INTVAL (operands[2]) <= 62"
5050 [(set (match_dup 4) (match_dup 2))
5051 (set (match_dup 3) (lshiftrt:SI (match_dup 3) (match_dup 4)))
5052 (set (match_dup 4) (match_dup 3))
5053 (set (match_dup 3) (const_int 0))]
5055 operands[2] = GEN_INT (INTVAL (operands[2]) - 32);
5056 operands[3] = gen_highpart (SImode, operands[0]);
5057 operands[4] = gen_lowpart (SImode, operands[0]);
5060 (define_insn "*lshrdi_const63"
5061 [(set (match_operand:DI 0 "register_operand" "=d")
5062 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5065 "add%.l %0,%0\;clr%.l %0\;clr%.l %R1\;addx%.l %R1,%R1")
5067 (define_insn "*lshrdi3_const"
5068 [(set (match_operand:DI 0 "register_operand" "=d")
5069 (lshiftrt:DI (match_operand:DI 1 "register_operand" "0")
5070 (match_operand 2 "const_int_operand" "n")))]
5072 && ((INTVAL (operands[2]) >= 2 && INTVAL (operands[2]) <= 3)
5073 || INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16
5074 || (INTVAL (operands[2]) > 32 && INTVAL (operands[2]) <= 63)))"
5077 (define_expand "lshrdi3"
5078 [(set (match_operand:DI 0 "register_operand" "")
5079 (lshiftrt:DI (match_operand:DI 1 "register_operand" "")
5080 (match_operand 2 "const_int_operand" "")))]
5083 /* ??? This is a named pattern like this is not allowed to FAIL based
5085 if (GET_CODE (operands[2]) != CONST_INT
5086 || ((INTVAL (operands[2]) < 1 || INTVAL (operands[2]) > 3)
5087 && INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16
5088 && (INTVAL (operands[2]) < 32 || INTVAL (operands[2]) > 63)))
5092 ;; On all 68k models, this makes faster code in a special case.
5094 (define_insn "lshrsi_31"
5095 [(set (match_operand:SI 0 "register_operand" "=d")
5096 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5100 return "add%.l %0,%0\;subx%.l %0,%0\;neg%.l %0";
5103 ;; On most 68k models, this makes faster code in a special case.
5105 (define_insn "lshrsi_16"
5106 [(set (match_operand:SI 0 "register_operand" "=d")
5107 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5112 return "clr%.w %0\;swap %0";
5115 ;; On the 68000, this makes faster code in a special case.
5117 (define_insn "lshrsi_17_24"
5118 [(set (match_operand:SI 0 "register_operand" "=d")
5119 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5120 (match_operand:SI 2 "const_int_operand" "n")))]
5122 && INTVAL (operands[2]) > 16
5123 && INTVAL (operands[2]) <= 24"
5125 /* I think lsr%.w sets the CC properly. */
5126 operands[2] = GEN_INT (INTVAL (operands[2]) - 16);
5127 return "clr%.w %0\;swap %0\;lsr%.w %2,%0";
5130 (define_insn "lshrsi3"
5131 [(set (match_operand:SI 0 "register_operand" "=d")
5132 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
5133 (match_operand:SI 2 "general_operand" "dI")))]
5136 [(set_attr "type" "shift")
5137 (set_attr "opy" "2")])
5139 (define_insn "lshrhi3"
5140 [(set (match_operand:HI 0 "register_operand" "=d")
5141 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
5142 (match_operand:HI 2 "general_operand" "dI")))]
5147 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5148 (lshiftrt:HI (match_dup 0)
5149 (match_operand:HI 1 "general_operand" "dI")))]
5153 (define_insn "lshrqi3"
5154 [(set (match_operand:QI 0 "register_operand" "=d")
5155 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
5156 (match_operand:QI 2 "general_operand" "dI")))]
5161 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5162 (lshiftrt:QI (match_dup 0)
5163 (match_operand:QI 1 "general_operand" "dI")))]
5167 ;; rotate instructions
5169 (define_insn "rotlsi_16"
5170 [(set (match_operand:SI 0 "register_operand" "=d")
5171 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5175 [(set_attr "type" "shift")])
5177 (define_insn "rotlsi3"
5178 [(set (match_operand:SI 0 "register_operand" "=d")
5179 (rotate:SI (match_operand:SI 1 "register_operand" "0")
5180 (match_operand:SI 2 "general_operand" "dINO")))]
5183 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 16)
5185 else if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 16)
5187 operands[2] = GEN_INT (32 - INTVAL (operands[2]));
5188 return "ror%.l %2,%0";
5191 return "rol%.l %2,%0";
5194 (define_insn "rotlhi3"
5195 [(set (match_operand:HI 0 "register_operand" "=d")
5196 (rotate:HI (match_operand:HI 1 "register_operand" "0")
5197 (match_operand:HI 2 "general_operand" "dIP")))]
5200 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 8)
5202 operands[2] = GEN_INT (16 - INTVAL (operands[2]));
5203 return "ror%.w %2,%0";
5206 return "rol%.w %2,%0";
5209 (define_insn "*rotlhi3_lowpart"
5210 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5211 (rotate:HI (match_dup 0)
5212 (match_operand:HI 1 "general_operand" "dIP")))]
5215 if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) >= 8)
5217 operands[1] = GEN_INT (16 - INTVAL (operands[1]));
5218 return "ror%.w %1,%0";
5221 return "rol%.w %1,%0";
5224 (define_insn "rotlqi3"
5225 [(set (match_operand:QI 0 "register_operand" "=d")
5226 (rotate:QI (match_operand:QI 1 "register_operand" "0")
5227 (match_operand:QI 2 "general_operand" "dI")))]
5230 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) >= 4)
5232 operands[2] = GEN_INT (8 - INTVAL (operands[2]));
5233 return "ror%.b %2,%0";
5236 return "rol%.b %2,%0";
5239 (define_insn "*rotlqi3_lowpart"
5240 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5241 (rotate:QI (match_dup 0)
5242 (match_operand:QI 1 "general_operand" "dI")))]
5245 if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) >= 4)
5247 operands[1] = GEN_INT (8 - INTVAL (operands[1]));
5248 return "ror%.b %1,%0";
5251 return "rol%.b %1,%0";
5254 (define_insn "rotrsi3"
5255 [(set (match_operand:SI 0 "register_operand" "=d")
5256 (rotatert:SI (match_operand:SI 1 "register_operand" "0")
5257 (match_operand:SI 2 "general_operand" "dI")))]
5261 (define_insn "rotrhi3"
5262 [(set (match_operand:HI 0 "register_operand" "=d")
5263 (rotatert:HI (match_operand:HI 1 "register_operand" "0")
5264 (match_operand:HI 2 "general_operand" "dI")))]
5268 (define_insn "rotrhi_lowpart"
5269 [(set (strict_low_part (match_operand:HI 0 "register_operand" "+d"))
5270 (rotatert:HI (match_dup 0)
5271 (match_operand:HI 1 "general_operand" "dI")))]
5275 (define_insn "rotrqi3"
5276 [(set (match_operand:QI 0 "register_operand" "=d")
5277 (rotatert:QI (match_operand:QI 1 "register_operand" "0")
5278 (match_operand:QI 2 "general_operand" "dI")))]
5283 [(set (strict_low_part (match_operand:QI 0 "register_operand" "+d"))
5284 (rotatert:QI (match_dup 0)
5285 (match_operand:QI 1 "general_operand" "dI")))]
5289 (define_expand "bswapsi2"
5290 [(set (match_operand:SI 0 "register_operand")
5291 (bswap:SI (match_operand:SI 1 "register_operand")))]
5294 rtx x = operands[0];
5295 emit_move_insn (x, operands[1]);
5296 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5297 emit_insn (gen_rotlsi3 (x, x, GEN_INT (16)));
5298 emit_insn (gen_rotrhi_lowpart (gen_lowpart (HImode, x), GEN_INT (8)));
5303 ;; Bit set/clear in memory byte.
5305 ;; set bit, bit number is int
5306 (define_insn "bsetmemqi"
5307 [(set (match_operand:QI 0 "memory_operand" "+m")
5308 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5309 (match_operand:SI 1 "general_operand" "d")) 3)
5314 return "bset %1,%0";
5316 [(set_attr "type" "bitrw")])
5318 ;; set bit, bit number is (sign/zero)_extended from HImode/QImode
5319 (define_insn "*bsetmemqi_ext"
5320 [(set (match_operand:QI 0 "memory_operand" "+m")
5321 (ior:QI (subreg:QI (ashift:SI (const_int 1)
5322 (match_operator:SI 2 "extend_operator"
5323 [(match_operand 1 "general_operand" "d")])) 3)
5328 return "bset %1,%0";
5330 [(set_attr "type" "bitrw")])
5332 ;; clear bit, bit number is int
5333 (define_insn "bclrmemqi"
5334 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5336 (minus:SI (const_int 7)
5337 (match_operand:SI 1 "general_operand" "d")))
5342 return "bclr %1,%0";
5344 [(set_attr "type" "bitrw")])
5346 ;; clear bit, bit number is (sign/zero)_extended from HImode/QImode
5347 (define_insn "*bclrmemqi_ext"
5348 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+m")
5350 (minus:SI (const_int 7)
5351 (match_operator:SI 2 "extend_operator"
5352 [(match_operand 1 "general_operand" "d")])))
5357 return "bclr %1,%0";
5359 [(set_attr "type" "bitrw")])
5361 ;; Special cases of bit-field insns which we should
5362 ;; recognize in preference to the general case.
5363 ;; These handle aligned 8-bit and 16-bit fields,
5364 ;; which can usually be done with move instructions.
5367 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5368 ; alignment of structure members is specified.
5370 ; The move is allowed to be odd byte aligned, because that's still faster
5371 ; than an odd byte aligned bit-field instruction.
5373 (define_insn "*insv_32_mem"
5374 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5376 (match_operand:SI 1 "const_int_operand" "n"))
5377 (match_operand:SI 2 "general_src_operand" "rmSi"))]
5378 "TARGET_68020 && TARGET_BITFIELD
5379 && (INTVAL (operands[1]) % 8) == 0
5380 && ! mode_dependent_address_p (XEXP (operands[0], 0),
5381 MEM_ADDR_SPACE (operands[0]))"
5384 = adjust_address (operands[0], SImode, INTVAL (operands[1]) / 8);
5386 return "move%.l %2,%0";
5389 (define_insn "*insv_8_16_reg"
5390 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5391 (match_operand:SI 1 "const_int_operand" "n")
5392 (match_operand:SI 2 "const_int_operand" "n"))
5393 (match_operand:SI 3 "register_operand" "d"))]
5394 "TARGET_68020 && TARGET_BITFIELD
5395 && (INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16)
5396 && INTVAL (operands[2]) % INTVAL (operands[1]) == 0"
5398 if (INTVAL (operands[1]) + INTVAL (operands[2]) != 32)
5399 return "bfins %3,%0{%b2:%b1}";
5401 if (INTVAL (operands[1]) == 8)
5402 return "move%.b %3,%0";
5403 return "move%.w %3,%0";
5408 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5409 ; alignment of structure members is specified.
5411 ; The move is allowed to be odd byte aligned, because that's still faster
5412 ; than an odd byte aligned bit-field instruction.
5414 (define_insn "*extzv_32_mem"
5415 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5416 (zero_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5418 (match_operand:SI 2 "const_int_operand" "n")))]
5419 "TARGET_68020 && TARGET_BITFIELD
5420 && (INTVAL (operands[2]) % 8) == 0
5421 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5422 MEM_ADDR_SPACE (operands[1]))"
5425 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5427 return "move%.l %1,%0";
5430 (define_insn "*extzv_8_16_reg"
5431 [(set (match_operand:SI 0 "nonimmediate_operand" "=&d")
5432 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5433 (match_operand:SI 2 "const_int_operand" "n")
5434 (match_operand:SI 3 "const_int_operand" "n")))]
5435 "TARGET_68020 && TARGET_BITFIELD
5436 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5437 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5439 cc_status.flags |= CC_NOT_NEGATIVE;
5440 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5441 return "bfextu %1{%b3:%b2},%0";
5443 output_asm_insn ("clr%.l %0", operands);
5444 if (INTVAL (operands[2]) == 8)
5445 return "move%.b %1,%0";
5446 return "move%.w %1,%0";
5450 ; Special case for 32-bit field in memory. This only occurs when 32-bit
5451 ; alignment of structure members is specified.
5453 ; The move is allowed to be odd byte aligned, because that's still faster
5454 ; than an odd byte aligned bit-field instruction.
5456 (define_insn "*extv_32_mem"
5457 [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
5458 (sign_extract:SI (match_operand:QI 1 "memory_src_operand" "oS")
5460 (match_operand:SI 2 "const_int_operand" "n")))]
5461 "TARGET_68020 && TARGET_BITFIELD
5462 && (INTVAL (operands[2]) % 8) == 0
5463 && ! mode_dependent_address_p (XEXP (operands[1], 0),
5464 MEM_ADDR_SPACE (operands[1]))"
5467 = adjust_address (operands[1], SImode, INTVAL (operands[2]) / 8);
5469 return "move%.l %1,%0";
5472 (define_insn "*extv_8_16_reg"
5473 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5474 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5475 (match_operand:SI 2 "const_int_operand" "n")
5476 (match_operand:SI 3 "const_int_operand" "n")))]
5477 "TARGET_68020 && TARGET_BITFIELD
5478 && (INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16)
5479 && INTVAL (operands[3]) % INTVAL (operands[2]) == 0"
5481 if (INTVAL (operands[2]) + INTVAL (operands[3]) != 32)
5482 return "bfexts %1{%b3:%b2},%0";
5484 if (INTVAL (operands[2]) == 8)
5485 return "move%.b %1,%0\;extb%.l %0";
5486 return "move%.w %1,%0\;ext%.l %0";
5489 ;; Bit-field instructions, general cases.
5490 ;; "o,d" constraint causes a nonoffsettable memref to match the "o"
5491 ;; so that its address is reloaded.
5493 (define_expand "extv"
5494 [(set (match_operand:SI 0 "register_operand" "")
5495 (sign_extract:SI (match_operand:SI 1 "general_operand" "")
5496 (match_operand:SI 2 "const_int_operand" "")
5497 (match_operand:SI 3 "const_int_operand" "")))]
5498 "TARGET_68020 && TARGET_BITFIELD"
5501 (define_insn "*extv_bfexts_mem"
5502 [(set (match_operand:SI 0 "register_operand" "=d")
5503 (sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
5504 (match_operand:SI 2 "nonmemory_operand" "dn")
5505 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5506 "TARGET_68020 && TARGET_BITFIELD"
5507 "bfexts %1{%b3:%b2},%0")
5509 (define_expand "extzv"
5510 [(set (match_operand:SI 0 "register_operand" "")
5511 (zero_extract:SI (match_operand:SI 1 "general_operand" "")
5512 (match_operand:SI 2 "const_int_operand" "")
5513 (match_operand:SI 3 "const_int_operand" "")))]
5514 "TARGET_68020 && TARGET_BITFIELD"
5517 (define_insn "*extzv_bfextu_mem"
5518 [(set (match_operand:SI 0 "register_operand" "=d")
5519 (zero_extract:SI (match_operand:QI 1 "memory_operand" "o")
5520 (match_operand:SI 2 "nonmemory_operand" "dn")
5521 (match_operand:SI 3 "nonmemory_operand" "dn")))]
5522 "TARGET_68020 && TARGET_BITFIELD"
5524 if (GET_CODE (operands[2]) == CONST_INT)
5526 if (INTVAL (operands[2]) != 32)
5527 cc_status.flags |= CC_NOT_NEGATIVE;
5533 return "bfextu %1{%b3:%b2},%0";
5536 (define_insn "*insv_bfchg_mem"
5537 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5538 (match_operand:SI 1 "nonmemory_operand" "dn")
5539 (match_operand:SI 2 "nonmemory_operand" "dn"))
5540 (xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
5541 (match_operand 3 "const_int_operand" "n")))]
5542 "TARGET_68020 && TARGET_BITFIELD
5543 && (INTVAL (operands[3]) == -1
5544 || (GET_CODE (operands[1]) == CONST_INT
5545 && (~ INTVAL (operands[3]) & ((1 << INTVAL (operands[1]))- 1)) == 0))"
5548 return "bfchg %0{%b2:%b1}";
5551 (define_insn "*insv_bfclr_mem"
5552 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5553 (match_operand:SI 1 "nonmemory_operand" "dn")
5554 (match_operand:SI 2 "nonmemory_operand" "dn"))
5556 "TARGET_68020 && TARGET_BITFIELD"
5559 return "bfclr %0{%b2:%b1}";
5562 (define_insn "*insv_bfset_mem"
5563 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5564 (match_operand:SI 1 "general_operand" "dn")
5565 (match_operand:SI 2 "general_operand" "dn"))
5567 "TARGET_68020 && TARGET_BITFIELD"
5570 return "bfset %0{%b2:%b1}";
5573 (define_expand "insv"
5574 [(set (zero_extract:SI (match_operand:SI 0 "nonimmediate_operand" "")
5575 (match_operand:SI 1 "const_int_operand" "")
5576 (match_operand:SI 2 "const_int_operand" ""))
5577 (match_operand:SI 3 "register_operand" ""))]
5578 "TARGET_68020 && TARGET_BITFIELD"
5581 (define_insn "*insv_bfins_mem"
5582 [(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
5583 (match_operand:SI 1 "nonmemory_operand" "dn")
5584 (match_operand:SI 2 "nonmemory_operand" "dn"))
5585 (match_operand:SI 3 "register_operand" "d"))]
5586 "TARGET_68020 && TARGET_BITFIELD"
5587 "bfins %3,%0{%b2:%b1}")
5589 ;; Now recognize bit-field insns that operate on registers
5590 ;; (or at least were intended to do so).
5592 (define_insn "*extv_bfexts_reg"
5593 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5594 (sign_extract:SI (match_operand:SI 1 "register_operand" "d")
5595 (match_operand:SI 2 "const_int_operand" "n")
5596 (match_operand:SI 3 "const_int_operand" "n")))]
5597 "TARGET_68020 && TARGET_BITFIELD"
5598 "bfexts %1{%b3:%b2},%0")
5600 (define_insn "*extv_bfextu_reg"
5601 [(set (match_operand:SI 0 "nonimmediate_operand" "=d")
5602 (zero_extract:SI (match_operand:SI 1 "register_operand" "d")
5603 (match_operand:SI 2 "const_int_operand" "n")
5604 (match_operand:SI 3 "const_int_operand" "n")))]
5605 "TARGET_68020 && TARGET_BITFIELD"
5607 if (GET_CODE (operands[2]) == CONST_INT)
5609 if (INTVAL (operands[2]) != 32)
5610 cc_status.flags |= CC_NOT_NEGATIVE;
5616 return "bfextu %1{%b3:%b2},%0";
5619 (define_insn "*insv_bfclr_reg"
5620 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5621 (match_operand:SI 1 "const_int_operand" "n")
5622 (match_operand:SI 2 "const_int_operand" "n"))
5624 "TARGET_68020 && TARGET_BITFIELD"
5627 return "bfclr %0{%b2:%b1}";
5630 (define_insn "*insv_bfset_reg"
5631 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5632 (match_operand:SI 1 "const_int_operand" "n")
5633 (match_operand:SI 2 "const_int_operand" "n"))
5635 "TARGET_68020 && TARGET_BITFIELD"
5638 return "bfset %0{%b2:%b1}";
5641 (define_insn "*insv_bfins_reg"
5642 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
5643 (match_operand:SI 1 "const_int_operand" "n")
5644 (match_operand:SI 2 "const_int_operand" "n"))
5645 (match_operand:SI 3 "register_operand" "d"))]
5646 "TARGET_68020 && TARGET_BITFIELD"
5649 /* These special cases are now recognized by a specific pattern. */
5650 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5651 && INTVAL (operands[1]) == 16 && INTVAL (operands[2]) == 16)
5652 return "move%.w %3,%0";
5653 if (GET_CODE (operands[1]) == CONST_INT && GET_CODE (operands[2]) == CONST_INT
5654 && INTVAL (operands[1]) == 24 && INTVAL (operands[2]) == 8)
5655 return "move%.b %3,%0";
5657 return "bfins %3,%0{%b2:%b1}";
5660 ;; Special patterns for optimizing bit-field instructions.
5662 (define_insn "*tst_bftst_mem"
5664 (compare (zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
5665 (match_operand:SI 1 "const_int_operand" "n")
5666 (match_operand:SI 2 "general_operand" "dn"))
5668 "TARGET_68020 && TARGET_BITFIELD"
5670 if (operands[1] == const1_rtx
5671 && GET_CODE (operands[2]) == CONST_INT)
5673 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5674 return output_btst (operands,
5675 GEN_INT (width - INTVAL (operands[2])),
5676 operands[0], insn, 1000);
5677 /* Pass 1000 as SIGNPOS argument so that btst will
5678 not think we are testing the sign bit for an `and'
5679 and assume that nonzero implies a negative result. */
5681 if (INTVAL (operands[1]) != 32)
5682 cc_status.flags = CC_NOT_NEGATIVE;
5683 return "bftst %0{%b2:%b1}";
5687 ;;; now handle the register cases
5688 (define_insn "*tst_bftst_reg"
5690 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "d")
5691 (match_operand:SI 1 "const_int_operand" "n")
5692 (match_operand:SI 2 "general_operand" "dn"))
5694 "TARGET_68020 && TARGET_BITFIELD"
5696 if (operands[1] == const1_rtx
5697 && GET_CODE (operands[2]) == CONST_INT)
5699 int width = GET_CODE (operands[0]) == REG ? 31 : 7;
5700 return output_btst (operands, GEN_INT (width - INTVAL (operands[2])),
5701 operands[0], insn, 1000);
5702 /* Pass 1000 as SIGNPOS argument so that btst will
5703 not think we are testing the sign bit for an `and'
5704 and assume that nonzero implies a negative result. */
5706 if (INTVAL (operands[1]) != 32)
5707 cc_status.flags = CC_NOT_NEGATIVE;
5708 return "bftst %0{%b2:%b1}";
5711 (define_insn "scc0_di"
5712 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm")
5713 (match_operator 1 "ordered_comparison_operator"
5714 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5717 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5720 (define_insn "scc0_di_5200"
5721 [(set (match_operand:QI 0 "nonimmediate_operand" "=d")
5722 (match_operator 1 "ordered_comparison_operator"
5723 [(match_operand:DI 2 "general_operand" "ro") (const_int 0)]))]
5726 return output_scc_di (operands[1], operands[2], const0_rtx, operands[0]);
5729 (define_insn "scc_di"
5730 [(set (match_operand:QI 0 "nonimmediate_operand" "=dm,dm")
5731 (match_operator 1 "ordered_comparison_operator"
5732 [(match_operand:DI 2 "general_operand" "ro,r")
5733 (match_operand:DI 3 "general_operand" "r,ro")]))]
5736 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5739 (define_insn "scc_di_5200"
5740 [(set (match_operand:QI 0 "nonimmediate_operand" "=d,d")
5741 (match_operator 1 "ordered_comparison_operator"
5742 [(match_operand:DI 2 "general_operand" "ro,r")
5743 (match_operand:DI 3 "general_operand" "r,ro")]))]
5746 return output_scc_di (operands[1], operands[2], operands[3], operands[0]);
5749 ;; Note that operand 0 of an SCC insn is supported in the hardware as
5750 ;; memory, but we cannot allow it to be in memory in case the address
5751 ;; needs to be reloaded.
5754 [(set (match_operand:QI 0 "register_operand" "=d")
5755 (eq:QI (cc0) (const_int 0)))]
5758 cc_status = cc_prev_status;
5759 OUTPUT_JUMP ("seq %0", "fseq %0", "seq %0");
5763 [(set (match_operand:QI 0 "register_operand" "=d")
5764 (ne:QI (cc0) (const_int 0)))]
5767 cc_status = cc_prev_status;
5768 OUTPUT_JUMP ("sne %0", "fsne %0", "sne %0");
5772 [(set (match_operand:QI 0 "register_operand" "=d")
5773 (gt:QI (cc0) (const_int 0)))]
5776 cc_status = cc_prev_status;
5777 OUTPUT_JUMP ("sgt %0", "fsgt %0", 0);
5781 [(set (match_operand:QI 0 "register_operand" "=d")
5782 (gtu:QI (cc0) (const_int 0)))]
5785 cc_status = cc_prev_status;
5790 [(set (match_operand:QI 0 "register_operand" "=d")
5791 (lt:QI (cc0) (const_int 0)))]
5794 cc_status = cc_prev_status;
5795 OUTPUT_JUMP ("slt %0", "fslt %0", "smi %0");
5799 [(set (match_operand:QI 0 "register_operand" "=d")
5800 (ltu:QI (cc0) (const_int 0)))]
5803 cc_status = cc_prev_status;
5808 [(set (match_operand:QI 0 "register_operand" "=d")
5809 (ge:QI (cc0) (const_int 0)))]
5812 cc_status = cc_prev_status;
5813 OUTPUT_JUMP ("sge %0", "fsge %0", "spl %0");
5817 [(set (match_operand:QI 0 "register_operand" "=d")
5818 (geu:QI (cc0) (const_int 0)))]
5821 cc_status = cc_prev_status;
5824 [(set_attr "type" "scc")])
5827 [(set (match_operand:QI 0 "register_operand" "=d")
5828 (le:QI (cc0) (const_int 0)))]
5831 cc_status = cc_prev_status;
5832 OUTPUT_JUMP ("sle %0", "fsle %0", 0);
5836 [(set (match_operand:QI 0 "register_operand" "=d")
5837 (leu:QI (cc0) (const_int 0)))]
5840 cc_status = cc_prev_status;
5843 [(set_attr "type" "scc")])
5845 (define_insn "*sordered_1"
5846 [(set (match_operand:QI 0 "register_operand" "=d")
5847 (ordered:QI (cc0) (const_int 0)))]
5848 "TARGET_68881 && !TUNE_68060"
5850 cc_status = cc_prev_status;
5854 (define_insn "*sunordered_1"
5855 [(set (match_operand:QI 0 "register_operand" "=d")
5856 (unordered:QI (cc0) (const_int 0)))]
5857 "TARGET_68881 && !TUNE_68060"
5859 cc_status = cc_prev_status;
5863 (define_insn "*suneq_1"
5864 [(set (match_operand:QI 0 "register_operand" "=d")
5865 (uneq:QI (cc0) (const_int 0)))]
5866 "TARGET_68881 && !TUNE_68060"
5868 cc_status = cc_prev_status;
5872 (define_insn "*sunge_1"
5873 [(set (match_operand:QI 0 "register_operand" "=d")
5874 (unge:QI (cc0) (const_int 0)))]
5875 "TARGET_68881 && !TUNE_68060"
5877 cc_status = cc_prev_status;
5881 (define_insn "*sungt_1"
5882 [(set (match_operand:QI 0 "register_operand" "=d")
5883 (ungt:QI (cc0) (const_int 0)))]
5884 "TARGET_68881 && !TUNE_68060"
5886 cc_status = cc_prev_status;
5890 (define_insn "*sunle_1"
5891 [(set (match_operand:QI 0 "register_operand" "=d")
5892 (unle:QI (cc0) (const_int 0)))]
5893 "TARGET_68881 && !TUNE_68060"
5895 cc_status = cc_prev_status;
5899 (define_insn "*sunlt_1"
5900 [(set (match_operand:QI 0 "register_operand" "=d")
5901 (unlt:QI (cc0) (const_int 0)))]
5902 "TARGET_68881 && !TUNE_68060"
5904 cc_status = cc_prev_status;
5908 (define_insn "*sltgt_1"
5909 [(set (match_operand:QI 0 "register_operand" "=d")
5910 (ltgt:QI (cc0) (const_int 0)))]
5911 "TARGET_68881 && !TUNE_68060"
5913 cc_status = cc_prev_status;
5917 (define_insn "*fsogt_1"
5918 [(set (match_operand:QI 0 "register_operand" "=d")
5919 (not:QI (unle:QI (cc0) (const_int 0))))]
5920 "TARGET_68881 && !TUNE_68060"
5922 cc_status = cc_prev_status;
5926 (define_insn "*fsoge_1"
5927 [(set (match_operand:QI 0 "register_operand" "=d")
5928 (not:QI (unlt:QI (cc0) (const_int 0))))]
5929 "TARGET_68881 && !TUNE_68060"
5931 cc_status = cc_prev_status;
5935 (define_insn "*fsolt_1"
5936 [(set (match_operand:QI 0 "register_operand" "=d")
5937 (not:QI (unge:QI (cc0) (const_int 0))))]
5938 "TARGET_68881 && !TUNE_68060"
5940 cc_status = cc_prev_status;
5944 (define_insn "*fsole_1"
5945 [(set (match_operand:QI 0 "register_operand" "=d")
5946 (not:QI (ungt:QI (cc0) (const_int 0))))]
5947 "TARGET_68881 && !TUNE_68060"
5949 cc_status = cc_prev_status;
5953 ;; Basic conditional jump instructions.
5955 (define_insn "beq0_di"
5957 (if_then_else (eq (match_operand:DI 0 "general_operand" "d*a,o,<>")
5959 (label_ref (match_operand 1 "" ",,"))
5961 (clobber (match_scratch:SI 2 "=d,&d,d"))]
5965 if (which_alternative == 2)
5966 return "move%.l %0,%2\;or%.l %0,%2\;jeq %l1";
5967 if ((cc_prev_status.value1
5968 && rtx_equal_p (cc_prev_status.value1, operands[0]))
5969 || (cc_prev_status.value2
5970 && rtx_equal_p (cc_prev_status.value2, operands[0])))
5972 cc_status = cc_prev_status;
5975 if (GET_CODE (operands[0]) == REG)
5976 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
5978 operands[3] = adjust_address (operands[0], SImode, 4);
5979 if (! ADDRESS_REG_P (operands[0]))
5981 if (reg_overlap_mentioned_p (operands[2], operands[0]))
5983 if (reg_overlap_mentioned_p (operands[2], operands[3]))
5984 return "or%.l %0,%2\;jeq %l1";
5986 return "or%.l %3,%2\;jeq %l1";
5988 return "move%.l %0,%2\;or%.l %3,%2\;jeq %l1";
5990 operands[4] = gen_label_rtx();
5991 if (TARGET_68020 || TARGET_COLDFIRE)
5992 output_asm_insn ("tst%.l %0\;jne %l4\;tst%.l %3\;jeq %l1", operands);
5994 output_asm_insn ("cmp%.w #0,%0\;jne %l4\;cmp%.w #0,%3\;jeq %l1", operands);
5995 (*targetm.asm_out.internal_label) (asm_out_file, "L",
5996 CODE_LABEL_NUMBER (operands[4]));
6000 (define_insn "bne0_di"
6002 (if_then_else (ne (match_operand:DI 0 "general_operand" "d,o,*a")
6004 (label_ref (match_operand 1 "" ",,"))
6006 (clobber (match_scratch:SI 2 "=d,&d,X"))]
6009 if ((cc_prev_status.value1
6010 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6011 || (cc_prev_status.value2
6012 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6014 cc_status = cc_prev_status;
6018 if (GET_CODE (operands[0]) == REG)
6019 operands[3] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
6021 operands[3] = adjust_address (operands[0], SImode, 4);
6022 if (!ADDRESS_REG_P (operands[0]))
6024 if (reg_overlap_mentioned_p (operands[2], operands[0]))
6026 if (reg_overlap_mentioned_p (operands[2], operands[3]))
6027 return "or%.l %0,%2\;jne %l1";
6029 return "or%.l %3,%2\;jne %l1";
6031 return "move%.l %0,%2\;or%.l %3,%2\;jne %l1";
6033 if (TARGET_68020 || TARGET_COLDFIRE)
6034 return "tst%.l %0\;jne %l1\;tst%.l %3\;jne %l1";
6036 return "cmp%.w #0,%0\;jne %l1\;cmp%.w #0,%3\;jne %l1";
6039 (define_insn "bge0_di"
6041 (if_then_else (ge (match_operand:DI 0 "general_operand" "ro")
6043 (label_ref (match_operand 1 "" ""))
6047 if ((cc_prev_status.value1
6048 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6049 || (cc_prev_status.value2
6050 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6052 cc_status = cc_prev_status;
6053 return cc_status.flags & CC_REVERSED ? "jle %l1" : "jpl %l1";
6056 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6057 output_asm_insn("tst%.l %0", operands);
6060 /* On an address reg, cmpw may replace cmpl. */
6061 output_asm_insn("cmp%.w #0,%0", operands);
6066 (define_insn "blt0_di"
6068 (if_then_else (lt (match_operand:DI 0 "general_operand" "ro")
6070 (label_ref (match_operand 1 "" ""))
6074 if ((cc_prev_status.value1
6075 && rtx_equal_p (cc_prev_status.value1, operands[0]))
6076 || (cc_prev_status.value2
6077 && rtx_equal_p (cc_prev_status.value2, operands[0])))
6079 cc_status = cc_prev_status;
6080 return cc_status.flags & CC_REVERSED ? "jgt %l1" : "jmi %l1";
6083 if (TARGET_68020 || TARGET_COLDFIRE || ! ADDRESS_REG_P (operands[0]))
6084 output_asm_insn("tst%.l %0", operands);
6087 /* On an address reg, cmpw may replace cmpl. */
6088 output_asm_insn("cmp%.w #0,%0", operands);
6095 (if_then_else (eq (cc0)
6097 (label_ref (match_operand 0 "" ""))
6101 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6103 [(set_attr "type" "bcc")])
6107 (if_then_else (ne (cc0)
6109 (label_ref (match_operand 0 "" ""))
6113 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6115 [(set_attr "type" "bcc")])
6119 (if_then_else (gt (cc0)
6121 (label_ref (match_operand 0 "" ""))
6125 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6127 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6131 OUTPUT_JUMP ("jgt %l0", "fjgt %l0", 0);
6133 [(set_attr "type" "bcc")])
6137 (if_then_else (gtu (cc0)
6139 (label_ref (match_operand 0 "" ""))
6143 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6145 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6151 [(set_attr "type" "bcc")])
6155 (if_then_else (lt (cc0)
6157 (label_ref (match_operand 0 "" ""))
6161 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6163 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6167 OUTPUT_JUMP ("jlt %l0", "fjlt %l0", "jmi %l0");
6169 [(set_attr "type" "bcc")])
6173 (if_then_else (ltu (cc0)
6175 (label_ref (match_operand 0 "" ""))
6179 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6181 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6187 [(set_attr "type" "bcc")])
6191 (if_then_else (ge (cc0)
6193 (label_ref (match_operand 0 "" ""))
6197 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6199 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6203 OUTPUT_JUMP ("jge %l0", "fjge %l0", "jpl %l0");
6208 (if_then_else (geu (cc0)
6210 (label_ref (match_operand 0 "" ""))
6214 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6216 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6222 [(set_attr "type" "bcc")])
6226 (if_then_else (le (cc0)
6228 (label_ref (match_operand 0 "" ""))
6232 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6234 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6238 OUTPUT_JUMP ("jle %l0", "fjle %l0", 0);
6240 [(set_attr "type" "bcc")])
6244 (if_then_else (leu (cc0)
6246 (label_ref (match_operand 0 "" ""))
6250 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6252 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6258 [(set_attr "type" "bcc")])
6260 (define_insn "bordered"
6262 (if_then_else (ordered (cc0) (const_int 0))
6263 (label_ref (match_operand 0 "" ""))
6267 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6270 [(set_attr "type" "fbcc")])
6272 (define_insn "bunordered"
6274 (if_then_else (unordered (cc0) (const_int 0))
6275 (label_ref (match_operand 0 "" ""))
6279 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6282 [(set_attr "type" "fbcc")])
6284 (define_insn "buneq"
6286 (if_then_else (uneq (cc0) (const_int 0))
6287 (label_ref (match_operand 0 "" ""))
6291 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6294 [(set_attr "type" "fbcc")])
6296 (define_insn "bunge"
6298 (if_then_else (unge (cc0) (const_int 0))
6299 (label_ref (match_operand 0 "" ""))
6303 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6306 [(set_attr "type" "fbcc")])
6308 (define_insn "bungt"
6310 (if_then_else (ungt (cc0) (const_int 0))
6311 (label_ref (match_operand 0 "" ""))
6315 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6318 [(set_attr "type" "fbcc")])
6320 (define_insn "bunle"
6322 (if_then_else (unle (cc0) (const_int 0))
6323 (label_ref (match_operand 0 "" ""))
6327 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6330 [(set_attr "type" "fbcc")])
6332 (define_insn "bunlt"
6334 (if_then_else (unlt (cc0) (const_int 0))
6335 (label_ref (match_operand 0 "" ""))
6339 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6342 [(set_attr "type" "fbcc")])
6344 (define_insn "bltgt"
6346 (if_then_else (ltgt (cc0) (const_int 0))
6347 (label_ref (match_operand 0 "" ""))
6351 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6354 [(set_attr "type" "fbcc")])
6356 ;; Negated conditional jump instructions.
6358 (define_insn "*beq_rev"
6360 (if_then_else (eq (cc0)
6363 (label_ref (match_operand 0 "" ""))))]
6366 OUTPUT_JUMP ("jne %l0", "fjne %l0", "jne %l0");
6368 [(set_attr "type" "bcc")])
6370 (define_insn "*bne_rev"
6372 (if_then_else (ne (cc0)
6375 (label_ref (match_operand 0 "" ""))))]
6378 OUTPUT_JUMP ("jeq %l0", "fjeq %l0", "jeq %l0");
6380 [(set_attr "type" "bcc")])
6382 (define_insn "*bgt_rev"
6384 (if_then_else (gt (cc0)
6387 (label_ref (match_operand 0 "" ""))))]
6390 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6392 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6396 OUTPUT_JUMP ("jle %l0", "fjngt %l0", 0);
6398 [(set_attr "type" "bcc")])
6400 (define_insn "*bgtu_rev"
6402 (if_then_else (gtu (cc0)
6405 (label_ref (match_operand 0 "" ""))))]
6408 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6410 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6416 [(set_attr "type" "bcc")])
6418 (define_insn "*blt_rev"
6420 (if_then_else (lt (cc0)
6423 (label_ref (match_operand 0 "" ""))))]
6426 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6428 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6432 OUTPUT_JUMP ("jge %l0", "fjnlt %l0", "jpl %l0");
6434 [(set_attr "type" "bcc")])
6436 (define_insn "*bltu_rev"
6438 (if_then_else (ltu (cc0)
6441 (label_ref (match_operand 0 "" ""))))]
6444 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6446 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6452 [(set_attr "type" "bcc")])
6454 (define_insn "*bge_rev"
6456 (if_then_else (ge (cc0)
6459 (label_ref (match_operand 0 "" ""))))]
6462 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6464 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6468 OUTPUT_JUMP ("jlt %l0", "fjnge %l0", "jmi %l0");
6470 [(set_attr "type" "bcc")])
6472 (define_insn "*bgeu_rev"
6474 (if_then_else (geu (cc0)
6477 (label_ref (match_operand 0 "" ""))))]
6480 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6482 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6488 [(set_attr "type" "bcc")])
6490 (define_insn "*ble_rev"
6492 (if_then_else (le (cc0)
6495 (label_ref (match_operand 0 "" ""))))]
6498 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6500 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6504 OUTPUT_JUMP ("jgt %l0", "fjnle %l0", 0);
6506 [(set_attr "type" "bcc")])
6508 (define_insn "*bleu_rev"
6510 (if_then_else (leu (cc0)
6513 (label_ref (match_operand 0 "" ""))))]
6516 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0)
6518 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
6524 [(set_attr "type" "bcc")])
6526 (define_insn "*bordered_rev"
6528 (if_then_else (ordered (cc0) (const_int 0))
6530 (label_ref (match_operand 0 "" ""))))]
6533 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6536 [(set_attr "type" "fbcc")])
6538 (define_insn "*bunordered_rev"
6540 (if_then_else (unordered (cc0) (const_int 0))
6542 (label_ref (match_operand 0 "" ""))))]
6545 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6548 [(set_attr "type" "fbcc")])
6550 (define_insn "*buneq_rev"
6552 (if_then_else (uneq (cc0) (const_int 0))
6554 (label_ref (match_operand 0 "" ""))))]
6557 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6560 [(set_attr "type" "fbcc")])
6562 (define_insn "*bunge_rev"
6564 (if_then_else (unge (cc0) (const_int 0))
6566 (label_ref (match_operand 0 "" ""))))]
6569 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6572 [(set_attr "type" "fbcc")])
6574 (define_insn "*bungt_rev"
6576 (if_then_else (ungt (cc0) (const_int 0))
6578 (label_ref (match_operand 0 "" ""))))]
6581 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6584 [(set_attr "type" "fbcc")])
6586 (define_insn "*bunle_rev"
6588 (if_then_else (unle (cc0) (const_int 0))
6590 (label_ref (match_operand 0 "" ""))))]
6593 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6596 [(set_attr "type" "fbcc")])
6598 (define_insn "*bunlt_rev"
6600 (if_then_else (unlt (cc0) (const_int 0))
6602 (label_ref (match_operand 0 "" ""))))]
6605 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6608 [(set_attr "type" "fbcc")])
6610 (define_insn "*bltgt_rev"
6612 (if_then_else (ltgt (cc0) (const_int 0))
6614 (label_ref (match_operand 0 "" ""))))]
6617 gcc_assert (cc_prev_status.flags & CC_IN_68881);
6620 [(set_attr "type" "fbcc")])
6622 ;; Unconditional and other jump instructions
6625 (label_ref (match_operand 0 "" "")))]
6628 [(set_attr "type" "bra")])
6630 (define_expand "tablejump"
6631 [(parallel [(set (pc) (match_operand 0 "" ""))
6632 (use (label_ref (match_operand 1 "" "")))])]
6635 #if CASE_VECTOR_PC_RELATIVE
6636 operands[0] = gen_rtx_PLUS (SImode, pc_rtx,
6637 gen_rtx_SIGN_EXTEND (SImode, operands[0]));
6641 ;; Jump to variable address from dispatch table of absolute addresses.
6642 (define_insn "*tablejump_internal"
6643 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
6644 (use (label_ref (match_operand 1 "" "")))]
6647 return MOTOROLA ? "jmp (%0)" : "jmp %0@";
6649 [(set_attr "type" "jmp")])
6651 ;; Jump to variable address from dispatch table of relative addresses.
6655 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
6656 (use (label_ref (match_operand 1 "" "")))]
6659 #ifdef ASM_RETURN_CASE_JUMP
6660 ASM_RETURN_CASE_JUMP;
6662 if (TARGET_COLDFIRE)
6664 if (ADDRESS_REG_P (operands[0]))
6665 return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
6667 return "ext%.l %0\;jmp (2,pc,%0.l)";
6669 return "extl %0\;jmp pc@(2,%0:l)";
6672 return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
6676 ;; Decrement-and-branch insns.
6677 (define_insn "*dbne_hi"
6680 (ne (match_operand:HI 0 "nonimmediate_operand" "+d*g")
6682 (label_ref (match_operand 1 "" ""))
6685 (plus:HI (match_dup 0)
6690 if (DATA_REG_P (operands[0]))
6691 return "dbra %0,%l1";
6692 if (GET_CODE (operands[0]) == MEM)
6693 return "subq%.w #1,%0\;jcc %l1";
6694 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6697 (define_insn "*dbne_si"
6700 (ne (match_operand:SI 0 "nonimmediate_operand" "+d*g")
6702 (label_ref (match_operand 1 "" ""))
6705 (plus:SI (match_dup 0)
6710 if (DATA_REG_P (operands[0]))
6711 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6712 if (GET_CODE (operands[0]) == MEM)
6713 return "subq%.l #1,%0\;jcc %l1";
6714 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6717 ;; Two dbra patterns that use REG_NOTES info generated by strength_reduce.
6719 (define_insn "*dbge_hi"
6722 (ge (plus:HI (match_operand:HI 0 "nonimmediate_operand" "+d*am")
6725 (label_ref (match_operand 1 "" ""))
6728 (plus:HI (match_dup 0)
6730 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6733 if (DATA_REG_P (operands[0]))
6734 return "dbra %0,%l1";
6735 if (GET_CODE (operands[0]) == MEM)
6736 return "subq%.w #1,%0\;jcc %l1";
6737 return "subq%.w #1,%0\;cmp%.w #-1,%0\;jne %l1";
6740 (define_expand "decrement_and_branch_until_zero"
6741 [(parallel [(set (pc)
6743 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "")
6746 (label_ref (match_operand 1 "" ""))
6749 (plus:SI (match_dup 0)
6754 (define_insn "*dbge_si"
6757 (ge (plus:SI (match_operand:SI 0 "nonimmediate_operand" "+d*am")
6760 (label_ref (match_operand 1 "" ""))
6763 (plus:SI (match_dup 0)
6765 "!TARGET_COLDFIRE && find_reg_note (insn, REG_NONNEG, 0)"
6768 if (DATA_REG_P (operands[0]))
6769 return "dbra %0,%l1\;clr%.w %0\;subq%.l #1,%0\;jcc %l1";
6770 if (GET_CODE (operands[0]) == MEM)
6771 return "subq%.l #1,%0\;jcc %l1";
6772 return "subq%.l #1,%0\;cmp%.l #-1,%0\;jne %l1";
6775 (define_expand "sibcall"
6776 [(call (match_operand:QI 0 "memory_operand" "")
6777 (match_operand:SI 1 "general_operand" ""))]
6780 operands[0] = m68k_legitimize_sibcall_address (operands[0]);
6783 (define_insn "*sibcall"
6784 [(call (mem:QI (match_operand:SI 0 "sibcall_operand" ""))
6785 (match_operand:SI 1 "general_operand" ""))]
6786 "SIBLING_CALL_P (insn)"
6788 return output_sibcall (operands[0]);
6791 (define_expand "sibcall_value"
6792 [(set (match_operand 0 "" "")
6793 (call (match_operand:QI 1 "memory_operand" "")
6794 (match_operand:SI 2 "general_operand" "")))]
6797 operands[1] = m68k_legitimize_sibcall_address (operands[1]);
6800 (define_insn "*sibcall_value"
6801 [(set (match_operand 0 "" "=rf,rf")
6802 (call (mem:QI (match_operand:SI 1 "sibcall_operand" ""))
6803 (match_operand:SI 2 "general_operand" "")))]
6804 "SIBLING_CALL_P (insn)"
6806 operands[0] = operands[1];
6807 return output_sibcall (operands[0]);
6810 ;; Call subroutine with no return value.
6811 (define_expand "call"
6812 [(call (match_operand:QI 0 "memory_operand" "")
6813 (match_operand:SI 1 "general_operand" ""))]
6814 ;; Operand 1 not really used on the m68000.
6817 operands[0] = m68k_legitimize_call_address (operands[0]);
6820 (define_insn "*call"
6821 [(call (mem:QI (match_operand:SI 0 "call_operand" "a,W"))
6822 (match_operand:SI 1 "general_operand" "g,g"))]
6823 ;; Operand 1 not really used on the m68000.
6824 "!SIBLING_CALL_P (insn)"
6826 return output_call (operands[0]);
6828 [(set_attr "type" "jsr")])
6830 ;; Call subroutine, returning value in operand 0
6831 ;; (which must be a hard register).
6832 (define_expand "call_value"
6833 [(set (match_operand 0 "" "")
6834 (call (match_operand:QI 1 "memory_operand" "")
6835 (match_operand:SI 2 "general_operand" "")))]
6836 ;; Operand 2 not really used on the m68000.
6839 operands[1] = m68k_legitimize_call_address (operands[1]);
6842 (define_insn "*non_symbolic_call_value"
6843 [(set (match_operand 0 "" "=rf,rf")
6844 (call (mem:QI (match_operand:SI 1 "non_symbolic_call_operand" "a,W"))
6845 (match_operand:SI 2 "general_operand" "g,g")))]
6846 ;; Operand 2 not really used on the m68000.
6847 "!SIBLING_CALL_P (insn)"
6849 [(set_attr "type" "jsr")
6850 (set_attr "opx" "1")])
6852 (define_insn "*symbolic_call_value_jsr"
6853 [(set (match_operand 0 "" "=rf,rf")
6854 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6855 (match_operand:SI 2 "general_operand" "g,g")))]
6856 ;; Operand 2 not really used on the m68000.
6857 "!SIBLING_CALL_P (insn) && m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_JSR"
6859 operands[0] = operands[1];
6860 return m68k_symbolic_call;
6862 [(set_attr "type" "jsr")
6863 (set_attr "opx" "1")])
6865 (define_insn "*symbolic_call_value_bsr"
6866 [(set (match_operand 0 "" "=rf,rf")
6867 (call (mem:QI (match_operand:SI 1 "symbolic_operand" "a,W"))
6868 (match_operand:SI 2 "general_operand" "g,g")))]
6869 ;; Operand 2 not really used on the m68000.
6870 "!SIBLING_CALL_P (insn)
6871 && (m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_C
6872 || m68k_symbolic_call_var == M68K_SYMBOLIC_CALL_BSR_P)"
6874 operands[0] = operands[1];
6875 return m68k_symbolic_call;
6877 [(set_attr "type" "bsr")
6878 (set_attr "opx" "1")])
6880 ;; Call subroutine returning any type.
6882 (define_expand "untyped_call"
6883 [(parallel [(call (match_operand 0 "" "")
6885 (match_operand 1 "" "")
6886 (match_operand 2 "" "")])]
6887 "NEEDS_UNTYPED_CALL"
6891 emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
6893 for (i = 0; i < XVECLEN (operands[2], 0); i++)
6895 rtx set = XVECEXP (operands[2], 0, i);
6896 emit_move_insn (SET_DEST (set), SET_SRC (set));
6899 /* The optimizer does not know that the call sets the function value
6900 registers we stored in the result block. We avoid problems by
6901 claiming that all hard registers are used and clobbered at this
6903 emit_insn (gen_blockage ());
6908 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
6909 ;; all of memory. This blocks insns from being moved across this point.
6911 (define_insn "blockage"
6912 [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6920 [(set_attr "type" "nop")])
6922 (define_expand "prologue"
6926 m68k_expand_prologue ();
6930 (define_expand "epilogue"
6934 m68k_expand_epilogue (false);
6938 (define_expand "sibcall_epilogue"
6942 m68k_expand_epilogue (true);
6946 ;; Used for frameless functions which save no regs and allocate no locals.
6947 (define_expand "return"
6949 "m68k_use_return_insn ()"
6952 (define_insn "*return"
6956 switch (m68k_get_function_kind (current_function_decl))
6958 case m68k_fk_interrupt_handler:
6961 case m68k_fk_interrupt_thread:
6965 if (crtl->args.pops_args)
6967 operands[0] = GEN_INT (crtl->args.pops_args);
6974 [(set_attr "type" "rts")])
6976 (define_insn "*m68k_store_multiple"
6977 [(match_parallel 0 "" [(match_operand 1 "")])]
6978 "m68k_movem_pattern_p (operands[0], NULL, 0, true)"
6980 return m68k_output_movem (operands, operands[0], 0, true);
6983 (define_insn "*m68k_store_multiple_automod"
6984 [(match_parallel 0 ""
6985 [(set (match_operand:SI 1 "register_operand" "=a")
6986 (plus:SI (match_operand:SI 2 "register_operand" "1")
6987 (match_operand:SI 3 "const_int_operand")))])]
6988 "m68k_movem_pattern_p (operands[0], operands[1], INTVAL (operands[3]), true)"
6990 return m68k_output_movem (operands, operands[0], INTVAL (operands[3]), true);
6993 (define_insn "*m68k_load_multiple"
6994 [(match_parallel 0 "" [(match_operand 1 "")])]
6995 "m68k_movem_pattern_p (operands[0], NULL, 0, false)"
6997 return m68k_output_movem (operands, operands[0], 0, false);
7000 (define_insn "*m68k_load_multiple_automod"
7001 [(match_parallel 0 ""
7002 [(set (match_operand:SI 1 "register_operand" "=a")
7003 (plus:SI (match_operand:SI 2 "register_operand" "1")
7004 (match_operand:SI 3 "const_int_operand")))])]
7005 "m68k_movem_pattern_p (operands[0], operands[1],
7006 INTVAL (operands[3]), false)"
7008 return m68k_output_movem (operands, operands[0],
7009 INTVAL (operands[3]), false);
7012 (define_expand "link"
7014 [(set (match_operand:SI 0 "register_operand")
7015 (plus:SI (reg:SI SP_REG) (const_int -4)))
7018 (set (reg:SI SP_REG)
7019 (plus:SI (reg:SI SP_REG)
7020 (match_operand:SI 1 "const_int_operand")))])]
7021 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7023 operands[2] = gen_frame_mem (SImode,
7024 plus_constant (Pmode, stack_pointer_rtx, -4));
7027 (define_insn "*link"
7028 [(set (match_operand:SI 0 "register_operand" "+r")
7029 (plus:SI (reg:SI SP_REG) (const_int -4)))
7030 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
7032 (set (reg:SI SP_REG)
7033 (plus:SI (reg:SI SP_REG)
7034 (match_operand:SI 1 "const_int_operand")))]
7035 "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
7037 operands[1] = GEN_INT (INTVAL (operands[1]) + 4);
7039 return "link %0,%1";
7040 else if (INTVAL (operands[1]) >= -0x8000)
7041 return "link.w %0,%1";
7043 return "link.l %0,%1";
7045 [(set_attr "type" "link")])
7047 (define_expand "unlink"
7049 [(set (match_operand:SI 0 "register_operand")
7051 (set (reg:SI SP_REG)
7052 (plus:SI (match_dup 0)
7056 operands[1] = gen_frame_mem (SImode, copy_rtx (operands[0]));
7059 (define_insn "*unlink"
7060 [(set (match_operand:SI 0 "register_operand" "+r")
7061 (mem:SI (match_dup 0)))
7062 (set (reg:SI SP_REG)
7063 (plus:SI (match_dup 0)
7067 [(set_attr "type" "unlk")])
7069 (define_insn "load_got"
7070 [(set (match_operand:SI 0 "register_operand" "=a")
7071 (unspec:SI [(const_int 0)] UNSPEC_GOT))]
7074 if (TARGET_ID_SHARED_LIBRARY)
7076 operands[1] = gen_rtx_REG (Pmode, PIC_REG);
7077 return MOTOROLA ? "move.l %?(%1),%0" : "movel %1@(%?), %0";
7081 if (TARGET_COLDFIRE)
7082 /* Load the full 32-bit PC-relative offset of
7083 _GLOBAL_OFFSET_TABLE_ into the PIC register, then use it to
7084 calculate the absolute value. The offset and "lea"
7085 operation word together occupy 6 bytes. */
7086 return ("move.l #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t"
7087 "lea (-6, %%pc, %0), %0");
7089 return "lea (%%pc, _GLOBAL_OFFSET_TABLE_@GOTPC), %0";
7092 return ("movel #_GLOBAL_OFFSET_TABLE_, %0\n\t"
7093 "lea %%pc@(0,%0:l),%0");
7096 (define_insn "indirect_jump"
7097 [(set (pc) (match_operand:SI 0 "address_operand" "p"))]
7100 [(set_attr "type" "jmp")])
7102 ;; This should not be used unless the add/sub insns can't be.
7105 [(set (match_operand:SI 0 "nonimmediate_operand" "=a")
7106 (match_operand:QI 1 "address_operand" "p"))]
7110 ;; This is the first machine-dependent peephole optimization.
7111 ;; It is useful when a floating value is returned from a function call
7112 ;; and then is moved into an FP register.
7113 ;; But it is mainly intended to test the support for these optimizations.
7116 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7117 (set (match_operand:DF 0 "register_operand" "")
7118 (match_operand:DF 1 "register_operand" ""))]
7119 "FP_REG_P (operands[0]) && !FP_REG_P (operands[1])"
7120 [(set (mem:SI (reg:SI SP_REG)) (match_dup 1))
7121 (set (mem:SI (pre_dec:SI (reg:SI SP_REG))) (match_dup 2))
7122 (set (match_dup 0) (mem:DF (post_inc:SI (reg:SI SP_REG))))]
7123 "split_di(operands + 1, 1, operands + 1, operands + 2);")
7125 ;; Optimize a stack-adjust followed by a push of an argument.
7126 ;; This is said to happen frequently with -msoft-float
7127 ;; when there are consecutive library calls.
7130 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7131 (set (match_operand:SF 0 "push_operand" "")
7132 (match_operand:SF 1 "general_operand" ""))]
7133 "!reg_mentioned_p (stack_pointer_rtx, operands[0])"
7134 [(set (match_dup 0) (match_dup 1))]
7135 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7138 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7139 (match_operand:SI 0 "const_int_operand" "")))
7140 (set (match_operand:SF 1 "push_operand" "")
7141 (match_operand:SF 2 "general_operand" ""))]
7142 "INTVAL (operands[0]) > 4
7143 && !reg_mentioned_p (stack_pointer_rtx, operands[2])"
7144 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7145 (set (match_dup 1) (match_dup 2))]
7147 operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7148 operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7151 ;; Speed up stack adjust followed by a fullword fixedpoint push.
7152 ;; Constant operands need special care, as replacing a "pea X.w" with
7153 ;; "move.l #X,(%sp)" is often not a win.
7155 ;; Already done by the previous csa pass, left as reference.
7157 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 4)))
7158 (set (match_operand:SI 0 "push_operand" "")
7159 (match_operand:SI 1 "general_operand" ""))]
7160 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7161 [(set (match_dup 0) (match_dup 1))]
7162 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7164 ;; Try to use moveq, after stack push has been changed into a simple move.
7166 [(match_scratch:SI 2 "d")
7167 (set (match_operand:SI 0 "memory_operand" "")
7168 (match_operand:SI 1 "const_int_operand" ""))]
7169 "GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
7170 && INTVAL (operands[1]) != 0
7171 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7172 && !valid_mov3q_const (INTVAL (operands[1]))"
7173 [(set (match_dup 2) (match_dup 1))
7174 (set (match_dup 0) (match_dup 2))])
7176 ;; This sequence adds an instruction, but is two bytes shorter.
7178 [(match_scratch:SI 2 "d")
7179 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 12)))
7180 (set (match_operand:SI 0 "push_operand" "")
7181 (match_operand:SI 1 "const_int_operand" ""))]
7182 "INTVAL (operands[1]) != 0
7183 && IN_RANGE (INTVAL (operands[1]), -0x80, 0x7f)
7184 && !valid_mov3q_const (INTVAL (operands[1]))"
7185 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int 8)))
7186 (set (match_dup 2) (match_dup 1))
7187 (set (match_dup 0) (match_dup 2))]
7188 "operands[0] = replace_equiv_address (operands[0], stack_pointer_rtx);")
7190 ;; Changing pea X.w into a move.l is no real win here.
7192 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG)
7193 (match_operand:SI 0 "const_int_operand" "")))
7194 (set (match_operand:SI 1 "push_operand" "")
7195 (match_operand:SI 2 "general_operand" ""))]
7196 "INTVAL (operands[0]) > 4
7197 && !reg_mentioned_p (stack_pointer_rtx, operands[2])
7198 && !(CONST_INT_P (operands[2]) && INTVAL (operands[2]) != 0
7199 && IN_RANGE (INTVAL (operands[2]), -0x8000, 0x7fff)
7200 && !valid_mov3q_const (INTVAL (operands[2])))"
7201 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_dup 0)))
7202 (set (match_dup 1) (match_dup 2))]
7204 operands[0] = GEN_INT (INTVAL (operands[0]) - 4);
7205 operands[1] = replace_equiv_address (operands[1], stack_pointer_rtx);
7208 ;; Speed up pushing a single byte/two bytes but leaving four bytes of space
7209 ;; (which differs slightly between m680x0 and ColdFire).
7212 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -4)))
7213 (set (match_operand:QI 0 "memory_operand" "")
7214 (match_operand:QI 1 "register_operand" ""))]
7215 "!reg_mentioned_p (stack_pointer_rtx, operands[1])
7216 && GET_CODE (XEXP (operands[0], 0)) == PLUS
7217 && rtx_equal_p (XEXP (XEXP (operands[0], 0), 0), stack_pointer_rtx)
7218 && CONST_INT_P (XEXP (XEXP (operands[0], 0), 1))
7219 && INTVAL (XEXP (XEXP (operands[0], 0), 1)) == 3"
7220 [(set (match_dup 0) (match_dup 1))]
7222 rtx addr = gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx);
7223 operands[0] = adjust_automodify_address (operands[0], SImode, addr, -3);
7224 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7228 [(set (match_operand:QI 0 "push_operand" "")
7229 (match_operand:QI 1 "register_operand" ""))
7230 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -3)))]
7231 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7232 [(set (match_dup 0) (match_dup 1))]
7234 operands[0] = adjust_automodify_address (operands[0], SImode,
7235 XEXP (operands[0], 0), -3);
7236 operands[1] = simplify_gen_subreg (SImode, operands[1], QImode, 0);
7240 [(set (match_operand:HI 0 "push_operand" "")
7241 (match_operand:HI 1 "register_operand" ""))
7242 (set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (const_int -2)))]
7243 "!reg_mentioned_p (stack_pointer_rtx, operands[1])"
7244 [(set (match_dup 0) (match_dup 1))]
7246 operands[0] = adjust_automodify_address (operands[0], SImode,
7247 XEXP (operands[0], 0), -2);
7248 operands[1] = simplify_gen_subreg (SImode, operands[1], HImode, 0);
7251 ;; Optimize a series of strict_low_part assignments
7254 [(set (match_operand:SI 0 "register_operand" "")
7256 (set (strict_low_part (match_operand:HI 1 "register_operand" ""))
7257 (match_operand:HI 2 "general_operand" ""))]
7258 "REGNO (operands[0]) == REGNO (operands[1])
7259 && strict_low_part_peephole_ok (HImode, insn, operands[0])"
7260 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7264 [(set (match_operand:SI 0 "register_operand" "")
7266 (set (strict_low_part (match_operand:QI 1 "register_operand" ""))
7267 (match_operand:QI 2 "general_operand" ""))]
7268 "REGNO (operands[0]) == REGNO (operands[1])
7269 && strict_low_part_peephole_ok (QImode, insn, operands[0])"
7270 [(set (strict_low_part (match_dup 1)) (match_dup 2))]
7278 ;; jCC label ; abnormal loop termination
7279 ;; dbra dN, loop ; normal loop termination
7287 ;; Which moves the jCC condition outside the inner loop for free.
7291 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7292 [(cc0) (const_int 0)])
7293 (label_ref (match_operand 2 "" ""))
7298 (ne (match_operand:HI 0 "register_operand" "")
7300 (label_ref (match_operand 1 "" ""))
7303 (plus:HI (match_dup 0)
7305 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7308 output_dbcc_and_branch (operands);
7313 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7314 [(cc0) (const_int 0)])
7315 (label_ref (match_operand 2 "" ""))
7320 (ne (match_operand:SI 0 "register_operand" "")
7322 (label_ref (match_operand 1 "" ""))
7325 (plus:SI (match_dup 0)
7327 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7330 output_dbcc_and_branch (operands);
7335 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7336 [(cc0) (const_int 0)])
7337 (label_ref (match_operand 2 "" ""))
7342 (ge (plus:HI (match_operand:HI 0 "register_operand" "")
7345 (label_ref (match_operand 1 "" ""))
7348 (plus:HI (match_dup 0)
7350 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7353 output_dbcc_and_branch (operands);
7358 [(set (pc) (if_then_else (match_operator 3 "valid_dbcc_comparison_p"
7359 [(cc0) (const_int 0)])
7360 (label_ref (match_operand 2 "" ""))
7365 (ge (plus:SI (match_operand:SI 0 "register_operand" "")
7368 (label_ref (match_operand 1 "" ""))
7371 (plus:SI (match_dup 0)
7373 "!TARGET_COLDFIRE && DATA_REG_P (operands[0]) && ! flags_in_68881 ()"
7376 output_dbcc_and_branch (operands);
7381 (define_insn "extendsfxf2"
7382 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7383 (float_extend:XF (match_operand:SF 1 "general_operand" "f,rmF")))]
7386 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7388 if (REGNO (operands[0]) == REGNO (operands[1]))
7390 /* Extending float to double in an fp-reg is a no-op.
7391 NOTICE_UPDATE_CC has already assumed that the
7392 cc will be set. So cancel what it did. */
7393 cc_status = cc_prev_status;
7396 return "f%$move%.x %1,%0";
7398 if (FP_REG_P (operands[0]))
7400 if (FP_REG_P (operands[1]))
7401 return "f%$move%.x %1,%0";
7402 else if (ADDRESS_REG_P (operands[1]))
7403 return "move%.l %1,%-\;f%$move%.s %+,%0";
7404 else if (GET_CODE (operands[1]) == CONST_DOUBLE)
7405 return output_move_const_single (operands);
7406 return "f%$move%.s %f1,%0";
7408 return "fmove%.x %f1,%0";
7412 (define_insn "extenddfxf2"
7413 [(set (match_operand:XF 0 "nonimmediate_operand" "=fm,f")
7415 (match_operand:DF 1 "general_operand" "f,rmE")))]
7418 if (FP_REG_P (operands[0]) && FP_REG_P (operands[1]))
7420 if (REGNO (operands[0]) == REGNO (operands[1]))
7422 /* Extending float to double in an fp-reg is a no-op.
7423 NOTICE_UPDATE_CC has already assumed that the
7424 cc will be set. So cancel what it did. */
7425 cc_status = cc_prev_status;
7428 return "fmove%.x %1,%0";
7430 if (FP_REG_P (operands[0]))
7432 if (REG_P (operands[1]))
7435 xoperands[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
7436 output_asm_insn ("move%.l %1,%-", xoperands);
7437 output_asm_insn ("move%.l %1,%-", operands);
7438 return "f%&move%.d %+,%0";
7440 if (GET_CODE (operands[1]) == CONST_DOUBLE)
7441 return output_move_const_double (operands);
7442 return "f%&move%.d %f1,%0";
7444 return "fmove%.x %f1,%0";
7447 (define_insn "truncxfdf2"
7448 [(set (match_operand:DF 0 "nonimmediate_operand" "=m,!r")
7450 (match_operand:XF 1 "general_operand" "f,f")))]
7453 if (REG_P (operands[0]))
7455 output_asm_insn ("fmove%.d %f1,%-\;move%.l %+,%0", operands);
7456 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
7457 return "move%.l %+,%0";
7459 return "fmove%.d %f1,%0";
7462 (define_insn "truncxfsf2"
7463 [(set (match_operand:SF 0 "nonimmediate_operand" "=dm")
7465 (match_operand:XF 1 "general_operand" "f")))]
7469 (define_insn "sin<mode>2"
7470 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7472 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_SIN))]
7473 "TARGET_68881 && flag_unsafe_math_optimizations"
7475 if (FP_REG_P (operands[1]))
7476 return "fsin%.x %1,%0";
7478 return "fsin%.<FP:prec> %1,%0";
7481 (define_insn "cos<mode>2"
7482 [(set (match_operand:FP 0 "nonimmediate_operand" "=f")
7484 [(match_operand:FP 1 "general_operand" "f<FP:dreg>m")] UNSPEC_COS))]
7485 "TARGET_68881 && flag_unsafe_math_optimizations"
7487 if (FP_REG_P (operands[1]))
7488 return "fcos%.x %1,%0";
7490 return "fcos%.<FP:prec> %1,%0";
7493 ;; Unconditional traps are assumed to have (const_int 1) for the condition.
7495 [(trap_if (const_int 1) (const_int 7))]
7498 [(set_attr "type" "trap")])
7500 (define_expand "ctrapdi4"
7501 [(trap_if (match_operator 0 "ordered_comparison_operator"
7502 [(cc0) (const_int 0)])
7503 (match_operand:SI 3 "const1_operand" ""))]
7506 if (operands[2] == const0_rtx)
7507 emit_insn (gen_tstdi (operands[1]));
7509 emit_insn (gen_cmpdi (operands[1], operands[2]));
7510 operands[1] = cc0_rtx;
7511 operands[2] = const0_rtx;
7514 (define_expand "ctrapsi4"
7516 (compare (match_operand:SI 1 "nonimmediate_operand" "")
7517 (match_operand:SI 2 "general_operand" "")))
7518 (trap_if (match_operator 0 "ordered_comparison_operator"
7519 [(cc0) (const_int 0)])
7520 (match_operand:SI 3 "const1_operand" ""))]
7524 (define_expand "ctraphi4"
7526 (compare (match_operand:HI 1 "nonimmediate_src_operand" "")
7527 (match_operand:HI 2 "general_src_operand" "")))
7528 (trap_if (match_operator 0 "ordered_comparison_operator"
7529 [(cc0) (const_int 0)])
7530 (match_operand:SI 3 "const1_operand" ""))]
7534 (define_expand "ctrapqi4"
7536 (compare (match_operand:QI 1 "nonimmediate_src_operand" "")
7537 (match_operand:QI 2 "general_src_operand" "")))
7538 (trap_if (match_operator 0 "ordered_comparison_operator"
7539 [(cc0) (const_int 0)])
7540 (match_operand:SI 3 "const1_operand" ""))]
7544 (define_insn "*conditional_trap"
7545 [(trap_if (match_operator 0 "ordered_comparison_operator"
7546 [(cc0) (const_int 0)])
7547 (match_operand:SI 1 "const1_operand" "I"))]
7548 "TARGET_68020 && ! flags_in_68881 ()"
7550 switch (GET_CODE (operands[0]))
7552 case EQ: return "trapeq";
7553 case NE: return "trapne";
7554 case GT: return "trapgt";
7555 case GTU: return "traphi";
7556 case LT: return "traplt";
7557 case LTU: return "trapcs";
7558 case GE: return "trapge";
7559 case GEU: return "trapcc";
7560 case LE: return "traple";
7561 case LEU: return "trapls";
7562 default: gcc_unreachable ();
7566 ;; These are to prevent the scheduler from moving stores to the frame
7567 ;; before the stack adjustment.
7568 (define_insn "stack_tie"
7569 [(set (mem:BLK (scratch))
7570 (unspec:BLK [(match_operand:SI 0 "register_operand" "r")
7571 (match_operand:SI 1 "register_operand" "r")]
7575 [(set_attr "type" "ignore")])
7577 ;; Instruction that subscribes one word in ColdFire instruction buffer.
7578 ;; This instruction is used within scheduler only and should not appear
7579 ;; in the instruction stream.
7581 [(unspec [(const_int 0)] UNSPEC_IB)]
7584 [(set_attr "type" "ib")])