1 ;; -*- Mode: Scheme -*-
2 ;; Machine description for GNU compiler,
3 ;; for ATMEL AVR micro controllers.
4 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008
5 ;; Free Software Foundation, Inc.
6 ;; Contributed by Denis Chertykov (denisc@overta.ru)
8 ;; This file is part of GCC.
10 ;; GCC is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GCC is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GCC; see the file COPYING3. If not see
22 ;; <http://www.gnu.org/licenses/>.
24 ;; Special characters after '%':
25 ;; A No effect (add 0).
26 ;; B Add 1 to REG number, MEM address or CONST_INT.
29 ;; j Branch condition.
30 ;; k Reverse branch condition.
31 ;; o Displacement for (mem (plus (reg) (const_int))) operands.
32 ;; p POST_INC or PRE_DEC address as a pointer (X, Y, Z)
33 ;; r POST_INC or PRE_DEC address as a register (r26, r28, r30)
34 ;; ~ Output 'r' if not AVR_HAVE_JMP_CALL.
35 ;; ! Output 'e' if AVR_HAVE_EIJMP_EICALL.
38 ;; 0 Length of a string, see "strlenhi".
39 ;; 1 Jump by register pair Z or by table addressed by Z, see "casesi".
47 (TMP_REGNO 0) ; temporary register r0
48 (ZERO_REGNO 1) ; zero register r1
58 (UNSPECV_PROLOGUE_SAVES 0)
59 (UNSPECV_EPILOGUE_RESTORES 1)
60 (UNSPECV_WRITE_SP_IRQ_ON 2)
61 (UNSPECV_WRITE_SP_IRQ_OFF 3)
62 (UNSPECV_GOTO_RECEIVER 4)])
64 (include "predicates.md")
65 (include "constraints.md")
67 ;; Condition code settings.
68 (define_attr "cc" "none,set_czn,set_zn,set_n,compare,clobber"
69 (const_string "none"))
71 (define_attr "type" "branch,branch1,arith,xcall"
72 (const_string "arith"))
74 (define_attr "mcu_have_movw" "yes,no"
75 (const (if_then_else (symbol_ref "AVR_HAVE_MOVW")
77 (const_string "no"))))
79 (define_attr "mcu_mega" "yes,no"
80 (const (if_then_else (symbol_ref "AVR_HAVE_JMP_CALL")
82 (const_string "no"))))
85 ;; The size of instructions in bytes.
86 ;; XXX may depend from "cc"
88 (define_attr "length" ""
89 (cond [(eq_attr "type" "branch")
90 (if_then_else (and (ge (minus (pc) (match_dup 0))
92 (le (minus (pc) (match_dup 0))
95 (if_then_else (and (ge (minus (pc) (match_dup 0))
97 (le (minus (pc) (match_dup 0))
101 (eq_attr "type" "branch1")
102 (if_then_else (and (ge (minus (pc) (match_dup 0))
104 (le (minus (pc) (match_dup 0))
107 (if_then_else (and (ge (minus (pc) (match_dup 0))
109 (le (minus (pc) (match_dup 0))
113 (eq_attr "type" "xcall")
114 (if_then_else (eq_attr "mcu_mega" "no")
119 ;; Define mode iterator
120 (define_mode_iterator QISI [(QI "") (HI "") (SI "")])
122 ;;========================================================================
123 ;; The following is used by nonlocal_goto and setjmp.
124 ;; The receiver pattern will create no instructions since internally
125 ;; virtual_stack_vars = hard_frame_pointer + 1 so the RTL become R28=R28
126 ;; This avoids creating add/sub offsets in frame_pointer save/resore.
127 ;; The 'null' receiver also avoids problems with optimisation
128 ;; not recognising incoming jmp and removing code that resets frame_pointer.
129 ;; The code derived from builtins.c.
131 (define_expand "nonlocal_goto_receiver"
133 (unspec_volatile:HI [(const_int 0)] UNSPECV_GOTO_RECEIVER))]
136 emit_move_insn (virtual_stack_vars_rtx,
137 gen_rtx_PLUS (Pmode, hard_frame_pointer_rtx,
138 gen_int_mode (STARTING_FRAME_OFFSET,
140 /* This might change the hard frame pointer in ways that aren't
141 apparent to early optimization passes, so force a clobber. */
142 emit_clobber (hard_frame_pointer_rtx);
147 ;; Defining nonlocal_goto_receiver means we must also define this.
148 ;; even though its function is identical to that in builtins.c
150 (define_expand "nonlocal_goto"
152 (use (match_operand 0 "general_operand"))
153 (use (match_operand 1 "general_operand"))
154 (use (match_operand 2 "general_operand"))
155 (use (match_operand 3 "general_operand"))
159 rtx r_label = copy_to_reg (operands[1]);
160 rtx r_fp = operands[3];
161 rtx r_sp = operands[2];
163 emit_clobber (gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode)));
165 emit_clobber (gen_rtx_MEM (BLKmode, hard_frame_pointer_rtx));
167 emit_move_insn (hard_frame_pointer_rtx, r_fp);
168 emit_stack_restore (SAVE_NONLOCAL, r_sp, NULL_RTX);
170 emit_use (hard_frame_pointer_rtx);
171 emit_use (stack_pointer_rtx);
173 emit_indirect_jump (r_label);
179 (define_insn "*pushqi"
180 [(set (mem:QI (post_dec (reg:HI REG_SP)))
181 (match_operand:QI 0 "reg_or_0_operand" "r,L"))]
186 [(set_attr "length" "1,1")])
189 (define_insn "*pushhi"
190 [(set (mem:HI (post_dec (reg:HI REG_SP)))
191 (match_operand:HI 0 "reg_or_0_operand" "r,L"))]
195 push __zero_reg__\;push __zero_reg__"
196 [(set_attr "length" "2,2")])
198 (define_insn "*pushsi"
199 [(set (mem:SI (post_dec (reg:HI REG_SP)))
200 (match_operand:SI 0 "reg_or_0_operand" "r,L"))]
203 push %D0\;push %C0\;push %B0\;push %A0
204 push __zero_reg__\;push __zero_reg__\;push __zero_reg__\;push __zero_reg__"
205 [(set_attr "length" "4,4")])
207 (define_insn "*pushsf"
208 [(set (mem:SF (post_dec (reg:HI REG_SP)))
209 (match_operand:SF 0 "register_operand" "r"))]
215 [(set_attr "length" "4")])
217 ;;========================================================================
219 ;; The last alternative (any immediate constant to any register) is
220 ;; very expensive. It should be optimized by peephole2 if a scratch
221 ;; register is available, but then that register could just as well be
222 ;; allocated for the variable we are loading. But, most of NO_LD_REGS
223 ;; are call-saved registers, and most of LD_REGS are call-used registers,
224 ;; so this may still be a win for registers live across function calls.
226 (define_expand "movqi"
227 [(set (match_operand:QI 0 "nonimmediate_operand" "")
228 (match_operand:QI 1 "general_operand" ""))]
230 "/* One of the ops has to be in a register. */
231 if (!register_operand(operand0, QImode)
232 && ! (register_operand(operand1, QImode) || const0_rtx == operand1))
233 operands[1] = copy_to_mode_reg(QImode, operand1);
236 (define_insn "*movqi"
237 [(set (match_operand:QI 0 "nonimmediate_operand" "=r,d,Qm,r,q,r,*r")
238 (match_operand:QI 1 "general_operand" "r,i,rL,Qm,r,q,i"))]
239 "(register_operand (operands[0],QImode)
240 || register_operand (operands[1], QImode) || const0_rtx == operands[1])"
241 "* return output_movqi (insn, operands, NULL);"
242 [(set_attr "length" "1,1,5,5,1,1,4")
243 (set_attr "cc" "none,none,clobber,clobber,none,none,clobber")])
245 ;; This is used in peephole2 to optimize loading immediate constants
246 ;; if a scratch register from LD_REGS happens to be available.
248 (define_insn "*reload_inqi"
249 [(set (match_operand:QI 0 "register_operand" "=l")
250 (match_operand:QI 1 "immediate_operand" "i"))
251 (clobber (match_operand:QI 2 "register_operand" "=&d"))]
255 [(set_attr "length" "2")
256 (set_attr "cc" "none")])
259 [(match_scratch:QI 2 "d")
260 (set (match_operand:QI 0 "l_register_operand" "")
261 (match_operand:QI 1 "immediate_operand" ""))]
262 "(operands[1] != const0_rtx
263 && operands[1] != const1_rtx
264 && operands[1] != constm1_rtx)"
265 [(parallel [(set (match_dup 0) (match_dup 1))
266 (clobber (match_dup 2))])]
269 ;;============================================================================
270 ;; move word (16 bit)
272 (define_expand "movhi"
273 [(set (match_operand:HI 0 "nonimmediate_operand" "")
274 (match_operand:HI 1 "general_operand" ""))]
278 /* One of the ops has to be in a register. */
279 if (!register_operand(operand0, HImode)
280 && !(register_operand(operand1, HImode) || const0_rtx == operands[1]))
282 operands[1] = copy_to_mode_reg(HImode, operand1);
286 (define_insn "*movhi_sp"
287 [(set (match_operand:HI 0 "register_operand" "=q,r")
288 (match_operand:HI 1 "register_operand" "r,q"))]
289 "((stack_register_operand(operands[0], HImode) && register_operand (operands[1], HImode))
290 || (register_operand (operands[0], HImode) && stack_register_operand(operands[1], HImode)))"
291 "* return output_movhi (insn, operands, NULL);"
292 [(set_attr "length" "5,2")
293 (set_attr "cc" "none,none")])
295 (define_insn "movhi_sp_r_irq_off"
296 [(set (match_operand:HI 0 "stack_register_operand" "=q")
297 (unspec_volatile:HI [(match_operand:HI 1 "register_operand" "r")]
298 UNSPECV_WRITE_SP_IRQ_OFF))]
302 [(set_attr "length" "2")
303 (set_attr "cc" "none")])
305 (define_insn "movhi_sp_r_irq_on"
306 [(set (match_operand:HI 0 "stack_register_operand" "=q")
307 (unspec_volatile:HI [(match_operand:HI 1 "register_operand" "r")]
308 UNSPECV_WRITE_SP_IRQ_ON))]
314 [(set_attr "length" "4")
315 (set_attr "cc" "none")])
318 [(match_scratch:QI 2 "d")
319 (set (match_operand:HI 0 "l_register_operand" "")
320 (match_operand:HI 1 "immediate_operand" ""))]
321 "(operands[1] != const0_rtx
322 && operands[1] != constm1_rtx)"
323 [(parallel [(set (match_dup 0) (match_dup 1))
324 (clobber (match_dup 2))])]
327 ;; '*' because it is not used in rtl generation, only in above peephole
328 (define_insn "*reload_inhi"
329 [(set (match_operand:HI 0 "register_operand" "=r")
330 (match_operand:HI 1 "immediate_operand" "i"))
331 (clobber (match_operand:QI 2 "register_operand" "=&d"))]
333 "* return output_reload_inhi (insn, operands, NULL);"
334 [(set_attr "length" "4")
335 (set_attr "cc" "none")])
337 (define_insn "*movhi"
338 [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,d,*r,q,r")
339 (match_operand:HI 1 "general_operand" "r,m,rL,i,i,r,q"))]
340 "(register_operand (operands[0],HImode)
341 || register_operand (operands[1],HImode) || const0_rtx == operands[1])"
342 "* return output_movhi (insn, operands, NULL);"
343 [(set_attr "length" "2,6,7,2,6,5,2")
344 (set_attr "cc" "none,clobber,clobber,none,clobber,none,none")])
346 (define_peephole2 ; movw
347 [(set (match_operand:QI 0 "even_register_operand" "")
348 (match_operand:QI 1 "even_register_operand" ""))
349 (set (match_operand:QI 2 "odd_register_operand" "")
350 (match_operand:QI 3 "odd_register_operand" ""))]
352 && REGNO (operands[0]) == REGNO (operands[2]) - 1
353 && REGNO (operands[1]) == REGNO (operands[3]) - 1)"
354 [(set (match_dup 4) (match_dup 5))]
356 operands[4] = gen_rtx_REG (HImode, REGNO (operands[0]));
357 operands[5] = gen_rtx_REG (HImode, REGNO (operands[1]));
360 (define_peephole2 ; movw_r
361 [(set (match_operand:QI 0 "odd_register_operand" "")
362 (match_operand:QI 1 "odd_register_operand" ""))
363 (set (match_operand:QI 2 "even_register_operand" "")
364 (match_operand:QI 3 "even_register_operand" ""))]
366 && REGNO (operands[2]) == REGNO (operands[0]) - 1
367 && REGNO (operands[3]) == REGNO (operands[1]) - 1)"
368 [(set (match_dup 4) (match_dup 5))]
370 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));
371 operands[5] = gen_rtx_REG (HImode, REGNO (operands[3]));
374 ;;==========================================================================
375 ;; move double word (32 bit)
377 (define_expand "movsi"
378 [(set (match_operand:SI 0 "nonimmediate_operand" "")
379 (match_operand:SI 1 "general_operand" ""))]
383 /* One of the ops has to be in a register. */
384 if (!register_operand (operand0, SImode)
385 && !(register_operand (operand1, SImode) || const0_rtx == operand1))
387 operands[1] = copy_to_mode_reg (SImode, operand1);
393 (define_peephole2 ; movsi_lreg_const
394 [(match_scratch:QI 2 "d")
395 (set (match_operand:SI 0 "l_register_operand" "")
396 (match_operand:SI 1 "immediate_operand" ""))
398 "(operands[1] != const0_rtx
399 && operands[1] != constm1_rtx)"
400 [(parallel [(set (match_dup 0) (match_dup 1))
401 (clobber (match_dup 2))])]
404 ;; '*' because it is not used in rtl generation.
405 (define_insn "*reload_insi"
406 [(set (match_operand:SI 0 "register_operand" "=r")
407 (match_operand:SI 1 "immediate_operand" "i"))
408 (clobber (match_operand:QI 2 "register_operand" "=&d"))]
410 "* return output_reload_insisf (insn, operands, NULL);"
411 [(set_attr "length" "8")
412 (set_attr "cc" "none")])
415 (define_insn "*movsi"
416 [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,Qm,!d,r")
417 (match_operand:SI 1 "general_operand" "r,L,Qm,rL,i,i"))]
418 "(register_operand (operands[0],SImode)
419 || register_operand (operands[1],SImode) || const0_rtx == operands[1])"
420 "* return output_movsisf (insn, operands, NULL);"
421 [(set_attr "length" "4,4,8,9,4,10")
422 (set_attr "cc" "none,set_zn,clobber,clobber,none,clobber")])
424 ;; fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
425 ;; move floating point numbers (32 bit)
427 (define_expand "movsf"
428 [(set (match_operand:SF 0 "nonimmediate_operand" "")
429 (match_operand:SF 1 "general_operand" ""))]
433 /* One of the ops has to be in a register. */
434 if (!register_operand (operand1, SFmode)
435 && !register_operand (operand0, SFmode))
437 operands[1] = copy_to_mode_reg (SFmode, operand1);
441 (define_insn "*movsf"
442 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,r,Qm,!d,r")
443 (match_operand:SF 1 "general_operand" "r,G,Qm,r,F,F"))]
444 "register_operand (operands[0], SFmode)
445 || register_operand (operands[1], SFmode)"
446 "* return output_movsisf (insn, operands, NULL);"
447 [(set_attr "length" "4,4,8,9,4,10")
448 (set_attr "cc" "none,set_zn,clobber,clobber,none,clobber")])
450 ;;=========================================================================
451 ;; move string (like memcpy)
452 ;; implement as RTL loop
454 (define_expand "movmemhi"
455 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
456 (match_operand:BLK 1 "memory_operand" ""))
457 (use (match_operand:HI 2 "const_int_operand" ""))
458 (use (match_operand:HI 3 "const_int_operand" ""))])]
463 enum machine_mode mode;
464 rtx label = gen_label_rtx ();
468 /* Copy pointers into new psuedos - they will be changed. */
469 rtx addr0 = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
470 rtx addr1 = copy_to_mode_reg (Pmode, XEXP (operands[1], 0));
472 /* Create rtx for tmp register - we use this as scratch. */
473 rtx tmp_reg_rtx = gen_rtx_REG (QImode, TMP_REGNO);
475 if (GET_CODE (operands[2]) != CONST_INT)
478 count = INTVAL (operands[2]);
482 /* Work out branch probability for latter use. */
483 prob = REG_BR_PROB_BASE - REG_BR_PROB_BASE / count;
485 /* See if constant fit 8 bits. */
486 mode = (count < 0x100) ? QImode : HImode;
487 /* Create loop counter register. */
488 loop_reg = copy_to_mode_reg (mode, gen_int_mode (count, mode));
490 /* Now create RTL code for move loop. */
491 /* Label at top of loop. */
494 /* Move one byte into scratch and inc pointer. */
495 emit_move_insn (tmp_reg_rtx, gen_rtx_MEM (QImode, addr1));
496 emit_move_insn (addr1, gen_rtx_PLUS (Pmode, addr1, const1_rtx));
498 /* Move to mem and inc pointer. */
499 emit_move_insn (gen_rtx_MEM (QImode, addr0), tmp_reg_rtx);
500 emit_move_insn (addr0, gen_rtx_PLUS (Pmode, addr0, const1_rtx));
502 /* Decrement count. */
503 emit_move_insn (loop_reg, gen_rtx_PLUS (mode, loop_reg, constm1_rtx));
505 /* Compare with zero and jump if not equal. */
506 emit_cmp_and_jump_insns (loop_reg, const0_rtx, NE, NULL_RTX, mode, 1,
508 /* Set jump probability based on loop count. */
509 jump = get_last_insn ();
510 REG_NOTES (jump) = gen_rtx_EXPR_LIST (REG_BR_PROB,
516 ;; =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2 =%2
517 ;; memset (%0, %2, %1)
519 (define_expand "setmemhi"
520 [(parallel [(set (match_operand:BLK 0 "memory_operand" "")
521 (match_operand 2 "const_int_operand" ""))
522 (use (match_operand:HI 1 "const_int_operand" ""))
523 (use (match_operand:HI 3 "const_int_operand" "n"))
524 (clobber (match_scratch:HI 4 ""))
525 (clobber (match_dup 5))])]
530 enum machine_mode mode;
532 /* If value to set is not zero, use the library routine. */
533 if (operands[2] != const0_rtx)
536 if (GET_CODE (operands[1]) != CONST_INT)
539 cnt8 = byte_immediate_operand (operands[1], GET_MODE (operands[1]));
540 mode = cnt8 ? QImode : HImode;
541 operands[5] = gen_rtx_SCRATCH (mode);
542 operands[1] = copy_to_mode_reg (mode,
543 gen_int_mode (INTVAL (operands[1]), mode));
544 addr0 = copy_to_mode_reg (Pmode, XEXP (operands[0], 0));
545 operands[0] = gen_rtx_MEM (BLKmode, addr0);
548 (define_insn "*clrmemqi"
549 [(set (mem:BLK (match_operand:HI 0 "register_operand" "e"))
551 (use (match_operand:QI 1 "register_operand" "r"))
552 (use (match_operand:QI 2 "const_int_operand" "n"))
553 (clobber (match_scratch:HI 3 "=0"))
554 (clobber (match_scratch:QI 4 "=&1"))]
556 "st %a0+,__zero_reg__
559 [(set_attr "length" "3")
560 (set_attr "cc" "clobber")])
562 (define_insn "*clrmemhi"
563 [(set (mem:BLK (match_operand:HI 0 "register_operand" "e,e"))
565 (use (match_operand:HI 1 "register_operand" "!w,d"))
566 (use (match_operand:HI 2 "const_int_operand" "n,n"))
567 (clobber (match_scratch:HI 3 "=0,0"))
568 (clobber (match_scratch:HI 4 "=&1,&1"))]
571 if (which_alternative==0)
572 return (AS2 (st,%a0+,__zero_reg__) CR_TAB
573 AS2 (sbiw,%A1,1) CR_TAB
576 return (AS2 (st,%a0+,__zero_reg__) CR_TAB
577 AS2 (subi,%A1,1) CR_TAB
578 AS2 (sbci,%B1,0) CR_TAB
581 [(set_attr "length" "3,4")
582 (set_attr "cc" "clobber,clobber")])
584 (define_expand "strlenhi"
586 (unspec:HI [(match_operand:BLK 1 "memory_operand" "")
587 (match_operand:QI 2 "const_int_operand" "")
588 (match_operand:HI 3 "immediate_operand" "")]
590 (set (match_dup 4) (plus:HI (match_dup 4)
592 (set (match_operand:HI 0 "register_operand" "")
593 (minus:HI (match_dup 4)
598 if (! (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) == 0))
600 addr = copy_to_mode_reg (Pmode, XEXP (operands[1],0));
601 operands[1] = gen_rtx_MEM (BLKmode, addr);
603 operands[4] = gen_reg_rtx (HImode);
606 (define_insn "*strlenhi"
607 [(set (match_operand:HI 0 "register_operand" "=e")
608 (unspec:HI [(mem:BLK (match_operand:HI 1 "register_operand" "%0"))
610 (match_operand:HI 2 "immediate_operand" "i")]
616 [(set_attr "length" "3")
617 (set_attr "cc" "clobber")])
619 ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
622 (define_insn "addqi3"
623 [(set (match_operand:QI 0 "register_operand" "=r,d,r,r")
624 (plus:QI (match_operand:QI 1 "register_operand" "%0,0,0,0")
625 (match_operand:QI 2 "nonmemory_operand" "r,i,P,N")))]
632 [(set_attr "length" "1,1,1,1")
633 (set_attr "cc" "set_czn,set_czn,set_zn,set_zn")])
636 (define_expand "addhi3"
637 [(set (match_operand:HI 0 "register_operand" "")
638 (plus:HI (match_operand:HI 1 "register_operand" "")
639 (match_operand:HI 2 "nonmemory_operand" "")))]
643 if (GET_CODE (operands[2]) == CONST_INT)
645 short tmp = INTVAL (operands[2]);
646 operands[2] = GEN_INT(tmp);
651 (define_insn "*addhi3_zero_extend"
652 [(set (match_operand:HI 0 "register_operand" "=r")
653 (plus:HI (zero_extend:HI
654 (match_operand:QI 1 "register_operand" "r"))
655 (match_operand:HI 2 "register_operand" "0")))]
658 adc %B0,__zero_reg__"
659 [(set_attr "length" "2")
660 (set_attr "cc" "set_n")])
662 (define_insn "*addhi3_zero_extend1"
663 [(set (match_operand:HI 0 "register_operand" "=r")
664 (plus:HI (match_operand:HI 1 "register_operand" "%0")
666 (match_operand:QI 2 "register_operand" "r"))))]
669 adc %B0,__zero_reg__"
670 [(set_attr "length" "2")
671 (set_attr "cc" "set_n")])
673 (define_insn "*addhi3_sp_R_pc2"
674 [(set (match_operand:HI 1 "stack_register_operand" "=q")
675 (plus:HI (match_operand:HI 2 "stack_register_operand" "q")
676 (match_operand:HI 0 "avr_sp_immediate_operand" "R")))]
679 if (CONST_INT_P (operands[0]))
681 switch(INTVAL (operands[0]))
684 return \"rcall .\" CR_TAB
688 return \"rcall .\" CR_TAB
690 \"push __tmp_reg__\";
692 return \"rcall .\" CR_TAB
695 return \"rcall .\" CR_TAB
696 \"push __tmp_reg__\";
700 return \"push __tmp_reg__\";
704 return \"pop __tmp_reg__\";
706 return \"pop __tmp_reg__\" CR_TAB
709 return \"pop __tmp_reg__\" CR_TAB
710 \"pop __tmp_reg__\" CR_TAB
713 return \"pop __tmp_reg__\" CR_TAB
714 \"pop __tmp_reg__\" CR_TAB
715 \"pop __tmp_reg__\" CR_TAB
718 return \"pop __tmp_reg__\" CR_TAB
719 \"pop __tmp_reg__\" CR_TAB
720 \"pop __tmp_reg__\" CR_TAB
721 \"pop __tmp_reg__\" CR_TAB
727 [(set (attr "length")
728 (cond [(eq (const_int -6) (symbol_ref "INTVAL (operands[0])")) (const_int 3)
729 (eq (const_int -5) (symbol_ref "INTVAL (operands[0])")) (const_int 3)
730 (eq (const_int -4) (symbol_ref "INTVAL (operands[0])")) (const_int 2)
731 (eq (const_int -3) (symbol_ref "INTVAL (operands[0])")) (const_int 2)
732 (eq (const_int -2) (symbol_ref "INTVAL (operands[0])")) (const_int 1)
733 (eq (const_int -1) (symbol_ref "INTVAL (operands[0])")) (const_int 1)
734 (eq (const_int 0) (symbol_ref "INTVAL (operands[0])")) (const_int 0)
735 (eq (const_int 1) (symbol_ref "INTVAL (operands[0])")) (const_int 1)
736 (eq (const_int 2) (symbol_ref "INTVAL (operands[0])")) (const_int 2)
737 (eq (const_int 3) (symbol_ref "INTVAL (operands[0])")) (const_int 3)
738 (eq (const_int 4) (symbol_ref "INTVAL (operands[0])")) (const_int 4)
739 (eq (const_int 5) (symbol_ref "INTVAL (operands[0])")) (const_int 5)]
742 (define_insn "*addhi3_sp_R_pc3"
743 [(set (match_operand:HI 1 "stack_register_operand" "=q")
744 (plus:HI (match_operand:HI 2 "stack_register_operand" "q")
745 (match_operand:QI 0 "avr_sp_immediate_operand" "R")))]
748 if (CONST_INT_P (operands[0]))
750 switch(INTVAL (operands[0]))
753 return \"rcall .\" CR_TAB
756 return \"rcall .\" CR_TAB
757 \"push __tmp_reg__\" CR_TAB
758 \"push __tmp_reg__\";
760 return \"rcall .\" CR_TAB
761 \"push __tmp_reg__\";
765 return \"push __tmp_reg__\" CR_TAB
766 \"push __tmp_reg__\";
768 return \"push __tmp_reg__\";
772 return \"pop __tmp_reg__\";
774 return \"pop __tmp_reg__\" CR_TAB
777 return \"pop __tmp_reg__\" CR_TAB
778 \"pop __tmp_reg__\" CR_TAB
781 return \"pop __tmp_reg__\" CR_TAB
782 \"pop __tmp_reg__\" CR_TAB
783 \"pop __tmp_reg__\" CR_TAB
786 return \"pop __tmp_reg__\" CR_TAB
787 \"pop __tmp_reg__\" CR_TAB
788 \"pop __tmp_reg__\" CR_TAB
789 \"pop __tmp_reg__\" CR_TAB
795 [(set (attr "length")
796 (cond [(eq (const_int -6) (symbol_ref "INTVAL (operands[0])")) (const_int 2)
797 (eq (const_int -5) (symbol_ref "INTVAL (operands[0])")) (const_int 3)
798 (eq (const_int -4) (symbol_ref "INTVAL (operands[0])")) (const_int 2)
799 (eq (const_int -3) (symbol_ref "INTVAL (operands[0])")) (const_int 1)
800 (eq (const_int -2) (symbol_ref "INTVAL (operands[0])")) (const_int 2)
801 (eq (const_int -1) (symbol_ref "INTVAL (operands[0])")) (const_int 1)
802 (eq (const_int 0) (symbol_ref "INTVAL (operands[0])")) (const_int 0)
803 (eq (const_int 1) (symbol_ref "INTVAL (operands[0])")) (const_int 1)
804 (eq (const_int 2) (symbol_ref "INTVAL (operands[0])")) (const_int 2)
805 (eq (const_int 3) (symbol_ref "INTVAL (operands[0])")) (const_int 3)
806 (eq (const_int 4) (symbol_ref "INTVAL (operands[0])")) (const_int 4)
807 (eq (const_int 5) (symbol_ref "INTVAL (operands[0])")) (const_int 5)]
810 (define_insn "*addhi3"
811 [(set (match_operand:HI 0 "register_operand" "=r,!w,!w,d,r,r")
813 (match_operand:HI 1 "register_operand" "%0,0,0,0,0,0")
814 (match_operand:HI 2 "nonmemory_operand" "r,I,J,i,P,N")))]
817 add %A0,%A2\;adc %B0,%B2
820 subi %A0,lo8(-(%2))\;sbci %B0,hi8(-(%2))
821 sec\;adc %A0,__zero_reg__\;adc %B0,__zero_reg__
822 sec\;sbc %A0,__zero_reg__\;sbc %B0,__zero_reg__"
823 [(set_attr "length" "2,1,1,2,3,3")
824 (set_attr "cc" "set_n,set_czn,set_czn,set_czn,set_n,set_n")])
826 (define_insn "addsi3"
827 [(set (match_operand:SI 0 "register_operand" "=r,!w,!w,d,r,r")
829 (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0")
830 (match_operand:SI 2 "nonmemory_operand" "r,I,J,i,P,N")))]
833 add %A0,%A2\;adc %B0,%B2\;adc %C0,%C2\;adc %D0,%D2
834 adiw %0,%2\;adc %C0,__zero_reg__\;adc %D0,__zero_reg__
835 sbiw %0,%n2\;sbc %C0,__zero_reg__\;sbc %D0,__zero_reg__
836 subi %0,lo8(-(%2))\;sbci %B0,hi8(-(%2))\;sbci %C0,hlo8(-(%2))\;sbci %D0,hhi8(-(%2))
837 sec\;adc %A0,__zero_reg__\;adc %B0,__zero_reg__\;adc %C0,__zero_reg__\;adc %D0,__zero_reg__
838 sec\;sbc %A0,__zero_reg__\;sbc %B0,__zero_reg__\;sbc %C0,__zero_reg__\;sbc %D0,__zero_reg__"
839 [(set_attr "length" "4,3,3,4,5,5")
840 (set_attr "cc" "set_n,set_n,set_czn,set_czn,set_n,set_n")])
842 (define_insn "*addsi3_zero_extend"
843 [(set (match_operand:SI 0 "register_operand" "=r")
844 (plus:SI (zero_extend:SI
845 (match_operand:QI 1 "register_operand" "r"))
846 (match_operand:SI 2 "register_operand" "0")))]
851 adc %D0,__zero_reg__"
852 [(set_attr "length" "4")
853 (set_attr "cc" "set_n")])
855 ;-----------------------------------------------------------------------------
857 (define_insn "subqi3"
858 [(set (match_operand:QI 0 "register_operand" "=r,d")
859 (minus:QI (match_operand:QI 1 "register_operand" "0,0")
860 (match_operand:QI 2 "nonmemory_operand" "r,i")))]
865 [(set_attr "length" "1,1")
866 (set_attr "cc" "set_czn,set_czn")])
868 (define_insn "subhi3"
869 [(set (match_operand:HI 0 "register_operand" "=r,d")
870 (minus:HI (match_operand:HI 1 "register_operand" "0,0")
871 (match_operand:HI 2 "nonmemory_operand" "r,i")))]
874 sub %A0,%A2\;sbc %B0,%B2
875 subi %A0,lo8(%2)\;sbci %B0,hi8(%2)"
876 [(set_attr "length" "2,2")
877 (set_attr "cc" "set_czn,set_czn")])
879 (define_insn "*subhi3_zero_extend1"
880 [(set (match_operand:HI 0 "register_operand" "=r")
881 (minus:HI (match_operand:HI 1 "register_operand" "0")
883 (match_operand:QI 2 "register_operand" "r"))))]
886 sbc %B0,__zero_reg__"
887 [(set_attr "length" "2")
888 (set_attr "cc" "set_n")])
890 (define_insn "subsi3"
891 [(set (match_operand:SI 0 "register_operand" "=r,d")
892 (minus:SI (match_operand:SI 1 "register_operand" "0,0")
893 (match_operand:SI 2 "nonmemory_operand" "r,i")))]
896 sub %0,%2\;sbc %B0,%B2\;sbc %C0,%C2\;sbc %D0,%D2
897 subi %A0,lo8(%2)\;sbci %B0,hi8(%2)\;sbci %C0,hlo8(%2)\;sbci %D0,hhi8(%2)"
898 [(set_attr "length" "4,4")
899 (set_attr "cc" "set_czn,set_czn")])
901 (define_insn "*subsi3_zero_extend"
902 [(set (match_operand:SI 0 "register_operand" "=r")
903 (minus:SI (match_operand:SI 1 "register_operand" "0")
905 (match_operand:QI 2 "register_operand" "r"))))]
910 sbc %D0,__zero_reg__"
911 [(set_attr "length" "4")
912 (set_attr "cc" "set_n")])
914 ;******************************************************************************
917 (define_expand "mulqi3"
918 [(set (match_operand:QI 0 "register_operand" "")
919 (mult:QI (match_operand:QI 1 "register_operand" "")
920 (match_operand:QI 2 "register_operand" "")))]
925 emit_insn (gen_mulqi3_call (operands[0], operands[1], operands[2]));
930 (define_insn "*mulqi3_enh"
931 [(set (match_operand:QI 0 "register_operand" "=r")
932 (mult:QI (match_operand:QI 1 "register_operand" "r")
933 (match_operand:QI 2 "register_operand" "r")))]
938 [(set_attr "length" "3")
939 (set_attr "cc" "clobber")])
941 (define_expand "mulqi3_call"
942 [(set (reg:QI 24) (match_operand:QI 1 "register_operand" ""))
943 (set (reg:QI 22) (match_operand:QI 2 "register_operand" ""))
944 (parallel [(set (reg:QI 24) (mult:QI (reg:QI 24) (reg:QI 22)))
945 (clobber (reg:QI 22))])
946 (set (match_operand:QI 0 "register_operand" "") (reg:QI 24))]
950 (define_insn "*mulqi3_call"
951 [(set (reg:QI 24) (mult:QI (reg:QI 24) (reg:QI 22)))
952 (clobber (reg:QI 22))]
955 [(set_attr "type" "xcall")
956 (set_attr "cc" "clobber")])
958 (define_insn "mulqihi3"
959 [(set (match_operand:HI 0 "register_operand" "=r")
960 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "d"))
961 (sign_extend:HI (match_operand:QI 2 "register_operand" "d"))))]
966 [(set_attr "length" "3")
967 (set_attr "cc" "clobber")])
969 (define_insn "umulqihi3"
970 [(set (match_operand:HI 0 "register_operand" "=r")
971 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "r"))
972 (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
977 [(set_attr "length" "3")
978 (set_attr "cc" "clobber")])
980 (define_expand "mulhi3"
981 [(set (match_operand:HI 0 "register_operand" "")
982 (mult:HI (match_operand:HI 1 "register_operand" "")
983 (match_operand:HI 2 "register_operand" "")))]
989 emit_insn (gen_mulhi3_call (operands[0], operands[1], operands[2]));
994 (define_insn "*mulhi3_enh"
995 [(set (match_operand:HI 0 "register_operand" "=&r")
996 (mult:HI (match_operand:HI 1 "register_operand" "r")
997 (match_operand:HI 2 "register_operand" "r")))]
1006 [(set_attr "length" "7")
1007 (set_attr "cc" "clobber")])
1009 (define_expand "mulhi3_call"
1010 [(set (reg:HI 24) (match_operand:HI 1 "register_operand" ""))
1011 (set (reg:HI 22) (match_operand:HI 2 "register_operand" ""))
1012 (parallel [(set (reg:HI 24) (mult:HI (reg:HI 24) (reg:HI 22)))
1013 (clobber (reg:HI 22))
1014 (clobber (reg:QI 21))])
1015 (set (match_operand:HI 0 "register_operand" "") (reg:HI 24))]
1019 (define_insn "*mulhi3_call"
1020 [(set (reg:HI 24) (mult:HI (reg:HI 24) (reg:HI 22)))
1021 (clobber (reg:HI 22))
1022 (clobber (reg:QI 21))]
1025 [(set_attr "type" "xcall")
1026 (set_attr "cc" "clobber")])
1028 ;; Operand 2 (reg:SI 18) not clobbered on the enhanced core.
1029 ;; All call-used registers clobbered otherwise - normal library call.
1030 (define_expand "mulsi3"
1031 [(set (reg:SI 22) (match_operand:SI 1 "register_operand" ""))
1032 (set (reg:SI 18) (match_operand:SI 2 "register_operand" ""))
1033 (parallel [(set (reg:SI 22) (mult:SI (reg:SI 22) (reg:SI 18)))
1034 (clobber (reg:HI 26))
1035 (clobber (reg:HI 30))])
1036 (set (match_operand:SI 0 "register_operand" "") (reg:SI 22))]
1040 (define_insn "*mulsi3_call"
1041 [(set (reg:SI 22) (mult:SI (reg:SI 22) (reg:SI 18)))
1042 (clobber (reg:HI 26))
1043 (clobber (reg:HI 30))]
1046 [(set_attr "type" "xcall")
1047 (set_attr "cc" "clobber")])
1049 ; / % / % / % / % / % / % / % / % / % / % / % / % / % / % / % / % / % / % / %
1052 ;; Generate libgcc.S calls ourselves, because:
1053 ;; - we know exactly which registers are clobbered (for QI and HI
1054 ;; modes, some of the call-used registers are preserved)
1055 ;; - we get both the quotient and the remainder at no extra cost
1057 (define_expand "divmodqi4"
1058 [(set (reg:QI 24) (match_operand:QI 1 "register_operand" ""))
1059 (set (reg:QI 22) (match_operand:QI 2 "register_operand" ""))
1060 (parallel [(set (reg:QI 24) (div:QI (reg:QI 24) (reg:QI 22)))
1061 (set (reg:QI 25) (mod:QI (reg:QI 24) (reg:QI 22)))
1062 (clobber (reg:QI 22))
1063 (clobber (reg:QI 23))])
1064 (set (match_operand:QI 0 "register_operand" "") (reg:QI 24))
1065 (set (match_operand:QI 3 "register_operand" "") (reg:QI 25))]
1069 (define_insn "*divmodqi4_call"
1070 [(set (reg:QI 24) (div:QI (reg:QI 24) (reg:QI 22)))
1071 (set (reg:QI 25) (mod:QI (reg:QI 24) (reg:QI 22)))
1072 (clobber (reg:QI 22))
1073 (clobber (reg:QI 23))]
1075 "%~call __divmodqi4"
1076 [(set_attr "type" "xcall")
1077 (set_attr "cc" "clobber")])
1079 (define_expand "udivmodqi4"
1080 [(set (reg:QI 24) (match_operand:QI 1 "register_operand" ""))
1081 (set (reg:QI 22) (match_operand:QI 2 "register_operand" ""))
1082 (parallel [(set (reg:QI 24) (udiv:QI (reg:QI 24) (reg:QI 22)))
1083 (set (reg:QI 25) (umod:QI (reg:QI 24) (reg:QI 22)))
1084 (clobber (reg:QI 23))])
1085 (set (match_operand:QI 0 "register_operand" "") (reg:QI 24))
1086 (set (match_operand:QI 3 "register_operand" "") (reg:QI 25))]
1090 (define_insn "*udivmodqi4_call"
1091 [(set (reg:QI 24) (udiv:QI (reg:QI 24) (reg:QI 22)))
1092 (set (reg:QI 25) (umod:QI (reg:QI 24) (reg:QI 22)))
1093 (clobber (reg:QI 23))]
1095 "%~call __udivmodqi4"
1096 [(set_attr "type" "xcall")
1097 (set_attr "cc" "clobber")])
1099 (define_expand "divmodhi4"
1100 [(set (reg:HI 24) (match_operand:HI 1 "register_operand" ""))
1101 (set (reg:HI 22) (match_operand:HI 2 "register_operand" ""))
1102 (parallel [(set (reg:HI 22) (div:HI (reg:HI 24) (reg:HI 22)))
1103 (set (reg:HI 24) (mod:HI (reg:HI 24) (reg:HI 22)))
1104 (clobber (reg:HI 26))
1105 (clobber (reg:QI 21))])
1106 (set (match_operand:HI 0 "register_operand" "") (reg:HI 22))
1107 (set (match_operand:HI 3 "register_operand" "") (reg:HI 24))]
1111 (define_insn "*divmodhi4_call"
1112 [(set (reg:HI 22) (div:HI (reg:HI 24) (reg:HI 22)))
1113 (set (reg:HI 24) (mod:HI (reg:HI 24) (reg:HI 22)))
1114 (clobber (reg:HI 26))
1115 (clobber (reg:QI 21))]
1117 "%~call __divmodhi4"
1118 [(set_attr "type" "xcall")
1119 (set_attr "cc" "clobber")])
1121 (define_expand "udivmodhi4"
1122 [(set (reg:HI 24) (match_operand:HI 1 "register_operand" ""))
1123 (set (reg:HI 22) (match_operand:HI 2 "register_operand" ""))
1124 (parallel [(set (reg:HI 22) (udiv:HI (reg:HI 24) (reg:HI 22)))
1125 (set (reg:HI 24) (umod:HI (reg:HI 24) (reg:HI 22)))
1126 (clobber (reg:HI 26))
1127 (clobber (reg:QI 21))])
1128 (set (match_operand:HI 0 "register_operand" "") (reg:HI 22))
1129 (set (match_operand:HI 3 "register_operand" "") (reg:HI 24))]
1133 (define_insn "*udivmodhi4_call"
1134 [(set (reg:HI 22) (udiv:HI (reg:HI 24) (reg:HI 22)))
1135 (set (reg:HI 24) (umod:HI (reg:HI 24) (reg:HI 22)))
1136 (clobber (reg:HI 26))
1137 (clobber (reg:QI 21))]
1139 "%~call __udivmodhi4"
1140 [(set_attr "type" "xcall")
1141 (set_attr "cc" "clobber")])
1143 (define_expand "divmodsi4"
1144 [(set (reg:SI 22) (match_operand:SI 1 "register_operand" ""))
1145 (set (reg:SI 18) (match_operand:SI 2 "register_operand" ""))
1146 (parallel [(set (reg:SI 18) (div:SI (reg:SI 22) (reg:SI 18)))
1147 (set (reg:SI 22) (mod:SI (reg:SI 22) (reg:SI 18)))
1148 (clobber (reg:HI 26))
1149 (clobber (reg:HI 30))])
1150 (set (match_operand:SI 0 "register_operand" "") (reg:SI 18))
1151 (set (match_operand:SI 3 "register_operand" "") (reg:SI 22))]
1155 (define_insn "*divmodsi4_call"
1156 [(set (reg:SI 18) (div:SI (reg:SI 22) (reg:SI 18)))
1157 (set (reg:SI 22) (mod:SI (reg:SI 22) (reg:SI 18)))
1158 (clobber (reg:HI 26))
1159 (clobber (reg:HI 30))]
1161 "%~call __divmodsi4"
1162 [(set_attr "type" "xcall")
1163 (set_attr "cc" "clobber")])
1165 (define_expand "udivmodsi4"
1166 [(set (reg:SI 22) (match_operand:SI 1 "register_operand" ""))
1167 (set (reg:SI 18) (match_operand:SI 2 "register_operand" ""))
1168 (parallel [(set (reg:SI 18) (udiv:SI (reg:SI 22) (reg:SI 18)))
1169 (set (reg:SI 22) (umod:SI (reg:SI 22) (reg:SI 18)))
1170 (clobber (reg:HI 26))
1171 (clobber (reg:HI 30))])
1172 (set (match_operand:SI 0 "register_operand" "") (reg:SI 18))
1173 (set (match_operand:SI 3 "register_operand" "") (reg:SI 22))]
1177 (define_insn "*udivmodsi4_call"
1178 [(set (reg:SI 18) (udiv:SI (reg:SI 22) (reg:SI 18)))
1179 (set (reg:SI 22) (umod:SI (reg:SI 22) (reg:SI 18)))
1180 (clobber (reg:HI 26))
1181 (clobber (reg:HI 30))]
1183 "%~call __udivmodsi4"
1184 [(set_attr "type" "xcall")
1185 (set_attr "cc" "clobber")])
1187 ;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
1190 (define_insn "andqi3"
1191 [(set (match_operand:QI 0 "register_operand" "=r,d")
1192 (and:QI (match_operand:QI 1 "register_operand" "%0,0")
1193 (match_operand:QI 2 "nonmemory_operand" "r,i")))]
1198 [(set_attr "length" "1,1")
1199 (set_attr "cc" "set_zn,set_zn")])
1201 (define_insn "andhi3"
1202 [(set (match_operand:HI 0 "register_operand" "=r,d,r")
1203 (and:HI (match_operand:HI 1 "register_operand" "%0,0,0")
1204 (match_operand:HI 2 "nonmemory_operand" "r,i,M")))
1205 (clobber (match_scratch:QI 3 "=X,X,&d"))]
1208 if (which_alternative==0)
1209 return (AS2 (and,%A0,%A2) CR_TAB
1211 else if (which_alternative==1)
1213 if (GET_CODE (operands[2]) == CONST_INT)
1215 int mask = INTVAL (operands[2]);
1216 if ((mask & 0xff) != 0xff)
1217 output_asm_insn (AS2 (andi,%A0,lo8(%2)), operands);
1218 if ((mask & 0xff00) != 0xff00)
1219 output_asm_insn (AS2 (andi,%B0,hi8(%2)), operands);
1222 return (AS2 (andi,%A0,lo8(%2)) CR_TAB
1223 AS2 (andi,%B0,hi8(%2)));
1225 return (AS2 (ldi,%3,lo8(%2)) CR_TAB
1226 AS2 (and,%A0,%3) CR_TAB
1229 [(set_attr "length" "2,2,3")
1230 (set_attr "cc" "set_n,clobber,set_n")])
1232 (define_insn "andsi3"
1233 [(set (match_operand:SI 0 "register_operand" "=r,d")
1234 (and:SI (match_operand:SI 1 "register_operand" "%0,0")
1235 (match_operand:SI 2 "nonmemory_operand" "r,i")))]
1238 if (which_alternative==0)
1239 return (AS2 (and, %0,%2) CR_TAB
1240 AS2 (and, %B0,%B2) CR_TAB
1241 AS2 (and, %C0,%C2) CR_TAB
1242 AS2 (and, %D0,%D2));
1243 else if (which_alternative==1)
1245 if (GET_CODE (operands[2]) == CONST_INT)
1247 HOST_WIDE_INT mask = INTVAL (operands[2]);
1248 if ((mask & 0xff) != 0xff)
1249 output_asm_insn (AS2 (andi,%A0,lo8(%2)), operands);
1250 if ((mask & 0xff00) != 0xff00)
1251 output_asm_insn (AS2 (andi,%B0,hi8(%2)), operands);
1252 if ((mask & 0xff0000L) != 0xff0000L)
1253 output_asm_insn (AS2 (andi,%C0,hlo8(%2)), operands);
1254 if ((mask & 0xff000000L) != 0xff000000L)
1255 output_asm_insn (AS2 (andi,%D0,hhi8(%2)), operands);
1258 return (AS2 (andi, %A0,lo8(%2)) CR_TAB
1259 AS2 (andi, %B0,hi8(%2)) CR_TAB
1260 AS2 (andi, %C0,hlo8(%2)) CR_TAB
1261 AS2 (andi, %D0,hhi8(%2)));
1265 [(set_attr "length" "4,4")
1266 (set_attr "cc" "set_n,clobber")])
1268 (define_peephole2 ; andi
1269 [(set (match_operand:QI 0 "d_register_operand" "")
1270 (and:QI (match_dup 0)
1271 (match_operand:QI 1 "const_int_operand" "")))
1273 (and:QI (match_dup 0)
1274 (match_operand:QI 2 "const_int_operand" "")))]
1276 [(set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))]
1278 operands[1] = GEN_INT (INTVAL (operands[1]) & INTVAL (operands[2]));
1281 ;;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1284 (define_insn "iorqi3"
1285 [(set (match_operand:QI 0 "register_operand" "=r,d")
1286 (ior:QI (match_operand:QI 1 "register_operand" "%0,0")
1287 (match_operand:QI 2 "nonmemory_operand" "r,i")))]
1292 [(set_attr "length" "1,1")
1293 (set_attr "cc" "set_zn,set_zn")])
1295 (define_insn "iorhi3"
1296 [(set (match_operand:HI 0 "register_operand" "=r,d")
1297 (ior:HI (match_operand:HI 1 "register_operand" "%0,0")
1298 (match_operand:HI 2 "nonmemory_operand" "r,i")))]
1301 if (which_alternative==0)
1302 return (AS2 (or,%A0,%A2) CR_TAB
1304 if (GET_CODE (operands[2]) == CONST_INT)
1306 int mask = INTVAL (operands[2]);
1308 output_asm_insn (AS2 (ori,%A0,lo8(%2)), operands);
1310 output_asm_insn (AS2 (ori,%B0,hi8(%2)), operands);
1313 return (AS2 (ori,%0,lo8(%2)) CR_TAB
1314 AS2 (ori,%B0,hi8(%2)));
1316 [(set_attr "length" "2,2")
1317 (set_attr "cc" "set_n,clobber")])
1319 (define_insn "*iorhi3_clobber"
1320 [(set (match_operand:HI 0 "register_operand" "=r,r")
1321 (ior:HI (match_operand:HI 1 "register_operand" "%0,0")
1322 (match_operand:HI 2 "immediate_operand" "M,i")))
1323 (clobber (match_scratch:QI 3 "=&d,&d"))]
1326 ldi %3,lo8(%2)\;or %A0,%3
1327 ldi %3,lo8(%2)\;or %A0,%3\;ldi %3,hi8(%2)\;or %B0,%3"
1328 [(set_attr "length" "2,4")
1329 (set_attr "cc" "clobber,set_n")])
1331 (define_insn "iorsi3"
1332 [(set (match_operand:SI 0 "register_operand" "=r,d")
1333 (ior:SI (match_operand:SI 1 "register_operand" "%0,0")
1334 (match_operand:SI 2 "nonmemory_operand" "r,i")))]
1337 if (which_alternative==0)
1338 return (AS2 (or, %0,%2) CR_TAB
1339 AS2 (or, %B0,%B2) CR_TAB
1340 AS2 (or, %C0,%C2) CR_TAB
1342 if (GET_CODE (operands[2]) == CONST_INT)
1344 HOST_WIDE_INT mask = INTVAL (operands[2]);
1346 output_asm_insn (AS2 (ori,%A0,lo8(%2)), operands);
1348 output_asm_insn (AS2 (ori,%B0,hi8(%2)), operands);
1349 if (mask & 0xff0000L)
1350 output_asm_insn (AS2 (ori,%C0,hlo8(%2)), operands);
1351 if (mask & 0xff000000L)
1352 output_asm_insn (AS2 (ori,%D0,hhi8(%2)), operands);
1355 return (AS2 (ori, %A0,lo8(%2)) CR_TAB
1356 AS2 (ori, %B0,hi8(%2)) CR_TAB
1357 AS2 (ori, %C0,hlo8(%2)) CR_TAB
1358 AS2 (ori, %D0,hhi8(%2)));
1360 [(set_attr "length" "4,4")
1361 (set_attr "cc" "set_n,clobber")])
1363 (define_insn "*iorsi3_clobber"
1364 [(set (match_operand:SI 0 "register_operand" "=r,r")
1365 (ior:SI (match_operand:SI 1 "register_operand" "%0,0")
1366 (match_operand:SI 2 "immediate_operand" "M,i")))
1367 (clobber (match_scratch:QI 3 "=&d,&d"))]
1370 ldi %3,lo8(%2)\;or %A0,%3
1371 ldi %3,lo8(%2)\;or %A0,%3\;ldi %3,hi8(%2)\;or %B0,%3\;ldi %3,hlo8(%2)\;or %C0,%3\;ldi %3,hhi8(%2)\;or %D0,%3"
1372 [(set_attr "length" "2,8")
1373 (set_attr "cc" "clobber,set_n")])
1375 ;;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1378 (define_insn "xorqi3"
1379 [(set (match_operand:QI 0 "register_operand" "=r")
1380 (xor:QI (match_operand:QI 1 "register_operand" "%0")
1381 (match_operand:QI 2 "register_operand" "r")))]
1384 [(set_attr "length" "1")
1385 (set_attr "cc" "set_zn")])
1387 (define_insn "xorhi3"
1388 [(set (match_operand:HI 0 "register_operand" "=r")
1389 (xor:HI (match_operand:HI 1 "register_operand" "%0")
1390 (match_operand:HI 2 "register_operand" "r")))]
1394 [(set_attr "length" "2")
1395 (set_attr "cc" "set_n")])
1397 (define_insn "xorsi3"
1398 [(set (match_operand:SI 0 "register_operand" "=r")
1399 (xor:SI (match_operand:SI 1 "register_operand" "%0")
1400 (match_operand:SI 2 "register_operand" "r")))]
1406 [(set_attr "length" "4")
1407 (set_attr "cc" "set_n")])
1409 ;; swap swap swap swap swap swap swap swap swap swap swap swap swap swap swap
1412 (define_expand "rotlqi3"
1413 [(set (match_operand:QI 0 "register_operand" "")
1414 (rotate:QI (match_operand:QI 1 "register_operand" "")
1415 (match_operand:QI 2 "const_int_operand" "")))]
1419 if (INTVAL (operands[2]) != 4)
1423 (define_insn "*rotlqi3_4"
1424 [(set (match_operand:QI 0 "register_operand" "=r")
1425 (rotate:QI (match_operand:QI 1 "register_operand" "0")
1429 [(set_attr "length" "1")
1430 (set_attr "cc" "none")])
1432 (define_expand "rotlhi3"
1433 [(set (match_operand:HI 0 "register_operand" "")
1434 (rotate:HI (match_operand:HI 1 "register_operand" "")
1435 (match_operand:HI 2 "const_int_operand" "")))]
1439 if (INTVAL (operands[2]) != 8)
1443 (define_insn_and_split "*rotlhi3_8"
1444 [(set (match_operand:HI 0 "register_operand" "=r")
1445 (rotate:HI (match_operand:HI 1 "register_operand" "r")
1448 "mov __tmp_reg__,%A0
1450 mov %B0, __tmp_reg__"
1452 && REGNO (operands[0]) != REGNO (operands[1])"
1453 [(set (match_dup 2) (match_dup 5))
1454 (set (match_dup 3) (match_dup 4))]
1455 "operands[2] = gen_lowpart (QImode, operands[0]);
1456 operands[3] = gen_highpart (QImode, operands[0]);
1458 operands[4] = gen_lowpart (QImode, operands[1]);
1459 operands[5] = gen_highpart (QImode, operands[1]);"
1460 [(set_attr "length" "3")
1461 (set_attr "cc" "none")])
1463 (define_expand "rotlsi3"
1464 [(set (match_operand:SI 0 "register_operand" "")
1465 (rotate:SI (match_operand:SI 1 "register_operand" "")
1466 (match_operand:SI 2 "const_int_operand" "")))]
1470 if (INTVAL (operands[2]) != 8
1471 || INTVAL (operands[2]) != 16
1472 || INTVAL (operands[2]) != 24)
1476 (define_insn_and_split "*rotlsi3_16"
1477 [(set (match_operand:SI 0 "register_operand" "=r")
1478 (rotate:SI (match_operand:SI 1 "register_operand" "r")
1481 "{mov __tmp_reg__,%A1\;mov %A0,%C1\;mov %C0, __tmp_reg__\;mov __tmp_reg__,%B1\;mov %B0,%D1\;mov %D0, __tmp_reg__|movw __tmp_reg__,%A1\;movw %A0,%C1\;movw %C0, __tmp_reg__\;clr __zero_reg__}"
1483 && REGNO (operands[0]) != REGNO (operands[1])"
1484 [(set (match_dup 2) (match_dup 5))
1485 (set (match_dup 3) (match_dup 4))]
1486 "unsigned int si_lo_off = subreg_lowpart_offset (HImode, SImode);
1487 unsigned int si_hi_off = subreg_highpart_offset (HImode, SImode);
1489 operands[2] = simplify_gen_subreg (HImode, operands[0], SImode, si_lo_off);
1490 operands[3] = simplify_gen_subreg (HImode, operands[0], SImode, si_hi_off);
1492 operands[4] = simplify_gen_subreg (HImode, operands[1], SImode, si_lo_off);
1493 operands[5] = simplify_gen_subreg (HImode, operands[1], SImode, si_hi_off);
1495 if (REGNO (operands[0]) == REGNO(operands[1]) + 2)
1497 emit_move_insn (operands[3], operands[4]);
1500 else if (REGNO (operands[0]) == REGNO(operands[1]) - 2)
1502 emit_move_insn (operands[2], operands[5]);
1505 [(set (attr "length") (if_then_else (eq_attr "mcu_have_movw" "yes")
1508 (set (attr "cc") (if_then_else (eq_attr "mcu_have_movw" "yes")
1509 (const_string "clobber")
1510 (const_string "none")))])
1512 (define_insn_and_split "*rotlsi3_8"
1513 [(set (match_operand:SI 0 "register_operand" "=r")
1514 (rotate:SI (match_operand:SI 1 "register_operand" "r")
1517 "mov __tmp_reg__,%D1
1521 mov %A0, __tmp_reg__"
1523 && REGNO (operands[0]) != REGNO (operands[1])"
1525 "unsigned int si_lo_off = subreg_lowpart_offset (HImode, SImode);
1526 unsigned int si_hi_off = subreg_highpart_offset (HImode, SImode);
1527 unsigned int hi_lo_off = subreg_lowpart_offset (QImode, HImode);
1528 unsigned int hi_hi_off = subreg_highpart_offset (QImode, HImode);
1530 operands[2] = simplify_gen_subreg (HImode, operands[0], SImode, si_lo_off);
1531 operands[4] = simplify_gen_subreg (HImode, operands[0], SImode, si_hi_off);
1532 operands[3] = simplify_gen_subreg (QImode, operands[2], HImode, hi_hi_off);
1533 operands[2] = simplify_gen_subreg (QImode, operands[2], HImode, hi_lo_off);
1534 operands[5] = simplify_gen_subreg (QImode, operands[4], HImode, hi_hi_off);
1535 operands[4] = simplify_gen_subreg (QImode, operands[4], HImode, hi_lo_off);
1537 operands[6] = simplify_gen_subreg (HImode, operands[1], SImode, si_lo_off);
1538 operands[8] = simplify_gen_subreg (HImode, operands[1], SImode, si_hi_off);
1539 operands[7] = simplify_gen_subreg (QImode, operands[6], HImode, hi_hi_off);
1540 operands[6] = simplify_gen_subreg (QImode, operands[6], HImode, hi_lo_off);
1541 operands[9] = simplify_gen_subreg (QImode, operands[8], HImode, hi_hi_off);
1542 operands[8] = simplify_gen_subreg (QImode, operands[8], HImode, hi_lo_off);
1544 if (REGNO (operands[0]) < REGNO(operands[1]))
1546 emit_move_insn (operands[2], operands[9]);
1547 emit_move_insn (operands[3], operands[6]);
1548 emit_move_insn (operands[4], operands[7]);
1549 emit_move_insn (operands[5], operands[8]);
1553 emit_move_insn (operands[5], operands[8]);
1554 emit_move_insn (operands[2], operands[9]);
1555 emit_move_insn (operands[4], operands[7]);
1556 emit_move_insn (operands[3], operands[6]);
1559 [(set_attr "length" "5")
1560 (set_attr "cc" "none")])
1562 (define_insn_and_split "*rotlsi3_24"
1563 [(set (match_operand:SI 0 "register_operand" "=r")
1564 (rotate:SI (match_operand:SI 1 "register_operand" "r")
1567 "mov __tmp_reg__,%A1
1571 mov %D0, __tmp_reg__"
1573 && REGNO (operands[0]) != REGNO (operands[1])"
1575 "unsigned int si_lo_off = subreg_lowpart_offset (HImode, SImode);
1576 unsigned int si_hi_off = subreg_highpart_offset (HImode, SImode);
1577 unsigned int hi_lo_off = subreg_lowpart_offset (QImode, HImode);
1578 unsigned int hi_hi_off = subreg_highpart_offset (QImode, HImode);
1580 operands[2] = simplify_gen_subreg (HImode, operands[0], SImode, si_lo_off);
1581 operands[4] = simplify_gen_subreg (HImode, operands[0], SImode, si_hi_off);
1582 operands[3] = simplify_gen_subreg (QImode, operands[2], HImode, hi_hi_off);
1583 operands[2] = simplify_gen_subreg (QImode, operands[2], HImode, hi_lo_off);
1584 operands[5] = simplify_gen_subreg (QImode, operands[4], HImode, hi_hi_off);
1585 operands[4] = simplify_gen_subreg (QImode, operands[4], HImode, hi_lo_off);
1587 operands[6] = simplify_gen_subreg (HImode, operands[1], SImode, si_lo_off);
1588 operands[8] = simplify_gen_subreg (HImode, operands[1], SImode, si_hi_off);
1589 operands[7] = simplify_gen_subreg (QImode, operands[6], HImode, hi_hi_off);
1590 operands[6] = simplify_gen_subreg (QImode, operands[6], HImode, hi_lo_off);
1591 operands[9] = simplify_gen_subreg (QImode, operands[8], HImode, hi_hi_off);
1592 operands[8] = simplify_gen_subreg (QImode, operands[8], HImode, hi_lo_off);
1594 if (REGNO (operands[0]) < REGNO(operands[1]))
1596 emit_move_insn (operands[2], operands[7]);
1597 emit_move_insn (operands[5], operands[6]);
1598 emit_move_insn (operands[3], operands[8]);
1599 emit_move_insn (operands[4], operands[9]);
1603 emit_move_insn (operands[5], operands[6]);
1604 emit_move_insn (operands[4], operands[9]);
1605 emit_move_insn (operands[3], operands[8]);
1606 emit_move_insn (operands[2], operands[7]);
1609 [(set_attr "length" "5")
1610 (set_attr "cc" "none")])
1612 ;;<< << << << << << << << << << << << << << << << << << << << << << << << << <<
1613 ;; arithmetic shift left
1615 (define_expand "ashlqi3"
1616 [(set (match_operand:QI 0 "register_operand" "")
1617 (ashift:QI (match_operand:QI 1 "register_operand" "")
1618 (match_operand:QI 2 "general_operand" "")))]
1622 (define_split ; ashlqi3_const4
1623 [(set (match_operand:QI 0 "d_register_operand" "")
1624 (ashift:QI (match_dup 0)
1627 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1628 (set (match_dup 0) (and:QI (match_dup 0) (const_int -16)))]
1631 (define_split ; ashlqi3_const5
1632 [(set (match_operand:QI 0 "d_register_operand" "")
1633 (ashift:QI (match_dup 0)
1636 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1637 (set (match_dup 0) (ashift:QI (match_dup 0) (const_int 1)))
1638 (set (match_dup 0) (and:QI (match_dup 0) (const_int -32)))]
1641 (define_split ; ashlqi3_const6
1642 [(set (match_operand:QI 0 "d_register_operand" "")
1643 (ashift:QI (match_dup 0)
1646 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1647 (set (match_dup 0) (ashift:QI (match_dup 0) (const_int 2)))
1648 (set (match_dup 0) (and:QI (match_dup 0) (const_int -64)))]
1651 (define_insn "*ashlqi3"
1652 [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,!d,r,r")
1653 (ashift:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0,0,0")
1654 (match_operand:QI 2 "general_operand" "r,L,P,K,n,n,Qm")))]
1656 "* return ashlqi3_out (insn, operands, NULL);"
1657 [(set_attr "length" "5,0,1,2,4,6,9")
1658 (set_attr "cc" "clobber,none,set_czn,set_czn,set_czn,set_czn,clobber")])
1660 (define_insn "ashlhi3"
1661 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r,r")
1662 (ashift:HI (match_operand:HI 1 "register_operand" "0,0,0,r,0,0,0")
1663 (match_operand:QI 2 "general_operand" "r,L,P,O,K,n,Qm")))]
1665 "* return ashlhi3_out (insn, operands, NULL);"
1666 [(set_attr "length" "6,0,2,2,4,10,10")
1667 (set_attr "cc" "clobber,none,set_n,clobber,set_n,clobber,clobber")])
1669 (define_insn "ashlsi3"
1670 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r")
1671 (ashift:SI (match_operand:SI 1 "register_operand" "0,0,0,r,0,0,0")
1672 (match_operand:QI 2 "general_operand" "r,L,P,O,K,n,Qm")))]
1674 "* return ashlsi3_out (insn, operands, NULL);"
1675 [(set_attr "length" "8,0,4,4,8,10,12")
1676 (set_attr "cc" "clobber,none,set_n,clobber,set_n,clobber,clobber")])
1678 ;; Optimize if a scratch register from LD_REGS happens to be available.
1680 (define_peephole2 ; ashlqi3_l_const4
1681 [(set (match_operand:QI 0 "l_register_operand" "")
1682 (ashift:QI (match_dup 0)
1684 (match_scratch:QI 1 "d")]
1686 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1687 (set (match_dup 1) (const_int -16))
1688 (set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))]
1691 (define_peephole2 ; ashlqi3_l_const5
1692 [(set (match_operand:QI 0 "l_register_operand" "")
1693 (ashift:QI (match_dup 0)
1695 (match_scratch:QI 1 "d")]
1697 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1698 (set (match_dup 0) (ashift:QI (match_dup 0) (const_int 1)))
1699 (set (match_dup 1) (const_int -32))
1700 (set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))]
1703 (define_peephole2 ; ashlqi3_l_const6
1704 [(set (match_operand:QI 0 "l_register_operand" "")
1705 (ashift:QI (match_dup 0)
1707 (match_scratch:QI 1 "d")]
1709 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1710 (set (match_dup 0) (ashift:QI (match_dup 0) (const_int 2)))
1711 (set (match_dup 1) (const_int -64))
1712 (set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))]
1716 [(match_scratch:QI 3 "d")
1717 (set (match_operand:HI 0 "register_operand" "")
1718 (ashift:HI (match_operand:HI 1 "register_operand" "")
1719 (match_operand:QI 2 "const_int_operand" "")))]
1721 [(parallel [(set (match_dup 0) (ashift:HI (match_dup 1) (match_dup 2)))
1722 (clobber (match_dup 3))])]
1725 (define_insn "*ashlhi3_const"
1726 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
1727 (ashift:HI (match_operand:HI 1 "register_operand" "0,0,r,0,0")
1728 (match_operand:QI 2 "const_int_operand" "L,P,O,K,n")))
1729 (clobber (match_scratch:QI 3 "=X,X,X,X,&d"))]
1731 "* return ashlhi3_out (insn, operands, NULL);"
1732 [(set_attr "length" "0,2,2,4,10")
1733 (set_attr "cc" "none,set_n,clobber,set_n,clobber")])
1736 [(match_scratch:QI 3 "d")
1737 (set (match_operand:SI 0 "register_operand" "")
1738 (ashift:SI (match_operand:SI 1 "register_operand" "")
1739 (match_operand:QI 2 "const_int_operand" "")))]
1741 [(parallel [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2)))
1742 (clobber (match_dup 3))])]
1745 (define_insn "*ashlsi3_const"
1746 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1747 (ashift:SI (match_operand:SI 1 "register_operand" "0,0,r,0")
1748 (match_operand:QI 2 "const_int_operand" "L,P,O,n")))
1749 (clobber (match_scratch:QI 3 "=X,X,X,&d"))]
1751 "* return ashlsi3_out (insn, operands, NULL);"
1752 [(set_attr "length" "0,4,4,10")
1753 (set_attr "cc" "none,set_n,clobber,clobber")])
1755 ;; >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
1756 ;; arithmetic shift right
1758 (define_insn "ashrqi3"
1759 [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r")
1760 (ashiftrt:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0,0")
1761 (match_operand:QI 2 "general_operand" "r,L,P,K,n,Qm")))]
1763 "* return ashrqi3_out (insn, operands, NULL);"
1764 [(set_attr "length" "5,0,1,2,5,9")
1765 (set_attr "cc" "clobber,none,clobber,clobber,clobber,clobber")])
1767 (define_insn "ashrhi3"
1768 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r,r")
1769 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0,0,0,r,0,0,0")
1770 (match_operand:QI 2 "general_operand" "r,L,P,O,K,n,Qm")))]
1772 "* return ashrhi3_out (insn, operands, NULL);"
1773 [(set_attr "length" "6,0,2,4,4,10,10")
1774 (set_attr "cc" "clobber,none,clobber,set_n,clobber,clobber,clobber")])
1776 (define_insn "ashrsi3"
1777 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r")
1778 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,0,r,0,0,0")
1779 (match_operand:QI 2 "general_operand" "r,L,P,O,K,n,Qm")))]
1781 "* return ashrsi3_out (insn, operands, NULL);"
1782 [(set_attr "length" "8,0,4,6,8,10,12")
1783 (set_attr "cc" "clobber,none,clobber,set_n,clobber,clobber,clobber")])
1785 ;; Optimize if a scratch register from LD_REGS happens to be available.
1788 [(match_scratch:QI 3 "d")
1789 (set (match_operand:HI 0 "register_operand" "")
1790 (ashiftrt:HI (match_operand:HI 1 "register_operand" "")
1791 (match_operand:QI 2 "const_int_operand" "")))]
1793 [(parallel [(set (match_dup 0) (ashiftrt:HI (match_dup 1) (match_dup 2)))
1794 (clobber (match_dup 3))])]
1797 (define_insn "*ashrhi3_const"
1798 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
1799 (ashiftrt:HI (match_operand:HI 1 "register_operand" "0,0,r,0,0")
1800 (match_operand:QI 2 "const_int_operand" "L,P,O,K,n")))
1801 (clobber (match_scratch:QI 3 "=X,X,X,X,&d"))]
1803 "* return ashrhi3_out (insn, operands, NULL);"
1804 [(set_attr "length" "0,2,4,4,10")
1805 (set_attr "cc" "none,clobber,set_n,clobber,clobber")])
1808 [(match_scratch:QI 3 "d")
1809 (set (match_operand:SI 0 "register_operand" "")
1810 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
1811 (match_operand:QI 2 "const_int_operand" "")))]
1813 [(parallel [(set (match_dup 0) (ashiftrt:SI (match_dup 1) (match_dup 2)))
1814 (clobber (match_dup 3))])]
1817 (define_insn "*ashrsi3_const"
1818 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1819 (ashiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r,0")
1820 (match_operand:QI 2 "const_int_operand" "L,P,O,n")))
1821 (clobber (match_scratch:QI 3 "=X,X,X,&d"))]
1823 "* return ashrsi3_out (insn, operands, NULL);"
1824 [(set_attr "length" "0,4,4,10")
1825 (set_attr "cc" "none,clobber,set_n,clobber")])
1827 ;; >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
1828 ;; logical shift right
1830 (define_expand "lshrqi3"
1831 [(set (match_operand:QI 0 "register_operand" "")
1832 (lshiftrt:QI (match_operand:QI 1 "register_operand" "")
1833 (match_operand:QI 2 "general_operand" "")))]
1837 (define_split ; lshrqi3_const4
1838 [(set (match_operand:QI 0 "d_register_operand" "")
1839 (lshiftrt:QI (match_dup 0)
1842 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1843 (set (match_dup 0) (and:QI (match_dup 0) (const_int 15)))]
1846 (define_split ; lshrqi3_const5
1847 [(set (match_operand:QI 0 "d_register_operand" "")
1848 (lshiftrt:QI (match_dup 0)
1851 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1852 (set (match_dup 0) (lshiftrt:QI (match_dup 0) (const_int 1)))
1853 (set (match_dup 0) (and:QI (match_dup 0) (const_int 7)))]
1856 (define_split ; lshrqi3_const6
1857 [(set (match_operand:QI 0 "d_register_operand" "")
1858 (lshiftrt:QI (match_dup 0)
1861 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1862 (set (match_dup 0) (lshiftrt:QI (match_dup 0) (const_int 2)))
1863 (set (match_dup 0) (and:QI (match_dup 0) (const_int 3)))]
1866 (define_insn "*lshrqi3"
1867 [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,!d,r,r")
1868 (lshiftrt:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0,0,0")
1869 (match_operand:QI 2 "general_operand" "r,L,P,K,n,n,Qm")))]
1871 "* return lshrqi3_out (insn, operands, NULL);"
1872 [(set_attr "length" "5,0,1,2,4,6,9")
1873 (set_attr "cc" "clobber,none,set_czn,set_czn,set_czn,set_czn,clobber")])
1875 (define_insn "lshrhi3"
1876 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r,r")
1877 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0,0,0,r,0,0,0")
1878 (match_operand:QI 2 "general_operand" "r,L,P,O,K,n,Qm")))]
1880 "* return lshrhi3_out (insn, operands, NULL);"
1881 [(set_attr "length" "6,0,2,2,4,10,10")
1882 (set_attr "cc" "clobber,none,clobber,clobber,clobber,clobber,clobber")])
1884 (define_insn "lshrsi3"
1885 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r")
1886 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,0,r,0,0,0")
1887 (match_operand:QI 2 "general_operand" "r,L,P,O,K,n,Qm")))]
1889 "* return lshrsi3_out (insn, operands, NULL);"
1890 [(set_attr "length" "8,0,4,4,8,10,12")
1891 (set_attr "cc" "clobber,none,clobber,clobber,clobber,clobber,clobber")])
1893 ;; Optimize if a scratch register from LD_REGS happens to be available.
1895 (define_peephole2 ; lshrqi3_l_const4
1896 [(set (match_operand:QI 0 "l_register_operand" "")
1897 (lshiftrt:QI (match_dup 0)
1899 (match_scratch:QI 1 "d")]
1901 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1902 (set (match_dup 1) (const_int 15))
1903 (set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))]
1906 (define_peephole2 ; lshrqi3_l_const5
1907 [(set (match_operand:QI 0 "l_register_operand" "")
1908 (lshiftrt:QI (match_dup 0)
1910 (match_scratch:QI 1 "d")]
1912 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1913 (set (match_dup 0) (lshiftrt:QI (match_dup 0) (const_int 1)))
1914 (set (match_dup 1) (const_int 7))
1915 (set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))]
1918 (define_peephole2 ; lshrqi3_l_const6
1919 [(set (match_operand:QI 0 "l_register_operand" "")
1920 (lshiftrt:QI (match_dup 0)
1922 (match_scratch:QI 1 "d")]
1924 [(set (match_dup 0) (rotate:QI (match_dup 0) (const_int 4)))
1925 (set (match_dup 0) (lshiftrt:QI (match_dup 0) (const_int 2)))
1926 (set (match_dup 1) (const_int 3))
1927 (set (match_dup 0) (and:QI (match_dup 0) (match_dup 1)))]
1931 [(match_scratch:QI 3 "d")
1932 (set (match_operand:HI 0 "register_operand" "")
1933 (lshiftrt:HI (match_operand:HI 1 "register_operand" "")
1934 (match_operand:QI 2 "const_int_operand" "")))]
1936 [(parallel [(set (match_dup 0) (lshiftrt:HI (match_dup 1) (match_dup 2)))
1937 (clobber (match_dup 3))])]
1940 (define_insn "*lshrhi3_const"
1941 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
1942 (lshiftrt:HI (match_operand:HI 1 "register_operand" "0,0,r,0,0")
1943 (match_operand:QI 2 "const_int_operand" "L,P,O,K,n")))
1944 (clobber (match_scratch:QI 3 "=X,X,X,X,&d"))]
1946 "* return lshrhi3_out (insn, operands, NULL);"
1947 [(set_attr "length" "0,2,2,4,10")
1948 (set_attr "cc" "none,clobber,clobber,clobber,clobber")])
1951 [(match_scratch:QI 3 "d")
1952 (set (match_operand:SI 0 "register_operand" "")
1953 (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
1954 (match_operand:QI 2 "const_int_operand" "")))]
1956 [(parallel [(set (match_dup 0) (lshiftrt:SI (match_dup 1) (match_dup 2)))
1957 (clobber (match_dup 3))])]
1960 (define_insn "*lshrsi3_const"
1961 [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
1962 (lshiftrt:SI (match_operand:SI 1 "register_operand" "0,0,r,0")
1963 (match_operand:QI 2 "const_int_operand" "L,P,O,n")))
1964 (clobber (match_scratch:QI 3 "=X,X,X,&d"))]
1966 "* return lshrsi3_out (insn, operands, NULL);"
1967 [(set_attr "length" "0,4,4,10")
1968 (set_attr "cc" "none,clobber,clobber,clobber")])
1970 ;; abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x) abs(x)
1973 (define_insn "absqi2"
1974 [(set (match_operand:QI 0 "register_operand" "=r")
1975 (abs:QI (match_operand:QI 1 "register_operand" "0")))]
1979 [(set_attr "length" "2")
1980 (set_attr "cc" "clobber")])
1983 (define_insn "abssf2"
1984 [(set (match_operand:SF 0 "register_operand" "=d,r")
1985 (abs:SF (match_operand:SF 1 "register_operand" "0,0")))]
1990 [(set_attr "length" "1,2")
1991 (set_attr "cc" "set_n,clobber")])
1993 ;; 0 - x 0 - x 0 - x 0 - x 0 - x 0 - x 0 - x 0 - x 0 - x 0 - x 0 - x
1996 (define_insn "negqi2"
1997 [(set (match_operand:QI 0 "register_operand" "=r")
1998 (neg:QI (match_operand:QI 1 "register_operand" "0")))]
2001 [(set_attr "length" "1")
2002 (set_attr "cc" "set_zn")])
2004 (define_insn "neghi2"
2005 [(set (match_operand:HI 0 "register_operand" "=!d,r,&r")
2006 (neg:HI (match_operand:HI 1 "register_operand" "0,0,r")))]
2009 com %B0\;neg %A0\;sbci %B0,lo8(-1)
2010 com %B0\;neg %A0\;sbc %B0,__zero_reg__\;inc %B0
2011 clr %A0\;clr %B0\;sub %A0,%A1\;sbc %B0,%B1"
2012 [(set_attr "length" "3,4,4")
2013 (set_attr "cc" "set_czn,set_n,set_czn")])
2015 (define_insn "negsi2"
2016 [(set (match_operand:SI 0 "register_operand" "=!d,r,&r")
2017 (neg:SI (match_operand:SI 1 "register_operand" "0,0,r")))]
2020 com %D0\;com %C0\;com %B0\;neg %A0\;sbci %B0,lo8(-1)\;sbci %C0,lo8(-1)\;sbci %D0,lo8(-1)
2021 com %D0\;com %C0\;com %B0\;com %A0\;adc %A0,__zero_reg__\;adc %B0,__zero_reg__\;adc %C0,__zero_reg__\;adc %D0,__zero_reg__
2022 clr %A0\;clr %B0\;{clr %C0\;clr %D0|movw %C0,%A0}\;sub %A0,%A1\;sbc %B0,%B1\;sbc %C0,%C1\;sbc %D0,%D1"
2023 [(set_attr_alternative "length"
2026 (if_then_else (eq_attr "mcu_have_movw" "yes")
2029 (set_attr "cc" "set_czn,set_n,set_czn")])
2031 (define_insn "negsf2"
2032 [(set (match_operand:SF 0 "register_operand" "=d,r")
2033 (neg:SF (match_operand:SF 1 "register_operand" "0,0")))]
2037 bst %D0,7\;com %D0\;bld %D0,7\;com %D0"
2038 [(set_attr "length" "1,4")
2039 (set_attr "cc" "set_n,set_n")])
2041 ;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2044 (define_insn "one_cmplqi2"
2045 [(set (match_operand:QI 0 "register_operand" "=r")
2046 (not:QI (match_operand:QI 1 "register_operand" "0")))]
2049 [(set_attr "length" "1")
2050 (set_attr "cc" "set_czn")])
2052 (define_insn "one_cmplhi2"
2053 [(set (match_operand:HI 0 "register_operand" "=r")
2054 (not:HI (match_operand:HI 1 "register_operand" "0")))]
2058 [(set_attr "length" "2")
2059 (set_attr "cc" "set_n")])
2061 (define_insn "one_cmplsi2"
2062 [(set (match_operand:SI 0 "register_operand" "=r")
2063 (not:SI (match_operand:SI 1 "register_operand" "0")))]
2069 [(set_attr "length" "4")
2070 (set_attr "cc" "set_n")])
2072 ;; xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x
2075 (define_insn "extendqihi2"
2076 [(set (match_operand:HI 0 "register_operand" "=r,r")
2077 (sign_extend:HI (match_operand:QI 1 "register_operand" "0,*r")))]
2080 clr %B0\;sbrc %0,7\;com %B0
2081 mov %A0,%A1\;clr %B0\;sbrc %A0,7\;com %B0"
2082 [(set_attr "length" "3,4")
2083 (set_attr "cc" "set_n,set_n")])
2085 (define_insn "extendqisi2"
2086 [(set (match_operand:SI 0 "register_operand" "=r,r")
2087 (sign_extend:SI (match_operand:QI 1 "register_operand" "0,*r")))]
2090 clr %B0\;sbrc %A0,7\;com %B0\;mov %C0,%B0\;mov %D0,%B0
2091 mov %A0,%A1\;clr %B0\;sbrc %A0,7\;com %B0\;mov %C0,%B0\;mov %D0,%B0"
2092 [(set_attr "length" "5,6")
2093 (set_attr "cc" "set_n,set_n")])
2095 (define_insn "extendhisi2"
2096 [(set (match_operand:SI 0 "register_operand" "=r,&r")
2097 (sign_extend:SI (match_operand:HI 1 "register_operand" "0,*r")))]
2100 clr %C0\;sbrc %B0,7\;com %C0\;mov %D0,%C0
2101 {mov %A0,%A1\;mov %B0,%B1|movw %A0,%A1}\;clr %C0\;sbrc %B0,7\;com %C0\;mov %D0,%C0"
2102 [(set_attr_alternative "length"
2104 (if_then_else (eq_attr "mcu_have_movw" "yes")
2107 (set_attr "cc" "set_n,set_n")])
2109 ;; xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x xx<---x
2112 (define_insn_and_split "zero_extendqihi2"
2113 [(set (match_operand:HI 0 "register_operand" "=r")
2114 (zero_extend:HI (match_operand:QI 1 "register_operand" "r")))]
2118 [(set (match_dup 2) (match_dup 1))
2119 (set (match_dup 3) (const_int 0))]
2120 "unsigned int low_off = subreg_lowpart_offset (QImode, HImode);
2121 unsigned int high_off = subreg_highpart_offset (QImode, HImode);
2123 operands[2] = simplify_gen_subreg (QImode, operands[0], HImode, low_off);
2124 operands[3] = simplify_gen_subreg (QImode, operands[0], HImode, high_off);
2127 (define_insn_and_split "zero_extendqisi2"
2128 [(set (match_operand:SI 0 "register_operand" "=r")
2129 (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
2133 [(set (match_dup 2) (zero_extend:HI (match_dup 1)))
2134 (set (match_dup 3) (const_int 0))]
2135 "unsigned int low_off = subreg_lowpart_offset (HImode, SImode);
2136 unsigned int high_off = subreg_highpart_offset (HImode, SImode);
2138 operands[2] = simplify_gen_subreg (HImode, operands[0], SImode, low_off);
2139 operands[3] = simplify_gen_subreg (HImode, operands[0], SImode, high_off);
2142 (define_insn_and_split "zero_extendhisi2"
2143 [(set (match_operand:SI 0 "register_operand" "=r")
2144 (zero_extend:SI (match_operand:HI 1 "register_operand" "r")))]
2148 [(set (match_dup 2) (match_dup 1))
2149 (set (match_dup 3) (const_int 0))]
2150 "unsigned int low_off = subreg_lowpart_offset (HImode, SImode);
2151 unsigned int high_off = subreg_highpart_offset (HImode, SImode);
2153 operands[2] = simplify_gen_subreg (HImode, operands[0], SImode, low_off);
2154 operands[3] = simplify_gen_subreg (HImode, operands[0], SImode, high_off);
2157 (define_insn_and_split "zero_extendqidi2"
2158 [(set (match_operand:DI 0 "register_operand" "=r")
2159 (zero_extend:DI (match_operand:QI 1 "register_operand" "r")))]
2163 [(set (match_dup 2) (zero_extend:SI (match_dup 1)))
2164 (set (match_dup 3) (const_int 0))]
2165 "unsigned int low_off = subreg_lowpart_offset (SImode, DImode);
2166 unsigned int high_off = subreg_highpart_offset (SImode, DImode);
2168 operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off);
2169 operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off);
2172 (define_insn_and_split "zero_extendhidi2"
2173 [(set (match_operand:DI 0 "register_operand" "=r")
2174 (zero_extend:DI (match_operand:HI 1 "register_operand" "r")))]
2178 [(set (match_dup 2) (zero_extend:SI (match_dup 1)))
2179 (set (match_dup 3) (const_int 0))]
2180 "unsigned int low_off = subreg_lowpart_offset (SImode, DImode);
2181 unsigned int high_off = subreg_highpart_offset (SImode, DImode);
2183 operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off);
2184 operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off);
2187 (define_insn_and_split "zero_extendsidi2"
2188 [(set (match_operand:DI 0 "register_operand" "=r")
2189 (zero_extend:DI (match_operand:SI 1 "register_operand" "r")))]
2193 [(set (match_dup 2) (match_dup 1))
2194 (set (match_dup 3) (const_int 0))]
2195 "unsigned int low_off = subreg_lowpart_offset (SImode, DImode);
2196 unsigned int high_off = subreg_highpart_offset (SImode, DImode);
2198 operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off);
2199 operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off);
2202 ;;<=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=><=>
2205 ; Optimize negated tests into reverse compare if overflow is undefined.
2206 (define_insn "*negated_tstqi"
2208 (compare (neg:QI (match_operand:QI 0 "register_operand" "r"))
2210 "(!flag_wrapv && !flag_trapv && flag_strict_overflow)"
2211 "cp __zero_reg__,%0"
2212 [(set_attr "cc" "compare")
2213 (set_attr "length" "1")])
2215 (define_insn "*reversed_tstqi"
2217 (compare (const_int 0)
2218 (match_operand:QI 0 "register_operand" "r")))]
2220 "cp __zero_reg__,%0"
2221 [(set_attr "cc" "compare")
2222 (set_attr "length" "2")])
2224 (define_insn "*negated_tsthi"
2226 (compare (neg:HI (match_operand:HI 0 "register_operand" "r"))
2228 "(!flag_wrapv && !flag_trapv && flag_strict_overflow)"
2229 "cp __zero_reg__,%A0
2230 cpc __zero_reg__,%B0"
2231 [(set_attr "cc" "compare")
2232 (set_attr "length" "2")])
2234 ;; Leave here the clobber used by the cmphi pattern for simplicity, even
2235 ;; though it is unused, because this pattern is synthesized by avr_reorg.
2236 (define_insn "*reversed_tsthi"
2238 (compare (const_int 0)
2239 (match_operand:HI 0 "register_operand" "r")))
2240 (clobber (match_scratch:QI 1 "=X"))]
2242 "cp __zero_reg__,%A0
2243 cpc __zero_reg__,%B0"
2244 [(set_attr "cc" "compare")
2245 (set_attr "length" "2")])
2247 (define_insn "*negated_tstsi"
2249 (compare (neg:SI (match_operand:SI 0 "register_operand" "r"))
2251 "(!flag_wrapv && !flag_trapv && flag_strict_overflow)"
2252 "cp __zero_reg__,%A0
2253 cpc __zero_reg__,%B0
2254 cpc __zero_reg__,%C0
2255 cpc __zero_reg__,%D0"
2256 [(set_attr "cc" "compare")
2257 (set_attr "length" "4")])
2259 (define_insn "*reversed_tstsi"
2261 (compare (const_int 0)
2262 (match_operand:SI 0 "register_operand" "r")))
2263 (clobber (match_scratch:QI 1 "=X"))]
2265 "cp __zero_reg__,%A0
2266 cpc __zero_reg__,%B0
2267 cpc __zero_reg__,%C0
2268 cpc __zero_reg__,%D0"
2269 [(set_attr "cc" "compare")
2270 (set_attr "length" "4")])
2273 (define_insn "*cmpqi"
2275 (compare (match_operand:QI 0 "register_operand" "r,r,d")
2276 (match_operand:QI 1 "nonmemory_operand" "L,r,i")))]
2282 [(set_attr "cc" "compare,compare,compare")
2283 (set_attr "length" "1,1,1")])
2285 (define_insn "*cmpqi_sign_extend"
2287 (compare (sign_extend:HI
2288 (match_operand:QI 0 "register_operand" "d"))
2289 (match_operand:HI 1 "const_int_operand" "n")))]
2290 "INTVAL (operands[1]) >= -128 && INTVAL (operands[1]) <= 127"
2292 [(set_attr "cc" "compare")
2293 (set_attr "length" "1")])
2295 (define_insn "*cmphi"
2297 (compare (match_operand:HI 0 "register_operand" "!w,r,r,d,d,r,r")
2298 (match_operand:HI 1 "nonmemory_operand" "L,L,r,M,i,M,i")))
2299 (clobber (match_scratch:QI 2 "=X,X,X,X,&d,&d,&d"))]
2302 switch (which_alternative)
2305 return out_tsthi (insn, operands[0], NULL);
2308 return (AS2 (cp,%A0,%A1) CR_TAB
2311 if (reg_unused_after (insn, operands[0])
2312 && INTVAL (operands[1]) >= 0 && INTVAL (operands[1]) <= 63
2313 && test_hard_reg_class (ADDW_REGS, operands[0]))
2314 return AS2 (sbiw,%0,%1);
2316 return (AS2 (cpi,%0,%1) CR_TAB
2317 AS2 (cpc,%B0,__zero_reg__));
2319 if (reg_unused_after (insn, operands[0]))
2320 return (AS2 (subi,%0,lo8(%1)) CR_TAB
2321 AS2 (sbci,%B0,hi8(%1)));
2323 return (AS2 (ldi, %2,hi8(%1)) CR_TAB
2324 AS2 (cpi, %A0,lo8(%1)) CR_TAB
2327 return (AS2 (ldi, %2,lo8(%1)) CR_TAB
2328 AS2 (cp, %A0,%2) CR_TAB
2329 AS2 (cpc, %B0,__zero_reg__));
2332 return (AS2 (ldi, %2,lo8(%1)) CR_TAB
2333 AS2 (cp, %A0,%2) CR_TAB
2334 AS2 (ldi, %2,hi8(%1)) CR_TAB
2339 [(set_attr "cc" "compare,compare,compare,compare,compare,compare,compare")
2340 (set_attr "length" "1,2,2,2,3,3,4")])
2343 (define_insn "*cmpsi"
2345 (compare (match_operand:SI 0 "register_operand" "r,r,d,d,r,r")
2346 (match_operand:SI 1 "nonmemory_operand" "L,r,M,i,M,i")))
2347 (clobber (match_scratch:QI 2 "=X,X,X,&d,&d,&d"))]
2350 switch (which_alternative)
2353 return out_tstsi (insn, operands[0], NULL);
2356 return (AS2 (cp,%A0,%A1) CR_TAB
2357 AS2 (cpc,%B0,%B1) CR_TAB
2358 AS2 (cpc,%C0,%C1) CR_TAB
2361 if (reg_unused_after (insn, operands[0])
2362 && INTVAL (operands[1]) >= 0 && INTVAL (operands[1]) <= 63
2363 && test_hard_reg_class (ADDW_REGS, operands[0]))
2364 return (AS2 (sbiw,%0,%1) CR_TAB
2365 AS2 (cpc,%C0,__zero_reg__) CR_TAB
2366 AS2 (cpc,%D0,__zero_reg__));
2368 return (AS2 (cpi,%A0,lo8(%1)) CR_TAB
2369 AS2 (cpc,%B0,__zero_reg__) CR_TAB
2370 AS2 (cpc,%C0,__zero_reg__) CR_TAB
2371 AS2 (cpc,%D0,__zero_reg__));
2373 if (reg_unused_after (insn, operands[0]))
2374 return (AS2 (subi,%A0,lo8(%1)) CR_TAB
2375 AS2 (sbci,%B0,hi8(%1)) CR_TAB
2376 AS2 (sbci,%C0,hlo8(%1)) CR_TAB
2377 AS2 (sbci,%D0,hhi8(%1)));
2379 return (AS2 (cpi, %A0,lo8(%1)) CR_TAB
2380 AS2 (ldi, %2,hi8(%1)) CR_TAB
2381 AS2 (cpc, %B0,%2) CR_TAB
2382 AS2 (ldi, %2,hlo8(%1)) CR_TAB
2383 AS2 (cpc, %C0,%2) CR_TAB
2384 AS2 (ldi, %2,hhi8(%1)) CR_TAB
2387 return (AS2 (ldi,%2,lo8(%1)) CR_TAB
2388 AS2 (cp,%A0,%2) CR_TAB
2389 AS2 (cpc,%B0,__zero_reg__) CR_TAB
2390 AS2 (cpc,%C0,__zero_reg__) CR_TAB
2391 AS2 (cpc,%D0,__zero_reg__));
2393 return (AS2 (ldi, %2,lo8(%1)) CR_TAB
2394 AS2 (cp, %A0,%2) CR_TAB
2395 AS2 (ldi, %2,hi8(%1)) CR_TAB
2396 AS2 (cpc, %B0,%2) CR_TAB
2397 AS2 (ldi, %2,hlo8(%1)) CR_TAB
2398 AS2 (cpc, %C0,%2) CR_TAB
2399 AS2 (ldi, %2,hhi8(%1)) CR_TAB
2404 [(set_attr "cc" "compare,compare,compare,compare,compare,compare")
2405 (set_attr "length" "4,4,4,7,5,8")])
2408 ;; ----------------------------------------------------------------------
2409 ;; JUMP INSTRUCTIONS
2410 ;; ----------------------------------------------------------------------
2411 ;; Conditional jump instructions
2413 (define_expand "cbranchsi4"
2414 [(parallel [(set (cc0)
2415 (compare (match_operand:SI 1 "register_operand" "")
2416 (match_operand:SI 2 "nonmemory_operand" "")))
2417 (clobber (match_scratch:QI 4 ""))])
2420 (match_operator 0 "ordered_comparison_operator" [(cc0)
2422 (label_ref (match_operand 3 "" ""))
2426 (define_expand "cbranchhi4"
2427 [(parallel [(set (cc0)
2428 (compare (match_operand:HI 1 "register_operand" "")
2429 (match_operand:HI 2 "nonmemory_operand" "")))
2430 (clobber (match_scratch:QI 4 ""))])
2433 (match_operator 0 "ordered_comparison_operator" [(cc0)
2435 (label_ref (match_operand 3 "" ""))
2439 (define_expand "cbranchqi4"
2441 (compare (match_operand:QI 1 "register_operand" "")
2442 (match_operand:QI 2 "nonmemory_operand" "")))
2445 (match_operator 0 "ordered_comparison_operator" [(cc0)
2447 (label_ref (match_operand 3 "" ""))
2452 ;; Test a single bit in a QI/HI/SImode register.
2453 (define_insn "*sbrx_branch"
2456 (match_operator 0 "eqne_operator"
2458 (match_operand:QI 1 "register_operand" "r")
2460 (match_operand 2 "const_int_operand" "n"))
2462 (label_ref (match_operand 3 "" ""))
2465 "* return avr_out_sbxx_branch (insn, operands);"
2466 [(set (attr "length")
2467 (if_then_else (and (ge (minus (pc) (match_dup 3)) (const_int -2046))
2468 (le (minus (pc) (match_dup 3)) (const_int 2046)))
2470 (if_then_else (eq_attr "mcu_mega" "no")
2473 (set_attr "cc" "clobber")])
2475 (define_insn "*sbrx_and_branchhi"
2478 (match_operator 0 "eqne_operator"
2480 (match_operand:HI 1 "register_operand" "r")
2481 (match_operand:HI 2 "single_one_operand" "n"))
2483 (label_ref (match_operand 3 "" ""))
2486 "* return avr_out_sbxx_branch (insn, operands);"
2487 [(set (attr "length")
2488 (if_then_else (and (ge (minus (pc) (match_dup 3)) (const_int -2046))
2489 (le (minus (pc) (match_dup 3)) (const_int 2046)))
2491 (if_then_else (eq_attr "mcu_mega" "no")
2494 (set_attr "cc" "clobber")])
2496 (define_insn "*sbrx_and_branchsi"
2499 (match_operator 0 "eqne_operator"
2501 (match_operand:SI 1 "register_operand" "r")
2502 (match_operand:SI 2 "single_one_operand" "n"))
2504 (label_ref (match_operand 3 "" ""))
2507 "* return avr_out_sbxx_branch (insn, operands);"
2508 [(set (attr "length")
2509 (if_then_else (and (ge (minus (pc) (match_dup 3)) (const_int -2046))
2510 (le (minus (pc) (match_dup 3)) (const_int 2046)))
2512 (if_then_else (eq_attr "mcu_mega" "no")
2515 (set_attr "cc" "clobber")])
2517 ;; Convert sign tests to bit 7/15/31 tests that match the above insns.
2519 [(set (cc0) (compare (match_operand:QI 0 "register_operand" "")
2521 (set (pc) (if_then_else (ge (cc0) (const_int 0))
2522 (label_ref (match_operand 1 "" ""))
2525 [(set (pc) (if_then_else (eq (zero_extract:HI (match_dup 0)
2529 (label_ref (match_dup 1))
2534 [(set (cc0) (compare (match_operand:QI 0 "register_operand" "")
2536 (set (pc) (if_then_else (lt (cc0) (const_int 0))
2537 (label_ref (match_operand 1 "" ""))
2540 [(set (pc) (if_then_else (ne (zero_extract:HI (match_dup 0)
2544 (label_ref (match_dup 1))
2549 [(parallel [(set (cc0) (compare (match_operand:HI 0 "register_operand" "")
2551 (clobber (match_operand:HI 2 ""))])
2552 (set (pc) (if_then_else (ge (cc0) (const_int 0))
2553 (label_ref (match_operand 1 "" ""))
2556 [(set (pc) (if_then_else (eq (and:HI (match_dup 0) (const_int -32768))
2558 (label_ref (match_dup 1))
2563 [(parallel [(set (cc0) (compare (match_operand:HI 0 "register_operand" "")
2565 (clobber (match_operand:HI 2 ""))])
2566 (set (pc) (if_then_else (lt (cc0) (const_int 0))
2567 (label_ref (match_operand 1 "" ""))
2570 [(set (pc) (if_then_else (ne (and:HI (match_dup 0) (const_int -32768))
2572 (label_ref (match_dup 1))
2577 [(parallel [(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
2579 (clobber (match_operand:SI 2 ""))])
2580 (set (pc) (if_then_else (ge (cc0) (const_int 0))
2581 (label_ref (match_operand 1 "" ""))
2584 [(set (pc) (if_then_else (eq (and:SI (match_dup 0) (match_dup 2))
2586 (label_ref (match_dup 1))
2588 "operands[2] = GEN_INT (-2147483647 - 1);")
2591 [(parallel [(set (cc0) (compare (match_operand:SI 0 "register_operand" "")
2593 (clobber (match_operand:SI 2 ""))])
2594 (set (pc) (if_then_else (lt (cc0) (const_int 0))
2595 (label_ref (match_operand 1 "" ""))
2598 [(set (pc) (if_then_else (ne (and:SI (match_dup 0) (match_dup 2))
2600 (label_ref (match_dup 1))
2602 "operands[2] = GEN_INT (-2147483647 - 1);")
2604 ;; ************************************************************************
2605 ;; Implementation of conditional jumps here.
2606 ;; Compare with 0 (test) jumps
2607 ;; ************************************************************************
2609 (define_insn "branch"
2611 (if_then_else (match_operator 1 "simple_comparison_operator"
2614 (label_ref (match_operand 0 "" ""))
2618 return ret_cond_branch (operands[1], avr_jump_mode (operands[0],insn), 0);"
2619 [(set_attr "type" "branch")
2620 (set_attr "cc" "clobber")])
2622 ;; ****************************************************************
2623 ;; AVR does not have following conditional jumps: LE,LEU,GT,GTU.
2624 ;; Convert them all to proper jumps.
2625 ;; ****************************************************************/
2627 (define_insn "difficult_branch"
2629 (if_then_else (match_operator 1 "difficult_comparison_operator"
2632 (label_ref (match_operand 0 "" ""))
2636 return ret_cond_branch (operands[1], avr_jump_mode (operands[0],insn), 0);"
2637 [(set_attr "type" "branch1")
2638 (set_attr "cc" "clobber")])
2642 (define_insn "rvbranch"
2644 (if_then_else (match_operator 1 "simple_comparison_operator"
2648 (label_ref (match_operand 0 "" ""))))]
2651 return ret_cond_branch (operands[1], avr_jump_mode (operands[0], insn), 1);"
2652 [(set_attr "type" "branch1")
2653 (set_attr "cc" "clobber")])
2655 (define_insn "difficult_rvbranch"
2657 (if_then_else (match_operator 1 "difficult_comparison_operator"
2661 (label_ref (match_operand 0 "" ""))))]
2664 return ret_cond_branch (operands[1], avr_jump_mode (operands[0], insn), 1);"
2665 [(set_attr "type" "branch")
2666 (set_attr "cc" "clobber")])
2668 ;; **************************************************************************
2669 ;; Unconditional and other jump instructions.
2673 (label_ref (match_operand 0 "" "")))]
2676 if (AVR_HAVE_JMP_CALL && get_attr_length (insn) != 1)
2677 return AS1 (jmp,%0);
2678 return AS1 (rjmp,%0);
2680 [(set (attr "length")
2681 (if_then_else (match_operand 0 "symbol_ref_operand" "")
2682 (if_then_else (eq_attr "mcu_mega" "no")
2685 (if_then_else (and (ge (minus (pc) (match_dup 0)) (const_int -2047))
2686 (le (minus (pc) (match_dup 0)) (const_int 2047)))
2689 (set_attr "cc" "none")])
2693 (define_expand "call"
2694 [(call (match_operand:HI 0 "call_insn_operand" "")
2695 (match_operand:HI 1 "general_operand" ""))]
2696 ;; Operand 1 not used on the AVR.
2702 (define_expand "call_value"
2703 [(set (match_operand 0 "register_operand" "")
2704 (call (match_operand:HI 1 "call_insn_operand" "")
2705 (match_operand:HI 2 "general_operand" "")))]
2706 ;; Operand 2 not used on the AVR.
2710 (define_insn "call_insn"
2711 [(call (mem:HI (match_operand:HI 0 "nonmemory_operand" "!z,*r,s,n"))
2712 (match_operand:HI 1 "general_operand" "X,X,X,X"))]
2713 ;; We don't need in saving Z register because r30,r31 is a call used registers
2714 ;; Operand 1 not used on the AVR.
2715 "(register_operand (operands[0], HImode) || CONSTANT_P (operands[0]))"
2717 if (which_alternative==0)
2719 else if (which_alternative==1)
2722 return (AS2 (movw, r30, %0) CR_TAB
2725 return (AS2 (mov, r30, %A0) CR_TAB
2726 AS2 (mov, r31, %B0) CR_TAB
2729 else if (which_alternative==2)
2730 return AS1(%~call,%c0);
2731 return (AS2 (ldi,r30,lo8(%0)) CR_TAB
2732 AS2 (ldi,r31,hi8(%0)) CR_TAB
2735 [(set_attr "cc" "clobber,clobber,clobber,clobber")
2736 (set_attr_alternative "length"
2738 (if_then_else (eq_attr "mcu_have_movw" "yes")
2741 (if_then_else (eq_attr "mcu_mega" "yes")
2746 (define_insn "call_value_insn"
2747 [(set (match_operand 0 "register_operand" "=r,r,r,r")
2748 (call (mem:HI (match_operand:HI 1 "nonmemory_operand" "!z,*r,s,n"))
2749 ;; We don't need in saving Z register because r30,r31 is a call used registers
2750 (match_operand:HI 2 "general_operand" "X,X,X,X")))]
2751 ;; Operand 2 not used on the AVR.
2752 "(register_operand (operands[0], VOIDmode) || CONSTANT_P (operands[0]))"
2754 if (which_alternative==0)
2756 else if (which_alternative==1)
2759 return (AS2 (movw, r30, %1) CR_TAB
2762 return (AS2 (mov, r30, %A1) CR_TAB
2763 AS2 (mov, r31, %B1) CR_TAB
2766 else if (which_alternative==2)
2767 return AS1(%~call,%c1);
2768 return (AS2 (ldi, r30, lo8(%1)) CR_TAB
2769 AS2 (ldi, r31, hi8(%1)) CR_TAB
2772 [(set_attr "cc" "clobber,clobber,clobber,clobber")
2773 (set_attr_alternative "length"
2775 (if_then_else (eq_attr "mcu_have_movw" "yes")
2778 (if_then_else (eq_attr "mcu_mega" "yes")
2787 [(set_attr "cc" "none")
2788 (set_attr "length" "1")])
2791 (define_insn "indirect_jump"
2792 [(set (pc) (match_operand:HI 0 "register_operand" "!z,*r"))]
2793 "!AVR_HAVE_EIJMP_EICALL"
2796 push %A0\;push %B0\;ret"
2797 [(set_attr "length" "1,3")
2798 (set_attr "cc" "none,none")])
2800 (define_insn "*indirect_jump_avr6"
2801 [(set (pc) (match_operand:HI 0 "register_operand" "z"))]
2802 "AVR_HAVE_EIJMP_EICALL"
2804 [(set_attr "length" "1")
2805 (set_attr "cc" "none")])
2809 ;; Table made from "rjmp" instructions for <=8K devices.
2810 (define_insn "*tablejump_rjmp"
2811 [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "!z,*r")]
2813 (use (label_ref (match_operand 1 "" "")))
2814 (clobber (match_dup 0))]
2815 "(!AVR_HAVE_JMP_CALL) && (!AVR_HAVE_EIJMP_EICALL)"
2818 push %A0\;push %B0\;ret"
2819 [(set_attr "length" "1,3")
2820 (set_attr "cc" "none,none")])
2822 ;; Not a prologue, but similar idea - move the common piece of code to libgcc.
2823 (define_insn "*tablejump_lib"
2824 [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
2826 (use (label_ref (match_operand 1 "" "")))
2827 (clobber (match_dup 0))]
2828 "AVR_HAVE_JMP_CALL && TARGET_CALL_PROLOGUES"
2829 "jmp __tablejump2__"
2830 [(set_attr "length" "2")
2831 (set_attr "cc" "clobber")])
2833 (define_insn "*tablejump_enh"
2834 [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
2836 (use (label_ref (match_operand 1 "" "")))
2837 (clobber (match_dup 0))]
2838 "AVR_HAVE_JMP_CALL && AVR_HAVE_LPMX"
2845 [(set_attr "length" "6")
2846 (set_attr "cc" "clobber")])
2848 (define_insn "*tablejump"
2849 [(set (pc) (unspec:HI [(match_operand:HI 0 "register_operand" "z")]
2851 (use (label_ref (match_operand 1 "" "")))
2852 (clobber (match_dup 0))]
2853 "AVR_HAVE_JMP_CALL && !AVR_HAVE_EIJMP_EICALL"
2862 [(set_attr "length" "8")
2863 (set_attr "cc" "clobber")])
2865 (define_expand "casesi"
2867 (minus:HI (subreg:HI (match_operand:SI 0 "register_operand" "") 0)
2868 (match_operand:HI 1 "register_operand" "")))
2869 (parallel [(set (cc0)
2870 (compare (match_dup 6)
2871 (match_operand:HI 2 "register_operand" "")))
2872 (clobber (match_scratch:QI 9 ""))])
2875 (if_then_else (gtu (cc0)
2877 (label_ref (match_operand 4 "" ""))
2881 (plus:HI (match_dup 6) (label_ref (match_operand:HI 3 "" ""))))
2883 (parallel [(set (pc) (unspec:HI [(match_dup 6)] UNSPEC_INDEX_JMP))
2884 (use (label_ref (match_dup 3)))
2885 (clobber (match_dup 6))])]
2889 operands[6] = gen_reg_rtx (HImode);
2893 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2894 ;; This instruction sets Z flag
2897 [(set (cc0) (const_int 0))]
2900 [(set_attr "length" "1")
2901 (set_attr "cc" "compare")])
2903 ;; Clear/set/test a single bit in I/O address space.
2906 [(set (mem:QI (match_operand 0 "low_io_address_operand" "n"))
2907 (and:QI (mem:QI (match_dup 0))
2908 (match_operand:QI 1 "single_zero_operand" "n")))]
2911 operands[2] = GEN_INT (exact_log2 (~INTVAL (operands[1]) & 0xff));
2912 return AS2 (cbi,%0-0x20,%2);
2914 [(set_attr "length" "1")
2915 (set_attr "cc" "none")])
2918 [(set (mem:QI (match_operand 0 "low_io_address_operand" "n"))
2919 (ior:QI (mem:QI (match_dup 0))
2920 (match_operand:QI 1 "single_one_operand" "n")))]
2923 operands[2] = GEN_INT (exact_log2 (INTVAL (operands[1]) & 0xff));
2924 return AS2 (sbi,%0-0x20,%2);
2926 [(set_attr "length" "1")
2927 (set_attr "cc" "none")])
2929 ;; Lower half of the I/O space - use sbic/sbis directly.
2930 (define_insn "*sbix_branch"
2933 (match_operator 0 "eqne_operator"
2935 (mem:QI (match_operand 1 "low_io_address_operand" "n"))
2937 (match_operand 2 "const_int_operand" "n"))
2939 (label_ref (match_operand 3 "" ""))
2942 "* return avr_out_sbxx_branch (insn, operands);"
2943 [(set (attr "length")
2944 (if_then_else (and (ge (minus (pc) (match_dup 3)) (const_int -2046))
2945 (le (minus (pc) (match_dup 3)) (const_int 2046)))
2947 (if_then_else (eq_attr "mcu_mega" "no")
2950 (set_attr "cc" "clobber")])
2952 ;; Tests of bit 7 are pessimized to sign tests, so we need this too...
2953 (define_insn "*sbix_branch_bit7"
2956 (match_operator 0 "gelt_operator"
2957 [(mem:QI (match_operand 1 "low_io_address_operand" "n"))
2959 (label_ref (match_operand 2 "" ""))
2963 operands[3] = operands[2];
2964 operands[2] = GEN_INT (7);
2965 return avr_out_sbxx_branch (insn, operands);
2967 [(set (attr "length")
2968 (if_then_else (and (ge (minus (pc) (match_dup 2)) (const_int -2046))
2969 (le (minus (pc) (match_dup 2)) (const_int 2046)))
2971 (if_then_else (eq_attr "mcu_mega" "no")
2974 (set_attr "cc" "clobber")])
2976 ;; Upper half of the I/O space - read port to __tmp_reg__ and use sbrc/sbrs.
2977 (define_insn "*sbix_branch_tmp"
2980 (match_operator 0 "eqne_operator"
2982 (mem:QI (match_operand 1 "high_io_address_operand" "n"))
2984 (match_operand 2 "const_int_operand" "n"))
2986 (label_ref (match_operand 3 "" ""))
2989 "* return avr_out_sbxx_branch (insn, operands);"
2990 [(set (attr "length")
2991 (if_then_else (and (ge (minus (pc) (match_dup 3)) (const_int -2046))
2992 (le (minus (pc) (match_dup 3)) (const_int 2045)))
2994 (if_then_else (eq_attr "mcu_mega" "no")
2997 (set_attr "cc" "clobber")])
2999 (define_insn "*sbix_branch_tmp_bit7"
3002 (match_operator 0 "gelt_operator"
3003 [(mem:QI (match_operand 1 "high_io_address_operand" "n"))
3005 (label_ref (match_operand 2 "" ""))
3009 operands[3] = operands[2];
3010 operands[2] = GEN_INT (7);
3011 return avr_out_sbxx_branch (insn, operands);
3013 [(set (attr "length")
3014 (if_then_else (and (ge (minus (pc) (match_dup 2)) (const_int -2046))
3015 (le (minus (pc) (match_dup 2)) (const_int 2045)))
3017 (if_then_else (eq_attr "mcu_mega" "no")
3020 (set_attr "cc" "clobber")])
3022 ;; ************************* Peepholes ********************************
3025 [(set (match_operand:SI 0 "d_register_operand" "")
3026 (plus:SI (match_dup 0)
3030 (compare (match_dup 0)
3032 (clobber (match_operand:QI 1 "d_register_operand" ""))])
3034 (if_then_else (ne (cc0) (const_int 0))
3035 (label_ref (match_operand 2 "" ""))
3041 if (test_hard_reg_class (ADDW_REGS, operands[0]))
3042 output_asm_insn (AS2 (sbiw,%0,1) CR_TAB
3043 AS2 (sbc,%C0,__zero_reg__) CR_TAB
3044 AS2 (sbc,%D0,__zero_reg__) \"\\n\", operands);
3046 output_asm_insn (AS2 (subi,%A0,1) CR_TAB
3047 AS2 (sbc,%B0,__zero_reg__) CR_TAB
3048 AS2 (sbc,%C0,__zero_reg__) CR_TAB
3049 AS2 (sbc,%D0,__zero_reg__) \"\\n\", operands);
3050 switch (avr_jump_mode (operands[2],insn))
3053 return AS1 (brcc,%2);
3055 return (AS1 (brcs,.+2) CR_TAB
3058 return (AS1 (brcs,.+4) CR_TAB
3063 [(set (match_operand:HI 0 "d_register_operand" "")
3064 (plus:HI (match_dup 0)
3068 (compare (match_dup 0)
3070 (clobber (match_operand:QI 1 "d_register_operand" ""))])
3072 (if_then_else (ne (cc0) (const_int 0))
3073 (label_ref (match_operand 2 "" ""))
3079 if (test_hard_reg_class (ADDW_REGS, operands[0]))
3080 output_asm_insn (AS2 (sbiw,%0,1), operands);
3082 output_asm_insn (AS2 (subi,%A0,1) CR_TAB
3083 AS2 (sbc,%B0,__zero_reg__) \"\\n\", operands);
3084 switch (avr_jump_mode (operands[2],insn))
3087 return AS1 (brcc,%2);
3089 return (AS1 (brcs,.+2) CR_TAB
3092 return (AS1 (brcs,.+4) CR_TAB
3097 [(set (match_operand:QI 0 "d_register_operand" "")
3098 (plus:QI (match_dup 0)
3101 (compare (match_dup 0)
3104 (if_then_else (ne (cc0) (const_int 0))
3105 (label_ref (match_operand 1 "" ""))
3111 cc_status.value1 = operands[0];
3112 cc_status.flags |= CC_OVERFLOW_UNUSABLE;
3113 output_asm_insn (AS2 (subi,%A0,1), operands);
3114 switch (avr_jump_mode (operands[1],insn))
3117 return AS1 (brcc,%1);
3119 return (AS1 (brcs,.+2) CR_TAB
3122 return (AS1 (brcs,.+4) CR_TAB
3128 (compare (match_operand:QI 0 "register_operand" "")
3131 (if_then_else (eq (cc0) (const_int 0))
3132 (label_ref (match_operand 1 "" ""))
3134 "jump_over_one_insn_p (insn, operands[1])"
3135 "cpse %0,__zero_reg__")
3139 (compare (match_operand:QI 0 "register_operand" "")
3140 (match_operand:QI 1 "register_operand" "")))
3142 (if_then_else (eq (cc0) (const_int 0))
3143 (label_ref (match_operand 2 "" ""))
3145 "jump_over_one_insn_p (insn, operands[2])"
3148 ;;pppppppppppppppppppppppppppppppppppppppppppppppppppp
3149 ;;prologue/epilogue support instructions
3151 (define_insn "popqi"
3152 [(set (match_operand:QI 0 "register_operand" "=r")
3153 (mem:QI (post_inc (reg:HI REG_SP))))]
3156 [(set_attr "cc" "none")
3157 (set_attr "length" "1")])
3159 (define_insn "pophi"
3160 [(set (match_operand:HI 0 "register_operand" "=r")
3161 (mem:HI (post_inc (reg:HI REG_SP))))]
3164 [(set_attr "cc" "none")
3165 (set_attr "length" "2")])
3167 ;; Enable Interrupts
3168 (define_insn "enable_interrupt"
3169 [(unspec [(const_int 0)] UNSPEC_SEI)]
3172 [(set_attr "length" "1")
3173 (set_attr "cc" "none")
3176 ;; Disable Interrupts
3177 (define_insn "disable_interrupt"
3178 [(unspec [(const_int 0)] UNSPEC_CLI)]
3181 [(set_attr "length" "1")
3182 (set_attr "cc" "none")
3185 ;; Library prologue saves
3186 (define_insn "call_prologue_saves"
3187 [(unspec_volatile:HI [(const_int 0)] UNSPECV_PROLOGUE_SAVES)
3188 (match_operand:HI 0 "immediate_operand" "")
3189 (set (reg:HI REG_SP) (minus:HI
3191 (match_operand:HI 1 "immediate_operand" "")))
3192 (use (reg:HI REG_X))
3193 (clobber (reg:HI REG_Z))]
3195 "ldi r30,lo8(gs(1f))
3197 %~jmp __prologue_saves__+((18 - %0) * 2)
3199 [(set_attr_alternative "length"
3200 [(if_then_else (eq_attr "mcu_mega" "yes")
3203 (set_attr "cc" "clobber")
3206 ; epilogue restores using library
3207 (define_insn "epilogue_restores"
3208 [(unspec_volatile:QI [(const_int 0)] UNSPECV_EPILOGUE_RESTORES)
3209 (set (reg:HI REG_Y ) (plus:HI
3211 (match_operand:HI 0 "immediate_operand" "")))
3212 (set (reg:HI REG_SP) (reg:HI REG_Y))
3213 (clobber (reg:QI REG_Z))]
3216 %~jmp __epilogue_restores__ + ((18 - %0) * 2)"
3217 [(set_attr_alternative "length"
3218 [(if_then_else (eq_attr "mcu_mega" "yes")
3221 (set_attr "cc" "clobber")
3225 (define_insn "return"
3227 "reload_completed && avr_simple_epilogue ()"
3229 [(set_attr "cc" "none")
3230 (set_attr "length" "1")])
3232 (define_insn "return_from_epilogue"
3236 && !(cfun->machine->is_interrupt || cfun->machine->is_signal)
3237 && !cfun->machine->is_naked)"
3239 [(set_attr "cc" "none")
3240 (set_attr "length" "1")])
3242 (define_insn "return_from_interrupt_epilogue"
3246 && (cfun->machine->is_interrupt || cfun->machine->is_signal)
3247 && !cfun->machine->is_naked)"
3249 [(set_attr "cc" "none")
3250 (set_attr "length" "1")])
3252 (define_insn "return_from_naked_epilogue"
3256 && cfun->machine->is_naked)"
3258 [(set_attr "cc" "none")
3259 (set_attr "length" "0")])
3261 (define_expand "prologue"
3270 (define_expand "epilogue"