1 ;; GCC machine description for Renesas H8/300
2 ;; Copyright (C) 1992-2014 Free Software Foundation, Inc.
4 ;; Contributed by Steve Chamberlain (sac@cygnus.com),
5 ;; Jim Wilson (wilson@cygnus.com), and Doug Evans (dje@cygnus.com).
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; GCC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
23 ;; We compute exact length on each instruction for most of the time.
24 ;; In some case, most notably bit operations that may involve memory
25 ;; operands, the lengths in this file are "worst case".
27 ;; On the H8/300H and H8S, adds/subs operate on the 32bit "er"
28 ;; registers. Right now GCC doesn't expose the "e" half to the
29 ;; compiler, so using add/subs for addhi and subhi is safe. Long
30 ;; term, we want to expose the "e" half to the compiler (gives us 8
31 ;; more 16bit registers). At that point addhi and subhi can't use
34 ;; There's currently no way to have an insv/extzv expander for the H8/300H
35 ;; because word_mode is different for the H8/300 and H8/300H.
37 ;; Shifts/rotates by small constants should be handled by special
38 ;; patterns so we get the length and cc status correct.
40 ;; Bitfield operations no longer accept memory operands. We need
41 ;; to add variants which operate on memory back to the MD.
43 ;; ??? Implement remaining bit ops available on the h8300
45 ;; ----------------------------------------------------------------------
47 ;; ----------------------------------------------------------------------
70 ;; ----------------------------------------------------------------------
72 ;; ----------------------------------------------------------------------
74 (define_attr "cpu" "h8300,h8300h"
75 (const (symbol_ref "cpu_type")))
77 (define_attr "type" "branch,arith,bitbranch,call"
78 (const_string "arith"))
80 (define_attr "length_table" "none,addb,addw,addl,logicb,movb,movw,movl,mova_zero,mova,unary,mov_imm4,short_immediate,bitfield,bitbranch"
81 (const_string "none"))
83 ;; The size of instructions in bytes.
85 (define_attr "length" ""
86 (cond [(eq_attr "type" "branch")
87 ;; In a forward delayed branch, (pc) represents the end of the
88 ;; delay sequence, not the end of the branch itself.
89 (if_then_else (and (ge (minus (match_dup 0) (pc))
91 (le (plus (minus (match_dup 0) (pc))
92 (symbol_ref "DELAY_SLOT_LENGTH (insn)"))
95 (if_then_else (and (eq_attr "cpu" "h8300h")
96 (and (ge (minus (pc) (match_dup 0))
98 (le (minus (pc) (match_dup 0))
102 (eq_attr "type" "bitbranch")
103 (if_then_else (and (ge (minus (match_dup 0) (pc))
105 (le (minus (match_dup 0) (pc))
107 (plus (symbol_ref "h8300_insn_length_from_table (insn, operands)")
109 (if_then_else (and (eq_attr "cpu" "h8300h")
110 (and (ge (minus (pc) (match_dup 0))
112 (le (minus (pc) (match_dup 0))
114 (plus (symbol_ref "h8300_insn_length_from_table (insn, operands)")
116 (plus (symbol_ref "h8300_insn_length_from_table (insn, operands)")
118 (eq_attr "length_table" "!none")
119 (symbol_ref "h8300_insn_length_from_table (insn, operands)")]
122 ;; Condition code settings.
124 ;; none - insn does not affect cc
125 ;; none_0hit - insn does not affect cc but it does modify operand 0
126 ;; This attribute is used to keep track of when operand 0 changes.
127 ;; See the description of NOTICE_UPDATE_CC for more info.
128 ;; set_znv - insn sets z,n,v to usable values (like a tst insn); c is unknown.
129 ;; set_zn - insn sets z,n to usable values; v,c are unknown.
130 ;; compare - compare instruction
131 ;; clobber - value of cc is unknown
133 (define_attr "cc" "none,none_0hit,set_znv,set_zn,compare,clobber"
134 (const_string "clobber"))
136 ;; Type of delay slot. NONE means the instruction has no delay slot.
137 ;; JUMP means it is an unconditional jump that (if short enough)
138 ;; could be implemented using bra/s.
140 (define_attr "delay_slot" "none,jump"
141 (const_string "none"))
143 ;; "yes" if the instruction can be put into a delay slot. It's not
144 ;; entirely clear that jsr is not valid in delay slots, but it
145 ;; definitely doesn't have the effect of causing the called function
146 ;; to return to the target of the delayed branch.
148 (define_attr "can_delay" "no,yes"
149 (cond [(eq_attr "type" "branch,bitbranch,call")
151 (geu (symbol_ref "get_attr_length (insn)") (const_int 2))
153 (const_string "yes")))
155 ;; Only allow jumps to have a delay slot if we think they might
156 ;; be short enough. This is just an optimization: we don't know
157 ;; for certain whether they will be or not.
159 (define_delay (and (eq_attr "delay_slot" "jump")
160 (eq (symbol_ref "get_attr_length (insn)") (const_int 2)))
161 [(eq_attr "can_delay" "yes")
165 ;; Provide the maximum length of an assembly instruction in an asm
166 ;; statement. The maximum length of 14 bytes is achieved on H8SX.
168 (define_asm_attributes
169 [(set (attr "length")
170 (cond [(match_test "TARGET_H8300") (const_int 4)
171 (match_test "TARGET_H8300H") (const_int 10)
172 (match_test "TARGET_H8300S") (const_int 10)]
175 (include "predicates.md")
176 (include "constraints.md")
178 ;; ----------------------------------------------------------------------
180 ;; ----------------------------------------------------------------------
182 ;; This mode iterator allows :P to be used for patterns that operate on
183 ;; pointer-sized quantities. Exactly one of the two alternatives will match.
185 (define_mode_iterator P [(HI "Pmode == HImode") (SI "Pmode == SImode")])
188 ;; ----------------------------------------------------------------------
190 ;; ----------------------------------------------------------------------
194 (define_insn "*movqi_h8300"
195 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
196 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
198 && h8300_move_ok (operands[0], operands[1])"
206 [(set_attr "length" "2,2,2,2,4,4")
207 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
209 (define_insn "*movqi_h8300hs"
210 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,<,r,r,m")
211 (match_operand:QI 1 "general_operand_src" " I,r>,r,n,m,r"))]
212 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
213 && h8300_move_ok (operands[0], operands[1])"
221 [(set (attr "length")
222 (symbol_ref "compute_mov_length (operands)"))
223 (set_attr "cc" "set_zn,set_znv,set_znv,clobber,set_znv,set_znv")])
225 (define_insn "*movqi_h8sx"
226 [(set (match_operand:QI 0 "general_operand_dst" "=Z,rQ")
227 (match_operand:QI 1 "general_operand_src" "P4>X,rQi"))]
232 [(set_attr "length_table" "mov_imm4,movb")
233 (set_attr "cc" "set_znv")])
235 (define_expand "movqi"
236 [(set (match_operand:QI 0 "general_operand_dst" "")
237 (match_operand:QI 1 "general_operand_src" ""))]
240 /* One of the ops has to be in a register. */
241 if (!TARGET_H8300SX && !h8300_move_ok (operands[0], operands[1]))
242 operands[1] = copy_to_mode_reg (QImode, operands[1]);
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 && h8300_move_ok (operands[0], operands[1])"
270 [(set (attr "length")
271 (symbol_ref "compute_mov_length (operands)"))
272 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
274 (define_insn "*movhi_h8300hs"
275 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,<,r,r,m")
276 (match_operand:HI 1 "general_operand_src" "I,r>,r,i,m,r"))]
277 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
278 && h8300_move_ok (operands[0], operands[1])"
286 [(set (attr "length")
287 (symbol_ref "compute_mov_length (operands)"))
288 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
290 (define_insn "*movhi_h8sx"
291 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Z,Q,rQ")
292 (match_operand:HI 1 "general_operand_src" "I,P3>X,P4>X,IP8>X,rQi"))]
300 [(set_attr "length_table" "*,*,mov_imm4,short_immediate,movw")
301 (set_attr "length" "2,2,*,*,*")
302 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv")])
304 (define_expand "movhi"
305 [(set (match_operand:HI 0 "general_operand_dst" "")
306 (match_operand:HI 1 "general_operand_src" ""))]
309 /* One of the ops has to be in a register. */
310 if (!h8300_move_ok (operands[0], operands[1]))
311 operands[1] = copy_to_mode_reg (HImode, operand1);
314 (define_insn "movstricthi"
315 [(set (strict_low_part (match_operand:HI 0 "general_operand_dst" "+r,r,r"))
316 (match_operand:HI 1 "general_operand_src" "I,P3>X,rmi"))]
322 [(set_attr "length" "2,2,*")
323 (set_attr "length_table" "*,*,movw")
324 (set_attr "cc" "set_zn,set_znv,set_znv")])
328 (define_expand "movsi"
329 [(set (match_operand:SI 0 "general_operand_dst" "")
330 (match_operand:SI 1 "general_operand_src" ""))]
335 if (h8300_expand_movsi (operands))
338 else if (!TARGET_H8300SX)
340 /* One of the ops has to be in a register. */
341 if (!h8300_move_ok (operands[0], operands[1]))
342 operands[1] = copy_to_mode_reg (SImode, operand1);
346 (define_insn "*movsi_h8300"
347 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,o,<,r")
348 (match_operand:SI 1 "general_operand_src" "I,r,io,r,r,>"))]
350 && h8300_move_ok (operands[0], operands[1])"
352 unsigned int rn = -1;
353 switch (which_alternative)
356 return "sub.w %e0,%e0\;sub.w %f0,%f0";
358 if (REGNO (operands[0]) < REGNO (operands[1]))
359 return "mov.w %e1,%e0\;mov.w %f1,%f0";
361 return "mov.w %f1,%f0\;mov.w %e1,%e0";
363 /* Make sure we don't trample the register we index with. */
364 if (GET_CODE (operands[1]) == MEM)
366 rtx inside = XEXP (operands[1], 0);
371 else if (GET_CODE (inside) == PLUS)
373 rtx lhs = XEXP (inside, 0);
374 rtx rhs = XEXP (inside, 1);
375 if (REG_P (lhs)) rn = REGNO (lhs);
376 if (REG_P (rhs)) rn = REGNO (rhs);
379 if (rn == REGNO (operands[0]))
381 /* Move the second word first. */
382 return "mov.w %f1,%f0\;mov.w %e1,%e0";
386 if (GET_CODE (operands[1]) == CONST_INT)
388 /* If either half is zero, use sub.w to clear that
390 if ((INTVAL (operands[1]) & 0xffff) == 0)
391 return "mov.w %e1,%e0\;sub.w %f0,%f0";
392 if (((INTVAL (operands[1]) >> 16) & 0xffff) == 0)
393 return "sub.w %e0,%e0\;mov.w %f1,%f0";
394 /* If the upper half and the lower half are the same,
395 copy one half to the other. */
396 if ((INTVAL (operands[1]) & 0xffff)
397 == ((INTVAL (operands[1]) >> 16) & 0xffff))
398 return "mov.w\\t%e1,%e0\;mov.w\\t%e0,%f0";
400 return "mov.w %e1,%e0\;mov.w %f1,%f0";
403 return "mov.w %e1,%e0\;mov.w %f1,%f0";
405 return "mov.w %f1,%T0\;mov.w %e1,%T0";
407 return "mov.w %T1,%e0\;mov.w %T1,%f0";
412 [(set (attr "length")
413 (symbol_ref "compute_mov_length (operands)"))])
415 (define_insn "*movsi_h8300hs"
416 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,<,r,r,m,*a,*a,r")
417 (match_operand:SI 1 "general_operand_src" "I,r,i,r,>,m,r,I,r,*a"))]
418 "(TARGET_H8300S || TARGET_H8300H) && !TARGET_H8300SX
419 && h8300_move_ok (operands[0], operands[1])"
421 switch (which_alternative)
424 return "sub.l %S0,%S0";
428 return "clrmac\;ldmac %1,macl";
430 return "stmac macl,%0";
432 if (GET_CODE (operands[1]) == CONST_INT)
434 int val = INTVAL (operands[1]);
436 /* Look for constants which can be made by adding an 8-bit
437 number to zero in one of the two low bytes. */
438 if (val == (val & 0xff))
440 operands[1] = GEN_INT ((char) val & 0xff);
441 return "sub.l\\t%S0,%S0\;add.b\\t%1,%w0";
444 if (val == (val & 0xff00))
446 operands[1] = GEN_INT ((char) (val >> 8) & 0xff);
447 return "sub.l\\t%S0,%S0\;add.b\\t%1,%x0";
450 /* Look for constants that can be obtained by subs, inc, and
452 switch (val & 0xffffffff)
455 return "sub.l\\t%S0,%S0\;subs\\t#1,%S0";
457 return "sub.l\\t%S0,%S0\;subs\\t#2,%S0";
459 return "sub.l\\t%S0,%S0\;subs\\t#4,%S0";
462 return "sub.l\\t%S0,%S0\;dec.w\\t#1,%f0";
464 return "sub.l\\t%S0,%S0\;dec.w\\t#2,%f0";
467 return "sub.l\\t%S0,%S0\;dec.w\\t#1,%e0";
469 return "sub.l\\t%S0,%S0\;dec.w\\t#2,%e0";
472 return "sub.l\\t%S0,%S0\;inc.w\\t#1,%e0";
474 return "sub.l\\t%S0,%S0\;inc.w\\t#2,%e0";
478 return "mov.l %S1,%S0";
480 [(set (attr "length")
481 (symbol_ref "compute_mov_length (operands)"))
482 (set_attr "cc" "set_zn,set_znv,clobber,set_znv,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
484 (define_insn "*movsi_h8sx"
485 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,Q,rQ,*a,*a,r")
486 (match_operand:SI 1 "general_operand_src" "I,P3>X,IP8>X,rQi,I,r,*a"))]
494 clrmac\;ldmac %1,macl
496 [(set_attr "length_table" "*,*,short_immediate,movl,*,*,*")
497 (set_attr "length" "2,2,*,*,2,6,4")
498 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,none_0hit,none_0hit,set_znv")])
500 (define_insn "*movsf_h8sx"
501 [(set (match_operand:SF 0 "general_operand_dst" "=r,rQ")
502 (match_operand:SF 1 "general_operand_src" "G,rQi"))]
507 [(set_attr "length" "2,*")
508 (set_attr "length_table" "*,movl")
509 (set_attr "cc" "set_zn,set_znv")])
511 ;; Implement block moves using movmd. Defining movmemsi allows the full
512 ;; range of constant lengths (up to 0x40000 bytes when using movmd.l).
513 ;; See h8sx_emit_movmd for details.
515 (define_expand "movmemsi"
516 [(use (match_operand:BLK 0 "memory_operand" ""))
517 (use (match_operand:BLK 1 "memory_operand" ""))
518 (use (match_operand:SI 2 "" ""))
519 (use (match_operand:SI 3 "const_int_operand" ""))]
522 if (h8sx_emit_movmd (operands[0], operands[1], operands[2], INTVAL (operands[3])))
528 ;; Expander for generating movmd insns. Operand 0 is the destination
529 ;; memory region, operand 1 is the source, operand 2 is the counter
530 ;; register and operand 3 is the chunk size (1, 2 or 4).
532 (define_expand "movmd"
534 [(set (match_operand:BLK 0 "memory_operand" "")
535 (match_operand:BLK 1 "memory_operand" ""))
536 (unspec [(match_operand:HI 2 "register_operand" "")
537 (match_operand:HI 3 "const_int_operand" "")] UNSPEC_MOVMD)
538 (clobber (match_dup 4))
539 (clobber (match_dup 5))
544 operands[4] = copy_rtx (XEXP (operands[0], 0));
545 operands[5] = copy_rtx (XEXP (operands[1], 0));
548 ;; This is a difficult instruction to reload since operand 0 must be the
549 ;; frame pointer. See h8300_reg_class_from_letter for an explanation.
551 (define_insn "movmd_internal_normal"
552 [(set (mem:BLK (match_operand:HI 3 "register_operand" "0,r"))
553 (mem:BLK (match_operand:HI 4 "register_operand" "1,1")))
554 (unspec [(match_operand:HI 5 "register_operand" "2,2")
555 (match_operand:HI 6 "const_int_operand" "n,n")] UNSPEC_MOVMD)
556 (clobber (match_operand:HI 0 "register_operand" "=d,??D"))
557 (clobber (match_operand:HI 1 "register_operand" "=f,f"))
558 (set (match_operand:HI 2 "register_operand" "=c,c")
560 "TARGET_H8300SX && TARGET_NORMAL_MODE"
564 [(set_attr "length" "2,14")
565 (set_attr "can_delay" "no")
566 (set_attr "cc" "none,clobber")])
568 (define_insn "movmd_internal"
569 [(set (mem:BLK (match_operand:SI 3 "register_operand" "0,r"))
570 (mem:BLK (match_operand:SI 4 "register_operand" "1,1")))
571 (unspec [(match_operand:HI 5 "register_operand" "2,2")
572 (match_operand:HI 6 "const_int_operand" "n,n")] UNSPEC_MOVMD)
573 (clobber (match_operand:SI 0 "register_operand" "=d,??D"))
574 (clobber (match_operand:SI 1 "register_operand" "=f,f"))
575 (set (match_operand:HI 2 "register_operand" "=c,c")
577 "TARGET_H8300SX && !TARGET_NORMAL_MODE"
581 [(set_attr "length" "2,14")
582 (set_attr "can_delay" "no")
583 (set_attr "cc" "none,clobber")])
585 ;; Split the above instruction if the destination register isn't er6.
586 ;; We need a sequence like:
594 ;; where <dest> is the current destination register (operand 4).
595 ;; The fourth instruction will be deleted if <dest> dies here.
598 [(set (match_operand:BLK 0 "memory_operand" "")
599 (match_operand:BLK 1 "memory_operand" ""))
600 (unspec [(match_operand:HI 2 "register_operand" "")
601 (match_operand:HI 3 "const_int_operand" "")] UNSPEC_MOVMD)
602 (clobber (match_operand:HI 4 "register_operand" ""))
603 (clobber (match_operand:HI 5 "register_operand" ""))
606 "TARGET_H8300SX && TARGET_NORMAL_MODE && reload_completed
607 && REGNO (operands[4]) != DESTINATION_REG"
612 h8300_swap_into_er6 (XEXP (operands[0], 0));
613 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
614 emit_insn (gen_movmd (dest, operands[1], operands[2], operands[3]));
615 h8300_swap_out_of_er6 (operands[4]);
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:SI 4 "register_operand" ""))
625 (clobber (match_operand:SI 5 "register_operand" ""))
628 "TARGET_H8300SX && !TARGET_NORMAL_MODE && reload_completed
629 && REGNO (operands[4]) != DESTINATION_REG"
634 h8300_swap_into_er6 (XEXP (operands[0], 0));
635 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
636 emit_insn (gen_movmd (dest, operands[1], operands[2], operands[3]));
637 h8300_swap_out_of_er6 (operands[4]);
641 ;; Expand a call to stpcpy() using movsd. Operand 0 should point to
642 ;; the final character, but movsd leaves it pointing to the character
645 (define_expand "movstr"
646 [(use (match_operand 0 "register_operand" ""))
647 (use (match_operand:BLK 1 "memory_operand" ""))
648 (use (match_operand:BLK 2 "memory_operand" ""))]
651 operands[1] = replace_equiv_address
652 (operands[1], copy_to_mode_reg (Pmode, XEXP (operands[1], 0)));
653 operands[2] = replace_equiv_address
654 (operands[2], copy_to_mode_reg (Pmode, XEXP (operands[2], 0)));
655 emit_insn (gen_movsd (operands[1], operands[2], gen_reg_rtx (Pmode)));
656 emit_insn (gen_add3_insn (operands[0], XEXP (operands[1], 0), constm1_rtx));
660 ;; Expander for generating a movsd instruction. Operand 0 is the
661 ;; destination string, operand 1 is the source string and operand 2
662 ;; is a scratch register.
664 (define_expand "movsd"
666 [(set (match_operand:BLK 0 "memory_operand" "")
667 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "")]
669 (clobber (match_dup 3))
670 (clobber (match_dup 4))
671 (clobber (match_operand 2 "register_operand" ""))])]
674 operands[3] = copy_rtx (XEXP (operands[0], 0));
675 operands[4] = copy_rtx (XEXP (operands[1], 0));
678 ;; See comments above memcpy_internal().
680 (define_insn "stpcpy_internal_normal"
681 [(set (mem:BLK (match_operand:HI 3 "register_operand" "0,r"))
682 (unspec:BLK [(mem:BLK (match_operand:HI 4 "register_operand" "1,1"))]
684 (clobber (match_operand:HI 0 "register_operand" "=d,??D"))
685 (clobber (match_operand:HI 1 "register_operand" "=f,f"))
686 (clobber (match_operand:HI 2 "register_operand" "=c,c"))]
687 "TARGET_H8300SX && TARGET_NORMAL_MODE"
689 \n1:\tmovsd\t2f\;bra\t1b\n2:
691 [(set_attr "length" "6,18")
692 (set_attr "cc" "none,clobber")])
694 (define_insn "stpcpy_internal"
695 [(set (mem:BLK (match_operand:SI 3 "register_operand" "0,r"))
696 (unspec:BLK [(mem:BLK (match_operand:SI 4 "register_operand" "1,1"))]
698 (clobber (match_operand:SI 0 "register_operand" "=d,??D"))
699 (clobber (match_operand:SI 1 "register_operand" "=f,f"))
700 (clobber (match_operand:SI 2 "register_operand" "=c,c"))]
701 "TARGET_H8300SX && !TARGET_NORMAL_MODE"
703 \n1:\tmovsd\t2f\;bra\t1b\n2:
705 [(set_attr "length" "6,18")
706 (set_attr "cc" "none,clobber")])
708 ;; Split the above instruction if the destination isn't er6. This works
709 ;; in the same way as the movmd splitter.
712 [(set (match_operand:BLK 0 "memory_operand" "")
713 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "")] UNSPEC_STPCPY))
714 (clobber (match_operand:HI 2 "register_operand" ""))
715 (clobber (match_operand:HI 3 "register_operand" ""))
716 (clobber (match_operand:HI 4 "register_operand" ""))]
717 "TARGET_H8300SX && TARGET_NORMAL_MODE && reload_completed
718 && REGNO (operands[2]) != DESTINATION_REG"
723 h8300_swap_into_er6 (XEXP (operands[0], 0));
724 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
725 emit_insn (gen_movsd (dest, operands[1], operands[4]));
726 h8300_swap_out_of_er6 (operands[2]);
731 [(set (match_operand:BLK 0 "memory_operand" "")
732 (unspec:BLK [(match_operand:BLK 1 "memory_operand" "")] UNSPEC_STPCPY))
733 (clobber (match_operand:SI 2 "register_operand" ""))
734 (clobber (match_operand:SI 3 "register_operand" ""))
735 (clobber (match_operand:SI 4 "register_operand" ""))]
736 "TARGET_H8300SX && !TARGET_NORMAL_MODE && reload_completed
737 && REGNO (operands[2]) != DESTINATION_REG"
742 h8300_swap_into_er6 (XEXP (operands[0], 0));
743 dest = replace_equiv_address (operands[0], hard_frame_pointer_rtx);
744 emit_insn (gen_movsd (dest, operands[1], operands[4]));
745 h8300_swap_out_of_er6 (operands[2]);
751 (define_expand "movsf"
752 [(set (match_operand:SF 0 "general_operand_dst" "")
753 (match_operand:SF 1 "general_operand_src" ""))]
758 if (h8300_expand_movsi (operands))
761 else if (!TARGET_H8300SX)
763 /* One of the ops has to be in a register. */
764 if (!register_operand (operand1, SFmode)
765 && !register_operand (operand0, SFmode))
767 operands[1] = copy_to_mode_reg (SFmode, operand1);
772 (define_insn "*movsf_h8300"
773 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,o,<,r")
774 (match_operand:SF 1 "general_operand_src" "G,r,io,r,r,>"))]
776 && (register_operand (operands[0], SFmode)
777 || register_operand (operands[1], SFmode))"
779 /* Copy of the movsi stuff. */
780 unsigned int rn = -1;
781 switch (which_alternative)
784 return "sub.w %e0,%e0\;sub.w %f0,%f0";
786 if (REGNO (operands[0]) < REGNO (operands[1]))
787 return "mov.w %e1,%e0\;mov.w %f1,%f0";
789 return "mov.w %f1,%f0\;mov.w %e1,%e0";
791 /* Make sure we don't trample the register we index with. */
792 if (GET_CODE (operands[1]) == MEM)
794 rtx inside = XEXP (operands[1], 0);
799 else if (GET_CODE (inside) == PLUS)
801 rtx lhs = XEXP (inside, 0);
802 rtx rhs = XEXP (inside, 1);
803 if (REG_P (lhs)) rn = REGNO (lhs);
804 if (REG_P (rhs)) rn = REGNO (rhs);
807 if (rn == REGNO (operands[0]))
808 /* Move the second word first. */
809 return "mov.w %f1,%f0\;mov.w %e1,%e0";
811 /* Move the first word first. */
812 return "mov.w %e1,%e0\;mov.w %f1,%f0";
815 return "mov.w %e1,%e0\;mov.w %f1,%f0";
817 return "mov.w %f1,%T0\;mov.w %e1,%T0";
819 return "mov.w %T1,%e0\;mov.w %T1,%f0";
824 [(set (attr "length")
825 (symbol_ref "compute_mov_length (operands)"))])
827 (define_insn "*movsf_h8300hs"
828 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,m,<,r")
829 (match_operand:SF 1 "general_operand_src" "G,r,im,r,r,>"))]
830 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
831 && (register_operand (operands[0], SFmode)
832 || register_operand (operands[1], SFmode))"
840 [(set (attr "length")
841 (symbol_ref "compute_mov_length (operands)"))
842 (set_attr "cc" "set_zn,set_znv,set_znv,set_znv,set_znv,set_znv")])
844 ;; ----------------------------------------------------------------------
846 ;; ----------------------------------------------------------------------
848 (define_insn "*pushqi1_h8300"
852 (plus:HI (reg:HI SP_REG) (const_int -2))))
853 (match_operand:QI 0 "register_no_sp_elim_operand" "r"))]
856 [(set_attr "length" "2")])
858 (define_insn "*pushqi1_h8300hs_<mode>"
862 (plus:P (reg:P SP_REG) (const_int -4))))
863 (match_operand:QI 0 "register_no_sp_elim_operand" "r"))]
864 "TARGET_H8300H || TARGET_H8300S"
866 [(set_attr "length" "4")])
868 (define_insn "*pushhi1_h8300hs_<mode>"
872 (plus:P (reg:P SP_REG) (const_int -4))))
873 (match_operand:HI 0 "register_no_sp_elim_operand" "r"))]
874 "TARGET_H8300H || TARGET_H8300S"
876 [(set_attr "length" "4")])
878 ;; ----------------------------------------------------------------------
880 ;; ----------------------------------------------------------------------
884 (compare (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "r,U")
886 (match_operand 1 "const_int_operand" "n,n"))
890 [(set_attr "length" "2,4")
891 (set_attr "cc" "set_zn,set_zn")])
895 (compare (zero_extract:HI (match_operand:HI 0 "register_operand" "r")
897 (match_operand 1 "const_int_operand" "n"))
901 [(set_attr "length" "2")
902 (set_attr "cc" "set_zn")])
904 (define_insn_and_split "*tst_extzv_1_n"
906 (compare (zero_extract:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>")
908 (match_operand 1 "const_int_operand" "n,n,n"))
910 (clobber (match_scratch:QI 2 "=X,X,&r"))]
911 "TARGET_H8300H || TARGET_H8300S"
917 && !satisfies_constraint_U (operands[0])"
920 (parallel [(set (cc0) (compare (zero_extract:SI (match_dup 2)
924 (clobber (scratch:QI))])]
926 [(set_attr "length" "2,8,10")
927 (set_attr "cc" "set_zn,set_zn,set_zn")])
931 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
933 (match_operand 1 "const_int_operand" "n"))
935 "(TARGET_H8300H || TARGET_H8300S)
936 && INTVAL (operands[1]) <= 15"
938 [(set_attr "length" "2")
939 (set_attr "cc" "set_zn")])
941 (define_insn_and_split "*tstsi_upper_bit"
943 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
945 (match_operand 1 "const_int_operand" "n"))
947 (clobber (match_scratch:SI 2 "=&r"))]
948 "(TARGET_H8300H || TARGET_H8300S)
949 && INTVAL (operands[1]) >= 16"
951 "&& reload_completed"
953 (ior:SI (and:SI (match_dup 2)
955 (lshiftrt:SI (match_dup 0)
958 (compare (zero_extract:SI (match_dup 2)
963 operands[3] = GEN_INT (INTVAL (operands[1]) - 16);
966 (define_insn "*tstsi_variable_bit"
968 (compare (zero_extract:SI (match_operand:SI 0 "register_operand" "r")
970 (and:SI (match_operand:SI 1 "register_operand" "r")
973 "TARGET_H8300H || TARGET_H8300S"
975 [(set_attr "length" "2")
976 (set_attr "cc" "set_zn")])
978 (define_insn_and_split "*tstsi_variable_bit_qi"
980 (compare (zero_extract:SI (zero_extend:SI (match_operand:QI 0 "general_operand_src" "r,U,mn>"))
982 (and:SI (match_operand:SI 1 "register_operand" "r,r,r")
985 (clobber (match_scratch:QI 2 "=X,X,&r"))]
986 "TARGET_H8300H || TARGET_H8300S"
992 && !satisfies_constraint_U (operands[0])"
995 (parallel [(set (cc0)
996 (compare (zero_extract:SI (zero_extend:SI (match_dup 2))
998 (and:SI (match_dup 1)
1001 (clobber (scratch:QI))])]
1003 [(set_attr "length" "2,8,10")
1004 (set_attr "cc" "set_zn,set_zn,set_zn")])
1006 (define_insn "*tstqi"
1008 (compare (match_operand:QI 0 "register_operand" "r")
1012 [(set_attr "length" "2")
1013 (set_attr "cc" "set_znv")])
1015 (define_insn "*tsthi"
1017 (compare (match_operand:HI 0 "register_operand" "r")
1021 [(set_attr "length" "2")
1022 (set_attr "cc" "set_znv")])
1024 (define_insn "*tsthi_upper"
1026 (compare (and:HI (match_operand:HI 0 "register_operand" "r")
1031 [(set_attr "length" "2")
1032 (set_attr "cc" "set_znv")])
1034 (define_insn "*tstsi"
1036 (compare (match_operand:SI 0 "register_operand" "r")
1038 "TARGET_H8300H || TARGET_H8300S"
1040 [(set_attr "length" "2")
1041 (set_attr "cc" "set_znv")])
1043 (define_insn "*tstsi_upper"
1045 (compare (and:SI (match_operand:SI 0 "register_operand" "r")
1050 [(set_attr "length" "2")
1051 (set_attr "cc" "set_znv")])
1053 (define_insn "*cmpqi"
1055 (compare (match_operand:QI 0 "h8300_dst_operand" "rQ")
1056 (match_operand:QI 1 "h8300_src_operand" "rQi")))]
1059 [(set_attr "length_table" "addb")
1060 (set_attr "cc" "compare")])
1062 (define_insn "*cmphi_h8300_znvc"
1064 (compare (match_operand:HI 0 "register_operand" "r")
1065 (match_operand:HI 1 "register_operand" "r")))]
1068 [(set_attr "length" "2")
1069 (set_attr "cc" "compare")])
1071 (define_insn "*cmphi_h8300hs_znvc"
1073 (compare (match_operand:HI 0 "h8300_dst_operand" "rU,rQ")
1074 (match_operand:HI 1 "h8300_src_operand" "P3>X,rQi")))]
1075 "TARGET_H8300H || TARGET_H8300S"
1077 switch (which_alternative)
1080 if (!TARGET_H8300SX)
1081 return "cmp.w %T1,%T0";
1083 return "cmp.w %T1:3,%T0";
1085 return "cmp.w %T1,%T0";
1090 [(set_attr "length_table" "short_immediate,addw")
1091 (set_attr "cc" "compare,compare")])
1093 (define_insn "cmpsi"
1095 (compare (match_operand:SI 0 "h8300_dst_operand" "r,rQ")
1096 (match_operand:SI 1 "h8300_src_operand" "P3>X,rQi")))]
1097 "TARGET_H8300H || TARGET_H8300S"
1099 switch (which_alternative)
1102 if (!TARGET_H8300SX)
1103 return "cmp.l %S1,%S0";
1105 return "cmp.l %S1:3,%S0";
1107 return "cmp.l %S1,%S0";
1112 [(set_attr "length" "2,*")
1113 (set_attr "length_table" "*,addl")
1114 (set_attr "cc" "compare,compare")])
1116 ;; ----------------------------------------------------------------------
1118 ;; ----------------------------------------------------------------------
1120 (define_expand "addqi3"
1121 [(set (match_operand:QI 0 "register_operand" "")
1122 (plus:QI (match_operand:QI 1 "register_operand" "")
1123 (match_operand:QI 2 "h8300_src_operand" "")))]
1127 (define_insn "*addqi3"
1128 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
1129 (plus:QI (match_operand:QI 1 "h8300_dst_operand" "%0")
1130 (match_operand:QI 2 "h8300_src_operand" "rQi")))]
1131 "h8300_operands_match_p (operands)"
1133 [(set_attr "length_table" "addb")
1134 (set_attr "cc" "set_zn")])
1136 (define_expand "addhi3"
1137 [(set (match_operand:HI 0 "register_operand" "")
1138 (plus:HI (match_operand:HI 1 "register_operand" "")
1139 (match_operand:HI 2 "h8300_src_operand" "")))]
1143 (define_insn "*addhi3_h8300"
1144 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
1145 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
1146 (match_operand:HI 2 "h8300_src_operand" "L,N,J,n,r")))]
1152 add.b %s2,%s0\;addx %t2,%t0
1154 [(set_attr "length" "2,2,2,4,2")
1155 (set_attr "cc" "none_0hit,none_0hit,clobber,clobber,set_zn")])
1157 ;; This splitter is very important to make the stack adjustment
1158 ;; interrupt-safe. The combination of add.b and addx is unsafe!
1160 ;; We apply this split after the peephole2 pass so that we won't end
1161 ;; up creating too many adds/subs when a scratch register is
1162 ;; available, which is actually a common case because stack unrolling
1163 ;; tends to happen immediately after a function call.
1166 [(set (match_operand:HI 0 "stack_pointer_operand" "")
1167 (plus:HI (match_dup 0)
1168 (match_operand 1 "const_int_gt_2_operand" "")))]
1169 "TARGET_H8300 && epilogue_completed"
1172 split_adds_subs (HImode, operands);
1177 [(match_scratch:HI 2 "r")
1178 (set (match_operand:HI 0 "stack_pointer_operand" "")
1179 (plus:HI (match_dup 0)
1180 (match_operand:HI 1 "const_int_ge_8_operand" "")))]
1185 (plus:HI (match_dup 0)
1189 (define_insn "*addhi3_h8300hs"
1190 [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r")
1191 (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0")
1192 (match_operand:HI 2 "h8300_src_operand" "L,N,J,n,r")))]
1193 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX"
1200 [(set_attr "length" "2,2,2,4,2")
1201 (set_attr "cc" "none_0hit,none_0hit,clobber,set_zn,set_zn")])
1203 (define_insn "*addhi3_incdec"
1204 [(set (match_operand:HI 0 "register_operand" "=r,r")
1205 (unspec:HI [(match_operand:HI 1 "register_operand" "0,0")
1206 (match_operand:HI 2 "incdec_operand" "M,O")]
1208 "TARGET_H8300H || TARGET_H8300S"
1212 [(set_attr "length" "2,2")
1213 (set_attr "cc" "set_zn,set_zn")])
1215 (define_insn "*addhi3_h8sx"
1216 [(set (match_operand:HI 0 "h8300_dst_operand" "=rU,rU,r,rQ")
1217 (plus:HI (match_operand:HI 1 "h8300_dst_operand" "%0,0,0,0")
1218 (match_operand:HI 2 "h8300_src_operand" "P3>X,P3<X,J,rQi")))]
1219 "TARGET_H8300SX && h8300_operands_match_p (operands)"
1225 [(set_attr "length_table" "short_immediate,short_immediate,*,addw")
1226 (set_attr "length" "*,*,2,*")
1227 (set_attr "cc" "set_zn")])
1230 [(set (match_operand:HI 0 "register_operand" "")
1231 (plus:HI (match_dup 0)
1232 (match_operand:HI 1 "two_insn_adds_subs_operand" "")))]
1236 split_adds_subs (HImode, operands);
1240 (define_expand "addsi3"
1241 [(set (match_operand:SI 0 "register_operand" "")
1242 (plus:SI (match_operand:SI 1 "register_operand" "")
1243 (match_operand:SI 2 "h8300_src_operand" "")))]
1247 (define_insn "*addsi_h8300"
1248 [(set (match_operand:SI 0 "register_operand" "=r,r")
1249 (plus:SI (match_operand:SI 1 "register_operand" "%0,0")
1250 (match_operand:SI 2 "h8300_src_operand" "n,r")))]
1253 return output_plussi (operands);
1255 [(set (attr "length")
1256 (symbol_ref "compute_plussi_length (operands)"))
1258 (symbol_ref "compute_plussi_cc (operands)"))])
1260 (define_insn "*addsi_h8300hs"
1261 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ,rQ")
1262 (plus:SI (match_operand:SI 1 "h8300_dst_operand" "%0,0")
1263 (match_operand:SI 2 "h8300_src_operand" "i,rQ")))]
1264 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
1266 return output_plussi (operands);
1268 [(set (attr "length")
1269 (symbol_ref "compute_plussi_length (operands)"))
1271 (symbol_ref "compute_plussi_cc (operands)"))])
1273 (define_insn "*addsi3_incdec"
1274 [(set (match_operand:SI 0 "register_operand" "=r,r")
1275 (unspec:SI [(match_operand:SI 1 "register_operand" "0,0")
1276 (match_operand:SI 2 "incdec_operand" "M,O")]
1278 "TARGET_H8300H || TARGET_H8300S"
1282 [(set_attr "length" "2,2")
1283 (set_attr "cc" "set_zn,set_zn")])
1286 [(set (match_operand:SI 0 "register_operand" "")
1287 (plus:SI (match_dup 0)
1288 (match_operand:SI 1 "two_insn_adds_subs_operand" "")))]
1289 "TARGET_H8300H || TARGET_H8300S"
1292 split_adds_subs (SImode, operands);
1296 ;; ----------------------------------------------------------------------
1297 ;; SUBTRACT INSTRUCTIONS
1298 ;; ----------------------------------------------------------------------
1300 (define_expand "subqi3"
1301 [(set (match_operand:QI 0 "register_operand" "")
1302 (minus:QI (match_operand:QI 1 "register_operand" "")
1303 (match_operand:QI 2 "h8300_src_operand" "")))]
1307 (define_insn "*subqi3"
1308 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
1309 (minus:QI (match_operand:QI 1 "h8300_dst_operand" "0")
1310 (match_operand:QI 2 "h8300_dst_operand" "rQ")))]
1311 "h8300_operands_match_p (operands)"
1313 [(set_attr "length_table" "addb")
1314 (set_attr "cc" "set_zn")])
1316 (define_expand "subhi3"
1317 [(set (match_operand:HI 0 "register_operand" "")
1318 (minus:HI (match_operand:HI 1 "register_operand" "")
1319 (match_operand:HI 2 "h8300_src_operand" "")))]
1323 (define_insn "*subhi3_h8300"
1324 [(set (match_operand:HI 0 "register_operand" "=r,r")
1325 (minus:HI (match_operand:HI 1 "register_operand" "0,0")
1326 (match_operand:HI 2 "h8300_src_operand" "r,n")))]
1330 add.b %E2,%s0\;addx %F2,%t0"
1331 [(set_attr "length" "2,4")
1332 (set_attr "cc" "set_zn,clobber")])
1334 (define_insn "*subhi3_h8300hs"
1335 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ,rQ")
1336 (minus:HI (match_operand:HI 1 "h8300_dst_operand" "0,0")
1337 (match_operand:HI 2 "h8300_src_operand" "rQ,i")))]
1338 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
1342 [(set_attr "length_table" "addw")
1343 (set_attr "cc" "set_zn")])
1345 (define_expand "subsi3"
1346 [(set (match_operand:SI 0 "register_operand" "")
1347 (minus:SI (match_operand:SI 1 "register_operand" "")
1348 (match_operand:SI 2 "h8300_src_operand" "")))]
1352 operands[2] = force_reg (SImode, operands[2]);
1355 (define_insn "*subsi3_h8300"
1356 [(set (match_operand:SI 0 "register_operand" "=r")
1357 (minus:SI (match_operand:SI 1 "register_operand" "0")
1358 (match_operand:SI 2 "register_operand" "r")))]
1360 "sub.w %f2,%f0\;subx %y2,%y0\;subx %z2,%z0"
1361 [(set_attr "length" "6")])
1363 (define_insn "*subsi3_h8300hs"
1364 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ,rQ")
1365 (minus:SI (match_operand:SI 1 "h8300_dst_operand" "0,0")
1366 (match_operand:SI 2 "h8300_src_operand" "rQ,i")))]
1367 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
1371 [(set_attr "length_table" "addl")
1372 (set_attr "cc" "set_zn")])
1374 ;; ----------------------------------------------------------------------
1375 ;; MULTIPLY INSTRUCTIONS
1376 ;; ----------------------------------------------------------------------
1378 ;; Note that the H8/300 can only handle umulqihi3.
1380 (define_expand "mulqihi3"
1381 [(set (match_operand:HI 0 "register_operand" "")
1382 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" ""))
1383 ;; intentionally-mismatched modes
1384 (match_operand:QI 2 "reg_or_nibble_operand" "")))]
1385 "TARGET_H8300H || TARGET_H8300S"
1387 if (GET_MODE (operands[2]) != VOIDmode)
1388 operands[2] = gen_rtx_SIGN_EXTEND (HImode, operands[2]);
1391 (define_insn "*mulqihi3_const"
1392 [(set (match_operand:HI 0 "register_operand" "=r")
1393 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1394 (match_operand:QI 2 "nibble_operand" "IP4>X")))]
1397 [(set_attr "length" "4")
1398 (set_attr "cc" "set_zn")])
1400 (define_insn "*mulqihi3"
1401 [(set (match_operand:HI 0 "register_operand" "=r")
1402 (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1403 (sign_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1404 "TARGET_H8300H || TARGET_H8300S"
1406 [(set_attr "length" "4")
1407 (set_attr "cc" "set_zn")])
1409 (define_expand "mulhisi3"
1410 [(set (match_operand:SI 0 "register_operand" "")
1411 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" ""))
1412 ;; intentionally-mismatched modes
1413 (match_operand:HI 2 "reg_or_nibble_operand" "")))]
1414 "TARGET_H8300H || TARGET_H8300S"
1416 if (GET_MODE (operands[2]) != VOIDmode)
1417 operands[2] = gen_rtx_SIGN_EXTEND (SImode, operands[2]);
1420 (define_insn "*mulhisi3_const"
1421 [(set (match_operand:SI 0 "register_operand" "=r")
1422 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1423 (match_operand:SI 2 "nibble_operand" "IP4>X")))]
1426 [(set_attr "length" "4")
1427 (set_attr "cc" "set_zn")])
1429 (define_insn "*mulhisi3"
1430 [(set (match_operand:SI 0 "register_operand" "=r")
1431 (mult:SI (sign_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1432 (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1433 "TARGET_H8300H || TARGET_H8300S"
1435 [(set_attr "length" "4")
1436 (set_attr "cc" "set_zn")])
1438 (define_expand "umulqihi3"
1439 [(set (match_operand:HI 0 "register_operand" "")
1440 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" ""))
1441 ;; intentionally-mismatched modes
1442 (match_operand:QI 2 "reg_or_nibble_operand" "")))]
1443 "TARGET_H8300H || TARGET_H8300S"
1445 if (GET_MODE (operands[2]) != VOIDmode)
1446 operands[2] = gen_rtx_ZERO_EXTEND (HImode, operands[2]);
1449 (define_insn "*umulqihi3_const"
1450 [(set (match_operand:HI 0 "register_operand" "=r")
1451 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1452 (match_operand:QI 2 "nibble_operand" "IP4>X")))]
1455 [(set_attr "length" "4")
1456 (set_attr "cc" "set_zn")])
1458 (define_insn "*umulqihi3"
1459 [(set (match_operand:HI 0 "register_operand" "=r")
1460 (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "%0"))
1461 (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
1464 [(set_attr "length" "2")
1465 (set_attr "cc" "none_0hit")])
1467 (define_expand "umulhisi3"
1468 [(set (match_operand:SI 0 "register_operand" "")
1469 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" ""))
1470 ;; intentionally-mismatched modes
1471 (match_operand:HI 2 "reg_or_nibble_operand" "")))]
1472 "TARGET_H8300H || TARGET_H8300S"
1474 if (GET_MODE (operands[2]) != VOIDmode)
1475 operands[2] = gen_rtx_ZERO_EXTEND (SImode, operands[2]);
1478 (define_insn "*umulhisi3_const"
1479 [(set (match_operand:SI 0 "register_operand" "=r")
1480 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1481 (match_operand:SI 2 "nibble_operand" "IP4>X")))]
1484 [(set_attr "length" "4")
1485 (set_attr "cc" "set_zn")])
1487 (define_insn "*umulhisi3"
1488 [(set (match_operand:SI 0 "register_operand" "=r")
1489 (mult:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "%0"))
1490 (zero_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
1491 "TARGET_H8300H || TARGET_H8300S"
1493 [(set_attr "length" "2")
1494 (set_attr "cc" "none_0hit")])
1496 ;; We could have used mulu.[wl] here, but mulu.[lw] is only available
1497 ;; on a H8SX with a multiplier, whereas muls.w seems to be available
1498 ;; on all H8SX variants.
1500 (define_insn "mulhi3"
1501 [(set (match_operand:HI 0 "register_operand" "=r")
1502 (mult:HI (match_operand:HI 1 "register_operand" "%0")
1503 (match_operand:HI 2 "reg_or_nibble_operand" "r IP4>X")))]
1506 [(set_attr "length" "2")
1507 (set_attr "cc" "set_zn")])
1509 (define_insn "mulsi3"
1510 [(set (match_operand:SI 0 "register_operand" "=r")
1511 (mult:SI (match_operand:SI 1 "register_operand" "%0")
1512 (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))]
1515 [(set_attr "length" "2")
1516 (set_attr "cc" "set_zn")])
1518 (define_insn "smulsi3_highpart"
1519 [(set (match_operand:SI 0 "register_operand" "=r")
1523 (sign_extend:DI (match_operand:SI 1 "register_operand" "%0"))
1524 (sign_extend:DI (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))
1527 "muls/u.l\\t%S2,%S0"
1528 [(set_attr "length" "2")
1529 (set_attr "cc" "set_zn")])
1531 (define_insn "umulsi3_highpart"
1532 [(set (match_operand:SI 0 "register_operand" "=r")
1536 (zero_extend:DI (match_operand:SI 1 "register_operand" "%0"))
1537 (zero_extend:DI (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))
1540 "mulu/u.l\\t%S2,%S0"
1541 [(set_attr "length" "2")
1542 (set_attr "cc" "none_0hit")])
1544 ;; This is a "bridge" instruction. Combine can't cram enough insns
1545 ;; together to crate a MAC instruction directly, but it can create
1546 ;; this instruction, which then allows combine to create the real
1549 ;; Unfortunately, if combine doesn't create a MAC instruction, this
1550 ;; insn must generate reasonably correct code. Egad.
1553 [(set (match_operand:SI 0 "register_operand" "=a")
1556 (mem:HI (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1558 (mem:HI (post_inc:SI (match_operand:SI 2 "register_operand" "r"))))))]
1560 "clrmac\;mac @%2+,@%1+"
1561 [(set_attr "length" "6")
1562 (set_attr "cc" "none_0hit")])
1565 [(set (match_operand:SI 0 "register_operand" "=a")
1567 (sign_extend:SI (mem:HI
1568 (post_inc:SI (match_operand:SI 1 "register_operand" "r"))))
1569 (sign_extend:SI (mem:HI
1570 (post_inc:SI (match_operand:SI 2 "register_operand" "r")))))
1571 (match_operand:SI 3 "register_operand" "0")))]
1574 [(set_attr "length" "4")
1575 (set_attr "cc" "none_0hit")])
1577 ;; ----------------------------------------------------------------------
1578 ;; DIVIDE/MOD INSTRUCTIONS
1579 ;; ----------------------------------------------------------------------
1581 (define_insn "udivhi3"
1582 [(set (match_operand:HI 0 "register_operand" "=r")
1583 (udiv:HI (match_operand:HI 1 "register_operand" "0")
1584 (match_operand:HI 2 "reg_or_nibble_operand" "r IP4>X")))]
1587 [(set_attr "length" "2")])
1589 (define_insn "divhi3"
1590 [(set (match_operand:HI 0 "register_operand" "=r")
1591 (div:HI (match_operand:HI 1 "register_operand" "0")
1592 (match_operand:HI 2 "reg_or_nibble_operand" "r IP4>X")))]
1595 [(set_attr "length" "2")])
1597 (define_insn "udivsi3"
1598 [(set (match_operand:SI 0 "register_operand" "=r")
1599 (udiv:SI (match_operand:SI 1 "register_operand" "0")
1600 (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))]
1603 [(set_attr "length" "2")])
1605 (define_insn "divsi3"
1606 [(set (match_operand:SI 0 "register_operand" "=r")
1607 (div:SI (match_operand:SI 1 "register_operand" "0")
1608 (match_operand:SI 2 "reg_or_nibble_operand" "r IP4>X")))]
1611 [(set_attr "length" "2")])
1613 (define_insn "udivmodqi4"
1614 [(set (match_operand:QI 0 "register_operand" "=r")
1617 (match_operand:HI 1 "register_operand" "0")
1618 (zero_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1619 (set (match_operand:QI 3 "register_operand" "=r")
1623 (zero_extend:HI (match_dup 2)))))]
1626 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1627 return "divxu.b\\t%X2,%T0";
1629 return "divxu.b\\t%X2,%T0\;mov.b\\t%t0,%s3";
1631 [(set_attr "length" "4")])
1633 (define_insn "divmodqi4"
1634 [(set (match_operand:QI 0 "register_operand" "=r")
1637 (match_operand:HI 1 "register_operand" "0")
1638 (sign_extend:HI (match_operand:QI 2 "register_operand" "r")))))
1639 (set (match_operand:QI 3 "register_operand" "=r")
1643 (sign_extend:HI (match_dup 2)))))]
1644 "TARGET_H8300H || TARGET_H8300S"
1646 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1647 return "divxs.b\\t%X2,%T0";
1649 return "divxs.b\\t%X2,%T0\;mov.b\\t%t0,%s3";
1651 [(set_attr "length" "6")])
1653 (define_insn "udivmodhi4"
1654 [(set (match_operand:HI 0 "register_operand" "=r")
1657 (match_operand:SI 1 "register_operand" "0")
1658 (zero_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1659 (set (match_operand:HI 3 "register_operand" "=r")
1663 (zero_extend:SI (match_dup 2)))))]
1664 "TARGET_H8300H || TARGET_H8300S"
1666 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1667 return "divxu.w\\t%T2,%S0";
1669 return "divxu.w\\t%T2,%S0\;mov.w\\t%e0,%f3";
1671 [(set_attr "length" "4")])
1673 (define_insn "divmodhi4"
1674 [(set (match_operand:HI 0 "register_operand" "=r")
1677 (match_operand:SI 1 "register_operand" "0")
1678 (sign_extend:SI (match_operand:HI 2 "register_operand" "r")))))
1679 (set (match_operand:HI 3 "register_operand" "=r")
1683 (sign_extend:SI (match_dup 2)))))]
1684 "TARGET_H8300H || TARGET_H8300S"
1686 if (find_reg_note (insn, REG_UNUSED, operands[3]))
1687 return "divxs.w\\t%T2,%S0";
1689 return "divxs.w\\t%T2,%S0\;mov.w\\t%e0,%f3";
1691 [(set_attr "length" "6")])
1693 ;; ----------------------------------------------------------------------
1695 ;; ----------------------------------------------------------------------
1697 (define_insn "bclrqi_msx"
1698 [(set (match_operand:QI 0 "bit_register_indirect_operand" "=WU")
1699 (and:QI (match_operand:QI 1 "bit_register_indirect_operand" "%0")
1700 (match_operand:QI 2 "single_zero_operand" "Y0")))]
1701 "TARGET_H8300SX && rtx_equal_p (operands[0], operands[1])"
1703 [(set_attr "length" "8")])
1706 [(set (match_operand:HI 0 "bit_register_indirect_operand")
1707 (and:HI (match_operand:HI 1 "bit_register_indirect_operand")
1708 (match_operand:HI 2 "single_zero_operand")))]
1711 (and:QI (match_dup 1)
1714 if (abs (INTVAL (operands[2])) > 0xFF)
1716 operands[0] = adjust_address (operands[0], QImode, 0);
1717 operands[1] = adjust_address (operands[1], QImode, 0);
1718 operands[2] = GEN_INT ((INTVAL (operands[2])) >> 8);
1722 operands[0] = adjust_address (operands[0], QImode, 1);
1723 operands[1] = adjust_address (operands[1], QImode, 1);
1727 (define_insn "bclrhi_msx"
1728 [(set (match_operand:HI 0 "bit_register_indirect_operand" "=m")
1729 (and:HI (match_operand:HI 1 "bit_register_indirect_operand" "%0")
1730 (match_operand:HI 2 "single_zero_operand" "Y0")))]
1733 [(set_attr "length" "8")])
1735 (define_insn "*andqi3_2"
1736 [(set (match_operand:QI 0 "bit_operand" "=U,rQ,r")
1737 (and:QI (match_operand:QI 1 "bit_operand" "%0,0,WU")
1738 (match_operand:QI 2 "h8300_src_operand" "Y0,rQi,IP1>X")))]
1744 [(set_attr "length" "8,*,8")
1745 (set_attr "length_table" "*,logicb,*")
1746 (set_attr "cc" "none_0hit,set_znv,none_0hit")])
1748 (define_insn "andqi3_1"
1749 [(set (match_operand:QI 0 "bit_operand" "=U,r")
1750 (and:QI (match_operand:QI 1 "bit_operand" "%0,0")
1751 (match_operand:QI 2 "h8300_src_operand" "Y0,rn")))]
1752 "register_operand (operands[0], QImode)
1753 || single_zero_operand (operands[2], QImode)"
1757 [(set_attr "length" "2,8")
1758 (set_attr "cc" "none_0hit,set_znv")])
1760 (define_expand "andqi3"
1761 [(set (match_operand:QI 0 "register_operand" "")
1762 (and:QI (match_operand:QI 1 "register_operand" "")
1763 (match_operand:QI 2 "h8300_src_operand" "")))]
1767 (define_expand "andhi3"
1768 [(set (match_operand:HI 0 "register_operand" "")
1769 (and:HI (match_operand:HI 1 "register_operand" "")
1770 (match_operand:HI 2 "h8300_src_operand" "")))]
1774 (define_insn "*andorqi3"
1775 [(set (match_operand:QI 0 "register_operand" "=r")
1776 (ior:QI (and:QI (match_operand:QI 2 "register_operand" "r")
1777 (match_operand:QI 3 "single_one_operand" "n"))
1778 (match_operand:QI 1 "register_operand" "0")))]
1780 "bld\\t%V3,%X2\;bor\\t%V3,%X0\;bst\\t%V3,%X0"
1781 [(set_attr "length" "6")])
1783 (define_insn "*andorhi3"
1784 [(set (match_operand:HI 0 "register_operand" "=r")
1785 (ior:HI (and:HI (match_operand:HI 2 "register_operand" "r")
1786 (match_operand:HI 3 "single_one_operand" "n"))
1787 (match_operand:HI 1 "register_operand" "0")))]
1790 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1791 if (INTVAL (operands[3]) > 128)
1793 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1794 return "bld\\t%V3,%t2\;bor\\t%V3,%t0\;bst\\t%V3,%t0";
1796 return "bld\\t%V3,%s2\;bor\\t%V3,%s0\;bst\\t%V3,%s0";
1798 [(set_attr "length" "6")])
1800 (define_insn "*andorsi3"
1801 [(set (match_operand:SI 0 "register_operand" "=r")
1802 (ior:SI (and:SI (match_operand:SI 2 "register_operand" "r")
1803 (match_operand:SI 3 "single_one_operand" "n"))
1804 (match_operand:SI 1 "register_operand" "0")))]
1805 "(INTVAL (operands[3]) & 0xffff) != 0"
1807 operands[3] = GEN_INT (INTVAL (operands[3]) & 0xffff);
1808 if (INTVAL (operands[3]) > 128)
1810 operands[3] = GEN_INT (INTVAL (operands[3]) >> 8);
1811 return "bld\\t%V3,%x2\;bor\\t%V3,%x0\;bst\\t%V3,%x0";
1813 return "bld\\t%V3,%w2\;bor\\t%V3,%w0\;bst\\t%V3,%w0";
1815 [(set_attr "length" "6")])
1817 (define_insn "*andorsi3_shift_8"
1818 [(set (match_operand:SI 0 "register_operand" "=r")
1819 (ior:SI (and:SI (ashift:SI (match_operand:SI 2 "register_operand" "r")
1822 (match_operand:SI 1 "register_operand" "0")))]
1825 [(set_attr "length" "2")])
1827 (define_expand "andsi3"
1828 [(set (match_operand:SI 0 "register_operand" "")
1829 (and:SI (match_operand:SI 1 "register_operand" "")
1830 (match_operand:SI 2 "h8300_src_operand" "")))]
1834 ;; ----------------------------------------------------------------------
1836 ;; ----------------------------------------------------------------------
1838 (define_insn "bsetqi_msx"
1839 [(set (match_operand:QI 0 "bit_register_indirect_operand" "=WU")
1840 (ior:QI (match_operand:QI 1 "bit_register_indirect_operand" "%0")
1841 (match_operand:QI 2 "single_one_operand" "Y2")))]
1842 "TARGET_H8300SX && rtx_equal_p (operands[0], operands[1])"
1844 [(set_attr "length" "8")])
1847 [(set (match_operand:HI 0 "bit_register_indirect_operand")
1848 (ior:HI (match_operand:HI 1 "bit_register_indirect_operand")
1849 (match_operand:HI 2 "single_one_operand")))]
1852 (ior:QI (match_dup 1)
1855 if (abs (INTVAL (operands[2])) > 0xFF)
1857 operands[0] = adjust_address (operands[0], QImode, 0);
1858 operands[1] = adjust_address (operands[1], QImode, 0);
1859 operands[2] = GEN_INT ((INTVAL (operands[2])) >> 8);
1863 operands[0] = adjust_address (operands[0], QImode, 1);
1864 operands[1] = adjust_address (operands[1], QImode, 1);
1868 (define_insn "bsethi_msx"
1869 [(set (match_operand:HI 0 "bit_register_indirect_operand" "=m")
1870 (ior:HI (match_operand:HI 1 "bit_register_indirect_operand" "%0")
1871 (match_operand:HI 2 "single_one_operand" "Y2")))]
1874 [(set_attr "length" "8")])
1876 (define_insn "iorqi3_1"
1877 [(set (match_operand:QI 0 "bit_operand" "=U,rQ")
1878 (ior:QI (match_operand:QI 1 "bit_operand" "%0,0")
1879 (match_operand:QI 2 "h8300_src_operand" "Y2,rQi")))]
1880 "TARGET_H8300SX || register_operand (operands[0], QImode)
1881 || single_one_operand (operands[2], QImode)"
1885 [(set_attr "length" "8,*")
1886 (set_attr "length_table" "*,logicb")
1887 (set_attr "cc" "none_0hit,set_znv")])
1890 (define_expand "iorqi3"
1891 [(set (match_operand:QI 0 "register_operand" "")
1892 (ior:QI (match_operand:QI 1 "register_operand" "")
1893 (match_operand:QI 2 "h8300_src_operand" "")))]
1897 (define_expand "iorhi3"
1898 [(set (match_operand:HI 0 "register_operand" "")
1899 (ior:HI (match_operand:HI 1 "register_operand" "")
1900 (match_operand:HI 2 "h8300_src_operand" "")))]
1904 (define_expand "iorsi3"
1905 [(set (match_operand:SI 0 "register_operand" "")
1906 (ior:SI (match_operand:SI 1 "register_operand" "")
1907 (match_operand:SI 2 "h8300_src_operand" "")))]
1911 ;; ----------------------------------------------------------------------
1913 ;; ----------------------------------------------------------------------
1915 (define_insn "bnotqi_msx"
1916 [(set (match_operand:QI 0 "bit_register_indirect_operand" "=WU")
1917 (xor:QI (match_operand:QI 1 "bit_register_indirect_operand" "%0")
1918 (match_operand:QI 2 "single_one_operand" "Y2")))]
1920 && rtx_equal_p (operands[0], operands[1])"
1922 [(set_attr "length" "8")])
1925 [(set (match_operand:HI 0 "bit_register_indirect_operand")
1926 (xor:HI (match_operand:HI 1 "bit_register_indirect_operand")
1927 (match_operand:HI 2 "single_one_operand")))]
1930 (xor:QI (match_dup 1)
1933 if (abs (INTVAL (operands[2])) > 0xFF)
1935 operands[0] = adjust_address (operands[0], QImode, 0);
1936 operands[1] = adjust_address (operands[1], QImode, 0);
1937 operands[2] = GEN_INT ((INTVAL (operands[2])) >> 8);
1941 operands[0] = adjust_address (operands[0], QImode, 1);
1942 operands[1] = adjust_address (operands[1], QImode, 1);
1946 (define_insn "bnothi_msx"
1947 [(set (match_operand:HI 0 "bit_register_indirect_operand" "=m")
1948 (xor:HI (match_operand:HI 1 "bit_register_indirect_operand" "%0")
1949 (match_operand:HI 2 "single_one_operand" "Y2")))]
1952 [(set_attr "length" "8")])
1954 (define_insn "xorqi3_1"
1955 [(set (match_operand:QI 0 "bit_operand" "=U,r")
1956 (xor:QI (match_operand:QI 1 "bit_operand" "%0,0")
1957 (match_operand:QI 2 "h8300_src_operand" "Y2,rQi")))]
1958 "TARGET_H8300SX || register_operand (operands[0], QImode)
1959 || single_one_operand (operands[2], QImode)"
1963 [(set_attr "length" "8,*")
1964 (set_attr "length_table" "*,logicb")
1965 (set_attr "cc" "none_0hit,set_znv")])
1967 (define_expand "xorqi3"
1968 [(set (match_operand:QI 0 "register_operand" "")
1969 (xor:QI (match_operand:QI 1 "register_operand" "")
1970 (match_operand:QI 2 "h8300_src_operand" "")))]
1974 (define_expand "xorhi3"
1975 [(set (match_operand:HI 0 "register_operand" "")
1976 (xor:HI (match_operand:HI 1 "register_operand" "")
1977 (match_operand:HI 2 "h8300_src_operand" "")))]
1981 (define_expand "xorsi3"
1982 [(set (match_operand:SI 0 "register_operand" "")
1983 (xor:SI (match_operand:SI 1 "register_operand" "")
1984 (match_operand:SI 2 "h8300_src_operand" "")))]
1988 ;; ----------------------------------------------------------------------
1989 ;; {AND,IOR,XOR}{HI3,SI3} PATTERNS
1990 ;; ----------------------------------------------------------------------
1992 ;; We need a separate pattern here because machines other than the
1993 ;; original H8300 don't have to split the 16-bit operand into a pair
1994 ;; of high/low instructions, so we can accept literal addresses, that
1995 ;; have to be loaded into a register on H8300.
1997 (define_insn "*logicalhi3_sn"
1998 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
1999 (match_operator:HI 3 "bit_operator"
2000 [(match_operand:HI 1 "h8300_dst_operand" "%0")
2001 (match_operand:HI 2 "h8300_src_operand" "rQi")]))]
2002 "(TARGET_H8300S || TARGET_H8300H) && h8300_operands_match_p (operands)"
2004 return output_logical_op (HImode, operands);
2006 [(set (attr "length")
2007 (symbol_ref "compute_logical_op_length (HImode, operands)"))
2009 (symbol_ref "compute_logical_op_cc (HImode, operands)"))])
2011 (define_insn "*logicalsi3_sn"
2012 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2013 (match_operator:SI 3 "bit_operator"
2014 [(match_operand:SI 1 "h8300_dst_operand" "%0")
2015 (match_operand:SI 2 "h8300_src_operand" "rQi")]))]
2016 "(TARGET_H8300S || TARGET_H8300H) && h8300_operands_match_p (operands)"
2018 return output_logical_op (SImode, operands);
2020 [(set (attr "length")
2021 (symbol_ref "compute_logical_op_length (SImode, operands)"))
2023 (symbol_ref "compute_logical_op_cc (SImode, operands)"))])
2025 (define_insn "*logicalhi3"
2026 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
2027 (match_operator:HI 3 "bit_operator"
2028 [(match_operand:HI 1 "h8300_dst_operand" "%0")
2029 (match_operand:HI 2 "h8300_src_operand" "rQi")]))]
2030 "h8300_operands_match_p (operands)"
2032 return output_logical_op (HImode, operands);
2034 [(set (attr "length")
2035 (symbol_ref "compute_logical_op_length (HImode, operands)"))
2037 (symbol_ref "compute_logical_op_cc (HImode, operands)"))])
2039 (define_insn "*logicalsi3"
2040 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2041 (match_operator:SI 3 "bit_operator"
2042 [(match_operand:SI 1 "h8300_dst_operand" "%0")
2043 (match_operand:SI 2 "h8300_src_operand" "rQi")]))]
2044 "h8300_operands_match_p (operands)"
2046 return output_logical_op (SImode, operands);
2048 [(set (attr "length")
2049 (symbol_ref "compute_logical_op_length (SImode, operands)"))
2051 (symbol_ref "compute_logical_op_cc (SImode, operands)"))])
2053 ;; ----------------------------------------------------------------------
2054 ;; NEGATION INSTRUCTIONS
2055 ;; ----------------------------------------------------------------------
2057 (define_expand "negqi2"
2058 [(set (match_operand:QI 0 "register_operand" "")
2059 (neg:QI (match_operand:QI 1 "register_operand" "")))]
2063 (define_insn "*negqi2"
2064 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
2065 (neg:QI (match_operand:QI 1 "h8300_dst_operand" "0")))]
2068 [(set_attr "length_table" "unary")
2069 (set_attr "cc" "set_zn")])
2071 (define_expand "neghi2"
2072 [(set (match_operand:HI 0 "register_operand" "")
2073 (neg:HI (match_operand:HI 1 "register_operand" "")))]
2078 emit_insn (gen_neghi2_h8300 (operands[0], operands[1]));
2083 (define_expand "neghi2_h8300"
2085 (not:HI (match_operand:HI 1 "register_operand" "")))
2086 (set (match_dup 2) (plus:HI (match_dup 2) (const_int 1)))
2087 (set (match_operand:HI 0 "register_operand" "")
2091 operands[2] = gen_reg_rtx (HImode);
2094 (define_insn "*neghi2_h8300hs"
2095 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
2096 (neg:HI (match_operand:HI 1 "h8300_dst_operand" "0")))]
2097 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2099 [(set_attr "length_table" "unary")
2100 (set_attr "cc" "set_zn")])
2102 (define_expand "negsi2"
2103 [(set (match_operand:SI 0 "register_operand" "")
2104 (neg:SI (match_operand:SI 1 "register_operand" "")))]
2109 emit_insn (gen_negsi2_h8300 (operands[0], operands[1]));
2114 (define_expand "negsi2_h8300"
2116 (not:SI (match_operand:SI 1 "register_operand" "")))
2117 (set (match_dup 2) (plus:SI (match_dup 2) (const_int 1)))
2118 (set (match_operand:SI 0 "register_operand" "")
2122 operands[2] = gen_reg_rtx (SImode);
2125 (define_insn "*negsi2_h8300hs"
2126 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2127 (neg:SI (match_operand:SI 1 "h8300_dst_operand" "0")))]
2128 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2130 [(set_attr "length_table" "unary")
2131 (set_attr "cc" "set_zn")])
2133 (define_expand "negsf2"
2134 [(set (match_operand:SF 0 "register_operand" "")
2135 (neg:SF (match_operand:SF 1 "register_operand" "")))]
2139 (define_insn "*negsf2_h8300"
2140 [(set (match_operand:SF 0 "register_operand" "=r")
2141 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
2144 [(set_attr "length" "2")])
2146 (define_insn "*negsf2_h8300hs"
2147 [(set (match_operand:SF 0 "register_operand" "=r")
2148 (neg:SF (match_operand:SF 1 "register_operand" "0")))]
2149 "TARGET_H8300H || TARGET_H8300S"
2150 "xor.w\\t#32768,%e0"
2151 [(set_attr "length" "4")])
2153 ;; ----------------------------------------------------------------------
2154 ;; ABSOLUTE VALUE INSTRUCTIONS
2155 ;; ----------------------------------------------------------------------
2157 (define_expand "abssf2"
2158 [(set (match_operand:SF 0 "register_operand" "")
2159 (abs:SF (match_operand:SF 1 "register_operand" "")))]
2163 (define_insn "*abssf2_h8300"
2164 [(set (match_operand:SF 0 "register_operand" "=r")
2165 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
2168 [(set_attr "length" "2")])
2170 (define_insn "*abssf2_h8300hs"
2171 [(set (match_operand:SF 0 "register_operand" "=r")
2172 (abs:SF (match_operand:SF 1 "register_operand" "0")))]
2173 "TARGET_H8300H || TARGET_H8300S"
2174 "and.w\\t#32767,%e0"
2175 [(set_attr "length" "4")])
2177 ;; ----------------------------------------------------------------------
2179 ;; ----------------------------------------------------------------------
2181 (define_expand "one_cmplqi2"
2182 [(set (match_operand:QI 0 "register_operand" "")
2183 (not:QI (match_operand:QI 1 "register_operand" "")))]
2187 (define_insn "*one_cmplqi2"
2188 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
2189 (not:QI (match_operand:QI 1 "h8300_dst_operand" "0")))]
2192 [(set_attr "length_table" "unary")
2193 (set_attr "cc" "set_znv")])
2195 (define_expand "one_cmplhi2"
2196 [(set (match_operand:HI 0 "register_operand" "")
2197 (not:HI (match_operand:HI 1 "register_operand" "")))]
2201 (define_insn "*one_cmplhi2_h8300"
2202 [(set (match_operand:HI 0 "register_operand" "=r")
2203 (not:HI (match_operand:HI 1 "register_operand" "0")))]
2206 [(set_attr "length" "4")])
2208 (define_insn "*one_cmplhi2_h8300hs"
2209 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
2210 (not:HI (match_operand:HI 1 "h8300_dst_operand" "0")))]
2211 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2213 [(set_attr "cc" "set_znv")
2214 (set_attr "length_table" "unary")])
2216 (define_expand "one_cmplsi2"
2217 [(set (match_operand:SI 0 "register_operand" "")
2218 (not:SI (match_operand:SI 1 "register_operand" "")))]
2222 (define_insn "*one_cmplsi2_h8300"
2223 [(set (match_operand:SI 0 "register_operand" "=r")
2224 (not:SI (match_operand:SI 1 "register_operand" "0")))]
2226 "not %w0\;not %x0\;not %y0\;not %z0"
2227 [(set_attr "length" "8")])
2229 (define_insn "*one_cmplsi2_h8300hs"
2230 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
2231 (not:SI (match_operand:SI 1 "h8300_dst_operand" "0")))]
2232 "(TARGET_H8300H || TARGET_H8300S) && h8300_operands_match_p (operands)"
2234 [(set_attr "cc" "set_znv")
2235 (set_attr "length_table" "unary")])
2237 ;; ----------------------------------------------------------------------
2238 ;; JUMP INSTRUCTIONS
2239 ;; ----------------------------------------------------------------------
2241 ;; Conditional jump instructions
2243 (define_expand "cbranchqi4"
2244 [(use (match_operator 0 "ordered_comparison_operator"
2245 [(match_operand:QI 1 "h8300_dst_operand" "")
2246 (match_operand:QI 2 "h8300_src_operand" "")]))
2247 (use (match_operand 3 ""))]
2250 h8300_expand_branch (operands);
2254 (define_expand "cbranchhi4"
2255 [(use (match_operator 0 "ordered_comparison_operator"
2256 [(match_operand:HI 1 "h8300_dst_operand" "")
2257 (match_operand:HI 2 "h8300_src_operand" "")]))
2258 (use (match_operand 3 ""))]
2261 /* Force operand1 into a register if we're compiling
2263 if ((GET_CODE (operands[2]) != REG && operands[2] != const0_rtx)
2265 operands[2] = force_reg (HImode, operands[2]);
2266 h8300_expand_branch (operands);
2270 (define_expand "cbranchsi4"
2271 [(use (match_operator 0 "ordered_comparison_operator"
2272 [(match_operand:SI 1 "h8300_dst_operand" "")
2273 (match_operand:SI 2 "h8300_src_operand" "")]))
2274 (use (match_operand 3 ""))]
2275 "TARGET_H8300H || TARGET_H8300S"
2277 h8300_expand_branch (operands);
2281 (define_insn "branch_true"
2283 (if_then_else (match_operator 1 "comparison_operator"
2284 [(cc0) (const_int 0)])
2285 (label_ref (match_operand 0 "" ""))
2289 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
2290 && (GET_CODE (operands[1]) == GT
2291 || GET_CODE (operands[1]) == GE
2292 || GET_CODE (operands[1]) == LE
2293 || GET_CODE (operands[1]) == LT))
2295 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
2299 if (get_attr_length (insn) == 2)
2301 else if (get_attr_length (insn) == 4)
2302 return "b%j1 %l0:16";
2304 return "b%k1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:";
2306 [(set_attr "type" "branch")
2307 (set_attr "cc" "none")])
2309 (define_insn "branch_false"
2311 (if_then_else (match_operator 1 "comparison_operator"
2312 [(cc0) (const_int 0)])
2314 (label_ref (match_operand 0 "" ""))))]
2317 if ((cc_status.flags & CC_OVERFLOW_UNUSABLE) != 0
2318 && (GET_CODE (operands[1]) == GT
2319 || GET_CODE (operands[1]) == GE
2320 || GET_CODE (operands[1]) == LE
2321 || GET_CODE (operands[1]) == LT))
2323 cc_status.flags &= ~CC_OVERFLOW_UNUSABLE;
2327 if (get_attr_length (insn) == 2)
2329 else if (get_attr_length (insn) == 4)
2330 return "b%k1 %l0:16";
2332 return "b%j1 .Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:";
2334 [(set_attr "type" "branch")
2335 (set_attr "cc" "none")])
2337 (define_insn "*brabc"
2339 (if_then_else (eq (zero_extract (match_operand:QI 1 "bit_memory_operand" "WU")
2341 (match_operand:QI 2 "immediate_operand" "n"))
2343 (label_ref (match_operand 0 "" ""))
2347 switch (get_attr_length (insn)
2348 - h8300_insn_length_from_table (insn, operands))
2351 return "bra/bc %2,%R1,%l0";
2353 return "bra/bc %2,%R1,%l0:16";
2355 return "bra/bs %2,%R1,.Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:";
2358 [(set_attr "type" "bitbranch")
2359 (set_attr "length_table" "bitbranch")
2360 (set_attr "cc" "none")])
2362 (define_insn "*brabs"
2364 (if_then_else (ne (zero_extract (match_operand:QI 1 "bit_memory_operand" "WU")
2366 (match_operand:QI 2 "immediate_operand" "n"))
2368 (label_ref (match_operand 0 "" ""))
2372 switch (get_attr_length (insn)
2373 - h8300_insn_length_from_table (insn, operands))
2376 return "bra/bs %2,%R1,%l0";
2378 return "bra/bs %2,%R1,%l0:16";
2380 return "bra/bc %2,%R1,.Lh8BR%=\;jmp @%l0\\n.Lh8BR%=:";
2383 [(set_attr "type" "bitbranch")
2384 (set_attr "length_table" "bitbranch")
2385 (set_attr "cc" "none")])
2387 ;; Unconditional and other jump instructions.
2391 (label_ref (match_operand 0 "" "")))]
2394 if (final_sequence != 0)
2396 if (get_attr_length (insn) == 2)
2400 /* The branch isn't short enough to use bra/s. Output the
2401 branch and delay slot in their normal order.
2403 If this is a backward branch, it will now be branching two
2404 bytes further than previously thought. The length-based
2405 test for bra vs. jump is very conservative though, so the
2406 branch will still be within range. */
2410 vec = XVEC (final_sequence, 0);
2412 final_scan_insn (RTVEC_ELT (vec, 1), asm_out_file, optimize, 1, & seen);
2413 final_scan_insn (RTVEC_ELT (vec, 0), asm_out_file, optimize, 1, & seen);
2414 INSN_DELETED_P (RTVEC_ELT (vec, 1)) = 1;
2418 else if (get_attr_length (insn) == 2)
2420 else if (get_attr_length (insn) == 4)
2421 return "bra %l0:16";
2425 [(set_attr "type" "branch")
2426 (set (attr "delay_slot")
2427 (if_then_else (match_test "TARGET_H8300SX")
2428 (const_string "jump")
2429 (const_string "none")))
2430 (set_attr "cc" "none")])
2432 ;; This is a define expand, because pointers may be either 16 or 32 bits.
2434 (define_expand "tablejump"
2435 [(parallel [(set (pc) (match_operand 0 "register_operand" ""))
2436 (use (label_ref (match_operand 1 "" "")))])]
2440 (define_insn "*tablejump_h8300"
2441 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
2442 (use (label_ref (match_operand 1 "" "")))]
2445 [(set_attr "cc" "none")
2446 (set_attr "length" "2")])
2448 (define_insn "*tablejump_h8300hs_advanced"
2449 [(set (pc) (match_operand:SI 0 "register_operand" "r"))
2450 (use (label_ref (match_operand 1 "" "")))]
2451 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE"
2453 [(set_attr "cc" "none")
2454 (set_attr "length" "2")])
2456 (define_insn "*tablejump_h8300hs_normal"
2457 [(set (pc) (match_operand:HI 0 "register_operand" "r"))
2458 (use (label_ref (match_operand 1 "" "")))]
2459 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
2461 [(set_attr "cc" "none")
2462 (set_attr "length" "2")])
2464 ;; This is a define expand, because pointers may be either 16 or 32 bits.
2466 (define_expand "indirect_jump"
2467 [(set (pc) (match_operand 0 "jump_address_operand" ""))]
2471 (define_insn "*indirect_jump_h8300"
2472 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
2475 [(set_attr "cc" "none")
2476 (set_attr "length" "2")])
2478 (define_insn "*indirect_jump_h8300hs_advanced"
2479 [(set (pc) (match_operand:SI 0 "jump_address_operand" "Vr"))]
2480 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE"
2482 [(set_attr "cc" "none")
2483 (set_attr "length" "2")])
2485 (define_insn "*indirect_jump_h8300hs_normal"
2486 [(set (pc) (match_operand:HI 0 "jump_address_operand" "Vr"))]
2487 "(TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE"
2489 [(set_attr "cc" "none")
2490 (set_attr "length" "2")])
2492 ;; Call subroutine with no return value.
2494 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
2497 [(call (match_operand:QI 0 "call_insn_operand" "or")
2498 (match_operand:HI 1 "general_operand" "g"))]
2501 if (GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
2502 && SYMBOL_REF_FLAG (XEXP (operands[0], 0)))
2503 return "jsr\\t@%0:8";
2507 [(set_attr "type" "call")
2508 (set (attr "length")
2509 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
2513 ;; Call subroutine, returning value in operand 0
2514 ;; (which must be a hard register).
2516 ;; ??? Even though we use HImode here, this works on the H8/300H and H8S.
2518 (define_insn "call_value"
2519 [(set (match_operand 0 "" "=r")
2520 (call (match_operand:QI 1 "call_insn_operand" "or")
2521 (match_operand:HI 2 "general_operand" "g")))]
2524 if (GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
2525 && SYMBOL_REF_FLAG (XEXP (operands[1], 0)))
2526 return "jsr\\t@%1:8";
2530 [(set_attr "type" "call")
2531 (set (attr "length")
2532 (if_then_else (match_operand:QI 0 "small_call_insn_operand" "")
2540 [(set_attr "cc" "none")
2541 (set_attr "length" "2")])
2543 ;; ----------------------------------------------------------------------
2544 ;; PROLOGUE/EPILOGUE-RELATED INSTRUCTIONS
2545 ;; ----------------------------------------------------------------------
2547 (define_expand "push_h8300"
2548 [(set (mem:HI (pre_dec:HI (reg:HI SP_REG)))
2549 (match_operand:HI 0 "register_operand" ""))]
2553 (define_expand "push_h8300hs_advanced"
2554 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
2555 (match_operand:SI 0 "register_operand" ""))]
2556 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
2559 (define_expand "push_h8300hs_normal"
2560 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
2561 (match_operand:SI 0 "register_operand" ""))]
2562 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
2565 (define_expand "pop_h8300"
2566 [(set (match_operand:HI 0 "register_operand" "")
2567 (mem:HI (post_inc:HI (reg:HI SP_REG))))]
2571 (define_expand "pop_h8300hs_advanced"
2572 [(set (match_operand:SI 0 "register_operand" "")
2573 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
2574 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
2577 (define_expand "pop_h8300hs_normal"
2578 [(set (match_operand:SI 0 "register_operand" "")
2579 (mem:SI (post_inc:HI (reg:HI SP_REG))))]
2580 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
2583 (define_insn "ldm_h8300sx"
2584 [(match_parallel 0 "h8300_ldm_parallel"
2585 [(set (match_operand:SI 1 "register_operand" "")
2586 (match_operand:SI 2 "memory_operand" ""))])]
2589 operands[3] = SET_DEST (XVECEXP (operands[0], 0,
2590 XVECLEN (operands[0], 0) - 2));
2591 return "ldm.l\t@er7+,%S1-%S3";
2593 [(set_attr "cc" "none")
2594 (set_attr "length" "4")])
2596 (define_insn "stm_h8300sx"
2597 [(match_parallel 0 "h8300_stm_parallel"
2598 [(set (match_operand:SI 1 "memory_operand" "")
2599 (match_operand:SI 2 "register_operand" ""))])]
2602 operands[3] = SET_SRC (XVECEXP (operands[0], 0,
2603 XVECLEN (operands[0], 0) - 2));
2604 return "stm.l\t%S2-%S3,@-er7";
2606 [(set_attr "cc" "none")
2607 (set_attr "length" "4")])
2609 (define_insn "return_h8sx"
2610 [(match_parallel 0 "h8300_return_parallel"
2612 (set (match_operand:SI 1 "register_operand" "")
2613 (match_operand:SI 2 "memory_operand" ""))])]
2616 operands[3] = SET_DEST (XVECEXP (operands[0], 0,
2617 XVECLEN (operands[0], 0) - 2));
2618 if (h8300_current_function_interrupt_function_p ()
2619 || h8300_current_function_monitor_function_p ())
2620 return "rte/l\t%S1-%S3";
2622 return "rts/l\t%S1-%S3";
2624 [(set_attr "cc" "none")
2625 (set_attr "can_delay" "no")
2626 (set_attr "length" "2")])
2628 (define_expand "return"
2630 "h8300_can_use_return_insn_p ()"
2633 (define_insn "*return_1"
2637 if (h8300_current_function_interrupt_function_p ()
2638 || h8300_current_function_monitor_function_p ())
2643 [(set_attr "cc" "none")
2644 (set_attr "can_delay" "no")
2645 (set_attr "length" "2")])
2647 (define_expand "prologue"
2651 h8300_expand_prologue ();
2655 (define_expand "epilogue"
2659 h8300_expand_epilogue ();
2663 (define_insn "monitor_prologue"
2664 [(unspec_volatile [(const_int 0)] UNSPEC_MONITOR)]
2668 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";
2669 else if (TARGET_H8300H && TARGET_NORMAL_MODE)
2670 return "subs\\t#2,er7\;mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\\t#128,ccr";
2671 else if (TARGET_H8300H)
2672 return "mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\\t#128,ccr";
2673 else if (TARGET_H8300S && TARGET_NEXR )
2674 return "mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr";
2675 else if (TARGET_H8300S && TARGET_NEXR && TARGET_NORMAL_MODE)
2676 return "subs\\t#2,er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr";
2677 else if (TARGET_H8300S && TARGET_NORMAL_MODE)
2678 return "subs\\t#2,er7\;stc\texr,@-er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(6,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr";
2679 else if (TARGET_H8300S)
2680 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";
2683 [(set_attr "length" "20")])
2685 ;; ----------------------------------------------------------------------
2686 ;; EXTEND INSTRUCTIONS
2687 ;; ----------------------------------------------------------------------
2689 (define_expand "zero_extendqihi2"
2690 [(set (match_operand:HI 0 "register_operand" "")
2691 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2695 (define_insn "*zero_extendqihi2_h8300"
2696 [(set (match_operand:HI 0 "register_operand" "=r,r")
2697 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2702 [(set_attr "length" "2,10")])
2704 (define_insn "*zero_extendqihi2_h8300hs"
2705 [(set (match_operand:HI 0 "register_operand" "=r,r")
2706 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2707 "TARGET_H8300H || TARGET_H8300S"
2711 [(set_attr "length" "2,10")
2712 (set_attr "cc" "set_znv,set_znv")])
2714 ;; Split the zero extension of a general operand (actually a memory
2715 ;; operand) into a load of the operand and the actual zero extension
2716 ;; so that 1) the length will be accurate, and 2) the zero extensions
2717 ;; appearing at the end of basic blocks may be merged.
2720 [(set (match_operand:HI 0 "register_operand" "")
2721 (zero_extend:HI (match_operand:QI 1 "general_operand_src" "")))]
2726 (zero_extend:HI (match_dup 2)))]
2728 operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));
2731 (define_expand "zero_extendqisi2"
2732 [(set (match_operand:SI 0 "register_operand" "")
2733 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2737 operands[1] = force_reg (QImode, operands[1]);
2740 (define_insn "*zero_extendqisi2_h8300"
2741 [(set (match_operand:SI 0 "register_operand" "=r,r")
2742 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2745 mov.b #0,%x0\;sub.w %e0,%e0
2746 mov.b %R1,%w0\;mov.b #0,%x0\;sub.w %e0,%e0"
2747 [(set_attr "length" "4,8")])
2749 (define_insn "*zero_extendqisi2_h8300hs"
2750 [(set (match_operand:SI 0 "register_operand" "=r,r")
2751 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2752 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX"
2756 [(set (match_operand:SI 0 "register_operand" "")
2757 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2758 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
2759 && reg_overlap_mentioned_p (operands[0], operands[1])
2760 && reload_completed"
2764 (zero_extend:HI (match_dup 2)))
2766 (zero_extend:SI (match_dup 3)))]
2768 operands[2] = gen_lowpart (QImode, operands[0]);
2769 operands[3] = gen_lowpart (HImode, operands[0]);
2773 [(set (match_operand:SI 0 "register_operand" "")
2774 (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
2775 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX
2776 && !reg_overlap_mentioned_p (operands[0], operands[1])
2777 && reload_completed"
2780 (set (strict_low_part (match_dup 2))
2783 operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));
2786 (define_insn "*zero_extendqisi2_h8sx"
2787 [(set (match_operand:SI 0 "register_operand" "=r")
2788 (zero_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2791 [(set_attr "length" "2")
2792 (set_attr "cc" "set_znv")])
2794 (define_expand "zero_extendhisi2"
2795 [(set (match_operand:SI 0 "register_operand" "")
2796 (zero_extend:SI (match_operand:HI 1 "register_operand" "")))]
2800 ;; %e prints the high part of a CONST_INT, not the low part. Arggh.
2801 (define_insn "*zero_extendhisi2_h8300"
2802 [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2803 (zero_extend:SI (match_operand:HI 1 "general_operand_src" "0,i,g>")))]
2807 mov.w %f1,%f0\;sub.w %e0,%e0
2808 mov.w %e1,%f0\;sub.w %e0,%e0"
2809 [(set_attr "length" "2,4,6")])
2811 (define_insn "*zero_extendhisi2_h8300hs"
2812 [(set (match_operand:SI 0 "register_operand" "=r")
2813 (zero_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2814 "TARGET_H8300H || TARGET_H8300S"
2816 [(set_attr "length" "2")
2817 (set_attr "cc" "set_znv")])
2819 (define_expand "extendqihi2"
2820 [(set (match_operand:HI 0 "register_operand" "")
2821 (sign_extend:HI (match_operand:QI 1 "register_operand" "")))]
2825 (define_insn "*extendqihi2_h8300"
2826 [(set (match_operand:HI 0 "register_operand" "=r,r")
2827 (sign_extend:HI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2830 bld #7,%s0\;subx %t0,%t0
2831 mov.b %R1,%s0\;bld #7,%s0\;subx %t0,%t0"
2832 [(set_attr "length" "4,8")])
2834 (define_insn "*extendqihi2_h8300hs"
2835 [(set (match_operand:HI 0 "register_operand" "=r")
2836 (sign_extend:HI (match_operand:QI 1 "register_operand" "0")))]
2837 "TARGET_H8300H || TARGET_H8300S"
2839 [(set_attr "length" "2")
2840 (set_attr "cc" "set_znv")])
2842 (define_expand "extendqisi2"
2843 [(set (match_operand:SI 0 "register_operand" "")
2844 (sign_extend:SI (match_operand:QI 1 "register_operand" "")))]
2848 (define_insn "*extendqisi2_h8300"
2849 [(set (match_operand:SI 0 "register_operand" "=r,r")
2850 (sign_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
2853 bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0
2854 mov.b %R1,%w0\;bld #7,%w0\;subx %x0,%x0\;subx %y0,%y0\;subx %z0,%z0"
2855 [(set_attr "length" "8,12")])
2857 ;; The following pattern is needed because without the pattern, the
2858 ;; combiner would split (sign_extend:SI (reg:QI)) into two 24-bit
2859 ;; shifts, one ashift and one ashiftrt.
2861 (define_insn_and_split "*extendqisi2_h8300hs"
2862 [(set (match_operand:SI 0 "register_operand" "=r")
2863 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2864 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_H8300SX"
2866 "&& reload_completed"
2868 (sign_extend:HI (match_dup 1)))
2870 (sign_extend:SI (match_dup 2)))]
2872 operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));
2875 (define_insn "*extendqisi2_h8sx"
2876 [(set (match_operand:SI 0 "register_operand" "=r")
2877 (sign_extend:SI (match_operand:QI 1 "register_operand" "0")))]
2880 [(set_attr "length" "2")
2881 (set_attr "cc" "set_znv")])
2883 (define_expand "extendhisi2"
2884 [(set (match_operand:SI 0 "register_operand" "")
2885 (sign_extend:SI (match_operand:HI 1 "register_operand" "")))]
2889 (define_insn "*extendhisi2_h8300"
2890 [(set (match_operand:SI 0 "register_operand" "=r,r")
2891 (sign_extend:SI (match_operand:HI 1 "general_operand_src" "0,g>")))]
2894 bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0
2895 mov.w %T1,%f0\;bld #7,%x0\;subx %y0,%y0\;subx %z0,%z0"
2896 [(set_attr "length" "6,10")])
2898 (define_insn "*extendhisi2_h8300hs"
2899 [(set (match_operand:SI 0 "register_operand" "=r")
2900 (sign_extend:SI (match_operand:HI 1 "register_operand" "0")))]
2901 "TARGET_H8300H || TARGET_H8300S"
2903 [(set_attr "length" "2")
2904 (set_attr "cc" "set_znv")])
2906 ;; ----------------------------------------------------------------------
2908 ;; ----------------------------------------------------------------------
2910 ;; We make some attempt to provide real efficient shifting. One example is
2911 ;; doing an 8-bit shift of a 16-bit value by moving a byte reg into the other
2912 ;; reg and moving 0 into the former reg.
2914 ;; We also try to achieve this in a uniform way. IE: We don't try to achieve
2915 ;; this in both rtl and at insn emit time. Ideally, we'd use rtl as that would
2916 ;; give the optimizer more cracks at the code. However, we wish to do things
2917 ;; like optimizing shifting the sign bit to bit 0 by rotating the other way.
2918 ;; There is rtl to handle this (rotate + and), but the H8/300 doesn't handle
2919 ;; 16-bit rotates. Also, if we emit complicated rtl, combine may not be able
2920 ;; to detect cases it can optimize.
2922 ;; For these and other fuzzy reasons, I've decided to go the less pretty but
2923 ;; easier "do it at insn emit time" route.
2927 (define_expand "ashlqi3"
2928 [(set (match_operand:QI 0 "register_operand" "")
2929 (ashift:QI (match_operand:QI 1 "register_operand" "")
2930 (match_operand:QI 2 "nonmemory_operand" "")))]
2933 if (expand_a_shift (QImode, ASHIFT, operands))
2937 (define_expand "ashrqi3"
2938 [(set (match_operand:QI 0 "register_operand" "")
2939 (ashiftrt:QI (match_operand:QI 1 "register_operand" "")
2940 (match_operand:QI 2 "nonmemory_operand" "")))]
2943 if (expand_a_shift (QImode, ASHIFTRT, operands))
2947 (define_expand "lshrqi3"
2948 [(set (match_operand:QI 0 "register_operand" "")
2949 (lshiftrt:QI (match_operand:QI 1 "register_operand" "")
2950 (match_operand:QI 2 "nonmemory_operand" "")))]
2953 if (expand_a_shift (QImode, LSHIFTRT, operands))
2958 [(set (match_operand:QI 0 "h8300_dst_operand" "=rQ")
2959 (match_operator:QI 3 "h8sx_unary_shift_operator"
2960 [(match_operand:QI 1 "h8300_dst_operand" "0")
2961 (match_operand:QI 2 "const_int_operand" "")]))]
2962 "h8300_operands_match_p (operands)"
2964 return output_h8sx_shift (operands, 'b', 'X');
2966 [(set_attr "length_table" "unary")
2967 (set_attr "cc" "set_znv")])
2970 [(set (match_operand:QI 0 "register_operand" "=r")
2971 (match_operator:QI 3 "h8sx_binary_shift_operator"
2972 [(match_operand:QI 1 "register_operand" "0")
2973 (match_operand:QI 2 "nonmemory_operand" "r P3>X")]))]
2976 return output_h8sx_shift (operands, 'b', 'X');
2978 [(set_attr "length" "4")
2979 (set_attr "cc" "set_znv")])
2981 (define_insn "*shiftqi"
2982 [(set (match_operand:QI 0 "register_operand" "=r,r")
2983 (match_operator:QI 3 "nshift_operator"
2984 [(match_operand:QI 1 "register_operand" "0,0")
2985 (match_operand:QI 2 "nonmemory_operand" "R,rn")]))
2986 (clobber (match_scratch:QI 4 "=X,&r"))]
2989 return output_a_shift (operands);
2991 [(set (attr "length")
2992 (symbol_ref "compute_a_shift_length (insn, operands)"))
2994 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
2998 (define_expand "ashlhi3"
2999 [(set (match_operand:HI 0 "register_operand" "")
3000 (ashift:HI (match_operand:HI 1 "register_operand" "")
3001 (match_operand:QI 2 "nonmemory_operand" "")))]
3004 if (expand_a_shift (HImode, ASHIFT, operands))
3008 (define_expand "lshrhi3"
3009 [(set (match_operand:HI 0 "register_operand" "")
3010 (lshiftrt:HI (match_operand:HI 1 "register_operand" "")
3011 (match_operand:QI 2 "nonmemory_operand" "")))]
3014 if (expand_a_shift (HImode, LSHIFTRT, operands))
3018 (define_expand "ashrhi3"
3019 [(set (match_operand:HI 0 "register_operand" "")
3020 (ashiftrt:HI (match_operand:HI 1 "register_operand" "")
3021 (match_operand:QI 2 "nonmemory_operand" "")))]
3024 if (expand_a_shift (HImode, ASHIFTRT, operands))
3029 [(set (match_operand:HI 0 "h8300_dst_operand" "=rQ")
3030 (match_operator:HI 3 "h8sx_unary_shift_operator"
3031 [(match_operand:HI 1 "h8300_dst_operand" "0")
3032 (match_operand:QI 2 "const_int_operand" "")]))]
3033 "h8300_operands_match_p (operands)"
3035 return output_h8sx_shift (operands, 'w', 'T');
3037 [(set_attr "length_table" "unary")
3038 (set_attr "cc" "set_znv")])
3041 [(set (match_operand:HI 0 "register_operand" "=r")
3042 (match_operator:HI 3 "h8sx_binary_shift_operator"
3043 [(match_operand:HI 1 "register_operand" "0")
3044 (match_operand:QI 2 "nonmemory_operand" "r P4>X")]))]
3047 return output_h8sx_shift (operands, 'w', 'T');
3049 [(set_attr "length" "4")
3050 (set_attr "cc" "set_znv")])
3052 (define_insn "*shifthi"
3053 [(set (match_operand:HI 0 "register_operand" "=r,r")
3054 (match_operator:HI 3 "nshift_operator"
3055 [(match_operand:HI 1 "register_operand" "0,0")
3056 (match_operand:QI 2 "nonmemory_operand" "S,rn")]))
3057 (clobber (match_scratch:QI 4 "=X,&r"))]
3060 return output_a_shift (operands);
3062 [(set (attr "length")
3063 (symbol_ref "compute_a_shift_length (insn, operands)"))
3065 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
3069 (define_expand "ashlsi3"
3070 [(set (match_operand:SI 0 "register_operand" "")
3071 (ashift:SI (match_operand:SI 1 "register_operand" "")
3072 (match_operand:QI 2 "nonmemory_operand" "")))]
3075 if (expand_a_shift (SImode, ASHIFT, operands))
3079 (define_expand "lshrsi3"
3080 [(set (match_operand:SI 0 "register_operand" "")
3081 (lshiftrt:SI (match_operand:SI 1 "register_operand" "")
3082 (match_operand:QI 2 "nonmemory_operand" "")))]
3085 if (expand_a_shift (SImode, LSHIFTRT, operands))
3089 (define_expand "ashrsi3"
3090 [(set (match_operand:SI 0 "register_operand" "")
3091 (ashiftrt:SI (match_operand:SI 1 "register_operand" "")
3092 (match_operand:QI 2 "nonmemory_operand" "")))]
3095 if (expand_a_shift (SImode, ASHIFTRT, operands))
3100 [(set (match_operand:SI 0 "h8300_dst_operand" "=rQ")
3101 (match_operator:SI 3 "h8sx_unary_shift_operator"
3102 [(match_operand:SI 1 "h8300_dst_operand" "0")
3103 (match_operand:QI 2 "const_int_operand" "")]))]
3104 "h8300_operands_match_p (operands)"
3106 return output_h8sx_shift (operands, 'l', 'S');
3108 [(set_attr "length_table" "unary")
3109 (set_attr "cc" "set_znv")])
3112 [(set (match_operand:SI 0 "register_operand" "=r")
3113 (match_operator:SI 3 "h8sx_binary_shift_operator"
3114 [(match_operand:SI 1 "register_operand" "0")
3115 (match_operand:QI 2 "nonmemory_operand" "r P5>X")]))]
3118 return output_h8sx_shift (operands, 'l', 'S');
3120 [(set_attr "length" "4")
3121 (set_attr "cc" "set_znv")])
3123 (define_insn "*shiftsi"
3124 [(set (match_operand:SI 0 "register_operand" "=r,r")
3125 (match_operator:SI 3 "nshift_operator"
3126 [(match_operand:SI 1 "register_operand" "0,0")
3127 (match_operand:QI 2 "nonmemory_operand" "T,rn")]))
3128 (clobber (match_scratch:QI 4 "=X,&r"))]
3131 return output_a_shift (operands);
3133 [(set (attr "length")
3134 (symbol_ref "compute_a_shift_length (insn, operands)"))
3136 (symbol_ref "compute_a_shift_cc (insn, operands)"))])
3138 ;; Split a variable shift into a loop. If the register containing
3139 ;; the shift count dies, then we just use that register.
3142 [(set (match_operand 0 "register_operand" "")
3143 (match_operator 2 "nshift_operator"
3145 (match_operand:QI 1 "register_operand" "")]))
3146 (clobber (match_operand:QI 3 "register_operand" ""))]
3148 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
3149 [(set (cc0) (compare (match_dup 1) (const_int 0)))
3151 (if_then_else (le (cc0) (const_int 0))
3152 (label_ref (match_dup 5))
3157 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
3158 (clobber (scratch:QI))])
3159 (set (match_dup 1) (plus:QI (match_dup 1) (const_int -1)))
3160 (set (cc0) (compare (match_dup 1) (const_int 0)))
3162 (if_then_else (ne (cc0) (const_int 0))
3163 (label_ref (match_dup 4))
3167 operands[4] = gen_label_rtx ();
3168 operands[5] = gen_label_rtx ();
3172 [(set (match_operand 0 "register_operand" "")
3173 (match_operator 2 "nshift_operator"
3175 (match_operand:QI 1 "register_operand" "")]))
3176 (clobber (match_operand:QI 3 "register_operand" ""))]
3178 && !find_regno_note (insn, REG_DEAD, REGNO (operands[1]))"
3181 (set (cc0) (compare (match_dup 3) (const_int 0)))
3183 (if_then_else (le (cc0) (const_int 0))
3184 (label_ref (match_dup 5))
3189 (match_op_dup 2 [(match_dup 0) (const_int 1)]))
3190 (clobber (scratch:QI))])
3191 (set (match_dup 3) (plus:QI (match_dup 3) (const_int -1)))
3192 (set (cc0) (compare (match_dup 3) (const_int 0)))
3194 (if_then_else (ne (cc0) (const_int 0))
3195 (label_ref (match_dup 4))
3199 operands[4] = gen_label_rtx ();
3200 operands[5] = gen_label_rtx ();
3203 ;; ----------------------------------------------------------------------
3205 ;; ----------------------------------------------------------------------
3207 (define_expand "rotlqi3"
3208 [(set (match_operand:QI 0 "register_operand" "")
3209 (rotate:QI (match_operand:QI 1 "register_operand" "")
3210 (match_operand:QI 2 "nonmemory_operand" "")))]
3213 if (expand_a_rotate (operands))
3217 (define_insn "rotlqi3_1"
3218 [(set (match_operand:QI 0 "register_operand" "=r")
3219 (rotate:QI (match_operand:QI 1 "register_operand" "0")
3220 (match_operand:QI 2 "immediate_operand" "")))]
3223 return output_a_rotate (ROTATE, operands);
3225 [(set (attr "length")
3226 (symbol_ref "compute_a_rotate_length (operands)"))])
3228 (define_expand "rotlhi3"
3229 [(set (match_operand:HI 0 "register_operand" "")
3230 (rotate:HI (match_operand:HI 1 "register_operand" "")
3231 (match_operand:QI 2 "nonmemory_operand" "")))]
3234 if (expand_a_rotate (operands))
3238 (define_insn "rotlhi3_1"
3239 [(set (match_operand:HI 0 "register_operand" "=r")
3240 (rotate:HI (match_operand:HI 1 "register_operand" "0")
3241 (match_operand:QI 2 "immediate_operand" "")))]
3244 return output_a_rotate (ROTATE, operands);
3246 [(set (attr "length")
3247 (symbol_ref "compute_a_rotate_length (operands)"))])
3249 (define_expand "rotlsi3"
3250 [(set (match_operand:SI 0 "register_operand" "")
3251 (rotate:SI (match_operand:SI 1 "register_operand" "")
3252 (match_operand:QI 2 "nonmemory_operand" "")))]
3253 "TARGET_H8300H || TARGET_H8300S"
3255 if (expand_a_rotate (operands))
3259 (define_insn "rotlsi3_1"
3260 [(set (match_operand:SI 0 "register_operand" "=r")
3261 (rotate:SI (match_operand:SI 1 "register_operand" "0")
3262 (match_operand:QI 2 "immediate_operand" "")))]
3263 "TARGET_H8300H || TARGET_H8300S"
3265 return output_a_rotate (ROTATE, operands);
3267 [(set (attr "length")
3268 (symbol_ref "compute_a_rotate_length (operands)"))])
3270 ;; -----------------------------------------------------------------
3272 ;; -----------------------------------------------------------------
3273 ;; The H8/300 has given 1/8th of its opcode space to bitfield
3274 ;; instructions so let's use them as well as we can.
3276 ;; You'll never believe all these patterns perform one basic action --
3277 ;; load a bit from the source, optionally invert the bit, then store it
3278 ;; in the destination (which is known to be zero).
3280 ;; Combine obviously need some work to better identify this situation and
3281 ;; canonicalize the form better.
3284 ;; Normal loads with a 16bit destination.
3288 [(set (match_operand:HI 0 "register_operand" "=&r")
3289 (zero_extract:HI (match_operand:HI 1 "register_operand" "r")
3291 (match_operand:HI 2 "immediate_operand" "n")))]
3293 "sub.w %0,%0\;bld %Z2,%Y1\;bst #0,%X0"
3294 [(set_attr "length" "6")])
3297 ;; Inverted loads with a 16bit destination.
3301 [(set (match_operand:HI 0 "register_operand" "=&r")
3302 (zero_extract:HI (xor:HI (match_operand:HI 1 "register_operand" "r")
3303 (match_operand:HI 3 "const_int_operand" "n"))
3305 (match_operand:HI 2 "const_int_operand" "n")))]
3306 "(TARGET_H8300 || TARGET_H8300SX)
3307 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
3308 "sub.w %0,%0\;bild %Z2,%Y1\;bst #0,%X0"
3309 [(set_attr "length" "8")])
3312 ;; Normal loads with a 32bit destination.
3315 (define_insn "*extzv_1_r_h8300"
3316 [(set (match_operand:SI 0 "register_operand" "=&r")
3317 (zero_extract:SI (match_operand:HI 1 "register_operand" "r")
3319 (match_operand 2 "const_int_operand" "n")))]
3320 "TARGET_H8300 && INTVAL (operands[2]) < 16"
3322 return output_simode_bld (0, operands);
3324 [(set_attr "length" "8")])
3326 (define_insn "*extzv_1_r_h8300hs"
3327 [(set (match_operand:SI 0 "register_operand" "=r,r")
3328 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
3330 (match_operand 2 "const_int_operand" "n,n")))]
3331 "(TARGET_H8300H || TARGET_H8300S) && INTVAL (operands[2]) < 16"
3333 return output_simode_bld (0, operands);
3335 [(set_attr "cc" "set_znv,set_znv")
3336 (set_attr "length" "8,6")])
3339 ;; Inverted loads with a 32bit destination.
3342 (define_insn "*extzv_1_r_inv_h8300"
3343 [(set (match_operand:SI 0 "register_operand" "=&r")
3344 (zero_extract:SI (xor:HI (match_operand:HI 1 "register_operand" "r")
3345 (match_operand:HI 3 "const_int_operand" "n"))
3347 (match_operand 2 "const_int_operand" "n")))]
3348 "TARGET_H8300 && INTVAL (operands[2]) < 16
3349 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
3351 return output_simode_bld (1, operands);
3353 [(set_attr "length" "8")])
3355 (define_insn "*extzv_1_r_inv_h8300hs"
3356 [(set (match_operand:SI 0 "register_operand" "=r,r")
3357 (zero_extract:SI (xor:SI (match_operand:SI 1 "register_operand" "?0,r")
3358 (match_operand 3 "const_int_operand" "n,n"))
3360 (match_operand 2 "const_int_operand" "n,n")))]
3361 "(TARGET_H8300H || TARGET_H8300S) && INTVAL (operands[2]) < 16
3362 && (1 << INTVAL (operands[2])) == INTVAL (operands[3])"
3364 return output_simode_bld (1, operands);
3366 [(set_attr "cc" "set_znv,set_znv")
3367 (set_attr "length" "8,6")])
3369 (define_expand "insv"
3370 [(set (zero_extract:HI (match_operand:HI 0 "general_operand" "")
3371 (match_operand:HI 1 "general_operand" "")
3372 (match_operand:HI 2 "general_operand" ""))
3373 (match_operand:HI 3 "general_operand" ""))]
3374 "TARGET_H8300 || TARGET_H8300SX"
3378 if (GET_CODE (operands[1]) == CONST_INT
3379 && GET_CODE (operands[2]) == CONST_INT
3380 && INTVAL (operands[1]) <= 8
3381 && INTVAL (operands[2]) >= 0
3382 && INTVAL (operands[1]) + INTVAL (operands[2]) <= 8
3383 && memory_operand (operands[0], GET_MODE (operands[0])))
3385 /* If the source operand is zero, it's better to use AND rather
3386 than BFST. Likewise OR if the operand is all ones. */
3387 if (GET_CODE (operands[3]) == CONST_INT)
3389 HOST_WIDE_INT mask = (1 << INTVAL (operands[1])) - 1;
3390 if ((INTVAL (operands[3]) & mask) == 0)
3392 if ((INTVAL (operands[3]) & mask) == mask)
3395 if (! bit_memory_operand (operands[0], GET_MODE (operands[0])))
3397 if (!can_create_pseudo_p ())
3399 operands[0] = replace_equiv_address (operands[0], force_reg (Pmode,
3400 XEXP (operands[0], 0)));
3402 operands[3] = gen_lowpart (QImode, operands[3]);
3405 if (! register_operand (operands[3], QImode))
3407 if (!can_create_pseudo_p ())
3409 operands[3] = force_reg (QImode, operands[3]);
3411 emit_insn (gen_bfst (adjust_address (operands[0], QImode, 0),
3412 operands[3], operands[1], operands[2]));
3418 /* We only have single bit bit-field instructions. */
3419 if (INTVAL (operands[1]) != 1)
3422 /* For now, we don't allow memory operands. */
3423 if (GET_CODE (operands[0]) == MEM
3424 || GET_CODE (operands[3]) == MEM)
3427 if (GET_CODE (operands[3]) != REG)
3428 operands[3] = force_reg (HImode, operands[3]);
3432 [(set (zero_extract:HI (match_operand:HI 0 "register_operand" "+r")
3434 (match_operand:HI 1 "immediate_operand" "n"))
3435 (match_operand:HI 2 "register_operand" "r"))]
3437 "bld #0,%R2\;bst %Z1,%Y0 ; i1"
3438 [(set_attr "length" "4")])
3440 (define_expand "extzv"
3441 [(set (match_operand:HI 0 "register_operand" "")
3442 (zero_extract:HI (match_operand:HI 1 "bit_operand" "")
3443 (match_operand:HI 2 "general_operand" "")
3444 (match_operand:HI 3 "general_operand" "")))]
3445 "TARGET_H8300 || TARGET_H8300SX"
3449 if (GET_CODE (operands[2]) == CONST_INT
3450 && GET_CODE (operands[3]) == CONST_INT
3451 && INTVAL (operands[2]) <= 8
3452 && INTVAL (operands[3]) >= 0
3453 && INTVAL (operands[2]) + INTVAL (operands[3]) <= 8
3454 && memory_operand (operands[1], QImode))
3458 /* Optimize the case where we're extracting into a paradoxical
3459 subreg. It's only necessary to extend to the inner reg. */
3460 if (GET_CODE (operands[0]) == SUBREG
3461 && subreg_lowpart_p (operands[0])
3462 && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0])))
3463 < GET_MODE_SIZE (GET_MODE (operands[0])))
3464 && (GET_MODE_CLASS (GET_MODE (SUBREG_REG (operands[0])))
3466 operands[0] = SUBREG_REG (operands[0]);
3468 if (!can_create_pseudo_p ())
3469 temp = gen_lowpart (QImode, operands[0]);
3471 temp = gen_reg_rtx (QImode);
3474 if (! bit_memory_operand (operands[1], QImode))
3476 if (!can_create_pseudo_p ())
3478 operands[1] = replace_equiv_address (operands[1],
3479 force_reg (Pmode, XEXP (operands[1], 0)));
3481 emit_insn (gen_bfld (temp, operands[1], operands[2], operands[3]));
3482 convert_move (operands[0], temp, 1);
3488 /* We only have single bit bit-field instructions. */
3489 if (INTVAL (operands[2]) != 1)
3492 /* For now, we don't allow memory operands. */
3493 if (GET_CODE (operands[1]) == MEM)
3497 ;; BAND, BOR, and BXOR patterns
3500 [(set (match_operand:HI 0 "bit_operand" "=Ur")
3501 (match_operator:HI 4 "bit_operator"
3502 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
3504 (match_operand:HI 2 "immediate_operand" "n"))
3505 (match_operand:HI 3 "bit_operand" "0")]))]
3507 "bld %Z2,%Y1\;b%c4 #0,%R0\;bst #0,%R0; bl1"
3508 [(set_attr "length" "6")])
3511 [(set (match_operand:HI 0 "bit_operand" "=Ur")
3512 (match_operator:HI 5 "bit_operator"
3513 [(zero_extract:HI (match_operand:HI 1 "register_operand" "r")
3515 (match_operand:HI 2 "immediate_operand" "n"))
3516 (zero_extract:HI (match_operand:HI 3 "register_operand" "r")
3518 (match_operand:HI 4 "immediate_operand" "n"))]))]
3520 "bld %Z2,%Y1\;b%c5 %Z4,%Y3\;bst #0,%R0; bl3"
3521 [(set_attr "length" "6")])
3524 [(set (match_operand:QI 0 "register_operand" "=r")
3525 (zero_extract:QI (match_operand:QI 1 "bit_memory_operand" "WU")
3526 (match_operand:QI 2 "immediate_operand" "n")
3527 (match_operand:QI 3 "immediate_operand" "n")))]
3528 "TARGET_H8300SX && INTVAL (operands[2]) + INTVAL (operands[3]) <= 8"
3530 operands[2] = GEN_INT ((1 << (INTVAL (operands[2]) + INTVAL (operands[3])))
3531 - (1 << INTVAL (operands[3])));
3532 return "bfld %2,%1,%R0";
3534 [(set_attr "cc" "none_0hit")
3535 (set_attr "length_table" "bitfield")])
3538 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU")
3539 (match_operand:QI 2 "immediate_operand" "n")
3540 (match_operand:QI 3 "immediate_operand" "n"))
3541 (match_operand:QI 1 "register_operand" "r"))]
3542 "TARGET_H8300SX && INTVAL (operands[2]) + INTVAL (operands[3]) <= 8"
3544 operands[2] = GEN_INT ((1 << (INTVAL (operands[2]) + INTVAL (operands[3])))
3545 - (1 << INTVAL (operands[3])));
3546 return "bfst %R1,%2,%0";
3548 [(set_attr "cc" "none_0hit")
3549 (set_attr "length_table" "bitfield")])
3551 (define_expand "cstoreqi4"
3552 [(use (match_operator 1 "eqne_operator"
3553 [(match_operand:QI 2 "h8300_dst_operand" "")
3554 (match_operand:QI 3 "h8300_src_operand" "")]))
3555 (clobber (match_operand:HI 0 "register_operand"))]
3558 h8300_expand_store (operands);
3562 (define_expand "cstorehi4"
3563 [(use (match_operator 1 "eqne_operator"
3564 [(match_operand:HI 2 "h8300_dst_operand" "")
3565 (match_operand:HI 3 "h8300_src_operand" "")]))
3566 (clobber (match_operand:HI 0 "register_operand"))]
3569 h8300_expand_store (operands);
3573 (define_expand "cstoresi4"
3574 [(use (match_operator 1 "eqne_operator"
3575 [(match_operand:SI 2 "h8300_dst_operand" "")
3576 (match_operand:SI 3 "h8300_src_operand" "")]))
3577 (clobber (match_operand:HI 0 "register_operand"))]
3580 h8300_expand_store (operands);
3584 (define_insn "*bstzhireg"
3585 [(set (match_operand:HI 0 "register_operand" "=r")
3586 (match_operator:HI 1 "eqne_operator" [(cc0) (const_int 0)]))]
3588 "mulu.w #0,%T0\;b%k1 .Lh8BR%=\;inc.w #1,%T0\\n.Lh8BR%=:"
3589 [(set_attr "cc" "clobber")])
3591 (define_insn_and_split "*cmpstz"
3592 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU,+WU")
3594 (match_operand:QI 1 "immediate_operand" "n,n"))
3595 (match_operator:QI 2 "eqne_operator"
3596 [(match_operand 3 "h8300_dst_operand" "r,rQ")
3597 (match_operand 4 "h8300_src_operand" "I,rQi")]))]
3599 && (GET_MODE (operands[3]) == GET_MODE (operands[4])
3600 || GET_CODE (operands[4]) == CONST_INT)
3601 && GET_MODE_CLASS (GET_MODE (operands[3])) == MODE_INT
3602 && GET_MODE_SIZE (GET_MODE (operands[3])) <= 4"
3605 [(set (cc0) (match_dup 5))
3606 (set (zero_extract:QI (match_dup 0) (const_int 1) (match_dup 1))
3607 (match_op_dup:QI 2 [(cc0) (const_int 0)]))]
3609 operands[5] = gen_rtx_COMPARE (VOIDmode, operands[3], operands[4]);
3611 [(set_attr "cc" "set_znv,compare")])
3613 (define_insn "*bstz"
3614 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU")
3616 (match_operand:QI 1 "immediate_operand" "n"))
3617 (eq:QI (cc0) (const_int 0)))]
3618 "TARGET_H8300SX && reload_completed"
3620 [(set_attr "cc" "none_0hit")
3621 (set_attr "length_table" "unary")])
3623 (define_insn "*bistz"
3624 [(set (zero_extract:QI (match_operand:QI 0 "bit_memory_operand" "+WU")
3626 (match_operand:QI 1 "immediate_operand" "n"))
3627 (ne:QI (cc0) (const_int 0)))]
3628 "TARGET_H8300SX && reload_completed"
3630 [(set_attr "cc" "none_0hit")
3631 (set_attr "length_table" "unary")])
3633 (define_insn_and_split "*cmpcondbset"
3634 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3635 (if_then_else:QI (match_operator 1 "eqne_operator"
3636 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3637 (match_operand 3 "h8300_src_operand" "I,rQi")])
3638 (ior:QI (match_operand:QI 4 "bit_memory_operand" "0,0")
3639 (match_operand:QI 5 "single_one_operand" "n,n"))
3644 [(set (cc0) (match_dup 6))
3646 (if_then_else:QI (match_op_dup 1 [(cc0) (const_int 0)])
3647 (ior:QI (match_dup 4) (match_dup 5))
3650 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3652 [(set_attr "cc" "set_znv,compare")])
3654 (define_insn "*condbset"
3655 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3656 (if_then_else:QI (match_operator:QI 2 "eqne_operator"
3657 [(cc0) (const_int 0)])
3658 (ior:QI (match_operand:QI 3 "bit_memory_operand" "0")
3659 (match_operand:QI 1 "single_one_operand" "n"))
3661 "TARGET_H8300SX && reload_completed"
3663 [(set_attr "cc" "none_0hit")
3664 (set_attr "length_table" "logicb")])
3666 (define_insn_and_split "*cmpcondbclr"
3667 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3668 (if_then_else:QI (match_operator 1 "eqne_operator"
3669 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3670 (match_operand 3 "h8300_src_operand" "I,rQi")])
3671 (and:QI (match_operand:QI 4 "bit_memory_operand" "0,0")
3672 (match_operand:QI 5 "single_zero_operand" "n,n"))
3677 [(set (cc0) (match_dup 6))
3679 (if_then_else:QI (match_op_dup 1 [(cc0) (const_int 0)])
3680 (and:QI (match_dup 4) (match_dup 5))
3683 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3685 [(set_attr "cc" "set_znv,compare")])
3687 (define_insn "*condbclr"
3688 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3689 (if_then_else:QI (match_operator:QI 2 "eqne_operator"
3690 [(cc0) (const_int 0)])
3691 (and:QI (match_operand:QI 3 "bit_memory_operand" "0")
3692 (match_operand:QI 1 "single_zero_operand" "n"))
3694 "TARGET_H8300SX && reload_completed"
3696 [(set_attr "cc" "none_0hit")
3697 (set_attr "length_table" "logicb")])
3699 (define_insn_and_split "*cmpcondbsetreg"
3700 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3701 (if_then_else:QI (match_operator 1 "eqne_operator"
3702 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3703 (match_operand 3 "h8300_src_operand" "I,rQi")])
3704 (ior:QI (match_operand:QI 4 "bit_memory_operand" "0,0")
3705 (ashift:QI (const_int 1)
3706 (match_operand:QI 5 "register_operand" "r,r")))
3711 [(set (cc0) (match_dup 6))
3713 (if_then_else:QI (match_op_dup 1 [(cc0) (const_int 0)])
3714 (ior:QI (match_dup 4)
3715 (ashift:QI (const_int 1)
3716 (match_operand:QI 5 "register_operand" "r,r")))
3719 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3721 [(set_attr "cc" "set_znv,compare")])
3723 (define_insn "*condbsetreg"
3724 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3725 (if_then_else:QI (match_operator:QI 2 "eqne_operator"
3726 [(cc0) (const_int 0)])
3727 (ior:QI (match_operand:QI 3 "bit_memory_operand" "0")
3728 (ashift:QI (const_int 1)
3729 (match_operand:QI 1 "register_operand" "r")))
3731 "TARGET_H8300SX && reload_completed"
3733 [(set_attr "cc" "none_0hit")
3734 (set_attr "length_table" "logicb")])
3736 (define_insn_and_split "*cmpcondbclrreg"
3737 [(set (match_operand:QI 0 "nonimmediate_operand" "=WU,WU")
3738 (if_then_else:QI (match_operator 1 "eqne_operator"
3739 [(match_operand 2 "h8300_dst_operand" "r,rQ")
3740 (match_operand 3 "h8300_src_operand" "I,rQi")])
3741 (and:QI (match_operand:QI 4 "bit_memory_operand" "0,0")
3742 (ashift:QI (const_int 1)
3743 (match_operand:QI 5 "register_operand" "r,r")))
3748 [(set (cc0) (match_dup 6))
3750 (if_then_else:QI (match_op_dup 1 [(cc0) (const_int 0)])
3751 (and:QI (match_dup 4)
3752 (ashift:QI (const_int 1)
3753 (match_operand:QI 5 "register_operand" "r,r")))
3756 operands[6] = gen_rtx_COMPARE (VOIDmode, operands[2], operands[3]);
3758 [(set_attr "cc" "set_znv,compare")])
3760 (define_insn "*condbclrreg"
3761 [(set (match_operand:QI 0 "bit_memory_operand" "=WU")
3762 (if_then_else:QI (match_operator:QI 2 "eqne_operator"
3763 [(cc0) (const_int 0)])
3764 (and:QI (match_operand:QI 3 "bit_memory_operand" "0")
3765 (ashift:QI (const_int 1)
3766 (match_operand:QI 1 "register_operand" "r")))
3768 "TARGET_H8300SX && reload_completed"
3770 [(set_attr "cc" "none_0hit")
3771 (set_attr "length_table" "logicb")])
3774 ;; -----------------------------------------------------------------
3776 ;; -----------------------------------------------------------------
3780 (define_insn "*insv_si_1_n"
3781 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3783 (match_operand:SI 1 "const_int_operand" "n"))
3784 (match_operand:SI 2 "register_operand" "r"))]
3785 "(TARGET_H8300H || TARGET_H8300S) && INTVAL (operands[1]) < 16"
3786 "bld\\t#0,%w2\;bst\\t%Z1,%Y0"
3787 [(set_attr "length" "4")])
3789 (define_insn "*insv_si_1_n_lshiftrt"
3790 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3792 (match_operand:SI 1 "const_int_operand" "n"))
3793 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3794 (match_operand:SI 3 "const_int_operand" "n")))]
3795 "(TARGET_H8300H || TARGET_H8300S)
3796 && INTVAL (operands[1]) < 16
3797 && INTVAL (operands[3]) < 16"
3798 "bld\\t%Z3,%Y2\;bst\\t%Z1,%Y0"
3799 [(set_attr "length" "4")])
3801 (define_insn "*insv_si_1_n_lshiftrt_16"
3802 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3804 (match_operand:SI 1 "const_int_operand" "n"))
3805 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
3807 "(TARGET_H8300H || TARGET_H8300S) && INTVAL (operands[1]) < 16"
3808 "rotr.w\\t%e2\;rotl.w\\t%e2\;bst\\t%Z1,%Y0"
3809 [(set_attr "length" "6")])
3811 (define_insn "*insv_si_8_8"
3812 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3815 (match_operand:SI 1 "register_operand" "r"))]
3816 "TARGET_H8300H || TARGET_H8300S"
3818 [(set_attr "length" "2")])
3820 (define_insn "*insv_si_8_8_lshiftrt_8"
3821 [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
3824 (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3826 "TARGET_H8300H || TARGET_H8300S"
3828 [(set_attr "length" "2")])
3832 (define_insn "*extzv_8_8"
3833 [(set (match_operand:SI 0 "register_operand" "=r,r")
3834 (zero_extract:SI (match_operand:SI 1 "register_operand" "?0,r")
3837 "TARGET_H8300H || TARGET_H8300S"
3839 mov.b\\t%x1,%w0\;extu.w\\t%f0\;extu.l\\t%S0
3840 sub.l\\t%S0,%S0\;mov.b\\t%x1,%w0"
3841 [(set_attr "cc" "set_znv,clobber")
3842 (set_attr "length" "6,4")])
3844 (define_insn "*extzv_8_16"
3845 [(set (match_operand:SI 0 "register_operand" "=r")
3846 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3849 "TARGET_H8300H || TARGET_H8300S"
3850 "mov.w\\t%e1,%f0\;extu.w\\t%f0\;extu.l\\t%S0"
3851 [(set_attr "cc" "set_znv")
3852 (set_attr "length" "6")])
3854 (define_insn "*extzv_16_8"
3855 [(set (match_operand:SI 0 "register_operand" "=r")
3856 (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
3859 (clobber (match_scratch:SI 2 "=&r"))]
3861 "mov.w\\t%e1,%f2\;mov.b\\t%x1,%w0\;mov.b\\t%w2,%x0\;extu.l\\t%S0"
3862 [(set_attr "length" "8")
3863 (set_attr "cc" "set_znv")])
3865 ;; Extract the exponent of a float.
3867 (define_insn_and_split "*extzv_8_23"
3868 [(set (match_operand:SI 0 "register_operand" "=r")
3869 (zero_extract:SI (match_operand:SI 1 "register_operand" "0")
3872 "(TARGET_H8300H || TARGET_H8300S)"
3874 "&& reload_completed"
3875 [(parallel [(set (match_dup 0)
3876 (ashift:SI (match_dup 0)
3878 (clobber (scratch:QI))])
3879 (parallel [(set (match_dup 0)
3880 (lshiftrt:SI (match_dup 0)
3882 (clobber (scratch:QI))])]
3887 ;; ((SImode) HImode) << 15
3889 (define_insn_and_split "*twoshifts_l16_r1"
3890 [(set (match_operand:SI 0 "register_operand" "=r")
3891 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
3893 (const_int 2147450880)))]
3894 "(TARGET_H8300H || TARGET_H8300S)"
3896 "&& reload_completed"
3897 [(parallel [(set (match_dup 0)
3898 (ashift:SI (match_dup 0)
3900 (clobber (scratch:QI))])
3901 (parallel [(set (match_dup 0)
3902 (lshiftrt:SI (match_dup 0)
3904 (clobber (scratch:QI))])]
3907 ;; Transform (SImode << B) & 0xffff into (SImode) (HImode << B).
3909 (define_insn_and_split "*andsi3_ashift_n_lower"
3910 [(set (match_operand:SI 0 "register_operand" "=r,r")
3911 (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "0,0")
3912 (match_operand:QI 2 "const_int_operand" "S,n"))
3913 (match_operand:SI 3 "const_int_operand" "n,n")))
3914 (clobber (match_scratch:QI 4 "=X,&r"))]
3915 "(TARGET_H8300H || TARGET_H8300S)
3916 && INTVAL (operands[2]) <= 15
3917 && INTVAL (operands[3]) == ((-1 << INTVAL (operands[2])) & 0xffff)"
3919 "&& reload_completed"
3920 [(parallel [(set (match_dup 5)
3921 (ashift:HI (match_dup 5)
3923 (clobber (match_dup 4))])
3925 (zero_extend:SI (match_dup 5)))]
3927 operands[5] = gen_rtx_REG (HImode, REGNO (operands[0]));
3930 ;; Accept (A >> 30) & 2 and the like.
3932 (define_insn "*andsi3_lshiftrt_n_sb"
3933 [(set (match_operand:SI 0 "register_operand" "=r")
3934 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3935 (match_operand:SI 2 "const_int_operand" "n"))
3936 (match_operand:SI 3 "single_one_operand" "n")))]
3937 "(TARGET_H8300H || TARGET_H8300S)
3938 && exact_log2 (INTVAL (operands[3])) < 16
3939 && INTVAL (operands[2]) + exact_log2 (INTVAL (operands[3])) == 31"
3941 operands[3] = GEN_INT (exact_log2 (INTVAL (operands[3])));
3942 return "shll.l\\t%S0\;xor.l\\t%S0,%S0\;bst\\t%Z3,%Y0";
3944 [(set_attr "length" "8")])
3946 (define_insn_and_split "*andsi3_lshiftrt_9_sb"
3947 [(set (match_operand:SI 0 "register_operand" "=r")
3948 (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3950 (const_int 4194304)))]
3951 "TARGET_H8300H || TARGET_H8300S"
3953 "&& reload_completed"
3955 (and:SI (lshiftrt:SI (match_dup 0)
3958 (parallel [(set (match_dup 0)
3959 (ashift:SI (match_dup 0)
3961 (clobber (scratch:QI))])]
3966 (define_insn "*addsi3_upper"
3967 [(set (match_operand:SI 0 "register_operand" "=r")
3968 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
3970 (match_operand:SI 2 "register_operand" "0")))]
3971 "TARGET_H8300H || TARGET_H8300S"
3973 [(set_attr "length" "2")])
3975 (define_insn "*addsi3_lshiftrt_16_zexthi"
3976 [(set (match_operand:SI 0 "register_operand" "=r")
3977 (plus:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
3979 (zero_extend:SI (match_operand:HI 2 "register_operand" "0"))))]
3980 "TARGET_H8300H || TARGET_H8300S"
3981 "add.w\\t%e1,%f0\;xor.w\\t%e0,%e0\;rotxl.w\\t%e0"
3982 [(set_attr "length" "6")])
3984 (define_insn_and_split "*addsi3_and_r_1"
3985 [(set (match_operand:SI 0 "register_operand" "=r")
3986 (plus:SI (and:SI (match_operand:SI 1 "register_operand" "r")
3988 (match_operand:SI 2 "register_operand" "0")))]
3989 "TARGET_H8300H || TARGET_H8300S"
3991 "&& reload_completed"
3992 [(set (cc0) (compare (zero_extract:SI (match_dup 1)
3997 (if_then_else (eq (cc0)
3999 (label_ref (match_dup 3))
4002 (plus:SI (match_dup 2)
4006 operands[3] = gen_label_rtx ();
4009 (define_insn_and_split "*addsi3_and_not_r_1"
4010 [(set (match_operand:SI 0 "register_operand" "=r")
4011 (plus:SI (and:SI (not:SI (match_operand:SI 1 "register_operand" "r"))
4013 (match_operand:SI 2 "register_operand" "0")))]
4014 "TARGET_H8300H || TARGET_H8300S"
4016 "&& reload_completed"
4017 [(set (cc0) (compare (zero_extract:SI (match_dup 1)
4022 (if_then_else (ne (cc0)
4024 (label_ref (match_dup 3))
4027 (plus:SI (match_dup 2)
4031 operands[3] = gen_label_rtx ();
4036 (define_insn "*ixorhi3_zext"
4037 [(set (match_operand:HI 0 "register_operand" "=r")
4038 (match_operator:HI 1 "iorxor_operator"
4039 [(zero_extend:HI (match_operand:QI 2 "register_operand" "r"))
4040 (match_operand:HI 3 "register_operand" "0")]))]
4043 [(set_attr "length" "2")])
4047 (define_insn "*ixorsi3_zext_qi"
4048 [(set (match_operand:SI 0 "register_operand" "=r")
4049 (match_operator:SI 1 "iorxor_operator"
4050 [(zero_extend:SI (match_operand:QI 2 "register_operand" "r"))
4051 (match_operand:SI 3 "register_operand" "0")]))]
4054 [(set_attr "length" "2")])
4056 (define_insn "*ixorsi3_zext_hi"
4057 [(set (match_operand:SI 0 "register_operand" "=r")
4058 (match_operator:SI 1 "iorxor_operator"
4059 [(zero_extend:SI (match_operand:HI 2 "register_operand" "r"))
4060 (match_operand:SI 3 "register_operand" "0")]))]
4061 "TARGET_H8300H || TARGET_H8300S"
4063 [(set_attr "length" "2")])
4065 (define_insn "*ixorsi3_ashift_16"
4066 [(set (match_operand:SI 0 "register_operand" "=r")
4067 (match_operator:SI 1 "iorxor_operator"
4068 [(ashift:SI (match_operand:SI 2 "register_operand" "r")
4070 (match_operand:SI 3 "register_operand" "0")]))]
4071 "TARGET_H8300H || TARGET_H8300S"
4073 [(set_attr "length" "2")])
4075 (define_insn "*ixorsi3_lshiftrt_16"
4076 [(set (match_operand:SI 0 "register_operand" "=r")
4077 (match_operator:SI 1 "iorxor_operator"
4078 [(lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
4080 (match_operand:SI 3 "register_operand" "0")]))]
4081 "TARGET_H8300H || TARGET_H8300S"
4083 [(set_attr "length" "2")])
4087 (define_insn "*iorhi3_ashift_8"
4088 [(set (match_operand:HI 0 "register_operand" "=r")
4089 (ior:HI (ashift:HI (match_operand:HI 1 "register_operand" "r")
4091 (match_operand:HI 2 "register_operand" "0")))]
4094 [(set_attr "length" "2")])
4096 (define_insn "*iorhi3_lshiftrt_8"
4097 [(set (match_operand:HI 0 "register_operand" "=r")
4098 (ior:HI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
4100 (match_operand:HI 2 "register_operand" "0")))]
4103 [(set_attr "length" "2")])
4105 (define_insn "*iorhi3_two_qi"
4106 [(set (match_operand:HI 0 "register_operand" "=r")
4107 (ior:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
4108 (ashift:HI (match_operand:HI 2 "register_operand" "r")
4112 [(set_attr "length" "2")])
4114 (define_insn "*iorhi3_two_qi_mem"
4115 [(set (match_operand:HI 0 "register_operand" "=&r")
4116 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" "m"))
4117 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "m") 0)
4120 "mov.b\\t%X2,%t0\;mov.b\\t%X1,%s0"
4121 [(set_attr "length" "16")])
4124 [(set (match_operand:HI 0 "register_operand" "")
4125 (ior:HI (zero_extend:HI (match_operand:QI 1 "memory_operand" ""))
4126 (ashift:HI (subreg:HI (match_operand:QI 2 "memory_operand" "") 0)
4128 "(TARGET_H8300H || TARGET_H8300S)
4130 && byte_accesses_mergeable_p (XEXP (operands[2], 0), XEXP (operands[1], 0))"
4134 operands[3] = gen_rtx_MEM (HImode, XEXP (operands[2], 0));
4139 (define_insn "*iorsi3_two_hi"
4140 [(set (match_operand:SI 0 "register_operand" "=r")
4141 (ior:SI (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
4142 (ashift:SI (match_operand:SI 2 "register_operand" "r")
4144 "TARGET_H8300H || TARGET_H8300S"
4146 [(set_attr "length" "2")])
4148 (define_insn_and_split "*iorsi3_two_qi_zext"
4149 [(set (match_operand:SI 0 "register_operand" "=&r")
4150 (ior:SI (zero_extend:SI (match_operand:QI 1 "memory_operand" "m"))
4151 (and:SI (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
4153 (const_int 65280))))]
4154 "TARGET_H8300H || TARGET_H8300S"
4156 "&& reload_completed"
4158 (ior:HI (zero_extend:HI (match_dup 1))
4159 (ashift:HI (subreg:HI (match_dup 2) 0)
4162 (zero_extend:SI (match_dup 3)))]
4164 operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4167 (define_insn "*iorsi3_e2f"
4168 [(set (match_operand:SI 0 "register_operand" "=r")
4169 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
4171 (lshiftrt:SI (match_operand:SI 2 "register_operand" "r")
4173 "TARGET_H8300H || TARGET_H8300S"
4175 [(set_attr "length" "2")])
4177 (define_insn_and_split "*iorsi3_two_qi_sext"
4178 [(set (match_operand:SI 0 "register_operand" "=r")
4179 (ior:SI (zero_extend:SI (match_operand:QI 1 "register_operand" "0"))
4180 (ashift:SI (sign_extend:SI (match_operand:QI 2 "register_operand" "r"))
4182 "TARGET_H8300H || TARGET_H8300S"
4184 "&& reload_completed"
4186 (ior:HI (zero_extend:HI (match_dup 1))
4187 (ashift:HI (match_dup 4)
4190 (sign_extend:SI (match_dup 3)))]
4192 operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4193 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));
4196 (define_insn "*iorsi3_w"
4197 [(set (match_operand:SI 0 "register_operand" "=r,&r")
4198 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0,0")
4200 (zero_extend:SI (match_operand:QI 2 "general_operand_src" "r,g>"))))]
4201 "TARGET_H8300H || TARGET_H8300S"
4203 [(set_attr "length" "2,8")])
4205 (define_insn "*iorsi3_ashift_31"
4206 [(set (match_operand:SI 0 "register_operand" "=&r")
4207 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4209 (match_operand:SI 2 "register_operand" "0")))]
4210 "TARGET_H8300H || TARGET_H8300S"
4211 "rotxl.l\\t%S0\;bor\\t#0,%w1\;rotxr.l\\t%S0"
4212 [(set_attr "length" "6")
4213 (set_attr "cc" "set_znv")])
4215 (define_insn "*iorsi3_and_ashift"
4216 [(set (match_operand:SI 0 "register_operand" "=r")
4217 (ior:SI (and:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4218 (match_operand:SI 2 "const_int_operand" "n"))
4219 (match_operand:SI 3 "single_one_operand" "n"))
4220 (match_operand:SI 4 "register_operand" "0")))]
4221 "(TARGET_H8300H || TARGET_H8300S)
4222 && (INTVAL (operands[3]) & ~0xffff) == 0"
4224 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
4225 - INTVAL (operands[2]));
4226 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
4227 operands[2] = srcpos;
4228 operands[3] = dstpos;
4229 return "bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0";
4231 [(set_attr "length" "6")])
4233 (define_insn "*iorsi3_and_lshiftrt"
4234 [(set (match_operand:SI 0 "register_operand" "=r")
4235 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4236 (match_operand:SI 2 "const_int_operand" "n"))
4237 (match_operand:SI 3 "single_one_operand" "n"))
4238 (match_operand:SI 4 "register_operand" "0")))]
4239 "(TARGET_H8300H || TARGET_H8300S)
4240 && ((INTVAL (operands[3]) << INTVAL (operands[2])) & ~0xffff) == 0"
4242 rtx srcpos = GEN_INT (exact_log2 (INTVAL (operands[3]))
4243 + INTVAL (operands[2]));
4244 rtx dstpos = GEN_INT (exact_log2 (INTVAL (operands[3])));
4245 operands[2] = srcpos;
4246 operands[3] = dstpos;
4247 return "bld\\t%Z2,%Y1\;bor\\t%Z3,%Y0\;bst\\t%Z3,%Y0";
4249 [(set_attr "length" "6")])
4251 (define_insn "*iorsi3_zero_extract"
4252 [(set (match_operand:SI 0 "register_operand" "=r")
4253 (ior:SI (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
4255 (match_operand:SI 2 "const_int_operand" "n"))
4256 (match_operand:SI 3 "register_operand" "0")))]
4257 "(TARGET_H8300H || TARGET_H8300S) && INTVAL (operands[2]) < 16"
4258 "bld\\t%Z2,%Y1\;bor\\t#0,%w0\;bst\\t#0,%w0"
4259 [(set_attr "length" "6")])
4261 (define_insn "*iorsi3_and_lshiftrt_n_sb"
4262 [(set (match_operand:SI 0 "register_operand" "=r")
4263 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4266 (match_operand:SI 2 "register_operand" "0")))]
4267 "TARGET_H8300H || TARGET_H8300S"
4268 "rotl.l\\t%S1\;rotr.l\\t%S1\;bor\\t#1,%w0\;bst\\t#1,%w0"
4269 [(set_attr "length" "8")])
4271 (define_insn "*iorsi3_and_lshiftrt_9_sb"
4272 [(set (match_operand:SI 0 "register_operand" "=r")
4273 (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4275 (const_int 4194304))
4276 (match_operand:SI 2 "register_operand" "0")))
4277 (clobber (match_scratch:HI 3 "=&r"))]
4278 "TARGET_H8300H || TARGET_H8300S"
4280 if (find_regno_note (insn, REG_DEAD, REGNO (operands[1])))
4281 return "shll.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0";
4283 return "rotl.l\\t%S1\;rotr.l\\t%S1\;xor.w\\t%T3,%T3\;bst\\t#6,%s3\;or.w\\t%T3,%e0";
4285 [(set_attr "length" "10")])
4287 ;; Used to OR the exponent of a float.
4289 (define_insn "*iorsi3_shift"
4290 [(set (match_operand:SI 0 "register_operand" "=r")
4291 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r")
4293 (match_operand:SI 2 "register_operand" "0")))
4294 (clobber (match_scratch:SI 3 "=&r"))]
4295 "TARGET_H8300H || TARGET_H8300S"
4299 [(set (match_operand:SI 0 "register_operand" "")
4300 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4303 (clobber (match_operand:SI 2 "register_operand" ""))]
4304 "(TARGET_H8300H || TARGET_H8300S)
4305 && epilogue_completed
4306 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4307 && REGNO (operands[0]) != REGNO (operands[1])"
4308 [(parallel [(set (match_dup 3)
4309 (ashift:HI (match_dup 3)
4311 (clobber (scratch:QI))])
4313 (ior:SI (ashift:SI (match_dup 1)
4317 operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));
4321 [(set (match_operand:SI 0 "register_operand" "")
4322 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "")
4325 (clobber (match_operand:SI 2 "register_operand" ""))]
4326 "(TARGET_H8300H || TARGET_H8300S)
4327 && epilogue_completed
4328 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4329 && REGNO (operands[0]) != REGNO (operands[1]))"
4332 (parallel [(set (match_dup 3)
4333 (ashift:HI (match_dup 3)
4335 (clobber (scratch:QI))])
4337 (ior:SI (ashift:SI (match_dup 2)
4341 operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));
4344 (define_insn "*iorsi2_and_1_lshiftrt_1"
4345 [(set (match_operand:SI 0 "register_operand" "=r")
4346 (ior:SI (and:SI (match_operand:SI 1 "register_operand" "0")
4348 (lshiftrt:SI (match_dup 1)
4350 "TARGET_H8300H || TARGET_H8300S"
4351 "shlr.l\\t%S0\;bor\\t#0,%w0\;bst\\t#0,%w0"
4352 [(set_attr "length" "6")])
4354 (define_insn_and_split "*iorsi3_ashift_16_ashift_24"
4355 [(set (match_operand:SI 0 "register_operand" "=r")
4356 (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
4358 (ashift:SI (match_operand:SI 2 "register_operand" "r")
4360 "TARGET_H8300H || TARGET_H8300S"
4362 "&& reload_completed"
4364 (ior:HI (ashift:HI (match_dup 4)
4367 (parallel [(set (match_dup 0)
4368 (ashift:SI (match_dup 0)
4370 (clobber (scratch:QI))])]
4372 operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4373 operands[4] = gen_rtx_REG (HImode, REGNO (operands[2]));
4376 (define_insn_and_split "*iorsi3_ashift_16_ashift_24_mem"
4377 [(set (match_operand:SI 0 "register_operand" "=&r")
4378 (ior:SI (and:SI (ashift:SI (subreg:SI (match_operand:QI 1 "memory_operand" "m") 0)
4380 (const_int 16711680))
4381 (ashift:SI (subreg:SI (match_operand:QI 2 "memory_operand" "m") 0)
4383 "TARGET_H8300H || TARGET_H8300S"
4385 "&& reload_completed"
4387 (ior:HI (zero_extend:HI (match_dup 1))
4388 (ashift:HI (subreg:HI (match_dup 2) 0)
4390 (parallel [(set (match_dup 0)
4391 (ashift:SI (match_dup 0)
4393 (clobber (scratch:QI))])]
4395 operands[3] = gen_rtx_REG (HImode, REGNO (operands[0]));
4398 ;; Used to add the exponent of a float.
4400 (define_insn "*addsi3_shift"
4401 [(set (match_operand:SI 0 "register_operand" "=r")
4402 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "r")
4403 (const_int 8388608))
4404 (match_operand:SI 2 "register_operand" "0")))
4405 (clobber (match_scratch:SI 3 "=&r"))]
4406 "TARGET_H8300H || TARGET_H8300S"
4410 [(set (match_operand:SI 0 "register_operand" "")
4411 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4412 (const_int 8388608))
4414 (clobber (match_operand:SI 2 "register_operand" ""))]
4415 "(TARGET_H8300H || TARGET_H8300S)
4416 && epilogue_completed
4417 && find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4418 && REGNO (operands[0]) != REGNO (operands[1])"
4419 [(parallel [(set (match_dup 3)
4420 (ashift:HI (match_dup 3)
4422 (clobber (scratch:QI))])
4424 (plus:SI (mult:SI (match_dup 1)
4428 operands[3] = gen_rtx_REG (HImode, REGNO (operands[1]));
4432 [(set (match_operand:SI 0 "register_operand" "")
4433 (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "")
4434 (const_int 8388608))
4436 (clobber (match_operand:SI 2 "register_operand" ""))]
4437 "(TARGET_H8300H || TARGET_H8300S)
4438 && epilogue_completed
4439 && !(find_regno_note (insn, REG_DEAD, REGNO (operands[1]))
4440 && REGNO (operands[0]) != REGNO (operands[1]))"
4443 (parallel [(set (match_dup 3)
4444 (ashift:HI (match_dup 3)
4446 (clobber (scratch:QI))])
4448 (plus:SI (mult:SI (match_dup 2)
4452 operands[3] = gen_rtx_REG (HImode, REGNO (operands[2]));
4457 (define_insn_and_split "*ashiftsi_sextqi_7"
4458 [(set (match_operand:SI 0 "register_operand" "=r")
4459 (ashift:SI (sign_extend:SI (match_operand:QI 1 "register_operand" "0"))
4461 "TARGET_H8300H || TARGET_H8300S"
4463 "&& reload_completed"
4464 [(parallel [(set (match_dup 2)
4465 (ashift:HI (match_dup 2)
4467 (clobber (scratch:QI))])
4469 (sign_extend:SI (match_dup 2)))
4470 (parallel [(set (match_dup 0)
4471 (ashiftrt:SI (match_dup 0)
4473 (clobber (scratch:QI))])]
4475 operands[2] = gen_rtx_REG (HImode, REGNO (operands[0]));
4478 ;; Storing a part of HImode to QImode.
4481 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4482 (subreg:QI (lshiftrt:HI (match_operand:HI 1 "register_operand" "r")
4486 [(set_attr "cc" "set_znv")
4487 (set_attr "length" "8")])
4489 ;; Storing a part of SImode to QImode.
4492 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4493 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4497 [(set_attr "cc" "set_znv")
4498 (set_attr "length" "8")])
4501 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4502 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4504 (clobber (match_scratch:SI 2 "=&r"))]
4505 "TARGET_H8300H || TARGET_H8300S"
4506 "mov.w\\t%e1,%f2\;mov.b\\t%w2,%R0"
4507 [(set_attr "cc" "set_znv")
4508 (set_attr "length" "10")])
4511 [(set (match_operand:QI 0 "general_operand_dst" "=rm<")
4512 (subreg:QI (lshiftrt:SI (match_operand:SI 1 "register_operand" "r")
4514 (clobber (match_scratch:SI 2 "=&r"))]
4515 "TARGET_H8300H || TARGET_H8300S"
4516 "mov.w\\t%e1,%f2\;mov.b\\t%x2,%R0"
4517 [(set_attr "cc" "set_znv")
4518 (set_attr "length" "10")])
4520 (define_insn_and_split ""
4522 (if_then_else (eq (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
4526 (label_ref (match_operand 1 "" ""))
4531 [(set (cc0) (compare (match_dup 0)
4534 (if_then_else (ge (cc0)
4536 (label_ref (match_dup 1))
4540 (define_insn_and_split ""
4542 (if_then_else (ne (zero_extract:SI (subreg:SI (match_operand:QI 0 "register_operand" "") 0)
4546 (label_ref (match_operand 1 "" ""))
4551 [(set (cc0) (compare (match_dup 0)
4554 (if_then_else (lt (cc0)
4556 (label_ref (match_dup 1))
4560 ;; -----------------------------------------------------------------
4561 ;; PEEPHOLE PATTERNS
4562 ;; -----------------------------------------------------------------
4564 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
4567 [(parallel [(set (match_operand:HI 0 "register_operand" "")
4568 (lshiftrt:HI (match_dup 0)
4569 (match_operand:HI 1 "const_int_operand" "")))
4570 (clobber (match_operand:HI 2 "" ""))])
4572 (and:HI (match_dup 0)
4573 (match_operand:HI 3 "const_int_operand" "")))]
4574 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
4576 (and:HI (match_dup 0)
4578 (parallel [(set (match_dup 0)
4579 (lshiftrt:HI (match_dup 0) (match_dup 1)))
4580 (clobber (match_dup 2))])]
4583 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
4586 [(parallel [(set (match_operand:HI 0 "register_operand" "")
4587 (ashift:HI (match_dup 0)
4588 (match_operand:HI 1 "const_int_operand" "")))
4589 (clobber (match_operand:HI 2 "" ""))])
4591 (and:HI (match_dup 0)
4592 (match_operand:HI 3 "const_int_operand" "")))]
4593 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
4595 (and:HI (match_dup 0)
4597 (parallel [(set (match_dup 0)
4598 (ashift:HI (match_dup 0) (match_dup 1)))
4599 (clobber (match_dup 2))])]
4602 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
4605 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4606 (lshiftrt:SI (match_dup 0)
4607 (match_operand:SI 1 "const_int_operand" "")))
4608 (clobber (match_operand:SI 2 "" ""))])
4610 (and:SI (match_dup 0)
4611 (match_operand:SI 3 "const_int_operand" "")))]
4612 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
4614 (and:SI (match_dup 0)
4616 (parallel [(set (match_dup 0)
4617 (lshiftrt:SI (match_dup 0) (match_dup 1)))
4618 (clobber (match_dup 2))])]
4621 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
4624 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4625 (ashift:SI (match_dup 0)
4626 (match_operand:SI 1 "const_int_operand" "")))
4627 (clobber (match_operand:SI 2 "" ""))])
4629 (and:SI (match_dup 0)
4630 (match_operand:SI 3 "const_int_operand" "")))]
4631 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
4633 (and:SI (match_dup 0)
4635 (parallel [(set (match_dup 0)
4636 (ashift:SI (match_dup 0) (match_dup 1)))
4637 (clobber (match_dup 2))])]
4640 ;; Convert (A >> B) & C to (A & 65535) >> B if C == 65535 >> B.
4643 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4644 (lshiftrt:SI (match_dup 0)
4645 (match_operand:SI 1 "const_int_operand" "")))
4646 (clobber (match_operand:SI 2 "" ""))])
4648 (and:SI (match_dup 0)
4649 (match_operand:SI 3 "const_int_operand" "")))]
4650 "INTVAL (operands[3]) == (65535 >> INTVAL (operands[1]))"
4652 (and:SI (match_dup 0)
4654 (parallel [(set (match_dup 0)
4655 (lshiftrt:SI (match_dup 0) (match_dup 1)))
4656 (clobber (match_dup 2))])]
4659 ;; Convert (A << B) & C to (A & 65535) << B if C == 65535 << B.
4662 [(parallel [(set (match_operand:SI 0 "register_operand" "")
4663 (ashift:SI (match_dup 0)
4664 (match_operand:SI 1 "const_int_operand" "")))
4665 (clobber (match_operand:SI 2 "" ""))])
4667 (and:SI (match_dup 0)
4668 (match_operand:SI 3 "const_int_operand" "")))]
4669 "INTVAL (operands[3]) == (65535 << INTVAL (operands[1]))"
4671 (and:SI (match_dup 0)
4673 (parallel [(set (match_dup 0)
4674 (ashift:SI (match_dup 0) (match_dup 1)))
4675 (clobber (match_dup 2))])]
4678 ;; Convert a QImode push into an SImode push so that the
4679 ;; define_peephole2 below can cram multiple pushes into one stm.l.
4682 [(parallel [(set (reg:SI SP_REG)
4683 (plus:SI (reg:SI SP_REG) (const_int -4)))
4684 (set (mem:QI (plus:SI (reg:SI SP_REG) (const_int -3)))
4685 (match_operand:QI 0 "register_operand" ""))])]
4686 "TARGET_H8300S && !TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4687 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4690 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
4694 [(parallel [(set (reg:HI SP_REG)
4695 (plus:HI (reg:HI SP_REG) (const_int -4)))
4696 (set (mem:QI (plus:HI (reg:HI SP_REG) (const_int -3)))
4697 (match_operand:QI 0 "register_operand" ""))])]
4698 "TARGET_H8300S && TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4699 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4702 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
4705 ;; Convert a HImode push into an SImode push so that the
4706 ;; define_peephole2 below can cram multiple pushes into one stm.l.
4709 [(parallel [(set (reg:SI SP_REG)
4710 (plus:SI (reg:SI SP_REG) (const_int -4)))
4711 (set (mem:HI (plus:SI (reg:SI SP_REG) (const_int -2)))
4712 (match_operand:HI 0 "register_operand" ""))])]
4713 "TARGET_H8300S && !TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4714 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4717 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
4721 [(parallel [(set (reg:HI SP_REG)
4722 (plus:HI (reg:HI SP_REG) (const_int -4)))
4723 (set (mem:HI (plus:HI (reg:HI SP_REG) (const_int -2)))
4724 (match_operand:HI 0 "register_operand" ""))])]
4725 "TARGET_H8300S && TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
4726 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4729 operands[0] = gen_rtx_REG (SImode, REGNO (operands[0]));
4732 ;; Cram four pushes into stm.l.
4735 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4736 (match_operand:SI 0 "register_operand" ""))
4737 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4738 (match_operand:SI 1 "register_operand" ""))
4739 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4740 (match_operand:SI 2 "register_operand" ""))
4741 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4742 (match_operand:SI 3 "register_operand" ""))]
4743 "TARGET_H8300S && !TARGET_NORMAL_MODE
4744 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
4745 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4746 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4747 && REGNO (operands[3]) == REGNO (operands[0]) + 3
4748 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
4749 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4751 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4753 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
4755 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
4757 (set (reg:SI SP_REG)
4758 (plus:SI (reg:SI SP_REG)
4759 (const_int -16)))])]
4763 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4764 (match_operand:SI 0 "register_operand" ""))
4765 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4766 (match_operand:SI 1 "register_operand" ""))
4767 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4768 (match_operand:SI 2 "register_operand" ""))
4769 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4770 (match_operand:SI 3 "register_operand" ""))]
4771 "TARGET_H8300S && TARGET_NORMAL_MODE
4772 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
4773 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4774 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4775 && REGNO (operands[3]) == REGNO (operands[0]) + 3
4776 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
4777 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4779 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4781 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4783 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
4785 (set (reg:HI SP_REG)
4786 (plus:HI (reg:HI SP_REG)
4787 (const_int -16)))])]
4790 ;; Cram three pushes into stm.l.
4793 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4794 (match_operand:SI 0 "register_operand" ""))
4795 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4796 (match_operand:SI 1 "register_operand" ""))
4797 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4798 (match_operand:SI 2 "register_operand" ""))]
4799 "TARGET_H8300S && !TARGET_NORMAL_MODE
4800 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
4801 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4802 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4803 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
4804 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4806 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4808 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
4810 (set (reg:SI SP_REG)
4811 (plus:SI (reg:SI SP_REG)
4812 (const_int -12)))])]
4816 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4817 (match_operand:SI 0 "register_operand" ""))
4818 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4819 (match_operand:SI 1 "register_operand" ""))
4820 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4821 (match_operand:SI 2 "register_operand" ""))]
4822 "TARGET_H8300S && TARGET_NORMAL_MODE
4823 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
4824 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4825 && REGNO (operands[2]) == REGNO (operands[0]) + 2
4826 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
4827 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4829 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4831 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
4833 (set (reg:HI SP_REG)
4834 (plus:HI (reg:HI SP_REG)
4835 (const_int -12)))])]
4838 ;; Cram two pushes into stm.l.
4841 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4842 (match_operand:SI 0 "register_operand" ""))
4843 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
4844 (match_operand:SI 1 "register_operand" ""))]
4845 "TARGET_H8300S && !TARGET_NORMAL_MODE
4846 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
4847 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4848 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
4849 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
4851 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
4853 (set (reg:SI SP_REG)
4854 (plus:SI (reg:SI SP_REG)
4859 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4860 (match_operand:SI 0 "register_operand" ""))
4861 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
4862 (match_operand:SI 1 "register_operand" ""))]
4863 "TARGET_H8300S && TARGET_NORMAL_MODE
4864 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
4865 && REGNO (operands[1]) == REGNO (operands[0]) + 1
4866 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
4867 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
4869 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
4871 (set (reg:HI SP_REG)
4872 (plus:HI (reg:HI SP_REG)
4879 ;; add.w r7,r0 (6 bytes)
4884 ;; adds #2,r0 (4 bytes)
4887 [(set (match_operand:HI 0 "register_operand" "")
4888 (match_operand:HI 1 "const_int_operand" ""))
4890 (plus:HI (match_dup 0)
4891 (match_operand:HI 2 "register_operand" "")))]
4892 "REG_P (operands[0]) && REG_P (operands[2])
4893 && REGNO (operands[0]) != REGNO (operands[2])
4894 && (satisfies_constraint_J (operands[1])
4895 || satisfies_constraint_L (operands[1])
4896 || satisfies_constraint_N (operands[1]))"
4900 (plus:HI (match_dup 0)
4908 ;; add.l er7,er0 (6 bytes)
4913 ;; adds #4,er0 (4 bytes)
4916 [(set (match_operand:SI 0 "register_operand" "")
4917 (match_operand:SI 1 "const_int_operand" ""))
4919 (plus:SI (match_dup 0)
4920 (match_operand:SI 2 "register_operand" "")))]
4921 "(TARGET_H8300H || TARGET_H8300S)
4922 && REG_P (operands[0]) && REG_P (operands[2])
4923 && REGNO (operands[0]) != REGNO (operands[2])
4924 && (satisfies_constraint_L (operands[1])
4925 || satisfies_constraint_N (operands[1]))"
4929 (plus:SI (match_dup 0)
4936 ;; add.l #10,er0 (takes 8 bytes)
4942 ;; add.l er7,er0 (takes 6 bytes)
4945 [(set (match_operand:SI 0 "register_operand" "")
4946 (match_operand:SI 1 "register_operand" ""))
4948 (plus:SI (match_dup 0)
4949 (match_operand:SI 2 "const_int_operand" "")))]
4950 "(TARGET_H8300H || TARGET_H8300S)
4951 && REG_P (operands[0]) && REG_P (operands[1])
4952 && REGNO (operands[0]) != REGNO (operands[1])
4953 && !satisfies_constraint_L (operands[2])
4954 && !satisfies_constraint_N (operands[2])
4955 && ((INTVAL (operands[2]) & 0xff) == INTVAL (operands[2])
4956 || (INTVAL (operands[2]) & 0xff00) == INTVAL (operands[2])
4957 || INTVAL (operands[2]) == 0xffff
4958 || INTVAL (operands[2]) == 0xfffe)"
4962 (plus:SI (match_dup 0)
4978 [(set (match_operand:HI 0 "register_operand" "")
4979 (plus:HI (match_dup 0)
4980 (match_operand 1 "incdec_operand" "")))
4981 (set (cc0) (compare (match_dup 0)
4984 (if_then_else (match_operator 3 "eqne_operator"
4985 [(cc0) (const_int 0)])
4986 (label_ref (match_operand 2 "" ""))
4988 "TARGET_H8300H || TARGET_H8300S"
4989 [(set (match_operand:HI 0 "register_operand" "")
4990 (unspec:HI [(match_dup 0)
4993 (set (cc0) (compare (match_dup 0)
4996 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
4997 (label_ref (match_dup 2))
5001 ;; The SImode version of the previous pattern.
5004 [(set (match_operand:SI 0 "register_operand" "")
5005 (plus:SI (match_dup 0)
5006 (match_operand 1 "incdec_operand" "")))
5007 (set (cc0) (compare (match_dup 0)
5010 (if_then_else (match_operator 3 "eqne_operator"
5011 [(cc0) (const_int 0)])
5012 (label_ref (match_operand 2 "" ""))
5014 "TARGET_H8300H || TARGET_H8300S"
5015 [(set (match_operand:SI 0 "register_operand" "")
5016 (unspec:SI [(match_dup 0)
5019 (set (cc0) (compare (match_dup 0)
5022 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5023 (label_ref (match_dup 2))
5028 [(parallel [(set (cc0)
5029 (compare (zero_extract:SI (match_operand:QI 0 "register_operand" "")
5033 (clobber (scratch:QI))])
5035 (if_then_else (match_operator 1 "eqne_operator"
5036 [(cc0) (const_int 0)])
5037 (label_ref (match_operand 2 "" ""))
5039 "TARGET_H8300H || TARGET_H8300S"
5040 [(set (cc0) (compare (match_dup 0)
5043 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5044 (label_ref (match_dup 2))
5047 operands[3] = ((GET_CODE (operands[1]) == EQ)
5048 ? gen_rtx_GE (VOIDmode, cc0_rtx, const0_rtx)
5049 : gen_rtx_LT (VOIDmode, cc0_rtx, const0_rtx));
5052 ;; The next three peephole2's will try to transform
5054 ;; mov.b A,r0l (or mov.l A,er0)
5061 ;; and.b #CST,r0l (if CST is not 255)
5064 [(set (match_operand:QI 0 "register_operand" "")
5065 (match_operand:QI 1 "general_operand" ""))
5066 (set (match_operand:SI 2 "register_operand" "")
5067 (and:SI (match_dup 2)
5069 "(TARGET_H8300H || TARGET_H8300S)
5070 && !reg_overlap_mentioned_p (operands[2], operands[1])
5071 && REGNO (operands[0]) == REGNO (operands[2])"
5074 (set (strict_low_part (match_dup 0))
5079 [(set (match_operand:SI 0 "register_operand" "")
5080 (match_operand:SI 1 "general_operand" ""))
5082 (and:SI (match_dup 0)
5084 "(TARGET_H8300H || TARGET_H8300S)
5085 && !reg_overlap_mentioned_p (operands[0], operands[1])
5086 && !(GET_CODE (operands[1]) == MEM && !offsettable_memref_p (operands[1]))
5087 && !(GET_CODE (operands[1]) == MEM && MEM_VOLATILE_P (operands[1]))"
5090 (set (strict_low_part (match_dup 2))
5093 operands[2] = gen_lowpart (QImode, operands[0]);
5094 operands[3] = gen_lowpart (QImode, operands[1]);
5098 [(set (match_operand 0 "register_operand" "")
5099 (match_operand 1 "general_operand" ""))
5100 (set (match_operand:SI 2 "register_operand" "")
5101 (and:SI (match_dup 2)
5102 (match_operand:SI 3 "const_int_qi_operand" "")))]
5103 "(TARGET_H8300H || TARGET_H8300S)
5104 && (GET_MODE (operands[0]) == QImode
5105 || GET_MODE (operands[0]) == HImode
5106 || GET_MODE (operands[0]) == SImode)
5107 && GET_MODE (operands[0]) == GET_MODE (operands[1])
5108 && REGNO (operands[0]) == REGNO (operands[2])
5109 && !reg_overlap_mentioned_p (operands[2], operands[1])
5110 && !(GET_MODE (operands[1]) != QImode
5111 && GET_CODE (operands[1]) == MEM
5112 && !offsettable_memref_p (operands[1]))
5113 && !(GET_MODE (operands[1]) != QImode
5114 && GET_CODE (operands[1]) == MEM
5115 && MEM_VOLATILE_P (operands[1]))"
5118 (set (strict_low_part (match_dup 4))
5121 (and:SI (match_dup 2)
5124 operands[4] = gen_lowpart (QImode, operands[0]);
5125 operands[5] = gen_lowpart (QImode, operands[1]);
5126 operands[6] = GEN_INT (~0xff | INTVAL (operands[3]));
5130 [(set (match_operand:SI 0 "register_operand" "")
5131 (match_operand:SI 1 "register_operand" ""))
5133 (and:SI (match_dup 0)
5134 (const_int 65280)))]
5135 "(TARGET_H8300H || TARGET_H8300S)
5136 && !reg_overlap_mentioned_p (operands[0], operands[1])"
5139 (set (zero_extract:SI (match_dup 0)
5142 (lshiftrt:SI (match_dup 1)
5146 ;; If a load of mem:SI is followed by an AND that turns off the upper
5147 ;; half, then we can load mem:HI instead.
5150 [(set (match_operand:SI 0 "register_operand" "")
5151 (match_operand:SI 1 "memory_operand" ""))
5153 (and:SI (match_dup 0)
5154 (match_operand:SI 2 "const_int_operand" "")))]
5155 "(TARGET_H8300H || TARGET_H8300S)
5156 && !MEM_VOLATILE_P (operands[1])
5157 && offsettable_memref_p (operands[1])
5158 && (INTVAL (operands[2]) & ~0xffff) == 0
5159 && INTVAL (operands[2]) != 255"
5163 (and:SI (match_dup 0)
5166 operands[3] = gen_lowpart (HImode, operands[0]);
5167 operands[4] = gen_lowpart (HImode, operands[1]);
5170 ;; Convert a memory comparison to a move if there is a scratch register.
5173 [(match_scratch:QI 1 "r")
5175 (compare (match_operand:QI 0 "memory_operand" "")
5180 (set (cc0) (compare (match_dup 1)
5185 [(match_scratch:HI 1 "r")
5187 (compare (match_operand:HI 0 "memory_operand" "")
5189 "TARGET_H8300H || TARGET_H8300S"
5192 (set (cc0) (compare (match_dup 1)
5197 [(match_scratch:SI 1 "r")
5199 (compare (match_operand:SI 0 "memory_operand" "")
5201 "TARGET_H8300H || TARGET_H8300S"
5204 (set (cc0) (compare (match_dup 1)
5209 ;; (compare (reg:HI) (const_int)) takes 4 bytes, so we try to achieve
5210 ;; the equivalent with shorter sequences. Here is the summary. Cases
5211 ;; are grouped for each define_peephole2.
5213 ;; reg const_int use insn
5214 ;; --------------------------------------------------------
5215 ;; dead -2 eq/ne inc.l
5216 ;; dead -1 eq/ne inc.l
5217 ;; dead 1 eq/ne dec.l
5218 ;; dead 2 eq/ne dec.l
5220 ;; dead 1 ge/lt shar.l
5221 ;; dead 3 (H8S) ge/lt shar.l
5223 ;; dead 1 geu/ltu shar.l
5224 ;; dead 3 (H8S) geu/ltu shar.l
5226 ;; ---- 255 ge/lt mov.b
5228 ;; ---- 255 geu/ltu mov.b
5242 (compare (match_operand:HI 0 "register_operand" "")
5243 (match_operand:HI 1 "incdec_operand" "")))
5245 (if_then_else (match_operator 3 "eqne_operator"
5246 [(cc0) (const_int 0)])
5247 (label_ref (match_operand 2 "" ""))
5249 "(TARGET_H8300H || TARGET_H8300S)
5250 && INTVAL (operands[1]) != 0
5251 && peep2_reg_dead_p (1, operands[0])"
5253 (unspec:HI [(match_dup 0)
5256 (set (cc0) (compare (match_dup 0)
5259 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5260 (label_ref (match_dup 2))
5263 operands[4] = GEN_INT (- INTVAL (operands[1]));
5278 (compare (match_operand:HI 0 "register_operand" "")
5279 (match_operand:HI 1 "const_int_operand" "")))
5281 (if_then_else (match_operator 2 "gtle_operator"
5282 [(cc0) (const_int 0)])
5283 (label_ref (match_operand 3 "" ""))
5285 "(TARGET_H8300H || TARGET_H8300S)
5286 && peep2_reg_dead_p (1, operands[0])
5287 && (INTVAL (operands[1]) == 1
5288 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5289 [(parallel [(set (match_dup 0)
5290 (ashiftrt:HI (match_dup 0)
5292 (clobber (scratch:QI))])
5293 (set (cc0) (compare (match_dup 0)
5296 (if_then_else (match_dup 2)
5297 (label_ref (match_dup 3))
5300 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5315 (compare (match_operand:HI 0 "register_operand" "")
5316 (match_operand:HI 1 "const_int_operand" "")))
5318 (if_then_else (match_operator 2 "gtuleu_operator"
5319 [(cc0) (const_int 0)])
5320 (label_ref (match_operand 3 "" ""))
5322 "(TARGET_H8300H || TARGET_H8300S)
5323 && peep2_reg_dead_p (1, operands[0])
5324 && (INTVAL (operands[1]) == 1
5325 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5326 [(parallel [(set (match_dup 0)
5327 (ashiftrt:HI (match_dup 0)
5329 (clobber (scratch:QI))])
5330 (set (cc0) (compare (match_dup 0)
5333 (if_then_else (match_dup 5)
5334 (label_ref (match_dup 3))
5337 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5338 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5339 VOIDmode, cc0_rtx, const0_rtx);
5354 (compare (match_operand:HI 0 "register_operand" "")
5357 (if_then_else (match_operator 1 "gtle_operator"
5358 [(cc0) (const_int 0)])
5359 (label_ref (match_operand 2 "" ""))
5361 "TARGET_H8300H || TARGET_H8300S"
5362 [(set (cc0) (compare (and:HI (match_dup 0)
5366 (if_then_else (match_dup 1)
5367 (label_ref (match_dup 2))
5383 (compare (match_operand:HI 0 "register_operand" "")
5386 (if_then_else (match_operator 1 "gtuleu_operator"
5387 [(cc0) (const_int 0)])
5388 (label_ref (match_operand 2 "" ""))
5390 "TARGET_H8300H || TARGET_H8300S"
5391 [(set (cc0) (compare (and:HI (match_dup 0)
5395 (if_then_else (match_dup 3)
5396 (label_ref (match_dup 2))
5399 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
5400 VOIDmode, cc0_rtx, const0_rtx);
5403 ;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
5404 ;; the equivalent with shorter sequences. Here is the summary. Cases
5405 ;; are grouped for each define_peephole2.
5407 ;; reg const_int use insn
5408 ;; --------------------------------------------------------
5409 ;; live -2 eq/ne copy and inc.l
5410 ;; live -1 eq/ne copy and inc.l
5411 ;; live 1 eq/ne copy and dec.l
5412 ;; live 2 eq/ne copy and dec.l
5414 ;; dead -2 eq/ne inc.l
5415 ;; dead -1 eq/ne inc.l
5416 ;; dead 1 eq/ne dec.l
5417 ;; dead 2 eq/ne dec.l
5419 ;; dead -131072 eq/ne inc.w and test
5420 ;; dead -65536 eq/ne inc.w and test
5421 ;; dead 65536 eq/ne dec.w and test
5422 ;; dead 131072 eq/ne dec.w and test
5424 ;; dead 0x000000?? except 1 and 2 eq/ne xor.b and test
5425 ;; dead 0x0000??00 eq/ne xor.b and test
5426 ;; dead 0x0000ffff eq/ne not.w and test
5428 ;; dead 0xffffff?? except -1 and -2 eq/ne xor.b and not.l
5429 ;; dead 0xffff??ff eq/ne xor.b and not.l
5430 ;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l
5431 ;; dead 0x80000000 eq/ne rotl.l and dec.l
5433 ;; live 1 ge/lt copy and shar.l
5434 ;; live 3 (H8S) ge/lt copy and shar.l
5436 ;; live 1 geu/ltu copy and shar.l
5437 ;; live 3 (H8S) geu/ltu copy and shar.l
5439 ;; dead 1 ge/lt shar.l
5440 ;; dead 3 (H8S) ge/lt shar.l
5442 ;; dead 1 geu/ltu shar.l
5443 ;; dead 3 (H8S) geu/ltu shar.l
5445 ;; dead 3 (H8/300H) ge/lt and.b and test
5446 ;; dead 7 ge/lt and.b and test
5447 ;; dead 15 ge/lt and.b and test
5448 ;; dead 31 ge/lt and.b and test
5449 ;; dead 63 ge/lt and.b and test
5450 ;; dead 127 ge/lt and.b and test
5451 ;; dead 255 ge/lt and.b and test
5453 ;; dead 3 (H8/300H) geu/ltu and.b and test
5454 ;; dead 7 geu/ltu and.b and test
5455 ;; dead 15 geu/ltu and.b and test
5456 ;; dead 31 geu/ltu and.b and test
5457 ;; dead 63 geu/ltu and.b and test
5458 ;; dead 127 geu/ltu and.b and test
5459 ;; dead 255 geu/ltu and.b and test
5461 ;; ---- 65535 ge/lt mov.w
5463 ;; ---- 65535 geu/ltu mov.w
5477 (compare (match_operand:SI 0 "register_operand" "")
5478 (match_operand:SI 1 "incdec_operand" "")))
5480 (if_then_else (match_operator 3 "eqne_operator"
5481 [(cc0) (const_int 0)])
5482 (label_ref (match_operand 2 "" ""))
5484 "(TARGET_H8300H || TARGET_H8300S)
5485 && INTVAL (operands[1]) != 0
5486 && peep2_reg_dead_p (1, operands[0])"
5488 (unspec:SI [(match_dup 0)
5491 (set (cc0) (compare (match_dup 0)
5494 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5495 (label_ref (match_dup 2))
5498 operands[4] = GEN_INT (- INTVAL (operands[1]));
5513 (compare (match_operand:SI 0 "register_operand" "")
5514 (match_operand:SI 1 "const_int_operand" "")))
5516 (if_then_else (match_operator 3 "eqne_operator"
5517 [(cc0) (const_int 0)])
5518 (label_ref (match_operand 2 "" ""))
5520 "(TARGET_H8300H || TARGET_H8300S)
5521 && peep2_reg_dead_p (1, operands[0])
5522 && (INTVAL (operands[1]) == -131072
5523 || INTVAL (operands[1]) == -65536
5524 || INTVAL (operands[1]) == 65536
5525 || INTVAL (operands[1]) == 131072)"
5527 (plus:SI (match_dup 0)
5529 (set (cc0) (compare (match_dup 0)
5532 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5533 (label_ref (match_dup 2))
5536 operands[4] = GEN_INT (- INTVAL (operands[1]));
5552 (compare (match_operand:SI 0 "register_operand" "")
5553 (match_operand:SI 1 "const_int_operand" "")))
5555 (if_then_else (match_operator 3 "eqne_operator"
5556 [(cc0) (const_int 0)])
5557 (label_ref (match_operand 2 "" ""))
5559 "(TARGET_H8300H || TARGET_H8300S)
5560 && peep2_reg_dead_p (1, operands[0])
5561 && ((INTVAL (operands[1]) & 0x00ff) == INTVAL (operands[1])
5562 || (INTVAL (operands[1]) & 0xff00) == INTVAL (operands[1])
5563 || INTVAL (operands[1]) == 0x0000ffff)
5564 && INTVAL (operands[1]) != 0
5565 && INTVAL (operands[1]) != 1
5566 && INTVAL (operands[1]) != 2"
5568 (xor:SI (match_dup 0)
5570 (set (cc0) (compare (match_dup 0)
5573 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5574 (label_ref (match_dup 2))
5591 (compare (match_operand:SI 0 "register_operand" "")
5592 (match_operand:SI 1 "const_int_operand" "")))
5594 (if_then_else (match_operator 3 "eqne_operator"
5595 [(cc0) (const_int 0)])
5596 (label_ref (match_operand 2 "" ""))
5598 "(TARGET_H8300H || TARGET_H8300S)
5599 && peep2_reg_dead_p (1, operands[0])
5600 && ((INTVAL (operands[1]) | 0x00ff) == -1
5601 || (INTVAL (operands[1]) | 0xff00) == -1)
5602 && INTVAL (operands[1]) != -1
5603 && INTVAL (operands[1]) != -2"
5605 (xor:SI (match_dup 0)
5608 (not:SI (match_dup 0)))
5609 (set (cc0) (compare (match_dup 0)
5612 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5613 (label_ref (match_dup 2))
5616 operands[4] = GEN_INT (INTVAL (operands[1]) ^ -1);
5621 ;; cmp.l #-2147483648,er0
5632 (compare (match_operand:SI 0 "register_operand" "")
5633 (match_operand:SI 1 "const_int_operand" "")))
5635 (if_then_else (match_operator 3 "eqne_operator"
5636 [(cc0) (const_int 0)])
5637 (label_ref (match_operand 2 "" ""))
5639 "(TARGET_H8300H || TARGET_H8300S)
5640 && peep2_reg_dead_p (1, operands[0])
5641 && (INTVAL (operands[1]) == -2147483647 - 1
5642 || (TARGET_H8300S && INTVAL (operands[1]) == 1073741824))"
5644 (rotate:SI (match_dup 0)
5647 (unspec:SI [(match_dup 0)
5650 (set (cc0) (compare (match_dup 0)
5653 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
5654 (label_ref (match_dup 2))
5657 operands[4] = GEN_INT (INTVAL (operands[1]) == -2147483647 - 1 ? 1 : 2);
5671 ;; We avoid this transformation if we see more than one copy of the
5672 ;; same compare insn immediately before this one.
5675 [(match_scratch:SI 4 "r")
5677 (compare (match_operand:SI 0 "register_operand" "")
5678 (match_operand:SI 1 "const_int_operand" "")))
5680 (if_then_else (match_operator 2 "gtle_operator"
5681 [(cc0) (const_int 0)])
5682 (label_ref (match_operand 3 "" ""))
5684 "(TARGET_H8300H || TARGET_H8300S)
5685 && !peep2_reg_dead_p (1, operands[0])
5686 && (INTVAL (operands[1]) == 1
5687 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
5688 && !same_cmp_preceding_p (insn)"
5691 (parallel [(set (match_dup 4)
5692 (ashiftrt:SI (match_dup 4)
5694 (clobber (scratch:QI))])
5695 (set (cc0) (compare (match_dup 4)
5698 (if_then_else (match_dup 2)
5699 (label_ref (match_dup 3))
5702 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5716 ;; We avoid this transformation if we see more than one copy of the
5717 ;; same compare insn immediately before this one.
5720 [(match_scratch:SI 4 "r")
5722 (compare (match_operand:SI 0 "register_operand" "")
5723 (match_operand:SI 1 "const_int_operand" "")))
5725 (if_then_else (match_operator 2 "gtuleu_operator"
5726 [(cc0) (const_int 0)])
5727 (label_ref (match_operand 3 "" ""))
5729 "(TARGET_H8300H || TARGET_H8300S)
5730 && !peep2_reg_dead_p (1, operands[0])
5731 && (INTVAL (operands[1]) == 1
5732 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
5733 && !same_cmp_preceding_p (insn)"
5736 (parallel [(set (match_dup 4)
5737 (ashiftrt:SI (match_dup 4)
5739 (clobber (scratch:QI))])
5740 (set (cc0) (compare (match_dup 4)
5743 (if_then_else (match_dup 6)
5744 (label_ref (match_dup 3))
5747 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5748 operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5749 VOIDmode, cc0_rtx, const0_rtx);
5764 (compare (match_operand:SI 0 "register_operand" "")
5765 (match_operand:SI 1 "const_int_operand" "")))
5767 (if_then_else (match_operator 2 "gtle_operator"
5768 [(cc0) (const_int 0)])
5769 (label_ref (match_operand 3 "" ""))
5771 "(TARGET_H8300H || TARGET_H8300S)
5772 && peep2_reg_dead_p (1, operands[0])
5773 && (INTVAL (operands[1]) == 1
5774 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5775 [(parallel [(set (match_dup 0)
5776 (ashiftrt:SI (match_dup 0)
5778 (clobber (scratch:QI))])
5779 (set (cc0) (compare (match_dup 0)
5782 (if_then_else (match_dup 2)
5783 (label_ref (match_dup 3))
5786 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5801 (compare (match_operand:SI 0 "register_operand" "")
5802 (match_operand:SI 1 "const_int_operand" "")))
5804 (if_then_else (match_operator 2 "gtuleu_operator"
5805 [(cc0) (const_int 0)])
5806 (label_ref (match_operand 3 "" ""))
5808 "(TARGET_H8300H || TARGET_H8300S)
5809 && peep2_reg_dead_p (1, operands[0])
5810 && (INTVAL (operands[1]) == 1
5811 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
5812 [(parallel [(set (match_dup 0)
5813 (ashiftrt:SI (match_dup 0)
5815 (clobber (scratch:QI))])
5816 (set (cc0) (compare (match_dup 0)
5819 (if_then_else (match_dup 5)
5820 (label_ref (match_dup 3))
5823 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
5824 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5825 VOIDmode, cc0_rtx, const0_rtx);
5841 (compare (match_operand:SI 0 "register_operand" "")
5842 (match_operand:SI 1 "const_int_operand" "")))
5844 (if_then_else (match_operator 2 "gtle_operator"
5845 [(cc0) (const_int 0)])
5846 (label_ref (match_operand 3 "" ""))
5848 "(TARGET_H8300H || TARGET_H8300S)
5849 && peep2_reg_dead_p (1, operands[0])
5850 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
5851 || INTVAL (operands[1]) == 7
5852 || INTVAL (operands[1]) == 15
5853 || INTVAL (operands[1]) == 31
5854 || INTVAL (operands[1]) == 63
5855 || INTVAL (operands[1]) == 127
5856 || INTVAL (operands[1]) == 255)"
5858 (and:SI (match_dup 0)
5860 (set (cc0) (compare (match_dup 0)
5863 (if_then_else (match_dup 2)
5864 (label_ref (match_dup 3))
5867 operands[4] = GEN_INT (~INTVAL (operands[1]));
5883 (compare (match_operand:SI 0 "register_operand" "")
5884 (match_operand:SI 1 "const_int_operand" "")))
5886 (if_then_else (match_operator 2 "gtuleu_operator"
5887 [(cc0) (const_int 0)])
5888 (label_ref (match_operand 3 "" ""))
5890 "(TARGET_H8300H || TARGET_H8300S)
5891 && peep2_reg_dead_p (1, operands[0])
5892 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
5893 || INTVAL (operands[1]) == 7
5894 || INTVAL (operands[1]) == 15
5895 || INTVAL (operands[1]) == 31
5896 || INTVAL (operands[1]) == 63
5897 || INTVAL (operands[1]) == 127
5898 || INTVAL (operands[1]) == 255)"
5900 (and:SI (match_dup 0)
5902 (set (cc0) (compare (match_dup 0)
5905 (if_then_else (match_dup 5)
5906 (label_ref (match_dup 3))
5909 operands[4] = GEN_INT (~INTVAL (operands[1]));
5910 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
5911 VOIDmode, cc0_rtx, const0_rtx);
5926 (compare (match_operand:SI 0 "register_operand" "")
5929 (if_then_else (match_operator 1 "gtle_operator"
5930 [(cc0) (const_int 0)])
5931 (label_ref (match_operand 2 "" ""))
5933 "TARGET_H8300H || TARGET_H8300S"
5934 [(set (cc0) (compare (and:SI (match_dup 0)
5938 (if_then_else (match_dup 1)
5939 (label_ref (match_dup 2))
5955 (compare (match_operand:SI 0 "register_operand" "")
5958 (if_then_else (match_operator 1 "gtuleu_operator"
5959 [(cc0) (const_int 0)])
5960 (label_ref (match_operand 2 "" ""))
5962 "TARGET_H8300H || TARGET_H8300S"
5963 [(set (cc0) (compare (and:SI (match_dup 0)
5967 (if_then_else (match_dup 3)
5968 (label_ref (match_dup 2))
5971 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
5972 VOIDmode, cc0_rtx, const0_rtx);
5986 ;; We avoid this transformation if we see more than one copy of the
5987 ;; same compare insn.
5990 [(match_scratch:SI 4 "r")
5992 (compare (match_operand:SI 0 "register_operand" "")
5993 (match_operand:SI 1 "incdec_operand" "")))
5995 (if_then_else (match_operator 3 "eqne_operator"
5996 [(cc0) (const_int 0)])
5997 (label_ref (match_operand 2 "" ""))
5999 "(TARGET_H8300H || TARGET_H8300S)
6000 && INTVAL (operands[1]) != 0
6001 && !peep2_reg_dead_p (1, operands[0])
6002 && !same_cmp_following_p (insn)"
6006 (unspec:SI [(match_dup 4)
6009 (set (cc0) (compare (match_dup 4)
6012 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
6013 (label_ref (match_dup 2))
6016 operands[5] = GEN_INT (- INTVAL (operands[1]));
6018 ;; Narrow the mode of testing if possible.
6021 [(set (match_operand:HI 0 "register_operand" "")
6022 (and:HI (match_dup 0)
6023 (match_operand:HI 1 "const_int_qi_operand" "")))
6024 (set (cc0) (compare (match_dup 0)
6027 (if_then_else (match_operator 3 "eqne_operator"
6028 [(cc0) (const_int 0)])
6029 (label_ref (match_operand 2 "" ""))
6031 "peep2_reg_dead_p (2, operands[0])"
6033 (and:QI (match_dup 4)
6035 (set (cc0) (compare (match_dup 4)
6038 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
6039 (label_ref (match_dup 2))
6042 operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
6043 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);
6047 [(set (match_operand:SI 0 "register_operand" "")
6048 (and:SI (match_dup 0)
6049 (match_operand:SI 1 "const_int_qi_operand" "")))
6050 (set (cc0) (compare (match_dup 0)
6053 (if_then_else (match_operator 3 "eqne_operator"
6054 [(cc0) (const_int 0)])
6055 (label_ref (match_operand 2 "" ""))
6057 "peep2_reg_dead_p (2, operands[0])"
6059 (and:QI (match_dup 4)
6061 (set (cc0) (compare (match_dup 4)
6064 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
6065 (label_ref (match_dup 2))
6068 operands[4] = gen_rtx_REG (QImode, REGNO (operands[0]));
6069 operands[5] = gen_int_mode (INTVAL (operands[1]), QImode);
6073 [(set (match_operand:SI 0 "register_operand" "")
6074 (and:SI (match_dup 0)
6075 (match_operand:SI 1 "const_int_hi_operand" "")))
6076 (set (cc0) (compare (match_dup 0)
6079 (if_then_else (match_operator 3 "eqne_operator"
6080 [(cc0) (const_int 0)])
6081 (label_ref (match_operand 2 "" ""))
6083 "peep2_reg_dead_p (2, operands[0])"
6085 (and:HI (match_dup 4)
6087 (set (cc0) (compare (match_dup 4)
6090 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
6091 (label_ref (match_dup 2))
6094 operands[4] = gen_rtx_REG (HImode, REGNO (operands[0]));
6095 operands[5] = gen_int_mode (INTVAL (operands[1]), HImode);
6099 [(set (match_operand:SI 0 "register_operand" "")
6100 (and:SI (match_dup 0)
6101 (match_operand:SI 1 "const_int_qi_operand" "")))
6103 (xor:SI (match_dup 0)
6104 (match_operand:SI 2 "const_int_qi_operand" "")))
6105 (set (cc0) (compare (match_dup 0)
6108 (if_then_else (match_operator 4 "eqne_operator"
6109 [(cc0) (const_int 0)])
6110 (label_ref (match_operand 3 "" ""))
6112 "peep2_reg_dead_p (3, operands[0])
6113 && (~INTVAL (operands[1]) & INTVAL (operands[2])) == 0"
6115 (and:QI (match_dup 5)
6118 (xor:QI (match_dup 5)
6120 (set (cc0) (compare (match_dup 5)
6123 (if_then_else (match_op_dup 4 [(cc0) (const_int 0)])
6124 (label_ref (match_dup 3))
6127 operands[5] = gen_rtx_REG (QImode, REGNO (operands[0]));
6128 operands[6] = gen_int_mode (INTVAL (operands[1]), QImode);
6129 operands[7] = gen_int_mode (INTVAL (operands[2]), QImode);
6132 ;; These triggers right at the end of allocation of locals in the
6133 ;; prologue (and possibly at other places).
6135 ;; stack adjustment of -4, generate one push
6137 ;; before : 6 bytes, 10 clocks
6138 ;; after : 4 bytes, 10 clocks
6141 [(set (reg:SI SP_REG)
6142 (plus:SI (reg:SI SP_REG)
6144 (set (mem:SI (reg:SI SP_REG))
6145 (match_operand:SI 0 "register_operand" ""))]
6146 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
6147 && REGNO (operands[0]) != SP_REG"
6148 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
6152 ;; stack adjustment of -12, generate one push
6154 ;; before : 10 bytes, 14 clocks
6155 ;; after : 8 bytes, 14 clocks
6158 [(set (reg:SI SP_REG)
6159 (plus:SI (reg:SI SP_REG)
6161 (set (mem:SI (reg:SI SP_REG))
6162 (match_operand:SI 0 "register_operand" ""))]
6163 "(TARGET_H8300H || TARGET_H8300S) && !TARGET_NORMAL_MODE
6164 && REGNO (operands[0]) != SP_REG"
6165 [(set (reg:SI SP_REG)
6166 (plus:SI (reg:SI SP_REG)
6168 (set (reg:SI SP_REG)
6169 (plus:SI (reg:SI SP_REG)
6171 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
6185 ;; if "reg" dies at the end of the sequence.
6188 [(set (match_operand 0 "register_operand" "")
6189 (match_operand 1 "memory_operand" ""))
6191 (match_operator 2 "h8sx_binary_memory_operator"
6193 (match_operand 3 "h8300_src_operand" "")]))
6194 (set (match_operand 4 "memory_operand" "")
6196 "0 /* Disable because it breaks compiling fp-bit.c. */
6198 && peep2_reg_dead_p (3, operands[0])
6199 && !reg_overlap_mentioned_p (operands[0], operands[3])
6200 && !reg_overlap_mentioned_p (operands[0], operands[4])
6201 && h8sx_mergeable_memrefs_p (operands[4], operands[1])"
6205 operands[5] = shallow_copy_rtx (operands[2]);
6206 XEXP (operands[5], 0) = operands[1];
6218 ;; if "reg" dies in the second insn.
6221 [(set (match_operand 0 "register_operand" "")
6222 (match_operand 1 "h8300_src_operand" ""))
6223 (set (match_operand 2 "h8300_dst_operand" "")
6224 (match_operator 3 "h8sx_binary_memory_operator"
6225 [(match_operand 4 "h8300_dst_operand" "")
6227 "0 /* Disable because it breaks compiling fp-bit.c. */
6229 && peep2_reg_dead_p (2, operands[0])
6230 && !reg_overlap_mentioned_p (operands[0], operands[4])"
6234 operands[5] = shallow_copy_rtx (operands[3]);
6235 XEXP (operands[5], 1) = operands[1];
6248 ;; if "reg" dies at the end of the sequence.
6251 [(set (match_operand 0 "register_operand" "")
6252 (match_operand 1 "memory_operand" ""))
6254 (match_operator 2 "h8sx_unary_memory_operator"
6256 (set (match_operand 3 "memory_operand" "")
6259 && peep2_reg_dead_p (3, operands[0])
6260 && !reg_overlap_mentioned_p (operands[0], operands[3])
6261 && h8sx_mergeable_memrefs_p (operands[3], operands[1])"
6265 operands[4] = shallow_copy_rtx (operands[2]);
6266 XEXP (operands[4], 0) = operands[1];
6278 ;; if "reg" dies in the comparison.
6281 [(set (match_operand 0 "register_operand" "")
6282 (match_operand 1 "h8300_dst_operand" ""))
6284 (compare (match_dup 0)
6285 (match_operand 2 "h8300_src_operand" "")))]
6287 && peep2_reg_dead_p (2, operands[0])
6288 && !reg_overlap_mentioned_p (operands[0], operands[2])
6289 && operands[2] != const0_rtx"
6291 (compare (match_dup 1)
6294 ;; Likewise for the second operand.
6297 [(set (match_operand 0 "register_operand" "")
6298 (match_operand 1 "h8300_src_operand" ""))
6300 (compare (match_operand 2 "h8300_dst_operand" "")
6303 && peep2_reg_dead_p (2, operands[0])
6304 && !reg_overlap_mentioned_p (operands[0], operands[2])"
6306 (compare (match_dup 2)
6309 ;; Combine two moves.
6312 [(set (match_operand 0 "register_operand" "")
6313 (match_operand 1 "h8300_src_operand" ""))
6314 (set (match_operand 2 "h8300_dst_operand" "")
6317 && peep2_reg_dead_p (2, operands[0])
6318 && !reg_overlap_mentioned_p (operands[0], operands[2])"