1 ;; GCC machine description for Matsushita MN10300
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 ;; 2005, 2006, 2007, 2008, 2009, 2010
4 ;; Free Software Foundation, Inc.
5 ;; Contributed by Jeff Law (law@cygnus.com).
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; GCC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
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.
41 (include "predicates.md")
42 (include "constraints.md")
44 ;; ----------------------------------------------------------------------
46 ;; ----------------------------------------------------------------------
50 (define_expand "movqi"
51 [(set (match_operand:QI 0 "general_operand")
52 (match_operand:QI 1 "general_operand"))]
56 /* One of the ops has to be in a register. */
57 if (!register_operand (operand0, QImode)
58 && !register_operand (operand1, QImode))
59 operands[1] = copy_to_mode_reg (QImode, operand1);
62 (define_insn "*am33_movqi"
63 [(set (match_operand:QI 0 "nonimmediate_operand" "=d*x*a*f,d*x*a,d*x*a,m,*f,d*x*a")
64 (match_operand:QI 1 "general_operand" "0,d*xai,m,d*xa,d*xa*f,*f"))]
66 && (register_operand (operands[0], QImode)
67 || register_operand (operands[1], QImode))"
70 switch (which_alternative)
75 if (CONST_DOUBLE_P (operands[1]))
78 xoperands[0] = operands[0];
79 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
80 output_asm_insn (\"mov %1,%0\", xoperands);
84 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS
85 && CONST_INT_P (operands[1]))
87 HOST_WIDE_INT val = INTVAL (operands[1]);
89 if (((val & 0x80) && ! (val & 0xffffff00))
90 || ((val & 0x800000) && ! (val & 0xff000000)))
91 return \"movu %1,%0\";
96 return \"movbu %1,%0\";
99 return \"fmov %1,%0\";
106 (define_insn "*mn10300_movqi"
107 [(set (match_operand:QI 0 "nonimmediate_operand" "=d*a,d,d,!*a,d*a,d,m")
108 (match_operand:QI 1 "general_operand" "0,I,i,i,da,m,d"))]
109 "register_operand (operands[0], QImode)
110 || register_operand (operands[1], QImode)"
113 switch (which_alternative)
121 if (CONST_DOUBLE_P (operands[1]))
124 xoperands[0] = operands[0];
125 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
126 output_asm_insn (\"mov %1,%0\", xoperands);
130 return \"mov %1,%0\";
133 return \"movbu %1,%0\";
142 (define_expand "movhi"
143 [(set (match_operand:HI 0 "general_operand")
144 (match_operand:HI 1 "general_operand"))]
148 /* One of the ops has to be in a register. */
149 if (!register_operand (operand1, HImode)
150 && !register_operand (operand0, HImode))
151 operands[1] = copy_to_mode_reg (HImode, operand1);
154 (define_insn "*am33_movhi"
155 [(set (match_operand:HI 0 "nonimmediate_operand" "=d*x*a*f,d*x*a,d*x*a,m,*f,d*x*a")
156 (match_operand:HI 1 "general_operand" "0,d*x*ai,m,d*x*a,d*x*a*f,*f"))]
158 && (register_operand (operands[0], HImode)
159 || register_operand (operands[1], HImode))"
162 switch (which_alternative)
167 if (CONST_DOUBLE_P (operands[1]))
170 xoperands[0] = operands[0];
171 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
172 output_asm_insn (\"mov %1,%0\", xoperands);
176 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS
177 && CONST_INT_P (operands[1]))
179 HOST_WIDE_INT val = INTVAL (operands[1]);
181 if (((val & 0x80) && ! (val & 0xffffff00))
182 || ((val & 0x800000) && ! (val & 0xff000000)))
183 return \"movu %1,%0\";
185 return \"mov %1,%0\";
188 return \"movhu %1,%0\";
191 return \"fmov %1,%0\";
198 (define_insn "*mn10300_movhi"
199 [(set (match_operand:HI 0 "nonimmediate_operand" "=d*a,d,d,!*a,d*a,d,m")
200 (match_operand:HI 1 "general_operand" "0,I,i,i,da,m,d"))]
201 "register_operand (operands[0], HImode)
202 || register_operand (operands[1], HImode)"
205 switch (which_alternative)
213 if (CONST_DOUBLE_P (operands[1]))
216 xoperands[0] = operands[0];
217 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
218 output_asm_insn (\"mov %1,%0\", xoperands);
221 return \"mov %1,%0\";
224 return \"movhu %1,%0\";
233 ;; We use this to handle addition of two values when one operand is the
234 ;; stack pointer and the other is a memory reference of some kind. Reload
235 ;; does not handle them correctly without this expander.
236 (define_expand "reload_insi"
237 [(set (match_operand:SI 0 "register_operand" "=a")
238 (match_operand:SI 1 "impossible_plus_operand" ""))
239 (clobber (match_operand:SI 2 "register_operand" "=&r"))]
243 gcc_assert (REGNO (operands[0]) != REGNO (operands[2]));
245 if (XEXP (operands[1], 0) == stack_pointer_rtx)
247 if (GET_CODE (XEXP (operands[1], 1)) == SUBREG
248 && (GET_MODE_SIZE (GET_MODE (XEXP (operands[1], 1)))
249 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (XEXP (operands[1], 1))))))
250 emit_move_insn (operands[2],
252 (GET_MODE (XEXP (operands[1], 1)),
253 SUBREG_REG (XEXP (operands[1], 1))));
255 emit_move_insn (operands[2], XEXP (operands[1], 1));
256 emit_move_insn (operands[0], XEXP (operands[1], 0));
260 if (GET_CODE (XEXP (operands[1], 0)) == SUBREG
261 && (GET_MODE_SIZE (GET_MODE (XEXP (operands[1], 0)))
262 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (XEXP (operands[1], 0))))))
263 emit_move_insn (operands[2],
265 (GET_MODE (XEXP (operands[1], 0)),
266 SUBREG_REG (XEXP (operands[1], 0))));
268 emit_move_insn (operands[2], XEXP (operands[1], 0));
269 emit_move_insn (operands[0], XEXP (operands[1], 1));
271 emit_insn (gen_addsi3 (operands[0], operands[0], operands[2]));
275 (define_insn "pop_pic_reg"
276 [(set (reg:SI PIC_REG)
277 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
281 (define_expand "movsi"
282 [(set (match_operand:SI 0 "general_operand")
283 (match_operand:SI 1 "general_operand"))]
287 /* One of the ops has to be in a register. */
288 if (!register_operand (operand1, SImode)
289 && !register_operand (operand0, SImode))
290 operands[1] = copy_to_mode_reg (SImode, operand1);
294 if (SYMBOLIC_CONST_P (operands[1]))
296 if (MEM_P (operands[0]))
297 operands[1] = force_reg (Pmode, operands[1]);
300 temp = (!can_create_pseudo_p ()
302 : gen_reg_rtx (Pmode));
303 operands[1] = mn10300_legitimize_pic_address (operands[1], temp);
306 else if (GET_CODE (operands[1]) == CONST
307 && GET_CODE (XEXP (operands[1], 0)) == PLUS
308 && SYMBOLIC_CONST_P (XEXP (XEXP (operands[1], 0), 0)))
310 temp = !can_create_pseudo_p () ? operands[0] : gen_reg_rtx (Pmode);
311 temp = mn10300_legitimize_pic_address (XEXP (XEXP (operands[1], 0), 0),
313 operands[1] = expand_binop (SImode, add_optab, temp,
314 XEXP (XEXP (operands[1], 0), 1),
315 (!can_create_pseudo_p ()
317 : gen_reg_rtx (Pmode)),
323 (define_insn "*movsi_internal"
324 [(set (match_operand:SI 0 "nonimmediate_operand"
325 "=dx,ax,dx,a,dxm,dxm,axm,axm,dx,dx,ax,ax,axR,!*y,*f,*f,dxaQ")
326 (match_operand:SI 1 "general_operand"
327 "0,0,I,I,dx,ax,dx,ax,dixm,aixm,dixm,aixm,!*y,axR,0,dxaQi*f,*f"))]
328 "register_operand (operands[0], SImode)
329 || register_operand (operands[1], SImode)"
332 switch (which_alternative)
349 if (CONST_DOUBLE_P (operands[1]))
352 xoperands[0] = operands[0];
353 xoperands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
354 output_asm_insn (\"mov %1,%0\", xoperands);
358 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS
359 && CONST_INT_P (operands[1]))
361 HOST_WIDE_INT val = INTVAL (operands[1]);
363 if (((val & 0x80) && ! (val & 0xffffff00))
364 || ((val & 0x800000) && ! (val & 0xff000000)))
365 return \"movu %1,%0\";
367 return \"mov %1,%0\";
372 return \"fmov %1,%0\";
379 (define_expand "movsf"
380 [(set (match_operand:SF 0 "general_operand")
381 (match_operand:SF 1 "general_operand"))]
385 /* One of the ops has to be in a register. */
386 if (!register_operand (operand1, SFmode)
387 && !register_operand (operand0, SFmode))
388 operands[1] = copy_to_mode_reg (SFmode, operand1);
391 (define_insn "*movsf_internal"
392 [(set (match_operand:SF 0 "nonimmediate_operand" "=f,dx,ax,dx,a,f,dxaQ,daxm,dax")
393 (match_operand:SF 1 "general_operand" "0,0,0,G,G,fdxaQF,f,dax,daxFm"))]
394 "register_operand (operands[0], SFmode)
395 || register_operand (operands[1], SFmode)"
398 switch (which_alternative)
404 /* Cases 3 & 4: below. */
407 return \"fmov %1, %0\";
412 if (REGNO_REG_CLASS (true_regnum (operands[0])) == EXTENDED_REGS
413 && CONST_INT_P (operands[1]))
415 HOST_WIDE_INT val = INTVAL (operands[1]);
417 if (((val & 0x80) && ! (val & 0xffffff00))
418 || ((val & 0x800000) && ! (val & 0xff000000)))
419 return \"movu %1,%0\";
421 return \"mov %1,%0\";
428 (define_expand "movdi"
429 [(set (match_operand:DI 0 "general_operand")
430 (match_operand:DI 1 "general_operand"))]
434 /* One of the ops has to be in a register. */
435 if (!register_operand (operand1, DImode)
436 && !register_operand (operand0, DImode))
437 operands[1] = copy_to_mode_reg (DImode, operand1);
440 (define_insn "*movdi_internal"
441 [(set (match_operand:DI 0 "nonimmediate_operand"
442 "=dx,ax,dx,a,dxm,dxm,axm,axm,dx,dx,ax,ax,*f,*f,*f,dxa,*f,Q")
443 (match_operand:DI 1 "general_operand"
444 "0,0,I,I,dx,ax,dx,ax,dxim,axim,dxim,axim,0,*f,dxai,*f,Q,*f"))]
445 "register_operand (operands[0], DImode)
446 || register_operand (operands[1], DImode)"
452 switch (which_alternative)
459 return \"mov 0, %L0\;mov 0, %H0\";
462 if (rtx_equal_p (operands[0], operands[1]))
463 return \"sub %L1,%L0\;mov %L0,%H0\";
465 return \"mov %1,%L0\;mov %L0,%H0\";
474 if (CONST_INT_P (operands[1]))
477 split_double (operands[1], &low, &high);
478 val[0] = INTVAL (low);
479 val[1] = INTVAL (high);
481 if (CONST_DOUBLE_P (operands[1]))
483 if (GET_MODE (operands[1]) == DFmode)
485 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
486 REAL_VALUE_TO_TARGET_DOUBLE (rv, val);
488 else if (GET_MODE (operands[1]) == VOIDmode
489 || GET_MODE (operands[1]) == DImode)
491 val[0] = CONST_DOUBLE_LOW (operands[1]);
492 val[1] = CONST_DOUBLE_HIGH (operands[1]);
496 if (MEM_P (operands[1])
497 && reg_overlap_mentioned_p (operands[0], XEXP (operands[1], 0)))
499 rtx temp = operands[0];
501 while (GET_CODE (temp) == SUBREG)
502 temp = SUBREG_REG (temp);
504 gcc_assert (REG_P (temp));
506 if (reg_overlap_mentioned_p (gen_rtx_REG (SImode, REGNO (temp)),
507 XEXP (operands[1], 0)))
508 return \"mov %H1,%H0\;mov %L1,%L0\";
510 return \"mov %L1,%L0\;mov %H1,%H0\";
513 else if (MEM_P (operands[1])
514 && CONSTANT_ADDRESS_P (XEXP (operands[1], 0))
515 && REGNO_REG_CLASS (REGNO (operands[0])) == ADDRESS_REGS)
519 xoperands[0] = operands[0];
520 xoperands[1] = XEXP (operands[1], 0);
522 output_asm_insn (\"mov %1,%L0\;mov (4,%L0),%H0\;mov (%L0),%L0\",
528 if ((CONST_INT_P (operands[1])
529 || CONST_DOUBLE_P (operands[1]))
532 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
533 output_asm_insn (\"mov 0, %L0\", operands);
535 output_asm_insn (\"mov %L1,%L0\", operands);
537 else if ((CONST_INT_P (operands[1])
538 || CONST_DOUBLE_P (operands[1]))
539 && (REGNO_REG_CLASS (true_regnum (operands[0]))
541 && (((val[0] & 0x80) && ! (val[0] & 0xffffff00))
542 || ((val[0] & 0x800000) && ! (val[0] & 0xff000000))))
543 output_asm_insn (\"movu %L1,%L0\", operands);
545 output_asm_insn (\"mov %L1,%L0\", operands);
547 if ((CONST_INT_P (operands[1])
548 || CONST_DOUBLE_P (operands[1]))
551 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
552 output_asm_insn (\"mov 0, %H0\", operands);
554 output_asm_insn (\"mov %H1,%H0\", operands);
556 else if ((CONST_INT_P (operands[1])
557 || CONST_DOUBLE_P (operands[1]))
559 output_asm_insn (\"mov %L0,%H0\", operands);
560 else if ((CONST_INT_P (operands[1])
561 || CONST_DOUBLE_P (operands[1]))
562 && (REGNO_REG_CLASS (true_regnum (operands[0]))
564 && (((val[1] & 0x80) && ! (val[1] & 0xffffff00))
565 || ((val[1] & 0x800000) && ! (val[1] & 0xff000000))))
566 output_asm_insn (\"movu %H1,%H0\", operands);
568 output_asm_insn (\"mov %H1,%H0\", operands);
576 return \"fmov %L1, %L0\;fmov %H1, %H0\";
578 if (MEM_P (operands[1])
579 && CONST_INT_P (XEXP (operands[1], 0))
580 && (INTVAL (XEXP (operands[1], 0)) & 7) == 0)
581 return \"fmov %D1, %D0\";
583 return \"fmov %L1, %L0\;fmov %H1, %H0\";
585 if (MEM_P (operands[0])
586 && CONST_INT_P (XEXP (operands[0], 0))
587 && (INTVAL (XEXP (operands[0], 0)) & 7) == 0)
588 return \"fmov %D1, %D0\";
590 return \"fmov %L1, %L0\;fmov %H1, %H0\";
597 (define_expand "movdf"
598 [(set (match_operand:DF 0 "general_operand")
599 (match_operand:DF 1 "general_operand"))]
603 /* One of the ops has to be in a register. */
604 if (!register_operand (operand1, DFmode)
605 && !register_operand (operand0, DFmode))
606 operands[1] = copy_to_mode_reg (DFmode, operand1);
609 (define_insn "*am33_2_movdf"
610 [(set (match_operand:DF 0 "nonimmediate_operand"
611 ;; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
612 "=f,dx,ax,dx,f,f,dxa,f,Q,a,dxm,dxm,axm,axm,dx,dx,ax,ax")
613 (match_operand:DF 1 "general_operand"
614 ;; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
615 "0,0,0,G,f,dxaF,f,Q,f,G,dx,ax,dx,ax,dxFm,axFm,dxFm,axFm"))]
617 && (register_operand (operands[0], DFmode)
618 || register_operand (operands[1], DFmode))"
624 switch (which_alternative)
632 return \"mov 0, %L0\;mov 0, %H0\";
637 return \"fmov %L1, %L0\;fmov %H1, %H0\";
640 if (MEM_P (operands[1])
641 && CONST_INT_P (XEXP (operands[1], 0))
642 && (INTVAL (XEXP (operands[1], 0)) & 7) == 0)
643 return \"fmov %D1, %D0\";
645 return \"fmov %L1, %L0\;fmov %H1, %H0\";
648 if (MEM_P (operands[0])
649 && CONST_INT_P (XEXP (operands[0], 0))
650 && (INTVAL (XEXP (operands[0], 0)) & 7) == 0)
651 return \"fmov %D1, %D0\";
653 return \"fmov %L1, %L0\;fmov %H1, %H0\";
656 if (rtx_equal_p (operands[0], operands[1]))
657 return \"sub %L1,%L0\;mov %L0,%H0\";
659 return \"mov %1,%L0\;mov %L0,%H0\";
668 if (CONST_INT_P (operands[1]))
671 split_double (operands[1], &low, &high);
672 val[0] = INTVAL (low);
673 val[1] = INTVAL (high);
675 if (CONST_DOUBLE_P (operands[1]))
677 if (GET_MODE (operands[1]) == DFmode)
679 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
680 REAL_VALUE_TO_TARGET_DOUBLE (rv, val);
682 else if (GET_MODE (operands[1]) == VOIDmode
683 || GET_MODE (operands[1]) == DImode)
685 val[0] = CONST_DOUBLE_LOW (operands[1]);
686 val[1] = CONST_DOUBLE_HIGH (operands[1]);
690 if (MEM_P (operands[1])
691 && reg_overlap_mentioned_p (operands[0], XEXP (operands[1], 0)))
693 rtx temp = operands[0];
695 while (GET_CODE (temp) == SUBREG)
696 temp = SUBREG_REG (temp);
698 gcc_assert (REG_P (temp));
700 if (reg_overlap_mentioned_p (gen_rtx_REG (SImode, REGNO (temp)),
701 XEXP (operands[1], 0)))
702 return \"mov %H1,%H0\;mov %L1,%L0\";
704 return \"mov %L1,%L0\;mov %H1,%H0\";
707 else if (MEM_P (operands[1])
708 && CONSTANT_ADDRESS_P (XEXP (operands[1], 0))
709 && REGNO_REG_CLASS (REGNO (operands[0])) == ADDRESS_REGS)
713 xoperands[0] = operands[0];
714 xoperands[1] = XEXP (operands[1], 0);
716 output_asm_insn (\"mov %1,%L0\;mov (4,%L0),%H0\;mov (%L0),%L0\",
722 if ((CONST_INT_P (operands[1])
723 || CONST_DOUBLE_P (operands[1]))
726 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
727 output_asm_insn (\"mov 0, %L0\", operands);
729 output_asm_insn (\"mov %L1,%L0\", operands);
731 else if ((CONST_INT_P (operands[1])
732 || CONST_DOUBLE_P (operands[1]))
733 && (REGNO_REG_CLASS (true_regnum (operands[0]))
735 && (((val[0] & 0x80) && ! (val[0] & 0xffffff00))
736 || ((val[0] & 0x800000) && ! (val[0] & 0xff000000))))
737 output_asm_insn (\"movu %L1,%L0\", operands);
739 output_asm_insn (\"mov %L1,%L0\", operands);
741 if ((CONST_INT_P (operands[1])
742 || CONST_DOUBLE_P (operands[1]))
745 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
746 output_asm_insn (\"mov 0, %H0\", operands);
748 output_asm_insn (\"mov %H1,%H0\", operands);
750 else if ((CONST_INT_P (operands[1])
751 || CONST_DOUBLE_P (operands[1]))
753 output_asm_insn (\"mov %L0,%H0\", operands);
754 else if ((CONST_INT_P (operands[1])
755 || CONST_DOUBLE_P (operands[1]))
756 && (REGNO_REG_CLASS (true_regnum (operands[0]))
758 && (((val[1] & 0x80) && ! (val[1] & 0xffffff00))
759 || ((val[1] & 0x800000) && ! (val[1] & 0xff000000))))
760 output_asm_insn (\"movu %H1,%H0\", operands);
762 output_asm_insn (\"mov %H1,%H0\", operands);
771 (define_insn "*mn10300_movdf"
772 [(set (match_operand:DF 0 "nonimmediate_operand"
773 ;; 0 1 2 3 4 5 6 7 8 9 10
774 "=dxa,dx,a,dxm,dxm,axm,axm,dx,dx,ax,ax")
775 (match_operand:DF 1 "general_operand"
776 ;; 0 1 2 3 4 5 6 7 8 9 10
777 "0,G,G,dx,ax,dx,ax,dxFm,axFm,dxFm,axFm"))]
778 "register_operand (operands[0], DFmode)
779 || register_operand (operands[1], DFmode)"
785 switch (which_alternative)
791 return \"mov 0, %L0\;mov 0, %H0\";
794 if (rtx_equal_p (operands[0], operands[1]))
795 return \"sub %L1,%L0\;mov %L0,%H0\";
797 return \"mov %1,%L0\;mov %L0,%H0\";
806 if (CONST_INT_P (operands[1]))
809 split_double (operands[1], &low, &high);
810 val[0] = INTVAL (low);
811 val[1] = INTVAL (high);
813 if (CONST_DOUBLE_P (operands[1]))
815 if (GET_MODE (operands[1]) == DFmode)
817 REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
818 REAL_VALUE_TO_TARGET_DOUBLE (rv, val);
820 else if (GET_MODE (operands[1]) == VOIDmode
821 || GET_MODE (operands[1]) == DImode)
823 val[0] = CONST_DOUBLE_LOW (operands[1]);
824 val[1] = CONST_DOUBLE_HIGH (operands[1]);
828 if (MEM_P (operands[1])
829 && reg_overlap_mentioned_p (operands[0], XEXP (operands[1], 0)))
831 rtx temp = operands[0];
833 while (GET_CODE (temp) == SUBREG)
834 temp = SUBREG_REG (temp);
836 gcc_assert (REG_P (temp));
838 if (reg_overlap_mentioned_p (gen_rtx_REG (SImode, REGNO (temp)),
839 XEXP (operands[1], 0)))
840 return \"mov %H1,%H0\;mov %L1,%L0\";
842 return \"mov %L1,%L0\;mov %H1,%H0\";
845 else if (MEM_P (operands[1])
846 && CONSTANT_ADDRESS_P (XEXP (operands[1], 0))
847 && REGNO_REG_CLASS (REGNO (operands[0])) == ADDRESS_REGS)
851 xoperands[0] = operands[0];
852 xoperands[1] = XEXP (operands[1], 0);
854 output_asm_insn (\"mov %1,%L0\;mov (4,%L0),%H0\;mov (%L0),%L0\",
860 if ((CONST_INT_P (operands[1])
861 || CONST_DOUBLE_P (operands[1]))
864 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
865 output_asm_insn (\"mov 0, %L0\", operands);
867 output_asm_insn (\"mov %L1,%L0\", operands);
869 else if ((CONST_INT_P (operands[1])
870 || CONST_DOUBLE_P (operands[1]))
871 && (REGNO_REG_CLASS (true_regnum (operands[0]))
873 && (((val[0] & 0x80) && ! (val[0] & 0xffffff00))
874 || ((val[0] & 0x800000) && ! (val[0] & 0xff000000))))
875 output_asm_insn (\"movu %L1,%L0\", operands);
877 output_asm_insn (\"mov %L1,%L0\", operands);
879 if ((CONST_INT_P (operands[1])
880 || CONST_DOUBLE_P (operands[1]))
883 if (REGNO_REG_CLASS (REGNO (operands[0])) == DATA_REGS)
884 output_asm_insn (\"mov 0, %H0\", operands);
886 output_asm_insn (\"mov %H1,%H0\", operands);
888 else if ((CONST_INT_P (operands[1])
889 || CONST_DOUBLE_P (operands[1]))
891 output_asm_insn (\"mov %L0,%H0\", operands);
892 else if ((CONST_INT_P (operands[1])
893 || CONST_DOUBLE_P (operands[1]))
894 && (REGNO_REG_CLASS (true_regnum (operands[0]))
896 && (((val[1] & 0x80) && ! (val[1] & 0xffffff00))
897 || ((val[1] & 0x800000) && ! (val[1] & 0xff000000))))
898 output_asm_insn (\"movu %H1,%H0\", operands);
900 output_asm_insn (\"mov %H1,%H0\", operands);
910 ;; ----------------------------------------------------------------------
912 ;; ----------------------------------------------------------------------
914 (define_expand "addsi3"
915 [(parallel [(set (match_operand:SI 0 "register_operand")
916 (plus:SI (match_operand:SI 1 "register_operand")
917 (match_operand:SI 2 "nonmemory_operand")))
918 (clobber (reg:CC CC_REG))
924 (define_insn "*am33_addsi3"
925 [(set (match_operand:SI 0 "register_operand" "=dx,a,x,a,dax,!*y,!dax")
926 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,dax")
927 (match_operand:SI 2 "nonmemory_operand" "J,J,L,L,daxi,i,dax")))
928 (clobber (reg:CC CC_REG))
933 switch (which_alternative)
943 return \"add %2,%0\";
946 enum reg_class src1_class, src2_class, dst_class;
948 src1_class = REGNO_REG_CLASS (true_regnum (operands[1]));
949 src2_class = REGNO_REG_CLASS (true_regnum (operands[2]));
950 dst_class = REGNO_REG_CLASS (true_regnum (operands[0]));
952 /* I'm not sure if this can happen or not. Might as well be prepared
953 and generate the best possible code if it does happen. */
954 if (true_regnum (operands[0]) == true_regnum (operands[1]))
955 return \"add %2,%0\";
956 if (true_regnum (operands[0]) == true_regnum (operands[2]))
957 return \"add %1,%0\";
959 /* Catch cases where no extended register was used. These should be
960 handled just like the mn10300. */
961 if (src1_class != EXTENDED_REGS
962 && src2_class != EXTENDED_REGS
963 && dst_class != EXTENDED_REGS)
965 /* We have to copy one of the sources into the destination, then
966 add the other source to the destination.
968 Carefully select which source to copy to the destination; a
969 naive implementation will waste a byte when the source classes
970 are different and the destination is an address register.
971 Selecting the lowest cost register copy will optimize this
973 if (REGNO_REG_CLASS (true_regnum (operands[1]))
974 == REGNO_REG_CLASS (true_regnum (operands[0])))
975 return \"mov %1,%0\;add %2,%0\";
976 return \"mov %2,%0\;add %1,%0\";
979 /* At least one register is an extended register. */
981 /* The three operand add instruction on the am33 is a win iff the
982 output register is an extended register, or if both source
983 registers are extended registers. */
984 if (dst_class == EXTENDED_REGS
985 || src1_class == src2_class)
986 return \"add %2,%1,%0\";
988 /* It is better to copy one of the sources to the destination, then
989 perform a 2 address add. The destination in this case must be
990 an address or data register and one of the sources must be an
991 extended register and the remaining source must not be an extended
994 The best code for this case is to copy the extended reg to the
995 destination, then emit a two address add. */
996 if (src1_class == EXTENDED_REGS)
997 return \"mov %1,%0\;add %2,%0\";
998 return \"mov %2,%0\;add %1,%0\";
1006 (define_insn "*mn10300_addsi3"
1007 [(set (match_operand:SI 0 "register_operand" "=dx,a,a,dax,!*y,!dax")
1008 (plus:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,dax")
1009 (match_operand:SI 2 "nonmemory_operand" "J,J,L,daxi,i,dax")))
1010 (clobber (reg:CC CC_REG))
1015 switch (which_alternative)
1024 return \"add %2,%0\";
1026 /* I'm not sure if this can happen or not. Might as well be prepared
1027 and generate the best possible code if it does happen. */
1028 if (true_regnum (operands[0]) == true_regnum (operands[1]))
1029 return \"add %2,%0\";
1030 if (true_regnum (operands[0]) == true_regnum (operands[2]))
1031 return \"add %1,%0\";
1033 /* We have to copy one of the sources into the destination, then add
1034 the other source to the destination.
1036 Carefully select which source to copy to the destination; a naive
1037 implementation will waste a byte when the source classes are different
1038 and the destination is an address register. Selecting the lowest
1039 cost register copy will optimize this sequence. */
1040 if (REGNO_REG_CLASS (true_regnum (operands[1]))
1041 == REGNO_REG_CLASS (true_regnum (operands[0])))
1042 return \"mov %1,%0\;add %2,%0\";
1043 return \"mov %2,%0\;add %1,%0\";
1050 ;; ----------------------------------------------------------------------
1051 ;; SUBTRACT INSTRUCTIONS
1052 ;; ----------------------------------------------------------------------
1054 (define_expand "subsi3"
1055 [(parallel [(set (match_operand:SI 0 "register_operand")
1056 (minus:SI (match_operand:SI 1 "register_operand")
1057 (match_operand:SI 2 "nonmemory_operand")))
1058 (clobber (reg:CC CC_REG))
1064 (define_insn "*am33_subsi3"
1065 [(set (match_operand:SI 0 "register_operand" "=dax,!dax")
1066 (minus:SI (match_operand:SI 1 "register_operand" "0,dax")
1067 (match_operand:SI 2 "nonmemory_operand" "daxi,dax")))]
1071 if (true_regnum (operands[0]) == true_regnum (operands[1]))
1072 return \"sub %2,%0\";
1075 enum reg_class src1_class, src2_class, dst_class;
1077 src1_class = REGNO_REG_CLASS (true_regnum (operands[1]));
1078 src2_class = REGNO_REG_CLASS (true_regnum (operands[2]));
1079 dst_class = REGNO_REG_CLASS (true_regnum (operands[0]));
1081 /* If no extended registers are used, then the best way to handle
1082 this is to copy the first source operand into the destination
1083 and emit a two address subtraction. */
1084 if (src1_class != EXTENDED_REGS
1085 && src2_class != EXTENDED_REGS
1086 && dst_class != EXTENDED_REGS
1087 && true_regnum (operands[0]) != true_regnum (operands[2]))
1088 return \"mov %1,%0\;sub %2,%0\";
1089 return \"sub %2,%1,%0\";
1094 (define_insn "*mn10300_subsi3"
1095 [(set (match_operand:SI 0 "register_operand" "=dax")
1096 (minus:SI (match_operand:SI 1 "register_operand" "0")
1097 (match_operand:SI 2 "nonmemory_operand" "daxi")))
1098 (clobber (reg:CC CC_REG))
1104 (define_expand "negsi2"
1105 [(set (match_operand:SI 0 "register_operand")
1106 (neg:SI (match_operand:SI 1 "register_operand")))]
1110 rtx target = gen_reg_rtx (SImode);
1112 emit_move_insn (target, const0_rtx);
1113 emit_insn (gen_subsi3 (target, target, operands[1]));
1114 emit_move_insn (operands[0], target);
1118 ;; ----------------------------------------------------------------------
1119 ;; MULTIPLY INSTRUCTIONS
1120 ;; ----------------------------------------------------------------------
1122 (define_insn "mulsidi3"
1123 [(set (match_operand:DI 0 "register_operand" "=dax")
1124 (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "dax"))
1125 (sign_extend:DI (match_operand:SI 2 "register_operand" "dax"))))
1126 (clobber (reg:CC CC_REG))
1132 (define_insn "umulsidi3"
1133 [(set (match_operand:DI 0 "register_operand" "=dax")
1134 (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "dax"))
1135 (zero_extend:DI (match_operand:SI 2 "register_operand" "dax"))))
1136 (clobber (reg:CC CC_REG))
1139 "mulu %1,%2,%H0,%L0"
1142 (define_expand "mulsi3"
1143 [(parallel [(set (match_operand:SI 0 "register_operand")
1144 (mult:SI (match_operand:SI 1 "register_operand")
1145 (match_operand:SI 2 "register_operand")))
1146 (clobber (reg:CC CC_REG))
1152 (define_insn "*am33_mulsi3"
1153 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
1154 (mult:SI (match_operand:SI 1 "register_operand" "%0,0")
1155 (match_operand:SI 2 "nonmemory_operand" "dx,daxi")))
1156 (clobber (reg:CC CC_REG))
1161 if (TARGET_MULT_BUG)
1162 return \"nop\;nop\;mul %2,%0\";
1164 return \"mul %2,%0\";
1168 (define_insn "*mn10300_mulsi3"
1169 [(set (match_operand:SI 0 "register_operand" "=dx")
1170 (mult:SI (match_operand:SI 1 "register_operand" "%0")
1171 (match_operand:SI 2 "register_operand" "dx")))
1172 (clobber (reg:CC CC_REG))
1177 if (TARGET_MULT_BUG)
1178 return \"nop\;nop\;mul %2,%0\";
1180 return \"mul %2,%0\";
1184 (define_expand "udivmodsi4"
1185 [(parallel [(set (match_operand:SI 0 "nonimmediate_operand")
1186 (udiv:SI (match_operand:SI 1 "general_operand")
1187 (match_operand:SI 2 "general_operand")))
1188 (set (match_operand:SI 3 "nonimmediate_operand")
1189 (umod:SI (match_dup 1) (match_dup 2)))
1190 (clobber (reg:CC CC_REG))
1195 if (!register_operand (operands[1], SImode))
1196 operands[1] = copy_to_mode_reg (SImode, operands[1]);
1197 if (!register_operand (operands[2], SImode))
1198 operands[2] = copy_to_mode_reg (SImode, operands[2]);
1202 (define_insn "*udivmodsi4_insn"
1203 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx")
1204 (udiv:SI (match_operand:SI 1 "register_operand" "0")
1205 (match_operand:SI 2 "register_operand" "dx")))
1206 (set (match_operand:SI 3 "nonimmediate_operand" "=&d")
1207 (umod:SI (match_dup 1) (match_dup 2)))
1208 (clobber (reg:CC CC_REG))
1213 output_asm_insn (\"sub %3,%3\;mov %3,mdr\", operands);
1215 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1216 return \"divu %2,%0\";
1218 return \"divu %2,%0\;mov mdr,%3\";
1222 (define_insn "divmodsi4"
1223 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx")
1224 (div:SI (match_operand:SI 1 "general_operand" "0")
1225 (match_operand:SI 2 "general_operand" "dx")))
1226 (set (match_operand:SI 3 "nonimmediate_operand" "=d")
1227 (mod:SI (match_dup 1) (match_dup 2)))
1228 (clobber (reg:CC CC_REG))
1233 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1234 return \"ext %0\;div %2,%0\";
1236 return \"ext %0\;div %2,%0\;mov mdr,%3\";
1241 ;; ----------------------------------------------------------------------
1243 ;; ----------------------------------------------------------------------
1245 (define_expand "andsi3"
1246 [(parallel [(set (match_operand:SI 0 "register_operand")
1247 (and:SI (match_operand:SI 1 "register_operand")
1248 (match_operand:SI 2 "nonmemory_operand")))
1249 (clobber (reg:CC CC_REG))
1255 (define_insn "*am33_andsi3"
1256 [(set (match_operand:SI 0 "register_operand" "=dx,dx,!dax")
1257 (and:SI (match_operand:SI 1 "register_operand" "%0,0,dax")
1258 (match_operand:SI 2 "nonmemory_operand" "N,dxi,dax")))
1259 (clobber (reg:CC CC_REG))
1264 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xff)
1265 return \"extbu %0\";
1266 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xffff)
1267 return \"exthu %0\";
1268 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0x7fffffff)
1269 return \"add %0,%0\;lsr 1,%0\";
1270 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0x3fffffff)
1271 return \"asl2 %0\;lsr 2,%0\";
1272 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0x1fffffff)
1273 return \"add %0,%0\;asl2 %0\;lsr 3,%0\";
1274 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0x0fffffff)
1275 return \"asl2 %0\;asl2 %0\;lsr 4,%0\";
1276 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xfffffffe)
1277 return \"lsr 1,%0\;add %0,%0\";
1278 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xfffffffc)
1279 return \"lsr 2,%0\;asl2 %0\";
1280 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xfffffff8)
1281 return \"lsr 3,%0\;add %0,%0\;asl2 %0\";
1282 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xfffffff0)
1283 return \"lsr 4,%0\;asl2 %0\;asl2 %0\";
1284 if (REG_P (operands[2]) && REG_P (operands[1])
1285 && true_regnum (operands[0]) != true_regnum (operands[1])
1286 && true_regnum (operands[0]) != true_regnum (operands[2])
1287 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
1288 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
1289 && REGNO_REG_CLASS (true_regnum (operands[2])) == DATA_REGS)
1290 return \"mov %1,%0\;and %2,%0\";
1291 if (REG_P (operands[2]) && REG_P (operands[1])
1292 && true_regnum (operands[0]) != true_regnum (operands[1])
1293 && true_regnum (operands[0]) != true_regnum (operands[2]))
1294 return \"and %1,%2,%0\";
1295 if (REG_P (operands[2]) && REG_P (operands[0])
1296 && true_regnum (operands[2]) == true_regnum (operands[0]))
1297 return \"and %1,%0\";
1298 return \"and %2,%0\";
1302 (define_insn "*mn10300_andsi3"
1303 [(set (match_operand:SI 0 "register_operand" "=dx,dx")
1304 (and:SI (match_operand:SI 1 "register_operand" "%0,0")
1305 (match_operand:SI 2 "nonmemory_operand" "N,dxi")))
1306 (clobber (reg:CC CC_REG))
1311 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xff)
1312 return \"extbu %0\";
1313 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xffff)
1314 return \"exthu %0\";
1315 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0x7fffffff)
1316 return \"add %0,%0\;lsr 1,%0\";
1317 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0x3fffffff)
1318 return \"asl2 %0\;lsr 2,%0\";
1319 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0x1fffffff)
1320 return \"add %0,%0\;asl2 %0\;lsr 3,%0\";
1321 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0x0fffffff)
1322 return \"asl2 %0\;asl2 %0\;lsr 4,%0\";
1323 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xfffffffe)
1324 return \"lsr 1,%0\;add %0,%0\";
1325 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xfffffffc)
1326 return \"lsr 2,%0\;asl2 %0\";
1327 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xfffffff8)
1328 return \"lsr 3,%0\;add %0,%0\;asl2 %0\";
1329 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 0xfffffff0)
1330 return \"lsr 4,%0\;asl2 %0\;asl2 %0\";
1331 return \"and %2,%0\";
1335 ;; ----------------------------------------------------------------------
1337 ;; ----------------------------------------------------------------------
1339 (define_expand "iorsi3"
1340 [(parallel [(set (match_operand:SI 0 "register_operand")
1341 (ior:SI (match_operand:SI 1 "register_operand")
1342 (match_operand:SI 2 "nonmemory_operand")))
1343 (clobber (reg:CC CC_REG))
1349 (define_insn "*am33_iorsi3"
1350 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
1351 (ior:SI (match_operand:SI 1 "register_operand" "%0,dax")
1352 (match_operand:SI 2 "nonmemory_operand" "dxi,dax")))
1353 (clobber (reg:CC CC_REG))
1358 if (REG_P (operands[2]) && REG_P (operands[1])
1359 && true_regnum (operands[0]) != true_regnum (operands[1])
1360 && true_regnum (operands[0]) != true_regnum (operands[2])
1361 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
1362 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
1363 && REGNO_REG_CLASS (true_regnum (operands[2])) == DATA_REGS)
1364 return \"mov %1,%0\;or %2,%0\";
1365 if (REG_P (operands[2]) && REG_P (operands[1])
1366 && true_regnum (operands[0]) != true_regnum (operands[1])
1367 && true_regnum (operands[0]) != true_regnum (operands[2]))
1368 return \"or %1,%2,%0\";
1369 if (REG_P (operands[2]) && REG_P (operands[0])
1370 && true_regnum (operands[2]) == true_regnum (operands[0]))
1371 return \"or %1,%0\";
1372 return \"or %2,%0\";
1376 (define_insn "*mn10300_iorsi3"
1377 [(set (match_operand:SI 0 "register_operand" "=dx")
1378 (ior:SI (match_operand:SI 1 "register_operand" "%0")
1379 (match_operand:SI 2 "nonmemory_operand" "dxi")))
1380 (clobber (reg:CC CC_REG))
1386 ;; ----------------------------------------------------------------------
1388 ;; ----------------------------------------------------------------------
1390 (define_expand "xorsi3"
1391 [(parallel [(set (match_operand:SI 0 "register_operand")
1392 (xor:SI (match_operand:SI 1 "register_operand")
1393 (match_operand:SI 2 "nonmemory_operand")))
1394 (clobber (reg:CC CC_REG))
1400 (define_insn "*am33_xorsi3"
1401 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
1402 (xor:SI (match_operand:SI 1 "register_operand" "%0,dax")
1403 (match_operand:SI 2 "nonmemory_operand" "dxi,dax")))
1404 (clobber (reg:CC CC_REG))
1409 if (REG_P (operands[2]) && REG_P (operands[1])
1410 && true_regnum (operands[0]) != true_regnum (operands[1])
1411 && true_regnum (operands[0]) != true_regnum (operands[2])
1412 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
1413 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
1414 && REGNO_REG_CLASS (true_regnum (operands[2])) == DATA_REGS)
1415 return \"mov %1,%0\;xor %2,%0\";
1416 if (REG_P (operands[2]) && REG_P (operands[1])
1417 && true_regnum (operands[0]) != true_regnum (operands[1])
1418 && true_regnum (operands[0]) != true_regnum (operands[2]))
1419 return \"xor %1,%2,%0\";
1420 if (REG_P (operands[2]) && REG_P (operands[0])
1421 && true_regnum (operands[2]) == true_regnum (operands[0]))
1422 return \"xor %1,%0\";
1423 return \"xor %2,%0\";
1427 (define_insn "*mn10300_xorsi3"
1428 [(set (match_operand:SI 0 "register_operand" "=dx")
1429 (xor:SI (match_operand:SI 1 "register_operand" "%0")
1430 (match_operand:SI 2 "nonmemory_operand" "dxi")))
1431 (clobber (reg:CC CC_REG))
1437 ;; ----------------------------------------------------------------------
1439 ;; ----------------------------------------------------------------------
1441 (define_expand "one_cmplsi2"
1442 [(parallel [(set (match_operand:SI 0 "register_operand")
1443 (not:SI (match_operand:SI 1 "register_operand")))
1444 (clobber (reg:CC CC_REG))
1450 (define_insn "*am33_cmplsi2"
1451 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
1452 (not:SI (match_operand:SI 1 "register_operand" "0,0")))
1453 (clobber (reg:CC CC_REG))
1459 (define_insn "*mn10300_cmplsi2"
1460 [(set (match_operand:SI 0 "register_operand" "=dx")
1461 (not:SI (match_operand:SI 1 "register_operand" "0")))
1462 (clobber (reg:CC CC_REG))
1468 ;; -----------------------------------------------------------------
1470 ;; -----------------------------------------------------------------
1473 ;; These set/clear memory in byte sized chunks.
1475 ;; They are no smaller/faster than loading the value into a register
1476 ;; and storing the register, but they don't need a scratch register
1477 ;; which may allow for better code generation.
1478 (define_insn "*byte_clear"
1479 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,d") (const_int 0))
1480 (clobber (reg:CC CC_REG))
1482 "(! MEM_P (operands[0])) || (! MEM_VOLATILE_P (operands[0])
1483 && GET_CODE (XEXP (operands[0], 0)) != PLUS)"
1489 (define_insn "*byte_set"
1490 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,d") (const_int -1))
1491 (clobber (reg:CC CC_REG))
1493 "( ! MEM_P (operands[0])) || (! MEM_VOLATILE_P (operands[0])
1494 && GET_CODE (XEXP (operands[0], 0)) != PLUS)"
1500 (define_insn "*bit_clear1"
1501 [(set (match_operand:QI 0 "nonimmediate_operand" "+R,d")
1503 (and:SI (subreg:SI (match_dup 0) 0)
1504 (match_operand:SI 1 "const_int_operand" "i,i")) 0))
1505 (clobber (reg:CC CC_REG))
1513 (define_insn "*bit_clear2"
1514 [(set (match_operand:QI 0 "memory_operand" "=R,T")
1517 (not:QI (match_operand:QI 1 "nonmemory_operand" "i,d"))))
1518 (clobber (reg:CC CC_REG))
1526 (define_insn "*bit_set"
1527 [(set (match_operand:QI 0 "nonimmediate_operand" "+R,d")
1529 (ior:SI (subreg:SI (match_dup 0) 0)
1530 (match_operand:SI 1 "const_int_operand" "i,i")) 0))
1531 (clobber (reg:CC CC_REG))
1539 (define_expand "iorqi3"
1540 [(parallel [(set (match_operand:QI 0 "nonimmediate_operand")
1541 (ior:QI (match_operand:QI 1 "nonimmediate_operand")
1542 (match_operand:QI 2 "nonmemory_operand")))
1543 (clobber (reg:CC CC_REG))
1549 (define_insn "*am33_iorqi3"
1550 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,T,r")
1551 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
1552 ;; This constraint should really be nonmemory_operand,
1553 ;; but making it general_operand, along with the
1554 ;; condition that not both input operands are MEMs, it
1555 ;; here helps combine do a better job.
1556 (match_operand:QI 2 "general_operand" "i,d,ir")))
1557 (clobber (reg:CC CC_REG))
1560 ((! MEM_P (operands[2])) || (! MEM_P (operands[1])))"
1567 (define_insn "*mn10300_iorqi3"
1568 [(set (match_operand:QI 0 "nonimmediate_operand" "=R,T,d")
1569 (ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0")
1570 ;; This constraint should really be nonmemory_operand,
1571 ;; but making it general_operand, along with the
1572 ;; condition that not both input operands are MEMs, it
1573 ;; here helps combine do a better job.
1574 (match_operand:QI 2 "general_operand" "i,d,id")))
1575 (clobber (reg:CC CC_REG))
1577 "(! MEM_P (operands[2])) || (! MEM_P (operands[1]))"
1584 (define_insn "*test_int_bitfield"
1585 [(set (reg:CC CC_REG)
1586 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "dx")
1587 (match_operand 1 "const_int_operand" "")
1588 (match_operand 2 "const_int_operand" ""))
1593 int len = INTVAL (operands[1]);
1594 int bit = INTVAL (operands[2]);
1605 xoperands[0] = operands[0];
1606 xoperands[1] = GEN_INT (trunc_int_for_mode (mask, SImode));
1607 output_asm_insn (\"btst %1,%0\", xoperands);
1612 (define_insn "*test_byte_bitfield"
1613 [(set (reg:CC CC_REG)
1614 (compare (zero_extract:SI (match_operand:QI 0 "general_operand" "R,dx")
1615 (match_operand 1 "const_int_operand" "")
1616 (match_operand 2 "const_int_operand" ""))
1618 "mn10300_mask_ok_for_mem_btst (INTVAL (operands[1]), INTVAL (operands[2]))"
1621 int len = INTVAL (operands[1]);
1622 int bit = INTVAL (operands[2]);
1633 /* If the source operand is not a reg (i.e. it is memory), then extract the
1634 bits from mask that we actually want to test. Note that the mask will
1635 never cross a byte boundary. */
1636 if (!REG_P (operands[0]))
1640 else if (mask & 0xff00)
1641 mask = (mask >> 8) & 0xff;
1642 else if (mask & 0xff0000)
1643 mask = (mask >> 16) & 0xff;
1644 else if (mask & 0xff000000)
1645 mask = (mask >> 24) & 0xff;
1648 xoperands[0] = operands[0];
1649 xoperands[1] = GEN_INT (trunc_int_for_mode (mask, SImode));
1650 if (REG_P (operands[0]))
1651 output_asm_insn (\"btst %1,%0\", xoperands);
1653 output_asm_insn (\"btst %U1,%A0\", xoperands);
1658 (define_insn "*bit_test"
1659 [(set (reg:CC CC_REG)
1660 (compare (and:SI (match_operand:SI 0 "register_operand" "dx")
1661 (match_operand:SI 1 "const_int_operand" ""))
1668 (define_insn "*subreg_bit_test"
1669 [(set (reg:CC CC_REG)
1671 (subreg:SI (match_operand:QI 0 "general_operand" "R,dx") 0)
1672 (match_operand:SI 1 "const_8bit_operand" ""))
1681 ;; ----------------------------------------------------------------------
1682 ;; COMPARE AND BRANCH INSTRUCTIONS
1683 ;; ----------------------------------------------------------------------
1685 ;; We expand the comparison into a single insn so that it will not be split
1687 (define_expand "cbranchsi4"
1690 (match_operator 0 "ordered_comparison_operator"
1691 [(match_operand:SI 1 "register_operand")
1692 (match_operand:SI 2 "nonmemory_operand")])
1693 (label_ref (match_operand 3 ""))
1699 (define_insn_and_split "*cbranchsi4_post_reload"
1701 (if_then_else (match_operator 3 "ordered_comparison_operator"
1702 [(match_operand:SI 0 "register_operand" "dax")
1703 (match_operand:SI 1 "nonmemory_operand" "daxi")])
1704 (label_ref (match_operand 2 "" ""))
1712 /* We construct the split by hand as otherwise the JUMP_LABEL
1713 attribute is not set correctly on the jump insn. */
1714 emit_insn (gen_cmpsi (operands[0], operands[1]));
1716 emit_jump_insn (gen_integer_conditional_branch
1717 (gen_rtx_fmt_ee (GET_CODE (operands[3]),
1719 gen_rtx_REG (CCmode, CC_REG),
1725 ;; Ordinarily, the cmp instruction will set the Z bit of cc0 to 1 if
1726 ;; its operands hold equal values, but the operands of a cmp
1727 ;; instruction must be distinct registers. In the case where we'd
1728 ;; like to compare a register to itself, we can achieve this effect
1729 ;; with a btst 0,d0 instead. (This will not alter the contents of d0
1730 ;; but will have the proper effect on cc0. Using d0 is arbitrary; any
1731 ;; data register would work.)
1733 ;; Even though the first alternative would be preferable if it can
1734 ;; possibly match, reload must not be given the opportunity to attempt
1735 ;; to use it. It assumes that such matches can only occur when one of
1736 ;; the operands is used for input and the other for output. Since
1737 ;; this is not the case, it abort()s. Indeed, such a reload cannot be
1738 ;; possibly satisfied, so just mark the alternative with a `!', so
1739 ;; that it is not considered by reload.
1741 (define_insn "cmpsi"
1742 [(set (reg:CC CC_REG)
1743 (compare (match_operand:SI 0 "register_operand" "!*d*a*x,dax,dax")
1744 (match_operand:SI 1 "nonmemory_operand" "*0,I,daxi")))]
1747 if (which_alternative == 0)
1748 return \"btst 0,d0\";
1749 if (which_alternative == 1)
1750 return mn10300_output_cmp (operands[0], insn);
1751 return \"cmp %1,%0\";
1755 (define_insn "integer_conditional_branch"
1757 (if_then_else (match_operator 0 "comparison_operator" [(reg:CC CC_REG) (const_int 0)])
1758 (label_ref (match_operand 1 "" ""))
1764 (define_expand "cbranchsf4"
1767 (match_operator 0 "ordered_comparison_operator"
1768 [(match_operand:SF 1 "register_operand")
1769 (match_operand:SF 2 "nonmemory_operand")])
1770 (label_ref (match_operand 3 ""))
1776 (define_insn_and_split "*cbranchsf4_post_reload"
1778 (if_then_else (match_operator 3 "ordered_comparison_operator"
1779 [(match_operand:SF 0 "register_operand" "f")
1780 (match_operand:SF 1 "nonmemory_operand" "fF")])
1781 (label_ref (match_operand 2 "" ""))
1786 "&& reload_completed"
1789 /* We construct the split by hand as otherwise the JUMP_LABEL
1790 attribute is not set correctly on the jump insn. */
1791 emit_insn (gen_am33_cmpsf (operands[0], operands[1]));
1793 emit_jump_insn (gen_float_conditional_branch
1794 (gen_rtx_fmt_ee (GET_CODE (operands[3]),
1796 gen_rtx_REG (CC_FLOATmode, CC_REG),
1802 (define_insn "am33_cmpsf"
1803 [(set (reg:CC_FLOAT CC_REG)
1804 (compare:CC_FLOAT (match_operand:SF 0 "register_operand" "f")
1805 (match_operand:SF 1 "nonmemory_operand" "fF")))]
1810 (define_insn "float_conditional_branch"
1812 (if_then_else (match_operator 0 "comparison_operator"
1813 [(reg:CC_FLOAT CC_REG) (const_int 0)])
1814 (label_ref (match_operand 1 "" ""))
1820 ;; Unconditional and other jump instructions.
1824 (label_ref (match_operand 0 "" "")))]
1829 (define_insn "indirect_jump"
1830 [(set (pc) (match_operand:SI 0 "register_operand" "a"))]
1835 (define_expand "builtin_setjmp_receiver"
1836 [(match_operand 0 "" "")]
1841 emit_insn (gen_GOTaddr2picreg ());
1846 (define_expand "casesi"
1847 [(match_operand:SI 0 "register_operand")
1848 (match_operand:SI 1 "immediate_operand")
1849 (match_operand:SI 2 "immediate_operand")
1850 (match_operand 3 "" "") (match_operand 4 "")]
1854 rtx table = gen_reg_rtx (SImode);
1855 rtx index = gen_reg_rtx (SImode);
1856 rtx addr = gen_reg_rtx (Pmode);
1859 emit_move_insn (table, gen_rtx_LABEL_REF (VOIDmode, operands[3]));
1860 emit_insn (gen_addsi3 (index, operands[0], GEN_INT (- INTVAL (operands[1]))));
1861 test = gen_rtx_fmt_ee (GTU, VOIDmode, index, operands[2]);
1862 emit_jump_insn (gen_cbranchsi4 (test, index, operands[2], operands[4]));
1864 emit_insn (gen_ashlsi3 (index, index, const2_rtx));
1865 emit_move_insn (addr, gen_rtx_MEM (SImode,
1866 gen_rtx_PLUS (SImode, table, index)));
1868 emit_insn (gen_addsi3 (addr, addr, table));
1870 emit_jump_insn (gen_tablejump (addr, operands[3]));
1874 (define_insn "tablejump"
1875 [(set (pc) (match_operand:SI 0 "register_operand" "a"))
1876 (use (label_ref (match_operand 1 "" "")))]
1881 ;; Call subroutine with no return value.
1883 (define_expand "call"
1884 [(call (match_operand:QI 0 "general_operand")
1885 (match_operand:SI 1 "general_operand"))]
1889 if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF)
1891 if (MN10300_GLOBAL_P (XEXP (operands[0], 0)))
1893 /* The PLT code won't run on AM30, but then, there's no
1894 shared library support for AM30 either, so we just assume
1895 the linker is going to adjust all @PLT relocs to the
1897 emit_use (pic_offset_table_rtx);
1898 XEXP (operands[0], 0) = gen_sym2PLT (XEXP (operands[0], 0));
1901 XEXP (operands[0], 0) = gen_sym2PIC (XEXP (operands[0], 0));
1903 if (! call_address_operand (XEXP (operands[0], 0), VOIDmode))
1904 XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0));
1905 emit_call_insn (gen_call_internal (XEXP (operands[0], 0), operands[1]));
1909 ;; NB: Mode on match_operand 0 deliberately omitted in
1910 ;; order to be able to match UNSPECs in PIC mode.
1911 (define_insn "call_internal"
1912 [(call (mem:QI (match_operand 0 "call_address_operand" "aS"))
1913 (match_operand:SI 1 "general_operand" "g"))]
1917 if (REG_P (operands[0]))
1918 return \"calls %C0\";
1920 return \"call %C0,[],0\";
1924 ;; Call subroutine, returning value in operand 0
1925 ;; (which must be a hard register).
1927 (define_expand "call_value"
1928 [(set (match_operand 0 "")
1929 (call (match_operand:QI 1 "general_operand")
1930 (match_operand:SI 2 "general_operand")))]
1934 if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF)
1936 if (MN10300_GLOBAL_P (XEXP (operands[1], 0)))
1938 /* The PLT code won't run on AM30, but then, there's no
1939 shared library support for AM30 either, so we just assume
1940 the linker is going to adjust all @PLT relocs to the
1942 emit_use (pic_offset_table_rtx);
1943 XEXP (operands[1], 0) = gen_sym2PLT (XEXP (operands[1], 0));
1946 XEXP (operands[1], 0) = gen_sym2PIC (XEXP (operands[1], 0));
1948 if (! call_address_operand (XEXP (operands[1], 0), VOIDmode))
1949 XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0));
1950 emit_call_insn (gen_call_value_internal (operands[0],
1951 XEXP (operands[1], 0),
1956 ;; NB: Mode on match_operands 0 and 1 deliberately omitted
1957 ;; in order to be able to match UNSPECs in PIC mode.
1958 (define_insn "call_value_internal"
1959 [(set (match_operand 0 "register_operand" "=dax")
1960 (call (mem:QI (match_operand 1 "call_address_operand" "aS"))
1961 (match_operand:SI 2 "general_operand" "g")))]
1965 if (REG_P (operands[1]))
1966 return \"calls %C1\";
1968 return \"call %C1,[],0\";
1972 (define_expand "untyped_call"
1973 [(parallel [(call (match_operand 0 "")
1975 (match_operand 1 "")
1976 (match_operand 2 "")])]
1982 emit_call_insn (gen_call (operands[0], const0_rtx));
1984 for (i = 0; i < XVECLEN (operands[2], 0); i++)
1986 rtx set = XVECEXP (operands[2], 0, i);
1987 emit_move_insn (SET_DEST (set), SET_SRC (set));
1998 ;; ----------------------------------------------------------------------
1999 ;; EXTEND INSTRUCTIONS
2000 ;; ----------------------------------------------------------------------
2002 (define_expand "zero_extendqisi2"
2003 [(set (match_operand:SI 0 "general_operand")
2005 (match_operand:QI 1 "general_operand")))]
2010 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx,!dax,!dax,!dax")
2012 (match_operand:QI 1 "general_operand" "0,dax,m,0,dax,m")))]
2024 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx")
2026 (match_operand:QI 1 "general_operand" "0,d,m")))]
2034 (define_expand "zero_extendhisi2"
2035 [(set (match_operand:SI 0 "general_operand")
2037 (match_operand:HI 1 "general_operand")))]
2042 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx,!dax,!dax,!dax")
2044 (match_operand:HI 1 "general_operand" "0,dax,m,0,dax,m")))]
2056 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,dx")
2058 (match_operand:HI 1 "general_operand" "0,dx,m")))]
2066 ;;- sign extension instructions
2068 (define_expand "extendqisi2"
2069 [(set (match_operand:SI 0 "general_operand")
2071 (match_operand:QI 1 "general_operand")))]
2076 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,!dax,!dax")
2078 (match_operand:QI 1 "general_operand" "0,dx,0,dax")))]
2088 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx")
2090 (match_operand:QI 1 "general_operand" "0,dx")))]
2097 (define_expand "extendhisi2"
2098 [(set (match_operand:SI 0 "general_operand")
2100 (match_operand:HI 1 "general_operand")))]
2105 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx,!dax,!dax")
2107 (match_operand:HI 1 "general_operand" "0,dax,0,dax")))]
2117 [(set (match_operand:SI 0 "nonimmediate_operand" "=dx,dx")
2119 (match_operand:HI 1 "general_operand" "0,dx")))]
2126 ;; ----------------------------------------------------------------------
2128 ;; ----------------------------------------------------------------------
2130 (define_expand "ashlsi3"
2131 [(parallel [(set (match_operand:SI 0 "register_operand")
2133 (match_operand:SI 1 "register_operand")
2134 (match_operand:QI 2 "nonmemory_operand")))
2135 (clobber (reg:CC CC_REG))
2141 (define_insn "*am33_ashlsi3"
2142 [(set (match_operand:SI 0 "register_operand" "=dax,dx,!dax")
2144 (match_operand:SI 1 "register_operand" "0,0,dax")
2145 (match_operand:QI 2 "nonmemory_operand" "J,dxi,dax")))
2146 (clobber (reg:CC CC_REG))
2151 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 1)
2152 return \"add %0,%0\";
2154 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 2)
2157 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 3
2158 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS)
2159 return \"asl2 %0\;add %0,%0\";
2161 if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 4
2162 && REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS)
2163 return \"asl2 %0\;asl2 %0\";
2165 if (true_regnum (operands[1]) == true_regnum (operands[0]))
2166 return \"asl %S2,%0\";
2168 if (REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
2169 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
2170 && true_regnum (operands[0]) != true_regnum (operands[2]))
2171 return \"mov %1,%0\;asl %S2,%0\";
2172 return \"asl %2,%1,%0\";
2176 (define_insn "*mn10300_ashlsi3"
2177 [(set (match_operand:SI 0 "register_operand" "=dax,dx,dx,dx,dx")
2179 (match_operand:SI 1 "register_operand" "0,0,0,0,0")
2180 (match_operand:QI 2 "nonmemory_operand" "J,K,M,L,dxi")))
2181 (clobber (reg:CC CC_REG))
2192 (define_expand "lshrsi3"
2193 [(parallel [(set (match_operand:SI 0 "register_operand")
2195 (match_operand:SI 1 "register_operand")
2196 (match_operand:QI 2 "nonmemory_operand")))
2197 (clobber (reg:CC CC_REG))
2203 (define_insn "*am33_lshrsi3"
2204 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
2206 (match_operand:SI 1 "register_operand" "0,dax")
2207 (match_operand:QI 2 "nonmemory_operand" "dxi,dax")))
2208 (clobber (reg:CC CC_REG))
2213 if (true_regnum (operands[1]) == true_regnum (operands[0]))
2214 return \"lsr %S2,%0\";
2216 if (REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
2217 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
2218 && true_regnum (operands[0]) != true_regnum (operands[2]))
2219 return \"mov %1,%0\;lsr %S2,%0\";
2220 return \"lsr %2,%1,%0\";
2224 (define_insn "*mn10300_lshrsi3"
2225 [(set (match_operand:SI 0 "register_operand" "=dx")
2227 (match_operand:SI 1 "register_operand" "0")
2228 (match_operand:QI 2 "nonmemory_operand" "dxi")))
2229 (clobber (reg:CC CC_REG))
2235 (define_expand "ashrsi3"
2236 [(parallel [(set (match_operand:SI 0 "register_operand")
2238 (match_operand:SI 1 "register_operand")
2239 (match_operand:QI 2 "nonmemory_operand")))
2240 (clobber (reg:CC CC_REG))
2246 (define_insn "*am33_ashrisi3"
2247 [(set (match_operand:SI 0 "register_operand" "=dx,!dax")
2249 (match_operand:SI 1 "register_operand" "0,dax")
2250 (match_operand:QI 2 "nonmemory_operand" "dxi,dax")))
2251 (clobber (reg:CC CC_REG))
2256 if (true_regnum (operands[1]) == true_regnum (operands[0]))
2257 return \"asr %S2,%0\";
2259 if (REGNO_REG_CLASS (true_regnum (operands[0])) == DATA_REGS
2260 && REGNO_REG_CLASS (true_regnum (operands[1])) == DATA_REGS
2261 && true_regnum (operands[0]) != true_regnum (operands[2]))
2262 return \"mov %1,%0\;asr %S2,%0\";
2263 return \"asr %2,%1,%0\";
2267 (define_insn "*mn10300_ashrsi3"
2268 [(set (match_operand:SI 0 "register_operand" "=dx")
2270 (match_operand:SI 1 "register_operand" "0")
2271 (match_operand:QI 2 "nonmemory_operand" "dxi")))
2272 (clobber (reg:CC CC_REG))
2278 ;; ----------------------------------------------------------------------
2280 ;; ----------------------------------------------------------------------
2282 ;; The mn103 series does not have floating point instructions, but since
2283 ;; FP values are held in integer regs, we can clear the high bit easily
2284 ;; which gives us an efficient inline floating point absolute value.
2286 ;; Similarly for negation of a FP value.
2289 (define_expand "absdf2"
2290 [(set (match_operand:DF 0 "register_operand")
2291 (abs:DF (match_operand:DF 1 "register_operand")))]
2295 rtx target, result, insns;
2298 target = operand_subword (operands[0], 1, 1, DFmode);
2299 result = expand_binop (SImode, and_optab,
2300 operand_subword_force (operands[1], 1, DFmode),
2301 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
2303 gcc_assert (result);
2305 if (result != target)
2306 emit_move_insn (result, target);
2308 emit_move_insn (operand_subword (operands[0], 0, 1, DFmode),
2309 operand_subword_force (operands[1], 0, DFmode));
2311 insns = get_insns ();
2318 (define_expand "abssf2"
2319 [(set (match_operand:SF 0 "register_operand")
2320 (abs:SF (match_operand:SF 1 "register_operand")))]
2329 emit_insn (gen_abssf2_am33_2 (operands[0], operands[1]));
2333 target = operand_subword_force (operands[0], 0, SFmode);
2334 result = expand_binop (SImode, and_optab,
2335 operand_subword_force (operands[1], 0, SFmode),
2336 GEN_INT (0x7fffffff), target, 0, OPTAB_WIDEN);
2337 gcc_assert (result);
2339 if (result != target)
2340 emit_move_insn (result, target);
2342 /* Make a place for REG_EQUAL. */
2343 emit_move_insn (operands[0], operands[0]);
2348 (define_insn "abssf2_am33_2"
2349 [(set (match_operand:SF 0 "register_operand" "=f,f")
2350 (abs:SF (match_operand:SF 1 "register_operand" "0,?f")))]
2357 (define_expand "negdf2"
2358 [(set (match_operand:DF 0 "register_operand")
2359 (neg:DF (match_operand:DF 1 "register_operand")))]
2363 rtx target, result, insns;
2366 target = operand_subword (operands[0], 1, 1, DFmode);
2367 result = expand_binop (SImode, xor_optab,
2368 operand_subword_force (operands[1], 1, DFmode),
2369 GEN_INT (trunc_int_for_mode (0x80000000, SImode)),
2370 target, 0, OPTAB_WIDEN);
2372 gcc_assert (result);
2374 if (result != target)
2375 emit_move_insn (result, target);
2377 emit_move_insn (operand_subword (operands[0], 0, 1, DFmode),
2378 operand_subword_force (operands[1], 0, DFmode));
2380 insns = get_insns ();
2387 (define_expand "negsf2"
2388 [(set (match_operand:SF 0 "register_operand")
2389 (neg:SF (match_operand:SF 1 "register_operand")))]
2398 emit_insn (gen_negsf2_am33_2 (operands[0], operands[1]));
2402 target = operand_subword_force (operands[0], 0, SFmode);
2403 result = expand_binop (SImode, xor_optab,
2404 operand_subword_force (operands[1], 0, SFmode),
2405 GEN_INT (trunc_int_for_mode (0x80000000, SImode)),
2406 target, 0, OPTAB_WIDEN);
2407 gcc_assert (result);
2409 if (result != target)
2410 emit_move_insn (result, target);
2412 /* Make a place for REG_EQUAL. */
2413 emit_move_insn (operands[0], operands[0]);
2417 (define_insn "negsf2_am33_2"
2418 [(set (match_operand:SF 0 "register_operand" "=f,f")
2419 (neg:SF (match_operand:SF 1 "register_operand" "0,?f")))]
2426 (define_expand "sqrtsf2"
2427 [(parallel [(set (match_operand:SF 0 "register_operand" "")
2428 (sqrt:SF (match_operand:SF 1 "register_operand" "")))
2429 (clobber (reg:CC_FLOAT CC_REG))
2432 "TARGET_AM33_2 && flag_unsafe_math_optimizations"
2435 rtx scratch = gen_reg_rtx (SFmode);
2436 emit_insn (gen_rsqrtsf2 (scratch, operands[1], CONST1_RTX (SFmode)));
2437 emit_insn (gen_divsf3 (operands[0], force_reg (SFmode, CONST1_RTX (SFmode)),
2442 (define_insn "rsqrtsf2"
2443 [(set (match_operand:SF 0 "register_operand" "=f,f")
2444 (div:SF (match_operand:SF 2 "const_1f_operand" "F,F")
2445 (sqrt:SF (match_operand:SF 1 "register_operand" "0,?f"))))
2446 (clobber (reg:CC_FLOAT CC_REG))
2454 (define_expand "addsf3"
2455 [(parallel [(set (match_operand:SF 0 "register_operand")
2456 (plus:SF (match_operand:SF 1 "register_operand")
2457 (match_operand:SF 2 "nonmemory_operand")))
2458 (clobber (reg:CC_FLOAT CC_REG))])
2464 (define_insn "*addsf3_internal"
2465 [(set (match_operand:SF 0 "register_operand" "=f,f")
2466 (plus:SF (match_operand:SF 1 "register_operand" "%0,f")
2467 (match_operand:SF 2 "nonmemory_operand" "f,?fF")))
2468 (clobber (reg:CC_FLOAT CC_REG))
2476 (define_expand "subsf3"
2477 [(parallel [(set (match_operand:SF 0 "register_operand")
2478 (minus:SF (match_operand:SF 1 "register_operand")
2479 (match_operand:SF 2 "nonmemory_operand")))
2480 (clobber (reg:CC_FLOAT CC_REG))])
2486 (define_insn "*subsf3_internal"
2487 [(set (match_operand:SF 0 "register_operand" "=f,f")
2488 (minus:SF (match_operand:SF 1 "register_operand" "0,f")
2489 (match_operand:SF 2 "nonmemory_operand" "f,?fF")))
2490 (clobber (reg:CC_FLOAT CC_REG))
2498 (define_expand "mulsf3"
2499 [(parallel [(set (match_operand:SF 0 "register_operand")
2500 (mult:SF (match_operand:SF 1 "register_operand")
2501 (match_operand:SF 2 "nonmemory_operand")))
2502 (clobber (reg:CC_FLOAT CC_REG))])
2508 (define_insn "*mulsf3_internal"
2509 [(set (match_operand:SF 0 "register_operand" "=f,f")
2510 (mult:SF (match_operand:SF 1 "register_operand" "%0,f")
2511 (match_operand:SF 2 "nonmemory_operand" "f,?fF")))
2512 (clobber (reg:CC_FLOAT CC_REG))
2520 (define_insn "divsf3"
2521 [(set (match_operand:SF 0 "register_operand" "=f,f")
2522 (div:SF (match_operand:SF 1 "register_operand" "0,f")
2523 (match_operand:SF 2 "nonmemory_operand" "f,?fF")))
2524 (clobber (reg:CC_FLOAT CC_REG))
2532 (define_insn "fmaddsf4"
2533 [(set (match_operand:SF 0 "register_operand" "=A")
2534 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f")
2535 (match_operand:SF 2 "register_operand" "f"))
2536 (match_operand:SF 3 "register_operand" "f")))
2537 (clobber (reg:CC_FLOAT CC_REG))
2540 "fmadd %1, %2, %3, %0"
2543 (define_insn "fmsubsf4"
2544 [(set (match_operand:SF 0 "register_operand" "=A")
2545 (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f")
2546 (match_operand:SF 2 "register_operand" "f"))
2547 (match_operand:SF 3 "register_operand" "f")))
2548 (clobber (reg:CC_FLOAT CC_REG))
2551 "fmsub %1, %2, %3, %0"
2554 (define_insn "fnmaddsf4"
2555 [(set (match_operand:SF 0 "register_operand" "=A")
2556 (minus:SF (match_operand:SF 3 "register_operand" "f")
2557 (mult:SF (match_operand:SF 1 "register_operand" "%f")
2558 (match_operand:SF 2 "register_operand" "f"))))
2559 (clobber (reg:CC_FLOAT CC_REG))
2562 "fnmadd %1, %2, %3, %0"
2565 (define_insn "fnmsubsf4"
2566 [(set (match_operand:SF 0 "register_operand" "=A")
2567 (minus:SF (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "%f")
2568 (match_operand:SF 2 "register_operand" "f")))
2569 (match_operand:SF 3 "register_operand" "f")))
2570 (clobber (reg:CC_FLOAT CC_REG))
2573 "fnmsub %1, %2, %3, %0"
2576 ;; ----------------------------------------------------------------------
2577 ;; PROLOGUE/EPILOGUE
2578 ;; ----------------------------------------------------------------------
2579 (define_expand "prologue"
2582 "mn10300_expand_prologue (); DONE;")
2584 (define_expand "epilogue"
2589 mn10300_expand_epilogue ();
2593 (define_insn "return_internal"
2600 ;; This insn restores the callee saved registers and does a return, it
2601 ;; can also deallocate stack space.
2602 (define_insn "return_internal_regs"
2604 (match_operand:SI 0 "const_int_operand" "i")
2609 fputs (\"\\tret \", asm_out_file);
2610 mn10300_print_reg_list (asm_out_file, mn10300_get_live_callee_saved_regs ());
2611 fprintf (asm_out_file, \",%d\\n\", (int) INTVAL (operands[0]));
2616 ;; This instruction matches one generated by mn10300_gen_multiple_store()
2617 (define_insn "store_movm"
2618 [(match_parallel 0 "mn10300_store_multiple_operation"
2619 [(set (reg:SI SP_REG) (plus:SI (reg:SI SP_REG) (match_operand 1 "" "")))])]
2623 fputs (\"\\tmovm \", asm_out_file);
2624 mn10300_print_reg_list (asm_out_file,
2625 mn10300_store_multiple_operation (operands[0],
2627 fprintf (asm_out_file, \",(sp)\\n\");
2632 (define_insn "return"
2634 "mn10300_can_use_return_insn ()"
2637 rtx next = next_active_insn (insn);
2641 && GET_CODE (PATTERN (next)) == RETURN)
2648 ;; Try to combine consecutive updates of the stack pointer (or any
2649 ;; other register for that matter).
2651 [(parallel [(set (match_operand:SI 0 "register_operand" "=dxay")
2652 (plus:SI (match_dup 0)
2653 (match_operand 1 "const_int_operand" "")))
2654 (clobber (reg:CC CC_REG))
2656 (parallel [(set (match_dup 0)
2657 (plus:SI (match_dup 0)
2658 (match_operand 2 "const_int_operand" "")))
2659 (clobber (reg:CC CC_REG))
2665 operands[1] = GEN_INT (INTVAL (operands[2]) + INTVAL (operands[1]));
2666 return \"add %1,%0\";
2670 (define_expand "int_label"
2671 [(unspec [(match_operand:SI 0 "" "")] UNSPEC_INT_LABEL)]
2674 (define_expand "GOTaddr2picreg"
2678 /* It would be nice to be able to have int_label keep track of the
2679 counter and all, but if we add C code to it, we'll get an insn
2680 back, and we just want the pattern. */
2681 operands[0] = gen_int_label (GEN_INT (mn10300_unspec_int_label_counter++));
2683 emit_insn (gen_am33_loadPC (operands[0]));
2685 emit_insn (gen_mn10300_loadPC (operands[0]));
2686 emit_insn (gen_add_GOT_to_pic_reg (copy_rtx (operands[0])));
2691 (define_insn "am33_loadPC"
2693 [(set (reg:SI PIC_REG) (pc))
2694 (use (match_operand 0 "" ""))])]
2699 (define_insn_and_split "mn10300_loadPC"
2701 [(set (reg:SI PIC_REG) (pc))
2702 (use (match_operand 0 "" ""))])]
2705 "&& reload_completed"
2706 [(match_operand 0 "" "")]
2708 rtx sp_reg = gen_rtx_REG (SImode, SP_REG);
2709 int need_stack_space = (get_frame_size () == 0
2710 && crtl->outgoing_args_size == 0);
2712 if (need_stack_space)
2713 emit_insn (gen_addsi3 (sp_reg, sp_reg, GEN_INT (-4)));
2715 emit_insn (gen_call_next_insn (operands[0]));
2717 if (need_stack_space)
2718 emit_insn (gen_pop_pic_reg ());
2720 emit_move_insn (pic_offset_table_rtx, gen_rtx_MEM (SImode, sp_reg));
2725 (define_insn "call_next_insn"
2727 [(set (mem:SI (reg:SI SP_REG)) (pc))
2728 (use (match_operand 0 "" ""))])]
2732 (define_expand "add_GOT_to_pic_reg"
2733 [(parallel [(set (reg:SI PIC_REG)
2737 (unspec:SI [(minus:SI
2740 (const (match_operand:SI 0 "" ""))
2743 (clobber (reg:CC CC_REG))
2747 "operands[1] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME);"
2750 (define_expand "add_GOT_to_any_reg"
2751 [(parallel [(set (match_operand:SI 0 "" "")
2753 (match_operand:SI 1 "" "")
2758 (const (match_operand:SI 2 "" ""))
2761 (clobber (reg:CC CC_REG))
2765 "operands[3] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME);"
2768 (define_expand "symGOT2reg"
2769 [(match_operand:SI 0 "")
2770 (match_operand:SI 1 "")]
2774 rtx insn = emit_insn (gen_symGOT2reg_i (operands[0], operands[1]));
2776 MEM_READONLY_P (SET_SRC (PATTERN (insn))) = 1;
2778 set_unique_reg_note (insn, REG_EQUAL, operands[1]);
2783 (define_expand "symGOT2reg_i"
2784 [(set (match_operand:SI 0 "")
2785 (mem:SI (plus:SI (reg:SI PIC_REG)
2786 (const (unspec [(match_operand:SI 1 "")]
2791 (define_expand "symGOTOFF2reg"
2792 [(match_operand:SI 0 "") (match_operand:SI 1 "")]
2796 rtx insn = emit_insn (gen_symGOTOFF2reg_i (operands[0], operands[1]));
2798 set_unique_reg_note (insn, REG_EQUAL, operands[1]);
2803 (define_expand "symGOTOFF2reg_i"
2804 [(set (match_operand:SI 0 "")
2805 (const (unspec [(match_operand:SI 1 "")] UNSPEC_GOTOFF)))
2806 (parallel [(set (match_dup 0)
2807 (plus:SI (match_dup 0)
2809 (clobber (reg:CC CC_REG))
2815 (define_expand "sym2PIC"
2816 [(unspec [(match_operand:SI 0 "")] UNSPEC_PIC)]
2819 (define_expand "sym2PLT"
2820 [(unspec [(match_operand:SI 0 "")] UNSPEC_PLT)]