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, 2005 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, 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, 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 optimization: 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 (include "predicates.md")
181 ;; ----------------------------------------------------------------------
183 ;; ----------------------------------------------------------------------
187 (define_insn "*movqi_h8300"
188 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
189 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
191 && (register_operand (operands[0], QImode)
192 || register_operand (operands[1], QImode))"
200 [(set_attr "length" "2,2,2,2,4,4")
201 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
203 (define_insn "*movqi_h8300hs"
204 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
205 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
206 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
207 && (register_operand (operands[0], QImode)
208 || register_operand (operands[1], QImode))"
216 [(set (attr "length")
217 (symbol_ref "compute_mov_length (operands)"))
218 (set_attr "cc" "set_zn,set_znv,set_znv,clobber,set_znv,set_znv")])
220 (define_insn "*movqi_h8sx"
221 [(set (match_operand:QI 0 "general_operand_dst" "=Z,rQ")
222 (match_operand:QI 1 "general_operand_src" "P4>X,rQi"))]
227 [(set_attr "length_table" "mov_imm4,movb")
228 (set_attr "cc" "set_znv")])
230 (define_expand "movqi"
231 [(set (match_operand:QI 0 "general_operand_dst" "")
232 (match_operand:QI 1 "general_operand_src" ""))]
236 /* One of the ops has to be in a register. */
238 && !register_operand (operand0, QImode)
239 && !register_operand (operand1, QImode))
241 operands[1] = copy_to_mode_reg (QImode, operand1);
245 (define_insn "movstrictqi"
246 [(set (strict_low_part (match_operand:QI 0 "general_operand_dst" "+r,r"))
247 (match_operand:QI 1 "general_operand_src" "I,rmi>"))]
252 [(set_attr "length" "2,*")
253 (set_attr "length_table" "*,movb")
254 (set_attr "cc" "set_zn,set_znv")])
258 (define_insn "*movhi_h8300"
259 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
260 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
262 && (register_operand (operands[0], HImode)
263 || register_operand (operands[1], HImode))
264 && !(GET_CODE (operands[0]) == MEM
265 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
266 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
267 && GET_CODE (operands[1]) == REG
268 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
276 [(set (attr "length")
277 (symbol_ref "compute_mov_length (operands)"))
278 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
280 (define_insn "*movhi_h8300hs"
281 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
282 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
283 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
284 && (register_operand (operands[0], HImode)
285 || register_operand (operands[1], HImode))"
293 [(set (attr "length")
294 (symbol_ref "compute_mov_length (operands)"))
295 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
297 (define_insn "*movhi_h8sx"
298 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Z,Q,rQ")
299 (match_operand:HI 1 "general_operand_src" "I,P3>X,P4>X,IP8>X,rQi"))]
307 [(set_attr "length_table" "*,*,mov_imm4,short_immediate,movw")
308 (set_attr "length" "2,2,*,*,*")
309 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv")])
311 (define_expand "movhi"
312 [(set (match_operand:HI 0 "general_operand_dst" "")
313 (match_operand:HI 1 "general_operand_src" ""))]
317 /* One of the ops has to be in a register. */
318 if (!register_operand (operand1, HImode)
319 && !register_operand (operand0, HImode))
321 operands[1] = copy_to_mode_reg (HImode, operand1);
325 (define_insn "movstricthi"
326 [(set (strict_low_part (match_operand:HI 0 "general_operand_dst" "+r,r,r"))
327 (match_operand:HI 1 "general_operand_src" "I,P3>X,rmi"))]
333 [(set_attr "length" "2,2,*")
334 (set_attr "length_table" "*,*,movw")
335 (set_attr "cc" "set_zn,set_znv,set_znv")])
339 (define_expand "movsi"
340 [(set (match_operand:SI 0 "general_operand_dst" "")
341 (match_operand:SI 1 "general_operand_src" ""))]
347 if (h8300_expand_movsi (operands))
350 else if (!TARGET_H8300SX)
352 /* One of the ops has to be in a register. */
353 if (!register_operand (operand1, SImode)
354 && !register_operand (operand0, SImode))
356 operands[1] = copy_to_mode_reg (SImode, operand1);
361 (define_insn "*movsi_h8300"
362 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,o,<,r")
363 (match_operand:SI 1 "general_operand_src" "I,r,io,r,r,>"))]
365 && (register_operand (operands[0], SImode)
366 || register_operand (operands[1], SImode))"
369 unsigned int rn = -1;
370 switch (which_alternative)
373 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
375 if (REGNO (operands[0]) < REGNO (operands[1]))
376 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
378 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
380 /* Make sure we don't trample the register we index with. */
381 if (GET_CODE (operands[1]) == MEM)
383 rtx inside = XEXP (operands[1], 0);
388 else if (GET_CODE (inside) == PLUS)
390 rtx lhs = XEXP (inside, 0);
391 rtx rhs = XEXP (inside, 1);
392 if (REG_P (lhs)) rn = REGNO (lhs);
393 if (REG_P (rhs)) rn = REGNO (rhs);
396 if (rn == REGNO (operands[0]))
398 /* Move the second word first. */
399 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
403 if (GET_CODE (operands[1]) == CONST_INT)
405 /* If either half is zero, use sub.w to clear that
407 if ((INTVAL (operands[1]) & 0xffff) == 0)
408 return \"mov.w %e1,%e0\;sub.w %f0,%f0\";
409 if (((INTVAL (operands[1]) >> 16) & 0xffff) == 0)
410 return \"sub.w %e0,%e0\;mov.w %f1,%f0\";
411 /* If the upper half and the lower half are the same,
412 copy one half to the other. */
413 if ((INTVAL (operands[1]) & 0xffff)
414 == ((INTVAL (operands[1]) >> 16) & 0xffff))
415 return \"mov.w\\t%e1,%e0\;mov.w\\t%e0,%f0\";
417 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
420 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
422 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
424 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
429 [(set (attr "length")
430 (symbol_ref "compute_mov_length (operands)"))])
432 (define_insn "*movsi_h8300hs"
433 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,<,r,r,m,*a,*a,r")
434 (match_operand:SI 1 "general_operand_src" "I,r,i,r,>,m,r,I,r,*a"))]
435 "(TARGET_H8300S || TARGET_H8300H) && !TARGET_H8300SX
436 && (register_operand (operands[0], SImode)
437 || register_operand (operands[1], SImode))
438 && !(GET_CODE (operands[0]) == MEM
439 && GET_CODE (XEXP (operands[0], 0)) == PRE_DEC
440 && GET_CODE (XEXP (XEXP (operands[0], 0), 0)) == REG
441 && GET_CODE (operands[1]) == REG
442 && REGNO (XEXP (XEXP (operands[0], 0), 0)) == REGNO (operands[1]))"
445 switch (which_alternative)
448 return \"sub.l %S0,%S0\";
452 return \"clrmac\;ldmac %1,macl\";
454 return \"stmac macl,%0\";
456 if (GET_CODE (operands[1]) == CONST_INT)
458 int val = INTVAL (operands[1]);
460 /* Look for constants which can be made by adding an 8-bit
461 number to zero in one of the two low bytes. */
462 if (val == (val & 0xff))
464 operands[1] = GEN_INT ((char) val & 0xff);
465 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%w0\";
468 if (val == (val & 0xff00))
470 operands[1] = GEN_INT ((char) (val >> 8) & 0xff);
471 return \"sub.l\\t%S0,%S0\;add.b\\t%1,%x0\";
474 /* Look for constants that can be obtained by subs, inc, and
476 switch (val & 0xffffffff)
479 return \"sub.l\\t%S0,%S0\;subs\\t#1,%S0\";
481 return \"sub.l\\t%S0,%S0\;subs\\t#2,%S0\";
483 return \"sub.l\\t%S0,%S0\;subs\\t#4,%S0\";
486 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%f0\";
488 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%f0\";
491 return \"sub.l\\t%S0,%S0\;dec.w\\t#1,%e0\";
493 return \"sub.l\\t%S0,%S0\;dec.w\\t#2,%e0\";
496 return \"sub.l\\t%S0,%S0\;inc.w\\t#1,%e0\";
498 return \"sub.l\\t%S0,%S0\;inc.w\\t#2,%e0\";
502 return \"mov.l %S1,%S0\";
504 [(set (attr "length")
505 (symbol_ref "compute_mov_length (operands)"))
506 (set_attr "cc" "set_zn,set_znv,clobber,set_znv,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
508 (define_insn "*movsi_h8sx"
509 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,Q,rQ,*a,*a,r")
510 (match_operand:SI 1 "general_operand_src" "I,P3>X,IP8>X,rQi,I,r,*a"))]
518 clrmac\;ldmac %1,macl
520 [(set_attr "length_table" "*,*,short_immediate,movl,*,*,*")
521 (set_attr "length" "2,2,*,*,2,6,4")
522 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
524 (define_insn "*movsf_h8sx"
525 [(set (match_operand:SF 0 "general_operand_dst" "=r,rQ")
526 (match_operand:SF 1 "general_operand_src" "G,rQi"))]
531 [(set_attr "length" "2,*")
532 (set_attr "length_table" "*,movl")
533 (set_attr "cc" "set_zn,set_znv")])
535 ;; Implement block moves using movmd. Defining movmemsi allows the full
536 ;; range of constant lengths (up to 0x40000 bytes when using movmd.l).
537 ;; See h8sx_emit_movmd for details.
538 (define_expand "movmemsi"
539 [(use (match_operand:BLK 0 "memory_operand" ""))
540 (use (match_operand:BLK 1 "memory_operand" ""))
541 (use (match_operand:SI 2 "" ""))
542 (use (match_operand:SI 3 "const_int_operand" ""))]
545 if (h8sx_emit_movmd (operands[0], operands[1], operands[2],
546 INTVAL (operands[3])))
552 ;; Expander for generating movmd insns. Operand 0 is the destination
553 ;; memory region, operand 1 is the source, operand 2 is the counter
554 ;; register and operand 3 is the chunk size (1, 2 or 4).
555 (define_expand "movmd"
557 [(set (match_operand:BLK 0 "memory_operand" "")
558 (match_operand:BLK 1 "memory_operand" ""))
559 (unspec [(match_operand:HI 2 "register_operand" "")
560 (match_operand:HI 3 "const_int_operand" "")] UNSPEC_MOVMD)
561 (clobber (match_dup 4))
562 (clobber (match_dup 5))
567 operands[4] = copy_rtx (XEXP (operands[0], 0));
568 operands[5] = copy_rtx (XEXP (operands[1], 0));
572 ;; This is a difficult instruction to reload since operand 0 must be the
573 ;; frame pointer. See h8300_reg_class_from_letter for an explanation.
574 (define_insn "movmd_internal_normal"
575 [(set (mem:BLK (match_operand:HI 3 "register_operand" "0,r"))
576 (mem:BLK (match_operand:HI 4 "register_operand" "1,1")))
577 (unspec [(match_operand:HI 5 "register_operand" "2,2")
578 (match_operand:HI 6 "const_int_operand" "n,n")] UNSPEC_MOVMD)
579 (clobber (match_operand:HI 0 "register_operand" "=d,??D"))
580 (clobber (match_operand:HI 1 "register_operand" "=f,f"))
581 (set (match_operand:HI 2 "register_operand" "=c,c")
583 "TARGET_H8300SX && TARGET_NORMAL_MODE"
587 [(set_attr "length" "2,14")
588 (set_attr "can_delay" "no")
589 (set_attr "cc" "none,clobber")])
591 (define_insn "movmd_internal"
592 [(set (mem:BLK (match_operand:SI 3 "register_operand" "0,r"))
593 (mem:BLK (match_operand:SI 4 "register_operand" "1,1")))
594 (unspec [(match_operand:HI 5 "register_operand" "2,2")
595 (match_operand:HI 6 "const_int_operand" "n,n")] UNSPEC_MOVMD)
596 (clobber (match_operand:SI 0 "register_operand" "=d,??D"))
597 (clobber (match_operand:SI 1 "register_operand" "=f,f"))
598 (set (match_operand:HI 2 "register_operand" "=c,c")
600 "TARGET_H8300SX && !TARGET_NORMAL_MODE"
604 [(set_attr "length" "2,14")
605 (set_attr "can_delay" "no")
606 (set_attr "cc" "none,clobber")])
608 ;; Split the above instruction if the destination register isn't er6.
609 ;; We need a sequence like:
617 ;; where <dest> is the current destination register (operand 4).
618 ;; The fourth instruction will be deleted if <dest> dies here.
620 [(set (match_operand:BLK 0 "memory_operand" "")
621 (match_operand:BLK 1 "memory_operand" ""))
622 (unspec [(match_operand:HI 2 "register_operand" "")
623 (match_operand:HI 3 "const_int_operand" "")] UNSPEC_MOVMD)
624 (clobber (match_operand:HI 4 "register_operand" ""))
625 (clobber (match_operand:HI 5 "register_operand" ""))
628 "TARGET_H8300SX && TARGET_NORMAL_MODE
630 && REGNO (operands[4]) != DESTINATION_REG"
635 h8300_swap_into_er6 (XEXP (operands[0], 0));
636 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
637 emit_insn (gen_movmd (dest, operands[1], operands[2], operands[3]));
638 h8300_swap_out_of_er6 (operands[4]);
643 [(set (match_operand:BLK 0 "memory_operand" "")
644 (match_operand:BLK 1 "memory_operand" ""))
645 (unspec [(match_operand:HI 2 "register_operand" "")
646 (match_operand:HI 3 "const_int_operand" "")] UNSPEC_MOVMD)
647 (clobber (match_operand:SI 4 "register_operand" ""))
648 (clobber (match_operand:SI 5 "register_operand" ""))
651 "TARGET_H8300SX && !TARGET_NORMAL_MODE
653 && REGNO (operands[4]) != DESTINATION_REG"
658 h8300_swap_into_er6 (XEXP (operands[0], 0));
659 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
660 emit_insn (gen_movmd (dest, operands[1], operands[2], operands[3]));
661 h8300_swap_out_of_er6 (operands[4]);
665 ;; Expand a call to stpcpy() using movsd. Operand 0 should point to
666 ;; the final character, but movsd leaves it pointing to the character
668 (define_expand "movstr"
669 [(use (match_operand 0 "register_operand" ""))
670 (use (match_operand:BLK 1 "memory_operand" ""))
671 (use (match_operand:BLK 2 "memory_operand" ""))]
674 operands[1] = replace_equiv_address
675 (operands[1], copy_to_mode_reg (Pmode, XEXP (operands[1], 0)));
676 operands[2] = replace_equiv_address
677 (operands[2], copy_to_mode_reg (Pmode, XEXP (operands[2], 0)));
678 emit_insn (gen_movsd (operands[1], operands[2], gen_reg_rtx (Pmode)));
679 emit_insn (gen_add3_insn (operands[0],
680 XEXP (operands[1], 0),
685 ;; Expander for generating a movsd instruction. Operand 0 is the
686 ;; destination string, operand 1 is the source string and operand 2
687 ;; is a scratch register.
688 (define_expand "movsd"
690 [(set (match_operand:BLK 0 "memory_operand" "")
691 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "")]
693 (clobber (match_dup 3))
694 (clobber (match_dup 4))
695 (clobber (match_operand 2 "register_operand" ""))])]
698 operands[3] = copy_rtx (XEXP (operands[0], 0));
699 operands[4] = copy_rtx (XEXP (operands[1], 0));
702 ;; See comments above memcpy_internal().
703 (define_insn "stpcpy_internal_normal"
704 [(set (mem:BLK (match_operand:HI 3 "register_operand" "0,r"))
705 (unspec:BLK [(mem:BLK (match_operand:HI 4 "register_operand" "1,1"))]
707 (clobber (match_operand:HI 0 "register_operand" "=d,??D"))
708 (clobber (match_operand:HI 1 "register_operand" "=f,f"))
709 (clobber (match_operand:HI 2 "register_operand" "=c,c"))]
710 "TARGET_H8300SX && TARGET_NORMAL_MODE"
712 \n1:\tmovsd\t2f\;bra\t1b\n2:
714 [(set_attr "length" "6,18")
715 (set_attr "cc" "none,clobber")])
717 (define_insn "stpcpy_internal"
718 [(set (mem:BLK (match_operand:SI 3 "register_operand" "0,r"))
719 (unspec:BLK [(mem:BLK (match_operand:SI 4 "register_operand" "1,1"))]
721 (clobber (match_operand:SI 0 "register_operand" "=d,??D"))
722 (clobber (match_operand:SI 1 "register_operand" "=f,f"))
723 (clobber (match_operand:SI 2 "register_operand" "=c,c"))]
724 "TARGET_H8300SX && !TARGET_NORMAL_MODE"
726 \n1:\tmovsd\t2f\;bra\t1b\n2:
728 [(set_attr "length" "6,18")
729 (set_attr "cc" "none,clobber")])
731 ;; Split the above instruction if the destination isn't er6. This works
732 ;; in the same way as the movmd splitter.
734 [(set (match_operand:BLK 0 "memory_operand" "")
735 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "")] UNSPEC_STPCPY))
736 (clobber (match_operand:HI 2 "register_operand" ""))
737 (clobber (match_operand:HI 3 "register_operand" ""))
738 (clobber (match_operand:HI 4 "register_operand" ""))]
739 "TARGET_H8300SX && TARGET_NORMAL_MODE
741 && REGNO (operands[2]) != DESTINATION_REG"
746 h8300_swap_into_er6 (XEXP (operands[0], 0));
747 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
748 emit_insn (gen_movsd (dest, operands[1], operands[4]));
749 h8300_swap_out_of_er6 (operands[2]);
754 [(set (match_operand:BLK 0 "memory_operand" "")
755 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "")] UNSPEC_STPCPY))
756 (clobber (match_operand:SI 2 "register_operand" ""))
757 (clobber (match_operand:SI 3 "register_operand" ""))
758 (clobber (match_operand:SI 4 "register_operand" ""))]
759 "TARGET_H8300SX && !TARGET_NORMAL_MODE
761 && REGNO (operands[2]) != DESTINATION_REG"
766 h8300_swap_into_er6 (XEXP (operands[0], 0));
767 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
768 emit_insn (gen_movsd (dest, operands[1], operands[4]));
769 h8300_swap_out_of_er6 (operands[2]);
775 (define_expand "movsf"
776 [(set (match_operand:SF 0 "general_operand_dst" "")
777 (match_operand:SF 1 "general_operand_src" ""))]
783 if (h8300_expand_movsi (operands))
786 else if (!TARGET_H8300SX)
788 /* One of the ops has to be in a register. */
789 if (!register_operand (operand1, SFmode)
790 && !register_operand (operand0, SFmode))
792 operands[1] = copy_to_mode_reg (SFmode, operand1);
797 (define_insn "*movsf_h8300"
798 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,o,<,r")
799 (match_operand:SF 1 "general_operand_src" "G,r,io,r,r,>"))]
801 && (register_operand (operands[0], SFmode)
802 || register_operand (operands[1], SFmode))"
805 /* Copy of the movsi stuff. */
806 unsigned int rn = -1;
807 switch (which_alternative)
810 return \"sub.w %e0,%e0\;sub.w %f0,%f0\";
812 if (REGNO (operands[0]) < REGNO (operands[1]))
813 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
815 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
817 /* Make sure we don't trample the register we index with. */
818 if (GET_CODE (operands[1]) == MEM)
820 rtx inside = XEXP (operands[1], 0);
825 else if (GET_CODE (inside) == PLUS)
827 rtx lhs = XEXP (inside, 0);
828 rtx rhs = XEXP (inside, 1);
829 if (REG_P (lhs)) rn = REGNO (lhs);
830 if (REG_P (rhs)) rn = REGNO (rhs);
833 if (rn == REGNO (operands[0]))
834 /* Move the second word first. */
835 return \"mov.w %f1,%f0\;mov.w %e1,%e0\";
837 /* Move the first word first. */
838 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
841 return \"mov.w %e1,%e0\;mov.w %f1,%f0\";
843 return \"mov.w %f1,%T0\;mov.w %e1,%T0\";
845 return \"mov.w %T1,%e0\;mov.w %T1,%f0\";
850 [(set (attr "length")
851 (symbol_ref "compute_mov_length (operands)"))])
853 (define_insn "*movsf_h8300hs"
854 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,m,<,r")
855 (match_operand:SF 1 "general_operand_src" "G,r,im,r,r,>"))]
856 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
857 && (register_operand (operands[0], SFmode)
858 || register_operand (operands[1], SFmode))"
866 [(set (attr "length")
867 (symbol_ref "compute_mov_length (operands)"))
868 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
870 ;; ----------------------------------------------------------------------
872 ;; ----------------------------------------------------------------------
874 (define_insn "pushqi1_h8300"
875 [(set (reg:HI SP_REG)
876 (plus:HI (reg:HI SP_REG) (const_int -2)))
877 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -1)))
878 (match_operand:QI 0 "register_operand" "r"))]
880 && operands[0] != stack_pointer_rtx"
882 [(set_attr "length" "2")])
884 (define_insn "pushqi1_h8300hs_advanced"
885 [(set (reg:SI SP_REG)
886 (plus:SI (reg:SI SP_REG) (const_int -4)))
887 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
888 (match_operand:QI 0 "register_operand" "r"))]
889 "(TARGET_H8300H || TARGET_H8300S)
890 && operands[0] != stack_pointer_rtx"
892 [(set_attr "length" "4")])
894 (define_insn "pushqi1_h8300hs_normal"
895 [(set (reg:HI SP_REG)
896 (plus:HI (reg:HI SP_REG) (const_int -4)))
897 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
898 (match_operand:QI 0 "register_operand" "r"))]
899 "(TARGET_H8300H || TARGET_H8300S)
900 && operands[0] != stack_pointer_rtx"
902 [(set_attr "length" "4")])
904 (define_expand "pushqi1"
905 [(match_operand:QI 0 "register_operand" "")]
910 emit_insn (gen_pushqi1_h8300 (operands[0]));
911 else if (!TARGET_NORMAL_MODE)
912 emit_insn (gen_pushqi1_h8300hs_advanced (operands[0]));
914 emit_insn (gen_pushqi1_h8300hs_normal (operands[0]));
918 (define_expand "pushhi1_h8300"
919 [(set (mem:HI (pre_dec:HI (reg:HI SP_REG)))
920 (match_operand:HI 0 "register_operand" ""))]
922 && operands[0] != stack_pointer_rtx"
925 (define_insn "pushhi1_h8300hs_advanced"
926 [(set (reg:SI SP_REG)
927 (plus:SI (reg:SI SP_REG) (const_int -4)))
928 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
929 (match_operand:HI 0 "register_operand" "r"))]
930 "(TARGET_H8300H || TARGET_H8300S)
931 && operands[0] != stack_pointer_rtx"
933 [(set_attr "length" "4")])
935 (define_insn "pushhi1_h8300hs_normal"
936 [(set (reg:HI SP_REG)
937 (plus:HI (reg:HI SP_REG) (const_int -4)))
938 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
939 (match_operand:HI 0 "register_operand" "r"))]
940 "(TARGET_H8300H || TARGET_H8300S)
941 && operands[0] != stack_pointer_rtx"
943 [(set_attr "length" "4")])
945 (define_expand "pushhi1"
946 [(match_operand:HI 0 "register_operand" "")]
951 emit_insn (gen_pushhi1_h8300 (operands[0]));
952 else if (!TARGET_NORMAL_MODE)
953 emit_insn (gen_pushhi1_h8300hs_advanced (operands[0]));
955 emit_insn (gen_pushhi1_h8300hs_normal (operands[0]));
959 ;; ----------------------------------------------------------------------
961 ;; ----------------------------------------------------------------------
964 [(set (cc0) (zero_extract:HI (match_operand:QI 0 "bit_memory_operand" "r,U")
966 (match_operand 1 "const_int_operand" "n,n")))]
969 [(set_attr "length" "2,4")
970 (set_attr "cc" "set_zn,set_zn")])
973 [(set (cc0) (zero_extract:HI (match_operand:HI 0 "register_operand" "r")
975 (match_operand 1 "const_int_operand" "n")))]
978 [(set_attr "length" "2")
979 (set_attr "cc" "set_zn")])
981 (define_insn_and_split "*tst_extzv_1_n"
983 (zero_extract:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>")
985 (match_operand 1 "const_int_operand" "n,n,n")))
986 (clobber (match_scratch:QI 2 "=X,X,&r"))]
987 "(TARGET_H8300H || TARGET_H8300S)"
993 && !OK_FOR_U (operands[0])"
996 (parallel [(set (cc0) (zero_extract:SI (match_dup 2)
999 (clobber (scratch:QI))])]
1001 [(set_attr "length" "2,8,10")
1002 (set_attr "cc" "set_zn,set_zn,set_zn")])
1005 [(set (cc0) (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1007 (match_operand 1 "const_int_operand" "n")))]
1008 "(TARGET_H8300H || TARGET_H8300S)
1009 && INTVAL (operands[1]) <= 15"
1011 [(set_attr "length" "2")
1012 (set_attr "cc" "set_zn")])
1014 (define_insn_and_split "*tstsi_upper_bit"
1016 (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1018 (match_operand 1 "const_int_operand" "n")))
1019 (clobber (match_scratch:SI 2 "=&r"))]
1020 "(TARGET_H8300H || TARGET_H8300S)
1021 && INTVAL (operands[1]) >= 16"
1023 "&& reload_completed"
1025 (ior:SI (and:SI (match_dup 2)
1027 (lshiftrt:SI (match_dup 0)
1030 (zero_extract:SI (match_dup 2)
1033 "operands[3] = GEN_INT (INTVAL (operands[1]) - 16);")
1035 (define_insn "*tstsi_variable_bit"
1037 (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
1039 (and:SI (match_operand:SI 1 "register_operand" "r")
1041 "TARGET_H8300H || TARGET_H8300S"
1043 [(set_attr "length" "2")
1044 (set_attr "cc" "set_zn")])
1046 (define_insn_and_split "*tstsi_variable_bit_qi"
1048 (zero_extract:SI (zero_extend:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>"))
1050 (and:SI (match_operand:SI 1 "register_operand" "r,r,r")
1052 (clobber (match_scratch:QI 2 "=X,X,&r"))]
1053 "(TARGET_H8300H || TARGET_H8300S)"
1058 "&& reload_completed
1059 && !OK_FOR_U (operands[0])"
1062 (parallel [(set (cc0) (zero_extract:SI (zero_extend:SI (match_dup 2))
1064 (and:SI (match_dup 1)
1066 (clobber (scratch:QI))])]
1068 [(set_attr "length" "2,8,10")
1069 (set_attr "cc" "set_zn,set_zn,set_zn")])
1071 (define_insn "tstqi"
1072 [(set (cc0) (match_operand:QI 0 "register_operand" "r"))]
1075 [(set_attr "length" "2")
1076 (set_attr "cc" "set_znv")])
1078 (define_insn "tsthi"
1079 [(set (cc0) (match_operand:HI 0 "register_operand" "r"))]
1082 [(set_attr "length" "2")
1083 (set_attr "cc" "set_znv")])
1085 (define_insn "*tsthi_upper"
1087 (and:HI (match_operand:HI 0 "register_operand" "r")
1091 [(set_attr "length" "2")
1092 (set_attr "cc" "set_znv")])
1094 (define_insn "tstsi"
1095 [(set (cc0) (match_operand:SI 0 "register_operand" "r"))]
1096 "TARGET_H8300H || TARGET_H8300S"
1098 [(set_attr "length" "2")
1099 (set_attr "cc" "set_znv")])
1101 (define_insn "*tstsi_upper"
1103 (and:SI (match_operand:SI 0 "register_operand" "r")
1104 (const_int -65536)))]
1107 [(set_attr "length" "2")
1108 (set_attr "cc" "set_znv")])
1110 (define_insn "cmpqi"
1112 (compare (match_operand:QI 0 "h8300_dst_operand" "rQ")
1113 (match_operand:QI 1 "h8300_src_operand" "rQi")))]
1116 [(set_attr "length_table" "addb")
1117 (set_attr "cc" "compare")])
1119 (define_expand "cmphi"
1121 (compare (match_operand:HI 0 "h8300_dst_operand" "")
1122 (match_operand:HI 1 "h8300_src_operand" "")))]
1126 /* Force operand1 into a register if we're compiling
1128 if (GET_CODE (operands[1]) != REG && TARGET_H8300)
1129 operands[1] = force_reg (HImode, operands[1]);
1132 (define_insn "*cmphi_h8300_znvc"
1134 (compare (match_operand:HI 0 "register_operand" "r")
1135 (match_operand:HI 1 "register_operand" "r")))]
1138 [(set_attr "length" "2")
1139 (set_attr "cc" "compare")])
1141 (define_insn "*cmphi_h8300hs_znvc"
1143 (compare (match_operand:HI 0 "h8300_dst_operand" "rU,rQ")
1144 (match_operand:HI 1 "h8300_src_operand" "P3>X,rQi")))]
1145 "TARGET_H8300H || TARGET_H8300S"
1147 [(set_attr "length_table" "short_immediate,addw")
1148 (set_attr "cc" "compare,compare")])
1150 (define_insn "cmpsi"
1152 (compare (match_operand:SI 0 "h8300_dst_operand" "r,rQ")
1153 (match_operand:SI 1 "h8300_src_operand" "P3>X,rQi")))]
1154 "TARGET_H8300H || TARGET_H8300S"
1156 [(set_attr "length" "2,*")
1157 (set_attr "length_table" "*,addl")
1158 (set_attr "cc" "compare,compare")])
1160 ;; ----------------------------------------------------------------------
1162 ;; ----------------------------------------------------------------------
1164 (define_expand "addqi3"
1165 [(set (match_operand:QI 0 "register_operand" "")
1166 (plus:QI (match_operand:QI 1 "register_operand" "")
1167 (match_operand:QI 2 "h8300_src_operand" "")))]
1171 (define_insn "*addqi3"
1172 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
1173 (plus:QI (match_operand:QI 1 "h8300_dst_operand" "%0")
1174 (match_operand:QI 2 "h8300_src_operand" "rQi")))]
1175 "h8300_operands_match_p (operands)"
1177 [(set_attr "length_table" "addb")
1178 (set_attr "cc" "set_zn")])
1180 (define_expand "addhi3"
1181 [(set (match_operand:HI 0 "register_operand" "")
1182 (plus:HI (match_operand:HI 1 "register_operand" "")
1183 (match_operand:HI 2 "h8300_src_operand" "")))]
1187 (define_insn "*addhi3_h8300"
1188 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
1189 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
1190 (match_operand:HI 2 "h8300_src_operand" "L,N,J,n,r")))]
1196 add.b %s2,%s0\;addx %t2,%t0
1198 [(set_attr "length" "2,2,2,4,2")
1199 (set_attr "cc" "none_0hit,none_0hit,clobber,clobber,set_zn")])
1201 ;; This splitter is very important to make the stack adjustment
1202 ;; interrupt-safe. The combination of add.b and addx is unsafe!
1204 ;; We apply this split after the peephole2 pass so that we won't end
1205 ;; up creating too many adds/subs when a scratch register is
1206 ;; available, which is actually a common case because stack unrolling
1207 ;; tends to happen immediately after a function call.
1210 [(set (match_operand:HI 0 "stack_pointer_operand" "")
1211 (plus:HI (match_dup 0)
1212 (match_operand 1 "const_int_gt_2_operand" "")))]
1213 "TARGET_H8300 && flow2_completed"
1215 "split_adds_subs (HImode, operands); DONE;")
1218 [(match_scratch:HI 2 "r")
1219 (set (match_operand:HI 0 "stack_pointer_operand" "")
1220 (plus:HI (match_dup 0)
1221 (match_operand:HI 1 "const_int_ge_8_operand" "")))]
1226 (plus:HI (match_dup 0)
1230 (define_insn "*addhi3_h8300hs"
1231 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
1232 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
1233 (match_operand:HI 2 "h8300_src_operand" "L,N,J,n,r")))]
1234 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX"
1241 [(set_attr "length" "2,2,2,4,2")
1242 (set_attr "cc" "none_0hit,none_0hit,clobber,set_zn,set_zn")])
1244 (define_insn "*addhi3_incdec"
1245 [(set (match_operand:HI 0 "register_operand" "=r,r")
1246 (unspec:HI [(match_operand:HI 1 "register_operand" "0,0")
1247 (match_operand:HI 2 "incdec_operand" "M,O")]
1249 "TARGET_H8300H || TARGET_H8300S"
1253 [(set_attr "length" "2,2")
1254 (set_attr "cc" "set_zn,set_zn")])
1256 (define_insn "*addhi3_h8sx"
1257 [(set (match_operand:HI 0 "h8300_dst_operand" "=rU,rU,r,rQ")
1258 (plus:HI (match_operand:HI 1 "h8300_dst_operand" "%0,0,0,0")
1259 (match_operand:HI 2 "h8300_src_operand" "P3>X,P3<X,J,rQi")))]
1260 "TARGET_H8300SX && h8300_operands_match_p (operands)"
1266 [(set_attr "length_table" "short_immediate,short_immediate,*,addw")
1267 (set_attr "length" "*,*,2,*")
1268 (set_attr "cc" "set_zn")])
1271 [(set (match_operand:HI 0 "register_operand" "")
1272 (plus:HI (match_dup 0)
1273 (match_operand:HI 1 "two_insn_adds_subs_operand" "")))]
1276 "split_adds_subs (HImode, operands); DONE;")
1278 (define_expand "addsi3"
1279 [(set (match_operand:SI 0 "register_operand" "")
1280 (plus:SI (match_operand:SI 1 "register_operand" "")
1281 (match_operand:SI 2 "h8300_src_operand" "")))]
1285 (define_insn "*addsi_h8300"
1286 [(set (match_operand:SI 0 "register_operand" "=r,r")
1287 (plus:SI (match_operand:SI 1 "register_operand" "%0,0")
1288 (match_operand:SI 2 "h8300_src_operand" "n,r")))]
1290 "* return output_plussi (operands);"
1291 [(set (attr "length")
1292 (symbol_ref "compute_plussi_length (operands)"))
1294 (symbol_ref "compute_plussi_cc (operands)"))])
1296 (define_insn "*addsi_h8300hs"
1297 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ,rQ")
1298 (plus:SI (match_operand:SI 1 "h8300_dst_operand" "%0,0")
1299 (match_operand:SI 2 "h8300_src_operand" "i,rQ")))]
1300 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
1301 "* return output_plussi (operands);"
1302 [(set (attr "length")
1303 (symbol_ref "compute_plussi_length (operands)"))
1305 (symbol_ref "compute_plussi_cc (operands)"))])
1307 (define_insn "*addsi3_incdec"
1308 [(set (match_operand:SI 0 "register_operand" "=r,r")
1309 (unspec:SI [(match_operand:SI 1 "register_operand" "0,0")
1310 (match_operand:SI 2 "incdec_operand" "M,O")]
1312 "TARGET_H8300H || TARGET_H8300S"
1316 [(set_attr "length" "2,2")
1317 (set_attr "cc" "set_zn,set_zn")])
1320 [(set (match_operand:SI 0 "register_operand" "")
1321 (plus:SI (match_dup 0)
1322 (match_operand:SI 1 "two_insn_adds_subs_operand" "")))]
1323 "TARGET_H8300H || TARGET_H8300S"
1325 "split_adds_subs (SImode, operands); DONE;")
1327 ;; ----------------------------------------------------------------------
1328 ;; SUBTRACT INSTRUCTIONS
1329 ;; ----------------------------------------------------------------------
1331 (define_expand "subqi3"
1332 [(set (match_operand:QI 0 "register_operand" "")
1333 (minus:QI (match_operand:QI 1 "register_operand" "")
1334 (match_operand:QI 2 "h8300_src_operand" "")))]
1338 (define_insn "*subqi3"
1339 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
1340 (minus:QI (match_operand:QI 1 "h8300_dst_operand" "0")
1341 (match_operand:QI 2 "h8300_dst_operand" "rQ")))]
1342 "h8300_operands_match_p (operands)"
1344 [(set_attr "length_table" "addb")
1345 (set_attr "cc" "set_zn")])
1347 (define_expand "subhi3"
1348 [(set (match_operand:HI 0 "register_operand" "")
1349 (minus:HI (match_operand:HI 1 "register_operand" "")
1350 (match_operand:HI 2 "h8300_src_operand" "")))]
1354 (define_insn "*subhi3_h8300"
1355 [(set (match_operand:HI 0 "register_operand" "=r,r")
1356 (minus:HI (match_operand:HI 1 "register_operand" "0,0")
1357 (match_operand:HI 2 "h8300_src_operand" "r,n")))]
1361 add.b %E2,%s0\;addx %F2,%t0"
1362 [(set_attr "length" "2,4")
1363 (set_attr "cc" "set_zn,clobber")])
1365 (define_insn "*subhi3_h8300hs"
1366 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ,rQ")
1367 (minus:HI (match_operand:HI 1 "h8300_dst_operand" "0,0")
1368 (match_operand:HI 2 "h8300_src_operand" "rQ,i")))]
1369 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
1373 [(set_attr "length_table" "addw")
1374 (set_attr "cc" "set_zn")])
1376 (define_expand "subsi3"
1377 [(set (match_operand:SI 0 "register_operand" "")
1378 (minus:SI (match_operand:SI 1 "register_operand" "")
1379 (match_operand:SI 2 "h8300_src_operand" "")))]
1383 operands[2] = force_reg (SImode, operands[2]);
1386 (define_insn "*subsi3_h8300"
1387 [(set (match_operand:SI 0 "register_operand" "=r")
1388 (minus:SI (match_operand:SI 1 "register_operand" "0")
1389 (match_operand:SI 2 "register_operand" "r")))]
1391 "sub.w %f2,%f0\;subx %y2,%y0\;subx %z2,%z0"
1392 [(set_attr "length" "6")])
1394 (define_insn "*subsi3_h8300hs"
1395 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ,rQ")
1396 (minus:SI (match_operand:SI 1 "h8300_dst_operand" "0,0")
1397 (match_operand:SI 2 "h8300_src_operand" "rQ,i")))]
1398 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
1402 [(set_attr "length_table" "addl")
1403 (set_attr "cc" "set_zn")])
1405 ;; ----------------------------------------------------------------------
1406 ;; MULTIPLY INSTRUCTIONS
1407 ;; ----------------------------------------------------------------------
1409 ;; Note that the H8/300 can only handle umulqihi3.
1411 (define_expand "mulqihi3"
1412 [(set (match_operand:HI 0 "register_operand" "")
1413 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" ""))
1414 ;; intentionally-mismatched modes
1415 (match_operand:QI 2 "reg_or_nibble_operand" "")))]
1416 "TARGET_H8300H || TARGET_H8300S"
1419 if (GET_MODE (operands[2]) != VOIDmode)
1420 operands[2] = gen_rtx_SIGN_EXTEND (HImode, operands[2]);
1423 (define_insn "*mulqihi3_const"
1424 [(set (match_operand:HI 0 "register_operand" "=r")
1425 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1426 (match_operand:QI 2 "nibble_operand" "IP4>X")))]
1429 [(set_attr "length" "4")
1430 (set_attr "cc" "set_zn")])
1432 (define_insn "*mulqihi3"
1433 [(set (match_operand:HI 0 "register_operand" "=r")
1434 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1435 (sign_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1436 "TARGET_H8300H || TARGET_H8300S"
1438 [(set_attr "length" "4")
1439 (set_attr "cc" "set_zn")])
1441 (define_expand "mulhisi3"
1442 [(set (match_operand:SI 0 "register_operand" "")
1443 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" ""))
1444 ;; intentionally-mismatched modes
1445 (match_operand:HI 2 "reg_or_nibble_operand" "")))]
1446 "TARGET_H8300H || TARGET_H8300S"
1449 if (GET_MODE (operands[2]) != VOIDmode)
1450 operands[2] = gen_rtx_SIGN_EXTEND (SImode, operands[2]);
1453 (define_insn "*mulhisi3_const"
1454 [(set (match_operand:SI 0 "register_operand" "=r")
1455 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1456 (match_operand:SI 2 "nibble_operand" "IP4>X")))]
1459 [(set_attr "length" "4")
1460 (set_attr "cc" "set_zn")])
1462 (define_insn "*mulhisi3"
1463 [(set (match_operand:SI 0 "register_operand" "=r")
1464 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1465 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1466 "TARGET_H8300H || TARGET_H8300S"
1468 [(set_attr "length" "4")
1469 (set_attr "cc" "set_zn")])
1471 (define_expand "umulqihi3"
1472 [(set (match_operand:HI 0 "register_operand" "")
1473 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" ""))
1474 ;; intentionally-mismatched modes
1475 (match_operand:QI 2 "reg_or_nibble_operand" "")))]
1476 "TARGET_H8300H || TARGET_H8300S"
1479 if (GET_MODE (operands[2]) != VOIDmode)
1480 operands[2] = gen_rtx_ZERO_EXTEND (HImode, operands[2]);
1483 (define_insn "*umulqihi3_const"
1484 [(set (match_operand:HI 0 "register_operand" "=r")
1485 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1486 (match_operand:QI 2 "nibble_operand" "IP4>X")))]
1489 [(set_attr "length" "4")
1490 (set_attr "cc" "set_zn")])
1492 (define_insn "*umulqihi3"
1493 [(set (match_operand:HI 0 "register_operand" "=r")
1494 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1495 (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1498 [(set_attr "length" "2")
1499 (set_attr "cc" "none_0hit")])
1501 (define_expand "umulhisi3"
1502 [(set (match_operand:SI 0 "register_operand" "")
1503 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" ""))
1504 ;; intentionally-mismatched modes
1505 (match_operand:HI 2 "reg_or_nibble_operand" "")))]
1506 "TARGET_H8300H || TARGET_H8300S"
1509 if (GET_MODE (operands[2]) != VOIDmode)
1510 operands[2] = gen_rtx_ZERO_EXTEND (SImode, operands[2]);
1513 (define_insn "*umulhisi3_const"
1514 [(set (match_operand:SI 0 "register_operand" "=r")
1515 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1516 (match_operand:SI 2 "nibble_operand" "IP4>X")))]
1519 [(set_attr "length" "4")
1520 (set_attr "cc" "set_zn")])
1522 (define_insn "*umulhisi3"
1523 [(set (match_operand:SI 0 "register_operand" "=r")
1524 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1525 (zero_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1526 "TARGET_H8300H || TARGET_H8300S"
1528 [(set_attr "length" "2")
1529 (set_attr "cc" "none_0hit")])
1531 ;; We could have used mulu.[wl] here, but mulu.[lw] is only available
1532 ;; on a H8SX with a multiplier, whereas muls.w seems to be available
1533 ;; on all H8SX variants.
1534 (define_insn "mulhi3"
1535 [(set (match_operand:HI 0 "register_operand" "=r")
1536 (mult:HI (match_operand:HI 1 "register_operand" "%0")
1537 (match_operand:HI 2 "reg_or_nibble_operand" "r IP4>X")))]
1540 [(set_attr "length" "2")
1541 (set_attr "cc" "set_zn")])
1543 (define_insn "mulsi3"
1544 [(set (match_operand:SI 0 "register_operand" "=r")
1545 (mult:SI (match_operand:SI 1 "register_operand" "%0")
1546 (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))]
1549 [(set_attr "length" "2")
1550 (set_attr "cc" "set_zn")])
1552 (define_insn "smulsi3_highpart"
1553 [(set (match_operand:SI 0 "register_operand" "=r")
1557 (sign_extend:DI (match_operand:SI 1 "register_operand" "%0"))
1558 (sign_extend:DI (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))
1561 "muls/u.l\\t%S2,%S0"
1562 [(set_attr "length" "2")
1563 (set_attr "cc" "set_zn")])
1565 (define_insn "umulsi3_highpart"
1566 [(set (match_operand:SI 0 "register_operand" "=r")
1570 (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
1571 (zero_extend:DI (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))
1574 "mulu/u.l\\t%S2,%S0"
1575 [(set_attr "length" "2")
1576 (set_attr "cc" "none_0hit")])
1578 ;; This is a "bridge" instruction. Combine can't cram enough insns
1579 ;; together to crate a MAC instruction directly, but it can create
1580 ;; this instruction, which then allows combine to create the real
1583 ;; Unfortunately, if combine doesn't create a MAC instruction, this
1584 ;; insn must generate reasonably correct code. Egad.
1586 [(set (match_operand:SI 0 "register_operand" "=a")
1589 (mem:HI (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1591 (mem:HI (post_inc:SI (match_operand:SI 2 "register_operand" "r"))))))]
1593 "clrmac\;mac @%2+,@%1+"
1594 [(set_attr "length" "6")
1595 (set_attr "cc" "none_0hit")])
1598 [(set (match_operand:SI 0 "register_operand" "=a")
1600 (sign_extend:SI (mem:HI
1601 (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1602 (sign_extend:SI (mem:HI
1603 (post_inc:SI (match_operand:SI 2 "register_operand" "r")))))
1604 (match_operand:SI 3 "register_operand" "0")))]
1607 [(set_attr "length" "4")
1608 (set_attr "cc" "none_0hit")])
1610 ;; ----------------------------------------------------------------------
1611 ;; DIVIDE/MOD INSTRUCTIONS
1612 ;; ----------------------------------------------------------------------
1614 (define_insn "udivhi3"
1615 [(set (match_operand:HI 0 "register_operand" "=r")
1617 (match_operand:HI 1 "register_operand" "0")
1618 (match_operand:HI 2 "reg_or_nibble_operand" "r IP4>X")))]
1621 [(set_attr "length" "2")])
1623 (define_insn "divhi3"
1624 [(set (match_operand:HI 0 "register_operand" "=r")
1626 (match_operand:HI 1 "register_operand" "0")
1627 (match_operand:HI 2 "reg_or_nibble_operand" "r IP4>X")))]
1630 [(set_attr "length" "2")])
1632 (define_insn "udivsi3"
1633 [(set (match_operand:SI 0 "register_operand" "=r")
1635 (match_operand:SI 1 "register_operand" "0")
1636 (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))]
1639 [(set_attr "length" "2")])
1641 (define_insn "divsi3"
1642 [(set (match_operand:SI 0 "register_operand" "=r")
1644 (match_operand:SI 1 "register_operand" "0")
1645 (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))]
1648 [(set_attr "length" "2")])
1650 (define_insn "udivmodqi4"
1651 [(set (match_operand:QI 0 "register_operand" "=r")
1654 (match_operand:HI 1 "register_operand" "0")
1655 (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1656 (set (match_operand:QI 3 "register_operand" "=r")
1660 (zero_extend:HI (match_dup 2)))))]
1664 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1665 return \"divxu.b\\t%X2,%T0\";
1667 return \"divxu.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
1669 [(set_attr "length" "4")])
1671 (define_insn "divmodqi4"
1672 [(set (match_operand:QI 0 "register_operand" "=r")
1675 (match_operand:HI 1 "register_operand" "0")
1676 (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1677 (set (match_operand:QI 3 "register_operand" "=r")
1681 (sign_extend:HI (match_dup 2)))))]
1682 "TARGET_H8300H || TARGET_H8300S"
1685 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1686 return \"divxs.b\\t%X2,%T0\";
1688 return \"divxs.b\\t%X2,%T0\;mov.b\\t%t0,%s3\";
1690 [(set_attr "length" "6")])
1692 (define_insn "udivmodhi4"
1693 [(set (match_operand:HI 0 "register_operand" "=r")
1696 (match_operand:SI 1 "register_operand" "0")
1697 (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1698 (set (match_operand:HI 3 "register_operand" "=r")
1702 (zero_extend:SI (match_dup 2)))))]
1703 "TARGET_H8300H || TARGET_H8300S"
1706 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1707 return \"divxu.w\\t%T2,%S0\";
1709 return \"divxu.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
1711 [(set_attr "length" "4")])
1713 (define_insn "divmodhi4"
1714 [(set (match_operand:HI 0 "register_operand" "=r")
1717 (match_operand:SI 1 "register_operand" "0")
1718 (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1719 (set (match_operand:HI 3 "register_operand" "=r")
1723 (sign_extend:SI (match_dup 2)))))]
1724 "TARGET_H8300H || TARGET_H8300S"
1727 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1728 return \"divxs.w\\t%T2,%S0\";
1730 return \"divxs.w\\t%T2,%S0\;mov.w\\t%e0,%f3\";
1732 [(set_attr "length" "6")])
1734 ;; ----------------------------------------------------------------------
1736 ;; ----------------------------------------------------------------------
1738 (define_insn "*andqi3_2"
1739 [(set (match_operand:QI 0 "bit_operand" "=rQ,r")
1740 (and:QI (match_operand:QI 1 "bit_operand" "%0,WU")
1741 (match_operand:QI 2 "h8300_src_operand" "rQi,IP1>X")))]
1746 [(set_attr "length" "*,8")
1747 (set_attr "length_table" "logicb,*")
1748 (set_attr "cc" "set_znv,none_0hit")])
1750 (define_insn "andqi3_1"
1751 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1752 (and:QI (match_operand:QI 1 "bit_operand" "%0,0")
1753 (match_operand:QI 2 "h8300_src_operand" "rn,n")))]
1754 "register_operand (operands[0], QImode)
1755 || single_zero_operand (operands[2], QImode)"
1759 [(set_attr "length" "2,8")
1760 (set_attr "cc" "set_znv,none_0hit")])
1762 (define_expand "andqi3"
1763 [(set (match_operand:QI 0 "register_operand" "")
1764 (and:QI (match_operand:QI 1 "register_operand" "")
1765 (match_operand:QI 2 "h8300_src_operand" "")))]
1769 (define_expand "andhi3"
1770 [(set (match_operand:HI 0 "register_operand" "")
1771 (and:HI (match_operand:HI 1 "register_operand" "")
1772 (match_operand:HI 2 "h8300_src_operand" "")))]
1776 (define_insn "*andorqi3"
1777 [(set (match_operand:QI 0 "register_operand" "=r")
1778 (ior:QI (and:QI (match_operand:QI 2 "register_operand" "r")
1779 (match_operand:QI 3 "single_one_operand" "n"))
1780 (match_operand:QI 1 "register_operand" "0")))]
1782 "bld\\t%V3,%X2\;bor\\t%V3,%X0\;bst\\t%V3,%X0"
1783 [(set_attr "length" "6")])
1785 (define_insn "*andorhi3"
1786 [(set (match_operand:HI 0 "register_operand" "=r")
1787 (ior:HI (and:HI (match_operand:HI 2 "register_operand" "r")
1788 (match_operand:HI 3 "single_one_operand" "n"))
1789 (match_operand:HI 1 "register_operand" "0")))]
1793 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1794 if (INTVAL (operands[3]) > 128)
1796 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1797 return \"bld\\t%V3,%t2\;bor\\t%V3,%t0\;bst\\t%V3,%t0\";
1799 return \"bld\\t%V3,%s2\;bor\\t%V3,%s0\;bst\\t%V3,%s0\";
1801 [(set_attr "length" "6")])
1803 (define_insn "*andorsi3"
1804 [(set (match_operand:SI 0 "register_operand" "=r")
1805 (ior:SI (and:SI (match_operand:SI 2 "register_operand" "r")
1806 (match_operand:SI 3 "single_one_operand" "n"))
1807 (match_operand:SI 1 "register_operand" "0")))]
1808 "(INTVAL (operands[3]) & 0xffff) != 0"
1811 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1812 if (INTVAL (operands[3]) > 128)
1814 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1815 return \"bld\\t%V3,%x2\;bor\\t%V3,%x0\;bst\\t%V3,%x0\";
1817 return \"bld\\t%V3,%w2\;bor\\t%V3,%w0\;bst\\t%V3,%w0\";
1819 [(set_attr "length" "6")])
1821 (define_insn "*andorsi3_shift_8"
1822 [(set (match_operand:SI 0 "register_operand" "=r")
1823 (ior:SI (and:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
1826 (match_operand:SI 1 "register_operand" "0")))]
1829 [(set_attr "length" "2")])
1831 (define_expand "andsi3"
1832 [(set (match_operand:SI 0 "register_operand" "")
1833 (and:SI (match_operand:SI 1 "register_operand" "")
1834 (match_operand:SI 2 "h8300_src_operand" "")))]
1838 ;; ----------------------------------------------------------------------
1840 ;; ----------------------------------------------------------------------
1842 (define_insn "iorqi3_1"
1843 [(set (match_operand:QI 0 "bit_operand" "=rQ,U")
1844 (ior:QI (match_operand:QI 1 "bit_operand" "%0,0")
1845 (match_operand:QI 2 "h8300_src_operand" "rQi,n")))]
1846 "TARGET_H8300SX || register_operand (operands[0], QImode)
1847 || single_one_operand (operands[2], QImode)"
1851 [(set_attr "length" "*,8")
1852 (set_attr "length_table" "logicb,*")
1853 (set_attr "cc" "set_znv,none_0hit")])
1855 (define_expand "iorqi3"
1856 [(set (match_operand:QI 0 "register_operand" "")
1857 (ior:QI (match_operand:QI 1 "register_operand" "")
1858 (match_operand:QI 2 "h8300_src_operand" "")))]
1862 (define_expand "iorhi3"
1863 [(set (match_operand:HI 0 "register_operand" "")
1864 (ior:HI (match_operand:HI 1 "register_operand" "")
1865 (match_operand:HI 2 "h8300_src_operand" "")))]
1869 (define_expand "iorsi3"
1870 [(set (match_operand:SI 0 "register_operand" "")
1871 (ior:SI (match_operand:SI 1 "register_operand" "")
1872 (match_operand:SI 2 "h8300_src_operand" "")))]
1876 ;; ----------------------------------------------------------------------
1878 ;; ----------------------------------------------------------------------
1880 (define_insn "xorqi3_1"
1881 [(set (match_operand:QI 0 "bit_operand" "=r,U")
1882 (xor:QI (match_operand:QI 1 "bit_operand" "%0,0")
1883 (match_operand:QI 2 "h8300_src_operand" "rQi,n")))]
1884 "TARGET_H8300SX || register_operand (operands[0], QImode)
1885 || single_one_operand (operands[2], QImode)"
1889 [(set_attr "length" "*,8")
1890 (set_attr "length_table" "logicb,*")
1891 (set_attr "cc" "set_znv,none_0hit")])
1893 (define_expand "xorqi3"
1894 [(set (match_operand:QI 0 "register_operand" "")
1895 (xor:QI (match_operand:QI 1 "register_operand" "")
1896 (match_operand:QI 2 "h8300_src_operand" "")))]
1900 (define_expand "xorhi3"
1901 [(set (match_operand:HI 0 "register_operand" "")
1902 (xor:HI (match_operand:HI 1 "register_operand" "")
1903 (match_operand:HI 2 "h8300_src_operand" "")))]
1907 (define_expand "xorsi3"
1908 [(set (match_operand:SI 0 "register_operand" "")
1909 (xor:SI (match_operand:SI 1 "register_operand" "")
1910 (match_operand:SI 2 "h8300_src_operand" "")))]
1914 ;; ----------------------------------------------------------------------
1915 ;; {AND,IOR,XOR}{HI3,SI3} PATTERNS
1916 ;; ----------------------------------------------------------------------
1918 ;; We need a separate pattern here because machines other than the
1919 ;; original H8300 don't have to split the 16-bit operand into a pair
1920 ;; of high/low instructions, so we can accept literal addresses, that
1921 ;; have to be loaded into a register on H8300.
1922 (define_insn "*logicalhi3_sn"
1923 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
1924 (match_operator:HI 3 "bit_operator"
1925 [(match_operand:HI 1 "h8300_dst_operand" "%0")
1926 (match_operand:HI 2 "h8300_src_operand" "rQi")]))]
1927 "(TARGET_H8300S || TARGET_H8300H) && h8300_operands_match_p (operands)"
1928 "* return output_logical_op (HImode, operands);"
1929 [(set (attr "length")
1930 (symbol_ref "compute_logical_op_length (HImode, operands)"))
1932 (symbol_ref "compute_logical_op_cc (HImode, operands)"))])
1934 (define_insn "*logicalsi3_sn"
1935 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
1936 (match_operator:SI 3 "bit_operator"
1937 [(match_operand:SI 1 "h8300_dst_operand" "%0")
1938 (match_operand:SI 2 "h8300_src_operand" "rQi")]))]
1939 "(TARGET_H8300S || TARGET_H8300H) && h8300_operands_match_p (operands)"
1940 "* return output_logical_op (SImode, operands);"
1941 [(set (attr "length")
1942 (symbol_ref "compute_logical_op_length (SImode, operands)"))
1944 (symbol_ref "compute_logical_op_cc (SImode, operands)"))])
1946 (define_insn "*logicalhi3"
1947 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
1948 (match_operator:HI 3 "bit_operator"
1949 [(match_operand:HI 1 "h8300_dst_operand" "%0")
1950 (match_operand:HI 2 "h8300_src_operand" "rQi")]))]
1951 "h8300_operands_match_p (operands)"
1952 "* return output_logical_op (HImode, operands);"
1953 [(set (attr "length")
1954 (symbol_ref "compute_logical_op_length (HImode, operands)"))
1956 (symbol_ref "compute_logical_op_cc (HImode, operands)"))])
1958 (define_insn "*logicalsi3"
1959 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
1960 (match_operator:SI 3 "bit_operator"
1961 [(match_operand:SI 1 "h8300_dst_operand" "%0")
1962 (match_operand:SI 2 "h8300_src_operand" "rQi")]))]
1963 "h8300_operands_match_p (operands)"
1964 "* return output_logical_op (SImode, operands);"
1965 [(set (attr "length")
1966 (symbol_ref "compute_logical_op_length (SImode, operands)"))
1968 (symbol_ref "compute_logical_op_cc (SImode, operands)"))])
1970 ;; ----------------------------------------------------------------------
1971 ;; NEGATION INSTRUCTIONS
1972 ;; ----------------------------------------------------------------------
1974 (define_expand "negqi2"
1975 [(set (match_operand:QI 0 "register_operand" "")
1976 (neg:QI (match_operand:QI 1 "register_operand" "")))]
1980 (define_insn "*negqi2"
1981 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
1982 (neg:QI (match_operand:QI 1 "h8300_dst_operand" "0")))]
1985 [(set_attr "length_table" "unary")
1986 (set_attr "cc" "set_zn")])
1988 (define_expand "neghi2"
1989 [(set (match_operand:HI 0 "register_operand" "")
1990 (neg:HI (match_operand:HI 1 "register_operand" "")))]
1996 emit_insn (gen_neghi2_h8300 (operands[0], operands[1]));
2001 (define_expand "neghi2_h8300"
2003 (not:HI (match_operand:HI 1 "register_operand" "")))
2004 (set (match_dup 2) (plus:HI (match_dup 2) (const_int 1)))
2005 (set (match_operand:HI 0 "register_operand" "")
2008 "operands[2] = gen_reg_rtx (HImode);")
2010 (define_insn "*neghi2_h8300hs"
2011 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
2012 (neg:HI (match_operand:HI 1 "h8300_dst_operand" "0")))]
2013 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2015 [(set_attr "length_table" "unary")
2016 (set_attr "cc" "set_zn")])
2018 (define_expand "negsi2"
2019 [(set (match_operand:SI 0 "register_operand" "")
2020 (neg:SI (match_operand:SI 1 "register_operand" "")))]
2026 emit_insn (gen_negsi2_h8300 (operands[0], operands[1]));
2031 (define_expand "negsi2_h8300"
2033 (not:SI (match_operand:SI 1 "register_operand" "")))
2034 (set (match_dup 2) (plus:SI (match_dup 2) (const_int 1)))
2035 (set (match_operand:SI 0 "register_operand" "")
2038 "operands[2] = gen_reg_rtx (SImode);")
2040 (define_insn "*negsi2_h8300hs"
2041 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2042 (neg:SI (match_operand:SI 1 "h8300_dst_operand" "0")))]
2043 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2045 [(set_attr "length_table" "unary")
2046 (set_attr "cc" "set_zn")])
2048 (define_expand "negsf2"
2049 [(set (match_operand:SF 0 "register_operand" "")
2050 (neg:SF (match_operand:SF 1 "register_operand" "")))]
2054 (define_insn "*negsf2_h8300"
2055 [(set (match_operand:SF 0 "register_operand" "=r")
2056 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
2059 [(set_attr "length" "2")])
2061 (define_insn "*negsf2_h8300hs"
2062 [(set (match_operand:SF 0 "register_operand" "=r")
2063 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
2064 "TARGET_H8300H || TARGET_H8300S"
2065 "xor.w\\t#32768,%e0"
2066 [(set_attr "length" "4")])
2068 ;; ----------------------------------------------------------------------
2069 ;; ABSOLUTE VALUE INSTRUCTIONS
2070 ;; ----------------------------------------------------------------------
2072 (define_expand "abssf2"
2073 [(set (match_operand:SF 0 "register_operand" "")
2074 (abs:SF (match_operand:SF 1 "register_operand" "")))]
2078 (define_insn "*abssf2_h8300"
2079 [(set (match_operand:SF 0 "register_operand" "=r")
2080 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
2083 [(set_attr "length" "2")])
2085 (define_insn "*abssf2_h8300hs"
2086 [(set (match_operand:SF 0 "register_operand" "=r")
2087 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
2088 "TARGET_H8300H || TARGET_H8300S"
2089 "and.w\\t#32767,%e0"
2090 [(set_attr "length" "4")])
2092 ;; ----------------------------------------------------------------------
2094 ;; ----------------------------------------------------------------------
2096 (define_expand "one_cmplqi2"
2097 [(set (match_operand:QI 0 "register_operand" "")
2098 (not:QI (match_operand:QI 1 "register_operand" "")))]
2102 (define_insn "*one_cmplqi2"
2103 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
2104 (not:QI (match_operand:QI 1 "h8300_dst_operand" "0")))]
2107 [(set_attr "length_table" "unary")
2108 (set_attr "cc" "set_znv")])
2110 (define_expand "one_cmplhi2"
2111 [(set (match_operand:HI 0 "register_operand" "")
2112 (not:HI (match_operand:HI 1 "register_operand" "")))]
2116 (define_insn "*one_cmplhi2_h8300"
2117 [(set (match_operand:HI 0 "register_operand" "=r")
2118 (not:HI (match_operand:HI 1 "register_operand" "0")))]
2121 [(set_attr "length" "4")])
2123 (define_insn "*one_cmplhi2_h8300hs"
2124 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
2125 (not:HI (match_operand:HI 1 "h8300_dst_operand" "0")))]
2126 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2128 [(set_attr "cc" "set_znv")
2129 (set_attr "length_table" "unary")])
2131 (define_expand "one_cmplsi2"
2132 [(set (match_operand:SI 0 "register_operand" "")
2133 (not:SI (match_operand:SI 1 "register_operand" "")))]
2137 (define_insn "*one_cmplsi2_h8300"
2138 [(set (match_operand:SI 0 "register_operand" "=r")
2139 (not:SI (match_operand:SI 1 "register_operand" "0")))]
2141 "not %w0\;not %x0\;not %y0\;not %z0"
2142 [(set_attr "length" "8")])
2144 (define_insn "*one_cmplsi2_h8300hs"
2145 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2146 (not:SI (match_operand:SI 1 "h8300_dst_operand" "0")))]
2147 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2149 [(set_attr "cc" "set_znv")
2150 (set_attr "length_table" "unary")])
2152 ;; ----------------------------------------------------------------------
2153 ;; JUMP INSTRUCTIONS
2154 ;; ----------------------------------------------------------------------
2156 ;; Conditional jump instructions
2158 (define_expand "ble"
2159 [(match_operand 0 "" "")]
2161 "h8300_expand_branch (LE, operands[0]); DONE;")
2163 (define_expand "bleu"
2164 [(match_operand 0 "" "")]
2166 "h8300_expand_branch (LEU, operands[0]); DONE;")
2168 (define_expand "bge"
2169 [(match_operand 0 "" "")]
2171 "h8300_expand_branch (GE, operands[0]); DONE;")
2173 (define_expand "bgeu"
2174 [(match_operand 0 "" "")]
2176 "h8300_expand_branch (GEU, operands[0]); DONE;")
2178 (define_expand "blt"
2179 [(match_operand 0 "" "")]
2181 "h8300_expand_branch (LT, operands[0]); DONE;")
2183 (define_expand "bltu"
2184 [(match_operand 0 "" "")]
2186 "h8300_expand_branch (LTU, operands[0]); DONE;")
2188 (define_expand "bgt"
2189 [(match_operand 0 "" "")]
2191 "h8300_expand_branch (GT, operands[0]); DONE;")
2193 (define_expand "bgtu"
2194 [(match_operand 0 "" "")]
2196 "h8300_expand_branch (GTU, operands[0]); DONE;")
2198 (define_expand "beq"
2199 [(match_operand 0 "" "")]
2201 "h8300_expand_branch (EQ, operands[0]); DONE;")
2203 (define_expand "bne"
2204 [(match_operand 0 "" "")]
2206 "h8300_expand_branch (NE, operands[0]); DONE;")
2208 (define_insn "branch_true"
2210 (if_then_else (match_operator 1 "comparison_operator"
2211 [(cc0) (const_int 0)])
2212 (label_ref (match_operand 0 "" ""))
2217 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
2218 && (GET_CODE (operands[1]) == GT
2219 || GET_CODE (operands[1]) == GE
2220 || GET_CODE (operands[1]) == LE
2221 || GET_CODE (operands[1]) == LT))
2223 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
2227 if (get_attr_length (insn) == 2)
2228 return \"b%j1 %l0\";
2229 else if (get_attr_length (insn) == 4)
2230 return \"b%j1 %l0:16\";
2232 return \"b%k1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
2234 [(set_attr "type" "branch")
2235 (set_attr "cc" "none")])
2237 (define_insn "branch_false"
2239 (if_then_else (match_operator 1 "comparison_operator"
2240 [(cc0) (const_int 0)])
2242 (label_ref (match_operand 0 "" ""))))]
2246 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
2247 && (GET_CODE (operands[1]) == GT
2248 || GET_CODE (operands[1]) == GE
2249 || GET_CODE (operands[1]) == LE
2250 || GET_CODE (operands[1]) == LT))
2252 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
2256 if (get_attr_length (insn) == 2)
2257 return \"b%k1 %l0\";
2258 else if (get_attr_length (insn) == 4)
2259 return \"b%k1 %l0:16\";
2261 return \"b%j1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
2263 [(set_attr "type" "branch")
2264 (set_attr "cc" "none")])
2266 (define_insn "*brabc"
2269 (eq (zero_extract (match_operand:QI 1 "bit_memory_operand" "WU")
2271 (match_operand:QI 2 "immediate_operand" "n"))
2273 (label_ref (match_operand 0 "" ""))
2278 switch (get_attr_length (insn)
2279 - h8300_insn_length_from_table (insn, operands))
2282 return \"bra/bc %2,%R1,%l0\";
2285 return \"bra/bc %2,%R1,%l0:16\";
2288 return \"bra/bs %2,%R1,.Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
2291 [(set_attr "type" "bitbranch")
2292 (set_attr "length_table" "bitbranch")
2293 (set_attr "cc" "none")])
2295 (define_insn "*brabs"
2298 (ne (zero_extract (match_operand:QI 1 "bit_memory_operand" "WU")
2300 (match_operand:QI 2 "immediate_operand" "n"))
2302 (label_ref (match_operand 0 "" ""))
2307 switch (get_attr_length (insn)
2308 - h8300_insn_length_from_table (insn, operands))
2311 return \"bra/bs %2,%R1,%l0\";
2314 return \"bra/bs %2,%R1,%l0:16\";
2317 return \"bra/bc %2,%R1,.Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:\";
2320 [(set_attr "type" "bitbranch")
2321 (set_attr "length_table" "bitbranch")
2322 (set_attr "cc" "none")])
2324 ;; Unconditional and other jump instructions.
2328 (label_ref (match_operand 0 "" "")))]
2332 if (final_sequence != 0)
2334 if (get_attr_length (insn) == 2)
2335 return \"bra/s %l0\";
2338 /* The branch isn't short enough to use bra/s. Output the
2339 branch and delay slot in their normal order.
2341 If this is a backward branch, it will now be branching two
2342 bytes further than previously thought. The length-based
2343 test for bra vs. jump is very conservative though, so the
2344 branch will still be within range. */
2348 vec = XVEC (final_sequence, 0);
2350 final_scan_insn (RTVEC_ELT (vec, 1), asm_out_file, optimize, 1, & seen);
2351 final_scan_insn (RTVEC_ELT (vec, 0), asm_out_file, optimize, 1, & seen);
2352 INSN_DELETED_P (RTVEC_ELT (vec, 1)) = 1;
2356 else if (get_attr_length (insn) == 2)
2358 else if (get_attr_length (insn) == 4)
2359 return \"bra %l0:16\";
2361 return \"jmp @%l0\";
2363 [(set_attr "type" "branch")
2364 (set (attr "delay_slot")
2365 (if_then_else (ne (symbol_ref "TARGET_H8300SX") (const_int 0))
2366 (const_string "jump")
2367 (const_string "none")))
2368 (set_attr "cc" "none")])
2370 ;; This is a define expand, because pointers may be either 16 or 32 bits.
2372 (define_expand "tablejump"
2373 [(parallel [(set (pc) (match_operand 0 "register_operand" ""))
2374 (use (label_ref (match_operand 1 "" "")))])]
2378 (define_insn "*tablejump_h8300"
2379 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
2380 (use (label_ref (match_operand 1 "" "")))]
2383 [(set_attr "cc" "none")
2384 (set_attr "length" "2")])
2386 (define_insn "*tablejump_h8300hs_advanced"
2387 [(set (pc) (match_operand:SI 0 "register_operand" "r"))
2388 (use (label_ref (match_operand 1 "" "")))]
2389 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE"
2391 [(set_attr "cc" "none")
2392 (set_attr "length" "2")])
2394 (define_insn "*tablejump_h8300hs_normal"
2395 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
2396 (use (label_ref (match_operand 1 "" "")))]
2397 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
2399 [(set_attr "cc" "none")
2400 (set_attr "length" "2")])
2402 ;; This is a define expand, because pointers may be either 16 or 32 bits.
2404 (define_expand "indirect_jump"
2405 [(set (pc) (match_operand 0 "jump_address_operand" ""))]
2409 (define_insn "*indirect_jump_h8300"
2410 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
2413 [(set_attr "cc" "none")
2414 (set_attr "length" "2")])
2416 (define_insn "*indirect_jump_h8300hs_advanced"
2417 [(set (pc) (match_operand:SI 0 "jump_address_operand" "Vr"))]
2418 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE"
2420 [(set_attr "cc" "none")
2421 (set_attr "length" "2")])
2423 (define_insn "*indirect_jump_h8300hs_normal"
2424 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
2425 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
2427 [(set_attr "cc" "none")
2428 (set_attr "length" "2")])
2430 ;; Call subroutine with no return value.
2432 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
2435 [(call (match_operand:QI 0 "call_insn_operand" "or")
2436 (match_operand:HI 1 "general_operand" "g"))]
2440 if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
2441 && SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
2442 return \"jsr\\t@%0:8\";
2444 return \"jsr\\t%0\";
2446 [(set_attr "type" "call")
2447 (set (attr "length")
2448 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
2452 ;; Call subroutine, returning value in operand 0
2453 ;; (which must be a hard register).
2455 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
2457 (define_insn "call_value"
2458 [(set (match_operand 0 "" "=r")
2459 (call (match_operand:QI 1 "call_insn_operand" "or")
2460 (match_operand:HI 2 "general_operand" "g")))]
2464 if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2465 && SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
2466 return \"jsr\\t@%1:8\";
2468 return \"jsr\\t%1\";
2470 [(set_attr "type" "call")
2471 (set (attr "length")
2472 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
2480 [(set_attr "cc" "none")
2481 (set_attr "length" "2")])
2483 ;; ----------------------------------------------------------------------
2484 ;; PROLOGUE/EPILOGUE-RELATED INSTRUCTIONS
2485 ;; ----------------------------------------------------------------------
2487 (define_expand "push_h8300"
2488 [(set (mem:HI (pre_dec:HI (reg:HI SP_REG)))
2489 (match_operand:HI 0 "register_operand" ""))]
2493 (define_expand "push_h8300hs_advanced"
2494 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
2495 (match_operand:SI 0 "register_operand" ""))]
2496 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
2499 (define_expand "push_h8300hs_normal"
2500 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
2501 (match_operand:SI 0 "register_operand" ""))]
2502 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
2505 (define_expand "pop_h8300"
2506 [(set (match_operand:HI 0 "register_operand" "")
2507 (mem:HI (post_inc:HI (reg:HI SP_REG))))]
2511 (define_expand "pop_h8300hs_advanced"
2512 [(set (match_operand:SI 0 "register_operand" "")
2513 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
2514 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
2517 (define_expand "pop_h8300hs_normal"
2518 [(set (match_operand:SI 0 "register_operand" "")
2519 (mem:SI (post_inc:HI (reg:HI SP_REG))))]
2520 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
2523 (define_insn "ldm_h8300sx"
2524 [(match_parallel 0 "h8300_ldm_parallel"
2525 [(set (match_operand:SI 1 "register_operand" "")
2526 (match_operand:SI 2 "memory_operand" ""))])]
2529 operands[3] = SET_DEST (XVECEXP (operands[0], 0,
2530 XVECLEN (operands[0], 0) - 2));
2531 return "ldm.l\t@er7+,%S1-%S3";
2533 [(set_attr "cc" "none")
2534 (set_attr "length" "4")])
2536 (define_insn "stm_h8300sx"
2537 [(match_parallel 0 "h8300_stm_parallel"
2538 [(set (match_operand:SI 1 "memory_operand" "")
2539 (match_operand:SI 2 "register_operand" ""))])]
2542 operands[3] = SET_SRC (XVECEXP (operands[0], 0,
2543 XVECLEN (operands[0], 0) - 2));
2544 return "stm.l\t%S2-%S3,@-er7";
2546 [(set_attr "cc" "none")
2547 (set_attr "length" "4")])
2549 (define_insn "return_h8sx"
2550 [(match_parallel 0 "h8300_return_parallel"
2552 (set (match_operand:SI 1 "register_operand" "")
2553 (match_operand:SI 2 "memory_operand" ""))])]
2556 operands[3] = SET_DEST (XVECEXP (operands[0], 0,
2557 XVECLEN (operands[0], 0) - 2));
2558 if (h8300_current_function_interrupt_function_p ())
2559 return "rte/l\t%S1-%S3";
2561 return "rts/l\t%S1-%S3";
2563 [(set_attr "cc" "none")
2564 (set_attr "can_delay" "no")
2565 (set_attr "length" "2")])
2567 (define_expand "return"
2569 "h8300_can_use_return_insn_p ()"
2572 (define_insn "*return_1"
2577 if (h8300_current_function_interrupt_function_p ())
2582 [(set_attr "cc" "none")
2583 (set_attr "can_delay" "no")
2584 (set_attr "length" "2")])
2586 (define_expand "prologue"
2589 "h8300_expand_prologue (); DONE;")
2591 (define_expand "epilogue"
2594 "h8300_expand_epilogue (); DONE;")
2596 (define_insn "monitor_prologue"
2597 [(unspec_volatile [(const_int 0)] UNSPEC_MONITOR)]
2602 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\";
2603 else if (TARGET_H8300H)
2604 return \"mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\\t#128,ccr\";
2605 else if (TARGET_H8300S)
2606 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\";
2609 [(set_attr "length" "20")])
2611 ;; ----------------------------------------------------------------------
2612 ;; EXTEND INSTRUCTIONS
2613 ;; ----------------------------------------------------------------------
2615 (define_expand "zero_extendqihi2"
2616 [(set (match_operand:HI 0 "register_operand" "")
2617 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2621 (define_insn "*zero_extendqihi2_h8300"
2622 [(set (match_operand:HI 0 "register_operand" "=r,r")
2623 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2628 [(set_attr "length" "2,10")])
2630 (define_insn "*zero_extendqihi2_h8300hs"
2631 [(set (match_operand:HI 0 "register_operand" "=r,r")
2632 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2633 "TARGET_H8300H || TARGET_H8300S"
2637 [(set_attr "length" "2,10")
2638 (set_attr "cc" "set_znv,set_znv")])
2640 ;; Split the zero extension of a general operand (actually a memory
2641 ;; operand) into a load of the operand and the actual zero extension
2642 ;; so that 1) the length will be accurate, and 2) the zero extensions
2643 ;; appearing at the end of basic blocks may be merged.
2646 [(set (match_operand:HI 0 "register_operand" "")
2647 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2652 (zero_extend:HI (match_dup 2)))]
2653 "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
2655 (define_expand "zero_extendqisi2"
2656 [(set (match_operand:SI 0 "register_operand" "")
2657 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2661 operands[1] = force_reg (QImode, operands[1]);
2664 (define_insn "*zero_extendqisi2_h8300"
2665 [(set (match_operand:SI 0 "register_operand" "=r,r")
2666 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2669 mov.b #0,%x0\;sub.w %e0,%e0
2670 mov.b %R1,%w0\;mov.b #0,%x0\;sub.w %e0,%e0"
2671 [(set_attr "length" "4,8")])
2673 (define_insn "*zero_extendqisi2_h8300hs"
2674 [(set (match_operand:SI 0 "register_operand" "=r,r")
2675 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2676 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX"
2680 [(set (match_operand:SI 0 "register_operand" "")
2681 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2682 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
2683 && reg_overlap_mentioned_p (operands[0], operands[1])
2684 && reload_completed"
2688 (zero_extend:HI (match_dup 2)))
2690 (zero_extend:SI (match_dup 3)))]
2691 "operands[2] = gen_lowpart (QImode, operands[0]);
2692 operands[3] = gen_lowpart (HImode, operands[0]);")
2695 [(set (match_operand:SI 0 "register_operand" "")
2696 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2697 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
2698 && !reg_overlap_mentioned_p (operands[0], operands[1])
2699 && reload_completed"
2702 (set (strict_low_part (match_dup 2))
2704 "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
2706 (define_insn "*zero_extendqisi2_h8sx"
2707 [(set (match_operand:SI 0 "register_operand" "=r")
2708 (zero_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2711 [(set_attr "length" "2")
2712 (set_attr "cc" "set_znv")])
2714 (define_expand "zero_extendhisi2"
2715 [(set (match_operand:SI 0 "register_operand" "")
2716 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
2720 ;; %e prints the high part of a CONST_INT, not the low part. Arggh.
2721 (define_insn "*zero_extendhisi2_h8300"
2722 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2723 (zero_extend:SI (match_operand:HI 1 "general_operand_src" "0,i,g>")))]
2727 mov.w %f1,%f0\;sub.w %e0,%e0
2728 mov.w %e1,%f0\;sub.w %e0,%e0"
2729 [(set_attr "length" "2,4,6")])
2731 (define_insn "*zero_extendhisi2_h8300hs"
2732 [(set (match_operand:SI 0 "register_operand" "=r")
2733 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2734 "TARGET_H8300H || TARGET_H8300S"
2736 [(set_attr "length" "2")
2737 (set_attr "cc" "set_znv")])
2739 (define_expand "extendqihi2"
2740 [(set (match_operand:HI 0 "register_operand" "")
2741 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
2745 (define_insn "*extendqihi2_h8300"
2746 [(set (match_operand:HI 0 "register_operand" "=r,r")
2747 (sign_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2750 bld #7,%s0\;subx %t0,%t0
2751 mov.b %R1,%s0\;bld #7,%s0\;subx %t0,%t0"
2752 [(set_attr "length" "4,8")])
2754 (define_insn "*extendqihi2_h8300hs"
2755 [(set (match_operand:HI 0 "register_operand" "=r")
2756 (sign_extend:HI (match_operand:QI 1 "register_operand" "0")))]
2757 "TARGET_H8300H || TARGET_H8300S"
2759 [(set_attr "length" "2")
2760 (set_attr "cc" "set_znv")])
2762 (define_expand "extendqisi2"
2763 [(set (match_operand:SI 0 "register_operand" "")
2764 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
2768 (define_insn "*extendqisi2_h8300"
2769 [(set (match_operand:SI 0 "register_operand" "=r,r")
2770 (sign_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2773 bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0
2774 mov.b %R1,%w0\;bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0"
2775 [(set_attr "length" "8,12")])
2777 ;; The following pattern is needed because without the pattern, the
2778 ;; combiner would split (sign_extend:SI (reg:QI)) into into two 24-bit
2779 ;; shifts, one ashift and one ashiftrt.
2781 (define_insn_and_split "*extendqisi2_h8300hs"
2782 [(set (match_operand:SI 0 "register_operand" "=r")
2783 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2784 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX"
2786 "&& reload_completed"
2788 (sign_extend:HI (match_dup 1)))
2790 (sign_extend:SI (match_dup 2)))]
2791 "operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));")
2793 (define_insn "*extendqisi2_h8sx"
2794 [(set (match_operand:SI 0 "register_operand" "=r")
2795 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2798 [(set_attr "length" "2")
2799 (set_attr "cc" "set_znv")])
2801 (define_expand "extendhisi2"
2802 [(set (match_operand:SI 0 "register_operand" "")
2803 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
2807 (define_insn "*extendhisi2_h8300"
2808 [(set (match_operand:SI 0 "register_operand" "=r,r")
2809 (sign_extend:SI (match_operand:HI 1 "general_operand_src" "0,g>")))]
2812 bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0
2813 mov.w %T1,%f0\;bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0"
2814 [(set_attr "length" "6,10")])
2816 (define_insn "*extendhisi2_h8300hs"
2817 [(set (match_operand:SI 0 "register_operand" "=r")
2818 (sign_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2819 "TARGET_H8300H || TARGET_H8300S"
2821 [(set_attr "length" "2")
2822 (set_attr "cc" "set_znv")])
2824 ;; ----------------------------------------------------------------------
2826 ;; ----------------------------------------------------------------------
2828 ;; We make some attempt to provide real efficient shifting. One example is
2829 ;; doing an 8 bit shift of a 16 bit value by moving a byte reg into the other
2830 ;; reg and moving 0 into the former reg.
2832 ;; We also try to achieve this in a uniform way. IE: We don't try to achieve
2833 ;; this in both rtl and at insn emit time. Ideally, we'd use rtl as that would
2834 ;; give the optimizer more cracks at the code. However, we wish to do things
2835 ;; like optimizing shifting the sign bit to bit 0 by rotating the other way.
2836 ;; There is rtl to handle this (rotate + and), but the H8/300 doesn't handle
2837 ;; 16 bit rotates. Also, if we emit complicated rtl, combine may not be able
2838 ;; to detect cases it can optimize.
2840 ;; For these and other fuzzy reasons, I've decided to go the less pretty but
2841 ;; easier "do it at insn emit time" route.
2845 (define_expand "ashlqi3"
2846 [(set (match_operand:QI 0 "register_operand" "")
2847 (ashift:QI (match_operand:QI 1 "register_operand" "")
2848 (match_operand:QI 2 "nonmemory_operand" "")))]
2850 "if (expand_a_shift (QImode, ASHIFT, operands)) DONE;")
2852 (define_expand "ashrqi3"
2853 [(set (match_operand:QI 0 "register_operand" "")
2854 (ashiftrt:QI (match_operand:QI 1 "register_operand" "")
2855 (match_operand:QI 2 "nonmemory_operand" "")))]
2857 "if (expand_a_shift (QImode, ASHIFTRT, operands)) DONE;")
2859 (define_expand "lshrqi3"
2860 [(set (match_operand:QI 0 "register_operand" "")
2861 (lshiftrt:QI (match_operand:QI 1 "register_operand" "")
2862 (match_operand:QI 2 "nonmemory_operand" "")))]
2864 "if (expand_a_shift (QImode, LSHIFTRT, operands)) DONE;")
2867 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
2868 (match_operator:QI 3 "h8sx_unary_shift_operator"
2869 [(match_operand:QI 1 "h8300_dst_operand" "0")
2870 (match_operand:QI 2 "const_int_operand" "")]))]
2871 "h8300_operands_match_p (operands)"
2872 { return output_h8sx_shift (operands, 'b', 'X'); }
2873 [(set_attr "length_table" "unary")
2874 (set_attr "cc" "set_znv")])
2877 [(set (match_operand:QI 0 "register_operand" "=r")
2878 (match_operator:QI 3 "h8sx_binary_shift_operator"
2879 [(match_operand:QI 1 "register_operand" "0")
2880 (match_operand:QI 2 "nonmemory_operand" "r P3>X")]))]
2882 { return output_h8sx_shift (operands, 'b', 'X'); }
2883 [(set_attr "length" "4")
2884 (set_attr "cc" "set_znv")])
2886 (define_insn "*shiftqi"
2887 [(set (match_operand:QI 0 "register_operand" "=r,r")
2888 (match_operator:QI 3 "nshift_operator"
2889 [ (match_operand:QI 1 "register_operand" "0,0")
2890 (match_operand:QI 2 "nonmemory_operand" "R,rn")]))
2891 (clobber (match_scratch:QI 4 "=X,&r"))]
2893 "* return output_a_shift (operands);"
2894 [(set (attr "length")
2895 (symbol_ref "compute_a_shift_length (insn, operands)"))
2897 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2901 (define_expand "ashlhi3"
2902 [(set (match_operand:HI 0 "register_operand" "")
2903 (ashift:HI (match_operand:HI 1 "register_operand" "")
2904 (match_operand:QI 2 "nonmemory_operand" "")))]
2906 "if (expand_a_shift (HImode, ASHIFT, operands)) DONE;")
2908 (define_expand "lshrhi3"
2909 [(set (match_operand:HI 0 "register_operand" "")
2910 (lshiftrt:HI (match_operand:HI 1 "register_operand" "")
2911 (match_operand:QI 2 "nonmemory_operand" "")))]
2913 "if (expand_a_shift (HImode, LSHIFTRT, operands)) DONE;")
2915 (define_expand "ashrhi3"
2916 [(set (match_operand:HI 0 "register_operand" "")
2917 (ashiftrt:HI (match_operand:HI 1 "register_operand" "")
2918 (match_operand:QI 2 "nonmemory_operand" "")))]
2920 "if (expand_a_shift (HImode, ASHIFTRT, operands)) DONE;")
2923 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
2924 (match_operator:HI 3 "h8sx_unary_shift_operator"
2925 [(match_operand:HI 1 "h8300_dst_operand" "0")
2926 (match_operand:QI 2 "const_int_operand" "")]))]
2927 "h8300_operands_match_p (operands)"
2928 { return output_h8sx_shift (operands, 'w', 'T'); }
2929 [(set_attr "length_table" "unary")
2930 (set_attr "cc" "set_znv")])
2933 [(set (match_operand:HI 0 "register_operand" "=r")
2934 (match_operator:HI 3 "h8sx_binary_shift_operator"
2935 [(match_operand:HI 1 "register_operand" "0")
2936 (match_operand:QI 2 "nonmemory_operand" "r P4>X")]))]
2938 { return output_h8sx_shift (operands, 'w', 'T'); }
2939 [(set_attr "length" "4")
2940 (set_attr "cc" "set_znv")])
2942 (define_insn "*shifthi"
2943 [(set (match_operand:HI 0 "register_operand" "=r,r")
2944 (match_operator:HI 3 "nshift_operator"
2945 [ (match_operand:HI 1 "register_operand" "0,0")
2946 (match_operand:QI 2 "nonmemory_operand" "S,rn")]))
2947 (clobber (match_scratch:QI 4 "=X,&r"))]
2949 "* return output_a_shift (operands);"
2950 [(set (attr "length")
2951 (symbol_ref "compute_a_shift_length (insn, operands)"))
2953 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2957 (define_expand "ashlsi3"
2958 [(set (match_operand:SI 0 "register_operand" "")
2959 (ashift:SI (match_operand:SI 1 "register_operand" "")
2960 (match_operand:QI 2 "nonmemory_operand" "")))]
2962 "if (expand_a_shift (SImode, ASHIFT, operands)) DONE;")
2964 (define_expand "lshrsi3"
2965 [(set (match_operand:SI 0 "register_operand" "")
2966 (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
2967 (match_operand:QI 2 "nonmemory_operand" "")))]
2969 "if (expand_a_shift (SImode, LSHIFTRT, operands)) DONE;")
2971 (define_expand "ashrsi3"
2972 [(set (match_operand:SI 0 "register_operand" "")
2973 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
2974 (match_operand:QI 2 "nonmemory_operand" "")))]
2976 "if (expand_a_shift (SImode, ASHIFTRT, operands)) DONE;")
2979 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2980 (match_operator:SI 3 "h8sx_unary_shift_operator"
2981 [(match_operand:SI 1 "h8300_dst_operand" "0")
2982 (match_operand:QI 2 "const_int_operand" "")]))]
2983 "h8300_operands_match_p (operands)"
2984 { return output_h8sx_shift (operands, 'l', 'S'); }
2985 [(set_attr "length_table" "unary")
2986 (set_attr "cc" "set_znv")])
2989 [(set (match_operand:SI 0 "register_operand" "=r")
2990 (match_operator:SI 3 "h8sx_binary_shift_operator"
2991 [(match_operand:SI 1 "register_operand" "0")
2992 (match_operand:QI 2 "nonmemory_operand" "r P5>X")]))]
2994 { return output_h8sx_shift (operands, 'l', 'S'); }
2995 [(set_attr "length" "4")
2996 (set_attr "cc" "set_znv")])
2998 (define_insn "*shiftsi"
2999 [(set (match_operand:SI 0 "register_operand" "=r,r")
3000 (match_operator:SI 3 "nshift_operator"
3001 [ (match_operand:SI 1 "register_operand" "0,0")
3002 (match_operand:QI 2 "nonmemory_operand" "T,rn")]))
3003 (clobber (match_scratch:QI 4 "=X,&r"))]
3005 "* return output_a_shift (operands);"
3006 [(set (attr "length")
3007 (symbol_ref "compute_a_shift_length (insn, operands)"))
3009 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
3011 ;; Split a variable shift into a loop. If the register containing
3012 ;; the shift count dies, then we just use that register.
3015 [(set (match_operand 0 "register_operand" "")
3016 (match_operator 2 "nshift_operator"
3018 (match_operand:QI 1 "register_operand" "")]))
3019 (clobber (match_operand:QI 3 "register_operand" ""))]
3021 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
3025 (if_then_else (le (cc0) (const_int 0))
3026 (label_ref (match_dup 5))
3031 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
3032 (clobber (scratch:QI))])
3034 (plus:QI (match_dup 1) (const_int -1)))
3038 (if_then_else (ne (cc0) (const_int 0))
3039 (label_ref (match_dup 4))
3042 "operands[4] = gen_label_rtx ();
3043 operands[5] = gen_label_rtx ();")
3046 [(set (match_operand 0 "register_operand" "")
3047 (match_operator 2 "nshift_operator"
3049 (match_operand:QI 1 "register_operand" "")]))
3050 (clobber (match_operand:QI 3 "register_operand" ""))]
3052 && !find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
3058 (if_then_else (le (cc0) (const_int 0))
3059 (label_ref (match_dup 5))
3064 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
3065 (clobber (scratch:QI))])
3067 (plus:QI (match_dup 3) (const_int -1)))
3071 (if_then_else (ne (cc0) (const_int 0))
3072 (label_ref (match_dup 4))
3075 "operands[4] = gen_label_rtx ();
3076 operands[5] = gen_label_rtx ();")
3078 ;; ----------------------------------------------------------------------
3080 ;; ----------------------------------------------------------------------
3082 (define_expand "rotlqi3"
3083 [(set (match_operand:QI 0 "register_operand" "")
3084 (rotate:QI (match_operand:QI 1 "register_operand" "")
3085 (match_operand:QI 2 "nonmemory_operand" "")))]
3087 "if (expand_a_rotate (operands)) DONE;")
3089 (define_insn "rotlqi3_1"
3090 [(set (match_operand:QI 0 "register_operand" "=r")
3091 (rotate:QI (match_operand:QI 1 "register_operand" "0")
3092 (match_operand:QI 2 "immediate_operand" "")))]
3094 "* return output_a_rotate (ROTATE, operands);"
3095 [(set (attr "length")
3096 (symbol_ref "compute_a_rotate_length (operands)"))])
3098 (define_expand "rotlhi3"
3099 [(set (match_operand:HI 0 "register_operand" "")
3100 (rotate:HI (match_operand:HI 1 "register_operand" "")
3101 (match_operand:QI 2 "nonmemory_operand" "")))]
3103 "if (expand_a_rotate (operands)) DONE;")
3105 (define_insn "rotlhi3_1"
3106 [(set (match_operand:HI 0 "register_operand" "=r")
3107 (rotate:HI (match_operand:HI 1 "register_operand" "0")
3108 (match_operand:QI 2 "immediate_operand" "")))]
3110 "* return output_a_rotate (ROTATE, operands);"
3111 [(set (attr "length")
3112 (symbol_ref "compute_a_rotate_length (operands)"))])
3114 (define_expand "rotlsi3"
3115 [(set (match_operand:SI 0 "register_operand" "")
3116 (rotate:SI (match_operand:SI 1 "register_operand" "")
3117 (match_operand:QI 2 "nonmemory_operand" "")))]
3118 "TARGET_H8300H || TARGET_H8300S"
3119 "if (expand_a_rotate (operands)) DONE;")
3121 (define_insn "rotlsi3_1"
3122 [(set (match_operand:SI 0 "register_operand" "=r")
3123 (rotate:SI (match_operand:SI 1 "register_operand" "0")
3124 (match_operand:QI 2 "immediate_operand" "")))]
3125 "TARGET_H8300H || TARGET_H8300S"
3126 "* return output_a_rotate (ROTATE, operands);"
3127 [(set (attr "length")
3128 (symbol_ref "compute_a_rotate_length (operands)"))])
3130 ;; -----------------------------------------------------------------
3132 ;; -----------------------------------------------------------------
3133 ;; The H8/300 has given 1/8th of its opcode space to bitfield
3134 ;; instructions so let's use them as well as we can.
3136 ;; You'll never believe all these patterns perform one basic action --
3137 ;; load a bit from the source, optionally invert the bit, then store it
3138 ;; in the destination (which is known to be zero).
3140 ;; Combine obviously need some work to better identify this situation and
3141 ;; canonicalize the form better.
3144 ;; Normal loads with a 16bit destination.
3148 [(set (match_operand:HI 0 "register_operand" "=&r")
3149 (zero_extract:HI (match_operand:HI 1 "register_operand" "r")
3151 (match_operand:HI 2 "immediate_operand" "n")))]
3153 "sub.w %0,%0\;bld %Z2,%Y1\;bst #0,%X0"
3154 [(set_attr "length" "6")])
3157 ;; Inverted loads with a 16bit destination.
3161 [(set (match_operand:HI 0 "register_operand" "=&r")
3162 (zero_extract:HI (xor:HI (match_operand:HI 1 "register_operand" "r")
3163 (match_operand:HI 3 "const_int_operand" "n"))
3165 (match_operand:HI 2 "const_int_operand" "n")))]
3167 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
3168 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
3169 [(set_attr "length" "8")])
3172 ;; Normal loads with a 32bit destination.
3175 (define_insn "*extzv_1_r_h8300"
3176 [(set (match_operand:SI 0 "register_operand" "=&r")
3177 (zero_extract:SI (match_operand:HI 1 "register_operand" "r")
3179 (match_operand 2 "const_int_operand" "n")))]
3181 && INTVAL (operands[2]) < 16"
3182 "* return output_simode_bld (0, operands);"
3183 [(set_attr "length" "8")])
3185 (define_insn "*extzv_1_r_h8300hs"
3186 [(set (match_operand:SI 0 "register_operand" "=r,r")
3187 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
3189 (match_operand 2 "const_int_operand" "n,n")))]
3190 "(TARGET_H8300H || TARGET_H8300S)
3191 && INTVAL (operands[2]) < 16"
3192 "* return output_simode_bld (0, operands);"
3193 [(set_attr "cc" "set_znv,set_znv")
3194 (set_attr "length" "8,6")])
3197 ;; Inverted loads with a 32bit destination.
3200 (define_insn "*extzv_1_r_inv_h8300"
3201 [(set (match_operand:SI 0 "register_operand" "=&r")
3202 (zero_extract:SI (xor:HI (match_operand:HI 1 "register_operand" "r")
3203 (match_operand:HI 3 "const_int_operand" "n"))
3205 (match_operand 2 "const_int_operand" "n")))]
3207 && INTVAL (operands[2]) < 16
3208 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
3209 "* return output_simode_bld (1, operands);"
3210 [(set_attr "length" "8")])
3212 (define_insn "*extzv_1_r_inv_h8300hs"
3213 [(set (match_operand:SI 0 "register_operand" "=r,r")
3214 (zero_extract:SI (xor:SI (match_operand:SI 1 "register_operand" "?0,r")
3215 (match_operand 3 "const_int_operand" "n,n"))
3217 (match_operand 2 "const_int_operand" "n,n")))]
3218 "(TARGET_H8300H || TARGET_H8300S)
3219 && INTVAL (operands[2]) < 16
3220 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
3221 "* return output_simode_bld (1, operands);"
3222 [(set_attr "cc" "set_znv,set_znv")
3223 (set_attr "length" "8,6")])
3225 (define_expand "insv"
3226 [(set (zero_extract:HI (match_operand:HI 0 "general_operand" "")
3227 (match_operand:HI 1 "general_operand" "")
3228 (match_operand:HI 2 "general_operand" ""))
3229 (match_operand:HI 3 "general_operand" ""))]
3230 "TARGET_H8300 || TARGET_H8300SX"
3235 if (GET_CODE (operands[1]) == CONST_INT
3236 && GET_CODE (operands[2]) == CONST_INT
3237 && INTVAL (operands[1]) <= 8
3238 && INTVAL (operands[2]) >= 0
3239 && INTVAL (operands[1]) + INTVAL (operands[2]) <= 8
3240 && memory_operand (operands[0], GET_MODE (operands[0])))
3242 /* If the source operand is zero, it's better to use AND rather
3243 than BFST. Likewise OR if the operand is all ones. */
3244 if (GET_CODE (operands[3]) == CONST_INT)
3246 HOST_WIDE_INT mask = (1 << INTVAL (operands[1])) - 1;
3247 if ((INTVAL (operands[3]) & mask) == 0)
3249 if ((INTVAL (operands[3]) & mask) == mask)
3252 if (! bit_memory_operand (operands[0], GET_MODE (operands[0])))
3257 replace_equiv_address (operands[0],
3259 XEXP (operands[0], 0)));
3261 operands[3] = gen_lowpart (QImode, operands[3]);
3264 if (! register_operand (operands[3], QImode))
3268 operands[3] = force_reg (QImode, operands[3]);
3270 emit_insn (gen_bfst (adjust_address (operands[0], QImode, 0),
3271 operands[3], operands[1], operands[2]));
3278 /* We only have single bit bit-field instructions. */
3279 if (INTVAL (operands[1]) != 1)
3282 /* For now, we don't allow memory operands. */
3283 if (GET_CODE (operands[0]) == MEM
3284 || GET_CODE (operands[3]) == MEM)
3289 [(set (zero_extract:HI (match_operand:HI 0 "register_operand" "+r")
3291 (match_operand:HI 1 "immediate_operand" "n"))
3292 (match_operand:HI 2 "register_operand" "r"))]
3294 "bld #0,%R2\;bst %Z1,%Y0 ; i1"
3295 [(set_attr "length" "4")])
3297 (define_expand "extzv"
3298 [(set (match_operand:HI 0 "register_operand" "")
3299 (zero_extract:HI (match_operand:HI 1 "bit_operand" "")
3300 (match_operand:HI 2 "general_operand" "")
3301 (match_operand:HI 3 "general_operand" "")))]
3302 "TARGET_H8300 || TARGET_H8300SX"
3307 if (GET_CODE (operands[2]) == CONST_INT
3308 && GET_CODE (operands[3]) == CONST_INT
3309 && INTVAL (operands[2]) <= 8
3310 && INTVAL (operands[3]) >= 0
3311 && INTVAL (operands[2]) + INTVAL (operands[3]) <= 8
3312 && memory_operand (operands[1], QImode))
3316 /* Optimize the case where we're extracting into a paradoxical
3317 subreg. It's only necessary to extend to the inner reg. */
3318 if (GET_CODE (operands[0]) == SUBREG
3319 && subreg_lowpart_p (operands[0])
3320 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0])))
3321 < GET_MODE_SIZE (GET_MODE (operands[0])))
3322 && (GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0])))
3324 operands[0] = SUBREG_REG (operands[0]);
3327 temp = gen_lowpart (QImode, operands[0]);
3329 temp = gen_reg_rtx (QImode);
3332 if (! bit_memory_operand (operands[1], QImode))
3337 replace_equiv_address (operands[1],
3339 XEXP (operands[1], 0)));
3341 emit_insn (gen_bfld (temp, operands[1], operands[2], operands[3]));
3342 convert_move (operands[0], temp, 1);
3348 /* We only have single bit bit-field instructions. */
3349 if (INTVAL (operands[2]) != 1)
3352 /* For now, we don't allow memory operands. */
3353 if (GET_CODE (operands[1]) == MEM)
3357 ;; BAND, BOR, and BXOR patterns
3360 [(set (match_operand:HI 0 "bit_operand" "=Ur")
3361 (match_operator:HI 4 "bit_operator"
3362 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
3364 (match_operand:HI 2 "immediate_operand" "n"))
3365 (match_operand:HI 3 "bit_operand" "0")]))]
3367 "bld %Z2,%Y1\;b%c4 #0,%R0\;bst #0,%R0; bl1"
3368 [(set_attr "length" "6")])
3371 [(set (match_operand:HI 0 "bit_operand" "=Ur")
3372 (match_operator:HI 5 "bit_operator"
3373 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
3375 (match_operand:HI 2 "immediate_operand" "n"))
3376 (zero_extract:HI (match_operand:HI 3 "register_operand" "r")
3378 (match_operand:HI 4 "immediate_operand" "n"))]))]
3380 "bld %Z2,%Y1\;b%c5 %Z4,%Y3\;bst #0,%R0; bl3"
3381 [(set_attr "length" "6")])
3384 [(set (match_operand:QI 0 "register_operand" "=r")
3385 (zero_extract:QI (match_operand:QI 1 "bit_memory_operand" "WU")
3386 (match_operand:QI 2 "immediate_operand" "n")
3387 (match_operand:QI 3 "immediate_operand" "n")))]
3388 "TARGET_H8300SX && INTVAL (operands[2]) + INTVAL (operands[3]) <= 8"
3391 operands[2] = GEN_INT ((1 << (INTVAL (operands[2]) + INTVAL (operands[3])))
3392 - (1 << INTVAL (operands[3])));
3393 return \"bfld %2,%1,%R0\";
3395 [(set_attr "cc" "none_0hit")
3396 (set_attr "length_table" "bitfield")])
3399 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU")
3400 (match_operand:QI 2 "immediate_operand" "n")
3401 (match_operand:QI 3 "immediate_operand" "n"))
3402 (match_operand:QI 1 "register_operand" "r"))]
3403 "TARGET_H8300SX && INTVAL (operands[2]) + INTVAL (operands[3]) <= 8"
3406 operands[2] = GEN_INT ((1 << (INTVAL (operands[2]) + INTVAL (operands[3])))
3407 - (1 << INTVAL (operands[3])));
3408 return \"bfst %R1,%2,%0\";
3410 [(set_attr "cc" "none_0hit")
3411 (set_attr "length_table" "bitfield")])
3413 (define_expand "seq"
3414 [(set (match_operand:HI 0 "register_operand" "")
3415 (eq:HI (cc0) (const_int 0)))]
3419 (define_expand "sne"
3420 [(set (match_operand:HI 0 "register_operand" "")
3421 (ne:HI (cc0) (const_int 0)))]
3425 (define_insn "*bstzhireg"
3426 [(set (match_operand:HI 0 "register_operand" "=r")
3427 (match_operator:HI 1 "eqne_operator" [(cc0) (const_int 0)]))]
3429 "mulu.w #0,%T0\;b%k1 .Lh8BR%=\;inc.w #1,%T0\\n.Lh8BR%=:"
3430 [(set_attr "cc" "clobber")])
3432 (define_insn_and_split "*cmpstz"
3433 [(set (zero_extract:QI
3434 (match_operand:QI 0 "bit_memory_operand" "+WU,+WU")
3436 (match_operand:QI 1 "immediate_operand" "n,n"))
3439 [(match_operand 3 "h8300_dst_operand" "r,rQ")
3440 (match_operand 4 "h8300_src_operand" "I,rQi")]))]
3442 && (GET_MODE (operands[3]) == GET_MODE (operands[4])
3443 || GET_CODE (operands[4]) == CONST_INT)
3444 && GET_MODE_CLASS (GET_MODE (operands[3])) == MODE_INT
3445 && GET_MODE_SIZE (GET_MODE (operands[3])) <= 4"
3448 [(set (cc0) (match_dup 5))
3449 (set (zero_extract:QI (match_dup 0) (const_int 1) (match_dup 1))
3450 (match_op_dup:QI 2 [(cc0) (const_int 0)]))]
3453 if (operands[4] == const0_rtx && GET_CODE (operands[3]) == REG)
3454 operands[5] = operands[3];
3456 operands[5] = gen_rtx_COMPARE (VOIDmode, operands[3], operands[4]);
3458 [(set_attr "cc" "set_znv,compare")])
3460 (define_insn "*bstz"
3461 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU")
3463 (match_operand:QI 1 "immediate_operand" "n"))
3464 (eq:QI (cc0) (const_int 0)))]
3465 "TARGET_H8300SX && reload_completed"
3467 [(set_attr "cc" "none_0hit")
3468 (set_attr "length_table" "unary")])
3470 (define_insn "*bistz"
3471 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU")
3473 (match_operand:QI 1 "immediate_operand" "n"))
3474 (ne:QI (cc0) (const_int 0)))]
3475 "TARGET_H8300SX && reload_completed"
3477 [(set_attr "cc" "none_0hit")
3478 (set_attr "length_table" "unary")])
3480 (define_insn_and_split "*cmpcondbset"
3481 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3485 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3486 (match_operand 3 "h8300_src_operand" "I,rQi")])
3488 (match_operand:QI 4 "bit_memory_operand" "0,0")
3489 (match_operand:QI 5 "single_one_operand" "n,n"))
3494 [(set (cc0) (match_dup 6))
3497 (match_op_dup 1 [(cc0) (const_int 0)])
3498 (ior:QI (match_dup 4) (match_dup 5)) (match_dup 4)))]
3501 if (operands[3] == const0_rtx && GET_CODE (operands[2]) == REG)
3502 operands[6] = operands[2];
3504 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3506 [(set_attr "cc" "set_znv,compare")])
3508 (define_insn "*condbset"
3509 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3511 (match_operator:QI 2 "eqne_operator"
3512 [(cc0) (const_int 0)])
3514 (match_operand:QI 3 "bit_memory_operand" "0")
3515 (match_operand:QI 1 "single_one_operand" "n"))
3517 "TARGET_H8300SX && reload_completed"
3519 [(set_attr "cc" "none_0hit")
3520 (set_attr "length_table" "logicb")])
3522 (define_insn_and_split "*cmpcondbclr"
3523 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3527 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3528 (match_operand 3 "h8300_src_operand" "I,rQi")])
3530 (match_operand:QI 4 "bit_memory_operand" "0,0")
3531 (match_operand:QI 5 "single_zero_operand" "n,n"))
3536 [(set (cc0) (match_dup 6))
3539 (match_op_dup 1 [(cc0) (const_int 0)])
3540 (and:QI (match_dup 4) (match_dup 5)) (match_dup 4)))]
3543 if (operands[3] == const0_rtx && GET_CODE (operands[2]) == REG)
3544 operands[6] = operands[2];
3546 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3548 [(set_attr "cc" "set_znv,compare")])
3550 (define_insn "*condbclr"
3551 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3553 (match_operator:QI 2 "eqne_operator"
3554 [(cc0) (const_int 0)])
3556 (match_operand:QI 3 "bit_memory_operand" "0")
3557 (match_operand:QI 1 "single_zero_operand" "n"))
3559 "TARGET_H8300SX && reload_completed"
3561 [(set_attr "cc" "none_0hit")
3562 (set_attr "length_table" "logicb")])
3564 (define_insn_and_split "*cmpcondbsetreg"
3565 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3569 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3570 (match_operand 3 "h8300_src_operand" "I,rQi")])
3572 (match_operand:QI 4 "bit_memory_operand" "0,0")
3573 (ashift:QI (const_int 1)
3574 (match_operand:QI 5 "register_operand" "r,r")))
3579 [(set (cc0) (match_dup 6))
3582 (match_op_dup 1 [(cc0) (const_int 0)])
3583 (ior:QI (match_dup 4)
3584 (ashift:QI (const_int 1)
3585 (match_operand:QI 5 "register_operand" "r,r")))
3589 if (operands[3] == const0_rtx && GET_CODE (operands[2]) == REG)
3590 operands[6] = operands[2];
3592 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3594 [(set_attr "cc" "set_znv,compare")])
3596 (define_insn "*condbsetreg"
3597 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3599 (match_operator:QI 2 "eqne_operator"
3600 [(cc0) (const_int 0)])
3602 (match_operand:QI 3 "bit_memory_operand" "0")
3603 (ashift:QI (const_int 1)
3604 (match_operand:QI 1 "register_operand" "r")))
3606 "TARGET_H8300SX && reload_completed"
3608 [(set_attr "cc" "none_0hit")
3609 (set_attr "length_table" "logicb")])
3611 (define_insn_and_split "*cmpcondbclrreg"
3612 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3616 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3617 (match_operand 3 "h8300_src_operand" "I,rQi")])
3619 (match_operand:QI 4 "bit_memory_operand" "0,0")
3620 (ashift:QI (const_int 1)
3621 (match_operand:QI 5 "register_operand" "r,r")))
3626 [(set (cc0) (match_dup 6))
3629 (match_op_dup 1 [(cc0) (const_int 0)])
3630 (and:QI (match_dup 4)
3631 (ashift:QI (const_int 1)
3632 (match_operand:QI 5 "register_operand" "r,r")))
3636 if (operands[3] == const0_rtx && GET_CODE (operands[2]) == REG)
3637 operands[6] = operands[2];
3639 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3641 [(set_attr "cc" "set_znv,compare")])
3643 (define_insn "*condbclrreg"
3644 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3646 (match_operator:QI 2 "eqne_operator"
3647 [(cc0) (const_int 0)])
3649 (match_operand:QI 3 "bit_memory_operand" "0")
3650 (ashift:QI (const_int 1)
3651 (match_operand:QI 1 "register_operand" "r")))
3653 "TARGET_H8300SX && reload_completed"
3655 [(set_attr "cc" "none_0hit")
3656 (set_attr "length_table" "logicb")])
3659 ;; -----------------------------------------------------------------
3661 ;; -----------------------------------------------------------------
3665 (define_insn "*insv_si_1_n"
3666 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3668 (match_operand:SI 1 "const_int_operand" "n"))
3669 (match_operand:SI 2 "register_operand" "r"))]
3670 "(TARGET_H8300H || TARGET_H8300S)
3671 && INTVAL (operands[1]) < 16"
3672 "bld\\t#0,%w2\;bst\\t%Z1,%Y0"
3673 [(set_attr "length" "4")])
3675 (define_insn "*insv_si_1_n_lshiftrt"
3676 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3678 (match_operand:SI 1 "const_int_operand" "n"))
3679 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3680 (match_operand:SI 3 "const_int_operand" "n")))]
3681 "(TARGET_H8300H || TARGET_H8300S)
3682 && INTVAL (operands[1]) < 16
3683 && INTVAL (operands[3]) < 16"
3684 "bld\\t%Z3,%Y2\;bst\\t%Z1,%Y0"
3685 [(set_attr "length" "4")])
3687 (define_insn "*insv_si_1_n_lshiftrt_16"
3688 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3690 (match_operand:SI 1 "const_int_operand" "n"))
3691 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3693 "(TARGET_H8300H || TARGET_H8300S)
3694 && INTVAL (operands[1]) < 16"
3695 "rotr.w\\t%e2\;rotl.w\\t%e2\;bst\\t%Z1,%Y0"
3696 [(set_attr "length" "6")])
3698 (define_insn "*insv_si_8_8"
3699 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3702 (match_operand:SI 1 "register_operand" "r"))]
3703 "TARGET_H8300H || TARGET_H8300S"
3705 [(set_attr "length" "2")])
3707 (define_insn "*insv_si_8_8_lshiftrt_8"
3708 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3711 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3713 "TARGET_H8300H || TARGET_H8300S"
3715 [(set_attr "length" "2")])
3719 (define_insn "*extzv_8_8"
3720 [(set (match_operand:SI 0 "register_operand" "=r,r")
3721 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
3724 "TARGET_H8300H || TARGET_H8300S"
3726 mov.b\\t%x1,%w0\;extu.w\\t%f0\;extu.l\\t%S0
3727 sub.l\\t%S0,%S0\;mov.b\\t%x1,%w0"
3728 [(set_attr "cc" "set_znv,clobber")
3729 (set_attr "length" "6,4")])
3731 (define_insn "*extzv_8_16"
3732 [(set (match_operand:SI 0 "register_operand" "=r")
3733 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3736 "TARGET_H8300H || TARGET_H8300S"
3737 "mov.w\\t%e1,%f0\;extu.w\\t%f0\;extu.l\\t%S0"
3738 [(set_attr "cc" "set_znv")
3739 (set_attr "length" "6")])
3741 (define_insn "*extzv_16_8"
3742 [(set (match_operand:SI 0 "register_operand" "=r")
3743 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3746 (clobber (match_scratch:SI 2 "=&r"))]
3748 "mov.w\\t%e1,%f2\;mov.b\\t%x1,%w0\;mov.b\\t%w2,%x0\;extu.l\\t%S0"
3749 [(set_attr "length" "8")
3750 (set_attr "cc" "set_znv")])
3752 ;; Extract the exponent of a float.
3754 (define_insn_and_split "*extzv_8_23"
3755 [(set (match_operand:SI 0 "register_operand" "=r")
3756 (zero_extract:SI (match_operand:SI 1 "register_operand" "0")
3759 "(TARGET_H8300H || TARGET_H8300S)"
3761 "&& reload_completed"
3762 [(parallel [(set (match_dup 0)
3763 (ashift:SI (match_dup 0)
3765 (clobber (scratch:QI))])
3766 (parallel [(set (match_dup 0)
3767 (lshiftrt:SI (match_dup 0)
3769 (clobber (scratch:QI))])]
3774 ;; ((SImode) HImode) << 15
3776 (define_insn_and_split "*twoshifts_l16_r1"
3777 [(set (match_operand:SI 0 "register_operand" "=r")
3778 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
3780 (const_int 2147450880)))]
3781 "(TARGET_H8300H || TARGET_H8300S)"
3783 "&& reload_completed"
3784 [(parallel [(set (match_dup 0)
3785 (ashift:SI (match_dup 0)
3787 (clobber (scratch:QI))])
3788 (parallel [(set (match_dup 0)
3789 (lshiftrt:SI (match_dup 0)
3791 (clobber (scratch:QI))])]
3794 ;; Transform (SImode << B) & 0xffff into (SImode) (HImode << B).
3796 (define_insn_and_split "*andsi3_ashift_n_lower"
3797 [(set (match_operand:SI 0 "register_operand" "=r,r")
3798 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0,0")
3799 (match_operand:QI 2 "const_int_operand" "S,n"))
3800 (match_operand:SI 3 "const_int_operand" "n,n")))
3801 (clobber (match_scratch:QI 4 "=X,&r"))]
3802 "(TARGET_H8300H || TARGET_H8300S)
3803 && INTVAL (operands[2]) <= 15
3804 && INTVAL (operands[3]) == ((-1 << INTVAL (operands[2])) & 0xffff)"
3806 "&& reload_completed"
3807 [(parallel [(set (match_dup 5)
3808 (ashift:HI (match_dup 5)
3810 (clobber (match_dup 4))])
3812 (zero_extend:SI (match_dup 5)))]
3813 "operands[5] = gen_rtx_REG (HImode, REGNO (operands[0]));")
3815 ;; Accept (A >> 30) & 2 and the like.
3817 (define_insn "*andsi3_lshiftrt_n_sb"
3818 [(set (match_operand:SI 0 "register_operand" "=r")
3819 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3820 (match_operand:SI 2 "const_int_operand" "n"))
3821 (match_operand:SI 3 "single_one_operand" "n")))]
3822 "(TARGET_H8300H || TARGET_H8300S)
3823 && exact_log2 (INTVAL (operands[3])) < 16
3824 && INTVAL (operands[2]) + exact_log2 (INTVAL (operands[3])) == 31"
3827 operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
3828 return \"shll.l\\t%S0\;xor.l\\t%S0,%S0\;bst\\t%Z3,%Y0\";
3830 [(set_attr "length" "8")])
3832 (define_insn_and_split "*andsi3_lshiftrt_9_sb"
3833 [(set (match_operand:SI 0 "register_operand" "=r")
3834 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3836 (const_int 4194304)))]
3837 "(TARGET_H8300H || TARGET_H8300S)"
3839 "&& reload_completed"
3841 (and:SI (lshiftrt:SI (match_dup 0)
3844 (parallel [(set (match_dup 0)
3845 (ashift:SI (match_dup 0)
3847 (clobber (scratch:QI))])]
3852 (define_insn "*addsi3_upper"
3853 [(set (match_operand:SI 0 "register_operand" "=r")
3854 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3856 (match_operand:SI 2 "register_operand" "0")))]
3857 "TARGET_H8300H || TARGET_H8300S"
3859 [(set_attr "length" "2")])
3861 (define_insn "*addsi3_lshiftrt_16_zexthi"
3862 [(set (match_operand:SI 0 "register_operand" "=r")
3863 (plus:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3865 (zero_extend:SI (match_operand:HI 2 "register_operand" "0"))))]
3866 "TARGET_H8300H || TARGET_H8300S"
3867 "add.w\\t%e1,%f0\;xor.w\\t%e0,%e0\;rotxl.w\\t%e0"
3868 [(set_attr "length" "6")])
3870 (define_insn_and_split "*addsi3_and_r_1"
3871 [(set (match_operand:SI 0 "register_operand" "=r")
3872 (plus:SI (and:SI (match_operand:SI 1 "register_operand" "r")
3874 (match_operand:SI 2 "register_operand" "0")))]
3875 "(TARGET_H8300H || TARGET_H8300S)"
3877 "&& reload_completed"
3879 (zero_extract:SI (match_dup 1)
3883 (if_then_else (eq (cc0)
3885 (label_ref (match_dup 3))
3888 (plus:SI (match_dup 2)
3891 "operands[3] = gen_label_rtx ();")
3893 (define_insn_and_split "*addsi3_and_not_r_1"
3894 [(set (match_operand:SI 0 "register_operand" "=r")
3895 (plus:SI (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
3897 (match_operand:SI 2 "register_operand" "0")))]
3898 "(TARGET_H8300H || TARGET_H8300S)"
3900 "&& reload_completed"
3902 (zero_extract:SI (match_dup 1)
3906 (if_then_else (ne (cc0)
3908 (label_ref (match_dup 3))
3911 (plus:SI (match_dup 2)
3914 "operands[3] = gen_label_rtx ();")
3918 (define_insn "*ixorhi3_zext"
3919 [(set (match_operand:HI 0 "register_operand" "=r")
3920 (match_operator:HI 1 "iorxor_operator"
3921 [(zero_extend:HI (match_operand:QI 2 "register_operand" "r"))
3922 (match_operand:HI 3 "register_operand" "0")]))]
3925 [(set_attr "length" "2")])
3929 (define_insn "*ixorsi3_zext_qi"
3930 [(set (match_operand:SI 0 "register_operand" "=r")
3931 (match_operator:SI 1 "iorxor_operator"
3932 [(zero_extend:SI (match_operand:QI 2 "register_operand" "r"))
3933 (match_operand:SI 3 "register_operand" "0")]))]
3936 [(set_attr "length" "2")])
3938 (define_insn "*ixorsi3_zext_hi"
3939 [(set (match_operand:SI 0 "register_operand" "=r")
3940 (match_operator:SI 1 "iorxor_operator"
3941 [(zero_extend:SI (match_operand:HI 2 "register_operand" "r"))
3942 (match_operand:SI 3 "register_operand" "0")]))]
3943 "TARGET_H8300H || TARGET_H8300S"
3945 [(set_attr "length" "2")])
3947 (define_insn "*ixorsi3_ashift_16"
3948 [(set (match_operand:SI 0 "register_operand" "=r")
3949 (match_operator:SI 1 "iorxor_operator"
3950 [(ashift:SI (match_operand:SI 2 "register_operand" "r")
3952 (match_operand:SI 3 "register_operand" "0")]))]
3953 "TARGET_H8300H || TARGET_H8300S"
3955 [(set_attr "length" "2")])
3957 (define_insn "*ixorsi3_lshiftrt_16"
3958 [(set (match_operand:SI 0 "register_operand" "=r")
3959 (match_operator:SI 1 "iorxor_operator"
3960 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3962 (match_operand:SI 3 "register_operand" "0")]))]
3963 "TARGET_H8300H || TARGET_H8300S"
3965 [(set_attr "length" "2")])
3969 (define_insn "*iorhi3_ashift_8"
3970 [(set (match_operand:HI 0 "register_operand" "=r")
3971 (ior:HI (ashift:HI (match_operand:HI 1 "register_operand" "r")
3973 (match_operand:HI 2 "register_operand" "0")))]
3976 [(set_attr "length" "2")])
3978 (define_insn "*iorhi3_lshiftrt_8"
3979 [(set (match_operand:HI 0 "register_operand" "=r")
3980 (ior:HI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
3982 (match_operand:HI 2 "register_operand" "0")))]
3985 [(set_attr "length" "2")])
3987 (define_insn "*iorhi3_two_qi"
3988 [(set (match_operand:HI 0 "register_operand" "=r")
3989 (ior:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
3990 (ashift:HI (match_operand:HI 2 "register_operand" "r")
3994 [(set_attr "length" "2")])
3996 (define_insn "*iorhi3_two_qi_mem"
3997 [(set (match_operand:HI 0 "register_operand" "=&r")
3998 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" "m"))
3999 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "m") 0)
4002 "mov.b\\t%X2,%t0\;mov.b\\t%X1,%s0"
4003 [(set_attr "length" "16")])
4006 [(set (match_operand:HI 0 "register_operand" "")
4007 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" ""))
4008 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "") 0)
4010 "(TARGET_H8300H || TARGET_H8300S)
4012 && byte_accesses_mergeable_p (XEXP (operands[2], 0), XEXP (operands[1], 0))"
4015 "operands[3] = gen_rtx_MEM (HImode, XEXP (operands[2], 0));")
4019 (define_insn "*iorsi3_two_hi"
4020 [(set (match_operand:SI 0 "register_operand" "=r")
4021 (ior:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
4022 (ashift:SI (match_operand:SI 2 "register_operand" "r")
4024 "TARGET_H8300H || TARGET_H8300S"
4026 [(set_attr "length" "2")])
4028 (define_insn_and_split "*iorsi3_two_qi_zext"
4029 [(set (match_operand:SI 0 "register_operand" "=&r")
4030 (ior:SI (zero_extend:SI (match_operand:QI 1 "memory_operand" "m"))
4032 (and:SI (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
4034 (const_int 65280))))]
4035 "(TARGET_H8300H || TARGET_H8300S)"
4037 "&& reload_completed"
4039 (ior:HI (zero_extend:HI (match_dup 1))
4040 (ashift:HI (subreg:HI (match_dup 2) 0)
4043 (zero_extend:SI (match_dup 3)))]
4044 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));")
4046 (define_insn "*iorsi3_e2f"
4047 [(set (match_operand:SI 0 "register_operand" "=r")
4048 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
4050 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
4052 "TARGET_H8300H || TARGET_H8300S"
4054 [(set_attr "length" "2")])
4056 (define_insn_and_split "*iorsi3_two_qi_sext"
4057 [(set (match_operand:SI 0 "register_operand" "=r")
4058 (ior:SI (zero_extend:SI (match_operand:QI 1 "register_operand" "0"))
4059 (ashift:SI (sign_extend:SI (match_operand:QI 2 "register_operand" "r"))
4061 "(TARGET_H8300H || TARGET_H8300S)"
4063 "&& reload_completed"
4065 (ior:HI (zero_extend:HI (match_dup 1))
4066 (ashift:HI (match_dup 4)
4069 (sign_extend:SI (match_dup 3)))]
4070 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4071 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));")
4073 (define_insn "*iorsi3_w"
4074 [(set (match_operand:SI 0 "register_operand" "=r,&r")
4075 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0,0")
4077 (zero_extend:SI (match_operand:QI 2 "general_operand_src" "r,g>"))))]
4078 "TARGET_H8300H || TARGET_H8300S"
4080 [(set_attr "length" "2,8")])
4082 (define_insn "*iorsi3_ashift_31"
4083 [(set (match_operand:SI 0 "register_operand" "=&r")
4084 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4086 (match_operand:SI 2 "register_operand" "0")))]
4087 "TARGET_H8300H || TARGET_H8300S"
4088 "rotxl.l\\t%S0\;bor\\t#0,%w1\;rotxr.l\\t%S0"
4089 [(set_attr "length" "6")
4090 (set_attr "cc" "set_znv")])
4092 (define_insn "*iorsi3_and_ashift"
4093 [(set (match_operand:SI 0 "register_operand" "=r")
4094 (ior:SI (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4095 (match_operand:SI 2 "const_int_operand" "n"))
4096 (match_operand:SI 3 "single_one_operand" "n"))
4097 (match_operand:SI 4 "register_operand" "0")))]
4098 "(TARGET_H8300H || TARGET_H8300S)
4099 && (INTVAL (operands[3]) & ~0xffff) == 0"
4102 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
4103 - INTVAL (operands[2]));
4104 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
4105 operands[2] = srcpos;
4106 operands[3] = dstpos;
4107 return \"bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0\";
4109 [(set_attr "length" "6")])
4111 (define_insn "*iorsi3_and_lshiftrt"
4112 [(set (match_operand:SI 0 "register_operand" "=r")
4113 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4114 (match_operand:SI 2 "const_int_operand" "n"))
4115 (match_operand:SI 3 "single_one_operand" "n"))
4116 (match_operand:SI 4 "register_operand" "0")))]
4117 "(TARGET_H8300H || TARGET_H8300S)
4118 && ((INTVAL (operands[3]) << INTVAL (operands[2])) & ~0xffff) == 0"
4121 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
4122 + INTVAL (operands[2]));
4123 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
4124 operands[2] = srcpos;
4125 operands[3] = dstpos;
4126 return \"bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0\";
4128 [(set_attr "length" "6")])
4130 (define_insn "*iorsi3_zero_extract"
4131 [(set (match_operand:SI 0 "register_operand" "=r")
4132 (ior:SI (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
4134 (match_operand:SI 2 "const_int_operand" "n"))
4135 (match_operand:SI 3 "register_operand" "0")))]
4136 "(TARGET_H8300H || TARGET_H8300S)
4137 && INTVAL (operands[2]) < 16"
4138 "bld\\t%Z2,%Y1\;bor\\t#0,%w0\;bst\\t#0,%w0"
4139 [(set_attr "length" "6")])
4141 (define_insn "*iorsi3_and_lshiftrt_n_sb"
4142 [(set (match_operand:SI 0 "register_operand" "=r")
4143 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4146 (match_operand:SI 2 "register_operand" "0")))]
4147 "(TARGET_H8300H || TARGET_H8300S)"
4148 "rotl.l\\t%S1\;rotr.l\\t%S1\;bor\\t#1,%w0\;bst\\t#1,%w0"
4149 [(set_attr "length" "8")])
4151 (define_insn "*iorsi3_and_lshiftrt_9_sb"
4152 [(set (match_operand:SI 0 "register_operand" "=r")
4153 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4155 (const_int 4194304))
4156 (match_operand:SI 2 "register_operand" "0")))
4157 (clobber (match_scratch:HI 3 "=&r"))]
4158 "(TARGET_H8300H || TARGET_H8300S)"
4161 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4162 return \"shll.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0\";
4164 return \"rotl.l\\t%S1\;rotr.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0\";
4166 [(set_attr "length" "10")])
4168 ;; Used to OR the exponent of a float.
4170 (define_insn "*iorsi3_shift"
4171 [(set (match_operand:SI 0 "register_operand" "=r")
4172 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4174 (match_operand:SI 2 "register_operand" "0")))
4175 (clobber (match_scratch:SI 3 "=&r"))]
4176 "TARGET_H8300H || TARGET_H8300S"
4180 [(set (match_operand:SI 0 "register_operand" "")
4181 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4184 (clobber (match_operand:SI 2 "register_operand" ""))]
4185 "(TARGET_H8300H || TARGET_H8300S)
4187 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4188 && REGNO (operands[0]) != REGNO (operands[1])"
4189 [(parallel [(set (match_dup 3)
4190 (ashift:HI (match_dup 3)
4192 (clobber (scratch:QI))])
4194 (ior:SI (ashift:SI (match_dup 1)
4197 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));")
4200 [(set (match_operand:SI 0 "register_operand" "")
4201 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4204 (clobber (match_operand:SI 2 "register_operand" ""))]
4205 "(TARGET_H8300H || TARGET_H8300S)
4207 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4208 && REGNO (operands[0]) != REGNO (operands[1]))"
4211 (parallel [(set (match_dup 3)
4212 (ashift:HI (match_dup 3)
4214 (clobber (scratch:QI))])
4216 (ior:SI (ashift:SI (match_dup 2)
4219 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));")
4221 (define_insn "*iorsi2_and_1_lshiftrt_1"
4222 [(set (match_operand:SI 0 "register_operand" "=r")
4223 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
4225 (lshiftrt:SI (match_dup 1)
4227 "TARGET_H8300H || TARGET_H8300S"
4228 "shlr.l\\t%S0\;bor\\t#0,%w0\;bst\\t#0,%w0"
4229 [(set_attr "length" "6")])
4231 (define_insn_and_split "*iorsi3_ashift_16_ashift_24"
4232 [(set (match_operand:SI 0 "register_operand" "=r")
4233 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
4235 (ashift:SI (match_operand:SI 2 "register_operand" "r")
4237 "(TARGET_H8300H || TARGET_H8300S)"
4239 "&& reload_completed"
4241 (ior:HI (ashift:HI (match_dup 4)
4244 (parallel [(set (match_dup 0)
4245 (ashift:SI (match_dup 0)
4247 (clobber (scratch:QI))])]
4248 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4249 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));")
4251 (define_insn_and_split "*iorsi3_ashift_16_ashift_24_mem"
4252 [(set (match_operand:SI 0 "register_operand" "=&r")
4253 (ior:SI (and:SI (ashift:SI (subreg:SI (match_operand:QI 1 "memory_operand" "m") 0)
4255 (const_int 16711680))
4256 (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
4258 "(TARGET_H8300H || TARGET_H8300S)"
4260 "&& reload_completed"
4262 (ior:HI (zero_extend:HI (match_dup 1))
4263 (ashift:HI (subreg:HI (match_dup 2) 0)
4265 (parallel [(set (match_dup 0)
4266 (ashift:SI (match_dup 0)
4268 (clobber (scratch:QI))])]
4269 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));")
4271 ;; Used to add the exponent of a float.
4273 (define_insn "*addsi3_shift"
4274 [(set (match_operand:SI 0 "register_operand" "=r")
4275 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
4276 (const_int 8388608))
4277 (match_operand:SI 2 "register_operand" "0")))
4278 (clobber (match_scratch:SI 3 "=&r"))]
4279 "TARGET_H8300H || TARGET_H8300S"
4283 [(set (match_operand:SI 0 "register_operand" "")
4284 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4285 (const_int 8388608))
4287 (clobber (match_operand:SI 2 "register_operand" ""))]
4288 "(TARGET_H8300H || TARGET_H8300S)
4290 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4291 && REGNO (operands[0]) != REGNO (operands[1])"
4292 [(parallel [(set (match_dup 3)
4293 (ashift:HI (match_dup 3)
4295 (clobber (scratch:QI))])
4297 (plus:SI (mult:SI (match_dup 1)
4300 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));")
4303 [(set (match_operand:SI 0 "register_operand" "")
4304 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4305 (const_int 8388608))
4307 (clobber (match_operand:SI 2 "register_operand" ""))]
4308 "(TARGET_H8300H || TARGET_H8300S)
4310 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4311 && REGNO (operands[0]) != REGNO (operands[1]))"
4314 (parallel [(set (match_dup 3)
4315 (ashift:HI (match_dup 3)
4317 (clobber (scratch:QI))])
4319 (plus:SI (mult:SI (match_dup 2)
4322 "operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));")
4326 (define_insn_and_split "*ashiftsi_sextqi_7"
4327 [(set (match_operand:SI 0 "register_operand" "=r")
4328 (ashift:SI (sign_extend:SI (match_operand:QI 1 "register_operand" "0"))
4330 "(TARGET_H8300H || TARGET_H8300S)"
4332 "&& reload_completed"
4333 [(parallel [(set (match_dup 2)
4334 (ashift:HI (match_dup 2)
4336 (clobber (scratch:QI))])
4338 (sign_extend:SI (match_dup 2)))
4339 (parallel [(set (match_dup 0)
4340 (ashiftrt:SI (match_dup 0)
4342 (clobber (scratch:QI))])]
4343 "operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));")
4345 ;; Storing a part of HImode to QImode.
4348 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4349 (subreg:QI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
4353 [(set_attr "cc" "set_znv")
4354 (set_attr "length" "8")])
4356 ;; Storing a part of SImode to QImode.
4359 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4360 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4364 [(set_attr "cc" "set_znv")
4365 (set_attr "length" "8")])
4368 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4369 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4371 (clobber (match_scratch:SI 2 "=&r"))]
4372 "TARGET_H8300H || TARGET_H8300S"
4373 "mov.w\\t%e1,%f2\;mov.b\\t%w2,%R0"
4374 [(set_attr "cc" "set_znv")
4375 (set_attr "length" "10")])
4378 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4379 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4381 (clobber (match_scratch:SI 2 "=&r"))]
4382 "TARGET_H8300H || TARGET_H8300S"
4383 "mov.w\\t%e1,%f2\;mov.b\\t%x2,%R0"
4384 [(set_attr "cc" "set_znv")
4385 (set_attr "length" "10")])
4387 (define_insn_and_split ""
4389 (if_then_else (eq (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
4393 (label_ref (match_operand 1 "" ""))
4401 (if_then_else (ge (cc0)
4403 (label_ref (match_dup 1))
4407 (define_insn_and_split ""
4409 (if_then_else (ne (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
4413 (label_ref (match_operand 1 "" ""))
4421 (if_then_else (lt (cc0)
4423 (label_ref (match_dup 1))
4427 ;; -----------------------------------------------------------------
4428 ;; PEEPHOLE PATTERNS
4429 ;; -----------------------------------------------------------------
4431 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
4434 [(parallel [(set (match_operand:HI 0 "register_operand" "")
4435 (lshiftrt:HI (match_dup 0)
4436 (match_operand:HI 1 "const_int_operand" "")))
4437 (clobber (match_operand:HI 2 "" ""))])
4439 (and:HI (match_dup 0)
4440 (match_operand:HI 3 "const_int_operand" "")))]
4441 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
4443 (and:HI (match_dup 0)
4447 (lshiftrt:HI (match_dup 0)
4449 (clobber (match_dup 2))])]
4452 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
4455 [(parallel [(set (match_operand:HI 0 "register_operand" "")
4456 (ashift:HI (match_dup 0)
4457 (match_operand:HI 1 "const_int_operand" "")))
4458 (clobber (match_operand:HI 2 "" ""))])
4460 (and:HI (match_dup 0)
4461 (match_operand:HI 3 "const_int_operand" "")))]
4462 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
4464 (and:HI (match_dup 0)
4468 (ashift:HI (match_dup 0)
4470 (clobber (match_dup 2))])]
4473 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
4476 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4477 (lshiftrt:SI (match_dup 0)
4478 (match_operand:SI 1 "const_int_operand" "")))
4479 (clobber (match_operand:SI 2 "" ""))])
4481 (and:SI (match_dup 0)
4482 (match_operand:SI 3 "const_int_operand" "")))]
4483 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
4485 (and:SI (match_dup 0)
4489 (lshiftrt:SI (match_dup 0)
4491 (clobber (match_dup 2))])]
4494 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
4497 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4498 (ashift:SI (match_dup 0)
4499 (match_operand:SI 1 "const_int_operand" "")))
4500 (clobber (match_operand:SI 2 "" ""))])
4502 (and:SI (match_dup 0)
4503 (match_operand:SI 3 "const_int_operand" "")))]
4504 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
4506 (and:SI (match_dup 0)
4510 (ashift:SI (match_dup 0)
4512 (clobber (match_dup 2))])]
4515 ;; Convert (A >> B) & C to (A & 65535) >> B if C == 65535 >> B.
4518 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4519 (lshiftrt:SI (match_dup 0)
4520 (match_operand:SI 1 "const_int_operand" "")))
4521 (clobber (match_operand:SI 2 "" ""))])
4523 (and:SI (match_dup 0)
4524 (match_operand:SI 3 "const_int_operand" "")))]
4525 "INTVAL (operands[3]) == (65535 >> INTVAL (operands[1]))"
4527 (and:SI (match_dup 0)
4531 (lshiftrt:SI (match_dup 0)
4533 (clobber (match_dup 2))])]
4536 ;; Convert (A << B) & C to (A & 65535) << B if C == 65535 << B.
4539 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4540 (ashift:SI (match_dup 0)
4541 (match_operand:SI 1 "const_int_operand" "")))
4542 (clobber (match_operand:SI 2 "" ""))])
4544 (and:SI (match_dup 0)
4545 (match_operand:SI 3 "const_int_operand" "")))]
4546 "INTVAL (operands[3]) == (65535 << INTVAL (operands[1]))"
4548 (and:SI (match_dup 0)
4552 (ashift:SI (match_dup 0)
4554 (clobber (match_dup 2))])]
4557 ;; Convert a QImode push into an SImode push so that the
4558 ;; define_peephole2 below can cram multiple pushes into one stm.l.
4561 [(parallel [(set (reg:SI SP_REG)
4562 (plus:SI (reg:SI SP_REG) (const_int -4)))
4563 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
4564 (match_operand:QI 0 "register_operand" ""))])]
4565 "TARGET_H8300S && !TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4566 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4568 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
4571 [(parallel [(set (reg:HI SP_REG)
4572 (plus:HI (reg:HI SP_REG) (const_int -4)))
4573 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
4574 (match_operand:QI 0 "register_operand" ""))])]
4575 "TARGET_H8300S && TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4576 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4578 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
4580 ;; Convert a HImode push into an SImode push so that the
4581 ;; define_peephole2 below can cram multiple pushes into one stm.l.
4584 [(parallel [(set (reg:SI SP_REG)
4585 (plus:SI (reg:SI SP_REG) (const_int -4)))
4586 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
4587 (match_operand:HI 0 "register_operand" ""))])]
4588 "TARGET_H8300S && !TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4589 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4591 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
4594 [(parallel [(set (reg:HI SP_REG)
4595 (plus:HI (reg:HI SP_REG) (const_int -4)))
4596 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
4597 (match_operand:HI 0 "register_operand" ""))])]
4598 "TARGET_H8300S && TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4599 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4601 "operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));")
4603 ;; Cram four pushes into stm.l.
4606 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4607 (match_operand:SI 0 "register_operand" ""))
4608 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4609 (match_operand:SI 1 "register_operand" ""))
4610 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4611 (match_operand:SI 2 "register_operand" ""))
4612 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4613 (match_operand:SI 3 "register_operand" ""))]
4614 "TARGET_H8300S && !TARGET_NORMAL_MODE
4615 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
4616 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4617 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4618 && REGNO (operands[3]) == REGNO (operands[0]) + 3
4619 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
4620 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4622 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4624 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
4626 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
4628 (set (reg:SI SP_REG)
4629 (plus:SI (reg:SI SP_REG)
4630 (const_int -16)))])]
4634 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4635 (match_operand:SI 0 "register_operand" ""))
4636 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4637 (match_operand:SI 1 "register_operand" ""))
4638 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4639 (match_operand:SI 2 "register_operand" ""))
4640 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4641 (match_operand:SI 3 "register_operand" ""))]
4642 "TARGET_H8300S && TARGET_NORMAL_MODE
4643 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
4644 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4645 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4646 && REGNO (operands[3]) == REGNO (operands[0]) + 3
4647 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
4648 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4650 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4652 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4654 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
4656 (set (reg:HI SP_REG)
4657 (plus:HI (reg:HI SP_REG)
4658 (const_int -16)))])]
4661 ;; Cram three pushes into stm.l.
4664 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4665 (match_operand:SI 0 "register_operand" ""))
4666 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4667 (match_operand:SI 1 "register_operand" ""))
4668 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4669 (match_operand:SI 2 "register_operand" ""))]
4670 "TARGET_H8300S && !TARGET_NORMAL_MODE
4671 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
4672 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4673 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4674 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
4675 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4677 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4679 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
4681 (set (reg:SI SP_REG)
4682 (plus:SI (reg:SI SP_REG)
4683 (const_int -12)))])]
4687 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4688 (match_operand:SI 0 "register_operand" ""))
4689 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4690 (match_operand:SI 1 "register_operand" ""))
4691 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4692 (match_operand:SI 2 "register_operand" ""))]
4693 "TARGET_H8300S && TARGET_NORMAL_MODE
4694 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
4695 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4696 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4697 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
4698 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4700 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4702 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4704 (set (reg:HI SP_REG)
4705 (plus:HI (reg:HI SP_REG)
4706 (const_int -12)))])]
4709 ;; Cram two pushes into stm.l.
4712 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4713 (match_operand:SI 0 "register_operand" ""))
4714 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4715 (match_operand:SI 1 "register_operand" ""))]
4716 "TARGET_H8300S && !TARGET_NORMAL_MODE
4717 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
4718 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4719 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
4720 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4722 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4724 (set (reg:SI SP_REG)
4725 (plus:SI (reg:SI SP_REG)
4730 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4731 (match_operand:SI 0 "register_operand" ""))
4732 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4733 (match_operand:SI 1 "register_operand" ""))]
4734 "TARGET_H8300S && TARGET_NORMAL_MODE
4735 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
4736 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4737 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
4738 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4740 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4742 (set (reg:HI SP_REG)
4743 (plus:HI (reg:HI SP_REG)
4750 ;; add.w r7,r0 (6 bytes)
4755 ;; adds #2,r0 (4 bytes)
4758 [(set (match_operand:HI 0 "register_operand" "")
4759 (match_operand:HI 1 "const_int_operand" ""))
4761 (plus:HI (match_dup 0)
4762 (match_operand:HI 2 "register_operand" "")))]
4763 "REG_P (operands[0]) && REG_P (operands[2])
4764 && REGNO (operands[0]) != REGNO (operands[2])
4765 && (CONST_OK_FOR_J (INTVAL (operands[1]))
4766 || CONST_OK_FOR_L (INTVAL (operands[1]))
4767 || CONST_OK_FOR_N (INTVAL (operands[1])))"
4771 (plus:HI (match_dup 0)
4779 ;; add.l er7,er0 (6 bytes)
4784 ;; adds #4,er0 (4 bytes)
4787 [(set (match_operand:SI 0 "register_operand" "")
4788 (match_operand:SI 1 "const_int_operand" ""))
4790 (plus:SI (match_dup 0)
4791 (match_operand:SI 2 "register_operand" "")))]
4792 "(TARGET_H8300H || TARGET_H8300S)
4793 && REG_P (operands[0]) && REG_P (operands[2])
4794 && REGNO (operands[0]) != REGNO (operands[2])
4795 && (CONST_OK_FOR_L (INTVAL (operands[1]))
4796 || CONST_OK_FOR_N (INTVAL (operands[1])))"
4800 (plus:SI (match_dup 0)
4807 ;; add.l #10,er0 (takes 8 bytes)
4813 ;; add.l er7,er0 (takes 6 bytes)
4816 [(set (match_operand:SI 0 "register_operand" "")
4817 (match_operand:SI 1 "register_operand" ""))
4819 (plus:SI (match_dup 0)
4820 (match_operand:SI 2 "const_int_operand" "")))]
4821 "(TARGET_H8300H || TARGET_H8300S)
4822 && REG_P (operands[0]) && REG_P (operands[1])
4823 && REGNO (operands[0]) != REGNO (operands[1])
4824 && !CONST_OK_FOR_L (INTVAL (operands[2]))
4825 && !CONST_OK_FOR_N (INTVAL (operands[2]))
4826 && ((INTVAL (operands[2]) & 0xff) == INTVAL (operands[2])
4827 || (INTVAL (operands[2]) & 0xff00) == INTVAL (operands[2])
4828 || INTVAL (operands[2]) == 0xffff
4829 || INTVAL (operands[2]) == 0xfffe)"
4833 (plus:SI (match_dup 0)
4849 [(set (match_operand:HI 0 "register_operand" "")
4850 (plus:HI (match_dup 0)
4851 (match_operand 1 "incdec_operand" "")))
4855 (if_then_else (match_operator 3 "eqne_operator"
4856 [(cc0) (const_int 0)])
4857 (label_ref (match_operand 2 "" ""))
4859 "TARGET_H8300H || TARGET_H8300S"
4860 [(set (match_operand:HI 0 "register_operand" "")
4861 (unspec:HI [(match_dup 0)
4867 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4868 (label_ref (match_dup 2))
4872 ;; The SImode version of the previous pattern.
4875 [(set (match_operand:SI 0 "register_operand" "")
4876 (plus:SI (match_dup 0)
4877 (match_operand 1 "incdec_operand" "")))
4881 (if_then_else (match_operator 3 "eqne_operator"
4882 [(cc0) (const_int 0)])
4883 (label_ref (match_operand 2 "" ""))
4885 "TARGET_H8300H || TARGET_H8300S"
4886 [(set (match_operand:SI 0 "register_operand" "")
4887 (unspec:SI [(match_dup 0)
4893 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4894 (label_ref (match_dup 2))
4899 [(parallel [(set (cc0)
4900 (zero_extract:SI (match_operand:QI 0 "register_operand" "")
4903 (clobber (scratch:QI))])
4905 (if_then_else (match_operator 1 "eqne_operator"
4906 [(cc0) (const_int 0)])
4907 (label_ref (match_operand 2 "" ""))
4909 "(TARGET_H8300H || TARGET_H8300S)"
4913 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4914 (label_ref (match_dup 2))
4916 "operands[3] = ((GET_CODE (operands[1]) == EQ)
4917 ? gen_rtx_GE (VOIDmode, cc0_rtx, const0_rtx)
4918 : gen_rtx_LT (VOIDmode, cc0_rtx, const0_rtx));")
4920 ;; The next three peephole2's will try to transform
4922 ;; mov.b A,r0l (or mov.l A,er0)
4929 ;; and.b #CST,r0l (if CST is not 255)
4932 [(set (match_operand:QI 0 "register_operand" "")
4933 (match_operand:QI 1 "general_operand" ""))
4934 (set (match_operand:SI 2 "register_operand" "")
4935 (and:SI (match_dup 2)
4937 "(TARGET_H8300H || TARGET_H8300S)
4938 && !reg_overlap_mentioned_p (operands[2], operands[1])
4939 && REGNO (operands[0]) == REGNO (operands[2])"
4942 (set (strict_low_part (match_dup 0))
4947 [(set (match_operand:SI 0 "register_operand" "")
4948 (match_operand:SI 1 "general_operand" ""))
4950 (and:SI (match_dup 0)
4952 "(TARGET_H8300H || TARGET_H8300S)
4953 && !reg_overlap_mentioned_p (operands[0], operands[1])
4954 && !(GET_CODE (operands[1]) == MEM && !offsettable_memref_p (operands[1]))
4955 && !(GET_CODE (operands[1]) == MEM && MEM_VOLATILE_P (operands[1]))"
4958 (set (strict_low_part (match_dup 2))
4960 "operands[2] = gen_lowpart (QImode, operands[0]);
4961 operands[3] = gen_lowpart (QImode, operands[1]);")
4964 [(set (match_operand 0 "register_operand" "")
4965 (match_operand 1 "general_operand" ""))
4966 (set (match_operand:SI 2 "register_operand" "")
4967 (and:SI (match_dup 2)
4968 (match_operand:SI 3 "const_int_qi_operand" "")))]
4969 "(TARGET_H8300H || TARGET_H8300S)
4970 && (GET_MODE (operands[0]) == QImode
4971 || GET_MODE (operands[0]) == HImode
4972 || GET_MODE (operands[0]) == SImode)
4973 && GET_MODE (operands[0]) == GET_MODE (operands[1])
4974 && REGNO (operands[0]) == REGNO (operands[2])
4975 && !reg_overlap_mentioned_p (operands[2], operands[1])
4976 && !(GET_MODE (operands[1]) != QImode
4977 && GET_CODE (operands[1]) == MEM
4978 && !offsettable_memref_p (operands[1]))
4979 && !(GET_MODE (operands[1]) != QImode
4980 && GET_CODE (operands[1]) == MEM
4981 && MEM_VOLATILE_P (operands[1]))"
4984 (set (strict_low_part (match_dup 4))
4987 (and:SI (match_dup 2)
4989 "operands[4] = gen_lowpart (QImode, operands[0]);
4990 operands[5] = gen_lowpart (QImode, operands[1]);
4991 operands[6] = GEN_INT (~0xff | INTVAL (operands[3]));")
4994 [(set (match_operand:SI 0 "register_operand" "")
4995 (match_operand:SI 1 "register_operand" ""))
4997 (and:SI (match_dup 0)
4998 (const_int 65280)))]
4999 "(TARGET_H8300H || TARGET_H8300S)
5000 && !reg_overlap_mentioned_p (operands[0], operands[1])"
5003 (set (zero_extract:SI (match_dup 0)
5006 (lshiftrt:SI (match_dup 1)
5010 ;; If a load of mem:SI is followed by an AND that turns off the upper
5011 ;; half, then we can load mem:HI instead.
5014 [(set (match_operand:SI 0 "register_operand" "")
5015 (match_operand:SI 1 "memory_operand" ""))
5017 (and:SI (match_dup 0)
5018 (match_operand:SI 2 "const_int_operand" "")))]
5019 "(TARGET_H8300H || TARGET_H8300S)
5020 && !MEM_VOLATILE_P (operands[1])
5021 && offsettable_memref_p (operands[1])
5022 && (INTVAL (operands[2]) & ~0xffff) == 0
5023 && INTVAL (operands[2]) != 255"
5027 (and:SI (match_dup 0)
5029 "operands[3] = gen_lowpart (HImode, operands[0]);
5030 operands[4] = gen_lowpart (HImode, operands[1]);")
5032 ;; (compare (reg:HI) (const_int)) takes 4 bytes, so we try to achieve
5033 ;; the equivalent with shorter sequences. Here is the summary. Cases
5034 ;; are grouped for each define_peephole2.
5036 ;; reg const_int use insn
5037 ;; --------------------------------------------------------
5038 ;; dead -2 eq/ne inc.l
5039 ;; dead -1 eq/ne inc.l
5040 ;; dead 1 eq/ne dec.l
5041 ;; dead 2 eq/ne dec.l
5043 ;; dead 1 ge/lt shar.l
5044 ;; dead 3 (H8S) ge/lt shar.l
5046 ;; dead 1 geu/ltu shar.l
5047 ;; dead 3 (H8S) geu/ltu shar.l
5049 ;; ---- 255 ge/lt mov.b
5051 ;; ---- 255 geu/ltu mov.b
5065 (compare (match_operand:HI 0 "register_operand" "")
5066 (match_operand:HI 1 "incdec_operand" "")))
5068 (if_then_else (match_operator 3 "eqne_operator"
5069 [(cc0) (const_int 0)])
5070 (label_ref (match_operand 2 "" ""))
5072 "(TARGET_H8300H || TARGET_H8300S)
5073 && peep2_reg_dead_p (1, operands[0])"
5075 (unspec:HI [(match_dup 0)
5081 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5082 (label_ref (match_dup 2))
5084 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
5098 (compare (match_operand:HI 0 "register_operand" "")
5099 (match_operand:HI 1 "const_int_operand" "")))
5101 (if_then_else (match_operator 2 "gtle_operator"
5102 [(cc0) (const_int 0)])
5103 (label_ref (match_operand 3 "" ""))
5105 "(TARGET_H8300H || TARGET_H8300S)
5106 && peep2_reg_dead_p (1, operands[0])
5107 && (INTVAL (operands[1]) == 1
5108 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5109 [(parallel [(set (match_dup 0)
5110 (ashiftrt:HI (match_dup 0)
5112 (clobber (scratch:QI))])
5116 (if_then_else (match_dup 2)
5117 (label_ref (match_dup 3))
5119 "operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
5133 (compare (match_operand:HI 0 "register_operand" "")
5134 (match_operand:HI 1 "const_int_operand" "")))
5136 (if_then_else (match_operator 2 "gtuleu_operator"
5137 [(cc0) (const_int 0)])
5138 (label_ref (match_operand 3 "" ""))
5140 "(TARGET_H8300H || TARGET_H8300S)
5141 && peep2_reg_dead_p (1, operands[0])
5142 && (INTVAL (operands[1]) == 1
5143 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5144 [(parallel [(set (match_dup 0)
5145 (ashiftrt:HI (match_dup 0)
5147 (clobber (scratch:QI))])
5151 (if_then_else (match_dup 5)
5152 (label_ref (match_dup 3))
5155 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5156 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5174 (compare (match_operand:HI 0 "register_operand" "")
5177 (if_then_else (match_operator 1 "gtle_operator"
5178 [(cc0) (const_int 0)])
5179 (label_ref (match_operand 2 "" ""))
5181 "TARGET_H8300H || TARGET_H8300S"
5183 (and:HI (match_dup 0)
5186 (if_then_else (match_dup 1)
5187 (label_ref (match_dup 2))
5203 (compare (match_operand:HI 0 "register_operand" "")
5206 (if_then_else (match_operator 1 "gtuleu_operator"
5207 [(cc0) (const_int 0)])
5208 (label_ref (match_operand 2 "" ""))
5210 "TARGET_H8300H || TARGET_H8300S"
5212 (and:HI (match_dup 0)
5215 (if_then_else (match_dup 3)
5216 (label_ref (match_dup 2))
5219 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
5225 ;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
5226 ;; the equivalent with shorter sequences. Here is the summary. Cases
5227 ;; are grouped for each define_peephole2.
5229 ;; reg const_int use insn
5230 ;; --------------------------------------------------------
5231 ;; live -2 eq/ne copy and inc.l
5232 ;; live -1 eq/ne copy and inc.l
5233 ;; live 1 eq/ne copy and dec.l
5234 ;; live 2 eq/ne copy and dec.l
5236 ;; dead -2 eq/ne inc.l
5237 ;; dead -1 eq/ne inc.l
5238 ;; dead 1 eq/ne dec.l
5239 ;; dead 2 eq/ne dec.l
5241 ;; dead -131072 eq/ne inc.w and test
5242 ;; dead -65536 eq/ne inc.w and test
5243 ;; dead 65536 eq/ne dec.w and test
5244 ;; dead 131072 eq/ne dec.w and test
5246 ;; dead 0x000000?? except 1 and 2 eq/ne xor.b and test
5247 ;; dead 0x0000??00 eq/ne xor.b and test
5248 ;; dead 0x0000ffff eq/ne not.w and test
5250 ;; dead 0xffffff?? except -1 and -2 eq/ne xor.b and not.l
5251 ;; dead 0xffff??ff eq/ne xor.b and not.l
5252 ;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l
5253 ;; dead 0x80000000 eq/ne rotl.l and dec.l
5255 ;; live 1 ge/lt copy and shar.l
5256 ;; live 3 (H8S) ge/lt copy and shar.l
5258 ;; live 1 geu/ltu copy and shar.l
5259 ;; live 3 (H8S) geu/ltu copy and shar.l
5261 ;; dead 1 ge/lt shar.l
5262 ;; dead 3 (H8S) ge/lt shar.l
5264 ;; dead 1 geu/ltu shar.l
5265 ;; dead 3 (H8S) geu/ltu shar.l
5267 ;; dead 3 (H8/300H) ge/lt and.b and test
5268 ;; dead 7 ge/lt and.b and test
5269 ;; dead 15 ge/lt and.b and test
5270 ;; dead 31 ge/lt and.b and test
5271 ;; dead 63 ge/lt and.b and test
5272 ;; dead 127 ge/lt and.b and test
5273 ;; dead 255 ge/lt and.b and test
5275 ;; dead 3 (H8/300H) geu/ltu and.b and test
5276 ;; dead 7 geu/ltu and.b and test
5277 ;; dead 15 geu/ltu and.b and test
5278 ;; dead 31 geu/ltu and.b and test
5279 ;; dead 63 geu/ltu and.b and test
5280 ;; dead 127 geu/ltu and.b and test
5281 ;; dead 255 geu/ltu and.b and test
5283 ;; ---- 65535 ge/lt mov.w
5285 ;; ---- 65535 geu/ltu mov.w
5299 (compare (match_operand:SI 0 "register_operand" "")
5300 (match_operand:SI 1 "incdec_operand" "")))
5302 (if_then_else (match_operator 3 "eqne_operator"
5303 [(cc0) (const_int 0)])
5304 (label_ref (match_operand 2 "" ""))
5306 "(TARGET_H8300H || TARGET_H8300S)
5307 && peep2_reg_dead_p (1, operands[0])"
5309 (unspec:SI [(match_dup 0)
5315 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5316 (label_ref (match_dup 2))
5318 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
5332 (compare (match_operand:SI 0 "register_operand" "")
5333 (match_operand:SI 1 "const_int_operand" "")))
5335 (if_then_else (match_operator 3 "eqne_operator"
5336 [(cc0) (const_int 0)])
5337 (label_ref (match_operand 2 "" ""))
5339 "(TARGET_H8300H || TARGET_H8300S)
5340 && peep2_reg_dead_p (1, operands[0])
5341 && (INTVAL (operands[1]) == -131072
5342 || INTVAL (operands[1]) == -65536
5343 || INTVAL (operands[1]) == 65536
5344 || INTVAL (operands[1]) == 131072)"
5346 (plus:SI (match_dup 0)
5351 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5352 (label_ref (match_dup 2))
5354 "operands[4] = GEN_INT (- INTVAL (operands[1]));")
5369 (compare (match_operand:SI 0 "register_operand" "")
5370 (match_operand:SI 1 "const_int_operand" "")))
5372 (if_then_else (match_operator 3 "eqne_operator"
5373 [(cc0) (const_int 0)])
5374 (label_ref (match_operand 2 "" ""))
5376 "(TARGET_H8300H || TARGET_H8300S)
5377 && peep2_reg_dead_p (1, operands[0])
5378 && ((INTVAL (operands[1]) & 0x00ff) == INTVAL (operands[1])
5379 || (INTVAL (operands[1]) & 0xff00) == INTVAL (operands[1])
5380 || INTVAL (operands[1]) == 0x0000ffff)
5381 && INTVAL (operands[1]) != 1
5382 && INTVAL (operands[1]) != 2"
5384 (xor:SI (match_dup 0)
5389 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5390 (label_ref (match_dup 2))
5407 (compare (match_operand:SI 0 "register_operand" "")
5408 (match_operand:SI 1 "const_int_operand" "")))
5410 (if_then_else (match_operator 3 "eqne_operator"
5411 [(cc0) (const_int 0)])
5412 (label_ref (match_operand 2 "" ""))
5414 "(TARGET_H8300H || TARGET_H8300S)
5415 && peep2_reg_dead_p (1, operands[0])
5416 && ((INTVAL (operands[1]) | 0x00ff) == -1
5417 || (INTVAL (operands[1]) | 0xff00) == -1)
5418 && INTVAL (operands[1]) != -1
5419 && INTVAL (operands[1]) != -2"
5421 (xor:SI (match_dup 0)
5424 (not:SI (match_dup 0)))
5428 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5429 (label_ref (match_dup 2))
5431 "operands[4] = GEN_INT (INTVAL (operands[1]) ^ -1);")
5435 ;; cmp.l #-2147483648,er0
5446 (compare (match_operand:SI 0 "register_operand" "")
5447 (match_operand:SI 1 "const_int_operand" "")))
5449 (if_then_else (match_operator 3 "eqne_operator"
5450 [(cc0) (const_int 0)])
5451 (label_ref (match_operand 2 "" ""))
5453 "(TARGET_H8300H || TARGET_H8300S)
5454 && peep2_reg_dead_p (1, operands[0])
5455 && (INTVAL (operands[1]) == -2147483647 - 1
5456 || (TARGET_H8300S && INTVAL (operands[1]) == 1073741824))"
5458 (rotate:SI (match_dup 0)
5461 (unspec:SI [(match_dup 0)
5467 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5468 (label_ref (match_dup 2))
5470 "operands[4] = GEN_INT (INTVAL (operands[1]) == -2147483647 - 1 ? 1 : 2);")
5483 ;; We avoid this transformation if we see more than one copy of the
5484 ;; same compare insn immediately before this one.
5487 [(match_scratch:SI 4 "r")
5489 (compare (match_operand:SI 0 "register_operand" "")
5490 (match_operand:SI 1 "const_int_operand" "")))
5492 (if_then_else (match_operator 2 "gtle_operator"
5493 [(cc0) (const_int 0)])
5494 (label_ref (match_operand 3 "" ""))
5496 "(TARGET_H8300H || TARGET_H8300S)
5497 && !peep2_reg_dead_p (1, operands[0])
5498 && (INTVAL (operands[1]) == 1
5499 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
5500 && !same_cmp_preceding_p (insn)"
5503 (parallel [(set (match_dup 4)
5504 (ashiftrt:SI (match_dup 4)
5506 (clobber (scratch:QI))])
5510 (if_then_else (match_dup 2)
5511 (label_ref (match_dup 3))
5513 "operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
5526 ;; We avoid this transformation if we see more than one copy of the
5527 ;; same compare insn immediately before this one.
5530 [(match_scratch:SI 4 "r")
5532 (compare (match_operand:SI 0 "register_operand" "")
5533 (match_operand:SI 1 "const_int_operand" "")))
5535 (if_then_else (match_operator 2 "gtuleu_operator"
5536 [(cc0) (const_int 0)])
5537 (label_ref (match_operand 3 "" ""))
5539 "(TARGET_H8300H || TARGET_H8300S)
5540 && !peep2_reg_dead_p (1, operands[0])
5541 && (INTVAL (operands[1]) == 1
5542 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
5543 && !same_cmp_preceding_p (insn)"
5546 (parallel [(set (match_dup 4)
5547 (ashiftrt:SI (match_dup 4)
5549 (clobber (scratch:QI))])
5553 (if_then_else (match_dup 6)
5554 (label_ref (match_dup 3))
5557 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5558 operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5576 (compare (match_operand:SI 0 "register_operand" "")
5577 (match_operand:SI 1 "const_int_operand" "")))
5579 (if_then_else (match_operator 2 "gtle_operator"
5580 [(cc0) (const_int 0)])
5581 (label_ref (match_operand 3 "" ""))
5583 "(TARGET_H8300H || TARGET_H8300S)
5584 && peep2_reg_dead_p (1, operands[0])
5585 && (INTVAL (operands[1]) == 1
5586 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5587 [(parallel [(set (match_dup 0)
5588 (ashiftrt:SI (match_dup 0)
5590 (clobber (scratch:QI))])
5594 (if_then_else (match_dup 2)
5595 (label_ref (match_dup 3))
5597 "operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));")
5611 (compare (match_operand:SI 0 "register_operand" "")
5612 (match_operand:SI 1 "const_int_operand" "")))
5614 (if_then_else (match_operator 2 "gtuleu_operator"
5615 [(cc0) (const_int 0)])
5616 (label_ref (match_operand 3 "" ""))
5618 "(TARGET_H8300H || TARGET_H8300S)
5619 && peep2_reg_dead_p (1, operands[0])
5620 && (INTVAL (operands[1]) == 1
5621 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5622 [(parallel [(set (match_dup 0)
5623 (ashiftrt:SI (match_dup 0)
5625 (clobber (scratch:QI))])
5629 (if_then_else (match_dup 5)
5630 (label_ref (match_dup 3))
5633 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5634 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5653 (compare (match_operand:SI 0 "register_operand" "")
5654 (match_operand:SI 1 "const_int_operand" "")))
5656 (if_then_else (match_operator 2 "gtle_operator"
5657 [(cc0) (const_int 0)])
5658 (label_ref (match_operand 3 "" ""))
5660 "(TARGET_H8300H || TARGET_H8300S)
5661 && peep2_reg_dead_p (1, operands[0])
5662 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
5663 || INTVAL (operands[1]) == 7
5664 || INTVAL (operands[1]) == 15
5665 || INTVAL (operands[1]) == 31
5666 || INTVAL (operands[1]) == 63
5667 || INTVAL (operands[1]) == 127
5668 || INTVAL (operands[1]) == 255)"
5670 (and:SI (match_dup 0)
5675 (if_then_else (match_dup 2)
5676 (label_ref (match_dup 3))
5678 "operands[4] = GEN_INT (~INTVAL (operands[1]));")
5693 (compare (match_operand:SI 0 "register_operand" "")
5694 (match_operand:SI 1 "const_int_operand" "")))
5696 (if_then_else (match_operator 2 "gtuleu_operator"
5697 [(cc0) (const_int 0)])
5698 (label_ref (match_operand 3 "" ""))
5700 "(TARGET_H8300H || TARGET_H8300S)
5701 && peep2_reg_dead_p (1, operands[0])
5702 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
5703 || INTVAL (operands[1]) == 7
5704 || INTVAL (operands[1]) == 15
5705 || INTVAL (operands[1]) == 31
5706 || INTVAL (operands[1]) == 63
5707 || INTVAL (operands[1]) == 127
5708 || INTVAL (operands[1]) == 255)"
5710 (and:SI (match_dup 0)
5715 (if_then_else (match_dup 5)
5716 (label_ref (match_dup 3))
5719 operands[4] = GEN_INT (~INTVAL (operands[1]));
5720 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5738 (compare (match_operand:SI 0 "register_operand" "")
5741 (if_then_else (match_operator 1 "gtle_operator"
5742 [(cc0) (const_int 0)])
5743 (label_ref (match_operand 2 "" ""))
5745 "TARGET_H8300H || TARGET_H8300S"
5747 (and:SI (match_dup 0)
5748 (const_int -65536)))
5750 (if_then_else (match_dup 1)
5751 (label_ref (match_dup 2))
5767 (compare (match_operand:SI 0 "register_operand" "")
5770 (if_then_else (match_operator 1 "gtuleu_operator"
5771 [(cc0) (const_int 0)])
5772 (label_ref (match_operand 2 "" ""))
5774 "TARGET_H8300H || TARGET_H8300S"
5776 (and:SI (match_dup 0)
5777 (const_int -65536)))
5779 (if_then_else (match_dup 3)
5780 (label_ref (match_dup 2))
5783 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
5800 ;; We avoid this transformation if we see more than one copy of the
5801 ;; same compare insn.
5804 [(match_scratch:SI 4 "r")
5806 (compare (match_operand:SI 0 "register_operand" "")
5807 (match_operand:SI 1 "incdec_operand" "")))
5809 (if_then_else (match_operator 3 "eqne_operator"
5810 [(cc0) (const_int 0)])
5811 (label_ref (match_operand 2 "" ""))
5813 "(TARGET_H8300H || TARGET_H8300S)
5814 && !peep2_reg_dead_p (1, operands[0])
5815 && !same_cmp_following_p (insn)"
5819 (unspec:SI [(match_dup 4)
5825 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5826 (label_ref (match_dup 2))
5828 "operands[5] = GEN_INT (- INTVAL (operands[1]));")
5830 ;; Narrow the mode of testing if possible.
5833 [(set (match_operand:HI 0 "register_operand" "")
5834 (and:HI (match_dup 0)
5835 (match_operand:HI 1 "const_int_qi_operand" "")))
5839 (if_then_else (match_operator 3 "eqne_operator"
5840 [(cc0) (const_int 0)])
5841 (label_ref (match_operand 2 "" ""))
5843 "peep2_reg_dead_p (2, operands[0])"
5845 (and:QI (match_dup 4)
5850 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5851 (label_ref (match_dup 2))
5853 "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
5854 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);")
5857 [(set (match_operand:SI 0 "register_operand" "")
5858 (and:SI (match_dup 0)
5859 (match_operand:SI 1 "const_int_qi_operand" "")))
5863 (if_then_else (match_operator 3 "eqne_operator"
5864 [(cc0) (const_int 0)])
5865 (label_ref (match_operand 2 "" ""))
5867 "peep2_reg_dead_p (2, operands[0])"
5869 (and:QI (match_dup 4)
5874 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5875 (label_ref (match_dup 2))
5877 "operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
5878 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);")
5881 [(set (match_operand:SI 0 "register_operand" "")
5882 (and:SI (match_dup 0)
5883 (match_operand:SI 1 "const_int_hi_operand" "")))
5887 (if_then_else (match_operator 3 "eqne_operator"
5888 [(cc0) (const_int 0)])
5889 (label_ref (match_operand 2 "" ""))
5891 "peep2_reg_dead_p (2, operands[0])"
5893 (and:HI (match_dup 4)
5898 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5899 (label_ref (match_dup 2))
5901 "operands[4] = gen_rtx_REG (HImode, REGNO (operands[0]));
5902 operands[5] = gen_int_mode (INTVAL (operands[1]), HImode);")
5905 [(set (match_operand:SI 0 "register_operand" "")
5906 (and:SI (match_dup 0)
5907 (match_operand:SI 1 "const_int_qi_operand" "")))
5909 (xor:SI (match_dup 0)
5910 (match_operand:SI 2 "const_int_qi_operand" "")))
5914 (if_then_else (match_operator 4 "eqne_operator"
5915 [(cc0) (const_int 0)])
5916 (label_ref (match_operand 3 "" ""))
5918 "peep2_reg_dead_p (3, operands[0])
5919 && (~INTVAL (operands[1]) & INTVAL (operands[2])) == 0"
5921 (and:QI (match_dup 5)
5924 (xor:QI (match_dup 5)
5929 (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
5930 (label_ref (match_dup 3))
5932 "operands[5] = gen_rtx_REG (QImode, REGNO (operands[0]));
5933 operands[6] = gen_int_mode (INTVAL (operands[1]), QImode);
5934 operands[7] = gen_int_mode (INTVAL (operands[2]), QImode);")
5936 ;; These triggers right at the end of allocation of locals in the
5937 ;; prologue (and possibly at other places).
5939 ;; stack adjustment of -4, generate one push
5941 ;; before : 6 bytes, 10 clocks
5942 ;; after : 4 bytes, 10 clocks
5945 [(set (reg:SI SP_REG)
5946 (plus:SI (reg:SI SP_REG)
5948 (set (mem:SI (reg:SI SP_REG))
5949 (match_operand:SI 0 "register_operand" ""))]
5950 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
5951 && REGNO (operands[0]) != SP_REG"
5952 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
5956 ;; stack adjustment of -12, generate one push
5958 ;; before : 10 bytes, 14 clocks
5959 ;; after : 8 bytes, 14 clocks
5962 [(set (reg:SI SP_REG)
5963 (plus:SI (reg:SI SP_REG)
5965 (set (mem:SI (reg:SI SP_REG))
5966 (match_operand:SI 0 "register_operand" ""))]
5967 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
5968 && REGNO (operands[0]) != SP_REG"
5969 [(set (reg:SI SP_REG)
5970 (plus:SI (reg:SI SP_REG)
5972 (set (reg:SI SP_REG)
5973 (plus:SI (reg:SI SP_REG)
5975 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
5989 ;; if "reg" dies at the end of the sequence.
5991 [(set (match_operand 0 "register_operand" "")
5992 (match_operand 1 "memory_operand" ""))
5994 (match_operator 2 "h8sx_binary_memory_operator"
5996 (match_operand 3 "h8300_src_operand" "")]))
5997 (set (match_operand 4 "memory_operand" "")
5999 "0 /* Disable because it breaks compiling fp-bit.c. */
6001 && peep2_reg_dead_p (3, operands[0])
6002 && !reg_overlap_mentioned_p (operands[0], operands[3])
6003 && !reg_overlap_mentioned_p (operands[0], operands[4])
6004 && h8sx_mergeable_memrefs_p (operands[4], operands[1])"
6008 operands[5] = shallow_copy_rtx (operands[2]);
6009 XEXP (operands[5], 0) = operands[1];
6021 ;; if "reg" dies in the second insn.
6023 [(set (match_operand 0 "register_operand" "")
6024 (match_operand 1 "h8300_src_operand" ""))
6025 (set (match_operand 2 "h8300_dst_operand" "")
6026 (match_operator 3 "h8sx_binary_memory_operator"
6027 [(match_operand 4 "h8300_dst_operand" "")
6029 "0 /* Disable because it breaks compiling fp-bit.c. */
6031 && peep2_reg_dead_p (2, operands[0])
6032 && !reg_overlap_mentioned_p (operands[0], operands[4])"
6036 operands[5] = shallow_copy_rtx (operands[3]);
6037 XEXP (operands[5], 1) = operands[1];
6050 ;; if "reg" dies at the end of the sequence.
6052 [(set (match_operand 0 "register_operand" "")
6053 (match_operand 1 "memory_operand" ""))
6055 (match_operator 2 "h8sx_unary_memory_operator"
6057 (set (match_operand 3 "memory_operand" "")
6060 && peep2_reg_dead_p (3, operands[0])
6061 && !reg_overlap_mentioned_p (operands[0], operands[3])
6062 && h8sx_mergeable_memrefs_p (operands[3], operands[1])"
6066 operands[4] = shallow_copy_rtx (operands[2]);
6067 XEXP (operands[4], 0) = operands[1];
6079 ;; if "reg" dies in the comparison.
6081 [(set (match_operand 0 "register_operand" "")
6082 (match_operand 1 "h8300_dst_operand" ""))
6084 (compare (match_dup 0)
6085 (match_operand 2 "h8300_src_operand" "")))]
6087 && peep2_reg_dead_p (2, operands[0])
6088 && !reg_overlap_mentioned_p (operands[0], operands[2])"
6090 (compare (match_dup 1)
6093 ;; Likewise for the second operand.
6095 [(set (match_operand 0 "register_operand" "")
6096 (match_operand 1 "h8300_src_operand" ""))
6098 (compare (match_operand 2 "h8300_dst_operand" "")
6101 && peep2_reg_dead_p (2, operands[0])
6102 && !reg_overlap_mentioned_p (operands[0], operands[2])"
6104 (compare (match_dup 2)
6107 ;; Combine two moves.
6109 [(set (match_operand 0 "register_operand" "")
6110 (match_operand 1 "h8300_src_operand" ""))
6111 (set (match_operand 2 "h8300_dst_operand" "")
6114 && peep2_reg_dead_p (2, operands[0])
6115 && !reg_overlap_mentioned_p (operands[0], operands[2])"