1 ;; GCC machine description for Renesas H8/300
2 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
3 ;; 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 ;; Contributed by Steve Chamberlain (sac@cygnus.com),
6 ;; Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com).
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 2, 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 COPYING. If not, write to
22 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;; We compute exact length on each instruction for most of the time.
26 ;; In some case, most notably bit operations that may involve memory
27 ;; operands, the lengths in this file are "worst case".
29 ;; On the H8/300H and H8S, adds/subs operate on the 32bit "er"
30 ;; registers. Right now GCC doesn't expose the "e" half to the
31 ;; compiler, so using add/subs for addhi and subhi is safe. Long
32 ;; term, we want to expose the "e" half to the compiler (gives us 8
33 ;; more 16bit registers). At that point addhi and subhi can't use
36 ;; There's currently no way to have an insv/extzv expander for the H8/300H
37 ;; because word_mode is different for the H8/300 and H8/300H.
39 ;; Shifts/rotates by small constants should be handled by special
40 ;; patterns so we get the length and cc status correct.
42 ;; Bitfield operations no longer accept memory operands. We need
43 ;; to add variants which operate on memory back to the MD.
45 ;; ??? Implement remaining bit ops available on the h8300
47 ;; ----------------------------------------------------------------------
49 ;; ----------------------------------------------------------------------
72 ;; ----------------------------------------------------------------------
74 ;; ----------------------------------------------------------------------
76 (define_attr "cpu" "h8300,h8300h"
77 (const (symbol_ref "cpu_type")))
79 (define_attr "type" "branch,arith,bitbranch,call"
80 (const_string "arith"))
82 (define_attr "length_table" "none,addb,addw,addl,logicb,movb,movw,movl,mova_zero,mova,unary,mov_imm4,short_immediate,bitfield,bitbranch"
83 (const_string "none"))
85 ;; The size of instructions in bytes.
87 (define_attr "length" ""
88 (cond [(eq_attr "type" "branch")
89 ;; In a forward delayed branch, (pc) represents the end of the
90 ;; delay sequence, not the end of the branch itself.
91 (if_then_else (and (ge (minus (match_dup 0) (pc))
93 (le (plus (minus (match_dup 0) (pc))
94 (symbol_ref "DELAY_SLOT_LENGTH (insn)"))
97 (if_then_else (and (eq_attr "cpu" "h8300h")
98 (and (ge (minus (pc) (match_dup 0))
100 (le (minus (pc) (match_dup 0))
104 (eq_attr "type" "bitbranch")
106 (and (ge (minus (match_dup 0) (pc))
108 (le (minus (match_dup 0) (pc))
111 (symbol_ref "h8300_insn_length_from_table (insn, operands)")
114 (and (eq_attr "cpu" "h8300h")
115 (and (ge (minus (pc) (match_dup 0))
117 (le (minus (pc) (match_dup 0))
120 (symbol_ref "h8300_insn_length_from_table (insn, operands)")
123 (symbol_ref "h8300_insn_length_from_table (insn, operands)")
125 (eq_attr "length_table" "!none")
126 (symbol_ref "h8300_insn_length_from_table (insn, operands)")]
129 ;; Condition code settings.
131 ;; none - insn does not affect cc
132 ;; none_0hit - insn does not affect cc but it does modify operand 0
133 ;; This attribute is used to keep track of when operand 0 changes.
134 ;; See the description of NOTICE_UPDATE_CC for more info.
135 ;; set_znv - insn sets z,n,v to usable values (like a tst insn); c is unknown.
136 ;; set_zn - insn sets z,n to usable values; v,c are unknown.
137 ;; compare - compare instruction
138 ;; clobber - value of cc is unknown
140 (define_attr "cc" "none,none_0hit,set_znv,set_zn,compare,clobber"
141 (const_string "clobber"))
143 ;; Type of delay slot. NONE means the instruction has no delay slot.
144 ;; JUMP means it is an unconditional jump that (if short enough)
145 ;; could be implemented using bra/s.
146 (define_attr "delay_slot" "none,jump"
147 (const_string "none"))
149 ;; "yes" if the instruction can be put into a delay slot. It's not
150 ;; entirely clear that jsr is not valid in delay slots, but it
151 ;; definitely doesn't have the effect of causing the called function
152 ;; to return to the target of the delayed branch.
153 (define_attr "can_delay" "no,yes"
154 (cond [(eq_attr "type" "branch,bitbranch,call")
156 (ne (symbol_ref "get_attr_length (insn)") (const_int 2))
158 (const_string "yes")))
160 ;; Only allow jumps to have a delay slot if we think they might
161 ;; be short enough. This is just an optimisation: we don't know
162 ;; for certain whether they will be or not.
163 (define_delay (and (eq_attr "delay_slot" "jump")
164 (eq (symbol_ref "get_attr_length (insn)") (const_int 2)))
165 [(eq_attr "can_delay" "yes")
169 ;; Provide the maximum length of an assembly instruction in an asm
170 ;; statement. The maximum length of 14 bytes is achieved on H8SX.
172 (define_asm_attributes
173 [(set (attr "length")
174 (cond [(ne (symbol_ref "TARGET_H8300") (const_int 0)) (const_int 4)
175 (ne (symbol_ref "TARGET_H8300H") (const_int 0)) (const_int 10)
176 (ne (symbol_ref "TARGET_H8300S") (const_int 0)) (const_int 10)]
179 ;; ----------------------------------------------------------------------
181 ;; ----------------------------------------------------------------------
185 (define_insn "*movqi_h8300"
186 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
187 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
189 && (register_operand (operands[0], QImode)
190 || register_operand (operands[1], QImode))"
198 [(set_attr "length" "2,2,2,2,4,4")
199 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
201 (define_insn "*movqi_h8300hs"
202 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
203 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
204 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
205 && (register_operand (operands[0], QImode)
206 || register_operand (operands[1], QImode))"
214 [(set (attr "length")
215 (symbol_ref "compute_mov_length (operands)"))
216 (set_attr "cc" "set_zn,set_znv,set_znv,clobber,set_znv,set_znv")])
218 (define_insn "*movqi_h8sx"
219 [(set (match_operand:QI 0 "general_operand_dst" "=Z,rQ")
220 (match_operand:QI 1 "general_operand_src" "P4>X,rQi"))]
225 [(set_attr "length_table" "mov_imm4,movb")
226 (set_attr "cc" "set_znv")])
228 (define_expand "movqi"
229 [(set (match_operand:QI 0 "general_operand_dst" "")
230 (match_operand:QI 1 "general_operand_src" ""))]
234 /* One of the ops has to be in a register. */
236 && !register_operand (operand0, QImode)
237 && !register_operand (operand1, QImode))
239 operands[1] = copy_to_mode_reg (QImode, operand1);
243 (define_insn "movstrictqi"
244 [(set (strict_low_part (match_operand:QI 0 "general_operand_dst" "+r,r"))
245 (match_operand:QI 1 "general_operand_src" "I,rmi>"))]
250 [(set_attr "length" "2,*")
251 (set_attr "length_table" "*,movb")
252 (set_attr "cc" "set_zn,set_znv")])
256 (define_insn "*movhi_h8300"
257 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
258 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
260 && (register_operand (operands[0], HImode)
261 || register_operand (operands[1], HImode))
262 && !(GET_CODE (operands[0]) == MEM
263 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
264 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
265 && GET_CODE (operands[1]) == REG
266 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
274 [(set (attr "length")
275 (symbol_ref "compute_mov_length (operands)"))
276 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
278 (define_insn "*movhi_h8300hs"
279 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
280 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
281 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
282 && (register_operand (operands[0], HImode)
283 || register_operand (operands[1], HImode))"
291 [(set (attr "length")
292 (symbol_ref "compute_mov_length (operands)"))
293 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
295 (define_insn "*movhi_h8sx"
296 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Z,Q,rQ")
297 (match_operand:HI 1 "general_operand_src" "I,P3>X,P4>X,IP8>X,rQi"))]
305 [(set_attr "length_table" "*,*,mov_imm4,short_immediate,movw")
306 (set_attr "length" "2,2,*,*,*")
307 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv")])
309 (define_expand "movhi"
310 [(set (match_operand:HI 0 "general_operand_dst" "")
311 (match_operand:HI 1 "general_operand_src" ""))]
315 /* One of the ops has to be in a register. */
316 if (!register_operand (operand1, HImode)
317 && !register_operand (operand0, HImode))
319 operands[1] = copy_to_mode_reg (HImode, operand1);
323 (define_insn "movstricthi"
324 [(set (strict_low_part (match_operand:HI 0 "general_operand_dst" "+r,r,r"))
325 (match_operand:HI 1 "general_operand_src" "I,P3>X,rmi"))]
331 [(set_attr "length" "2,2,*")
332 (set_attr "length_table" "*,*,movw")
333 (set_attr "cc" "set_zn,set_znv,set_znv")])
337 (define_expand "movsi"
338 [(set (match_operand:SI 0 "general_operand_dst" "")
339 (match_operand:SI 1 "general_operand_src" ""))]
345 if (h8300_expand_movsi (operands))
348 else if (!TARGET_H8300SX)
350 /* One of the ops has to be in a register. */
351 if (!register_operand (operand1, SImode)
352 && !register_operand (operand0, SImode))
354 operands[1] = copy_to_mode_reg (SImode, operand1);
359 (define_insn "*movsi_h8300"
360 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,o,<,r")
361 (match_operand:SI 1 "general_operand_src" "I,r,io,r,r,>"))]
363 && (register_operand (operands[0], SImode)
364 || register_operand (operands[1], SImode))"
367 unsigned int rn = -1;
368 switch (which_alternative)
371 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
373 if (REGNO (operands[0]) < REGNO (operands[1]))
374 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
376 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
378 /* Make sure we don't trample the register we index with. */
379 if (GET_CODE (operands[1]) == MEM)
381 rtx inside = XEXP (operands[1], 0);
386 else if (GET_CODE (inside) == PLUS)
388 rtx lhs = XEXP (inside, 0);
389 rtx rhs = XEXP (inside, 1);
390 if (REG_P (lhs)) rn = REGNO (lhs);
391 if (REG_P (rhs)) rn = REGNO (rhs);
394 if (rn == REGNO (operands[0]))
396 /* Move the second word first. */
397 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
401 if (GET_CODE (operands[1]) == CONST_INT)
403 /* If either half is zero, use sub.w to clear that
405 if ((INTVAL (operands[1]) & 0xffff) == 0)
406 return \"mov.w %e1,%e0\;sub.w %f0,%f0\";
407 if (((INTVAL (operands[1]) >> 16) & 0xffff) == 0)
408 return \"sub.w %e0,%e0\;mov.w %f1,%f0\";
409 /* If the upper half and the lower half are the same,
410 copy one half to the other. */
411 if ((INTVAL (operands[1]) & 0xffff)
412 == ((INTVAL (operands[1]) >> 16) & 0xffff))
413 return \"mov.w\\t%e1,%e0\;mov.w\\t%e0,%f0\";
415 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
418 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
420 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
422 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
427 [(set (attr "length")
428 (symbol_ref "compute_mov_length (operands)"))])
430 (define_insn "*movsi_h8300hs"
431 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,<,r,r,m,*a,*a,r")
432 (match_operand:SI 1 "general_operand_src" "I,r,i,r,>,m,r,I,r,*a"))]
433 "(TARGET_H8300S || TARGET_H8300H) && !TARGET_H8300SX
434 && (register_operand (operands[0], SImode)
435 || register_operand (operands[1], SImode))
436 && !(GET_CODE (operands[0]) == MEM
437 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
438 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
439 && GET_CODE (operands[1]) == REG
440 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
443 switch (which_alternative)
446 return \"sub.l %S0,%S0\";
450 return \"clrmac\;ldmac %1,macl\";
452 return \"stmac macl,%0\";
454 if (GET_CODE (operands[1]) == CONST_INT)
456 int val = INTVAL (operands[1]);
458 /* Look for constants which can be made by adding an 8-bit
459 number to zero in one of the two low bytes. */
460 if (val == (val & 0xff))
462 operands[1] = GEN_INT ((char) val & 0xff);
463 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%w0\";
466 if (val == (val & 0xff00))
468 operands[1] = GEN_INT ((char) (val >> 8) & 0xff);
469 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%x0\";
472 /* Look for constants that can be obtained by subs, inc, and
474 switch (val & 0xffffffff)
477 return \"sub.l\\t%S0,%S0\;subs\\t#1,%S0\";
479 return \"sub.l\\t%S0,%S0\;subs\\t#2,%S0\";
481 return \"sub.l\\t%S0,%S0\;subs\\t#4,%S0\";
484 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%f0\";
486 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%f0\";
489 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%e0\";
491 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%e0\";
494 return \"sub.l\\t%S0,%S0\;inc.w\\t#1,%e0\";
496 return \"sub.l\\t%S0,%S0\;inc.w\\t#2,%e0\";
500 return \"mov.l %S1,%S0\";
502 [(set (attr "length")
503 (symbol_ref "compute_mov_length (operands)"))
504 (set_attr "cc" "set_zn,set_znv,clobber,set_znv,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
506 (define_insn "*movsi_h8sx"
507 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,Q,rQ,*a,*a,r")
508 (match_operand:SI 1 "general_operand_src" "I,P3>X,IP8>X,rQi,I,r,*a"))]
516 clrmac\;ldmac %1,macl
518 [(set_attr "length_table" "*,*,short_immediate,movl,*,*,*")
519 (set_attr "length" "2,2,*,*,2,6,4")
520 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
522 (define_insn "*movsf_h8sx"
523 [(set (match_operand:SF 0 "general_operand_dst" "=r,rQ")
524 (match_operand:SF 1 "general_operand_src" "G,rQi"))]
529 [(set_attr "length" "2,*")
530 (set_attr "length_table" "*,movl")
531 (set_attr "cc" "set_zn,set_znv")])
533 ;; Implement block moves using movmd. Defining movmemsi allows the full
534 ;; range of constant lengths (up to 0x40000 bytes when using movmd.l).
535 ;; See h8sx_emit_movmd for details.
536 (define_expand "movmemsi"
537 [(use (match_operand:BLK 0 "memory_operand" ""))
538 (use (match_operand:BLK 1 "memory_operand" ""))
539 (use (match_operand:SI 2 "" ""))
540 (use (match_operand:SI 3 "const_int_operand" ""))]
543 if (h8sx_emit_movmd (operands[0], operands[1], operands[2],
544 INTVAL (operands[3])))
550 ;; Expander for generating movmd insns. Operand 0 is the destination
551 ;; memory region, operand 1 is the source, operand 2 is the counter
552 ;; register and operand 3 is the chunk size (1, 2 or 4).
553 (define_expand "movmd"
555 [(set (match_operand:BLK 0 "memory_operand" "")
556 (match_operand:BLK 1 "memory_operand" ""))
557 (unspec [(match_operand:HI 2 "register_operand" "")
558 (match_operand:HI 3 "const_int_operand" "")] UNSPEC_MOVMD)
559 (clobber (match_dup 4))
560 (clobber (match_dup 5))
565 operands[4] = copy_rtx (XEXP (operands[0], 0));
566 operands[5] = copy_rtx (XEXP (operands[1], 0));
570 ;; This is a difficult instruction to reload since operand 0 must be the
571 ;; frame pointer. See h8300_reg_class_from_letter for an explanation.
572 (define_insn "movmd_internal_normal"
573 [(set (mem:BLK (match_operand:HI 3 "register_operand" "0,r"))
574 (mem:BLK (match_operand:HI 4 "register_operand" "1,1")))
575 (unspec [(match_operand:HI 5 "register_operand" "2,2")
576 (match_operand:HI 6 "const_int_operand" "n,n")] UNSPEC_MOVMD)
577 (clobber (match_operand:HI 0 "register_operand" "=d,??D"))
578 (clobber (match_operand:HI 1 "register_operand" "=f,f"))
579 (set (match_operand:HI 2 "register_operand" "=c,c")
581 "TARGET_H8300SX && TARGET_NORMAL_MODE"
585 [(set_attr "length" "2,14")
586 (set_attr "can_delay" "no")
587 (set_attr "cc" "none,clobber")])
589 (define_insn "movmd_internal"
590 [(set (mem:BLK (match_operand:SI 3 "register_operand" "0,r"))
591 (mem:BLK (match_operand:SI 4 "register_operand" "1,1")))
592 (unspec [(match_operand:HI 5 "register_operand" "2,2")
593 (match_operand:HI 6 "const_int_operand" "n,n")] UNSPEC_MOVMD)
594 (clobber (match_operand:SI 0 "register_operand" "=d,??D"))
595 (clobber (match_operand:SI 1 "register_operand" "=f,f"))
596 (set (match_operand:HI 2 "register_operand" "=c,c")
598 "TARGET_H8300SX && !TARGET_NORMAL_MODE"
602 [(set_attr "length" "2,14")
603 (set_attr "can_delay" "no")
604 (set_attr "cc" "none,clobber")])
606 ;; Split the above instruction if the destination register isn't er6.
607 ;; We need a sequence like:
615 ;; where <dest> is the current destination register (operand 4).
616 ;; The fourth instruction will be deleted if <dest> dies here.
618 [(set (match_operand:BLK 0 "memory_operand" "")
619 (match_operand:BLK 1 "memory_operand" ""))
620 (unspec [(match_operand:HI 2 "register_operand" "")
621 (match_operand:HI 3 "const_int_operand" "")] UNSPEC_MOVMD)
622 (clobber (match_operand:HI 4 "register_operand" ""))
623 (clobber (match_operand:HI 5 "register_operand" ""))
626 "TARGET_H8300SX && TARGET_NORMAL_MODE
628 && REGNO (operands[4]) != DESTINATION_REG"
633 h8300_swap_into_er6 (XEXP (operands[0], 0));
634 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
635 emit_insn (gen_movmd (dest, operands[1], operands[2], operands[3]));
636 h8300_swap_out_of_er6 (operands[4]);
641 [(set (match_operand:BLK 0 "memory_operand" "")
642 (match_operand:BLK 1 "memory_operand" ""))
643 (unspec [(match_operand:HI 2 "register_operand" "")
644 (match_operand:HI 3 "const_int_operand" "")] UNSPEC_MOVMD)
645 (clobber (match_operand:SI 4 "register_operand" ""))
646 (clobber (match_operand:SI 5 "register_operand" ""))
649 "TARGET_H8300SX && !TARGET_NORMAL_MODE
651 && REGNO (operands[4]) != DESTINATION_REG"
656 h8300_swap_into_er6 (XEXP (operands[0], 0));
657 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
658 emit_insn (gen_movmd (dest, operands[1], operands[2], operands[3]));
659 h8300_swap_out_of_er6 (operands[4]);
663 ;; Expand a call to stpcpy() using movsd. Operand 0 should point to
664 ;; the final character, but movsd leaves it pointing to the character
666 (define_expand "movstr"
667 [(use (match_operand 0 "register_operand" ""))
668 (use (match_operand:BLK 1 "memory_operand" ""))
669 (use (match_operand:BLK 2 "memory_operand" ""))]
672 operands[1] = replace_equiv_address
673 (operands[1], copy_to_mode_reg (Pmode, XEXP (operands[1], 0)));
674 operands[2] = replace_equiv_address
675 (operands[2], copy_to_mode_reg (Pmode, XEXP (operands[2], 0)));
676 emit_insn (gen_movsd (operands[1], operands[2], gen_reg_rtx (Pmode)));
677 emit_insn (gen_add3_insn (operands[0],
678 XEXP (operands[1], 0),
683 ;; Expander for generating a movsd instruction. Operand 0 is the
684 ;; destination string, operand 1 is the source string and operand 2
685 ;; is a scratch register.
686 (define_expand "movsd"
688 [(set (match_operand:BLK 0 "memory_operand" "")
689 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "")]
691 (clobber (match_dup 3))
692 (clobber (match_dup 4))
693 (clobber (match_operand 2 "register_operand" ""))])]
696 operands[3] = copy_rtx (XEXP (operands[0], 0));
697 operands[4] = copy_rtx (XEXP (operands[1], 0));
700 ;; See comments above memcpy_internal().
701 (define_insn "stpcpy_internal_normal"
702 [(set (mem:BLK (match_operand:HI 3 "register_operand" "0,r"))
703 (unspec:BLK [(mem:BLK (match_operand:HI 4 "register_operand" "1,1"))]
705 (clobber (match_operand:HI 0 "register_operand" "=d,??D"))
706 (clobber (match_operand:HI 1 "register_operand" "=f,f"))
707 (clobber (match_operand:HI 2 "register_operand" "=c,c"))]
708 "TARGET_H8300SX && TARGET_NORMAL_MODE"
710 \n1:\tmovsd\t2f\;bra\t1b\n2:
712 [(set_attr "length" "6,18")
713 (set_attr "cc" "none,clobber")])
715 (define_insn "stpcpy_internal"
716 [(set (mem:BLK (match_operand:SI 3 "register_operand" "0,r"))
717 (unspec:BLK [(mem:BLK (match_operand:SI 4 "register_operand" "1,1"))]
719 (clobber (match_operand:SI 0 "register_operand" "=d,??D"))
720 (clobber (match_operand:SI 1 "register_operand" "=f,f"))
721 (clobber (match_operand:SI 2 "register_operand" "=c,c"))]
722 "TARGET_H8300SX && !TARGET_NORMAL_MODE"
724 \n1:\tmovsd\t2f\;bra\t1b\n2:
726 [(set_attr "length" "6,18")
727 (set_attr "cc" "none,clobber")])
729 ;; Split the above instruction if the destination isn't er6. This works
730 ;; in the same way as the movmd splitter.
732 [(set (match_operand:BLK 0 "memory_operand" "")
733 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "")] UNSPEC_STPCPY))
734 (clobber (match_operand:HI 2 "register_operand" ""))
735 (clobber (match_operand:HI 3 "register_operand" ""))
736 (clobber (match_operand:HI 4 "register_operand" ""))]
737 "TARGET_H8300SX && TARGET_NORMAL_MODE
739 && REGNO (operands[2]) != DESTINATION_REG"
744 h8300_swap_into_er6 (XEXP (operands[0], 0));
745 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
746 emit_insn (gen_movsd (dest, operands[1], operands[4]));
747 h8300_swap_out_of_er6 (operands[2]);
752 [(set (match_operand:BLK 0 "memory_operand" "")
753 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "")] UNSPEC_STPCPY))
754 (clobber (match_operand:SI 2 "register_operand" ""))
755 (clobber (match_operand:SI 3 "register_operand" ""))
756 (clobber (match_operand:SI 4 "register_operand" ""))]
757 "TARGET_H8300SX && !TARGET_NORMAL_MODE
759 && REGNO (operands[2]) != DESTINATION_REG"
764 h8300_swap_into_er6 (XEXP (operands[0], 0));
765 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
766 emit_insn (gen_movsd (dest, operands[1], operands[4]));
767 h8300_swap_out_of_er6 (operands[2]);
773 (define_expand "movsf"
774 [(set (match_operand:SF 0 "general_operand_dst" "")
775 (match_operand:SF 1 "general_operand_src" ""))]
781 if (h8300_expand_movsi (operands))
784 else if (!TARGET_H8300SX)
786 /* One of the ops has to be in a register. */
787 if (!register_operand (operand1, SFmode)
788 && !register_operand (operand0, SFmode))
790 operands[1] = copy_to_mode_reg (SFmode, operand1);
795 (define_insn "*movsf_h8300"
796 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,o,<,r")
797 (match_operand:SF 1 "general_operand_src" "G,r,io,r,r,>"))]
799 && (register_operand (operands[0], SFmode)
800 || register_operand (operands[1], SFmode))"
803 /* Copy of the movsi stuff. */
804 unsigned int rn = -1;
805 switch (which_alternative)
808 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
810 if (REGNO (operands[0]) < REGNO (operands[1]))
811 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
813 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
815 /* Make sure we don't trample the register we index with. */
816 if (GET_CODE (operands[1]) == MEM)
818 rtx inside = XEXP (operands[1], 0);
823 else if (GET_CODE (inside) == PLUS)
825 rtx lhs = XEXP (inside, 0);
826 rtx rhs = XEXP (inside, 1);
827 if (REG_P (lhs)) rn = REGNO (lhs);
828 if (REG_P (rhs)) rn = REGNO (rhs);
831 if (rn == REGNO (operands[0]))
832 /* Move the second word first. */
833 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
835 /* Move the first word first. */
836 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
839 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
841 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
843 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
848 [(set (attr "length")
849 (symbol_ref "compute_mov_length (operands)"))])
851 (define_insn "*movsf_h8300hs"
852 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,m,<,r")
853 (match_operand:SF 1 "general_operand_src" "G,r,im,r,r,>"))]
854 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
855 && (register_operand (operands[0], SFmode)
856 || register_operand (operands[1], SFmode))"
864 [(set (attr "length")
865 (symbol_ref "compute_mov_length (operands)"))
866 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
868 ;; ----------------------------------------------------------------------
870 ;; ----------------------------------------------------------------------
872 (define_insn "pushqi1_h8300"
873 [(set (reg:HI SP_REG)
874 (plus:HI (reg:HI SP_REG) (const_int -2)))
875 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -1)))
876 (match_operand:QI 0 "register_operand" "r"))]
878 && operands[0] != stack_pointer_rtx"
880 [(set_attr "length" "2")])
882 (define_insn "pushqi1_h8300hs_advanced"
883 [(set (reg:SI SP_REG)
884 (plus:SI (reg:SI SP_REG) (const_int -4)))
885 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
886 (match_operand:QI 0 "register_operand" "r"))]
887 "(TARGET_H8300H || TARGET_H8300S)
888 && operands[0] != stack_pointer_rtx"
890 [(set_attr "length" "4")])
892 (define_insn "pushqi1_h8300hs_normal"
893 [(set (reg:HI SP_REG)
894 (plus:HI (reg:HI SP_REG) (const_int -4)))
895 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
896 (match_operand:QI 0 "register_operand" "r"))]
897 "(TARGET_H8300H || TARGET_H8300S)
898 && operands[0] != stack_pointer_rtx"
900 [(set_attr "length" "4")])
902 (define_expand "pushqi1"
903 [(match_operand:QI 0 "register_operand" "")]
908 emit_insn (gen_pushqi1_h8300 (operands[0]));
909 else if (!TARGET_NORMAL_MODE)
910 emit_insn (gen_pushqi1_h8300hs_advanced (operands[0]));
912 emit_insn (gen_pushqi1_h8300hs_normal (operands[0]));
916 (define_expand "pushhi1_h8300"
917 [(set (mem:HI (pre_dec:HI (reg:HI SP_REG)))
918 (match_operand:HI 0 "register_operand" ""))]
920 && operands[0] != stack_pointer_rtx"
923 (define_insn "pushhi1_h8300hs_advanced"
924 [(set (reg:SI SP_REG)
925 (plus:SI (reg:SI SP_REG) (const_int -4)))
926 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
927 (match_operand:HI 0 "register_operand" "r"))]
928 "(TARGET_H8300H || TARGET_H8300S)
929 && operands[0] != stack_pointer_rtx"
931 [(set_attr "length" "4")])
933 (define_insn "pushhi1_h8300hs_normal"
934 [(set (reg:HI SP_REG)
935 (plus:HI (reg:HI SP_REG) (const_int -4)))
936 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
937 (match_operand:HI 0 "register_operand" "r"))]
938 "(TARGET_H8300H || TARGET_H8300S)
939 && operands[0] != stack_pointer_rtx"
941 [(set_attr "length" "4")])
943 (define_expand "pushhi1"
944 [(match_operand:HI 0 "register_operand" "")]
949 emit_insn (gen_pushhi1_h8300 (operands[0]));
950 else if (!TARGET_NORMAL_MODE)
951 emit_insn (gen_pushhi1_h8300hs_advanced (operands[0]));
953 emit_insn (gen_pushhi1_h8300hs_normal (operands[0]));
957 ;; ----------------------------------------------------------------------
959 ;; ----------------------------------------------------------------------
962 [(set (cc0) (zero_extract:HI (match_operand:QI 0 "bit_memory_operand" "r,U")
964 (match_operand 1 "const_int_operand" "n,n")))]
967 [(set_attr "length" "2,4")
968 (set_attr "cc" "set_zn,set_zn")])
971 [(set (cc0) (zero_extract:HI (match_operand:HI 0 "register_operand" "r")
973 (match_operand 1 "const_int_operand" "n")))]
976 [(set_attr "length" "2")
977 (set_attr "cc" "set_zn")])
979 (define_insn_and_split "*tst_extzv_1_n"
981 (zero_extract:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>")
983 (match_operand 1 "const_int_operand" "n,n,n")))
984 (clobber (match_scratch:QI 2 "=X,X,&r"))]
985 "(TARGET_H8300H || TARGET_H8300S)"
991 && !OK_FOR_U (operands[0])"
994 (parallel [(set (cc0) (zero_extract:SI (match_dup 2)
997 (clobber (scratch:QI))])]
999 [(set_attr "length" "2,8,10")
1000 (set_attr "cc" "set_zn,set_zn,set_zn")])
1003 [(set (cc0) (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1005 (match_operand 1 "const_int_operand" "n")))]
1006 "(TARGET_H8300H || TARGET_H8300S)
1007 && INTVAL (operands[1]) <= 15"
1009 [(set_attr "length" "2")
1010 (set_attr "cc" "set_zn")])
1012 (define_insn_and_split "*tstsi_upper_bit"
1014 (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1016 (match_operand 1 "const_int_operand" "n")))
1017 (clobber (match_scratch:SI 2 "=&r"))]
1018 "(TARGET_H8300H || TARGET_H8300S)
1019 && INTVAL (operands[1]) >= 16"
1021 "&& reload_completed"
1023 (ior:SI (and:SI (match_dup 2)
1025 (lshiftrt:SI (match_dup 0)
1028 (zero_extract:SI (match_dup 2)
1031 "operands[3] = GEN_INT (INTVAL (operands[1]) - 16);")
1033 (define_insn "*tstsi_variable_bit"
1035 (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1037 (and:SI (match_operand:SI 1 "register_operand" "r")
1039 "TARGET_H8300H || TARGET_H8300S"
1041 [(set_attr "length" "2")
1042 (set_attr "cc" "set_zn")])
1044 (define_insn_and_split "*tstsi_variable_bit_qi"
1046 (zero_extract:SI (zero_extend:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>"))
1048 (and:SI (match_operand:SI 1 "register_operand" "r,r,r")
1050 (clobber (match_scratch:QI 2 "=X,X,&r"))]
1051 "(TARGET_H8300H || TARGET_H8300S)"
1056 "&& reload_completed
1057 && !OK_FOR_U (operands[0])"
1060 (parallel [(set (cc0) (zero_extract:SI (zero_extend:SI (match_dup 2))
1062 (and:SI (match_dup 1)
1064 (clobber (scratch:QI))])]
1066 [(set_attr "length" "2,8,10")
1067 (set_attr "cc" "set_zn,set_zn,set_zn")])
1069 (define_insn "tstqi"
1070 [(set (cc0) (match_operand:QI 0 "register_operand" "r"))]
1073 [(set_attr "length" "2")
1074 (set_attr "cc" "set_znv")])
1076 (define_insn "tsthi"
1077 [(set (cc0) (match_operand:HI 0 "register_operand" "r"))]
1080 [(set_attr "length" "2")
1081 (set_attr "cc" "set_znv")])
1083 (define_insn "*tsthi_upper"
1085 (and:HI (match_operand:HI 0 "register_operand" "r")
1089 [(set_attr "length" "2")
1090 (set_attr "cc" "set_znv")])
1092 (define_insn "tstsi"
1093 [(set (cc0) (match_operand:SI 0 "register_operand" "r"))]
1094 "TARGET_H8300H || TARGET_H8300S"
1096 [(set_attr "length" "2")
1097 (set_attr "cc" "set_znv")])
1099 (define_insn "*tstsi_upper"
1101 (and:SI (match_operand:SI 0 "register_operand" "r")
1102 (const_int -65536)))]
1105 [(set_attr "length" "2")
1106 (set_attr "cc" "set_znv")])
1108 (define_insn "cmpqi"
1110 (compare (match_operand:QI 0 "h8300_dst_operand" "rQ")
1111 (match_operand:QI 1 "h8300_src_operand" "rQi")))]
1114 [(set_attr "length_table" "addb")
1115 (set_attr "cc" "compare")])
1117 (define_expand "cmphi"
1119 (compare (match_operand:HI 0 "h8300_dst_operand" "")
1120 (match_operand:HI 1 "h8300_src_operand" "")))]
1124 /* Force operand1 into a register if we're compiling
1126 if (GET_CODE (operands[1]) != REG && TARGET_H8300)
1127 operands[1] = force_reg (HImode, operands[1]);
1130 (define_insn "*cmphi_h8300_znvc"
1132 (compare (match_operand:HI 0 "register_operand" "r")
1133 (match_operand:HI 1 "register_operand" "r")))]
1136 [(set_attr "length" "2")
1137 (set_attr "cc" "compare")])
1139 (define_insn "*cmphi_h8300hs_znvc"
1141 (compare (match_operand:HI 0 "h8300_dst_operand" "rU,rQ")
1142 (match_operand:HI 1 "h8300_src_operand" "P3>X,rQi")))]
1143 "TARGET_H8300H || TARGET_H8300S"
1145 [(set_attr "length_table" "short_immediate,addw")
1146 (set_attr "cc" "compare,compare")])
1148 (define_insn "cmpsi"
1150 (compare (match_operand:SI 0 "h8300_dst_operand" "r,rQ")
1151 (match_operand:SI 1 "h8300_src_operand" "P3>X,rQi")))]
1152 "TARGET_H8300H || TARGET_H8300S"
1154 [(set_attr "length" "2,*")
1155 (set_attr "length_table" "*,addl")
1156 (set_attr "cc" "compare,compare")])
1158 ;; ----------------------------------------------------------------------
1160 ;; ----------------------------------------------------------------------
1162 (define_expand "addqi3"
1163 [(set (match_operand:QI 0 "register_operand" "")
1164 (plus:QI (match_operand:QI 1 "register_operand" "")
1165 (match_operand:QI 2 "h8300_src_operand" "")))]
1169 (define_insn "*addqi3"
1170 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
1171 (plus:QI (match_operand:QI 1 "h8300_dst_operand" "%0")
1172 (match_operand:QI 2 "h8300_src_operand" "rQi")))]
1173 "h8300_operands_match_p (operands)"
1175 [(set_attr "length_table" "addb")
1176 (set_attr "cc" "set_zn")])
1178 (define_expand "addhi3"
1179 [(set (match_operand:HI 0 "register_operand" "")
1180 (plus:HI (match_operand:HI 1 "register_operand" "")
1181 (match_operand:HI 2 "h8300_src_operand" "")))]
1185 (define_insn "*addhi3_h8300"
1186 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
1187 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
1188 (match_operand:HI 2 "h8300_src_operand" "L,N,J,n,r")))]
1194 add.b %s2,%s0\;addx %t2,%t0
1196 [(set_attr "length" "2,2,2,4,2")
1197 (set_attr "cc" "none_0hit,none_0hit,clobber,clobber,set_zn")])
1199 ;; This splitter is very important to make the stack adjustment
1200 ;; interrupt-safe. The combination of add.b and addx is unsafe!
1202 ;; We apply this split after the peephole2 pass so that we won't end
1203 ;; up creating too many adds/subs when a scratch register is
1204 ;; available, which is actually a common case because stack unrolling
1205 ;; tends to happen immediately after a function call.
1208 [(set (match_operand:HI 0 "stack_pointer_operand" "")
1209 (plus:HI (match_dup 0)
1210 (match_operand 1 "const_int_gt_2_operand" "")))]
1211 "TARGET_H8300 && flow2_completed"
1213 "split_adds_subs (HImode, operands); DONE;")
1216 [(match_scratch:HI 2 "r")
1217 (set (match_operand:HI 0 "stack_pointer_operand" "")
1218 (plus:HI (match_dup 0)
1219 (match_operand:HI 1 "const_int_ge_8_operand" "")))]
1224 (plus:HI (match_dup 0)
1228 (define_insn "*addhi3_h8300hs"
1229 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
1230 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
1231 (match_operand:HI 2 "h8300_src_operand" "L,N,J,n,r")))]
1232 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX"
1239 [(set_attr "length" "2,2,2,4,2")
1240 (set_attr "cc" "none_0hit,none_0hit,clobber,set_zn,set_zn")])
1242 (define_insn "*addhi3_incdec"
1243 [(set (match_operand:HI 0 "register_operand" "=r,r")
1244 (unspec:HI [(match_operand:HI 1 "register_operand" "0,0")
1245 (match_operand:HI 2 "incdec_operand" "M,O")]
1247 "TARGET_H8300H || TARGET_H8300S"
1251 [(set_attr "length" "2,2")
1252 (set_attr "cc" "set_zn,set_zn")])
1254 (define_insn "*addhi3_h8sx"
1255 [(set (match_operand:HI 0 "h8300_dst_operand" "=rU,rU,r,rQ")
1256 (plus:HI (match_operand:HI 1 "h8300_dst_operand" "%0,0,0,0")
1257 (match_operand:HI 2 "h8300_src_operand" "P3>X,P3<X,J,rQi")))]
1258 "TARGET_H8300SX && h8300_operands_match_p (operands)"
1264 [(set_attr "length_table" "short_immediate,short_immediate,*,addw")
1265 (set_attr "length" "*,*,2,*")
1266 (set_attr "cc" "set_zn")])
1269 [(set (match_operand:HI 0 "register_operand" "")
1270 (plus:HI (match_dup 0)
1271 (match_operand:HI 1 "two_insn_adds_subs_operand" "")))]
1274 "split_adds_subs (HImode, operands); DONE;")
1276 (define_expand "addsi3"
1277 [(set (match_operand:SI 0 "register_operand" "")
1278 (plus:SI (match_operand:SI 1 "register_operand" "")
1279 (match_operand:SI 2 "h8300_src_operand" "")))]
1283 (define_insn "*addsi_h8300"
1284 [(set (match_operand:SI 0 "register_operand" "=r,r")
1285 (plus:SI (match_operand:SI 1 "register_operand" "%0,0")
1286 (match_operand:SI 2 "h8300_src_operand" "n,r")))]
1288 "* return output_plussi (operands);"
1289 [(set (attr "length")
1290 (symbol_ref "compute_plussi_length (operands)"))
1292 (symbol_ref "compute_plussi_cc (operands)"))])
1294 (define_insn "*addsi_h8300hs"
1295 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ,rQ")
1296 (plus:SI (match_operand:SI 1 "h8300_dst_operand" "%0,0")
1297 (match_operand:SI 2 "h8300_src_operand" "i,rQ")))]
1298 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
1299 "* return output_plussi (operands);"
1300 [(set (attr "length")
1301 (symbol_ref "compute_plussi_length (operands)"))
1303 (symbol_ref "compute_plussi_cc (operands)"))])
1305 (define_insn "*addsi3_incdec"
1306 [(set (match_operand:SI 0 "register_operand" "=r,r")
1307 (unspec:SI [(match_operand:SI 1 "register_operand" "0,0")
1308 (match_operand:SI 2 "incdec_operand" "M,O")]
1310 "TARGET_H8300H || TARGET_H8300S"
1314 [(set_attr "length" "2,2")
1315 (set_attr "cc" "set_zn,set_zn")])
1318 [(set (match_operand:SI 0 "register_operand" "")
1319 (plus:SI (match_dup 0)
1320 (match_operand:SI 1 "two_insn_adds_subs_operand" "")))]
1321 "TARGET_H8300H || TARGET_H8300S"
1323 "split_adds_subs (SImode, operands); DONE;")
1325 ;; ----------------------------------------------------------------------
1326 ;; SUBTRACT INSTRUCTIONS
1327 ;; ----------------------------------------------------------------------
1329 (define_expand "subqi3"
1330 [(set (match_operand:QI 0 "register_operand" "")
1331 (minus:QI (match_operand:QI 1 "register_operand" "")
1332 (match_operand:QI 2 "h8300_src_operand" "")))]
1336 (define_insn "*subqi3"
1337 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
1338 (minus:QI (match_operand:QI 1 "h8300_dst_operand" "0")
1339 (match_operand:QI 2 "h8300_dst_operand" "rQ")))]
1340 "h8300_operands_match_p (operands)"
1342 [(set_attr "length_table" "addb")
1343 (set_attr "cc" "set_zn")])
1345 (define_expand "subhi3"
1346 [(set (match_operand:HI 0 "register_operand" "")
1347 (minus:HI (match_operand:HI 1 "register_operand" "")
1348 (match_operand:HI 2 "h8300_src_operand" "")))]
1352 (define_insn "*subhi3_h8300"
1353 [(set (match_operand:HI 0 "register_operand" "=r,r")
1354 (minus:HI (match_operand:HI 1 "register_operand" "0,0")
1355 (match_operand:HI 2 "h8300_src_operand" "r,n")))]
1359 add.b %E2,%s0\;addx %F2,%t0"
1360 [(set_attr "length" "2,4")
1361 (set_attr "cc" "set_zn,clobber")])
1363 (define_insn "*subhi3_h8300hs"
1364 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ,rQ")
1365 (minus:HI (match_operand:HI 1 "h8300_dst_operand" "0,0")
1366 (match_operand:HI 2 "h8300_src_operand" "rQ,i")))]
1367 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
1371 [(set_attr "length_table" "addw")
1372 (set_attr "cc" "set_zn")])
1374 (define_expand "subsi3"
1375 [(set (match_operand:SI 0 "register_operand" "")
1376 (minus:SI (match_operand:SI 1 "register_operand" "")
1377 (match_operand:SI 2 "h8300_src_operand" "")))]
1381 operands[2] = force_reg (SImode, operands[2]);
1384 (define_insn "*subsi3_h8300"
1385 [(set (match_operand:SI 0 "register_operand" "=r")
1386 (minus:SI (match_operand:SI 1 "register_operand" "0")
1387 (match_operand:SI 2 "register_operand" "r")))]
1389 "sub.w %f2,%f0\;subx %y2,%y0\;subx %z2,%z0"
1390 [(set_attr "length" "6")])
1392 (define_insn "*subsi3_h8300hs"
1393 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ,rQ")
1394 (minus:SI (match_operand:SI 1 "h8300_dst_operand" "0,0")
1395 (match_operand:SI 2 "h8300_src_operand" "rQ,i")))]
1396 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
1400 [(set_attr "length_table" "addl")
1401 (set_attr "cc" "set_zn")])
1403 ;; ----------------------------------------------------------------------
1404 ;; MULTIPLY INSTRUCTIONS
1405 ;; ----------------------------------------------------------------------
1407 ;; Note that the H8/300 can only handle umulqihi3.
1409 (define_expand "mulqihi3"
1410 [(set (match_operand:HI 0 "register_operand" "")
1411 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" ""))
1412 ;; intentionally-mismatched modes
1413 (match_operand:QI 2 "reg_or_nibble_operand" "")))]
1414 "TARGET_H8300H || TARGET_H8300S"
1417 if (GET_MODE (operands[2]) != VOIDmode)
1418 operands[2] = gen_rtx_SIGN_EXTEND (HImode, operands[2]);
1421 (define_insn "*mulqihi3_const"
1422 [(set (match_operand:HI 0 "register_operand" "=r")
1423 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1424 (match_operand:QI 2 "nibble_operand" "IP4>X")))]
1427 [(set_attr "length" "4")
1428 (set_attr "cc" "set_zn")])
1430 (define_insn "*mulqihi3"
1431 [(set (match_operand:HI 0 "register_operand" "=r")
1432 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1433 (sign_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1434 "TARGET_H8300H || TARGET_H8300S"
1436 [(set_attr "length" "4")
1437 (set_attr "cc" "set_zn")])
1439 (define_expand "mulhisi3"
1440 [(set (match_operand:SI 0 "register_operand" "")
1441 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" ""))
1442 ;; intentionally-mismatched modes
1443 (match_operand:HI 2 "reg_or_nibble_operand" "")))]
1444 "TARGET_H8300H || TARGET_H8300S"
1447 if (GET_MODE (operands[2]) != VOIDmode)
1448 operands[2] = gen_rtx_SIGN_EXTEND (SImode, operands[2]);
1451 (define_insn "*mulhisi3_const"
1452 [(set (match_operand:SI 0 "register_operand" "=r")
1453 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1454 (match_operand:SI 2 "nibble_operand" "IP4>X")))]
1457 [(set_attr "length" "4")
1458 (set_attr "cc" "set_zn")])
1460 (define_insn "*mulhisi3"
1461 [(set (match_operand:SI 0 "register_operand" "=r")
1462 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1463 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1464 "TARGET_H8300H || TARGET_H8300S"
1466 [(set_attr "length" "4")
1467 (set_attr "cc" "set_zn")])
1469 (define_expand "umulqihi3"
1470 [(set (match_operand:HI 0 "register_operand" "")
1471 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" ""))
1472 ;; intentionally-mismatched modes
1473 (match_operand:QI 2 "reg_or_nibble_operand" "")))]
1474 "TARGET_H8300H || TARGET_H8300S"
1477 if (GET_MODE (operands[2]) != VOIDmode)
1478 operands[2] = gen_rtx_ZERO_EXTEND (HImode, operands[2]);
1481 (define_insn "*umulqihi3_const"
1482 [(set (match_operand:HI 0 "register_operand" "=r")
1483 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1484 (match_operand:QI 2 "nibble_operand" "IP4>X")))]
1487 [(set_attr "length" "4")
1488 (set_attr "cc" "set_zn")])
1490 (define_insn "*umulqihi3"
1491 [(set (match_operand:HI 0 "register_operand" "=r")
1492 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1493 (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1496 [(set_attr "length" "2")
1497 (set_attr "cc" "none_0hit")])
1499 (define_expand "umulhisi3"
1500 [(set (match_operand:SI 0 "register_operand" "")
1501 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" ""))
1502 ;; intentionally-mismatched modes
1503 (match_operand:HI 2 "reg_or_nibble_operand" "")))]
1504 "TARGET_H8300H || TARGET_H8300S"
1507 if (GET_MODE (operands[2]) != VOIDmode)
1508 operands[2] = gen_rtx_ZERO_EXTEND (SImode, operands[2]);
1511 (define_insn "*umulhisi3_const"
1512 [(set (match_operand:SI 0 "register_operand" "=r")
1513 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1514 (match_operand:SI 2 "nibble_operand" "IP4>X")))]
1517 [(set_attr "length" "4")
1518 (set_attr "cc" "set_zn")])
1520 (define_insn "*umulhisi3"
1521 [(set (match_operand:SI 0 "register_operand" "=r")
1522 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1523 (zero_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1524 "TARGET_H8300H || TARGET_H8300S"
1526 [(set_attr "length" "2")
1527 (set_attr "cc" "none_0hit")])
1529 ;; We could have used mulu.[wl] here, but mulu.[lw] is only available
1530 ;; on a H8SX with a multiplier, whereas muls.w seems to be available
1531 ;; on all H8SX variants.
1532 (define_insn "mulhi3"
1533 [(set (match_operand:HI 0 "register_operand" "=r")
1534 (mult:HI (match_operand:HI 1 "register_operand" "%0")
1535 (match_operand:HI 2 "reg_or_nibble_operand" "r IP4>X")))]
1538 [(set_attr "length" "2")
1539 (set_attr "cc" "set_zn")])
1541 (define_insn "mulsi3"
1542 [(set (match_operand:SI 0 "register_operand" "=r")
1543 (mult:SI (match_operand:SI 1 "register_operand" "%0")
1544 (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))]
1547 [(set_attr "length" "2")
1548 (set_attr "cc" "set_zn")])
1550 (define_insn "smulsi3_highpart"
1551 [(set (match_operand:SI 0 "register_operand" "=r")
1555 (sign_extend:DI (match_operand:SI 1 "register_operand" "%0"))
1556 (sign_extend:DI (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))
1559 "muls/u.l\\t%S2,%S0"
1560 [(set_attr "length" "2")
1561 (set_attr "cc" "set_zn")])
1563 (define_insn "umulsi3_highpart"
1564 [(set (match_operand:SI 0 "register_operand" "=r")
1568 (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
1569 (zero_extend:DI (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))
1572 "mulu/u.l\\t%S2,%S0"
1573 [(set_attr "length" "2")
1574 (set_attr "cc" "none_0hit")])
1576 ;; This is a "bridge" instruction. Combine can't cram enough insns
1577 ;; together to crate a MAC instruction directly, but it can create
1578 ;; this instruction, which then allows combine to create the real
1581 ;; Unfortunately, if combine doesn't create a MAC instruction, this
1582 ;; insn must generate reasonably correct code. Egad.
1584 [(set (match_operand:SI 0 "register_operand" "=a")
1587 (mem:HI (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1589 (mem:HI (post_inc:SI (match_operand:SI 2 "register_operand" "r"))))))]
1591 "clrmac\;mac @%2+,@%1+"
1592 [(set_attr "length" "6")
1593 (set_attr "cc" "none_0hit")])
1596 [(set (match_operand:SI 0 "register_operand" "=a")
1598 (sign_extend:SI (mem:HI
1599 (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1600 (sign_extend:SI (mem:HI
1601 (post_inc:SI (match_operand:SI 2 "register_operand" "r")))))
1602 (match_operand:SI 3 "register_operand" "0")))]
1605 [(set_attr "length" "4")
1606 (set_attr "cc" "none_0hit")])
1608 ;; ----------------------------------------------------------------------
1609 ;; DIVIDE/MOD INSTRUCTIONS
1610 ;; ----------------------------------------------------------------------
1612 (define_insn "udivhi3"
1613 [(set (match_operand:HI 0 "register_operand" "=r")
1615 (match_operand:HI 1 "register_operand" "0")
1616 (match_operand:HI 2 "reg_or_nibble_operand" "r IP4>X")))]
1619 [(set_attr "length" "2")])
1621 (define_insn "divhi3"
1622 [(set (match_operand:HI 0 "register_operand" "=r")
1624 (match_operand:HI 1 "register_operand" "0")
1625 (match_operand:HI 2 "reg_or_nibble_operand" "r IP4>X")))]
1628 [(set_attr "length" "2")])
1630 (define_insn "udivsi3"
1631 [(set (match_operand:SI 0 "register_operand" "=r")
1633 (match_operand:SI 1 "register_operand" "0")
1634 (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))]
1637 [(set_attr "length" "2")])
1639 (define_insn "divsi3"
1640 [(set (match_operand:SI 0 "register_operand" "=r")
1642 (match_operand:SI 1 "register_operand" "0")
1643 (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))]
1646 [(set_attr "length" "2")])
1648 (define_insn "udivmodqi4"
1649 [(set (match_operand:QI 0 "register_operand" "=r")
1652 (match_operand:HI 1 "register_operand" "0")
1653 (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1654 (set (match_operand:QI 3 "register_operand" "=r")
1658 (zero_extend:HI (match_dup 2)))))]
1662 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1663 return \"divxu.b\\t%X2,%T0\";
1665 return \"divxu.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
1667 [(set_attr "length" "4")])
1669 (define_insn "divmodqi4"
1670 [(set (match_operand:QI 0 "register_operand" "=r")
1673 (match_operand:HI 1 "register_operand" "0")
1674 (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1675 (set (match_operand:QI 3 "register_operand" "=r")
1679 (sign_extend:HI (match_dup 2)))))]
1680 "TARGET_H8300H || TARGET_H8300S"
1683 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1684 return \"divxs.b\\t%X2,%T0\";
1686 return \"divxs.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
1688 [(set_attr "length" "6")])
1690 (define_insn "udivmodhi4"
1691 [(set (match_operand:HI 0 "register_operand" "=r")
1694 (match_operand:SI 1 "register_operand" "0")
1695 (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1696 (set (match_operand:HI 3 "register_operand" "=r")
1700 (zero_extend:SI (match_dup 2)))))]
1701 "TARGET_H8300H || TARGET_H8300S"
1704 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1705 return \"divxu.w\\t%T2,%S0\";
1707 return \"divxu.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
1709 [(set_attr "length" "4")])
1711 (define_insn "divmodhi4"
1712 [(set (match_operand:HI 0 "register_operand" "=r")
1715 (match_operand:SI 1 "register_operand" "0")
1716 (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1717 (set (match_operand:HI 3 "register_operand" "=r")
1721 (sign_extend:SI (match_dup 2)))))]
1722 "TARGET_H8300H || TARGET_H8300S"
1725 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1726 return \"divxs.w\\t%T2,%S0\";
1728 return \"divxs.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
1730 [(set_attr "length" "6")])
1732 ;; ----------------------------------------------------------------------
1734 ;; ----------------------------------------------------------------------
1736 (define_insn "*andqi3_2"
1737 [(set (match_operand:QI 0 "bit_operand" "=rQ,r")
1738 (and:QI (match_operand:QI 1 "bit_operand" "%0,WU")
1739 (match_operand:QI 2 "h8300_src_operand" "rQi,IP1>X")))]
1744 [(set_attr "length" "*,8")
1745 (set_attr "length_table" "logicb,*")
1746 (set_attr "cc" "set_znv,none_0hit")])
1748 (define_insn "andqi3_1"
1749 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1750 (and:QI (match_operand:QI 1 "bit_operand" "%0,0")
1751 (match_operand:QI 2 "h8300_src_operand" "rn,n")))]
1752 "register_operand (operands[0], QImode)
1753 || single_zero_operand (operands[2], QImode)"
1757 [(set_attr "length" "2,8")
1758 (set_attr "cc" "set_znv,none_0hit")])
1760 (define_expand "andqi3"
1761 [(set (match_operand:QI 0 "register_operand" "")
1762 (and:QI (match_operand:QI 1 "register_operand" "")
1763 (match_operand:QI 2 "h8300_src_operand" "")))]
1767 (define_expand "andhi3"
1768 [(set (match_operand:HI 0 "register_operand" "")
1769 (and:HI (match_operand:HI 1 "register_operand" "")
1770 (match_operand:HI 2 "h8300_src_operand" "")))]
1774 (define_insn "*andorqi3"
1775 [(set (match_operand:QI 0 "register_operand" "=r")
1776 (ior:QI (and:QI (match_operand:QI 2 "register_operand" "r")
1777 (match_operand:QI 3 "single_one_operand" "n"))
1778 (match_operand:QI 1 "register_operand" "0")))]
1780 "bld\\t%V3,%X2\;bor\\t%V3,%X0\;bst\\t%V3,%X0"
1781 [(set_attr "length" "6")])
1783 (define_insn "*andorhi3"
1784 [(set (match_operand:HI 0 "register_operand" "=r")
1785 (ior:HI (and:HI (match_operand:HI 2 "register_operand" "r")
1786 (match_operand:HI 3 "single_one_operand" "n"))
1787 (match_operand:HI 1 "register_operand" "0")))]
1791 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1792 if (INTVAL (operands[3]) > 128)
1794 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1795 return \"bld\\t%V3,%t2\;bor\\t%V3,%t0\;bst\\t%V3,%t0\";
1797 return \"bld\\t%V3,%s2\;bor\\t%V3,%s0\;bst\\t%V3,%s0\";
1799 [(set_attr "length" "6")])
1801 (define_insn "*andorsi3"
1802 [(set (match_operand:SI 0 "register_operand" "=r")
1803 (ior:SI (and:SI (match_operand:SI 2 "register_operand" "r")
1804 (match_operand:SI 3 "single_one_operand" "n"))
1805 (match_operand:SI 1 "register_operand" "0")))]
1806 "(INTVAL (operands[3]) & 0xffff) != 0"
1809 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1810 if (INTVAL (operands[3]) > 128)
1812 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1813 return \"bld\\t%V3,%x2\;bor\\t%V3,%x0\;bst\\t%V3,%x0\";
1815 return \"bld\\t%V3,%w2\;bor\\t%V3,%w0\;bst\\t%V3,%w0\";
1817 [(set_attr "length" "6")])
1819 (define_insn "*andorsi3_shift_8"
1820 [(set (match_operand:SI 0 "register_operand" "=r")
1821 (ior:SI (and:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
1824 (match_operand:SI 1 "register_operand" "0")))]
1827 [(set_attr "length" "2")])
1829 (define_expand "andsi3"
1830 [(set (match_operand:SI 0 "register_operand" "")
1831 (and:SI (match_operand:SI 1 "register_operand" "")
1832 (match_operand:SI 2 "h8300_src_operand" "")))]
1836 ;; ----------------------------------------------------------------------
1838 ;; ----------------------------------------------------------------------
1840 (define_insn "iorqi3_1"
1841 [(set (match_operand:QI 0 "bit_operand" "=rQ,U")
1842 (ior:QI (match_operand:QI 1 "bit_operand" "%0,0")
1843 (match_operand:QI 2 "h8300_src_operand" "rQi,n")))]
1844 "TARGET_H8300SX || register_operand (operands[0], QImode)
1845 || single_one_operand (operands[2], QImode)"
1849 [(set_attr "length" "*,8")
1850 (set_attr "length_table" "logicb,*")
1851 (set_attr "cc" "set_znv,none_0hit")])
1853 (define_expand "iorqi3"
1854 [(set (match_operand:QI 0 "register_operand" "")
1855 (ior:QI (match_operand:QI 1 "register_operand" "")
1856 (match_operand:QI 2 "h8300_src_operand" "")))]
1860 (define_expand "iorhi3"
1861 [(set (match_operand:HI 0 "register_operand" "")
1862 (ior:HI (match_operand:HI 1 "register_operand" "")
1863 (match_operand:HI 2 "h8300_src_operand" "")))]
1867 (define_expand "iorsi3"
1868 [(set (match_operand:SI 0 "register_operand" "")
1869 (ior:SI (match_operand:SI 1 "register_operand" "")
1870 (match_operand:SI 2 "h8300_src_operand" "")))]
1874 ;; ----------------------------------------------------------------------
1876 ;; ----------------------------------------------------------------------
1878 (define_insn "xorqi3_1"
1879 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1880 (xor:QI (match_operand:QI 1 "bit_operand" "%0,0")
1881 (match_operand:QI 2 "h8300_src_operand" "rQi,n")))]
1882 "TARGET_H8300SX || register_operand (operands[0], QImode)
1883 || single_one_operand (operands[2], QImode)"
1887 [(set_attr "length" "*,8")
1888 (set_attr "length_table" "logicb,*")
1889 (set_attr "cc" "set_znv,none_0hit")])
1891 (define_expand "xorqi3"
1892 [(set (match_operand:QI 0 "register_operand" "")
1893 (xor:QI (match_operand:QI 1 "register_operand" "")
1894 (match_operand:QI 2 "h8300_src_operand" "")))]
1898 (define_expand "xorhi3"
1899 [(set (match_operand:HI 0 "register_operand" "")
1900 (xor:HI (match_operand:HI 1 "register_operand" "")
1901 (match_operand:HI 2 "h8300_src_operand" "")))]
1905 (define_expand "xorsi3"
1906 [(set (match_operand:SI 0 "register_operand" "")
1907 (xor:SI (match_operand:SI 1 "register_operand" "")
1908 (match_operand:SI 2 "h8300_src_operand" "")))]
1912 ;; ----------------------------------------------------------------------
1913 ;; {AND,IOR,XOR}{HI3,SI3} PATTERNS
1914 ;; ----------------------------------------------------------------------
1916 ;; We need a separate pattern here because machines other than the
1917 ;; original H8300 don't have to split the 16-bit operand into a pair
1918 ;; of high/low instructions, so we can accept literal addresses, that
1919 ;; have to be loaded into a register on H8300.
1920 (define_insn "*logicalhi3_sn"
1921 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
1922 (match_operator:HI 3 "bit_operator"
1923 [(match_operand:HI 1 "h8300_dst_operand" "%0")
1924 (match_operand:HI 2 "h8300_src_operand" "rQi")]))]
1925 "(TARGET_H8300S || TARGET_H8300H) && h8300_operands_match_p (operands)"
1926 "* return output_logical_op (HImode, operands);"
1927 [(set (attr "length")
1928 (symbol_ref "compute_logical_op_length (HImode, operands)"))
1930 (symbol_ref "compute_logical_op_cc (HImode, operands)"))])
1932 (define_insn "*logicalsi3_sn"
1933 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
1934 (match_operator:SI 3 "bit_operator"
1935 [(match_operand:SI 1 "h8300_dst_operand" "%0")
1936 (match_operand:SI 2 "h8300_src_operand" "rQi")]))]
1937 "(TARGET_H8300S || TARGET_H8300H) && h8300_operands_match_p (operands)"
1938 "* return output_logical_op (SImode, operands);"
1939 [(set (attr "length")
1940 (symbol_ref "compute_logical_op_length (SImode, operands)"))
1942 (symbol_ref "compute_logical_op_cc (SImode, operands)"))])
1944 (define_insn "*logicalhi3"
1945 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
1946 (match_operator:HI 3 "bit_operator"
1947 [(match_operand:HI 1 "h8300_dst_operand" "%0")
1948 (match_operand:HI 2 "h8300_src_operand" "rQi")]))]
1949 "h8300_operands_match_p (operands)"
1950 "* return output_logical_op (HImode, operands);"
1951 [(set (attr "length")
1952 (symbol_ref "compute_logical_op_length (HImode, operands)"))
1954 (symbol_ref "compute_logical_op_cc (HImode, operands)"))])
1956 (define_insn "*logicalsi3"
1957 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
1958 (match_operator:SI 3 "bit_operator"
1959 [(match_operand:SI 1 "h8300_dst_operand" "%0")
1960 (match_operand:SI 2 "h8300_src_operand" "rQi")]))]
1961 "h8300_operands_match_p (operands)"
1962 "* return output_logical_op (SImode, operands);"
1963 [(set (attr "length")
1964 (symbol_ref "compute_logical_op_length (SImode, operands)"))
1966 (symbol_ref "compute_logical_op_cc (SImode, operands)"))])
1968 ;; ----------------------------------------------------------------------
1969 ;; NEGATION INSTRUCTIONS
1970 ;; ----------------------------------------------------------------------
1972 (define_expand "negqi2"
1973 [(set (match_operand:QI 0 "register_operand" "")
1974 (neg:QI (match_operand:QI 1 "register_operand" "")))]
1978 (define_insn "*negqi2"
1979 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
1980 (neg:QI (match_operand:QI 1 "h8300_dst_operand" "0")))]
1983 [(set_attr "length_table" "unary")
1984 (set_attr "cc" "set_zn")])
1986 (define_expand "neghi2"
1987 [(set (match_operand:HI 0 "register_operand" "")
1988 (neg:HI (match_operand:HI 1 "register_operand" "")))]
1994 emit_insn (gen_neghi2_h8300 (operands[0], operands[1]));
1999 (define_expand "neghi2_h8300"
2001 (not:HI (match_operand:HI 1 "register_operand" "")))
2002 (set (match_dup 2) (plus:HI (match_dup 2) (const_int 1)))
2003 (set (match_operand:HI 0 "register_operand" "")
2006 "operands[2] = gen_reg_rtx (HImode);")
2008 (define_insn "*neghi2_h8300hs"
2009 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
2010 (neg:HI (match_operand:HI 1 "h8300_dst_operand" "0")))]
2011 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2013 [(set_attr "length_table" "unary")
2014 (set_attr "cc" "set_zn")])
2016 (define_expand "negsi2"
2017 [(set (match_operand:SI 0 "register_operand" "")
2018 (neg:SI (match_operand:SI 1 "register_operand" "")))]
2024 emit_insn (gen_negsi2_h8300 (operands[0], operands[1]));
2029 (define_expand "negsi2_h8300"
2031 (not:SI (match_operand:SI 1 "register_operand" "")))
2032 (set (match_dup 2) (plus:SI (match_dup 2) (const_int 1)))
2033 (set (match_operand:SI 0 "register_operand" "")
2036 "operands[2] = gen_reg_rtx (SImode);")
2038 (define_insn "*negsi2_h8300hs"
2039 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2040 (neg:SI (match_operand:SI 1 "h8300_dst_operand" "0")))]
2041 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2043 [(set_attr "length_table" "unary")
2044 (set_attr "cc" "set_zn")])
2046 (define_expand "negsf2"
2047 [(set (match_operand:SF 0 "register_operand" "")
2048 (neg:SF (match_operand:SF 1 "register_operand" "")))]
2052 (define_insn "*negsf2_h8300"
2053 [(set (match_operand:SF 0 "register_operand" "=r")
2054 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
2057 [(set_attr "length" "2")])
2059 (define_insn "*negsf2_h8300hs"
2060 [(set (match_operand:SF 0 "register_operand" "=r")
2061 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
2062 "TARGET_H8300H || TARGET_H8300S"
2063 "xor.w\\t#32768,%e0"
2064 [(set_attr "length" "4")])
2066 ;; ----------------------------------------------------------------------
2067 ;; ABSOLUTE VALUE INSTRUCTIONS
2068 ;; ----------------------------------------------------------------------
2070 (define_expand "abssf2"
2071 [(set (match_operand:SF 0 "register_operand" "")
2072 (abs:SF (match_operand:SF 1 "register_operand" "")))]
2076 (define_insn "*abssf2_h8300"
2077 [(set (match_operand:SF 0 "register_operand" "=r")
2078 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
2081 [(set_attr "length" "2")])
2083 (define_insn "*abssf2_h8300hs"
2084 [(set (match_operand:SF 0 "register_operand" "=r")
2085 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
2086 "TARGET_H8300H || TARGET_H8300S"
2087 "and.w\\t#32767,%e0"
2088 [(set_attr "length" "4")])
2090 ;; ----------------------------------------------------------------------
2092 ;; ----------------------------------------------------------------------
2094 (define_expand "one_cmplqi2"
2095 [(set (match_operand:QI 0 "register_operand" "")
2096 (not:QI (match_operand:QI 1 "register_operand" "")))]
2100 (define_insn "*one_cmplqi2"
2101 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
2102 (not:QI (match_operand:QI 1 "h8300_dst_operand" "0")))]
2105 [(set_attr "length_table" "unary")
2106 (set_attr "cc" "set_znv")])
2108 (define_expand "one_cmplhi2"
2109 [(set (match_operand:HI 0 "register_operand" "")
2110 (not:HI (match_operand:HI 1 "register_operand" "")))]
2114 (define_insn "*one_cmplhi2_h8300"
2115 [(set (match_operand:HI 0 "register_operand" "=r")
2116 (not:HI (match_operand:HI 1 "register_operand" "0")))]
2119 [(set_attr "length" "4")])
2121 (define_insn "*one_cmplhi2_h8300hs"
2122 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
2123 (not:HI (match_operand:HI 1 "h8300_dst_operand" "0")))]
2124 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2126 [(set_attr "cc" "set_znv")
2127 (set_attr "length_table" "unary")])
2129 (define_expand "one_cmplsi2"
2130 [(set (match_operand:SI 0 "register_operand" "")
2131 (not:SI (match_operand:SI 1 "register_operand" "")))]
2135 (define_insn "*one_cmplsi2_h8300"
2136 [(set (match_operand:SI 0 "register_operand" "=r")
2137 (not:SI (match_operand:SI 1 "register_operand" "0")))]
2139 "not %w0\;not %x0\;not %y0\;not %z0"
2140 [(set_attr "length" "8")])
2142 (define_insn "*one_cmplsi2_h8300hs"
2143 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2144 (not:SI (match_operand:SI 1 "h8300_dst_operand" "0")))]
2145 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2147 [(set_attr "cc" "set_znv")
2148 (set_attr "length_table" "unary")])
2150 ;; ----------------------------------------------------------------------
2151 ;; JUMP INSTRUCTIONS
2152 ;; ----------------------------------------------------------------------
2154 ;; Conditional jump instructions
2156 (define_expand "ble"
2157 [(match_operand 0 "" "")]
2159 "h8300_expand_branch (LE, operands[0]); DONE;")
2161 (define_expand "bleu"
2162 [(match_operand 0 "" "")]
2164 "h8300_expand_branch (LEU, operands[0]); DONE;")
2166 (define_expand "bge"
2167 [(match_operand 0 "" "")]
2169 "h8300_expand_branch (GE, operands[0]); DONE;")
2171 (define_expand "bgeu"
2172 [(match_operand 0 "" "")]
2174 "h8300_expand_branch (GEU, operands[0]); DONE;")
2176 (define_expand "blt"
2177 [(match_operand 0 "" "")]
2179 "h8300_expand_branch (LT, operands[0]); DONE;")
2181 (define_expand "bltu"
2182 [(match_operand 0 "" "")]
2184 "h8300_expand_branch (LTU, operands[0]); DONE;")
2186 (define_expand "bgt"
2187 [(match_operand 0 "" "")]
2189 "h8300_expand_branch (GT, operands[0]); DONE;")
2191 (define_expand "bgtu"
2192 [(match_operand 0 "" "")]
2194 "h8300_expand_branch (GTU, operands[0]); DONE;")
2196 (define_expand "beq"
2197 [(match_operand 0 "" "")]
2199 "h8300_expand_branch (EQ, operands[0]); DONE;")
2201 (define_expand "bne"
2202 [(match_operand 0 "" "")]
2204 "h8300_expand_branch (NE, operands[0]); DONE;")
2206 (define_insn "branch_true"
2208 (if_then_else (match_operator 1 "comparison_operator"
2209 [(cc0) (const_int 0)])
2210 (label_ref (match_operand 0 "" ""))
2215 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
2216 && (GET_CODE (operands[1]) == GT
2217 || GET_CODE (operands[1]) == GE
2218 || GET_CODE (operands[1]) == LE
2219 || GET_CODE (operands[1]) == LT))
2221 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
2225 if (get_attr_length (insn) == 2)
2226 return \"b%j1 %l0\";
2227 else if (get_attr_length (insn) == 4)
2228 return \"b%j1 %l0:16\";
2230 return \"b%k1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
2232 [(set_attr "type" "branch")
2233 (set_attr "cc" "none")])
2235 (define_insn "branch_false"
2237 (if_then_else (match_operator 1 "comparison_operator"
2238 [(cc0) (const_int 0)])
2240 (label_ref (match_operand 0 "" ""))))]
2244 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
2245 && (GET_CODE (operands[1]) == GT
2246 || GET_CODE (operands[1]) == GE
2247 || GET_CODE (operands[1]) == LE
2248 || GET_CODE (operands[1]) == LT))
2250 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
2254 if (get_attr_length (insn) == 2)
2255 return \"b%k1 %l0\";
2256 else if (get_attr_length (insn) == 4)
2257 return \"b%k1 %l0:16\";
2259 return \"b%j1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
2261 [(set_attr "type" "branch")
2262 (set_attr "cc" "none")])
2264 (define_insn "*brabc"
2267 (eq (zero_extract (match_operand:QI 1 "bit_memory_operand" "WU")
2269 (match_operand:QI 2 "immediate_operand" "n"))
2271 (label_ref (match_operand 0 "" ""))
2276 switch (get_attr_length (insn)
2277 - h8300_insn_length_from_table (insn, operands))
2280 return \"bra/bc %2,%R1,%l0\";
2283 return \"bra/bc %2,%R1,%l0:16\";
2286 return \"bra/bs %2,%R1,.Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
2289 [(set_attr "type" "bitbranch")
2290 (set_attr "length_table" "bitbranch")
2291 (set_attr "cc" "none")])
2293 (define_insn "*brabs"
2296 (ne (zero_extract (match_operand:QI 1 "bit_memory_operand" "WU")
2298 (match_operand:QI 2 "immediate_operand" "n"))
2300 (label_ref (match_operand 0 "" ""))
2305 switch (get_attr_length (insn)
2306 - h8300_insn_length_from_table (insn, operands))
2309 return \"bra/bs %2,%R1,%l0\";
2312 return \"bra/bs %2,%R1,%l0:16\";
2315 return \"bra/bc %2,%R1,.Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
2318 [(set_attr "type" "bitbranch")
2319 (set_attr "length_table" "bitbranch")
2320 (set_attr "cc" "none")])
2322 ;; Unconditional and other jump instructions.
2326 (label_ref (match_operand 0 "" "")))]
2330 if (final_sequence != 0)
2332 if (get_attr_length (insn) == 2)
2333 return \"bra/s %l0\";
2336 /* The branch isn't short enough to use bra/s. Output the
2337 branch and delay slot in their normal order.
2339 If this is a backward branch, it will now be branching two
2340 bytes further than previously thought. The length-based
2341 test for bra vs. jump is very conservative though, so the
2342 branch will still be within range. */
2346 vec = XVEC (final_sequence, 0);
2348 final_scan_insn (RTVEC_ELT (vec, 1), asm_out_file, optimize, 0, 1, & seen);
2349 final_scan_insn (RTVEC_ELT (vec, 0), asm_out_file, optimize, 0, 1, & seen);
2350 INSN_DELETED_P (RTVEC_ELT (vec, 1)) = 1;
2354 else if (get_attr_length (insn) == 2)
2356 else if (get_attr_length (insn) == 4)
2357 return \"bra %l0:16\";
2359 return \"jmp @%l0\";
2361 [(set_attr "type" "branch")
2362 (set (attr "delay_slot")
2363 (if_then_else (ne (symbol_ref "TARGET_H8300SX") (const_int 0))
2364 (const_string "jump")
2365 (const_string "none")))
2366 (set_attr "cc" "none")])
2368 ;; This is a define expand, because pointers may be either 16 or 32 bits.
2370 (define_expand "tablejump"
2371 [(parallel [(set (pc) (match_operand 0 "register_operand" ""))
2372 (use (label_ref (match_operand 1 "" "")))])]
2376 (define_insn "*tablejump_h8300"
2377 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
2378 (use (label_ref (match_operand 1 "" "")))]
2381 [(set_attr "cc" "none")
2382 (set_attr "length" "2")])
2384 (define_insn "*tablejump_h8300hs_advanced"
2385 [(set (pc) (match_operand:SI 0 "register_operand" "r"))
2386 (use (label_ref (match_operand 1 "" "")))]
2387 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE"
2389 [(set_attr "cc" "none")
2390 (set_attr "length" "2")])
2392 (define_insn "*tablejump_h8300hs_normal"
2393 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
2394 (use (label_ref (match_operand 1 "" "")))]
2395 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
2397 [(set_attr "cc" "none")
2398 (set_attr "length" "2")])
2400 ;; This is a define expand, because pointers may be either 16 or 32 bits.
2402 (define_expand "indirect_jump"
2403 [(set (pc) (match_operand 0 "jump_address_operand" ""))]
2407 (define_insn "*indirect_jump_h8300"
2408 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
2411 [(set_attr "cc" "none")
2412 (set_attr "length" "2")])
2414 (define_insn "*indirect_jump_h8300hs_advanced"
2415 [(set (pc) (match_operand:SI 0 "jump_address_operand" "Vr"))]
2416 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE"
2418 [(set_attr "cc" "none")
2419 (set_attr "length" "2")])
2421 (define_insn "*indirect_jump_h8300hs_normal"
2422 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
2423 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
2425 [(set_attr "cc" "none")
2426 (set_attr "length" "2")])
2428 ;; Call subroutine with no return value.
2430 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
2433 [(call (match_operand:QI 0 "call_insn_operand" "or")
2434 (match_operand:HI 1 "general_operand" "g"))]
2438 if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
2439 && SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
2440 return \"jsr\\t@%0:8\";
2442 return \"jsr\\t%0\";
2444 [(set_attr "type" "call")
2445 (set (attr "length")
2446 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
2450 ;; Call subroutine, returning value in operand 0
2451 ;; (which must be a hard register).
2453 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
2455 (define_insn "call_value"
2456 [(set (match_operand 0 "" "=r")
2457 (call (match_operand:QI 1 "call_insn_operand" "or")
2458 (match_operand:HI 2 "general_operand" "g")))]
2462 if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2463 && SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
2464 return \"jsr\\t@%1:8\";
2466 return \"jsr\\t%1\";
2468 [(set_attr "type" "call")
2469 (set (attr "length")
2470 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
2478 [(set_attr "cc" "none")
2479 (set_attr "length" "2")])
2481 ;; ----------------------------------------------------------------------
2482 ;; PROLOGUE/EPILOGUE-RELATED INSTRUCTIONS
2483 ;; ----------------------------------------------------------------------
2485 (define_expand "push_h8300"
2486 [(set (mem:HI (pre_dec:HI (reg:HI SP_REG)))
2487 (match_operand:HI 0 "register_operand" ""))]
2491 (define_expand "push_h8300hs_advanced"
2492 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
2493 (match_operand:SI 0 "register_operand" ""))]
2494 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
2497 (define_expand "push_h8300hs_normal"
2498 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
2499 (match_operand:SI 0 "register_operand" ""))]
2500 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
2503 (define_expand "pop_h8300"
2504 [(set (match_operand:HI 0 "register_operand" "")
2505 (mem:HI (post_inc:HI (reg:HI SP_REG))))]
2509 (define_expand "pop_h8300hs_advanced"
2510 [(set (match_operand:SI 0 "register_operand" "")
2511 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
2512 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
2515 (define_expand "pop_h8300hs_normal"
2516 [(set (match_operand:SI 0 "register_operand" "")
2517 (mem:SI (post_inc:HI (reg:HI SP_REG))))]
2518 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
2521 (define_insn "ldm_h8300sx"
2522 [(match_parallel 0 "h8300_ldm_parallel"
2523 [(set (match_operand:SI 1 "register_operand" "")
2524 (match_operand:SI 2 "memory_operand" ""))])]
2527 operands[3] = SET_DEST (XVECEXP (operands[0], 0,
2528 XVECLEN (operands[0], 0) - 2));
2529 return "ldm.l\t@er7+,%S1-%S3";
2531 [(set_attr "cc" "none")
2532 (set_attr "length" "4")])
2534 (define_insn "stm_h8300sx"
2535 [(match_parallel 0 "h8300_stm_parallel"
2536 [(set (match_operand:SI 1 "memory_operand" "")
2537 (match_operand:SI 2 "register_operand" ""))])]
2540 operands[3] = SET_SRC (XVECEXP (operands[0], 0,
2541 XVECLEN (operands[0], 0) - 2));
2542 return "stm.l\t%S2-%S3,@-er7";
2544 [(set_attr "cc" "none")
2545 (set_attr "length" "4")])
2547 (define_insn "return_h8sx"
2548 [(match_parallel 0 "h8300_return_parallel"
2550 (set (match_operand:SI 1 "register_operand" "")
2551 (match_operand:SI 2 "memory_operand" ""))])]
2554 operands[3] = SET_DEST (XVECEXP (operands[0], 0,
2555 XVECLEN (operands[0], 0) - 2));
2556 if (h8300_current_function_interrupt_function_p ())
2557 return "rte/l\t%S1-%S3";
2559 return "rts/l\t%S1-%S3";
2561 [(set_attr "cc" "none")
2562 (set_attr "can_delay" "no")
2563 (set_attr "length" "2")])
2565 (define_expand "return"
2567 "h8300_can_use_return_insn_p ()"
2570 (define_insn "*return_1"
2575 if (h8300_current_function_interrupt_function_p ())
2580 [(set_attr "cc" "none")
2581 (set_attr "can_delay" "no")
2582 (set_attr "length" "2")])
2584 (define_expand "prologue"
2587 "h8300_expand_prologue (); DONE;")
2589 (define_expand "epilogue"
2592 "h8300_expand_epilogue (); DONE;")
2594 (define_insn "monitor_prologue"
2595 [(unspec_volatile [(const_int 0)] UNSPEC_MONITOR)]
2600 return \"subs\\t#2,r7\;mov.w\\tr0,@-r7\;stc\\tccr,r0l\;mov.b\tr0l,@(2,r7)\;mov.w\\t@r7+,r0\;orc\t#128,ccr\";
2601 else if (TARGET_H8300H)
2602 return \"mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\\t#128,ccr\";
2603 else if (TARGET_H8300S)
2604 return \"stc\texr,@-er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(6,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr\";
2607 [(set_attr "length" "20")])
2609 ;; ----------------------------------------------------------------------
2610 ;; EXTEND INSTRUCTIONS
2611 ;; ----------------------------------------------------------------------
2613 (define_expand "zero_extendqihi2"
2614 [(set (match_operand:HI 0 "register_operand" "")
2615 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2619 (define_insn "*zero_extendqihi2_h8300"
2620 [(set (match_operand:HI 0 "register_operand" "=r,r")
2621 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2626 [(set_attr "length" "2,10")])
2628 (define_insn "*zero_extendqihi2_h8300hs"
2629 [(set (match_operand:HI 0 "register_operand" "=r,r")
2630 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2631 "TARGET_H8300H || TARGET_H8300S"
2635 [(set_attr "length" "2,10")
2636 (set_attr "cc" "set_znv,set_znv")])
2638 ;; Split the zero extension of a general operand (actually a memory
2639 ;; operand) into a load of the operand and the actual zero extension
2640 ;; so that 1) the length will be accurate, and 2) the zero extensions
2641 ;; appearing at the end of basic blocks may be merged.
2644 [(set (match_operand:HI 0 "register_operand" "")
2645 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2650 (zero_extend:HI (match_dup 2)))]
2651 "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
2653 (define_expand "zero_extendqisi2"
2654 [(set (match_operand:SI 0 "register_operand" "")
2655 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2659 operands[1] = force_reg (QImode, operands[1]);
2662 (define_insn "*zero_extendqisi2_h8300"
2663 [(set (match_operand:SI 0 "register_operand" "=r,r")
2664 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2667 mov.b #0,%x0\;sub.w %e0,%e0
2668 mov.b %R1,%w0\;mov.b #0,%x0\;sub.w %e0,%e0"
2669 [(set_attr "length" "4,8")])
2671 (define_insn "*zero_extendqisi2_h8300hs"
2672 [(set (match_operand:SI 0 "register_operand" "=r,r")
2673 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2674 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX"
2678 [(set (match_operand:SI 0 "register_operand" "")
2679 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2680 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
2681 && reg_overlap_mentioned_p (operands[0], operands[1])
2682 && reload_completed"
2686 (zero_extend:HI (match_dup 2)))
2688 (zero_extend:SI (match_dup 3)))]
2689 "operands[2] = gen_lowpart (QImode, operands[0]);
2690 operands[3] = gen_lowpart (HImode, operands[0]);")
2693 [(set (match_operand:SI 0 "register_operand" "")
2694 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2695 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
2696 && !reg_overlap_mentioned_p (operands[0], operands[1])
2697 && reload_completed"
2700 (set (strict_low_part (match_dup 2))
2702 "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
2704 (define_insn "*zero_extendqisi2_h8sx"
2705 [(set (match_operand:SI 0 "register_operand" "=r")
2706 (zero_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2709 [(set_attr "length" "2")
2710 (set_attr "cc" "set_znv")])
2712 (define_expand "zero_extendhisi2"
2713 [(set (match_operand:SI 0 "register_operand" "")
2714 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
2718 ;; %e prints the high part of a CONST_INT, not the low part. Arggh.
2719 (define_insn "*zero_extendhisi2_h8300"
2720 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2721 (zero_extend:SI (match_operand:HI 1 "general_operand_src" "0,i,g>")))]
2725 mov.w %f1,%f0\;sub.w %e0,%e0
2726 mov.w %e1,%f0\;sub.w %e0,%e0"
2727 [(set_attr "length" "2,4,6")])
2729 (define_insn "*zero_extendhisi2_h8300hs"
2730 [(set (match_operand:SI 0 "register_operand" "=r")
2731 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2732 "TARGET_H8300H || TARGET_H8300S"
2734 [(set_attr "length" "2")
2735 (set_attr "cc" "set_znv")])
2737 (define_expand "extendqihi2"
2738 [(set (match_operand:HI 0 "register_operand" "")
2739 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
2743 (define_insn "*extendqihi2_h8300"
2744 [(set (match_operand:HI 0 "register_operand" "=r,r")
2745 (sign_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2748 bld #7,%s0\;subx %t0,%t0
2749 mov.b %R1,%s0\;bld #7,%s0\;subx %t0,%t0"
2750 [(set_attr "length" "4,8")])
2752 (define_insn "*extendqihi2_h8300hs"
2753 [(set (match_operand:HI 0 "register_operand" "=r")
2754 (sign_extend:HI (match_operand:QI 1 "register_operand" "0")))]
2755 "TARGET_H8300H || TARGET_H8300S"
2757 [(set_attr "length" "2")
2758 (set_attr "cc" "set_znv")])
2760 (define_expand "extendqisi2"
2761 [(set (match_operand:SI 0 "register_operand" "")
2762 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
2766 (define_insn "*extendqisi2_h8300"
2767 [(set (match_operand:SI 0 "register_operand" "=r,r")
2768 (sign_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2771 bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0
2772 mov.b %R1,%w0\;bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0"
2773 [(set_attr "length" "8,12")])
2775 ;; The following pattern is needed because without the pattern, the
2776 ;; combiner would split (sign_extend:SI (reg:QI)) into into two 24-bit
2777 ;; shifts, one ashift and one ashiftrt.
2779 (define_insn_and_split "*extendqisi2_h8300hs"
2780 [(set (match_operand:SI 0 "register_operand" "=r")
2781 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2782 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX"
2784 "&& reload_completed"
2786 (sign_extend:HI (match_dup 1)))
2788 (sign_extend:SI (match_dup 2)))]
2789 "operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));")
2791 (define_insn "*extendqisi2_h8sx"
2792 [(set (match_operand:SI 0 "register_operand" "=r")
2793 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2796 [(set_attr "length" "2")
2797 (set_attr "cc" "set_znv")])
2799 (define_expand "extendhisi2"
2800 [(set (match_operand:SI 0 "register_operand" "")
2801 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
2805 (define_insn "*extendhisi2_h8300"
2806 [(set (match_operand:SI 0 "register_operand" "=r,r")
2807 (sign_extend:SI (match_operand:HI 1 "general_operand_src" "0,g>")))]
2810 bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0
2811 mov.w %T1,%f0\;bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0"
2812 [(set_attr "length" "6,10")])
2814 (define_insn "*extendhisi2_h8300hs"
2815 [(set (match_operand:SI 0 "register_operand" "=r")
2816 (sign_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2817 "TARGET_H8300H || TARGET_H8300S"
2819 [(set_attr "length" "2")
2820 (set_attr "cc" "set_znv")])
2822 ;; ----------------------------------------------------------------------
2824 ;; ----------------------------------------------------------------------
2826 ;; We make some attempt to provide real efficient shifting. One example is
2827 ;; doing an 8 bit shift of a 16 bit value by moving a byte reg into the other
2828 ;; reg and moving 0 into the former reg.
2830 ;; We also try to achieve this in a uniform way. IE: We don't try to achieve
2831 ;; this in both rtl and at insn emit time. Ideally, we'd use rtl as that would
2832 ;; give the optimizer more cracks at the code. However, we wish to do things
2833 ;; like optimizing shifting the sign bit to bit 0 by rotating the other way.
2834 ;; There is rtl to handle this (rotate + and), but the H8/300 doesn't handle
2835 ;; 16 bit rotates. Also, if we emit complicated rtl, combine may not be able
2836 ;; to detect cases it can optimize.
2838 ;; For these and other fuzzy reasons, I've decided to go the less pretty but
2839 ;; easier "do it at insn emit time" route.
2843 (define_expand "ashlqi3"
2844 [(set (match_operand:QI 0 "register_operand" "")
2845 (ashift:QI (match_operand:QI 1 "register_operand" "")
2846 (match_operand:QI 2 "nonmemory_operand" "")))]
2848 "if (expand_a_shift (QImode, ASHIFT, operands)) DONE;")
2850 (define_expand "ashrqi3"
2851 [(set (match_operand:QI 0 "register_operand" "")
2852 (ashiftrt:QI (match_operand:QI 1 "register_operand" "")
2853 (match_operand:QI 2 "nonmemory_operand" "")))]
2855 "if (expand_a_shift (QImode, ASHIFTRT, operands)) DONE;")
2857 (define_expand "lshrqi3"
2858 [(set (match_operand:QI 0 "register_operand" "")
2859 (lshiftrt:QI (match_operand:QI 1 "register_operand" "")
2860 (match_operand:QI 2 "nonmemory_operand" "")))]
2862 "if (expand_a_shift (QImode, LSHIFTRT, operands)) DONE;")
2865 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
2866 (match_operator:QI 3 "h8sx_unary_shift_operator"
2867 [(match_operand:QI 1 "h8300_dst_operand" "0")
2868 (match_operand:QI 2 "const_int_operand" "")]))]
2869 "h8300_operands_match_p (operands)"
2870 { return output_h8sx_shift (operands, 'b', 'X'); }
2871 [(set_attr "length_table" "unary")
2872 (set_attr "cc" "set_znv")])
2875 [(set (match_operand:QI 0 "register_operand" "=r")
2876 (match_operator:QI 3 "h8sx_binary_shift_operator"
2877 [(match_operand:QI 1 "register_operand" "0")
2878 (match_operand:QI 2 "nonmemory_operand" "r P3>X")]))]
2880 { return output_h8sx_shift (operands, 'b', 'X'); }
2881 [(set_attr "length" "4")
2882 (set_attr "cc" "set_znv")])
2884 (define_insn "*shiftqi"
2885 [(set (match_operand:QI 0 "register_operand" "=r,r")
2886 (match_operator:QI 3 "nshift_operator"
2887 [ (match_operand:QI 1 "register_operand" "0,0")
2888 (match_operand:QI 2 "nonmemory_operand" "R,rn")]))
2889 (clobber (match_scratch:QI 4 "=X,&r"))]
2891 "* return output_a_shift (operands);"
2892 [(set (attr "length")
2893 (symbol_ref "compute_a_shift_length (insn, operands)"))
2895 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2899 (define_expand "ashlhi3"
2900 [(set (match_operand:HI 0 "register_operand" "")
2901 (ashift:HI (match_operand:HI 1 "register_operand" "")
2902 (match_operand:QI 2 "nonmemory_operand" "")))]
2904 "if (expand_a_shift (HImode, ASHIFT, operands)) DONE;")
2906 (define_expand "lshrhi3"
2907 [(set (match_operand:HI 0 "register_operand" "")
2908 (lshiftrt:HI (match_operand:HI 1 "register_operand" "")
2909 (match_operand:QI 2 "nonmemory_operand" "")))]
2911 "if (expand_a_shift (HImode, LSHIFTRT, operands)) DONE;")
2913 (define_expand "ashrhi3"
2914 [(set (match_operand:HI 0 "register_operand" "")
2915 (ashiftrt:HI (match_operand:HI 1 "register_operand" "")
2916 (match_operand:QI 2 "nonmemory_operand" "")))]
2918 "if (expand_a_shift (HImode, ASHIFTRT, operands)) DONE;")
2921 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
2922 (match_operator:HI 3 "h8sx_unary_shift_operator"
2923 [(match_operand:HI 1 "h8300_dst_operand" "0")
2924 (match_operand:QI 2 "const_int_operand" "")]))]
2925 "h8300_operands_match_p (operands)"
2926 { return output_h8sx_shift (operands, 'w', 'T'); }
2927 [(set_attr "length_table" "unary")
2928 (set_attr "cc" "set_znv")])
2931 [(set (match_operand:HI 0 "register_operand" "=r")
2932 (match_operator:HI 3 "h8sx_binary_shift_operator"
2933 [(match_operand:HI 1 "register_operand" "0")
2934 (match_operand:QI 2 "nonmemory_operand" "r P4>X")]))]
2936 { return output_h8sx_shift (operands, 'w', 'T'); }
2937 [(set_attr "length" "4")
2938 (set_attr "cc" "set_znv")])
2940 (define_insn "*shifthi"
2941 [(set (match_operand:HI 0 "register_operand" "=r,r")
2942 (match_operator:HI 3 "nshift_operator"
2943 [ (match_operand:HI 1 "register_operand" "0,0")
2944 (match_operand:QI 2 "nonmemory_operand" "S,rn")]))
2945 (clobber (match_scratch:QI 4 "=X,&r"))]
2947 "* return output_a_shift (operands);"
2948 [(set (attr "length")
2949 (symbol_ref "compute_a_shift_length (insn, operands)"))
2951 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2955 (define_expand "ashlsi3"
2956 [(set (match_operand:SI 0 "register_operand" "")
2957 (ashift:SI (match_operand:SI 1 "register_operand" "")
2958 (match_operand:QI 2 "nonmemory_operand" "")))]
2960 "if (expand_a_shift (SImode, ASHIFT, operands)) DONE;")
2962 (define_expand "lshrsi3"
2963 [(set (match_operand:SI 0 "register_operand" "")
2964 (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
2965 (match_operand:QI 2 "nonmemory_operand" "")))]
2967 "if (expand_a_shift (SImode, LSHIFTRT, operands)) DONE;")
2969 (define_expand "ashrsi3"
2970 [(set (match_operand:SI 0 "register_operand" "")
2971 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
2972 (match_operand:QI 2 "nonmemory_operand" "")))]
2974 "if (expand_a_shift (SImode, ASHIFTRT, operands)) DONE;")
2977 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2978 (match_operator:SI 3 "h8sx_unary_shift_operator"
2979 [(match_operand:SI 1 "h8300_dst_operand" "0")
2980 (match_operand:QI 2 "const_int_operand" "")]))]
2981 "h8300_operands_match_p (operands)"
2982 { return output_h8sx_shift (operands, 'l', 'S'); }
2983 [(set_attr "length_table" "unary")
2984 (set_attr "cc" "set_znv")])
2987 [(set (match_operand:SI 0 "register_operand" "=r")
2988 (match_operator:SI 3 "h8sx_binary_shift_operator"
2989 [(match_operand:SI 1 "register_operand" "0")
2990 (match_operand:QI 2 "nonmemory_operand" "r P5>X")]))]
2992 { return output_h8sx_shift (operands, 'l', 'S'); }
2993 [(set_attr "length" "4")
2994 (set_attr "cc" "set_znv")])
2996 (define_insn "*shiftsi"
2997 [(set (match_operand:SI 0 "register_operand" "=r,r")
2998 (match_operator:SI 3 "nshift_operator"
2999 [ (match_operand:SI 1 "register_operand" "0,0")
3000 (match_operand:QI 2 "nonmemory_operand" "T,rn")]))
3001 (clobber (match_scratch:QI 4 "=X,&r"))]
3003 "* return output_a_shift (operands);"
3004 [(set (attr "length")
3005 (symbol_ref "compute_a_shift_length (insn, operands)"))
3007 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
3009 ;; Split a variable shift into a loop. If the register containing
3010 ;; the shift count dies, then we just use that register.
3013 [(set (match_operand 0 "register_operand" "")
3014 (match_operator 2 "nshift_operator"
3016 (match_operand:QI 1 "register_operand" "")]))
3017 (clobber (match_operand:QI 3 "register_operand" ""))]
3019 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
3023 (if_then_else (le (cc0) (const_int 0))
3024 (label_ref (match_dup 5))
3029 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
3030 (clobber (scratch:QI))])
3032 (plus:QI (match_dup 1) (const_int -1)))
3036 (if_then_else (ne (cc0) (const_int 0))
3037 (label_ref (match_dup 4))
3040 "operands[4] = gen_label_rtx ();
3041 operands[5] = gen_label_rtx ();")
3044 [(set (match_operand 0 "register_operand" "")
3045 (match_operator 2 "nshift_operator"
3047 (match_operand:QI 1 "register_operand" "")]))
3048 (clobber (match_operand:QI 3 "register_operand" ""))]
3050 && !find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
3056 (if_then_else (le (cc0) (const_int 0))
3057 (label_ref (match_dup 5))
3062 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
3063 (clobber (scratch:QI))])
3065 (plus:QI (match_dup 3) (const_int -1)))
3069 (if_then_else (ne (cc0) (const_int 0))
3070 (label_ref (match_dup 4))
3073 "operands[4] = gen_label_rtx ();
3074 operands[5] = gen_label_rtx ();")
3076 ;; ----------------------------------------------------------------------
3078 ;; ----------------------------------------------------------------------
3080 (define_expand "rotlqi3"
3081 [(set (match_operand:QI 0 "register_operand" "")
3082 (rotate:QI (match_operand:QI 1 "register_operand" "")
3083 (match_operand:QI 2 "nonmemory_operand" "")))]
3085 "if (expand_a_rotate (operands)) DONE;")
3087 (define_insn "rotlqi3_1"
3088 [(set (match_operand:QI 0 "register_operand" "=r")
3089 (rotate:QI (match_operand:QI 1 "register_operand" "0")
3090 (match_operand:QI 2 "immediate_operand" "")))]
3092 "* return output_a_rotate (ROTATE, operands);"
3093 [(set (attr "length")
3094 (symbol_ref "compute_a_rotate_length (operands)"))])
3096 (define_expand "rotlhi3"
3097 [(set (match_operand:HI 0 "register_operand" "")
3098 (rotate:HI (match_operand:HI 1 "register_operand" "")
3099 (match_operand:QI 2 "nonmemory_operand" "")))]
3101 "if (expand_a_rotate (operands)) DONE;")
3103 (define_insn "rotlhi3_1"
3104 [(set (match_operand:HI 0 "register_operand" "=r")
3105 (rotate:HI (match_operand:HI 1 "register_operand" "0")
3106 (match_operand:QI 2 "immediate_operand" "")))]
3108 "* return output_a_rotate (ROTATE, operands);"
3109 [(set (attr "length")
3110 (symbol_ref "compute_a_rotate_length (operands)"))])
3112 (define_expand "rotlsi3"
3113 [(set (match_operand:SI 0 "register_operand" "")
3114 (rotate:SI (match_operand:SI 1 "register_operand" "")
3115 (match_operand:QI 2 "nonmemory_operand" "")))]
3116 "TARGET_H8300H || TARGET_H8300S"
3117 "if (expand_a_rotate (operands)) DONE;")
3119 (define_insn "rotlsi3_1"
3120 [(set (match_operand:SI 0 "register_operand" "=r")
3121 (rotate:SI (match_operand:SI 1 "register_operand" "0")
3122 (match_operand:QI 2 "immediate_operand" "")))]
3123 "TARGET_H8300H || TARGET_H8300S"
3124 "* return output_a_rotate (ROTATE, operands);"
3125 [(set (attr "length")
3126 (symbol_ref "compute_a_rotate_length (operands)"))])
3128 ;; -----------------------------------------------------------------
3130 ;; -----------------------------------------------------------------
3131 ;; The H8/300 has given 1/8th of its opcode space to bitfield
3132 ;; instructions so let's use them as well as we can.
3134 ;; You'll never believe all these patterns perform one basic action --
3135 ;; load a bit from the source, optionally invert the bit, then store it
3136 ;; in the destination (which is known to be zero).
3138 ;; Combine obviously need some work to better identify this situation and
3139 ;; canonicalize the form better.
3142 ;; Normal loads with a 16bit destination.
3146 [(set (match_operand:HI 0 "register_operand" "=&r")
3147 (zero_extract:HI (match_operand:HI 1 "register_operand" "r")
3149 (match_operand:HI 2 "immediate_operand" "n")))]
3151 "sub.w %0,%0\;bld %Z2,%Y1\;bst #0,%X0"
3152 [(set_attr "length" "6")])
3155 ;; Inverted loads with a 16bit destination.
3159 [(set (match_operand:HI 0 "register_operand" "=&r")
3160 (zero_extract:HI (xor:HI (match_operand:HI 1 "register_operand" "r")
3161 (match_operand:HI 3 "const_int_operand" "n"))
3163 (match_operand:HI 2 "const_int_operand" "n")))]
3165 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
3166 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
3167 [(set_attr "length" "8")])
3170 ;; Normal loads with a 32bit destination.
3173 (define_insn "*extzv_1_r_h8300"
3174 [(set (match_operand:SI 0 "register_operand" "=&r")
3175 (zero_extract:SI (match_operand:HI 1 "register_operand" "r")
3177 (match_operand 2 "const_int_operand" "n")))]
3179 && INTVAL (operands[2]) < 16"
3180 "* return output_simode_bld (0, operands);"
3181 [(set_attr "length" "8")])
3183 (define_insn "*extzv_1_r_h8300hs"
3184 [(set (match_operand:SI 0 "register_operand" "=r,r")
3185 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
3187 (match_operand 2 "const_int_operand" "n,n")))]
3188 "(TARGET_H8300H || TARGET_H8300S)
3189 && INTVAL (operands[2]) < 16"
3190 "* return output_simode_bld (0, operands);"
3191 [(set_attr "cc" "set_znv,set_znv")
3192 (set_attr "length" "8,6")])
3195 ;; Inverted loads with a 32bit destination.
3198 (define_insn "*extzv_1_r_inv_h8300"
3199 [(set (match_operand:SI 0 "register_operand" "=&r")
3200 (zero_extract:SI (xor:HI (match_operand:HI 1 "register_operand" "r")
3201 (match_operand:HI 3 "const_int_operand" "n"))
3203 (match_operand 2 "const_int_operand" "n")))]
3205 && INTVAL (operands[2]) < 16
3206 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
3207 "* return output_simode_bld (1, operands);"
3208 [(set_attr "length" "8")])
3210 (define_insn "*extzv_1_r_inv_h8300hs"
3211 [(set (match_operand:SI 0 "register_operand" "=r,r")
3212 (zero_extract:SI (xor:SI (match_operand:SI 1 "register_operand" "?0,r")
3213 (match_operand 3 "const_int_operand" "n,n"))
3215 (match_operand 2 "const_int_operand" "n,n")))]
3216 "(TARGET_H8300H || TARGET_H8300S)
3217 && INTVAL (operands[2]) < 16
3218 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
3219 "* return output_simode_bld (1, operands);"
3220 [(set_attr "cc" "set_znv,set_znv")
3221 (set_attr "length" "8,6")])
3223 (define_expand "insv"
3224 [(set (zero_extract:HI (match_operand:HI 0 "general_operand" "")
3225 (match_operand:HI 1 "general_operand" "")
3226 (match_operand:HI 2 "general_operand" ""))
3227 (match_operand:HI 3 "general_operand" ""))]
3228 "TARGET_H8300 || TARGET_H8300SX"
3233 if (GET_CODE (operands[1]) == CONST_INT
3234 && GET_CODE (operands[2]) == CONST_INT
3235 && INTVAL (operands[1]) <= 8
3236 && INTVAL (operands[2]) >= 0
3237 && INTVAL (operands[1]) + INTVAL (operands[2]) <= 8
3238 && memory_operand (operands[0], GET_MODE (operands[0])))
3240 /* If the source operand is zero, it's better to use AND rather
3241 than BFST. Likewise OR if the operand is all ones. */
3242 if (GET_CODE (operands[3]) == CONST_INT)
3244 HOST_WIDE_INT mask = (1 << INTVAL (operands[1])) - 1;
3245 if ((INTVAL (operands[3]) & mask) == 0)
3247 if ((INTVAL (operands[3]) & mask) == mask)
3250 if (! bit_memory_operand (operands[0], GET_MODE (operands[0])))
3255 replace_equiv_address (operands[0],
3257 XEXP (operands[0], 0)));
3259 operands[3] = gen_lowpart (QImode, operands[3]);
3262 if (! register_operand (operands[3], QImode))
3266 operands[3] = force_reg (QImode, operands[3]);
3268 emit_insn (gen_bfst (adjust_address (operands[0], QImode, 0),
3269 operands[3], operands[1], operands[2]));
3276 /* We only have single bit bit-field instructions. */
3277 if (INTVAL (operands[1]) != 1)
3280 /* For now, we don't allow memory operands. */
3281 if (GET_CODE (operands[0]) == MEM
3282 || GET_CODE (operands[3]) == MEM)
3287 [(set (zero_extract:HI (match_operand:HI 0 "register_operand" "+r")
3289 (match_operand:HI 1 "immediate_operand" "n"))
3290 (match_operand:HI 2 "register_operand" "r"))]
3292 "bld #0,%R2\;bst %Z1,%Y0 ; i1"
3293 [(set_attr "length" "4")])
3295 (define_expand "extzv"
3296 [(set (match_operand:HI 0 "register_operand" "")
3297 (zero_extract:HI (match_operand:HI 1 "bit_operand" "")
3298 (match_operand:HI 2 "general_operand" "")
3299 (match_operand:HI 3 "general_operand" "")))]
3300 "TARGET_H8300 || TARGET_H8300SX"
3305 if (GET_CODE (operands[2]) == CONST_INT
3306 && GET_CODE (operands[3]) == CONST_INT
3307 && INTVAL (operands[2]) <= 8
3308 && INTVAL (operands[3]) >= 0
3309 && INTVAL (operands[2]) + INTVAL (operands[3]) <= 8
3310 && memory_operand (operands[1], QImode))
3314 /* Optimize the case where we're extracting into a paradoxical
3315 subreg. It's only necessary to extend to the inner reg. */
3316 if (GET_CODE (operands[0]) == SUBREG
3317 && subreg_lowpart_p (operands[0])
3318 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0])))
3319 < GET_MODE_SIZE (GET_MODE (operands[0])))
3320 && (GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0])))
3322 operands[0] = SUBREG_REG (operands[0]);
3325 temp = gen_lowpart (QImode, operands[0]);
3327 temp = gen_reg_rtx (QImode);
3330 if (! bit_memory_operand (operands[1], QImode))
3335 replace_equiv_address (operands[1],
3337 XEXP (operands[1], 0)));
3339 emit_insn (gen_bfld (temp, operands[1], operands[2], operands[3]));
3340 convert_move (operands[0], temp, 1);
3346 /* We only have single bit bit-field instructions. */
3347 if (INTVAL (operands[2]) != 1)
3350 /* For now, we don't allow memory operands. */
3351 if (GET_CODE (operands[1]) == MEM)
3355 ;; BAND, BOR, and BXOR patterns
3358 [(set (match_operand:HI 0 "bit_operand" "=Ur")
3359 (match_operator:HI 4 "bit_operator"
3360 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
3362 (match_operand:HI 2 "immediate_operand" "n"))
3363 (match_operand:HI 3 "bit_operand" "0")]))]
3365 "bld %Z2,%Y1\;b%c4 #0,%R0\;bst #0,%R0; bl1"
3366 [(set_attr "length" "6")])
3369 [(set (match_operand:HI 0 "bit_operand" "=Ur")
3370 (match_operator:HI 5 "bit_operator"
3371 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
3373 (match_operand:HI 2 "immediate_operand" "n"))
3374 (zero_extract:HI (match_operand:HI 3 "register_operand" "r")
3376 (match_operand:HI 4 "immediate_operand" "n"))]))]
3378 "bld %Z2,%Y1\;b%c5 %Z4,%Y3\;bst #0,%R0; bl3"
3379 [(set_attr "length" "6")])
3382 [(set (match_operand:QI 0 "register_operand" "=r")
3383 (zero_extract:QI (match_operand:QI 1 "bit_memory_operand" "WU")
3384 (match_operand:QI 2 "immediate_operand" "n")
3385 (match_operand:QI 3 "immediate_operand" "n")))]
3386 "TARGET_H8300SX && INTVAL (operands[2]) + INTVAL (operands[3]) <= 8"
3389 operands[2] = GEN_INT ((1 << (INTVAL (operands[2]) + INTVAL (operands[3])))
3390 - (1 << INTVAL (operands[3])));
3391 return \"bfld %2,%1,%R0\";
3393 [(set_attr "cc" "none_0hit")
3394 (set_attr "length_table" "bitfield")])
3397 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU")
3398 (match_operand:QI 2 "immediate_operand" "n")
3399 (match_operand:QI 3 "immediate_operand" "n"))
3400 (match_operand:QI 1 "register_operand" "r"))]
3401 "TARGET_H8300SX && INTVAL (operands[2]) + INTVAL (operands[3]) <= 8"
3404 operands[2] = GEN_INT ((1 << (INTVAL (operands[2]) + INTVAL (operands[3])))
3405 - (1 << INTVAL (operands[3])));
3406 return \"bfst %R1,%2,%0\";
3408 [(set_attr "cc" "none_0hit")
3409 (set_attr "length_table" "bitfield")])
3411 (define_expand "seq"
3412 [(set (match_operand:HI 0 "register_operand" "")
3413 (eq:HI (cc0) (const_int 0)))]
3417 (define_expand "sne"
3418 [(set (match_operand:HI 0 "register_operand" "")
3419 (ne:HI (cc0) (const_int 0)))]
3423 (define_insn "*bstzhireg"
3424 [(set (match_operand:HI 0 "register_operand" "=r")
3425 (match_operator:HI 1 "eqne_operator" [(cc0) (const_int 0)]))]
3427 "mulu.w #0,%T0\;b%k1 .Lh8BR%=\;inc.w #1,%T0\\n.Lh8BR%=:"
3428 [(set_attr "cc" "clobber")])
3430 (define_insn_and_split "*cmpstz"
3431 [(set (zero_extract:QI
3432 (match_operand:QI 0 "bit_memory_operand" "+WU,+WU")
3434 (match_operand:QI 1 "immediate_operand" "n,n"))
3437 [(match_operand 3 "h8300_dst_operand" "r,rQ")
3438 (match_operand 4 "h8300_src_operand" "I,rQi")]))]
3440 && (GET_MODE (operands[3]) == GET_MODE (operands[4])
3441 || GET_CODE (operands[4]) == CONST_INT)
3442 && GET_MODE_CLASS (GET_MODE (operands[3])) == MODE_INT
3443 && GET_MODE_SIZE (GET_MODE (operands[3])) <= 4"
3446 [(set (cc0) (match_dup 5))
3447 (set (zero_extract:QI (match_dup 0) (const_int 1) (match_dup 1))
3448 (match_op_dup:QI 2 [(cc0) (const_int 0)]))]
3451 if (operands[4] == const0_rtx && GET_CODE (operands[3]) == REG)
3452 operands[5] = operands[3];
3454 operands[5] = gen_rtx_COMPARE (VOIDmode, operands[3], operands[4]);
3456 [(set_attr "cc" "set_znv,compare")])
3458 (define_insn "*bstz"
3459 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU")
3461 (match_operand:QI 1 "immediate_operand" "n"))
3462 (eq:QI (cc0) (const_int 0)))]
3463 "TARGET_H8300SX && reload_completed"
3465 [(set_attr "cc" "none_0hit")
3466 (set_attr "length_table" "unary")])
3468 (define_insn "*bistz"
3469 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU")
3471 (match_operand:QI 1 "immediate_operand" "n"))
3472 (ne:QI (cc0) (const_int 0)))]
3473 "TARGET_H8300SX && reload_completed"
3475 [(set_attr "cc" "none_0hit")
3476 (set_attr "length_table" "unary")])
3478 (define_insn_and_split "*cmpcondbset"
3479 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3483 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3484 (match_operand 3 "h8300_src_operand" "I,rQi")])
3486 (match_operand:QI 4 "bit_memory_operand" "0,0")
3487 (match_operand:QI 5 "single_one_operand" "n,n"))
3492 [(set (cc0) (match_dup 6))
3495 (match_op_dup 1 [(cc0) (const_int 0)])
3496 (ior:QI (match_dup 4) (match_dup 5)) (match_dup 4)))]
3499 if (operands[3] == const0_rtx && GET_CODE (operands[2]) == REG)
3500 operands[6] = operands[2];
3502 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3504 [(set_attr "cc" "set_znv,compare")])
3506 (define_insn "*condbset"
3507 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3509 (match_operator:QI 2 "eqne_operator"
3510 [(cc0) (const_int 0)])
3512 (match_operand:QI 3 "bit_memory_operand" "0")
3513 (match_operand:QI 1 "single_one_operand" "n"))
3515 "TARGET_H8300SX && reload_completed"
3517 [(set_attr "cc" "none_0hit")
3518 (set_attr "length_table" "logicb")])
3520 (define_insn_and_split "*cmpcondbclr"
3521 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3525 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3526 (match_operand 3 "h8300_src_operand" "I,rQi")])
3528 (match_operand:QI 4 "bit_memory_operand" "0,0")
3529 (match_operand:QI 5 "single_zero_operand" "n,n"))
3534 [(set (cc0) (match_dup 6))
3537 (match_op_dup 1 [(cc0) (const_int 0)])
3538 (and:QI (match_dup 4) (match_dup 5)) (match_dup 4)))]
3541 if (operands[3] == const0_rtx && GET_CODE (operands[2]) == REG)
3542 operands[6] = operands[2];
3544 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3546 [(set_attr "cc" "set_znv,compare")])
3548 (define_insn "*condbclr"
3549 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3551 (match_operator:QI 2 "eqne_operator"
3552 [(cc0) (const_int 0)])
3554 (match_operand:QI 3 "bit_memory_operand" "0")
3555 (match_operand:QI 1 "single_zero_operand" "n"))
3557 "TARGET_H8300SX && reload_completed"
3559 [(set_attr "cc" "none_0hit")
3560 (set_attr "length_table" "logicb")])
3562 (define_insn_and_split "*cmpcondbsetreg"
3563 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3567 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3568 (match_operand 3 "h8300_src_operand" "I,rQi")])
3570 (match_operand:QI 4 "bit_memory_operand" "0,0")
3571 (ashift:QI (const_int 1)
3572 (match_operand:QI 5 "register_operand" "r,r")))
3577 [(set (cc0) (match_dup 6))
3580 (match_op_dup 1 [(cc0) (const_int 0)])
3581 (ior:QI (match_dup 4)
3582 (ashift:QI (const_int 1)
3583 (match_operand:QI 5 "register_operand" "r,r")))
3587 if (operands[3] == const0_rtx && GET_CODE (operands[2]) == REG)
3588 operands[6] = operands[2];
3590 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3592 [(set_attr "cc" "set_znv,compare")])
3594 (define_insn "*condbsetreg"
3595 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3597 (match_operator:QI 2 "eqne_operator"
3598 [(cc0) (const_int 0)])
3600 (match_operand:QI 3 "bit_memory_operand" "0")
3601 (ashift:QI (const_int 1)
3602 (match_operand:QI 1 "register_operand" "r")))
3604 "TARGET_H8300SX && reload_completed"
3606 [(set_attr "cc" "none_0hit")
3607 (set_attr "length_table" "logicb")])
3609 (define_insn_and_split "*cmpcondbclrreg"
3610 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3614 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3615 (match_operand 3 "h8300_src_operand" "I,rQi")])
3617 (match_operand:QI 4 "bit_memory_operand" "0,0")
3618 (ashift:QI (const_int 1)
3619 (match_operand:QI 5 "register_operand" "r,r")))
3624 [(set (cc0) (match_dup 6))
3627 (match_op_dup 1 [(cc0) (const_int 0)])
3628 (and:QI (match_dup 4)
3629 (ashift:QI (const_int 1)
3630 (match_operand:QI 5 "register_operand" "r,r")))
3634 if (operands[3] == const0_rtx && GET_CODE (operands[2]) == REG)
3635 operands[6] = operands[2];
3637 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3639 [(set_attr "cc" "set_znv,compare")])
3641 (define_insn "*condbclrreg"
3642 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3644 (match_operator:QI 2 "eqne_operator"
3645 [(cc0) (const_int 0)])
3647 (match_operand:QI 3 "bit_memory_operand" "0")
3648 (ashift:QI (const_int 1)
3649 (match_operand:QI 1 "register_operand" "r")))
3651 "TARGET_H8300SX && reload_completed"
3653 [(set_attr "cc" "none_0hit")
3654 (set_attr "length_table" "logicb")])
3657 ;; -----------------------------------------------------------------
3659 ;; -----------------------------------------------------------------
3663 (define_insn "*insv_si_1_n"
3664 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3666 (match_operand:SI 1 "const_int_operand" "n"))
3667 (match_operand:SI 2 "register_operand" "r"))]
3668 "(TARGET_H8300H || TARGET_H8300S)
3669 && INTVAL (operands[1]) < 16"
3670 "bld\\t#0,%w2\;bst\\t%Z1,%Y0"
3671 [(set_attr "length" "4")])
3673 (define_insn "*insv_si_1_n_lshiftrt"
3674 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3676 (match_operand:SI 1 "const_int_operand" "n"))
3677 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3678 (match_operand:SI 3 "const_int_operand" "n")))]
3679 "(TARGET_H8300H || TARGET_H8300S)
3680 && INTVAL (operands[1]) < 16
3681 && INTVAL (operands[3]) < 16"
3682 "bld\\t%Z3,%Y2\;bst\\t%Z1,%Y0"
3683 [(set_attr "length" "4")])
3685 (define_insn "*insv_si_1_n_lshiftrt_16"
3686 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3688 (match_operand:SI 1 "const_int_operand" "n"))
3689 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3691 "(TARGET_H8300H || TARGET_H8300S)
3692 && INTVAL (operands[1]) < 16"
3693 "rotr.w\\t%e2\;rotl.w\\t%e2\;bst\\t%Z1,%Y0"
3694 [(set_attr "length" "6")])
3696 (define_insn "*insv_si_8_8"
3697 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3700 (match_operand:SI 1 "register_operand" "r"))]
3701 "TARGET_H8300H || TARGET_H8300S"
3703 [(set_attr "length" "2")])
3705 (define_insn "*insv_si_8_8_lshiftrt_8"
3706 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3709 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3711 "TARGET_H8300H || TARGET_H8300S"
3713 [(set_attr "length" "2")])
3717 (define_insn "*extzv_8_8"
3718 [(set (match_operand:SI 0 "register_operand" "=r,r")
3719 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
3722 "TARGET_H8300H || TARGET_H8300S"
3724 mov.b\\t%x1,%w0\;extu.w\\t%f0\;extu.l\\t%S0
3725 sub.l\\t%S0,%S0\;mov.b\\t%x1,%w0"
3726 [(set_attr "cc" "set_znv,clobber")
3727 (set_attr "length" "6,4")])
3729 (define_insn "*extzv_8_16"
3730 [(set (match_operand:SI 0 "register_operand" "=r")
3731 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3734 "TARGET_H8300H || TARGET_H8300S"
3735 "mov.w\\t%e1,%f0\;extu.w\\t%f0\;extu.l\\t%S0"
3736 [(set_attr "cc" "set_znv")
3737 (set_attr "length" "6")])
3739 (define_insn "*extzv_16_8"
3740 [(set (match_operand:SI 0 "register_operand" "=r")
3741 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3744 (clobber (match_scratch:SI 2 "=&r"))]
3746 "mov.w\\t%e1,%f2\;mov.b\\t%x1,%w0\;mov.b\\t%w2,%x0\;extu.l\\t%S0"
3747 [(set_attr "length" "8")
3748 (set_attr "cc" "set_znv")])
3750 ;; Extract the exponent of a float.
3752 (define_insn_and_split "*extzv_8_23"
3753 [(set (match_operand:SI 0 "register_operand" "=r")
3754 (zero_extract:SI (match_operand:SI 1 "register_operand" "0")
3757 "(TARGET_H8300H || TARGET_H8300S)"
3759 "&& reload_completed"
3760 [(parallel [(set (match_dup 0)
3761 (ashift:SI (match_dup 0)
3763 (clobber (scratch:QI))])
3764 (parallel [(set (match_dup 0)
3765 (lshiftrt:SI (match_dup 0)
3767 (clobber (scratch:QI))])]
3772 ;; ((SImode) HImode) << 15
3774 (define_insn_and_split "*twoshifts_l16_r1"
3775 [(set (match_operand:SI 0 "register_operand" "=r")
3776 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
3778 (const_int 2147450880)))]
3779 "(TARGET_H8300H || TARGET_H8300S)"
3781 "&& reload_completed"
3782 [(parallel [(set (match_dup 0)
3783 (ashift:SI (match_dup 0)
3785 (clobber (scratch:QI))])
3786 (parallel [(set (match_dup 0)
3787 (lshiftrt:SI (match_dup 0)
3789 (clobber (scratch:QI))])]
3792 ;; Transform (SImode << B) & 0xffff into (SImode) (HImode << B).
3794 (define_insn_and_split "*andsi3_ashift_n_lower"
3795 [(set (match_operand:SI 0 "register_operand" "=r,r")
3796 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0,0")
3797 (match_operand:QI 2 "const_int_operand" "S,n"))
3798 (match_operand:SI 3 "const_int_operand" "n,n")))
3799 (clobber (match_scratch:QI 4 "=X,&r"))]
3800 "(TARGET_H8300H || TARGET_H8300S)
3801 && INTVAL (operands[2]) <= 15
3802 && INTVAL (operands[3]) == ((-1 << INTVAL (operands[2])) & 0xffff)"
3804 "&& reload_completed"
3805 [(parallel [(set (match_dup 5)
3806 (ashift:HI (match_dup 5)
3808 (clobber (match_dup 4))])
3810 (zero_extend:SI (match_dup 5)))]
3811 "operands[5] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3813 ;; Accept (A >> 30) & 2 and the like.
3815 (define_insn "*andsi3_lshiftrt_n_sb"
3816 [(set (match_operand:SI 0 "register_operand" "=r")
3817 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3818 (match_operand:SI 2 "const_int_operand" "n"))
3819 (match_operand:SI 3 "single_one_operand" "n")))]
3820 "(TARGET_H8300H || TARGET_H8300S)
3821 && exact_log2 (INTVAL (operands[3])) < 16
3822 && INTVAL (operands[2]) + exact_log2 (INTVAL (operands[3])) == 31"
3825 operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
3826 return \"shll.l\\t%S0\;xor.l\\t%S0,%S0\;bst\\t%Z3,%Y0\";
3828 [(set_attr "length" "8")])
3830 (define_insn_and_split "*andsi3_lshiftrt_9_sb"
3831 [(set (match_operand:SI 0 "register_operand" "=r")
3832 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3834 (const_int 4194304)))]
3835 "(TARGET_H8300H || TARGET_H8300S)"
3837 "&& reload_completed"
3839 (and:SI (lshiftrt:SI (match_dup 0)
3842 (parallel [(set (match_dup 0)
3843 (ashift:SI (match_dup 0)
3845 (clobber (scratch:QI))])]
3850 (define_insn "*addsi3_upper"
3851 [(set (match_operand:SI 0 "register_operand" "=r")
3852 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3854 (match_operand:SI 2 "register_operand" "0")))]
3855 "TARGET_H8300H || TARGET_H8300S"
3857 [(set_attr "length" "2")])
3859 (define_insn "*addsi3_lshiftrt_16_zexthi"
3860 [(set (match_operand:SI 0 "register_operand" "=r")
3861 (plus:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3863 (zero_extend:SI (match_operand:HI 2 "register_operand" "0"))))]
3864 "TARGET_H8300H || TARGET_H8300S"
3865 "add.w\\t%e1,%f0\;xor.w\\t%e0,%e0\;rotxl.w\\t%e0"
3866 [(set_attr "length" "6")])
3868 (define_insn_and_split "*addsi3_and_r_1"
3869 [(set (match_operand:SI 0 "register_operand" "=r")
3870 (plus:SI (and:SI (match_operand:SI 1 "register_operand" "r")
3872 (match_operand:SI 2 "register_operand" "0")))]
3873 "(TARGET_H8300H || TARGET_H8300S)"
3875 "&& reload_completed"
3877 (zero_extract:SI (match_dup 1)
3881 (if_then_else (eq (cc0)
3883 (label_ref (match_dup 3))
3886 (plus:SI (match_dup 2)
3889 "operands[3] = gen_label_rtx ();")
3891 (define_insn_and_split "*addsi3_and_not_r_1"
3892 [(set (match_operand:SI 0 "register_operand" "=r")
3893 (plus:SI (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
3895 (match_operand:SI 2 "register_operand" "0")))]
3896 "(TARGET_H8300H || TARGET_H8300S)"
3898 "&& reload_completed"
3900 (zero_extract:SI (match_dup 1)
3904 (if_then_else (ne (cc0)
3906 (label_ref (match_dup 3))
3909 (plus:SI (match_dup 2)
3912 "operands[3] = gen_label_rtx ();")
3916 (define_insn "*ixorhi3_zext"
3917 [(set (match_operand:HI 0 "register_operand" "=r")
3918 (match_operator:HI 1 "iorxor_operator"
3919 [(zero_extend:HI (match_operand:QI 2 "register_operand" "r"))
3920 (match_operand:HI 3 "register_operand" "0")]))]
3923 [(set_attr "length" "2")])
3927 (define_insn "*ixorsi3_zext_qi"
3928 [(set (match_operand:SI 0 "register_operand" "=r")
3929 (match_operator:SI 1 "iorxor_operator"
3930 [(zero_extend:SI (match_operand:QI 2 "register_operand" "r"))
3931 (match_operand:SI 3 "register_operand" "0")]))]
3934 [(set_attr "length" "2")])
3936 (define_insn "*ixorsi3_zext_hi"
3937 [(set (match_operand:SI 0 "register_operand" "=r")
3938 (match_operator:SI 1 "iorxor_operator"
3939 [(zero_extend:SI (match_operand:HI 2 "register_operand" "r"))
3940 (match_operand:SI 3 "register_operand" "0")]))]
3941 "TARGET_H8300H || TARGET_H8300S"
3943 [(set_attr "length" "2")])
3945 (define_insn "*ixorsi3_ashift_16"
3946 [(set (match_operand:SI 0 "register_operand" "=r")
3947 (match_operator:SI 1 "iorxor_operator"
3948 [(ashift:SI (match_operand:SI 2 "register_operand" "r")
3950 (match_operand:SI 3 "register_operand" "0")]))]
3951 "TARGET_H8300H || TARGET_H8300S"
3953 [(set_attr "length" "2")])
3955 (define_insn "*ixorsi3_lshiftrt_16"
3956 [(set (match_operand:SI 0 "register_operand" "=r")
3957 (match_operator:SI 1 "iorxor_operator"
3958 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3960 (match_operand:SI 3 "register_operand" "0")]))]
3961 "TARGET_H8300H || TARGET_H8300S"
3963 [(set_attr "length" "2")])
3967 (define_insn "*iorhi3_ashift_8"
3968 [(set (match_operand:HI 0 "register_operand" "=r")
3969 (ior:HI (ashift:HI (match_operand:HI 1 "register_operand" "r")
3971 (match_operand:HI 2 "register_operand" "0")))]
3974 [(set_attr "length" "2")])
3976 (define_insn "*iorhi3_lshiftrt_8"
3977 [(set (match_operand:HI 0 "register_operand" "=r")
3978 (ior:HI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
3980 (match_operand:HI 2 "register_operand" "0")))]
3983 [(set_attr "length" "2")])
3985 (define_insn "*iorhi3_two_qi"
3986 [(set (match_operand:HI 0 "register_operand" "=r")
3987 (ior:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
3988 (ashift:HI (match_operand:HI 2 "register_operand" "r")
3992 [(set_attr "length" "2")])
3994 (define_insn "*iorhi3_two_qi_mem"
3995 [(set (match_operand:HI 0 "register_operand" "=&r")
3996 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" "m"))
3997 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "m") 0)
4000 "mov.b\\t%X2,%t0\;mov.b\\t%X1,%s0"
4001 [(set_attr "length" "16")])
4004 [(set (match_operand:HI 0 "register_operand" "")
4005 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" ""))
4006 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "") 0)
4008 "(TARGET_H8300H || TARGET_H8300S)
4010 && byte_accesses_mergeable_p (XEXP (operands[2], 0), XEXP (operands[1], 0))"
4013 "operands[3] = gen_rtx_MEM (HImode, XEXP (operands[2], 0));")
4017 (define_insn "*iorsi3_two_hi"
4018 [(set (match_operand:SI 0 "register_operand" "=r")
4019 (ior:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
4020 (ashift:SI (match_operand:SI 2 "register_operand" "r")
4022 "TARGET_H8300H || TARGET_H8300S"
4024 [(set_attr "length" "2")])
4026 (define_insn_and_split "*iorsi3_two_qi_zext"
4027 [(set (match_operand:SI 0 "register_operand" "=&r")
4028 (ior:SI (zero_extend:SI (match_operand:QI 1 "memory_operand" "m"))
4030 (and:SI (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
4032 (const_int 65280))))]
4033 "(TARGET_H8300H || TARGET_H8300S)"
4035 "&& reload_completed"
4037 (ior:HI (zero_extend:HI (match_dup 1))
4038 (ashift:HI (subreg:HI (match_dup 2) 0)
4041 (zero_extend:SI (match_dup 3)))]
4042 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));")
4044 (define_insn "*iorsi3_e2f"
4045 [(set (match_operand:SI 0 "register_operand" "=r")
4046 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
4048 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
4050 "TARGET_H8300H || TARGET_H8300S"
4052 [(set_attr "length" "2")])
4054 (define_insn_and_split "*iorsi3_two_qi_sext"
4055 [(set (match_operand:SI 0 "register_operand" "=r")
4056 (ior:SI (zero_extend:SI (match_operand:QI 1 "register_operand" "0"))
4057 (ashift:SI (sign_extend:SI (match_operand:QI 2 "register_operand" "r"))
4059 "(TARGET_H8300H || TARGET_H8300S)"
4061 "&& reload_completed"
4063 (ior:HI (zero_extend:HI (match_dup 1))
4064 (ashift:HI (match_dup 4)
4067 (sign_extend:SI (match_dup 3)))]
4068 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4069 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));")
4071 (define_insn "*iorsi3_w"
4072 [(set (match_operand:SI 0 "register_operand" "=r,&r")
4073 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0,0")
4075 (zero_extend:SI (match_operand:QI 2 "general_operand_src" "r,g>"))))]
4076 "TARGET_H8300H || TARGET_H8300S"
4078 [(set_attr "length" "2,8")])
4080 (define_insn "*iorsi3_ashift_31"
4081 [(set (match_operand:SI 0 "register_operand" "=&r")
4082 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4084 (match_operand:SI 2 "register_operand" "0")))]
4085 "TARGET_H8300H || TARGET_H8300S"
4086 "rotxl.l\\t%S0\;bor\\t#0,%w1\;rotxr.l\\t%S0"
4087 [(set_attr "length" "6")
4088 (set_attr "cc" "set_znv")])
4090 (define_insn "*iorsi3_and_ashift"
4091 [(set (match_operand:SI 0 "register_operand" "=r")
4092 (ior:SI (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4093 (match_operand:SI 2 "const_int_operand" "n"))
4094 (match_operand:SI 3 "single_one_operand" "n"))
4095 (match_operand:SI 4 "register_operand" "0")))]
4096 "(TARGET_H8300H || TARGET_H8300S)
4097 && (INTVAL (operands[3]) & ~0xffff) == 0"
4100 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
4101 - INTVAL (operands[2]));
4102 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
4103 operands[2] = srcpos;
4104 operands[3] = dstpos;
4105 return \"bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0\";
4107 [(set_attr "length" "6")])
4109 (define_insn "*iorsi3_and_lshiftrt"
4110 [(set (match_operand:SI 0 "register_operand" "=r")
4111 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4112 (match_operand:SI 2 "const_int_operand" "n"))
4113 (match_operand:SI 3 "single_one_operand" "n"))
4114 (match_operand:SI 4 "register_operand" "0")))]
4115 "(TARGET_H8300H || TARGET_H8300S)
4116 && ((INTVAL (operands[3]) << INTVAL (operands[2])) & ~0xffff) == 0"
4119 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
4120 + INTVAL (operands[2]));
4121 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
4122 operands[2] = srcpos;
4123 operands[3] = dstpos;
4124 return \"bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0\";
4126 [(set_attr "length" "6")])
4128 (define_insn "*iorsi3_zero_extract"
4129 [(set (match_operand:SI 0 "register_operand" "=r")
4130 (ior:SI (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
4132 (match_operand:SI 2 "const_int_operand" "n"))
4133 (match_operand:SI 3 "register_operand" "0")))]
4134 "(TARGET_H8300H || TARGET_H8300S)
4135 && INTVAL (operands[2]) < 16"
4136 "bld\\t%Z2,%Y1\;bor\\t#0,%w0\;bst\\t#0,%w0"
4137 [(set_attr "length" "6")])
4139 (define_insn "*iorsi3_and_lshiftrt_n_sb"
4140 [(set (match_operand:SI 0 "register_operand" "=r")
4141 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4144 (match_operand:SI 2 "register_operand" "0")))]
4145 "(TARGET_H8300H || TARGET_H8300S)"
4146 "rotl.l\\t%S1\;rotr.l\\t%S1\;bor\\t#1,%w0\;bst\\t#1,%w0"
4147 [(set_attr "length" "8")])
4149 (define_insn "*iorsi3_and_lshiftrt_9_sb"
4150 [(set (match_operand:SI 0 "register_operand" "=r")
4151 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4153 (const_int 4194304))
4154 (match_operand:SI 2 "register_operand" "0")))
4155 (clobber (match_scratch:HI 3 "=&r"))]
4156 "(TARGET_H8300H || TARGET_H8300S)"
4159 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4160 return \"shll.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0\";
4162 return \"rotl.l\\t%S1\;rotr.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0\";
4164 [(set_attr "length" "10")])
4166 ;; Used to OR the exponent of a float.
4168 (define_insn "*iorsi3_shift"
4169 [(set (match_operand:SI 0 "register_operand" "=r")
4170 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4172 (match_operand:SI 2 "register_operand" "0")))
4173 (clobber (match_scratch:SI 3 "=&r"))]
4174 "TARGET_H8300H || TARGET_H8300S"
4178 [(set (match_operand:SI 0 "register_operand" "")
4179 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4182 (clobber (match_operand:SI 2 "register_operand" ""))]
4183 "(TARGET_H8300H || TARGET_H8300S)
4185 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4186 && REGNO (operands[0]) != REGNO (operands[1])"
4187 [(parallel [(set (match_dup 3)
4188 (ashift:HI (match_dup 3)
4190 (clobber (scratch:QI))])
4192 (ior:SI (ashift:SI (match_dup 1)
4195 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));")
4198 [(set (match_operand:SI 0 "register_operand" "")
4199 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4202 (clobber (match_operand:SI 2 "register_operand" ""))]
4203 "(TARGET_H8300H || TARGET_H8300S)
4205 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4206 && REGNO (operands[0]) != REGNO (operands[1]))"
4209 (parallel [(set (match_dup 3)
4210 (ashift:HI (match_dup 3)
4212 (clobber (scratch:QI))])
4214 (ior:SI (ashift:SI (match_dup 2)
4217 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));")
4219 (define_insn "*iorsi2_and_1_lshiftrt_1"
4220 [(set (match_operand:SI 0 "register_operand" "=r")
4221 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
4223 (lshiftrt:SI (match_dup 1)
4225 "TARGET_H8300H || TARGET_H8300S"
4226 "shlr.l\\t%S0\;bor\\t#0,%w0\;bst\\t#0,%w0"
4227 [(set_attr "length" "6")])
4229 (define_insn_and_split "*iorsi3_ashift_16_ashift_24"
4230 [(set (match_operand:SI 0 "register_operand" "=r")
4231 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
4233 (ashift:SI (match_operand:SI 2 "register_operand" "r")
4235 "(TARGET_H8300H || TARGET_H8300S)"
4237 "&& reload_completed"
4239 (ior:HI (ashift:HI (match_dup 4)
4242 (parallel [(set (match_dup 0)
4243 (ashift:SI (match_dup 0)
4245 (clobber (scratch:QI))])]
4246 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4247 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));")
4249 (define_insn_and_split "*iorsi3_ashift_16_ashift_24_mem"
4250 [(set (match_operand:SI 0 "register_operand" "=&r")
4251 (ior:SI (and:SI (ashift:SI (subreg:SI (match_operand:QI 1 "memory_operand" "m") 0)
4253 (const_int 16711680))
4254 (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
4256 "(TARGET_H8300H || TARGET_H8300S)"
4258 "&& reload_completed"
4260 (ior:HI (zero_extend:HI (match_dup 1))
4261 (ashift:HI (subreg:HI (match_dup 2) 0)
4263 (parallel [(set (match_dup 0)
4264 (ashift:SI (match_dup 0)
4266 (clobber (scratch:QI))])]
4267 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));")
4269 ;; Used to add the exponent of a float.
4271 (define_insn "*addsi3_shift"
4272 [(set (match_operand:SI 0 "register_operand" "=r")
4273 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
4274 (const_int 8388608))
4275 (match_operand:SI 2 "register_operand" "0")))
4276 (clobber (match_scratch:SI 3 "=&r"))]
4277 "TARGET_H8300H || TARGET_H8300S"
4281 [(set (match_operand:SI 0 "register_operand" "")
4282 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4283 (const_int 8388608))
4285 (clobber (match_operand:SI 2 "register_operand" ""))]
4286 "(TARGET_H8300H || TARGET_H8300S)
4288 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4289 && REGNO (operands[0]) != REGNO (operands[1])"
4290 [(parallel [(set (match_dup 3)
4291 (ashift:HI (match_dup 3)
4293 (clobber (scratch:QI))])
4295 (plus:SI (mult:SI (match_dup 1)
4298 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));")
4301 [(set (match_operand:SI 0 "register_operand" "")
4302 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4303 (const_int 8388608))
4305 (clobber (match_operand:SI 2 "register_operand" ""))]
4306 "(TARGET_H8300H || TARGET_H8300S)
4308 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4309 && REGNO (operands[0]) != REGNO (operands[1]))"
4312 (parallel [(set (match_dup 3)
4313 (ashift:HI (match_dup 3)
4315 (clobber (scratch:QI))])
4317 (plus:SI (mult:SI (match_dup 2)
4320 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));")
4324 (define_insn_and_split "*ashiftsi_sextqi_7"
4325 [(set (match_operand:SI 0 "register_operand" "=r")
4326 (ashift:SI (sign_extend:SI (match_operand:QI 1 "register_operand" "0"))
4328 "(TARGET_H8300H || TARGET_H8300S)"
4330 "&& reload_completed"
4331 [(parallel [(set (match_dup 2)
4332 (ashift:HI (match_dup 2)
4334 (clobber (scratch:QI))])
4336 (sign_extend:SI (match_dup 2)))
4337 (parallel [(set (match_dup 0)
4338 (ashiftrt:SI (match_dup 0)
4340 (clobber (scratch:QI))])]
4341 "operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));")
4343 ;; Storing a part of HImode to QImode.
4346 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4347 (subreg:QI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
4351 [(set_attr "cc" "set_znv")
4352 (set_attr "length" "8")])
4354 ;; Storing a part of SImode to QImode.
4357 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4358 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4362 [(set_attr "cc" "set_znv")
4363 (set_attr "length" "8")])
4366 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4367 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4369 (clobber (match_scratch:SI 2 "=&r"))]
4370 "TARGET_H8300H || TARGET_H8300S"
4371 "mov.w\\t%e1,%f2\;mov.b\\t%w2,%R0"
4372 [(set_attr "cc" "set_znv")
4373 (set_attr "length" "10")])
4376 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4377 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4379 (clobber (match_scratch:SI 2 "=&r"))]
4380 "TARGET_H8300H || TARGET_H8300S"
4381 "mov.w\\t%e1,%f2\;mov.b\\t%x2,%R0"
4382 [(set_attr "cc" "set_znv")
4383 (set_attr "length" "10")])
4385 (define_insn_and_split ""
4387 (if_then_else (eq (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
4391 (label_ref (match_operand 1 "" ""))
4399 (if_then_else (ge (cc0)
4401 (label_ref (match_dup 1))
4405 (define_insn_and_split ""
4407 (if_then_else (ne (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
4411 (label_ref (match_operand 1 "" ""))
4419 (if_then_else (lt (cc0)
4421 (label_ref (match_dup 1))
4425 ;; -----------------------------------------------------------------
4426 ;; PEEPHOLE PATTERNS
4427 ;; -----------------------------------------------------------------
4429 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
4432 [(parallel [(set (match_operand:HI 0 "register_operand" "")
4433 (lshiftrt:HI (match_dup 0)
4434 (match_operand:HI 1 "const_int_operand" "")))
4435 (clobber (match_operand:HI 2 "" ""))])
4437 (and:HI (match_dup 0)
4438 (match_operand:HI 3 "const_int_operand" "")))]
4439 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
4441 (and:HI (match_dup 0)
4445 (lshiftrt:HI (match_dup 0)
4447 (clobber (match_dup 2))])]
4450 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
4453 [(parallel [(set (match_operand:HI 0 "register_operand" "")
4454 (ashift:HI (match_dup 0)
4455 (match_operand:HI 1 "const_int_operand" "")))
4456 (clobber (match_operand:HI 2 "" ""))])
4458 (and:HI (match_dup 0)
4459 (match_operand:HI 3 "const_int_operand" "")))]
4460 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
4462 (and:HI (match_dup 0)
4466 (ashift:HI (match_dup 0)
4468 (clobber (match_dup 2))])]
4471 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
4474 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4475 (lshiftrt:SI (match_dup 0)
4476 (match_operand:SI 1 "const_int_operand" "")))
4477 (clobber (match_operand:SI 2 "" ""))])
4479 (and:SI (match_dup 0)
4480 (match_operand:SI 3 "const_int_operand" "")))]
4481 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
4483 (and:SI (match_dup 0)
4487 (lshiftrt:SI (match_dup 0)
4489 (clobber (match_dup 2))])]
4492 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
4495 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4496 (ashift:SI (match_dup 0)
4497 (match_operand:SI 1 "const_int_operand" "")))
4498 (clobber (match_operand:SI 2 "" ""))])
4500 (and:SI (match_dup 0)
4501 (match_operand:SI 3 "const_int_operand" "")))]
4502 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
4504 (and:SI (match_dup 0)
4508 (ashift:SI (match_dup 0)
4510 (clobber (match_dup 2))])]
4513 ;; Convert (A >> B) & C to (A & 65535) >> B if C == 65535 >> B.
4516 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4517 (lshiftrt:SI (match_dup 0)
4518 (match_operand:SI 1 "const_int_operand" "")))
4519 (clobber (match_operand:SI 2 "" ""))])
4521 (and:SI (match_dup 0)
4522 (match_operand:SI 3 "const_int_operand" "")))]
4523 "INTVAL (operands[3]) == (65535 >> INTVAL (operands[1]))"
4525 (and:SI (match_dup 0)
4529 (lshiftrt:SI (match_dup 0)
4531 (clobber (match_dup 2))])]
4534 ;; Convert (A << B) & C to (A & 65535) << B if C == 65535 << B.
4537 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4538 (ashift:SI (match_dup 0)
4539 (match_operand:SI 1 "const_int_operand" "")))
4540 (clobber (match_operand:SI 2 "" ""))])
4542 (and:SI (match_dup 0)
4543 (match_operand:SI 3 "const_int_operand" "")))]
4544 "INTVAL (operands[3]) == (65535 << INTVAL (operands[1]))"
4546 (and:SI (match_dup 0)
4550 (ashift:SI (match_dup 0)
4552 (clobber (match_dup 2))])]
4555 ;; Convert a QImode push into an SImode push so that the
4556 ;; define_peephole2 below can cram multiple pushes into one stm.l.
4559 [(parallel [(set (reg:SI SP_REG)
4560 (plus:SI (reg:SI SP_REG) (const_int -4)))
4561 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
4562 (match_operand:QI 0 "register_operand" ""))])]
4563 "TARGET_H8300S && !TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4564 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4566 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
4569 [(parallel [(set (reg:HI SP_REG)
4570 (plus:HI (reg:HI SP_REG) (const_int -4)))
4571 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
4572 (match_operand:QI 0 "register_operand" ""))])]
4573 "TARGET_H8300S && TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4574 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4576 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
4578 ;; Convert a HImode push into an SImode push so that the
4579 ;; define_peephole2 below can cram multiple pushes into one stm.l.
4582 [(parallel [(set (reg:SI SP_REG)
4583 (plus:SI (reg:SI SP_REG) (const_int -4)))
4584 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
4585 (match_operand:HI 0 "register_operand" ""))])]
4586 "TARGET_H8300S && !TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4587 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4589 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
4592 [(parallel [(set (reg:HI SP_REG)
4593 (plus:HI (reg:HI SP_REG) (const_int -4)))
4594 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
4595 (match_operand:HI 0 "register_operand" ""))])]
4596 "TARGET_H8300S && TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4597 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4599 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
4601 ;; Cram four pushes into stm.l.
4604 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4605 (match_operand:SI 0 "register_operand" ""))
4606 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4607 (match_operand:SI 1 "register_operand" ""))
4608 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4609 (match_operand:SI 2 "register_operand" ""))
4610 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4611 (match_operand:SI 3 "register_operand" ""))]
4612 "TARGET_H8300S && !TARGET_NORMAL_MODE
4613 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
4614 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4615 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4616 && REGNO (operands[3]) == REGNO (operands[0]) + 3
4617 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
4618 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4620 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4622 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
4624 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
4626 (set (reg:SI SP_REG)
4627 (plus:SI (reg:SI SP_REG)
4628 (const_int -16)))])]
4632 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4633 (match_operand:SI 0 "register_operand" ""))
4634 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4635 (match_operand:SI 1 "register_operand" ""))
4636 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4637 (match_operand:SI 2 "register_operand" ""))
4638 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4639 (match_operand:SI 3 "register_operand" ""))]
4640 "TARGET_H8300S && TARGET_NORMAL_MODE
4641 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
4642 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4643 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4644 && REGNO (operands[3]) == REGNO (operands[0]) + 3
4645 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
4646 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4648 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4650 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4652 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
4654 (set (reg:HI SP_REG)
4655 (plus:HI (reg:HI SP_REG)
4656 (const_int -16)))])]
4659 ;; Cram three pushes into stm.l.
4662 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4663 (match_operand:SI 0 "register_operand" ""))
4664 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4665 (match_operand:SI 1 "register_operand" ""))
4666 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4667 (match_operand:SI 2 "register_operand" ""))]
4668 "TARGET_H8300S && !TARGET_NORMAL_MODE
4669 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
4670 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4671 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4672 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
4673 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4675 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4677 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
4679 (set (reg:SI SP_REG)
4680 (plus:SI (reg:SI SP_REG)
4681 (const_int -12)))])]
4685 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4686 (match_operand:SI 0 "register_operand" ""))
4687 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4688 (match_operand:SI 1 "register_operand" ""))
4689 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4690 (match_operand:SI 2 "register_operand" ""))]
4691 "TARGET_H8300S && TARGET_NORMAL_MODE
4692 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
4693 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4694 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4695 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
4696 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4698 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4700 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4702 (set (reg:HI SP_REG)
4703 (plus:HI (reg:HI SP_REG)
4704 (const_int -12)))])]
4707 ;; Cram two pushes into stm.l.
4710 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4711 (match_operand:SI 0 "register_operand" ""))
4712 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4713 (match_operand:SI 1 "register_operand" ""))]
4714 "TARGET_H8300S && !TARGET_NORMAL_MODE
4715 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
4716 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4717 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
4718 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4720 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4722 (set (reg:SI SP_REG)
4723 (plus:SI (reg:SI SP_REG)
4728 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4729 (match_operand:SI 0 "register_operand" ""))
4730 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4731 (match_operand:SI 1 "register_operand" ""))]
4732 "TARGET_H8300S && TARGET_NORMAL_MODE
4733 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
4734 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4735 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
4736 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4738 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4740 (set (reg:HI SP_REG)
4741 (plus:HI (reg:HI SP_REG)
4748 ;; add.w r7,r0 (6 bytes)
4753 ;; adds #2,r0 (4 bytes)
4756 [(set (match_operand:HI 0 "register_operand" "")
4757 (match_operand:HI 1 "const_int_operand" ""))
4759 (plus:HI (match_dup 0)
4760 (match_operand:HI 2 "register_operand" "")))]
4761 "REG_P (operands[0]) && REG_P (operands[2])
4762 && REGNO (operands[0]) != REGNO (operands[2])
4763 && (CONST_OK_FOR_J (INTVAL (operands[1]))
4764 || CONST_OK_FOR_L (INTVAL (operands[1]))
4765 || CONST_OK_FOR_N (INTVAL (operands[1])))"
4769 (plus:HI (match_dup 0)
4777 ;; add.l er7,er0 (6 bytes)
4782 ;; adds #4,er0 (4 bytes)
4785 [(set (match_operand:SI 0 "register_operand" "")
4786 (match_operand:SI 1 "const_int_operand" ""))
4788 (plus:SI (match_dup 0)
4789 (match_operand:SI 2 "register_operand" "")))]
4790 "(TARGET_H8300H || TARGET_H8300S)
4791 && REG_P (operands[0]) && REG_P (operands[2])
4792 && REGNO (operands[0]) != REGNO (operands[2])
4793 && (CONST_OK_FOR_L (INTVAL (operands[1]))
4794 || CONST_OK_FOR_N (INTVAL (operands[1])))"
4798 (plus:SI (match_dup 0)
4805 ;; add.l #10,er0 (takes 8 bytes)
4811 ;; add.l er7,er0 (takes 6 bytes)
4814 [(set (match_operand:SI 0 "register_operand" "")
4815 (match_operand:SI 1 "register_operand" ""))
4817 (plus:SI (match_dup 0)
4818 (match_operand:SI 2 "const_int_operand" "")))]
4819 "(TARGET_H8300H || TARGET_H8300S)
4820 && REG_P (operands[0]) && REG_P (operands[1])
4821 && REGNO (operands[0]) != REGNO (operands[1])
4822 && !CONST_OK_FOR_L (INTVAL (operands[2]))
4823 && !CONST_OK_FOR_N (INTVAL (operands[2]))
4824 && ((INTVAL (operands[2]) & 0xff) == INTVAL (operands[2])
4825 || (INTVAL (operands[2]) & 0xff00) == INTVAL (operands[2])
4826 || INTVAL (operands[2]) == 0xffff
4827 || INTVAL (operands[2]) == 0xfffe)"
4831 (plus:SI (match_dup 0)
4847 [(set (match_operand:HI 0 "register_operand" "")
4848 (plus:HI (match_dup 0)
4849 (match_operand 1 "incdec_operand" "")))
4853 (if_then_else (match_operator 3 "eqne_operator"
4854 [(cc0) (const_int 0)])
4855 (label_ref (match_operand 2 "" ""))
4857 "TARGET_H8300H || TARGET_H8300S"
4858 [(set (match_operand:HI 0 "register_operand" "")
4859 (unspec:HI [(match_dup 0)
4865 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4866 (label_ref (match_dup 2))
4870 ;; The SImode version of the previous pattern.
4873 [(set (match_operand:SI 0 "register_operand" "")
4874 (plus:SI (match_dup 0)
4875 (match_operand 1 "incdec_operand" "")))
4879 (if_then_else (match_operator 3 "eqne_operator"
4880 [(cc0) (const_int 0)])
4881 (label_ref (match_operand 2 "" ""))
4883 "TARGET_H8300H || TARGET_H8300S"
4884 [(set (match_operand:SI 0 "register_operand" "")
4885 (unspec:SI [(match_dup 0)
4891 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4892 (label_ref (match_dup 2))
4897 [(parallel [(set (cc0)
4898 (zero_extract:SI (match_operand:QI 0 "register_operand" "")
4901 (clobber (scratch:QI))])
4903 (if_then_else (match_operator 1 "eqne_operator"
4904 [(cc0) (const_int 0)])
4905 (label_ref (match_operand 2 "" ""))
4907 "(TARGET_H8300H || TARGET_H8300S)"
4911 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4912 (label_ref (match_dup 2))
4914 "operands[3] = ((GET_CODE (operands[1]) == EQ)
4915 ? gen_rtx_GE (VOIDmode, cc0_rtx, const0_rtx)
4916 : gen_rtx_LT (VOIDmode, cc0_rtx, const0_rtx));")
4918 ;; The next three peephole2's will try to transform
4920 ;; mov.b A,r0l (or mov.l A,er0)
4927 ;; and.b #CST,r0l (if CST is not 255)
4930 [(set (match_operand:QI 0 "register_operand" "")
4931 (match_operand:QI 1 "general_operand" ""))
4932 (set (match_operand:SI 2 "register_operand" "")
4933 (and:SI (match_dup 2)
4935 "(TARGET_H8300H || TARGET_H8300S)
4936 && !reg_overlap_mentioned_p (operands[2], operands[1])
4937 && REGNO (operands[0]) == REGNO (operands[2])"
4940 (set (strict_low_part (match_dup 0))
4945 [(set (match_operand:SI 0 "register_operand" "")
4946 (match_operand:SI 1 "general_operand" ""))
4948 (and:SI (match_dup 0)
4950 "(TARGET_H8300H || TARGET_H8300S)
4951 && !reg_overlap_mentioned_p (operands[0], operands[1])
4952 && !(GET_CODE (operands[1]) == MEM && !offsettable_memref_p (operands[1]))
4953 && !(GET_CODE (operands[1]) == MEM && MEM_VOLATILE_P (operands[1]))"
4956 (set (strict_low_part (match_dup 2))
4958 "operands[2] = gen_lowpart (QImode, operands[0]);
4959 operands[3] = gen_lowpart (QImode, operands[1]);")
4962 [(set (match_operand 0 "register_operand" "")
4963 (match_operand 1 "general_operand" ""))
4964 (set (match_operand:SI 2 "register_operand" "")
4965 (and:SI (match_dup 2)
4966 (match_operand:SI 3 "const_int_qi_operand" "")))]
4967 "(TARGET_H8300H || TARGET_H8300S)
4968 && (GET_MODE (operands[0]) == QImode
4969 || GET_MODE (operands[0]) == HImode
4970 || GET_MODE (operands[0]) == SImode)
4971 && GET_MODE (operands[0]) == GET_MODE (operands[1])
4972 && REGNO (operands[0]) == REGNO (operands[2])
4973 && !reg_overlap_mentioned_p (operands[2], operands[1])
4974 && !(GET_MODE (operands[1]) != QImode
4975 && GET_CODE (operands[1]) == MEM
4976 && !offsettable_memref_p (operands[1]))
4977 && !(GET_MODE (operands[1]) != QImode
4978 && GET_CODE (operands[1]) == MEM
4979 && MEM_VOLATILE_P (operands[1]))"
4982 (set (strict_low_part (match_dup 4))
4985 (and:SI (match_dup 2)
4987 "operands[4] = gen_lowpart (QImode, operands[0]);
4988 operands[5] = gen_lowpart (QImode, operands[1]);
4989 operands[6] = GEN_INT (~0xff | INTVAL (operands[3]));")
4992 [(set (match_operand:SI 0 "register_operand" "")
4993 (match_operand:SI 1 "register_operand" ""))
4995 (and:SI (match_dup 0)
4996 (const_int 65280)))]
4997 "(TARGET_H8300H || TARGET_H8300S)
4998 && !reg_overlap_mentioned_p (operands[0], operands[1])"
5001 (set (zero_extract:SI (match_dup 0)
5004 (lshiftrt:SI (match_dup 1)
5008 ;; If a load of mem:SI is followed by an AND that turns off the upper
5009 ;; half, then we can load mem:HI instead.
5012 [(set (match_operand:SI 0 "register_operand" "")
5013 (match_operand:SI 1 "memory_operand" ""))
5015 (and:SI (match_dup 0)
5016 (match_operand:SI 2 "const_int_operand" "")))]
5017 "(TARGET_H8300H || TARGET_H8300S)
5018 && !MEM_VOLATILE_P (operands[1])
5019 && offsettable_memref_p (operands[1])
5020 && (INTVAL (operands[2]) & ~0xffff) == 0
5021 && INTVAL (operands[2]) != 255"
5025 (and:SI (match_dup 0)
5027 "operands[3] = gen_lowpart (HImode, operands[0]);
5028 operands[4] = gen_lowpart (HImode, operands[1]);")
5030 ;; (compare (reg:HI) (const_int)) takes 4 bytes, so we try to achieve
5031 ;; the equivalent with shorter sequences. Here is the summary. Cases
5032 ;; are grouped for each define_peephole2.
5034 ;; reg const_int use insn
5035 ;; --------------------------------------------------------
5036 ;; dead -2 eq/ne inc.l
5037 ;; dead -1 eq/ne inc.l
5038 ;; dead 1 eq/ne dec.l
5039 ;; dead 2 eq/ne dec.l
5041 ;; dead 1 ge/lt shar.l
5042 ;; dead 3 (H8S) ge/lt shar.l
5044 ;; dead 1 geu/ltu shar.l
5045 ;; dead 3 (H8S) geu/ltu shar.l
5047 ;; ---- 255 ge/lt mov.b
5049 ;; ---- 255 geu/ltu mov.b
5063 (compare (match_operand:HI 0 "register_operand" "")
5064 (match_operand:HI 1 "incdec_operand" "")))
5066 (if_then_else (match_operator 3 "eqne_operator"
5067 [(cc0) (const_int 0)])
5068 (label_ref (match_operand 2 "" ""))
5070 "(TARGET_H8300H || TARGET_H8300S)
5071 && peep2_reg_dead_p (1, operands[0])"
5073 (unspec:HI [(match_dup 0)
5079 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5080 (label_ref (match_dup 2))
5082 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
5096 (compare (match_operand:HI 0 "register_operand" "")
5097 (match_operand:HI 1 "const_int_operand" "")))
5099 (if_then_else (match_operator 2 "gtle_operator"
5100 [(cc0) (const_int 0)])
5101 (label_ref (match_operand 3 "" ""))
5103 "(TARGET_H8300H || TARGET_H8300S)
5104 && peep2_reg_dead_p (1, operands[0])
5105 && (INTVAL (operands[1]) == 1
5106 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5107 [(parallel [(set (match_dup 0)
5108 (ashiftrt:HI (match_dup 0)
5110 (clobber (scratch:QI))])
5114 (if_then_else (match_dup 2)
5115 (label_ref (match_dup 3))
5117 "operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
5131 (compare (match_operand:HI 0 "register_operand" "")
5132 (match_operand:HI 1 "const_int_operand" "")))
5134 (if_then_else (match_operator 2 "gtuleu_operator"
5135 [(cc0) (const_int 0)])
5136 (label_ref (match_operand 3 "" ""))
5138 "(TARGET_H8300H || TARGET_H8300S)
5139 && peep2_reg_dead_p (1, operands[0])
5140 && (INTVAL (operands[1]) == 1
5141 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5142 [(parallel [(set (match_dup 0)
5143 (ashiftrt:HI (match_dup 0)
5145 (clobber (scratch:QI))])
5149 (if_then_else (match_dup 5)
5150 (label_ref (match_dup 3))
5153 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5154 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5172 (compare (match_operand:HI 0 "register_operand" "")
5175 (if_then_else (match_operator 1 "gtle_operator"
5176 [(cc0) (const_int 0)])
5177 (label_ref (match_operand 2 "" ""))
5179 "TARGET_H8300H || TARGET_H8300S"
5181 (and:HI (match_dup 0)
5184 (if_then_else (match_dup 1)
5185 (label_ref (match_dup 2))
5201 (compare (match_operand:HI 0 "register_operand" "")
5204 (if_then_else (match_operator 1 "gtuleu_operator"
5205 [(cc0) (const_int 0)])
5206 (label_ref (match_operand 2 "" ""))
5208 "TARGET_H8300H || TARGET_H8300S"
5210 (and:HI (match_dup 0)
5213 (if_then_else (match_dup 3)
5214 (label_ref (match_dup 2))
5217 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
5223 ;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
5224 ;; the equivalent with shorter sequences. Here is the summary. Cases
5225 ;; are grouped for each define_peephole2.
5227 ;; reg const_int use insn
5228 ;; --------------------------------------------------------
5229 ;; live -2 eq/ne copy and inc.l
5230 ;; live -1 eq/ne copy and inc.l
5231 ;; live 1 eq/ne copy and dec.l
5232 ;; live 2 eq/ne copy and dec.l
5234 ;; dead -2 eq/ne inc.l
5235 ;; dead -1 eq/ne inc.l
5236 ;; dead 1 eq/ne dec.l
5237 ;; dead 2 eq/ne dec.l
5239 ;; dead -131072 eq/ne inc.w and test
5240 ;; dead -65536 eq/ne inc.w and test
5241 ;; dead 65536 eq/ne dec.w and test
5242 ;; dead 131072 eq/ne dec.w and test
5244 ;; dead 0x000000?? except 1 and 2 eq/ne xor.b and test
5245 ;; dead 0x0000??00 eq/ne xor.b and test
5246 ;; dead 0x0000ffff eq/ne not.w and test
5248 ;; dead 0xffffff?? except -1 and -2 eq/ne xor.b and not.l
5249 ;; dead 0xffff??ff eq/ne xor.b and not.l
5250 ;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l
5251 ;; dead 0x80000000 eq/ne rotl.l and dec.l
5253 ;; live 1 ge/lt copy and shar.l
5254 ;; live 3 (H8S) ge/lt copy and shar.l
5256 ;; live 1 geu/ltu copy and shar.l
5257 ;; live 3 (H8S) geu/ltu copy and shar.l
5259 ;; dead 1 ge/lt shar.l
5260 ;; dead 3 (H8S) ge/lt shar.l
5262 ;; dead 1 geu/ltu shar.l
5263 ;; dead 3 (H8S) geu/ltu shar.l
5265 ;; dead 3 (H8/300H) ge/lt and.b and test
5266 ;; dead 7 ge/lt and.b and test
5267 ;; dead 15 ge/lt and.b and test
5268 ;; dead 31 ge/lt and.b and test
5269 ;; dead 63 ge/lt and.b and test
5270 ;; dead 127 ge/lt and.b and test
5271 ;; dead 255 ge/lt and.b and test
5273 ;; dead 3 (H8/300H) geu/ltu and.b and test
5274 ;; dead 7 geu/ltu and.b and test
5275 ;; dead 15 geu/ltu and.b and test
5276 ;; dead 31 geu/ltu and.b and test
5277 ;; dead 63 geu/ltu and.b and test
5278 ;; dead 127 geu/ltu and.b and test
5279 ;; dead 255 geu/ltu and.b and test
5281 ;; ---- 65535 ge/lt mov.w
5283 ;; ---- 65535 geu/ltu mov.w
5297 (compare (match_operand:SI 0 "register_operand" "")
5298 (match_operand:SI 1 "incdec_operand" "")))
5300 (if_then_else (match_operator 3 "eqne_operator"
5301 [(cc0) (const_int 0)])
5302 (label_ref (match_operand 2 "" ""))
5304 "(TARGET_H8300H || TARGET_H8300S)
5305 && peep2_reg_dead_p (1, operands[0])"
5307 (unspec:SI [(match_dup 0)
5313 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5314 (label_ref (match_dup 2))
5316 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
5330 (compare (match_operand:SI 0 "register_operand" "")
5331 (match_operand:SI 1 "const_int_operand" "")))
5333 (if_then_else (match_operator 3 "eqne_operator"
5334 [(cc0) (const_int 0)])
5335 (label_ref (match_operand 2 "" ""))
5337 "(TARGET_H8300H || TARGET_H8300S)
5338 && peep2_reg_dead_p (1, operands[0])
5339 && (INTVAL (operands[1]) == -131072
5340 || INTVAL (operands[1]) == -65536
5341 || INTVAL (operands[1]) == 65536
5342 || INTVAL (operands[1]) == 131072)"
5344 (plus:SI (match_dup 0)
5349 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5350 (label_ref (match_dup 2))
5352 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
5367 (compare (match_operand:SI 0 "register_operand" "")
5368 (match_operand:SI 1 "const_int_operand" "")))
5370 (if_then_else (match_operator 3 "eqne_operator"
5371 [(cc0) (const_int 0)])
5372 (label_ref (match_operand 2 "" ""))
5374 "(TARGET_H8300H || TARGET_H8300S)
5375 && peep2_reg_dead_p (1, operands[0])
5376 && ((INTVAL (operands[1]) & 0x00ff) == INTVAL (operands[1])
5377 || (INTVAL (operands[1]) & 0xff00) == INTVAL (operands[1])
5378 || INTVAL (operands[1]) == 0x0000ffff)
5379 && INTVAL (operands[1]) != 1
5380 && INTVAL (operands[1]) != 2"
5382 (xor:SI (match_dup 0)
5387 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5388 (label_ref (match_dup 2))
5405 (compare (match_operand:SI 0 "register_operand" "")
5406 (match_operand:SI 1 "const_int_operand" "")))
5408 (if_then_else (match_operator 3 "eqne_operator"
5409 [(cc0) (const_int 0)])
5410 (label_ref (match_operand 2 "" ""))
5412 "(TARGET_H8300H || TARGET_H8300S)
5413 && peep2_reg_dead_p (1, operands[0])
5414 && ((INTVAL (operands[1]) | 0x00ff) == -1
5415 || (INTVAL (operands[1]) | 0xff00) == -1)
5416 && INTVAL (operands[1]) != -1
5417 && INTVAL (operands[1]) != -2"
5419 (xor:SI (match_dup 0)
5422 (not:SI (match_dup 0)))
5426 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5427 (label_ref (match_dup 2))
5429 "operands[4] = GEN_INT (INTVAL (operands[1]) ^ -1);")
5433 ;; cmp.l #-2147483648,er0
5444 (compare (match_operand:SI 0 "register_operand" "")
5445 (match_operand:SI 1 "const_int_operand" "")))
5447 (if_then_else (match_operator 3 "eqne_operator"
5448 [(cc0) (const_int 0)])
5449 (label_ref (match_operand 2 "" ""))
5451 "(TARGET_H8300H || TARGET_H8300S)
5452 && peep2_reg_dead_p (1, operands[0])
5453 && (INTVAL (operands[1]) == -2147483647 - 1
5454 || (TARGET_H8300S && INTVAL (operands[1]) == 1073741824))"
5456 (rotate:SI (match_dup 0)
5459 (unspec:SI [(match_dup 0)
5465 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5466 (label_ref (match_dup 2))
5468 "operands[4] = GEN_INT (INTVAL (operands[1]) == -2147483647 - 1 ? 1 : 2);")
5481 ;; We avoid this transformation if we see more than one copy of the
5482 ;; same compare insn immediately before this one.
5485 [(match_scratch:SI 4 "r")
5487 (compare (match_operand:SI 0 "register_operand" "")
5488 (match_operand:SI 1 "const_int_operand" "")))
5490 (if_then_else (match_operator 2 "gtle_operator"
5491 [(cc0) (const_int 0)])
5492 (label_ref (match_operand 3 "" ""))
5494 "(TARGET_H8300H || TARGET_H8300S)
5495 && !peep2_reg_dead_p (1, operands[0])
5496 && (INTVAL (operands[1]) == 1
5497 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
5498 && !same_cmp_preceding_p (insn)"
5501 (parallel [(set (match_dup 4)
5502 (ashiftrt:SI (match_dup 4)
5504 (clobber (scratch:QI))])
5508 (if_then_else (match_dup 2)
5509 (label_ref (match_dup 3))
5511 "operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
5524 ;; We avoid this transformation if we see more than one copy of the
5525 ;; same compare insn immediately before this one.
5528 [(match_scratch:SI 4 "r")
5530 (compare (match_operand:SI 0 "register_operand" "")
5531 (match_operand:SI 1 "const_int_operand" "")))
5533 (if_then_else (match_operator 2 "gtuleu_operator"
5534 [(cc0) (const_int 0)])
5535 (label_ref (match_operand 3 "" ""))
5537 "(TARGET_H8300H || TARGET_H8300S)
5538 && !peep2_reg_dead_p (1, operands[0])
5539 && (INTVAL (operands[1]) == 1
5540 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
5541 && !same_cmp_preceding_p (insn)"
5544 (parallel [(set (match_dup 4)
5545 (ashiftrt:SI (match_dup 4)
5547 (clobber (scratch:QI))])
5551 (if_then_else (match_dup 6)
5552 (label_ref (match_dup 3))
5555 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5556 operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5574 (compare (match_operand:SI 0 "register_operand" "")
5575 (match_operand:SI 1 "const_int_operand" "")))
5577 (if_then_else (match_operator 2 "gtle_operator"
5578 [(cc0) (const_int 0)])
5579 (label_ref (match_operand 3 "" ""))
5581 "(TARGET_H8300H || TARGET_H8300S)
5582 && peep2_reg_dead_p (1, operands[0])
5583 && (INTVAL (operands[1]) == 1
5584 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5585 [(parallel [(set (match_dup 0)
5586 (ashiftrt:SI (match_dup 0)
5588 (clobber (scratch:QI))])
5592 (if_then_else (match_dup 2)
5593 (label_ref (match_dup 3))
5595 "operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
5609 (compare (match_operand:SI 0 "register_operand" "")
5610 (match_operand:SI 1 "const_int_operand" "")))
5612 (if_then_else (match_operator 2 "gtuleu_operator"
5613 [(cc0) (const_int 0)])
5614 (label_ref (match_operand 3 "" ""))
5616 "(TARGET_H8300H || TARGET_H8300S)
5617 && peep2_reg_dead_p (1, operands[0])
5618 && (INTVAL (operands[1]) == 1
5619 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5620 [(parallel [(set (match_dup 0)
5621 (ashiftrt:SI (match_dup 0)
5623 (clobber (scratch:QI))])
5627 (if_then_else (match_dup 5)
5628 (label_ref (match_dup 3))
5631 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5632 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5651 (compare (match_operand:SI 0 "register_operand" "")
5652 (match_operand:SI 1 "const_int_operand" "")))
5654 (if_then_else (match_operator 2 "gtle_operator"
5655 [(cc0) (const_int 0)])
5656 (label_ref (match_operand 3 "" ""))
5658 "(TARGET_H8300H || TARGET_H8300S)
5659 && peep2_reg_dead_p (1, operands[0])
5660 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
5661 || INTVAL (operands[1]) == 7
5662 || INTVAL (operands[1]) == 15
5663 || INTVAL (operands[1]) == 31
5664 || INTVAL (operands[1]) == 63
5665 || INTVAL (operands[1]) == 127
5666 || INTVAL (operands[1]) == 255)"
5668 (and:SI (match_dup 0)
5673 (if_then_else (match_dup 2)
5674 (label_ref (match_dup 3))
5676 "operands[4] = GEN_INT (~INTVAL (operands[1]));")
5691 (compare (match_operand:SI 0 "register_operand" "")
5692 (match_operand:SI 1 "const_int_operand" "")))
5694 (if_then_else (match_operator 2 "gtuleu_operator"
5695 [(cc0) (const_int 0)])
5696 (label_ref (match_operand 3 "" ""))
5698 "(TARGET_H8300H || TARGET_H8300S)
5699 && peep2_reg_dead_p (1, operands[0])
5700 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
5701 || INTVAL (operands[1]) == 7
5702 || INTVAL (operands[1]) == 15
5703 || INTVAL (operands[1]) == 31
5704 || INTVAL (operands[1]) == 63
5705 || INTVAL (operands[1]) == 127
5706 || INTVAL (operands[1]) == 255)"
5708 (and:SI (match_dup 0)
5713 (if_then_else (match_dup 5)
5714 (label_ref (match_dup 3))
5717 operands[4] = GEN_INT (~INTVAL (operands[1]));
5718 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5736 (compare (match_operand:SI 0 "register_operand" "")
5739 (if_then_else (match_operator 1 "gtle_operator"
5740 [(cc0) (const_int 0)])
5741 (label_ref (match_operand 2 "" ""))
5743 "TARGET_H8300H || TARGET_H8300S"
5745 (and:SI (match_dup 0)
5746 (const_int -65536)))
5748 (if_then_else (match_dup 1)
5749 (label_ref (match_dup 2))
5765 (compare (match_operand:SI 0 "register_operand" "")
5768 (if_then_else (match_operator 1 "gtuleu_operator"
5769 [(cc0) (const_int 0)])
5770 (label_ref (match_operand 2 "" ""))
5772 "TARGET_H8300H || TARGET_H8300S"
5774 (and:SI (match_dup 0)
5775 (const_int -65536)))
5777 (if_then_else (match_dup 3)
5778 (label_ref (match_dup 2))
5781 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
5798 ;; We avoid this transformation if we see more than one copy of the
5799 ;; same compare insn.
5802 [(match_scratch:SI 4 "r")
5804 (compare (match_operand:SI 0 "register_operand" "")
5805 (match_operand:SI 1 "incdec_operand" "")))
5807 (if_then_else (match_operator 3 "eqne_operator"
5808 [(cc0) (const_int 0)])
5809 (label_ref (match_operand 2 "" ""))
5811 "(TARGET_H8300H || TARGET_H8300S)
5812 && !peep2_reg_dead_p (1, operands[0])
5813 && !same_cmp_following_p (insn)"
5817 (unspec:SI [(match_dup 4)
5823 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5824 (label_ref (match_dup 2))
5826 "operands[5] = GEN_INT (- INTVAL (operands[1]));")
5828 ;; Narrow the mode of testing if possible.
5831 [(set (match_operand:HI 0 "register_operand" "")
5832 (and:HI (match_dup 0)
5833 (match_operand:HI 1 "const_int_qi_operand" "")))
5837 (if_then_else (match_operator 3 "eqne_operator"
5838 [(cc0) (const_int 0)])
5839 (label_ref (match_operand 2 "" ""))
5841 "peep2_reg_dead_p (2, operands[0])"
5843 (and:QI (match_dup 4)
5848 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5849 (label_ref (match_dup 2))
5851 "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
5852 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);")
5855 [(set (match_operand:SI 0 "register_operand" "")
5856 (and:SI (match_dup 0)
5857 (match_operand:SI 1 "const_int_qi_operand" "")))
5861 (if_then_else (match_operator 3 "eqne_operator"
5862 [(cc0) (const_int 0)])
5863 (label_ref (match_operand 2 "" ""))
5865 "peep2_reg_dead_p (2, operands[0])"
5867 (and:QI (match_dup 4)
5872 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5873 (label_ref (match_dup 2))
5875 "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
5876 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);")
5879 [(set (match_operand:SI 0 "register_operand" "")
5880 (and:SI (match_dup 0)
5881 (match_operand:SI 1 "const_int_hi_operand" "")))
5885 (if_then_else (match_operator 3 "eqne_operator"
5886 [(cc0) (const_int 0)])
5887 (label_ref (match_operand 2 "" ""))
5889 "peep2_reg_dead_p (2, operands[0])"
5891 (and:HI (match_dup 4)
5896 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5897 (label_ref (match_dup 2))
5899 "operands[4] = gen_rtx_REG (HImode, REGNO (operands[0]));
5900 operands[5] = gen_int_mode (INTVAL (operands[1]), HImode);")
5903 [(set (match_operand:SI 0 "register_operand" "")
5904 (and:SI (match_dup 0)
5905 (match_operand:SI 1 "const_int_qi_operand" "")))
5907 (xor:SI (match_dup 0)
5908 (match_operand:SI 2 "const_int_qi_operand" "")))
5912 (if_then_else (match_operator 4 "eqne_operator"
5913 [(cc0) (const_int 0)])
5914 (label_ref (match_operand 3 "" ""))
5916 "peep2_reg_dead_p (3, operands[0])
5917 && (~INTVAL (operands[1]) & INTVAL (operands[2])) == 0"
5919 (and:QI (match_dup 5)
5922 (xor:QI (match_dup 5)
5927 (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
5928 (label_ref (match_dup 3))
5930 "operands[5] = gen_rtx_REG (QImode, REGNO (operands[0]));
5931 operands[6] = gen_int_mode (INTVAL (operands[1]), QImode);
5932 operands[7] = gen_int_mode (INTVAL (operands[2]), QImode);")
5934 ;; These triggers right at the end of allocation of locals in the
5935 ;; prologue (and possibly at other places).
5937 ;; stack adjustment of -4, generate one push
5939 ;; before : 6 bytes, 10 clocks
5940 ;; after : 4 bytes, 10 clocks
5943 [(set (reg:SI SP_REG)
5944 (plus:SI (reg:SI SP_REG)
5946 (set (mem:SI (reg:SI SP_REG))
5947 (match_operand:SI 0 "register_operand" ""))]
5948 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
5949 && REGNO (operands[0]) != SP_REG"
5950 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
5954 ;; stack adjustment of -12, generate one push
5956 ;; before : 10 bytes, 14 clocks
5957 ;; after : 8 bytes, 14 clocks
5960 [(set (reg:SI SP_REG)
5961 (plus:SI (reg:SI SP_REG)
5963 (set (mem:SI (reg:SI SP_REG))
5964 (match_operand:SI 0 "register_operand" ""))]
5965 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
5966 && REGNO (operands[0]) != SP_REG"
5967 [(set (reg:SI SP_REG)
5968 (plus:SI (reg:SI SP_REG)
5970 (set (reg:SI SP_REG)
5971 (plus:SI (reg:SI SP_REG)
5973 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
5987 ;; if "reg" dies at the end of the sequence.
5989 [(set (match_operand 0 "register_operand" "")
5990 (match_operand 1 "memory_operand" ""))
5992 (match_operator 2 "h8sx_binary_memory_operator"
5994 (match_operand 3 "h8300_src_operand" "")]))
5995 (set (match_operand 4 "memory_operand" "")
5997 "0 /* Disable because it breaks compiling fp-bit.c. */
5999 && peep2_reg_dead_p (3, operands[0])
6000 && !reg_overlap_mentioned_p (operands[0], operands[3])
6001 && !reg_overlap_mentioned_p (operands[0], operands[4])
6002 && h8sx_mergeable_memrefs_p (operands[4], operands[1])"
6006 operands[5] = shallow_copy_rtx (operands[2]);
6007 XEXP (operands[5], 0) = operands[1];
6019 ;; if "reg" dies in the second insn.
6021 [(set (match_operand 0 "register_operand" "")
6022 (match_operand 1 "h8300_src_operand" ""))
6023 (set (match_operand 2 "h8300_dst_operand" "")
6024 (match_operator 3 "h8sx_binary_memory_operator"
6025 [(match_operand 4 "h8300_dst_operand" "")
6027 "0 /* Disable because it breaks compiling fp-bit.c. */
6029 && peep2_reg_dead_p (2, operands[0])
6030 && !reg_overlap_mentioned_p (operands[0], operands[4])"
6034 operands[5] = shallow_copy_rtx (operands[3]);
6035 XEXP (operands[5], 1) = operands[1];
6048 ;; if "reg" dies at the end of the sequence.
6050 [(set (match_operand 0 "register_operand" "")
6051 (match_operand 1 "memory_operand" ""))
6053 (match_operator 2 "h8sx_unary_memory_operator"
6055 (set (match_operand 3 "memory_operand" "")
6058 && peep2_reg_dead_p (3, operands[0])
6059 && !reg_overlap_mentioned_p (operands[0], operands[3])
6060 && h8sx_mergeable_memrefs_p (operands[3], operands[1])"
6064 operands[4] = shallow_copy_rtx (operands[2]);
6065 XEXP (operands[4], 0) = operands[1];
6077 ;; if "reg" dies in the comparison.
6079 [(set (match_operand 0 "register_operand" "")
6080 (match_operand 1 "h8300_dst_operand" ""))
6082 (compare (match_dup 0)
6083 (match_operand 2 "h8300_src_operand" "")))]
6085 && peep2_reg_dead_p (2, operands[0])
6086 && !reg_overlap_mentioned_p (operands[0], operands[2])"
6088 (compare (match_dup 1)
6091 ;; Likewise for the second operand.
6093 [(set (match_operand 0 "register_operand" "")
6094 (match_operand 1 "h8300_src_operand" ""))
6096 (compare (match_operand 2 "h8300_dst_operand" "")
6099 && peep2_reg_dead_p (2, operands[0])
6100 && !reg_overlap_mentioned_p (operands[0], operands[2])"
6102 (compare (match_dup 2)
6105 ;; Combine two moves.
6107 [(set (match_operand 0 "register_operand" "")
6108 (match_operand 1 "h8300_src_operand" ""))
6109 (set (match_operand 2 "h8300_dst_operand" "")
6112 && peep2_reg_dead_p (2, operands[0])
6113 && !reg_overlap_mentioned_p (operands[0], operands[2])"