1 ;; GCC machine description for Matsushita MN10300
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by Jeff Law (law@cygnus.com).
6 ;; This file is part of GCC.
8 ;; GCC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; GCC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
23 ;; The original PO technology requires these to be ordered by speed,
24 ;; so that assigner will pick the fastest.
26 ;; See file "rtl.def" for documentation on define_insn, match_*, et. al.
28 ;; Condition code settings.
29 ;; none - insn does not affect cc
30 ;; none_0hit - insn does not affect cc but it does modify operand 0
31 ;; This attribute is used to keep track of when operand 0 changes.
32 ;; See the description of NOTICE_UPDATE_CC for more info.
33 ;; set_znv - insn sets z,n,v to usable values; c is unusable.
34 ;; set_zn - insn sets z,n to usable values; v,c are unusable.
35 ;; compare - compare instruction
36 ;; clobber - value of cc is unknown
37 (define_attr "cc" "none,none_0hit,set_znv,set_zn,compare,clobber"
38 (const_string "clobber"))
51 ;; ----------------------------------------------------------------------
53 ;; ----------------------------------------------------------------------
57 (define_expand "movqi"
58 [(set (match_operand:QI 0 "general_operand" "")
59 (match_operand:QI 1 "general_operand" ""))]
63 /* One of the ops has to be in a register */
64 if (!register_operand (operand0, QImode)
65 && !register_operand (operand1, QImode))
66 operands[1] = copy_to_mode_reg (QImode, operand1);
70 [(set (match_operand:QI 0 "nonimmediate_operand" "=d*x*a*f,d*x,d*x*a,d*x*a,m,*f,d*x*a")
71 (match_operand:QI 1 "general_operand" "0,I,d*xai,m,d*xa,d*xa*f,*f"))]
73 && (register_operand (operands[0], QImode)
74 || register_operand (operands[1], QImode))"
77 switch (which_alternative)
84 if (GET_CODE (operands[1]) == CONST_DOUBLE)
87 xoperands[0] = operands[0];
88 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
89 output_asm_insn (\"mov %1,%0\", xoperands);
93 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS
94 && GET_CODE (operands[1]) == CONST_INT)
96 HOST_WIDE_INT val = INTVAL (operands[1]);
98 if (((val & 0x80) && ! (val & 0xffffff00))
99 || ((val & 0x800000) && ! (val & 0xff000000)))
100 return \"movu %1,%0\";
102 return \"mov %1,%0\";
105 return \"movbu %1,%0\";
108 return \"fmov %1,%0\";
113 [(set_attr "cc" "none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")])
116 [(set (match_operand:QI 0 "nonimmediate_operand" "=d*a,d,d*a,d,m")
117 (match_operand:QI 1 "general_operand" "0,I,dai,m,d"))]
118 "register_operand (operands[0], QImode)
119 || register_operand (operands[1], QImode)"
122 switch (which_alternative)
129 if (GET_CODE (operands[1]) == CONST_DOUBLE)
132 xoperands[0] = operands[0];
133 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
134 output_asm_insn (\"mov %1,%0\", xoperands);
138 return \"mov %1,%0\";
141 return \"movbu %1,%0\";
146 [(set_attr "cc" "none,clobber,none_0hit,none_0hit,none_0hit")])
150 (define_expand "movhi"
151 [(set (match_operand:HI 0 "general_operand" "")
152 (match_operand:HI 1 "general_operand" ""))]
156 /* One of the ops has to be in a register */
157 if (!register_operand (operand1, HImode)
158 && !register_operand (operand0, HImode))
159 operands[1] = copy_to_mode_reg (HImode, operand1);
163 [(set (match_operand:HI 0 "nonimmediate_operand" "=d*x*a*f,d*x,d*x*a,d*x*a,m,*f,d*x*a")
164 (match_operand:HI 1 "general_operand" "0,I,d*x*ai,m,d*x*a,d*x*a*f,*f"))]
166 && (register_operand (operands[0], HImode)
167 || register_operand (operands[1], HImode))"
170 switch (which_alternative)
177 if (GET_CODE (operands[1]) == CONST_DOUBLE)
180 xoperands[0] = operands[0];
181 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
182 output_asm_insn (\"mov %1,%0\", xoperands);
186 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS
187 && GET_CODE (operands[1]) == CONST_INT)
189 HOST_WIDE_INT val = INTVAL (operands[1]);
191 if (((val & 0x80) && ! (val & 0xffffff00))
192 || ((val & 0x800000) && ! (val & 0xff000000)))
193 return \"movu %1,%0\";
195 return \"mov %1,%0\";
198 return \"movhu %1,%0\";
201 return \"fmov %1,%0\";
206 [(set_attr "cc" "none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")])
209 [(set (match_operand:HI 0 "nonimmediate_operand" "=d*a,d,d*a,d,m")
210 (match_operand:HI 1 "general_operand" "0,I,dai,m,d"))]
211 "register_operand (operands[0], HImode)
212 || register_operand (operands[1], HImode)"
215 switch (which_alternative)
222 if (GET_CODE (operands[1]) == CONST_DOUBLE)
225 xoperands[0] = operands[0];
226 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
227 output_asm_insn (\"mov %1,%0\", xoperands);
230 return \"mov %1,%0\";
233 return \"movhu %1,%0\";
238 [(set_attr "cc" "none,clobber,none_0hit,none_0hit,none_0hit")])
242 ;; We use this to handle addition of two values when one operand is the
243 ;; stack pointer and the other is a memory reference of some kind. Reload
244 ;; does not handle them correctly without this expander.
245 (define_expand "reload_insi"
246 [(set (match_operand:SI 0 "register_operand" "=a")
247 (match_operand:SI 1 "impossible_plus_operand" ""))
248 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
252 if (XEXP (operands[1], 0) == stack_pointer_rtx)
254 if (GET_CODE (XEXP (operands[1], 1)) == SUBREG
255 && (GET_MODE_SIZE (GET_MODE (XEXP (operands[1], 1)))
256 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (XEXP (operands[1], 1))))))
257 emit_move_insn (operands[2],
259 (GET_MODE (XEXP (operands[1], 1)),
260 SUBREG_REG (XEXP (operands[1], 1))));
262 emit_move_insn (operands[2], XEXP (operands[1], 1));
263 emit_move_insn (operands[0], XEXP (operands[1], 0));
267 if (GET_CODE (XEXP (operands[1], 0)) == SUBREG
268 && (GET_MODE_SIZE (GET_MODE (XEXP (operands[1], 0)))
269 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (XEXP (operands[1], 0))))))
270 emit_move_insn (operands[2],
272 (GET_MODE (XEXP (operands[1], 0)),
273 SUBREG_REG (XEXP (operands[1], 0))));
275 emit_move_insn (operands[2], XEXP (operands[1], 0));
276 emit_move_insn (operands[0], XEXP (operands[1], 1));
278 emit_insn (gen_addsi3 (operands[0], operands[0], operands[2]));
282 (define_insn "pop_pic_reg"
283 [(set (reg:SI PIC_REG)
284 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
288 (define_expand "movsi"
289 [(set (match_operand:SI 0 "general_operand" "")
290 (match_operand:SI 1 "general_operand" ""))]
294 /* One of the ops has to be in a register */
295 if (!register_operand (operand1, SImode)
296 && !register_operand (operand0, SImode))
297 operands[1] = copy_to_mode_reg (SImode, operand1);
301 if (SYMBOLIC_CONST_P (operands[1]))
303 if (GET_CODE (operands[0]) == MEM)
304 operands[1] = force_reg (Pmode, operands[1]);
307 temp = no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode);
308 operands[1] = legitimize_pic_address (operands[1], temp);
311 else if (GET_CODE (operands[1]) == CONST
312 && GET_CODE (XEXP (operands[1], 0)) == PLUS
313 && SYMBOLIC_CONST_P (XEXP (XEXP (operands[1], 0), 0)))
315 temp = no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode);
316 temp = legitimize_pic_address (XEXP (XEXP (operands[1], 0), 0),
318 operands[1] = expand_binop (SImode, add_optab, temp,
319 XEXP (XEXP (operands[1], 0), 1),
320 no_new_pseudos ? temp
321 : gen_reg_rtx (Pmode),
328 [(set (match_operand:SI 0 "nonimmediate_operand"
329 "=dx,ax,dx,a,dxm,dxm,axm,axm,dx,dx,ax,ax,axR,!*y,*f,*f,dxaQ")
330 (match_operand:SI 1 "general_operand"
331 "0,0,I,I,dx,ax,dx,ax,dixm,aixm,dixm,aixm,!*y,axR,0,dxaQi*f,*f"))]
332 "register_operand (operands[0], SImode)
333 || register_operand (operands[1], SImode)"
336 switch (which_alternative)
354 if (GET_CODE (operands[1]) == CONST_DOUBLE)
357 xoperands[0] = operands[0];
358 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
359 output_asm_insn (\"mov %1,%0\", xoperands);
363 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS
364 && GET_CODE (operands[1]) == CONST_INT)
366 HOST_WIDE_INT val = INTVAL (operands[1]);
368 if (((val & 0x80) && ! (val & 0xffffff00))
369 || ((val & 0x800000) && ! (val & 0xff000000)))
370 return \"movu %1,%0\";
372 return \"mov %1,%0\";
377 return \"fmov %1,%0\";
382 [(set_attr "cc" "none,none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit,none,none_0hit,none_0hit")])
384 (define_expand "movsf"
385 [(set (match_operand:SF 0 "general_operand" "")
386 (match_operand:SF 1 "general_operand" ""))]
390 /* One of the ops has to be in a register */
391 if (!register_operand (operand1, SFmode)
392 && !register_operand (operand0, SFmode))
393 operands[1] = copy_to_mode_reg (SFmode, operand1);
397 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,dx,ax,dx,a,f,dxaQ,daxm,dax")
398 (match_operand:SF 1 "general_operand" "0,0,0,G,G,fdxaQF,f,dax,daxFm"))]
399 "register_operand (operands[0], SFmode)
400 || register_operand (operands[1], SFmode)"
403 switch (which_alternative)
414 return \"fmov %1, %0\";
418 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS
419 && GET_CODE (operands[1]) == CONST_INT)
421 HOST_WIDE_INT val = INTVAL (operands[1]);
423 if (((val & 0x80) && ! (val & 0xffffff00))
424 || ((val & 0x800000) && ! (val & 0xff000000)))
425 return \"movu %1,%0\";
427 return \"mov %1,%0\";
432 [(set_attr "cc" "none,none,none,clobber,none_0hit,none_0hit,none_0hit,none_0hit,none_0hit")])
434 (define_expand "movdi"
435 [(set (match_operand:DI 0 "general_operand" "")
436 (match_operand:DI 1 "general_operand" ""))]
440 /* One of the ops has to be in a register */
441 if (!register_operand (operand1, DImode)
442 && !register_operand (operand0, DImode))
443 operands[1] = copy_to_mode_reg (DImode, operand1);
447 [(set (match_operand:DI 0 "nonimmediate_operand"
448 "=dx,ax,dx,a,dxm,dxm,axm,axm,dx,dx,ax,ax,*f,*f,*f,dxa,*f,Q")
449 (match_operand:DI 1 "general_operand"
450 "0,0,I,I,dx,ax,dx,ax,dxim,axim,dxim,axim,0,*f,dxai,*f,Q,*f"))]
451 "register_operand (operands[0], DImode)
452 || register_operand (operands[1], DImode)"
458 switch (which_alternative)
465 return \"clr %L0\;clr %H0\";
468 if (rtx_equal_p (operands[0], operands[1]))
469 return \"sub %L1,%L0\;mov %L0,%H0\";
471 return \"mov %1,%L0\;mov %L0,%H0\";
480 if (GET_CODE (operands[1]) == CONST_INT)
483 split_double (operands[1], &low, &high);
484 val[0] = INTVAL (low);
485 val[1] = INTVAL (high);
487 if (GET_CODE (operands[1]) == CONST_DOUBLE)
489 if (GET_MODE (operands[1]) == DFmode)
491 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
492 REAL_VALUE_TO_TARGET_DOUBLE (rv, val);
494 else if (GET_MODE (operands[1]) == VOIDmode
495 || GET_MODE (operands[1]) == DImode)
497 val[0] = CONST_DOUBLE_LOW (operands[1]);
498 val[1] = CONST_DOUBLE_HIGH (operands[1]);
502 if (GET_CODE (operands[1]) == MEM
503 && reg_overlap_mentioned_p (operands[0], XEXP (operands[1], 0)))
505 rtx temp = operands[0];
507 while (GET_CODE (temp) == SUBREG)
508 temp = SUBREG_REG (temp);
510 if (GET_CODE (temp) != REG)
513 if (reg_overlap_mentioned_p (gen_rtx_REG (SImode, REGNO (temp)),
514 XEXP (operands[1], 0)))
515 return \"mov %H1,%H0\;mov %L1,%L0\";
517 return \"mov %L1,%L0\;mov %H1,%H0\";
520 else if (GET_CODE (operands[1]) == MEM
521 && CONSTANT_ADDRESS_P (XEXP (operands[1], 0))
522 && REGNO_REG_CLASS (REGNO (operands[0])) == ADDRESS_REGS)
526 xoperands[0] = operands[0];
527 xoperands[1] = XEXP (operands[1], 0);
529 output_asm_insn (\"mov %1,%L0\;mov (4,%L0),%H0\;mov (%L0),%L0\",
535 if ((GET_CODE (operands[1]) == CONST_INT
536 || GET_CODE (operands[1]) == CONST_DOUBLE)
539 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
540 output_asm_insn (\"clr %L0\", operands);
542 output_asm_insn (\"mov %L1,%L0\", operands);
544 else if ((GET_CODE (operands[1]) == CONST_INT
545 || GET_CODE (operands[1]) == CONST_DOUBLE)
546 && (REGNO_REG_CLASS (true_regnum (operands[0]))
548 && (((val[0] & 0x80) && ! (val[0] & 0xffffff00))
549 || ((val[0] & 0x800000) && ! (val[0] & 0xff000000))))
550 output_asm_insn (\"movu %L1,%L0\", operands);
552 output_asm_insn (\"mov %L1,%L0\", operands);
554 if ((GET_CODE (operands[1]) == CONST_INT
555 || GET_CODE (operands[1]) == CONST_DOUBLE)
558 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
559 output_asm_insn (\"clr %H0\", operands);
561 output_asm_insn (\"mov %H1,%H0\", operands);
563 else if ((GET_CODE (operands[1]) == CONST_INT
564 || GET_CODE (operands[1]) == CONST_DOUBLE)
566 output_asm_insn (\"mov %L0,%H0\", operands);
567 else if ((GET_CODE (operands[1]) == CONST_INT
568 || GET_CODE (operands[1]) == CONST_DOUBLE)
569 && (REGNO_REG_CLASS (true_regnum (operands[0]))
571 && (((val[1] & 0x80) && ! (val[1] & 0xffffff00))
572 || ((val[1] & 0x800000) && ! (val[1] & 0xff000000))))
573 output_asm_insn (\"movu %H1,%H0\", operands);
575 output_asm_insn (\"mov %H1,%H0\", operands);
583 return \"fmov %L1, %L0\;fmov %H1, %H0\";
585 if (GET_CODE (operands[1]) == MEM
586 && GET_CODE (XEXP (operands[1], 0)) == CONST_INT
587 && (INTVAL (XEXP (operands[1], 0)) & 7) == 0)
588 return \"fmov %D1, %D0\";
590 return \"fmov %L1, %L0\;fmov %H1, %H0\";
592 if (GET_CODE (operands[0]) == MEM
593 && GET_CODE (XEXP (operands[0], 0)) == CONST_INT
594 && (INTVAL (XEXP (operands[0], 0)) & 7) == 0)
595 return \"fmov %D1, %D0\";
597 return \"fmov %L1, %L0\;fmov %H1, %H0\";
605 (ior (lt (symbol_ref "which_alternative") (const_int 2))
606 (eq (symbol_ref "which_alternative") (const_int 12))
607 ) (const_string "none")
608 (eq (symbol_ref "which_alternative") (const_int 2)
609 ) (const_string "clobber")
610 (eq (symbol_ref "which_alternative") (const_int 3)
612 (ne (symbol_ref "rtx_equal_p (operands[0], operands[1])")
613 (const_int 0)) (const_string "clobber")
614 (const_string "none_0hit"))
615 (ior (eq (symbol_ref "which_alternative") (const_int 8))
616 (eq (symbol_ref "which_alternative") (const_int 9))
618 (ne (symbol_ref "mn10300_wide_const_load_uses_clr
620 (const_int 0)) (const_string "clobber")
621 (const_string "none_0hit"))
622 ] (const_string "none_0hit")))])
624 (define_expand "movdf"
625 [(set (match_operand:DF 0 "general_operand" "")
626 (match_operand:DF 1 "general_operand" ""))]
630 /* One of the ops has to be in a register */
631 if (!register_operand (operand1, DFmode)
632 && !register_operand (operand0, DFmode))
633 operands[1] = copy_to_mode_reg (DFmode, operand1);
637 [(set (match_operand:DF 0 "nonimmediate_operand"
638 "=f,dx,ax,dx,f,f,dxa,f,Q,a,dxm,dxm,axm,axm,dx,dx,ax,ax")
639 (match_operand:DF 1 "general_operand"
640 "0,0,0,G,f,dxaF,f,Q,f,G,dx,ax,dx,ax,dxFm,axFm,dxFm,axFm"))]
641 "register_operand (operands[0], DFmode)
642 || register_operand (operands[1], DFmode)"
648 switch (which_alternative)
656 return \"clr %L0\;clr %H0\";
661 return \"fmov %L1, %L0\;fmov %H1, %H0\";
664 if (GET_CODE (operands[1]) == MEM
665 && GET_CODE (XEXP (operands[1], 0)) == CONST_INT
666 && (INTVAL (XEXP (operands[1], 0)) & 7) == 0)
667 return \"fmov %D1, %D0\";
669 return \"fmov %L1, %L0\;fmov %H1, %H0\";
672 if (GET_CODE (operands[0]) == MEM
673 && GET_CODE (XEXP (operands[0], 0)) == CONST_INT
674 && (INTVAL (XEXP (operands[0], 0)) & 7) == 0)
675 return \"fmov %D1, %D0\";
677 return \"fmov %L1, %L0\;fmov %H1, %H0\";
680 if (rtx_equal_p (operands[0], operands[1]))
681 return \"sub %L1,%L0\;mov %L0,%H0\";
683 return \"mov %1,%L0\;mov %L0,%H0\";
692 if (GET_CODE (operands[1]) == CONST_INT)
695 split_double (operands[1], &low, &high);
696 val[0] = INTVAL (low);
697 val[1] = INTVAL (high);
699 if (GET_CODE (operands[1]) == CONST_DOUBLE)
701 if (GET_MODE (operands[1]) == DFmode)
703 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
704 REAL_VALUE_TO_TARGET_DOUBLE (rv, val);
706 else if (GET_MODE (operands[1]) == VOIDmode
707 || GET_MODE (operands[1]) == DImode)
709 val[0] = CONST_DOUBLE_LOW (operands[1]);
710 val[1] = CONST_DOUBLE_HIGH (operands[1]);
714 if (GET_CODE (operands[1]) == MEM
715 && reg_overlap_mentioned_p (operands[0], XEXP (operands[1], 0)))
717 rtx temp = operands[0];
719 while (GET_CODE (temp) == SUBREG)
720 temp = SUBREG_REG (temp);
722 if (GET_CODE (temp) != REG)
725 if (reg_overlap_mentioned_p (gen_rtx_REG (SImode, REGNO (temp)),
726 XEXP (operands[1], 0)))
727 return \"mov %H1,%H0\;mov %L1,%L0\";
729 return \"mov %L1,%L0\;mov %H1,%H0\";
732 else if (GET_CODE (operands[1]) == MEM
733 && CONSTANT_ADDRESS_P (XEXP (operands[1], 0))
734 && REGNO_REG_CLASS (REGNO (operands[0])) == ADDRESS_REGS)
738 xoperands[0] = operands[0];
739 xoperands[1] = XEXP (operands[1], 0);
741 output_asm_insn (\"mov %1,%L0\;mov (4,%L0),%H0\;mov (%L0),%L0\",
747 if ((GET_CODE (operands[1]) == CONST_INT
748 || GET_CODE (operands[1]) == CONST_DOUBLE)
751 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
752 output_asm_insn (\"clr %L0\", operands);
754 output_asm_insn (\"mov %L1,%L0\", operands);
756 else if ((GET_CODE (operands[1]) == CONST_INT
757 || GET_CODE (operands[1]) == CONST_DOUBLE)
758 && (REGNO_REG_CLASS (true_regnum (operands[0]))
760 && (((val[0] & 0x80) && ! (val[0] & 0xffffff00))
761 || ((val[0] & 0x800000) && ! (val[0] & 0xff000000))))
762 output_asm_insn (\"movu %L1,%L0\", operands);
764 output_asm_insn (\"mov %L1,%L0\", operands);
766 if ((GET_CODE (operands[1]) == CONST_INT
767 || GET_CODE (operands[1]) == CONST_DOUBLE)
770 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
771 output_asm_insn (\"clr %H0\", operands);
773 output_asm_insn (\"mov %H1,%H0\", operands);
775 else if ((GET_CODE (operands[1]) == CONST_INT
776 || GET_CODE (operands[1]) == CONST_DOUBLE)
778 output_asm_insn (\"mov %L0,%H0\", operands);
779 else if ((GET_CODE (operands[1]) == CONST_INT
780 || GET_CODE (operands[1]) == CONST_DOUBLE)
781 && (REGNO_REG_CLASS (true_regnum (operands[0]))
783 && (((val[1] & 0x80) && ! (val[1] & 0xffffff00))
784 || ((val[1] & 0x800000) && ! (val[1] & 0xff000000))))
785 output_asm_insn (\"movu %H1,%H0\", operands);
787 output_asm_insn (\"mov %H1,%H0\", operands);
797 (lt (symbol_ref "which_alternative") (const_int 3)
798 ) (const_string "none")
799 (eq (symbol_ref "which_alternative") (const_int 3)
800 ) (const_string "clobber")
801 (eq (symbol_ref "which_alternative") (const_int 9)
803 (ne (symbol_ref "rtx_equal_p (operands[0], operands[1])")
804 (const_int 0)) (const_string "clobber")
805 (const_string "none_0hit"))
806 (ior (eq (symbol_ref "which_alternative") (const_int 14))
807 (eq (symbol_ref "which_alternative") (const_int 15))
809 (ne (symbol_ref "mn10300_wide_const_load_uses_clr
811 (const_int 0)) (const_string "clobber")
812 (const_string "none_0hit"))
813 ] (const_string "none_0hit")))])
817 ;; ----------------------------------------------------------------------
819 ;; ----------------------------------------------------------------------
821 ;; Go ahead and define tstsi so we can eliminate redundant tst insns
822 ;; when we start trying to optimize this port.
824 [(set (cc0) (match_operand:SI 0 "register_operand" "dax"))]
826 "* return output_tst (operands[0], insn);"
827 [(set_attr "cc" "set_znv")])
830 [(set (cc0) (zero_extend:SI (match_operand:QI 0 "memory_operand" "dx,!a")))]
832 "* return output_tst (operands[0], insn);"
833 [(set_attr "cc" "set_znv")])
836 [(set (cc0) (zero_extend:SI (match_operand:QI 0 "memory_operand" "dx")))]
838 "* return output_tst (operands[0], insn);"
839 [(set_attr "cc" "set_znv")])
842 [(set (cc0) (zero_extend:SI (match_operand:HI 0 "memory_operand" "dx,!a")))]
844 "* return output_tst (operands[0], insn);"
845 [(set_attr "cc" "set_znv")])
848 [(set (cc0) (zero_extend:SI (match_operand:HI 0 "memory_operand" "dx")))]
850 "* return output_tst (operands[0], insn);"
851 [(set_attr "cc" "set_znv")])
853 ;; Ordinarily, the cmp instruction will set the Z bit of cc0 to 1 if
854 ;; its operands hold equal values, but the operands of a cmp
855 ;; instruction must be distinct registers. In the case where we'd
856 ;; like to compare a register to itself, we can achieve this effect
857 ;; with a btst 0,d0 instead. (This will not alter the contents of d0
858 ;; but will have the proper effect on cc0. Using d0 is arbitrary; any
859 ;; data register would work.)
861 ;; Even though the first alternative would be preferable if it can
862 ;; possibly match, reload must not be given the opportunity to attempt
863 ;; to use it. It assumes that such matches can only occur when one of
864 ;; the operands is used for input and the other for output. Since
865 ;; this is not the case, it abort()s. Indeed, such a reload cannot be
866 ;; possibly satisfied, so just mark the alternative with a `!', so
867 ;; that it is not considered by reload.
871 (compare (match_operand:SI 0 "register_operand" "!*d*a*x,dax")
872 (match_operand:SI 1 "nonmemory_operand" "*0,daxi")))]
877 [(set_attr "cc" "compare,compare")])
881 (compare (match_operand:SF 0 "register_operand" "f,f")
882 (match_operand:SF 1 "nonmemory_operand" "f,F")))]
885 [(set_attr "cc" "compare,compare")])
887 ;; ----------------------------------------------------------------------
889 ;; ----------------------------------------------------------------------
891 (define_expand "addsi3"
892 [(set (match_operand:SI 0 "register_operand" "")
893 (plus:SI (match_operand:SI 1 "register_operand" "")
894 (match_operand:SI 2 "nonmemory_operand" "")))]
899 [(set (match_operand:SI 0 "register_operand" "=dx,a,x,a,dax,!*y,!dax")
900 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,dax")
901 (match_operand:SI 2 "nonmemory_operand" "J,J,L,L,daxi,i,dax")))]
905 switch (which_alternative)
915 return \"add %2,%0\";
918 enum reg_class src1_class, src2_class, dst_class;
920 src1_class = REGNO_REG_CLASS (true_regnum (operands[1]));
921 src2_class = REGNO_REG_CLASS (true_regnum (operands[2]));
922 dst_class = REGNO_REG_CLASS (true_regnum (operands[0]));
924 /* I'm not sure if this can happen or not. Might as well be prepared
925 and generate the best possible code if it does happen. */
926 if (true_regnum (operands[0]) == true_regnum (operands[1]))
927 return \"add %2,%0\";
928 if (true_regnum (operands[0]) == true_regnum (operands[2]))
929 return \"add %1,%0\";
931 /* Catch cases where no extended register was used. These should be
932 handled just like the mn10300. */
933 if (src1_class != EXTENDED_REGS
934 && src2_class != EXTENDED_REGS
935 && dst_class != EXTENDED_REGS)
937 /* We have to copy one of the sources into the destination, then
938 add the other source to the destination.
940 Carefully select which source to copy to the destination; a naive
941 implementation will waste a byte when the source classes are
942 different and the destination is an address register. Selecting
943 the lowest cost register copy will optimize this sequence. */
944 if (REGNO_REG_CLASS (true_regnum (operands[1]))
945 == REGNO_REG_CLASS (true_regnum (operands[0])))
946 return \"mov %1,%0\;add %2,%0\";
947 return \"mov %2,%0\;add %1,%0\";
950 /* At least one register is an extended register. */
952 /* The three operand add instruction on the am33 is a win iff the
953 output register is an extended register, or if both source
954 registers are extended registers. */
955 if (dst_class == EXTENDED_REGS
956 || src1_class == src2_class)
957 return \"add %2,%1,%0\";
959 /* It is better to copy one of the sources to the destination, then
960 perform a 2 address add. The destination in this case must be
961 an address or data register and one of the sources must be an
962 extended register and the remaining source must not be an extended
965 The best code for this case is to copy the extended reg to the
966 destination, then emit a two address add. */
967 if (src1_class == EXTENDED_REGS)
968 return \"mov %1,%0\;add %2,%0\";
969 return \"mov %2,%0\;add %1,%0\";
975 [(set_attr "cc" "set_zn,none_0hit,set_zn,none_0hit,set_zn,none_0hit,set_zn")])
978 [(set (match_operand:SI 0 "register_operand" "=dx,a,a,dax,!*y,!dax")
979 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,dax")
980 (match_operand:SI 2 "nonmemory_operand" "J,J,L,daxi,i,dax")))]
984 switch (which_alternative)
993 return \"add %2,%0\";
995 /* I'm not sure if this can happen or not. Might as well be prepared
996 and generate the best possible code if it does happen. */
997 if (true_regnum (operands[0]) == true_regnum (operands[1]))
998 return \"add %2,%0\";
999 if (true_regnum (operands[0]) == true_regnum (operands[2]))
1000 return \"add %1,%0\";
1002 /* We have to copy one of the sources into the destination, then add
1003 the other source to the destination.
1005 Carefully select which source to copy to the destination; a naive
1006 implementation will waste a byte when the source classes are different
1007 and the destination is an address register. Selecting the lowest
1008 cost register copy will optimize this sequence. */
1009 if (REGNO_REG_CLASS (true_regnum (operands[1]))
1010 == REGNO_REG_CLASS (true_regnum (operands[0])))
1011 return \"mov %1,%0\;add %2,%0\";
1012 return \"mov %2,%0\;add %1,%0\";
1017 [(set_attr "cc" "set_zn,none_0hit,none_0hit,set_zn,none_0hit,set_zn")])
1019 ;; ----------------------------------------------------------------------
1020 ;; SUBTRACT INSTRUCTIONS
1021 ;; ----------------------------------------------------------------------
1023 (define_expand "subsi3"
1024 [(set (match_operand:SI 0 "register_operand" "")
1025 (minus:SI (match_operand:SI 1 "register_operand" "")
1026 (match_operand:SI 2 "nonmemory_operand" "")))]
1031 [(set (match_operand:SI 0 "register_operand" "=dax,!dax")
1032 (minus:SI (match_operand:SI 1 "register_operand" "0,dax")
1033 (match_operand:SI 2 "nonmemory_operand" "daxi,dax")))]
1037 if (true_regnum (operands[0]) == true_regnum (operands[1]))
1038 return \"sub %2,%0\";
1041 enum reg_class src1_class, src2_class, dst_class;
1043 src1_class = REGNO_REG_CLASS (true_regnum (operands[1]));
1044 src2_class = REGNO_REG_CLASS (true_regnum (operands[2]));
1045 dst_class = REGNO_REG_CLASS (true_regnum (operands[0]));
1047 /* If no extended registers are used, then the best way to handle
1048 this is to copy the first source operand into the destination
1049 and emit a two address subtraction. */
1050 if (src1_class != EXTENDED_REGS
1051 && src2_class != EXTENDED_REGS
1052 && dst_class != EXTENDED_REGS
1053 && true_regnum (operands[0]) != true_regnum (operands[2]))
1054 return \"mov %1,%0\;sub %2,%0\";
1055 return \"sub %2,%1,%0\";
1058 [(set_attr "cc" "set_zn")])
1061 [(set (match_operand:SI 0 "register_operand" "=dax")
1062 (minus:SI (match_operand:SI 1 "register_operand" "0")
1063 (match_operand:SI 2 "nonmemory_operand" "daxi")))]
1066 [(set_attr "cc" "set_zn")])
1068 (define_expand "negsi2"
1069 [(set (match_operand:SI 0 "register_operand" "")
1070 (neg:SI (match_operand:SI 1 "register_operand" "")))]
1074 rtx target = gen_reg_rtx (SImode);
1076 emit_move_insn (target, const0_rtx);
1077 emit_insn (gen_subsi3 (target, target, operands[1]));
1078 emit_move_insn (operands[0], target);
1082 ;; ----------------------------------------------------------------------
1083 ;; MULTIPLY INSTRUCTIONS
1084 ;; ----------------------------------------------------------------------
1086 (define_insn "mulsidi3"
1087 [(set (match_operand:DI 0 "register_operand" "=dax")
1088 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "dax"))
1089 (sign_extend:DI (match_operand:SI 2 "register_operand" "dax"))))]
1092 [(set_attr "cc" "set_zn")])
1094 (define_insn "umulsidi3"
1095 [(set (match_operand:DI 0 "register_operand" "=dax")
1096 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "dax"))
1097 (zero_extend:DI (match_operand:SI 2 "register_operand" "dax"))))]
1099 "mulu %1,%2,%H0,%L0"
1100 [(set_attr "cc" "set_zn")])
1102 (define_expand "mulsi3"
1103 [(set (match_operand:SI 0 "register_operand" "")
1104 (mult:SI (match_operand:SI 1 "register_operand" "")
1105 (match_operand:SI 2 "register_operand" "")))]
1110 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
1111 (mult:SI (match_operand:SI 1 "register_operand" "%0,0")
1112 (match_operand:SI 2 "nonmemory_operand" "dx,daxi")))]
1116 if (TARGET_MULT_BUG)
1117 return \"nop\;nop\;mul %2,%0\";
1119 return \"mul %2,%0\";
1121 [(set_attr "cc" "set_zn")])
1124 [(set (match_operand:SI 0 "register_operand" "=dx")
1125 (mult:SI (match_operand:SI 1 "register_operand" "%0")
1126 (match_operand:SI 2 "register_operand" "dx")))]
1130 if (TARGET_MULT_BUG)
1131 return \"nop\;nop\;mul %2,%0\";
1133 return \"mul %2,%0\";
1135 [(set_attr "cc" "set_zn")])
1137 (define_insn "udivmodsi4"
1138 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx")
1139 (udiv:SI (match_operand:SI 1 "general_operand" "0")
1140 (match_operand:SI 2 "general_operand" "dx")))
1141 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
1142 (umod:SI (match_dup 1) (match_dup 2)))]
1146 output_asm_insn (\"sub %3,%3\;mov %3,mdr\", operands);
1148 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1149 return \"divu %2,%0\";
1151 return \"divu %2,%0\;mov mdr,%3\";
1153 [(set_attr "cc" "set_zn")])
1155 (define_insn "divmodsi4"
1156 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx")
1157 (div:SI (match_operand:SI 1 "general_operand" "0")
1158 (match_operand:SI 2 "general_operand" "dx")))
1159 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
1160 (mod:SI (match_dup 1) (match_dup 2)))]
1164 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1165 return \"ext %0\;div %2,%0\";
1167 return \"ext %0\;div %2,%0\;mov mdr,%3\";
1169 [(set_attr "cc" "set_zn")])
1172 ;; ----------------------------------------------------------------------
1174 ;; ----------------------------------------------------------------------
1176 (define_expand "andsi3"
1177 [(set (match_operand:SI 0 "register_operand" "")
1178 (and:SI (match_operand:SI 1 "register_operand" "")
1179 (match_operand:SI 2 "nonmemory_operand" "")))]
1184 [(set (match_operand:SI 0 "register_operand" "=dx,dx,!dax")
1185 (and:SI (match_operand:SI 1 "register_operand" "%0,0,dax")
1186 (match_operand:SI 2 "nonmemory_operand" "N,dxi,dax")))]
1190 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xff)
1191 return \"extbu %0\";
1192 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xffff)
1193 return \"exthu %0\";
1194 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x7fffffff)
1195 return \"add %0,%0\;lsr 1,%0\";
1196 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x3fffffff)
1197 return \"asl2 %0\;lsr 2,%0\";
1198 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x1fffffff)
1199 return \"add %0,%0\;asl2 %0\;lsr 3,%0\";
1200 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x0fffffff)
1201 return \"asl2 %0\;asl2 %0\;lsr 4,%0\";
1202 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffffe)
1203 return \"lsr 1,%0\;add %0,%0\";
1204 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffffc)
1205 return \"lsr 2,%0\;asl2 %0\";
1206 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffff8)
1207 return \"lsr 3,%0\;add %0,%0\;asl2 %0\";
1208 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffff0)
1209 return \"lsr 4,%0\;asl2 %0\;asl2 %0\";
1210 if (REG_P (operands[2]) && REG_P (operands[1])
1211 && true_regnum (operands[0]) != true_regnum (operands[1])
1212 && true_regnum (operands[0]) != true_regnum (operands[2])
1213 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
1214 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
1215 && REGNO_REG_CLASS (true_regnum (operands[2])) == DATA_REGS)
1216 return \"mov %1,%0\;and %2,%0\";
1217 if (REG_P (operands[2]) && REG_P (operands[1])
1218 && true_regnum (operands[0]) != true_regnum (operands[1])
1219 && true_regnum (operands[0]) != true_regnum (operands[2]))
1220 return \"and %1,%2,%0\";
1221 if (REG_P (operands[2]) && REG_P (operands[0])
1222 && true_regnum (operands[2]) == true_regnum (operands[0]))
1223 return \"and %1,%0\";
1224 return \"and %2,%0\";
1229 (eq (symbol_ref "which_alternative") (const_int 0)
1230 ) (const_string "none_0hit")
1231 (ne (symbol_ref "GET_CODE (operands[2]) == CONST_INT
1232 && (INTVAL (operands[2]) == 0x7fffffff
1233 || INTVAL (operands[2]) == 0x3fffffff
1234 || INTVAL (operands[2]) == 0x1fffffff
1235 || INTVAL (operands[2]) == 0x0fffffff
1236 || INTVAL (operands[2]) == 0xfffffffe
1237 || INTVAL (operands[2]) == 0xfffffffc
1238 || INTVAL (operands[2]) == 0xfffffff8
1239 || INTVAL (operands[2]) == 0xfffffff0)")
1240 (const_int 0)) (const_string "set_zn")
1241 ] (const_string "set_znv")))])
1244 [(set (match_operand:SI 0 "register_operand" "=dx,dx")
1245 (and:SI (match_operand:SI 1 "register_operand" "%0,0")
1246 (match_operand:SI 2 "nonmemory_operand" "N,dxi")))]
1250 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xff)
1251 return \"extbu %0\";
1252 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xffff)
1253 return \"exthu %0\";
1254 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x7fffffff)
1255 return \"add %0,%0\;lsr 1,%0\";
1256 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x3fffffff)
1257 return \"asl2 %0\;lsr 2,%0\";
1258 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x1fffffff)
1259 return \"add %0,%0\;asl2 %0\;lsr 3,%0\";
1260 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0x0fffffff)
1261 return \"asl2 %0\;asl2 %0\;lsr 4,%0\";
1262 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffffe)
1263 return \"lsr 1,%0\;add %0,%0\";
1264 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffffc)
1265 return \"lsr 2,%0\;asl2 %0\";
1266 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffff8)
1267 return \"lsr 3,%0\;add %0,%0\;asl2 %0\";
1268 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0xfffffff0)
1269 return \"lsr 4,%0\;asl2 %0\;asl2 %0\";
1270 return \"and %2,%0\";
1275 (eq (symbol_ref "which_alternative") (const_int 0)
1276 ) (const_string "none_0hit")
1277 ;; Shifts don't set the V flag, but bitwise operations clear
1278 ;; it (which correctly reflects the absence of overflow in a
1279 ;; compare-with-zero that might follow). As for the
1280 ;; 0xfffffffe case, the add may overflow, so we can't use the
1282 (ne (symbol_ref "GET_CODE (operands[2]) == CONST_INT
1283 && (INTVAL (operands[2]) == 0x7fffffff
1284 || INTVAL (operands[2]) == 0x3fffffff
1285 || INTVAL (operands[2]) == 0x1fffffff
1286 || INTVAL (operands[2]) == 0x0fffffff
1287 || INTVAL (operands[2]) == 0xfffffffe
1288 || INTVAL (operands[2]) == 0xfffffffc
1289 || INTVAL (operands[2]) == 0xfffffff8
1290 || INTVAL (operands[2]) == 0xfffffff0)")
1291 (const_int 0)) (const_string "set_zn")
1292 ] (const_string "set_znv")))])
1294 ;; ----------------------------------------------------------------------
1296 ;; ----------------------------------------------------------------------
1298 (define_expand "iorsi3"
1299 [(set (match_operand:SI 0 "register_operand" "")
1300 (ior:SI (match_operand:SI 1 "register_operand" "")
1301 (match_operand:SI 2 "nonmemory_operand" "")))]
1306 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
1307 (ior:SI (match_operand:SI 1 "register_operand" "%0,dax")
1308 (match_operand:SI 2 "nonmemory_operand" "dxi,dax")))]
1312 if (REG_P (operands[2]) && REG_P (operands[1])
1313 && true_regnum (operands[0]) != true_regnum (operands[1])
1314 && true_regnum (operands[0]) != true_regnum (operands[2])
1315 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
1316 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
1317 && REGNO_REG_CLASS (true_regnum (operands[2])) == DATA_REGS)
1318 return \"mov %1,%0\;or %2,%0\";
1319 if (REG_P (operands[2]) && REG_P (operands[1])
1320 && true_regnum (operands[0]) != true_regnum (operands[1])
1321 && true_regnum (operands[0]) != true_regnum (operands[2]))
1322 return \"or %1,%2,%0\";
1323 if (REG_P (operands[2]) && REG_P (operands[0])
1324 && true_regnum (operands[2]) == true_regnum (operands[0]))
1325 return \"or %1,%0\";
1326 return \"or %2,%0\";
1328 [(set_attr "cc" "set_znv")])
1331 [(set (match_operand:SI 0 "register_operand" "=dx")
1332 (ior:SI (match_operand:SI 1 "register_operand" "%0")
1333 (match_operand:SI 2 "nonmemory_operand" "dxi")))]
1336 [(set_attr "cc" "set_znv")])
1338 ;; ----------------------------------------------------------------------
1340 ;; ----------------------------------------------------------------------
1342 (define_expand "xorsi3"
1343 [(set (match_operand:SI 0 "register_operand" "")
1344 (xor:SI (match_operand:SI 1 "register_operand" "")
1345 (match_operand:SI 2 "nonmemory_operand" "")))]
1350 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
1351 (xor:SI (match_operand:SI 1 "register_operand" "%0,dax")
1352 (match_operand:SI 2 "nonmemory_operand" "dxi,dax")))]
1356 if (REG_P (operands[2]) && REG_P (operands[1])
1357 && true_regnum (operands[0]) != true_regnum (operands[1])
1358 && true_regnum (operands[0]) != true_regnum (operands[2])
1359 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
1360 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
1361 && REGNO_REG_CLASS (true_regnum (operands[2])) == DATA_REGS)
1362 return \"mov %1,%0\;xor %2,%0\";
1363 if (REG_P (operands[2]) && REG_P (operands[1])
1364 && true_regnum (operands[0]) != true_regnum (operands[1])
1365 && true_regnum (operands[0]) != true_regnum (operands[2]))
1366 return \"xor %1,%2,%0\";
1367 if (REG_P (operands[2]) && REG_P (operands[0])
1368 && true_regnum (operands[2]) == true_regnum (operands[0]))
1369 return \"xor %1,%0\";
1370 return \"xor %2,%0\";
1372 [(set_attr "cc" "set_znv")])
1375 [(set (match_operand:SI 0 "register_operand" "=dx")
1376 (xor:SI (match_operand:SI 1 "register_operand" "%0")
1377 (match_operand:SI 2 "nonmemory_operand" "dxi")))]
1380 [(set_attr "cc" "set_znv")])
1382 ;; ----------------------------------------------------------------------
1384 ;; ----------------------------------------------------------------------
1386 (define_expand "one_cmplsi2"
1387 [(set (match_operand:SI 0 "register_operand" "")
1388 (not:SI (match_operand:SI 1 "register_operand" "")))]
1393 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
1394 (not:SI (match_operand:SI 1 "register_operand" "0,0")))]
1397 [(set_attr "cc" "set_znv")])
1400 [(set (match_operand:SI 0 "register_operand" "=dx")
1401 (not:SI (match_operand:SI 1 "register_operand" "0")))]
1404 [(set_attr "cc" "set_znv")])
1406 ;; -----------------------------------------------------------------
1408 ;; -----------------------------------------------------------------
1411 ;; These set/clear memory in byte sized chunks.
1413 ;; They are no smaller/faster than loading the value into a register
1414 ;; and storing the register, but they don't need a scratch register
1415 ;; which may allow for better code generation.
1417 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,d") (const_int 0))]
1422 [(set_attr "cc" "clobber")])
1425 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,d") (const_int -1))]
1430 [(set_attr "cc" "clobber,none_0hit")])
1433 [(set (match_operand:QI 0 "nonimmediate_operand" "+R,d")
1435 (and:SI (subreg:SI (match_dup 0) 0)
1436 (match_operand:SI 1 "const_int_operand" "i,i")) 0))]
1441 [(set_attr "cc" "clobber,set_znv")])
1444 [(set (match_operand:QI 0 "memory_operand" "=R,T")
1447 (not:QI (match_operand:QI 1 "nonmemory_operand" "i,d"))))]
1452 [(set_attr "cc" "clobber,clobber")])
1455 [(set (match_operand:QI 0 "nonimmediate_operand" "+R,d")
1457 (ior:SI (subreg:SI (match_dup 0) 0)
1458 (match_operand:SI 1 "const_int_operand" "i,i")) 0))]
1463 [(set_attr "cc" "clobber,set_znv")])
1465 (define_expand "iorqi3"
1466 [(set (match_operand:QI 0 "nonimmediate_operand" "")
1467 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "")
1468 (match_operand:QI 2 "nonmemory_operand" "")))]
1473 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,T,r")
1474 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
1475 ;; This constraint should really be nonmemory_operand,
1476 ;; but making it general_operand, along with the
1477 ;; condition that not both input operands are MEMs, it
1478 ;; here helps combine do a better job.
1479 (match_operand:QI 2 "general_operand" "i,d,ir")))]
1481 (GET_CODE (operands[2]) != MEM || GET_CODE (operands[1]) != MEM)"
1486 [(set_attr "cc" "clobber,clobber,set_znv")])
1489 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,T,d")
1490 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
1491 ;; This constraint should really be nonmemory_operand,
1492 ;; but making it general_operand, along with the
1493 ;; condition that not both input operands are MEMs, it
1494 ;; here helps combine do a better job.
1495 (match_operand:QI 2 "general_operand" "i,d,id")))]
1496 "GET_CODE (operands[2]) != MEM || GET_CODE (operands[1]) != MEM"
1501 [(set_attr "cc" "clobber,clobber,set_znv")])
1505 (zero_extract:SI (match_operand:SI 0 "register_operand" "dx")
1506 (match_operand 1 "const_int_operand" "")
1507 (match_operand 2 "const_int_operand" "")))]
1511 int len = INTVAL (operands[1]);
1512 int bit = INTVAL (operands[2]);
1523 xoperands[0] = operands[0];
1524 xoperands[1] = GEN_INT (trunc_int_for_mode (mask, SImode));
1525 output_asm_insn (\"btst %1,%0\", xoperands);
1528 [(set_attr "cc" "clobber")])
1532 (zero_extract:SI (match_operand:QI 0 "general_operand" "R,dx")
1533 (match_operand 1 "const_int_operand" "")
1534 (match_operand 2 "const_int_operand" "")))]
1535 "mask_ok_for_mem_btst (INTVAL (operands[1]), INTVAL (operands[2]))"
1538 int len = INTVAL (operands[1]);
1539 int bit = INTVAL (operands[2]);
1550 /* If the source operand is not a reg (ie it is memory), then extract the
1551 bits from mask that we actually want to test. Note that the mask will
1552 never cross a byte boundary. */
1553 if (!REG_P (operands[0]))
1557 else if (mask & 0xff00)
1558 mask = (mask >> 8) & 0xff;
1559 else if (mask & 0xff0000)
1560 mask = (mask >> 16) & 0xff;
1561 else if (mask & 0xff000000)
1562 mask = (mask >> 24) & 0xff;
1565 xoperands[0] = operands[0];
1566 xoperands[1] = GEN_INT (trunc_int_for_mode (mask, SImode));
1567 if (GET_CODE (operands[0]) == REG)
1568 output_asm_insn (\"btst %1,%0\", xoperands);
1570 output_asm_insn (\"btst %U1,%A0\", xoperands);
1573 [(set_attr "cc" "clobber")])
1576 [(set (cc0) (and:SI (match_operand:SI 0 "register_operand" "dx")
1577 (match_operand:SI 1 "const_int_operand" "")))]
1580 [(set_attr "cc" "clobber")])
1585 (subreg:SI (match_operand:QI 0 "general_operand" "R,dx") 0)
1586 (match_operand:SI 1 "const_8bit_operand" "")))]
1591 [(set_attr "cc" "clobber")])
1594 ;; ----------------------------------------------------------------------
1595 ;; JUMP INSTRUCTIONS
1596 ;; ----------------------------------------------------------------------
1598 ;; Conditional jump instructions
1600 (define_expand "ble"
1602 (if_then_else (le (cc0)
1604 (label_ref (match_operand 0 "" ""))
1609 (define_expand "bleu"
1611 (if_then_else (leu (cc0)
1613 (label_ref (match_operand 0 "" ""))
1618 (define_expand "bge"
1620 (if_then_else (ge (cc0)
1622 (label_ref (match_operand 0 "" ""))
1627 (define_expand "bgeu"
1629 (if_then_else (geu (cc0)
1631 (label_ref (match_operand 0 "" ""))
1636 (define_expand "blt"
1638 (if_then_else (lt (cc0)
1640 (label_ref (match_operand 0 "" ""))
1645 (define_expand "bltu"
1647 (if_then_else (ltu (cc0)
1649 (label_ref (match_operand 0 "" ""))
1654 (define_expand "bgt"
1656 (if_then_else (gt (cc0)
1658 (label_ref (match_operand 0 "" ""))
1663 (define_expand "bgtu"
1665 (if_then_else (gtu (cc0)
1667 (label_ref (match_operand 0 "" ""))
1672 (define_expand "beq"
1674 (if_then_else (eq (cc0)
1676 (label_ref (match_operand 0 "" ""))
1681 (define_expand "bne"
1683 (if_then_else (ne (cc0)
1685 (label_ref (match_operand 0 "" ""))
1692 (if_then_else (match_operator 1 "comparison_operator"
1693 [(cc0) (const_int 0)])
1694 (label_ref (match_operand 0 "" ""))
1699 if (cc_status.mdep.fpCC)
1700 return \"fb%b1 %0\";
1701 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1702 && (GET_CODE (operands[1]) == GT
1703 || GET_CODE (operands[1]) == GE
1704 || GET_CODE (operands[1]) == LE
1705 || GET_CODE (operands[1]) == LT))
1709 [(set_attr "cc" "none")])
1713 (if_then_else (match_operator 1 "comparison_operator"
1714 [(cc0) (const_int 0)])
1716 (label_ref (match_operand 0 "" ""))))]
1720 if (cc_status.mdep.fpCC)
1721 return \"fb%B1 %0\";
1722 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
1723 && (GET_CODE (operands[1]) == GT
1724 || GET_CODE (operands[1]) == GE
1725 || GET_CODE (operands[1]) == LE
1726 || GET_CODE (operands[1]) == LT))
1730 [(set_attr "cc" "none")])
1732 ;; Unconditional and other jump instructions.
1736 (label_ref (match_operand 0 "" "")))]
1739 [(set_attr "cc" "none")])
1741 (define_insn "indirect_jump"
1742 [(set (pc) (match_operand:SI 0 "register_operand" "a"))]
1745 [(set_attr "cc" "none")])
1747 (define_expand "builtin_setjmp_receiver"
1748 [(match_operand 0 "" "")]
1753 emit_insn (gen_GOTaddr2picreg ());
1758 (define_expand "casesi"
1759 [(match_operand:SI 0 "register_operand" "")
1760 (match_operand:SI 1 "immediate_operand" "")
1761 (match_operand:SI 2 "immediate_operand" "")
1762 (match_operand 3 "" "") (match_operand 4 "" "")]
1766 rtx table = gen_reg_rtx (SImode);
1767 rtx index = gen_reg_rtx (SImode);
1768 rtx addr = gen_reg_rtx (Pmode);
1770 emit_move_insn (table, gen_rtx_LABEL_REF (VOIDmode, operands[3]));
1771 emit_move_insn (index, plus_constant (operands[0], - INTVAL (operands[1])));
1772 emit_insn (gen_cmpsi (index, operands[2]));
1773 emit_jump_insn (gen_bgtu (operands[4]));
1774 emit_move_insn (index, gen_rtx_ASHIFT (SImode, index, const2_rtx));
1775 emit_move_insn (addr, gen_rtx_MEM (SImode,
1776 gen_rtx_PLUS (SImode, table, index)));
1778 emit_move_insn (addr, gen_rtx_PLUS (SImode, addr, table));
1780 emit_jump_insn (gen_tablejump (addr, operands[3]));
1784 (define_insn "tablejump"
1785 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
1786 (use (label_ref (match_operand 1 "" "")))]
1789 [(set_attr "cc" "none")])
1791 ;; Call subroutine with no return value.
1793 (define_expand "call"
1794 [(call (match_operand:QI 0 "general_operand" "")
1795 (match_operand:SI 1 "general_operand" ""))]
1799 if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
1801 if (MN10300_GLOBAL_P (XEXP (operands[0], 0)))
1803 /* The PLT code won't run on AM30, but then, there's no
1804 shared library support for AM30 either, so we just assume
1805 the linker is going to adjust all @PLT relocs to the
1807 emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
1808 XEXP (operands[0], 0) = gen_sym2PLT (XEXP (operands[0], 0));
1811 XEXP (operands[0], 0) = gen_sym2PIC (XEXP (operands[0], 0));
1813 if (! call_address_operand (XEXP (operands[0], 0), VOIDmode))
1814 XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0));
1815 emit_call_insn (gen_call_internal (XEXP (operands[0], 0), operands[1]));
1819 (define_insn "call_internal"
1820 [(call (mem:QI (match_operand:SI 0 "call_address_operand" "aS"))
1821 (match_operand:SI 1 "general_operand" "g"))]
1825 if (REG_P (operands[0]))
1826 return \"calls %C0\";
1828 return \"call %C0,[],0\";
1830 [(set_attr "cc" "clobber")])
1832 ;; Call subroutine, returning value in operand 0
1833 ;; (which must be a hard register).
1835 (define_expand "call_value"
1836 [(set (match_operand 0 "" "")
1837 (call (match_operand:QI 1 "general_operand" "")
1838 (match_operand:SI 2 "general_operand" "")))]
1842 if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
1844 if (MN10300_GLOBAL_P (XEXP (operands[1], 0)))
1846 /* The PLT code won't run on AM30, but then, there's no
1847 shared library support for AM30 either, so we just assume
1848 the linker is going to adjust all @PLT relocs to the
1850 emit_insn (gen_rtx_USE (VOIDmode, pic_offset_table_rtx));
1851 XEXP (operands[1], 0) = gen_sym2PLT (XEXP (operands[1], 0));
1854 XEXP (operands[1], 0) = gen_sym2PIC (XEXP (operands[1], 0));
1856 if (! call_address_operand (XEXP (operands[1], 0), VOIDmode))
1857 XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0));
1858 emit_call_insn (gen_call_value_internal (operands[0],
1859 XEXP (operands[1], 0),
1864 (define_insn "call_value_internal"
1865 [(set (match_operand 0 "" "=dax")
1866 (call (mem:QI (match_operand:SI 1 "call_address_operand" "aS"))
1867 (match_operand:SI 2 "general_operand" "g")))]
1871 if (REG_P (operands[1]))
1872 return \"calls %C1\";
1874 return \"call %C1,[],0\";
1876 [(set_attr "cc" "clobber")])
1878 (define_expand "untyped_call"
1879 [(parallel [(call (match_operand 0 "" "")
1881 (match_operand 1 "" "")
1882 (match_operand 2 "" "")])]
1888 emit_call_insn (gen_call (operands[0], const0_rtx));
1890 for (i = 0; i < XVECLEN (operands[2], 0); i++)
1892 rtx set = XVECEXP (operands[2], 0, i);
1893 emit_move_insn (SET_DEST (set), SET_SRC (set));
1902 [(set_attr "cc" "none")])
1904 ;; ----------------------------------------------------------------------
1905 ;; EXTEND INSTRUCTIONS
1906 ;; ----------------------------------------------------------------------
1908 (define_expand "zero_extendqisi2"
1909 [(set (match_operand:SI 0 "general_operand" "")
1911 (match_operand:QI 1 "general_operand" "")))]
1916 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx,!dax,!dax,!dax")
1918 (match_operand:QI 1 "general_operand" "0,dax,m,0,dax,m")))]
1927 [(set_attr "cc" "none_0hit")])
1930 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx")
1932 (match_operand:QI 1 "general_operand" "0,d,m")))]
1938 [(set_attr "cc" "none_0hit")])
1940 (define_expand "zero_extendhisi2"
1941 [(set (match_operand:SI 0 "general_operand" "")
1943 (match_operand:HI 1 "general_operand" "")))]
1948 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx,!dax,!dax,!dax")
1950 (match_operand:HI 1 "general_operand" "0,dax,m,0,dax,m")))]
1959 [(set_attr "cc" "none_0hit")])
1962 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx")
1964 (match_operand:HI 1 "general_operand" "0,dx,m")))]
1970 [(set_attr "cc" "none_0hit")])
1972 ;;- sign extension instructions
1974 (define_expand "extendqisi2"
1975 [(set (match_operand:SI 0 "general_operand" "")
1977 (match_operand:QI 1 "general_operand" "")))]
1982 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,!dax,!dax")
1984 (match_operand:QI 1 "general_operand" "0,dx,0,dax")))]
1991 [(set_attr "cc" "none_0hit")])
1994 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx")
1996 (match_operand:QI 1 "general_operand" "0,dx")))]
2001 [(set_attr "cc" "none_0hit")])
2003 (define_expand "extendhisi2"
2004 [(set (match_operand:SI 0 "general_operand" "")
2006 (match_operand:HI 1 "general_operand" "")))]
2011 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,!dax,!dax")
2013 (match_operand:HI 1 "general_operand" "0,dax,0,dax")))]
2020 [(set_attr "cc" "none_0hit")])
2023 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx")
2025 (match_operand:HI 1 "general_operand" "0,dx")))]
2030 [(set_attr "cc" "none_0hit")])
2032 ;; ----------------------------------------------------------------------
2034 ;; ----------------------------------------------------------------------
2036 (define_expand "ashlsi3"
2037 [(set (match_operand:SI 0 "register_operand" "")
2039 (match_operand:SI 1 "register_operand" "")
2040 (match_operand:QI 2 "nonmemory_operand" "")))]
2045 [(set (match_operand:SI 0 "register_operand" "=dax,dx,!dax")
2047 (match_operand:SI 1 "register_operand" "0,0,dax")
2048 (match_operand:QI 2 "nonmemory_operand" "J,dxi,dax")))]
2052 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 1)
2053 return \"add %0,%0\";
2055 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 2)
2058 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 3
2059 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS)
2060 return \"asl2 %0\;add %0,%0\";
2062 if (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 4
2063 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS)
2064 return \"asl2 %0\;asl2 %0\";
2066 if (true_regnum (operands[1]) == true_regnum (operands[0]))
2067 return \"asl %S2,%0\";
2069 if (REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
2070 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
2071 && true_regnum (operands[0]) != true_regnum (operands[2]))
2072 return \"mov %1,%0\;asl %S2,%0\";
2073 return \"asl %2,%1,%0\";
2075 [(set_attr "cc" "set_zn")])
2078 [(set (match_operand:SI 0 "register_operand" "=dax,dx,dx,dx,dx")
2080 (match_operand:SI 1 "register_operand" "0,0,0,0,0")
2081 (match_operand:QI 2 "nonmemory_operand" "J,K,M,L,dxi")))]
2089 [(set_attr "cc" "set_zn")])
2091 (define_expand "lshrsi3"
2092 [(set (match_operand:SI 0 "register_operand" "")
2094 (match_operand:SI 1 "register_operand" "")
2095 (match_operand:QI 2 "nonmemory_operand" "")))]
2100 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
2102 (match_operand:SI 1 "register_operand" "0,dax")
2103 (match_operand:QI 2 "nonmemory_operand" "dxi,dax")))]
2107 if (true_regnum (operands[1]) == true_regnum (operands[0]))
2108 return \"lsr %S2,%0\";
2110 if (REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
2111 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
2112 && true_regnum (operands[0]) != true_regnum (operands[2]))
2113 return \"mov %1,%0\;lsr %S2,%0\";
2114 return \"lsr %2,%1,%0\";
2116 [(set_attr "cc" "set_zn")])
2119 [(set (match_operand:SI 0 "register_operand" "=dx")
2121 (match_operand:SI 1 "register_operand" "0")
2122 (match_operand:QI 2 "nonmemory_operand" "dxi")))]
2125 [(set_attr "cc" "set_zn")])
2127 (define_expand "ashrsi3"
2128 [(set (match_operand:SI 0 "register_operand" "")
2130 (match_operand:SI 1 "register_operand" "")
2131 (match_operand:QI 2 "nonmemory_operand" "")))]
2136 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
2138 (match_operand:SI 1 "register_operand" "0,dax")
2139 (match_operand:QI 2 "nonmemory_operand" "dxi,dax")))]
2143 if (true_regnum (operands[1]) == true_regnum (operands[0]))
2144 return \"asr %S2,%0\";
2146 if (REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
2147 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
2148 && true_regnum (operands[0]) != true_regnum (operands[2]))
2149 return \"mov %1,%0\;asr %S2,%0\";
2150 return \"asr %2,%1,%0\";
2152 [(set_attr "cc" "set_zn")])
2155 [(set (match_operand:SI 0 "register_operand" "=dx")
2157 (match_operand:SI 1 "register_operand" "0")
2158 (match_operand:QI 2 "nonmemory_operand" "dxi")))]
2161 [(set_attr "cc" "set_zn")])
2163 ;; ----------------------------------------------------------------------
2165 ;; ----------------------------------------------------------------------
2167 ;; The mn103 series does not have floating point instructions, but since
2168 ;; FP values are held in integer regs, we can clear the high bit easily
2169 ;; which gives us an efficient inline floating point absolute value.
2171 ;; Similarly for negation of a FP value.
2174 (define_expand "absdf2"
2175 [(set (match_operand:DF 0 "register_operand" "")
2176 (abs:DF (match_operand:DF 1 "register_operand" "")))]
2180 rtx target, result, insns;
2183 target = operand_subword (operands[0], 1, 1, DFmode);
2184 result = expand_binop (SImode, and_optab,
2185 operand_subword_force (operands[1], 1, DFmode),
2186 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
2191 if (result != target)
2192 emit_move_insn (result, target);
2194 emit_move_insn (operand_subword (operands[0], 0, 1, DFmode),
2195 operand_subword_force (operands[1], 0, DFmode));
2197 insns = get_insns ();
2200 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
2204 (define_expand "abssf2"
2205 [(set (match_operand:SF 0 "register_operand" "")
2206 (abs:SF (match_operand:SF 1 "register_operand" "")))]
2215 emit_insn (gen_abssf2_am33_2 (operands[0], operands[1]));
2219 target = operand_subword_force (operands[0], 0, SFmode);
2220 result = expand_binop (SImode, and_optab,
2221 operand_subword_force (operands[1], 0, SFmode),
2222 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
2226 if (result != target)
2227 emit_move_insn (result, target);
2229 /* Make a place for REG_EQUAL. */
2230 emit_move_insn (operands[0], operands[0]);
2235 (define_insn "abssf2_am33_2"
2236 [(set (match_operand:SF 0 "register_operand" "=f,f")
2237 (abs:SF (match_operand:SF 1 "register_operand" "0,?f")))]
2242 [(set_attr "cc" "none_0hit")])
2244 (define_expand "negdf2"
2245 [(set (match_operand:DF 0 "register_operand" "")
2246 (neg:DF (match_operand:DF 1 "register_operand" "")))]
2250 rtx target, result, insns;
2253 target = operand_subword (operands[0], 1, 1, DFmode);
2254 result = expand_binop (SImode, xor_optab,
2255 operand_subword_force (operands[1], 1, DFmode),
2256 GEN_INT (trunc_int_for_mode (0x80000000, SImode)),
2257 target, 0, OPTAB_WIDEN);
2262 if (result != target)
2263 emit_move_insn (result, target);
2265 emit_move_insn (operand_subword (operands[0], 0, 1, DFmode),
2266 operand_subword_force (operands[1], 0, DFmode));
2268 insns = get_insns ();
2271 emit_no_conflict_block (insns, operands[0], operands[1], 0, 0);
2275 (define_expand "negsf2"
2276 [(set (match_operand:SF 0 "register_operand" "")
2277 (neg:SF (match_operand:SF 1 "register_operand" "")))]
2286 emit_insn (gen_negsf2_am33_2 (operands[0], operands[1]));
2290 target = operand_subword_force (operands[0], 0, SFmode);
2291 result = expand_binop (SImode, xor_optab,
2292 operand_subword_force (operands[1], 0, SFmode),
2293 GEN_INT (trunc_int_for_mode (0x80000000, SImode)),
2294 target, 0, OPTAB_WIDEN);
2298 if (result != target)
2299 emit_move_insn (result, target);
2301 /* Make a place for REG_EQUAL. */
2302 emit_move_insn (operands[0], operands[0]);
2306 (define_insn "negsf2_am33_2"
2307 [(set (match_operand:SF 0 "register_operand" "=f,f")
2308 (neg:SF (match_operand:SF 1 "register_operand" "0,?f")))]
2313 [(set_attr "cc" "none_0hit")])
2315 (define_expand "sqrtsf2"
2316 [(set (match_operand:SF 0 "register_operand" "")
2317 (sqrt:SF (match_operand:SF 1 "register_operand" "")))]
2318 "TARGET_AM33_2 && flag_unsafe_math_optimizations"
2321 rtx scratch = gen_reg_rtx (SFmode);
2322 emit_insn (gen_rsqrtsf2 (scratch, operands[1], CONST1_RTX (SFmode)));
2323 emit_insn (gen_divsf3 (operands[0], force_reg (SFmode, CONST1_RTX (SFmode)),
2328 (define_insn "rsqrtsf2"
2329 [(set (match_operand:SF 0 "register_operand" "=f,f")
2330 (div:SF (match_operand:SF 2 "const_1f_operand" "F,F")
2331 (sqrt:SF (match_operand:SF 1 "register_operand" "0,?f"))))]
2336 [(set_attr "cc" "none_0hit")])
2338 (define_insn "addsf3"
2339 [(set (match_operand:SF 0 "register_operand" "=f,f")
2340 (plus:SF (match_operand:SF 1 "register_operand" "%0,f")
2341 (match_operand:SF 2 "general_operand" "f,?fF")))]
2346 [(set_attr "cc" "none_0hit")])
2348 (define_insn "subsf3"
2349 [(set (match_operand:SF 0 "register_operand" "=f,f")
2350 (minus:SF (match_operand:SF 1 "register_operand" "0,f")
2351 (match_operand:SF 2 "general_operand" "f,?fF")))]
2356 [(set_attr "cc" "none_0hit")])
2358 (define_insn "mulsf3"
2359 [(set (match_operand:SF 0 "register_operand" "=f,f")
2360 (mult:SF (match_operand:SF 1 "register_operand" "%0,f")
2361 (match_operand:SF 2 "general_operand" "f,?fF")))]
2366 [(set_attr "cc" "none_0hit")])
2368 (define_insn "divsf3"
2369 [(set (match_operand:SF 0 "register_operand" "=f,f")
2370 (div:SF (match_operand:SF 1 "register_operand" "0,f")
2371 (match_operand:SF 2 "general_operand" "f,?fF")))]
2376 [(set_attr "cc" "none_0hit")])
2378 (define_insn "fmaddsf4"
2379 [(set (match_operand:SF 0 "register_operand" "=A")
2380 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f")
2381 (match_operand:SF 2 "register_operand" "f"))
2382 (match_operand:SF 3 "register_operand" "f")))]
2384 "fmadd %1, %2, %3, %0"
2385 [(set_attr "cc" "none_0hit")])
2387 (define_insn "fmsubsf4"
2388 [(set (match_operand:SF 0 "register_operand" "=A")
2389 (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f")
2390 (match_operand:SF 2 "register_operand" "f"))
2391 (match_operand:SF 3 "register_operand" "f")))]
2393 "fmsub %1, %2, %3, %0"
2394 [(set_attr "cc" "none_0hit")])
2396 (define_insn "fnmaddsf4"
2397 [(set (match_operand:SF 0 "register_operand" "=A")
2398 (minus:SF (match_operand:SF 3 "register_operand" "f")
2399 (mult:SF (match_operand:SF 1 "register_operand" "%f")
2400 (match_operand:SF 2 "register_operand" "f"))))]
2402 "fnmadd %1, %2, %3, %0"
2403 [(set_attr "cc" "none_0hit")])
2405 (define_insn "fnmsubsf4"
2406 [(set (match_operand:SF 0 "register_operand" "=A")
2407 (minus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "%f")
2408 (match_operand:SF 2 "register_operand" "f")))
2409 (match_operand:SF 3 "register_operand" "f")))]
2411 "fnmsub %1, %2, %3, %0"
2412 [(set_attr "cc" "none_0hit")])
2415 ;; ----------------------------------------------------------------------
2416 ;; PROLOGUE/EPILOGUE
2417 ;; ----------------------------------------------------------------------
2418 (define_expand "prologue"
2421 "expand_prologue (); DONE;")
2423 (define_expand "epilogue"
2432 (define_insn "return_internal"
2437 [(set_attr "cc" "clobber")])
2439 ;; This insn restores the callee saved registers and does a return, it
2440 ;; can also deallocate stack space.
2441 (define_insn "return_internal_regs"
2443 (match_operand:SI 0 "const_int_operand" "i")
2448 fputs (\"\\tret \", asm_out_file);
2449 mn10300_print_reg_list (asm_out_file, mn10300_get_live_callee_saved_regs ());
2450 fprintf (asm_out_file, \",%d\\n\", (int) INTVAL (operands[0]));
2453 [(set_attr "cc" "clobber")])
2455 ;; This instruction matches one generated by mn10300_gen_multiple_store()
2456 (define_insn "store_movm"
2457 [(match_parallel 0 "store_multiple_operation"
2458 [(set (reg:SI 9) (plus:SI (reg:SI 9) (match_operand 1 "" "")))])]
2462 fputs (\"\\tmovm \", asm_out_file);
2463 mn10300_print_reg_list (asm_out_file,
2464 store_multiple_operation (operands[0], VOIDmode));
2465 fprintf (asm_out_file, \",(sp)\\n\");
2468 [(set_attr "cc" "clobber")])
2470 (define_insn "return"
2472 "can_use_return_insn ()"
2475 rtx next = next_active_insn (insn);
2478 && GET_CODE (next) == JUMP_INSN
2479 && GET_CODE (PATTERN (next)) == RETURN)
2484 [(set_attr "cc" "clobber")])
2486 ;; Try to combine consecutive updates of the stack pointer (or any
2487 ;; other register for that matter).
2489 [(set (match_operand:SI 0 "register_operand" "=dxay")
2490 (plus:SI (match_dup 0)
2491 (match_operand 1 "const_int_operand" "")))
2493 (plus:SI (match_dup 0)
2494 (match_operand 2 "const_int_operand" "")))]
2498 operands[1] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[1]));
2499 return \"add %1,%0\";
2501 [(set_attr "cc" "clobber")])
2504 ;; We had patterns to check eq/ne, but the they don't work because
2505 ;; 0x80000000 + 0x80000000 = 0x0 with a carry out.
2507 ;; The Z flag and C flag would be set, and we have no way to
2508 ;; check for the Z flag set and C flag clear.
2510 ;; This will work on the mn10200 because we can check the ZX flag
2511 ;; if the comparison is in HImode.
2513 [(set (cc0) (match_operand:SI 0 "register_operand" "dx"))
2514 (set (pc) (if_then_else (ge (cc0) (const_int 0))
2515 (match_operand 1 "" "")
2517 "dead_or_set_p (ins1, operands[0]) && REG_OK_FOR_INDEX_P (operands[0])"
2519 [(set_attr "cc" "clobber")])
2522 [(set (cc0) (match_operand:SI 0 "register_operand" "dx"))
2523 (set (pc) (if_then_else (lt (cc0) (const_int 0))
2524 (match_operand 1 "" "")
2526 "dead_or_set_p (ins1, operands[0]) && REG_OK_FOR_INDEX_P (operands[0])"
2528 [(set_attr "cc" "clobber")])
2531 [(set (cc0) (match_operand:SI 0 "register_operand" "dx"))
2532 (set (pc) (if_then_else (ge (cc0) (const_int 0))
2534 (match_operand 1 "" "")))]
2535 "dead_or_set_p (ins1, operands[0]) && REG_OK_FOR_INDEX_P (operands[0])"
2537 [(set_attr "cc" "clobber")])
2540 [(set (cc0) (match_operand:SI 0 "register_operand" "dx"))
2541 (set (pc) (if_then_else (lt (cc0) (const_int 0))
2543 (match_operand 1 "" "")))]
2544 "dead_or_set_p (ins1, operands[0]) && REG_OK_FOR_INDEX_P (operands[0])"
2546 [(set_attr "cc" "clobber")])
2548 (define_expand "int_label"
2549 [(unspec [(match_operand:SI 0 "" "")] UNSPEC_INT_LABEL)]
2552 (define_expand "GOTaddr2picreg"
2556 /* It would be nice to be able to have int_label keep track of the
2557 counter and all, but if we add C code to it, we'll get an insn
2558 back, and we just want the pattern. */
2559 operands[0] = gen_int_label (GEN_INT (mn10300_unspec_int_label_counter++));
2561 emit_insn (gen_am33_loadPC (operands[0]));
2563 emit_insn (gen_mn10300_loadPC (operands[0]));
2564 emit_insn (gen_add_GOT_to_pic_reg (operands[0]));
2569 (define_insn "am33_loadPC"
2571 [(set (reg:SI PIC_REG) (pc))
2572 (use (match_operand 0 "" ""))])]
2577 (define_insn_and_split "mn10300_loadPC"
2579 [(set (reg:SI PIC_REG) (pc))
2580 (use (match_operand 0 "" ""))])]
2584 [(match_operand 0 "" "")]
2587 rtx sp_reg = gen_rtx_REG (SImode, SP_REG);
2588 int need_stack_space = (get_frame_size () == 0
2589 && current_function_outgoing_args_size == 0);
2591 if (need_stack_space)
2592 emit_move_insn (sp_reg, plus_constant (sp_reg, -4));
2594 emit_insn (gen_call_next_insn (operands[0]));
2596 if (need_stack_space)
2597 emit_insn (gen_pop_pic_reg ());
2599 emit_move_insn (pic_offset_table_rtx, gen_rtx_MEM (SImode, sp_reg));
2604 (define_insn "call_next_insn"
2606 [(set (mem:SI (reg:SI SP_REG)) (pc))
2607 (use (match_operand 0 "" ""))])]
2611 (define_expand "add_GOT_to_pic_reg"
2612 [(set (reg:SI PIC_REG)
2619 (const (match_operand:SI 0 "" ""))
2625 operands[1] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME);
2628 (define_expand "symGOT2reg"
2629 [(match_operand:SI 0 "" "")
2630 (match_operand:SI 1 "" "")]
2634 rtx insn = emit_insn (gen_symGOT2reg_i (operands[0], operands[1]));
2636 MEM_READONLY_P (SET_SRC (PATTERN (insn))) = 1;
2638 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
2644 (define_expand "symGOT2reg_i"
2645 [(set (match_operand:SI 0 "" "")
2646 (mem:SI (plus:SI (reg:SI PIC_REG)
2647 (const (unspec [(match_operand:SI 1 "" "")]
2652 (define_expand "symGOTOFF2reg"
2653 [(match_operand:SI 0 "" "") (match_operand:SI 1 "" "")]
2657 rtx insn = emit_insn (gen_symGOTOFF2reg_i (operands[0], operands[1]));
2659 REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, operands[1],
2665 (define_expand "symGOTOFF2reg_i"
2666 [(set (match_operand:SI 0 "" "")
2667 (const (unspec [(match_operand:SI 1 "" "")] UNSPEC_GOTOFF)))
2668 (set (match_dup 0) (plus:SI (match_dup 0) (reg:SI PIC_REG)))]
2672 (define_expand "sym2PIC"
2673 [(unspec [(match_operand:SI 0 "" "")] UNSPEC_PIC)]
2676 (define_expand "sym2PLT"
2677 [(unspec [(match_operand:SI 0 "" "")] UNSPEC_PLT)]